LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Fun with sony motion controllers: navigation controller
@ 2015-03-14 19:19 Pavel Machek
  2015-03-14 19:23 ` Fun with sony motion controllers: motion controller Pavel Machek
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Pavel Machek @ 2015-03-14 19:19 UTC (permalink / raw)
  To: vojtech, mike-,
	jslaby, dave, jikos, colin.leitner, frank.praznik, kernel list,
	linux-input

Hi!

After oopsing kernel with ps/3 peripherals, I decided to play some
more.

First "sony motion controller" (part of ps/3 move without the
led). Good news is that it no longer oopses. After pressing the PS
button, it seems to work, but it produces endless stream of events in
evtest:

Event: time 1426360519.967818, type 3 (EV_ABS), code 0 (ABS_X), value 131
Event: time 1426360519.967818, type 3 (EV_ABS), code 1 (ABS_Y), value 129
Event: time 1426360519.967818, type 3 (EV_ABS), code 59 (ABS_MT_DISTANCE), value 513
Event: time 1426360519.967818, type 3 (EV_ABS), code 60 (ABS_MT_TOOL_X), value 513

Should it really produce multitouch events?

Force feedback does not seem to work:

root@amd:~# fftest /dev/input/event7
Force feedback test program.
HOLD FIRMLY YOUR WHEEL OR JOYSTICK TO PREVENT DAMAGES

Device /dev/input/event7 opened
Features:
  * Absolute axes: X, Y, Z, RZ, Misc ,
      [27 00 00 00 00 FF FF 7F ]
  * Relative axes:
	    [00 00 ]
  * Force feedback effects types:
   Force feedback periodic effects:
     [00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ]
  * Number of simultaneous effects: 0

Uploading effect #0 (Periodic sinusoidal) ... Error:: Function not implemented
Uploading effect #1 (Constant) ... Error: Function not implemented
Uploading effect #2 (Spring) ... Error: Function not implemented
Uploading effect #3 (Damper) ... Error: Function not implemented
Uploading effect #4 (Strong rumble, with heavy motor) ... Error: Function not implemented
Uploading effect #5 (Weak rumble, with light motor) ... Error: Function not implemented
Enter effect number, -1 to exit

Battery status reporting seems to work. Unfortunately, desktop (Mate on
Debian 8) seems to think it is system battery, and acts funny.

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Fun with sony motion controllers: motion controller
  2015-03-14 19:19 Fun with sony motion controllers: navigation controller Pavel Machek
@ 2015-03-14 19:23 ` Pavel Machek
  2015-03-14 20:53   ` Pavel Machek
  2015-03-14 19:31 ` Fun with sony motion controllers: dualshock Pavel Machek
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Pavel Machek @ 2015-03-14 19:23 UTC (permalink / raw)
  To: vojtech, mike-,
	jslaby, dave, jikos, colin.leitner, frank.praznik, kernel list,
	linux-input

Hi!

Second "sony motion controller" (part of ps/3 move with the big
LED). The LED is something I'd really like to work.

It is detected:

[  741.363723] input: Sony Computer Entertainment Motion Controller as
/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1:1.0/0003:054C:03D5.000A/input/input19
[  741.421269] hid-generic 0003:054C:03D5.000A: input,hiddev0,hidraw0:
USB HID v1.10 Gamepad [Sony Computer Entertainment Motion Controller]
on usb-0000:00:1d.0-1/input0

root@amd:~# evtest /dev/input/event7
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x54c product 0x3d5 version 0x110
Input device name: "Sony Computer Entertainment Motion Controller"
Supported events:
  Event type 0 (EV_SYN)
    Event type 1 (EV_KEY)
...
Properties:
Testing ... (interrupt to exit)

But no matter what I do, I don't get any events in evtest, or any
changes in jstest.

/sys/class/power_supply does not appear and /sys/class/leds does not
change.

Is this controller supported at all? What interface should be used for
talking to the RGB LED?

Yes, I'd really like the LED to work. The rest would be nice bonus.

									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Fun with sony motion controllers: dualshock
  2015-03-14 19:19 Fun with sony motion controllers: navigation controller Pavel Machek
  2015-03-14 19:23 ` Fun with sony motion controllers: motion controller Pavel Machek
@ 2015-03-14 19:31 ` Pavel Machek
  2015-03-14 19:47 ` Fun with sony motion controllers: navigation controller Pavel Machek
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Pavel Machek @ 2015-03-14 19:31 UTC (permalink / raw)
  To: vojtech, mike-,
	jslaby, dave, jikos, colin.leitner, frank.praznik, kernel list,
	linux-input

Hi!

After oopsing kernel with ps/3 peripherals, I decided to play some
more.

Third, regular controller. The one you don't have to dance with.

/sys/class/power_supply/*/capacity works.

again, evtest reports funny-looking multitouch events:

Event: time 1426361100.640824, -------------- EV_SYN ------------
Event: time 1426361100.650827, type 3 (EV_ABS), code 59
(ABS_MT_DISTANCE), value 506
Event: time 1426361100.650827, -------------- EV_SYN ------------
Event: time 1426361100.660827, type 3 (EV_ABS), code 5 (ABS_RZ), value
127
Event: time 1426361100.660827, -------------- EV_SYN ------------

...but seems to work. I even have 4 new leds that work. Unfortunately
they are small and not colorful.

Aha, force feedback needs CONFIG_SONY_FF. Setting it now. Did not have
it for previous mails.

Best regards,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Fun with sony motion controllers: navigation controller
  2015-03-14 19:19 Fun with sony motion controllers: navigation controller Pavel Machek
  2015-03-14 19:23 ` Fun with sony motion controllers: motion controller Pavel Machek
  2015-03-14 19:31 ` Fun with sony motion controllers: dualshock Pavel Machek
@ 2015-03-14 19:47 ` Pavel Machek
  2015-03-14 20:54 ` [PATCH] hid-sony: underscores are unneccessary for u8, u16 Pavel Machek
  2015-03-16 12:55 ` Fun with sony motion controllers: navigation controller Jiri Kosina
  4 siblings, 0 replies; 16+ messages in thread
From: Pavel Machek @ 2015-03-14 19:47 UTC (permalink / raw)
  To: vojtech, mike-,
	jslaby, dave, jikos, colin.leitner, frank.praznik, kernel list,
	linux-input

Hi!

> After oopsing kernel with ps/3 peripherals, I decided to play some
> more.
> 
> First "sony motion controller" (part of ps/3 move without the

I meant "navigation controller".

I enabled CONFIG_HID_SONY_FF, and fftest now works with the other
controller, but not work this one:

Setting master gain to 75% ... OK
Uploading effect #0 (Periodic sinusoidal) ... OK (id 0)
Uploading effect #1 (Constant) ... Error: Invalid argument
Uploading effect #2 (Spring) ... Error: Invalid argument
Uploading effect #3 (Damper) ... Error: Invalid argument
Uploading effect #4 (Strong rumble, with heavy motor) ... OK (id 1)
Uploading effect #5 (Weak rumble, with light motor) ... OK (id 2)
Enter effect number, -1 to exit
5

I can enter the effect numbers, but nothing happens.

Thanks,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Fun with sony motion controllers: motion controller
  2015-03-14 19:23 ` Fun with sony motion controllers: motion controller Pavel Machek
@ 2015-03-14 20:53   ` Pavel Machek
  0 siblings, 0 replies; 16+ messages in thread
From: Pavel Machek @ 2015-03-14 20:53 UTC (permalink / raw)
  To: vojtech, mike-,
	jslaby, dave, jikos, colin.leitner, frank.praznik, kernel list,
	linux-input

Hi!

> Second "sony motion controller" (part of ps/3 move with the big
> LED). The LED is something I'd really like to work.
> 
> It is detected:
> 
> [  741.363723] input: Sony Computer Entertainment Motion Controller as
> /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1:1.0/0003:054C:03D5.000A/input/input19
> [  741.421269] hid-generic 0003:054C:03D5.000A: input,hiddev0,hidraw0:
> USB HID v1.10 Gamepad [Sony Computer Entertainment Motion Controller]
> on usb-0000:00:1d.0-1/input0
> 
> root@amd:~# evtest /dev/input/event7
> Input driver version is 1.0.1
> Input device ID: bus 0x3 vendor 0x54c product 0x3d5 version 0x110
> Input device name: "Sony Computer Entertainment Motion Controller"
> Supported events:
>   Event type 0 (EV_SYN)
>     Event type 1 (EV_KEY)
> ...
> Properties:
> Testing ... (interrupt to exit)
> 
> But no matter what I do, I don't get any events in evtest, or any
> changes in jstest.
> 
> /sys/class/power_supply does not appear and /sys/class/leds does not
> change.
> 
> Is this controller supported at all? What interface should be used for
> talking to the RGB LED?
> 
> Yes, I'd really like the LED to work. The rest would be nice bonus.

I tried adding USB id's to hid-sony.c, but no luck. But this is
strange:

pavel@amd:/data/l/linux/samples/hidraw$ sudo ./hid-example
/dev/hidraw3
Report Descriptor Size: 178
Report Descriptor:
5 1 9 5 a1 1 85 1 5 9 19 1 29 18 15 0 25 1 35 0 45 1 75 1 95 18 81 2 6
0 ff 9 24 75 8 95 3 81 2 5 1 9 30 9 31 9 32 9 35 15 0 26 ff 0 95 4 81
2 6 0 ff 9 20 95 26 81 2 85 2 9 21 95 30 91 2 85 6 9 27 95 8 91 2 85 3
9 23 95 8 b1 2 85 10 9 22 95 30 b1 2 85 e0 9 25 95 30 b1 2 85 11 9 26
95 30 b1 2 c0 6 2 ff 9 20 a1 1 9 21 85 4 15 0 26 ff 0 75 8 95 f b1 2 9
22 85 5 95 16 b1 2 c0 6 3 ff 9 20 a1 1 9 21 85 a0 15 0 26 ff 0 75 8 95
22 b1 2 9 22 85 a1 95 16 b1 2 c0

Raw Name: Sony Computer Entertainment Motion Controller
Raw Phys: usb-0000:00:1d.0-1/input0
Raw Info:
    bustype: 3 (USB)
    	     vendor: 0x054c
	     	     product: 0x03d5
		     HIDIOCSFEATURE: Broken pipe
		     HIDIOCGFEATURE: Broken pipe
		     write() wrote 2 bytes
		     read: Resource temporarily unavailable
		     pavel@amd:/data/l/linux/samples/hidraw$

									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] hid-sony: underscores are unneccessary for u8, u16
  2015-03-14 19:19 Fun with sony motion controllers: navigation controller Pavel Machek
                   ` (2 preceding siblings ...)
  2015-03-14 19:47 ` Fun with sony motion controllers: navigation controller Pavel Machek
@ 2015-03-14 20:54 ` Pavel Machek
  2015-03-16 12:55 ` Fun with sony motion controllers: navigation controller Jiri Kosina
  4 siblings, 0 replies; 16+ messages in thread
From: Pavel Machek @ 2015-03-14 20:54 UTC (permalink / raw)
  To: vojtech, mike-,
	jslaby, dave, jikos, colin.leitner, frank.praznik, kernel list,
	linux-input
  Cc: trivial


Usage of __uX types is unneccessary in the kernel, replace it with uX.
    
Signed-off-by: Pavel Machek <pavel@ucw.cz>

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 1896c01..f65e334 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -57,7 +57,7 @@
 
 #define MAX_LEDS 4
 
-static __u8 sixaxis_rdesc[] = {
+static u8 sixaxis_rdesc[] = {
 	0x05, 0x01,         /*  Usage Page (Desktop),               */
 	0x09, 0x04,         /*  Usage (Joystik),                    */
 	0xA1, 0x01,         /*  Collection (Application),           */
@@ -605,7 +605,7 @@ static u8 dualshock4_bt_rdesc[] = {
 	0xC0                /*  End Collection                      */
 };
 
-static __u8 ps3remote_rdesc[] = {
+static u8 ps3remote_rdesc[] = {
 	0x05, 0x01,          /* GUsagePage Generic Desktop */
 	0x09, 0x05,          /* LUsage 0x05 [Game Pad] */
 	0xA1, 0x01,          /* MCollection Application (mouse, keyboard) */
@@ -769,33 +769,33 @@ static enum power_supply_property sony_battery_props[] = {
 };
 
 struct sixaxis_led {
-	__u8 time_enabled; /* the total time the led is active (0xff means forever) */
-	__u8 duty_length;  /* how long a cycle is in deciseconds (0 means "really fast") */
-	__u8 enabled;
-	__u8 duty_off; /* % of duty_length the led is off (0xff means 100%) */
-	__u8 duty_on;  /* % of duty_length the led is on (0xff mean 100%) */
+	u8 time_enabled; /* the total time the led is active (0xff means forever) */
+	u8 duty_length;  /* how long a cycle is in deciseconds (0 means "really fast") */
+	u8 enabled;
+	u8 duty_off; /* % of duty_length the led is off (0xff means 100%) */
+	u8 duty_on;  /* % of duty_length the led is on (0xff mean 100%) */
 } __packed;
 
 struct sixaxis_rumble {
-	__u8 padding;
-	__u8 right_duration; /* Right motor duration (0xff means forever) */
-	__u8 right_motor_on; /* Right (small) motor on/off, only supports values of 0 or 1 (off/on) */
-	__u8 left_duration;    /* Left motor duration (0xff means forever) */
-	__u8 left_motor_force; /* left (large) motor, supports force values from 0 to 255 */
+	u8 padding;
+	u8 right_duration; /* Right motor duration (0xff means forever) */
+	u8 right_motor_on; /* Right (small) motor on/off, only supports values of 0 or 1 (off/on) */
+	u8 left_duration;    /* Left motor duration (0xff means forever) */
+	u8 left_motor_force; /* left (large) motor, supports force values from 0 to 255 */
 } __packed;
 
 struct sixaxis_output_report {
-	__u8 report_id;
+	u8 report_id;
 	struct sixaxis_rumble rumble;
-	__u8 padding[4];
-	__u8 leds_bitmap; /* bitmap of enabled LEDs: LED_1 = 0x02, LED_2 = 0x04, ... */
+	u8 padding[4];
+	u8 leds_bitmap; /* bitmap of enabled LEDs: LED_1 = 0x02, LED_2 = 0x04, ... */
 	struct sixaxis_led led[4];    /* LEDx at (4 - x) */
 	struct sixaxis_led _reserved; /* LED5, not actually soldered */
 } __packed;
 
 union sixaxis_output_report_01 {
 	struct sixaxis_output_report data;
-	__u8 buf[36];
+	u8 buf[36];
 };
 
 #define DS4_REPORT_0x02_SIZE 37
@@ -817,32 +817,32 @@ struct sony_sc {
 	struct work_struct state_worker;
 	struct power_supply battery;
 	int device_id;
-	__u8 *output_report_dmabuf;
+	u8 *output_report_dmabuf;
 
 #ifdef CONFIG_SONY_FF
-	__u8 left;
-	__u8 right;
+	u8 left;
+	u8 right;
 #endif
 
-	__u8 mac_address[6];
-	__u8 worker_initialized;
-	__u8 cable_state;
-	__u8 battery_charging;
-	__u8 battery_capacity;
-	__u8 led_state[MAX_LEDS];
-	__u8 led_delay_on[MAX_LEDS];
-	__u8 led_delay_off[MAX_LEDS];
-	__u8 led_count;
+	u8 mac_address[6];
+	u8 worker_initialized;
+	u8 cable_state;
+	u8 battery_charging;
+	u8 battery_capacity;
+	u8 led_state[MAX_LEDS];
+	u8 led_delay_on[MAX_LEDS];
+	u8 led_delay_off[MAX_LEDS];
+	u8 led_count;
 };
 
-static __u8 *sixaxis_fixup(struct hid_device *hdev, __u8 *rdesc,
+static u8 *sixaxis_fixup(struct hid_device *hdev, u8 *rdesc,
 			     unsigned int *rsize)
 {
 	*rsize = sizeof(sixaxis_rdesc);
 	return sixaxis_rdesc;
 }
 
-static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc,
+static u8 *ps3remote_fixup(struct hid_device *hdev, u8 *rdesc,
 			     unsigned int *rsize)
 {
 	*rsize = sizeof(ps3remote_rdesc);
@@ -883,7 +883,7 @@ static int ps3remote_mapping(struct hid_device *hdev, struct hid_input *hi,
 	return 1;
 }
 
-static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
+static u8 *sony_report_fixup(struct hid_device *hdev, u8 *rdesc,
 		unsigned int *rsize)
 {
 	struct sony_sc *sc = hid_get_drvdata(hdev);
@@ -928,11 +928,11 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 	return rdesc;
 }
 
-static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
+static void sixaxis_parse_report(struct sony_sc *sc, u8 *rd, int size)
 {
-	static const __u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 };
+	static const u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 };
 	unsigned long flags;
-	__u8 cable_state, battery_capacity, battery_charging;
+	u8 cable_state, battery_capacity, battery_charging;
 
 	/*
 	 * The sixaxis is charging if the battery value is 0xee
@@ -945,7 +945,7 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
 		battery_charging = !(rd[30] & 0x01);
 		cable_state = 1;
 	} else {
-		__u8 index = rd[30] <= 5 ? rd[30] : 5;
+		u8 index = rd[30] <= 5 ? rd[30] : 5;
 		battery_capacity = sixaxis_battery_capacity[index];
 		battery_charging = 0;
 		cable_state = 0;
@@ -958,14 +958,14 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
 	spin_unlock_irqrestore(&sc->lock, flags);
 }
 
-static void dualshock4_parse_report(struct sony_sc *sc, __u8 *rd, int size)
+static void dualshock4_parse_report(struct sony_sc *sc, u8 *rd, int size)
 {
 	struct hid_input *hidinput = list_entry(sc->hdev->inputs.next,
 						struct hid_input, list);
 	struct input_dev *input_dev = hidinput->input;
 	unsigned long flags;
 	int n, offset;
-	__u8 cable_state, battery_capacity, battery_charging;
+	u8 cable_state, battery_capacity, battery_charging;
 
 	/*
 	 * Battery and touchpad data starts at byte 30 in the USB report and
@@ -1015,7 +1015,7 @@ static void dualshock4_parse_report(struct sony_sc *sc, __u8 *rd, int size)
 	 * follows the data for the first.
 	 */
 	for (n = 0; n < 2; n++) {
-		__u16 x, y;
+		u16 x, y;
 
 		x = rd[offset+1] | ((rd[offset+2] & 0xF) << 8);
 		y = ((rd[offset+2] & 0xF0) >> 4) | (rd[offset+3] << 4);
@@ -1031,7 +1031,7 @@ static void dualshock4_parse_report(struct sony_sc *sc, __u8 *rd, int size)
 }
 
 static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
-		__u8 *rd, int size)
+		u8 *rd, int size)
 {
 	struct sony_sc *sc = hid_get_drvdata(hdev);
 
@@ -1149,8 +1149,8 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev)
 
 static int sixaxis_set_operational_bt(struct hid_device *hdev)
 {
-	static const __u8 report[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 };
-	__u8 *buf;
+	static const u8 report[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 };
+	u8 *buf;
 	int ret;
 
 	buf = kmemdup(report, sizeof(report), GFP_KERNEL);
@@ -1171,7 +1171,7 @@ static int sixaxis_set_operational_bt(struct hid_device *hdev)
  */
 static int dualshock4_set_operational_bt(struct hid_device *hdev)
 {
-	__u8 *buf;
+	u8 *buf;
 	int ret;
 
 	buf = kmalloc(DS4_REPORT_0x02_SIZE, GFP_KERNEL);
@@ -1186,9 +1186,9 @@ static int dualshock4_set_operational_bt(struct hid_device *hdev)
 	return ret;
 }
 
-static void sixaxis_set_leds_from_id(int id, __u8 values[MAX_LEDS])
+static void sixaxis_set_leds_from_id(int id, u8 values[MAX_LEDS])
 {
-	static const __u8 sixaxis_leds[10][4] = {
+	static const u8 sixaxis_leds[10][4] = {
 				{ 0x01, 0x00, 0x00, 0x00 },
 				{ 0x00, 0x01, 0x00, 0x00 },
 				{ 0x00, 0x00, 0x01, 0x00 },
@@ -1210,10 +1210,10 @@ static void sixaxis_set_leds_from_id(int id, __u8 values[MAX_LEDS])
 	memcpy(values, sixaxis_leds[id], sizeof(sixaxis_leds[id]));
 }
 
-static void dualshock4_set_leds_from_id(int id, __u8 values[MAX_LEDS])
+static void dualshock4_set_leds_from_id(int id, u8 values[MAX_LEDS])
 {
 	/* The first 4 color/index entries match what the PS4 assigns */
-	static const __u8 color_code[7][3] = {
+	static const u8 color_code[7][3] = {
 			/* Blue   */	{ 0x00, 0x00, 0x01 },
 			/* Red	  */	{ 0x01, 0x00, 0x00 },
 			/* Green  */	{ 0x00, 0x01, 0x00 },
@@ -1232,7 +1232,7 @@ static void dualshock4_set_leds_from_id(int id, __u8 values[MAX_LEDS])
 	memcpy(values, color_code[id], sizeof(color_code[id]));
 }
 
-static void buzz_set_leds(struct hid_device *hdev, const __u8 *leds)
+static void buzz_set_leds(struct hid_device *hdev, const u8 *leds)
 {
 	struct list_head *report_list =
 		&hdev->report_enum[HID_OUTPUT_REPORT].report_list;
@@ -1250,7 +1250,7 @@ static void buzz_set_leds(struct hid_device *hdev, const __u8 *leds)
 	hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
 }
 
-static void sony_set_leds(struct sony_sc *sc, const __u8 *leds, int count)
+static void sony_set_leds(struct sony_sc *sc, const u8 *leds, int count)
 {
 	int n;
 
@@ -1338,7 +1338,7 @@ static int sony_led_blink_set(struct led_classdev *led, unsigned long *delay_on,
 	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
 	struct sony_sc *drv_data = hid_get_drvdata(hdev);
 	int n;
-	__u8 new_on, new_off;
+	u8 new_on, new_off;
 
 	if (!drv_data) {
 		hid_err(hdev, "No device data\n");
@@ -1409,9 +1409,9 @@ static int sony_leds_init(struct sony_sc *sc)
 	const char *name_fmt;
 	static const char * const ds4_name_str[] = { "red", "green", "blue",
 						  "global" };
-	__u8 initial_values[MAX_LEDS] = { 0 };
-	__u8 max_brightness[MAX_LEDS] = { [0 ... (MAX_LEDS - 1)] = 1 };
-	__u8 use_hw_blink[MAX_LEDS] = { 0 };
+	u8 initial_values[MAX_LEDS] = { 0 };
+	u8 max_brightness[MAX_LEDS] = { [0 ... (MAX_LEDS - 1)] = 1 };
+	u8 use_hw_blink[MAX_LEDS] = { 0 };
 
 	BUG_ON(!(sc->quirks & SONY_LED_SUPPORT));
 
@@ -1548,7 +1548,7 @@ static void sixaxis_state_worker(struct work_struct *work)
 		}
 	}
 
-	hid_hw_raw_request(sc->hdev, report->report_id, (__u8 *)report,
+	hid_hw_raw_request(sc->hdev, report->report_id, (u8 *)report,
 			sizeof(struct sixaxis_output_report),
 			HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
 }
@@ -1557,7 +1557,7 @@ static void dualshock4_state_worker(struct work_struct *work)
 {
 	struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
 	struct hid_device *hdev = sc->hdev;
-	__u8 *buf = sc->output_report_dmabuf;
+	u8 *buf = sc->output_report_dmabuf;
 	int offset;
 
 	if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) {
@@ -1809,7 +1809,7 @@ static int sony_get_bt_devaddr(struct sony_sc *sc)
 
 static int sony_check_add(struct sony_sc *sc)
 {
-	__u8 *buf = NULL;
+	u8 *buf = NULL;
 	int n, ret;
 
 	if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) ||

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Fun with sony motion controllers: navigation controller
  2015-03-14 19:19 Fun with sony motion controllers: navigation controller Pavel Machek
                   ` (3 preceding siblings ...)
  2015-03-14 20:54 ` [PATCH] hid-sony: underscores are unneccessary for u8, u16 Pavel Machek
@ 2015-03-16 12:55 ` Jiri Kosina
  2015-03-16 13:05   ` Pavel Machek
  4 siblings, 1 reply; 16+ messages in thread
From: Jiri Kosina @ 2015-03-16 12:55 UTC (permalink / raw)
  To: Pavel Machek
  Cc: vojtech, mike-,
	jslaby, dave, colin.leitner, frank.praznik, kernel list,
	linux-input

On Sat, 14 Mar 2015, Pavel Machek wrote:

> Hi!
> 
> After oopsing kernel with ps/3 peripherals, I decided to play some
> more.
> 
> First "sony motion controller" (part of ps/3 move without the
> led). Good news is that it no longer oopses. After pressing the PS
> button, it seems to work, but it produces endless stream of events in
> evtest:
> 
> Event: time 1426360519.967818, type 3 (EV_ABS), code 0 (ABS_X), value 131
> Event: time 1426360519.967818, type 3 (EV_ABS), code 1 (ABS_Y), value 129
> Event: time 1426360519.967818, type 3 (EV_ABS), code 59 (ABS_MT_DISTANCE), value 513
> Event: time 1426360519.967818, type 3 (EV_ABS), code 60 (ABS_MT_TOOL_X), value 513
> 
> Should it really produce multitouch events?

Some sony devices are producing multitouch events. You unfortunately 
didn't send us the VID/PID of the device you are playing with.

Frank, I guess you'll handle this report once Pavel provides the necessary 
data? Thanks.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Fun with sony motion controllers: navigation controller
  2015-03-16 12:55 ` Fun with sony motion controllers: navigation controller Jiri Kosina
@ 2015-03-16 13:05   ` Pavel Machek
  2015-03-16 13:55     ` Jiri Kosina
  2015-04-09 21:25     ` Turn Sony motion controller into RGB led Pavel Machek
  0 siblings, 2 replies; 16+ messages in thread
From: Pavel Machek @ 2015-03-16 13:05 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: vojtech, mike-,
	jslaby, dave, colin.leitner, frank.praznik, kernel list,
	linux-input

On Mon 2015-03-16 13:55:39, Jiri Kosina wrote:
> On Sat, 14 Mar 2015, Pavel Machek wrote:
> 
> > Hi!
> > 
> > After oopsing kernel with ps/3 peripherals, I decided to play some
> > more.
> > 
> > First "sony motion controller" (part of ps/3 move without the
> > led). Good news is that it no longer oopses. After pressing the PS
> > button, it seems to work, but it produces endless stream of events in
> > evtest:
> > 
> > Event: time 1426360519.967818, type 3 (EV_ABS), code 0 (ABS_X), value 131
> > Event: time 1426360519.967818, type 3 (EV_ABS), code 1 (ABS_Y), value 129
> > Event: time 1426360519.967818, type 3 (EV_ABS), code 59 (ABS_MT_DISTANCE), value 513
> > Event: time 1426360519.967818, type 3 (EV_ABS), code 60 (ABS_MT_TOOL_X), value 513
> > 
> > Should it really produce multitouch events?
> 
> Some sony devices are producing multitouch events. You unfortunately 
> didn't send us the VID/PID of the device you are playing with.

Umm. I thought multitouch events are for touchscreen. This is joystick
with accelerometer...?

Device is:

[10920.396060] usb 2-1: new full-speed USB device number 2 using
uhci_hcd
[10920.676076] usb 2-1: New USB device found, idVendor=054c,
idProduct=042f
[10920.676082] usb 2-1: New USB device strings: Mfr=1, Product=2,
SerialNumber=0
[10920.676085] usb 2-1: Product: Navigation Controller
[10920.676088] usb 2-1: Manufacturer: Sony

> Frank, I guess you'll handle this report once Pavel provides the necessary 
> data? Thanks.

Thanks,
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Fun with sony motion controllers: navigation controller
  2015-03-16 13:05   ` Pavel Machek
@ 2015-03-16 13:55     ` Jiri Kosina
  2015-03-16 15:26       ` Frank Praznik
  2015-04-09 21:25     ` Turn Sony motion controller into RGB led Pavel Machek
  1 sibling, 1 reply; 16+ messages in thread
From: Jiri Kosina @ 2015-03-16 13:55 UTC (permalink / raw)
  To: Pavel Machek
  Cc: vojtech, mike-,
	jslaby, dave, colin.leitner, frank.praznik, kernel list,
	linux-input

On Mon, 16 Mar 2015, Pavel Machek wrote:

> On Mon 2015-03-16 13:55:39, Jiri Kosina wrote:
> > On Sat, 14 Mar 2015, Pavel Machek wrote:
> > 
> > > Hi!
> > > 
> > > After oopsing kernel with ps/3 peripherals, I decided to play some
> > > more.
> > > 
> > > First "sony motion controller" (part of ps/3 move without the
> > > led). Good news is that it no longer oopses. After pressing the PS
> > > button, it seems to work, but it produces endless stream of events in
> > > evtest:
> > > 
> > > Event: time 1426360519.967818, type 3 (EV_ABS), code 0 (ABS_X), value 131
> > > Event: time 1426360519.967818, type 3 (EV_ABS), code 1 (ABS_Y), value 129
> > > Event: time 1426360519.967818, type 3 (EV_ABS), code 59 (ABS_MT_DISTANCE), value 513
> > > Event: time 1426360519.967818, type 3 (EV_ABS), code 60 (ABS_MT_TOOL_X), value 513
> > > 
> > > Should it really produce multitouch events?
> > 
> > Some sony devices are producing multitouch events. You unfortunately 
> > didn't send us the VID/PID of the device you are playing with.
> 
> Umm. I thought multitouch events are for touchscreen. This is joystick
> with accelerometer...?

Ok, that's USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER, which should get 
SIXAXIS_CONTROLLER_USB. That one shouldn't really be producing multitouch 
events.

Could you please add printk()s to hid-sony.c to see how it's possible that 
it's generating those?

I am sure Frank will comment on this as well.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Fun with sony motion controllers: navigation controller
  2015-03-16 13:55     ` Jiri Kosina
@ 2015-03-16 15:26       ` Frank Praznik
  2015-03-16 22:28         ` Pavel Machek
  0 siblings, 1 reply; 16+ messages in thread
From: Frank Praznik @ 2015-03-16 15:26 UTC (permalink / raw)
  To: Jiri Kosina, Pavel Machek
  Cc: vojtech, mike-, jslaby, dave, colin.leitner, kernel list, linux-input

On 3/16/2015 09:55, Jiri Kosina wrote:
> On Mon, 16 Mar 2015, Pavel Machek wrote:
>
>> On Mon 2015-03-16 13:55:39, Jiri Kosina wrote:
>>> On Sat, 14 Mar 2015, Pavel Machek wrote:
>>>
>>>> Hi!
>>>>
>>>> After oopsing kernel with ps/3 peripherals, I decided to play some
>>>> more.
>>>>
>>>> First "sony motion controller" (part of ps/3 move without the
>>>> led). Good news is that it no longer oopses. After pressing the PS
>>>> button, it seems to work, but it produces endless stream of events in
>>>> evtest:
>>>>
>>>> Event: time 1426360519.967818, type 3 (EV_ABS), code 0 (ABS_X), value 131
>>>> Event: time 1426360519.967818, type 3 (EV_ABS), code 1 (ABS_Y), value 129
>>>> Event: time 1426360519.967818, type 3 (EV_ABS), code 59 (ABS_MT_DISTANCE), value 513
>>>> Event: time 1426360519.967818, type 3 (EV_ABS), code 60 (ABS_MT_TOOL_X), value 513
>>>>
>>>> Should it really produce multitouch events?
>>> Some sony devices are producing multitouch events. You unfortunately
>>> didn't send us the VID/PID of the device you are playing with.
>> Umm. I thought multitouch events are for touchscreen. This is joystick
>> with accelerometer...?
> Ok, that's USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER, which should get
> SIXAXIS_CONTROLLER_USB. That one shouldn't really be producing multitouch
> events.
>
> Could you please add printk()s to hid-sony.c to see how it's possible that
> it's generating those?
>
> I am sure Frank will comment on this as well.
>

The Dualshock 3 is a special case in that every button except for start, 
select and the PS button are both digital and analog.  As such, the 
controller reports 27 axes that end up spilling over into the ABS_MT 
values.  This mapping comes from the default HID descriptor from the 
device, so it's been this way from day 1.  If the navigation controller 
is basically the same as a DS3 then it will have the same issues.

To note, the DS3 only has 20 actual, physical axes meaning that 7 of the 
reported axes don't even do anything and I'm not sure why they are 
there.  The HID descriptor could be rewritten to map everything in a 
more correct manner, but that would break the mapping that has been 
there for 8 or 9 years at this point and probably break some user-space 
applications in the process.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Fun with sony motion controllers: navigation controller
  2015-03-16 15:26       ` Frank Praznik
@ 2015-03-16 22:28         ` Pavel Machek
  0 siblings, 0 replies; 16+ messages in thread
From: Pavel Machek @ 2015-03-16 22:28 UTC (permalink / raw)
  To: Frank Praznik
  Cc: Jiri Kosina, vojtech, mike-,
	jslaby, dave, colin.leitner, kernel list, linux-input

Hi!

> >I am sure Frank will comment on this as well.
> 
> The Dualshock 3 is a special case in that every button except for start,
> select and the PS button are both digital and analog.  As such, the
> controller reports 27 axes that end up spilling over into the ABS_MT values.
> This mapping comes from the default HID descriptor from the device, so it's
> been this way from day 1.  If the navigation controller is basically the
> same as a DS3 then it will have the same issues.
> 
> To note, the DS3 only has 20 actual, physical axes meaning that 7 of the
> reported axes don't even do anything and I'm not sure why they are there.
> The HID descriptor could be rewritten to map everything in a more correct
> manner, but that would break the mapping that has been there for 8 or 9
> years at this point and probably break some user-space applications in the
> process.

Ok, makes sense, but could this go to the beggining of hid-sony.c file
as a comment, so that it is easy to find?

And BTW to you know anything about the other move controller? I have
code to light the LED (which I really wanted), but can't get other
data. In particular, I'd like temperature ;-).

[18788.740182] usb 2-2: new full-speed USB device number 2 using uhci_hcd
[18788.906163] usb 2-2: New USB device found, idVendor=054c, idProduct=03d5
[18788.906173] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[18788.906179] usb 2-2: Product: Motion Controller
[18788.906184] usb 2-2: Manufacturer: Sony Computer Entertainment
[18788.924254] input: Sony Computer Entertainment Motion Controller as
/devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.0/0003:054C:03D5.0002/input/input12
[18788.981391] sony 0003:054C:03D5.0002: input,hidraw0: USB HID v1.10
Joystick [Sony Computer Entertainment Motion Controller] on
usb-0000:00:1d.0-2/input0

Thanks,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Turn Sony motion controller into RGB led
  2015-03-16 13:05   ` Pavel Machek
  2015-03-16 13:55     ` Jiri Kosina
@ 2015-04-09 21:25     ` Pavel Machek
  2015-04-09 21:50       ` Jiri Kosina
  2015-04-10  0:33       ` Frank Praznik
  1 sibling, 2 replies; 16+ messages in thread
From: Pavel Machek @ 2015-04-09 21:25 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: vojtech, mike-,
	jslaby, dave, colin.leitner, frank.praznik, kernel list,
	linux-input

Hi!

I did not yet figure out how to get sensor data from the controller,
but it works rather well as a RGB led.

And yes, this probably would need some more cleanup, but I'm out of
time now. Perhaps someone else can help...

BTW what happened to the __u8->u8 conversion patch? That should go in AFAICT.

Signed-off-by: Pavel Machek <pavel@ucw.cz>

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 56ce8c2..a1c8b63 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1941,6 +1941,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER) },	
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 9c47867..d94d2c3 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -843,6 +843,7 @@
 #define USB_DEVICE_ID_SONY_PS3_CONTROLLER	0x0268
 #define USB_DEVICE_ID_SONY_PS4_CONTROLLER	0x05c4
 #define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER	0x042f
+#define USB_DEVICE_ID_SONY_MOTION_CONTROLLER	0x03d5
 #define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER		0x0002
 #define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER	0x1000
 
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 1896c01..6dec2a0 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -46,20 +46,22 @@
 #define PS3REMOTE                 BIT(4)
 #define DUALSHOCK4_CONTROLLER_USB BIT(5)
 #define DUALSHOCK4_CONTROLLER_BT  BIT(6)
+#define MOTION_CONTROLLER	  BIT(7)
 
 #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT)
 #define DUALSHOCK4_CONTROLLER (DUALSHOCK4_CONTROLLER_USB |\
 				DUALSHOCK4_CONTROLLER_BT)
 #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\
-				DUALSHOCK4_CONTROLLER)
+				DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER)
 #define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER)
 #define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER)
 
 #define MAX_LEDS 4
 
-static __u8 sixaxis_rdesc[] = {
+/* PS/3 SixAxis and DualShock controllers */      
+static u8 sixaxis_rdesc[] = {
 	0x05, 0x01,         /*  Usage Page (Desktop),               */
-	0x09, 0x04,         /*  Usage (Joystik),                    */
+	0x09, 0x04,         /*  Usage (Joystick),                   */
 	0xA1, 0x01,         /*  Collection (Application),           */
 	0xA1, 0x02,         /*      Collection (Logical),           */
 	0x85, 0x01,         /*          Report ID (1),              */
@@ -134,6 +136,85 @@ static __u8 sixaxis_rdesc[] = {
 	0xC0                /*  End Collection                      */
 };
 
+/* PS/3 Motion controller */      
+static u8 motion_rdesc[] = {
+	0x05, 0x01,         /*  Usage Page (Desktop),               */
+	0x09, 0x04,         /*  Usage (Joystick),                   */
+	0xA1, 0x01,         /*  Collection (Application),           */
+	0xA1, 0x02,         /*      Collection (Logical),           */
+	0x85, 0x01,         /*          Report ID (1),              */
+	0x75, 0x08,         /*          Report Size (8),            */
+	0x95, 0x01,         /*          Report Count (1),           */
+	0x15, 0x00,         /*          Logical Minimum (0),        */
+	0x26, 0xFF, 0x00,   /*          Logical Maximum (255),      */
+	0x81, 0x03,         /*          Input (Constant, Variable), */
+	0x75, 0x01,         /*          Report Size (1),            */
+	0x95, 0x13,         /*          Report Count (19),          */
+	0x15, 0x00,         /*          Logical Minimum (0),        */
+	0x25, 0x01,         /*          Logical Maximum (1),        */
+	0x35, 0x00,         /*          Physical Minimum (0),       */
+	0x45, 0x01,         /*          Physical Maximum (1),       */
+	0x05, 0x09,         /*          Usage Page (Button),        */
+	0x19, 0x01,         /*          Usage Minimum (01h),        */
+	0x29, 0x13,         /*          Usage Maximum (13h),        */
+	0x81, 0x02,         /*          Input (Variable),           */
+	0x75, 0x01,         /*          Report Size (1),            */
+	0x95, 0x0D,         /*          Report Count (13),          */
+	0x06, 0x00, 0xFF,   /*          Usage Page (FF00h),         */
+	0x81, 0x03,         /*          Input (Constant, Variable), */
+	0x15, 0x00,         /*          Logical Minimum (0),        */
+	0x26, 0xFF, 0x00,   /*          Logical Maximum (255),      */
+	0x05, 0x01,         /*          Usage Page (Desktop),       */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0xA1, 0x00,         /*          Collection (Physical),      */
+	0x75, 0x08,         /*              Report Size (8),        */
+	0x95, 0x04,         /*              Report Count (4),       */
+	0x35, 0x00,         /*              Physical Minimum (0),   */
+	0x46, 0xFF, 0x00,   /*              Physical Maximum (255), */
+	0x09, 0x30,         /*              Usage (X),              */
+	0x09, 0x31,         /*              Usage (Y),              */
+	0x09, 0x32,         /*              Usage (Z),              */
+	0x09, 0x35,         /*              Usage (Rz),             */
+	0x81, 0x02,         /*              Input (Variable),       */
+	0xC0,               /*          End Collection,             */
+	0x05, 0x01,         /*          Usage Page (Desktop),       */
+	0x95, 0x13,         /*          Report Count (19),          */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0x81, 0x02,         /*          Input (Variable),           */
+	0x95, 0x0C,         /*          Report Count (12),          */
+	0x81, 0x01,         /*          Input (Constant),           */
+	0x75, 0x10,         /*          Report Size (16),           */
+	0x95, 0x04,         /*          Report Count (4),           */
+	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
+	0x46, 0xFF, 0x03,   /*          Physical Maximum (1023),    */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0x81, 0x02,         /*          Input (Variable),           */
+	0xC0,               /*      End Collection,                 */
+	0xA1, 0x02,         /*      Collection (Logical),           */
+	0x85, 0x02,         /*          Report ID (2),              */
+	0x75, 0x08,         /*          Report Size (8),            */
+	0x95, 0x30,         /*          Report Count (48),          */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0xB1, 0x02,         /*          Feature (Variable),         */
+	0xC0,               /*      End Collection,                 */
+	0xA1, 0x02,         /*      Collection (Logical),           */
+	0x85, 0xEE,         /*          Report ID (238),            */
+	0x75, 0x08,         /*          Report Size (8),            */
+	0x95, 0x30,         /*          Report Count (48),          */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0xB1, 0x02,         /*          Feature (Variable),         */
+	0xC0,               /*      End Collection,                 */
+	0xA1, 0x02,         /*      Collection (Logical),           */
+	0x85, 0xEF,         /*          Report ID (239),            */
+	0x75, 0x08,         /*          Report Size (8),            */
+	0x95, 0x30,         /*          Report Count (48),          */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0xB1, 0x02,         /*          Feature (Variable),         */
+	0xC0,               /*      End Collection,                 */
+	0xC0                /*  End Collection                      */
+};
+
+
 /*
  * The default descriptor doesn't provide mapping for the accelerometers
  * or orientation sensors.  This fixed descriptor maps the accelerometers
@@ -605,7 +686,7 @@ static u8 dualshock4_bt_rdesc[] = {
 	0xC0                /*  End Collection                      */
 };
 
-static __u8 ps3remote_rdesc[] = {
+static u8 ps3remote_rdesc[] = {
 	0x05, 0x01,          /* GUsagePage Generic Desktop */
 	0x09, 0x05,          /* LUsage 0x05 [Game Pad] */
 	0xA1, 0x01,          /* MCollection Application (mouse, keyboard) */
@@ -769,33 +850,33 @@ static enum power_supply_property sony_battery_props[] = {
 };
 
 struct sixaxis_led {
-	__u8 time_enabled; /* the total time the led is active (0xff means forever) */
-	__u8 duty_length;  /* how long a cycle is in deciseconds (0 means "really fast") */
-	__u8 enabled;
-	__u8 duty_off; /* % of duty_length the led is off (0xff means 100%) */
-	__u8 duty_on;  /* % of duty_length the led is on (0xff mean 100%) */
+	u8 time_enabled; /* the total time the led is active (0xff means forever) */
+	u8 duty_length;  /* how long a cycle is in deciseconds (0 means "really fast") */
+	u8 enabled;
+	u8 duty_off; /* % of duty_length the led is off (0xff means 100%) */
+	u8 duty_on;  /* % of duty_length the led is on (0xff mean 100%) */
 } __packed;
 
 struct sixaxis_rumble {
-	__u8 padding;
-	__u8 right_duration; /* Right motor duration (0xff means forever) */
-	__u8 right_motor_on; /* Right (small) motor on/off, only supports values of 0 or 1 (off/on) */
-	__u8 left_duration;    /* Left motor duration (0xff means forever) */
-	__u8 left_motor_force; /* left (large) motor, supports force values from 0 to 255 */
+	u8 padding;
+	u8 right_duration; /* Right motor duration (0xff means forever) */
+	u8 right_motor_on; /* Right (small) motor on/off, only supports values of 0 or 1 (off/on) */
+	u8 left_duration;    /* Left motor duration (0xff means forever) */
+	u8 left_motor_force; /* left (large) motor, supports force values from 0 to 255 */
 } __packed;
 
 struct sixaxis_output_report {
-	__u8 report_id;
+	u8 report_id;
 	struct sixaxis_rumble rumble;
-	__u8 padding[4];
-	__u8 leds_bitmap; /* bitmap of enabled LEDs: LED_1 = 0x02, LED_2 = 0x04, ... */
+	u8 padding[4];
+	u8 leds_bitmap; /* bitmap of enabled LEDs: LED_1 = 0x02, LED_2 = 0x04, ... */
 	struct sixaxis_led led[4];    /* LEDx at (4 - x) */
 	struct sixaxis_led _reserved; /* LED5, not actually soldered */
 } __packed;
 
 union sixaxis_output_report_01 {
 	struct sixaxis_output_report data;
-	__u8 buf[36];
+	u8 buf[36];
 };
 
 #define DS4_REPORT_0x02_SIZE 37
@@ -817,32 +898,69 @@ struct sony_sc {
 	struct work_struct state_worker;
 	struct power_supply battery;
 	int device_id;
-	__u8 *output_report_dmabuf;
+	u8 *output_report_dmabuf;
 
 #ifdef CONFIG_SONY_FF
-	__u8 left;
-	__u8 right;
+	u8 left;
+	u8 right;
 #endif
 
-	__u8 mac_address[6];
-	__u8 worker_initialized;
-	__u8 cable_state;
-	__u8 battery_charging;
-	__u8 battery_capacity;
-	__u8 led_state[MAX_LEDS];
-	__u8 led_delay_on[MAX_LEDS];
-	__u8 led_delay_off[MAX_LEDS];
-	__u8 led_count;
+	u8 mac_address[6];
+	u8 worker_initialized;
+	u8 cable_state;
+	u8 battery_charging;
+	u8 battery_capacity;
+	u8 led_state[MAX_LEDS];
+	u8 led_delay_on[MAX_LEDS];
+	u8 led_delay_off[MAX_LEDS];
+	u8 led_count;
+};
+
+struct motion_leds {
+	u8 type, zero;
+	u8 r, g, b;
+	u8 zero2;
+	u8 rumble;
 };
 
-static __u8 *sixaxis_fixup(struct hid_device *hdev, __u8 *rdesc,
+static u8 *sixaxis_fixup(struct hid_device *hdev, u8 *rdesc,
 			     unsigned int *rsize)
 {
 	*rsize = sizeof(sixaxis_rdesc);
 	return sixaxis_rdesc;
 }
 
-static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc,
+static int motion_set_leds(struct hid_device *hdev, u8 r, u8 g, u8 b)
+{
+	int ret;
+	struct motion_leds *buf = kzalloc(sizeof(struct motion_leds), GFP_KERNEL);
+
+	if (sizeof(struct motion_leds) != 7) {
+		printk("Struct has bad size\n");
+	}
+
+#define SET_LEDS 0x02
+	buf->type = SET_LEDS;
+	buf->r = r;
+	buf->g = g;
+	buf->b = b;	
+	
+	ret = hid_hw_output_report(hdev, buf, sizeof(struct motion_leds));
+	printk("motion: set leds %d\n", ret);
+	kfree(buf);
+
+	return ret;
+}
+
+static u8 *motion_fixup(struct hid_device *hdev, u8 *rdesc,
+			     unsigned int *rsize)
+{
+	printk("Fixup for motion\n");
+	*rsize = sizeof(motion_rdesc);
+	return motion_rdesc;
+}
+
+static u8 *ps3remote_fixup(struct hid_device *hdev, u8 *rdesc,
 			     unsigned int *rsize)
 {
 	*rsize = sizeof(ps3remote_rdesc);
@@ -883,11 +1001,13 @@ static int ps3remote_mapping(struct hid_device *hdev, struct hid_input *hi,
 	return 1;
 }
 
-static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
+static u8 *sony_report_fixup(struct hid_device *hdev, u8 *rdesc,
 		unsigned int *rsize)
 {
 	struct sony_sc *sc = hid_get_drvdata(hdev);
 
+	printk("Got report with rsize %d\n", *rsize);
+
 	/*
 	 * Some Sony RF receivers wrongly declare the mouse pointer as a
 	 * a constant non-data variable.
@@ -922,17 +1042,20 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 	if (sc->quirks & SIXAXIS_CONTROLLER)
 		return sixaxis_fixup(hdev, rdesc, rsize);
 
+	if (sc->quirks & MOTION_CONTROLLER)
+		return motion_fixup(hdev, rdesc, rsize);
+	
 	if (sc->quirks & PS3REMOTE)
 		return ps3remote_fixup(hdev, rdesc, rsize);
 
 	return rdesc;
 }
 
-static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
+static void sixaxis_parse_report(struct sony_sc *sc, u8 *rd, int size)
 {
-	static const __u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 };
+	static const u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 };
 	unsigned long flags;
-	__u8 cable_state, battery_capacity, battery_charging;
+	u8 cable_state, battery_capacity, battery_charging;
 
 	/*
 	 * The sixaxis is charging if the battery value is 0xee
@@ -945,7 +1068,7 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
 		battery_charging = !(rd[30] & 0x01);
 		cable_state = 1;
 	} else {
-		__u8 index = rd[30] <= 5 ? rd[30] : 5;
+		u8 index = rd[30] <= 5 ? rd[30] : 5;
 		battery_capacity = sixaxis_battery_capacity[index];
 		battery_charging = 0;
 		cable_state = 0;
@@ -958,14 +1081,14 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
 	spin_unlock_irqrestore(&sc->lock, flags);
 }
 
-static void dualshock4_parse_report(struct sony_sc *sc, __u8 *rd, int size)
+static void dualshock4_parse_report(struct sony_sc *sc, u8 *rd, int size)
 {
 	struct hid_input *hidinput = list_entry(sc->hdev->inputs.next,
 						struct hid_input, list);
 	struct input_dev *input_dev = hidinput->input;
 	unsigned long flags;
 	int n, offset;
-	__u8 cable_state, battery_capacity, battery_charging;
+	u8 cable_state, battery_capacity, battery_charging;
 
 	/*
 	 * Battery and touchpad data starts at byte 30 in the USB report and
@@ -1015,7 +1138,7 @@ static void dualshock4_parse_report(struct sony_sc *sc, __u8 *rd, int size)
 	 * follows the data for the first.
 	 */
 	for (n = 0; n < 2; n++) {
-		__u16 x, y;
+		u16 x, y;
 
 		x = rd[offset+1] | ((rd[offset+2] & 0xF) << 8);
 		y = ((rd[offset+2] & 0xF0) >> 4) | (rd[offset+3] << 4);
@@ -1031,10 +1154,12 @@ static void dualshock4_parse_report(struct sony_sc *sc, __u8 *rd, int size)
 }
 
 static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
-		__u8 *rd, int size)
+		u8 *rd, int size)
 {
 	struct sony_sc *sc = hid_get_drvdata(hdev);
 
+	printk("sony_raw_event, size %d\n", size);
+
 	/*
 	 * Sixaxis HID report has acclerometers/gyro with MSByte first, this
 	 * has to be BYTE_SWAPPED before passing up to joystick interface
@@ -1149,8 +1274,8 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev)
 
 static int sixaxis_set_operational_bt(struct hid_device *hdev)
 {
-	static const __u8 report[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 };
-	__u8 *buf;
+	static const u8 report[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 };
+	u8 *buf;
 	int ret;
 
 	buf = kmemdup(report, sizeof(report), GFP_KERNEL);
@@ -1171,7 +1296,7 @@ static int sixaxis_set_operational_bt(struct hid_device *hdev)
  */
 static int dualshock4_set_operational_bt(struct hid_device *hdev)
 {
-	__u8 *buf;
+	u8 *buf;
 	int ret;
 
 	buf = kmalloc(DS4_REPORT_0x02_SIZE, GFP_KERNEL);
@@ -1186,9 +1311,9 @@ static int dualshock4_set_operational_bt(struct hid_device *hdev)
 	return ret;
 }
 
-static void sixaxis_set_leds_from_id(int id, __u8 values[MAX_LEDS])
+static void sixaxis_set_leds_from_id(int id, u8 values[MAX_LEDS])
 {
-	static const __u8 sixaxis_leds[10][4] = {
+	static const u8 sixaxis_leds[10][4] = {
 				{ 0x01, 0x00, 0x00, 0x00 },
 				{ 0x00, 0x01, 0x00, 0x00 },
 				{ 0x00, 0x00, 0x01, 0x00 },
@@ -1210,10 +1335,10 @@ static void sixaxis_set_leds_from_id(int id, __u8 values[MAX_LEDS])
 	memcpy(values, sixaxis_leds[id], sizeof(sixaxis_leds[id]));
 }
 
-static void dualshock4_set_leds_from_id(int id, __u8 values[MAX_LEDS])
+static void dualshock4_set_leds_from_id(int id, u8 values[MAX_LEDS])
 {
 	/* The first 4 color/index entries match what the PS4 assigns */
-	static const __u8 color_code[7][3] = {
+	static const u8 color_code[7][3] = {
 			/* Blue   */	{ 0x00, 0x00, 0x01 },
 			/* Red	  */	{ 0x01, 0x00, 0x00 },
 			/* Green  */	{ 0x00, 0x01, 0x00 },
@@ -1232,7 +1357,7 @@ static void dualshock4_set_leds_from_id(int id, __u8 values[MAX_LEDS])
 	memcpy(values, color_code[id], sizeof(color_code[id]));
 }
 
-static void buzz_set_leds(struct hid_device *hdev, const __u8 *leds)
+static void buzz_set_leds(struct hid_device *hdev, const u8 *leds)
 {
 	struct list_head *report_list =
 		&hdev->report_enum[HID_OUTPUT_REPORT].report_list;
@@ -1250,7 +1375,7 @@ static void buzz_set_leds(struct hid_device *hdev, const __u8 *leds)
 	hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
 }
 
-static void sony_set_leds(struct sony_sc *sc, const __u8 *leds, int count)
+static void sony_set_leds(struct sony_sc *sc, const u8 *leds, int count)
 {
 	int n;
 
@@ -1258,11 +1383,12 @@ static void sony_set_leds(struct sony_sc *sc, const __u8 *leds, int count)
 
 	if (sc->quirks & BUZZ_CONTROLLER && count == 4) {
 		buzz_set_leds(sc->hdev, leds);
-	} else {
-		for (n = 0; n < count; n++)
-			sc->led_state[n] = leds[n];
-		schedule_work(&sc->state_worker);
+		return;
 	}
+	
+	for (n = 0; n < count; n++)
+		sc->led_state[n] = leds[n];
+	schedule_work(&sc->state_worker);
 }
 
 static void sony_led_set_brightness(struct led_classdev *led,
@@ -1338,14 +1464,14 @@ static int sony_led_blink_set(struct led_classdev *led, unsigned long *delay_on,
 	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
 	struct sony_sc *drv_data = hid_get_drvdata(hdev);
 	int n;
-	__u8 new_on, new_off;
+	u8 new_on, new_off;
 
 	if (!drv_data) {
 		hid_err(hdev, "No device data\n");
 		return -EINVAL;
 	}
 
-	/* Max delay is 255 deciseconds or 2550 milliseconds */
+	/* Max delay is 2.55 seconds */
 	if (*delay_on > 2550)
 		*delay_on = 2550;
 	if (*delay_off > 2550)
@@ -1409,9 +1535,9 @@ static int sony_leds_init(struct sony_sc *sc)
 	const char *name_fmt;
 	static const char * const ds4_name_str[] = { "red", "green", "blue",
 						  "global" };
-	__u8 initial_values[MAX_LEDS] = { 0 };
-	__u8 max_brightness[MAX_LEDS] = { [0 ... (MAX_LEDS - 1)] = 1 };
-	__u8 use_hw_blink[MAX_LEDS] = { 0 };
+	u8 initial_values[MAX_LEDS] = { 0 };
+	u8 max_brightness[MAX_LEDS] = { [0 ... (MAX_LEDS - 1)] = 1 };
+	u8 use_hw_blink[MAX_LEDS] = { 0 };
 
 	BUG_ON(!(sc->quirks & SONY_LED_SUPPORT));
 
@@ -1432,6 +1558,12 @@ static int sony_leds_init(struct sony_sc *sc)
 		use_ds4_names = 1;
 		name_len = 0;
 		name_fmt = "%s:%s";
+	} else if (sc->quirks & MOTION_CONTROLLER) {
+		sc->led_count = 3;
+		memset(max_brightness, 255, 3);
+		use_ds4_names = 1;
+		name_len = 0;
+		name_fmt = "%s:%s";
 	} else {
 		sixaxis_set_leds_from_id(sc->device_id, initial_values);
 		sc->led_count = 4;
@@ -1548,7 +1680,7 @@ static void sixaxis_state_worker(struct work_struct *work)
 		}
 	}
 
-	hid_hw_raw_request(sc->hdev, report->report_id, (__u8 *)report,
+	hid_hw_raw_request(sc->hdev, report->report_id, (u8 *)report,
 			sizeof(struct sixaxis_output_report),
 			HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
 }
@@ -1557,7 +1689,7 @@ static void dualshock4_state_worker(struct work_struct *work)
 {
 	struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
 	struct hid_device *hdev = sc->hdev;
-	__u8 *buf = sc->output_report_dmabuf;
+	u8 *buf = sc->output_report_dmabuf;
 	int offset;
 
 	if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) {
@@ -1600,6 +1732,16 @@ static void dualshock4_state_worker(struct work_struct *work)
 				HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
 }
 
+static void motion_state_worker(struct work_struct *work)
+{
+	struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
+	struct hid_device *hdev = sc->hdev;
+
+	motion_set_leds(hdev, sc->led_state[0], sc->led_state[1], sc->led_state[2]);
+
+//	schedule_delayed_work(&sc->state_worker, HZ*3);
+}
+
 static int sony_allocate_output_report(struct sony_sc *sc)
 {
 	if (sc->quirks & SIXAXIS_CONTROLLER)
@@ -1809,7 +1951,7 @@ static int sony_get_bt_devaddr(struct sony_sc *sc)
 
 static int sony_check_add(struct sony_sc *sc)
 {
-	__u8 *buf = NULL;
+	u8 *buf = NULL;
 	int n, ret;
 
 	if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) ||
@@ -1938,6 +2080,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	struct sony_sc *sc;
 	unsigned int connect_mask = HID_CONNECT_DEFAULT;
 
+	printk("sony: probe\n");
+
 	sc = devm_kzalloc(&hdev->dev, sizeof(*sc), GFP_KERNEL);
 	if (sc == NULL) {
 		hid_err(hdev, "can't alloc sony descriptor\n");
@@ -1950,12 +2094,16 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	hid_set_drvdata(hdev, sc);
 	sc->hdev = hdev;
 
+	printk("have device %lx\n", hdev);
+
 	ret = hid_parse(hdev);
 	if (ret) {
 		hid_err(hdev, "parse failed\n");
 		return ret;
 	}
 
+	printk("parsed %lx\n", hdev);	
+
 	if (sc->quirks & VAIO_RDESC_CONSTANT)
 		connect_mask |= HID_CONNECT_HIDDEV_FORCE;
 	else if (sc->quirks & SIXAXIS_CONTROLLER)
@@ -2017,6 +2165,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		}
 
 		sony_init_work(sc, dualshock4_state_worker);
+	} else if (sc->quirks & MOTION_CONTROLLER) {
+		sony_init_work(sc, motion_state_worker);		
 	} else {
 		ret = 0;
 	}
@@ -2097,6 +2247,8 @@ static const struct hid_device_id sony_devices[] = {
 		.driver_data = SIXAXIS_CONTROLLER_USB },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER),
 		.driver_data = SIXAXIS_CONTROLLER_USB },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER),
+		.driver_data = MOTION_CONTROLLER },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
 		.driver_data = SIXAXIS_CONTROLLER_BT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),
@@ -2142,6 +2294,8 @@ static int __init sony_init(void)
 {
 	dbg_hid("Sony:%s\n", __func__);
 
+	printk("Sony: init\n");
+
 	return hid_register_driver(&sony_driver);
 }
 
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 9c2d7c2..1342b71 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -151,7 +151,14 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
 
 	if ((report_type == HID_OUTPUT_REPORT) &&
 	    !(dev->quirks & HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP)) {
+		printk("hid_hw_output_report(dev, buf, %d_REPORT);\n", count);
 		ret = hid_hw_output_report(dev, buf, count);
+		{
+			int i;
+			for (i=0; i<count; i++)
+				printk("%02x ", buf[i]);
+			printk("\n");
+		}
 		/*
 		 * compatibility with old implementation of USB-HID and I2C-HID:
 		 * if the device does not support receiving output reports,
@@ -161,6 +168,15 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
 			goto out_free;
 	}
 
+	printk("hid_hw_raw_request(dev, %02x, buf, %d, %d, HID_REQ_SET_REPORT);\n",
+	       buf[0], count, report_type);
+	{
+		int i;
+		for (i=0; i<count; i++)
+			printk("%02x ", buf[i]);
+		printk("\n");
+	}
+
 	ret = hid_hw_raw_request(dev, buf[0], buf, count, report_type,
 				HID_REQ_SET_REPORT);
 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Turn Sony motion controller into RGB led
  2015-04-09 21:25     ` Turn Sony motion controller into RGB led Pavel Machek
@ 2015-04-09 21:50       ` Jiri Kosina
  2015-04-10  0:33       ` Frank Praznik
  1 sibling, 0 replies; 16+ messages in thread
From: Jiri Kosina @ 2015-04-09 21:50 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Vojtech Pavlik, mike-,
	jslaby, dave, colin.leitner, frank.praznik, kernel list,
	linux-input

On Thu, 9 Apr 2015, Pavel Machek wrote:

> I did not yet figure out how to get sensor data from the controller,
> but it works rather well as a RGB led.

Thanks for the patch, Pavel.

> And yes, this probably would need some more cleanup, but I'm out of
> time now. Perhaps someone else can help...

Yeah, this definitely can't be applied as-is. A few of the most 
outstanding issues pointed out below.

> BTW what happened to the __u8->u8 conversion patch? That should go in AFAICT.

It hasn't been lost, still in my queue, but as it is of a very low 
priority, it hasn't been processed yet. Please make this one independent 
on it (i.e. do not intermix the type conversion with the actual RGB led 
patch).

> Signed-off-by: Pavel Machek <pavel@ucw.cz>
> 
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index 56ce8c2..a1c8b63 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -1941,6 +1941,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
>  	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) },
>  	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
>  	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
> +	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER) },	

Minor nit -- we generally try to keep this list alphabetically sorted, 
although even before your change USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 
is misplaced. Would be nice to have it fixed while you are at it.

[ ... snip ... ]
> -static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc,
> +static int motion_set_leds(struct hid_device *hdev, u8 r, u8 g, u8 b)
> +{
> +	int ret;
> +	struct motion_leds *buf = kzalloc(sizeof(struct motion_leds), GFP_KERNEL);

kzalloc() failure handling missing.

> +
> +	if (sizeof(struct motion_leds) != 7) {

What is this trying to achieve? What error is it protecting against?

> +		printk("Struct has bad size\n");

This needs to be prefixed by the driver / device identification (pr_/dev_ 
macros).

> +	}
> +
> +#define SET_LEDS 0x02

Please put this outside of the function scope.

> +	buf->type = SET_LEDS;
> +	buf->r = r;
> +	buf->g = g;
> +	buf->b = b;	
> +	
> +	ret = hid_hw_output_report(hdev, buf, sizeof(struct motion_leds));
> +	printk("motion: set leds %d\n", ret);

Again, please make this (and most of the other printk()s added by the 
patch) driver/device specific (and dependent on a debug option).

[ ... snip ... ]
> +static void motion_state_worker(struct work_struct *work)
> +{
> +	struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
> +	struct hid_device *hdev = sc->hdev;
> +
> +	motion_set_leds(hdev, sc->led_state[0], sc->led_state[1], sc->led_state[2]);
> +
> +//	schedule_delayed_work(&sc->state_worker, HZ*3);

The work gets scheduled whenever sony_set_leds() is called, so this can be 
just removed, right?

[ ... snip ... ]
> diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
> index 9c2d7c2..1342b71 100644
> --- a/drivers/hid/hidraw.c
> +++ b/drivers/hid/hidraw.c
> @@ -151,7 +151,14 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
>  
>  	if ((report_type == HID_OUTPUT_REPORT) &&
>  	    !(dev->quirks & HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP)) {
> +		printk("hid_hw_output_report(dev, buf, %d_REPORT);\n", count);
>  		ret = hid_hw_output_report(dev, buf, count);
> +		{
> +			int i;
> +			for (i=0; i<count; i++)
> +				printk("%02x ", buf[i]);
> +			printk("\n");
> +		}
[ ... snip ... ]
> +	printk("hid_hw_raw_request(dev, %02x, buf, %d, %d, HID_REQ_SET_REPORT);\n",
> +	       buf[0], count, report_type);
> +	{
> +		int i;
> +		for (i=0; i<count; i++)
> +			printk("%02x ", buf[i]);
> +		printk("\n");
> +	}
> +

Both these need to go.

Maybe Frank or someone else would be willing to work on improving this 
patch. I am not applying it in this form.

Thanks,

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Turn Sony motion controller into RGB led
  2015-04-09 21:25     ` Turn Sony motion controller into RGB led Pavel Machek
  2015-04-09 21:50       ` Jiri Kosina
@ 2015-04-10  0:33       ` Frank Praznik
  2015-04-24 12:53         ` Pavel Machek
  2015-04-24 13:51         ` Pavel Machek
  1 sibling, 2 replies; 16+ messages in thread
From: Frank Praznik @ 2015-04-10  0:33 UTC (permalink / raw)
  To: Pavel Machek, Jiri Kosina
  Cc: vojtech, mike-, jslaby, dave, colin.leitner, kernel list, linux-input

On 4/9/2015 17:25, Pavel Machek wrote:
> Hi!
>
> I did not yet figure out how to get sensor data from the controller,
> but it works rather well as a RGB led.

Hi Pavel,

 From what I've read, the motion controller only sends sensor data when 
connected via bluetooth.
Otherwise it should be in report 1 with the buttons and other data.

Jiri already covered many of the issues, so just a couple of comments on 
top of what he already wrote:

>   
> -static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc,
> +static int motion_set_leds(struct hid_device *hdev, u8 r, u8 g, u8 b)
> +{
> +	int ret;
> +	struct motion_leds *buf = kzalloc(sizeof(struct motion_leds), GFP_KERNEL);

The other devices allocate this buffer up front and store it in 
output_report_dmabuf in the sony_sc struct
to avoid hitting the allocator every time an output report is sent. No 
reason why the motion controller can't
do the same.  Add an entry in sony_allocate_output_report() and it will 
be automatically freed when the
device is removed.

> +
> +	if (sizeof(struct motion_leds) != 7) {
> +		printk("Struct has bad size\n");
> +	}
> +

On the printk usage in general: the rest of the driver uses 
hid_info/hid_err to automatically format the output
string with the driver/device information when printing log messages.  
Use these instead of printk for consistency.
A lot of them should be removed anyways since they look like debugging 
leftovers.

If you can send a version without all of the unrelated underscore 
changes I'll help clean it up.  I don't own one of these controllers
though, so I can't help test the functionality.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Turn Sony motion controller into RGB led
  2015-04-10  0:33       ` Frank Praznik
@ 2015-04-24 12:53         ` Pavel Machek
  2015-04-24 13:51         ` Pavel Machek
  1 sibling, 0 replies; 16+ messages in thread
From: Pavel Machek @ 2015-04-24 12:53 UTC (permalink / raw)
  To: Frank Praznik
  Cc: Jiri Kosina, vojtech, mike-,
	jslaby, dave, colin.leitner, kernel list, linux-input

Hi!

> >I did not yet figure out how to get sensor data from the controller,
> >but it works rather well as a RGB led.
> 
> Hi Pavel,
> 
> From what I've read, the motion controller only sends sensor data when
> connected via bluetooth.
> Otherwise it should be in report 1 with the buttons and other data.

Aha, that would explain a lot.

> If you can send a version without all of the unrelated underscore changes
> I'll help clean it up.  I don't own one of these controllers
> though, so I can't help test the functionality.

Ok, if the offer is still valid, lets do that.

Best regards,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Turn Sony motion controller into RGB led
  2015-04-10  0:33       ` Frank Praznik
  2015-04-24 12:53         ` Pavel Machek
@ 2015-04-24 13:51         ` Pavel Machek
  1 sibling, 0 replies; 16+ messages in thread
From: Pavel Machek @ 2015-04-24 13:51 UTC (permalink / raw)
  To: Frank Praznik
  Cc: Jiri Kosina, vojtech, mike-,
	jslaby, dave, colin.leitner, kernel list, linux-input

Hi!

> If you can send a version without all of the unrelated underscore changes
> I'll help clean it up.  I don't own one of these controllers
> though, so I can't help test the functionality.

I cleaned some of the (easy) comments, and tested that it still
works. Here's the updated version. Thanks,

Signed-off-by: Pavel Machek <pavel@ucw.cz>
									Pavel


diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 722a925..1c5b515 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1958,15 +1958,16 @@ static const struct hid_device_id hid_have_special_driver[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER) },
-	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
-	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_SRWS1) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_THINGM, USB_DEVICE_ID_BLINK1) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 41f167e..d74243d 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -852,6 +852,7 @@
 #define USB_DEVICE_ID_SONY_PS3_CONTROLLER	0x0268
 #define USB_DEVICE_ID_SONY_PS4_CONTROLLER	0x05c4
 #define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER	0x042f
+#define USB_DEVICE_ID_SONY_MOTION_CONTROLLER	0x03d5
 #define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER		0x0002
 #define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER	0x1000
 
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 6ca96ce..08f97e6 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -46,20 +46,22 @@
 #define PS3REMOTE                 BIT(4)
 #define DUALSHOCK4_CONTROLLER_USB BIT(5)
 #define DUALSHOCK4_CONTROLLER_BT  BIT(6)
+#define MOTION_CONTROLLER	  BIT(7)
 
 #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT)
 #define DUALSHOCK4_CONTROLLER (DUALSHOCK4_CONTROLLER_USB |\
 				DUALSHOCK4_CONTROLLER_BT)
 #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\
-				DUALSHOCK4_CONTROLLER)
+				DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER)
 #define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER)
 #define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER)
 
 #define MAX_LEDS 4
 
+/* PS/3 SixAxis and DualShock controllers */
 static __u8 sixaxis_rdesc[] = {
 	0x05, 0x01,         /*  Usage Page (Desktop),               */
-	0x09, 0x04,         /*  Usage (Joystik),                    */
+	0x09, 0x04,         /*  Usage (Joystick),                   */
 	0xA1, 0x01,         /*  Collection (Application),           */
 	0xA1, 0x02,         /*      Collection (Logical),           */
 	0x85, 0x01,         /*          Report ID (1),              */
@@ -134,6 +136,85 @@ static __u8 sixaxis_rdesc[] = {
 	0xC0                /*  End Collection                      */
 };
 
+/* PS/3 Motion controller */
+static __u8 motion_rdesc[] = {
+	0x05, 0x01,         /*  Usage Page (Desktop),               */
+	0x09, 0x04,         /*  Usage (Joystick),                   */
+	0xA1, 0x01,         /*  Collection (Application),           */
+	0xA1, 0x02,         /*      Collection (Logical),           */
+	0x85, 0x01,         /*          Report ID (1),              */
+	0x75, 0x08,         /*          Report Size (8),            */
+	0x95, 0x01,         /*          Report Count (1),           */
+	0x15, 0x00,         /*          Logical Minimum (0),        */
+	0x26, 0xFF, 0x00,   /*          Logical Maximum (255),      */
+	0x81, 0x03,         /*          Input (Constant, Variable), */
+	0x75, 0x01,         /*          Report Size (1),            */
+	0x95, 0x13,         /*          Report Count (19),          */
+	0x15, 0x00,         /*          Logical Minimum (0),        */
+	0x25, 0x01,         /*          Logical Maximum (1),        */
+	0x35, 0x00,         /*          Physical Minimum (0),       */
+	0x45, 0x01,         /*          Physical Maximum (1),       */
+	0x05, 0x09,         /*          Usage Page (Button),        */
+	0x19, 0x01,         /*          Usage Minimum (01h),        */
+	0x29, 0x13,         /*          Usage Maximum (13h),        */
+	0x81, 0x02,         /*          Input (Variable),           */
+	0x75, 0x01,         /*          Report Size (1),            */
+	0x95, 0x0D,         /*          Report Count (13),          */
+	0x06, 0x00, 0xFF,   /*          Usage Page (FF00h),         */
+	0x81, 0x03,         /*          Input (Constant, Variable), */
+	0x15, 0x00,         /*          Logical Minimum (0),        */
+	0x26, 0xFF, 0x00,   /*          Logical Maximum (255),      */
+	0x05, 0x01,         /*          Usage Page (Desktop),       */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0xA1, 0x00,         /*          Collection (Physical),      */
+	0x75, 0x08,         /*              Report Size (8),        */
+	0x95, 0x04,         /*              Report Count (4),       */
+	0x35, 0x00,         /*              Physical Minimum (0),   */
+	0x46, 0xFF, 0x00,   /*              Physical Maximum (255), */
+	0x09, 0x30,         /*              Usage (X),              */
+	0x09, 0x31,         /*              Usage (Y),              */
+	0x09, 0x32,         /*              Usage (Z),              */
+	0x09, 0x35,         /*              Usage (Rz),             */
+	0x81, 0x02,         /*              Input (Variable),       */
+	0xC0,               /*          End Collection,             */
+	0x05, 0x01,         /*          Usage Page (Desktop),       */
+	0x95, 0x13,         /*          Report Count (19),          */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0x81, 0x02,         /*          Input (Variable),           */
+	0x95, 0x0C,         /*          Report Count (12),          */
+	0x81, 0x01,         /*          Input (Constant),           */
+	0x75, 0x10,         /*          Report Size (16),           */
+	0x95, 0x04,         /*          Report Count (4),           */
+	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
+	0x46, 0xFF, 0x03,   /*          Physical Maximum (1023),    */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0x81, 0x02,         /*          Input (Variable),           */
+	0xC0,               /*      End Collection,                 */
+	0xA1, 0x02,         /*      Collection (Logical),           */
+	0x85, 0x02,         /*          Report ID (2),              */
+	0x75, 0x08,         /*          Report Size (8),            */
+	0x95, 0x30,         /*          Report Count (48),          */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0xB1, 0x02,         /*          Feature (Variable),         */
+	0xC0,               /*      End Collection,                 */
+	0xA1, 0x02,         /*      Collection (Logical),           */
+	0x85, 0xEE,         /*          Report ID (238),            */
+	0x75, 0x08,         /*          Report Size (8),            */
+	0x95, 0x30,         /*          Report Count (48),          */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0xB1, 0x02,         /*          Feature (Variable),         */
+	0xC0,               /*      End Collection,                 */
+	0xA1, 0x02,         /*      Collection (Logical),           */
+	0x85, 0xEF,         /*          Report ID (239),            */
+	0x75, 0x08,         /*          Report Size (8),            */
+	0x95, 0x30,         /*          Report Count (48),          */
+	0x09, 0x01,         /*          Usage (Pointer),            */
+	0xB1, 0x02,         /*          Feature (Variable),         */
+	0xC0,               /*      End Collection,                 */
+	0xC0                /*  End Collection                      */
+};
+
+
 /*
  * The default descriptor doesn't provide mapping for the accelerometers
  * or orientation sensors.  This fixed descriptor maps the accelerometers
@@ -837,6 +918,13 @@ struct sony_sc {
 	__u8 led_count;
 };
 
+struct motion_leds {
+	u8 type, zero;
+	u8 r, g, b;
+	u8 zero2;
+	u8 rumble;
+};
+
 static __u8 *sixaxis_fixup(struct hid_device *hdev, __u8 *rdesc,
 			     unsigned int *rsize)
 {
@@ -844,6 +932,31 @@ static __u8 *sixaxis_fixup(struct hid_device *hdev, __u8 *rdesc,
 	return sixaxis_rdesc;
 }
 
+static int motion_set_leds(struct hid_device *hdev, u8 r, u8 g, u8 b)
+{
+	int ret;
+	struct motion_leds *buf = kzalloc(sizeof(struct motion_leds), GFP_KERNEL);
+
+	BUILD_BUG_ON(sizeof(struct motion_leds) != 7);
+
+	buf->type = 0x02; /* set leds */
+	buf->r = r;
+	buf->g = g;
+	buf->b = b;
+
+	ret = hid_hw_output_report(hdev, buf, sizeof(struct motion_leds));
+	kfree(buf);
+
+	return ret;
+}
+
+static u8 *motion_fixup(struct hid_device *hdev, u8 *rdesc,
+			     unsigned int *rsize)
+{
+	*rsize = sizeof(motion_rdesc);
+	return motion_rdesc;
+}
+
 static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc,
 			     unsigned int *rsize)
 {
@@ -890,6 +1003,8 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 {
 	struct sony_sc *sc = hid_get_drvdata(hdev);
 
+	printk("Got report with rsize %d\n", *rsize);
+
 	/*
 	 * Some Sony RF receivers wrongly declare the mouse pointer as a
 	 * a constant non-data variable.
@@ -924,6 +1039,9 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 	if (sc->quirks & SIXAXIS_CONTROLLER)
 		return sixaxis_fixup(hdev, rdesc, rsize);
 
+	if (sc->quirks & MOTION_CONTROLLER)
+		return motion_fixup(hdev, rdesc, rsize);
+
 	if (sc->quirks & PS3REMOTE)
 		return ps3remote_fixup(hdev, rdesc, rsize);
 
@@ -1037,6 +1155,8 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
 {
 	struct sony_sc *sc = hid_get_drvdata(hdev);
 
+	printk("sony_raw_event, size %d\n", size);
+
 	/*
 	 * Sixaxis HID report has acclerometers/gyro with MSByte first, this
 	 * has to be BYTE_SWAPPED before passing up to joystick interface
@@ -1280,11 +1400,12 @@ static void sony_set_leds(struct sony_sc *sc, const __u8 *leds, int count)
 
 	if (sc->quirks & BUZZ_CONTROLLER && count == 4) {
 		buzz_set_leds(sc->hdev, leds);
-	} else {
-		for (n = 0; n < count; n++)
-			sc->led_state[n] = leds[n];
-		schedule_work(&sc->state_worker);
+		return;
 	}
+
+	for (n = 0; n < count; n++)
+		sc->led_state[n] = leds[n];
+	schedule_work(&sc->state_worker);
 }
 
 static void sony_led_set_brightness(struct led_classdev *led,
@@ -1367,7 +1488,7 @@ static int sony_led_blink_set(struct led_classdev *led, unsigned long *delay_on,
 		return -EINVAL;
 	}
 
-	/* Max delay is 255 deciseconds or 2550 milliseconds */
+	/* Max delay is 2.55 seconds */
 	if (*delay_on > 2550)
 		*delay_on = 2550;
 	if (*delay_off > 2550)
@@ -1454,6 +1575,12 @@ static int sony_leds_init(struct sony_sc *sc)
 		use_ds4_names = 1;
 		name_len = 0;
 		name_fmt = "%s:%s";
+	} else if (sc->quirks & MOTION_CONTROLLER) {
+		sc->led_count = 3;
+		memset(max_brightness, 255, 3);
+		use_ds4_names = 1;
+		name_len = 0;
+		name_fmt = "%s:%s";
 	} else {
 		sixaxis_set_leds_from_id(sc->device_id, initial_values);
 		sc->led_count = 4;
@@ -1622,6 +1749,14 @@ static void dualshock4_state_worker(struct work_struct *work)
 				HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
 }
 
+static void motion_state_worker(struct work_struct *work)
+{
+	struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
+	struct hid_device *hdev = sc->hdev;
+
+	motion_set_leds(hdev, sc->led_state[0], sc->led_state[1], sc->led_state[2]);
+}
+
 static int sony_allocate_output_report(struct sony_sc *sc)
 {
 	if (sc->quirks & SIXAXIS_CONTROLLER)
@@ -1685,7 +1820,7 @@ static int sony_battery_get_property(struct power_supply *psy,
 	struct sony_sc *sc = power_supply_get_drvdata(psy);
 	unsigned long flags;
 	int ret = 0;
-	u8 battery_charging, battery_capacity, cable_state;
+	__u8 battery_charging, battery_capacity, cable_state;
 
 	spin_lock_irqsave(&sc->lock, flags);
 	battery_charging = sc->battery_charging;
@@ -2043,6 +2178,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		}
 
 		sony_init_work(sc, dualshock4_state_worker);
+	} else if (sc->quirks & MOTION_CONTROLLER) {
+		sony_init_work(sc, motion_state_worker);
 	} else {
 		ret = 0;
 	}
@@ -2123,6 +2260,8 @@ static const struct hid_device_id sony_devices[] = {
 		.driver_data = SIXAXIS_CONTROLLER_USB },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER),
 		.driver_data = SIXAXIS_CONTROLLER_USB },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER),
+		.driver_data = MOTION_CONTROLLER },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
 		.driver_data = SIXAXIS_CONTROLLER_BT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 9c2d7c2..1342b71 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -151,7 +151,14 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
 
 	if ((report_type == HID_OUTPUT_REPORT) &&
 	    !(dev->quirks & HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP)) {
+		printk("hid_hw_output_report(dev, buf, %d_REPORT);\n", count);
 		ret = hid_hw_output_report(dev, buf, count);
+		{
+			int i;
+			for (i=0; i<count; i++)
+				printk("%02x ", buf[i]);
+			printk("\n");
+		}
 		/*
 		 * compatibility with old implementation of USB-HID and I2C-HID:
 		 * if the device does not support receiving output reports,
@@ -161,6 +168,15 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
 			goto out_free;
 	}
 
+	printk("hid_hw_raw_request(dev, %02x, buf, %d, %d, HID_REQ_SET_REPORT);\n",
+	       buf[0], count, report_type);
+	{
+		int i;
+		for (i=0; i<count; i++)
+			printk("%02x ", buf[i]);
+		printk("\n");
+	}
+
 	ret = hid_hw_raw_request(dev, buf[0], buf, count, report_type,
 				HID_REQ_SET_REPORT);
 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-04-24 13:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-14 19:19 Fun with sony motion controllers: navigation controller Pavel Machek
2015-03-14 19:23 ` Fun with sony motion controllers: motion controller Pavel Machek
2015-03-14 20:53   ` Pavel Machek
2015-03-14 19:31 ` Fun with sony motion controllers: dualshock Pavel Machek
2015-03-14 19:47 ` Fun with sony motion controllers: navigation controller Pavel Machek
2015-03-14 20:54 ` [PATCH] hid-sony: underscores are unneccessary for u8, u16 Pavel Machek
2015-03-16 12:55 ` Fun with sony motion controllers: navigation controller Jiri Kosina
2015-03-16 13:05   ` Pavel Machek
2015-03-16 13:55     ` Jiri Kosina
2015-03-16 15:26       ` Frank Praznik
2015-03-16 22:28         ` Pavel Machek
2015-04-09 21:25     ` Turn Sony motion controller into RGB led Pavel Machek
2015-04-09 21:50       ` Jiri Kosina
2015-04-10  0:33       ` Frank Praznik
2015-04-24 12:53         ` Pavel Machek
2015-04-24 13:51         ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).