blob: 26992e15d0e26d85a630b3df1248638e9789129f [file] [log] [blame]
Jiri Slabybd28ce02008-06-25 23:47:04 +02001/*
Jiri Kosina078328d2013-06-13 12:03:49 +02002 * HID driver for Sony / PS2 / PS3 BD devices.
Jiri Slabybd28ce02008-06-25 23:47:04 +02003 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
Jiri Slabybd28ce02008-06-25 23:47:04 +02007 * Copyright (c) 2008 Jiri Slaby
Jiri Kosina078328d2013-06-13 12:03:49 +02008 * Copyright (c) 2012 David Dillow <dave@thedillows.org>
9 * Copyright (c) 2006-2013 Jiri Kosina
Colin Leitnerf04d5142013-05-27 23:41:05 +020010 * Copyright (c) 2013 Colin Leitner <colin.leitner@gmail.com>
Jiri Slabybd28ce02008-06-25 23:47:04 +020011 */
12
13/*
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option)
17 * any later version.
18 */
19
Frank Praznikad142b92014-02-20 11:36:00 -050020/*
21 * NOTE: in order for the Sony PS3 BD Remote Control to be found by
Jiri Kosina078328d2013-06-13 12:03:49 +020022 * a Bluetooth host, the key combination Start+Enter has to be kept pressed
23 * for about 7 seconds with the Bluetooth Host Controller in discovering mode.
24 *
25 * There will be no PIN request from the device.
26 */
27
Jiri Slabybd28ce02008-06-25 23:47:04 +020028#include <linux/device.h>
29#include <linux/hid.h>
30#include <linux/module.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090031#include <linux/slab.h>
Jiri Slabybd28ce02008-06-25 23:47:04 +020032#include <linux/usb.h>
Jiri Kosina40e32ee2013-05-28 11:22:09 +020033#include <linux/leds.h>
Frank Praznikd902f472014-01-27 10:17:36 -050034#include <linux/power_supply.h>
35#include <linux/spinlock.h>
Frank Praznike5606232014-01-27 10:17:37 -050036#include <linux/input/mt.h>
Jiri Slabybd28ce02008-06-25 23:47:04 +020037
38#include "hid-ids.h"
39
Frank Praznik6c79c182014-01-16 21:43:03 -050040#define VAIO_RDESC_CONSTANT BIT(0)
41#define SIXAXIS_CONTROLLER_USB BIT(1)
42#define SIXAXIS_CONTROLLER_BT BIT(2)
43#define BUZZ_CONTROLLER BIT(3)
44#define PS3REMOTE BIT(4)
Frank Praznik8ab16762014-01-16 21:42:31 -050045#define DUALSHOCK4_CONTROLLER_USB BIT(5)
46#define DUALSHOCK4_CONTROLLER_BT BIT(6)
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +020047
Frank Praznikfee4e2d2014-02-18 17:22:01 -050048#define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT)
Frank Praznik68330d82014-02-05 20:03:49 -050049#define DUALSHOCK4_CONTROLLER (DUALSHOCK4_CONTROLLER_USB |\
50 DUALSHOCK4_CONTROLLER_BT)
Frank Praznikfee4e2d2014-02-18 17:22:01 -050051#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\
Frank Praznik68330d82014-02-05 20:03:49 -050052 DUALSHOCK4_CONTROLLER)
Frank Praznikfee4e2d2014-02-18 17:22:01 -050053#define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER)
Frank Praznik60781cf2014-01-11 15:13:15 -050054
55#define MAX_LEDS 4
Sven Eckelmann0a286ef2013-11-19 20:26:32 +010056
Simon Wood61ab44b2011-06-10 12:00:26 +020057static const u8 sixaxis_rdesc_fixup[] = {
58 0x95, 0x13, 0x09, 0x01, 0x81, 0x02, 0x95, 0x0C,
59 0x81, 0x01, 0x75, 0x10, 0x95, 0x04, 0x26, 0xFF,
60 0x03, 0x46, 0xFF, 0x03, 0x09, 0x01, 0x81, 0x02
61};
62
Mauro Carvalho Chehabe57a67d2012-12-14 20:57:34 -020063static const u8 sixaxis_rdesc_fixup2[] = {
64 0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0xa1, 0x02,
65 0x85, 0x01, 0x75, 0x08, 0x95, 0x01, 0x15, 0x00,
66 0x26, 0xff, 0x00, 0x81, 0x03, 0x75, 0x01, 0x95,
67 0x13, 0x15, 0x00, 0x25, 0x01, 0x35, 0x00, 0x45,
68 0x01, 0x05, 0x09, 0x19, 0x01, 0x29, 0x13, 0x81,
69 0x02, 0x75, 0x01, 0x95, 0x0d, 0x06, 0x00, 0xff,
70 0x81, 0x03, 0x15, 0x00, 0x26, 0xff, 0x00, 0x05,
71 0x01, 0x09, 0x01, 0xa1, 0x00, 0x75, 0x08, 0x95,
72 0x04, 0x35, 0x00, 0x46, 0xff, 0x00, 0x09, 0x30,
73 0x09, 0x31, 0x09, 0x32, 0x09, 0x35, 0x81, 0x02,
74 0xc0, 0x05, 0x01, 0x95, 0x13, 0x09, 0x01, 0x81,
75 0x02, 0x95, 0x0c, 0x81, 0x01, 0x75, 0x10, 0x95,
76 0x04, 0x26, 0xff, 0x03, 0x46, 0xff, 0x03, 0x09,
77 0x01, 0x81, 0x02, 0xc0, 0xa1, 0x02, 0x85, 0x02,
78 0x75, 0x08, 0x95, 0x30, 0x09, 0x01, 0xb1, 0x02,
79 0xc0, 0xa1, 0x02, 0x85, 0xee, 0x75, 0x08, 0x95,
80 0x30, 0x09, 0x01, 0xb1, 0x02, 0xc0, 0xa1, 0x02,
81 0x85, 0xef, 0x75, 0x08, 0x95, 0x30, 0x09, 0x01,
82 0xb1, 0x02, 0xc0, 0xc0,
83};
84
Frank Praznikad142b92014-02-20 11:36:00 -050085/*
86 * The default descriptor doesn't provide mapping for the accelerometers
Frank Praznik58d70272014-01-20 12:27:01 -050087 * or orientation sensors. This fixed descriptor maps the accelerometers
88 * to usage values 0x40, 0x41 and 0x42 and maps the orientation sensors
89 * to usage values 0x43, 0x44 and 0x45.
90 */
Frank Prazniked19d8c2014-01-16 21:43:12 -050091static u8 dualshock4_usb_rdesc[] = {
Frank Praznik58d70272014-01-20 12:27:01 -050092 0x05, 0x01, /* Usage Page (Desktop), */
93 0x09, 0x05, /* Usage (Gamepad), */
94 0xA1, 0x01, /* Collection (Application), */
95 0x85, 0x01, /* Report ID (1), */
96 0x09, 0x30, /* Usage (X), */
97 0x09, 0x31, /* Usage (Y), */
98 0x09, 0x32, /* Usage (Z), */
99 0x09, 0x35, /* Usage (Rz), */
100 0x15, 0x00, /* Logical Minimum (0), */
101 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
102 0x75, 0x08, /* Report Size (8), */
103 0x95, 0x04, /* Report Count (4), */
104 0x81, 0x02, /* Input (Variable), */
105 0x09, 0x39, /* Usage (Hat Switch), */
106 0x15, 0x00, /* Logical Minimum (0), */
107 0x25, 0x07, /* Logical Maximum (7), */
108 0x35, 0x00, /* Physical Minimum (0), */
109 0x46, 0x3B, 0x01, /* Physical Maximum (315), */
110 0x65, 0x14, /* Unit (Degrees), */
111 0x75, 0x04, /* Report Size (4), */
112 0x95, 0x01, /* Report Count (1), */
113 0x81, 0x42, /* Input (Variable, Null State), */
114 0x65, 0x00, /* Unit, */
115 0x05, 0x09, /* Usage Page (Button), */
116 0x19, 0x01, /* Usage Minimum (01h), */
117 0x29, 0x0E, /* Usage Maximum (0Eh), */
118 0x15, 0x00, /* Logical Minimum (0), */
119 0x25, 0x01, /* Logical Maximum (1), */
120 0x75, 0x01, /* Report Size (1), */
121 0x95, 0x0E, /* Report Count (14), */
122 0x81, 0x02, /* Input (Variable), */
123 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
124 0x09, 0x20, /* Usage (20h), */
125 0x75, 0x06, /* Report Size (6), */
126 0x95, 0x01, /* Report Count (1), */
127 0x15, 0x00, /* Logical Minimum (0), */
128 0x25, 0x7F, /* Logical Maximum (127), */
129 0x81, 0x02, /* Input (Variable), */
130 0x05, 0x01, /* Usage Page (Desktop), */
131 0x09, 0x33, /* Usage (Rx), */
132 0x09, 0x34, /* Usage (Ry), */
133 0x15, 0x00, /* Logical Minimum (0), */
134 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
135 0x75, 0x08, /* Report Size (8), */
136 0x95, 0x02, /* Report Count (2), */
137 0x81, 0x02, /* Input (Variable), */
138 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
139 0x09, 0x21, /* Usage (21h), */
140 0x95, 0x03, /* Report Count (3), */
141 0x81, 0x02, /* Input (Variable), */
142 0x05, 0x01, /* Usage Page (Desktop), */
143 0x19, 0x40, /* Usage Minimum (40h), */
144 0x29, 0x42, /* Usage Maximum (42h), */
145 0x16, 0x00, 0x80, /* Logical Minimum (-32768), */
146 0x26, 0x00, 0x7F, /* Logical Maximum (32767), */
147 0x75, 0x10, /* Report Size (16), */
148 0x95, 0x03, /* Report Count (3), */
149 0x81, 0x02, /* Input (Variable), */
150 0x19, 0x43, /* Usage Minimum (43h), */
151 0x29, 0x45, /* Usage Maximum (45h), */
152 0x16, 0xFF, 0xBF, /* Logical Minimum (-16385), */
153 0x26, 0x00, 0x40, /* Logical Maximum (16384), */
154 0x95, 0x03, /* Report Count (3), */
155 0x81, 0x02, /* Input (Variable), */
156 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
157 0x09, 0x21, /* Usage (21h), */
158 0x15, 0x00, /* Logical Minimum (0), */
159 0x25, 0xFF, /* Logical Maximum (255), */
160 0x75, 0x08, /* Report Size (8), */
161 0x95, 0x27, /* Report Count (39), */
162 0x81, 0x02, /* Input (Variable), */
163 0x85, 0x05, /* Report ID (5), */
164 0x09, 0x22, /* Usage (22h), */
165 0x95, 0x1F, /* Report Count (31), */
166 0x91, 0x02, /* Output (Variable), */
167 0x85, 0x04, /* Report ID (4), */
168 0x09, 0x23, /* Usage (23h), */
169 0x95, 0x24, /* Report Count (36), */
170 0xB1, 0x02, /* Feature (Variable), */
171 0x85, 0x02, /* Report ID (2), */
172 0x09, 0x24, /* Usage (24h), */
173 0x95, 0x24, /* Report Count (36), */
174 0xB1, 0x02, /* Feature (Variable), */
175 0x85, 0x08, /* Report ID (8), */
176 0x09, 0x25, /* Usage (25h), */
177 0x95, 0x03, /* Report Count (3), */
178 0xB1, 0x02, /* Feature (Variable), */
179 0x85, 0x10, /* Report ID (16), */
180 0x09, 0x26, /* Usage (26h), */
181 0x95, 0x04, /* Report Count (4), */
182 0xB1, 0x02, /* Feature (Variable), */
183 0x85, 0x11, /* Report ID (17), */
184 0x09, 0x27, /* Usage (27h), */
185 0x95, 0x02, /* Report Count (2), */
186 0xB1, 0x02, /* Feature (Variable), */
187 0x85, 0x12, /* Report ID (18), */
188 0x06, 0x02, 0xFF, /* Usage Page (FF02h), */
189 0x09, 0x21, /* Usage (21h), */
190 0x95, 0x0F, /* Report Count (15), */
191 0xB1, 0x02, /* Feature (Variable), */
192 0x85, 0x13, /* Report ID (19), */
193 0x09, 0x22, /* Usage (22h), */
194 0x95, 0x16, /* Report Count (22), */
195 0xB1, 0x02, /* Feature (Variable), */
196 0x85, 0x14, /* Report ID (20), */
197 0x06, 0x05, 0xFF, /* Usage Page (FF05h), */
198 0x09, 0x20, /* Usage (20h), */
199 0x95, 0x10, /* Report Count (16), */
200 0xB1, 0x02, /* Feature (Variable), */
201 0x85, 0x15, /* Report ID (21), */
202 0x09, 0x21, /* Usage (21h), */
203 0x95, 0x2C, /* Report Count (44), */
204 0xB1, 0x02, /* Feature (Variable), */
205 0x06, 0x80, 0xFF, /* Usage Page (FF80h), */
206 0x85, 0x80, /* Report ID (128), */
207 0x09, 0x20, /* Usage (20h), */
208 0x95, 0x06, /* Report Count (6), */
209 0xB1, 0x02, /* Feature (Variable), */
210 0x85, 0x81, /* Report ID (129), */
211 0x09, 0x21, /* Usage (21h), */
212 0x95, 0x06, /* Report Count (6), */
213 0xB1, 0x02, /* Feature (Variable), */
214 0x85, 0x82, /* Report ID (130), */
215 0x09, 0x22, /* Usage (22h), */
216 0x95, 0x05, /* Report Count (5), */
217 0xB1, 0x02, /* Feature (Variable), */
218 0x85, 0x83, /* Report ID (131), */
219 0x09, 0x23, /* Usage (23h), */
220 0x95, 0x01, /* Report Count (1), */
221 0xB1, 0x02, /* Feature (Variable), */
222 0x85, 0x84, /* Report ID (132), */
223 0x09, 0x24, /* Usage (24h), */
224 0x95, 0x04, /* Report Count (4), */
225 0xB1, 0x02, /* Feature (Variable), */
226 0x85, 0x85, /* Report ID (133), */
227 0x09, 0x25, /* Usage (25h), */
228 0x95, 0x06, /* Report Count (6), */
229 0xB1, 0x02, /* Feature (Variable), */
230 0x85, 0x86, /* Report ID (134), */
231 0x09, 0x26, /* Usage (26h), */
232 0x95, 0x06, /* Report Count (6), */
233 0xB1, 0x02, /* Feature (Variable), */
234 0x85, 0x87, /* Report ID (135), */
235 0x09, 0x27, /* Usage (27h), */
236 0x95, 0x23, /* Report Count (35), */
237 0xB1, 0x02, /* Feature (Variable), */
238 0x85, 0x88, /* Report ID (136), */
239 0x09, 0x28, /* Usage (28h), */
240 0x95, 0x22, /* Report Count (34), */
241 0xB1, 0x02, /* Feature (Variable), */
242 0x85, 0x89, /* Report ID (137), */
243 0x09, 0x29, /* Usage (29h), */
244 0x95, 0x02, /* Report Count (2), */
245 0xB1, 0x02, /* Feature (Variable), */
246 0x85, 0x90, /* Report ID (144), */
247 0x09, 0x30, /* Usage (30h), */
248 0x95, 0x05, /* Report Count (5), */
249 0xB1, 0x02, /* Feature (Variable), */
250 0x85, 0x91, /* Report ID (145), */
251 0x09, 0x31, /* Usage (31h), */
252 0x95, 0x03, /* Report Count (3), */
253 0xB1, 0x02, /* Feature (Variable), */
254 0x85, 0x92, /* Report ID (146), */
255 0x09, 0x32, /* Usage (32h), */
256 0x95, 0x03, /* Report Count (3), */
257 0xB1, 0x02, /* Feature (Variable), */
258 0x85, 0x93, /* Report ID (147), */
259 0x09, 0x33, /* Usage (33h), */
260 0x95, 0x0C, /* Report Count (12), */
261 0xB1, 0x02, /* Feature (Variable), */
262 0x85, 0xA0, /* Report ID (160), */
263 0x09, 0x40, /* Usage (40h), */
264 0x95, 0x06, /* Report Count (6), */
265 0xB1, 0x02, /* Feature (Variable), */
266 0x85, 0xA1, /* Report ID (161), */
267 0x09, 0x41, /* Usage (41h), */
268 0x95, 0x01, /* Report Count (1), */
269 0xB1, 0x02, /* Feature (Variable), */
270 0x85, 0xA2, /* Report ID (162), */
271 0x09, 0x42, /* Usage (42h), */
272 0x95, 0x01, /* Report Count (1), */
273 0xB1, 0x02, /* Feature (Variable), */
274 0x85, 0xA3, /* Report ID (163), */
275 0x09, 0x43, /* Usage (43h), */
276 0x95, 0x30, /* Report Count (48), */
277 0xB1, 0x02, /* Feature (Variable), */
278 0x85, 0xA4, /* Report ID (164), */
279 0x09, 0x44, /* Usage (44h), */
280 0x95, 0x0D, /* Report Count (13), */
281 0xB1, 0x02, /* Feature (Variable), */
282 0x85, 0xA5, /* Report ID (165), */
283 0x09, 0x45, /* Usage (45h), */
284 0x95, 0x15, /* Report Count (21), */
285 0xB1, 0x02, /* Feature (Variable), */
286 0x85, 0xA6, /* Report ID (166), */
287 0x09, 0x46, /* Usage (46h), */
288 0x95, 0x15, /* Report Count (21), */
289 0xB1, 0x02, /* Feature (Variable), */
290 0x85, 0xF0, /* Report ID (240), */
291 0x09, 0x47, /* Usage (47h), */
292 0x95, 0x3F, /* Report Count (63), */
293 0xB1, 0x02, /* Feature (Variable), */
294 0x85, 0xF1, /* Report ID (241), */
295 0x09, 0x48, /* Usage (48h), */
296 0x95, 0x3F, /* Report Count (63), */
297 0xB1, 0x02, /* Feature (Variable), */
298 0x85, 0xF2, /* Report ID (242), */
299 0x09, 0x49, /* Usage (49h), */
300 0x95, 0x0F, /* Report Count (15), */
301 0xB1, 0x02, /* Feature (Variable), */
302 0x85, 0xA7, /* Report ID (167), */
303 0x09, 0x4A, /* Usage (4Ah), */
304 0x95, 0x01, /* Report Count (1), */
305 0xB1, 0x02, /* Feature (Variable), */
306 0x85, 0xA8, /* Report ID (168), */
307 0x09, 0x4B, /* Usage (4Bh), */
308 0x95, 0x01, /* Report Count (1), */
309 0xB1, 0x02, /* Feature (Variable), */
310 0x85, 0xA9, /* Report ID (169), */
311 0x09, 0x4C, /* Usage (4Ch), */
312 0x95, 0x08, /* Report Count (8), */
313 0xB1, 0x02, /* Feature (Variable), */
314 0x85, 0xAA, /* Report ID (170), */
315 0x09, 0x4E, /* Usage (4Eh), */
316 0x95, 0x01, /* Report Count (1), */
317 0xB1, 0x02, /* Feature (Variable), */
318 0x85, 0xAB, /* Report ID (171), */
319 0x09, 0x4F, /* Usage (4Fh), */
320 0x95, 0x39, /* Report Count (57), */
321 0xB1, 0x02, /* Feature (Variable), */
322 0x85, 0xAC, /* Report ID (172), */
323 0x09, 0x50, /* Usage (50h), */
324 0x95, 0x39, /* Report Count (57), */
325 0xB1, 0x02, /* Feature (Variable), */
326 0x85, 0xAD, /* Report ID (173), */
327 0x09, 0x51, /* Usage (51h), */
328 0x95, 0x0B, /* Report Count (11), */
329 0xB1, 0x02, /* Feature (Variable), */
330 0x85, 0xAE, /* Report ID (174), */
331 0x09, 0x52, /* Usage (52h), */
332 0x95, 0x01, /* Report Count (1), */
333 0xB1, 0x02, /* Feature (Variable), */
334 0x85, 0xAF, /* Report ID (175), */
335 0x09, 0x53, /* Usage (53h), */
336 0x95, 0x02, /* Report Count (2), */
337 0xB1, 0x02, /* Feature (Variable), */
338 0x85, 0xB0, /* Report ID (176), */
339 0x09, 0x54, /* Usage (54h), */
340 0x95, 0x3F, /* Report Count (63), */
341 0xB1, 0x02, /* Feature (Variable), */
342 0xC0 /* End Collection */
Frank Prazniked19d8c2014-01-16 21:43:12 -0500343};
344
Frank Praznikad142b92014-02-20 11:36:00 -0500345/*
346 * The default behavior of the Dualshock 4 is to send reports using report
Frank Praznikd8296742014-02-05 20:03:45 -0500347 * type 1 when running over Bluetooth. However, as soon as it receives a
348 * report of type 17 to set the LEDs or rumble it starts returning it's state
349 * in report 17 instead of 1. Since report 17 is undefined in the default HID
350 * descriptor the button and axis definitions must be moved to report 17 or
351 * the HID layer won't process the received input once a report is sent.
352 */
353static u8 dualshock4_bt_rdesc[] = {
354 0x05, 0x01, /* Usage Page (Desktop), */
355 0x09, 0x05, /* Usage (Gamepad), */
356 0xA1, 0x01, /* Collection (Application), */
357 0x85, 0x01, /* Report ID (1), */
358 0x75, 0x08, /* Report Size (8), */
359 0x95, 0x0A, /* Report Count (9), */
360 0x81, 0x02, /* Input (Variable), */
361 0x06, 0x04, 0xFF, /* Usage Page (FF04h), */
362 0x85, 0x02, /* Report ID (2), */
363 0x09, 0x24, /* Usage (24h), */
364 0x95, 0x24, /* Report Count (36), */
365 0xB1, 0x02, /* Feature (Variable), */
366 0x85, 0xA3, /* Report ID (163), */
367 0x09, 0x25, /* Usage (25h), */
368 0x95, 0x30, /* Report Count (48), */
369 0xB1, 0x02, /* Feature (Variable), */
370 0x85, 0x05, /* Report ID (5), */
371 0x09, 0x26, /* Usage (26h), */
372 0x95, 0x28, /* Report Count (40), */
373 0xB1, 0x02, /* Feature (Variable), */
374 0x85, 0x06, /* Report ID (6), */
375 0x09, 0x27, /* Usage (27h), */
376 0x95, 0x34, /* Report Count (52), */
377 0xB1, 0x02, /* Feature (Variable), */
378 0x85, 0x07, /* Report ID (7), */
379 0x09, 0x28, /* Usage (28h), */
380 0x95, 0x30, /* Report Count (48), */
381 0xB1, 0x02, /* Feature (Variable), */
382 0x85, 0x08, /* Report ID (8), */
383 0x09, 0x29, /* Usage (29h), */
384 0x95, 0x2F, /* Report Count (47), */
385 0xB1, 0x02, /* Feature (Variable), */
386 0x06, 0x03, 0xFF, /* Usage Page (FF03h), */
387 0x85, 0x03, /* Report ID (3), */
388 0x09, 0x21, /* Usage (21h), */
389 0x95, 0x26, /* Report Count (38), */
390 0xB1, 0x02, /* Feature (Variable), */
391 0x85, 0x04, /* Report ID (4), */
392 0x09, 0x22, /* Usage (22h), */
393 0x95, 0x2E, /* Report Count (46), */
394 0xB1, 0x02, /* Feature (Variable), */
395 0x85, 0xF0, /* Report ID (240), */
396 0x09, 0x47, /* Usage (47h), */
397 0x95, 0x3F, /* Report Count (63), */
398 0xB1, 0x02, /* Feature (Variable), */
399 0x85, 0xF1, /* Report ID (241), */
400 0x09, 0x48, /* Usage (48h), */
401 0x95, 0x3F, /* Report Count (63), */
402 0xB1, 0x02, /* Feature (Variable), */
403 0x85, 0xF2, /* Report ID (242), */
404 0x09, 0x49, /* Usage (49h), */
405 0x95, 0x0F, /* Report Count (15), */
406 0xB1, 0x02, /* Feature (Variable), */
407 0x85, 0x11, /* Report ID (17), */
408 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
409 0x09, 0x20, /* Usage (20h), */
410 0x95, 0x02, /* Report Count (2), */
411 0x81, 0x02, /* Input (Variable), */
412 0x05, 0x01, /* Usage Page (Desktop), */
413 0x09, 0x30, /* Usage (X), */
414 0x09, 0x31, /* Usage (Y), */
415 0x09, 0x32, /* Usage (Z), */
416 0x09, 0x35, /* Usage (Rz), */
417 0x15, 0x00, /* Logical Minimum (0), */
418 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
419 0x75, 0x08, /* Report Size (8), */
420 0x95, 0x04, /* Report Count (4), */
421 0x81, 0x02, /* Input (Variable), */
422 0x09, 0x39, /* Usage (Hat Switch), */
423 0x15, 0x00, /* Logical Minimum (0), */
424 0x25, 0x07, /* Logical Maximum (7), */
425 0x75, 0x04, /* Report Size (4), */
426 0x95, 0x01, /* Report Count (1), */
427 0x81, 0x42, /* Input (Variable, Null State), */
428 0x05, 0x09, /* Usage Page (Button), */
429 0x19, 0x01, /* Usage Minimum (01h), */
430 0x29, 0x0E, /* Usage Maximum (0Eh), */
431 0x15, 0x00, /* Logical Minimum (0), */
432 0x25, 0x01, /* Logical Maximum (1), */
433 0x75, 0x01, /* Report Size (1), */
434 0x95, 0x0E, /* Report Count (14), */
435 0x81, 0x02, /* Input (Variable), */
436 0x75, 0x06, /* Report Size (6), */
437 0x95, 0x01, /* Report Count (1), */
438 0x81, 0x01, /* Input (Constant), */
439 0x05, 0x01, /* Usage Page (Desktop), */
440 0x09, 0x33, /* Usage (Rx), */
441 0x09, 0x34, /* Usage (Ry), */
442 0x15, 0x00, /* Logical Minimum (0), */
443 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
444 0x75, 0x08, /* Report Size (8), */
445 0x95, 0x02, /* Report Count (2), */
446 0x81, 0x02, /* Input (Variable), */
447 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
448 0x09, 0x20, /* Usage (20h), */
449 0x95, 0x03, /* Report Count (3), */
450 0x81, 0x02, /* Input (Variable), */
451 0x05, 0x01, /* Usage Page (Desktop), */
452 0x19, 0x40, /* Usage Minimum (40h), */
453 0x29, 0x42, /* Usage Maximum (42h), */
454 0x16, 0x00, 0x80, /* Logical Minimum (-32768), */
455 0x26, 0x00, 0x7F, /* Logical Maximum (32767), */
456 0x75, 0x10, /* Report Size (16), */
457 0x95, 0x03, /* Report Count (3), */
458 0x81, 0x02, /* Input (Variable), */
459 0x19, 0x43, /* Usage Minimum (43h), */
460 0x29, 0x45, /* Usage Maximum (45h), */
461 0x16, 0xFF, 0xBF, /* Logical Minimum (-16385), */
462 0x26, 0x00, 0x40, /* Logical Maximum (16384), */
463 0x95, 0x03, /* Report Count (3), */
464 0x81, 0x02, /* Input (Variable), */
465 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
466 0x09, 0x20, /* Usage (20h), */
467 0x15, 0x00, /* Logical Minimum (0), */
468 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
469 0x75, 0x08, /* Report Size (8), */
470 0x95, 0x31, /* Report Count (51), */
471 0x81, 0x02, /* Input (Variable), */
472 0x09, 0x21, /* Usage (21h), */
473 0x75, 0x08, /* Report Size (8), */
474 0x95, 0x4D, /* Report Count (77), */
475 0x91, 0x02, /* Output (Variable), */
476 0x85, 0x12, /* Report ID (18), */
477 0x09, 0x22, /* Usage (22h), */
478 0x95, 0x8D, /* Report Count (141), */
479 0x81, 0x02, /* Input (Variable), */
480 0x09, 0x23, /* Usage (23h), */
481 0x91, 0x02, /* Output (Variable), */
482 0x85, 0x13, /* Report ID (19), */
483 0x09, 0x24, /* Usage (24h), */
484 0x95, 0xCD, /* Report Count (205), */
485 0x81, 0x02, /* Input (Variable), */
486 0x09, 0x25, /* Usage (25h), */
487 0x91, 0x02, /* Output (Variable), */
488 0x85, 0x14, /* Report ID (20), */
489 0x09, 0x26, /* Usage (26h), */
490 0x96, 0x0D, 0x01, /* Report Count (269), */
491 0x81, 0x02, /* Input (Variable), */
492 0x09, 0x27, /* Usage (27h), */
493 0x91, 0x02, /* Output (Variable), */
494 0x85, 0x15, /* Report ID (21), */
495 0x09, 0x28, /* Usage (28h), */
496 0x96, 0x4D, 0x01, /* Report Count (333), */
497 0x81, 0x02, /* Input (Variable), */
498 0x09, 0x29, /* Usage (29h), */
499 0x91, 0x02, /* Output (Variable), */
500 0x85, 0x16, /* Report ID (22), */
501 0x09, 0x2A, /* Usage (2Ah), */
502 0x96, 0x8D, 0x01, /* Report Count (397), */
503 0x81, 0x02, /* Input (Variable), */
504 0x09, 0x2B, /* Usage (2Bh), */
505 0x91, 0x02, /* Output (Variable), */
506 0x85, 0x17, /* Report ID (23), */
507 0x09, 0x2C, /* Usage (2Ch), */
508 0x96, 0xCD, 0x01, /* Report Count (461), */
509 0x81, 0x02, /* Input (Variable), */
510 0x09, 0x2D, /* Usage (2Dh), */
511 0x91, 0x02, /* Output (Variable), */
512 0x85, 0x18, /* Report ID (24), */
513 0x09, 0x2E, /* Usage (2Eh), */
514 0x96, 0x0D, 0x02, /* Report Count (525), */
515 0x81, 0x02, /* Input (Variable), */
516 0x09, 0x2F, /* Usage (2Fh), */
517 0x91, 0x02, /* Output (Variable), */
518 0x85, 0x19, /* Report ID (25), */
519 0x09, 0x30, /* Usage (30h), */
520 0x96, 0x22, 0x02, /* Report Count (546), */
521 0x81, 0x02, /* Input (Variable), */
522 0x09, 0x31, /* Usage (31h), */
523 0x91, 0x02, /* Output (Variable), */
524 0x06, 0x80, 0xFF, /* Usage Page (FF80h), */
525 0x85, 0x82, /* Report ID (130), */
526 0x09, 0x22, /* Usage (22h), */
527 0x95, 0x3F, /* Report Count (63), */
528 0xB1, 0x02, /* Feature (Variable), */
529 0x85, 0x83, /* Report ID (131), */
530 0x09, 0x23, /* Usage (23h), */
531 0xB1, 0x02, /* Feature (Variable), */
532 0x85, 0x84, /* Report ID (132), */
533 0x09, 0x24, /* Usage (24h), */
534 0xB1, 0x02, /* Feature (Variable), */
535 0x85, 0x90, /* Report ID (144), */
536 0x09, 0x30, /* Usage (30h), */
537 0xB1, 0x02, /* Feature (Variable), */
538 0x85, 0x91, /* Report ID (145), */
539 0x09, 0x31, /* Usage (31h), */
540 0xB1, 0x02, /* Feature (Variable), */
541 0x85, 0x92, /* Report ID (146), */
542 0x09, 0x32, /* Usage (32h), */
543 0xB1, 0x02, /* Feature (Variable), */
544 0x85, 0x93, /* Report ID (147), */
545 0x09, 0x33, /* Usage (33h), */
546 0xB1, 0x02, /* Feature (Variable), */
547 0x85, 0xA0, /* Report ID (160), */
548 0x09, 0x40, /* Usage (40h), */
549 0xB1, 0x02, /* Feature (Variable), */
550 0x85, 0xA4, /* Report ID (164), */
551 0x09, 0x44, /* Usage (44h), */
552 0xB1, 0x02, /* Feature (Variable), */
553 0xC0 /* End Collection */
554};
555
Jiri Kosina078328d2013-06-13 12:03:49 +0200556static __u8 ps3remote_rdesc[] = {
557 0x05, 0x01, /* GUsagePage Generic Desktop */
558 0x09, 0x05, /* LUsage 0x05 [Game Pad] */
559 0xA1, 0x01, /* MCollection Application (mouse, keyboard) */
560
561 /* Use collection 1 for joypad buttons */
562 0xA1, 0x02, /* MCollection Logical (interrelated data) */
563
564 /* Ignore the 1st byte, maybe it is used for a controller
565 * number but it's not needed for correct operation */
566 0x75, 0x08, /* GReportSize 0x08 [8] */
567 0x95, 0x01, /* GReportCount 0x01 [1] */
568 0x81, 0x01, /* MInput 0x01 (Const[0] Arr[1] Abs[2]) */
569
570 /* Bytes from 2nd to 4th are a bitmap for joypad buttons, for these
571 * buttons multiple keypresses are allowed */
572 0x05, 0x09, /* GUsagePage Button */
573 0x19, 0x01, /* LUsageMinimum 0x01 [Button 1 (primary/trigger)] */
574 0x29, 0x18, /* LUsageMaximum 0x18 [Button 24] */
575 0x14, /* GLogicalMinimum [0] */
576 0x25, 0x01, /* GLogicalMaximum 0x01 [1] */
577 0x75, 0x01, /* GReportSize 0x01 [1] */
578 0x95, 0x18, /* GReportCount 0x18 [24] */
579 0x81, 0x02, /* MInput 0x02 (Data[0] Var[1] Abs[2]) */
580
581 0xC0, /* MEndCollection */
582
583 /* Use collection 2 for remote control buttons */
584 0xA1, 0x02, /* MCollection Logical (interrelated data) */
585
586 /* 5th byte is used for remote control buttons */
587 0x05, 0x09, /* GUsagePage Button */
588 0x18, /* LUsageMinimum [No button pressed] */
589 0x29, 0xFE, /* LUsageMaximum 0xFE [Button 254] */
590 0x14, /* GLogicalMinimum [0] */
591 0x26, 0xFE, 0x00, /* GLogicalMaximum 0x00FE [254] */
592 0x75, 0x08, /* GReportSize 0x08 [8] */
593 0x95, 0x01, /* GReportCount 0x01 [1] */
594 0x80, /* MInput */
595
596 /* Ignore bytes from 6th to 11th, 6th to 10th are always constant at
597 * 0xff and 11th is for press indication */
598 0x75, 0x08, /* GReportSize 0x08 [8] */
599 0x95, 0x06, /* GReportCount 0x06 [6] */
600 0x81, 0x01, /* MInput 0x01 (Const[0] Arr[1] Abs[2]) */
601
602 /* 12th byte is for battery strength */
603 0x05, 0x06, /* GUsagePage Generic Device Controls */
604 0x09, 0x20, /* LUsage 0x20 [Battery Strength] */
605 0x14, /* GLogicalMinimum [0] */
606 0x25, 0x05, /* GLogicalMaximum 0x05 [5] */
607 0x75, 0x08, /* GReportSize 0x08 [8] */
608 0x95, 0x01, /* GReportCount 0x01 [1] */
609 0x81, 0x02, /* MInput 0x02 (Data[0] Var[1] Abs[2]) */
610
611 0xC0, /* MEndCollection */
612
613 0xC0 /* MEndCollection [Game Pad] */
614};
615
616static const unsigned int ps3remote_keymap_joypad_buttons[] = {
617 [0x01] = KEY_SELECT,
618 [0x02] = BTN_THUMBL, /* L3 */
619 [0x03] = BTN_THUMBR, /* R3 */
620 [0x04] = BTN_START,
621 [0x05] = KEY_UP,
622 [0x06] = KEY_RIGHT,
623 [0x07] = KEY_DOWN,
624 [0x08] = KEY_LEFT,
625 [0x09] = BTN_TL2, /* L2 */
626 [0x0a] = BTN_TR2, /* R2 */
627 [0x0b] = BTN_TL, /* L1 */
628 [0x0c] = BTN_TR, /* R1 */
629 [0x0d] = KEY_OPTION, /* options/triangle */
630 [0x0e] = KEY_BACK, /* back/circle */
631 [0x0f] = BTN_0, /* cross */
632 [0x10] = KEY_SCREEN, /* view/square */
633 [0x11] = KEY_HOMEPAGE, /* PS button */
634 [0x14] = KEY_ENTER,
635};
636static const unsigned int ps3remote_keymap_remote_buttons[] = {
637 [0x00] = KEY_1,
638 [0x01] = KEY_2,
639 [0x02] = KEY_3,
640 [0x03] = KEY_4,
641 [0x04] = KEY_5,
642 [0x05] = KEY_6,
643 [0x06] = KEY_7,
644 [0x07] = KEY_8,
645 [0x08] = KEY_9,
646 [0x09] = KEY_0,
647 [0x0e] = KEY_ESC, /* return */
648 [0x0f] = KEY_CLEAR,
649 [0x16] = KEY_EJECTCD,
650 [0x1a] = KEY_MENU, /* top menu */
651 [0x28] = KEY_TIME,
652 [0x30] = KEY_PREVIOUS,
653 [0x31] = KEY_NEXT,
654 [0x32] = KEY_PLAY,
655 [0x33] = KEY_REWIND, /* scan back */
656 [0x34] = KEY_FORWARD, /* scan forward */
657 [0x38] = KEY_STOP,
658 [0x39] = KEY_PAUSE,
659 [0x40] = KEY_CONTEXT_MENU, /* pop up/menu */
660 [0x60] = KEY_FRAMEBACK, /* slow/step back */
661 [0x61] = KEY_FRAMEFORWARD, /* slow/step forward */
662 [0x63] = KEY_SUBTITLE,
663 [0x64] = KEY_AUDIO,
664 [0x65] = KEY_ANGLE,
665 [0x70] = KEY_INFO, /* display */
666 [0x80] = KEY_BLUE,
667 [0x81] = KEY_RED,
668 [0x82] = KEY_GREEN,
669 [0x83] = KEY_YELLOW,
670};
671
Colin Leitnerf04d5142013-05-27 23:41:05 +0200672static const unsigned int buzz_keymap[] = {
Frank Praznikad142b92014-02-20 11:36:00 -0500673 /*
674 * The controller has 4 remote buzzers, each with one LED and 5
Colin Leitnerf04d5142013-05-27 23:41:05 +0200675 * buttons.
676 *
677 * We use the mapping chosen by the controller, which is:
678 *
679 * Key Offset
680 * -------------------
681 * Buzz 1
682 * Blue 5
683 * Orange 4
684 * Green 3
685 * Yellow 2
686 *
687 * So, for example, the orange button on the third buzzer is mapped to
688 * BTN_TRIGGER_HAPPY14
689 */
690 [ 1] = BTN_TRIGGER_HAPPY1,
691 [ 2] = BTN_TRIGGER_HAPPY2,
692 [ 3] = BTN_TRIGGER_HAPPY3,
693 [ 4] = BTN_TRIGGER_HAPPY4,
694 [ 5] = BTN_TRIGGER_HAPPY5,
695 [ 6] = BTN_TRIGGER_HAPPY6,
696 [ 7] = BTN_TRIGGER_HAPPY7,
697 [ 8] = BTN_TRIGGER_HAPPY8,
698 [ 9] = BTN_TRIGGER_HAPPY9,
699 [10] = BTN_TRIGGER_HAPPY10,
700 [11] = BTN_TRIGGER_HAPPY11,
701 [12] = BTN_TRIGGER_HAPPY12,
702 [13] = BTN_TRIGGER_HAPPY13,
703 [14] = BTN_TRIGGER_HAPPY14,
704 [15] = BTN_TRIGGER_HAPPY15,
705 [16] = BTN_TRIGGER_HAPPY16,
706 [17] = BTN_TRIGGER_HAPPY17,
707 [18] = BTN_TRIGGER_HAPPY18,
708 [19] = BTN_TRIGGER_HAPPY19,
709 [20] = BTN_TRIGGER_HAPPY20,
710};
711
Frank Praznikd902f472014-01-27 10:17:36 -0500712static enum power_supply_property sony_battery_props[] = {
713 POWER_SUPPLY_PROP_PRESENT,
714 POWER_SUPPLY_PROP_CAPACITY,
715 POWER_SUPPLY_PROP_SCOPE,
716 POWER_SUPPLY_PROP_STATUS,
717};
718
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +0200719struct sony_sc {
Frank Praznikd902f472014-01-27 10:17:36 -0500720 spinlock_t lock;
Sven Eckelmann0a286ef2013-11-19 20:26:32 +0100721 struct hid_device *hdev;
Frank Praznik60781cf2014-01-11 15:13:15 -0500722 struct led_classdev *leds[MAX_LEDS];
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +0200723 unsigned long quirks;
Sven Eckelmann0a286ef2013-11-19 20:26:32 +0100724 struct work_struct state_worker;
Frank Praznikd902f472014-01-27 10:17:36 -0500725 struct power_supply battery;
Colin Leitnerf04d5142013-05-27 23:41:05 +0200726
Sven Eckelmann9f323b62013-11-17 20:38:21 +0100727#ifdef CONFIG_SONY_FF
Sven Eckelmann9f323b62013-11-17 20:38:21 +0100728 __u8 left;
729 __u8 right;
730#endif
731
Frank Praznikd902f472014-01-27 10:17:36 -0500732 __u8 cable_state;
733 __u8 battery_charging;
734 __u8 battery_capacity;
Frank Praznik60781cf2014-01-11 15:13:15 -0500735 __u8 led_state[MAX_LEDS];
736 __u8 led_count;
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +0200737};
738
Jiri Kosina078328d2013-06-13 12:03:49 +0200739static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc,
740 unsigned int *rsize)
741{
742 *rsize = sizeof(ps3remote_rdesc);
743 return ps3remote_rdesc;
744}
745
746static int ps3remote_mapping(struct hid_device *hdev, struct hid_input *hi,
747 struct hid_field *field, struct hid_usage *usage,
748 unsigned long **bit, int *max)
749{
750 unsigned int key = usage->hid & HID_USAGE;
751
752 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON)
753 return -1;
754
755 switch (usage->collection_index) {
756 case 1:
757 if (key >= ARRAY_SIZE(ps3remote_keymap_joypad_buttons))
758 return -1;
759
760 key = ps3remote_keymap_joypad_buttons[key];
761 if (!key)
762 return -1;
763 break;
764 case 2:
765 if (key >= ARRAY_SIZE(ps3remote_keymap_remote_buttons))
766 return -1;
767
768 key = ps3remote_keymap_remote_buttons[key];
769 if (!key)
770 return -1;
771 break;
772 default:
773 return -1;
774 }
775
776 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, key);
777 return 1;
778}
779
780
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +0200781/* Sony Vaio VGX has wrongly mouse pointer declared as constant */
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400782static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
783 unsigned int *rsize)
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +0200784{
785 struct sony_sc *sc = hid_get_drvdata(hdev);
786
Fernando Luis Vázquez Cao99d24902013-01-22 15:20:38 +0900787 /*
788 * Some Sony RF receivers wrongly declare the mouse pointer as a
789 * a constant non-data variable.
790 */
791 if ((sc->quirks & VAIO_RDESC_CONSTANT) && *rsize >= 56 &&
792 /* usage page: generic desktop controls */
793 /* rdesc[0] == 0x05 && rdesc[1] == 0x01 && */
794 /* usage: mouse */
795 rdesc[2] == 0x09 && rdesc[3] == 0x02 &&
796 /* input (usage page for x,y axes): constant, variable, relative */
797 rdesc[54] == 0x81 && rdesc[55] == 0x07) {
Fernando Luis Vázquez Caoa46491842013-01-15 19:40:48 +0900798 hid_info(hdev, "Fixing up Sony RF Receiver report descriptor\n");
Fernando Luis Vázquez Cao99d24902013-01-22 15:20:38 +0900799 /* input: data, variable, relative */
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +0200800 rdesc[55] = 0x06;
801 }
Simon Wood61ab44b2011-06-10 12:00:26 +0200802
Frank Prazniked19d8c2014-01-16 21:43:12 -0500803 /*
804 * The default Dualshock 4 USB descriptor doesn't assign
805 * the gyroscope values to corresponding axes so we need a
806 * modified one.
807 */
808 if ((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && *rsize == 467) {
809 hid_info(hdev, "Using modified Dualshock 4 report descriptor with gyroscope axes\n");
810 rdesc = dualshock4_usb_rdesc;
811 *rsize = sizeof(dualshock4_usb_rdesc);
Frank Praznikd8296742014-02-05 20:03:45 -0500812 } else if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) && *rsize == 357) {
813 hid_info(hdev, "Using modified Dualshock 4 Bluetooth report descriptor\n");
814 rdesc = dualshock4_bt_rdesc;
815 *rsize = sizeof(dualshock4_bt_rdesc);
Frank Prazniked19d8c2014-01-16 21:43:12 -0500816 }
817
Simon Wood61ab44b2011-06-10 12:00:26 +0200818 /* The HID descriptor exposed over BT has a trailing zero byte */
819 if ((((sc->quirks & SIXAXIS_CONTROLLER_USB) && *rsize == 148) ||
820 ((sc->quirks & SIXAXIS_CONTROLLER_BT) && *rsize == 149)) &&
821 rdesc[83] == 0x75) {
822 hid_info(hdev, "Fixing up Sony Sixaxis report descriptor\n");
823 memcpy((void *)&rdesc[83], (void *)&sixaxis_rdesc_fixup,
824 sizeof(sixaxis_rdesc_fixup));
Mauro Carvalho Chehabe57a67d2012-12-14 20:57:34 -0200825 } else if (sc->quirks & SIXAXIS_CONTROLLER_USB &&
826 *rsize > sizeof(sixaxis_rdesc_fixup2)) {
827 hid_info(hdev, "Sony Sixaxis clone detected. Using original report descriptor (size: %d clone; %d new)\n",
828 *rsize, (int)sizeof(sixaxis_rdesc_fixup2));
829 *rsize = sizeof(sixaxis_rdesc_fixup2);
830 memcpy(rdesc, &sixaxis_rdesc_fixup2, *rsize);
Simon Wood61ab44b2011-06-10 12:00:26 +0200831 }
Jiri Kosina078328d2013-06-13 12:03:49 +0200832
833 if (sc->quirks & PS3REMOTE)
834 return ps3remote_fixup(hdev, rdesc, rsize);
835
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400836 return rdesc;
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +0200837}
838
Frank Praznikd902f472014-01-27 10:17:36 -0500839static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
840{
841 static const __u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 };
842 unsigned long flags;
843 __u8 cable_state, battery_capacity, battery_charging;
844
Frank Praznikad142b92014-02-20 11:36:00 -0500845 /*
846 * The sixaxis is charging if the battery value is 0xee
Frank Praznikd902f472014-01-27 10:17:36 -0500847 * and it is fully charged if the value is 0xef.
848 * It does not report the actual level while charging so it
849 * is set to 100% while charging is in progress.
850 */
851 if (rd[30] >= 0xee) {
852 battery_capacity = 100;
Frank Praznika43e94a2014-02-15 13:35:42 -0500853 battery_charging = !(rd[30] & 0x01);
Frank Praznikd902f472014-01-27 10:17:36 -0500854 } else {
855 battery_capacity = sixaxis_battery_capacity[rd[30]];
856 battery_charging = 0;
857 }
Frank Praznika43e94a2014-02-15 13:35:42 -0500858 cable_state = !((rd[31] >> 4) & 0x01);
Frank Praznikd902f472014-01-27 10:17:36 -0500859
860 spin_lock_irqsave(&sc->lock, flags);
861 sc->cable_state = cable_state;
862 sc->battery_capacity = battery_capacity;
863 sc->battery_charging = battery_charging;
864 spin_unlock_irqrestore(&sc->lock, flags);
865}
866
867static void dualshock4_parse_report(struct sony_sc *sc, __u8 *rd, int size)
868{
Frank Praznike5606232014-01-27 10:17:37 -0500869 struct hid_input *hidinput = list_entry(sc->hdev->inputs.next,
870 struct hid_input, list);
871 struct input_dev *input_dev = hidinput->input;
Frank Praznikd902f472014-01-27 10:17:36 -0500872 unsigned long flags;
Frank Praznik6c5f8602014-02-05 20:03:47 -0500873 int n, offset;
Frank Praznikd902f472014-01-27 10:17:36 -0500874 __u8 cable_state, battery_capacity, battery_charging;
875
Frank Praznikad142b92014-02-20 11:36:00 -0500876 /*
877 * Battery and touchpad data starts at byte 30 in the USB report and
Frank Praznik6c5f8602014-02-05 20:03:47 -0500878 * 32 in Bluetooth report.
879 */
880 offset = (sc->quirks & DUALSHOCK4_CONTROLLER_USB) ? 30 : 32;
881
Frank Praznikad142b92014-02-20 11:36:00 -0500882 /*
883 * The lower 4 bits of byte 30 contain the battery level
Frank Praznikd902f472014-01-27 10:17:36 -0500884 * and the 5th bit contains the USB cable state.
885 */
Frank Praznik6c5f8602014-02-05 20:03:47 -0500886 cable_state = (rd[offset] >> 4) & 0x01;
887 battery_capacity = rd[offset] & 0x0F;
Frank Praznikd902f472014-01-27 10:17:36 -0500888
Frank Praznikad142b92014-02-20 11:36:00 -0500889 /*
890 * When a USB power source is connected the battery level ranges from
Frank Praznik6c5f8602014-02-05 20:03:47 -0500891 * 0 to 10, and when running on battery power it ranges from 0 to 9.
892 * A battery level above 10 when plugged in means charge completed.
Frank Praznikd902f472014-01-27 10:17:36 -0500893 */
Frank Praznik6c5f8602014-02-05 20:03:47 -0500894 if (!cable_state || battery_capacity > 10)
Frank Praznikd902f472014-01-27 10:17:36 -0500895 battery_charging = 0;
896 else
897 battery_charging = 1;
898
Frank Praznik6c5f8602014-02-05 20:03:47 -0500899 if (!cable_state)
900 battery_capacity++;
Frank Praznikd902f472014-01-27 10:17:36 -0500901 if (battery_capacity > 10)
Frank Praznik6c5f8602014-02-05 20:03:47 -0500902 battery_capacity = 10;
903
Frank Praznikd902f472014-01-27 10:17:36 -0500904 battery_capacity *= 10;
905
906 spin_lock_irqsave(&sc->lock, flags);
907 sc->cable_state = cable_state;
908 sc->battery_capacity = battery_capacity;
909 sc->battery_charging = battery_charging;
910 spin_unlock_irqrestore(&sc->lock, flags);
Frank Praznike5606232014-01-27 10:17:37 -0500911
Frank Praznik6c5f8602014-02-05 20:03:47 -0500912 offset += 5;
913
Frank Praznikad142b92014-02-20 11:36:00 -0500914 /*
915 * The Dualshock 4 multi-touch trackpad data starts at offset 35 on USB
Frank Praznik6c5f8602014-02-05 20:03:47 -0500916 * and 37 on Bluetooth.
Frank Praznike5606232014-01-27 10:17:37 -0500917 * The first 7 bits of the first byte is a counter and bit 8 is a touch
918 * indicator that is 0 when pressed and 1 when not pressed.
919 * The next 3 bytes are two 12 bit touch coordinates, X and Y.
920 * The data for the second touch is in the same format and immediatly
921 * follows the data for the first.
922 */
923 for (n = 0; n < 2; n++) {
924 __u16 x, y;
925
926 x = rd[offset+1] | ((rd[offset+2] & 0xF) << 8);
927 y = ((rd[offset+2] & 0xF0) >> 4) | (rd[offset+3] << 4);
928
929 input_mt_slot(input_dev, n);
930 input_mt_report_slot_state(input_dev, MT_TOOL_FINGER,
931 !(rd[offset] >> 7));
932 input_report_abs(input_dev, ABS_MT_POSITION_X, x);
933 input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
934
935 offset += 4;
936 }
Frank Praznikd902f472014-01-27 10:17:36 -0500937}
938
Simon Woodc9e4d872011-06-10 12:00:27 +0200939static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
940 __u8 *rd, int size)
941{
942 struct sony_sc *sc = hid_get_drvdata(hdev);
943
Frank Praznikad142b92014-02-20 11:36:00 -0500944 /*
945 * Sixaxis HID report has acclerometers/gyro with MSByte first, this
Simon Woodc9e4d872011-06-10 12:00:27 +0200946 * has to be BYTE_SWAPPED before passing up to joystick interface
947 */
Frank Praznikfee4e2d2014-02-18 17:22:01 -0500948 if ((sc->quirks & SIXAXIS_CONTROLLER) && rd[0] == 0x01 && size == 49) {
Simon Woodc9e4d872011-06-10 12:00:27 +0200949 swap(rd[41], rd[42]);
950 swap(rd[43], rd[44]);
951 swap(rd[45], rd[46]);
952 swap(rd[47], rd[48]);
Frank Praznikd902f472014-01-27 10:17:36 -0500953
954 sixaxis_parse_report(sc, rd, size);
Frank Praznik68330d82014-02-05 20:03:49 -0500955 } else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 &&
956 size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT)
957 && rd[0] == 0x11 && size == 78)) {
Frank Praznikd902f472014-01-27 10:17:36 -0500958 dualshock4_parse_report(sc, rd, size);
Simon Woodc9e4d872011-06-10 12:00:27 +0200959 }
960
961 return 0;
962}
963
Colin Leitnerf04d5142013-05-27 23:41:05 +0200964static int sony_mapping(struct hid_device *hdev, struct hid_input *hi,
965 struct hid_field *field, struct hid_usage *usage,
966 unsigned long **bit, int *max)
967{
968 struct sony_sc *sc = hid_get_drvdata(hdev);
969
970 if (sc->quirks & BUZZ_CONTROLLER) {
971 unsigned int key = usage->hid & HID_USAGE;
972
973 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON)
974 return -1;
975
976 switch (usage->collection_index) {
977 case 1:
978 if (key >= ARRAY_SIZE(buzz_keymap))
979 return -1;
980
981 key = buzz_keymap[key];
982 if (!key)
983 return -1;
984 break;
985 default:
986 return -1;
987 }
988
989 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, key);
990 return 1;
991 }
992
Jiri Kosina078328d2013-06-13 12:03:49 +0200993 if (sc->quirks & PS3REMOTE)
994 return ps3remote_mapping(hdev, hi, field, usage, bit, max);
995
Benjamin Tissoires6f498012013-07-24 16:53:07 +0200996 /* Let hid-core decide for the others */
997 return 0;
Colin Leitnerf04d5142013-05-27 23:41:05 +0200998}
999
Antonio Ospite5710fab2011-02-20 18:26:45 +01001000/*
1001 * The Sony Sixaxis does not handle HID Output Reports on the Interrupt EP
1002 * like it should according to usbhid/hid-core.c::usbhid_output_raw_report()
1003 * so we need to override that forcing HID Output Reports on the Control EP.
1004 *
1005 * There is also another issue about HID Output Reports via USB, the Sixaxis
1006 * does not want the report_id as part of the data packet, so we have to
1007 * discard buf[0] when sending the actual control message, even for numbered
1008 * reports, humpf!
1009 */
Antonio Ospite569b10a2010-10-19 16:13:10 +02001010static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf,
1011 size_t count, unsigned char report_type)
1012{
1013 struct usb_interface *intf = to_usb_interface(hid->dev.parent);
1014 struct usb_device *dev = interface_to_usbdev(intf);
1015 struct usb_host_interface *interface = intf->cur_altsetting;
1016 int report_id = buf[0];
1017 int ret;
1018
Antonio Ospite5710fab2011-02-20 18:26:45 +01001019 if (report_type == HID_OUTPUT_REPORT) {
1020 /* Don't send the Report ID */
1021 buf++;
1022 count--;
1023 }
1024
Antonio Ospite569b10a2010-10-19 16:13:10 +02001025 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1026 HID_REQ_SET_REPORT,
1027 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
1028 ((report_type + 1) << 8) | report_id,
1029 interface->desc.bInterfaceNumber, buf, count,
1030 USB_CTRL_SET_TIMEOUT);
1031
Antonio Ospite5710fab2011-02-20 18:26:45 +01001032 /* Count also the Report ID, in case of an Output report. */
1033 if (ret > 0 && report_type == HID_OUTPUT_REPORT)
1034 ret++;
1035
Antonio Ospite569b10a2010-10-19 16:13:10 +02001036 return ret;
1037}
1038
Jiri Slabybd28ce02008-06-25 23:47:04 +02001039/*
1040 * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
1041 * to "operational". Without this, the ps3 controller will not report any
1042 * events.
1043 */
Antonio Ospite816651a2010-05-03 22:15:55 +02001044static int sixaxis_set_operational_usb(struct hid_device *hdev)
Jiri Slabybd28ce02008-06-25 23:47:04 +02001045{
Jiri Slabybd28ce02008-06-25 23:47:04 +02001046 int ret;
1047 char *buf = kmalloc(18, GFP_KERNEL);
1048
1049 if (!buf)
1050 return -ENOMEM;
1051
Benjamin Tissoirescafebc02014-02-05 16:33:22 -05001052 ret = hid_hw_raw_request(hdev, 0xf2, buf, 17, HID_FEATURE_REPORT,
1053 HID_REQ_GET_REPORT);
Benjamin Tissoiresf204828a2013-09-11 22:12:25 +02001054
Jiri Slabybd28ce02008-06-25 23:47:04 +02001055 if (ret < 0)
Joe Perches4291ee32010-12-09 19:29:03 -08001056 hid_err(hdev, "can't set operational mode\n");
Jiri Slabybd28ce02008-06-25 23:47:04 +02001057
1058 kfree(buf);
1059
1060 return ret;
1061}
1062
Antonio Ospite816651a2010-05-03 22:15:55 +02001063static int sixaxis_set_operational_bt(struct hid_device *hdev)
Bastien Noceraf9ce7c22010-01-20 12:01:53 +00001064{
Antonio Ospitefddb33f2010-05-03 17:19:03 +02001065 unsigned char buf[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 };
Benjamin Tissoires7e845d42014-02-05 16:33:23 -05001066 return hid_output_raw_report(hdev, buf, sizeof(buf),
1067 HID_FEATURE_REPORT);
Bastien Noceraf9ce7c22010-01-20 12:01:53 +00001068}
1069
Frank Praznikad142b92014-02-20 11:36:00 -05001070/*
1071 * Requesting feature report 0x02 in Bluetooth mode changes the state of the
Frank Praznik68330d82014-02-05 20:03:49 -05001072 * controller so that it sends full input reports of type 0x11.
1073 */
1074static int dualshock4_set_operational_bt(struct hid_device *hdev)
1075{
1076 __u8 buf[37] = { 0 };
1077
1078 return hid_hw_raw_request(hdev, 0x02, buf, sizeof(buf),
1079 HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
1080}
1081
Frank Praznik60781cf2014-01-11 15:13:15 -05001082static void buzz_set_leds(struct hid_device *hdev, const __u8 *leds)
Colin Leitnerf04d5142013-05-27 23:41:05 +02001083{
1084 struct list_head *report_list =
1085 &hdev->report_enum[HID_OUTPUT_REPORT].report_list;
1086 struct hid_report *report = list_entry(report_list->next,
1087 struct hid_report, list);
1088 __s32 *value = report->field[0]->value;
1089
1090 value[0] = 0x00;
Frank Praznik60781cf2014-01-11 15:13:15 -05001091 value[1] = leds[0] ? 0xff : 0x00;
1092 value[2] = leds[1] ? 0xff : 0x00;
1093 value[3] = leds[2] ? 0xff : 0x00;
1094 value[4] = leds[3] ? 0xff : 0x00;
Colin Leitnerf04d5142013-05-27 23:41:05 +02001095 value[5] = 0x00;
1096 value[6] = 0x00;
1097 hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
1098}
1099
Frank Praznik60781cf2014-01-11 15:13:15 -05001100static void sony_set_leds(struct hid_device *hdev, const __u8 *leds, int count)
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001101{
1102 struct sony_sc *drv_data = hid_get_drvdata(hdev);
Frank Praznik60781cf2014-01-11 15:13:15 -05001103 int n;
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001104
Frank Praznik60781cf2014-01-11 15:13:15 -05001105 BUG_ON(count > MAX_LEDS);
1106
1107 if (drv_data->quirks & BUZZ_CONTROLLER && count == 4) {
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001108 buzz_set_leds(hdev, leds);
Frank Praznikfee4e2d2014-02-18 17:22:01 -05001109 } else {
Frank Praznik60781cf2014-01-11 15:13:15 -05001110 for (n = 0; n < count; n++)
1111 drv_data->led_state[n] = leds[n];
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001112 schedule_work(&drv_data->state_worker);
1113 }
1114}
1115
Sven Eckelmannc5382512013-11-19 20:26:30 +01001116static void sony_led_set_brightness(struct led_classdev *led,
Colin Leitnerf04d5142013-05-27 23:41:05 +02001117 enum led_brightness value)
1118{
1119 struct device *dev = led->dev->parent;
1120 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1121 struct sony_sc *drv_data;
Colin Leitnerf04d5142013-05-27 23:41:05 +02001122
1123 int n;
1124
1125 drv_data = hid_get_drvdata(hdev);
Sven Eckelmann2251b852013-11-19 20:26:31 +01001126 if (!drv_data) {
Colin Leitnerf04d5142013-05-27 23:41:05 +02001127 hid_err(hdev, "No device data\n");
1128 return;
1129 }
Colin Leitnerf04d5142013-05-27 23:41:05 +02001130
Frank Praznik60781cf2014-01-11 15:13:15 -05001131 for (n = 0; n < drv_data->led_count; n++) {
Sven Eckelmann2251b852013-11-19 20:26:31 +01001132 if (led == drv_data->leds[n]) {
Frank Praznik60781cf2014-01-11 15:13:15 -05001133 if (value != drv_data->led_state[n]) {
1134 drv_data->led_state[n] = value;
1135 sony_set_leds(hdev, drv_data->led_state, drv_data->led_count);
Colin Leitnerf04d5142013-05-27 23:41:05 +02001136 }
1137 break;
1138 }
1139 }
1140}
1141
Sven Eckelmannc5382512013-11-19 20:26:30 +01001142static enum led_brightness sony_led_get_brightness(struct led_classdev *led)
Colin Leitnerf04d5142013-05-27 23:41:05 +02001143{
1144 struct device *dev = led->dev->parent;
1145 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1146 struct sony_sc *drv_data;
Colin Leitnerf04d5142013-05-27 23:41:05 +02001147
1148 int n;
Colin Leitnerf04d5142013-05-27 23:41:05 +02001149
1150 drv_data = hid_get_drvdata(hdev);
Sven Eckelmann2251b852013-11-19 20:26:31 +01001151 if (!drv_data) {
Colin Leitnerf04d5142013-05-27 23:41:05 +02001152 hid_err(hdev, "No device data\n");
1153 return LED_OFF;
1154 }
Colin Leitnerf04d5142013-05-27 23:41:05 +02001155
Frank Praznik60781cf2014-01-11 15:13:15 -05001156 for (n = 0; n < drv_data->led_count; n++) {
Simon Wood7db75042014-02-05 12:34:18 -07001157 if (led == drv_data->leds[n])
1158 return drv_data->led_state[n];
Colin Leitnerf04d5142013-05-27 23:41:05 +02001159 }
1160
Simon Wood7db75042014-02-05 12:34:18 -07001161 return LED_OFF;
Colin Leitnerf04d5142013-05-27 23:41:05 +02001162}
Colin Leitnerf04d5142013-05-27 23:41:05 +02001163
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001164static void sony_leds_remove(struct hid_device *hdev)
1165{
1166 struct sony_sc *drv_data;
1167 struct led_classdev *led;
1168 int n;
1169
1170 drv_data = hid_get_drvdata(hdev);
1171 BUG_ON(!(drv_data->quirks & SONY_LED_SUPPORT));
1172
Frank Praznik60781cf2014-01-11 15:13:15 -05001173 for (n = 0; n < drv_data->led_count; n++) {
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001174 led = drv_data->leds[n];
1175 drv_data->leds[n] = NULL;
1176 if (!led)
1177 continue;
1178 led_classdev_unregister(led);
1179 kfree(led);
1180 }
Frank Praznik60781cf2014-01-11 15:13:15 -05001181
1182 drv_data->led_count = 0;
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001183}
1184
Sven Eckelmannc5382512013-11-19 20:26:30 +01001185static int sony_leds_init(struct hid_device *hdev)
Colin Leitnerf04d5142013-05-27 23:41:05 +02001186{
1187 struct sony_sc *drv_data;
Jiri Kosina40e32ee2013-05-28 11:22:09 +02001188 int n, ret = 0;
Frank Praznik60781cf2014-01-11 15:13:15 -05001189 int max_brightness;
Frank Praznik61ebca92014-01-20 12:27:02 -05001190 int use_colors;
Jiri Kosina40e32ee2013-05-28 11:22:09 +02001191 struct led_classdev *led;
1192 size_t name_sz;
1193 char *name;
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001194 size_t name_len;
1195 const char *name_fmt;
Frank Praznik61ebca92014-01-20 12:27:02 -05001196 static const char * const color_str[] = { "red", "green", "blue" };
Frank Praznik60781cf2014-01-11 15:13:15 -05001197 static const __u8 initial_values[MAX_LEDS] = { 0x00, 0x00, 0x00, 0x00 };
Colin Leitnerf04d5142013-05-27 23:41:05 +02001198
1199 drv_data = hid_get_drvdata(hdev);
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001200 BUG_ON(!(drv_data->quirks & SONY_LED_SUPPORT));
Colin Leitnerf04d5142013-05-27 23:41:05 +02001201
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001202 if (drv_data->quirks & BUZZ_CONTROLLER) {
Frank Praznik61ebca92014-01-20 12:27:02 -05001203 drv_data->led_count = 4;
1204 max_brightness = 1;
1205 use_colors = 0;
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001206 name_len = strlen("::buzz#");
1207 name_fmt = "%s::buzz%d";
1208 /* Validate expected report characteristics. */
1209 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7))
1210 return -ENODEV;
Frank Praznik68330d82014-02-05 20:03:49 -05001211 } else if (drv_data->quirks & DUALSHOCK4_CONTROLLER) {
Frank Praznik60781cf2014-01-11 15:13:15 -05001212 drv_data->led_count = 3;
1213 max_brightness = 255;
Frank Praznik61ebca92014-01-20 12:27:02 -05001214 use_colors = 1;
1215 name_len = 0;
1216 name_fmt = "%s:%s";
Frank Praznik60781cf2014-01-11 15:13:15 -05001217 } else {
1218 drv_data->led_count = 4;
1219 max_brightness = 1;
Frank Praznik61ebca92014-01-20 12:27:02 -05001220 use_colors = 0;
1221 name_len = strlen("::sony#");
1222 name_fmt = "%s::sony%d";
Frank Praznik60781cf2014-01-11 15:13:15 -05001223 }
1224
Frank Praznikad142b92014-02-20 11:36:00 -05001225 /*
1226 * Clear LEDs as we have no way of reading their initial state. This is
Colin Leitnerf04d5142013-05-27 23:41:05 +02001227 * only relevant if the driver is loaded after somebody actively set the
Frank Praznikad142b92014-02-20 11:36:00 -05001228 * LEDs to on
1229 */
Frank Praznik60781cf2014-01-11 15:13:15 -05001230 sony_set_leds(hdev, initial_values, drv_data->led_count);
Colin Leitnerf04d5142013-05-27 23:41:05 +02001231
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001232 name_sz = strlen(dev_name(&hdev->dev)) + name_len + 1;
Colin Leitnerf04d5142013-05-27 23:41:05 +02001233
Frank Praznik60781cf2014-01-11 15:13:15 -05001234 for (n = 0; n < drv_data->led_count; n++) {
Frank Praznik61ebca92014-01-20 12:27:02 -05001235
1236 if (use_colors)
1237 name_sz = strlen(dev_name(&hdev->dev)) + strlen(color_str[n]) + 2;
1238
Jiri Kosina40e32ee2013-05-28 11:22:09 +02001239 led = kzalloc(sizeof(struct led_classdev) + name_sz, GFP_KERNEL);
1240 if (!led) {
1241 hid_err(hdev, "Couldn't allocate memory for LED %d\n", n);
Julia Lawall8cd5fcd2013-12-29 23:47:27 +01001242 ret = -ENOMEM;
Jiri Kosina40e32ee2013-05-28 11:22:09 +02001243 goto error_leds;
Colin Leitnerf04d5142013-05-27 23:41:05 +02001244 }
Jiri Kosina40e32ee2013-05-28 11:22:09 +02001245
1246 name = (void *)(&led[1]);
Frank Praznik61ebca92014-01-20 12:27:02 -05001247 if (use_colors)
1248 snprintf(name, name_sz, name_fmt, dev_name(&hdev->dev), color_str[n]);
1249 else
1250 snprintf(name, name_sz, name_fmt, dev_name(&hdev->dev), n + 1);
Jiri Kosina40e32ee2013-05-28 11:22:09 +02001251 led->name = name;
1252 led->brightness = 0;
Frank Praznik60781cf2014-01-11 15:13:15 -05001253 led->max_brightness = max_brightness;
Sven Eckelmannc5382512013-11-19 20:26:30 +01001254 led->brightness_get = sony_led_get_brightness;
1255 led->brightness_set = sony_led_set_brightness;
Jiri Kosina40e32ee2013-05-28 11:22:09 +02001256
Julia Lawall8cd5fcd2013-12-29 23:47:27 +01001257 ret = led_classdev_register(&hdev->dev, led);
1258 if (ret) {
Jiri Kosina40e32ee2013-05-28 11:22:09 +02001259 hid_err(hdev, "Failed to register LED %d\n", n);
1260 kfree(led);
1261 goto error_leds;
1262 }
1263
Sven Eckelmann2251b852013-11-19 20:26:31 +01001264 drv_data->leds[n] = led;
Colin Leitnerf04d5142013-05-27 23:41:05 +02001265 }
Colin Leitnerf04d5142013-05-27 23:41:05 +02001266
1267 return ret;
1268
Colin Leitnerf04d5142013-05-27 23:41:05 +02001269error_leds:
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001270 sony_leds_remove(hdev);
Colin Leitnerf04d5142013-05-27 23:41:05 +02001271
Colin Leitnerf04d5142013-05-27 23:41:05 +02001272 return ret;
Colin Leitnerf04d5142013-05-27 23:41:05 +02001273}
1274
Frank Praznikcad665a2014-01-11 15:13:54 -05001275static void sixaxis_state_worker(struct work_struct *work)
Sven Eckelmanna08c22c2013-11-09 19:25:57 +01001276{
Sven Eckelmann92b5c412013-11-19 20:26:28 +01001277 struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
Sven Eckelmanna08c22c2013-11-09 19:25:57 +01001278 unsigned char buf[] = {
1279 0x01,
1280 0x00, 0xff, 0x00, 0xff, 0x00,
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001281 0x00, 0x00, 0x00, 0x00, 0x00,
Sven Eckelmanna08c22c2013-11-09 19:25:57 +01001282 0xff, 0x27, 0x10, 0x00, 0x32,
1283 0xff, 0x27, 0x10, 0x00, 0x32,
1284 0xff, 0x27, 0x10, 0x00, 0x32,
1285 0xff, 0x27, 0x10, 0x00, 0x32,
1286 0x00, 0x00, 0x00, 0x00, 0x00
1287 };
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001288
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001289#ifdef CONFIG_SONY_FF
Frank Praznik0bd88dd2014-01-11 15:12:42 -05001290 buf[3] = sc->right ? 1 : 0;
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001291 buf[5] = sc->left;
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001292#endif
1293
Frank Praznik60781cf2014-01-11 15:13:15 -05001294 buf[10] |= sc->led_state[0] << 1;
1295 buf[10] |= sc->led_state[1] << 2;
1296 buf[10] |= sc->led_state[2] << 3;
1297 buf[10] |= sc->led_state[3] << 4;
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001298
Frank Praznikfee4e2d2014-02-18 17:22:01 -05001299 if (sc->quirks & SIXAXIS_CONTROLLER_USB)
1300 hid_output_raw_report(sc->hdev, buf, sizeof(buf), HID_OUTPUT_REPORT);
1301 else
1302 hid_hw_raw_request(sc->hdev, 0x01, buf, sizeof(buf),
1303 HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001304}
1305
Frank Praznik0bd88dd2014-01-11 15:12:42 -05001306static void dualshock4_state_worker(struct work_struct *work)
1307{
1308 struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
Frank Praznik0da8ea62014-01-16 21:42:51 -05001309 struct hid_device *hdev = sc->hdev;
Frank Praznik48220232014-02-05 20:03:44 -05001310 int offset;
Frank Praznik0da8ea62014-01-16 21:42:51 -05001311
Frank Praznikfdcf105d2014-02-05 20:03:46 -05001312 __u8 buf[78] = { 0 };
Frank Praznik48220232014-02-05 20:03:44 -05001313
Frank Praznikfdcf105d2014-02-05 20:03:46 -05001314 if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) {
1315 buf[0] = 0x05;
1316 buf[1] = 0x03;
1317 offset = 4;
1318 } else {
1319 buf[0] = 0x11;
1320 buf[1] = 0xB0;
1321 buf[3] = 0x0F;
1322 offset = 6;
1323 }
Frank Praznik0bd88dd2014-01-11 15:12:42 -05001324
1325#ifdef CONFIG_SONY_FF
Frank Praznik48220232014-02-05 20:03:44 -05001326 buf[offset++] = sc->right;
1327 buf[offset++] = sc->left;
1328#else
1329 offset += 2;
Frank Praznik0bd88dd2014-01-11 15:12:42 -05001330#endif
1331
Frank Praznik48220232014-02-05 20:03:44 -05001332 buf[offset++] = sc->led_state[0];
1333 buf[offset++] = sc->led_state[1];
1334 buf[offset++] = sc->led_state[2];
Frank Praznik60781cf2014-01-11 15:13:15 -05001335
Frank Praznikfdcf105d2014-02-05 20:03:46 -05001336 if (sc->quirks & DUALSHOCK4_CONTROLLER_USB)
1337 hid_hw_output_report(hdev, buf, 32);
1338 else
1339 hid_hw_raw_request(hdev, 0x11, buf, 78,
1340 HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
Frank Praznik0bd88dd2014-01-11 15:12:42 -05001341}
1342
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001343#ifdef CONFIG_SONY_FF
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001344static int sony_play_effect(struct input_dev *dev, void *data,
1345 struct ff_effect *effect)
1346{
Sven Eckelmanna08c22c2013-11-09 19:25:57 +01001347 struct hid_device *hid = input_get_drvdata(dev);
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001348 struct sony_sc *sc = hid_get_drvdata(hid);
Sven Eckelmanna08c22c2013-11-09 19:25:57 +01001349
1350 if (effect->type != FF_RUMBLE)
1351 return 0;
1352
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001353 sc->left = effect->u.rumble.strong_magnitude / 256;
Frank Praznik0bd88dd2014-01-11 15:12:42 -05001354 sc->right = effect->u.rumble.weak_magnitude / 256;
Sven Eckelmanna08c22c2013-11-09 19:25:57 +01001355
Sven Eckelmann92b5c412013-11-19 20:26:28 +01001356 schedule_work(&sc->state_worker);
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001357 return 0;
Sven Eckelmanna08c22c2013-11-09 19:25:57 +01001358}
1359
1360static int sony_init_ff(struct hid_device *hdev)
1361{
1362 struct hid_input *hidinput = list_entry(hdev->inputs.next,
1363 struct hid_input, list);
1364 struct input_dev *input_dev = hidinput->input;
1365
1366 input_set_capability(input_dev, EV_FF, FF_RUMBLE);
1367 return input_ff_create_memless(input_dev, NULL, sony_play_effect);
1368}
1369
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001370static void sony_destroy_ff(struct hid_device *hdev)
1371{
1372 struct sony_sc *sc = hid_get_drvdata(hdev);
1373
Sven Eckelmann92b5c412013-11-19 20:26:28 +01001374 cancel_work_sync(&sc->state_worker);
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001375}
1376
Sven Eckelmanna08c22c2013-11-09 19:25:57 +01001377#else
1378static int sony_init_ff(struct hid_device *hdev)
1379{
1380 return 0;
1381}
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001382
1383static void sony_destroy_ff(struct hid_device *hdev)
1384{
1385}
Sven Eckelmanna08c22c2013-11-09 19:25:57 +01001386#endif
1387
Frank Praznikd902f472014-01-27 10:17:36 -05001388static int sony_battery_get_property(struct power_supply *psy,
1389 enum power_supply_property psp,
1390 union power_supply_propval *val)
1391{
1392 struct sony_sc *sc = container_of(psy, struct sony_sc, battery);
1393 unsigned long flags;
1394 int ret = 0;
1395 u8 battery_charging, battery_capacity, cable_state;
1396
1397 spin_lock_irqsave(&sc->lock, flags);
1398 battery_charging = sc->battery_charging;
1399 battery_capacity = sc->battery_capacity;
1400 cable_state = sc->cable_state;
1401 spin_unlock_irqrestore(&sc->lock, flags);
1402
1403 switch (psp) {
1404 case POWER_SUPPLY_PROP_PRESENT:
1405 val->intval = 1;
1406 break;
1407 case POWER_SUPPLY_PROP_SCOPE:
1408 val->intval = POWER_SUPPLY_SCOPE_DEVICE;
1409 break;
1410 case POWER_SUPPLY_PROP_CAPACITY:
1411 val->intval = battery_capacity;
1412 break;
1413 case POWER_SUPPLY_PROP_STATUS:
1414 if (battery_charging)
1415 val->intval = POWER_SUPPLY_STATUS_CHARGING;
1416 else
1417 if (battery_capacity == 100 && cable_state)
1418 val->intval = POWER_SUPPLY_STATUS_FULL;
1419 else
1420 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
1421 break;
1422 default:
1423 ret = -EINVAL;
1424 break;
1425 }
1426 return ret;
1427}
1428
1429static int sony_battery_probe(struct sony_sc *sc)
1430{
1431 static atomic_t power_id_seq = ATOMIC_INIT(0);
1432 unsigned long power_id;
1433 struct hid_device *hdev = sc->hdev;
1434 int ret;
1435
Frank Praznikad142b92014-02-20 11:36:00 -05001436 /*
1437 * Set the default battery level to 100% to avoid low battery warnings
Frank Praznikd9a293a2014-02-05 20:03:48 -05001438 * if the battery is polled before the first device report is received.
1439 */
1440 sc->battery_capacity = 100;
1441
Frank Praznikd902f472014-01-27 10:17:36 -05001442 power_id = (unsigned long)atomic_inc_return(&power_id_seq);
1443
1444 sc->battery.properties = sony_battery_props;
1445 sc->battery.num_properties = ARRAY_SIZE(sony_battery_props);
1446 sc->battery.get_property = sony_battery_get_property;
1447 sc->battery.type = POWER_SUPPLY_TYPE_BATTERY;
1448 sc->battery.use_for_apm = 0;
1449 sc->battery.name = kasprintf(GFP_KERNEL, "sony_controller_battery_%lu",
1450 power_id);
1451 if (!sc->battery.name)
1452 return -ENOMEM;
1453
1454 ret = power_supply_register(&hdev->dev, &sc->battery);
1455 if (ret) {
1456 hid_err(hdev, "Unable to register battery device\n");
1457 goto err_free;
1458 }
1459
1460 power_supply_powers(&sc->battery, &hdev->dev);
1461 return 0;
1462
1463err_free:
1464 kfree(sc->battery.name);
1465 sc->battery.name = NULL;
1466 return ret;
1467}
1468
1469static void sony_battery_remove(struct sony_sc *sc)
1470{
1471 if (!sc->battery.name)
1472 return;
1473
1474 power_supply_unregister(&sc->battery);
1475 kfree(sc->battery.name);
1476 sc->battery.name = NULL;
1477}
1478
Frank Praznike5606232014-01-27 10:17:37 -05001479static int sony_register_touchpad(struct sony_sc *sc, int touch_count,
1480 int w, int h)
1481{
1482 struct hid_input *hidinput = list_entry(sc->hdev->inputs.next,
1483 struct hid_input, list);
1484 struct input_dev *input_dev = hidinput->input;
1485 int ret;
1486
1487 ret = input_mt_init_slots(input_dev, touch_count, 0);
1488 if (ret < 0) {
1489 hid_err(sc->hdev, "Unable to initialize multi-touch slots\n");
1490 return ret;
1491 }
1492
1493 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, w, 0, 0);
1494 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, h, 0, 0);
1495
1496 return 0;
1497}
1498
Jiri Slabybd28ce02008-06-25 23:47:04 +02001499static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
1500{
1501 int ret;
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +02001502 unsigned long quirks = id->driver_data;
1503 struct sony_sc *sc;
Colin Leitnerf04d5142013-05-27 23:41:05 +02001504 unsigned int connect_mask = HID_CONNECT_DEFAULT;
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +02001505
Benjamin Tissoiresabf832b2013-07-24 19:38:04 +02001506 sc = devm_kzalloc(&hdev->dev, sizeof(*sc), GFP_KERNEL);
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +02001507 if (sc == NULL) {
Joe Perches4291ee32010-12-09 19:29:03 -08001508 hid_err(hdev, "can't alloc sony descriptor\n");
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +02001509 return -ENOMEM;
1510 }
1511
1512 sc->quirks = quirks;
1513 hid_set_drvdata(hdev, sc);
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001514 sc->hdev = hdev;
Jiri Slabybd28ce02008-06-25 23:47:04 +02001515
Jiri Slabybd28ce02008-06-25 23:47:04 +02001516 ret = hid_parse(hdev);
1517 if (ret) {
Joe Perches4291ee32010-12-09 19:29:03 -08001518 hid_err(hdev, "parse failed\n");
Benjamin Tissoiresabf832b2013-07-24 19:38:04 +02001519 return ret;
Jiri Slabybd28ce02008-06-25 23:47:04 +02001520 }
1521
Colin Leitnerf04d5142013-05-27 23:41:05 +02001522 if (sc->quirks & VAIO_RDESC_CONSTANT)
1523 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
1524 else if (sc->quirks & SIXAXIS_CONTROLLER_USB)
1525 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
1526 else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
1527 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
1528
1529 ret = hid_hw_start(hdev, connect_mask);
Jiri Slabybd28ce02008-06-25 23:47:04 +02001530 if (ret) {
Joe Perches4291ee32010-12-09 19:29:03 -08001531 hid_err(hdev, "hw start failed\n");
Benjamin Tissoiresabf832b2013-07-24 19:38:04 +02001532 return ret;
Jiri Slabybd28ce02008-06-25 23:47:04 +02001533 }
1534
Antonio Ospite569b10a2010-10-19 16:13:10 +02001535 if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
1536 hdev->hid_output_raw_report = sixaxis_usb_output_raw_report;
Antonio Ospite816651a2010-05-03 22:15:55 +02001537 ret = sixaxis_set_operational_usb(hdev);
Frank Praznikcad665a2014-01-11 15:13:54 -05001538 INIT_WORK(&sc->state_worker, sixaxis_state_worker);
Frank Praznikfee4e2d2014-02-18 17:22:01 -05001539 } else if (sc->quirks & SIXAXIS_CONTROLLER_BT) {
Antonio Ospite816651a2010-05-03 22:15:55 +02001540 ret = sixaxis_set_operational_bt(hdev);
Frank Praznikfee4e2d2014-02-18 17:22:01 -05001541 INIT_WORK(&sc->state_worker, sixaxis_state_worker);
1542 } else if (sc->quirks & DUALSHOCK4_CONTROLLER) {
Frank Praznik68330d82014-02-05 20:03:49 -05001543 if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) {
1544 ret = dualshock4_set_operational_bt(hdev);
1545 if (ret < 0) {
1546 hid_err(hdev, "failed to set the Dualshock 4 operational mode\n");
1547 goto err_stop;
1548 }
1549 }
Frank Praznikad142b92014-02-20 11:36:00 -05001550 /*
1551 * The Dualshock 4 touchpad supports 2 touches and has a
Frank Praznike5606232014-01-27 10:17:37 -05001552 * resolution of 1920x940.
1553 */
1554 ret = sony_register_touchpad(sc, 2, 1920, 940);
1555 if (ret < 0)
1556 goto err_stop;
1557
Frank Praznik0bd88dd2014-01-11 15:12:42 -05001558 INIT_WORK(&sc->state_worker, dualshock4_state_worker);
1559 } else {
1560 ret = 0;
1561 }
Bastien Noceraf9ce7c22010-01-20 12:01:53 +00001562
Jiri Kosina4dfdc462008-12-30 00:49:59 +01001563 if (ret < 0)
Jiri Slabybd28ce02008-06-25 23:47:04 +02001564 goto err_stop;
1565
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001566 if (sc->quirks & SONY_LED_SUPPORT) {
1567 ret = sony_leds_init(hdev);
1568 if (ret < 0)
1569 goto err_stop;
1570 }
1571
Frank Praznikd902f472014-01-27 10:17:36 -05001572 if (sc->quirks & SONY_BATTERY_SUPPORT) {
1573 ret = sony_battery_probe(sc);
1574 if (ret < 0)
1575 goto err_stop;
1576
1577 /* Open the device to receive reports with battery info */
1578 ret = hid_hw_open(hdev);
1579 if (ret < 0) {
1580 hid_err(hdev, "hw open failed\n");
1581 goto err_stop;
1582 }
1583 }
1584
Sven Eckelmanna08c22c2013-11-09 19:25:57 +01001585 ret = sony_init_ff(hdev);
1586 if (ret < 0)
Frank Praznikd902f472014-01-27 10:17:36 -05001587 goto err_close;
Sven Eckelmanna08c22c2013-11-09 19:25:57 +01001588
Jiri Slabybd28ce02008-06-25 23:47:04 +02001589 return 0;
Frank Praznikd902f472014-01-27 10:17:36 -05001590err_close:
1591 hid_hw_close(hdev);
Jiri Slabybd28ce02008-06-25 23:47:04 +02001592err_stop:
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001593 if (sc->quirks & SONY_LED_SUPPORT)
1594 sony_leds_remove(hdev);
Frank Praznikd902f472014-01-27 10:17:36 -05001595 if (sc->quirks & SONY_BATTERY_SUPPORT)
1596 sony_battery_remove(sc);
Jiri Slabybd28ce02008-06-25 23:47:04 +02001597 hid_hw_stop(hdev);
Jiri Slabybd28ce02008-06-25 23:47:04 +02001598 return ret;
1599}
1600
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +02001601static void sony_remove(struct hid_device *hdev)
1602{
Colin Leitnerf04d5142013-05-27 23:41:05 +02001603 struct sony_sc *sc = hid_get_drvdata(hdev);
1604
Sven Eckelmann0a286ef2013-11-19 20:26:32 +01001605 if (sc->quirks & SONY_LED_SUPPORT)
Sven Eckelmannc5382512013-11-19 20:26:30 +01001606 sony_leds_remove(hdev);
Colin Leitnerf04d5142013-05-27 23:41:05 +02001607
Frank Praznikd902f472014-01-27 10:17:36 -05001608 if (sc->quirks & SONY_BATTERY_SUPPORT) {
1609 hid_hw_close(hdev);
1610 sony_battery_remove(sc);
1611 }
1612
Sven Eckelmann9f323b62013-11-17 20:38:21 +01001613 sony_destroy_ff(hdev);
1614
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +02001615 hid_hw_stop(hdev);
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +02001616}
1617
Jiri Slabybd28ce02008-06-25 23:47:04 +02001618static const struct hid_device_id sony_devices[] = {
Antonio Ospite816651a2010-05-03 22:15:55 +02001619 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
1620 .driver_data = SIXAXIS_CONTROLLER_USB },
Jiri Kosina35dca5b2011-04-28 15:43:13 +02001621 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER),
1622 .driver_data = SIXAXIS_CONTROLLER_USB },
Antonio Ospite816651a2010-05-03 22:15:55 +02001623 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
1624 .driver_data = SIXAXIS_CONTROLLER_BT },
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +02001625 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),
1626 .driver_data = VAIO_RDESC_CONSTANT },
Fernando Luis Vázquez Caoa46491842013-01-15 19:40:48 +09001627 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE),
1628 .driver_data = VAIO_RDESC_CONSTANT },
Colin Leitnerf04d5142013-05-27 23:41:05 +02001629 /* Wired Buzz Controller. Reported as Sony Hub from its USB ID and as
1630 * Logitech joystick from the device descriptor. */
1631 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER),
1632 .driver_data = BUZZ_CONTROLLER },
1633 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER),
1634 .driver_data = BUZZ_CONTROLLER },
Jiri Kosina078328d2013-06-13 12:03:49 +02001635 /* PS3 BD Remote Control */
1636 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE),
1637 .driver_data = PS3REMOTE },
1638 /* Logitech Harmony Adapter for PS3 */
1639 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3),
1640 .driver_data = PS3REMOTE },
Frank Praznik0bd88dd2014-01-11 15:12:42 -05001641 /* Sony Dualshock 4 controllers for PS4 */
1642 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
Frank Praznik8ab16762014-01-16 21:42:31 -05001643 .driver_data = DUALSHOCK4_CONTROLLER_USB },
Frank Praznik0bd88dd2014-01-11 15:12:42 -05001644 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
Frank Praznik8ab16762014-01-16 21:42:31 -05001645 .driver_data = DUALSHOCK4_CONTROLLER_BT },
Jiri Slabybd28ce02008-06-25 23:47:04 +02001646 { }
1647};
1648MODULE_DEVICE_TABLE(hid, sony_devices);
1649
1650static struct hid_driver sony_driver = {
Colin Leitnerf04d5142013-05-27 23:41:05 +02001651 .name = "sony",
1652 .id_table = sony_devices,
1653 .input_mapping = sony_mapping,
1654 .probe = sony_probe,
1655 .remove = sony_remove,
1656 .report_fixup = sony_report_fixup,
1657 .raw_event = sony_raw_event
Jiri Slabybd28ce02008-06-25 23:47:04 +02001658};
H Hartley Sweetenf4254582012-12-17 15:28:26 -07001659module_hid_driver(sony_driver);
Jiri Slabybd28ce02008-06-25 23:47:04 +02001660
Jiri Slabybd28ce02008-06-25 23:47:04 +02001661MODULE_LICENSE("GPL");