summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/asus-wmi.c
diff options
context:
space:
mode:
authorLuke D. Jones <luke@ljones.dev>2022-08-13 21:27:53 +1200
committerHans de Goede <hdegoede@redhat.com>2022-08-25 16:23:53 +0200
commite397c3c460bf3849384f2f55516d1887617cfca9 (patch)
tree0aecefa844d587a1e4782c300826822ad62ed3b0 /drivers/platform/x86/asus-wmi.c
parent00aa846955fbfb04f7bc0c26c49febfe5395eca1 (diff)
platform/x86: asus-wmi: Add support for ROG X13 tablet mode
Add quirk for ASUS ROG X13 Flow 2-in-1 to enable tablet mode with lid flip (all screen rotations). Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://lore.kernel.org/r/20220813092753.6635-2-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform/x86/asus-wmi.c')
-rw-r--r--drivers/platform/x86/asus-wmi.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index fe2d072e1acc..5352055848d0 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -68,6 +68,7 @@ module_param(fnlock_default, bool, 0444);
#define NOTIFY_KBD_FBM 0x99
#define NOTIFY_KBD_TTP 0xae
#define NOTIFY_LID_FLIP 0xfa
+#define NOTIFY_LID_FLIP_ROG 0xbd
#define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0)
@@ -530,6 +531,19 @@ static int asus_wmi_input_init(struct asus_wmi *asus)
dev_err(dev, "Error checking for lid-flip: %d\n", result);
}
break;
+ case asus_wmi_lid_flip_rog_devid:
+ result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_LID_FLIP_ROG);
+ if (result < 0)
+ asus->driver->quirks->tablet_switch_mode = asus_wmi_no_tablet_switch;
+ 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) {
+ dev_err(dev, "This device has lid-flip-rog quirk but got ENODEV checking it. This is a bug.");
+ } else {
+ dev_err(dev, "Error checking for lid-flip: %d\n", result);
+ }
+ break;
}
err = input_register_device(asus->inputdev);
@@ -564,6 +578,17 @@ static void lid_flip_tablet_mode_get_state(struct asus_wmi *asus)
}
}
+static void lid_flip_rog_tablet_mode_get_state(struct asus_wmi *asus)
+{
+ int result;
+
+ result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_LID_FLIP_ROG);
+ if (result >= 0) {
+ input_report_switch(asus->inputdev, SW_TABLET_MODE, result);
+ input_sync(asus->inputdev);
+ }
+}
+
/* dGPU ********************************************************************/
static ssize_t dgpu_disable_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -3069,6 +3094,12 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus)
return;
}
+ if (asus->driver->quirks->tablet_switch_mode == asus_wmi_lid_flip_rog_devid &&
+ code == NOTIFY_LID_FLIP_ROG) {
+ lid_flip_rog_tablet_mode_get_state(asus);
+ return;
+ }
+
if (asus->fan_boost_mode_available && code == NOTIFY_KBD_FBM) {
fan_boost_mode_switch_next(asus);
return;
@@ -3701,6 +3732,9 @@ static int asus_hotk_resume(struct device *device)
case asus_wmi_lid_flip_devid:
lid_flip_tablet_mode_get_state(asus);
break;
+ case asus_wmi_lid_flip_rog_devid:
+ lid_flip_rog_tablet_mode_get_state(asus);
+ break;
}
return 0;
@@ -3749,6 +3783,9 @@ static int asus_hotk_restore(struct device *device)
case asus_wmi_lid_flip_devid:
lid_flip_tablet_mode_get_state(asus);
break;
+ case asus_wmi_lid_flip_rog_devid:
+ lid_flip_rog_tablet_mode_get_state(asus);
+ break;
}
return 0;