Merge tag 'v6.4' into next
[sfrench/cifs-2.6.git] / drivers / input / joystick / xpad.c
index f33622fe946f657380155fd1db111ab9d23e39f3..ede380551e55ca9f5fe1f9dab02fe9b50c2403e6 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * X-Box gamepad driver
+ * Xbox gamepad driver
  *
  * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de>
  *               2004 Oliver Schwartz <Oliver.Schwartz@gmx.de>,
@@ -23,8 +23,8 @@
  *  - ITO Takayuki for providing essential xpad information on his website
  *  - Vojtech Pavlik     - iforce driver / input subsystem
  *  - Greg Kroah-Hartman - usb-skeleton driver
- *  - XBOX Linux project - extra USB id's
- *  - Pekka Pöyry (quantus) - Xbox One controller reverse engineering
+ *  - Xbox Linux project - extra USB IDs
+ *  - Pekka Pöyry (quantus) - Xbox One controller reverse-engineering
  *
  * TODO:
  *  - fine tune axes (especially trigger axes)
@@ -52,7 +52,7 @@
  * 2002-07-17 - 0.0.5 : simplified d-pad handling
  *
  * 2004-10-02 - 0.0.6 : DDR pad support
- *  - borrowed from the XBOX linux kernel
+ *  - borrowed from the Xbox Linux kernel
  *  - USB id's for commonly used dance pads are present
  *  - dance pads will map D-PAD to buttons, not axes
  *  - pass the module paramater 'dpad_to_buttons' to force
@@ -264,6 +264,7 @@ static const struct xpad_device {
        { 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE },
        { 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
        { 0x0f0d, 0x00c5, "Hori Fighting Commander ONE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+       { 0x0f0d, 0x00dc, "HORIPAD FPS for Nintendo Switch", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
        { 0x0f30, 0x010b, "Philips Recoil", 0, XTYPE_XBOX },
        { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
        { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
@@ -365,6 +366,7 @@ static const struct xpad_device {
        { 0x31e3, 0x1300, "Wooting 60HE (AVR)", 0, XTYPE_XBOX360 },
        { 0x31e3, 0x1310, "Wooting 60HE (ARM)", 0, XTYPE_XBOX360 },
        { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 },
+       { 0x3537, 0x1004, "GameSir T4 Kaleid", 0, XTYPE_XBOX360 },
        { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX },
        { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
        { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
@@ -454,51 +456,53 @@ static const signed short xpad_btn_paddles[] = {
        { XPAD_XBOXONE_VENDOR_PROTOCOL((vend), 208) }
 
 static const struct usb_device_id xpad_table[] = {
-       { USB_INTERFACE_INFO('X', 'B', 0) },    /* X-Box USB-IF not approved class */
-       XPAD_XBOX360_VENDOR(0x0079),            /* GPD Win 2 Controller */
+       { USB_INTERFACE_INFO('X', 'B', 0) },    /* Xbox USB-IF not-approved class */
+       XPAD_XBOX360_VENDOR(0x0079),            /* GPD Win 2 controller */
        XPAD_XBOX360_VENDOR(0x03eb),            /* Wooting Keyboards (Legacy) */
-       XPAD_XBOX360_VENDOR(0x044f),            /* Thrustmaster X-Box 360 controllers */
-       XPAD_XBOX360_VENDOR(0x045e),            /* Microsoft X-Box 360 controllers */
-       XPAD_XBOXONE_VENDOR(0x045e),            /* Microsoft X-Box One controllers */
-       XPAD_XBOX360_VENDOR(0x046d),            /* Logitech X-Box 360 style controllers */
+       XPAD_XBOX360_VENDOR(0x044f),            /* Thrustmaster Xbox 360 controllers */
+       XPAD_XBOX360_VENDOR(0x045e),            /* Microsoft Xbox 360 controllers */
+       XPAD_XBOXONE_VENDOR(0x045e),            /* Microsoft Xbox One controllers */
+       XPAD_XBOX360_VENDOR(0x046d),            /* Logitech Xbox 360-style controllers */
        XPAD_XBOX360_VENDOR(0x056e),            /* Elecom JC-U3613M */
        XPAD_XBOX360_VENDOR(0x06a3),            /* Saitek P3600 */
-       XPAD_XBOX360_VENDOR(0x0738),            /* Mad Catz X-Box 360 controllers */
+       XPAD_XBOX360_VENDOR(0x0738),            /* Mad Catz Xbox 360 controllers */
        { USB_DEVICE(0x0738, 0x4540) },         /* Mad Catz Beat Pad */
        XPAD_XBOXONE_VENDOR(0x0738),            /* Mad Catz FightStick TE 2 */
-       XPAD_XBOX360_VENDOR(0x07ff),            /* Mad Catz GamePad */
+       XPAD_XBOX360_VENDOR(0x07ff),            /* Mad Catz Gamepad */
        XPAD_XBOX360_VENDOR(0x0c12),            /* Zeroplus X-Box 360 controllers */
-       XPAD_XBOX360_VENDOR(0x0e6f),            /* 0x0e6f X-Box 360 controllers */
-       XPAD_XBOXONE_VENDOR(0x0e6f),            /* 0x0e6f X-Box One controllers */
-       XPAD_XBOX360_VENDOR(0x0f0d),            /* Hori Controllers */
-       XPAD_XBOXONE_VENDOR(0x0f0d),            /* Hori Controllers */
-       XPAD_XBOX360_VENDOR(0x1038),            /* SteelSeries Controllers */
+       XPAD_XBOX360_VENDOR(0x0e6f),            /* 0x0e6f Xbox 360 controllers */
+       XPAD_XBOXONE_VENDOR(0x0e6f),            /* 0x0e6f Xbox One controllers */
+       XPAD_XBOX360_VENDOR(0x0f0d),            /* Hori controllers */
+       XPAD_XBOXONE_VENDOR(0x0f0d),            /* Hori controllers */
+       XPAD_XBOX360_VENDOR(0x1038),            /* SteelSeries controllers */
        XPAD_XBOXONE_VENDOR(0x10f5),            /* Turtle Beach Controllers */
        XPAD_XBOX360_VENDOR(0x11c9),            /* Nacon GC100XF */
        XPAD_XBOX360_VENDOR(0x1209),            /* Ardwiino Controllers */
-       XPAD_XBOX360_VENDOR(0x12ab),            /* X-Box 360 dance pads */
-       XPAD_XBOX360_VENDOR(0x1430),            /* RedOctane X-Box 360 controllers */
-       XPAD_XBOX360_VENDOR(0x146b),            /* BigBen Interactive Controllers */
+       XPAD_XBOX360_VENDOR(0x12ab),            /* Xbox 360 dance pads */
+       XPAD_XBOX360_VENDOR(0x1430),            /* RedOctane Xbox 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(0x15e4),            /* Numark Xbox 360 controllers */
+       XPAD_XBOX360_VENDOR(0x162e),            /* Joytech Xbox 360 controllers */
        XPAD_XBOX360_VENDOR(0x1689),            /* Razer Onza */
        XPAD_XBOX360_VENDOR(0x1949),            /* Amazon controllers */
-       XPAD_XBOX360_VENDOR(0x1bad),            /* Harminix Rock Band Guitar and Drums */
-       XPAD_XBOX360_VENDOR(0x20d6),            /* PowerA Controllers */
-       XPAD_XBOXONE_VENDOR(0x20d6),            /* PowerA Controllers */
-       XPAD_XBOX360_VENDOR(0x24c6),            /* PowerA Controllers */
-       XPAD_XBOXONE_VENDOR(0x24c6),            /* PowerA Controllers */
+       XPAD_XBOX360_VENDOR(0x1bad),            /* Harmonix Rock Band guitar and drums */
+       XPAD_XBOX360_VENDOR(0x20d6),            /* PowerA controllers */
+       XPAD_XBOXONE_VENDOR(0x20d6),            /* PowerA controllers */
+       XPAD_XBOX360_VENDOR(0x24c6),            /* PowerA controllers */
+       XPAD_XBOXONE_VENDOR(0x24c6),            /* PowerA controllers */
        XPAD_XBOX360_VENDOR(0x2563),            /* OneXPlayer Gamepad */
        XPAD_XBOX360_VENDOR(0x260d),            /* Dareu H101 */
        XPAD_XBOX360_VENDOR(0x2c22),            /* Qanba Controllers */
        XPAD_XBOX360_VENDOR(0x2dc8),            /* 8BitDo Pro 2 Wired Controller */
        XPAD_XBOXONE_VENDOR(0x2dc8),            /* 8BitDo Pro 2 Wired Controller for Xbox */
-       XPAD_XBOXONE_VENDOR(0x2e24),            /* Hyperkin Duke X-Box One pad */
-       XPAD_XBOX360_VENDOR(0x2f24),            /* GameSir Controllers */
+       XPAD_XBOXONE_VENDOR(0x2e24),            /* Hyperkin Duke Xbox One pad */
+       XPAD_XBOX360_VENDOR(0x2f24),            /* GameSir controllers */
        XPAD_XBOX360_VENDOR(0x31e3),            /* Wooting Keyboards */
        XPAD_XBOX360_VENDOR(0x3285),            /* Nacon GC-100 */
+       XPAD_XBOX360_VENDOR(0x3537),            /* GameSir Controllers */
+       XPAD_XBOXONE_VENDOR(0x3537),            /* GameSir Controllers */
        { }
 };
 
@@ -724,7 +728,7 @@ static void xpad360w_poweroff_controller(struct usb_xpad *xpad);
  *     Completes a request by converting the data into events for the
  *     input subsystem.
  *
- *     The used report descriptor was taken from ITO Takayukis website:
+ *     The used report descriptor was taken from ITO Takayuki's website:
  *      http://euc.jp/periphs/xbox-controller.ja.html
  */
 static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
@@ -1569,7 +1573,7 @@ struct xpad_led {
 };
 
 /*
- * set the LEDs on Xbox360 / Wireless Controllers
+ * set the LEDs on Xbox 360 / Wireless Controllers
  * @param command
  *  0: off
  *  1: all blink, then previous setting
@@ -1720,6 +1724,27 @@ static int xpad_start_input(struct usb_xpad *xpad)
                        return error;
                }
        }
+       if (xpad->xtype == XTYPE_XBOX360) {
+               /*
+                * Some third-party controllers Xbox 360-style controllers
+                * require this message to finish initialization.
+                */
+               u8 dummy[20];
+
+               error = usb_control_msg_recv(xpad->udev, 0,
+                                            /* bRequest */ 0x01,
+                                            /* bmRequestType */
+                                            USB_TYPE_VENDOR | USB_DIR_IN |
+                                               USB_RECIP_INTERFACE,
+                                            /* wValue */ 0x100,
+                                            /* wIndex */ 0x00,
+                                            dummy, sizeof(dummy),
+                                            25, GFP_KERNEL);
+               if (error)
+                       dev_warn(&xpad->dev->dev,
+                                "unable to receive magic message: %d\n",
+                                error);
+       }
 
        return 0;
 }
@@ -2229,5 +2254,5 @@ static struct usb_driver xpad_driver = {
 module_usb_driver(xpad_driver);
 
 MODULE_AUTHOR("Marko Friedemann <mfr@bmx-chemnitz.de>");
-MODULE_DESCRIPTION("X-Box pad driver");
+MODULE_DESCRIPTION("Xbox pad driver");
 MODULE_LICENSE("GPL");