Merge branch 'next' into for-linus
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 2 May 2017 16:48:26 +0000 (09:48 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 2 May 2017 16:48:26 +0000 (09:48 -0700)
Prepare input updates for 4.12 merge window.

1  2 
drivers/input/joystick/xpad.c
include/uapi/linux/Kbuild

@@@ -202,7 -202,6 +202,7 @@@ static const struct xpad_device 
        { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
        { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
        { 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 },
 +      { 0x1532, 0x0a03, "Razer Wildcat", 0, XTYPE_XBOXONE },
        { 0x15e4, 0x3f00, "Power A Mini Pro Elite", 0, XTYPE_XBOX360 },
        { 0x15e4, 0x3f0a, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
        { 0x15e4, 0x3f10, "Batarang Xbox 360 controller", 0, XTYPE_XBOX360 },
@@@ -327,7 -326,6 +327,7 @@@ static struct usb_device_id xpad_table[
        XPAD_XBOX360_VENDOR(0x1430),            /* RedOctane X-Box 360 controllers */
        XPAD_XBOX360_VENDOR(0x146b),            /* BigBen Interactive Controllers */
        XPAD_XBOX360_VENDOR(0x1532),            /* Razer Sabertooth */
 +      XPAD_XBOXONE_VENDOR(0x1532),            /* Razer Wildcat */
        XPAD_XBOX360_VENDOR(0x15e4),            /* Numark X-Box 360 controllers */
        XPAD_XBOX360_VENDOR(0x162e),            /* Joytech X-Box 360 controllers */
        XPAD_XBOX360_VENDOR(0x1689),            /* Razer Onza */
  
  MODULE_DEVICE_TABLE(usb, xpad_table);
  
+ struct xboxone_init_packet {
+       u16 idVendor;
+       u16 idProduct;
+       const u8 *data;
+       u8 len;
+ };
+ #define XBOXONE_INIT_PKT(_vid, _pid, _data)           \
+       {                                               \
+               .idVendor       = (_vid),               \
+               .idProduct      = (_pid),               \
+               .data           = (_data),              \
+               .len            = ARRAY_SIZE(_data),    \
+       }
+ /*
+  * This packet is required for all Xbox One pads with 2015
+  * or later firmware installed (or present from the factory).
+  */
+ static const u8 xboxone_fw2015_init[] = {
+       0x05, 0x20, 0x00, 0x01, 0x00
+ };
+ /*
+  * This packet is required for the Titanfall 2 Xbox One pads
+  * (0x0e6f:0x0165) to finish initialization and for Hori pads
+  * (0x0f0d:0x0067) to make the analog sticks work.
+  */
+ static const u8 xboxone_hori_init[] = {
+       0x01, 0x20, 0x00, 0x09, 0x00, 0x04, 0x20, 0x3a,
+       0x00, 0x00, 0x00, 0x80, 0x00
+ };
+ /*
+  * A rumble packet is required for some PowerA pads to start
+  * sending input reports. One of those pads is (0x24c6:0x543a).
+  */
+ static const u8 xboxone_zerorumble_init[] = {
+       0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00
+ };
+ /*
+  * This specifies the selection of init packets that a gamepad
+  * will be sent on init *and* the order in which they will be
+  * sent. The correct sequence number will be added when the
+  * packet is going to be sent.
+  */
+ static const struct xboxone_init_packet xboxone_init_packets[] = {
+       XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_init),
+       XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_init),
+       XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_zerorumble_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_zerorumble_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_zerorumble_init),
+ };
  struct xpad_output_packet {
        u8 data[XPAD_PKT_LEN];
        u8 len;
@@@ -375,6 -431,7 +433,7 @@@ struct usb_xpad 
  
        struct xpad_output_packet out_packets[XPAD_NUM_OUT_PACKETS];
        int last_out_packet;
+       int init_seq;
  
  #if defined(CONFIG_JOYSTICK_XPAD_LEDS)
        struct xpad_led *led;
@@@ -750,11 -807,47 +809,47 @@@ exit
  }
  
  /* Callers must hold xpad->odata_lock spinlock */
+ static bool xpad_prepare_next_init_packet(struct usb_xpad *xpad)
+ {
+       const struct xboxone_init_packet *init_packet;
+       if (xpad->xtype != XTYPE_XBOXONE)
+               return false;
+       /* Perform initialization sequence for Xbox One pads that require it */
+       while (xpad->init_seq < ARRAY_SIZE(xboxone_init_packets)) {
+               init_packet = &xboxone_init_packets[xpad->init_seq++];
+               if (init_packet->idVendor != 0 &&
+                   init_packet->idVendor != xpad->dev->id.vendor)
+                       continue;
+               if (init_packet->idProduct != 0 &&
+                   init_packet->idProduct != xpad->dev->id.product)
+                       continue;
+               /* This packet applies to our device, so prepare to send it */
+               memcpy(xpad->odata, init_packet->data, init_packet->len);
+               xpad->irq_out->transfer_buffer_length = init_packet->len;
+               /* Update packet with current sequence number */
+               xpad->odata[2] = xpad->odata_serial++;
+               return true;
+       }
+       return false;
+ }
+ /* Callers must hold xpad->odata_lock spinlock */
  static bool xpad_prepare_next_out_packet(struct usb_xpad *xpad)
  {
        struct xpad_output_packet *pkt, *packet = NULL;
        int i;
  
+       /* We may have init packets to send before we can send user commands */
+       if (xpad_prepare_next_init_packet(xpad))
+               return true;
        for (i = 0; i < XPAD_NUM_OUT_PACKETS; i++) {
                if (++xpad->last_out_packet >= XPAD_NUM_OUT_PACKETS)
                        xpad->last_out_packet = 0;
@@@ -940,24 -1033,17 +1035,17 @@@ static int xpad_inquiry_pad_presence(st
  
  static int xpad_start_xbox_one(struct usb_xpad *xpad)
  {
-       struct xpad_output_packet *packet =
-                       &xpad->out_packets[XPAD_OUT_CMD_IDX];
        unsigned long flags;
        int retval;
  
        spin_lock_irqsave(&xpad->odata_lock, flags);
  
-       /* Xbox one controller needs to be initialized. */
-       packet->data[0] = 0x05;
-       packet->data[1] = 0x20;
-       packet->data[2] = xpad->odata_serial++; /* packet serial */
-       packet->data[3] = 0x01; /* rumble bit enable?  */
-       packet->data[4] = 0x00;
-       packet->len = 5;
-       packet->pending = true;
-       /* Reset the sequence so we send out start packet first */
-       xpad->last_out_packet = -1;
+       /*
+        * Begin the init sequence by attempting to send a packet.
+        * We will cycle through the init packet sequence before
+        * sending any packets from the output ring.
+        */
+       xpad->init_seq = 0;
        retval = xpad_try_sending_next_out_packet(xpad);
  
        spin_unlock_irqrestore(&xpad->odata_lock, flags);
@@@ -64,6 -64,7 +64,7 @@@ header-y += auto_fs.
  header-y += auxvec.h
  header-y += ax25.h
  header-y += b1lli.h
+ header-y += batman_adv.h
  header-y += baycom.h
  header-y += bcm933xx_hcs.h
  header-y += bfs_fs.h
@@@ -109,6 -110,7 +110,7 @@@ header-y += dlm_netlink.
  header-y += dlm_plock.h
  header-y += dm-ioctl.h
  header-y += dm-log-userspace.h
+ header-y += dma-buf.h
  header-y += dn.h
  header-y += dqblk_xfs.h
  header-y += edd.h
@@@ -194,6 -196,7 +196,7 @@@ header-y += if_tun.
  header-y += if_tunnel.h
  header-y += if_vlan.h
  header-y += if_x25.h
+ header-y += ife.h
  header-y += igmp.h
  header-y += ila.h
  header-y += in6.h
@@@ -305,6 -308,7 +308,7 @@@ header-y += netrom.
  header-y += net_namespace.h
  header-y += net_tstamp.h
  header-y += nfc.h
+ header-y += psample.h
  header-y += nfs2.h
  header-y += nfs3.h
  header-y += nfs4.h
@@@ -379,6 -383,10 +383,10 @@@ header-y += sctp.
  header-y += sdla.h
  header-y += seccomp.h
  header-y += securebits.h
+ header-y += seg6_genl.h
+ header-y += seg6.h
+ header-y += seg6_hmac.h
+ header-y += seg6_iptunnel.h
  header-y += selinux_netlink.h
  header-y += sem.h
  header-y += serial_core.h
@@@ -437,7 -445,6 +445,7 @@@ header-y += unistd.
  header-y += unix_diag.h
  header-y += usbdevice_fs.h
  header-y += usbip.h
 +header-y += userio.h
  header-y += utime.h
  header-y += utsname.h
  header-y += uuid.h
@@@ -459,6 -466,7 +467,7 @@@ header-y += virtio_console.
  header-y += virtio_gpu.h
  header-y += virtio_ids.h
  header-y += virtio_input.h
+ header-y += virtio_mmio.h
  header-y += virtio_net.h
  header-y += virtio_pci.h
  header-y += virtio_ring.h