aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/acpi/video.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index bb5ed059114a..f0e6eb534161 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -294,7 +294,7 @@ static int acpi_video_device_lcd_get_level_current(
294 unsigned long long *level); 294 unsigned long long *level);
295static int acpi_video_get_next_level(struct acpi_video_device *device, 295static int acpi_video_get_next_level(struct acpi_video_device *device,
296 u32 level_current, u32 event); 296 u32 level_current, u32 event);
297static void acpi_video_switch_brightness(struct acpi_video_device *device, 297static int acpi_video_switch_brightness(struct acpi_video_device *device,
298 int event); 298 int event);
299static int acpi_video_device_get_state(struct acpi_video_device *device, 299static int acpi_video_device_get_state(struct acpi_video_device *device,
300 unsigned long long *state); 300 unsigned long long *state);
@@ -308,7 +308,9 @@ static int acpi_video_get_brightness(struct backlight_device *bd)
308 int i; 308 int i;
309 struct acpi_video_device *vd = 309 struct acpi_video_device *vd =
310 (struct acpi_video_device *)bl_get_data(bd); 310 (struct acpi_video_device *)bl_get_data(bd);
311 acpi_video_device_lcd_get_level_current(vd, &cur_level); 311
312 if (acpi_video_device_lcd_get_level_current(vd, &cur_level))
313 return -EINVAL;
312 for (i = 2; i < vd->brightness->count; i++) { 314 for (i = 2; i < vd->brightness->count; i++) {
313 if (vd->brightness->levels[i] == cur_level) 315 if (vd->brightness->levels[i] == cur_level)
314 /* The first two entries are special - see page 575 316 /* The first two entries are special - see page 575
@@ -373,7 +375,8 @@ static int video_get_cur_state(struct thermal_cooling_device *cdev, char *buf)
373 unsigned long long level; 375 unsigned long long level;
374 int state; 376 int state;
375 377
376 acpi_video_device_lcd_get_level_current(video, &level); 378 if (acpi_video_device_lcd_get_level_current(video, &level))
379 return -EINVAL;
377 for (state = 2; state < video->brightness->count; state++) 380 for (state = 2; state < video->brightness->count; state++)
378 if (level == video->brightness->levels[state]) 381 if (level == video->brightness->levels[state])
379 return sprintf(buf, "%d\n", 382 return sprintf(buf, "%d\n",
@@ -502,11 +505,29 @@ static int
502acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, 505acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
503 unsigned long long *level) 506 unsigned long long *level)
504{ 507{
505 if (device->cap._BQC) 508 acpi_status status = AE_OK;
506 return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, 509
507 level); 510 if (device->cap._BQC) {
511 status = acpi_evaluate_integer(device->dev->handle, "_BQC",
512 NULL, level);
513 if (ACPI_SUCCESS(status)) {
514 device->brightness->curr = *level;
515 return 0;
516 } else {
517 /* Fixme:
518 * should we return an error or ignore this failure?
519 * dev->brightness->curr is a cached value which stores
520 * the correct current backlight level in most cases.
521 * ACPI video backlight still works w/ buggy _BQC.
522 * http://bugzilla.kernel.org/show_bug.cgi?id=12233
523 */
524 ACPI_WARNING((AE_INFO, "Evaluating _BQC failed"));
525 device->cap._BQC = 0;
526 }
527 }
528
508 *level = device->brightness->curr; 529 *level = device->brightness->curr;
509 return AE_OK; 530 return 0;
510} 531}
511 532
512static int 533static int
@@ -1749,15 +1770,29 @@ acpi_video_get_next_level(struct acpi_video_device *device,
1749 } 1770 }
1750} 1771}
1751 1772
1752static void 1773static int
1753acpi_video_switch_brightness(struct acpi_video_device *device, int event) 1774acpi_video_switch_brightness(struct acpi_video_device *device, int event)
1754{ 1775{
1755 unsigned long long level_current, level_next; 1776 unsigned long long level_current, level_next;
1777 int result = -EINVAL;
1778
1756 if (!device->brightness) 1779 if (!device->brightness)
1757 return; 1780 goto out;
1758 acpi_video_device_lcd_get_level_current(device, &level_current); 1781
1782 result = acpi_video_device_lcd_get_level_current(device,
1783 &level_current);
1784 if (result)
1785 goto out;
1786
1759 level_next = acpi_video_get_next_level(device, level_current, event); 1787 level_next = acpi_video_get_next_level(device, level_current, event);
1788
1760 acpi_video_device_lcd_set_level(device, level_next); 1789 acpi_video_device_lcd_set_level(device, level_next);
1790
1791out:
1792 if (result)
1793 printk(KERN_ERR PREFIX "Failed to switch the brightness\n");
1794
1795 return result;
1761} 1796}
1762 1797
1763static int 1798static int