Skip to content

HID: Add Legion Go and Go S Drivers

Derek J. Clark linux-doc linux-input lkml 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest19 patches 4 repliesIn review
  2. v516 patches 3 repliesSuperseded
  3. v416 patches 0 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v316 patches1 replySuperseded
v216 patches6 repliesSuperseded
v16 patches4 repliesSuperseded

Changes in v6 from the cover letter · 36 lines

- Include multiple bug fixes from Ethan Tidmore.
- Make all local attributes static.
- Invert the rgb_speed logic for the go driver. On the Go this
attribute sets a delay, so flip the logic to match Go S where the
larger number means faster so userspace can target this consistently.
- Include 3 new patches that fix formatting issues with v5 authored by additional developers.
v5: https://lore.kernel.org/linux-input/[email protected]/
- Make all RO attributes cache the data during probe using delayed
work for both drivers. All RW attributes are read in realtime to
ensure they match the device current state in the event of firmware reset or a userspace application.
- Fix endianness of version strings and print as hex for Go driver.
- Remove reset__esume function. It was not being hit as the MCU of
both devices disconnects of suspend, forcing a reinit of the driver. Udev or userpsace will need to set the OS Mode upon resume.
v4: https://lore.kernel.org/linux-input/[email protected]/
- Use dmabuf allocated per request for both drivers instead of a devm preallocated buffer that is reused. This solves a bug where some attributes couldn't be restored without manual writing after resume.
- Reduce the number of quirks and flags in the Go S init to only those necessary. Previously they were duplicated from the Go driver but everything except HID_CONNECT_HIDRAW was found to be unnessary
during operational testing.
- Clean up formatting for debug prints in Go S driver.
- Fix bugs in RGB driver for Go that caused the effect to switch to
solid when the speed or brightness was changed.
- Remove extraneous setting of os_mode member of drvdata when setting os_mode. It will be read from the hardware in _show.
v3: https://lore.kernel.org/linux-input/[email protected]/
- Fix Documentation formatting by removing extra + characters.
- Fix bugs in hid-lenovo-go-s IMU & TP RO attributes being tied to the wrong _show function.
- Rename enume os_mode_index to os_mode_types_index to fix collision
with os_mode_index attribute.
- Remove accidental rename for enabled->enable attributes in patch 4
- Add SOB for Mario in patch 10 as Co-Developer.
v2: https://lore.kernel.org/linux-input/[email protected]/
- Break up adding the Go S driver into feature specific patches.
- Rename Go S driver from lenovo-legos-hid to hid-lenovo-go-s and move
it out of a subdirectory.
- Drop the arbitrary uevent properties patch.
- Add Go series driver.
- Move DEVICE_ATTR_NAMED macros to device.h.
v1: https://lore.kernel.org/linux-input/[email protected]/

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19include: device.h: Add named device attributesinclude/linux/device.h+46 -00 replies
2/19HID: hid-lenovo-go: Add Lenovo Legion Go Series HID DriverMAINTAINERS drivers/hid/Kconfig drivers/hid/Makefile +2 more+938 -00 replies
3/19HID: hid-lenovo-go: Add Feature Status Attributesdrivers/hid/hid-lenovo-go.c+395 -10 replies
4/19HID: hid-lenovo-go: Add Rumble and Haptic Settingsdrivers/hid/hid-lenovo-go.c+312 -00 replies
5/19HID: hid-lenovo-go: Add FPS Mode DPI settingsdrivers/hid/hid-lenovo-go.c+68 -00 replies
6/19HID: hid-lenovo-go: Add RGB LED control interfacedrivers/hid/hid-lenovo-go.c+429 -00 replies
7/19HID: hid-lenovo-go: Add Calibration Settingsdrivers/hid/hid-lenovo-go.c+283 -10 replies
8/19HID: hid-lenovo-go: Add OS Mode Toggledrivers/hid/hid-lenovo-go.c+101 -00 replies
9/19HID: Include firmware version in the ueventdrivers/hid/hid-core.c include/linux/hid.h+6 -00 replies
10/19HID: hid-lenovo-go-s: Add Lenovo Legion Go S Series HID DriverMAINTAINERS drivers/hid/Kconfig drivers/hid/Makefile +2 more+296 -00 replies
11/19HID: hid-lenovo-go-s: Add MCU ID Attributedrivers/hid/hid-lenovo-go-s.c+56 -00 replies
12/19HID: hid-lenovo-go-s: Add Feature Status Attributesdrivers/hid/hid-lenovo-go-s.c+483 -10 replies
13/19HID: hid-lenovo-go-s: Add Touchpad Mode Attributesdrivers/hid/hid-lenovo-go-s.c+142 -00 replies
14/19HID: hid-lenovo-go-s: Add RGB LED control interfacedrivers/hid/hid-lenovo-go-s.c+422 -00 replies
15/19HID: hid-lenovo-go-s: Add IMU and Touchpad RO Attributesdrivers/hid/hid-lenovo-go-s.c+124 -00 replies
16/19HID: Add documentation for Lenovo Legion Go driversDocumentation/ABI/testing/sysfs-driver-hid-lenovo-go Documentation/ABI/testing/sysfs-driver-hid-lenovo-go-s MAINTAINERS+1030 -03 replies
17/19HID: hid-lenovo-go-s: Remove unneeded semicolondrivers/hid/hid-lenovo-go-s.c+1 -10 replies
18/19HID: hid-lenovo-go: Remove unneeded semicolondrivers/hid/hid-lenovo-go.c+26 -260 replies
19/19HID: hid-lenovo-go-s: Fix spelling mistake "configuratiion" -> "configuration"drivers/hid/hid-lenovo-go-s.c+1 -10 replies

Reviews trailers per patch

All 19 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMark PearsonGreg Kroah-HartmanDerek J. Clark
SeriesR-b
1/19R-b A-b
2/19R-b
3/19R-b
4/19R-b
5/19R-b
6/19R-b
7/19R-b
8/19R-b
9/19R-b R-b
10/19R-b
11/19R-b
12/19R-b
13/19R-b
14/19R-b
15/19R-b
16/19R-b
17/19R-b R-b
18/19R-b
19/19R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v6 thread

Cover letter [PATCH v6 00/19] HID: Add Legion Go and Go S Drivers

This series adds configuration driver support for the Legion Go S, Legion Go, and Legion Go 2 built-in controller HID interfaces. This allows for configuring hardware specific attributes such as the auso sleep timeout, rumble intensity, etc. non-configuration reports are forwarded to the HID subsystem to ensure no loss of functionality in userspace. Basic gamepad functionality is provided through xpad, while advanced features are currently only implemented in userspace daemons such as InputPlumber[1]. I plan to move this functionality into the kernel in a later patch series.

Three new device.h macros are added that solve a fairly specific problem. Many of the attributes need to have the same name as other attributes when they are in separate attribute subdirectories. The previous version of this series, along with the upcoming his-asus-ally driver[2] use this macro to simplify the sysfs by removing redundancy. An upcoming out of tree driver for the Zotac Zone [3] also found this macro to be useful. This greatly reduces the path length and term redundancy of file paths in the sysfs, while also allowing for cleaner subdirectories that are grouped by functionality. Rather than carry the same macro in four drivers, it seems beneficial to me that we include the macro with the other device macros.

A new HID uevent property is also added, HID_FIRMWARE_VERSION, so as to permit fwupd to read the firmware version of the Go S HID interface without detaching the kernel driver.

Finally, there are some checkpatch warnings that will need to be supressed:
WARNING: ENOSYS means 'invalid syscall nr' and nothing else 1292: FILE: drivers/hid/lenovo-legos-hid/lenovo-legos-hid-config.c:1085:
+ case -ENOSYS: /* during rmmod -ENOSYS is expected */

This error handling case was added as it is experienced in the real world when the driver is rmmod. The LED subsystem produces this error code in its legacy code and this is not a new novel use of -ENOSYS, we are simply catching the case to avoid spurious errors in dmesg when the drivers are removed.

[1]: https://github.com/ShadowBlip/InputPlumber/tree/main/src/drivers/lego
[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://github.com/flukejones/linux/tree/wip/zotac-zone-6.15/drivers/hid/zotac-zone-hid

---
Change Log
v6:
- Include multiple bug fixes from Ethan Tidmore.
- Make all local attributes static.
- Invert the rgb_speed logic for the go driver. On the Go this
attribute sets a delay, so flip the logic to match Go S where the
larger number means faster so userspace can target this consistently.
- Include 3 new patches that fix formatting issues with v5 authored by additional developers.
v5: https://lore.kernel.org/linux-input/[email protected]/
- Make all RO attributes cache the data during probe using delayed
work for both drivers. All RW attributes are read in realtime to
ensure they match the device current state in the event of firmware reset or a userspace application.
- Fix endianness of version strings and print as hex for Go driver.
- Remove reset__esume function. It was not being hit as the MCU of
both devices disconnects of suspend, forcing a reinit of the driver. Udev or userpsace will need to set the OS Mode upon resume.
v4: https://lore.kernel.org/linux-input/[email protected]/
- Use dmabuf allocated per request for both drivers instead of a devm preallocated buffer that is reused. This solves a bug where some attributes couldn't be restored without manual writing after resume.
- Reduce the number of quirks and flags in the Go S init to only those necessary. Previously they were duplicated from the Go driver but everything except HID_CONNECT_HIDRAW was found to be unnessary
during operational testing.
- Clean up formatting for debug prints in Go S driver.
- Fix bugs in RGB driver for Go that caused the effect to switch to
solid when the speed or brightness was changed.
- Remove extraneous setting of os_mode member of drvdata when setting os_mode. It will be read from the hardware in _show.
v3: https://lore.kernel.org/linux-input/[email protected]/
- Fix Documentation formatting by removing extra + characters.
- Fix bugs in hid-lenovo-go-s IMU & TP RO attributes being tied to the wrong _show function.
- Rename enume os_mode_index to os_mode_types_index to fix collision
with os_mode_index attribute.
- Remove accidental rename for enabled->enable attributes in patch 4
- Add SOB for Mario in patch 10 as Co-Developer.
v2: https://lore.kernel.org/linux-input/[email protected]/
- Break up adding the Go S driver into feature specific patches.
- Rename Go S driver from lenovo-legos-hid to hid-lenovo-go-s and move
it out of a subdirectory.
- Drop the arbitrary uevent properties patch.
- Add Go series driver.
- Move DEVICE_ATTR_NAMED macros to device.h.
v1: https://lore.kernel.org/linux-input/[email protected]/

Chen Ni (2):
HID: hid-lenovo-go-s: Remove unneeded semicolon
HID: hid-lenovo-go: Remove unneeded semicolon

Colin Ian King (1):
HID: hid-lenovo-go-s: Fix spelling mistake "configuratiion" ->
"configuration"

Derek J. Clark (15):
include: device.h: Add named device attributes
HID: hid-lenovo-go: Add Lenovo Legion Go Series HID Driver
HID: hid-lenovo-go: Add Feature Status Attributes
HID: hid-lenovo-go: Add Rumble and Haptic Settings
HID: hid-lenovo-go: Add FPS Mode DPI settings
HID: hid-lenovo-go: Add RGB LED control interface
HID: hid-lenovo-go: Add Calibration Settings
HID: hid-lenovo-go: Add OS Mode Toggle
HID: hid-lenovo-go-s: Add Lenovo Legion Go S Series HID Driver
HID: hid-lenovo-go-s: Add MCU ID Attribute
HID: hid-lenovo-go-s: Add Feature Status Attributes
HID: hid-lenovo-go-s: Add Touchpad Mode Attributes
HID: hid-lenovo-go-s: Add RGB LED control interface
HID: hid-lenovo-go-s: Add IMU and Touchpad RO Attributes
HID: Add documentation for Lenovo Legion Go drivers

Mario Limonciello (1):
HID: Include firmware version in the uevent

 .../ABI/testing/sysfs-driver-hid-lenovo-go    |  724 +++++
 .../ABI/testing/sysfs-driver-hid-lenovo-go-s  |  304 ++
 MAINTAINERS                                   |   11 +
 drivers/hid/Kconfig                           |   24 +
 drivers/hid/Makefile                          |    2 +
 drivers/hid/hid-core.c                        |    5 +
 drivers/hid/hid-ids.h                         |    7 +
 drivers/hid/hid-lenovo-go-s.c                 | 1506 ++++++++++
 drivers/hid/hid-lenovo-go.c                   | 2502 +++++++++++++++++
 include/linux/device.h                        |   46 +
 include/linux/hid.h                           |    1 +
 11 files changed, 5132 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-hid-lenovo-go
 create mode 100644 Documentation/ABI/testing/sysfs-driver-hid-lenovo-go-s
 create mode 100644 drivers/hid/hid-lenovo-go-s.c
 create mode 100644 drivers/hid/hid-lenovo-go.c
Signature · 1 line
2.53.0