From: "Samuel Čavoj" <samuel@cavoj.net>
To: Darren Hart <dvhart@infradead.org>,
Andy Shevchenko <andy@infradead.org>,
Corentin Chary <corentin.chary@gmail.com>
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, "Samuel Čavoj" <samuel@cavoj.net>,
"Hans de Goede" <hdegoede@redhat.com>
Subject: [PATCH v2] platform/x86: asus-wmi: Add support for SW_TABLET_MODE on UX360
Date: Thu, 17 Sep 2020 15:34:26 +0200 [thread overview]
Message-ID: <20200917133425.168310-1-samuel@cavoj.net> (raw)
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.
Signed-off-by: Samuel Čavoj <samuel@cavoj.net>
Cc: Hans de Goede <hdegoede@redhat.com>
---
v1 -> v2:
- inherit wmi_backlight_set_devstate from default quirk
---
drivers/platform/x86/asus-nb-wmi.c | 15 +++++++++++++++
drivers/platform/x86/asus-wmi.c | 22 ++++++++++++++++++++++
drivers/platform/x86/asus-wmi.h | 1 +
include/linux/platform_data/x86/asus-wmi.h | 1 +
4 files changed, 39 insertions(+)
diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index 345bd224494b..5019b03b2c95 100644
--- a/drivers/platform/x86/asus-nb-wmi.c
+++ b/drivers/platform/x86/asus-nb-wmi.c
@@ -119,6 +119,11 @@ 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 = {
+ .wmi_backlight_set_devstate = true,
+ .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 +525,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,
+ },
{},
};
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index ae6289d37faf..e5066248e83a 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -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,15 @@ 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;
diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
index 1a95c172f94b..b302415bf1d9 100644
--- a/drivers/platform/x86/asus-wmi.h
+++ b/drivers/platform/x86/asus-wmi.h
@@ -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
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 897b8332a39f..2f274cf52805 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -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
--
2.28.0
next reply other threads:[~2020-09-17 14:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-17 13:34 Samuel Čavoj [this message]
2020-09-17 13:41 ` [PATCH v2] platform/x86: asus-wmi: Add support for SW_TABLET_MODE on UX360 Hans de Goede
2020-10-17 23:33 ` Samuel Čavoj
2020-10-18 9:26 ` Hans de Goede
2020-10-18 9:56 ` Samuel Čavoj
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200917133425.168310-1-samuel@cavoj.net \
--to=samuel@cavoj.net \
--cc=andy@infradead.org \
--cc=corentin.chary@gmail.com \
--cc=dvhart@infradead.org \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).