Skip to contentSkip to conversation

4e231fa "ACPI video: ignore buggy _BQC" - causes regression for _BQC_use_index workaround?

DISCUSSION Alan Jenkins 1 participant 1 message Sep 14, 2009 ACPI

lore
Share & tools
lore
#0 lore raw

I'm looking at cleaning up the ACPI video driver, and found what looks like a regression in 2.6.31. This is all from code inspection; I don't have the hardware. I think it will not hurt users, but it should still be looked at.

The new "ignore buggy _BQC" workaround appears to override the _BQC_use_index workaround. This means that on some systems the sysfs "actual_brightness" attribute will return a cached value, where previously it would query the hardware for an up-to-date value.

Quoted 5 lines
(quoted diff) +0 -1
@@ -618,8 +619,15 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
 
 			}
 			*level += bqc_offset_aml_bug_workaround;
-			device->brightness->curr = *level;

Review acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, · line 630

Quoted 10 lines
(quoted diff) +9 -1
-			return 0;
+			for (i = 2; i < device->brightness->count; i++)
+				if (device->brightness->levels[i] == *level) {
+					device->brightness->curr = *level;
+					return 0;
+			}
+			/* BQC returned an invalid level. Stop using it.  */
+			ACPI_WARNING((AE_INFO, "%s returned an invalid level",
+						buf));
+			device->cap._BQC = device->cap._BCQ = 0;

I believe this change will break the detection of _BQC_use_index in acpi_video_init_brightness():

    /*
     * 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;

    result = acpi_video_device_lcd_get_level_current(device, &level);
    if (result)
        goto out_free_levels;

    br->flags._BQC_use_index = (level == max_level ? 0 : 1);

If _BQC returns an index, then the value it returns won't be present in
_BCL. The initial call to get_level_current() will consider the _BQC
value invalid and disable _BQC - because we haven't had a chance to set _BQC_use_index yet.

I think the _BQC_use_index detection needs a "raw" version of get_level_current(), which omits the validity check. Would you like a patch?

Regards
Alan