[PATCH v4 1/1] HID: hid-sony: Only allow four LED states

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Hanno Zulla <kontakt@xxxxxxxx>
Date: Fri, 7 Sep 2018 11:34:03 +0200
Subject: [PATCH] HID: hid-sony: Only allow four LED states to identify controller

The PS4 console only support four game controllers, while Linux
supports any number of game controller connected to it. The kernel
driver should  mirror the original console's behaviour here and
leave the use of additional LED colours to user space.

Signed-off-by: Hanno Zulla <kontakt@xxxxxxxx>
---
 drivers/hid/hid-sony.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 9671a4bad643..e13a9dcab964 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -1777,15 +1777,12 @@ static void sixaxis_set_leds_from_id(struct sony_sc *sc)
 
 static void dualshock4_set_leds_from_id(struct sony_sc *sc)
 {
-	/* The first 4 color/index entries match what the PS4 assigns */
-	static const u8 color_code[7][3] = {
+	/* The four color/index entries match what the PS4 assigns */
+	static const u8 color_code[4][3] = {
 			/* Blue   */	{ 0x00, 0x00, 0x40 },
-			/* Red	  */	{ 0x40, 0x00, 0x00 },
+			/* Red    */	{ 0x40, 0x00, 0x00 },
 			/* Green  */	{ 0x00, 0x40, 0x00 },
-			/* Pink   */	{ 0x20, 0x00, 0x20 },
-			/* Orange */	{ 0x02, 0x01, 0x00 },
-			/* Teal   */	{ 0x00, 0x01, 0x01 },
-			/* White  */	{ 0x01, 0x01, 0x01 }
+			/* Pink   */	{ 0x20, 0x00, 0x20 }
 	};
 
 	int id = sc->device_id;
@@ -1795,7 +1792,7 @@ static void dualshock4_set_leds_from_id(struct sony_sc *sc)
 	if (id < 0)
 		return;
 
-	id %= 7;
+	id %= 4;
 	memcpy(sc->led_state, color_code[id], sizeof(color_code[id]));
 }
 
-- 
2.17.1




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux