[PATCH 1/2] platform/x86: asus-wmi: keep the lid-flip state when UNKNOWN is set
Robin Everaars <[email protected]> Wed, 05 Aug 2026 10:15:14 +0000
| Newsgroups | org.kernel.vger.platform-driver-x86,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------20fa7c1726f97877add1223ab9e81a38f1c05f3772bc2c28d1990ad963fdc953 Content-Type: multipart/mixed; boundary=868fdace0fdbbb72a93ff6a260411a2082498efa466d815837c21db2f9e7 From: Robin Everaars <[email protected]> To: [email protected], [email protected] Cc: [email protected], [email protected], [email protected], [email protected], [email protected] Subject: [PATCH 1/2] platform/x86: asus-wmi: keep the lid-flip state when UNKNOWN is set Date: Wed, 5 Aug 2026 12:15:01 +0200 Message-ID: <[email protected]> X-Mailer: git-send-email 2.55.0 In-Reply-To: <[email protected]> References: <[email protected]> MIME-Version: 1.0 --868fdace0fdbbb72a93ff6a260411a2082498efa466d815837c21db2f9e7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 <[email protected]> --- 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 --868fdace0fdbbb72a93ff6a260411a2082498efa466d815837c21db2f9e7 Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="publickey - [email protected] - 0x8B6BA132.asc"; name="publickey - [email protected] - 0x8B6BA132.asc" Content-Type: application/pgp-keys; filename="publickey - [email protected] - 0x8B6BA132.asc"; name="publickey - [email protected] - 0x8B6BA132.asc" LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCkNvbW1lbnQ6IGh0dHBzOi8vZ29w ZW5wZ3Aub3JnClZlcnNpb246IEdvcGVuUEdQIDIuMTAuMAoKeGpNRWFoOGxaUllKS3dZQkJBSGFS dzhCQVFkQWFSa3p2ZTQ5ckJFSk1LSkg3NDZSWEhZKzJmVDc3b3hST2k1ZAo4SnBMKzY3TktYSnZZ bWx1WlhabGNtRmhjbk5BY0cwdWJXVWdQSEp2WW1sdVpYWmxjbUZoY25OQWNHMHViV1UrCndzQVJC Qk1XQ2dDREJZSnFIeVZsQXdzSkJ3a1FIY1YvYThzR0dvcEZGQUFBQUFBQUhBQWdjMkZzZEVCdWIz UmgKZEdsdmJuTXViM0JsYm5CbmNHcHpMbTl5Wng2VjVxUzg5dzdDRFlTSXNjNU54dVBKSTFyZ29F eVkvdjhkYlAzSApxa29OQXhVS0NBUVdBQUlCQWhrQkFwc0RBaDRCRmlFRWkydWhNcmIyWHVqRm5G akxIY1YvYThzR0dvb0FBQVpzCkFQOXpJS1d3dWJDbEZFczBKNmpwUUhUS1hGVHErOTlNUmtmREtx SVRidW1RelFEL1IyT2F6VHA0b0NKTzJiT0QKTkZsaVZBbTh5WFA2QSs1ODZ6UjJZS3QwUkFiT09B UnFIeVZsRWdvckJnRUVBWmRWQVFVQkFRZEEzcDVGN2I1TwpGc1dLclNXRW1FSGlhL29lN25vLyta MVcwT1BmZllyRFB5OERBUWdId3I0RUdCWUtBSEFGZ21vZkpXVUpFQjNGCmYydkxCaHFLUlJRQUFB QUFBQndBSUhOaGJIUkFibTkwWVhScGIyNXpMbTl3Wlc1d1ozQnFjeTV2Y21ldlVkUisKViszVWd2 SVZqcURMRk9XeXlHcDVoNEpYQVBmWVpzRC8vUkhndlFLYkRCWWhCSXRyb1RLMjlsN294WnhZeXgz RgpmMnZMQmhxS0FBQm9GZ0VBOGU0ZVNMU2FMbXY4L2UyVzFMOS9WS0FiajJaN0pFUzZLQXBpOUJa Nm5RZ0JBTmhaCkZoTUZ6c3l6dTJZWXRhQjhTWXRWdGhKSjYvZUlRVFQ2VWRRRUlZc0YKPVlLaE0K LS0tLS1FTkQgUEdQIFBVQkxJQyBLRVkgQkxPQ0stLS0tLQ== --868fdace0fdbbb72a93ff6a260411a2082498efa466d815837c21db2f9e7-- --------20fa7c1726f97877add1223ab9e81a38f1c05f3772bc2c28d1990ad963fdc953 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: ProtonMail wqsEARYIAF0FgmpzDTEJEB3Ff2vLBhqKNRQAAAAAABwAEHNhbHRAbm90YXRp b25zLm9wZW5wZ3Bqcy5vcmd+7UF3EzxIbjS0/r772i6DFiEEi2uhMrb2XujF nFjLHcV/a8sGGooAAEm2AP9Um9v1lheVgRZhDU8dbXQIOvkvgJSwq8JUhQwb nxQgoAD8CpYgyVdyQplYl9h6zEFD3SVTe7XUyE1FGbQAj0dH2gI= =8Yuu -----END PGP SIGNATURE----- --------20fa7c1726f97877add1223ab9e81a38f1c05f3772bc2c28d1990ad963fdc953--