hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/hid/hid-sony.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * HID driver for Sony / PS2 / PS3 / PS4 BD devices.
34 *
....@@ -13,10 +14,6 @@
1314 */
1415
1516 /*
16
- * This program is free software; you can redistribute it and/or modify it
17
- * under the terms of the GNU General Public License as published by the Free
18
- * Software Foundation; either version 2 of the License, or (at your option)
19
- * any later version.
2017 */
2118
2219 /*
....@@ -58,6 +55,7 @@
5855 #define FUTUREMAX_DANCE_MAT BIT(13)
5956 #define NSG_MR5U_REMOTE_BT BIT(14)
6057 #define NSG_MR7U_REMOTE_BT BIT(15)
58
+#define SHANWAN_GAMEPAD BIT(16)
6159
6260 #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT)
6361 #define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT)
....@@ -1511,6 +1509,7 @@
15111509 */
15121510 static int sixaxis_set_operational_usb(struct hid_device *hdev)
15131511 {
1512
+ struct sony_sc *sc = hid_get_drvdata(hdev);
15141513 const int buf_size =
15151514 max(SIXAXIS_REPORT_0xF2_SIZE, SIXAXIS_REPORT_0xF5_SIZE);
15161515 u8 *buf;
....@@ -1540,14 +1539,15 @@
15401539
15411540 /*
15421541 * But the USB interrupt would cause SHANWAN controllers to
1543
- * start rumbling non-stop.
1542
+ * start rumbling non-stop, so skip step 3 for these controllers.
15441543 */
1545
- if (strcmp(hdev->name, "SHANWAN PS3 GamePad")) {
1546
- ret = hid_hw_output_report(hdev, buf, 1);
1547
- if (ret < 0) {
1548
- hid_info(hdev, "can't set operational mode: step 3, ignoring\n");
1549
- ret = 0;
1550
- }
1544
+ if (sc->quirks & SHANWAN_GAMEPAD)
1545
+ goto out;
1546
+
1547
+ ret = hid_hw_output_report(hdev, buf, 1);
1548
+ if (ret < 0) {
1549
+ hid_info(hdev, "can't set operational mode: step 3, ignoring\n");
1550
+ ret = 0;
15511551 }
15521552
15531553 out:
....@@ -2118,9 +2118,14 @@
21182118 }
21192119 }
21202120
2121
- hid_hw_raw_request(sc->hdev, report->report_id, (u8 *)report,
2122
- sizeof(struct sixaxis_output_report),
2123
- HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
2121
+ /* SHANWAN controllers require output reports via intr channel */
2122
+ if (sc->quirks & SHANWAN_GAMEPAD)
2123
+ hid_hw_output_report(sc->hdev, (u8 *)report,
2124
+ sizeof(struct sixaxis_output_report));
2125
+ else
2126
+ hid_hw_raw_request(sc->hdev, report->report_id, (u8 *)report,
2127
+ sizeof(struct sixaxis_output_report),
2128
+ HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
21242129 }
21252130
21262131 static void dualshock4_send_output_report(struct sony_sc *sc)
....@@ -2842,6 +2847,9 @@
28422847 if (!strcmp(hdev->name, "FutureMax Dance Mat"))
28432848 quirks |= FUTUREMAX_DANCE_MAT;
28442849
2850
+ if (!strcmp(hdev->name, "SHANWAN PS3 GamePad"))
2851
+ quirks |= SHANWAN_GAMEPAD;
2852
+
28452853 sc = devm_kzalloc(&hdev->dev, sizeof(*sc), GFP_KERNEL);
28462854 if (sc == NULL) {
28472855 hid_err(hdev, "can't alloc sony descriptor\n");