Skip to contentSkip to conversation

HID: santroller: add driver for Santroller controllers

PATCH New Sanjay Govind 1 participant 1 message Nov 15 HID

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 HID: santroller: add driver for Santroller controllers

Santroller is an open source firmware for DIY and modded game controllers and instruments: https://github.com/Santroller/Santroller

Santroller devices work like hubs: a user can connect several instruments and controllers to one device, and on USB each active profile appears as its own HID gamepad interface. On current firmware, each of these interfaces answers a vendor features report (usage 0xff00:0x2882) with the emulated controller type and a set of capability bits.

Santroller uses the pid.codes vendor ID 0x1209 and product IDs 0x2882 and 0x2883 for its v1 and v2 devices, respectively, over USB and Bluetooth.

Inputs are left to the generic HID input layer, as the report descriptor already describes the buttons, axes and d-pad. Since users name each profile, and on USB the firmware puts that name in the interface string, the driver uses it to name the input device, so each connected instrument or controller can be told apart.

The driver also handles the outputs the device reports supporting:
rumble, player LEDs, an RGB indicator LED and the euphoria LED of DJ Hero turntables.

The configuration interface and devices whose report descriptor lacks a matching input/output features report pair are left to hid-generic. Devices that advertise the pair but fail to answer are still connected as plain gamepads.

---
Tool assistance:
Copilot in VS Code assisted with the output retry change. The player LED and Kconfig fixes and this changelog were written with the help of Claude Opus 5.5.

Changes since v3:
- Retry failed output reports up to three times, 20 ms apart, refreshing the command from current state under the driver lock before each retry, so a transient send failure no longer loses a rumble stop or LED update. Stop on -ENODEV, -ESHUTDOWN or disabled output.
- Track lit player LEDs in a driver-owned mask updated from the value passed to brightness_set, instead of reading led_classdev.brightness, which the LED core does not update when a software blink is stopped during its on phase (Sashiko).
- Make HID_SANTROLLER depend on USB_HID || !USB_HID, so USB profile naming is not silently compiled out with HID_SANTROLLER=y and USB_HID=m (Sashiko).
- Initialise the RGB LED colour intensities to full, so writing only brightness lights it white instead of sending 0,0,0 until multi_intensity is written (Sashiko).

Changes since v2:
- Track feature-report responses under the driver lock, accept only the first reply while discovery is pending, and ignore late replies once discovery has finished.
- Require matching input and output features reports; validate the input report ID/type before accepting capabilities.
- Serialize RGB component calculation and state copying. Initialize the RGB LED at brightness zero, matching its zero-valued color components.
- Preserve pending rumble work across resume and skip LED restoration if no registered input device exists. Validate the saved input against the registered hid-input list after hid_connect() before using it.
- Initialize player LED state before registering LEDs so an early userspace update is not overwritten.
- Do not expose force feedback when the euphoria LED capability is present, because turntables use the rumble command for that LED.
- Guard USB profile naming with IS_REACHABLE(CONFIG_USB_HID), keeping Bluetooth-only builds free of an unresolved USB HID reference.
- Use heap-backed storage for the feature query because USB transports may DMA the buffer. Distinguish local allocation failure from transport errors, stop retrying when the device is gone, and return zero on a successful query. Add a short wait after transient send errors to avoid exhausting retries immediately.

Testing:
- v4: built and linked hid-santroller.ko with W=1 against 7.2.11-arch1-1, no warnings. The output retry was exercised with fault injection of -EIO into the output worker in a userspace harness using the driver's worker functions, under ASan and UBSan. The LED blink case was found by reading drivers/leds/led-core.c.
- v4 hardware testing with a USB drumtroller (1209:2883) against 7.2.11-arch1-1: the driver binds to each gamepad interface and registers force feedback and four player LEDs. FF_RUMBLE effects uploaded through evdev rumble the device on each interface with no output report errors. The player indicator follows the lowest lit player LED, falls back when it is turned off, and turns off when all are off. Stopping a timer-triggered blink during its on phase now turns the indicator off. The RGB and euphoria LEDs, including the RGB intensity default, were not tested, as this device does not report them.
- Built hid-santroller.o with W=1 and linked hid-santroller.ko with W=1 using the built multicolor LED symbol exports required for modpost.
- Checkpatch reported no errors; its one warning is for the existing -ENOSYS check.
- A prior draft was rebound on hardware and input was verified; that test was not repeated after the cumulative changes in this revision. Earlier v2 LED and rumble tests were also not repeated.

Previous versions:
v3: https://lore.kernel.org/linux-input/[email protected]/
v2: https://lore.kernel.org/linux-input/[email protected]/
v1: https://lore.kernel.org/linux-input/[email protected]/

---
 MAINTAINERS                  |   6 +
 drivers/hid/Kconfig          |  13 +
 drivers/hid/Makefile         |   1 +
 drivers/hid/hid-ids.h        |   4 +
 drivers/hid/hid-santroller.c | 717 +++++++++++++++++++++++++++++++++++
 5 files changed, 741 insertions(+)
 create mode 100644 drivers/hid/hid-santroller.c
MAINTAINERS +6 -0
index 4a69da715c58..028c8f7f40fa 100644
@@ -11703,6 +11703,12 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/hid/hid-pulsar.c
 
+HID SANTROLLER DRIVER
+M:	Sanjay Govind <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/hid/hid-santroller.c
+
 HID SENSOR HUB DRIVERS
 M:	Jiri Kosina <[email protected]>
 M:	Jonathan Cameron <[email protected]>
drivers/hid/Kconfig +13 -0
index 2481bc01c435..85e9a8db06cc 100644
@@ -1138,6 +1138,19 @@ config HID_SAMSUNG
 	help
 	Support for Samsung InfraRed remote control or keyboards.
 
+config HID_SANTROLLER
+	tristate "Santroller game controller support"
+	depends on USB_HID || !USB_HID
+	depends on LEDS_CLASS_MULTICOLOR
+	select INPUT_FF_MEMLESS
+	help
+	  Support for game controllers and instruments running the Santroller
+	  firmware, including rumble, player LEDs, the RGB indicator LED and
+	  the DJ Hero turntable euphoria LED.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called hid-santroller.
+
 config HID_SEMITEK
 	tristate "Semitek USB keyboards"
 	help
drivers/hid/Makefile +1 -0
index 43a8eb0f389b..afe88185289b 100644
@@ -131,6 +131,7 @@ obj-$(CONFIG_HID_ROCCAT)	+= hid-roccat.o hid-roccat-common.o \
 obj-$(CONFIG_HID_RMI)		+= hid-rmi.o
 obj-$(CONFIG_HID_SAITEK)	+= hid-saitek.o
 obj-$(CONFIG_HID_SAMSUNG)	+= hid-samsung.o
+obj-$(CONFIG_HID_SANTROLLER)	+= hid-santroller.o
 obj-$(CONFIG_HID_SEMITEK)	+= hid-semitek.o
 obj-$(CONFIG_HID_SIGMAMICRO)	+= hid-sigmamicro.o
 obj-$(CONFIG_HID_SMARTJOYPLUS)	+= hid-sjoy.o
drivers/hid/hid-ids.h +4 -0
index 91319aa6516d..ed3940cd36cd 100644
@@ -1216,6 +1216,10 @@
 #define USB_VENDOR_ID_PHILIPS		0x0471
 #define USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE 0x0617
 
+#define USB_VENDOR_ID_PID_CODES		0x1209
+#define USB_DEVICE_ID_SANTROLLER	0x2882
+#define USB_DEVICE_ID_SANTROLLER_V2	0x2883
+
 #define USB_VENDOR_ID_PI_ENGINEERING	0x05f3
 #define USB_DEVICE_ID_PI_ENGINEERING_VEC_USB_FOOTPEDAL	0xff
 
drivers/hid/hid-santroller.c new file +717 -0

717 lines not on this page · raw message

Signature · 1 line
2.56.0