Lines Matching +full:10 +full:base +full:- +full:te
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de>
16 * - information from http://euc.jp/periphs/xbox-controller.ja.html
17 * - the iForce driver drivers/char/joystick/iforce.c
18 * - the skeleton-driver drivers/usb/usb-skeleton.c
19 * - Xbox 360 information http://www.free60.org/wiki/Gamepad
20 * - Xbox One information https://github.com/quantus/xbox-one-controller-protocol
23 * - ITO Takayuki for providing essential xpad information on his website
24 * - Vojtech Pavlik - iforce driver / input subsystem
25 * - Greg Kroah-Hartman - usb-skeleton driver
26 * - Xbox Linux project - extra USB IDs
27 * - Pekka Pöyry (quantus) - Xbox One controller reverse-engineering
30 * - fine tune axes (especially trigger axes)
31 * - fix "analog" buttons (reported as digital now)
32 * - get rumble working
33 * - need USB IDs for other dance pads
37 * 2002-06-27 - 0.0.1 : first version, just said "XBOX HID controller"
39 * 2002-07-02 - 0.0.2 : basic working version
40 * - all axes and 9 of the 10 buttons work (german InterAct device)
41 * - the black button does not work
43 * 2002-07-14 - 0.0.3 : rework by Vojtech Pavlik
44 * - indentation fixes
45 * - usb + input init sequence fixes
47 * 2002-07-16 - 0.0.4 : minor changes, merge with Vojtech's v0.0.3
48 * - verified the lack of HID and report descriptors
49 * - verified that ALL buttons WORK
50 * - fixed d-pad to axes mapping
52 * 2002-07-17 - 0.0.5 : simplified d-pad handling
54 * 2004-10-02 - 0.0.6 : DDR pad support
55 * - borrowed from the Xbox Linux kernel
56 * - USB id's for commonly used dance pads are present
57 * - dance pads will map D-PAD to buttons, not axes
58 * - pass the module paramater 'dpad_to_buttons' to force
59 * the D-PAD to map to buttons if your pad is not detected
77 * xbox d-pads should map to buttons, as is required for DDR pads
97 /* Send power-off packet to xpad360w after holding the mode button for this many
110 MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads");
132 { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 },
147 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
148 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
151 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
152 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
153 { 0x045e, 0x028f, "Microsoft X-Box 360 pad v2", 0, XTYPE_XBOX360 },
156 { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
157 { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
158 { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", MAP_PADDLES, XTYPE_XBOXONE },
159 { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE },
161 { 0x045e, 0x0b00, "Microsoft X-Box One Elite 2 pad", MAP_PADDLES, XTYPE_XBOXONE },
162 { 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", MAP_PROFILE_BUTTON, XTYPE_XBOXONE },
172 { 0x056e, 0x2004, "Elecom JC-U3613M", 0, XTYPE_XBOX360 },
174 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
204 { 0x0738, 0x4a01, "Mad Catz FightStick TE 2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
207 { 0x0738, 0xb726, "Mad Catz Xbox controller - MW2", 0, XTYPE_XBOX360 },
210 { 0x0738, 0xcb02, "Saitek Cyborg Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
211 { 0x0738, 0xcb03, "Saitek P3200 Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
213 { 0x0738, 0xf738, "Super SFIV FightStick TE S", 0, XTYPE_XBOX360 },
221 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX },
223 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX },
250 { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
256 { 0x0e6f, 0x02a2, "PDP Wired Controller for Xbox One - Crimson Red", 0, XTYPE_XBOXONE },
257 { 0x0e6f, 0x02a4, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
258 { 0x0e6f, 0x02a6, "PDP Wired Controller for Xbox One - Camo Series", 0, XTYPE_XBOXONE },
262 { 0x0e6f, 0x02ad, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
295 { 0x11c9, 0x55f0, "Nacon GC-100XF", 0, XTYPE_XBOX360 },
302 { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 },
313 { 0x162e, 0xbeef, "Joytech Neo-Se Take2", 0, XTYPE_XBOX360 },
334 { 0x1bad, 0xf038, "Street Fighter IV FightStick TE", 0, XTYPE_XBOX360 },
335 { 0x1bad, 0xf039, "Mad Catz MvC2 TE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
337 …{ 0x1bad, 0xf03d, "Street Fighter IV Arcade Stick TE - Chun Li", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XB…
338 { 0x1bad, 0xf03e, "Mad Catz MLG FightStick TE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
354 { 0x1bad, 0xfd00, "Razer Onza TE", 0, XTYPE_XBOX360 },
362 { 0x20d6, 0x890b, "PowerA MOGA XP-Ultra Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
374 { 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA", 0, XTYPE_XBOX360 },
390 { 0x294b, 0x3303, "Snakebyte GAMEPAD BASE X", 0, XTYPE_XBOXONE },
394 { 0x2dc8, 0x200f, "8BitDo Ultimate 3-mode Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
401 { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE },
402 { 0x2e24, 0x1688, "Hyperkin X91 X-Box One pad", 0, XTYPE_XBOXONE },
412 { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 },
416 { 0x3285, 0x0663, "Nacon Evol-X", 0, XTYPE_XBOXONE },
421 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
422 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
429 -1 /* terminating entry */
435 -1 /* terminating entry */
440 BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, /* d-pad left, right */
441 BTN_TRIGGER_HAPPY3, BTN_TRIGGER_HAPPY4, /* d-pad up, down */
442 -1 /* terminating entry */
448 -1
454 -1
460 -1 /* terminating entry */
465 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */
466 -1 /* terminating entry */
472 -1
479 -1 /* terminating entry */
483 * Xbox 360 has a vendor-specific class, so we cannot match it with only
511 * macros - XPAD_XBOX360_VENDOR and XPAD_XBOXONE_VENDOR.
513 { USB_INTERFACE_INFO('X', 'B', 0) }, /* Xbox USB-IF not-approved class */
522 XPAD_XBOX360_VENDOR(0x046d), /* Logitech Xbox 360-style controllers */
523 XPAD_XBOX360_VENDOR(0x056e), /* Elecom JC-U3613M */
527 XPAD_XBOXONE_VENDOR(0x0738), /* Mad Catz FightStick TE 2 */
530 XPAD_XBOX360_VENDOR(0x0c12), /* Zeroplus X-Box 360 controllers */
531 XPAD_XBOX360_VENDOR(0x0db0), /* Micro Star International X-Box 360 controllers */
570 XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */
571 XPAD_XBOXONE_VENDOR(0x3285), /* Nacon Evol-X */
598 * - https://github.com/xpadneo/gip-dissector/blob/main/src/gip-dissector.lua
599 * - https://github.com/medusalix/xone/blob/master/bus/protocol.c
619 * which is a no-op for N < 128
784 int mapping; /* map d-pad to buttons or to axes */
805 * http://euc.jp/periphs/xbox-controller.ja.html
809 struct input_dev *dev = xpad->dev; in xpad_process_packet()
811 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_process_packet()
826 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_process_packet()
827 input_report_key(dev, BTN_TL2, data[10]); in xpad_process_packet()
830 input_report_abs(dev, ABS_Z, data[10]); in xpad_process_packet()
835 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_process_packet()
843 !!(data[2] & 0x08) - !!(data[2] & 0x04)); in xpad_process_packet()
845 !!(data[2] & 0x02) - !!(data[2] & 0x01)); in xpad_process_packet()
886 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad360_process_packet()
900 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad360_process_packet()
901 xpad->xtype == XTYPE_XBOX360W) { in xpad360_process_packet()
903 !!(data[2] & 0x08) - !!(data[2] & 0x04)); in xpad360_process_packet()
905 !!(data[2] & 0x02) - !!(data[2] & 0x01)); in xpad360_process_packet()
925 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad360_process_packet()
934 (__s16) le16_to_cpup((__le16 *)(data + 10))); in xpad360_process_packet()
940 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad360_process_packet()
951 if (xpad->xtype == XTYPE_XBOX360W) { in xpad360_process_packet()
952 if (xpad->mode_btn_down_ts > 0 && xpad->pad_present && in xpad360_process_packet()
953 ((ktime_get_seconds() - xpad->mode_btn_down_ts) >= in xpad360_process_packet()
956 xpad->mode_btn_down_ts = 0; in xpad360_process_packet()
962 xpad->mode_btn_down_ts = ktime_get_seconds(); in xpad360_process_packet()
964 xpad->mode_btn_down_ts = 0; in xpad360_process_packet()
973 if (xpad->pad_present) { in xpad_presence_work()
977 dev_err(&xpad->dev->dev, in xpad_presence_work()
980 rcu_assign_pointer(xpad->x360w_dev, xpad->dev); in xpad_presence_work()
983 RCU_INIT_POINTER(xpad->x360w_dev, NULL); in xpad_presence_work()
1000 * 00.1 - Status change: The controller or headset has connected/disconnected
1002 * 01.7 - Controller present
1003 * 01.6 - Headset present
1004 * 01.1 - Pad state (Bytes 4+) valid
1016 if (xpad->pad_present != present) { in xpad360w_process_packet()
1017 xpad->pad_present = present; in xpad360w_process_packet()
1018 schedule_work(&xpad->work); in xpad360w_process_packet()
1027 dev = rcu_dereference(xpad->x360w_dev); in xpad360w_process_packet()
1044 struct input_dev *dev = xpad->dev; in xpadone_process_packet()
1063 if (xpad->packet_type == PKT_XBE2_FW_5_11) { in xpadone_process_packet()
1083 if (xpad->mapping & MAP_SHARE_BUTTON) { in xpadone_process_packet()
1084 if (xpad->mapping & MAP_SHARE_OFFSET) in xpadone_process_packet()
1085 input_report_key(dev, KEY_RECORD, data[len - 26] & BIT(0)); in xpadone_process_packet()
1087 input_report_key(dev, KEY_RECORD, data[len - 18] & BIT(0)); in xpadone_process_packet()
1097 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpadone_process_packet()
1105 !!(data[5] & 0x08) - !!(data[5] & 0x04)); in xpadone_process_packet()
1107 !!(data[5] & 0x02) - !!(data[5] & 0x01)); in xpadone_process_packet()
1118 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpadone_process_packet()
1121 (__s16) le16_to_cpup((__le16 *)(data + 10))); in xpadone_process_packet()
1133 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpadone_process_packet()
1145 /* Profile button has a value of 0-3, so it is reported as an axis */ in xpadone_process_packet()
1146 if (xpad->mapping & MAP_PROFILE_BUTTON) in xpadone_process_packet()
1151 if (xpad->mapping & MAP_PADDLES) { in xpadone_process_packet()
1152 if (xpad->packet_type == PKT_XBE1) { in xpadone_process_packet()
1165 } else if (xpad->packet_type == PKT_XBE2_FW_OLD) { in xpadone_process_packet()
1178 } else if (xpad->packet_type == PKT_XBE2_FW_5_EARLY) { in xpadone_process_packet()
1205 struct usb_xpad *xpad = urb->context; in xpad_irq_in()
1206 struct device *dev = &xpad->intf->dev; in xpad_irq_in()
1209 status = urb->status; in xpad_irq_in()
1215 case -ECONNRESET: in xpad_irq_in()
1216 case -ENOENT: in xpad_irq_in()
1217 case -ESHUTDOWN: in xpad_irq_in()
1219 dev_dbg(dev, "%s - urb shutting down with status: %d\n", in xpad_irq_in()
1223 dev_dbg(dev, "%s - nonzero urb status received: %d\n", in xpad_irq_in()
1228 switch (xpad->xtype) { in xpad_irq_in()
1230 xpad360_process_packet(xpad, xpad->dev, 0, xpad->idata); in xpad_irq_in()
1233 xpad360w_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
1236 xpadone_process_packet(xpad, 0, xpad->idata, urb->actual_length); in xpad_irq_in()
1239 xpad_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
1245 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", in xpad_irq_in()
1249 /* Callers must hold xpad->odata_lock spinlock */
1254 if (xpad->xtype != XTYPE_XBOXONE) in xpad_prepare_next_init_packet()
1258 while (xpad->init_seq < ARRAY_SIZE(xboxone_init_packets)) { in xpad_prepare_next_init_packet()
1259 init_packet = &xboxone_init_packets[xpad->init_seq++]; in xpad_prepare_next_init_packet()
1261 if (init_packet->idVendor != 0 && in xpad_prepare_next_init_packet()
1262 init_packet->idVendor != xpad->dev->id.vendor) in xpad_prepare_next_init_packet()
1265 if (init_packet->idProduct != 0 && in xpad_prepare_next_init_packet()
1266 init_packet->idProduct != xpad->dev->id.product) in xpad_prepare_next_init_packet()
1270 memcpy(xpad->odata, init_packet->data, init_packet->len); in xpad_prepare_next_init_packet()
1271 xpad->irq_out->transfer_buffer_length = init_packet->len; in xpad_prepare_next_init_packet()
1274 xpad->odata[2] = xpad->odata_serial++; in xpad_prepare_next_init_packet()
1281 /* Callers must hold xpad->odata_lock spinlock */
1292 if (++xpad->last_out_packet >= XPAD_NUM_OUT_PACKETS) in xpad_prepare_next_out_packet()
1293 xpad->last_out_packet = 0; in xpad_prepare_next_out_packet()
1295 pkt = &xpad->out_packets[xpad->last_out_packet]; in xpad_prepare_next_out_packet()
1296 if (pkt->pending) { in xpad_prepare_next_out_packet()
1297 dev_dbg(&xpad->intf->dev, in xpad_prepare_next_out_packet()
1298 "%s - found pending output packet %d\n", in xpad_prepare_next_out_packet()
1299 __func__, xpad->last_out_packet); in xpad_prepare_next_out_packet()
1306 memcpy(xpad->odata, packet->data, packet->len); in xpad_prepare_next_out_packet()
1307 xpad->irq_out->transfer_buffer_length = packet->len; in xpad_prepare_next_out_packet()
1308 packet->pending = false; in xpad_prepare_next_out_packet()
1315 /* Callers must hold xpad->odata_lock spinlock */
1320 if (!xpad->irq_out_active && xpad_prepare_next_out_packet(xpad)) { in xpad_try_sending_next_out_packet()
1321 usb_anchor_urb(xpad->irq_out, &xpad->irq_out_anchor); in xpad_try_sending_next_out_packet()
1322 error = usb_submit_urb(xpad->irq_out, GFP_ATOMIC); in xpad_try_sending_next_out_packet()
1324 dev_err(&xpad->intf->dev, in xpad_try_sending_next_out_packet()
1325 "%s - usb_submit_urb failed with result %d\n", in xpad_try_sending_next_out_packet()
1327 usb_unanchor_urb(xpad->irq_out); in xpad_try_sending_next_out_packet()
1328 return -EIO; in xpad_try_sending_next_out_packet()
1331 xpad->irq_out_active = true; in xpad_try_sending_next_out_packet()
1339 struct usb_xpad *xpad = urb->context; in xpad_irq_out()
1340 struct device *dev = &xpad->intf->dev; in xpad_irq_out()
1341 int status = urb->status; in xpad_irq_out()
1344 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad_irq_out()
1349 xpad->irq_out_active = xpad_prepare_next_out_packet(xpad); in xpad_irq_out()
1352 case -ECONNRESET: in xpad_irq_out()
1353 case -ENOENT: in xpad_irq_out()
1354 case -ESHUTDOWN: in xpad_irq_out()
1356 dev_dbg(dev, "%s - urb shutting down with status: %d\n", in xpad_irq_out()
1358 xpad->irq_out_active = false; in xpad_irq_out()
1362 dev_dbg(dev, "%s - nonzero urb status received: %d\n", in xpad_irq_out()
1367 if (xpad->irq_out_active) { in xpad_irq_out()
1368 usb_anchor_urb(urb, &xpad->irq_out_anchor); in xpad_irq_out()
1372 "%s - usb_submit_urb failed with result %d\n", in xpad_irq_out()
1375 xpad->irq_out_active = false; in xpad_irq_out()
1385 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_output()
1388 init_usb_anchor(&xpad->irq_out_anchor); in xpad_init_output()
1390 xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_init_output()
1391 GFP_KERNEL, &xpad->odata_dma); in xpad_init_output()
1392 if (!xpad->odata) in xpad_init_output()
1393 return -ENOMEM; in xpad_init_output()
1395 spin_lock_init(&xpad->odata_lock); in xpad_init_output()
1397 xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); in xpad_init_output()
1398 if (!xpad->irq_out) { in xpad_init_output()
1399 error = -ENOMEM; in xpad_init_output()
1403 usb_fill_int_urb(xpad->irq_out, xpad->udev, in xpad_init_output()
1404 usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), in xpad_init_output()
1405 xpad->odata, XPAD_PKT_LEN, in xpad_init_output()
1406 xpad_irq_out, xpad, ep_irq_out->bInterval); in xpad_init_output()
1407 xpad->irq_out->transfer_dma = xpad->odata_dma; in xpad_init_output()
1408 xpad->irq_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_init_output()
1413 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); in xpad_init_output()
1419 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_stop_output()
1420 if (!usb_wait_anchor_empty_timeout(&xpad->irq_out_anchor, in xpad_stop_output()
1422 dev_warn(&xpad->intf->dev, in xpad_stop_output()
1424 usb_kill_anchored_urbs(&xpad->irq_out_anchor); in xpad_stop_output()
1431 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_deinit_output()
1432 usb_free_urb(xpad->irq_out); in xpad_deinit_output()
1433 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_deinit_output()
1434 xpad->odata, xpad->odata_dma); in xpad_deinit_output()
1441 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpad_inquiry_pad_presence()
1443 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad_inquiry_pad_presence()
1445 packet->data[0] = 0x08; in xpad_inquiry_pad_presence()
1446 packet->data[1] = 0x00; in xpad_inquiry_pad_presence()
1447 packet->data[2] = 0x0F; in xpad_inquiry_pad_presence()
1448 packet->data[3] = 0xC0; in xpad_inquiry_pad_presence()
1449 packet->data[4] = 0x00; in xpad_inquiry_pad_presence()
1450 packet->data[5] = 0x00; in xpad_inquiry_pad_presence()
1451 packet->data[6] = 0x00; in xpad_inquiry_pad_presence()
1452 packet->data[7] = 0x00; in xpad_inquiry_pad_presence()
1453 packet->data[8] = 0x00; in xpad_inquiry_pad_presence()
1454 packet->data[9] = 0x00; in xpad_inquiry_pad_presence()
1455 packet->data[10] = 0x00; in xpad_inquiry_pad_presence()
1456 packet->data[11] = 0x00; in xpad_inquiry_pad_presence()
1457 packet->len = 12; in xpad_inquiry_pad_presence()
1458 packet->pending = true; in xpad_inquiry_pad_presence()
1461 xpad->last_out_packet = -1; in xpad_inquiry_pad_presence()
1469 if (usb_ifnum_to_if(xpad->udev, GIP_WIRED_INTF_AUDIO)) { in xpad_start_xbox_one()
1476 error = usb_set_interface(xpad->udev, in xpad_start_xbox_one()
1479 dev_warn(&xpad->dev->dev, in xpad_start_xbox_one()
1484 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad_start_xbox_one()
1491 xpad->init_seq = 0; in xpad_start_xbox_one()
1498 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpadone_ack_mode_report()
1504 guard(spinlock_irqsave)(&xpad->odata_lock); in xpadone_ack_mode_report()
1506 packet->len = sizeof(mode_report_ack); in xpadone_ack_mode_report()
1507 memcpy(packet->data, mode_report_ack, packet->len); in xpadone_ack_mode_report()
1508 packet->data[2] = seq_num; in xpadone_ack_mode_report()
1509 packet->pending = true; in xpadone_ack_mode_report()
1512 xpad->last_out_packet = -1; in xpadone_ack_mode_report()
1520 struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_FF_IDX]; in xpad_play_effect()
1524 if (effect->type != FF_RUMBLE) in xpad_play_effect()
1527 strong = effect->u.rumble.strong_magnitude; in xpad_play_effect()
1528 weak = effect->u.rumble.weak_magnitude; in xpad_play_effect()
1530 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad_play_effect()
1532 switch (xpad->xtype) { in xpad_play_effect()
1534 packet->data[0] = 0x00; in xpad_play_effect()
1535 packet->data[1] = 0x06; in xpad_play_effect()
1536 packet->data[2] = 0x00; in xpad_play_effect()
1537 packet->data[3] = strong / 256; /* left actuator */ in xpad_play_effect()
1538 packet->data[4] = 0x00; in xpad_play_effect()
1539 packet->data[5] = weak / 256; /* right actuator */ in xpad_play_effect()
1540 packet->len = 6; in xpad_play_effect()
1541 packet->pending = true; in xpad_play_effect()
1545 packet->data[0] = 0x00; in xpad_play_effect()
1546 packet->data[1] = 0x08; in xpad_play_effect()
1547 packet->data[2] = 0x00; in xpad_play_effect()
1548 packet->data[3] = strong / 256; /* left actuator? */ in xpad_play_effect()
1549 packet->data[4] = weak / 256; /* right actuator? */ in xpad_play_effect()
1550 packet->data[5] = 0x00; in xpad_play_effect()
1551 packet->data[6] = 0x00; in xpad_play_effect()
1552 packet->data[7] = 0x00; in xpad_play_effect()
1553 packet->len = 8; in xpad_play_effect()
1554 packet->pending = true; in xpad_play_effect()
1558 packet->data[0] = 0x00; in xpad_play_effect()
1559 packet->data[1] = 0x01; in xpad_play_effect()
1560 packet->data[2] = 0x0F; in xpad_play_effect()
1561 packet->data[3] = 0xC0; in xpad_play_effect()
1562 packet->data[4] = 0x00; in xpad_play_effect()
1563 packet->data[5] = strong / 256; in xpad_play_effect()
1564 packet->data[6] = weak / 256; in xpad_play_effect()
1565 packet->data[7] = 0x00; in xpad_play_effect()
1566 packet->data[8] = 0x00; in xpad_play_effect()
1567 packet->data[9] = 0x00; in xpad_play_effect()
1568 packet->data[10] = 0x00; in xpad_play_effect()
1569 packet->data[11] = 0x00; in xpad_play_effect()
1570 packet->len = 12; in xpad_play_effect()
1571 packet->pending = true; in xpad_play_effect()
1575 packet->data[0] = GIP_CMD_RUMBLE; /* activate rumble */ in xpad_play_effect()
1576 packet->data[1] = 0x00; in xpad_play_effect()
1577 packet->data[2] = xpad->odata_serial++; in xpad_play_effect()
1578 packet->data[3] = GIP_PL_LEN(9); in xpad_play_effect()
1579 packet->data[4] = 0x00; in xpad_play_effect()
1580 packet->data[5] = GIP_MOTOR_ALL; in xpad_play_effect()
1581 packet->data[6] = 0x00; /* left trigger */ in xpad_play_effect()
1582 packet->data[7] = 0x00; /* right trigger */ in xpad_play_effect()
1583 packet->data[8] = strong / 512; /* left actuator */ in xpad_play_effect()
1584 packet->data[9] = weak / 512; /* right actuator */ in xpad_play_effect()
1585 packet->data[10] = 0xFF; /* on period */ in xpad_play_effect()
1586 packet->data[11] = 0x00; /* off period */ in xpad_play_effect()
1587 packet->data[12] = 0xFF; /* repeat count */ in xpad_play_effect()
1588 packet->len = 13; in xpad_play_effect()
1589 packet->pending = true; in xpad_play_effect()
1593 dev_dbg(&xpad->dev->dev, in xpad_play_effect()
1594 "%s - rumble command sent to unsupported xpad type: %d\n", in xpad_play_effect()
1595 __func__, xpad->xtype); in xpad_play_effect()
1596 return -EINVAL; in xpad_play_effect()
1604 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_ff()
1607 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE); in xpad_init_ff()
1609 return input_ff_create_memless(xpad->dev, NULL, xpad_play_effect); in xpad_init_ff()
1633 * 2: 1/top-left blink, then on
1634 * 3: 2/top-right blink, then on
1635 * 4: 3/bottom-left blink, then on
1636 * 5: 4/bottom-right blink, then on
1637 * 6: 1/top-left on
1638 * 7: 2/top-right on
1639 * 8: 3/bottom-left on
1640 * 9: 4/bottom-right on
1641 * 10: rotate
1651 &xpad->out_packets[XPAD_OUT_LED_IDX]; in xpad_send_led_command()
1655 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad_send_led_command()
1657 switch (xpad->xtype) { in xpad_send_led_command()
1659 packet->data[0] = 0x01; in xpad_send_led_command()
1660 packet->data[1] = 0x03; in xpad_send_led_command()
1661 packet->data[2] = command; in xpad_send_led_command()
1662 packet->len = 3; in xpad_send_led_command()
1663 packet->pending = true; in xpad_send_led_command()
1667 packet->data[0] = 0x00; in xpad_send_led_command()
1668 packet->data[1] = 0x00; in xpad_send_led_command()
1669 packet->data[2] = 0x08; in xpad_send_led_command()
1670 packet->data[3] = 0x40 + command; in xpad_send_led_command()
1671 packet->data[4] = 0x00; in xpad_send_led_command()
1672 packet->data[5] = 0x00; in xpad_send_led_command()
1673 packet->data[6] = 0x00; in xpad_send_led_command()
1674 packet->data[7] = 0x00; in xpad_send_led_command()
1675 packet->data[8] = 0x00; in xpad_send_led_command()
1676 packet->data[9] = 0x00; in xpad_send_led_command()
1677 packet->data[10] = 0x00; in xpad_send_led_command()
1678 packet->data[11] = 0x00; in xpad_send_led_command()
1679 packet->len = 12; in xpad_send_led_command()
1680 packet->pending = true; in xpad_send_led_command()
1693 led_set_brightness(&xpad->led->led_cdev, (xpad->pad_nr % 4) + 2); in xpad_identify_controller()
1702 xpad_send_led_command(xpad_led->xpad, value); in xpad_led_set()
1711 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W) in xpad_led_probe()
1714 xpad->led = led = kzalloc(sizeof(*led), GFP_KERNEL); in xpad_led_probe()
1716 return -ENOMEM; in xpad_led_probe()
1718 xpad->pad_nr = ida_alloc(&xpad_pad_seq, GFP_KERNEL); in xpad_led_probe()
1719 if (xpad->pad_nr < 0) { in xpad_led_probe()
1720 error = xpad->pad_nr; in xpad_led_probe()
1724 snprintf(led->name, sizeof(led->name), "xpad%d", xpad->pad_nr); in xpad_led_probe()
1725 led->xpad = xpad; in xpad_led_probe()
1727 led_cdev = &led->led_cdev; in xpad_led_probe()
1728 led_cdev->name = led->name; in xpad_led_probe()
1729 led_cdev->brightness_set = xpad_led_set; in xpad_led_probe()
1730 led_cdev->flags = LED_CORE_SUSPENDRESUME; in xpad_led_probe()
1732 error = led_classdev_register(&xpad->udev->dev, led_cdev); in xpad_led_probe()
1741 ida_free(&xpad_pad_seq, xpad->pad_nr); in xpad_led_probe()
1744 xpad->led = NULL; in xpad_led_probe()
1750 struct xpad_led *xpad_led = xpad->led; in xpad_led_disconnect()
1753 led_classdev_unregister(&xpad_led->led_cdev); in xpad_led_disconnect()
1754 ida_free(&xpad_pad_seq, xpad->pad_nr); in xpad_led_disconnect()
1767 if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) in xpad_start_input()
1768 return -EIO; in xpad_start_input()
1770 if (xpad->xtype == XTYPE_XBOXONE) { in xpad_start_input()
1773 usb_kill_urb(xpad->irq_in); in xpad_start_input()
1777 if (xpad->xtype == XTYPE_XBOX360) { in xpad_start_input()
1779 * Some third-party controllers Xbox 360-style controllers in xpad_start_input()
1784 error = usb_control_msg_recv(xpad->udev, 0, in xpad_start_input()
1794 dev_warn(&xpad->dev->dev, in xpad_start_input()
1804 usb_kill_urb(xpad->irq_in); in xpad_stop_input()
1810 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpad360w_poweroff_controller()
1812 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad360w_poweroff_controller()
1814 packet->data[0] = 0x00; in xpad360w_poweroff_controller()
1815 packet->data[1] = 0x00; in xpad360w_poweroff_controller()
1816 packet->data[2] = 0x08; in xpad360w_poweroff_controller()
1817 packet->data[3] = 0xC0; in xpad360w_poweroff_controller()
1818 packet->data[4] = 0x00; in xpad360w_poweroff_controller()
1819 packet->data[5] = 0x00; in xpad360w_poweroff_controller()
1820 packet->data[6] = 0x00; in xpad360w_poweroff_controller()
1821 packet->data[7] = 0x00; in xpad360w_poweroff_controller()
1822 packet->data[8] = 0x00; in xpad360w_poweroff_controller()
1823 packet->data[9] = 0x00; in xpad360w_poweroff_controller()
1824 packet->data[10] = 0x00; in xpad360w_poweroff_controller()
1825 packet->data[11] = 0x00; in xpad360w_poweroff_controller()
1826 packet->len = 12; in xpad360w_poweroff_controller()
1827 packet->pending = true; in xpad360w_poweroff_controller()
1830 xpad->last_out_packet = -1; in xpad360w_poweroff_controller()
1838 error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); in xpad360w_start_input()
1840 return -EIO; in xpad360w_start_input()
1851 usb_kill_urb(xpad->irq_in); in xpad360w_start_input()
1860 usb_kill_urb(xpad->irq_in); in xpad360w_stop_input()
1863 flush_work(&xpad->work); in xpad360w_stop_input()
1889 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128); in xpad_set_up_abs()
1893 if (xpad->xtype == XTYPE_XBOXONE) in xpad_set_up_abs()
1899 case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */ in xpad_set_up_abs()
1900 input_set_abs_params(input_dev, abs, -1, 1, 0, 0); in xpad_set_up_abs()
1913 if (xpad->input_created) { in xpad_deinit_input()
1914 xpad->input_created = false; in xpad_deinit_input()
1916 input_unregister_device(xpad->dev); in xpad_deinit_input()
1927 return -ENOMEM; in xpad_init_input()
1929 xpad->dev = input_dev; in xpad_init_input()
1930 input_dev->name = xpad->name; in xpad_init_input()
1931 input_dev->phys = xpad->phys; in xpad_init_input()
1932 usb_to_input_id(xpad->udev, &input_dev->id); in xpad_init_input()
1934 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_init_input()
1936 input_dev->id.product = 0x02a1; in xpad_init_input()
1939 input_dev->dev.parent = &xpad->intf->dev; in xpad_init_input()
1943 if (xpad->xtype != XTYPE_XBOX360W) { in xpad_init_input()
1944 input_dev->open = xpad_open; in xpad_init_input()
1945 input_dev->close = xpad_close; in xpad_init_input()
1948 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_init_input()
1958 /* set up model-specific ones */ in xpad_init_input()
1959 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W || in xpad_init_input()
1960 xpad->xtype == XTYPE_XBOXONE) { in xpad_init_input()
1963 if (xpad->mapping & MAP_SHARE_BUTTON) in xpad_init_input()
1970 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_init_input()
1977 if (xpad->mapping & MAP_PADDLES) { in xpad_init_input()
1988 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad_init_input()
1989 xpad->xtype == XTYPE_XBOX360W) { in xpad_init_input()
1994 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_init_input()
2004 if (xpad->mapping & MAP_PROFILE_BUTTON) in xpad_init_input()
2015 error = input_register_device(xpad->dev); in xpad_init_input()
2019 xpad->input_created = true; in xpad_init_input()
2038 if (intf->cur_altsetting->desc.bNumEndpoints != 2) in xpad_probe()
2039 return -ENODEV; in xpad_probe()
2042 if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && in xpad_probe()
2043 (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) in xpad_probe()
2049 return -ENOMEM; in xpad_probe()
2051 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); in xpad_probe()
2052 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); in xpad_probe()
2054 xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, in xpad_probe()
2055 GFP_KERNEL, &xpad->idata_dma); in xpad_probe()
2056 if (!xpad->idata) { in xpad_probe()
2057 error = -ENOMEM; in xpad_probe()
2061 xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); in xpad_probe()
2062 if (!xpad->irq_in) { in xpad_probe()
2063 error = -ENOMEM; in xpad_probe()
2067 xpad->udev = udev; in xpad_probe()
2068 xpad->intf = intf; in xpad_probe()
2069 xpad->mapping = xpad_device[i].mapping; in xpad_probe()
2070 xpad->xtype = xpad_device[i].xtype; in xpad_probe()
2071 xpad->name = xpad_device[i].name; in xpad_probe()
2072 xpad->packet_type = PKT_XB; in xpad_probe()
2073 INIT_WORK(&xpad->work, xpad_presence_work); in xpad_probe()
2075 if (xpad->xtype == XTYPE_UNKNOWN) { in xpad_probe()
2076 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { in xpad_probe()
2077 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) in xpad_probe()
2078 xpad->xtype = XTYPE_XBOX360W; in xpad_probe()
2079 else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208) in xpad_probe()
2080 xpad->xtype = XTYPE_XBOXONE; in xpad_probe()
2082 xpad->xtype = XTYPE_XBOX360; in xpad_probe()
2084 xpad->xtype = XTYPE_XBOX; in xpad_probe()
2088 xpad->mapping |= MAP_DPAD_TO_BUTTONS; in xpad_probe()
2090 xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; in xpad_probe()
2092 xpad->mapping |= MAP_STICKS_TO_NULL; in xpad_probe()
2095 if (xpad->xtype == XTYPE_XBOXONE && in xpad_probe()
2096 intf->cur_altsetting->desc.bInterfaceNumber != GIP_WIRED_INTF_DATA) { in xpad_probe()
2102 error = -ENODEV; in xpad_probe()
2110 &intf->cur_altsetting->endpoint[i].desc; in xpad_probe()
2121 error = -ENODEV; in xpad_probe()
2129 usb_fill_int_urb(xpad->irq_in, udev, in xpad_probe()
2130 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), in xpad_probe()
2131 xpad->idata, XPAD_PKT_LEN, xpad_irq_in, in xpad_probe()
2132 xpad, ep_irq_in->bInterval); in xpad_probe()
2133 xpad->irq_in->transfer_dma = xpad->idata_dma; in xpad_probe()
2134 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_probe()
2139 if (le16_to_cpu(udev->descriptor.idVendor) == 0x045e) { /* Microsoft controllers */ in xpad_probe()
2140 if (le16_to_cpu(udev->descriptor.idProduct) == 0x02e3) { in xpad_probe()
2144 xpad->packet_type = PKT_XBE1; in xpad_probe()
2145 } else if (le16_to_cpu(udev->descriptor.idProduct) == 0x0b00) { in xpad_probe()
2150 if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x0500) { in xpad_probe()
2154 xpad->packet_type = PKT_XBE2_FW_OLD; in xpad_probe()
2155 } else if (le16_to_cpu(udev->descriptor.bcdDevice) < in xpad_probe()
2160 xpad->packet_type = PKT_XBE2_FW_5_EARLY; in xpad_probe()
2165 xpad->packet_type = PKT_XBE2_FW_5_11; in xpad_probe()
2170 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_probe()
2188 udev->quirks |= USB_QUIRK_RESET_RESUME; in xpad_probe()
2199 usb_free_urb(xpad->irq_in); in xpad_probe()
2201 usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); in xpad_probe()
2211 if (xpad->xtype == XTYPE_XBOX360W) in xpad_disconnect()
2224 usb_free_urb(xpad->irq_in); in xpad_disconnect()
2225 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_disconnect()
2226 xpad->idata, xpad->idata_dma); in xpad_disconnect()
2236 struct input_dev *input = xpad->dev; in xpad_suspend()
2238 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_suspend()
2252 if (auto_poweroff && xpad->pad_present) in xpad_suspend()
2255 guard(mutex)(&input->mutex); in xpad_suspend()
2269 struct input_dev *input = xpad->dev; in xpad_resume()
2271 if (xpad->xtype == XTYPE_XBOX360W) in xpad_resume()
2274 guard(mutex)(&input->mutex); in xpad_resume()
2279 if (xpad->xtype == XTYPE_XBOXONE) { in xpad_resume()
2302 MODULE_AUTHOR("Marko Friedemann <mfr@bmx-chemnitz.de>");