From: Robin Everaars <robineveraars@pm.me>
To: hansg@kernel.org, ilpo.jarvinen@linux.intel.com
Cc: corentin.chary@gmail.com, luke@ljones.dev,
denis.benato@linux.dev, platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] platform/x86: asus-wmi: keep the lid-flip state when UNKNOWN is set
Date: Wed, 05 Aug 2026 10:15:14 +0000 [thread overview]
Message-ID: <20260805101502.235668-2-robineveraars@pm.me> (raw)
In-Reply-To: <20260805101502.235668-1-robineveraars@pm.me>
[-- Attachment #1.1: Type: text/plain, Size: 3066 bytes --]
On some convertibles the lid-flip devstate sets ASUS_WMI_DSTS_UNKNOWN_BIT
alongside the state bit while the machine is folded. Measured on an ASUS
ProArt PX13 (HN7306EAC), ASUS_WMI_DEVID_LID_FLIP_ROG answers 0x00010000
open and 0x00010003 folded, that is presence | status | UNKNOWN.
asus_wmi_get_devstate_simple() treats that bit as "the state is not known"
and fails the call with -ENODEV, so asus_wmi_tablet_mode_get_state()
discards a perfectly good state sitting in bit 0 and SW_TABLET_MODE never
moves.
Add asus_wmi_tablet_sw_get_state(), which gates on the presence bit only
and returns the status bit. Use it from the two tablet-switch paths. Every
other caller of asus_wmi_get_devstate_simple() is untouched, so the change
is confined to the tablet switch.
Signed-off-by: Robin Everaars <robineveraars@pm.me>
---
drivers/platform/x86/asus-wmi.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86
/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 8610663b8..f68fd2bcd 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -706,12 +706,40 @@ static void asus_wmi_tablet_sw_report(struct asus_wmi *asus, bool value)
input_sync(asus->inputdev);
}
+/*
+ * Read the lid-flip state directly rather than through
+ * asus_wmi_get_devstate_simple().
+ *
+ * On some convertibles the lid-flip devstate sets ASUS_WMI_DSTS_UNKNOWN_BIT
+ * alongside the state bit while folded. Measured on an ASUS ProArt PX13
+ * (HN7306EAC), devid ASUS_WMI_DEVID_LID_FLIP_ROG answers 0x00010000 open and
+ * 0x00010003 folded, i.e. presence | state | UNKNOWN. The generic helper reads
+ * that bit as "the state is not known" and rejects the whole call with -ENODEV,
+ * so asus_wmi_tablet_mode_get_state() discards a perfectly good state sitting in
+ * bit 0 and the switch never moves. Only presence gates the value here, which is
+ * safe because this path serves
the tablet switch alone.
+ */
+static int asus_wmi_tablet_sw_get_state(struct asus_wmi *asus, u32 dev_id)
+{
+ u32 retval;
+ int err;
+
+ err = asus_wmi_get_devstate(asus, dev_id, &retval);
+ if (err < 0)
+ return err;
+
+ if (!(retval & ASUS_WMI_DSTS_PRESENCE_BIT))
+ return -ENODEV;
+
+ return !!(retval & ASUS_WMI_DSTS_STATUS_BIT);
+}
+
static void asus_wmi_tablet_sw_init(struct asus_wmi *asus, u32 dev_id, int event_code)
{
struct device *dev = &asus->platform_device->dev;
int result;
- result = asus_wmi_get_devstate_simple(asus, dev_id);
+ result = asus_wmi_tablet_sw_get_state(asus, dev_id);
if (result >= 0) {
input_set_capability(asus->inputdev, EV_SW, SW_TABLET_MODE);
asus_wmi_tablet_sw_report(asus, result);
@@ -786,7 +814,7 @@ static void asus_wmi_tablet_mode_get_state(struct asus_wmi *asus)
if (!asus->tablet_switch_dev_id)
return;
- result = asus_wmi_get_devstate_simple(asus, asus->tablet_switch_dev_id);
+ result = asus_wmi
_tablet_sw_get_state(asus, asus->tablet_switch_dev_id);
if (result >= 0)
asus_wmi_tablet_sw_report(asus, result);
}
--
2.55.0
[-- Attachment #1.2: publickey - robineveraars@pm.me - 0x8B6BA132.asc --]
[-- Type: application/pgp-keys, Size: 889 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 322 bytes --]
next prev parent reply other threads:[~2026-08-05 10:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 10:15 [PATCH 0/2] platform/x86: asus-wmi: make the tablet switch work on the ProArt PX13 Robin Everaars
2026-08-05 10:15 ` Robin Everaars [this message]
2026-08-05 12:07 ` [PATCH 1/2] platform/x86: asus-wmi: keep the lid-flip state when UNKNOWN is set Denis Benato
2026-08-10 13:20 ` Hans de Goede
2026-08-10 13:31 ` Denis Benato
2026-08-05 10:15 ` [PATCH 2/2] platform/x86: asus-wmi: accept either lid-flip notify code Robin Everaars
2026-08-05 12:11 ` Denis Benato
2026-08-05 14:11 ` [PATCH v2 0/2] platform/x86: asus-wmi: make the tablet switch work on the ProArt PX13 Robin Everaars
2026-08-05 14:11 ` [PATCH v2 1/2] platform/x86: asus-wmi: keep the lid-flip state when UNKNOWN is set Robin Everaars
2026-08-10 13:31 ` Hans de Goede
2026-08-05 14:11 ` [PATCH v2 2/2] platform/x86: asus-wmi: accept either lid-flip notify code Robin Everaars
2026-08-10 13:37 ` Hans de Goede
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=20260805101502.235668-2-robineveraars@pm.me \
--to=robineveraars@pm.me \
--cc=corentin.chary@gmail.com \
--cc=denis.benato@linux.dev \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luke@ljones.dev \
--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
all inboxes | Powered by JetHome®