Skip to content

RFC Nintendo Wii Remote Extension Hotplugging

David Herrmann linux-input 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest21 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21HID: wiimote: extend driver descriptiondrivers/hid/Kconfig drivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-debug.c +2 more+27 -110 replies
2/21HID: wiimote: move queue handling into separate structdrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote.h+38 -300 replies
3/21HID: wiimote: keep HID device opendrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-ext.c+11 -490 replies
4/21HID: wiimote: add device detectiondrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote.h+188 -20 replies
5/21HID: wiimote: use cached battery values on I/O failuredrivers/hid/hid-wiimote-core.c+7 -70 replies
6/21HID: wiimote: wake up if output queue faileddrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote.h+38 -50 replies
7/21HID: wiimote: add sub-device module infrastructuredrivers/hid/Makefile drivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-modules.c +1 more+194 -40 replies
8/21HID: wiimote: convert KEYS and RUMBLE to modulesdrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-modules.c drivers/hid/hid-wiimote.h+172 -1140 replies
9/21HID: wiimote: convert BATTERY to moduledrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-modules.c drivers/hid/hid-wiimote.h+104 -760 replies
10/21HID: wiimote: convert LEDS to modulesdrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-modules.c drivers/hid/hid-wiimote.h+158 -1120 replies
11/21HID: wiimote: convert ACCEL to moduledrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-modules.c drivers/hid/hid-wiimote.h+140 -860 replies
12/21HID: wiimote: convert IR to moduledrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-modules.c drivers/hid/hid-wiimote.h+287 -2120 replies
13/21HID: wiimote: add extension hotplug supportdrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-modules.c drivers/hid/hid-wiimote.h+655 -210 replies
14/21HID: wiimote: add Balance Board supportdrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-modules.c drivers/hid/hid-wiimote.h+243 -00 replies
15/21HID: wiimote: add Nunchuk supportdrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-modules.c drivers/hid/hid-wiimote.h+205 -00 replies
16/21HID: wiimote: add Classic Controller extensiondrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-modules.c drivers/hid/hid-wiimote.h+286 -00 replies
17/21HID: wiimote: add Motion Plus extension moduledrivers/hid/hid-wiimote-modules.c drivers/hid/hid-wiimote.h+145 -00 replies
18/21HID: wiimote: fix ctx pointer in debugfs DRM-writedrivers/hid/hid-wiimote-debug.c+2 -10 replies
19/21HID: wiimote: lock DRM mode during debugfs overwritedrivers/hid/hid-wiimote-core.c drivers/hid/hid-wiimote-debug.c drivers/hid/hid-wiimote.h+7 -10 replies
20/21HID: wiimote: add sysfs extension/device-type attrsdrivers/hid/hid-wiimote-core.c+105 -10 replies
21/21HID: wiimote: add "bboard_calib" attributedrivers/hid/hid-wiimote-modules.c+67 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC 00/21] Nintendo Wii Remote Extension Hotplugging

Hi

Last two month I sat down and started reverse-engineering the wiimote protocol again. My goal was to finally get reliable extension hotplugging. What I then ended up with was a huge Bluetooth-HID rewrite, a major hid-wiimote modularization and finally working extension hotplug support.

The patches in Detail:
- #1 to #6 are small fixes and initial device-detection logic. They are fairly simple and fix small issues I encountered.
- #7 to #12 move all the sub-device drivers into modules. This allows us to extend device detection and load only the sub-devices that are actually present. For instance, the Balance Board does only provide one LED so we should not register led #2-#4. Note that the balance board still emulates the other LEDs in the protocol so we wouldn't notice that they are not present if we didn't know.
- #13 to #17 implement extension hotplugging. Patch #13 extends the core to handle hotplugging and #14 to #17 implement the protocol parsers as modules so we can dynamically load different modules.
- #18 to #21 add sysfs attributes and contain small fixes

I know that the driver became pretty huge, but it currently contains an IR-camera driver, 4 accelerometer/gyro drivers, force-feedback driver, LED driver, weight-sensor driver and like 5 different button/joystick drivers. So considering that I think it's actually pretty small.

Another point is that I tried to be as conservative as possible. I tested this code with several 3rd-party devices and all of them ended up breaking at some point because they expect the exact Wii-Console behavior. I fixed everything I found but I need more input from users here. At least I don't break any devices that worked with the driver so far (as far as I know).

Also please don't merge it, yet. I still have to remove hid-wiimote-ext.c as it is no longer needed, but I haven't tested how this affects backwards-compatibility. I did my best to not break existing user-space, but I want to do some more tests. So if there are no comments on this series, I will resend in about 1 week with a ready-to-merge series. But I wanted to see whether anyone has issues with the patches, first.

Some sidenotes:
- Marcel already ACK'ed my Bluetooth HIDP rewrite which finally gives us working Bluetooth HID without any kernel oops. Gustavo is currently applying the patches. This series doesn't exactly depend on it, but you cannot test Bluetooth device hotplugging without it, because the kernel just breaks.
- I currently work on the "Wii U Pro Controller". It's similar to the Classic Controller and I hope I can include patches for it in the next revision.
- I also work on reverse-engineering the Wii U GamePad. It uses 5Ghz 802.11n instead of Bluetooth, but the Miracast (Wifi Display) protocol allows a separate HID stream side-by-side with the MPEG-4 video stream. So there might be a new hid_ll_driver in the future. However, I guess UHID will serve well for the beginning.

Last but not least I noticed that we duplicate the HID Boot Protocol in usbhid and Bluetooth HID. The Wifi-Display HID also provides some similar protocol. So I currently look into creating a hid-boot.c so we have a central place that implements it.

Cheers
David

David Herrmann (21):
HID: wiimote: extend driver description
HID: wiimote: move queue handling into separate struct
HID: wiimote: keep HID device open
HID: wiimote: add device detection
HID: wiimote: use cached battery values on I/O failure
HID: wiimote: wake up if output queue failed
HID: wiimote: add sub-device module infrastructure
HID: wiimote: convert KEYS and RUMBLE to modules
HID: wiimote: convert BATTERY to module
HID: wiimote: convert LEDS to modules
HID: wiimote: convert ACCEL to module
HID: wiimote: convert IR to module
HID: wiimote: add extension hotplug support
HID: wiimote: add Balance Board support
HID: wiimote: add Nunchuk support
HID: wiimote: add Classic Controller extension
HID: wiimote: add Motion Plus extension module
HID: wiimote: fix ctx pointer in debugfs DRM-write
HID: wiimote: lock DRM mode during debugfs overwrite
HID: wiimote: add sysfs extension/device-type attrs
HID: wiimote: add "bboard_calib" attribute

 drivers/hid/Kconfig               |   20 +-
 drivers/hid/Makefile              |    2 +-
 drivers/hid/hid-wiimote-core.c    | 1571 +++++++++++++++++++++------------
 drivers/hid/hid-wiimote-debug.c   |   10 +-
 drivers/hid/hid-wiimote-ext.c     |   16 +-
 drivers/hid/hid-wiimote-modules.c | 1717 +++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-wiimote.h         |  168 +++-
 7 files changed, 2925 insertions(+), 579 deletions(-)
 create mode 100644 drivers/hid/hid-wiimote-modules.c
Signature · 1 line
1.8.2.1