Skip to content

Commit 5ad2616

Browse files
committed
ACPI: video: Fix acpi_video_handles_brightness_key_presses()
Commit 3a0cf7a ("ACPI: video: Change how we determine if brightness key-presses are handled") made acpi_video_handles_brightness_key_presses() report false when none of the ACPI Video Devices support backlight control. But it turns out that at least on a Dell Inspiron N4010 there is no ACPI backlight control, yet brightness hotkeys are still reported through the ACPI Video Bus; and since acpi_video_handles_brightness_key_presses() now returns false, brightness keypresses are now reported twice. To fix this rename the has_backlight flag to may_report_brightness_keys and also set it the first time a brightness key press event is received. Depending on the delivery of the other ACPI (WMI) event vs the ACPI Video Bus event this means that the first brightness key press might still get reported twice, but all further keypresses will be filtered as before. Note that this relies on other drivers reporting brightness key events calling acpi_video_handles_brightness_key_presses() when delivering the events (rather then once during driver probe). This is already required and documented in include/acpi/video.h: /* * Note: The value returned by acpi_video_handles_brightness_key_presses() * may change over time and should not be cached. */ Fixes: 3a0cf7a ("ACPI: video: Change how we determine if brightness key-presses are handled") Link: https://lore.kernel.org/regressions/CALF=6jEe5G8+r1Wo0vvz4GjNQQhdkLT5p8uCHn6ZXhg4nsOWow@mail.gmail.com/ Reported-and-tested-by: Ben Greening <bgreening@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://lore.kernel.org/r/20220713211101.85547-2-hdegoede@redhat.com
1 parent b0d5598 commit 5ad2616

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

drivers/acpi/acpi_video.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ module_param(device_id_scheme, bool, 0444);
7373
static int only_lcd = -1;
7474
module_param(only_lcd, int, 0444);
7575

76-
static bool has_backlight;
76+
static bool may_report_brightness_keys;
7777
static int register_count;
7878
static DEFINE_MUTEX(register_count_mutex);
7979
static DEFINE_MUTEX(video_list_lock);
@@ -1224,7 +1224,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
12241224
acpi_video_device_find_cap(data);
12251225

12261226
if (data->cap._BCM && data->cap._BCL)
1227-
has_backlight = true;
1227+
may_report_brightness_keys = true;
12281228

12291229
mutex_lock(&video->device_list_lock);
12301230
list_add_tail(&data->entry, &video->video_device_list);
@@ -1693,6 +1693,9 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
16931693
break;
16941694
}
16951695

1696+
if (keycode)
1697+
may_report_brightness_keys = true;
1698+
16961699
acpi_notifier_call_chain(device, event, 0);
16971700

16981701
if (keycode && (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS)) {
@@ -2253,7 +2256,7 @@ void acpi_video_unregister(void)
22532256
if (register_count) {
22542257
acpi_bus_unregister_driver(&acpi_video_bus);
22552258
register_count = 0;
2256-
has_backlight = false;
2259+
may_report_brightness_keys = false;
22572260
}
22582261
mutex_unlock(&register_count_mutex);
22592262
}
@@ -2275,7 +2278,7 @@ void acpi_video_unregister_backlight(void)
22752278

22762279
bool acpi_video_handles_brightness_key_presses(void)
22772280
{
2278-
return has_backlight &&
2281+
return may_report_brightness_keys &&
22792282
(report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS);
22802283
}
22812284
EXPORT_SYMBOL(acpi_video_handles_brightness_key_presses);

0 commit comments

Comments
 (0)