| @@ -48,19 +48,21 @@ · 47 unmodified lines |
| 48 | #define PS3REMOTE BIT(4) | 48 | #define PS3REMOTE BIT(4) |
| 49 | #define DUALSHOCK4_CONTROLLER_USB BIT(5) | 49 | #define DUALSHOCK4_CONTROLLER_USB BIT(5) |
| 50 | #define DUALSHOCK4_CONTROLLER_BT BIT(6) | 50 | #define DUALSHOCK4_CONTROLLER_BT BIT(6) |
| 51 | #define MOTION_CONTROLLER_USB BIT(7) | 51 | #define DUALSHOCK4_DONGLE BIT(7) |
| 52 | #define MOTION_CONTROLLER_BT BIT(8) | 52 | #define MOTION_CONTROLLER_USB BIT(8) |
| 53 | #define NAVIGATION_CONTROLLER_USB BIT(9) | 53 | #define MOTION_CONTROLLER_BT BIT(9) |
| 54 | #define NAVIGATION_CONTROLLER_BT BIT(10) | 54 | #define NAVIGATION_CONTROLLER_USB BIT(10) |
| 55 | #define SINO_LITE_CONTROLLER BIT(11) | 55 | #define NAVIGATION_CONTROLLER_BT BIT(11) |
| 56 | #define FUTUREMAX_DANCE_MAT BIT(12) | 56 | #define SINO_LITE_CONTROLLER BIT(12) |
| | 57 | #define FUTUREMAX_DANCE_MAT BIT(13) |
| 57 | | 58 | |
| 58 | #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT) | 59 | #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT) |
| 59 | #define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT) | 60 | #define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT) |
| 60 | #define NAVIGATION_CONTROLLER (NAVIGATION_CONTROLLER_USB |\ | 61 | #define NAVIGATION_CONTROLLER (NAVIGATION_CONTROLLER_USB |\ |
| 61 | NAVIGATION_CONTROLLER_BT) | 62 | NAVIGATION_CONTROLLER_BT) |
| 62 | #define DUALSHOCK4_CONTROLLER (DUALSHOCK4_CONTROLLER_USB |\ | 63 | #define DUALSHOCK4_CONTROLLER (DUALSHOCK4_CONTROLLER_USB |\ |
| 63 | DUALSHOCK4_CONTROLLER_BT) | 64 | DUALSHOCK4_CONTROLLER_BT | \ |
| | 65 | DUALSHOCK4_DONGLE) |
| 64 | #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\ | 66 | #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\ |
| 65 | DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER |\ | 67 | DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER |\ |
| 66 | NAVIGATION_CONTROLLER) | 68 | NAVIGATION_CONTROLLER) |
| @@ -73,89 +75,6 @@ · 6 unmodified lines |
| 73 | | 75 | |
| 74 | #define MAX_LEDS 4 | 76 | #define MAX_LEDS 4 |
| 75 | | 77 | |
| 76 | /* | | |
| 77 | * The Sixaxis reports both digital and analog values for each button on the | | |
| 78 | * controller except for Start, Select and the PS button. The controller ends | | |
| 79 | * up reporting 27 axes which causes them to spill over into the multi-touch | | |
| 80 | * axis values. Additionally, the controller only has 20 actual, physical axes | | |
| 81 | * so there are several unused axes in between the used ones. | | |
| 82 | */ | | |
| 83 | static u8 sixaxis_rdesc[] = { | | |
| 84 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 85 | 0x09, 0x04, /* Usage (Joystick), */ | | |
| 86 | 0xA1, 0x01, /* Collection (Application), */ | | |
| 87 | 0xA1, 0x02, /* Collection (Logical), */ | | |
| 88 | 0x85, 0x01, /* Report ID (1), */ | | |
| 89 | 0x75, 0x08, /* Report Size (8), */ | | |
| 90 | 0x95, 0x01, /* Report Count (1), */ | | |
| 91 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 92 | 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ | | |
| 93 | 0x81, 0x03, /* Input (Constant, Variable), */ | | |
| 94 | 0x75, 0x01, /* Report Size (1), */ | | |
| 95 | 0x95, 0x13, /* Report Count (19), */ | | |
| 96 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 97 | 0x25, 0x01, /* Logical Maximum (1), */ | | |
| 98 | 0x35, 0x00, /* Physical Minimum (0), */ | | |
| 99 | 0x45, 0x01, /* Physical Maximum (1), */ | | |
| 100 | 0x05, 0x09, /* Usage Page (Button), */ | | |
| 101 | 0x19, 0x01, /* Usage Minimum (01h), */ | | |
| 102 | 0x29, 0x13, /* Usage Maximum (13h), */ | | |
| 103 | 0x81, 0x02, /* Input (Variable), */ | | |
| 104 | 0x75, 0x01, /* Report Size (1), */ | | |
| 105 | 0x95, 0x0D, /* Report Count (13), */ | | |
| 106 | 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ | | |
| 107 | 0x81, 0x03, /* Input (Constant, Variable), */ | | |
| 108 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 109 | 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ | | |
| 110 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 111 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 112 | 0xA1, 0x00, /* Collection (Physical), */ | | |
| 113 | 0x75, 0x08, /* Report Size (8), */ | | |
| 114 | 0x95, 0x04, /* Report Count (4), */ | | |
| 115 | 0x35, 0x00, /* Physical Minimum (0), */ | | |
| 116 | 0x46, 0xFF, 0x00, /* Physical Maximum (255), */ | | |
| 117 | 0x09, 0x30, /* Usage (X), */ | | |
| 118 | 0x09, 0x31, /* Usage (Y), */ | | |
| 119 | 0x09, 0x32, /* Usage (Z), */ | | |
| 120 | 0x09, 0x35, /* Usage (Rz), */ | | |
| 121 | 0x81, 0x02, /* Input (Variable), */ | | |
| 122 | 0xC0, /* End Collection, */ | | |
| 123 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 124 | 0x95, 0x13, /* Report Count (19), */ | | |
| 125 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 126 | 0x81, 0x02, /* Input (Variable), */ | | |
| 127 | 0x95, 0x0C, /* Report Count (12), */ | | |
| 128 | 0x81, 0x01, /* Input (Constant), */ | | |
| 129 | 0x75, 0x10, /* Report Size (16), */ | | |
| 130 | 0x95, 0x04, /* Report Count (4), */ | | |
| 131 | 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */ | | |
| 132 | 0x46, 0xFF, 0x03, /* Physical Maximum (1023), */ | | |
| 133 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 134 | 0x81, 0x02, /* Input (Variable), */ | | |
| 135 | 0xC0, /* End Collection, */ | | |
| 136 | 0xA1, 0x02, /* Collection (Logical), */ | | |
| 137 | 0x85, 0x02, /* Report ID (2), */ | | |
| 138 | 0x75, 0x08, /* Report Size (8), */ | | |
| 139 | 0x95, 0x30, /* Report Count (48), */ | | |
| 140 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 141 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 142 | 0xC0, /* End Collection, */ | | |
| 143 | 0xA1, 0x02, /* Collection (Logical), */ | | |
| 144 | 0x85, 0xEE, /* Report ID (238), */ | | |
| 145 | 0x75, 0x08, /* Report Size (8), */ | | |
| 146 | 0x95, 0x30, /* Report Count (48), */ | | |
| 147 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 148 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 149 | 0xC0, /* End Collection, */ | | |
| 150 | 0xA1, 0x02, /* Collection (Logical), */ | | |
| 151 | 0x85, 0xEF, /* Report ID (239), */ | | |
| 152 | 0x75, 0x08, /* Report Size (8), */ | | |
| 153 | 0x95, 0x30, /* Report Count (48), */ | | |
| 154 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 155 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 156 | 0xC0, /* End Collection, */ | | |
| 157 | 0xC0 /* End Collection */ | | |
| 158 | }; | | |
| 159 | | 78 | |
| 160 | /* PS/3 Motion controller */ | 79 | /* PS/3 Motion controller */ |
| 161 | static u8 motion_rdesc[] = { | 80 | static u8 motion_rdesc[] = { |
| @@ -254,567 +173,6 @@ static u8 motion_rdesc[] = { · 92 unmodified lines |
| 254 | 0xC0 /* End Collection */ | 173 | 0xC0 /* End Collection */ |
| 255 | }; | 174 | }; |
| 256 | | 175 | |
| 257 | /* PS/3 Navigation controller */ | | |
| 258 | static u8 navigation_rdesc[] = { | | |
| 259 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 260 | 0x09, 0x04, /* Usage (Joystick), */ | | |
| 261 | 0xA1, 0x01, /* Collection (Application), */ | | |
| 262 | 0xA1, 0x02, /* Collection (Logical), */ | | |
| 263 | 0x85, 0x01, /* Report ID (1), */ | | |
| 264 | 0x75, 0x08, /* Report Size (8), */ | | |
| 265 | 0x95, 0x01, /* Report Count (1), */ | | |
| 266 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 267 | 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ | | |
| 268 | 0x81, 0x03, /* Input (Constant, Variable), */ | | |
| 269 | 0x75, 0x01, /* Report Size (1), */ | | |
| 270 | 0x95, 0x13, /* Report Count (19), */ | | |
| 271 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 272 | 0x25, 0x01, /* Logical Maximum (1), */ | | |
| 273 | 0x35, 0x00, /* Physical Minimum (0), */ | | |
| 274 | 0x45, 0x01, /* Physical Maximum (1), */ | | |
| 275 | 0x05, 0x09, /* Usage Page (Button), */ | | |
| 276 | 0x19, 0x01, /* Usage Minimum (01h), */ | | |
| 277 | 0x29, 0x13, /* Usage Maximum (13h), */ | | |
| 278 | 0x81, 0x02, /* Input (Variable), */ | | |
| 279 | 0x75, 0x01, /* Report Size (1), */ | | |
| 280 | 0x95, 0x0D, /* Report Count (13), */ | | |
| 281 | 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ | | |
| 282 | 0x81, 0x03, /* Input (Constant, Variable), */ | | |
| 283 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 284 | 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ | | |
| 285 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 286 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 287 | 0xA1, 0x00, /* Collection (Physical), */ | | |
| 288 | 0x75, 0x08, /* Report Size (8), */ | | |
| 289 | 0x95, 0x02, /* Report Count (2), */ | | |
| 290 | 0x35, 0x00, /* Physical Minimum (0), */ | | |
| 291 | 0x46, 0xFF, 0x00, /* Physical Maximum (255), */ | | |
| 292 | 0x09, 0x30, /* Usage (X), */ | | |
| 293 | 0x09, 0x31, /* Usage (Y), */ | | |
| 294 | 0x81, 0x02, /* Input (Variable), */ | | |
| 295 | 0xC0, /* End Collection, */ | | |
| 296 | 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ | | |
| 297 | 0x95, 0x06, /* Report Count (6), */ | | |
| 298 | 0x81, 0x03, /* Input (Constant, Variable), */ | | |
| 299 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 300 | 0x75, 0x08, /* Report Size (8), */ | | |
| 301 | 0x95, 0x05, /* Report Count (5), */ | | |
| 302 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 303 | 0x81, 0x02, /* Input (Variable), */ | | |
| 304 | 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ | | |
| 305 | 0x95, 0x01, /* Report Count (1), */ | | |
| 306 | 0x81, 0x02, /* Input (Variable), */ | | |
| 307 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 308 | 0x95, 0x01, /* Report Count (1), */ | | |
| 309 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 310 | 0x81, 0x02, /* Input (Variable), */ | | |
| 311 | 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ | | |
| 312 | 0x95, 0x1E, /* Report Count (24), */ | | |
| 313 | 0x81, 0x02, /* Input (Variable), */ | | |
| 314 | 0x75, 0x08, /* Report Size (8), */ | | |
| 315 | 0x95, 0x30, /* Report Count (48), */ | | |
| 316 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 317 | 0x91, 0x02, /* Output (Variable), */ | | |
| 318 | 0x75, 0x08, /* Report Size (8), */ | | |
| 319 | 0x95, 0x30, /* Report Count (48), */ | | |
| 320 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 321 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 322 | 0xC0, /* End Collection, */ | | |
| 323 | 0xA1, 0x02, /* Collection (Logical), */ | | |
| 324 | 0x85, 0x02, /* Report ID (2), */ | | |
| 325 | 0x75, 0x08, /* Report Size (8), */ | | |
| 326 | 0x95, 0x30, /* Report Count (48), */ | | |
| 327 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 328 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 329 | 0xC0, /* End Collection, */ | | |
| 330 | 0xA1, 0x02, /* Collection (Logical), */ | | |
| 331 | 0x85, 0xEE, /* Report ID (238), */ | | |
| 332 | 0x75, 0x08, /* Report Size (8), */ | | |
| 333 | 0x95, 0x30, /* Report Count (48), */ | | |
| 334 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 335 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 336 | 0xC0, /* End Collection, */ | | |
| 337 | 0xA1, 0x02, /* Collection (Logical), */ | | |
| 338 | 0x85, 0xEF, /* Report ID (239), */ | | |
| 339 | 0x75, 0x08, /* Report Size (8), */ | | |
| 340 | 0x95, 0x30, /* Report Count (48), */ | | |
| 341 | 0x09, 0x01, /* Usage (Pointer), */ | | |
| 342 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 343 | 0xC0, /* End Collection, */ | | |
| 344 | 0xC0 /* End Collection */ | | |
| 345 | }; | | |
| 346 | | | |
| 347 | /* | | |
| 348 | * The default descriptor doesn't provide mapping for the accelerometers | | |
| 349 | * or orientation sensors. This fixed descriptor maps the accelerometers | | |
| 350 | * to usage values 0x40, 0x41 and 0x42 and maps the orientation sensors | | |
| 351 | * to usage values 0x43, 0x44 and 0x45. | | |
| 352 | */ | | |
| 353 | static u8 dualshock4_usb_rdesc[] = { | | |
| 354 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 355 | 0x09, 0x05, /* Usage (Gamepad), */ | | |
| 356 | 0xA1, 0x01, /* Collection (Application), */ | | |
| 357 | 0x85, 0x01, /* Report ID (1), */ | | |
| 358 | 0x09, 0x30, /* Usage (X), */ | | |
| 359 | 0x09, 0x31, /* Usage (Y), */ | | |
| 360 | 0x09, 0x32, /* Usage (Z), */ | | |
| 361 | 0x09, 0x35, /* Usage (Rz), */ | | |
| 362 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 363 | 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ | | |
| 364 | 0x75, 0x08, /* Report Size (8), */ | | |
| 365 | 0x95, 0x04, /* Report Count (4), */ | | |
| 366 | 0x81, 0x02, /* Input (Variable), */ | | |
| 367 | 0x09, 0x39, /* Usage (Hat Switch), */ | | |
| 368 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 369 | 0x25, 0x07, /* Logical Maximum (7), */ | | |
| 370 | 0x35, 0x00, /* Physical Minimum (0), */ | | |
| 371 | 0x46, 0x3B, 0x01, /* Physical Maximum (315), */ | | |
| 372 | 0x65, 0x14, /* Unit (Degrees), */ | | |
| 373 | 0x75, 0x04, /* Report Size (4), */ | | |
| 374 | 0x95, 0x01, /* Report Count (1), */ | | |
| 375 | 0x81, 0x42, /* Input (Variable, Null State), */ | | |
| 376 | 0x65, 0x00, /* Unit, */ | | |
| 377 | 0x05, 0x09, /* Usage Page (Button), */ | | |
| 378 | 0x19, 0x01, /* Usage Minimum (01h), */ | | |
| 379 | 0x29, 0x0D, /* Usage Maximum (0Dh), */ | | |
| 380 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 381 | 0x25, 0x01, /* Logical Maximum (1), */ | | |
| 382 | 0x75, 0x01, /* Report Size (1), */ | | |
| 383 | 0x95, 0x0E, /* Report Count (14), */ | | |
| 384 | 0x81, 0x02, /* Input (Variable), */ | | |
| 385 | 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ | | |
| 386 | 0x09, 0x20, /* Usage (20h), */ | | |
| 387 | 0x75, 0x06, /* Report Size (6), */ | | |
| 388 | 0x95, 0x01, /* Report Count (1), */ | | |
| 389 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 390 | 0x25, 0x3F, /* Logical Maximum (63), */ | | |
| 391 | 0x81, 0x02, /* Input (Variable), */ | | |
| 392 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 393 | 0x09, 0x33, /* Usage (Rx), */ | | |
| 394 | 0x09, 0x34, /* Usage (Ry), */ | | |
| 395 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 396 | 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ | | |
| 397 | 0x75, 0x08, /* Report Size (8), */ | | |
| 398 | 0x95, 0x02, /* Report Count (2), */ | | |
| 399 | 0x81, 0x02, /* Input (Variable), */ | | |
| 400 | 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ | | |
| 401 | 0x09, 0x21, /* Usage (21h), */ | | |
| 402 | 0x95, 0x03, /* Report Count (3), */ | | |
| 403 | 0x81, 0x02, /* Input (Variable), */ | | |
| 404 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 405 | 0x19, 0x40, /* Usage Minimum (40h), */ | | |
| 406 | 0x29, 0x42, /* Usage Maximum (42h), */ | | |
| 407 | 0x16, 0x00, 0x80, /* Logical Minimum (-32768), */ | | |
| 408 | 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */ | | |
| 409 | 0x75, 0x10, /* Report Size (16), */ | | |
| 410 | 0x95, 0x03, /* Report Count (3), */ | | |
| 411 | 0x81, 0x02, /* Input (Variable), */ | | |
| 412 | 0x19, 0x43, /* Usage Minimum (43h), */ | | |
| 413 | 0x29, 0x45, /* Usage Maximum (45h), */ | | |
| 414 | 0x16, 0x00, 0x80, /* Logical Minimum (-32768), */ | | |
| 415 | 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */ | | |
| 416 | 0x95, 0x03, /* Report Count (3), */ | | |
| 417 | 0x81, 0x02, /* Input (Variable), */ | | |
| 418 | 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ | | |
| 419 | 0x09, 0x21, /* Usage (21h), */ | | |
| 420 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 421 | 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ | | |
| 422 | 0x75, 0x08, /* Report Size (8), */ | | |
| 423 | 0x95, 0x27, /* Report Count (39), */ | | |
| 424 | 0x81, 0x02, /* Input (Variable), */ | | |
| 425 | 0x85, 0x05, /* Report ID (5), */ | | |
| 426 | 0x09, 0x22, /* Usage (22h), */ | | |
| 427 | 0x95, 0x1F, /* Report Count (31), */ | | |
| 428 | 0x91, 0x02, /* Output (Variable), */ | | |
| 429 | 0x85, 0x04, /* Report ID (4), */ | | |
| 430 | 0x09, 0x23, /* Usage (23h), */ | | |
| 431 | 0x95, 0x24, /* Report Count (36), */ | | |
| 432 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 433 | 0x85, 0x02, /* Report ID (2), */ | | |
| 434 | 0x09, 0x24, /* Usage (24h), */ | | |
| 435 | 0x95, 0x24, /* Report Count (36), */ | | |
| 436 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 437 | 0x85, 0x08, /* Report ID (8), */ | | |
| 438 | 0x09, 0x25, /* Usage (25h), */ | | |
| 439 | 0x95, 0x03, /* Report Count (3), */ | | |
| 440 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 441 | 0x85, 0x10, /* Report ID (16), */ | | |
| 442 | 0x09, 0x26, /* Usage (26h), */ | | |
| 443 | 0x95, 0x04, /* Report Count (4), */ | | |
| 444 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 445 | 0x85, 0x11, /* Report ID (17), */ | | |
| 446 | 0x09, 0x27, /* Usage (27h), */ | | |
| 447 | 0x95, 0x02, /* Report Count (2), */ | | |
| 448 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 449 | 0x85, 0x12, /* Report ID (18), */ | | |
| 450 | 0x06, 0x02, 0xFF, /* Usage Page (FF02h), */ | | |
| 451 | 0x09, 0x21, /* Usage (21h), */ | | |
| 452 | 0x95, 0x0F, /* Report Count (15), */ | | |
| 453 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 454 | 0x85, 0x13, /* Report ID (19), */ | | |
| 455 | 0x09, 0x22, /* Usage (22h), */ | | |
| 456 | 0x95, 0x16, /* Report Count (22), */ | | |
| 457 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 458 | 0x85, 0x14, /* Report ID (20), */ | | |
| 459 | 0x06, 0x05, 0xFF, /* Usage Page (FF05h), */ | | |
| 460 | 0x09, 0x20, /* Usage (20h), */ | | |
| 461 | 0x95, 0x10, /* Report Count (16), */ | | |
| 462 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 463 | 0x85, 0x15, /* Report ID (21), */ | | |
| 464 | 0x09, 0x21, /* Usage (21h), */ | | |
| 465 | 0x95, 0x2C, /* Report Count (44), */ | | |
| 466 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 467 | 0x06, 0x80, 0xFF, /* Usage Page (FF80h), */ | | |
| 468 | 0x85, 0x80, /* Report ID (128), */ | | |
| 469 | 0x09, 0x20, /* Usage (20h), */ | | |
| 470 | 0x95, 0x06, /* Report Count (6), */ | | |
| 471 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 472 | 0x85, 0x81, /* Report ID (129), */ | | |
| 473 | 0x09, 0x21, /* Usage (21h), */ | | |
| 474 | 0x95, 0x06, /* Report Count (6), */ | | |
| 475 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 476 | 0x85, 0x82, /* Report ID (130), */ | | |
| 477 | 0x09, 0x22, /* Usage (22h), */ | | |
| 478 | 0x95, 0x05, /* Report Count (5), */ | | |
| 479 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 480 | 0x85, 0x83, /* Report ID (131), */ | | |
| 481 | 0x09, 0x23, /* Usage (23h), */ | | |
| 482 | 0x95, 0x01, /* Report Count (1), */ | | |
| 483 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 484 | 0x85, 0x84, /* Report ID (132), */ | | |
| 485 | 0x09, 0x24, /* Usage (24h), */ | | |
| 486 | 0x95, 0x04, /* Report Count (4), */ | | |
| 487 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 488 | 0x85, 0x85, /* Report ID (133), */ | | |
| 489 | 0x09, 0x25, /* Usage (25h), */ | | |
| 490 | 0x95, 0x06, /* Report Count (6), */ | | |
| 491 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 492 | 0x85, 0x86, /* Report ID (134), */ | | |
| 493 | 0x09, 0x26, /* Usage (26h), */ | | |
| 494 | 0x95, 0x06, /* Report Count (6), */ | | |
| 495 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 496 | 0x85, 0x87, /* Report ID (135), */ | | |
| 497 | 0x09, 0x27, /* Usage (27h), */ | | |
| 498 | 0x95, 0x23, /* Report Count (35), */ | | |
| 499 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 500 | 0x85, 0x88, /* Report ID (136), */ | | |
| 501 | 0x09, 0x28, /* Usage (28h), */ | | |
| 502 | 0x95, 0x22, /* Report Count (34), */ | | |
| 503 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 504 | 0x85, 0x89, /* Report ID (137), */ | | |
| 505 | 0x09, 0x29, /* Usage (29h), */ | | |
| 506 | 0x95, 0x02, /* Report Count (2), */ | | |
| 507 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 508 | 0x85, 0x90, /* Report ID (144), */ | | |
| 509 | 0x09, 0x30, /* Usage (30h), */ | | |
| 510 | 0x95, 0x05, /* Report Count (5), */ | | |
| 511 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 512 | 0x85, 0x91, /* Report ID (145), */ | | |
| 513 | 0x09, 0x31, /* Usage (31h), */ | | |
| 514 | 0x95, 0x03, /* Report Count (3), */ | | |
| 515 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 516 | 0x85, 0x92, /* Report ID (146), */ | | |
| 517 | 0x09, 0x32, /* Usage (32h), */ | | |
| 518 | 0x95, 0x03, /* Report Count (3), */ | | |
| 519 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 520 | 0x85, 0x93, /* Report ID (147), */ | | |
| 521 | 0x09, 0x33, /* Usage (33h), */ | | |
| 522 | 0x95, 0x0C, /* Report Count (12), */ | | |
| 523 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 524 | 0x85, 0xA0, /* Report ID (160), */ | | |
| 525 | 0x09, 0x40, /* Usage (40h), */ | | |
| 526 | 0x95, 0x06, /* Report Count (6), */ | | |
| 527 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 528 | 0x85, 0xA1, /* Report ID (161), */ | | |
| 529 | 0x09, 0x41, /* Usage (41h), */ | | |
| 530 | 0x95, 0x01, /* Report Count (1), */ | | |
| 531 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 532 | 0x85, 0xA2, /* Report ID (162), */ | | |
| 533 | 0x09, 0x42, /* Usage (42h), */ | | |
| 534 | 0x95, 0x01, /* Report Count (1), */ | | |
| 535 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 536 | 0x85, 0xA3, /* Report ID (163), */ | | |
| 537 | 0x09, 0x43, /* Usage (43h), */ | | |
| 538 | 0x95, 0x30, /* Report Count (48), */ | | |
| 539 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 540 | 0x85, 0xA4, /* Report ID (164), */ | | |
| 541 | 0x09, 0x44, /* Usage (44h), */ | | |
| 542 | 0x95, 0x0D, /* Report Count (13), */ | | |
| 543 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 544 | 0x85, 0xA5, /* Report ID (165), */ | | |
| 545 | 0x09, 0x45, /* Usage (45h), */ | | |
| 546 | 0x95, 0x15, /* Report Count (21), */ | | |
| 547 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 548 | 0x85, 0xA6, /* Report ID (166), */ | | |
| 549 | 0x09, 0x46, /* Usage (46h), */ | | |
| 550 | 0x95, 0x15, /* Report Count (21), */ | | |
| 551 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 552 | 0x85, 0xF0, /* Report ID (240), */ | | |
| 553 | 0x09, 0x47, /* Usage (47h), */ | | |
| 554 | 0x95, 0x3F, /* Report Count (63), */ | | |
| 555 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 556 | 0x85, 0xF1, /* Report ID (241), */ | | |
| 557 | 0x09, 0x48, /* Usage (48h), */ | | |
| 558 | 0x95, 0x3F, /* Report Count (63), */ | | |
| 559 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 560 | 0x85, 0xF2, /* Report ID (242), */ | | |
| 561 | 0x09, 0x49, /* Usage (49h), */ | | |
| 562 | 0x95, 0x0F, /* Report Count (15), */ | | |
| 563 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 564 | 0x85, 0xA7, /* Report ID (167), */ | | |
| 565 | 0x09, 0x4A, /* Usage (4Ah), */ | | |
| 566 | 0x95, 0x01, /* Report Count (1), */ | | |
| 567 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 568 | 0x85, 0xA8, /* Report ID (168), */ | | |
| 569 | 0x09, 0x4B, /* Usage (4Bh), */ | | |
| 570 | 0x95, 0x01, /* Report Count (1), */ | | |
| 571 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 572 | 0x85, 0xA9, /* Report ID (169), */ | | |
| 573 | 0x09, 0x4C, /* Usage (4Ch), */ | | |
| 574 | 0x95, 0x08, /* Report Count (8), */ | | |
| 575 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 576 | 0x85, 0xAA, /* Report ID (170), */ | | |
| 577 | 0x09, 0x4E, /* Usage (4Eh), */ | | |
| 578 | 0x95, 0x01, /* Report Count (1), */ | | |
| 579 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 580 | 0x85, 0xAB, /* Report ID (171), */ | | |
| 581 | 0x09, 0x4F, /* Usage (4Fh), */ | | |
| 582 | 0x95, 0x39, /* Report Count (57), */ | | |
| 583 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 584 | 0x85, 0xAC, /* Report ID (172), */ | | |
| 585 | 0x09, 0x50, /* Usage (50h), */ | | |
| 586 | 0x95, 0x39, /* Report Count (57), */ | | |
| 587 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 588 | 0x85, 0xAD, /* Report ID (173), */ | | |
| 589 | 0x09, 0x51, /* Usage (51h), */ | | |
| 590 | 0x95, 0x0B, /* Report Count (11), */ | | |
| 591 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 592 | 0x85, 0xAE, /* Report ID (174), */ | | |
| 593 | 0x09, 0x52, /* Usage (52h), */ | | |
| 594 | 0x95, 0x01, /* Report Count (1), */ | | |
| 595 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 596 | 0x85, 0xAF, /* Report ID (175), */ | | |
| 597 | 0x09, 0x53, /* Usage (53h), */ | | |
| 598 | 0x95, 0x02, /* Report Count (2), */ | | |
| 599 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 600 | 0x85, 0xB0, /* Report ID (176), */ | | |
| 601 | 0x09, 0x54, /* Usage (54h), */ | | |
| 602 | 0x95, 0x3F, /* Report Count (63), */ | | |
| 603 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 604 | 0xC0 /* End Collection */ | | |
| 605 | }; | | |
| 606 | | | |
| 607 | /* | | |
| 608 | * The default behavior of the Dualshock 4 is to send reports using report | | |
| 609 | * type 1 when running over Bluetooth. However, when feature report 2 is | | |
| 610 | * requested during the controller initialization it starts sending input | | |
| 611 | * reports in report 17. Since report 17 is undefined in the default HID | | |
| 612 | * descriptor the button and axis definitions must be moved to report 17 or | | |
| 613 | * the HID layer won't process the received input. | | |
| 614 | */ | | |
| 615 | static u8 dualshock4_bt_rdesc[] = { | | |
| 616 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 617 | 0x09, 0x05, /* Usage (Gamepad), */ | | |
| 618 | 0xA1, 0x01, /* Collection (Application), */ | | |
| 619 | 0x85, 0x01, /* Report ID (1), */ | | |
| 620 | 0x75, 0x08, /* Report Size (8), */ | | |
| 621 | 0x95, 0x0A, /* Report Count (9), */ | | |
| 622 | 0x81, 0x02, /* Input (Variable), */ | | |
| 623 | 0x06, 0x04, 0xFF, /* Usage Page (FF04h), */ | | |
| 624 | 0x85, 0x02, /* Report ID (2), */ | | |
| 625 | 0x09, 0x24, /* Usage (24h), */ | | |
| 626 | 0x95, 0x24, /* Report Count (36), */ | | |
| 627 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 628 | 0x85, 0xA3, /* Report ID (163), */ | | |
| 629 | 0x09, 0x25, /* Usage (25h), */ | | |
| 630 | 0x95, 0x30, /* Report Count (48), */ | | |
| 631 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 632 | 0x85, 0x05, /* Report ID (5), */ | | |
| 633 | 0x09, 0x26, /* Usage (26h), */ | | |
| 634 | 0x95, 0x28, /* Report Count (40), */ | | |
| 635 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 636 | 0x85, 0x06, /* Report ID (6), */ | | |
| 637 | 0x09, 0x27, /* Usage (27h), */ | | |
| 638 | 0x95, 0x34, /* Report Count (52), */ | | |
| 639 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 640 | 0x85, 0x07, /* Report ID (7), */ | | |
| 641 | 0x09, 0x28, /* Usage (28h), */ | | |
| 642 | 0x95, 0x30, /* Report Count (48), */ | | |
| 643 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 644 | 0x85, 0x08, /* Report ID (8), */ | | |
| 645 | 0x09, 0x29, /* Usage (29h), */ | | |
| 646 | 0x95, 0x2F, /* Report Count (47), */ | | |
| 647 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 648 | 0x06, 0x03, 0xFF, /* Usage Page (FF03h), */ | | |
| 649 | 0x85, 0x03, /* Report ID (3), */ | | |
| 650 | 0x09, 0x21, /* Usage (21h), */ | | |
| 651 | 0x95, 0x26, /* Report Count (38), */ | | |
| 652 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 653 | 0x85, 0x04, /* Report ID (4), */ | | |
| 654 | 0x09, 0x22, /* Usage (22h), */ | | |
| 655 | 0x95, 0x2E, /* Report Count (46), */ | | |
| 656 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 657 | 0x85, 0xF0, /* Report ID (240), */ | | |
| 658 | 0x09, 0x47, /* Usage (47h), */ | | |
| 659 | 0x95, 0x3F, /* Report Count (63), */ | | |
| 660 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 661 | 0x85, 0xF1, /* Report ID (241), */ | | |
| 662 | 0x09, 0x48, /* Usage (48h), */ | | |
| 663 | 0x95, 0x3F, /* Report Count (63), */ | | |
| 664 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 665 | 0x85, 0xF2, /* Report ID (242), */ | | |
| 666 | 0x09, 0x49, /* Usage (49h), */ | | |
| 667 | 0x95, 0x0F, /* Report Count (15), */ | | |
| 668 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 669 | 0x85, 0x11, /* Report ID (17), */ | | |
| 670 | 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ | | |
| 671 | 0x09, 0x20, /* Usage (20h), */ | | |
| 672 | 0x95, 0x02, /* Report Count (2), */ | | |
| 673 | 0x81, 0x02, /* Input (Variable), */ | | |
| 674 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 675 | 0x09, 0x30, /* Usage (X), */ | | |
| 676 | 0x09, 0x31, /* Usage (Y), */ | | |
| 677 | 0x09, 0x32, /* Usage (Z), */ | | |
| 678 | 0x09, 0x35, /* Usage (Rz), */ | | |
| 679 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 680 | 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ | | |
| 681 | 0x75, 0x08, /* Report Size (8), */ | | |
| 682 | 0x95, 0x04, /* Report Count (4), */ | | |
| 683 | 0x81, 0x02, /* Input (Variable), */ | | |
| 684 | 0x09, 0x39, /* Usage (Hat Switch), */ | | |
| 685 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 686 | 0x25, 0x07, /* Logical Maximum (7), */ | | |
| 687 | 0x75, 0x04, /* Report Size (4), */ | | |
| 688 | 0x95, 0x01, /* Report Count (1), */ | | |
| 689 | 0x81, 0x42, /* Input (Variable, Null State), */ | | |
| 690 | 0x05, 0x09, /* Usage Page (Button), */ | | |
| 691 | 0x19, 0x01, /* Usage Minimum (01h), */ | | |
| 692 | 0x29, 0x0D, /* Usage Maximum (0Dh), */ | | |
| 693 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 694 | 0x25, 0x01, /* Logical Maximum (1), */ | | |
| 695 | 0x75, 0x01, /* Report Size (1), */ | | |
| 696 | 0x95, 0x0E, /* Report Count (14), */ | | |
| 697 | 0x81, 0x02, /* Input (Variable), */ | | |
| 698 | 0x75, 0x06, /* Report Size (6), */ | | |
| 699 | 0x95, 0x01, /* Report Count (1), */ | | |
| 700 | 0x81, 0x01, /* Input (Constant), */ | | |
| 701 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 702 | 0x09, 0x33, /* Usage (Rx), */ | | |
| 703 | 0x09, 0x34, /* Usage (Ry), */ | | |
| 704 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 705 | 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ | | |
| 706 | 0x75, 0x08, /* Report Size (8), */ | | |
| 707 | 0x95, 0x02, /* Report Count (2), */ | | |
| 708 | 0x81, 0x02, /* Input (Variable), */ | | |
| 709 | 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ | | |
| 710 | 0x09, 0x20, /* Usage (20h), */ | | |
| 711 | 0x95, 0x03, /* Report Count (3), */ | | |
| 712 | 0x81, 0x02, /* Input (Variable), */ | | |
| 713 | 0x05, 0x01, /* Usage Page (Desktop), */ | | |
| 714 | 0x19, 0x40, /* Usage Minimum (40h), */ | | |
| 715 | 0x29, 0x42, /* Usage Maximum (42h), */ | | |
| 716 | 0x16, 0x00, 0x80, /* Logical Minimum (-32768), */ | | |
| 717 | 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */ | | |
| 718 | 0x75, 0x10, /* Report Size (16), */ | | |
| 719 | 0x95, 0x03, /* Report Count (3), */ | | |
| 720 | 0x81, 0x02, /* Input (Variable), */ | | |
| 721 | 0x19, 0x43, /* Usage Minimum (43h), */ | | |
| 722 | 0x29, 0x45, /* Usage Maximum (45h), */ | | |
| 723 | 0x16, 0x00, 0x80, /* Logical Minimum (-32768), */ | | |
| 724 | 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */ | | |
| 725 | 0x95, 0x03, /* Report Count (3), */ | | |
| 726 | 0x81, 0x02, /* Input (Variable), */ | | |
| 727 | 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ | | |
| 728 | 0x09, 0x20, /* Usage (20h), */ | | |
| 729 | 0x15, 0x00, /* Logical Minimum (0), */ | | |
| 730 | 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ | | |
| 731 | 0x75, 0x08, /* Report Size (8), */ | | |
| 732 | 0x95, 0x31, /* Report Count (51), */ | | |
| 733 | 0x81, 0x02, /* Input (Variable), */ | | |
| 734 | 0x09, 0x21, /* Usage (21h), */ | | |
| 735 | 0x75, 0x08, /* Report Size (8), */ | | |
| 736 | 0x95, 0x4D, /* Report Count (77), */ | | |
| 737 | 0x91, 0x02, /* Output (Variable), */ | | |
| 738 | 0x85, 0x12, /* Report ID (18), */ | | |
| 739 | 0x09, 0x22, /* Usage (22h), */ | | |
| 740 | 0x95, 0x8D, /* Report Count (141), */ | | |
| 741 | 0x81, 0x02, /* Input (Variable), */ | | |
| 742 | 0x09, 0x23, /* Usage (23h), */ | | |
| 743 | 0x91, 0x02, /* Output (Variable), */ | | |
| 744 | 0x85, 0x13, /* Report ID (19), */ | | |
| 745 | 0x09, 0x24, /* Usage (24h), */ | | |
| 746 | 0x95, 0xCD, /* Report Count (205), */ | | |
| 747 | 0x81, 0x02, /* Input (Variable), */ | | |
| 748 | 0x09, 0x25, /* Usage (25h), */ | | |
| 749 | 0x91, 0x02, /* Output (Variable), */ | | |
| 750 | 0x85, 0x14, /* Report ID (20), */ | | |
| 751 | 0x09, 0x26, /* Usage (26h), */ | | |
| 752 | 0x96, 0x0D, 0x01, /* Report Count (269), */ | | |
| 753 | 0x81, 0x02, /* Input (Variable), */ | | |
| 754 | 0x09, 0x27, /* Usage (27h), */ | | |
| 755 | 0x91, 0x02, /* Output (Variable), */ | | |
| 756 | 0x85, 0x15, /* Report ID (21), */ | | |
| 757 | 0x09, 0x28, /* Usage (28h), */ | | |
| 758 | 0x96, 0x4D, 0x01, /* Report Count (333), */ | | |
| 759 | 0x81, 0x02, /* Input (Variable), */ | | |
| 760 | 0x09, 0x29, /* Usage (29h), */ | | |
| 761 | 0x91, 0x02, /* Output (Variable), */ | | |
| 762 | 0x85, 0x16, /* Report ID (22), */ | | |
| 763 | 0x09, 0x2A, /* Usage (2Ah), */ | | |
| 764 | 0x96, 0x8D, 0x01, /* Report Count (397), */ | | |
| 765 | 0x81, 0x02, /* Input (Variable), */ | | |
| 766 | 0x09, 0x2B, /* Usage (2Bh), */ | | |
| 767 | 0x91, 0x02, /* Output (Variable), */ | | |
| 768 | 0x85, 0x17, /* Report ID (23), */ | | |
| 769 | 0x09, 0x2C, /* Usage (2Ch), */ | | |
| 770 | 0x96, 0xCD, 0x01, /* Report Count (461), */ | | |
| 771 | 0x81, 0x02, /* Input (Variable), */ | | |
| 772 | 0x09, 0x2D, /* Usage (2Dh), */ | | |
| 773 | 0x91, 0x02, /* Output (Variable), */ | | |
| 774 | 0x85, 0x18, /* Report ID (24), */ | | |
| 775 | 0x09, 0x2E, /* Usage (2Eh), */ | | |
| 776 | 0x96, 0x0D, 0x02, /* Report Count (525), */ | | |
| 777 | 0x81, 0x02, /* Input (Variable), */ | | |
| 778 | 0x09, 0x2F, /* Usage (2Fh), */ | | |
| 779 | 0x91, 0x02, /* Output (Variable), */ | | |
| 780 | 0x85, 0x19, /* Report ID (25), */ | | |
| 781 | 0x09, 0x30, /* Usage (30h), */ | | |
| 782 | 0x96, 0x22, 0x02, /* Report Count (546), */ | | |
| 783 | 0x81, 0x02, /* Input (Variable), */ | | |
| 784 | 0x09, 0x31, /* Usage (31h), */ | | |
| 785 | 0x91, 0x02, /* Output (Variable), */ | | |
| 786 | 0x06, 0x80, 0xFF, /* Usage Page (FF80h), */ | | |
| 787 | 0x85, 0x82, /* Report ID (130), */ | | |
| 788 | 0x09, 0x22, /* Usage (22h), */ | | |
| 789 | 0x95, 0x3F, /* Report Count (63), */ | | |
| 790 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 791 | 0x85, 0x83, /* Report ID (131), */ | | |
| 792 | 0x09, 0x23, /* Usage (23h), */ | | |
| 793 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 794 | 0x85, 0x84, /* Report ID (132), */ | | |
| 795 | 0x09, 0x24, /* Usage (24h), */ | | |
| 796 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 797 | 0x85, 0x90, /* Report ID (144), */ | | |
| 798 | 0x09, 0x30, /* Usage (30h), */ | | |
| 799 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 800 | 0x85, 0x91, /* Report ID (145), */ | | |
| 801 | 0x09, 0x31, /* Usage (31h), */ | | |
| 802 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 803 | 0x85, 0x92, /* Report ID (146), */ | | |
| 804 | 0x09, 0x32, /* Usage (32h), */ | | |
| 805 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 806 | 0x85, 0x93, /* Report ID (147), */ | | |
| 807 | 0x09, 0x33, /* Usage (33h), */ | | |
| 808 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 809 | 0x85, 0xA0, /* Report ID (160), */ | | |
| 810 | 0x09, 0x40, /* Usage (40h), */ | | |
| 811 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 812 | 0x85, 0xA4, /* Report ID (164), */ | | |
| 813 | 0x09, 0x44, /* Usage (44h), */ | | |
| 814 | 0xB1, 0x02, /* Feature (Variable), */ | | |
| 815 | 0xC0 /* End Collection */ | | |
| 816 | }; | | |
| 817 | | | |
| 818 | static u8 ps3remote_rdesc[] = { | 176 | static u8 ps3remote_rdesc[] = { |
| 819 | 0x05, 0x01, /* GUsagePage Generic Desktop */ | 177 | 0x05, 0x01, /* GUsagePage Generic Desktop */ |
| 820 | 0x09, 0x05, /* LUsage 0x05 [Game Pad] */ | 178 | 0x09, 0x05, /* LUsage 0x05 [Game Pad] */ |
| @@ -977,6 +335,67 @@ static const unsigned int buzz_keymap[] = { · 156 unmodified lines |
| 977 | [20] = BTN_TRIGGER_HAPPY20, | 335 | [20] = BTN_TRIGGER_HAPPY20, |
| 978 | }; | 336 | }; |
| 979 | | 337 | |
| | 338 | /* The Navigation controller is a partial DS3 and uses the same HID report |
| | 339 | * and hence the same keymap indices, however not not all axes/buttons |
| | 340 | * are physically present. We use the same axis and button mapping as |
| | 341 | * the DS3, which uses the Linux gamepad spec. |
| | 342 | */ |
| | 343 | static const unsigned int navigation_absmap[] = { |
| | 344 | [0x30] = ABS_X, |
| | 345 | [0x31] = ABS_Y, |
| | 346 | [0x33] = ABS_Z, /* L2 */ |
| | 347 | }; |
| | 348 | |
| | 349 | /* Buttons not physically available on the device, but still available |
| | 350 | * in the reports are explicitly set to 0 for documentation purposes. |
| | 351 | */ |
| | 352 | static const unsigned int navigation_keymap[] = { |
| | 353 | [0x01] = 0, /* Select */ |
| | 354 | [0x02] = BTN_THUMBL, /* L3 */ |
| | 355 | [0x03] = 0, /* R3 */ |
| | 356 | [0x04] = 0, /* Start */ |
| | 357 | [0x05] = BTN_DPAD_UP, /* Up */ |
| | 358 | [0x06] = BTN_DPAD_RIGHT, /* Right */ |
| | 359 | [0x07] = BTN_DPAD_DOWN, /* Down */ |
| | 360 | [0x08] = BTN_DPAD_LEFT, /* Left */ |
| | 361 | [0x09] = BTN_TL2, /* L2 */ |
| | 362 | [0x0a] = 0, /* R2 */ |
| | 363 | [0x0b] = BTN_TL, /* L1 */ |
| | 364 | [0x0c] = 0, /* R1 */ |
| | 365 | [0x0d] = BTN_NORTH, /* Triangle */ |
| | 366 | [0x0e] = BTN_EAST, /* Circle */ |
| | 367 | [0x0f] = BTN_SOUTH, /* Cross */ |
| | 368 | [0x10] = BTN_WEST, /* Square */ |
| | 369 | [0x11] = BTN_MODE, /* PS */ |
| | 370 | }; |
| | 371 | |
| | 372 | static const unsigned int sixaxis_absmap[] = { |
| | 373 | [0x30] = ABS_X, |
| | 374 | [0x31] = ABS_Y, |
| | 375 | [0x32] = ABS_RX, /* right stick X */ |
| | 376 | [0x35] = ABS_RY, /* right stick Y */ |
| | 377 | }; |
| | 378 | |
| | 379 | static const unsigned int sixaxis_keymap[] = { |
| | 380 | [0x01] = BTN_SELECT, /* Select */ |
| | 381 | [0x02] = BTN_THUMBL, /* L3 */ |
| | 382 | [0x03] = BTN_THUMBR, /* R3 */ |
| | 383 | [0x04] = BTN_START, /* Start */ |
| | 384 | [0x05] = BTN_DPAD_UP, /* Up */ |
| | 385 | [0x06] = BTN_DPAD_RIGHT, /* Right */ |
| | 386 | [0x07] = BTN_DPAD_DOWN, /* Down */ |
| | 387 | [0x08] = BTN_DPAD_LEFT, /* Left */ |
| | 388 | [0x09] = BTN_TL2, /* L2 */ |
| | 389 | [0x0a] = BTN_TR2, /* R2 */ |
| | 390 | [0x0b] = BTN_TL, /* L1 */ |
| | 391 | [0x0c] = BTN_TR, /* R1 */ |
| | 392 | [0x0d] = BTN_NORTH, /* Triangle */ |
| | 393 | [0x0e] = BTN_EAST, /* Circle */ |
| | 394 | [0x0f] = BTN_SOUTH, /* Cross */ |
| | 395 | [0x10] = BTN_WEST, /* Square */ |
| | 396 | [0x11] = BTN_MODE, /* PS */ |
| | 397 | }; |
| | 398 | |
| 980 | static const unsigned int ds4_absmap[] = { | 399 | static const unsigned int ds4_absmap[] = { |
| 981 | [0x30] = ABS_X, | 400 | [0x30] = ABS_X, |
| 982 | [0x31] = ABS_Y, | 401 | [0x31] = ABS_Y, |
| @@ -1002,6 +421,10 @@ static const unsigned int ds4_keymap[] = { · 19 unmodified lines |
| 1002 | [0xd] = BTN_MODE, /* PS */ | 421 | [0xd] = BTN_MODE, /* PS */ |
| 1003 | }; | 422 | }; |
| 1004 | | 423 | |
| | 424 | static const struct {int x; int y; } ds4_hat_mapping[] = { |
| | 425 | {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, |
| | 426 | {0, 0} |
| | 427 | }; |
| 1005 | | 428 | |
| 1006 | static enum power_supply_property sony_battery_props[] = { | 429 | static enum power_supply_property sony_battery_props[] = { |
| 1007 | POWER_SUPPLY_PROP_PRESENT, | 430 | POWER_SUPPLY_PROP_PRESENT, |
| @@ -1048,6 +471,7 @@ struct motion_output_report_02 { · 40 unmodified lines |
| 1048 | }; | 471 | }; |
| 1049 | | 472 | |
| 1050 | #define DS4_FEATURE_REPORT_0x02_SIZE 37 | 473 | #define DS4_FEATURE_REPORT_0x02_SIZE 37 |
| | 474 | #define DS4_FEATURE_REPORT_0x05_SIZE 41 |
| 1051 | #define DS4_FEATURE_REPORT_0x81_SIZE 7 | 475 | #define DS4_FEATURE_REPORT_0x81_SIZE 7 |
| 1052 | #define DS4_INPUT_REPORT_0x11_SIZE 78 | 476 | #define DS4_INPUT_REPORT_0x11_SIZE 78 |
| 1053 | #define DS4_OUTPUT_REPORT_0x05_SIZE 32 | 477 | #define DS4_OUTPUT_REPORT_0x05_SIZE 32 |
| @@ -1059,23 +483,62 @@ struct motion_output_report_02 { · 5 unmodified lines |
| 1059 | /* Offsets relative to USB input report (0x1). Bluetooth (0x11) requires an | 483 | /* Offsets relative to USB input report (0x1). Bluetooth (0x11) requires an |
| 1060 | * additional +2. | 484 | * additional +2. |
| 1061 | */ | 485 | */ |
| | 486 | #define DS4_INPUT_REPORT_AXIS_OFFSET 1 |
| 1062 | #define DS4_INPUT_REPORT_BUTTON_OFFSET 5 | 487 | #define DS4_INPUT_REPORT_BUTTON_OFFSET 5 |
| | 488 | #define DS4_INPUT_REPORT_TIMESTAMP_OFFSET 10 |
| | 489 | #define DS4_INPUT_REPORT_GYRO_X_OFFSET 13 |
| 1063 | #define DS4_INPUT_REPORT_BATTERY_OFFSET 30 | 490 | #define DS4_INPUT_REPORT_BATTERY_OFFSET 30 |
| 1064 | #define DS4_INPUT_REPORT_TOUCHPAD_OFFSET 33 | 491 | #define DS4_INPUT_REPORT_TOUCHPAD_OFFSET 33 |
| 1065 | | 492 | |
| | 493 | #define SENSOR_SUFFIX " Motion Sensors" |
| 1066 | #define DS4_TOUCHPAD_SUFFIX " Touchpad" | 494 | #define DS4_TOUCHPAD_SUFFIX " Touchpad" |
| 1067 | | 495 | |
| | 496 | /* Default to 4ms poll interval, which is same as USB (not adjustable). */ |
| | 497 | #define DS4_BT_DEFAULT_POLL_INTERVAL_MS 4 |
| | 498 | #define DS4_BT_MAX_POLL_INTERVAL_MS 62 |
| | 499 | #define DS4_GYRO_RES_PER_DEG_S 1024 |
| | 500 | #define DS4_ACC_RES_PER_G 8192 |
| | 501 | |
| | 502 | #define SIXAXIS_INPUT_REPORT_ACC_X_OFFSET 41 |
| | 503 | #define SIXAXIS_ACC_RES_PER_G 113 |
| | 504 | |
| 1068 | static DEFINE_SPINLOCK(sony_dev_list_lock); | 505 | static DEFINE_SPINLOCK(sony_dev_list_lock); |
| 1069 | static LIST_HEAD(sony_device_list); | 506 | static LIST_HEAD(sony_device_list); |
| 1070 | static DEFINE_IDA(sony_device_id_allocator); | 507 | static DEFINE_IDA(sony_device_id_allocator); |
| 1071 | | 508 | |
| | 509 | /* Used for calibration of DS4 accelerometer and gyro. */ |
| | 510 | struct ds4_calibration_data { |
| | 511 | int abs_code; |
| | 512 | short bias; |
| | 513 | /* Calibration requires scaling against a sensitivity value, which is a |
| | 514 | * float. Store sensitivity as a fraction to limit floating point |
| | 515 | * calculations until final calibration. |
| | 516 | */ |
| | 517 | int sens_numer; |
| | 518 | int sens_denom; |
| | 519 | }; |
| | 520 | |
| | 521 | enum ds4_dongle_state { |
| | 522 | DONGLE_DISCONNECTED, |
| | 523 | DONGLE_CALIBRATING, |
| | 524 | DONGLE_CONNECTED, |
| | 525 | DONGLE_DISABLED |
| | 526 | }; |
| | 527 | |
| | 528 | enum sony_worker { |
| | 529 | SONY_WORKER_STATE, |
| | 530 | SONY_WORKER_HOTPLUG |
| | 531 | }; |
| | 532 | |
| 1072 | struct sony_sc { | 533 | struct sony_sc { |
| 1073 | spinlock_t lock; | 534 | spinlock_t lock; |
| 1074 | struct list_head list_node; | 535 | struct list_head list_node; |
| 1075 | struct hid_device *hdev; | 536 | struct hid_device *hdev; |
| 1076 | struct input_dev *touchpad; | 537 | struct input_dev *touchpad; |
| | 538 | struct input_dev *sensor_dev; |
| 1077 | struct led_classdev *leds[MAX_LEDS]; | 539 | struct led_classdev *leds[MAX_LEDS]; |
| 1078 | unsigned long quirks; | 540 | unsigned long quirks; |
| | 541 | struct work_struct hotplug_worker; |
| 1079 | struct work_struct state_worker; | 542 | struct work_struct state_worker; |
| 1080 | void (*send_output_report)(struct sony_sc *); | 543 | void (*send_output_report)(struct sony_sc *); |
| 1081 | struct power_supply *battery; | 544 | struct power_supply *battery; |
| @@ -1089,46 +552,87 @@ struct sony_sc { · 7 unmodified lines |
| 1089 | #endif | 552 | #endif |
| 1090 | | 553 | |
| 1091 | u8 mac_address[6]; | 554 | u8 mac_address[6]; |
| 1092 | u8 worker_initialized; | 555 | u8 hotplug_worker_initialized; |
| | 556 | u8 state_worker_initialized; |
| 1093 | u8 defer_initialization; | 557 | u8 defer_initialization; |
| 1094 | u8 cable_state; | 558 | u8 cable_state; |
| 1095 | u8 battery_charging; | 559 | u8 battery_charging; |
| 1096 | u8 battery_capacity; | 560 | u8 battery_capacity; |
| 1097 | u8 led_state[MAX_LEDS]; | 561 | u8 led_state[MAX_LEDS]; |
| 1098 | u8 resume_led_state[MAX_LEDS]; | | |
| 1099 | u8 led_delay_on[MAX_LEDS]; | 562 | u8 led_delay_on[MAX_LEDS]; |
| 1100 | u8 led_delay_off[MAX_LEDS]; | 563 | u8 led_delay_off[MAX_LEDS]; |
| 1101 | u8 led_count; | 564 | u8 led_count; |
| 1102 | bool ds4_dongle_connected; | 565 | |
| | 566 | bool timestamp_initialized; |
| | 567 | u16 prev_timestamp; |
| | 568 | unsigned int timestamp_us; |
| | 569 | |
| | 570 | u8 ds4_bt_poll_interval; |
| | 571 | enum ds4_dongle_state ds4_dongle_state; |
| | 572 | /* DS4 calibration data */ |
| | 573 | struct ds4_calibration_data ds4_calib_data[6]; |
| 1103 | }; | 574 | }; |
| 1104 | | 575 | |
| 1105 | static void sony_set_leds(struct sony_sc *sc); | 576 | static void sony_set_leds(struct sony_sc *sc); |
| 1106 | | 577 | |
| 1107 | static inline void sony_schedule_work(struct sony_sc *sc) | 578 | static inline void sony_schedule_work(struct sony_sc *sc, |
| | 579 | enum sony_worker which) |
| 1108 | { | 580 | { |
| 1109 | if (!sc->defer_initialization) | 581 | switch (which) { |
| 1110 | schedule_work(&sc->state_worker); | 582 | case SONY_WORKER_STATE: |
| | 583 | if (!sc->defer_initialization) |
| | 584 | schedule_work(&sc->state_worker); |
| | 585 | break; |
| | 586 | case SONY_WORKER_HOTPLUG: |
| | 587 | if (sc->hotplug_worker_initialized) |
| | 588 | schedule_work(&sc->hotplug_worker); |
| | 589 | break; |
| | 590 | } |
| 1111 | } | 591 | } |
| 1112 | | 592 | |
| 1113 | static u8 *sixaxis_fixup(struct hid_device *hdev, u8 *rdesc, | 593 | static ssize_t ds4_show_poll_interval(struct device *dev, |
| 1114 | unsigned int *rsize) | 594 | struct device_attribute |
| | 595 | *attr, char *buf) |
| 1115 | { | 596 | { |
| 1116 | *rsize = sizeof(sixaxis_rdesc); | 597 | struct hid_device *hdev = to_hid_device(dev); |
| 1117 | return sixaxis_rdesc; | 598 | struct sony_sc *sc = hid_get_drvdata(hdev); |
| | 599 | |
| | 600 | return snprintf(buf, PAGE_SIZE, "%i\n", sc->ds4_bt_poll_interval); |
| 1118 | } | 601 | } |
| 1119 | | 602 | |
| 1120 | static u8 *motion_fixup(struct hid_device *hdev, u8 *rdesc, | 603 | static ssize_t ds4_store_poll_interval(struct device *dev, |
| 1121 | unsigned int *rsize) | 604 | struct device_attribute *attr, |
| | 605 | const char *buf, size_t count) |
| 1122 | { | 606 | { |
| 1123 | *rsize = sizeof(motion_rdesc); | 607 | struct hid_device *hdev = to_hid_device(dev); |
| 1124 | return motion_rdesc; | 608 | struct sony_sc *sc = hid_get_drvdata(hdev); |
| | 609 | unsigned long flags; |
| | 610 | u8 interval; |
| | 611 | |
| | 612 | if (kstrtou8(buf, 0, &interval)) |
| | 613 | return -EINVAL; |
| | 614 | |
| | 615 | if (interval > DS4_BT_MAX_POLL_INTERVAL_MS) |
| | 616 | return -EINVAL; |
| | 617 | |
| | 618 | spin_lock_irqsave(&sc->lock, flags); |
| | 619 | sc->ds4_bt_poll_interval = interval; |
| | 620 | spin_unlock_irqrestore(&sc->lock, flags); |
| | 621 | |
| | 622 | sony_schedule_work(sc, SONY_WORKER_STATE); |
| | 623 | |
| | 624 | return count; |
| 1125 | } | 625 | } |
| 1126 | | 626 | |
| 1127 | static u8 *navigation_fixup(struct hid_device *hdev, u8 *rdesc, | 627 | static DEVICE_ATTR(bt_poll_interval, 0644, ds4_show_poll_interval, |
| | 628 | ds4_store_poll_interval); |
| | 629 | |
| | 630 | |
| | 631 | static u8 *motion_fixup(struct hid_device *hdev, u8 *rdesc, |
| 1128 | unsigned int *rsize) | 632 | unsigned int *rsize) |
| 1129 | { | 633 | { |
| 1130 | *rsize = sizeof(navigation_rdesc); | 634 | *rsize = sizeof(motion_rdesc); |
| 1131 | return navigation_rdesc; | 635 | return motion_rdesc; |
| 1132 | } | 636 | } |
| 1133 | | 637 | |
| 1134 | static u8 *ps3remote_fixup(struct hid_device *hdev, u8 *rdesc, | 638 | static u8 *ps3remote_fixup(struct hid_device *hdev, u8 *rdesc, |
| @@ -1172,6 +676,102 @@ static int ps3remote_mapping(struct hid_device *hdev, struct hid_input *hi, · 37 unmodified lines |
| 1172 | return 1; | 676 | return 1; |
| 1173 | } | 677 | } |
| 1174 | | 678 | |
| | 679 | static int navigation_mapping(struct hid_device *hdev, struct hid_input *hi, |
| | 680 | struct hid_field *field, struct hid_usage *usage, |
| | 681 | unsigned long **bit, int *max) |
| | 682 | { |
| | 683 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { |
| | 684 | unsigned int key = usage->hid & HID_USAGE; |
| | 685 | |
| | 686 | if (key >= ARRAY_SIZE(sixaxis_keymap)) |
| | 687 | return -1; |
| | 688 | |
| | 689 | key = navigation_keymap[key]; |
| | 690 | if (!key) |
| | 691 | return -1; |
| | 692 | |
| | 693 | hid_map_usage_clear(hi, usage, bit, max, EV_KEY, key); |
| | 694 | return 1; |
| | 695 | } else if (usage->hid == HID_GD_POINTER) { |
| | 696 | /* See comment in sixaxis_mapping, basically the L2 (and R2) |
| | 697 | * triggers are reported through GD Pointer. |
| | 698 | * In addition we ignore any analog button 'axes' and only |
| | 699 | * support digital buttons. |
| | 700 | */ |
| | 701 | switch (usage->usage_index) { |
| | 702 | case 8: /* L2 */ |
| | 703 | usage->hid = HID_GD_Z; |
| | 704 | break; |
| | 705 | default: |
| | 706 | return -1; |
| | 707 | } |
| | 708 | |
| | 709 | hid_map_usage_clear(hi, usage, bit, max, EV_ABS, usage->hid & 0xf); |
| | 710 | return 1; |
| | 711 | } else if ((usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK) { |
| | 712 | unsigned int abs = usage->hid & HID_USAGE; |
| | 713 | |
| | 714 | if (abs >= ARRAY_SIZE(navigation_absmap)) |
| | 715 | return -1; |
| | 716 | |
| | 717 | abs = navigation_absmap[abs]; |
| | 718 | |
| | 719 | hid_map_usage_clear(hi, usage, bit, max, EV_ABS, abs); |
| | 720 | return 1; |
| | 721 | } |
| | 722 | |
| | 723 | return -1; |
| | 724 | } |
| | 725 | |
| | 726 | |
| | 727 | static int sixaxis_mapping(struct hid_device *hdev, struct hid_input *hi, |
| | 728 | struct hid_field *field, struct hid_usage *usage, |
| | 729 | unsigned long **bit, int *max) |
| | 730 | { |
| | 731 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { |
| | 732 | unsigned int key = usage->hid & HID_USAGE; |
| | 733 | |
| | 734 | if (key >= ARRAY_SIZE(sixaxis_keymap)) |
| | 735 | return -1; |
| | 736 | |
| | 737 | key = sixaxis_keymap[key]; |
| | 738 | hid_map_usage_clear(hi, usage, bit, max, EV_KEY, key); |
| | 739 | return 1; |
| | 740 | } else if (usage->hid == HID_GD_POINTER) { |
| | 741 | /* The DS3 provides analog values for most buttons and even |
| | 742 | * for HAT axes through GD Pointer. L2 and R2 are reported |
| | 743 | * among these as well instead of as GD Z / RZ. Remap L2 |
| | 744 | * and R2 and ignore other analog 'button axes' as there is |
| | 745 | * no good way for reporting them. |
| | 746 | */ |
| | 747 | switch (usage->usage_index) { |
| | 748 | case 8: /* L2 */ |
| | 749 | usage->hid = HID_GD_Z; |
| | 750 | break; |
| | 751 | case 9: /* R2 */ |
| | 752 | usage->hid = HID_GD_RZ; |
| | 753 | break; |
| | 754 | default: |
| | 755 | return -1; |
| | 756 | } |
| | 757 | |
| | 758 | hid_map_usage_clear(hi, usage, bit, max, EV_ABS, usage->hid & 0xf); |
| | 759 | return 1; |
| | 760 | } else if ((usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK) { |
| | 761 | unsigned int abs = usage->hid & HID_USAGE; |
| | 762 | |
| | 763 | if (abs >= ARRAY_SIZE(sixaxis_absmap)) |
| | 764 | return -1; |
| | 765 | |
| | 766 | abs = sixaxis_absmap[abs]; |
| | 767 | |
| | 768 | hid_map_usage_clear(hi, usage, bit, max, EV_ABS, abs); |
| | 769 | return 1; |
| | 770 | } |
| | 771 | |
| | 772 | return -1; |
| | 773 | } |
| | 774 | |
| 1175 | static int ds4_mapping(struct hid_device *hdev, struct hid_input *hi, | 775 | static int ds4_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 1176 | struct hid_field *field, struct hid_usage *usage, | 776 | struct hid_field *field, struct hid_usage *usage, |
| 1177 | unsigned long **bit, int *max) | 777 | unsigned long **bit, int *max) |
| @@ -1227,30 +827,9 @@ static u8 *sony_report_fixup(struct hid_device *hdev, u8 *rdesc, · 49 unmodified lines |
| 1227 | rdesc[55] = 0x06; | 827 | rdesc[55] = 0x06; |
| 1228 | } | 828 | } |
| 1229 | | 829 | |
| 1230 | /* | | |
| 1231 | * The default Dualshock 4 USB descriptor doesn't assign | | |
| 1232 | * the gyroscope values to corresponding axes so we need a | | |
| 1233 | * modified one. | | |
| 1234 | */ | | |
| 1235 | if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) { | | |
| 1236 | hid_info(hdev, "Using modified Dualshock 4 report descriptor with gyroscope axes\n"); | | |
| 1237 | rdesc = dualshock4_usb_rdesc; | | |
| 1238 | *rsize = sizeof(dualshock4_usb_rdesc); | | |
| 1239 | } else if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) { | | |
| 1240 | hid_info(hdev, "Using modified Dualshock 4 Bluetooth report descriptor\n"); | | |
| 1241 | rdesc = dualshock4_bt_rdesc; | | |
| 1242 | *rsize = sizeof(dualshock4_bt_rdesc); | | |
| 1243 | } | | |
| 1244 | | | |
| 1245 | if (sc->quirks & SIXAXIS_CONTROLLER) | | |
| 1246 | return sixaxis_fixup(hdev, rdesc, rsize); | | |
| 1247 | | | |
| 1248 | if (sc->quirks & MOTION_CONTROLLER) | 830 | if (sc->quirks & MOTION_CONTROLLER) |
| 1249 | return motion_fixup(hdev, rdesc, rsize); | 831 | return motion_fixup(hdev, rdesc, rsize); |
| 1250 | | 832 | |
| 1251 | if (sc->quirks & NAVIGATION_CONTROLLER) | | |
| 1252 | return navigation_fixup(hdev, rdesc, rsize); | | |
| 1253 | | | |
| 1254 | if (sc->quirks & PS3REMOTE) | 833 | if (sc->quirks & PS3REMOTE) |
| 1255 | return ps3remote_fixup(hdev, rdesc, rsize); | 834 | return ps3remote_fixup(hdev, rdesc, rsize); |
| 1256 | | 835 | |
| @@ -1288,21 +867,131 @@ static void sixaxis_parse_report(struct sony_sc *sc, u8 *rd, int size) · 31 unmodified lines |
| 1288 | sc->battery_capacity = battery_capacity; | 867 | sc->battery_capacity = battery_capacity; |
| 1289 | sc->battery_charging = battery_charging; | 868 | sc->battery_charging = battery_charging; |
| 1290 | spin_unlock_irqrestore(&sc->lock, flags); | 869 | spin_unlock_irqrestore(&sc->lock, flags); |
| | 870 | |
| | 871 | if (sc->quirks & SIXAXIS_CONTROLLER) { |
| | 872 | int val; |
| | 873 | |
| | 874 | offset = SIXAXIS_INPUT_REPORT_ACC_X_OFFSET; |
| | 875 | val = ((rd[offset+1] << 8) | rd[offset]) - 511; |
| | 876 | input_report_abs(sc->sensor_dev, ABS_X, val); |
| | 877 | |
| | 878 | /* Y and Z are swapped and inversed */ |
| | 879 | val = 511 - ((rd[offset+5] << 8) | rd[offset+4]); |
| | 880 | input_report_abs(sc->sensor_dev, ABS_Y, val); |
| | 881 | |
| | 882 | val = 511 - ((rd[offset+3] << 8) | rd[offset+2]); |
| | 883 | input_report_abs(sc->sensor_dev, ABS_Z, val); |
| | 884 | |
| | 885 | input_sync(sc->sensor_dev); |
| | 886 | } |
| 1291 | } | 887 | } |
| 1292 | | 888 | |
| 1293 | static void dualshock4_parse_report(struct sony_sc *sc, u8 *rd, int size) | 889 | static void dualshock4_parse_report(struct sony_sc *sc, u8 *rd, int size) |
| 1294 | { | 890 | { |
| | 891 | struct hid_input *hidinput = list_entry(sc->hdev->inputs.next, |
| | 892 | struct hid_input, list); |
| | 893 | struct input_dev *input_dev = hidinput->input; |
| 1295 | unsigned long flags; | 894 | unsigned long flags; |
| 1296 | int n, m, offset, num_touch_data, max_touch_data; | 895 | int n, m, offset, num_touch_data, max_touch_data; |
| 1297 | u8 cable_state, battery_capacity, battery_charging; | 896 | u8 cable_state, battery_capacity, battery_charging; |
| | 897 | u16 timestamp; |
| 1298 | | 898 | |
| 1299 | /* When using Bluetooth the header is 2 bytes longer, so skip these. */ | 899 | /* When using Bluetooth the header is 2 bytes longer, so skip these. */ |
| 1300 | int data_offset = (sc->quirks & DUALSHOCK4_CONTROLLER_USB) ? 0 : 2; | 900 | int data_offset = (sc->quirks & DUALSHOCK4_CONTROLLER_BT) ? 2 : 0; |
| 1301 | | 901 | |
| 1302 | /* Second bit of third button byte is for the touchpad button. */ | 902 | /* Second bit of third button byte is for the touchpad button. */ |
| 1303 | offset = data_offset + DS4_INPUT_REPORT_BUTTON_OFFSET; | 903 | offset = data_offset + DS4_INPUT_REPORT_BUTTON_OFFSET; |
| 1304 | input_report_key(sc->touchpad, BTN_LEFT, rd[offset+2] & 0x2); | 904 | input_report_key(sc->touchpad, BTN_LEFT, rd[offset+2] & 0x2); |
| 1305 | | 905 | |
| | 906 | /* |
| | 907 | * The default behavior of the Dualshock 4 is to send reports using |
| | 908 | * report type 1 when running over Bluetooth. However, when feature |
| | 909 | * report 2 is requested during the controller initialization it starts |
| | 910 | * sending input reports in report 17. Since report 17 is undefined |
| | 911 | * in the default HID descriptor, the HID layer won't generate events. |
| | 912 | * While it is possible (and this was done before) to fixup the HID |
| | 913 | * descriptor to add this mapping, it was better to do this manually. |
| | 914 | * The reason is there were various pieces software both open and closed |
| | 915 | * source, relying on the descriptors to be the same across various |
| | 916 | * operating systems. If the descriptors wouldn't match some |
| | 917 | * applications e.g. games on Wine would not be able to function due |
| | 918 | * to different descriptors, which such applications are not parsing. |
| | 919 | */ |
| | 920 | if (rd[0] == 17) { |
| | 921 | int value; |
| | 922 | |
| | 923 | offset = data_offset + DS4_INPUT_REPORT_AXIS_OFFSET; |
| | 924 | input_report_abs(input_dev, ABS_X, rd[offset]); |
| | 925 | input_report_abs(input_dev, ABS_Y, rd[offset+1]); |
| | 926 | input_report_abs(input_dev, ABS_RX, rd[offset+2]); |
| | 927 | input_report_abs(input_dev, ABS_RY, rd[offset+3]); |
| | 928 | |
| | 929 | value = rd[offset+4] & 0xf; |
| | 930 | if (value > 7) |
| | 931 | value = 8; /* Center 0, 0 */ |
| | 932 | input_report_abs(input_dev, ABS_HAT0X, ds4_hat_mapping[value].x); |
| | 933 | input_report_abs(input_dev, ABS_HAT0Y, ds4_hat_mapping[value].y); |
| | 934 | |
| | 935 | input_report_key(input_dev, BTN_WEST, rd[offset+4] & 0x10); |
| | 936 | input_report_key(input_dev, BTN_SOUTH, rd[offset+4] & 0x20); |
| | 937 | input_report_key(input_dev, BTN_EAST, rd[offset+4] & 0x40); |
| | 938 | input_report_key(input_dev, BTN_NORTH, rd[offset+4] & 0x80); |
| | 939 | |
| | 940 | input_report_key(input_dev, BTN_TL, rd[offset+5] & 0x1); |
| | 941 | input_report_key(input_dev, BTN_TR, rd[offset+5] & 0x2); |
| | 942 | input_report_key(input_dev, BTN_TL2, rd[offset+5] & 0x4); |
| | 943 | input_report_key(input_dev, BTN_TR2, rd[offset+5] & 0x8); |
| | 944 | input_report_key(input_dev, BTN_SELECT, rd[offset+5] & 0x10); |
| | 945 | input_report_key(input_dev, BTN_START, rd[offset+5] & 0x20); |
| | 946 | input_report_key(input_dev, BTN_THUMBL, rd[offset+5] & 0x40); |
| | 947 | input_report_key(input_dev, BTN_THUMBR, rd[offset+5] & 0x80); |
| | 948 | |
| | 949 | input_report_key(input_dev, BTN_MODE, rd[offset+6] & 0x1); |
| | 950 | |
| | 951 | input_report_abs(input_dev, ABS_Z, rd[offset+7]); |
| | 952 | input_report_abs(input_dev, ABS_RZ, rd[offset+8]); |
| | 953 | |
| | 954 | input_sync(input_dev); |
| | 955 | } |
| | 956 | |
| | 957 | /* Convert timestamp (in 5.33us unit) to timestamp_us */ |
| | 958 | offset = data_offset + DS4_INPUT_REPORT_TIMESTAMP_OFFSET; |
| | 959 | timestamp = get_unaligned_le16(&rd[offset]); |
| | 960 | if (!sc->timestamp_initialized) { |
| | 961 | sc->timestamp_us = ((unsigned int)timestamp * 16) / 3; |
| | 962 | sc->timestamp_initialized = true; |
| | 963 | } else { |
| | 964 | u16 delta; |
| | 965 | |
| | 966 | if (sc->prev_timestamp > timestamp) |
| | 967 | delta = (U16_MAX - sc->prev_timestamp + timestamp + 1); |
| | 968 | else |
| | 969 | delta = timestamp - sc->prev_timestamp; |
| | 970 | sc->timestamp_us += (delta * 16) / 3; |
| | 971 | } |
| | 972 | sc->prev_timestamp = timestamp; |
| | 973 | input_event(sc->sensor_dev, EV_MSC, MSC_TIMESTAMP, sc->timestamp_us); |
| | 974 | |
| | 975 | offset = data_offset + DS4_INPUT_REPORT_GYRO_X_OFFSET; |
| | 976 | for (n = 0; n < 6; n++) { |
| | 977 | /* Store data in int for more precision during mult_frac. */ |
| | 978 | int raw_data = (short)((rd[offset+1] << 8) | rd[offset]); |
| | 979 | struct ds4_calibration_data *calib = &sc->ds4_calib_data[n]; |
| | 980 | |
| | 981 | /* High precision is needed during calibration, but the |
| | 982 | * calibrated values are within 32-bit. |
| | 983 | * Note: we swap numerator 'x' and 'numer' in mult_frac for |
| | 984 | * precision reasons so we don't need 64-bit. |
| | 985 | */ |
| | 986 | int calib_data = mult_frac(calib->sens_numer, |
| | 987 | raw_data - calib->bias, |
| | 988 | calib->sens_denom); |
| | 989 | |
| | 990 | input_report_abs(sc->sensor_dev, calib->abs_code, calib_data); |
| | 991 | offset += 2; |
| | 992 | } |
| | 993 | input_sync(sc->sensor_dev); |
| | 994 | |
| 1306 | /* | 995 | /* |
| 1307 | * The lower 4 bits of byte 30 (or 32 for BT) contain the battery level | 996 | * The lower 4 bits of byte 30 (or 32 for BT) contain the battery level |
| 1308 | * and the 5th bit contains the USB cable state. | 997 | * and the 5th bit contains the USB cable state. |
| @@ -1341,7 +1030,7 @@ static void dualshock4_parse_report(struct sony_sc *sc, u8 *rd, int size) · 32 unmodified lines |
| 1341 | * Trackpad data starts 2 bytes later (e.g. 35 for USB). | 1030 | * Trackpad data starts 2 bytes later (e.g. 35 for USB). |
| 1342 | */ | 1031 | */ |
| 1343 | offset = data_offset + DS4_INPUT_REPORT_TOUCHPAD_OFFSET; | 1032 | offset = data_offset + DS4_INPUT_REPORT_TOUCHPAD_OFFSET; |
| 1344 | max_touch_data = (sc->quirks & DUALSHOCK4_CONTROLLER_USB) ? 3 : 4; | 1033 | max_touch_data = (sc->quirks & DUALSHOCK4_CONTROLLER_BT) ? 4 : 3; |
| 1345 | if (rd[offset] > 0 && rd[offset] <= max_touch_data) | 1034 | if (rd[offset] > 0 && rd[offset] <= max_touch_data) |
| 1346 | num_touch_data = rd[offset]; | 1035 | num_touch_data = rd[offset]; |
| 1347 | else | 1036 | else |
| @@ -1415,47 +1104,79 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report, · 67 unmodified lines |
| 1415 | } else if ((sc->quirks & NAVIGATION_CONTROLLER) && rd[0] == 0x01 && | 1104 | } else if ((sc->quirks & NAVIGATION_CONTROLLER) && rd[0] == 0x01 && |
| 1416 | size == 49) { | 1105 | size == 49) { |
| 1417 | sixaxis_parse_report(sc, rd, size); | 1106 | sixaxis_parse_report(sc, rd, size); |
| 1418 | } else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 && | 1107 | } else if ((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 && |
| 1419 | size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) | 1108 | size == 64) { |
| 1420 | && rd[0] == 0x11 && size == 78)) { | 1109 | dualshock4_parse_report(sc, rd, size); |
| 1421 | if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) { | 1110 | } else if (((sc->quirks & DUALSHOCK4_CONTROLLER_BT) && rd[0] == 0x11 && |
| 1422 | /* CRC check */ | 1111 | size == 78)) { |
| 1423 | u8 bthdr = 0xA1; | 1112 | /* CRC check */ |
| 1424 | u32 crc; | 1113 | u8 bthdr = 0xA1; |
| 1425 | u32 report_crc; | 1114 | u32 crc; |
| | 1115 | u32 report_crc; |
| 1426 | | 1116 | |
| 1427 | crc = crc32_le(0xFFFFFFFF, &bthdr, 1); | 1117 | crc = crc32_le(0xFFFFFFFF, &bthdr, 1); |
| 1428 | crc = ~crc32_le(crc, rd, DS4_INPUT_REPORT_0x11_SIZE-4); | 1118 | crc = ~crc32_le(crc, rd, DS4_INPUT_REPORT_0x11_SIZE-4); |
| 1429 | report_crc = get_unaligned_le32(&rd[DS4_INPUT_REPORT_0x11_SIZE-4]); | 1119 | report_crc = get_unaligned_le32(&rd[DS4_INPUT_REPORT_0x11_SIZE-4]); |
| 1430 | if (crc != report_crc) { | 1120 | if (crc != report_crc) { |
| 1431 | hid_dbg(sc->hdev, "DualShock 4 input report's CRC check failed, received crc 0x%0x != 0x%0x\n", | 1121 | hid_dbg(sc->hdev, "DualShock 4 input report's CRC check failed, received crc 0x%0x != 0x%0x\n", |
| 1432 | report_crc, crc); | 1122 | report_crc, crc); |
| 1433 | return -EILSEQ; | 1123 | return -EILSEQ; |
| 1434 | } | | |
| 1435 | } | 1124 | } |
| 1436 | | 1125 | |
| | 1126 | dualshock4_parse_report(sc, rd, size); |
| | 1127 | } else if ((sc->quirks & DUALSHOCK4_DONGLE) && rd[0] == 0x01 && |
| | 1128 | size == 64) { |
| | 1129 | unsigned long flags; |
| | 1130 | enum ds4_dongle_state dongle_state; |
| | 1131 | |
| 1437 | /* | 1132 | /* |
| 1438 | * In the case of a DS4 USB dongle, bit[2] of byte 31 indicates | 1133 | * In the case of a DS4 USB dongle, bit[2] of byte 31 indicates |
| 1439 | * if a DS4 is actually connected (indicated by '0'). | 1134 | * if a DS4 is actually connected (indicated by '0'). |
| 1440 | * For non-dongle, this bit is always 0 (connected). | 1135 | * For non-dongle, this bit is always 0 (connected). |
| 1441 | */ | 1136 | */ |
| 1442 | if (sc->hdev->vendor == USB_VENDOR_ID_SONY && | 1137 | bool connected = (rd[31] & 0x04) ? false : true; |
| 1443 | sc->hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) { | 1138 | |
| 1444 | bool connected = (rd[31] & 0x04) ? false : true; | 1139 | spin_lock_irqsave(&sc->lock, flags); |
| 1445 | | 1140 | dongle_state = sc->ds4_dongle_state; |
| 1446 | if (!sc->ds4_dongle_connected && connected) { | 1141 | spin_unlock_irqrestore(&sc->lock, flags); |
| 1447 | hid_info(sc->hdev, "DualShock 4 USB dongle: controller connected\n"); | 1142 | |
| 1448 | sony_set_leds(sc); | 1143 | /* |
| 1449 | sc->ds4_dongle_connected = true; | 1144 | * The dongle always sends input reports even when no |
| 1450 | } else if (sc->ds4_dongle_connected && !connected) { | 1145 | * DS4 is attached. When a DS4 is connected, we need to |
| 1451 | hid_info(sc->hdev, "DualShock 4 USB dongle: controller disconnected\n"); | 1146 | * obtain calibration data before we can use it. |
| 1452 | sc->ds4_dongle_connected = false; | 1147 | * The code below tracks dongle state and kicks of |
| 1453 | /* Return 0, so hidraw can get the report. */ | 1148 | * calibration when needed and only allows us to process |
| 1454 | return 0; | 1149 | * input if a DS4 is actually connected. |
| 1455 | } else if (!sc->ds4_dongle_connected) { | 1150 | */ |
| 1456 | /* Return 0, so hidraw can get the report. */ | 1151 | if (dongle_state == DONGLE_DISCONNECTED && connected) { |
| 1457 | return 0; | 1152 | hid_info(sc->hdev, "DualShock 4 USB dongle: controller connected\n"); |
| 1458 | } | 1153 | sony_set_leds(sc); |
| | 1154 | |
| | 1155 | spin_lock_irqsave(&sc->lock, flags); |
| | 1156 | sc->ds4_dongle_state = DONGLE_CALIBRATING; |
| | 1157 | spin_unlock_irqrestore(&sc->lock, flags); |
| | 1158 | |
| | 1159 | sony_schedule_work(sc, SONY_WORKER_HOTPLUG); |
| | 1160 | |
| | 1161 | /* Don't process the report since we don't have |
| | 1162 | * calibration data, but let hidraw have it anyway. |
| | 1163 | */ |
| | 1164 | return 0; |
| | 1165 | } else if ((dongle_state == DONGLE_CONNECTED || |
| | 1166 | dongle_state == DONGLE_DISABLED) && !connected) { |
| | 1167 | hid_info(sc->hdev, "DualShock 4 USB dongle: controller disconnected\n"); |
| | 1168 | |
| | 1169 | spin_lock_irqsave(&sc->lock, flags); |
| | 1170 | sc->ds4_dongle_state = DONGLE_DISCONNECTED; |
| | 1171 | spin_unlock_irqrestore(&sc->lock, flags); |
| | 1172 | |
| | 1173 | /* Return 0, so hidraw can get the report. */ |
| | 1174 | return 0; |
| | 1175 | } else if (dongle_state == DONGLE_CALIBRATING || |
| | 1176 | dongle_state == DONGLE_DISABLED || |
| | 1177 | dongle_state == DONGLE_DISCONNECTED) { |
| | 1178 | /* Return 0, so hidraw can get the report. */ |
| | 1179 | return 0; |
| 1459 | } | 1180 | } |
| 1460 | | 1181 | |
| 1461 | dualshock4_parse_report(sc, rd, size); | 1182 | dualshock4_parse_report(sc, rd, size); |
| @@ -1463,7 +1184,7 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report, · 1 unmodified line |
| 1463 | | 1184 | |
| 1464 | if (sc->defer_initialization) { | 1185 | if (sc->defer_initialization) { |
| 1465 | sc->defer_initialization = 0; | 1186 | sc->defer_initialization = 0; |
| 1466 | sony_schedule_work(sc); | 1187 | sony_schedule_work(sc, SONY_WORKER_STATE); |
| 1467 | } | 1188 | } |
| 1468 | | 1189 | |
| 1469 | return 0; | 1190 | return 0; |
| @@ -1501,10 +1222,16 @@ static int sony_mapping(struct hid_device *hdev, struct hid_input *hi, · 31 unmodified lines |
| 1501 | if (sc->quirks & PS3REMOTE) | 1222 | if (sc->quirks & PS3REMOTE) |
| 1502 | return ps3remote_mapping(hdev, hi, field, usage, bit, max); | 1223 | return ps3remote_mapping(hdev, hi, field, usage, bit, max); |
| 1503 | | 1224 | |
| | 1225 | if (sc->quirks & NAVIGATION_CONTROLLER) |
| | 1226 | return navigation_mapping(hdev, hi, field, usage, bit, max); |
| | 1227 | |
| | 1228 | if (sc->quirks & SIXAXIS_CONTROLLER) |
| | 1229 | return sixaxis_mapping(hdev, hi, field, usage, bit, max); |
| 1504 | | 1230 | |
| 1505 | if (sc->quirks & DUALSHOCK4_CONTROLLER) | 1231 | if (sc->quirks & DUALSHOCK4_CONTROLLER) |
| 1506 | return ds4_mapping(hdev, hi, field, usage, bit, max); | 1232 | return ds4_mapping(hdev, hi, field, usage, bit, max); |
| 1507 | | 1233 | |
| | 1234 | |
| 1508 | /* Let hid-core decide for the others */ | 1235 | /* Let hid-core decide for the others */ |
| 1509 | return 0; | 1236 | return 0; |
| 1510 | } | 1237 | } |
| @@ -1541,7 +1268,7 @@ static int sony_register_touchpad(struct sony_sc *sc, int touch_count, · 30 unmodified lines |
| 1541 | snprintf(name, name_sz, "%s" DS4_TOUCHPAD_SUFFIX, sc->hdev->name); | 1268 | snprintf(name, name_sz, "%s" DS4_TOUCHPAD_SUFFIX, sc->hdev->name); |
| 1542 | sc->touchpad->name = name; | 1269 | sc->touchpad->name = name; |
| 1543 | | 1270 | |
| 1544 | ret = input_mt_init_slots(sc->touchpad, touch_count, 0); | 1271 | ret = input_mt_init_slots(sc->touchpad, touch_count, INPUT_MT_POINTER); |
| 1545 | if (ret < 0) | 1272 | if (ret < 0) |
| 1546 | goto err; | 1273 | goto err; |
| 1547 | | 1274 | |
| @@ -1581,6 +1308,103 @@ static void sony_unregister_touchpad(struct sony_sc *sc) · 33 unmodified lines |
| 1581 | sc->touchpad = NULL; | 1308 | sc->touchpad = NULL; |
| 1582 | } | 1309 | } |
| 1583 | | 1310 | |
| | 1311 | static int sony_register_sensors(struct sony_sc *sc) |
| | 1312 | { |
| | 1313 | size_t name_sz; |
| | 1314 | char *name; |
| | 1315 | int ret; |
| | 1316 | int range; |
| | 1317 | |
| | 1318 | sc->sensor_dev = input_allocate_device(); |
| | 1319 | if (!sc->sensor_dev) |
| | 1320 | return -ENOMEM; |
| | 1321 | |
| | 1322 | input_set_drvdata(sc->sensor_dev, sc); |
| | 1323 | sc->sensor_dev->dev.parent = &sc->hdev->dev; |
| | 1324 | sc->sensor_dev->phys = sc->hdev->phys; |
| | 1325 | sc->sensor_dev->uniq = sc->hdev->uniq; |
| | 1326 | sc->sensor_dev->id.bustype = sc->hdev->bus; |
| | 1327 | sc->sensor_dev->id.vendor = sc->hdev->vendor; |
| | 1328 | sc->sensor_dev->id.product = sc->hdev->product; |
| | 1329 | sc->sensor_dev->id.version = sc->hdev->version; |
| | 1330 | |
| | 1331 | /* Append a suffix to the controller name as there are various |
| | 1332 | * DS4 compatible non-Sony devices with different names. |
| | 1333 | */ |
| | 1334 | name_sz = strlen(sc->hdev->name) + sizeof(SENSOR_SUFFIX); |
| | 1335 | name = kzalloc(name_sz, GFP_KERNEL); |
| | 1336 | if (!name) { |
| | 1337 | ret = -ENOMEM; |
| | 1338 | goto err; |
| | 1339 | } |
| | 1340 | snprintf(name, name_sz, "%s" SENSOR_SUFFIX, sc->hdev->name); |
| | 1341 | sc->sensor_dev->name = name; |
| | 1342 | |
| | 1343 | if (sc->quirks & SIXAXIS_CONTROLLER) { |
| | 1344 | /* For the DS3 we only support the accelerometer, which works |
| | 1345 | * quite well even without calibration. The device also has |
| | 1346 | * a 1-axis gyro, but it is very difficult to manage from within |
| | 1347 | * the driver even to get data, the sensor is inaccurate and |
| | 1348 | * the behavior is very different between hardware revisions. |
| | 1349 | */ |
| | 1350 | input_set_abs_params(sc->sensor_dev, ABS_X, -512, 511, 4, 0); |
| | 1351 | input_set_abs_params(sc->sensor_dev, ABS_Y, -512, 511, 4, 0); |
| | 1352 | input_set_abs_params(sc->sensor_dev, ABS_Z, -512, 511, 4, 0); |
| | 1353 | input_abs_set_res(sc->sensor_dev, ABS_X, SIXAXIS_ACC_RES_PER_G); |
| | 1354 | input_abs_set_res(sc->sensor_dev, ABS_Y, SIXAXIS_ACC_RES_PER_G); |
| | 1355 | input_abs_set_res(sc->sensor_dev, ABS_Z, SIXAXIS_ACC_RES_PER_G); |
| | 1356 | } else if (sc->quirks & DUALSHOCK4_CONTROLLER) { |
| | 1357 | range = DS4_ACC_RES_PER_G*4; |
| | 1358 | input_set_abs_params(sc->sensor_dev, ABS_X, -range, range, 16, 0); |
| | 1359 | input_set_abs_params(sc->sensor_dev, ABS_Y, -range, range, 16, 0); |
| | 1360 | input_set_abs_params(sc->sensor_dev, ABS_Z, -range, range, 16, 0); |
| | 1361 | input_abs_set_res(sc->sensor_dev, ABS_X, DS4_ACC_RES_PER_G); |
| | 1362 | input_abs_set_res(sc->sensor_dev, ABS_Y, DS4_ACC_RES_PER_G); |
| | 1363 | input_abs_set_res(sc->sensor_dev, ABS_Z, DS4_ACC_RES_PER_G); |
| | 1364 | |
| | 1365 | range = DS4_GYRO_RES_PER_DEG_S*2048; |
| | 1366 | input_set_abs_params(sc->sensor_dev, ABS_RX, -range, range, 16, 0); |
| | 1367 | input_set_abs_params(sc->sensor_dev, ABS_RY, -range, range, 16, 0); |
| | 1368 | input_set_abs_params(sc->sensor_dev, ABS_RZ, -range, range, 16, 0); |
| | 1369 | input_abs_set_res(sc->sensor_dev, ABS_RX, DS4_GYRO_RES_PER_DEG_S); |
| | 1370 | input_abs_set_res(sc->sensor_dev, ABS_RY, DS4_GYRO_RES_PER_DEG_S); |
| | 1371 | input_abs_set_res(sc->sensor_dev, ABS_RZ, DS4_GYRO_RES_PER_DEG_S); |
| | 1372 | |
| | 1373 | __set_bit(EV_MSC, sc->sensor_dev->evbit); |
| | 1374 | __set_bit(MSC_TIMESTAMP, sc->sensor_dev->mscbit); |
| | 1375 | } |
| | 1376 | |
| | 1377 | __set_bit(INPUT_PROP_ACCELEROMETER, sc->sensor_dev->propbit); |
| | 1378 | |
| | 1379 | ret = input_register_device(sc->sensor_dev); |
| | 1380 | if (ret < 0) |
| | 1381 | goto err; |
| | 1382 | |
| | 1383 | return 0; |
| | 1384 | |
| | 1385 | err: |
| | 1386 | kfree(sc->sensor_dev->name); |
| | 1387 | sc->sensor_dev->name = NULL; |
| | 1388 | |
| | 1389 | input_free_device(sc->sensor_dev); |
| | 1390 | sc->sensor_dev = NULL; |
| | 1391 | |
| | 1392 | return ret; |
| | 1393 | } |
| | 1394 | |
| | 1395 | static void sony_unregister_sensors(struct sony_sc *sc) |
| | 1396 | { |
| | 1397 | if (!sc->sensor_dev) |
| | 1398 | return; |
| | 1399 | |
| | 1400 | kfree(sc->sensor_dev->name); |
| | 1401 | sc->sensor_dev->name = NULL; |
| | 1402 | |
| | 1403 | input_unregister_device(sc->sensor_dev); |
| | 1404 | sc->sensor_dev = NULL; |
| | 1405 | } |
| | 1406 | |
| | 1407 | |
| 1584 | /* | 1408 | /* |
| 1585 | * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller | 1409 | * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller |
| 1586 | * to "operational". Without this, the ps3 controller will not report any | 1410 | * to "operational". Without this, the ps3 controller will not report any |
| @@ -1646,26 +1470,176 @@ static int sixaxis_set_operational_bt(struct hid_device *hdev) · 59 unmodified lines |
| 1646 | } | 1470 | } |
| 1647 | | 1471 | |
| 1648 | /* | 1472 | /* |
| 1649 | * Requesting feature report 0x02 in Bluetooth mode changes the state of the | 1473 | * Request DS4 calibration data for the motion sensors. |
| 1650 | * controller so that it sends full input reports of type 0x11. | 1474 | * For Bluetooth this also affects the operating mode (see below). |
| 1651 | */ | 1475 | */ |
| 1652 | static int dualshock4_set_operational_bt(struct hid_device *hdev) | 1476 | static int dualshock4_get_calibration_data(struct sony_sc *sc) |
| 1653 | { | 1477 | { |
| 1654 | u8 *buf; | 1478 | u8 *buf; |
| 1655 | int ret; | 1479 | int ret; |
| | 1480 | short gyro_pitch_bias, gyro_pitch_plus, gyro_pitch_minus; |
| | 1481 | short gyro_yaw_bias, gyro_yaw_plus, gyro_yaw_minus; |
| | 1482 | short gyro_roll_bias, gyro_roll_plus, gyro_roll_minus; |
| | 1483 | short gyro_speed_plus, gyro_speed_minus; |
| | 1484 | short acc_x_plus, acc_x_minus; |
| | 1485 | short acc_y_plus, acc_y_minus; |
| | 1486 | short acc_z_plus, acc_z_minus; |
| | 1487 | int speed_2x; |
| | 1488 | int range_2g; |
| | 1489 | |
| | 1490 | /* For Bluetooth we use a different request, which supports CRC. |
| | 1491 | * Note: in Bluetooth mode feature report 0x02 also changes the state |
| | 1492 | * of the controller, so that it sends input reports of type 0x11. |
| | 1493 | */ |
| | 1494 | if (sc->quirks & (DUALSHOCK4_CONTROLLER_USB | DUALSHOCK4_DONGLE)) { |
| | 1495 | buf = kmalloc(DS4_FEATURE_REPORT_0x02_SIZE, GFP_KERNEL); |
| | 1496 | if (!buf) |
| | 1497 | return -ENOMEM; |
| 1656 | | 1498 | |
| 1657 | buf = kmalloc(DS4_FEATURE_REPORT_0x02_SIZE, GFP_KERNEL); | 1499 | ret = hid_hw_raw_request(sc->hdev, 0x02, buf, |
| 1658 | if (!buf) | 1500 | DS4_FEATURE_REPORT_0x02_SIZE, |
| 1659 | return -ENOMEM; | 1501 | HID_FEATURE_REPORT, |
| | 1502 | HID_REQ_GET_REPORT); |
| | 1503 | if (ret < 0) |
| | 1504 | goto err_stop; |
| | 1505 | } else { |
| | 1506 | u8 bthdr = 0xA3; |
| | 1507 | u32 crc; |
| | 1508 | u32 report_crc; |
| | 1509 | int retries; |
| | 1510 | |
| | 1511 | buf = kmalloc(DS4_FEATURE_REPORT_0x05_SIZE, GFP_KERNEL); |
| | 1512 | if (!buf) |
| | 1513 | return -ENOMEM; |
| 1660 | | 1514 | |
| 1661 | ret = hid_hw_raw_request(hdev, 0x02, buf, DS4_FEATURE_REPORT_0x02_SIZE, | 1515 | for (retries = 0; retries < 3; retries++) { |
| 1662 | HID_FEATURE_REPORT, HID_REQ_GET_REPORT); | 1516 | ret = hid_hw_raw_request(sc->hdev, 0x05, buf, |
| | 1517 | DS4_FEATURE_REPORT_0x05_SIZE, |
| | 1518 | HID_FEATURE_REPORT, |
| | 1519 | HID_REQ_GET_REPORT); |
| | 1520 | if (ret < 0) |
| | 1521 | goto err_stop; |
| 1663 | | 1522 | |
| 1664 | kfree(buf); | 1523 | /* CRC check */ |
| | 1524 | crc = crc32_le(0xFFFFFFFF, &bthdr, 1); |
| | 1525 | crc = ~crc32_le(crc, buf, DS4_FEATURE_REPORT_0x05_SIZE-4); |
| | 1526 | report_crc = get_unaligned_le32(&buf[DS4_FEATURE_REPORT_0x05_SIZE-4]); |
| | 1527 | if (crc != report_crc) { |
| | 1528 | hid_warn(sc->hdev, "DualShock 4 calibration report's CRC check failed, received crc 0x%0x != 0x%0x\n", |
| | 1529 | report_crc, crc); |
| | 1530 | if (retries < 2) { |
| | 1531 | hid_warn(sc->hdev, "Retrying DualShock 4 get calibration report request\n"); |
| | 1532 | continue; |
| | 1533 | } else { |
| | 1534 | ret = -EILSEQ; |
| | 1535 | goto err_stop; |
| | 1536 | } |
| | 1537 | } else { |
| | 1538 | break; |
| | 1539 | } |
| | 1540 | } |
| | 1541 | } |
| 1665 | | 1542 | |
| | 1543 | gyro_pitch_bias = get_unaligned_le16(&buf[1]); |
| | 1544 | gyro_yaw_bias = get_unaligned_le16(&buf[3]); |
| | 1545 | gyro_roll_bias = get_unaligned_le16(&buf[5]); |
| | 1546 | if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) { |
| | 1547 | gyro_pitch_plus = get_unaligned_le16(&buf[7]); |
| | 1548 | gyro_pitch_minus = get_unaligned_le16(&buf[9]); |
| | 1549 | gyro_yaw_plus = get_unaligned_le16(&buf[11]); |
| | 1550 | gyro_yaw_minus = get_unaligned_le16(&buf[13]); |
| | 1551 | gyro_roll_plus = get_unaligned_le16(&buf[15]); |
| | 1552 | gyro_roll_minus = get_unaligned_le16(&buf[17]); |
| | 1553 | } else { |
| | 1554 | /* BT + Dongle */ |
| | 1555 | gyro_pitch_plus = get_unaligned_le16(&buf[7]); |
| | 1556 | gyro_yaw_plus = get_unaligned_le16(&buf[9]); |
| | 1557 | gyro_roll_plus = get_unaligned_le16(&buf[11]); |
| | 1558 | gyro_pitch_minus = get_unaligned_le16(&buf[13]); |
| | 1559 | gyro_yaw_minus = get_unaligned_le16(&buf[15]); |
| | 1560 | gyro_roll_minus = get_unaligned_le16(&buf[17]); |
| | 1561 | } |
| | 1562 | gyro_speed_plus = get_unaligned_le16(&buf[19]); |
| | 1563 | gyro_speed_minus = get_unaligned_le16(&buf[21]); |
| | 1564 | acc_x_plus = get_unaligned_le16(&buf[23]); |
| | 1565 | acc_x_minus = get_unaligned_le16(&buf[25]); |
| | 1566 | acc_y_plus = get_unaligned_le16(&buf[27]); |
| | 1567 | acc_y_minus = get_unaligned_le16(&buf[29]); |
| | 1568 | acc_z_plus = get_unaligned_le16(&buf[31]); |
| | 1569 | acc_z_minus = get_unaligned_le16(&buf[33]); |
| | 1570 | |
| | 1571 | /* Set gyroscope calibration and normalization parameters. |
| | 1572 | * Data values will be normalized to 1/DS4_GYRO_RES_PER_DEG_S degree/s. |
| | 1573 | */ |
| | 1574 | speed_2x = (gyro_speed_plus + gyro_speed_minus); |
| | 1575 | sc->ds4_calib_data[0].abs_code = ABS_RX; |
| | 1576 | sc->ds4_calib_data[0].bias = gyro_pitch_bias; |
| | 1577 | sc->ds4_calib_data[0].sens_numer = speed_2x*DS4_GYRO_RES_PER_DEG_S; |
| | 1578 | sc->ds4_calib_data[0].sens_denom = gyro_pitch_plus - gyro_pitch_minus; |
| | 1579 | |
| | 1580 | sc->ds4_calib_data[1].abs_code = ABS_RY; |
| | 1581 | sc->ds4_calib_data[1].bias = gyro_yaw_bias; |
| | 1582 | sc->ds4_calib_data[1].sens_numer = speed_2x*DS4_GYRO_RES_PER_DEG_S; |
| | 1583 | sc->ds4_calib_data[1].sens_denom = gyro_yaw_plus - gyro_yaw_minus; |
| | 1584 | |
| | 1585 | sc->ds4_calib_data[2].abs_code = ABS_RZ; |
| | 1586 | sc->ds4_calib_data[2].bias = gyro_roll_bias; |
| | 1587 | sc->ds4_calib_data[2].sens_numer = speed_2x*DS4_GYRO_RES_PER_DEG_S; |
| | 1588 | sc->ds4_calib_data[2].sens_denom = gyro_roll_plus - gyro_roll_minus; |
| | 1589 | |
| | 1590 | /* Set accelerometer calibration and normalization parameters. |
| | 1591 | * Data values will be normalized to 1/DS4_ACC_RES_PER_G G. |
| | 1592 | */ |
| | 1593 | range_2g = acc_x_plus - acc_x_minus; |
| | 1594 | sc->ds4_calib_data[3].abs_code = ABS_X; |
| | 1595 | sc->ds4_calib_data[3].bias = acc_x_plus - range_2g / 2; |
| | 1596 | sc->ds4_calib_data[3].sens_numer = 2*DS4_ACC_RES_PER_G; |
| | 1597 | sc->ds4_calib_data[3].sens_denom = range_2g; |
| | 1598 | |
| | 1599 | range_2g = acc_y_plus - acc_y_minus; |
| | 1600 | sc->ds4_calib_data[4].abs_code = ABS_Y; |
| | 1601 | sc->ds4_calib_data[4].bias = acc_y_plus - range_2g / 2; |
| | 1602 | sc->ds4_calib_data[4].sens_numer = 2*DS4_ACC_RES_PER_G; |
| | 1603 | sc->ds4_calib_data[4].sens_denom = range_2g; |
| | 1604 | |
| | 1605 | range_2g = acc_z_plus - acc_z_minus; |
| | 1606 | sc->ds4_calib_data[5].abs_code = ABS_Z; |
| | 1607 | sc->ds4_calib_data[5].bias = acc_z_plus - range_2g / 2; |
| | 1608 | sc->ds4_calib_data[5].sens_numer = 2*DS4_ACC_RES_PER_G; |
| | 1609 | sc->ds4_calib_data[5].sens_denom = range_2g; |
| | 1610 | |
| | 1611 | err_stop: |
| | 1612 | kfree(buf); |
| 1666 | return ret; | 1613 | return ret; |
| 1667 | } | 1614 | } |
| 1668 | | 1615 | |
| | 1616 | static void dualshock4_calibration_work(struct work_struct *work) |
| | 1617 | { |
| | 1618 | struct sony_sc *sc = container_of(work, struct sony_sc, hotplug_worker); |
| | 1619 | unsigned long flags; |
| | 1620 | enum ds4_dongle_state dongle_state; |
| | 1621 | int ret; |
| | 1622 | |
| | 1623 | ret = dualshock4_get_calibration_data(sc); |
| | 1624 | if (ret < 0) { |
| | 1625 | /* This call is very unlikely to fail for the dongle. When it |
| | 1626 | * fails we are probably in a very bad state, so mark the |
| | 1627 | * dongle as disabled. We will re-enable the dongle if a new |
| | 1628 | * DS4 hotplug is detect from sony_raw_event as any issues |
| | 1629 | * are likely resolved then (the dongle is quite stupid). |
| | 1630 | */ |
| | 1631 | hid_err(sc->hdev, "DualShock 4 USB dongle: calibration failed, disabling device\n"); |
| | 1632 | dongle_state = DONGLE_DISABLED; |
| | 1633 | } else { |
| | 1634 | hid_info(sc->hdev, "DualShock 4 USB dongle: calibration completed\n"); |
| | 1635 | dongle_state = DONGLE_CONNECTED; |
| | 1636 | } |
| | 1637 | |
| | 1638 | spin_lock_irqsave(&sc->lock, flags); |
| | 1639 | sc->ds4_dongle_state = dongle_state; |
| | 1640 | spin_unlock_irqrestore(&sc->lock, flags); |
| | 1641 | } |
| | 1642 | |
| 1669 | static void sixaxis_set_leds_from_id(struct sony_sc *sc) | 1643 | static void sixaxis_set_leds_from_id(struct sony_sc *sc) |
| 1670 | { | 1644 | { |
| 1671 | static const u8 sixaxis_leds[10][4] = { | 1645 | static const u8 sixaxis_leds[10][4] = { |
| @@ -1696,10 +1670,10 @@ static void dualshock4_set_leds_from_id(struct sony_sc *sc) · 24 unmodified lines |
| 1696 | { | 1670 | { |
| 1697 | /* The first 4 color/index entries match what the PS4 assigns */ | 1671 | /* The first 4 color/index entries match what the PS4 assigns */ |
| 1698 | static const u8 color_code[7][3] = { | 1672 | static const u8 color_code[7][3] = { |
| 1699 | /* Blue */ { 0x00, 0x00, 0x01 }, | 1673 | /* Blue */ { 0x00, 0x00, 0x40 }, |
| 1700 | /* Red */ { 0x01, 0x00, 0x00 }, | 1674 | /* Red */ { 0x40, 0x00, 0x00 }, |
| 1701 | /* Green */ { 0x00, 0x01, 0x00 }, | 1675 | /* Green */ { 0x00, 0x40, 0x00 }, |
| 1702 | /* Pink */ { 0x02, 0x00, 0x01 }, | 1676 | /* Pink */ { 0x20, 0x00, 0x20 }, |
| 1703 | /* Orange */ { 0x02, 0x01, 0x00 }, | 1677 | /* Orange */ { 0x02, 0x01, 0x00 }, |
| 1704 | /* Teal */ { 0x00, 0x01, 0x01 }, | 1678 | /* Teal */ { 0x00, 0x01, 0x01 }, |
| 1705 | /* White */ { 0x01, 0x01, 0x01 } | 1679 | /* White */ { 0x01, 0x01, 0x01 } |
| @@ -1740,7 +1714,7 @@ static void buzz_set_leds(struct sony_sc *sc) · 34 unmodified lines |
| 1740 | static void sony_set_leds(struct sony_sc *sc) | 1714 | static void sony_set_leds(struct sony_sc *sc) |
| 1741 | { | 1715 | { |
| 1742 | if (!(sc->quirks & BUZZ_CONTROLLER)) | 1716 | if (!(sc->quirks & BUZZ_CONTROLLER)) |
| 1743 | sony_schedule_work(sc); | 1717 | sony_schedule_work(sc, SONY_WORKER_STATE); |
| 1744 | else | 1718 | else |
| 1745 | buzz_set_leds(sc); | 1719 | buzz_set_leds(sc); |
| 1746 | } | 1720 | } |
| @@ -1851,7 +1825,7 @@ static int sony_led_blink_set(struct led_classdev *led, unsigned long *delay_on, · 104 unmodified lines |
| 1851 | new_off != drv_data->led_delay_off[n]) { | 1825 | new_off != drv_data->led_delay_off[n]) { |
| 1852 | drv_data->led_delay_on[n] = new_on; | 1826 | drv_data->led_delay_on[n] = new_on; |
| 1853 | drv_data->led_delay_off[n] = new_off; | 1827 | drv_data->led_delay_off[n] = new_off; |
| 1854 | sony_schedule_work(drv_data); | 1828 | sony_schedule_work(drv_data, SONY_WORKER_STATE); |
| 1855 | } | 1829 | } |
| 1856 | | 1830 | |
| 1857 | return 0; | 1831 | return 0; |
| @@ -1964,6 +1938,7 @@ static int sony_leds_init(struct sony_sc *sc) · 106 unmodified lines |
| 1964 | led->name = name; | 1938 | led->name = name; |
| 1965 | led->brightness = sc->led_state[n]; | 1939 | led->brightness = sc->led_state[n]; |
| 1966 | led->max_brightness = max_brightness[n]; | 1940 | led->max_brightness = max_brightness[n]; |
| | 1941 | led->flags = LED_CORE_SUSPENDRESUME; |
| 1967 | led->brightness_get = sony_led_get_brightness; | 1942 | led->brightness_get = sony_led_get_brightness; |
| 1968 | led->brightness_set = sony_led_set_brightness; | 1943 | led->brightness_set = sony_led_set_brightness; |
| 1969 | | 1944 | |
| @@ -2052,26 +2027,24 @@ static void dualshock4_send_output_report(struct sony_sc *sc) · 82 unmodified lines |
| 2052 | int offset; | 2027 | int offset; |
| 2053 | | 2028 | |
| 2054 | /* | 2029 | /* |
| 2055 | * NOTE: The buf[1] field of the Bluetooth report controls | 2030 | * NOTE: The lower 6 bits of buf[1] field of the Bluetooth report |
| 2056 | * the Dualshock 4 reporting rate. | 2031 | * control the interval at which Dualshock 4 reports data: |
| 2057 | * | 2032 | * 0x00 - 1ms |
| 2058 | * Known values include: | 2033 | * 0x01 - 1ms |
| 2059 | * | 2034 | * 0x02 - 2ms |
| 2060 | * 0x80 - 1000hz (full speed) | 2035 | * 0x3E - 62ms |
| 2061 | * 0xA0 - 31hz | 2036 | * 0x3F - disabled |
| 2062 | * 0xB0 - 20hz | | |
| 2063 | * 0xD0 - 66hz | | |
| 2064 | */ | 2037 | */ |
| 2065 | if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) { | 2038 | if (sc->quirks & (DUALSHOCK4_CONTROLLER_USB | DUALSHOCK4_DONGLE)) { |
| 2066 | memset(buf, 0, DS4_OUTPUT_REPORT_0x05_SIZE); | 2039 | memset(buf, 0, DS4_OUTPUT_REPORT_0x05_SIZE); |
| 2067 | buf[0] = 0x05; | 2040 | buf[0] = 0x05; |
| 2068 | buf[1] = 0xFF; | 2041 | buf[1] = 0x07; /* blink + LEDs + motor */ |
| 2069 | offset = 4; | 2042 | offset = 4; |
| 2070 | } else { | 2043 | } else { |
| 2071 | memset(buf, 0, DS4_OUTPUT_REPORT_0x11_SIZE); | 2044 | memset(buf, 0, DS4_OUTPUT_REPORT_0x11_SIZE); |
| 2072 | buf[0] = 0x11; | 2045 | buf[0] = 0x11; |
| 2073 | buf[1] = 0xC0; /* HID + CRC */ | 2046 | buf[1] = 0xC0 /* HID + CRC */ | sc->ds4_bt_poll_interval; |
| 2074 | buf[3] = 0x0F; | 2047 | buf[3] = 0x07; /* blink + LEDs + motor */ |
| 2075 | offset = 6; | 2048 | offset = 6; |
| 2076 | } | 2049 | } |
| 2077 | | 2050 | |
| @@ -2095,7 +2068,7 @@ static void dualshock4_send_output_report(struct sony_sc *sc) · 17 unmodified lines |
| 2095 | buf[offset++] = sc->led_delay_on[3]; | 2068 | buf[offset++] = sc->led_delay_on[3]; |
| 2096 | buf[offset++] = sc->led_delay_off[3]; | 2069 | buf[offset++] = sc->led_delay_off[3]; |
| 2097 | | 2070 | |
| 2098 | if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) | 2071 | if (sc->quirks & (DUALSHOCK4_CONTROLLER_USB | DUALSHOCK4_DONGLE)) |
| 2099 | hid_hw_output_report(hdev, buf, DS4_OUTPUT_REPORT_0x05_SIZE); | 2072 | hid_hw_output_report(hdev, buf, DS4_OUTPUT_REPORT_0x05_SIZE); |
| 2100 | else { | 2073 | else { |
| 2101 | /* CRC generation */ | 2074 | /* CRC generation */ |
| @@ -2152,7 +2125,7 @@ static int sony_allocate_output_report(struct sony_sc *sc) · 50 unmodified lines |
| 2152 | else if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) | 2125 | else if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) |
| 2153 | sc->output_report_dmabuf = kmalloc(DS4_OUTPUT_REPORT_0x11_SIZE, | 2126 | sc->output_report_dmabuf = kmalloc(DS4_OUTPUT_REPORT_0x11_SIZE, |
| 2154 | GFP_KERNEL); | 2127 | GFP_KERNEL); |
| 2155 | else if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) | 2128 | else if (sc->quirks & (DUALSHOCK4_CONTROLLER_USB | DUALSHOCK4_DONGLE)) |
| 2156 | sc->output_report_dmabuf = kmalloc(DS4_OUTPUT_REPORT_0x05_SIZE, | 2129 | sc->output_report_dmabuf = kmalloc(DS4_OUTPUT_REPORT_0x05_SIZE, |
| 2157 | GFP_KERNEL); | 2130 | GFP_KERNEL); |
| 2158 | else if (sc->quirks & MOTION_CONTROLLER) | 2131 | else if (sc->quirks & MOTION_CONTROLLER) |
| @@ -2180,7 +2153,7 @@ static int sony_play_effect(struct input_dev *dev, void *data, · 21 unmodified lines |
| 2180 | sc->left = effect->u.rumble.strong_magnitude / 256; | 2153 | sc->left = effect->u.rumble.strong_magnitude / 256; |
| 2181 | sc->right = effect->u.rumble.weak_magnitude / 256; | 2154 | sc->right = effect->u.rumble.weak_magnitude / 256; |
| 2182 | | 2155 | |
| 2183 | sony_schedule_work(sc); | 2156 | sony_schedule_work(sc, SONY_WORKER_STATE); |
| 2184 | return 0; | 2157 | return 0; |
| 2185 | } | 2158 | } |
| 2186 | | 2159 | |
| @@ -2397,7 +2370,7 @@ static int sony_check_add(struct sony_sc *sc) · 210 unmodified lines |
| 2397 | hid_warn(sc->hdev, "UNIQ does not contain a MAC address; duplicate check skipped\n"); | 2370 | hid_warn(sc->hdev, "UNIQ does not contain a MAC address; duplicate check skipped\n"); |
| 2398 | return 0; | 2371 | return 0; |
| 2399 | } | 2372 | } |
| 2400 | } else if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) { | 2373 | } else if (sc->quirks & (DUALSHOCK4_CONTROLLER_USB | DUALSHOCK4_DONGLE)) { |
| 2401 | buf = kmalloc(DS4_FEATURE_REPORT_0x81_SIZE, GFP_KERNEL); | 2374 | buf = kmalloc(DS4_FEATURE_REPORT_0x81_SIZE, GFP_KERNEL); |
| 2402 | if (!buf) | 2375 | if (!buf) |
| 2403 | return -ENOMEM; | 2376 | return -ENOMEM; |
| @@ -2451,6 +2424,12 @@ static int sony_check_add(struct sony_sc *sc) · 47 unmodified lines |
| 2451 | */ | 2424 | */ |
| 2452 | for (n = 0; n < 6; n++) | 2425 | for (n = 0; n < 6; n++) |
| 2453 | sc->mac_address[5-n] = buf[4+n]; | 2426 | sc->mac_address[5-n] = buf[4+n]; |
| | 2427 | |
| | 2428 | snprintf(sc->hdev->uniq, sizeof(sc->hdev->uniq), |
| | 2429 | "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", |
| | 2430 | sc->mac_address[5], sc->mac_address[4], |
| | 2431 | sc->mac_address[3], sc->mac_address[2], |
| | 2432 | sc->mac_address[1], sc->mac_address[0]); |
| 2454 | } else { | 2433 | } else { |
| 2455 | return 0; | 2434 | return 0; |
| 2456 | } | 2435 | } |
| @@ -2501,18 +2480,21 @@ static inline void sony_init_output_report(struct sony_sc *sc, · 44 unmodified lines |
| 2501 | { | 2480 | { |
| 2502 | sc->send_output_report = send_output_report; | 2481 | sc->send_output_report = send_output_report; |
| 2503 | | 2482 | |
| 2504 | if (!sc->worker_initialized) | 2483 | if (!sc->state_worker_initialized) |
| 2505 | INIT_WORK(&sc->state_worker, sony_state_worker); | 2484 | INIT_WORK(&sc->state_worker, sony_state_worker); |
| 2506 | | 2485 | |
| 2507 | sc->worker_initialized = 1; | 2486 | sc->state_worker_initialized = 1; |
| 2508 | } | 2487 | } |
| 2509 | | 2488 | |
| 2510 | static inline void sony_cancel_work_sync(struct sony_sc *sc) | 2489 | static inline void sony_cancel_work_sync(struct sony_sc *sc) |
| 2511 | { | 2490 | { |
| 2512 | if (sc->worker_initialized) | 2491 | if (sc->hotplug_worker_initialized) |
| | 2492 | cancel_work_sync(&sc->hotplug_worker); |
| | 2493 | if (sc->state_worker_initialized) |
| 2513 | cancel_work_sync(&sc->state_worker); | 2494 | cancel_work_sync(&sc->state_worker); |
| 2514 | } | 2495 | } |
| 2515 | | 2496 | |
| | 2497 | |
| 2516 | static int sony_input_configured(struct hid_device *hdev, | 2498 | static int sony_input_configured(struct hid_device *hdev, |
| 2517 | struct hid_input *hidinput) | 2499 | struct hid_input *hidinput) |
| 2518 | { | 2500 | { |
| @@ -2526,14 +2508,17 @@ static int sony_input_configured(struct hid_device *hdev, · 7 unmodified lines |
| 2526 | goto err_stop; | 2508 | goto err_stop; |
| 2527 | } | 2509 | } |
| 2528 | | 2510 | |
| | 2511 | ret = append_dev_id = sony_check_add(sc); |
| | 2512 | if (ret < 0) |
| | 2513 | goto err_stop; |
| | 2514 | |
| 2529 | ret = sony_allocate_output_report(sc); | 2515 | ret = sony_allocate_output_report(sc); |
| 2530 | if (ret < 0) { | 2516 | if (ret < 0) { |
| 2531 | hid_err(hdev, "failed to allocate the output report buffer\n"); | 2517 | hid_err(hdev, "failed to allocate the output report buffer\n"); |
| 2532 | goto err_stop; | 2518 | goto err_stop; |
| 2533 | } | 2519 | } |
| 2534 | | 2520 | |
| 2535 | if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || | 2521 | if (sc->quirks & NAVIGATION_CONTROLLER_USB) { |
| 2536 | (sc->quirks & NAVIGATION_CONTROLLER_USB)) { | | |
| 2537 | /* | 2522 | /* |
| 2538 | * The Sony Sixaxis does not handle HID Output Reports on the | 2523 | * The Sony Sixaxis does not handle HID Output Reports on the |
| 2539 | * Interrupt EP like it could, so we need to force HID Output | 2524 | * Interrupt EP like it could, so we need to force HID Output |
| @@ -2553,24 +2538,79 @@ static int sony_input_configured(struct hid_device *hdev, · 13 unmodified lines |
| 2553 | hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; | 2538 | hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; |
| 2554 | hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID; | 2539 | hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID; |
| 2555 | sc->defer_initialization = 1; | 2540 | sc->defer_initialization = 1; |
| | 2541 | |
| 2556 | ret = sixaxis_set_operational_usb(hdev); | 2542 | ret = sixaxis_set_operational_usb(hdev); |
| | 2543 | if (ret < 0) { |
| | 2544 | hid_err(hdev, "Failed to set controller into operational mode\n"); |
| | 2545 | goto err_stop; |
| | 2546 | } |
| | 2547 | |
| | 2548 | sony_init_output_report(sc, sixaxis_send_output_report); |
| | 2549 | } else if (sc->quirks & NAVIGATION_CONTROLLER_BT) { |
| | 2550 | /* |
| | 2551 | * The Navigation controller wants output reports sent on the ctrl |
| | 2552 | * endpoint when connected via Bluetooth. |
| | 2553 | */ |
| | 2554 | hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; |
| | 2555 | |
| | 2556 | ret = sixaxis_set_operational_bt(hdev); |
| | 2557 | if (ret < 0) { |
| | 2558 | hid_err(hdev, "Failed to set controller into operational mode\n"); |
| | 2559 | goto err_stop; |
| | 2560 | } |
| | 2561 | |
| 2557 | sony_init_output_report(sc, sixaxis_send_output_report); | 2562 | sony_init_output_report(sc, sixaxis_send_output_report); |
| 2558 | } else if ((sc->quirks & SIXAXIS_CONTROLLER_BT) || | 2563 | } else if (sc->quirks & SIXAXIS_CONTROLLER_USB) { |
| 2559 | (sc->quirks & NAVIGATION_CONTROLLER_BT)) { | 2564 | /* |
| | 2565 | * The Sony Sixaxis does not handle HID Output Reports on the |
| | 2566 | * Interrupt EP and the device only becomes active when the |
| | 2567 | * PS button is pressed. See comment for Navigation controller |
| | 2568 | * above for more details. |
| | 2569 | */ |
| | 2570 | hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; |
| | 2571 | hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID; |
| | 2572 | sc->defer_initialization = 1; |
| | 2573 | |
| | 2574 | ret = sixaxis_set_operational_usb(hdev); |
| | 2575 | if (ret < 0) { |
| | 2576 | hid_err(hdev, "Failed to set controller into operational mode\n"); |
| | 2577 | goto err_stop; |
| | 2578 | } |
| | 2579 | |
| | 2580 | ret = sony_register_sensors(sc); |
| | 2581 | if (ret) { |
| | 2582 | hid_err(sc->hdev, |
| | 2583 | "Unable to initialize motion sensors: %d\n", ret); |
| | 2584 | goto err_stop; |
| | 2585 | } |
| | 2586 | |
| | 2587 | sony_init_output_report(sc, sixaxis_send_output_report); |
| | 2588 | } else if (sc->quirks & SIXAXIS_CONTROLLER_BT) { |
| 2560 | /* | 2589 | /* |
| 2561 | * The Sixaxis wants output reports sent on the ctrl endpoint | 2590 | * The Sixaxis wants output reports sent on the ctrl endpoint |
| 2562 | * when connected via Bluetooth. | 2591 | * when connected via Bluetooth. |
| 2563 | */ | 2592 | */ |
| 2564 | hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; | 2593 | hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; |
| | 2594 | |
| 2565 | ret = sixaxis_set_operational_bt(hdev); | 2595 | ret = sixaxis_set_operational_bt(hdev); |
| | 2596 | if (ret < 0) { |
| | 2597 | hid_err(hdev, "Failed to set controller into operational mode\n"); |
| | 2598 | goto err_stop; |
| | 2599 | } |
| | 2600 | |
| | 2601 | ret = sony_register_sensors(sc); |
| | 2602 | if (ret) { |
| | 2603 | hid_err(sc->hdev, |
| | 2604 | "Unable to initialize motion sensors: %d\n", ret); |
| | 2605 | goto err_stop; |
| | 2606 | } |
| | 2607 | |
| 2566 | sony_init_output_report(sc, sixaxis_send_output_report); | 2608 | sony_init_output_report(sc, sixaxis_send_output_report); |
| 2567 | } else if (sc->quirks & DUALSHOCK4_CONTROLLER) { | 2609 | } else if (sc->quirks & DUALSHOCK4_CONTROLLER) { |
| 2568 | if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) { | 2610 | ret = dualshock4_get_calibration_data(sc); |
| 2569 | ret = dualshock4_set_operational_bt(hdev); | 2611 | if (ret < 0) { |
| 2570 | if (ret < 0) { | 2612 | hid_err(hdev, "Failed to get calibration data from Dualshock 4\n"); |
| 2571 | hid_err(hdev, "failed to set the Dualshock 4 operational mode\n"); | 2613 | goto err_stop; |
| 2572 | goto err_stop; | | |
| 2573 | } | | |
| 2574 | } | 2614 | } |
| 2575 | | 2615 | |
| 2576 | /* | 2616 | /* |
| @@ -2585,6 +2625,28 @@ static int sony_input_configured(struct hid_device *hdev, · 8 unmodified lines |
| 2585 | goto err_stop; | 2625 | goto err_stop; |
| 2586 | } | 2626 | } |
| 2587 | | 2627 | |
| | 2628 | ret = sony_register_sensors(sc); |
| | 2629 | if (ret) { |
| | 2630 | hid_err(sc->hdev, |
| | 2631 | "Unable to initialize motion sensors: %d\n", ret); |
| | 2632 | goto err_stop; |
| | 2633 | } |
| | 2634 | |
| | 2635 | if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) { |
| | 2636 | sc->ds4_bt_poll_interval = DS4_BT_DEFAULT_POLL_INTERVAL_MS; |
| | 2637 | ret = device_create_file(&sc->hdev->dev, &dev_attr_bt_poll_interval); |
| | 2638 | if (ret) |
| | 2639 | hid_warn(sc->hdev, |
| | 2640 | "can't create sysfs bt_poll_interval attribute err: %d\n", |
| | 2641 | ret); |
| | 2642 | } |
| | 2643 | |
| | 2644 | if (sc->quirks & DUALSHOCK4_DONGLE) { |
| | 2645 | INIT_WORK(&sc->hotplug_worker, dualshock4_calibration_work); |
| | 2646 | sc->hotplug_worker_initialized = 1; |
| | 2647 | sc->ds4_dongle_state = DONGLE_DISCONNECTED; |
| | 2648 | } |
| | 2649 | |
| 2588 | sony_init_output_report(sc, dualshock4_send_output_report); | 2650 | sony_init_output_report(sc, dualshock4_send_output_report); |
| 2589 | } else if (sc->quirks & MOTION_CONTROLLER) { | 2651 | } else if (sc->quirks & MOTION_CONTROLLER) { |
| 2590 | sony_init_output_report(sc, motion_send_output_report); | 2652 | sony_init_output_report(sc, motion_send_output_report); |
| @@ -2592,13 +2654,6 @@ static int sony_input_configured(struct hid_device *hdev, · 1 unmodified line |
| 2592 | ret = 0; | 2654 | ret = 0; |
| 2593 | } | 2655 | } |
| 2594 | | 2656 | |
| 2595 | if (ret < 0) | | |
| 2596 | goto err_stop; | | |
| 2597 | | | |
| 2598 | ret = append_dev_id = sony_check_add(sc); | | |
| 2599 | if (ret < 0) | | |
| 2600 | goto err_stop; | | |
| 2601 | | | |
| 2602 | if (sc->quirks & SONY_LED_SUPPORT) { | 2657 | if (sc->quirks & SONY_LED_SUPPORT) { |
| 2603 | ret = sony_leds_init(sc); | 2658 | ret = sony_leds_init(sc); |
| 2604 | if (ret < 0) | 2659 | if (ret < 0) |
| @@ -2628,12 +2683,20 @@ static int sony_input_configured(struct hid_device *hdev, · 23 unmodified lines |
| 2628 | err_close: | 2683 | err_close: |
| 2629 | hid_hw_close(hdev); | 2684 | hid_hw_close(hdev); |
| 2630 | err_stop: | 2685 | err_stop: |
| | 2686 | /* Piggy back on the default ds4_bt_ poll_interval to determine |
| | 2687 | * if we need to remove the file as we don't know for sure if we |
| | 2688 | * executed that logic. |
| | 2689 | */ |
| | 2690 | if (sc->ds4_bt_poll_interval) |
| | 2691 | device_remove_file(&sc->hdev->dev, &dev_attr_bt_poll_interval); |
| 2631 | if (sc->quirks & SONY_LED_SUPPORT) | 2692 | if (sc->quirks & SONY_LED_SUPPORT) |
| 2632 | sony_leds_remove(sc); | 2693 | sony_leds_remove(sc); |
| 2633 | if (sc->quirks & SONY_BATTERY_SUPPORT) | 2694 | if (sc->quirks & SONY_BATTERY_SUPPORT) |
| 2634 | sony_battery_remove(sc); | 2695 | sony_battery_remove(sc); |
| 2635 | if (sc->touchpad) | 2696 | if (sc->touchpad) |
| 2636 | sony_unregister_touchpad(sc); | 2697 | sony_unregister_touchpad(sc); |
| | 2698 | if (sc->sensor_dev) |
| | 2699 | sony_unregister_sensors(sc); |
| 2637 | sony_cancel_work_sync(sc); | 2700 | sony_cancel_work_sync(sc); |
| 2638 | kfree(sc->output_report_dmabuf); | 2701 | kfree(sc->output_report_dmabuf); |
| 2639 | sony_remove_dev_list(sc); | 2702 | sony_remove_dev_list(sc); |
| @@ -2675,13 +2738,13 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) · 35 unmodified lines |
| 2675 | else if (sc->quirks & SIXAXIS_CONTROLLER) | 2738 | else if (sc->quirks & SIXAXIS_CONTROLLER) |
| 2676 | connect_mask |= HID_CONNECT_HIDDEV_FORCE; | 2739 | connect_mask |= HID_CONNECT_HIDDEV_FORCE; |
| 2677 | | 2740 | |
| 2678 | /* Patch the hw version on DS4 compatible devices, so applications can | 2741 | /* Patch the hw version on DS3/4 compatible devices, so applications can |
| 2679 | * distinguish between the default HID mappings and the mappings defined | 2742 | * distinguish between the default HID mappings and the mappings defined |
| 2680 | * by the Linux game controller spec. This is important for the SDL2 | 2743 | * by the Linux game controller spec. This is important for the SDL2 |
| 2681 | * library, which has a game controller database, which uses device ids | 2744 | * library, which has a game controller database, which uses device ids |
| 2682 | * in combination with version as a key. | 2745 | * in combination with version as a key. |
| 2683 | */ | 2746 | */ |
| 2684 | if (sc->quirks & DUALSHOCK4_CONTROLLER) | 2747 | if (sc->quirks & (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER)) |
| 2685 | hdev->version |= 0x8000; | 2748 | hdev->version |= 0x8000; |
| 2686 | | 2749 | |
| 2687 | ret = hid_hw_start(hdev, connect_mask); | 2750 | ret = hid_hw_start(hdev, connect_mask); |
| @@ -2721,6 +2784,12 @@ static void sony_remove(struct hid_device *hdev) · 33 unmodified lines |
| 2721 | if (sc->touchpad) | 2784 | if (sc->touchpad) |
| 2722 | sony_unregister_touchpad(sc); | 2785 | sony_unregister_touchpad(sc); |
| 2723 | | 2786 | |
| | 2787 | if (sc->sensor_dev) |
| | 2788 | sony_unregister_sensors(sc); |
| | 2789 | |
| | 2790 | if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) |
| | 2791 | device_remove_file(&sc->hdev->dev, &dev_attr_bt_poll_interval); |
| | 2792 | |
| 2724 | sony_cancel_work_sync(sc); | 2793 | sony_cancel_work_sync(sc); |
| 2725 | | 2794 | |
| 2726 | kfree(sc->output_report_dmabuf); | 2795 | kfree(sc->output_report_dmabuf); |
| @@ -2736,47 +2805,32 @@ static void sony_remove(struct hid_device *hdev) · 9 unmodified lines |
| 2736 | | 2805 | |
| 2737 | static int sony_suspend(struct hid_device *hdev, pm_message_t message) | 2806 | static int sony_suspend(struct hid_device *hdev, pm_message_t message) |
| 2738 | { | 2807 | { |
| 2739 | /* | | |
| 2740 | * On suspend save the current LED state, | | |
| 2741 | * stop running force-feedback and blank the LEDS. | | |
| 2742 | */ | | |
| 2743 | if (SONY_LED_SUPPORT || SONY_FF_SUPPORT) { | | |
| 2744 | struct sony_sc *sc = hid_get_drvdata(hdev); | | |
| 2745 | | | |
| 2746 | #ifdef CONFIG_SONY_FF | 2808 | #ifdef CONFIG_SONY_FF |
| 2747 | sc->left = sc->right = 0; | | |
| 2748 | #endif | | |
| 2749 | | 2809 | |
| 2750 | memcpy(sc->resume_led_state, sc->led_state, | 2810 | /* On suspend stop any running force-feedback events */ |
| 2751 | sizeof(sc->resume_led_state)); | 2811 | if (SONY_FF_SUPPORT) { |
| 2752 | memset(sc->led_state, 0, sizeof(sc->led_state)); | 2812 | struct sony_sc *sc = hid_get_drvdata(hdev); |
| 2753 | | 2813 | |
| | 2814 | sc->left = sc->right = 0; |
| 2754 | sony_send_output_report(sc); | 2815 | sony_send_output_report(sc); |
| 2755 | } | 2816 | } |
| 2756 | | 2817 | |
| | 2818 | #endif |
| 2757 | return 0; | 2819 | return 0; |
| 2758 | } | 2820 | } |
| 2759 | | 2821 | |
| 2760 | static int sony_resume(struct hid_device *hdev) | 2822 | static int sony_resume(struct hid_device *hdev) |
| 2761 | { | 2823 | { |
| 2762 | /* Restore the state of controller LEDs on resume */ | 2824 | struct sony_sc *sc = hid_get_drvdata(hdev); |
| 2763 | if (SONY_LED_SUPPORT) { | | |
| 2764 | struct sony_sc *sc = hid_get_drvdata(hdev); | | |
| 2765 | | | |
| 2766 | memcpy(sc->led_state, sc->resume_led_state, | | |
| 2767 | sizeof(sc->led_state)); | | |
| 2768 | | | |
| 2769 | /* | | |
| 2770 | * The Sixaxis and navigation controllers on USB need to be | | |
| 2771 | * reinitialized on resume or they won't behave properly. | | |
| 2772 | */ | | |
| 2773 | if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || | | |
| 2774 | (sc->quirks & NAVIGATION_CONTROLLER_USB)) { | | |
| 2775 | sixaxis_set_operational_usb(sc->hdev); | | |
| 2776 | sc->defer_initialization = 1; | | |
| 2777 | } | | |
| 2778 | | 2825 | |
| 2779 | sony_set_leds(sc); | 2826 | /* |
| | 2827 | * The Sixaxis and navigation controllers on USB need to be |
| | 2828 | * reinitialized on resume or they won't behave properly. |
| | 2829 | */ |
| | 2830 | if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || |
| | 2831 | (sc->quirks & NAVIGATION_CONTROLLER_USB)) { |
| | 2832 | sixaxis_set_operational_usb(sc->hdev); |
| | 2833 | sc->defer_initialization = 1; |
| 2780 | } | 2834 | } |
| 2781 | | 2835 | |
| 2782 | return 0; | 2836 | return 0; |
| @@ -2828,7 +2882,7 @@ static const struct hid_device_id sony_devices[] = { · 45 unmodified lines |
| 2828 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2), | 2882 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2), |
| 2829 | .driver_data = DUALSHOCK4_CONTROLLER_BT }, | 2883 | .driver_data = DUALSHOCK4_CONTROLLER_BT }, |
| 2830 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE), | 2884 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE), |
| 2831 | .driver_data = DUALSHOCK4_CONTROLLER_USB }, | 2885 | .driver_data = DUALSHOCK4_DONGLE }, |
| 2832 | /* Nyko Core Controller for PS3 */ | 2886 | /* Nyko Core Controller for PS3 */ |
| 2833 | { HID_USB_DEVICE(USB_VENDOR_ID_SINO_LITE, USB_DEVICE_ID_SINO_LITE_CONTROLLER), | 2887 | { HID_USB_DEVICE(USB_VENDOR_ID_SINO_LITE, USB_DEVICE_ID_SINO_LITE_CONTROLLER), |
| 2834 | .driver_data = SIXAXIS_CONTROLLER_USB | SINO_LITE_CONTROLLER }, | 2888 | .driver_data = SIXAXIS_CONTROLLER_USB | SINO_LITE_CONTROLLER }, |