From: "Derek J. Clark" <derekjohn.clark@gmail.com>
To: Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <bentiss@kernel.org>
Cc: Mario Limonciello <mario.limonciello@amd.com>,
Zhixin Zhang <zhangzx36@lenovo.com>,
Mia Shao <shaohz1@lenovo.com>,
Mark Pearson <mpearson-lenovo@squebb.ca>,
"Pierre-Loup A . Griffais" <pgriffais@valvesoftware.com>,
"Derek J . Clark" <derekjohn.clark@gmail.com>,
linux-input@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v3 13/16] HID: hid-lenovo-go-s: Add Touchpad Mode Attributes
Date: Sat, 24 Jan 2026 01:49:04 +0000 [thread overview]
Message-ID: <20260124014907.991265-14-derekjohn.clark@gmail.com> (raw)
In-Reply-To: <20260124014907.991265-1-derekjohn.clark@gmail.com>
Adds attributes for managing the touchpad operating modes.
Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
---
drivers/hid/hid-lenovo-go-s.c | 142 ++++++++++++++++++++++++++++++++++
1 file changed, 142 insertions(+)
diff --git a/drivers/hid/hid-lenovo-go-s.c b/drivers/hid/hid-lenovo-go-s.c
index 076afdaa9628..38425e3d6cb2 100644
--- a/drivers/hid/hid-lenovo-go-s.c
+++ b/drivers/hid/hid-lenovo-go-s.c
@@ -47,6 +47,8 @@ struct hid_gos_cfg {
u8 os_mode;
u8 rgb_en;
u8 tp_en;
+ u8 tp_linux_mode;
+ u8 tp_windows_mode;
} drvdata;
struct gos_cfg_attr {
@@ -145,6 +147,22 @@ static const char *const dpad_mode_text[] = {
[DIR4] = "4-way",
};
+enum touchpad_mode_index {
+ TP_REL,
+ TP_ABS,
+};
+
+static const char *const touchpad_mode_text[] = {
+ [TP_REL] = "relative",
+ [TP_ABS] = "absolute",
+};
+
+enum touchpad_config_index {
+ CFG_WINDOWS_MODE = 0x03,
+ CFG_LINUX_MODE,
+
+};
+
static int hid_gos_version_event(u8 *data)
{
struct version_report *ver_rep = (struct version_report *)data;
@@ -204,6 +222,25 @@ static int hid_gos_gamepad_cfg_event(struct command_report *cmd_rep)
return ret;
}
+static int hid_gos_touchpad_event(struct command_report *cmd_rep)
+{
+ int ret = 0;
+
+ switch (cmd_rep->sub_cmd) {
+ case CFG_LINUX_MODE:
+ drvdata.tp_linux_mode = cmd_rep->data[0];
+ break;
+ case CFG_WINDOWS_MODE:
+ drvdata.tp_windows_mode = cmd_rep->data[0];
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
static int hid_gos_set_event_return(struct command_report *cmd_rep)
{
if (cmd_rep->data[0] != 0)
@@ -251,7 +288,11 @@ static int hid_gos_raw_event(struct hid_device *hdev, struct hid_report *report,
case GET_GAMEPAD_CFG:
ret = hid_gos_gamepad_cfg_event(cmd_rep);
break;
+ case GET_TP_PARAM:
+ ret = hid_gos_touchpad_event(cmd_rep);
+ break;
case SET_GAMEPAD_CFG:
+ case SET_TP_PARAM:
ret = hid_gos_set_event_return(cmd_rep);
break;
default:
@@ -537,6 +578,95 @@ static ssize_t gamepad_property_options(struct device *dev,
return count;
}
+static ssize_t touchpad_property_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count,
+ enum touchpad_config_index index)
+{
+ size_t size = 1;
+ u8 val = 0;
+ int ret;
+
+ switch (index) {
+ case CFG_WINDOWS_MODE:
+ ret = sysfs_match_string(touchpad_mode_text, buf);
+ if (ret < 0)
+ return ret;
+ val = ret;
+ break;
+ case CFG_LINUX_MODE:
+ ret = sysfs_match_string(touchpad_mode_text, buf);
+ if (ret < 0)
+ return ret;
+ val = ret;
+ break;
+ default:
+ return -EINVAL;
+ }
+ if (!val)
+ size = 0;
+
+ ret = mcu_property_out(drvdata.hdev, SET_TP_PARAM, index, &val, size);
+ if (ret < 0)
+ return ret;
+
+ return count;
+}
+
+static ssize_t touchpad_property_show(struct device *dev,
+ struct device_attribute *attr, char *buf,
+ enum touchpad_config_index index)
+{
+ int ret = 0;
+ u8 i;
+
+ ret = mcu_property_out(drvdata.hdev, GET_TP_PARAM, index, 0, 0);
+ if (ret < 0)
+ return ret;
+
+ switch (index) {
+ case CFG_WINDOWS_MODE:
+ i = drvdata.tp_windows_mode;
+ break;
+ case CFG_LINUX_MODE:
+ i = drvdata.tp_linux_mode;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (i >= ARRAY_SIZE(touchpad_mode_text))
+ return -EINVAL;
+
+ return sysfs_emit(buf, "%s\n", touchpad_mode_text[i]);
+}
+
+static ssize_t touchpad_property_options(struct device *dev,
+ struct device_attribute *attr,
+ char *buf,
+ enum touchpad_config_index index)
+{
+ size_t count = 0;
+ unsigned int i;
+
+ switch (index) {
+ case CFG_WINDOWS_MODE:
+ case CFG_LINUX_MODE:
+ for (i = 0; i < ARRAY_SIZE(touchpad_mode_text); i++) {
+ count += sysfs_emit_at(buf, count, "%s ",
+ touchpad_mode_text[i]);
+ }
+ break;
+ default:
+ return count;
+ }
+
+ if (count)
+ buf[count - 1] = '\n';
+
+ return count;
+}
+
static ssize_t mcu_id_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -666,9 +796,21 @@ struct gos_cfg_attr touchpad_enabled = { FEATURE_TOUCHPAD_ENABLE };
LEGOS_DEVICE_ATTR_RW(touchpad_enabled, "enabled", index, gamepad);
static DEVICE_ATTR_RO_NAMED(touchpad_enabled_index, "enabled_index");
+struct gos_cfg_attr touchpad_linux_mode = { CFG_LINUX_MODE };
+LEGOS_DEVICE_ATTR_RW(touchpad_linux_mode, "linux_mode", index, touchpad);
+static DEVICE_ATTR_RO_NAMED(touchpad_linux_mode_index, "linux_mode_index");
+
+struct gos_cfg_attr touchpad_windows_mode = { CFG_WINDOWS_MODE };
+LEGOS_DEVICE_ATTR_RW(touchpad_windows_mode, "windows_mode", index, touchpad);
+static DEVICE_ATTR_RO_NAMED(touchpad_windows_mode_index, "windows_mode_index");
+
static struct attribute *legos_touchpad_attrs[] = {
&dev_attr_touchpad_enabled.attr,
&dev_attr_touchpad_enabled_index.attr,
+ &dev_attr_touchpad_linux_mode.attr,
+ &dev_attr_touchpad_linux_mode_index.attr,
+ &dev_attr_touchpad_windows_mode.attr,
+ &dev_attr_touchpad_windows_mode_index.attr,
NULL,
};
--
2.52.0
next prev parent reply other threads:[~2026-01-24 1:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-24 1:48 [PATCH v3 00/16] HID: Add Legion Go and Go S Drivers Derek J. Clark
2026-01-24 1:48 ` [PATCH v3 01/16] include: device.h: Add named device attributes Derek J. Clark
2026-01-24 1:48 ` [PATCH v3 02/16] HID: hid-lenovo-go: Add Lenovo Legion Go Series HID Driver Derek J. Clark
2026-01-24 1:48 ` [PATCH v3 03/16] HID: hid-lenovo-go: Add Feature Status Attributes Derek J. Clark
2026-01-24 1:48 ` [PATCH v3 04/16] HID: hid-lenovo-go: Add Rumble and Haptic Settings Derek J. Clark
2026-01-24 1:48 ` [PATCH v3 05/16] HID: hid-lenovo-go: Add FPS Mode DPI settings Derek J. Clark
2026-01-24 1:48 ` [PATCH v3 06/16] HID: hid-lenovo-go: Add RGB LED control interface Derek J. Clark
2026-01-24 1:48 ` [PATCH v3 07/16] HID: hid-lenovo-go: Add Calibration Settings Derek J. Clark
2026-01-24 1:48 ` [PATCH v3 08/16] HID: hid-lenovo-go: Add OS Mode Toggle Derek J. Clark
2026-01-24 1:49 ` [PATCH v3 09/16] HID: Include firmware version in the uevent Derek J. Clark
2026-01-24 1:49 ` [PATCH v3 10/16] HID: hid-lenovo-go-s: Add Lenovo Legion Go S Series HID Driver Derek J. Clark
2026-01-24 1:49 ` [PATCH v3 11/16] HID: hid-lenovo-go-s: Add MCU ID Attribute Derek J. Clark
2026-01-24 1:49 ` [PATCH v3 12/16] HID: hid-lenovo-go-s: Add Feature Status Attributes Derek J. Clark
2026-01-24 1:49 ` Derek J. Clark [this message]
2026-01-24 1:49 ` [PATCH v3 14/16] HID: hid-lenovo-go-s: Add RGB LED control interface Derek J. Clark
2026-01-24 1:49 ` [PATCH v3 15/16] HID: hid-lenovo-go-s: Add IMU and Touchpad RO Attributes Derek J. Clark
2026-01-24 1:49 ` [PATCH v3 16/16] HID: Add documentation for Lenovo Legion Go drivers Derek J. Clark
2026-01-26 0:53 ` [PATCH v3 00/16] HID: Add Legion Go and Go S Drivers Mark Pearson
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=20260124014907.991265-14-derekjohn.clark@gmail.com \
--to=derekjohn.clark@gmail.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mpearson-lenovo@squebb.ca \
--cc=pgriffais@valvesoftware.com \
--cc=shaohz1@lenovo.com \
--cc=zhangzx36@lenovo.com \
/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