From 4500ca8e221e72cc38e7c239b9b1a041031ee450 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Mon, 3 Sep 2007 16:29:58 +0400 Subject: ACPI: video: Don't call absent methods Signed-off-by: Ryan May Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/video.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 3c9bb85a6a9..83aa41c5c59 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -409,14 +409,16 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device, static int acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) { - int status; + int status = AE_OK; union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 }; arg0.integer.value = level; - status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL); - + if (device->cap._BCM) + status = acpi_evaluate_object(device->dev->handle, "_BCM", + &args, NULL); + device->brightness->curr = level; printk(KERN_DEBUG "set_level status: %x\n", status); return status; } @@ -425,11 +427,11 @@ static int acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, unsigned long *level) { - int status; - - status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level); - - return status; + if (device->cap._BQC) + return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, + level); + *level = device->brightness->curr; + return AE_OK; } static int -- cgit v1.2.3 From 63f0edfc0b7f8058f9d3f9b572615ec97ae011ba Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Mon, 3 Sep 2007 16:30:08 +0400 Subject: ACPI: VIDEO: Adjust current level to closest available one. Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/video.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 83aa41c5c59..8a60a3d7001 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1636,9 +1636,20 @@ static int acpi_video_get_next_level(struct acpi_video_device *device, u32 level_current, u32 event) { - int min, max, min_above, max_below, i, l; + int min, max, min_above, max_below, i, l, delta = 255; max = max_below = 0; min = min_above = 255; + /* Find closest level to level_current */ + for (i = 0; i < device->brightness->count; i++) { + l = device->brightness->levels[i]; + if (abs(l - level_current) < abs(delta)) { + delta = l - level_current; + if (!delta) + break; + } + } + /* Ajust level_current to closest available level */ + level_current += delta; for (i = 0; i < device->brightness->count; i++) { l = device->brightness->levels[i]; if (l < min) -- cgit v1.2.3