aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/video.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/video.c')
-rw-r--r--drivers/acpi/video.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index d05891f16282..f31e3c8749e0 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -409,14 +409,17 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
409static int 409static int
410acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) 410acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
411{ 411{
412 int status; 412 int status = AE_OK;
413 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 413 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
414 struct acpi_object_list args = { 1, &arg0 }; 414 struct acpi_object_list args = { 1, &arg0 };
415 415
416 416
417 arg0.integer.value = level; 417 arg0.integer.value = level;
418 status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
419 418
419 if (device->cap._BCM)
420 status = acpi_evaluate_object(device->dev->handle, "_BCM",
421 &args, NULL);
422 device->brightness->curr = level;
420 return status; 423 return status;
421} 424}
422 425
@@ -424,11 +427,11 @@ static int
424acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, 427acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
425 unsigned long *level) 428 unsigned long *level)
426{ 429{
427 int status; 430 if (device->cap._BQC)
428 431 return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL,
429 status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level); 432 level);
430 433 *level = device->brightness->curr;
431 return status; 434 return AE_OK;
432} 435}
433 436
434static int 437static int
@@ -1633,9 +1636,20 @@ static int
1633acpi_video_get_next_level(struct acpi_video_device *device, 1636acpi_video_get_next_level(struct acpi_video_device *device,
1634 u32 level_current, u32 event) 1637 u32 level_current, u32 event)
1635{ 1638{
1636 int min, max, min_above, max_below, i, l; 1639 int min, max, min_above, max_below, i, l, delta = 255;
1637 max = max_below = 0; 1640 max = max_below = 0;
1638 min = min_above = 255; 1641 min = min_above = 255;
1642 /* Find closest level to level_current */
1643 for (i = 0; i < device->brightness->count; i++) {
1644 l = device->brightness->levels[i];
1645 if (abs(l - level_current) < abs(delta)) {
1646 delta = l - level_current;
1647 if (!delta)
1648 break;
1649 }
1650 }
1651 /* Ajust level_current to closest available level */
1652 level_current += delta;
1639 for (i = 0; i < device->brightness->count; i++) { 1653 for (i = 0; i < device->brightness->count; i++) {
1640 l = device->brightness->levels[i]; 1654 l = device->brightness->levels[i];
1641 if (l < min) 1655 if (l < min)