]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
f12b32557a37361458881dfc3a74ac56a52a9137
[thirdparty/kernel/stable-queue.git] /
1 From a5b92be2482e5f9ef30be4e4cda12ed484381493 Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Tue, 17 Oct 2023 11:07:24 +0200
4 Subject: platform/x86: asus-wmi: Only map brightness codes when using asus-wmi backlight control
5
6 From: Hans de Goede <hdegoede@redhat.com>
7
8 commit a5b92be2482e5f9ef30be4e4cda12ed484381493 upstream.
9
10 Older Asus laptops change the backlight level themselves and then send
11 WMI events with different codes for different backlight levels.
12
13 The asus-wmi.c code maps the entire range of codes reported on
14 brightness down keypresses to an internal ASUS_WMI_BRN_DOWN code:
15
16 define NOTIFY_BRNUP_MIN 0x11
17 define NOTIFY_BRNUP_MAX 0x1f
18 define NOTIFY_BRNDOWN_MIN 0x20
19 define NOTIFY_BRNDOWN_MAX 0x2e
20
21 if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
22 code = ASUS_WMI_BRN_UP;
23 else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX)
24 code = ASUS_WMI_BRN_DOWN;
25
26 This mapping is causing issues on new laptop models which actually
27 send 0x2b events for printscreen presses and 0x2c events for
28 capslock presses, which get translated into spurious brightness-down
29 presses.
30
31 This mapping is really only necessary when asus-wmi has registered
32 a backlight-device for backlight control. In this case the mapping
33 was used to decide to filter out the keypresss since in this case
34 the firmware has already modified the brightness itself and instead
35 of reporting a keypress asus-wmi will just report the new brightness
36 value to userspace.
37
38 OTOH when the firmware does not adjust the brightness itself then
39 it seems to always report 0x2e for brightness-down presses and
40 0x2f for brightness up presses independent of the actual brightness
41 level. So in this case the mapping of the code is not necessary
42 and this translation actually leads to spurious brightness-down
43 presses being send to userspace when pressing printscreen or capslock.
44
45 Modify asus_wmi_handle_event_code() to only do the mapping
46 when using asus-wmi backlight control to fix the spurious
47 brightness-down presses.
48
49 Reported-by: James John <me@donjajo.com>
50 Closes: https://lore.kernel.org/platform-driver-x86/a2c441fe-457e-44cf-a146-0ecd86b037cf@donjajo.com/
51 Closes: https://bbs.archlinux.org/viewtopic.php?pid=2123716
52 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
53 Link: https://lore.kernel.org/r/20231017090725.38163-3-hdegoede@redhat.com
54 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
55 ---
56 drivers/platform/x86/asus-wmi.c | 15 ++++-----------
57 1 file changed, 4 insertions(+), 11 deletions(-)
58
59 --- a/drivers/platform/x86/asus-wmi.c
60 +++ b/drivers/platform/x86/asus-wmi.c
61 @@ -3268,7 +3268,6 @@ static void asus_wmi_handle_event_code(i
62 {
63 unsigned int key_value = 1;
64 bool autorelease = 1;
65 - int orig_code = code;
66
67 if (asus->driver->key_filter) {
68 asus->driver->key_filter(asus->driver, &code, &key_value,
69 @@ -3277,16 +3276,10 @@ static void asus_wmi_handle_event_code(i
70 return;
71 }
72
73 - if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
74 - code = ASUS_WMI_BRN_UP;
75 - else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX)
76 - code = ASUS_WMI_BRN_DOWN;
77 -
78 - if (code == ASUS_WMI_BRN_DOWN || code == ASUS_WMI_BRN_UP) {
79 - if (acpi_video_get_backlight_type() == acpi_backlight_vendor) {
80 - asus_wmi_backlight_notify(asus, orig_code);
81 - return;
82 - }
83 + if (acpi_video_get_backlight_type() == acpi_backlight_vendor &&
84 + code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNDOWN_MAX) {
85 + asus_wmi_backlight_notify(asus, code);
86 + return;
87 }
88
89 if (code == NOTIFY_KBD_BRTUP) {