aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2009-04-09 02:24:35 -0400
committerLen Brown <len.brown@intel.com>2009-04-11 01:05:58 -0400
commite047cca66c6bb0b1c346e91305011aab79dfc4b0 (patch)
treec656787366e002db0ce091a1629f19d0566f94fa /drivers/acpi
parentd848223808c5d21e1b3cea090047e34722c6254b (diff)
ACPI video: handle indexed _BQC correctly
In the current code, for a box with an indexed _BQC method, we 1. get the current brightness level by evaluating _BQC 2. set the value gotten in step 1 to _BCM 3. get the current brightness level again 4. set the _BQC_use_index flag if the results gotten in step 1 and in step 3 don't equal. But this logic doesn't work actually, because the _BQC_use_index is not set when acpi_video_device_lcd_set_level is invoked. This results in a failure in step 2. http://bugzilla.kernel.org/show_bug.cgi?id=12249#c83 Now, we set the _BQC_use_index flag after invoking _BQC for the first time. And reevaluate the _BQC to get the correct brightness level. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/video.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index cd4fb7543a90..346277f93cda 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -807,12 +807,19 @@ acpi_video_init_brightness(struct acpi_video_device *device)
807 br->flags._BCM_use_index = br->flags._BCL_use_index; 807 br->flags._BCM_use_index = br->flags._BCL_use_index;
808 808
809 /* _BQC uses INDEX while _BCL uses VALUE in some laptops */ 809 /* _BQC uses INDEX while _BCL uses VALUE in some laptops */
810 br->curr = max_level; 810 br->curr = level_old = max_level;
811
812 if (!device->cap._BQC)
813 goto set_level;
814
811 result = acpi_video_device_lcd_get_level_current(device, &level_old); 815 result = acpi_video_device_lcd_get_level_current(device, &level_old);
812 if (result) 816 if (result)
813 goto out_free_levels; 817 goto out_free_levels;
814 818
815 result = acpi_video_device_lcd_set_level(device, br->curr); 819 /*
820 * Set the level to maximum and check if _BQC uses indexed value
821 */
822 result = acpi_video_device_lcd_set_level(device, max_level);
816 if (result) 823 if (result)
817 goto out_free_levels; 824 goto out_free_levels;
818 825
@@ -820,25 +827,19 @@ acpi_video_init_brightness(struct acpi_video_device *device)
820 if (result) 827 if (result)
821 goto out_free_levels; 828 goto out_free_levels;
822 829
823 if ((level != level_old) && !br->flags._BCM_use_index) { 830 br->flags._BQC_use_index = (level == max_level ? 0 : 1);
824 /* Note: 831
825 * This piece of code does not work correctly if the current 832 if (!br->flags._BQC_use_index)
826 * brightness levels is 0. 833 goto set_level;
827 * But I guess boxes that boot with such a dark screen are rare 834
828 * and no more code is needed to cover this specifial case. 835 if (br->flags._BCL_reversed)
829 */ 836 level_old = (br->count - 1) - level_old;
830 837 level_old = br->levels[level_old];
831 if (level_ac_battery != 2) { 838
832 /* 839set_level:
833 * For now, we don't support the _BCL like this: 840 result = acpi_video_device_lcd_set_level(device, level_old);
834 * 16, 15, 0, 1, 2, 3, ..., 14, 15, 16 841 if (result)
835 * because we may mess up the index returned by _BQC. 842 goto out_free_levels;
836 * Plus: we have not got a box like this.
837 */
838 ACPI_ERROR((AE_INFO, "_BCL not supported\n"));
839 }
840 br->flags._BQC_use_index = 1;
841 }
842 843
843 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 844 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
844 "found %d brightness levels\n", count - 2)); 845 "found %d brightness levels\n", count - 2));