aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoderick Colenbrander <roderick.colenbrander@sony.com>2016-12-08 22:09:52 -0500
committerJiri Kosina <jkosina@suse.cz>2016-12-19 09:07:37 -0500
commit405182c2459fe2de4a3994ef39e866993e0e61d1 (patch)
tree9a5869dd32a4feef8e5d8ca2451ba3454a6f127f
parentc70d5f70ccbbdf56bb86adb42127db90d0c90976 (diff)
HID: sony: Ignore DS4 dongle reports when no device is connected
When the DS4 dongle is connected, it always generates HID reports even when no DS4 is paired to it. This patch adds logic to ignore HID reports from the dongle if there is no DS4 currently attached. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-sony.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index c6982a29a56d..f405b07d0381 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -1099,8 +1099,11 @@ struct sony_sc {
1099 u8 led_delay_on[MAX_LEDS]; 1099 u8 led_delay_on[MAX_LEDS];
1100 u8 led_delay_off[MAX_LEDS]; 1100 u8 led_delay_off[MAX_LEDS];
1101 u8 led_count; 1101 u8 led_count;
1102 bool ds4_dongle_connected;
1102}; 1103};
1103 1104
1105static void sony_set_leds(struct sony_sc *sc);
1106
1104static inline void sony_schedule_work(struct sony_sc *sc) 1107static inline void sony_schedule_work(struct sony_sc *sc)
1105{ 1108{
1106 if (!sc->defer_initialization) 1109 if (!sc->defer_initialization)
@@ -1430,6 +1433,31 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
1430 return -EILSEQ; 1433 return -EILSEQ;
1431 } 1434 }
1432 } 1435 }
1436
1437 /*
1438 * In the case of a DS4 USB dongle, bit[2] of byte 31 indicates
1439 * if a DS4 is actually connected (indicated by '0').
1440 * For non-dongle, this bit is always 0 (connected).
1441 */
1442 if (sc->hdev->vendor == USB_VENDOR_ID_SONY &&
1443 sc->hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) {
1444 bool connected = (rd[31] & 0x04) ? false : true;
1445
1446 if (!sc->ds4_dongle_connected && connected) {
1447 hid_info(sc->hdev, "DualShock 4 USB dongle: controller connected\n");
1448 sony_set_leds(sc);
1449 sc->ds4_dongle_connected = true;
1450 } else if (sc->ds4_dongle_connected && !connected) {
1451 hid_info(sc->hdev, "DualShock 4 USB dongle: controller disconnected\n");
1452 sc->ds4_dongle_connected = false;
1453 /* Return 0, so hidraw can get the report. */
1454 return 0;
1455 } else if (!sc->ds4_dongle_connected) {
1456 /* Return 0, so hidraw can get the report. */
1457 return 0;
1458 }
1459 }
1460
1433 dualshock4_parse_report(sc, rd, size); 1461 dualshock4_parse_report(sc, rd, size);
1434 } 1462 }
1435 1463