Lines Matching +full:li +full:- +full:ion

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
112 MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads");
135 { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 },
150 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
151 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
154 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
155 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
156 { 0x045e, 0x028f, "Microsoft X-Box 360 pad v2", 0, XTYPE_XBOX360 },
159 { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
160 { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
161 { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", MAP_PADDLES, XTYPE_XBOXONE },
162 { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE },
164 { 0x045e, 0x0b00, "Microsoft X-Box One Elite 2 pad", MAP_PADDLES, XTYPE_XBOXONE },
165 { 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", MAP_PROFILE_BUTTON, XTYPE_XBOXONE },
176 { 0x056e, 0x2004, "Elecom JC-U3613M", 0, XTYPE_XBOX360 },
178 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
211 { 0x0738, 0xb726, "Mad Catz Xbox controller - MW2", 0, XTYPE_XBOX360 },
214 { 0x0738, 0xcb02, "Saitek Cyborg Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
215 { 0x0738, 0xcb03, "Saitek P3200 Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
225 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX },
227 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX },
254 { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
260 { 0x0e6f, 0x02a2, "PDP Wired Controller for Xbox One - Crimson Red", 0, XTYPE_XBOXONE },
261 { 0x0e6f, 0x02a4, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
262 { 0x0e6f, 0x02a6, "PDP Wired Controller for Xbox One - Camo Series", 0, XTYPE_XBOXONE },
266 { 0x0e6f, 0x02ad, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
299 { 0x11c9, 0x55f0, "Nacon GC-100XF", 0, XTYPE_XBOX360 },
306 { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 },
317 { 0x162e, 0xbeef, "Joytech Neo-Se Take2", 0, XTYPE_XBOX360 },
326 { 0x1bad, 0x0130, "Ion Drum Rocker", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
341 …{ 0x1bad, 0xf03d, "Street Fighter IV Arcade Stick TE - Chun Li", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XB…
366 { 0x20d6, 0x890b, "PowerA MOGA XP-Ultra Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
378 { 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA", 0, XTYPE_XBOX360 },
398 { 0x2dc8, 0x200f, "8BitDo Ultimate 3-mode Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
405 { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE },
406 { 0x2e24, 0x1688, "Hyperkin X91 X-Box One pad", 0, XTYPE_XBOXONE },
416 { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 },
420 { 0x3285, 0x0663, "Nacon Evol-X", 0, XTYPE_XBOXONE },
427 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
428 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
435 -1 /* terminating entry */
441 -1 /* terminating entry */
446 BTN_DPAD_LEFT, BTN_DPAD_RIGHT, /* d-pad left, right */
447 BTN_DPAD_UP, BTN_DPAD_DOWN, /* d-pad up, down */
448 -1 /* terminating entry */
454 -1
460 -1
466 -1 /* terminating entry */
471 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */
472 -1 /* terminating entry */
478 -1
485 -1 /* terminating entry */
489 * Xbox 360 has a vendor-specific class, so we cannot match it with only
517 * macros - XPAD_XBOX360_VENDOR and XPAD_XBOXONE_VENDOR.
519 { USB_INTERFACE_INFO('X', 'B', 0) }, /* Xbox USB-IF not-approved class */
528 XPAD_XBOX360_VENDOR(0x046d), /* Logitech Xbox 360-style controllers */
530 XPAD_XBOX360_VENDOR(0x056e), /* Elecom JC-U3613M */
537 XPAD_XBOX360_VENDOR(0x0c12), /* Zeroplus X-Box 360 controllers */
538 XPAD_XBOX360_VENDOR(0x0db0), /* Micro Star International X-Box 360 controllers */
577 XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */
578 XPAD_XBOXONE_VENDOR(0x3285), /* Nacon Evol-X */
607 * - https://github.com/xpadneo/gip-dissector/blob/main/src/gip-dissector.lua
608 * - https://github.com/medusalix/xone/blob/master/bus/protocol.c
629 * which is a no-op for N < 128
789 int mapping; /* map d-pad to buttons or to axes */
813 * http://euc.jp/periphs/xbox-controller.ja.html
817 struct input_dev *dev = xpad->dev; in xpad_process_packet()
819 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_process_packet()
834 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_process_packet()
843 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_process_packet()
851 !!(data[2] & 0x08) - !!(data[2] & 0x04)); in xpad_process_packet()
853 !!(data[2] & 0x02) - !!(data[2] & 0x01)); in xpad_process_packet()
894 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad360_process_packet()
908 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad360_process_packet()
909 xpad->xtype == XTYPE_XBOX360W) { in xpad360_process_packet()
911 !!(data[2] & 0x08) - !!(data[2] & 0x04)); in xpad360_process_packet()
913 !!(data[2] & 0x02) - !!(data[2] & 0x01)); in xpad360_process_packet()
933 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad360_process_packet()
948 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad360_process_packet()
959 if (xpad->xtype == XTYPE_XBOX360W) { in xpad360_process_packet()
960 if (xpad->mode_btn_down_ts > 0 && xpad->pad_present && in xpad360_process_packet()
961 ((ktime_get_seconds() - xpad->mode_btn_down_ts) >= in xpad360_process_packet()
964 xpad->mode_btn_down_ts = 0; in xpad360_process_packet()
970 xpad->mode_btn_down_ts = ktime_get_seconds(); in xpad360_process_packet()
972 xpad->mode_btn_down_ts = 0; in xpad360_process_packet()
981 if (xpad->pad_present) { in xpad_presence_work()
985 dev_err(&xpad->dev->dev, in xpad_presence_work()
988 rcu_assign_pointer(xpad->x360w_dev, xpad->dev); in xpad_presence_work()
991 RCU_INIT_POINTER(xpad->x360w_dev, NULL); in xpad_presence_work()
1008 * 00.1 - Status change: The controller or headset has connected/disconnected
1010 * 01.7 - Controller present
1011 * 01.6 - Headset present
1012 * 01.1 - Pad state (Bytes 4+) valid
1024 if (xpad->pad_present != present) { in xpad360w_process_packet()
1025 xpad->pad_present = present; in xpad360w_process_packet()
1026 schedule_work(&xpad->work); in xpad360w_process_packet()
1035 dev = rcu_dereference(xpad->x360w_dev); in xpad360w_process_packet()
1052 struct input_dev *dev = xpad->dev; in xpadone_process_packet()
1071 if (xpad->packet_type == PKT_XBE2_FW_5_11) { in xpadone_process_packet()
1090 if (xpad->delay_init && !xpad->delayed_init_done) { in xpadone_process_packet()
1091 xpad->delayed_init_done = true; in xpadone_process_packet()
1094 dev_warn(&xpad->dev->dev, in xpadone_process_packet()
1102 if (xpad->mapping & MAP_SHARE_BUTTON) { in xpadone_process_packet()
1103 if (xpad->mapping & MAP_SHARE_OFFSET) in xpadone_process_packet()
1104 input_report_key(dev, KEY_RECORD, data[len - 26] & BIT(0)); in xpadone_process_packet()
1106 input_report_key(dev, KEY_RECORD, data[len - 18] & BIT(0)); in xpadone_process_packet()
1116 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpadone_process_packet()
1124 !!(data[5] & 0x08) - !!(data[5] & 0x04)); in xpadone_process_packet()
1126 !!(data[5] & 0x02) - !!(data[5] & 0x01)); in xpadone_process_packet()
1137 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpadone_process_packet()
1152 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpadone_process_packet()
1164 /* Profile button has a value of 0-3, so it is reported as an axis */ in xpadone_process_packet()
1165 if (xpad->mapping & MAP_PROFILE_BUTTON) in xpadone_process_packet()
1170 if (xpad->mapping & MAP_PADDLES) { in xpadone_process_packet()
1171 if (xpad->packet_type == PKT_XBE1) { in xpadone_process_packet()
1184 } else if (xpad->packet_type == PKT_XBE2_FW_OLD) { in xpadone_process_packet()
1197 } else if (xpad->packet_type == PKT_XBE2_FW_5_EARLY) { in xpadone_process_packet()
1224 struct usb_xpad *xpad = urb->context; in xpad_irq_in()
1225 struct device *dev = &xpad->intf->dev; in xpad_irq_in()
1228 status = urb->status; in xpad_irq_in()
1234 case -ECONNRESET: in xpad_irq_in()
1235 case -ENOENT: in xpad_irq_in()
1236 case -ESHUTDOWN: in xpad_irq_in()
1238 dev_dbg(dev, "%s - urb shutting down with status: %d\n", in xpad_irq_in()
1242 dev_dbg(dev, "%s - nonzero urb status received: %d\n", in xpad_irq_in()
1247 switch (xpad->xtype) { in xpad_irq_in()
1249 xpad360_process_packet(xpad, xpad->dev, 0, xpad->idata); in xpad_irq_in()
1252 xpad360w_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
1255 xpadone_process_packet(xpad, 0, xpad->idata, urb->actual_length); in xpad_irq_in()
1258 xpad_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
1264 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", in xpad_irq_in()
1268 /* Callers must hold xpad->odata_lock spinlock */
1273 if (xpad->xtype != XTYPE_XBOXONE) in xpad_prepare_next_init_packet()
1281 if (xpad->delay_init && !xpad->delayed_init_done) in xpad_prepare_next_init_packet()
1285 while (xpad->init_seq < ARRAY_SIZE(xboxone_init_packets)) { in xpad_prepare_next_init_packet()
1286 init_packet = &xboxone_init_packets[xpad->init_seq++]; in xpad_prepare_next_init_packet()
1288 if (init_packet->idVendor != 0 && in xpad_prepare_next_init_packet()
1289 init_packet->idVendor != xpad->dev->id.vendor) in xpad_prepare_next_init_packet()
1292 if (init_packet->idProduct != 0 && in xpad_prepare_next_init_packet()
1293 init_packet->idProduct != xpad->dev->id.product) in xpad_prepare_next_init_packet()
1297 memcpy(xpad->odata, init_packet->data, init_packet->len); in xpad_prepare_next_init_packet()
1298 xpad->irq_out->transfer_buffer_length = init_packet->len; in xpad_prepare_next_init_packet()
1301 xpad->odata[2] = xpad->odata_serial++; in xpad_prepare_next_init_packet()
1308 /* Callers must hold xpad->odata_lock spinlock */
1319 if (++xpad->last_out_packet >= XPAD_NUM_OUT_PACKETS) in xpad_prepare_next_out_packet()
1320 xpad->last_out_packet = 0; in xpad_prepare_next_out_packet()
1322 pkt = &xpad->out_packets[xpad->last_out_packet]; in xpad_prepare_next_out_packet()
1323 if (pkt->pending) { in xpad_prepare_next_out_packet()
1324 dev_dbg(&xpad->intf->dev, in xpad_prepare_next_out_packet()
1325 "%s - found pending output packet %d\n", in xpad_prepare_next_out_packet()
1326 __func__, xpad->last_out_packet); in xpad_prepare_next_out_packet()
1333 memcpy(xpad->odata, packet->data, packet->len); in xpad_prepare_next_out_packet()
1334 xpad->irq_out->transfer_buffer_length = packet->len; in xpad_prepare_next_out_packet()
1335 packet->pending = false; in xpad_prepare_next_out_packet()
1342 /* Callers must hold xpad->odata_lock spinlock */
1347 if (!xpad->irq_out_active && xpad_prepare_next_out_packet(xpad)) { in xpad_try_sending_next_out_packet()
1348 usb_anchor_urb(xpad->irq_out, &xpad->irq_out_anchor); in xpad_try_sending_next_out_packet()
1349 error = usb_submit_urb(xpad->irq_out, GFP_ATOMIC); in xpad_try_sending_next_out_packet()
1351 if (error != -ENODEV) in xpad_try_sending_next_out_packet()
1352 dev_err(&xpad->intf->dev, in xpad_try_sending_next_out_packet()
1353 "%s - usb_submit_urb failed with result %d\n", in xpad_try_sending_next_out_packet()
1355 usb_unanchor_urb(xpad->irq_out); in xpad_try_sending_next_out_packet()
1359 xpad->irq_out_active = true; in xpad_try_sending_next_out_packet()
1367 struct usb_xpad *xpad = urb->context; in xpad_irq_out()
1368 struct device *dev = &xpad->intf->dev; in xpad_irq_out()
1369 int status = urb->status; in xpad_irq_out()
1372 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad_irq_out()
1377 xpad->irq_out_active = xpad_prepare_next_out_packet(xpad); in xpad_irq_out()
1380 case -ECONNRESET: in xpad_irq_out()
1381 case -ENOENT: in xpad_irq_out()
1382 case -ESHUTDOWN: in xpad_irq_out()
1384 dev_dbg(dev, "%s - urb shutting down with status: %d\n", in xpad_irq_out()
1386 xpad->irq_out_active = false; in xpad_irq_out()
1390 dev_dbg(dev, "%s - nonzero urb status received: %d\n", in xpad_irq_out()
1395 if (xpad->irq_out_active) { in xpad_irq_out()
1396 usb_anchor_urb(urb, &xpad->irq_out_anchor); in xpad_irq_out()
1400 "%s - usb_submit_urb failed with result %d\n", in xpad_irq_out()
1403 xpad->irq_out_active = false; in xpad_irq_out()
1413 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_output()
1416 init_usb_anchor(&xpad->irq_out_anchor); in xpad_init_output()
1418 xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_init_output()
1419 GFP_KERNEL, &xpad->odata_dma); in xpad_init_output()
1420 if (!xpad->odata) in xpad_init_output()
1421 return -ENOMEM; in xpad_init_output()
1423 spin_lock_init(&xpad->odata_lock); in xpad_init_output()
1425 xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); in xpad_init_output()
1426 if (!xpad->irq_out) { in xpad_init_output()
1427 error = -ENOMEM; in xpad_init_output()
1431 usb_fill_int_urb(xpad->irq_out, xpad->udev, in xpad_init_output()
1432 usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), in xpad_init_output()
1433 xpad->odata, XPAD_PKT_LEN, in xpad_init_output()
1434 xpad_irq_out, xpad, ep_irq_out->bInterval); in xpad_init_output()
1435 xpad->irq_out->transfer_dma = xpad->odata_dma; in xpad_init_output()
1436 xpad->irq_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_init_output()
1441 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); in xpad_init_output()
1447 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_stop_output()
1448 if (!usb_wait_anchor_empty_timeout(&xpad->irq_out_anchor, in xpad_stop_output()
1450 dev_warn(&xpad->intf->dev, in xpad_stop_output()
1452 usb_kill_anchored_urbs(&xpad->irq_out_anchor); in xpad_stop_output()
1459 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_deinit_output()
1460 usb_free_urb(xpad->irq_out); in xpad_deinit_output()
1461 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_deinit_output()
1462 xpad->odata, xpad->odata_dma); in xpad_deinit_output()
1469 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpad_inquiry_pad_presence()
1471 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad_inquiry_pad_presence()
1473 packet->data[0] = 0x08; in xpad_inquiry_pad_presence()
1474 packet->data[1] = 0x00; in xpad_inquiry_pad_presence()
1475 packet->data[2] = 0x0F; in xpad_inquiry_pad_presence()
1476 packet->data[3] = 0xC0; in xpad_inquiry_pad_presence()
1477 packet->data[4] = 0x00; in xpad_inquiry_pad_presence()
1478 packet->data[5] = 0x00; in xpad_inquiry_pad_presence()
1479 packet->data[6] = 0x00; in xpad_inquiry_pad_presence()
1480 packet->data[7] = 0x00; in xpad_inquiry_pad_presence()
1481 packet->data[8] = 0x00; in xpad_inquiry_pad_presence()
1482 packet->data[9] = 0x00; in xpad_inquiry_pad_presence()
1483 packet->data[10] = 0x00; in xpad_inquiry_pad_presence()
1484 packet->data[11] = 0x00; in xpad_inquiry_pad_presence()
1485 packet->len = 12; in xpad_inquiry_pad_presence()
1486 packet->pending = true; in xpad_inquiry_pad_presence()
1489 xpad->last_out_packet = -1; in xpad_inquiry_pad_presence()
1497 if (usb_ifnum_to_if(xpad->udev, GIP_WIRED_INTF_AUDIO)) { in xpad_start_xbox_one()
1504 error = usb_set_interface(xpad->udev, in xpad_start_xbox_one()
1507 dev_warn(&xpad->dev->dev, in xpad_start_xbox_one()
1512 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad_start_xbox_one()
1519 xpad->init_seq = 0; in xpad_start_xbox_one()
1526 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpadone_ack_mode_report()
1532 guard(spinlock_irqsave)(&xpad->odata_lock); in xpadone_ack_mode_report()
1534 packet->len = sizeof(mode_report_ack); in xpadone_ack_mode_report()
1535 memcpy(packet->data, mode_report_ack, packet->len); in xpadone_ack_mode_report()
1536 packet->data[2] = seq_num; in xpadone_ack_mode_report()
1537 packet->pending = true; in xpadone_ack_mode_report()
1540 xpad->last_out_packet = -1; in xpadone_ack_mode_report()
1548 struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_FF_IDX]; in xpad_play_effect()
1552 if (effect->type != FF_RUMBLE) in xpad_play_effect()
1555 strong = effect->u.rumble.strong_magnitude; in xpad_play_effect()
1556 weak = effect->u.rumble.weak_magnitude; in xpad_play_effect()
1558 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad_play_effect()
1560 switch (xpad->xtype) { in xpad_play_effect()
1562 packet->data[0] = 0x00; in xpad_play_effect()
1563 packet->data[1] = 0x06; in xpad_play_effect()
1564 packet->data[2] = 0x00; in xpad_play_effect()
1565 packet->data[3] = strong / 256; /* left actuator */ in xpad_play_effect()
1566 packet->data[4] = 0x00; in xpad_play_effect()
1567 packet->data[5] = weak / 256; /* right actuator */ in xpad_play_effect()
1568 packet->len = 6; in xpad_play_effect()
1569 packet->pending = true; in xpad_play_effect()
1573 packet->data[0] = 0x00; in xpad_play_effect()
1574 packet->data[1] = 0x08; in xpad_play_effect()
1575 packet->data[2] = 0x00; in xpad_play_effect()
1576 packet->data[3] = strong / 256; /* left actuator? */ in xpad_play_effect()
1577 packet->data[4] = weak / 256; /* right actuator? */ in xpad_play_effect()
1578 packet->data[5] = 0x00; in xpad_play_effect()
1579 packet->data[6] = 0x00; in xpad_play_effect()
1580 packet->data[7] = 0x00; in xpad_play_effect()
1581 packet->len = 8; in xpad_play_effect()
1582 packet->pending = true; in xpad_play_effect()
1586 packet->data[0] = 0x00; in xpad_play_effect()
1587 packet->data[1] = 0x01; in xpad_play_effect()
1588 packet->data[2] = 0x0F; in xpad_play_effect()
1589 packet->data[3] = 0xC0; in xpad_play_effect()
1590 packet->data[4] = 0x00; in xpad_play_effect()
1591 packet->data[5] = strong / 256; in xpad_play_effect()
1592 packet->data[6] = weak / 256; in xpad_play_effect()
1593 packet->data[7] = 0x00; in xpad_play_effect()
1594 packet->data[8] = 0x00; in xpad_play_effect()
1595 packet->data[9] = 0x00; in xpad_play_effect()
1596 packet->data[10] = 0x00; in xpad_play_effect()
1597 packet->data[11] = 0x00; in xpad_play_effect()
1598 packet->len = 12; in xpad_play_effect()
1599 packet->pending = true; in xpad_play_effect()
1603 packet->data[0] = GIP_CMD_RUMBLE; /* activate rumble */ in xpad_play_effect()
1604 packet->data[1] = 0x00; in xpad_play_effect()
1605 packet->data[2] = xpad->odata_serial++; in xpad_play_effect()
1606 packet->data[3] = GIP_PL_LEN(9); in xpad_play_effect()
1607 packet->data[4] = 0x00; in xpad_play_effect()
1608 packet->data[5] = GIP_MOTOR_ALL; in xpad_play_effect()
1609 packet->data[6] = 0x00; /* left trigger */ in xpad_play_effect()
1610 packet->data[7] = 0x00; /* right trigger */ in xpad_play_effect()
1611 packet->data[8] = strong / 512; /* left actuator */ in xpad_play_effect()
1612 packet->data[9] = weak / 512; /* right actuator */ in xpad_play_effect()
1613 packet->data[10] = 0xFF; /* on period */ in xpad_play_effect()
1614 packet->data[11] = 0x00; /* off period */ in xpad_play_effect()
1615 packet->data[12] = 0xFF; /* repeat count */ in xpad_play_effect()
1616 packet->len = 13; in xpad_play_effect()
1617 packet->pending = true; in xpad_play_effect()
1621 dev_dbg(&xpad->dev->dev, in xpad_play_effect()
1622 "%s - rumble command sent to unsupported xpad type: %d\n", in xpad_play_effect()
1623 __func__, xpad->xtype); in xpad_play_effect()
1624 return -EINVAL; in xpad_play_effect()
1632 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_ff()
1635 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE); in xpad_init_ff()
1637 return input_ff_create_memless(xpad->dev, NULL, xpad_play_effect); in xpad_init_ff()
1661 * 2: 1/top-left blink, then on
1662 * 3: 2/top-right blink, then on
1663 * 4: 3/bottom-left blink, then on
1664 * 5: 4/bottom-right blink, then on
1665 * 6: 1/top-left on
1666 * 7: 2/top-right on
1667 * 8: 3/bottom-left on
1668 * 9: 4/bottom-right on
1679 &xpad->out_packets[XPAD_OUT_LED_IDX]; in xpad_send_led_command()
1683 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad_send_led_command()
1685 switch (xpad->xtype) { in xpad_send_led_command()
1687 packet->data[0] = 0x01; in xpad_send_led_command()
1688 packet->data[1] = 0x03; in xpad_send_led_command()
1689 packet->data[2] = command; in xpad_send_led_command()
1690 packet->len = 3; in xpad_send_led_command()
1691 packet->pending = true; in xpad_send_led_command()
1695 packet->data[0] = 0x00; in xpad_send_led_command()
1696 packet->data[1] = 0x00; in xpad_send_led_command()
1697 packet->data[2] = 0x08; in xpad_send_led_command()
1698 packet->data[3] = 0x40 + command; in xpad_send_led_command()
1699 packet->data[4] = 0x00; in xpad_send_led_command()
1700 packet->data[5] = 0x00; in xpad_send_led_command()
1701 packet->data[6] = 0x00; in xpad_send_led_command()
1702 packet->data[7] = 0x00; in xpad_send_led_command()
1703 packet->data[8] = 0x00; in xpad_send_led_command()
1704 packet->data[9] = 0x00; in xpad_send_led_command()
1705 packet->data[10] = 0x00; in xpad_send_led_command()
1706 packet->data[11] = 0x00; in xpad_send_led_command()
1707 packet->len = 12; in xpad_send_led_command()
1708 packet->pending = true; in xpad_send_led_command()
1721 led_set_brightness(&xpad->led->led_cdev, (xpad->pad_nr % 4) + 2); in xpad_identify_controller()
1730 xpad_send_led_command(xpad_led->xpad, value); in xpad_led_set()
1739 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W) in xpad_led_probe()
1742 xpad->led = led = kzalloc(sizeof(*led), GFP_KERNEL); in xpad_led_probe()
1744 return -ENOMEM; in xpad_led_probe()
1746 xpad->pad_nr = ida_alloc(&xpad_pad_seq, GFP_KERNEL); in xpad_led_probe()
1747 if (xpad->pad_nr < 0) { in xpad_led_probe()
1748 error = xpad->pad_nr; in xpad_led_probe()
1752 snprintf(led->name, sizeof(led->name), "xpad%d", xpad->pad_nr); in xpad_led_probe()
1753 led->xpad = xpad; in xpad_led_probe()
1755 led_cdev = &led->led_cdev; in xpad_led_probe()
1756 led_cdev->name = led->name; in xpad_led_probe()
1757 led_cdev->brightness_set = xpad_led_set; in xpad_led_probe()
1758 led_cdev->flags = LED_CORE_SUSPENDRESUME; in xpad_led_probe()
1760 error = led_classdev_register(&xpad->udev->dev, led_cdev); in xpad_led_probe()
1769 ida_free(&xpad_pad_seq, xpad->pad_nr); in xpad_led_probe()
1772 xpad->led = NULL; in xpad_led_probe()
1778 struct xpad_led *xpad_led = xpad->led; in xpad_led_disconnect()
1781 led_classdev_unregister(&xpad_led->led_cdev); in xpad_led_disconnect()
1782 ida_free(&xpad_pad_seq, xpad->pad_nr); in xpad_led_disconnect()
1795 if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) in xpad_start_input()
1796 return -EIO; in xpad_start_input()
1798 if (xpad->xtype == XTYPE_XBOXONE) { in xpad_start_input()
1801 usb_kill_urb(xpad->irq_in); in xpad_start_input()
1805 if (xpad->xtype == XTYPE_XBOX360) { in xpad_start_input()
1807 * Some third-party controllers Xbox 360-style controllers in xpad_start_input()
1812 error = usb_control_msg_recv(xpad->udev, 0, in xpad_start_input()
1822 dev_warn(&xpad->dev->dev, in xpad_start_input()
1832 usb_kill_urb(xpad->irq_in); in xpad_stop_input()
1838 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpad360w_poweroff_controller()
1840 guard(spinlock_irqsave)(&xpad->odata_lock); in xpad360w_poweroff_controller()
1842 packet->data[0] = 0x00; in xpad360w_poweroff_controller()
1843 packet->data[1] = 0x00; in xpad360w_poweroff_controller()
1844 packet->data[2] = 0x08; in xpad360w_poweroff_controller()
1845 packet->data[3] = 0xC0; in xpad360w_poweroff_controller()
1846 packet->data[4] = 0x00; in xpad360w_poweroff_controller()
1847 packet->data[5] = 0x00; in xpad360w_poweroff_controller()
1848 packet->data[6] = 0x00; in xpad360w_poweroff_controller()
1849 packet->data[7] = 0x00; in xpad360w_poweroff_controller()
1850 packet->data[8] = 0x00; in xpad360w_poweroff_controller()
1851 packet->data[9] = 0x00; in xpad360w_poweroff_controller()
1852 packet->data[10] = 0x00; in xpad360w_poweroff_controller()
1853 packet->data[11] = 0x00; in xpad360w_poweroff_controller()
1854 packet->len = 12; in xpad360w_poweroff_controller()
1855 packet->pending = true; in xpad360w_poweroff_controller()
1858 xpad->last_out_packet = -1; in xpad360w_poweroff_controller()
1866 error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); in xpad360w_start_input()
1868 return -EIO; in xpad360w_start_input()
1879 usb_kill_urb(xpad->irq_in); in xpad360w_start_input()
1888 usb_kill_urb(xpad->irq_in); in xpad360w_stop_input()
1891 flush_work(&xpad->work); in xpad360w_stop_input()
1917 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128); in xpad_set_up_abs()
1921 if (xpad->xtype == XTYPE_XBOXONE) in xpad_set_up_abs()
1927 case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */ in xpad_set_up_abs()
1928 input_set_abs_params(input_dev, abs, -1, 1, 0, 0); in xpad_set_up_abs()
1941 if (xpad->input_created) { in xpad_deinit_input()
1942 xpad->input_created = false; in xpad_deinit_input()
1944 input_unregister_device(xpad->dev); in xpad_deinit_input()
1955 return -ENOMEM; in xpad_init_input()
1957 xpad->dev = input_dev; in xpad_init_input()
1958 input_dev->name = xpad->name; in xpad_init_input()
1959 input_dev->phys = xpad->phys; in xpad_init_input()
1960 usb_to_input_id(xpad->udev, &input_dev->id); in xpad_init_input()
1962 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_init_input()
1964 input_dev->id.product = 0x02a1; in xpad_init_input()
1967 input_dev->dev.parent = &xpad->intf->dev; in xpad_init_input()
1971 if (xpad->xtype != XTYPE_XBOX360W) { in xpad_init_input()
1972 input_dev->open = xpad_open; in xpad_init_input()
1973 input_dev->close = xpad_close; in xpad_init_input()
1976 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_init_input()
1986 /* set up model-specific ones */ in xpad_init_input()
1987 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W || in xpad_init_input()
1988 xpad->xtype == XTYPE_XBOXONE) { in xpad_init_input()
1991 if (xpad->mapping & MAP_SHARE_BUTTON) in xpad_init_input()
1998 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_init_input()
2005 if (xpad->mapping & MAP_PADDLES) { in xpad_init_input()
2016 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad_init_input()
2017 xpad->xtype == XTYPE_XBOX360W) { in xpad_init_input()
2022 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_init_input()
2032 if (xpad->mapping & MAP_PROFILE_BUTTON) in xpad_init_input()
2043 error = input_register_device(xpad->dev); in xpad_init_input()
2047 xpad->input_created = true; in xpad_init_input()
2066 if (intf->cur_altsetting->desc.bNumEndpoints != 2) in xpad_probe()
2067 return -ENODEV; in xpad_probe()
2070 if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && in xpad_probe()
2071 (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) in xpad_probe()
2077 return -ENOMEM; in xpad_probe()
2079 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); in xpad_probe()
2080 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); in xpad_probe()
2082 xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, in xpad_probe()
2083 GFP_KERNEL, &xpad->idata_dma); in xpad_probe()
2084 if (!xpad->idata) { in xpad_probe()
2085 error = -ENOMEM; in xpad_probe()
2089 xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); in xpad_probe()
2090 if (!xpad->irq_in) { in xpad_probe()
2091 error = -ENOMEM; in xpad_probe()
2095 xpad->udev = udev; in xpad_probe()
2096 xpad->intf = intf; in xpad_probe()
2097 xpad->mapping = xpad_device[i].mapping; in xpad_probe()
2098 xpad->xtype = xpad_device[i].xtype; in xpad_probe()
2099 xpad->name = xpad_device[i].name; in xpad_probe()
2101 xpad->delay_init = true; in xpad_probe()
2103 xpad->packet_type = PKT_XB; in xpad_probe()
2104 INIT_WORK(&xpad->work, xpad_presence_work); in xpad_probe()
2106 if (xpad->xtype == XTYPE_UNKNOWN) { in xpad_probe()
2107 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { in xpad_probe()
2108 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) in xpad_probe()
2109 xpad->xtype = XTYPE_XBOX360W; in xpad_probe()
2110 else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208) in xpad_probe()
2111 xpad->xtype = XTYPE_XBOXONE; in xpad_probe()
2113 xpad->xtype = XTYPE_XBOX360; in xpad_probe()
2115 xpad->xtype = XTYPE_XBOX; in xpad_probe()
2119 xpad->mapping |= MAP_DPAD_TO_BUTTONS; in xpad_probe()
2121 xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; in xpad_probe()
2123 xpad->mapping |= MAP_STICKS_TO_NULL; in xpad_probe()
2126 if (xpad->xtype == XTYPE_XBOXONE && in xpad_probe()
2127 intf->cur_altsetting->desc.bInterfaceNumber != GIP_WIRED_INTF_DATA) { in xpad_probe()
2133 error = -ENODEV; in xpad_probe()
2141 &intf->cur_altsetting->endpoint[i].desc; in xpad_probe()
2152 error = -ENODEV; in xpad_probe()
2160 usb_fill_int_urb(xpad->irq_in, udev, in xpad_probe()
2161 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), in xpad_probe()
2162 xpad->idata, XPAD_PKT_LEN, xpad_irq_in, in xpad_probe()
2163 xpad, ep_irq_in->bInterval); in xpad_probe()
2164 xpad->irq_in->transfer_dma = xpad->idata_dma; in xpad_probe()
2165 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_probe()
2170 if (le16_to_cpu(udev->descriptor.idVendor) == 0x045e) { /* Microsoft controllers */ in xpad_probe()
2171 if (le16_to_cpu(udev->descriptor.idProduct) == 0x02e3) { in xpad_probe()
2175 xpad->packet_type = PKT_XBE1; in xpad_probe()
2176 } else if (le16_to_cpu(udev->descriptor.idProduct) == 0x0b00) { in xpad_probe()
2181 if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x0500) { in xpad_probe()
2185 xpad->packet_type = PKT_XBE2_FW_OLD; in xpad_probe()
2186 } else if (le16_to_cpu(udev->descriptor.bcdDevice) < in xpad_probe()
2191 xpad->packet_type = PKT_XBE2_FW_5_EARLY; in xpad_probe()
2196 xpad->packet_type = PKT_XBE2_FW_5_11; in xpad_probe()
2201 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_probe()
2219 udev->quirks |= USB_QUIRK_RESET_RESUME; in xpad_probe()
2230 usb_free_urb(xpad->irq_in); in xpad_probe()
2232 usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); in xpad_probe()
2242 if (xpad->xtype == XTYPE_XBOX360W) in xpad_disconnect()
2255 usb_free_urb(xpad->irq_in); in xpad_disconnect()
2256 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_disconnect()
2257 xpad->idata, xpad->idata_dma); in xpad_disconnect()
2267 struct input_dev *input = xpad->dev; in xpad_suspend()
2269 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_suspend()
2283 if (auto_poweroff && xpad->pad_present) in xpad_suspend()
2286 guard(mutex)(&input->mutex); in xpad_suspend()
2300 struct input_dev *input = xpad->dev; in xpad_resume()
2302 xpad->delayed_init_done = false; in xpad_resume()
2303 if (xpad->xtype == XTYPE_XBOX360W) in xpad_resume()
2306 guard(mutex)(&input->mutex); in xpad_resume()
2311 if (xpad->xtype == XTYPE_XBOXONE) { in xpad_resume()
2334 MODULE_AUTHOR("Marko Friedemann <mfr@bmx-chemnitz.de>");