Skip to content

Commit 4545ee0

Browse files
mungewellJiri Kosina
authored andcommitted
HID: hid-sony: Navigation controller only has 1 LED and no rumble
Signed-off-by: Simon Wood <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 6eabaaa commit 4545ee0

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

drivers/hid/hid-sony.c

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,20 @@
4848
#define DUALSHOCK4_CONTROLLER_BT BIT(6)
4949
#define MOTION_CONTROLLER_USB BIT(7)
5050
#define MOTION_CONTROLLER_BT BIT(8)
51+
#define NAVIGATION_CONTROLLER_USB BIT(9)
52+
#define NAVIGATION_CONTROLLER_BT BIT(10)
5153

5254
#define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT)
5355
#define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT)
56+
#define NAVIGATION_CONTROLLER (NAVIGATION_CONTROLLER_USB |\
57+
NAVIGATION_CONTROLLER_BT)
5458
#define DUALSHOCK4_CONTROLLER (DUALSHOCK4_CONTROLLER_USB |\
5559
DUALSHOCK4_CONTROLLER_BT)
5660
#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\
57-
DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER)
61+
DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER |\
62+
NAVIGATION_CONTROLLER)
5863
#define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\
59-
MOTION_CONTROLLER_BT)
64+
MOTION_CONTROLLER_BT | NAVIGATION_CONTROLLER)
6065
#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\
6166
MOTION_CONTROLLER)
6267

@@ -1052,6 +1057,9 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
10521057
if (sc->quirks & MOTION_CONTROLLER)
10531058
return motion_fixup(hdev, rdesc, rsize);
10541059

1060+
if (sc->quirks & NAVIGATION_CONTROLLER)
1061+
return sixaxis_fixup(hdev, rdesc, rsize);
1062+
10551063
if (sc->quirks & PS3REMOTE)
10561064
return ps3remote_fixup(hdev, rdesc, rsize);
10571065

@@ -1181,6 +1189,9 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
11811189
sixaxis_parse_report(sc, rd, size);
11821190
} else if ((sc->quirks & MOTION_CONTROLLER_BT) && rd[0] == 0x01 && size == 49) {
11831191
sixaxis_parse_report(sc, rd, size);
1192+
} else if ((sc->quirks & NAVIGATION_CONTROLLER) && rd[0] == 0x01 &&
1193+
size == 49) {
1194+
sixaxis_parse_report(sc, rd, size);
11841195
} else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 &&
11851196
size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT)
11861197
&& rd[0] == 0x11 && size == 78)) {
@@ -1591,6 +1602,15 @@ static int sony_leds_init(struct sony_sc *sc)
15911602
use_ds4_names = 1;
15921603
name_len = 0;
15931604
name_fmt = "%s:%s";
1605+
} else if (sc->quirks & NAVIGATION_CONTROLLER) {
1606+
static const __u8 navigation_leds[4] = {0x01, 0x00, 0x00, 0x00};
1607+
1608+
memcpy(sc->led_state, navigation_leds, sizeof(navigation_leds));
1609+
sc->led_count = 1;
1610+
memset(use_hw_blink, 1, 4);
1611+
use_ds4_names = 0;
1612+
name_len = strlen("::sony#");
1613+
name_fmt = "%s::sony%d";
15941614
} else {
15951615
sixaxis_set_leds_from_id(sc);
15961616
sc->led_count = 4;
@@ -1782,7 +1802,8 @@ static void motion_state_worker(struct work_struct *work)
17821802

17831803
static int sony_allocate_output_report(struct sony_sc *sc)
17841804
{
1785-
if (sc->quirks & SIXAXIS_CONTROLLER)
1805+
if ((sc->quirks & SIXAXIS_CONTROLLER) ||
1806+
(sc->quirks & NAVIGATION_CONTROLLER))
17861807
sc->output_report_dmabuf =
17871808
kmalloc(sizeof(union sixaxis_output_report_01),
17881809
GFP_KERNEL);
@@ -2001,6 +2022,7 @@ static int sony_check_add(struct sony_sc *sc)
20012022

20022023
if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) ||
20032024
(sc->quirks & MOTION_CONTROLLER_BT) ||
2025+
(sc->quirks & NAVIGATION_CONTROLLER_BT) ||
20042026
(sc->quirks & SIXAXIS_CONTROLLER_BT)) {
20052027
/*
20062028
* sony_get_bt_devaddr() attempts to parse the Bluetooth MAC
@@ -2033,7 +2055,8 @@ static int sony_check_add(struct sony_sc *sc)
20332055
}
20342056

20352057
memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address));
2036-
} else if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
2058+
} else if ((sc->quirks & SIXAXIS_CONTROLLER_USB) ||
2059+
(sc->quirks & NAVIGATION_CONTROLLER_USB)) {
20372060
buf = kmalloc(SIXAXIS_REPORT_0xF2_SIZE, GFP_KERNEL);
20382061
if (!buf)
20392062
return -ENOMEM;
@@ -2167,7 +2190,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
21672190
goto err_stop;
21682191
}
21692192

2170-
if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
2193+
if ((sc->quirks & SIXAXIS_CONTROLLER_USB) ||
2194+
(sc->quirks & NAVIGATION_CONTROLLER_USB)) {
21712195
/*
21722196
* The Sony Sixaxis does not handle HID Output Reports on the
21732197
* Interrupt EP like it could, so we need to force HID Output
@@ -2182,7 +2206,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
21822206
hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID;
21832207
ret = sixaxis_set_operational_usb(hdev);
21842208
sony_init_work(sc, sixaxis_state_worker);
2185-
} else if (sc->quirks & SIXAXIS_CONTROLLER_BT) {
2209+
} else if ((sc->quirks & SIXAXIS_CONTROLLER_BT) ||
2210+
(sc->quirks & NAVIGATION_CONTROLLER_BT)) {
21862211
/*
21872212
* The Sixaxis wants output reports sent on the ctrl endpoint
21882213
* when connected via Bluetooth.
@@ -2286,9 +2311,9 @@ static const struct hid_device_id sony_devices[] = {
22862311
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
22872312
.driver_data = SIXAXIS_CONTROLLER_USB },
22882313
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER),
2289-
.driver_data = SIXAXIS_CONTROLLER_USB },
2314+
.driver_data = NAVIGATION_CONTROLLER_USB },
22902315
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER),
2291-
.driver_data = SIXAXIS_CONTROLLER_BT },
2316+
.driver_data = NAVIGATION_CONTROLLER_BT },
22922317
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER),
22932318
.driver_data = MOTION_CONTROLLER_USB },
22942319
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER),

0 commit comments

Comments
 (0)