platform/x86: asus-wmi: Add keyboard backlight toggle support
PATCH 1/1 platform/x86: asus-wmi: Add keyboard backlight toggle support
Some Asus laptops like UX550GE has hotkey (Fn+F7) for keyboard backlight toggle. In this UX550GE, the hotkey incremet the level of brightness for each keypress from 1 to 3, and then switch it off when the brightness has been the max. This commit interprets the code 0xc7 generated from hotkey to KEY_KBDILLUMUP to increment the brightness, then pass KEY_KBDILLUMTOGGLE to user space after the brightness max been reached for switching the led off.
https://phabricator.endlessm.com/T21390
--- drivers/platform/x86/asus-nb-wmi.c | 1 + drivers/platform/x86/asus-wmi.c | 8 ++++++++ 2 files changed, 9 insertions(+)
drivers/platform/x86/asus-nb-wmi.c +1 -0
@@ -496,6 +496,7 @@ static const struct key_entry asus_nb_wmi_keymap[] = { { KE_KEY, 0xC4, { KEY_KBDILLUMUP } }, { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } }, { KE_IGNORE, 0xC6, }, /* Ambient Light Sensor notification */ + { KE_KEY, 0xC7, { KEY_KBDILLUMTOGGLE } }, { KE_END, 0}, };
drivers/platform/x86/asus-wmi.c +8 -0
@@ -67,6 +67,7 @@ MODULE_LICENSE("GPL");#define NOTIFY_BRNDOWN_MAX 0x2e#define NOTIFY_KBD_BRTUP 0xc4#define NOTIFY_KBD_BRTDWN 0xc5 +#define NOTIFY_KBD_BRTTOGGLE 0xc7/* WMI Methods */ #define ASUS_WMI_METHODID_SPEC 0x43455053/* BIOS SPECification */
@@ -1745,6 +1746,13 @@ static void asus_wmi_notify(u32 value, void *context) } } +if (code ==NOTIFY_KBD_BRTTOGGLE ) { +if (asus->kbd_led_wk < asus->kbd_led.max_brightness) + code =NOTIFY_KBD_BRTUP ; +else + code =NOTIFY_KBD_BRTTOGGLE ; + } +if (is_display_toggle (code) && asus->driver->quirks->no_display_toggle) goto exit;
Signature · 1 line
2.7.4
2018-05-02 14:02 GMT+08:00 Chris Chiu <[email protected]>:
Quoted 10 lines
Some Asus laptops like UX550GE has hotkey (Fn+F7) for keyboard backlight toggle. In this UX550GE, the hotkey incremet the level of brightness for each keypress from 1 to 3, and then switch it off when the brightness has been the max. This commit interprets the code
0xc7generated from hotkey toKEY_KBDILLUMUPto increment the brightness, then passKEY_KBDILLUMTOGGLEto user space after the brightness max been reached for switching the led off.
Quoted 47 lines
Signed-off-by Chris Chiu <[email protected]>--- drivers/platform/x86/asus-nb-wmi.c | 1 + drivers/platform/x86/asus-wmi.c | 8 ++++++++ 2 files changed, 9 insertions(+)drivers/platform/x86/asus-nb-wmi.c +1
-0@@ -496,6 +496,7 @@ static const struct key_entry asus_nb_wmi_keymap[] = { { KE_KEY, 0xC4, { KEY_KBDILLUMUP } }, { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } }, { KE_IGNORE, 0xC6, }, /* Ambient Light Sensor notification */ + { KE_KEY, 0xC7, { KEY_KBDILLUMTOGGLE } }, { KE_END, 0}, };drivers/platform/x86/asus-wmi.c +8
-1@@ -67,6 +67,7 @@ MODULE_LICENSE("GPL");#define NOTIFY_BRNDOWN_MAX 0x2e#define NOTIFY_KBD_BRTUP 0xc4#define NOTIFY_KBD_BRTDWN 0xc5 +#define NOTIFY_KBD_BRTTOGGLE 0xc7/* WMI Methods */ #define ASUS_WMI_METHODID_SPEC 0x43455053/* BIOS SPECification */ @@ -1745,6 +1746,13 @@ static void asus_wmi_notify(u32 value, void *context) } } +if (code ==NOTIFY_KBD_BRTTOGGLE ) { +if (asus->kbd_led_wk < asus->kbd_led.max_brightness) + code =NOTIFY_KBD_BRTUP ; +else + code =NOTIFY_KBD_BRTTOGGLE ; + } +if (is_display_toggle (code) && asus->driver->quirks->no_display_toggle) goto exit; --2.7.4
Quoted 41 lines · Chris Chiu
Some Asus laptops like UX550GE has hotkey (Fn+F7) for keyboard backlight toggle. In this UX550GE, the hotkey incremet the level of brightness for each keypress from 1 to 3, and then switch it off when the brightness has been the max. This commit interprets the code
0xc7generated from hotkey toKEY_KBDILLUMUPto increment the brightness, then passKEY_KBDILLUMTOGGLEto user space after the brightness max been reached for switching the led off.https://phabricator.endlessm.com/T21390
Signed-off-by Chris Chiu <[email protected]>--- drivers/platform/x86/asus-nb-wmi.c | 1 + drivers/platform/x86/asus-wmi.c | 8 ++++++++ 2 files changed, 9 insertions(+)drivers/platform/x86/asus-nb-wmi.c +1
-0@@ -496,6 +496,7 @@ static const struct key_entry asus_nb_wmi_keymap[] = { { KE_KEY, 0xC4, { KEY_KBDILLUMUP } }, { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } }, { KE_IGNORE, 0xC6, }, /* Ambient Light Sensor notification */ + { KE_KEY, 0xC7, { KEY_KBDILLUMTOGGLE } }, { KE_END, 0}, };drivers/platform/x86/asus-wmi.c +1
-0@@ -67,6 +67,7 @@ MODULE_LICENSE("GPL");#define NOTIFY_BRNDOWN_MAX 0x2e#define NOTIFY_KBD_BRTUP 0xc4#define NOTIFY_KBD_BRTDWN 0xc5 +#define NOTIFY_KBD_BRTTOGGLE 0xc7/* WMI Methods */ #define ASUS_WMI_METHODID_SPEC 0x43455053/* BIOS SPECification */
drivers/platform/x86/asus-wmi.c static void asus_wmi_notify(u32 value, void *context) · line 1754
Quoted 9 lines
drivers/platform/x86/asus-wmi.c +6
-0@@ -1745,6 +1746,13 @@ static void asus_wmi_notify(u32 value, void *context) } } +if (code ==NOTIFY_KBD_BRTTOGGLE ) { +if (asus->kbd_led_wk < asus->kbd_led.max_brightness) + code =NOTIFY_KBD_BRTUP ; +else + code =NOTIFY_KBD_BRTTOGGLE ; + }
Did you intend the else branch to be a noop?
Quoted 4 lines
drivers/platform/x86/asus-wmi.c +1
-0+if (is_display_toggle (code) && asus->driver->quirks->no_display_toggle) goto exit;
Quoted 47 lines · Puma D.
Quoted 46 lines · Chris Chiu
Some Asus laptops like UX550GE has hotkey (Fn+F7) for keyboard backlight toggle. In this UX550GE, the hotkey incremet the level of brightness for each keypress from 1 to 3, and then switch it off when the brightness has been the max. This commit interprets the code
0xc7generated from hotkey toKEY_KBDILLUMUPto increment the brightness, then passKEY_KBDILLUMTOGGLEto user space after the brightness max been reached for switching the led off.https://phabricator.endlessm.com/T21390
Signed-off-by Chris Chiu <[email protected]>--- drivers/platform/x86/asus-nb-wmi.c | 1 + drivers/platform/x86/asus-wmi.c | 8 ++++++++ 2 files changed, 9 insertions(+)drivers/platform/x86/asus-nb-wmi.c +1
-0@@ -496,6 +496,7 @@ static const struct key_entry asus_nb_wmi_keymap[] = { { KE_KEY, 0xC4, { KEY_KBDILLUMUP } }, { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } }, { KE_IGNORE, 0xC6, }, /* Ambient Light Sensor notification */ + { KE_KEY, 0xC7, { KEY_KBDILLUMTOGGLE } }, { KE_END, 0}, }; diff --git a/drivers/platform/x86/asus-wmi.c
b/drivers/platform/x86/asus-wmi.c
index 1f6e68f..b64ff90 100644drivers/platform/x86/asus-wmi.c +1
-0@@ -67,6 +67,7 @@ MODULE_LICENSE("GPL");#define NOTIFY_BRNDOWN_MAX 0x2e#define NOTIFY_KBD_BRTUP 0xc4#define NOTIFY_KBD_BRTDWN 0xc5 +#define NOTIFY_KBD_BRTTOGGLE 0xc7/* WMI Methods */ #define ASUS_WMI_METHODID_SPEC 0x43455053/* BIOS SPECification */
drivers/platform/x86/asus-wmi.c +0
-0@@ -1745,6 +1746,13 @@ static void asus_wmi_notify(u32 value, void *context) } }
Quoted 9 lines
drivers/platform/x86/asus-wmi.c static void asus_wmi_notify(u32 value, void *context) · line 1754
Quoted 6 lines
drivers/platform/x86/asus-wmi.c +5
-0+ if (code == NOTIFY_KBD_BRTTOGGLE) { +if (asus->kbd_led_wk < asus->kbd_led.max_brightness) + code =NOTIFY_KBD_BRTUP ; +else + code =NOTIFY_KBD_BRTTOGGLE ; + }Did you intend the else branch to be a noop?
Thanks for pointing out. The 'else' does want to do nothing special but Brightness Toggle as the original code. I'll modify that and submit again.
Quoted 8 lines
Quoted 5 lines
drivers/platform/x86/asus-wmi.c +1
-0+if (is_display_toggle (code) && asus->driver->quirks->no_display_toggle) goto exit;