Skip to content

Commit 854a958

Browse files
author
Jiri Kosina
committed
Merge branch 'for-5.15/sony' into for-linus
- Support for GHLive PS4 dongles
2 parents 163a312 + a4bfe13 commit 854a958

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

drivers/hid/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ config HID_SONY
953953
* Buzz controllers
954954
* Sony PS3 Blue-ray Disk Remote Control (Bluetooth)
955955
* Logitech Harmony adapter for Sony Playstation 3 (Bluetooth)
956-
* Guitar Hero Live PS3 and Wii U guitar dongles
956+
* Guitar Hero Live PS3, Wii U and PS4 guitar dongles
957957
* Guitar Hero PS3 and PC guitar dongles
958958

959959
config SONY_FF

drivers/hid/hid-ids.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
#define USB_VENDOR_ID_ACTIONSTAR 0x2101
4242
#define USB_DEVICE_ID_ACTIONSTAR_1011 0x1011
4343

44-
#define USB_VENDOR_ID_ACTIVISION 0x1430
45-
#define USB_DEVICE_ID_ACTIVISION_GUITAR_DONGLE 0x474c
46-
4744
#define USB_VENDOR_ID_ADS_TECH 0x06e1
4845
#define USB_DEVICE_ID_ADS_TECH_RADIO_SI470X 0xa155
4946

@@ -1020,6 +1017,10 @@
10201017
#define USB_VENDOR_ID_REALTEK 0x0bda
10211018
#define USB_DEVICE_ID_REALTEK_READER 0x0152
10221019

1020+
#define USB_VENDOR_ID_REDOCTANE 0x1430
1021+
#define USB_DEVICE_ID_REDOCTANE_GUITAR_DONGLE 0x474c
1022+
#define USB_DEVICE_ID_REDOCTANE_PS4_GHLIVE_DONGLE 0x07bb
1023+
10231024
#define USB_VENDOR_ID_RETROUSB 0xf000
10241025
#define USB_DEVICE_ID_RETROUSB_SNES_RETROPAD 0x0003
10251026
#define USB_DEVICE_ID_RETROUSB_SNES_RETROPORT 0x00f1

drivers/hid/hid-sony.c

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
* Copyright (c) 2013 Colin Leitner <[email protected]>
1212
* Copyright (c) 2014-2016 Frank Praznik <[email protected]>
1313
* Copyright (c) 2018 Todd Kelner
14-
* Copyright (c) 2020 Pascal Giard <[email protected]>
14+
* Copyright (c) 2020-2021 Pascal Giard <[email protected]>
1515
* Copyright (c) 2020 Sanjay Govind <[email protected]>
16+
* Copyright (c) 2021 Daniel Nguyen <[email protected]>
1617
*/
1718

1819
/*
@@ -62,6 +63,7 @@
6263
#define SHANWAN_GAMEPAD BIT(16)
6364
#define GH_GUITAR_CONTROLLER BIT(17)
6465
#define GHL_GUITAR_PS3WIIU BIT(18)
66+
#define GHL_GUITAR_PS4 BIT(19)
6567

6668
#define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT)
6769
#define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT)
@@ -85,18 +87,27 @@
8587
#define NSG_MRXU_MAX_X 1667
8688
#define NSG_MRXU_MAX_Y 1868
8789

88-
#define GHL_GUITAR_POKE_INTERVAL 10 /* In seconds */
90+
/* The PS3/Wii U dongles require a poke every 10 seconds, but the PS4
91+
* requires one every 8 seconds. Using 8 seconds for all for simplicity.
92+
*/
93+
#define GHL_GUITAR_POKE_INTERVAL 8 /* In seconds */
8994
#define GUITAR_TILT_USAGE 44
9095

91-
/* Magic value and data taken from GHLtarUtility:
96+
/* Magic data taken from GHLtarUtility:
9297
* https://github.com/ghlre/GHLtarUtility/blob/master/PS3Guitar.cs
9398
* Note: The Wii U and PS3 dongles happen to share the same!
9499
*/
95-
static const u16 ghl_ps3wiiu_magic_value = 0x201;
96100
static const char ghl_ps3wiiu_magic_data[] = {
97101
0x02, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00
98102
};
99103

104+
/* Magic data for the PS4 dongles sniffed with a USB protocol
105+
* analyzer.
106+
*/
107+
static const char ghl_ps4_magic_data[] = {
108+
0x30, 0x02, 0x08, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00
109+
};
110+
100111
/* PS/3 Motion controller */
101112
static u8 motion_rdesc[] = {
102113
0x05, 0x01, /* Usage Page (Desktop), */
@@ -642,14 +653,14 @@ static void ghl_magic_poke(struct timer_list *t)
642653
hid_err(sc->hdev, "usb_submit_urb failed: %d", ret);
643654
}
644655

645-
static int ghl_init_urb(struct sony_sc *sc, struct usb_device *usbdev)
656+
static int ghl_init_urb(struct sony_sc *sc, struct usb_device *usbdev,
657+
const char ghl_magic_data[], u16 poke_size)
646658
{
647659
struct usb_ctrlrequest *cr;
648-
u16 poke_size;
649660
u8 *databuf;
650661
unsigned int pipe;
662+
u16 ghl_magic_value = (((HID_OUTPUT_REPORT + 1) << 8) | ghl_magic_data[0]);
651663

652-
poke_size = ARRAY_SIZE(ghl_ps3wiiu_magic_data);
653664
pipe = usb_sndctrlpipe(usbdev, 0);
654665

655666
cr = devm_kzalloc(&sc->hdev->dev, sizeof(*cr), GFP_ATOMIC);
@@ -663,10 +674,10 @@ static int ghl_init_urb(struct sony_sc *sc, struct usb_device *usbdev)
663674
cr->bRequestType =
664675
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT;
665676
cr->bRequest = USB_REQ_SET_CONFIGURATION;
666-
cr->wValue = cpu_to_le16(ghl_ps3wiiu_magic_value);
677+
cr->wValue = cpu_to_le16(ghl_magic_value);
667678
cr->wIndex = 0;
668679
cr->wLength = cpu_to_le16(poke_size);
669-
memcpy(databuf, ghl_ps3wiiu_magic_data, poke_size);
680+
memcpy(databuf, ghl_magic_data, poke_size);
670681
usb_fill_control_urb(
671682
sc->ghl_urb, usbdev, pipe,
672683
(unsigned char *) cr, databuf, poke_size,
@@ -3031,11 +3042,17 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
30313042
return -ENODEV;
30323043
}
30333044

3034-
if (sc->quirks & GHL_GUITAR_PS3WIIU) {
3045+
if (sc->quirks & (GHL_GUITAR_PS3WIIU | GHL_GUITAR_PS4)) {
30353046
sc->ghl_urb = usb_alloc_urb(0, GFP_ATOMIC);
30363047
if (!sc->ghl_urb)
30373048
return -ENOMEM;
3038-
ret = ghl_init_urb(sc, usbdev);
3049+
3050+
if (sc->quirks & GHL_GUITAR_PS3WIIU)
3051+
ret = ghl_init_urb(sc, usbdev, ghl_ps3wiiu_magic_data,
3052+
ARRAY_SIZE(ghl_ps3wiiu_magic_data));
3053+
else if (sc->quirks & GHL_GUITAR_PS4)
3054+
ret = ghl_init_urb(sc, usbdev, ghl_ps4_magic_data,
3055+
ARRAY_SIZE(ghl_ps4_magic_data));
30393056
if (ret) {
30403057
hid_err(hdev, "error preparing URB\n");
30413058
return ret;
@@ -3053,7 +3070,7 @@ static void sony_remove(struct hid_device *hdev)
30533070
{
30543071
struct sony_sc *sc = hid_get_drvdata(hdev);
30553072

3056-
if (sc->quirks & GHL_GUITAR_PS3WIIU) {
3073+
if (sc->quirks & (GHL_GUITAR_PS3WIIU | GHL_GUITAR_PS4)) {
30573074
del_timer_sync(&sc->ghl_poke_timer);
30583075
usb_free_urb(sc->ghl_urb);
30593076
}
@@ -3173,11 +3190,14 @@ static const struct hid_device_id sony_devices[] = {
31733190
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY_RHYTHM, USB_DEVICE_ID_SONY_PS3WIIU_GHLIVE_DONGLE),
31743191
.driver_data = GHL_GUITAR_PS3WIIU | GH_GUITAR_CONTROLLER },
31753192
/* Guitar Hero PC Guitar Dongle */
3176-
{ HID_USB_DEVICE(USB_VENDOR_ID_ACTIVISION, USB_DEVICE_ID_ACTIVISION_GUITAR_DONGLE),
3193+
{ HID_USB_DEVICE(USB_VENDOR_ID_REDOCTANE, USB_DEVICE_ID_REDOCTANE_GUITAR_DONGLE),
31773194
.driver_data = GH_GUITAR_CONTROLLER },
31783195
/* Guitar Hero PS3 World Tour Guitar Dongle */
31793196
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY_RHYTHM, USB_DEVICE_ID_SONY_PS3_GUITAR_DONGLE),
31803197
.driver_data = GH_GUITAR_CONTROLLER },
3198+
/* Guitar Hero Live PS4 guitar dongles */
3199+
{ HID_USB_DEVICE(USB_VENDOR_ID_REDOCTANE, USB_DEVICE_ID_REDOCTANE_PS4_GHLIVE_DONGLE),
3200+
.driver_data = GHL_GUITAR_PS4 | GH_GUITAR_CONTROLLER },
31813201
{ }
31823202
};
31833203
MODULE_DEVICE_TABLE(hid, sony_devices);

0 commit comments

Comments
 (0)