* [PATCH] platform/x86/hp/hp-wmi: Add periodic tablet mode poll
@ 2026-08-12 11:33 nicourced
0 siblings, 0 replies; only message in thread
From: nicourced @ 2026-08-12 11:33 UTC (permalink / raw)
To: hansg, ilpo.jarvinen
Cc: krishna.chomal108, emreleno, edip, platform-driver-x86,
linux-kernel, Ilya Mukhamadeev
From: Ilya Mukhamadeev <nicourced@altlinux.org>
Some HP convertible laptops (e.g., ProBook x360 series) do not generate
ACPI events when switching between laptop and tablet mode, causing the
input subsystem to never receive SW_TABLET_MODE notifications.
Add a periodic delayed work that polls the tablet mode state every
second and reports changes via input_report_switch(). Track the last
known state to avoid sending duplicate events, and clean up the work
queue on module removal.
---
drivers/platform/x86/hp/hp-wmi.c | 35 +++++++++++++++++++++++++++++---
1 file changed, 32 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index 8ba286ed8721..5fbfdde3291a 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -460,6 +460,8 @@ static struct notifier_block platform_power_source_nb;
static enum platform_profile_option active_platform_profile;
static bool platform_profile_support;
static bool zero_insize_support;
+static int last_tablet_state = -1;
+static struct delayed_work tablet_mode_work;
static struct rfkill *wifi_rfkill;
static struct rfkill *bluetooth_rfkill;
@@ -1176,9 +1178,13 @@ static void hp_wmi_notify(union acpi_object *obj, void *context)
if (test_bit(SW_DOCK, hp_wmi_input_dev->swbit))
input_report_switch(hp_wmi_input_dev, SW_DOCK,
hp_wmi_get_dock_state());
- if (test_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit))
- input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
- hp_wmi_get_tablet_mode());
+ if (test_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit)) {
+ int tablet = hp_wmi_get_tablet_mode();
+ if (tablet >= 0) {
+ last_tablet_state = tablet;
+ input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, tablet);
+ }
+ }
input_sync(hp_wmi_input_dev);
break;
case HPWMI_PARK_HDD:
@@ -1271,6 +1277,24 @@ static void hp_wmi_notify(union acpi_object *obj, void *context)
}
}
+/*
+ * Periodically poll tablet mode state and send input events if changed.
+ * This works around missing ACPI events on some HP laptops.
+ */
+static void hp_wmi_tablet_mode_work_handler(struct work_struct *work)
+{
+ int cur = hp_wmi_get_tablet_mode();
+ if (cur >= 0 && cur != last_tablet_state) {
+ last_tablet_state = cur;
+ if (hp_wmi_input_dev && test_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit)) {
+ input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, cur);
+ input_sync(hp_wmi_input_dev);
+ pr_debug("Tablet mode changed to %d\n", cur);
+ }
+ }
+ schedule_delayed_work(&tablet_mode_work, msecs_to_jiffies(1000));
+}
+
static int __init hp_wmi_input_setup(void)
{
acpi_status status;
@@ -1298,6 +1322,9 @@ static int __init hp_wmi_input_setup(void)
if (!(val < 0)) {
__set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit);
input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val);
+ last_tablet_state = val;
+ INIT_DELAYED_WORK(&tablet_mode_work, hp_wmi_tablet_mode_work_handler);
+ schedule_delayed_work(&tablet_mode_work, msecs_to_jiffies(1000));
}
err = sparse_keymap_setup(hp_wmi_input_dev, hp_wmi_keymap, NULL);
@@ -1331,6 +1358,8 @@ static int __init hp_wmi_input_setup(void)
static void hp_wmi_input_destroy(void)
{
+ cancel_delayed_work_sync(&tablet_mode_work);
+ last_tablet_state = -1;
wmi_remove_notify_handler(HPWMI_EVENT_GUID);
input_unregister_device(hp_wmi_input_dev);
}
--
2.50.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-12 11:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12 11:33 [PATCH] platform/x86/hp/hp-wmi: Add periodic tablet mode poll nicourced
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox