platform/x86: asus-wmi: Add support for SW_TABLET_MODE on UX360
PATCH 1/1 platform/x86: asus-wmi: Add support for SW_TABLET_MODE on UX360
The UX360CA has a WMI device id 0x00060062, which reports whether the lid is flipped in tablet mode (1) or in normal laptop mode (0).
This commit adds a quirk (quirk_asus_use_lid_flip_devid) for devices on which this WMI device should be used to figure out the SW_TABLET_MODE state, as opposed to the quirk_asus_use_kbd_dock_devid.
It is assumed other UX360* models have the same WMI device. As such, the quirk is applied to devices with DMI_MATCH(DMI_PRODUCT_NAME, "UX360"). More devices with this feature need to be tested and added accordingly.
The reason for using a whitelist via the quirk mechanism is that the new WMI device (0x00060062) is also present on some models which do not have a 360 degree hinge (at least FX503VD and GL503VD from Hans' DSTS collection) and therefore its presence cannot be relied on.
This patch is a followup to "platform/x86: asus-wmi: Fix SW_TABLET_MODE always reporting 1 on many different models" by Hans de Goede.
--- drivers/platform/x86/asus-nb-wmi.c | 14 +++++++++++++ drivers/platform/x86/asus-wmi.c | 23 ++++++++++++++++++++++ drivers/platform/x86/asus-wmi.h | 1 + include/linux/platform_data/x86/asus-wmi.h | 1 + 4 files changed, 39 insertions(+)
drivers/platform/x86/asus-nb-wmi.c +14 -0
@@ -119,6 +119,10 @@ static struct quirk_entry quirk_asus_use_kbd_dock_devid = { .use_kbd_dock_devid = true, }; +static struct quirk_entry quirk_asus_use_lid_flip_devid = { + .use_lid_flip_devid = true, +}; +static int dmi_matched (const struct dmi_system_id *dmi) {pr_info ("Identified laptop model '%s'\n" , dmi->ident);
@@ -520,6 +524,16 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_use_kbd_dock_devid, }, + { + .callback = dmi_matched, + .ident = "ASUS ZenBook Flip UX360", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + /* Match UX360* */ + DMI_MATCH(DMI_PRODUCT_NAME, "UX360"), + }, + .driver_data = &quirk_asus_use_lid_flip_devid, + }, {}, };
drivers/platform/x86/asus-wmi.c +23 -0
@@ -63,6 +63,7 @@ MODULE_LICENSE("GPL");#define NOTIFY_KBD_BRTTOGGLE 0xc7#define NOTIFY_KBD_FBM 0x99#define NOTIFY_KBD_TTP 0xae +#define NOTIFY_LID_FLIP 0xfa#define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0)
@@ -375,6 +376,18 @@ static int asus_wmi_input_init(struct asus_wmi *asus) } } +if (asus->driver->quirks->use_lid_flip_devid) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); +if (result >=0 ) { +input_set_capability (asus->inputdev,EV_SW ,SW_TABLET_MODE ); +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); + }else if (result == -ENODEV ) { +pr_err ("This device has lid_flip quirk but got ENODEV checking it. This is a bug." ); + }else { +pr_err ("Error checking for lid-flip: %d\n" , result); + } + } + err =input_register_device (asus->inputdev);if (err) goto err_free_dev;
@@ -2127,6 +2140,16 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus)return ; } +if (asus->driver->quirks->use_lid_flip_devid && code ==NOTIFY_LID_FLIP ) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); + +if (result >=0 ) { +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); +input_sync (asus->inputdev); + } +return ; + } +if (asus->fan_boost_mode_available && code ==NOTIFY_KBD_FBM ) {fan_boost_mode_switch_next (asus);return ;
drivers/platform/x86/asus-wmi.h +1 -0
@@ -34,6 +34,7 @@ struct quirk_entry {bool wmi_backlight_set_devstate;bool wmi_force_als_set;bool use_kbd_dock_devid; +bool use_lid_flip_devid;int wapf;/* * For machines with AMD graphic chips, it will send out WMI event
include/linux/platform_data/x86/asus-wmi.h +1 -0
@@ -62,6 +62,7 @@/* Misc */ #define ASUS_WMI_DEVID_CAMERA 0x00060013 +#define ASUS_WMI_DEVID_LID_FLIP 0x00060062/* Storage */ #define ASUS_WMI_DEVID_CARDREADER 0x00080013
Signature · 1 line
2.28.0
Hi,
Quoted 33 lines · Samuel Čavoj
The UX360CA has a WMI device id
0x00060062, which reports whether the lid is flipped in tablet mode (1) or in normal laptop mode (0).This commit adds a quirk (
quirk_asus_use_lid_flip_devid) for devices on which this WMI device should be used to figure out theSW_TABLET_MODEstate, as opposed to thequirk_asus_use_kbd_dock_devid.It is assumed other UX360* models have the same WMI device. As such, the quirk is applied to devices with
DMI_MATCH(DMI_PRODUCT_NAME, "UX360"). More devices with this feature need to be tested and added accordingly.The reason for using a whitelist via the quirk mechanism is that the new WMI device (
0x00060062) is also present on some models which do not have a 360 degree hinge (at least FX503VD and GL503VD from Hans' DSTS collection) and therefore its presence cannot be relied on.This patch is a followup to "platform/x86: asus-wmi: Fix
SW_TABLET_MODEalways reporting 1 on many different models" by Hans de Goede.Signed-off-by Samuel Čavoj <[email protected]>Cc Hans de Goede <[email protected]>--- drivers/platform/x86/asus-nb-wmi.c | 14 +++++++++++++ drivers/platform/x86/asus-wmi.c | 23 ++++++++++++++++++++++ drivers/platform/x86/asus-wmi.h | 1 + include/linux/platform_data/x86/asus-wmi.h | 1 + 4 files changed, 39 insertions(+)drivers/platform/x86/asus-nb-wmi.c +0
-0
drivers/platform/x86/asus-nb-wmi.c static struct quirk_entry quirk_asus_use_kbd_dock_devid = { · line 123
Quoted 5 lines
drivers/platform/x86/asus-nb-wmi.c +2
-0@@ -119,6 +119,10 @@ static struct quirk_entry quirk_asus_use_kbd_dock_devid = { .use_kbd_dock_devid = true, }; +static struct quirk_entry quirk_asus_use_lid_flip_devid = { + .use_lid_flip_devid = true,
Note the default (quirk_asus_unknown) quirks set:
.wmi_backlight_set_devstate = true,
So you're changing that to false for all devices using that
quirk now. I did not set this quirk for the transformer devices, since the quirk has to do with the handling of Fn + F7 (display off hotkey) by the embedded-controller. Since on transformer devices the keyboard is an USB device and not handled by the embedded-controller they do not need the wmi_backlight_set_devstate quirk, so I left it out. Chances are that your UX360 does need it. The purpose of the quirk is to make the embbedded controller send a KEY_DISPLAY_OFF event on FN + F7 and have it not do anything else (like turning off the backlight by itself).
TL;DR: you should probably add: .wmi_backlight_set_devstate = true,
to your new quirk_asus_use_lid_flip_devid quirk.
Quoted 88 lines
drivers/platform/x86/asus-nb-wmi.c +12
-0+}; +static int dmi_matched (const struct dmi_system_id *dmi) {pr_info ("Identified laptop model '%s'\n" , dmi->ident);@@ -520,6 +524,16 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_use_kbd_dock_devid, }, + { + .callback = dmi_matched, + .ident = "ASUS ZenBook Flip UX360", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + /* Match UX360* */ + DMI_MATCH(DMI_PRODUCT_NAME, "UX360"), + }, + .driver_data = &quirk_asus_use_lid_flip_devid, + }, {}, };drivers/platform/x86/asus-wmi.c +23
-0@@ -63,6 +63,7 @@ MODULE_LICENSE("GPL");#define NOTIFY_KBD_BRTTOGGLE 0xc7#define NOTIFY_KBD_FBM 0x99#define NOTIFY_KBD_TTP 0xae +#define NOTIFY_LID_FLIP 0xfa#define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0)@@ -375,6 +376,18 @@ static int asus_wmi_input_init(struct asus_wmi *asus) } } +if (asus->driver->quirks->use_lid_flip_devid) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); +if (result >=0 ) { +input_set_capability (asus->inputdev,EV_SW ,SW_TABLET_MODE ); +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); + }else if (result == -ENODEV ) { +pr_err ("This device has lid_flip quirk but got ENODEV checking it. This is a bug." ); + }else { +pr_err ("Error checking for lid-flip: %d\n" , result); + } + } + err =input_register_device (asus->inputdev);if (err) goto err_free_dev;@@ -2127,6 +2140,16 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus)return ; } +if (asus->driver->quirks->use_lid_flip_devid && code ==NOTIFY_LID_FLIP ) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); + +if (result >=0 ) { +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); +input_sync (asus->inputdev); + } +return ; + } +if (asus->fan_boost_mode_available && code ==NOTIFY_KBD_FBM ) {fan_boost_mode_switch_next (asus);return ;drivers/platform/x86/asus-wmi.h +1
-0@@ -34,6 +34,7 @@ struct quirk_entry {bool wmi_backlight_set_devstate;bool wmi_force_als_set;bool use_kbd_dock_devid; +bool use_lid_flip_devid;int wapf;/* * For machines with AMD graphic chips, it will send out WMI event include/linux/platform_data/x86/asus-wmi.h +0
-0
include/linux/platform_data/x86/asus-wmi.h line 68
Quoted 7 lines
include/linux/platform_data/x86/asus-wmi.h +1
-0@@ -62,6 +62,7 @@/* Misc */ #define ASUS_WMI_DEVID_CAMERA 0x00060013 +#define ASUS_WMI_DEVID_LID_FLIP 0x00060062/* Storage */ #define ASUS_WMI_DEVID_CARDREADER 0x00080013
Otherwise the patch looks good to me, thank you for the patch.
Regards,
Hans
Hi.
Quoted 56 lines · Hans de Goede
Hi,
Quoted 33 lines · Samuel Čavoj
The UX360CA has a WMI device id
0x00060062, which reports whether the lid is flipped in tablet mode (1) or in normal laptop mode (0).This commit adds a quirk (
quirk_asus_use_lid_flip_devid) for devices on which this WMI device should be used to figure out theSW_TABLET_MODEstate, as opposed to thequirk_asus_use_kbd_dock_devid.It is assumed other UX360* models have the same WMI device. As such, the quirk is applied to devices with
DMI_MATCH(DMI_PRODUCT_NAME, "UX360"). More devices with this feature need to be tested and added accordingly.The reason for using a whitelist via the quirk mechanism is that the new WMI device (
0x00060062) is also present on some models which do not have a 360 degree hinge (at least FX503VD and GL503VD from Hans' DSTS collection) and therefore its presence cannot be relied on.This patch is a followup to "platform/x86: asus-wmi: Fix
SW_TABLET_MODEalways reporting 1 on many different models" by Hans de Goede.Signed-off-by Samuel Čavoj <[email protected]>Cc Hans de Goede <[email protected]>--- drivers/platform/x86/asus-nb-wmi.c | 14 +++++++++++++ drivers/platform/x86/asus-wmi.c | 23 ++++++++++++++++++++++ drivers/platform/x86/asus-wmi.h | 1 + include/linux/platform_data/x86/asus-wmi.h | 1 + 4 files changed, 39 insertions(+)drivers/platform/x86/asus-nb-wmi.c +0
-0drivers/platform/x86/asus-nb-wmi.c static struct quirk_entry quirk_asus_use_kbd_dock_devid = { · line 122
Quoted 4 lines
drivers/platform/x86/asus-nb-wmi.c +2
-0@@ -119,6 +119,10 @@ static struct quirk_entry quirk_asus_use_kbd_dock_devid = { .use_kbd_dock_devid = true, }; +static struct quirk_entry quirk_asus_use_lid_flip_devid = { + .use_lid_flip_devid = true,Note the default (
quirk_asus_unknown) quirks set:.wmi_backlight_set_devstate = true,
So you're changing that to false for all devices using that
quirk now. I did not set this quirk for the transformer devices, since the quirk has to do with the handling of Fn + F7 (display off hotkey) by the embedded-controller. Since on transformer devices the keyboard is an USB device and not handled by the embedded-controller they do not need thewmi_backlight_set_devstatequirk, so I left it out. Chances are that your UX360 does need it. The purpose of the quirk is to make the embbedded controller send aKEY_DISPLAY_OFFevent on FN + F7 and have it not do anything else (like turning off the backlight by itself).
Quoted 3 lines
TL;DR: you should probably add: .wmi_backlight_set_devstate = true,
to your newquirk_asus_use_lid_flip_devidquirk.
Of course. I didn't notice that. Thank you.
Should I send a v2 right away, or do I wait for other potential comments?
Regards,
Sam
Quoted 97 lines
Quoted 84 lines
drivers/platform/x86/asus-nb-wmi.c +12
-0+}; +static int dmi_matched (const struct dmi_system_id *dmi) {pr_info ("Identified laptop model '%s'\n" , dmi->ident);@@ -520,6 +524,16 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_use_kbd_dock_devid, }, + { + .callback = dmi_matched, + .ident = "ASUS ZenBook Flip UX360", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + /* Match UX360* */ + DMI_MATCH(DMI_PRODUCT_NAME, "UX360"), + }, + .driver_data = &quirk_asus_use_lid_flip_devid, + }, {}, };drivers/platform/x86/asus-wmi.c +23
-0@@ -63,6 +63,7 @@ MODULE_LICENSE("GPL");#define NOTIFY_KBD_BRTTOGGLE 0xc7#define NOTIFY_KBD_FBM 0x99#define NOTIFY_KBD_TTP 0xae +#define NOTIFY_LID_FLIP 0xfa#define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0)@@ -375,6 +376,18 @@ static int asus_wmi_input_init(struct asus_wmi *asus) } } +if (asus->driver->quirks->use_lid_flip_devid) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); +if (result >=0 ) { +input_set_capability (asus->inputdev,EV_SW ,SW_TABLET_MODE ); +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); + }else if (result == -ENODEV ) { +pr_err ("This device has lid_flip quirk but got ENODEV checking it. This is a bug." ); + }else { +pr_err ("Error checking for lid-flip: %d\n" , result); + } + } + err =input_register_device (asus->inputdev);if (err) goto err_free_dev;@@ -2127,6 +2140,16 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus)return ; } +if (asus->driver->quirks->use_lid_flip_devid && code ==NOTIFY_LID_FLIP ) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); + +if (result >=0 ) { +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); +input_sync (asus->inputdev); + } +return ; + } +if (asus->fan_boost_mode_available && code ==NOTIFY_KBD_FBM ) {fan_boost_mode_switch_next (asus);return ;drivers/platform/x86/asus-wmi.h +1
-0@@ -34,6 +34,7 @@ struct quirk_entry {bool wmi_backlight_set_devstate;bool wmi_force_als_set;bool use_kbd_dock_devid; +bool use_lid_flip_devid;int wapf;/* * For machines with AMD graphic chips, it will send out WMI event include/linux/platform_data/x86/asus-wmi.h +0
-0include/linux/platform_data/x86/asus-wmi.h line 67
Quoted 6 lines
include/linux/platform_data/x86/asus-wmi.h +1
-0@@ -62,6 +62,7 @@/* Misc */ #define ASUS_WMI_DEVID_CAMERA 0x00060013 +#define ASUS_WMI_DEVID_LID_FLIP 0x00060062/* Storage */ #define ASUS_WMI_DEVID_CARDREADER 0x00080013Otherwise the patch looks good to me, thank you for the patch.
Regards,
Hans
Hi,
Quoted 59 lines · Samuel Čavoj
Hi.
Quoted 56 lines · Hans de Goede
Hi,
Quoted 33 lines · Samuel Čavoj
The UX360CA has a WMI device id
0x00060062, which reports whether the lid is flipped in tablet mode (1) or in normal laptop mode (0).This commit adds a quirk (
quirk_asus_use_lid_flip_devid) for devices on which this WMI device should be used to figure out theSW_TABLET_MODEstate, as opposed to thequirk_asus_use_kbd_dock_devid.It is assumed other UX360* models have the same WMI device. As such, the quirk is applied to devices with
DMI_MATCH(DMI_PRODUCT_NAME, "UX360"). More devices with this feature need to be tested and added accordingly.The reason for using a whitelist via the quirk mechanism is that the new WMI device (
0x00060062) is also present on some models which do not have a 360 degree hinge (at least FX503VD and GL503VD from Hans' DSTS collection) and therefore its presence cannot be relied on.This patch is a followup to "platform/x86: asus-wmi: Fix
SW_TABLET_MODEalways reporting 1 on many different models" by Hans de Goede.Signed-off-by Samuel Čavoj <[email protected]>Cc Hans de Goede <[email protected]>--- drivers/platform/x86/asus-nb-wmi.c | 14 +++++++++++++ drivers/platform/x86/asus-wmi.c | 23 ++++++++++++++++++++++ drivers/platform/x86/asus-wmi.h | 1 + include/linux/platform_data/x86/asus-wmi.h | 1 + 4 files changed, 39 insertions(+)drivers/platform/x86/asus-nb-wmi.c +0
-0drivers/platform/x86/asus-nb-wmi.c static struct quirk_entry quirk_asus_use_kbd_dock_devid = { · line 122
Quoted 4 lines
drivers/platform/x86/asus-nb-wmi.c +2
-0@@ -119,6 +119,10 @@ static struct quirk_entry quirk_asus_use_kbd_dock_devid = { .use_kbd_dock_devid = true, }; +static struct quirk_entry quirk_asus_use_lid_flip_devid = { + .use_lid_flip_devid = true,Note the default (
quirk_asus_unknown) quirks set:.wmi_backlight_set_devstate = true,
So you're changing that to false for all devices using that
quirk now. I did not set this quirk for the transformer devices, since the quirk has to do with the handling of Fn + F7 (display off hotkey) by the embedded-controller. Since on transformer devices the keyboard is an USB device and not handled by the embedded-controller they do not need thewmi_backlight_set_devstatequirk, so I left it out. Chances are that your UX360 does need it. The purpose of the quirk is to make the embbedded controller send aKEY_DISPLAY_OFFevent on FN + F7 and have it not do anything else (like turning off the backlight by itself).
Quoted 8 lines
Quoted 3 lines
TL;DR: you should probably add: .wmi_backlight_set_devstate = true,
to your newquirk_asus_use_lid_flip_devidquirk.Of course. I didn't notice that. Thank you.
Should I send a v2 right away, or do I wait for other potential comments?
Normally waiting for some other comments would be good, but this is a pretty straight-forward patch so I don't expect much other comments.
As such I think submitting a v2 right away is fine.
Regards,
Hans
Quoted 96 lines
Quoted 95 lines
Quoted 82 lines
drivers/platform/x86/asus-nb-wmi.c +12
-0+}; +static int dmi_matched (const struct dmi_system_id *dmi) {pr_info ("Identified laptop model '%s'\n" , dmi->ident);@@ -520,6 +524,16 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_use_kbd_dock_devid, }, + { + .callback = dmi_matched, + .ident = "ASUS ZenBook Flip UX360", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + /* Match UX360* */ + DMI_MATCH(DMI_PRODUCT_NAME, "UX360"), + }, + .driver_data = &quirk_asus_use_lid_flip_devid, + }, {}, };drivers/platform/x86/asus-wmi.c +23
-0@@ -63,6 +63,7 @@ MODULE_LICENSE("GPL");#define NOTIFY_KBD_BRTTOGGLE 0xc7#define NOTIFY_KBD_FBM 0x99#define NOTIFY_KBD_TTP 0xae +#define NOTIFY_LID_FLIP 0xfa#define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0)@@ -375,6 +376,18 @@ static int asus_wmi_input_init(struct asus_wmi *asus) } } +if (asus->driver->quirks->use_lid_flip_devid) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); +if (result >=0 ) { +input_set_capability (asus->inputdev,EV_SW ,SW_TABLET_MODE ); +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); + }else if (result == -ENODEV ) { +pr_err ("This device has lid_flip quirk but got ENODEV checking it. This is a bug." ); + }else { +pr_err ("Error checking for lid-flip: %d\n" , result); + } + } + err =input_register_device (asus->inputdev);if (err) goto err_free_dev;@@ -2127,6 +2140,16 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus)return ; } +if (asus->driver->quirks->use_lid_flip_devid && code ==NOTIFY_LID_FLIP ) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); + +if (result >=0 ) { +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); +input_sync (asus->inputdev); + } +return ; + } +if (asus->fan_boost_mode_available && code ==NOTIFY_KBD_FBM ) {fan_boost_mode_switch_next (asus);return ;drivers/platform/x86/asus-wmi.h +1
-0@@ -34,6 +34,7 @@ struct quirk_entry {bool wmi_backlight_set_devstate;bool wmi_force_als_set;bool use_kbd_dock_devid; +bool use_lid_flip_devid;int wapf;/* * For machines with AMD graphic chips, it will send out WMI event include/linux/platform_data/x86/asus-wmi.h +0
-0include/linux/platform_data/x86/asus-wmi.h line 67
Quoted 6 lines
include/linux/platform_data/x86/asus-wmi.h +1
-0@@ -62,6 +62,7 @@/* Misc */ #define ASUS_WMI_DEVID_CAMERA 0x00060013 +#define ASUS_WMI_DEVID_LID_FLIP 0x00060062/* Storage */ #define ASUS_WMI_DEVID_CARDREADER 0x00080013Otherwise the patch looks good to me, thank you for the patch.
Regards,
Hans
Quoted 6 lines · Samuel Čavoj
The UX360CA has a WMI device id
0x00060062, which reports whether the lid is flipped in tablet mode (1) or in normal laptop mode (0).This commit adds a quirk (
quirk_asus_use_lid_flip_devid) for devices on which this WMI device should be used to figure out theSW_TABLET_MODEstate, as opposed to thequirk_asus_use_kbd_dock_devid.
see Documentation/process/submitting-patches.rst
section2 the bit about "imperative mood".
--mark
Quoted 129 lines
It is assumed other UX360* models have the same WMI device. As such, the quirk is applied to devices with
DMI_MATCH(DMI_PRODUCT_NAME, "UX360"). More devices with this feature need to be tested and added accordingly.The reason for using a whitelist via the quirk mechanism is that the new WMI device (
0x00060062) is also present on some models which do not have a 360 degree hinge (at least FX503VD and GL503VD from Hans' DSTS collection) and therefore its presence cannot be relied on.This patch is a followup to "platform/x86: asus-wmi: Fix
SW_TABLET_MODEalways reporting 1 on many different models" by Hans de Goede.Signed-off-by Samuel Čavoj <[email protected]>Cc Hans de Goede <[email protected]>--- drivers/platform/x86/asus-nb-wmi.c | 14 +++++++++++++ drivers/platform/x86/asus-wmi.c | 23 ++++++++++++++++++++++ drivers/platform/x86/asus-wmi.h | 1 + include/linux/platform_data/x86/asus-wmi.h | 1 + 4 files changed, 39 insertions(+)drivers/platform/x86/asus-nb-wmi.c +14
-0@@ -119,6 +119,10 @@ static struct quirk_entry quirk_asus_use_kbd_dock_devid = { .use_kbd_dock_devid = true, }; +static struct quirk_entry quirk_asus_use_lid_flip_devid = { + .use_lid_flip_devid = true, +}; +static int dmi_matched (const struct dmi_system_id *dmi) {pr_info ("Identified laptop model '%s'\n" , dmi->ident);@@ -520,6 +524,16 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_use_kbd_dock_devid, }, + { + .callback = dmi_matched, + .ident = "ASUS ZenBook Flip UX360", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + /* Match UX360* */ + DMI_MATCH(DMI_PRODUCT_NAME, "UX360"), + }, + .driver_data = &quirk_asus_use_lid_flip_devid, + }, {}, };drivers/platform/x86/asus-wmi.c +23
-0@@ -63,6 +63,7 @@ MODULE_LICENSE("GPL");#define NOTIFY_KBD_BRTTOGGLE 0xc7#define NOTIFY_KBD_FBM 0x99#define NOTIFY_KBD_TTP 0xae +#define NOTIFY_LID_FLIP 0xfa#define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0)@@ -375,6 +376,18 @@ static int asus_wmi_input_init(struct asus_wmi *asus) } } +if (asus->driver->quirks->use_lid_flip_devid) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); +if (result >=0 ) { +input_set_capability (asus->inputdev,EV_SW ,SW_TABLET_MODE ); +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); + }else if (result == -ENODEV ) { +pr_err ("This device has lid_flip quirk but got ENODEV checking it. This is a bug." ); + }else { +pr_err ("Error checking for lid-flip: %d\n" , result); + } + } + err =input_register_device (asus->inputdev);if (err) goto err_free_dev;@@ -2127,6 +2140,16 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus)return ; } +if (asus->driver->quirks->use_lid_flip_devid && code ==NOTIFY_LID_FLIP ) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); + +if (result >=0 ) { +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); +input_sync (asus->inputdev); + } +return ; + } +if (asus->fan_boost_mode_available && code ==NOTIFY_KBD_FBM ) {fan_boost_mode_switch_next (asus);return ;drivers/platform/x86/asus-wmi.h +1
-0@@ -34,6 +34,7 @@ struct quirk_entry {bool wmi_backlight_set_devstate;bool wmi_force_als_set;bool use_kbd_dock_devid; +bool use_lid_flip_devid;int wapf;/* * For machines with AMD graphic chips, it will send out WMI event include/linux/platform_data/x86/asus-wmi.h +1
-0@@ -62,6 +62,7 @@/* Misc */ #define ASUS_WMI_DEVID_CAMERA 0x00060013 +#define ASUS_WMI_DEVID_LID_FLIP 0x00060062/* Storage */ #define ASUS_WMI_DEVID_CARDREADER 0x00080013Signature · 1 line
2.28.0
Quoted 9 lines · mark gross
Quoted 6 lines · Samuel Čavoj
The UX360CA has a WMI device id
0x00060062, which reports whether the lid is flipped in tablet mode (1) or in normal laptop mode (0).This commit adds a quirk (
quirk_asus_use_lid_flip_devid) for devices on which this WMI device should be used to figure out theSW_TABLET_MODEstate, as opposed to thequirk_asus_use_kbd_dock_devid.see
Documentation/process/submitting-patches.rst
section2 the bit about "imperative mood".
Thanks, I will keep that in mind going forward. I don't believe it's worth submitting a v3 at this point?
Regards,
Samuel
Quoted 129 lines
Quoted 129 lines
It is assumed other UX360* models have the same WMI device. As such, the quirk is applied to devices with
DMI_MATCH(DMI_PRODUCT_NAME, "UX360"). More devices with this feature need to be tested and added accordingly.The reason for using a whitelist via the quirk mechanism is that the new WMI device (
0x00060062) is also present on some models which do not have a 360 degree hinge (at least FX503VD and GL503VD from Hans' DSTS collection) and therefore its presence cannot be relied on.This patch is a followup to "platform/x86: asus-wmi: Fix
SW_TABLET_MODEalways reporting 1 on many different models" by Hans de Goede.Signed-off-by Samuel Čavoj <[email protected]>Cc Hans de Goede <[email protected]>--- drivers/platform/x86/asus-nb-wmi.c | 14 +++++++++++++ drivers/platform/x86/asus-wmi.c | 23 ++++++++++++++++++++++ drivers/platform/x86/asus-wmi.h | 1 + include/linux/platform_data/x86/asus-wmi.h | 1 + 4 files changed, 39 insertions(+)drivers/platform/x86/asus-nb-wmi.c +14
-0@@ -119,6 +119,10 @@ static struct quirk_entry quirk_asus_use_kbd_dock_devid = { .use_kbd_dock_devid = true, }; +static struct quirk_entry quirk_asus_use_lid_flip_devid = { + .use_lid_flip_devid = true, +}; +static int dmi_matched (const struct dmi_system_id *dmi) {pr_info ("Identified laptop model '%s'\n" , dmi->ident);@@ -520,6 +524,16 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_use_kbd_dock_devid, }, + { + .callback = dmi_matched, + .ident = "ASUS ZenBook Flip UX360", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + /* Match UX360* */ + DMI_MATCH(DMI_PRODUCT_NAME, "UX360"), + }, + .driver_data = &quirk_asus_use_lid_flip_devid, + }, {}, };drivers/platform/x86/asus-wmi.c +23
-0@@ -63,6 +63,7 @@ MODULE_LICENSE("GPL");#define NOTIFY_KBD_BRTTOGGLE 0xc7#define NOTIFY_KBD_FBM 0x99#define NOTIFY_KBD_TTP 0xae +#define NOTIFY_LID_FLIP 0xfa#define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0)@@ -375,6 +376,18 @@ static int asus_wmi_input_init(struct asus_wmi *asus) } } +if (asus->driver->quirks->use_lid_flip_devid) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); +if (result >=0 ) { +input_set_capability (asus->inputdev,EV_SW ,SW_TABLET_MODE ); +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); + }else if (result == -ENODEV ) { +pr_err ("This device has lid_flip quirk but got ENODEV checking it. This is a bug." ); + }else { +pr_err ("Error checking for lid-flip: %d\n" , result); + } + } + err =input_register_device (asus->inputdev);if (err) goto err_free_dev;@@ -2127,6 +2140,16 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus)return ; } +if (asus->driver->quirks->use_lid_flip_devid && code ==NOTIFY_LID_FLIP ) { + result =asus_wmi_get_devstate_simple (asus,ASUS_WMI_DEVID_LID_FLIP ); + +if (result >=0 ) { +input_report_switch (asus->inputdev,SW_TABLET_MODE , result); +input_sync (asus->inputdev); + } +return ; + } +if (asus->fan_boost_mode_available && code ==NOTIFY_KBD_FBM ) {fan_boost_mode_switch_next (asus);return ;drivers/platform/x86/asus-wmi.h +1
-0@@ -34,6 +34,7 @@ struct quirk_entry {bool wmi_backlight_set_devstate;bool wmi_force_als_set;bool use_kbd_dock_devid; +bool use_lid_flip_devid;int wapf;/* * For machines with AMD graphic chips, it will send out WMI event include/linux/platform_data/x86/asus-wmi.h +1
-0@@ -62,6 +62,7 @@/* Misc */ #define ASUS_WMI_DEVID_CAMERA 0x00060013 +#define ASUS_WMI_DEVID_LID_FLIP 0x00060062/* Storage */ #define ASUS_WMI_DEVID_CARDREADER 0x00080013Signature · 1 line
2.28.0