* [PATCH 0/5] Support for the Sony Motion Controller and other cleanups @ 2015-05-05 2:34 Frank Praznik 2015-05-05 2:34 ` [PATCH 1/5] hid: sony: Add the product ID for the Sony Motion Controller Frank Praznik ` (4 more replies) 0 siblings, 5 replies; 14+ messages in thread From: Frank Praznik @ 2015-05-05 2:34 UTC (permalink / raw) To: linux-input; +Cc: jkosina, pavel, Frank Praznik This set of patches adds initial support for the Sony Motion Controller via cleaned-up initial patches from Pavel Machek, streamlines LED initialization and state updates, adds a comment to explain why the Sixaxis has so many axes and why they spill over into the multi-touch space and makes some general cosmetic corrections. Pavel, could you test the motion controller patches? I didn't alter the basic logic from your patch so everything should work, but I'd like to make sure. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/5] hid: sony: Add the product ID for the Sony Motion Controller 2015-05-05 2:34 [PATCH 0/5] Support for the Sony Motion Controller and other cleanups Frank Praznik @ 2015-05-05 2:34 ` Frank Praznik 2015-05-05 2:34 ` [PATCH 2/5] hid: sony: Add support " Frank Praznik ` (3 subsequent siblings) 4 siblings, 0 replies; 14+ messages in thread From: Frank Praznik @ 2015-05-05 2:34 UTC (permalink / raw) To: linux-input; +Cc: jkosina, pavel, Frank Praznik Adds the PID for the Sony motion controller to the hardware ID list. Signed-off-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> --- drivers/hid/hid-core.c | 1 + drivers/hid/hid-ids.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 722a925..2cb9ac7 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1961,6 +1961,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_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_MOTION_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) }, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 41f167e..14fcb11 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -851,6 +851,7 @@ #define USB_DEVICE_ID_SONY_PS3_BDREMOTE 0x0306 #define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268 #define USB_DEVICE_ID_SONY_PS4_CONTROLLER 0x05c4 +#define USB_DEVICE_ID_SONY_MOTION_CONTROLLER 0x03d5 #define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f #define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002 #define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000 -- 2.1.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/5] hid: sony: Add support for the Sony Motion Controller 2015-05-05 2:34 [PATCH 0/5] Support for the Sony Motion Controller and other cleanups Frank Praznik 2015-05-05 2:34 ` [PATCH 1/5] hid: sony: Add the product ID for the Sony Motion Controller Frank Praznik @ 2015-05-05 2:34 ` Frank Praznik 2015-05-05 21:16 ` Pavel Machek 2015-05-05 2:34 ` [PATCH 3/5] hid: sony: Correct Sony device ordering Frank Praznik ` (2 subsequent siblings) 4 siblings, 1 reply; 14+ messages in thread From: Frank Praznik @ 2015-05-05 2:34 UTC (permalink / raw) To: linux-input; +Cc: jkosina, pavel, Frank Praznik Add a fixed-up HID descriptor for the Sony motion controller and enable controls for the LED light as well as force-feedback. The LED is multi-colored (red, green, blue) and has a 'global' control to allow it to be flashed or switched on an off atomically. The motion controller has a single rumble motor so the higher of the left and right values is used to set the speed. Signed-off-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> --- Pavel, can you please test this and make sure it works? This is basically Pavel's patch with the unrelated changes removed and a bit of additional functionality added. A 'global' LED control has been added to facilitate blinking and otherwise toggling the whole light on and off like on the Dualshock 4. It also adds rumble support since the device seems to support it. The device only has one rumble motor so the higher of the left and right values is used to set the speed. Both must be zero to stop the effect. drivers/hid/hid-sony.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 139 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 6ca96ce..4e5a067 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -46,14 +46,16 @@ #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 SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\ + MOTION_CONTROLLER) #define MAX_LEDS 4 @@ -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 @@ -798,6 +879,13 @@ union sixaxis_output_report_01 { __u8 buf[36]; }; +struct motion_output_report_02 { + u8 type, zero; + u8 r, g, b; + u8 zero2; + u8 rumble; +}; + #define DS4_REPORT_0x02_SIZE 37 #define DS4_REPORT_0x05_SIZE 32 #define DS4_REPORT_0x11_SIZE 78 @@ -844,6 +932,13 @@ static __u8 *sixaxis_fixup(struct hid_device *hdev, __u8 *rdesc, return sixaxis_rdesc; } +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) { @@ -924,6 +1019,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); @@ -1454,6 +1552,13 @@ 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) { + initial_values[3] = 1; + sc->led_count = 4; + 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 +1727,31 @@ 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; + struct motion_output_report_02 *report = + (struct motion_output_report_02 *)sc->output_report_dmabuf; + + memset(report, 0, sizeof(struct motion_output_report_02)); + + report->type = 0x02; /* set leds */ + + if (sc->led_state[3]) { + report->r = sc->led_state[0]; + report->g = sc->led_state[1]; + report->b = sc->led_state[2]; + } + +#ifdef CONFIG_SONY_FF + report->rumble = max(sc->right, sc->left); +#endif + + hid_hw_output_report(hdev, (__u8 *)report, + sizeof(struct motion_output_report_02)); +} + static int sony_allocate_output_report(struct sony_sc *sc) { if (sc->quirks & SIXAXIS_CONTROLLER) @@ -1634,6 +1764,9 @@ static int sony_allocate_output_report(struct sony_sc *sc) else if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) sc->output_report_dmabuf = kmalloc(DS4_REPORT_0x05_SIZE, GFP_KERNEL); + else if (sc->quirks & MOTION_CONTROLLER) + kmalloc(sizeof(struct motion_output_report_02), + GFP_KERNEL); else return 0; @@ -2043,6 +2176,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 +2258,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), -- 2.1.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] hid: sony: Add support for the Sony Motion Controller 2015-05-05 2:34 ` [PATCH 2/5] hid: sony: Add support " Frank Praznik @ 2015-05-05 21:16 ` Pavel Machek 2015-05-05 21:24 ` Pavel Machek ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Pavel Machek @ 2015-05-05 21:16 UTC (permalink / raw) To: Frank Praznik; +Cc: linux-input, jkosina Hi! > Add a fixed-up HID descriptor for the Sony motion controller and enable > controls for the LED light as well as force-feedback. > > The LED is multi-colored (red, green, blue) and has a 'global' control to > allow it to be flashed or switched on an off atomically. > > The motion controller has a single rumble motor so the higher of the left and > right values is used to set the speed. > > Signed-off-by: Pavel Machek <pavel@ucw.cz> > Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> > --- > > Pavel, can you please test this and make sure it works? I tried (on 4.1-rc2), and got this (full dmesg in attachment) Best regards, Pavel [ 1036.146757] perf interrupt took too long (2508 > 2500), lowering kernel.perf_event_max_sample_rate to 50000 [12720.492126] usb 4-1: new full-speed USB device number 2 using uhci_hcd [12720.659184] usb 4-1: New USB device found, idVendor=054c, idProduct=03d5 [12720.659194] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [12720.659199] usb 4-1: Product: Motion Controller [12720.659205] usb 4-1: Manufacturer: Sony Computer Entertainment [12739.603968] input: Sony Computer Entertainment Motion Controller as /devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0/0003:054C:03D5.0001/input/input9 [12739.605801] sony 0003:054C:03D5.0001: input,hidraw0: USB HID v1.10 Joystick [Sony Computer Entertainment Motion Controller] on usb-0000:00:1d.2-1/input0 [12739.605810] sony 0003:054C:03D5.0001: failed to allocate the output report buffer [12739.605814] ------------[ cut here ]------------ [12739.605827] WARNING: CPU: 1 PID: 10116 at lib/idr.c:1051 ida_remove+0xc7/0x100() [12739.605830] ida_remove called for id=0 which is not allocated. [12739.605832] Modules linked in: hid_sony(+) [12739.605841] CPU: 1 PID: 10116 Comm: insmod Tainted: G W 4.1.0-rc2+ #71 [12739.605844] Hardware name: LENOVO 17097HU/17097HU, BIOS 7BETD8WW (2.19 ) 03/31/2011 [12739.605848] 00000001 00000000 c1051c70 c489988f c1051c9c c1051c8c c403da7b 0000041b [12739.605861] c42be347 00000000 00000000 f85b20c0 c1051ca4 c403dad6 00000009 c1051c9c [12739.605873] c4b040dc c1051cb8 c1051cd0 c42be347 c4b04063 0000041b c4b040dc 00000000 [12739.605885] Call Trace: [12739.605892] [<c489988f>] dump_stack+0x41/0x52 [12739.605900] [<c403da7b>] warn_slowpath_common+0x6b/0xa0 [12739.605905] [<c42be347>] ? ida_remove+0xc7/0x100 [12739.605909] [<c403dad6>] warn_slowpath_fmt+0x26/0x30 [12739.605914] [<c42be347>] ida_remove+0xc7/0x100 [12739.605918] [<c42becf3>] ida_simple_remove+0x23/0x40 [12739.605926] [<f85b00ea>] sony_probe+0x45a/0xdc0 [hid_sony] [12739.605933] [<c4645668>] ? hid_match_device+0x68/0x80 [12739.605938] [<c4645676>] ? hid_match_device+0x76/0x80 [12739.605944] [<f85afc90>] ? sony_led_set_brightness+0xb0/0xb0 [hid_sony] [12739.605948] [<c464572b>] hid_device_probe+0xab/0x120 [12739.605954] [<c44610de>] driver_probe_device+0x11e/0x400 [12739.605958] [<c4645676>] ? hid_match_device+0x76/0x80 [12739.605962] [<c4461479>] __driver_attach+0x79/0x80 [12739.605966] [<c4461479>] ? __driver_attach+0x79/0x80 [12739.605970] [<c4461400>] ? __device_attach+0x40/0x40 [12739.605975] [<c445f4ff>] bus_for_each_dev+0x4f/0x80 [12739.605980] [<c4460b44>] driver_attach+0x14/0x20 [12739.605983] [<c4461400>] ? __device_attach+0x40/0x40 [12739.605987] [<c44607bf>] bus_add_driver+0x14f/0x220 [12739.605991] [<c42bf9dd>] ? kset_find_obj+0x4d/0xa0 [12739.605995] [<c44619e1>] driver_register+0x51/0xd0 [12739.605998] [<f85bd000>] ? 0xf85bd000 [12739.606002] [<c44619e1>] ? driver_register+0x51/0xd0 [12739.606006] [<c46433fe>] __hid_register_driver+0x3e/0x80 [12739.606012] [<f85bd037>] sony_init+0x37/0x1000 [hid_sony] [12739.606017] [<c4000442>] do_one_initcall+0xc2/0x1c0 [12739.606024] [<c40f948f>] ? cache_free_debugcheck+0xff/0x340 [12739.606029] [<c40f8609>] ? cache_alloc_debugcheck_after.isra.62+0x59/0x270 [12739.606035] [<c4898eaf>] ? do_init_module+0x17/0x190 [12739.606039] [<c4898eaf>] ? do_init_module+0x17/0x190 [12739.606044] [<c4898ede>] do_init_module+0x46/0x190 [12739.606048] [<c4898ede>] ? do_init_module+0x46/0x190 [12739.606055] [<c40ac9b3>] load_module+0x1813/0x1f30 [12739.606060] [<c40ad276>] SyS_finit_module+0x86/0xb0 [12739.606065] [<c40ad276>] ? SyS_finit_module+0x86/0xb0 [12739.606071] [<c4076f76>] ? up_write+0x16/0x40 [12739.606077] [<c48a205e>] syscall_call+0x7/0x7 [12739.606081] [<c48a205e>] ? syscall_call+0x7/0x7 [12739.606084] ---[ end trace ea8932ed620e4999 ]--- [12739.637922] sony: probe of 0003:054C:03D5.0001 failed with error -12 -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] hid: sony: Add support for the Sony Motion Controller 2015-05-05 21:16 ` Pavel Machek @ 2015-05-05 21:24 ` Pavel Machek 2015-05-05 21:36 ` Pavel Machek 2015-05-05 23:28 ` Frank Praznik 2 siblings, 0 replies; 14+ messages in thread From: Pavel Machek @ 2015-05-05 21:24 UTC (permalink / raw) To: Frank Praznik; +Cc: linux-input, jkosina On Tue 2015-05-05 23:16:40, Pavel Machek wrote: > Hi! > > > Add a fixed-up HID descriptor for the Sony motion controller and enable > > controls for the LED light as well as force-feedback. > > > > The LED is multi-colored (red, green, blue) and has a 'global' control to > > allow it to be flashed or switched on an off atomically. Oh... I don't think the global control at this level is good idea. Let me test how it works, but assigning different triggers to global and red would be interesting, for example. > > The motion controller has a single rumble motor so the higher of the left and > > right values is used to set the speed. > > > > Signed-off-by: Pavel Machek <pavel@ucw.cz> > > Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> > > --- > > > > Pavel, can you please test this and make sure it works? > > I tried (on 4.1-rc2), and got this (full dmesg in attachment) Ok, that one was easy. Now it registers but the LEDs do not light. Pavel diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 46e4ceb..09a8328 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -1770,7 +1770,7 @@ static int sony_allocate_output_report(struct sony_sc *sc) sc->output_report_dmabuf = kmalloc(DS4_REPORT_0x05_SIZE, GFP_KERNEL); else if (sc->quirks & MOTION_CONTROLLER) - kmalloc(sizeof(struct motion_output_report_02), + sc->output_report_dmabuf = kmalloc(sizeof(struct motion_output_report_02), GFP_KERNEL); else return 0; -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] hid: sony: Add support for the Sony Motion Controller 2015-05-05 21:16 ` Pavel Machek 2015-05-05 21:24 ` Pavel Machek @ 2015-05-05 21:36 ` Pavel Machek 2015-05-05 21:47 ` Pavel Machek 2015-05-05 23:28 ` Frank Praznik 2 siblings, 1 reply; 14+ messages in thread From: Pavel Machek @ 2015-05-05 21:36 UTC (permalink / raw) To: Frank Praznik; +Cc: linux-input, jkosina On Tue 2015-05-05 23:16:40, Pavel Machek wrote: > Hi! > > > Add a fixed-up HID descriptor for the Sony motion controller and enable > > controls for the LED light as well as force-feedback. > > > > The LED is multi-colored (red, green, blue) and has a 'global' control to > > allow it to be flashed or switched on an off atomically. Ok, I spoke too fast. It does work, somehow, as long as I keep the global control on (with the kmalloc fix). But for example this does not produce the desired result: root@duo:/sys/class/leds/0003:054C:03D5.0002:global# echo hearbeat > trigger root@duo:/sys/class/leds/0003:054C:03D5.0002:global# cd .. root@duo:/sys/class/leds# cd 0003\:054C\:03D5.0002\:red root@duo:/sys/class/leds/0003:054C:03D5.0002:red# cat brightness 255 root@duo:/sys/class/leds/0003:054C:03D5.0002:red# (Hm. It sometimes works somehow. Weird.) Yes, I believe we should eventually support RGB ways in some nice way, but no, having "global" LED "and-ed" with the color LEDs does not seem like a good way to me. The "global" brightness is ignored, only zero / non zero matters. It is not a real LED. RGB support should really be done at LED core, as more than one driver needs it. > > The motion controller has a single rumble motor so the higher of the left and > > right values is used to set the speed. Not sure how this is expected to work. I tried: (and did not get any vibrations). Thanks, Pavel root@duo:/sys/class/leds/0003:054C:03D5.0002:red# evtest /dev/input/event8 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) Event code 288 (BTN_TRIGGER) Event code 289 (BTN_THUMB) Event code 290 (BTN_THUMB2) Event code 291 (BTN_TOP) Event code 292 (BTN_TOP2) Event code 293 (BTN_PINKIE) Event code 294 (BTN_BASE) Event code 295 (BTN_BASE2) Event code 296 (BTN_BASE3) Event code 297 (BTN_BASE4) Event code 298 (BTN_BASE5) Event code 299 (BTN_BASE6) Event code 300 (?) Event code 301 (?) Event code 302 (?) Event code 303 (BTN_DEAD) Event code 704 (BTN_TRIGGER_HAPPY1) Event code 705 (BTN_TRIGGER_HAPPY2) Event code 706 (BTN_TRIGGER_HAPPY3) Event type 3 (EV_ABS) Event code 0 (ABS_X) Value 0 Min 0 Max 255 Flat 15 Event code 1 (ABS_Y) Value 0 Min 0 Max 255 Flat 15 Event code 2 (ABS_Z) Value 0 Min 0 Max 255 Flat 15 Event code 5 (ABS_RZ) Value 0 Min 0 Max 255 Flat 15 Event code 40 (ABS_MISC) Value 0 Min 0 Max 255 Flat 15 Event code 41 (?) Value 0 Min 0 Max 255 Flat 15 Event code 42 (?) Value 0 Min 0 Max 255 Flat 15 Event code 43 (?) Value 0 Min 0 Max 255 Flat 15 Event code 44 (?) Value 0 Min 0 Max 255 Flat 15 Event code 45 (?) Value 0 Min 0 Max 255 Flat 15 Event code 46 (?) Value 0 Min 0 Max 255 Flat 15 Event code 47 (ABS_MT_SLOT) Value 0 Min 0 Max 255 Flat 15 Event code 48 (ABS_MT_TOUCH_MAJOR) Value 0 Min 0 Max 255 Flat 15 Event code 49 (ABS_MT_TOUCH_MINOR) Value 0 Min 0 Max 255 Flat 15 Event code 50 (ABS_MT_WIDTH_MAJOR) Value 0 Min 0 Max 255 Flat 15 Event code 51 (ABS_MT_WIDTH_MINOR) Value 0 Min 0 Max 255 Flat 15 Event code 52 (ABS_MT_ORIENTATION) Value 0 Min 0 Max 255 Flat 15 Event code 53 (ABS_MT_POSITION_X) Value 0 Min 0 Max 255 Flat 15 Event code 54 (ABS_MT_POSITION_Y) Value 0 Min 0 Max 255 Flat 15 Event code 55 (ABS_MT_TOOL_TYPE) Value 0 Min 0 Max 255 Flat 15 Event code 56 (ABS_MT_BLOB_ID) Value 0 Min 0 Max 255 Flat 15 Event code 57 (ABS_MT_TRACKING_ID) Value 0 Min 0 Max 255 Flat 15 Event code 58 (ABS_MT_PRESSURE) Value 0 Min 0 Max 255 Flat 15 Event code 59 (ABS_MT_DISTANCE) Value 0 Min 0 Max 1023 Fuzz 3 Flat 63 Event code 60 (ABS_MT_TOOL_X) Value 0 Min 0 Max 1023 Fuzz 3 Flat 63 Event code 61 (ABS_MT_TOOL_Y) Value 0 Min 0 Max 1023 Fuzz 3 Flat 63 Event code 62 (?) Value 0 Min 0 Max 1023 Fuzz 3 Flat 63 Event type 4 (EV_MSC) Event code 4 (MSC_SCAN) Event type 21 (EV_FF) Event code 80 (FF_RUMBLE) Event code 81 (FF_PERIODIC) Event code 88 (FF_SQUARE) Event code 89 (FF_TRIANGLE) Event code 90 (FF_SINE) Event code 96 (FF_GAIN) Properties: Testing ... (interrupt to exit) ^C root@duo:/sys/class/leds/0003:054C:03D5.0002:red# echo 5 | fftest /dev/input/event2 Force feedback test program. HOLD FIRMLY YOUR WHEEL OR JOYSTICK TO PREVENT DAMAGES Device /dev/input/event2 opened Features: * Absolute axes: [00 00 00 00 00 00 00 00 ] * 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 Now Playing: Weak Rumble Enter effect number, -1 to exit Read error Stopping effects root@duo:/sys/class/leds/0003:054C:03D5.0002:red# > > Signed-off-by: Pavel Machek <pavel@ucw.cz> > > Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> > > --- > > > > Pavel, can you please test this and make sure it works? > > I tried (on 4.1-rc2), and got this (full dmesg in attachment) > > Best regards, > Pavel > > > [ 1036.146757] perf interrupt took too long (2508 > 2500), lowering kernel.perf_event_max_sample_rate to 50000 > [12720.492126] usb 4-1: new full-speed USB device number 2 using uhci_hcd > [12720.659184] usb 4-1: New USB device found, idVendor=054c, idProduct=03d5 > [12720.659194] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 > [12720.659199] usb 4-1: Product: Motion Controller > [12720.659205] usb 4-1: Manufacturer: Sony Computer Entertainment > [12739.603968] input: Sony Computer Entertainment Motion Controller as /devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0/0003:054C:03D5.0001/input/input9 > [12739.605801] sony 0003:054C:03D5.0001: input,hidraw0: USB HID v1.10 Joystick [Sony Computer Entertainment Motion Controller] on usb-0000:00:1d.2-1/input0 > [12739.605810] sony 0003:054C:03D5.0001: failed to allocate the output report buffer > [12739.605814] ------------[ cut here ]------------ > [12739.605827] WARNING: CPU: 1 PID: 10116 at lib/idr.c:1051 ida_remove+0xc7/0x100() > [12739.605830] ida_remove called for id=0 which is not allocated. > [12739.605832] Modules linked in: hid_sony(+) > [12739.605841] CPU: 1 PID: 10116 Comm: insmod Tainted: G W 4.1.0-rc2+ #71 > [12739.605844] Hardware name: LENOVO 17097HU/17097HU, BIOS 7BETD8WW (2.19 ) 03/31/2011 > [12739.605848] 00000001 00000000 c1051c70 c489988f c1051c9c c1051c8c c403da7b 0000041b > [12739.605861] c42be347 00000000 00000000 f85b20c0 c1051ca4 c403dad6 00000009 c1051c9c > [12739.605873] c4b040dc c1051cb8 c1051cd0 c42be347 c4b04063 0000041b c4b040dc 00000000 > [12739.605885] Call Trace: > [12739.605892] [<c489988f>] dump_stack+0x41/0x52 > [12739.605900] [<c403da7b>] warn_slowpath_common+0x6b/0xa0 > [12739.605905] [<c42be347>] ? ida_remove+0xc7/0x100 > [12739.605909] [<c403dad6>] warn_slowpath_fmt+0x26/0x30 > [12739.605914] [<c42be347>] ida_remove+0xc7/0x100 > [12739.605918] [<c42becf3>] ida_simple_remove+0x23/0x40 > [12739.605926] [<f85b00ea>] sony_probe+0x45a/0xdc0 [hid_sony] > [12739.605933] [<c4645668>] ? hid_match_device+0x68/0x80 > [12739.605938] [<c4645676>] ? hid_match_device+0x76/0x80 > [12739.605944] [<f85afc90>] ? sony_led_set_brightness+0xb0/0xb0 [hid_sony] > [12739.605948] [<c464572b>] hid_device_probe+0xab/0x120 > [12739.605954] [<c44610de>] driver_probe_device+0x11e/0x400 > [12739.605958] [<c4645676>] ? hid_match_device+0x76/0x80 > [12739.605962] [<c4461479>] __driver_attach+0x79/0x80 > [12739.605966] [<c4461479>] ? __driver_attach+0x79/0x80 > [12739.605970] [<c4461400>] ? __device_attach+0x40/0x40 > [12739.605975] [<c445f4ff>] bus_for_each_dev+0x4f/0x80 > [12739.605980] [<c4460b44>] driver_attach+0x14/0x20 > [12739.605983] [<c4461400>] ? __device_attach+0x40/0x40 > [12739.605987] [<c44607bf>] bus_add_driver+0x14f/0x220 > [12739.605991] [<c42bf9dd>] ? kset_find_obj+0x4d/0xa0 > [12739.605995] [<c44619e1>] driver_register+0x51/0xd0 > [12739.605998] [<f85bd000>] ? 0xf85bd000 > [12739.606002] [<c44619e1>] ? driver_register+0x51/0xd0 > [12739.606006] [<c46433fe>] __hid_register_driver+0x3e/0x80 > [12739.606012] [<f85bd037>] sony_init+0x37/0x1000 [hid_sony] > [12739.606017] [<c4000442>] do_one_initcall+0xc2/0x1c0 > [12739.606024] [<c40f948f>] ? cache_free_debugcheck+0xff/0x340 > [12739.606029] [<c40f8609>] ? cache_alloc_debugcheck_after.isra.62+0x59/0x270 > [12739.606035] [<c4898eaf>] ? do_init_module+0x17/0x190 > [12739.606039] [<c4898eaf>] ? do_init_module+0x17/0x190 > [12739.606044] [<c4898ede>] do_init_module+0x46/0x190 > [12739.606048] [<c4898ede>] ? do_init_module+0x46/0x190 > [12739.606055] [<c40ac9b3>] load_module+0x1813/0x1f30 > [12739.606060] [<c40ad276>] SyS_finit_module+0x86/0xb0 > [12739.606065] [<c40ad276>] ? SyS_finit_module+0x86/0xb0 > [12739.606071] [<c4076f76>] ? up_write+0x16/0x40 > [12739.606077] [<c48a205e>] syscall_call+0x7/0x7 > [12739.606081] [<c48a205e>] ? syscall_call+0x7/0x7 > [12739.606084] ---[ end trace ea8932ed620e4999 ]--- > [12739.637922] sony: probe of 0003:054C:03D5.0001 failed with error -12 > > > -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] hid: sony: Add support for the Sony Motion Controller 2015-05-05 21:36 ` Pavel Machek @ 2015-05-05 21:47 ` Pavel Machek 2015-05-05 21:55 ` Pavel Machek 2015-05-05 23:37 ` Frank Praznik 0 siblings, 2 replies; 14+ messages in thread From: Pavel Machek @ 2015-05-05 21:47 UTC (permalink / raw) To: Frank Praznik; +Cc: linux-input, jkosina Hi! > Not sure how this is expected to work. I tried: (and did not get any > vibrations). Hmm. Seems I tried wrong device. But no vibrations with the right device, either: root@duo:/sys/class/leds/0003:054C:03D5.0002:global# echo 4 | fftest /dev/input/event8 Force feedback test program. HOLD FIRMLY YOUR WHEEL OR JOYSTICK TO PREVENT DAMAGES Device /dev/input/event8 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: Periodic, Rumble, Gain, Force feedback periodic effects: Square, Triangle, Sine, [00 00 00 00 00 00 00 00 00 00 03 07 01 00 00 00 ] * Number of simultaneous effects: 16 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 Now Playing: Strong Rumble Enter effect number, -1 to exit Read error Stopping effects root@duo:/sys/class/leds/0003:054C:03D5.0002:global# If it has just one motor, should it say so in the description? Not advertising both heavy and light motor. If I do this, I can control vibrations using the "red" led. Value of 70 is lowest that produces anything... Best regards, Pavel diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 46e4ceb..de02a35 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -1751,6 +1751,8 @@ static void motion_state_worker(struct work_struct *work) #ifdef CONFIG_SONY_FF report->rumble = max(sc->right, sc->left); + report->rumble = report->r; + printk("Rumble: %d\n", report->r); #endif hid_hw_output_report(hdev, (__u8 *)report, @@ -1770,7 +1772,7 @@ static int sony_allocate_output_report(struct sony_sc *sc) sc->output_report_dmabuf = kmalloc(DS4_REPORT_0x05_SIZE, GFP_KERNEL); else if (sc->quirks & MOTION_CONTROLLER) - kmalloc(sizeof(struct motion_output_report_02), + sc->output_report_dmabuf = kmalloc(sizeof(struct motion_output_report_02), GFP_KERNEL); else return 0; -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] hid: sony: Add support for the Sony Motion Controller 2015-05-05 21:47 ` Pavel Machek @ 2015-05-05 21:55 ` Pavel Machek 2015-05-05 23:37 ` Frank Praznik 1 sibling, 0 replies; 14+ messages in thread From: Pavel Machek @ 2015-05-05 21:55 UTC (permalink / raw) To: Frank Praznik; +Cc: linux-input, jkosina Hi! > root@duo:/sys/class/leds/0003:054C:03D5.0002:global# echo 4 | fftest > /dev/input/event8 > Force feedback test program. > HOLD FIRMLY YOUR WHEEL OR JOYSTICK TO PREVENT DAMAGES > > Device /dev/input/event8 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: Periodic, Rumble, Gain, > Force feedback periodic effects: Square, Triangle, > Sine, > [00 00 00 00 00 00 00 00 00 00 03 07 01 00 00 00 > ] > * Number of simultaneous effects: 16 > > 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 > Now Playing: Strong Rumble > Enter effect number, -1 to exit > Read error > Stopping effects > root@duo:/sys/class/leds/0003:054C:03D5.0002:global# > > If it has just one motor, should it say so in the description? Not > advertising both heavy and light motor. Umm. Using echo with fftest was not good idea. Using it from command line, it works normally. Thanks and sorry for confusion, 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] 14+ messages in thread
* Re: [PATCH 2/5] hid: sony: Add support for the Sony Motion Controller 2015-05-05 21:47 ` Pavel Machek 2015-05-05 21:55 ` Pavel Machek @ 2015-05-05 23:37 ` Frank Praznik 2015-05-06 9:31 ` Pavel Machek 1 sibling, 1 reply; 14+ messages in thread From: Frank Praznik @ 2015-05-05 23:37 UTC (permalink / raw) To: Pavel Machek, Frank Praznik; +Cc: linux-input, jkosina On 5/5/2015 17:47, Pavel Machek wrote: > If it has just one motor, should it say so in the description? Not > advertising both heavy and light motor. > The FF_RUMBLE flag exposes two motors by default and there doesn't seem to be a way to change it. This is how the Wiimote with a single motor works (FF_RUMBLE and treating the strong/weak motors as one). Would one of the other effects be more suitable? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] hid: sony: Add support for the Sony Motion Controller 2015-05-05 23:37 ` Frank Praznik @ 2015-05-06 9:31 ` Pavel Machek 0 siblings, 0 replies; 14+ messages in thread From: Pavel Machek @ 2015-05-06 9:31 UTC (permalink / raw) To: Frank Praznik; +Cc: Frank Praznik, linux-input, jkosina On Tue 2015-05-05 19:37:34, Frank Praznik wrote: > On 5/5/2015 17:47, Pavel Machek wrote: > >If it has just one motor, should it say so in the description? Not > >advertising both heavy and light motor. > > > > The FF_RUMBLE flag exposes two motors by default and there doesn't seem to > be a way to change it. > > This is how the Wiimote with a single motor works (FF_RUMBLE and treating > the strong/weak motors as one). Would one of the other effects be more > suitable? I don't know enough about the force feedback subsystem, sorry. I guess it is okay as it is, then... Thanks for all the work! 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] 14+ messages in thread
* Re: [PATCH 2/5] hid: sony: Add support for the Sony Motion Controller 2015-05-05 21:16 ` Pavel Machek 2015-05-05 21:24 ` Pavel Machek 2015-05-05 21:36 ` Pavel Machek @ 2015-05-05 23:28 ` Frank Praznik 2 siblings, 0 replies; 14+ messages in thread From: Frank Praznik @ 2015-05-05 23:28 UTC (permalink / raw) To: Pavel Machek, Frank Praznik; +Cc: linux-input, jkosina On 5/5/2015 17:16, Pavel Machek wrote: > Hi! > >> Add a fixed-up HID descriptor for the Sony motion controller and enable >> controls for the LED light as well as force-feedback. >> >> The LED is multi-colored (red, green, blue) and has a 'global' control to >> allow it to be flashed or switched on an off atomically. >> >> The motion controller has a single rumble motor so the higher of the left and >> right values is used to set the speed. >> >> Signed-off-by: Pavel Machek <pavel@ucw.cz> >> Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> >> --- >> >> Pavel, can you please test this and make sure it works? > I tried (on 4.1-rc2), and got this (full dmesg in attachment) > > Best regards, > Pavel > <snip> Ack, sorry about that mistake. On the plus side, it uncovered a mishandled failure path in the initialization function. I'll add a patch for that in v2 of the series. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/5] hid: sony: Correct Sony device ordering 2015-05-05 2:34 [PATCH 0/5] Support for the Sony Motion Controller and other cleanups Frank Praznik 2015-05-05 2:34 ` [PATCH 1/5] hid: sony: Add the product ID for the Sony Motion Controller Frank Praznik 2015-05-05 2:34 ` [PATCH 2/5] hid: sony: Add support " Frank Praznik @ 2015-05-05 2:34 ` Frank Praznik 2015-05-05 2:34 ` [PATCH 4/5] hid: sony: Simplify LED initialization and eliminate redundant copies when updating LED states Frank Praznik 2015-05-05 2:34 ` [PATCH 5/5] hid: sony: Correct a typo in a HID descriptor comment and explain the odd Sixaxis axis mapping Frank Praznik 4 siblings, 0 replies; 14+ messages in thread From: Frank Praznik @ 2015-05-05 2:34 UTC (permalink / raw) To: linux-input; +Cc: jkosina, pavel, Frank Praznik Rearrange Sony controller devices into alphabetical order in the hardware device list. Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> --- drivers/hid/hid-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 2cb9ac7..aefb248 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1959,10 +1959,10 @@ static const struct hid_device_id hid_have_special_driver[] = { { 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_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_MOTION_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_BDREMOTE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_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) }, -- 2.1.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/5] hid: sony: Simplify LED initialization and eliminate redundant copies when updating LED states 2015-05-05 2:34 [PATCH 0/5] Support for the Sony Motion Controller and other cleanups Frank Praznik ` (2 preceding siblings ...) 2015-05-05 2:34 ` [PATCH 3/5] hid: sony: Correct Sony device ordering Frank Praznik @ 2015-05-05 2:34 ` Frank Praznik 2015-05-05 2:34 ` [PATCH 5/5] hid: sony: Correct a typo in a HID descriptor comment and explain the odd Sixaxis axis mapping Frank Praznik 4 siblings, 0 replies; 14+ messages in thread From: Frank Praznik @ 2015-05-05 2:34 UTC (permalink / raw) To: linux-input; +Cc: jkosina, pavel, Frank Praznik Directly set the initial LED states in the device state struct instead of copying them from a temporary array. This allows for the removal of a redundant "x = x" copy loop in sony_set_leds() that was taking place any time an LED was updated. It also allows for the simplifying of the parameters in functions dealing with LED initialization and updates since only a pointer to the sony_sc struct is needed now. Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> --- This completely removes the mostly useless loop in sony_set_leds() and streamlines other LED related functions in the process. drivers/hid/hid-sony.c | 60 ++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 4e5a067..266bac2 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -1306,7 +1306,7 @@ 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(struct sony_sc *sc) { static const __u8 sixaxis_leds[10][4] = { { 0x01, 0x00, 0x00, 0x00 }, @@ -1321,16 +1321,18 @@ static void sixaxis_set_leds_from_id(int id, __u8 values[MAX_LEDS]) { 0x01, 0x01, 0x01, 0x01 } }; - BUG_ON(MAX_LEDS < ARRAY_SIZE(sixaxis_leds[0])); + int id = sc->device_id; + + BUILD_BUG_ON(MAX_LEDS < ARRAY_SIZE(sixaxis_leds[0])); if (id < 0) return; id %= 10; - memcpy(values, sixaxis_leds[id], sizeof(sixaxis_leds[id])); + memcpy(sc->led_state, 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(struct sony_sc *sc) { /* The first 4 color/index entries match what the PS4 assigns */ static const __u8 color_code[7][3] = { @@ -1343,46 +1345,44 @@ static void dualshock4_set_leds_from_id(int id, __u8 values[MAX_LEDS]) /* White */ { 0x01, 0x01, 0x01 } }; - BUG_ON(MAX_LEDS < ARRAY_SIZE(color_code[0])); + int id = sc->device_id; + + BUILD_BUG_ON(MAX_LEDS < ARRAY_SIZE(color_code[0])); if (id < 0) return; id %= 7; - memcpy(values, color_code[id], sizeof(color_code[id])); + memcpy(sc->led_state, 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 sony_sc *sc) { + struct hid_device *hdev = sc->hdev; struct list_head *report_list = &hdev->report_enum[HID_OUTPUT_REPORT].report_list; struct hid_report *report = list_entry(report_list->next, struct hid_report, list); __s32 *value = report->field[0]->value; + BUILD_BUG_ON(MAX_LEDS < 4); + value[0] = 0x00; - value[1] = leds[0] ? 0xff : 0x00; - value[2] = leds[1] ? 0xff : 0x00; - value[3] = leds[2] ? 0xff : 0x00; - value[4] = leds[3] ? 0xff : 0x00; + value[1] = sc->led_state[0] ? 0xff : 0x00; + value[2] = sc->led_state[1] ? 0xff : 0x00; + value[3] = sc->led_state[2] ? 0xff : 0x00; + value[4] = sc->led_state[3] ? 0xff : 0x00; value[5] = 0x00; value[6] = 0x00; 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) { - int n; - - BUG_ON(count > MAX_LEDS); - - 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]; + if (!(sc->quirks & BUZZ_CONTROLLER)) schedule_work(&sc->state_worker); - } + else + buzz_set_leds(sc); } static void sony_led_set_brightness(struct led_classdev *led, @@ -1422,8 +1422,7 @@ static void sony_led_set_brightness(struct led_classdev *led, drv_data->led_delay_on[n] = 0; drv_data->led_delay_off[n] = 0; - sony_set_leds(drv_data, drv_data->led_state, - drv_data->led_count); + sony_set_leds(drv_data); break; } } @@ -1529,7 +1528,6 @@ 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 }; @@ -1544,8 +1542,8 @@ static int sony_leds_init(struct sony_sc *sc) if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7)) return -ENODEV; } else if (sc->quirks & DUALSHOCK4_CONTROLLER) { - dualshock4_set_leds_from_id(sc->device_id, initial_values); - initial_values[3] = 1; + dualshock4_set_leds_from_id(sc); + sc->led_state[3] = 1; sc->led_count = 4; memset(max_brightness, 255, 3); use_hw_blink[3] = 1; @@ -1553,14 +1551,14 @@ static int sony_leds_init(struct sony_sc *sc) name_len = 0; name_fmt = "%s:%s"; } else if (sc->quirks & MOTION_CONTROLLER) { - initial_values[3] = 1; + sc->led_state[3] = 1; sc->led_count = 4; 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); + sixaxis_set_leds_from_id(sc); sc->led_count = 4; memset(use_hw_blink, 1, 4); use_ds4_names = 0; @@ -1573,7 +1571,7 @@ static int sony_leds_init(struct sony_sc *sc) * only relevant if the driver is loaded after somebody actively set the * LEDs to on */ - sony_set_leds(sc, initial_values, sc->led_count); + sony_set_leds(sc); name_sz = strlen(dev_name(&hdev->dev)) + name_len + 1; @@ -1596,7 +1594,7 @@ static int sony_leds_init(struct sony_sc *sc) else snprintf(name, name_sz, name_fmt, dev_name(&hdev->dev), n + 1); led->name = name; - led->brightness = initial_values[n]; + led->brightness = sc->led_state[n]; led->max_brightness = max_brightness[n]; led->brightness_get = sony_led_get_brightness; led->brightness_set = sony_led_set_brightness; -- 2.1.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 5/5] hid: sony: Correct a typo in a HID descriptor comment and explain the odd Sixaxis axis mapping 2015-05-05 2:34 [PATCH 0/5] Support for the Sony Motion Controller and other cleanups Frank Praznik ` (3 preceding siblings ...) 2015-05-05 2:34 ` [PATCH 4/5] hid: sony: Simplify LED initialization and eliminate redundant copies when updating LED states Frank Praznik @ 2015-05-05 2:34 ` Frank Praznik 4 siblings, 0 replies; 14+ messages in thread From: Frank Praznik @ 2015-05-05 2:34 UTC (permalink / raw) To: linux-input; +Cc: jkosina, pavel, Frank Praznik Correct a spelling mistake in the Sixaxis HID descriptor comment. Add an explanation as to why the Sixaxis has so many analog axes and why some of them are seen as multi-touch axes. Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> --- drivers/hid/hid-sony.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 266bac2..46e4ceb 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -59,9 +59,16 @@ #define MAX_LEDS 4 +/* + * The Sixaxis reports both digital and analog values for each button on the + * controller except for Start, Select and the PS button. The controller ends + * up reporting 27 axes which causes them to spill over into the multi-touch + * axis values. Additionally, the controller only has 20 actual, physical axes + * so there are several unused axes in between the used ones. + */ 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), */ -- 2.1.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2015-05-06 9:31 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-05-05 2:34 [PATCH 0/5] Support for the Sony Motion Controller and other cleanups Frank Praznik 2015-05-05 2:34 ` [PATCH 1/5] hid: sony: Add the product ID for the Sony Motion Controller Frank Praznik 2015-05-05 2:34 ` [PATCH 2/5] hid: sony: Add support " Frank Praznik 2015-05-05 21:16 ` Pavel Machek 2015-05-05 21:24 ` Pavel Machek 2015-05-05 21:36 ` Pavel Machek 2015-05-05 21:47 ` Pavel Machek 2015-05-05 21:55 ` Pavel Machek 2015-05-05 23:37 ` Frank Praznik 2015-05-06 9:31 ` Pavel Machek 2015-05-05 23:28 ` Frank Praznik 2015-05-05 2:34 ` [PATCH 3/5] hid: sony: Correct Sony device ordering Frank Praznik 2015-05-05 2:34 ` [PATCH 4/5] hid: sony: Simplify LED initialization and eliminate redundant copies when updating LED states Frank Praznik 2015-05-05 2:34 ` [PATCH 5/5] hid: sony: Correct a typo in a HID descriptor comment and explain the odd Sixaxis axis mapping Frank Praznik
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).