platform/x86: thinkpad-acpi: Add X1 Fold keyboard attachment detection
PATCH v4 1/1 platform/x86: thinkpad-acpi: Add X1 Fold keyboard attachment detection
ThinkPad X1 Fold 16 Gen 1 firmware reports whether the keyboard is magnetically attached (on the screen), but thinkpad-acpi does not expose this to userspace. The state can be obtained via ACPI methods: GDST (get device state).
Add a read-only keyboard_attached_on_screen sysfs attribute, gated by a DMI match.
Cache the state and emit a sysfs notification on TP_HKEY_EV_TABLET_CHANGED (0x60c0) when it changes. Initialize the cache during hotkey setup and refresh it before the resume notification to keep the state consistent across suspend and resume.
---
This replaces the v3 patch:
https://lore.kernel.org/all/[email protected]/
Changes v1 -> v2:
* Use ACPI method instead of using the EC directly (thanks Mark).
Changes v2 -> v3:
* Added documentation to thinkpad-acpi.rst
* Patched against current thinkpad_acpi.c
Changes v3 -> v4:
* Rebased onto the current platform-drivers-x86 review-ilpo-next branch.
* Wrapped long lines reported by checkpatch.
--- .../admin-guide/laptops/thinkpad-acpi.rst | 26 +++++- drivers/platform/x86/lenovo/thinkpad_acpi.c | 86 ++++++++++++++++++- 2 files changed, 109 insertions(+), 3 deletions(-)
Documentation/admin-guide/laptops/thinkpad-acpi.rst +25 -1
@@ -583,7 +583,8 @@ Events that are propagated by the driver to userspace: 0x6030 System thermal table changed 0x6032 Thermal Control command set completion (DYTC, Windows) 0x6040 Nvidia Optimus/AC adapter related (TO BE VERIFIED) -0x60C0 X1 Yoga 2016, Tablet mode status changed +0x60C0 X1 Yoga 2016 tablet mode or X1 Fold 16 Gen 1 keyboard + attachment state changed 0x60F0 Thermal Transformation changed (GMTS, Windows) ====== =====================================================
@@ -1658,6 +1659,29 @@ if damage detected: The property is read-only. If feature is not supported then sysfs attribute is not created. +X1 Fold keyboard attachment +--------------------------- + +sysfs attribute: keyboard_attached_on_screen + +ThinkPad X1 Fold 16 Gen 1 systems can report whether the keyboard is +currently attached on-screen. + +This attribute is currently supported on ThinkPad X1 Fold 16 Gen 1 +systems only. + +The command to check the keyboard attachment state is:: + + cat /sys/devices/platform/thinkpad_acpi/keyboard_attached_on_screen + +The values are: + +- 0 if the keyboard is not attached on-screen +- 1 if the keyboard is attached on-screen + +The property is read-only. If feature is not supported then the sysfs +attribute is not created. + Multiple Commands, Module Parameters ------------------------------------
drivers/platform/x86/lenovo/thinkpad_acpi.c +84 -2
146 lines not on this page · raw message
Signature · 1 line
2.53.0
Ilpo Järvinen
maintainerQuoted 9 lines · Pit Henrich
ThinkPad X1 Fold 16 Gen 1 firmware reports whether the keyboard is magnetically attached (on the screen), but thinkpad-acpi does not expose this to userspace. The state can be obtained via ACPI methods: GDST (get device state).
Add a read-only
keyboard_attached_on_screensysfs attribute, gated by a DMI match.[...]
Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.
FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.
The list of commits applied:
[1/1] platform/x86: thinkpad-acpi: Add X1 Fold keyboard attachment detection
commit: ab0b68221ea686085a146736569ac32d773affcb
--
i.