HID: ghlive: support for ghlive ps3/wii u dongles
PATCH 1/1 HID: ghlive: support for ghlive ps3/wii u dongles
This commit introduces the Guitar Hero Live driver which adds support for the PS3 and Wii U dongles.
These dongles require a "magic" USB control message [1] to be sent approximately every 10 seconds otherwise the dongle will not report events where the strumbar is hit while a fret is being held.
Also, inspired by a patch sent on linux-input by Sanjay Govind [2], the accelerometer is mapped to ABS_RY for tilt.
Interestingly, the Wii U and PS3 dongles share the same VID and PID.
[1] https://github.com/ghlre/GHLtarUtility/
[2] https://marc.info/?l=linux-input&m=157242835928542&w=2
--- drivers/hid/Kconfig | 6 ++ drivers/hid/Makefile | 1 + drivers/hid/hid-ghlive.c | 220 +++++++++++++++++++++++++++++++++++++++ drivers/hid/hid-ids.h | 3 + 4 files changed, 230 insertions(+) create mode 100644 drivers/hid/hid-ghlive.c
drivers/hid/Kconfig +6 -0
@@ -362,6 +362,12 @@ config HID_GFRM ---help--- Support for Google Fiber TV Box remote controls +config HID_GHLIVE + tristate "Guitar Hero Live PS3/Wii U support" + depends on HID + help + Support for the Guitar Hero Live PS3 and Wii U guitar devices. + config HID_GLORIOUS tristate "Glorious PC Gaming Race mice" depends on HID
drivers/hid/Makefile +1 -0
@@ -48,6 +48,7 @@ obj-$(CONFIG_HID_ELO) += hid-elo.o obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o obj-$(CONFIG_HID_GEMBIRD) += hid-gembird.o obj-$(CONFIG_HID_GFRM) += hid-gfrm.o +obj-$(CONFIG_HID_GHLIVE) += hid-ghlive.o obj-$(CONFIG_HID_GLORIOUS) += hid-glorious.o obj-$(CONFIG_HID_GOOGLE_HAMMER) += hid-google-hammer.o obj-$(CONFIG_HID_GT683R) += hid-gt683r.o
drivers/hid/hid-ghlive.c new file +220 -0
220 lines not on this page · raw message
drivers/hid/hid-ids.h +3 -0
@@ -1060,6 +1060,9 @@#define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002#define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000 +#define USB_VENDOR_ID_SONY_GHLIVE 0x12ba +#define USB_DEVICE_ID_SONY_PS3WIIU_GHLIVE_DONGLE 0x074b +#define USB_VENDOR_ID_SINO_LITE 0x1345#define USB_DEVICE_ID_SINO_LITE_CONTROLLER 0x3008
Signature · 1 line
2.28.0
Jiri Kosina
maintainerQuoted 2 lines · Pascal Giard
This commit introduces the Guitar Hero Live driver which adds support for the PS3 and Wii U dongles.
Pascal,
thanks for the patch.
[ ... snip ... ]
Quoted 4 lines
--- drivers/hid/Kconfig | 6 ++ drivers/hid/Makefile | 1 + drivers/hid/hid-ghlive.c | 220 +++++++++++++++++++++++++++++++++++++++
Would it make more sense (with respect to how we are structuring/naming the hid drivers) to incorporate this into hid-sony (irrespective of currently ongoing discussions about actually splitting that driver :) )?
Quoted 19 lines
drivers/hid/hid-ghlive.c new file +19
-0+static void ghl_magic_poke (struct timer_list *t) +{ +struct ghlive_sc *sc =from_timer (sc, t, poke_timer); + +int ret; +unsigned int pipe; +struct urb *urb; +struct usb_ctrlrequest *cr; +const u16 poke_size = +ARRAY_SIZE (ghl_ps3wiiu_magic_data); +u8 *databuf; + + pipe =usb_sndctrlpipe (sc->usbdev,0 ); + + cr =kzalloc (sizeof (*cr),GFP_ATOMIC ); +if (!cr) + goto resched; + + databuf =kzalloc (poke_size,GFP_ATOMIC );
drivers/hid/hid-ghlive.c line 81
Quoted 10 lines
drivers/hid/hid-ghlive.c new file +10
-0+if (!databuf) { +kfree (cr); + goto resched; + } + + urb =usb_alloc_urb (0 ,GFP_ATOMIC ); +if (!urb) { +kfree (databuf); +kfree (cr); + goto resched;
So if one of the allocations above succeeds and a subsequent one fails, you're going to try re-allocate all of them next time again, leaking the ones that previously succeeded, right?
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Quoted 10 lines · Jiri Kosina
Quoted 2 lines · Pascal Giard
This commit introduces the Guitar Hero Live driver which adds support for the PS3 and Wii U dongles.
Pascal,
thanks for the patch.
Dear Jiri,
thank you for reviewing my patch.
Quoted 11 lines
[ ... snip ... ]
Quoted 4 lines
--- drivers/hid/Kconfig | 6 ++ drivers/hid/Makefile | 1 + drivers/hid/hid-ghlive.c | 220 +++++++++++++++++++++++++++++++++++++++Would it make more sense (with respect to how we are structuring/naming the hid drivers) to incorporate this into hid-sony (irrespective of currently ongoing discussions about actually splitting that driver :) )?
I think it would be most appropriate, yes.
Note that there are 3 other dongles out there:
- the xbox360 dongle does not need any special treatment, it just works with hid-generic;
- the ps4 dongle obviously makes sense to go into hid-sony (although no one has reversed engineered that one (yet));
- the xboxone dongle: that's an unknown one to me. I don't have any information about that one unfortunately and do not own one.
I wrote this as a separate hid driver as I saw that email [1] from Roderick Colenbrander in which he expressed a preference for a seperate driver in cases where the device is not from Sony proper.
Quoted 26 lines
Quoted 26 lines
drivers/hid/hid-ghlive.c new file +26
-0+static void ghl_magic_poke (struct timer_list *t) +{ +struct ghlive_sc *sc =from_timer (sc, t, poke_timer); + +int ret; +unsigned int pipe; +struct urb *urb; +struct usb_ctrlrequest *cr; +const u16 poke_size = +ARRAY_SIZE (ghl_ps3wiiu_magic_data); +u8 *databuf; + + pipe =usb_sndctrlpipe (sc->usbdev,0 ); + + cr =kzalloc (sizeof (*cr),GFP_ATOMIC ); +if (!cr) + goto resched; + + databuf =kzalloc (poke_size,GFP_ATOMIC ); +if (!databuf) { +kfree (cr); + goto resched; + } + + urb =usb_alloc_urb (0 ,GFP_ATOMIC ); +if (!urb) {
Quoted 9 lines
drivers/hid/hid-ghlive.c line 81
Quoted 3 lines
drivers/hid/hid-ghlive.c new file +3
-0+kfree (databuf); +kfree (cr); + goto resched;So if one of the allocations above succeeds and a subsequent one fails, you're going to try re-allocate all of them next time again, leaking the ones that previously succeeded, right?
I attempted to avoid such a case. IIUC there are 4 possible scenarios tied to those 3 allocs (cr, databuf, and urb):
1) alloc of cr fails. nothing to be freed, we reschedule;
2) alloc of cr succeeds, alloc of databuf fails. we free cr and we reschedule;
3) allocs of cr and databuf succeed, alloc of urb fails. we free cr and databuf, and we reschedule;
4) all allocs succeed, we submit the urb, and free urb. once the control packet is sent, the callback is called and we free cr and databuf.
Am I missing something? It's VERY possible that I am as this is my first patch and I wrote this by looking at other peoples' code. The only thing that comes to mind is if poke is called again before the control packet actually gets sent (and the callback called), in which case I'm not sure what would happen. But with a poke interval of 10 seconds, is that probability close enough to 0 to be ignored?
Thanks again for your valuable input, :-)
-Pascal
[1] https://marc.info/?l=linux-input&m=157273970001101&w=2
Jiri Kosina
maintainerQuoted 19 lines · Pascal Giard
Quoted 8 lines
Quoted 3 lines
drivers/hid/Kconfig | 6 ++ drivers/hid/Makefile | 1 + drivers/hid/hid-ghlive.c | 220 +++++++++++++++++++++++++++++++++++++++Would it make more sense (with respect to how we are structuring/naming the hid drivers) to incorporate this into hid-sony (irrespective of currently ongoing discussions about actually splitting that driver :) )?
I think it would be most appropriate, yes.
Note that there are 3 other dongles out there:
- the xbox360 dongle does not need any special treatment, it just works with hid-generic;
- the ps4 dongle obviously makes sense to go into hid-sony (although no one has reversed engineered that one (yet));
- the xboxone dongle: that's an unknown one to me. I don't have any information about that one unfortunately and do not own one.
Quoted 3 lines
I wrote this as a separate hid driver as I saw that email [1] from Roderick Colenbrander in which he expressed a preference for a seperate driver in cases where the device is not from Sony proper.
Yeah, but before that happens, I think we should just continue with status quo, meaning putting the support into hid-sony, if noone has any objections.
Quoted 15 lines
Quoted 4 lines
So if one of the allocations above succeeds and a subsequent one fails, you're going to try re-allocate all of them next time again, leaking the ones that previously succeeded, right?
I attempted to avoid such a case. IIUC there are 4 possible scenarios tied to those 3 allocs (cr, databuf, and urb):
1) alloc of cr fails. nothing to be freed, we reschedule;
2) alloc of cr succeeds, alloc of databuf fails. we free cr and we reschedule;
3) allocs of cr and databuf succeed, alloc of urb fails. we free cr and databuf, and we reschedule;
4) all allocs succeed, we submit the urb, and free urb. once the control packet is sent, the callback is called and we free cr and databuf.
Quoted 1 line
Am I missing something?
No, I probably didn't have my first coffee of the day when looking at your patch, sorry.
Still, the way it tries to allocate the buffers is sub-optimal, as if either (not necessarily the first one) fails, it retries the next iteration with attempting to allocate from scratch.
If the system really is in tight memory condition, it'd make more sense to keep the ones for which the allocation succeeded already allocated, and retry only the failed one(s).
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
PATCH v2 1/1 HID: sony: support for ghlive ps3/wii u dongles
In reply to Pascal GiardThis commit adds support for the Guitar Hero Live PS3 and Wii U dongles.
These dongles require a "magic" USB control message [1] to be sent approximately every 10 seconds otherwise the dongle will not report events where the strumbar is hit while a fret is being held.
Also, inspired by a patch sent on linux-input by Sanjay Govind [2], the accelerometer is mapped to ABS_RY for tilt.
Interestingly, the Wii U and PS3 dongles share the same VID and PID.
[1] https://github.com/ghlre/GHLtarUtility/
[2] https://marc.info/?l=linux-input&m=157242835928542&w=2
---
differences from v1:
* Patches hid-sony instead of creating a new driver
* Changed memory allocation scheme in case of fail
--- drivers/hid/Kconfig | 1 + drivers/hid/hid-ids.h | 3 ++ drivers/hid/hid-sony.c | 115 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+)
drivers/hid/Kconfig +1 -0
@@ -897,6 +897,7 @@ config HID_SONY * Buzz controllers * Sony PS3 Blue-ray Disk Remote Control (Bluetooth) * Logitech Harmony adapter for Sony Playstation 3 (Bluetooth) + * Guitar Hero Live PS3 and Wii U guitar dongles config SONY_FF bool "Sony PS2/3/4 accessories force feedback support"
drivers/hid/hid-ids.h +3 -0
@@ -1060,6 +1060,9 @@#define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002#define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000 +#define USB_VENDOR_ID_SONY_GHLIVE 0x12ba +#define USB_DEVICE_ID_SONY_PS3WIIU_GHLIVE_DONGLE 0x074b +#define USB_VENDOR_ID_SINO_LITE 0x1345#define USB_DEVICE_ID_SINO_LITE_CONTROLLER 0x3008
drivers/hid/hid-sony.c +115 -0
175 lines not on this page · raw message
Signature · 1 line
2.29.2
Jiri Kosina
maintainerRe: [PATCH v2] HID: sony: support for ghlive ps3/wii u dongles
Quoted 73 lines · Pascal Giard
This commit adds support for the Guitar Hero Live PS3 and Wii U dongles.
These dongles require a "magic" USB control message [1] to be sent approximately every 10 seconds otherwise the dongle will not report events where the strumbar is hit while a fret is being held.
Also, inspired by a patch sent on linux-input by Sanjay Govind [2], the accelerometer is mapped to
ABS_RYfor tilt.Interestingly, the Wii U and PS3 dongles share the same VID and PID.
[1] https://github.com/ghlre/GHLtarUtility/
[2] https://marc.info/?l=linux-input&m=157242835928542&w=2Signed-off-by Pascal Giard <[email protected]>---
differences from v1:
* Patches hid-sony instead of creating a new driver
* Changed memory allocation scheme in case of fail--- drivers/hid/Kconfig | 1 + drivers/hid/hid-ids.h | 3 ++ drivers/hid/hid-sony.c | 115 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+)drivers/hid/Kconfig +1
-0@@ -897,6 +897,7 @@ config HID_SONY * Buzz controllers * Sony PS3 Blue-ray Disk Remote Control (Bluetooth) * Logitech Harmony adapter for Sony Playstation 3 (Bluetooth) + * Guitar Hero Live PS3 and Wii U guitar dongles config SONY_FF bool "Sony PS2/3/4 accessories force feedback support"drivers/hid/hid-ids.h +3
-0@@ -1060,6 +1060,9 @@#define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002#define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000 +#define USB_VENDOR_ID_SONY_GHLIVE 0x12ba +#define USB_DEVICE_ID_SONY_PS3WIIU_GHLIVE_DONGLE 0x074b +#define USB_VENDOR_ID_SINO_LITE 0x1345#define USB_DEVICE_ID_SINO_LITE_CONTROLLER 0x3008drivers/hid/hid-sony.c +3
-0@@ -11,6 +11,7 @@* Copyright (c) 2013 Colin Leitner <[email protected]> * Copyright (c) 2014-2016 Frank Praznik <[email protected]> * Copyright (c) 2018 Todd Kelner +* Copyright (c) 2020 Pascal Giard <[email protected]> */ /* @@ -35,6 +36,8 @@#include <linux/idr.h> #include <linux/input/mt.h> #include <linux/crc32.h> +#include <linux/usb.h> +#include <linux/timer.h> #include <asm/unaligned.h> #include "hid-ids.h"
drivers/hid/hid-sony.c line 63
Quoted 5 lines
drivers/hid/hid-sony.c +2
-0@@ -56,6 +59,8 @@#define NSG_MR5U_REMOTE_BT BIT(14)#define NSG_MR7U_REMOTE_BT BIT(15)#define SHANWAN_GAMEPAD BIT(16) +#define GHL_GUITAR_PS3WIIU BIT(17) +#define GHL_GUITAR_CONTROLLER BIT(18)
Hi Pascal,
thanks for fixing the previous version. This one looks good to me, I just have one remaining question -- why do we need both quirks here? Given the particular VID/PID gets both of them set anyway (and only that VID/PID), and the code is shared, what is the point of consuming the extra bit?
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
PATCH v3 1/1 HID: sony: support for ghlive ps3/wii u dongles
In reply to Pascal GiardThis commit adds support for the Guitar Hero Live PS3 and Wii U dongles.
These dongles require a "magic" USB control message [1] to be sent approximately every 10 seconds otherwise the dongle will not report events where the strumbar is hit while a fret is being held.
Also, inspired by a patch sent on linux-input by Sanjay Govind [2], the accelerometer is mapped to ABS_RY for tilt.
Interestingly, the Wii U and PS3 dongles share the same VID and PID.
[1] https://github.com/ghlre/GHLtarUtility/
[2] https://marc.info/?l=linux-input&m=157242835928542&w=2
---
Changes in v3:
* Only use one quirk as for now only the PS3/WiiU dongle is supported.
Changes in v2:
* Patches hid-sony instead of creating a new driver
* Changed memory allocation scheme in case of fail
--- drivers/hid/Kconfig | 1 + drivers/hid/hid-ids.h | 3 ++ drivers/hid/hid-sony.c | 112 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+)
drivers/hid/Kconfig +1 -0
@@ -898,6 +898,7 @@ config HID_SONY * Buzz controllers * Sony PS3 Blue-ray Disk Remote Control (Bluetooth) * Logitech Harmony adapter for Sony Playstation 3 (Bluetooth) + * Guitar Hero Live PS3 and Wii U guitar dongles config SONY_FF bool "Sony PS2/3/4 accessories force feedback support"
drivers/hid/hid-ids.h +3 -0
@@ -1064,6 +1064,9 @@#define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002#define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000 +#define USB_VENDOR_ID_SONY_GHLIVE 0x12ba +#define USB_DEVICE_ID_SONY_PS3WIIU_GHLIVE_DONGLE 0x074b +#define USB_VENDOR_ID_SINO_LITE 0x1345#define USB_DEVICE_ID_SINO_LITE_CONTROLLER 0x3008
drivers/hid/hid-sony.c +112 -0
172 lines not on this page · raw message
Signature · 1 line
2.29.2
Re: [PATCH v3] HID: sony: support for ghlive ps3/wii u dongles
Quoted 1 line · Pascal Giard
This commit adds support for the Guitar Hero Live PS3 and Wii U dongles.
Applied, thanks Pascal.
Signature · 2 lines
Jiri Kosina SUSE Labs