• Home
  • Raw
  • Download

Lines Matching +full:controller +full:- +full:data

2  * X-Box gamepad driver
4 * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de>
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 * - information from http://euc.jp/periphs/xbox-controller.ja.html
31 * - the iForce driver drivers/char/joystick/iforce.c
32 * - the skeleton-driver drivers/usb/usb-skeleton.c
33 * - Xbox 360 information http://www.free60.org/wiki/Gamepad
34 * - Xbox One information https://github.com/quantus/xbox-one-controller-protocol
37 * - ITO Takayuki for providing essential xpad information on his website
38 * - Vojtech Pavlik - iforce driver / input subsystem
39 * - Greg Kroah-Hartman - usb-skeleton driver
40 * - XBOX Linux project - extra USB id's
41 * - Pekka Pöyry (quantus) - Xbox One controller reverse engineering
44 * - fine tune axes (especially trigger axes)
45 * - fix "analog" buttons (reported as digital now)
46 * - get rumble working
47 * - need USB IDs for other dance pads
51 * 2002-06-27 - 0.0.1 : first version, just said "XBOX HID controller"
53 * 2002-07-02 - 0.0.2 : basic working version
54 * - all axes and 9 of the 10 buttons work (german InterAct device)
55 * - the black button does not work
57 * 2002-07-14 - 0.0.3 : rework by Vojtech Pavlik
58 * - indentation fixes
59 * - usb + input init sequence fixes
61 * 2002-07-16 - 0.0.4 : minor changes, merge with Vojtech's v0.0.3
62 * - verified the lack of HID and report descriptors
63 * - verified that ALL buttons WORK
64 * - fixed d-pad to axes mapping
66 * 2002-07-17 - 0.0.5 : simplified d-pad handling
68 * 2004-10-02 - 0.0.6 : DDR pad support
69 * - borrowed from the XBOX linux kernel
70 * - USB id's for commonly used dance pads are present
71 * - dance pads will map D-PAD to buttons, not axes
72 * - pass the module paramater 'dpad_to_buttons' to force
73 * the D-PAD to map to buttons if your pad is not detected
90 * xbox d-pads should map to buttons, as is required for DDR pads
107 MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads");
128 { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 },
131 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
134 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
135 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
136 { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX },
137 { 0x045e, 0x0288, "Microsoft Xbox Controller S v2", 0, XTYPE_XBOX },
138 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
139 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
140 { 0x045e, 0x028f, "Microsoft X-Box 360 pad v2", 0, XTYPE_XBOX360 },
142 { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
143 { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
144 { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE },
145 { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE },
150 { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
151 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
152 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
155 { 0x056e, 0x2004, "Elecom JC-U3613M", 0, XTYPE_XBOX360 },
156 { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX },
157 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
158 { 0x05fe, 0x3030, "Chic Controller", 0, XTYPE_XBOX },
159 { 0x05fe, 0x3031, "Chic Controller", 0, XTYPE_XBOX },
165 { 0x0738, 0x4506, "Mad Catz 4506 Wireless Controller", 0, XTYPE_XBOX },
173 { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", 0, XTYPE_XBOX },
174 { 0x0738, 0x4586, "Mad Catz MicroCon Wireless Controller", 0, XTYPE_XBOX },
177 { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
179 { 0x0738, 0x4726, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
182 …{ 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX…
189 { 0x0738, 0xb726, "Mad Catz Xbox controller - MW2", 0, XTYPE_XBOX360 },
192 { 0x0738, 0xcb02, "Saitek Cyborg Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
193 { 0x0738, 0xcb03, "Saitek P3200 Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
198 { 0x0c12, 0x8801, "Nyko Xbox Controller", 0, XTYPE_XBOX },
199 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
201 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX },
202 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
203 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX },
205 { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX },
207 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX },
209 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX },
210 { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX },
211 { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX },
212 { 0x0e6f, 0x0008, "After Glow Pro Controller", 0, XTYPE_XBOX },
215 { 0x0e6f, 0x011f, "Rock Candy Gamepad Wired Controller", 0, XTYPE_XBOX360 },
216 { 0x0e6f, 0x0131, "PDP EA Sports Controller", 0, XTYPE_XBOX360 },
217 { 0x0e6f, 0x0133, "Xbox 360 Wired Controller", 0, XTYPE_XBOX360 },
218 { 0x0e6f, 0x0139, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
219 { 0x0e6f, 0x013a, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
220 { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE },
221 { 0x0e6f, 0x0147, "PDP Marvel Xbox One Controller", 0, XTYPE_XBOXONE },
223 { 0x0e6f, 0x0161, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
224 { 0x0e6f, 0x0162, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
225 { 0x0e6f, 0x0163, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
228 { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
232 { 0x0e6f, 0x02ab, "PDP Controller for Xbox One", 0, XTYPE_XBOXONE },
233 { 0x0e6f, 0x02a4, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
234 { 0x0e6f, 0x02a6, "PDP Wired Controller for Xbox One - Camo Series", 0, XTYPE_XBOXONE },
235 { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
237 { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
239 { 0x0e6f, 0x0501, "PDP Xbox 360 Controller", 0, XTYPE_XBOX360 },
252 { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
253 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
254 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX },
257 { 0x11c9, 0x55f0, "Nacon GC-100XF", 0, XTYPE_XBOX360 },
262 { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 },
264 { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 },
265 { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
270 { 0x15e4, 0x3f0a, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
271 { 0x15e4, 0x3f10, "Batarang Xbox 360 controller", 0, XTYPE_XBOX360 },
272 { 0x162e, 0xbeef, "Joytech Neo-Se Take2", 0, XTYPE_XBOX360 },
279 { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
283 { 0x1bad, 0xf023, "MLG Pro Circuit Controller (Xbox)", 0, XTYPE_XBOX360 },
293 …{ 0x1bad, 0xf03d, "Street Fighter IV Arcade Stick TE - Chun Li", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XB…
304 { 0x1bad, 0xf900, "Harmonix Xbox 360 Controller", 0, XTYPE_XBOX360 },
305 { 0x1bad, 0xf901, "Gamestop Xbox 360 Controller", 0, XTYPE_XBOX360 },
306 { 0x1bad, 0xf903, "Tron Xbox 360 controller", 0, XTYPE_XBOX360 },
313 { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 },
314 { 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
315 { 0x24c6, 0x530a, "Xbox 360 Pro EX Controller", 0, XTYPE_XBOX360 },
317 { 0x24c6, 0x5397, "FUS1ON Tournament Controller", 0, XTYPE_XBOX360 },
318 { 0x24c6, 0x541a, "PowerA Xbox One Mini Wired Controller", 0, XTYPE_XBOXONE },
320 { 0x24c6, 0x543a, "PowerA Xbox One wired controller", 0, XTYPE_XBOXONE },
322 { 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA", 0, XTYPE_XBOX360 },
326 { 0x24c6, 0x550d, "Hori GEM Xbox controller", 0, XTYPE_XBOX360 },
328 { 0x24c6, 0x551a, "PowerA FUSION Pro Controller", 0, XTYPE_XBOXONE },
329 { 0x24c6, 0x561a, "PowerA FUSION Controller", 0, XTYPE_XBOXONE },
331 { 0x24c6, 0x5b02, "Thrustmaster, Inc. GPX Controller", 0, XTYPE_XBOX360 },
336 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
337 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
344 -1 /* terminating entry */
350 -1 /* terminating entry */
355 BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, /* d-pad left, right */
356 BTN_TRIGGER_HAPPY3, BTN_TRIGGER_HAPPY4, /* d-pad up, down */
357 -1 /* terminating entry */
363 -1
366 static const signed short xpad360_btn[] = { /* buttons for x360 controller */
369 -1
375 -1 /* terminating entry */
380 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */
381 -1 /* terminating entry */
387 -1
391 * Xbox 360 has a vendor-specific class, so we cannot match it with only
406 /* The Xbox One controller uses subclass 71 and protocol 208. */
417 { USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */
418 XPAD_XBOX360_VENDOR(0x0079), /* GPD Win 2 Controller */
419 XPAD_XBOX360_VENDOR(0x044f), /* Thrustmaster X-Box 360 controllers */
420 XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */
421 XPAD_XBOXONE_VENDOR(0x045e), /* Microsoft X-Box One controllers */
422 XPAD_XBOX360_VENDOR(0x046d), /* Logitech X-Box 360 style controllers */
423 XPAD_XBOX360_VENDOR(0x056e), /* Elecom JC-U3613M */
425 XPAD_XBOX360_VENDOR(0x0738), /* Mad Catz X-Box 360 controllers */
429 XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */
430 XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f X-Box One controllers */
435 XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */
436 XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */
440 XPAD_XBOX360_VENDOR(0x15e4), /* Numark X-Box 360 controllers */
441 XPAD_XBOX360_VENDOR(0x162e), /* Joytech X-Box 360 controllers */
454 const u8 *data; member
462 .data = (_data), \
478 * initialize the controller that was previously used in
556 u8 data[XPAD_PKT_LEN]; member
578 unsigned char *idata; /* input data */
585 unsigned char *odata; /* output data */
599 int mapping; /* map d-pad to buttons or to axes */
613 * Completes a request by converting the data into events for the
617 * http://euc.jp/periphs/xbox-controller.ja.html
619 static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) in xpad_process_packet() argument
621 struct input_dev *dev = xpad->dev; in xpad_process_packet()
623 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_process_packet()
626 (__s16) le16_to_cpup((__le16 *)(data + 12))); in xpad_process_packet()
628 ~(__s16) le16_to_cpup((__le16 *)(data + 14))); in xpad_process_packet()
632 (__s16) le16_to_cpup((__le16 *)(data + 16))); in xpad_process_packet()
634 ~(__s16) le16_to_cpup((__le16 *)(data + 18))); in xpad_process_packet()
638 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_process_packet()
639 input_report_key(dev, BTN_TL2, data[10]); in xpad_process_packet()
640 input_report_key(dev, BTN_TR2, data[11]); in xpad_process_packet()
642 input_report_abs(dev, ABS_Z, data[10]); in xpad_process_packet()
643 input_report_abs(dev, ABS_RZ, data[11]); in xpad_process_packet()
647 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_process_packet()
649 input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); in xpad_process_packet()
650 input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); in xpad_process_packet()
651 input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); in xpad_process_packet()
652 input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); in xpad_process_packet()
655 !!(data[2] & 0x08) - !!(data[2] & 0x04)); in xpad_process_packet()
657 !!(data[2] & 0x02) - !!(data[2] & 0x01)); in xpad_process_packet()
661 input_report_key(dev, BTN_START, data[2] & 0x10); in xpad_process_packet()
662 input_report_key(dev, BTN_SELECT, data[2] & 0x20); in xpad_process_packet()
663 input_report_key(dev, BTN_THUMBL, data[2] & 0x40); in xpad_process_packet()
664 input_report_key(dev, BTN_THUMBR, data[2] & 0x80); in xpad_process_packet()
667 input_report_key(dev, BTN_A, data[4]); in xpad_process_packet()
668 input_report_key(dev, BTN_B, data[5]); in xpad_process_packet()
669 input_report_key(dev, BTN_X, data[6]); in xpad_process_packet()
670 input_report_key(dev, BTN_Y, data[7]); in xpad_process_packet()
673 input_report_key(dev, BTN_C, data[8]); in xpad_process_packet()
674 input_report_key(dev, BTN_Z, data[9]); in xpad_process_packet()
682 * Completes a request by converting the data into events for the
683 * input subsystem. It is version for xbox 360 controller
690 u16 cmd, unsigned char *data) in xpad360_process_packet() argument
692 /* valid pad data */ in xpad360_process_packet()
693 if (data[0] != 0x00) in xpad360_process_packet()
697 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad360_process_packet()
699 input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); in xpad360_process_packet()
700 input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); in xpad360_process_packet()
701 input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); in xpad360_process_packet()
702 input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); in xpad360_process_packet()
711 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad360_process_packet()
712 xpad->xtype == XTYPE_XBOX360W) { in xpad360_process_packet()
714 !!(data[2] & 0x08) - !!(data[2] & 0x04)); in xpad360_process_packet()
716 !!(data[2] & 0x02) - !!(data[2] & 0x01)); in xpad360_process_packet()
720 input_report_key(dev, BTN_START, data[2] & 0x10); in xpad360_process_packet()
721 input_report_key(dev, BTN_SELECT, data[2] & 0x20); in xpad360_process_packet()
724 input_report_key(dev, BTN_THUMBL, data[2] & 0x40); in xpad360_process_packet()
725 input_report_key(dev, BTN_THUMBR, data[2] & 0x80); in xpad360_process_packet()
728 input_report_key(dev, BTN_A, data[3] & 0x10); in xpad360_process_packet()
729 input_report_key(dev, BTN_B, data[3] & 0x20); in xpad360_process_packet()
730 input_report_key(dev, BTN_X, data[3] & 0x40); in xpad360_process_packet()
731 input_report_key(dev, BTN_Y, data[3] & 0x80); in xpad360_process_packet()
732 input_report_key(dev, BTN_TL, data[3] & 0x01); in xpad360_process_packet()
733 input_report_key(dev, BTN_TR, data[3] & 0x02); in xpad360_process_packet()
734 input_report_key(dev, BTN_MODE, data[3] & 0x04); in xpad360_process_packet()
736 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad360_process_packet()
739 (__s16) le16_to_cpup((__le16 *)(data + 6))); in xpad360_process_packet()
741 ~(__s16) le16_to_cpup((__le16 *)(data + 8))); in xpad360_process_packet()
745 (__s16) le16_to_cpup((__le16 *)(data + 10))); in xpad360_process_packet()
747 ~(__s16) le16_to_cpup((__le16 *)(data + 12))); in xpad360_process_packet()
751 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad360_process_packet()
752 input_report_key(dev, BTN_TL2, data[4]); in xpad360_process_packet()
753 input_report_key(dev, BTN_TR2, data[5]); in xpad360_process_packet()
755 input_report_abs(dev, ABS_Z, data[4]); in xpad360_process_packet()
756 input_report_abs(dev, ABS_RZ, data[5]); in xpad360_process_packet()
767 if (xpad->pad_present) { in xpad_presence_work()
771 dev_err(&xpad->dev->dev, in xpad_presence_work()
774 rcu_assign_pointer(xpad->x360w_dev, xpad->dev); in xpad_presence_work()
777 RCU_INIT_POINTER(xpad->x360w_dev, NULL); in xpad_presence_work()
790 * Completes a request by converting the data into events for the
791 * input subsystem. It is version for xbox 360 wireless controller.
794 * 00.1 - Status change: The controller or headset has connected/disconnected
796 * 01.7 - Controller present
797 * 01.6 - Headset present
798 * 01.1 - Pad state (Bytes 4+) valid
801 static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) in xpad360w_process_packet() argument
807 if (data[0] & 0x08) { in xpad360w_process_packet()
808 present = (data[1] & 0x80) != 0; in xpad360w_process_packet()
810 if (xpad->pad_present != present) { in xpad360w_process_packet()
811 xpad->pad_present = present; in xpad360w_process_packet()
812 schedule_work(&xpad->work); in xpad360w_process_packet()
816 /* Valid pad data */ in xpad360w_process_packet()
817 if (data[1] != 0x1) in xpad360w_process_packet()
821 dev = rcu_dereference(xpad->x360w_dev); in xpad360w_process_packet()
823 xpad360_process_packet(xpad, dev, cmd, &data[4]); in xpad360w_process_packet()
830 * Completes a request by converting the data into events for the
831 * input subsystem. This version is for the Xbox One controller.
836 static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) in xpadone_process_packet() argument
838 struct input_dev *dev = xpad->dev; in xpadone_process_packet()
841 if (data[0] == 0X07) { in xpadone_process_packet()
843 * The Xbox One S controller requires these reports to be in xpadone_process_packet()
847 if (data[1] == 0x30) in xpadone_process_packet()
848 xpadone_ack_mode_report(xpad, data[2]); in xpadone_process_packet()
850 input_report_key(dev, BTN_MODE, data[4] & 0x01); in xpadone_process_packet()
855 else if (data[0] != 0X20) in xpadone_process_packet()
859 input_report_key(dev, BTN_START, data[4] & 0x04); in xpadone_process_packet()
860 input_report_key(dev, BTN_SELECT, data[4] & 0x08); in xpadone_process_packet()
863 input_report_key(dev, BTN_A, data[4] & 0x10); in xpadone_process_packet()
864 input_report_key(dev, BTN_B, data[4] & 0x20); in xpadone_process_packet()
865 input_report_key(dev, BTN_X, data[4] & 0x40); in xpadone_process_packet()
866 input_report_key(dev, BTN_Y, data[4] & 0x80); in xpadone_process_packet()
869 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpadone_process_packet()
871 input_report_key(dev, BTN_TRIGGER_HAPPY1, data[5] & 0x04); in xpadone_process_packet()
872 input_report_key(dev, BTN_TRIGGER_HAPPY2, data[5] & 0x08); in xpadone_process_packet()
873 input_report_key(dev, BTN_TRIGGER_HAPPY3, data[5] & 0x01); in xpadone_process_packet()
874 input_report_key(dev, BTN_TRIGGER_HAPPY4, data[5] & 0x02); in xpadone_process_packet()
877 !!(data[5] & 0x08) - !!(data[5] & 0x04)); in xpadone_process_packet()
879 !!(data[5] & 0x02) - !!(data[5] & 0x01)); in xpadone_process_packet()
883 input_report_key(dev, BTN_TL, data[5] & 0x10); in xpadone_process_packet()
884 input_report_key(dev, BTN_TR, data[5] & 0x20); in xpadone_process_packet()
887 input_report_key(dev, BTN_THUMBL, data[5] & 0x40); in xpadone_process_packet()
888 input_report_key(dev, BTN_THUMBR, data[5] & 0x80); in xpadone_process_packet()
890 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpadone_process_packet()
893 (__s16) le16_to_cpup((__le16 *)(data + 10))); in xpadone_process_packet()
895 ~(__s16) le16_to_cpup((__le16 *)(data + 12))); in xpadone_process_packet()
899 (__s16) le16_to_cpup((__le16 *)(data + 14))); in xpadone_process_packet()
901 ~(__s16) le16_to_cpup((__le16 *)(data + 16))); in xpadone_process_packet()
905 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpadone_process_packet()
907 (__u16) le16_to_cpup((__le16 *)(data + 6))); in xpadone_process_packet()
909 (__u16) le16_to_cpup((__le16 *)(data + 8))); in xpadone_process_packet()
912 (__u16) le16_to_cpup((__le16 *)(data + 6))); in xpadone_process_packet()
914 (__u16) le16_to_cpup((__le16 *)(data + 8))); in xpadone_process_packet()
922 struct usb_xpad *xpad = urb->context; in xpad_irq_in()
923 struct device *dev = &xpad->intf->dev; in xpad_irq_in()
926 status = urb->status; in xpad_irq_in()
932 case -ECONNRESET: in xpad_irq_in()
933 case -ENOENT: in xpad_irq_in()
934 case -ESHUTDOWN: in xpad_irq_in()
936 dev_dbg(dev, "%s - urb shutting down with status: %d\n", in xpad_irq_in()
940 dev_dbg(dev, "%s - nonzero urb status received: %d\n", in xpad_irq_in()
945 switch (xpad->xtype) { in xpad_irq_in()
947 xpad360_process_packet(xpad, xpad->dev, 0, xpad->idata); in xpad_irq_in()
950 xpad360w_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
953 xpadone_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
956 xpad_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
962 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", in xpad_irq_in()
966 /* Callers must hold xpad->odata_lock spinlock */
971 if (xpad->xtype != XTYPE_XBOXONE) in xpad_prepare_next_init_packet()
975 while (xpad->init_seq < ARRAY_SIZE(xboxone_init_packets)) { in xpad_prepare_next_init_packet()
976 init_packet = &xboxone_init_packets[xpad->init_seq++]; in xpad_prepare_next_init_packet()
978 if (init_packet->idVendor != 0 && in xpad_prepare_next_init_packet()
979 init_packet->idVendor != xpad->dev->id.vendor) in xpad_prepare_next_init_packet()
982 if (init_packet->idProduct != 0 && in xpad_prepare_next_init_packet()
983 init_packet->idProduct != xpad->dev->id.product) in xpad_prepare_next_init_packet()
987 memcpy(xpad->odata, init_packet->data, init_packet->len); in xpad_prepare_next_init_packet()
988 xpad->irq_out->transfer_buffer_length = init_packet->len; in xpad_prepare_next_init_packet()
991 xpad->odata[2] = xpad->odata_serial++; in xpad_prepare_next_init_packet()
998 /* Callers must hold xpad->odata_lock spinlock */
1009 if (++xpad->last_out_packet >= XPAD_NUM_OUT_PACKETS) in xpad_prepare_next_out_packet()
1010 xpad->last_out_packet = 0; in xpad_prepare_next_out_packet()
1012 pkt = &xpad->out_packets[xpad->last_out_packet]; in xpad_prepare_next_out_packet()
1013 if (pkt->pending) { in xpad_prepare_next_out_packet()
1014 dev_dbg(&xpad->intf->dev, in xpad_prepare_next_out_packet()
1015 "%s - found pending output packet %d\n", in xpad_prepare_next_out_packet()
1016 __func__, xpad->last_out_packet); in xpad_prepare_next_out_packet()
1023 memcpy(xpad->odata, packet->data, packet->len); in xpad_prepare_next_out_packet()
1024 xpad->irq_out->transfer_buffer_length = packet->len; in xpad_prepare_next_out_packet()
1025 packet->pending = false; in xpad_prepare_next_out_packet()
1032 /* Callers must hold xpad->odata_lock spinlock */
1037 if (!xpad->irq_out_active && xpad_prepare_next_out_packet(xpad)) { in xpad_try_sending_next_out_packet()
1038 usb_anchor_urb(xpad->irq_out, &xpad->irq_out_anchor); in xpad_try_sending_next_out_packet()
1039 error = usb_submit_urb(xpad->irq_out, GFP_ATOMIC); in xpad_try_sending_next_out_packet()
1041 dev_err(&xpad->intf->dev, in xpad_try_sending_next_out_packet()
1042 "%s - usb_submit_urb failed with result %d\n", in xpad_try_sending_next_out_packet()
1044 usb_unanchor_urb(xpad->irq_out); in xpad_try_sending_next_out_packet()
1045 return -EIO; in xpad_try_sending_next_out_packet()
1048 xpad->irq_out_active = true; in xpad_try_sending_next_out_packet()
1056 struct usb_xpad *xpad = urb->context; in xpad_irq_out()
1057 struct device *dev = &xpad->intf->dev; in xpad_irq_out()
1058 int status = urb->status; in xpad_irq_out()
1062 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_irq_out()
1067 xpad->irq_out_active = xpad_prepare_next_out_packet(xpad); in xpad_irq_out()
1070 case -ECONNRESET: in xpad_irq_out()
1071 case -ENOENT: in xpad_irq_out()
1072 case -ESHUTDOWN: in xpad_irq_out()
1074 dev_dbg(dev, "%s - urb shutting down with status: %d\n", in xpad_irq_out()
1076 xpad->irq_out_active = false; in xpad_irq_out()
1080 dev_dbg(dev, "%s - nonzero urb status received: %d\n", in xpad_irq_out()
1085 if (xpad->irq_out_active) { in xpad_irq_out()
1086 usb_anchor_urb(urb, &xpad->irq_out_anchor); in xpad_irq_out()
1090 "%s - usb_submit_urb failed with result %d\n", in xpad_irq_out()
1093 xpad->irq_out_active = false; in xpad_irq_out()
1097 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_irq_out()
1105 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_output()
1108 init_usb_anchor(&xpad->irq_out_anchor); in xpad_init_output()
1110 xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_init_output()
1111 GFP_KERNEL, &xpad->odata_dma); in xpad_init_output()
1112 if (!xpad->odata) in xpad_init_output()
1113 return -ENOMEM; in xpad_init_output()
1115 spin_lock_init(&xpad->odata_lock); in xpad_init_output()
1117 xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); in xpad_init_output()
1118 if (!xpad->irq_out) { in xpad_init_output()
1119 error = -ENOMEM; in xpad_init_output()
1123 usb_fill_int_urb(xpad->irq_out, xpad->udev, in xpad_init_output()
1124 usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), in xpad_init_output()
1125 xpad->odata, XPAD_PKT_LEN, in xpad_init_output()
1126 xpad_irq_out, xpad, ep_irq_out->bInterval); in xpad_init_output()
1127 xpad->irq_out->transfer_dma = xpad->odata_dma; in xpad_init_output()
1128 xpad->irq_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_init_output()
1133 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); in xpad_init_output()
1139 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_stop_output()
1140 if (!usb_wait_anchor_empty_timeout(&xpad->irq_out_anchor, in xpad_stop_output()
1142 dev_warn(&xpad->intf->dev, in xpad_stop_output()
1144 usb_kill_anchored_urbs(&xpad->irq_out_anchor); in xpad_stop_output()
1151 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_deinit_output()
1152 usb_free_urb(xpad->irq_out); in xpad_deinit_output()
1153 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_deinit_output()
1154 xpad->odata, xpad->odata_dma); in xpad_deinit_output()
1161 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpad_inquiry_pad_presence()
1165 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_inquiry_pad_presence()
1167 packet->data[0] = 0x08; in xpad_inquiry_pad_presence()
1168 packet->data[1] = 0x00; in xpad_inquiry_pad_presence()
1169 packet->data[2] = 0x0F; in xpad_inquiry_pad_presence()
1170 packet->data[3] = 0xC0; in xpad_inquiry_pad_presence()
1171 packet->data[4] = 0x00; in xpad_inquiry_pad_presence()
1172 packet->data[5] = 0x00; in xpad_inquiry_pad_presence()
1173 packet->data[6] = 0x00; in xpad_inquiry_pad_presence()
1174 packet->data[7] = 0x00; in xpad_inquiry_pad_presence()
1175 packet->data[8] = 0x00; in xpad_inquiry_pad_presence()
1176 packet->data[9] = 0x00; in xpad_inquiry_pad_presence()
1177 packet->data[10] = 0x00; in xpad_inquiry_pad_presence()
1178 packet->data[11] = 0x00; in xpad_inquiry_pad_presence()
1179 packet->len = 12; in xpad_inquiry_pad_presence()
1180 packet->pending = true; in xpad_inquiry_pad_presence()
1183 xpad->last_out_packet = -1; in xpad_inquiry_pad_presence()
1186 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_inquiry_pad_presence()
1196 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_start_xbox_one()
1203 xpad->init_seq = 0; in xpad_start_xbox_one()
1206 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_start_xbox_one()
1215 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpadone_ack_mode_report()
1221 spin_lock_irqsave(&xpad->odata_lock, flags); in xpadone_ack_mode_report()
1223 packet->len = sizeof(mode_report_ack); in xpadone_ack_mode_report()
1224 memcpy(packet->data, mode_report_ack, packet->len); in xpadone_ack_mode_report()
1225 packet->data[2] = seq_num; in xpadone_ack_mode_report()
1226 packet->pending = true; in xpadone_ack_mode_report()
1229 xpad->last_out_packet = -1; in xpadone_ack_mode_report()
1232 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpadone_ack_mode_report()
1236 static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) in xpad_play_effect() argument
1239 struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_FF_IDX]; in xpad_play_effect()
1245 if (effect->type != FF_RUMBLE) in xpad_play_effect()
1248 strong = effect->u.rumble.strong_magnitude; in xpad_play_effect()
1249 weak = effect->u.rumble.weak_magnitude; in xpad_play_effect()
1251 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_play_effect()
1253 switch (xpad->xtype) { in xpad_play_effect()
1255 packet->data[0] = 0x00; in xpad_play_effect()
1256 packet->data[1] = 0x06; in xpad_play_effect()
1257 packet->data[2] = 0x00; in xpad_play_effect()
1258 packet->data[3] = strong / 256; /* left actuator */ in xpad_play_effect()
1259 packet->data[4] = 0x00; in xpad_play_effect()
1260 packet->data[5] = weak / 256; /* right actuator */ in xpad_play_effect()
1261 packet->len = 6; in xpad_play_effect()
1262 packet->pending = true; in xpad_play_effect()
1266 packet->data[0] = 0x00; in xpad_play_effect()
1267 packet->data[1] = 0x08; in xpad_play_effect()
1268 packet->data[2] = 0x00; in xpad_play_effect()
1269 packet->data[3] = strong / 256; /* left actuator? */ in xpad_play_effect()
1270 packet->data[4] = weak / 256; /* right actuator? */ in xpad_play_effect()
1271 packet->data[5] = 0x00; in xpad_play_effect()
1272 packet->data[6] = 0x00; in xpad_play_effect()
1273 packet->data[7] = 0x00; in xpad_play_effect()
1274 packet->len = 8; in xpad_play_effect()
1275 packet->pending = true; in xpad_play_effect()
1279 packet->data[0] = 0x00; in xpad_play_effect()
1280 packet->data[1] = 0x01; in xpad_play_effect()
1281 packet->data[2] = 0x0F; in xpad_play_effect()
1282 packet->data[3] = 0xC0; in xpad_play_effect()
1283 packet->data[4] = 0x00; in xpad_play_effect()
1284 packet->data[5] = strong / 256; in xpad_play_effect()
1285 packet->data[6] = weak / 256; in xpad_play_effect()
1286 packet->data[7] = 0x00; in xpad_play_effect()
1287 packet->data[8] = 0x00; in xpad_play_effect()
1288 packet->data[9] = 0x00; in xpad_play_effect()
1289 packet->data[10] = 0x00; in xpad_play_effect()
1290 packet->data[11] = 0x00; in xpad_play_effect()
1291 packet->len = 12; in xpad_play_effect()
1292 packet->pending = true; in xpad_play_effect()
1296 packet->data[0] = 0x09; /* activate rumble */ in xpad_play_effect()
1297 packet->data[1] = 0x00; in xpad_play_effect()
1298 packet->data[2] = xpad->odata_serial++; in xpad_play_effect()
1299 packet->data[3] = 0x09; in xpad_play_effect()
1300 packet->data[4] = 0x00; in xpad_play_effect()
1301 packet->data[5] = 0x0F; in xpad_play_effect()
1302 packet->data[6] = 0x00; in xpad_play_effect()
1303 packet->data[7] = 0x00; in xpad_play_effect()
1304 packet->data[8] = strong / 512; /* left actuator */ in xpad_play_effect()
1305 packet->data[9] = weak / 512; /* right actuator */ in xpad_play_effect()
1306 packet->data[10] = 0xFF; /* on period */ in xpad_play_effect()
1307 packet->data[11] = 0x00; /* off period */ in xpad_play_effect()
1308 packet->data[12] = 0xFF; /* repeat count */ in xpad_play_effect()
1309 packet->len = 13; in xpad_play_effect()
1310 packet->pending = true; in xpad_play_effect()
1314 dev_dbg(&xpad->dev->dev, in xpad_play_effect()
1315 "%s - rumble command sent to unsupported xpad type: %d\n", in xpad_play_effect()
1316 __func__, xpad->xtype); in xpad_play_effect()
1317 retval = -EINVAL; in xpad_play_effect()
1324 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_play_effect()
1330 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_ff()
1333 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE); in xpad_init_ff()
1335 return input_ff_create_memless(xpad->dev, NULL, xpad_play_effect); in xpad_init_ff()
1359 * 2: 1/top-left blink, then on
1360 * 3: 2/top-right blink, then on
1361 * 4: 3/bottom-left blink, then on
1362 * 5: 4/bottom-right blink, then on
1363 * 6: 1/top-left on
1364 * 7: 2/top-right on
1365 * 8: 3/bottom-left on
1366 * 9: 4/bottom-right on
1377 &xpad->out_packets[XPAD_OUT_LED_IDX]; in xpad_send_led_command()
1382 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_send_led_command()
1384 switch (xpad->xtype) { in xpad_send_led_command()
1386 packet->data[0] = 0x01; in xpad_send_led_command()
1387 packet->data[1] = 0x03; in xpad_send_led_command()
1388 packet->data[2] = command; in xpad_send_led_command()
1389 packet->len = 3; in xpad_send_led_command()
1390 packet->pending = true; in xpad_send_led_command()
1394 packet->data[0] = 0x00; in xpad_send_led_command()
1395 packet->data[1] = 0x00; in xpad_send_led_command()
1396 packet->data[2] = 0x08; in xpad_send_led_command()
1397 packet->data[3] = 0x40 + command; in xpad_send_led_command()
1398 packet->data[4] = 0x00; in xpad_send_led_command()
1399 packet->data[5] = 0x00; in xpad_send_led_command()
1400 packet->data[6] = 0x00; in xpad_send_led_command()
1401 packet->data[7] = 0x00; in xpad_send_led_command()
1402 packet->data[8] = 0x00; in xpad_send_led_command()
1403 packet->data[9] = 0x00; in xpad_send_led_command()
1404 packet->data[10] = 0x00; in xpad_send_led_command()
1405 packet->data[11] = 0x00; in xpad_send_led_command()
1406 packet->len = 12; in xpad_send_led_command()
1407 packet->pending = true; in xpad_send_led_command()
1413 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_send_led_command()
1422 led_set_brightness(&xpad->led->led_cdev, (xpad->pad_nr % 4) + 2); in xpad_identify_controller()
1431 xpad_send_led_command(xpad_led->xpad, value); in xpad_led_set()
1440 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W) in xpad_led_probe()
1443 xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL); in xpad_led_probe()
1445 return -ENOMEM; in xpad_led_probe()
1447 xpad->pad_nr = ida_simple_get(&xpad_pad_seq, 0, 0, GFP_KERNEL); in xpad_led_probe()
1448 if (xpad->pad_nr < 0) { in xpad_led_probe()
1449 error = xpad->pad_nr; in xpad_led_probe()
1453 snprintf(led->name, sizeof(led->name), "xpad%d", xpad->pad_nr); in xpad_led_probe()
1454 led->xpad = xpad; in xpad_led_probe()
1456 led_cdev = &led->led_cdev; in xpad_led_probe()
1457 led_cdev->name = led->name; in xpad_led_probe()
1458 led_cdev->brightness_set = xpad_led_set; in xpad_led_probe()
1459 led_cdev->flags = LED_CORE_SUSPENDRESUME; in xpad_led_probe()
1461 error = led_classdev_register(&xpad->udev->dev, led_cdev); in xpad_led_probe()
1470 ida_simple_remove(&xpad_pad_seq, xpad->pad_nr); in xpad_led_probe()
1473 xpad->led = NULL; in xpad_led_probe()
1479 struct xpad_led *xpad_led = xpad->led; in xpad_led_disconnect()
1482 led_classdev_unregister(&xpad_led->led_cdev); in xpad_led_disconnect()
1483 ida_simple_remove(&xpad_pad_seq, xpad->pad_nr); in xpad_led_disconnect()
1496 if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) in xpad_start_input()
1497 return -EIO; in xpad_start_input()
1499 if (xpad->xtype == XTYPE_XBOXONE) { in xpad_start_input()
1502 usb_kill_urb(xpad->irq_in); in xpad_start_input()
1512 usb_kill_urb(xpad->irq_in); in xpad_stop_input()
1519 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpad360w_poweroff_controller()
1521 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad360w_poweroff_controller()
1523 packet->data[0] = 0x00; in xpad360w_poweroff_controller()
1524 packet->data[1] = 0x00; in xpad360w_poweroff_controller()
1525 packet->data[2] = 0x08; in xpad360w_poweroff_controller()
1526 packet->data[3] = 0xC0; in xpad360w_poweroff_controller()
1527 packet->data[4] = 0x00; in xpad360w_poweroff_controller()
1528 packet->data[5] = 0x00; in xpad360w_poweroff_controller()
1529 packet->data[6] = 0x00; in xpad360w_poweroff_controller()
1530 packet->data[7] = 0x00; in xpad360w_poweroff_controller()
1531 packet->data[8] = 0x00; in xpad360w_poweroff_controller()
1532 packet->data[9] = 0x00; in xpad360w_poweroff_controller()
1533 packet->data[10] = 0x00; in xpad360w_poweroff_controller()
1534 packet->data[11] = 0x00; in xpad360w_poweroff_controller()
1535 packet->len = 12; in xpad360w_poweroff_controller()
1536 packet->pending = true; in xpad360w_poweroff_controller()
1539 xpad->last_out_packet = -1; in xpad360w_poweroff_controller()
1542 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad360w_poweroff_controller()
1549 error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); in xpad360w_start_input()
1551 return -EIO; in xpad360w_start_input()
1555 * This will force the controller to resend connection packets. in xpad360w_start_input()
1562 usb_kill_urb(xpad->irq_in); in xpad360w_start_input()
1571 usb_kill_urb(xpad->irq_in); in xpad360w_stop_input()
1574 flush_work(&xpad->work); in xpad360w_stop_input()
1600 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128); in xpad_set_up_abs()
1604 if (xpad->xtype == XTYPE_XBOXONE) in xpad_set_up_abs()
1610 case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */ in xpad_set_up_abs()
1611 input_set_abs_params(input_dev, abs, -1, 1, 0, 0); in xpad_set_up_abs()
1621 if (xpad->input_created) { in xpad_deinit_input()
1622 xpad->input_created = false; in xpad_deinit_input()
1624 input_unregister_device(xpad->dev); in xpad_deinit_input()
1635 return -ENOMEM; in xpad_init_input()
1637 xpad->dev = input_dev; in xpad_init_input()
1638 input_dev->name = xpad->name; in xpad_init_input()
1639 input_dev->phys = xpad->phys; in xpad_init_input()
1640 usb_to_input_id(xpad->udev, &input_dev->id); in xpad_init_input()
1642 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_init_input()
1644 input_dev->id.product = 0x02a1; in xpad_init_input()
1647 input_dev->dev.parent = &xpad->intf->dev; in xpad_init_input()
1651 if (xpad->xtype != XTYPE_XBOX360W) { in xpad_init_input()
1652 input_dev->open = xpad_open; in xpad_init_input()
1653 input_dev->close = xpad_close; in xpad_init_input()
1656 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_init_input()
1666 /* set up model-specific ones */ in xpad_init_input()
1667 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W || in xpad_init_input()
1668 xpad->xtype == XTYPE_XBOXONE) { in xpad_init_input()
1676 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_init_input()
1688 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad_init_input()
1689 xpad->xtype == XTYPE_XBOX360W) { in xpad_init_input()
1694 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_init_input()
1711 error = input_register_device(xpad->dev); in xpad_init_input()
1715 xpad->input_created = true; in xpad_init_input()
1734 if (intf->cur_altsetting->desc.bNumEndpoints != 2) in xpad_probe()
1735 return -ENODEV; in xpad_probe()
1738 if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && in xpad_probe()
1739 (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) in xpad_probe()
1745 return -ENOMEM; in xpad_probe()
1747 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); in xpad_probe()
1748 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); in xpad_probe()
1750 xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, in xpad_probe()
1751 GFP_KERNEL, &xpad->idata_dma); in xpad_probe()
1752 if (!xpad->idata) { in xpad_probe()
1753 error = -ENOMEM; in xpad_probe()
1757 xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); in xpad_probe()
1758 if (!xpad->irq_in) { in xpad_probe()
1759 error = -ENOMEM; in xpad_probe()
1763 xpad->udev = udev; in xpad_probe()
1764 xpad->intf = intf; in xpad_probe()
1765 xpad->mapping = xpad_device[i].mapping; in xpad_probe()
1766 xpad->xtype = xpad_device[i].xtype; in xpad_probe()
1767 xpad->name = xpad_device[i].name; in xpad_probe()
1768 INIT_WORK(&xpad->work, xpad_presence_work); in xpad_probe()
1770 if (xpad->xtype == XTYPE_UNKNOWN) { in xpad_probe()
1771 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { in xpad_probe()
1772 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) in xpad_probe()
1773 xpad->xtype = XTYPE_XBOX360W; in xpad_probe()
1774 else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208) in xpad_probe()
1775 xpad->xtype = XTYPE_XBOXONE; in xpad_probe()
1777 xpad->xtype = XTYPE_XBOX360; in xpad_probe()
1779 xpad->xtype = XTYPE_XBOX; in xpad_probe()
1783 xpad->mapping |= MAP_DPAD_TO_BUTTONS; in xpad_probe()
1785 xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; in xpad_probe()
1787 xpad->mapping |= MAP_STICKS_TO_NULL; in xpad_probe()
1790 if (xpad->xtype == XTYPE_XBOXONE && in xpad_probe()
1791 intf->cur_altsetting->desc.bInterfaceNumber != 0) { in xpad_probe()
1793 * The Xbox One controller lists three interfaces all with the in xpad_probe()
1797 error = -ENODEV; in xpad_probe()
1805 &intf->cur_altsetting->endpoint[i].desc; in xpad_probe()
1816 error = -ENODEV; in xpad_probe()
1824 usb_fill_int_urb(xpad->irq_in, udev, in xpad_probe()
1825 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), in xpad_probe()
1826 xpad->idata, XPAD_PKT_LEN, xpad_irq_in, in xpad_probe()
1827 xpad, ep_irq_in->bInterval); in xpad_probe()
1828 xpad->irq_in->transfer_dma = xpad->idata_dma; in xpad_probe()
1829 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_probe()
1833 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_probe()
1838 * exactly the message that a controller has arrived that in xpad_probe()
1851 udev->quirks |= USB_QUIRK_RESET_RESUME; in xpad_probe()
1862 usb_free_urb(xpad->irq_in); in xpad_probe()
1864 usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); in xpad_probe()
1874 if (xpad->xtype == XTYPE_XBOX360W) in xpad_disconnect()
1887 usb_free_urb(xpad->irq_in); in xpad_disconnect()
1888 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_disconnect()
1889 xpad->idata, xpad->idata_dma); in xpad_disconnect()
1899 struct input_dev *input = xpad->dev; in xpad_suspend()
1901 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_suspend()
1904 * they are notified when controller shows up in xpad_suspend()
1915 if (auto_poweroff && xpad->pad_present) in xpad_suspend()
1918 mutex_lock(&input->mutex); in xpad_suspend()
1919 if (input->users) in xpad_suspend()
1921 mutex_unlock(&input->mutex); in xpad_suspend()
1932 struct input_dev *input = xpad->dev; in xpad_resume()
1935 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_resume()
1938 mutex_lock(&input->mutex); in xpad_resume()
1939 if (input->users) { in xpad_resume()
1941 } else if (xpad->xtype == XTYPE_XBOXONE) { in xpad_resume()
1949 mutex_unlock(&input->mutex); in xpad_resume()
1967 MODULE_AUTHOR("Marko Friedemann <mfr@bmx-chemnitz.de>");
1968 MODULE_DESCRIPTION("X-Box pad driver");