From: Helge Bahmann <hcb@chaoticmind.net>
To: Jiri Kosina <jikos@kernel.org>,
linux-input@vger.kernel.org, Basavaraj Natikar <bnatikar@amd.com>
Cc: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Subject: [PATCH 2/2] amd-sfh-tabletmode: interpret sfh tablet mode hid report
Date: Tue, 21 Jul 2026 16:29:56 +0200 [thread overview]
Message-ID: <14202195.uLZWGnKmhe@zephyr> (raw)
In-Reply-To: <ecadaac8-e222-420a-ac5b-4d529fb3317e@amd.com>
Add a driver that hooks into the tablet mode hid reports
generated by the amd-sfh-hid driver. This enables tablet
mode switching on e.g. Asus Vivobook devices.
Signed-off-by: Helge Bahmann <hcb@chaoticmind.net>
---
drivers/input/misc/Kconfig | 11 ++++
drivers/input/misc/Makefile | 1 +
drivers/input/misc/amd_sfh_tabletmode.c | 88 +++++++++++++++++++++++++
3 files changed, 100 insertions(+)
create mode 100644 drivers/input/misc/amd_sfh_tabletmode.c
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 94a753fcb64f..5a1dacd6f7b9 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -1003,4 +1003,15 @@ config INPUT_STPMIC1_ONKEY
To compile this driver as a module, choose M here: the
module will be called stpmic1_onkey.
+config INPUT_AMD_SFH_TABLETMODE
+ tristate "AMD sensor fusion hub tablet mode driver"
+ help
+ Say Y to enable support of the tablet mode switch driver for
+ convertible laptops based on the AMD sensor fusion hub. This
+ driver is known to work on Asus VivoBook but will likely
+ work on other laptops featuring the same chipset.
+
+ To compile this driver as a module, choose M here: the
+ module will be called amd_sfh_tabletmode.
+
endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 415fc4e2918b..3f5abbe39f3a 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -96,3 +96,4 @@ obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o
obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o
obj-$(CONFIG_INPUT_YEALINK) += yealink.o
obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR) += ideapad_slidebar.o
+obj-$(CONFIG_INPUT_AMD_SFH_TABLETMODE) += amd_sfh_tabletmode.o
diff --git a/drivers/input/misc/amd_sfh_tabletmode.c b/drivers/input/misc/amd_sfh_tabletmode.c
new file mode 100644
index 000000000000..ee1207372207
--- /dev/null
+++ b/drivers/input/misc/amd_sfh_tabletmode.c
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * AMD MP2 PCIe tablet mode hid input driver
+ * Copyright 2026 Helge Bahmann Advanced Micro Devices, Inc.
+ * Authors: Helge Bahmann <hcb@chaoticmind.net>
+ */
+
+#include <linux/hid.h>
+#include <linux/module.h>
+
+#define AMD_SFH_HID_VENDOR 0x1022
+#define AMD_SFH_HID_PRODUCT 0x0001
+
+static int amd_sfh_tabletmode_probe(struct hid_device *hdev,
+ const struct hid_device_id *id)
+{
+ int error = 0;
+
+ error = hid_parse(hdev);
+ if (error)
+ return error;
+
+ error = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+ if (error)
+ return error;
+
+ return 0;
+}
+
+static void amd_sfh_tabletmode_remove(struct hid_device *hdev)
+{
+ hid_hw_stop(hdev);
+}
+
+static int amd_sfh_tabletmode_input_mapping(struct hid_device *hdev, struct hid_input *hi,
+ struct hid_field *field, struct hid_usage *usage,
+ unsigned long **bit, int *max)
+{
+ if ((usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER && (usage->hid & HID_USAGE) == 0x02ff) {
+ input_set_capability(hi->input, EV_SW, SW_TABLET_MODE);
+ usage->type = EV_SW;
+ usage->code = SW_TABLET_MODE;
+ return 1;
+ }
+ return 0;
+}
+
+static int amd_sfh_tabletmode_event(struct hid_device *hid, struct hid_field *field,
+ struct hid_usage *usage, __s32 value)
+{
+ input_report_switch(field->hidinput->input, SW_TABLET_MODE, value);
+
+ return 0;
+}
+
+static const struct hid_device_id amd_sfh_tabletmode_devices[] = {
+ { HID_DEVICE(BUS_AMD_SFH, HID_GROUP_GENERIC, AMD_SFH_HID_VENDOR, AMD_SFH_HID_PRODUCT) },
+ { }
+};
+MODULE_DEVICE_TABLE(hid, amd_sfh_tabletmode_devices);
+
+static struct hid_driver amd_sfh_tabletmode_driver = {
+ .name = "amd_sfh_tabletmode",
+ .id_table = amd_sfh_tabletmode_devices,
+ .probe = amd_sfh_tabletmode_probe,
+ .remove = amd_sfh_tabletmode_remove,
+ .input_mapping = amd_sfh_tabletmode_input_mapping,
+ .event = amd_sfh_tabletmode_event,
+};
+
+static int __init amd_sfh_tabletmode_init(void)
+{
+ int error;
+
+ error = hid_register_driver(&amd_sfh_tabletmode_driver);
+
+ return error;
+}
+module_init(amd_sfh_tabletmode_init);
+
+static void __exit amd_sfh_tabletmode_exit(void)
+{
+ hid_unregister_driver(&amd_sfh_tabletmode_driver);
+}
+module_exit(amd_sfh_tabletmode_exit);
+
+MODULE_DESCRIPTION("Input driver for tablet mode sensor on amd sfh.");
+MODULE_LICENSE("GPL");
--
2.47.3
next prev parent reply other threads:[~2026-07-21 14:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 6:22 [PATCH] amd-sfh-hid: tablet mode switch and asus quirk Helge Bahmann
2026-05-12 16:06 ` Jiri Kosina
2026-05-12 17:09 ` Basavaraj Natikar
2026-05-14 7:59 ` Helge Bahmann
2026-06-10 17:12 ` Basavaraj Natikar
2026-06-12 4:22 ` Helge Bahmann
2026-07-21 14:28 ` [PATCH 0/2] asus vivobook tablet mode Helge Bahmann
2026-07-21 17:52 ` Basavaraj Natikar
2026-07-21 14:29 ` [PATCH 1/2] amd-sfh-hid: tablet mode hid report and asus quirk Helge Bahmann
2026-07-21 14:47 ` sashiko-bot
2026-07-21 14:29 ` Helge Bahmann [this message]
2026-07-21 14:41 ` [PATCH 2/2] amd-sfh-tabletmode: interpret sfh tablet mode hid report sashiko-bot
2026-06-10 16:33 ` [PATCH] amd-sfh-hid: tablet mode switch and asus quirk Jiri Kosina
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=14202195.uLZWGnKmhe@zephyr \
--to=hcb@chaoticmind.net \
--cc=Basavaraj.Natikar@amd.com \
--cc=bnatikar@amd.com \
--cc=jikos@kernel.org \
--cc=linux-input@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.