mirror of
https://github.com/torvalds/linux.git
synced 2024-11-12 23:23:03 +00:00
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>
This commit is contained in:
parent
d848223808
commit
e047cca66c
@ -807,12 +807,19 @@ acpi_video_init_brightness(struct acpi_video_device *device)
|
||||
br->flags._BCM_use_index = br->flags._BCL_use_index;
|
||||
|
||||
/* _BQC uses INDEX while _BCL uses VALUE in some laptops */
|
||||
br->curr = max_level;
|
||||
br->curr = level_old = max_level;
|
||||
|
||||
if (!device->cap._BQC)
|
||||
goto set_level;
|
||||
|
||||
result = acpi_video_device_lcd_get_level_current(device, &level_old);
|
||||
if (result)
|
||||
goto out_free_levels;
|
||||
|
||||
result = acpi_video_device_lcd_set_level(device, br->curr);
|
||||
/*
|
||||
* Set the level to maximum and check if _BQC uses indexed value
|
||||
*/
|
||||
result = acpi_video_device_lcd_set_level(device, max_level);
|
||||
if (result)
|
||||
goto out_free_levels;
|
||||
|
||||
@ -820,25 +827,19 @@ acpi_video_init_brightness(struct acpi_video_device *device)
|
||||
if (result)
|
||||
goto out_free_levels;
|
||||
|
||||
if ((level != level_old) && !br->flags._BCM_use_index) {
|
||||
/* Note:
|
||||
* This piece of code does not work correctly if the current
|
||||
* brightness levels is 0.
|
||||
* But I guess boxes that boot with such a dark screen are rare
|
||||
* and no more code is needed to cover this specifial case.
|
||||
*/
|
||||
br->flags._BQC_use_index = (level == max_level ? 0 : 1);
|
||||
|
||||
if (level_ac_battery != 2) {
|
||||
/*
|
||||
* For now, we don't support the _BCL like this:
|
||||
* 16, 15, 0, 1, 2, 3, ..., 14, 15, 16
|
||||
* because we may mess up the index returned by _BQC.
|
||||
* Plus: we have not got a box like this.
|
||||
*/
|
||||
ACPI_ERROR((AE_INFO, "_BCL not supported\n"));
|
||||
}
|
||||
br->flags._BQC_use_index = 1;
|
||||
}
|
||||
if (!br->flags._BQC_use_index)
|
||||
goto set_level;
|
||||
|
||||
if (br->flags._BCL_reversed)
|
||||
level_old = (br->count - 1) - level_old;
|
||||
level_old = br->levels[level_old];
|
||||
|
||||
set_level:
|
||||
result = acpi_video_device_lcd_set_level(device, level_old);
|
||||
if (result)
|
||||
goto out_free_levels;
|
||||
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
||||
"found %d brightness levels\n", count - 2));
|
||||
|
Loading…
Reference in New Issue
Block a user