• Hans de Goede's avatar
    platform/x86: asus-wmi: Change ASUS_WMI_BRN_DOWN code from 0x20 to 0x2e · f37cc2fc
    Hans de Goede authored
    Older Asus laptops change the backlight level themselves and then send
    WMI events with different codes for different backlight levels.
    
    The asus-wmi.c code maps the entire range of codes reported on
    brightness down keypresses to an internal ASUS_WMI_BRN_DOWN code:
    
    define NOTIFY_BRNUP_MIN                0x11
    define NOTIFY_BRNUP_MAX                0x1f
    define NOTIFY_BRNDOWN_MIN              0x20
    define NOTIFY_BRNDOWN_MAX              0x2e
    
            if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
                    code = ASUS_WMI_BRN_UP;
            else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX)
                    code = ASUS_WMI_BRN_DOWN;
    
    Before this commit all the NOTIFY_BRNDOWN_MIN - NOTIFY_BRNDOWN_MAX
    aka 0x20 - 0x2e events were mapped to 0x20.
    
    This mapping is causing issues on new laptop models which actually
    send 0x2b events for printscreen presses and 0x2c events for
    capslock presses, which get translated into spurious brightness-down
    presses.
    
    The plan is disable the 0x11-0x2e special mapping on laptops
    where asus-wmi does not register a backlight-device to avoid
    the spurious brightness-down keypresses. New laptops always send
    0x2e for brightness-down presses, change the special internal
    ASUS_WMI_BRN_DOWN value from 0x20 to 0x2e to match this in
    preparation for fixing the spurious brightness-down presses.
    
    This change does not have any functional impact since all
    of 0x20 - 0x2e is mapped to ASUS_WMI_BRN_DOWN first and only
    then checked against the keymap code and the new 0x2e
    value is still in the 0x20 - 0x2e range.
    Reported-by: default avatarJames John <me@donjajo.com>
    Closes: https://lore.kernel.org/platform-driver-x86/a2c441fe-457e-44cf-a146-0ecd86b037cf@donjajo.com/
    Closes: https://bbs.archlinux.org/viewtopic.php?pid=2123716Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20231017090725.38163-2-hdegoede@redhat.com
    f37cc2fc
asus-wmi.h 2.28 KB