Commit 70287db8 authored by Matthew Garrett's avatar Matthew Garrett Committed by Len Brown

ACPI video: Be more liberal in validating _BQC behaviour

Right now, if _BQC returns a value we don't understand we immediately
invalidate it. Change this behaviour so we only invalidate it if it
continues to give an invalid answer after we've already set a brightness.
Signed-off-by: default avatarMatthew Garrett <mjg@redhat.com>
Acked-by: default avatarZhang Rui <rui.zhang@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent f8b55f25
...@@ -327,7 +327,7 @@ static int acpi_video_device_lcd_set_level(struct acpi_video_device *device, ...@@ -327,7 +327,7 @@ static int acpi_video_device_lcd_set_level(struct acpi_video_device *device,
int level); int level);
static int acpi_video_device_lcd_get_level_current( static int acpi_video_device_lcd_get_level_current(
struct acpi_video_device *device, struct acpi_video_device *device,
unsigned long long *level); unsigned long long *level, int init);
static int acpi_video_get_next_level(struct acpi_video_device *device, static int acpi_video_get_next_level(struct acpi_video_device *device,
u32 level_current, u32 event); u32 level_current, u32 event);
static int acpi_video_switch_brightness(struct acpi_video_device *device, static int acpi_video_switch_brightness(struct acpi_video_device *device,
...@@ -345,7 +345,7 @@ static int acpi_video_get_brightness(struct backlight_device *bd) ...@@ -345,7 +345,7 @@ static int acpi_video_get_brightness(struct backlight_device *bd)
struct acpi_video_device *vd = struct acpi_video_device *vd =
(struct acpi_video_device *)bl_get_data(bd); (struct acpi_video_device *)bl_get_data(bd);
if (acpi_video_device_lcd_get_level_current(vd, &cur_level)) if (acpi_video_device_lcd_get_level_current(vd, &cur_level, 0))
return -EINVAL; return -EINVAL;
for (i = 2; i < vd->brightness->count; i++) { for (i = 2; i < vd->brightness->count; i++) {
if (vd->brightness->levels[i] == cur_level) if (vd->brightness->levels[i] == cur_level)
...@@ -414,7 +414,7 @@ static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, unsig ...@@ -414,7 +414,7 @@ static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, unsig
unsigned long long level; unsigned long long level;
int offset; int offset;
if (acpi_video_device_lcd_get_level_current(video, &level)) if (acpi_video_device_lcd_get_level_current(video, &level, 0))
return -EINVAL; return -EINVAL;
for (offset = 2; offset < video->brightness->count; offset++) for (offset = 2; offset < video->brightness->count; offset++)
if (level == video->brightness->levels[offset]) { if (level == video->brightness->levels[offset]) {
...@@ -609,7 +609,7 @@ static struct dmi_system_id video_dmi_table[] __initdata = { ...@@ -609,7 +609,7 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
static int static int
acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
unsigned long long *level) unsigned long long *level, int init)
{ {
acpi_status status = AE_OK; acpi_status status = AE_OK;
int i; int i;
...@@ -633,10 +633,16 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, ...@@ -633,10 +633,16 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
device->brightness->curr = *level; device->brightness->curr = *level;
return 0; return 0;
} }
/* BQC returned an invalid level. Stop using it. */ if (!init) {
ACPI_WARNING((AE_INFO, "%s returned an invalid level", /*
buf)); * BQC returned an invalid level.
device->cap._BQC = device->cap._BCQ = 0; * Stop using it.
*/
ACPI_WARNING((AE_INFO,
"%s returned an invalid level",
buf));
device->cap._BQC = device->cap._BCQ = 0;
}
} else { } else {
/* Fixme: /* Fixme:
* should we return an error or ignore this failure? * should we return an error or ignore this failure?
...@@ -892,7 +898,7 @@ acpi_video_init_brightness(struct acpi_video_device *device) ...@@ -892,7 +898,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
if (!device->cap._BQC) if (!device->cap._BQC)
goto set_level; goto set_level;
result = acpi_video_device_lcd_get_level_current(device, &level_old); result = acpi_video_device_lcd_get_level_current(device, &level_old, 1);
if (result) if (result)
goto out_free_levels; goto out_free_levels;
...@@ -903,7 +909,7 @@ acpi_video_init_brightness(struct acpi_video_device *device) ...@@ -903,7 +909,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
if (result) if (result)
goto out_free_levels; goto out_free_levels;
result = acpi_video_device_lcd_get_level_current(device, &level); result = acpi_video_device_lcd_get_level_current(device, &level, 0);
if (result) if (result)
goto out_free_levels; goto out_free_levels;
...@@ -1996,7 +2002,7 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event) ...@@ -1996,7 +2002,7 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event)
goto out; goto out;
result = acpi_video_device_lcd_get_level_current(device, result = acpi_video_device_lcd_get_level_current(device,
&level_current); &level_current, 0);
if (result) if (result)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment