]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
xpad fixes and quirks for 3.18
authorSasha Levin <sashal@kernel.org>
Thu, 29 Nov 2018 09:06:06 +0000 (04:06 -0500)
committerSasha Levin <sashal@kernel.org>
Thu, 29 Nov 2018 09:06:06 +0000 (04:06 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
56 files changed:
queue-3.18/input-initialize-device-counter-variables-with-1.patch [new file with mode: 0644]
queue-3.18/input-xpad-add-covert-forces-edition-of-the-xbox-one.patch [new file with mode: 0644]
queue-3.18/input-xpad-add-gpd-win-2-controller-usb-ids.patch [new file with mode: 0644]
queue-3.18/input-xpad-add-mad-catz-fightstick-te-2-vid-pid.patch [new file with mode: 0644]
queue-3.18/input-xpad-add-more-third-party-controllers.patch [new file with mode: 0644]
queue-3.18/input-xpad-add-pdp-device-id-0x02a4.patch [new file with mode: 0644]
queue-3.18/input-xpad-add-product-id-for-xbox-one-s-pad.patch [new file with mode: 0644]
queue-3.18/input-xpad-add-rumble-support-for-xbox-one-controlle.patch [new file with mode: 0644]
queue-3.18/input-xpad-add-support-for-pdp-xbox-one-controllers.patch [new file with mode: 0644]
queue-3.18/input-xpad-add-support-for-xbox1-pdp-camo-series-gam.patch [new file with mode: 0644]
queue-3.18/input-xpad-add-usb-ids-for-mad-catz-brawlstick-and-r.patch [new file with mode: 0644]
queue-3.18/input-xpad-avoid-using-__set_bit-for-capabilities.patch [new file with mode: 0644]
queue-3.18/input-xpad-clarify-led-enumeration.patch [new file with mode: 0644]
queue-3.18/input-xpad-constify-usb_device_id.patch [new file with mode: 0644]
queue-3.18/input-xpad-correct-xbox-one-pad-device-name.patch [new file with mode: 0644]
queue-3.18/input-xpad-correctly-handle-concurrent-led-and-ff-re.patch [new file with mode: 0644]
queue-3.18/input-xpad-correctly-sort-vendor-id-s.patch [new file with mode: 0644]
queue-3.18/input-xpad-don-t-depend-on-endpoint-order.patch [new file with mode: 0644]
queue-3.18/input-xpad-factor-out-urb-submission-in-xpad_play_ef.patch [new file with mode: 0644]
queue-3.18/input-xpad-fix-clash-of-presence-handling-with-led-s.patch [new file with mode: 0644]
queue-3.18/input-xpad-fix-gpd-win-2-controller-name.patch [new file with mode: 0644]
queue-3.18/input-xpad-fix-oops-when-attaching-an-unknown-xbox-o.patch [new file with mode: 0644]
queue-3.18/input-xpad-fix-powera-init-quirk-for-some-gamepad-mo.patch [new file with mode: 0644]
queue-3.18/input-xpad-fix-razer-atrox-arcade-stick-button-mappi.patch [new file with mode: 0644]
queue-3.18/input-xpad-fix-rumble-on-xbox-one-controllers-with-2.patch [new file with mode: 0644]
queue-3.18/input-xpad-fix-some-coding-style-issues.patch [new file with mode: 0644]
queue-3.18/input-xpad-fix-stuck-mode-button-on-xbox-one-s-pad.patch [new file with mode: 0644]
queue-3.18/input-xpad-fix-xbox-one-rumble-stopping-after-2.5-se.patch [new file with mode: 0644]
queue-3.18/input-xpad-handle-present-and-gone-correctly.patch [new file with mode: 0644]
queue-3.18/input-xpad-move-pending-clear-to-the-correct-locatio.patch [new file with mode: 0644]
queue-3.18/input-xpad-move-reporting-xbox-one-home-button-to-co.patch [new file with mode: 0644]
queue-3.18/input-xpad-move-the-input-device-creation-to-a-new-f.patch [new file with mode: 0644]
queue-3.18/input-xpad-power-off-wireless-360-controllers-on-sus.patch [new file with mode: 0644]
queue-3.18/input-xpad-prevent-spurious-input-from-wired-xbox-36.patch [new file with mode: 0644]
queue-3.18/input-xpad-query-wireless-controller-state-at-init.patch [new file with mode: 0644]
queue-3.18/input-xpad-re-send-led-command-on-present-event.patch [new file with mode: 0644]
queue-3.18/input-xpad-remove-needless-bulk-out-urb-used-for-led.patch [new file with mode: 0644]
queue-3.18/input-xpad-remove-spurious-events-of-wireless-xpad-3.patch [new file with mode: 0644]
queue-3.18/input-xpad-remove-unused-function.patch [new file with mode: 0644]
queue-3.18/input-xpad-restore-led-state-after-device-resume.patch [new file with mode: 0644]
queue-3.18/input-xpad-set-the-leds-properly-on-xbox-wireless-co.patch [new file with mode: 0644]
queue-3.18/input-xpad-simplify-error-condition-in-init_output.patch [new file with mode: 0644]
queue-3.18/input-xpad-sort-supported-devices-by-usb-id.patch [new file with mode: 0644]
queue-3.18/input-xpad-support-some-quirky-xbox-one-pads.patch [new file with mode: 0644]
queue-3.18/input-xpad-sync-supported-devices-with-360controller.patch [new file with mode: 0644]
queue-3.18/input-xpad-sync-supported-devices-with-xbcd.patch [new file with mode: 0644]
queue-3.18/input-xpad-sync-supported-devices-with-xboxdrv.patch [new file with mode: 0644]
queue-3.18/input-xpad-update-xbox-one-force-feedback-support.patch [new file with mode: 0644]
queue-3.18/input-xpad-use-correct-product-id-for-x360w-controll.patch [new file with mode: 0644]
queue-3.18/input-xpad-use-ida-for-finding-the-pad_nr.patch [new file with mode: 0644]
queue-3.18/input-xpad-use-led-api-when-identifying-wireless-con.patch [new file with mode: 0644]
queue-3.18/input-xpad-validate-usb-endpoint-type-during-probe.patch [new file with mode: 0644]
queue-3.18/input-xpad-workaround-dead-irq_out-after-suspend-res.patch [new file with mode: 0644]
queue-3.18/input-xpad-x360w-report-dpad-as-buttons-and-axes.patch [new file with mode: 0644]
queue-3.18/input-xpad-xbox-one-elite-controller-support.patch [new file with mode: 0644]
queue-3.18/series

diff --git a/queue-3.18/input-initialize-device-counter-variables-with-1.patch b/queue-3.18/input-initialize-device-counter-variables-with-1.patch
new file mode 100644 (file)
index 0000000..725b18f
--- /dev/null
@@ -0,0 +1,139 @@
+From 32668ba47b820592b25c87acb1955d1c23b1ad69 Mon Sep 17 00:00:00 2001
+From: Aniroop Mathur <aniroop.mathur@gmail.com>
+Date: Wed, 3 Dec 2014 14:27:42 -0800
+Subject: Input: initialize device counter variables with -1
+
+[ Upstream commit 939ffb1712890ee22146d2dfc24adbc7da6afa84 ]
+
+Let's initialize atomic_t variables keeping track of number of various
+devices created so far with -1 in order to avoid extra subtraction
+operation.
+
+Signed-off-by: Aniroop Mathur <aniroop.mathur@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/gameport/gameport.c | 4 ++--
+ drivers/input/joystick/xpad.c     | 8 ++++----
+ drivers/input/misc/ims-pcu.c      | 4 ++--
+ drivers/input/serio/serio.c       | 4 ++--
+ drivers/input/serio/serio_raw.c   | 4 ++--
+ 5 files changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
+index e29c04e2aff4..e853a2134680 100644
+--- a/drivers/input/gameport/gameport.c
++++ b/drivers/input/gameport/gameport.c
+@@ -527,14 +527,14 @@ EXPORT_SYMBOL(gameport_set_phys);
+  */
+ static void gameport_init_port(struct gameport *gameport)
+ {
+-      static atomic_t gameport_no = ATOMIC_INIT(0);
++      static atomic_t gameport_no = ATOMIC_INIT(-1);
+       __module_get(THIS_MODULE);
+       mutex_init(&gameport->drv_mutex);
+       device_initialize(&gameport->dev);
+       dev_set_name(&gameport->dev, "gameport%lu",
+-                      (unsigned long)atomic_inc_return(&gameport_no) - 1);
++                      (unsigned long)atomic_inc_return(&gameport_no));
+       gameport->dev.bus = &gameport_bus;
+       gameport->dev.release = gameport_release_port;
+       if (gameport->parent)
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 1a728f310b27..9843c8cca2f7 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -888,8 +888,8 @@ static void xpad_led_set(struct led_classdev *led_cdev,
+ static int xpad_led_probe(struct usb_xpad *xpad)
+ {
+-      static atomic_t led_seq = ATOMIC_INIT(0);
+-      long led_no;
++      static atomic_t led_seq = ATOMIC_INIT(-1);
++      unsigned long led_no;
+       struct xpad_led *led;
+       struct led_classdev *led_cdev;
+       int error;
+@@ -901,9 +901,9 @@ static int xpad_led_probe(struct usb_xpad *xpad)
+       if (!led)
+               return -ENOMEM;
+-      led_no = (long)atomic_inc_return(&led_seq) - 1;
++      led_no = atomic_inc_return(&led_seq);
+-      snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
++      snprintf(led->name, sizeof(led->name), "xpad%lu", led_no);
+       led->xpad = xpad;
+       led_cdev = &led->led_cdev;
+diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
+index 063898d429c7..b5304e264881 100644
+--- a/drivers/input/misc/ims-pcu.c
++++ b/drivers/input/misc/ims-pcu.c
+@@ -1871,7 +1871,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
+ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
+ {
+-      static atomic_t device_no = ATOMIC_INIT(0);
++      static atomic_t device_no = ATOMIC_INIT(-1);
+       const struct ims_pcu_device_info *info;
+       int error;
+@@ -1902,7 +1902,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
+       }
+       /* Device appears to be operable, complete initialization */
+-      pcu->device_no = atomic_inc_return(&device_no) - 1;
++      pcu->device_no = atomic_inc_return(&device_no);
+       /*
+        * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor
+diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
+index d399b8b0f000..a05a5179da32 100644
+--- a/drivers/input/serio/serio.c
++++ b/drivers/input/serio/serio.c
+@@ -514,7 +514,7 @@ static void serio_release_port(struct device *dev)
+  */
+ static void serio_init_port(struct serio *serio)
+ {
+-      static atomic_t serio_no = ATOMIC_INIT(0);
++      static atomic_t serio_no = ATOMIC_INIT(-1);
+       __module_get(THIS_MODULE);
+@@ -525,7 +525,7 @@ static void serio_init_port(struct serio *serio)
+       mutex_init(&serio->drv_mutex);
+       device_initialize(&serio->dev);
+       dev_set_name(&serio->dev, "serio%lu",
+-                   (unsigned long)atomic_inc_return(&serio_no) - 1);
++                   (unsigned long)atomic_inc_return(&serio_no));
+       serio->dev.bus = &serio_bus;
+       serio->dev.release = serio_release_port;
+       serio->dev.groups = serio_device_attr_groups;
+diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
+index c9a02fe57576..71ef5d65a0c6 100644
+--- a/drivers/input/serio/serio_raw.c
++++ b/drivers/input/serio/serio_raw.c
+@@ -292,7 +292,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
+ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
+ {
+-      static atomic_t serio_raw_no = ATOMIC_INIT(0);
++      static atomic_t serio_raw_no = ATOMIC_INIT(-1);
+       struct serio_raw *serio_raw;
+       int err;
+@@ -303,7 +303,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
+       }
+       snprintf(serio_raw->name, sizeof(serio_raw->name),
+-               "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
++               "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no));
+       kref_init(&serio_raw->kref);
+       INIT_LIST_HEAD(&serio_raw->client_list);
+       init_waitqueue_head(&serio_raw->wait);
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-add-covert-forces-edition-of-the-xbox-one.patch b/queue-3.18/input-xpad-add-covert-forces-edition-of-the-xbox-one.patch
new file mode 100644 (file)
index 0000000..21575a9
--- /dev/null
@@ -0,0 +1,31 @@
+From 8c510fd71bf21cf9e310cb0b66b9352a57d5c7d2 Mon Sep 17 00:00:00 2001
+From: Erik Lundgren <eriklundgren93@gmail.com>
+Date: Tue, 6 Oct 2015 17:04:11 -0700
+Subject: Input: xpad - add Covert Forces edition of the Xbox One controller
+
+[ Upstream commit 39a7a88872df98f0c3c50fe278fd1a1f597afd95 ]
+
+It is identical to the Xbox One controller but has a different product ID.
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index a66720136290..7657cf4f08d9 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -125,6 +125,7 @@ static const struct xpad_device {
+       { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
+       { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
+       { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
++      { 0x045e, 0x02dd, "Microsoft X-Box One pad (Covert Forces)", 0, XTYPE_XBOXONE },
+       { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+       { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+       { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-add-gpd-win-2-controller-usb-ids.patch b/queue-3.18/input-xpad-add-gpd-win-2-controller-usb-ids.patch
new file mode 100644 (file)
index 0000000..47fe077
--- /dev/null
@@ -0,0 +1,42 @@
+From 44433a0de2fb765af322538002b8fd9915c52565 Mon Sep 17 00:00:00 2001
+From: Ethan Lee <flibitijibibo@gmail.com>
+Date: Fri, 1 Jun 2018 11:46:08 -0700
+Subject: Input: xpad - add GPD Win 2 Controller USB IDs
+
+[ Upstream commit c1ba08390a8bb13c927e699330896adc15b78205 ]
+
+GPD Win 2 Website: http://www.gpd.hk/gpdwin2.asp
+
+Tested on a unit from the first production run sent to Indiegogo backers
+
+Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 5bf85c43e6d9..66cc37b41113 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -128,6 +128,7 @@ static const struct xpad_device {
+       u8 mapping;
+       u8 xtype;
+ } xpad_device[] = {
++      { 0x0079, 0x18d4, "GPD Win 2 Controller", 0, XTYPE_XBOX360 },
+       { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX },
+       { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX },
+       { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
+@@ -414,6 +415,7 @@ static const signed short xpad_abs_triggers[] = {
+ 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 */
+       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 */
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-add-mad-catz-fightstick-te-2-vid-pid.patch b/queue-3.18/input-xpad-add-mad-catz-fightstick-te-2-vid-pid.patch
new file mode 100644 (file)
index 0000000..9cb820d
--- /dev/null
@@ -0,0 +1,59 @@
+From 4dd8d7672ab0f802369202bf24ec903daa205a6f Mon Sep 17 00:00:00 2001
+From: Silvan Jegen <s.jegen@gmail.com>
+Date: Thu, 17 Mar 2016 17:15:01 -0700
+Subject: Input: xpad - add Mad Catz FightStick TE 2 VID/PID
+
+[ Upstream commit d63b0f0c0f19dc8687387ead5a28148dcad1a4b9 ]
+
+This adds the VID/PID combination for the Xbox One version of the Mad
+Catz FightStick TE 2.
+
+The functionality that this provides is about on par with what the
+Windows drivers for the stick manage to deliver.
+
+What works:
+- Digital stick
+- 6 main buttons
+- Xbox button
+- The two buttons on the back
+- The locking buttons (preventing accidental Xbox button press)
+
+What doesn't work:
+- Two of the main buttons (don't work on Windows either)
+- The "Haptic" button setting does not have an effect (not sure if it
+  works on Windows)
+
+I added the MAP_TRIGGERS_TO_BUTTONS option but in my (limited) testing
+there was no practical difference with or without. The FightStick does
+not have triggers though so adding it makes sense.
+
+Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 5dc818aef2d1..6e15ce40dbab 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -153,6 +153,7 @@ static const struct xpad_device {
+       { 0x0738, 0x4728, "Mad Catz Street Fighter IV FightPad", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0738, 0x4740, "Mad Catz Beat Pad", 0, XTYPE_XBOX360 },
++      { 0x0738, 0x4a01, "Mad Catz FightStick TE 2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+       { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
+       { 0x0738, 0xb726, "Mad Catz Xbox controller - MW2", 0, XTYPE_XBOX360 },
+       { 0x0738, 0xbeef, "Mad Catz JOYTECH NEO SE Advanced GamePad", XTYPE_XBOX360 },
+@@ -305,6 +306,7 @@ static struct usb_device_id xpad_table[] = {
+       XPAD_XBOX360_VENDOR(0x046d),            /* Logitech X-Box 360 style controllers */
+       XPAD_XBOX360_VENDOR(0x0738),            /* Mad Catz X-Box 360 controllers */
+       { USB_DEVICE(0x0738, 0x4540) },         /* Mad Catz Beat Pad */
++      XPAD_XBOXONE_VENDOR(0x0738),            /* Mad Catz FightStick TE 2 */
+       XPAD_XBOX360_VENDOR(0x0e6f),            /* 0x0e6f X-Box 360 controllers */
+       XPAD_XBOX360_VENDOR(0x12ab),            /* X-Box 360 dance pads */
+       XPAD_XBOX360_VENDOR(0x1430),            /* RedOctane X-Box 360 controllers */
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-add-more-third-party-controllers.patch b/queue-3.18/input-xpad-add-more-third-party-controllers.patch
new file mode 100644 (file)
index 0000000..83420f6
--- /dev/null
@@ -0,0 +1,78 @@
+From b5dd82572c45b239027f8fdd2ca89ced85708c33 Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Fri, 27 May 2016 16:24:20 -0700
+Subject: Input: xpad - add more third-party controllers
+
+[ Upstream commit 6538c3b2d2d220a974e47928b165ea09b9cfa6b4 ]
+
+Signed-off-by: Pierre-Loup A. Griffais <eduke32@plagman.net>
+Signed-off-by: Thomas Debesse <dev@illwieckz.net>
+Signed-off-by: aronschatz <aronschatz@aselabs.com>
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 43b09dbacee6..2a0573eeadaa 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -173,9 +173,11 @@ static const struct xpad_device {
+       { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX },
+       { 0x0e6f, 0x0105, "HSM3 Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0113, "Afterglow AX.1 Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
++      { 0x0e6f, 0x0139, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
++      { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX },
+@@ -183,6 +185,7 @@ static const struct xpad_device {
+       { 0x0f0d, 0x000a, "Hori Co. DOA4 FightStick", 0, XTYPE_XBOX360 },
+       { 0x0f0d, 0x000d, "Hori Fighting Stick EX2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE },
+       { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
+       { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
+       { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX },
+@@ -200,6 +203,7 @@ static const struct xpad_device {
+       { 0x162e, 0xbeef, "Joytech Neo-Se Take2", 0, XTYPE_XBOX360 },
+       { 0x1689, 0xfd00, "Razer Onza Tournament Edition", 0, XTYPE_XBOX360 },
+       { 0x1689, 0xfd01, "Razer Onza Classic Edition", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0x542a, "Xbox ONE spectra", 0, XTYPE_XBOXONE },
+       { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+@@ -213,6 +217,8 @@ static const struct xpad_device {
+       { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0x541a, "PowerA Xbox One Mini Wired Controller", 0, XTYPE_XBOXONE },
++      { 0x24c6, 0x543a, "PowerA Xbox One wired controller", 0, XTYPE_XBOXONE },
+       { 0x24c6, 0x5500, "Hori XBOX 360 EX 2 with Turbo", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5506, "Hori SOULCALIBUR V Stick", 0, XTYPE_XBOX360 },
+@@ -308,13 +314,16 @@ static struct usb_device_id xpad_table[] = {
+       { USB_DEVICE(0x0738, 0x4540) },         /* Mad Catz Beat Pad */
+       XPAD_XBOXONE_VENDOR(0x0738),            /* Mad Catz FightStick TE 2 */
+       XPAD_XBOX360_VENDOR(0x0e6f),            /* 0x0e6f X-Box 360 controllers */
++      XPAD_XBOXONE_VENDOR(0x0e6f),            /* 0x0e6f X-Box One 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(0x1bad),            /* Harminix Rock Band Guitar and Drums */
+       XPAD_XBOX360_VENDOR(0x0f0d),            /* Hori Controllers */
++      XPAD_XBOXONE_VENDOR(0x0f0d),            /* Hori Controllers */
+       XPAD_XBOX360_VENDOR(0x1689),            /* Razer Onza */
+       XPAD_XBOX360_VENDOR(0x24c6),            /* PowerA Controllers */
++      XPAD_XBOXONE_VENDOR(0x24c6),            /* PowerA Controllers */
+       XPAD_XBOX360_VENDOR(0x1532),            /* Razer Sabertooth */
+       XPAD_XBOXONE_VENDOR(0x1532),            /* Razer Wildcat */
+       XPAD_XBOX360_VENDOR(0x15e4),            /* Numark X-Box 360 controllers */
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-add-pdp-device-id-0x02a4.patch b/queue-3.18/input-xpad-add-pdp-device-id-0x02a4.patch
new file mode 100644 (file)
index 0000000..658f680
--- /dev/null
@@ -0,0 +1,62 @@
+From 23af7e3532f79c1e9a993915b22a16a108009cb9 Mon Sep 17 00:00:00 2001
+From: Francis Therien <frtherien@gmail.com>
+Date: Mon, 26 Mar 2018 15:59:00 -0700
+Subject: Input: xpad - add PDP device id 0x02a4
+
+[ Upstream commit c6c848572f4da0e34ffe0a35364b4db871e13e42 ]
+
+Adds support for a PDP Xbox One controller with device ID
+(0x06ef:0x02a4). The Product string for this device is "PDP Wired
+Controller for Xbox One - Stealth Series | Phantom Black".
+
+Signed-off-by: Francis Therien <frtherien@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index d88d3e0f59fb..298581b0f6c1 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -230,6 +230,7 @@ static const struct xpad_device {
+       { 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0246, "Rock Candy Gamepad for Xbox One 2015", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02ab, "PDP Controller for Xbox One", 0, XTYPE_XBOXONE },
++      { 0x0e6f, 0x02a4, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0346, "Rock Candy Gamepad for Xbox One 2016", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
+@@ -478,7 +479,8 @@ static const u8 xboxone_hori_init[] = {
+ /*
+  * This packet is required for some of the PDP pads to start
+- * sending input reports. One of those pads is (0x0e6f:0x02ab).
++ * sending input reports. These pads include: (0x0e6f:0x02ab),
++ * (0x0e6f:0x02a4).
+  */
+ static const u8 xboxone_pdp_init1[] = {
+       0x0a, 0x20, 0x00, 0x03, 0x00, 0x01, 0x14
+@@ -486,7 +488,8 @@ static const u8 xboxone_pdp_init1[] = {
+ /*
+  * This packet is required for some of the PDP pads to start
+- * sending input reports. One of those pads is (0x0e6f:0x02ab).
++ * sending input reports. These pads include: (0x0e6f:0x02ab),
++ * (0x0e6f:0x02a4).
+  */
+ static const u8 xboxone_pdp_init2[] = {
+       0x06, 0x20, 0x00, 0x02, 0x01, 0x00
+@@ -524,6 +527,8 @@ static const struct xboxone_init_packet xboxone_init_packets[] = {
+       XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init),
+       XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init1),
+       XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init2),
++      XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init1),
++      XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init2),
+       XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init),
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-add-product-id-for-xbox-one-s-pad.patch b/queue-3.18/input-xpad-add-product-id-for-xbox-one-s-pad.patch
new file mode 100644 (file)
index 0000000..f9739aa
--- /dev/null
@@ -0,0 +1,32 @@
+From c447ece4799e53966b555d8d5fcbcd40414b9c1f Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Sun, 27 Nov 2016 20:37:31 -0800
+Subject: Input: xpad - add product ID for Xbox One S pad
+
+[ Upstream commit 599b8c09d974d6e4d85a8f7bc8ed7442977866a8 ]
+
+This is the new gamepad that ships with the Xbox One S which
+includes Bluetooth functionality.
+
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 9cbd485c0f73..48a88d7cb513 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -134,6 +134,7 @@ static const struct xpad_device {
+       { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
+       { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
+       { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE },
++      { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE },
+       { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+       { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+       { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-add-rumble-support-for-xbox-one-controlle.patch b/queue-3.18/input-xpad-add-rumble-support-for-xbox-one-controlle.patch
new file mode 100644 (file)
index 0000000..fb936c5
--- /dev/null
@@ -0,0 +1,72 @@
+From f21d3109d3296ef265fa37e0eec54f3ab840a63b Mon Sep 17 00:00:00 2001
+From: Ming-ting Yao Wei <mwei@lxde.org>
+Date: Tue, 14 Apr 2015 16:59:11 -0700
+Subject: Input: xpad - add rumble support for Xbox One controller
+
+[ Upstream commit 0604949ce3b9a59cff419daf706272620a9a0df0 ]
+
+This adds rumble support for Xbox One controller by sending continuous
+rumble command. Trigger button rumbling is not yet implemented.
+
+Signed-off-by: Ming-ting Yao Wei <mwei@lxde.org>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 21 ++++++++++++++++++++-
+ 1 file changed, 20 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 9843c8cca2f7..c4205ed022fd 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -31,12 +31,14 @@
+  *  - the iForce driver    drivers/char/joystick/iforce.c
+  *  - the skeleton-driver  drivers/usb/usb-skeleton.c
+  *  - Xbox 360 information http://www.free60.org/wiki/Gamepad
++ *  - Xbox One information https://github.com/quantus/xbox-one-controller-protocol
+  *
+  * Thanks to:
+  *  - 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
+  *
+  * TODO:
+  *  - fine tune axes (especially trigger axes)
+@@ -830,6 +832,23 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
+                       return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
++              case XTYPE_XBOXONE:
++                      xpad->odata[0] = 0x09; /* activate rumble */
++                      xpad->odata[1] = 0x08;
++                      xpad->odata[2] = 0x00;
++                      xpad->odata[3] = 0x08; /* continuous effect */
++                      xpad->odata[4] = 0x00; /* simple rumble mode */
++                      xpad->odata[5] = 0x03; /* L and R actuator only */
++                      xpad->odata[6] = 0x00; /* TODO: LT actuator */
++                      xpad->odata[7] = 0x00; /* TODO: RT actuator */
++                      xpad->odata[8] = strong / 256;  /* left actuator */
++                      xpad->odata[9] = weak / 256;    /* right actuator */
++                      xpad->odata[10] = 0x80; /* length of pulse */
++                      xpad->odata[11] = 0x00; /* stop period of pulse */
++                      xpad->irq_out->transfer_buffer_length = 12;
++
++                      return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
++
+               default:
+                       dev_dbg(&xpad->dev->dev,
+                               "%s - rumble command sent to unsupported xpad type: %d\n",
+@@ -843,7 +862,7 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
+ static int xpad_init_ff(struct usb_xpad *xpad)
+ {
+-      if (xpad->xtype == XTYPE_UNKNOWN || xpad->xtype == XTYPE_XBOXONE)
++      if (xpad->xtype == XTYPE_UNKNOWN)
+               return 0;
+       input_set_capability(xpad->dev, EV_FF, FF_RUMBLE);
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-add-support-for-pdp-xbox-one-controllers.patch b/queue-3.18/input-xpad-add-support-for-pdp-xbox-one-controllers.patch
new file mode 100644 (file)
index 0000000..bc77ee1
--- /dev/null
@@ -0,0 +1,68 @@
+From 3eff32124f73f18507b56a5bd36de6b6dcae12d6 Mon Sep 17 00:00:00 2001
+From: Mark Furneaux <mark@furneaux.ca>
+Date: Mon, 22 Jan 2018 11:24:17 -0800
+Subject: Input: xpad - add support for PDP Xbox One controllers
+
+[ Upstream commit e5c9c6a885fad00aa559b49d8fc23a60e290824e ]
+
+Adds support for the current lineup of Xbox One controllers from PDP
+(Performance Designed Products). These controllers are very picky with
+their initialization sequence and require an additional 2 packets before
+they send any input reports.
+
+Signed-off-by: Mark Furneaux <mark@furneaux.ca>
+Reviewed-by: Cameron Gutman <aicommander@gmail.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 19 +++++++++++++++++++
+ 1 file changed, 19 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index d86e59515b9c..d88d3e0f59fb 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -229,6 +229,7 @@ static const struct xpad_device {
+       { 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0246, "Rock Candy Gamepad for Xbox One 2015", 0, XTYPE_XBOXONE },
++      { 0x0e6f, 0x02ab, "PDP Controller for Xbox One", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0346, "Rock Candy Gamepad for Xbox One 2016", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
+@@ -475,6 +476,22 @@ static const u8 xboxone_hori_init[] = {
+       0x00, 0x00, 0x00, 0x80, 0x00
+ };
++/*
++ * This packet is required for some of the PDP pads to start
++ * sending input reports. One of those pads is (0x0e6f:0x02ab).
++ */
++static const u8 xboxone_pdp_init1[] = {
++      0x0a, 0x20, 0x00, 0x03, 0x00, 0x01, 0x14
++};
++
++/*
++ * This packet is required for some of the PDP pads to start
++ * sending input reports. One of those pads is (0x0e6f:0x02ab).
++ */
++static const u8 xboxone_pdp_init2[] = {
++      0x06, 0x20, 0x00, 0x02, 0x01, 0x00
++};
++
+ /*
+  * A specific rumble packet is required for some PowerA pads to start
+  * sending input reports. One of those pads is (0x24c6:0x543a).
+@@ -505,6 +522,8 @@ 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(0x0e6f, 0x02ab, xboxone_pdp_init1),
++      XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init2),
+       XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init),
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-add-support-for-xbox1-pdp-camo-series-gam.patch b/queue-3.18/input-xpad-add-support-for-xbox1-pdp-camo-series-gam.patch
new file mode 100644 (file)
index 0000000..3e5bf6c
--- /dev/null
@@ -0,0 +1,48 @@
+From a76edb780b373a893ef1b078c4b03bf412b8806f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ramses=20Ram=C3=ADrez?= <ramzeto@gmail.com>
+Date: Fri, 28 Sep 2018 16:59:26 -0700
+Subject: Input: xpad - add support for Xbox1 PDP Camo series gamepad
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+[ Upstream commit 9735082a7cbae572c2eabdc45acecc8c9fa0759b ]
+
+The "Xbox One PDP Wired Controller - Camo series" has a different
+product-id than the regular PDP controller and the PDP stealth series,
+but it uses the same initialization sequence. This patch adds the
+product-id of the camo series to the structures that handle the other
+PDP Xbox One controllers.
+
+Signed-off-by: Ramses Ramírez <ramzeto@gmail.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 69b44aebaf01..2e52015634f9 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -234,6 +234,7 @@ static const struct xpad_device {
+       { 0x0e6f, 0x0246, "Rock Candy Gamepad for Xbox One 2015", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02ab, "PDP Controller for Xbox One", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02a4, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
++      { 0x0e6f, 0x02a6, "PDP Wired Controller for Xbox One - Camo Series", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0346, "Rock Candy Gamepad for Xbox One 2016", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
+@@ -533,6 +534,8 @@ static const struct xboxone_init_packet xboxone_init_packets[] = {
+       XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init2),
+       XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init1),
+       XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init2),
++      XBOXONE_INIT_PKT(0x0e6f, 0x02a6, xboxone_pdp_init1),
++      XBOXONE_INIT_PKT(0x0e6f, 0x02a6, xboxone_pdp_init2),
+       XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init),
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-add-usb-ids-for-mad-catz-brawlstick-and-r.patch b/queue-3.18/input-xpad-add-usb-ids-for-mad-catz-brawlstick-and-r.patch
new file mode 100644 (file)
index 0000000..eb083ad
--- /dev/null
@@ -0,0 +1,43 @@
+From ff6f37186e7bd0f16184944b12452bc274981a94 Mon Sep 17 00:00:00 2001
+From: Benjamin Valentin <benpicco@googlemail.com>
+Date: Sun, 7 May 2017 14:49:09 -0700
+Subject: Input: xpad - add USB IDs for Mad Catz Brawlstick and Razer
+ Sabertooth
+
+[ Upstream commit 4706aa075662fe3cad29c3f49b50878de53f4f3b ]
+
+Add USB IDs for two more Xbox 360 controllers.
+
+I found them in the pull requests for the xboxdrv userspace driver, which
+seems abandoned.
+
+Thanks to psychogony and mkaito for reporting the IDs there!
+
+Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
+Reviewed-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 16338f0b004f..def96cd2479b 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -212,10 +212,12 @@ static const struct xpad_device {
+       { 0x162e, 0xbeef, "Joytech Neo-Se Take2", 0, XTYPE_XBOX360 },
+       { 0x1689, 0xfd00, "Razer Onza Tournament Edition", 0, XTYPE_XBOX360 },
+       { 0x1689, 0xfd01, "Razer Onza Classic Edition", 0, XTYPE_XBOX360 },
++      { 0x1689, 0xfe00, "Razer Sabertooth", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf018, "Mad Catz Street Fighter IV SE Fighting Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf019, "Mad Catz Brawlstick for Xbox 360", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf021, "Mad Cats Ghost Recon FS GamePad", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf023, "MLG Pro Circuit Controller (Xbox)", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf028, "Street Fighter IV FightPad", 0, XTYPE_XBOX360 },
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-avoid-using-__set_bit-for-capabilities.patch b/queue-3.18/input-xpad-avoid-using-__set_bit-for-capabilities.patch
new file mode 100644 (file)
index 0000000..a413cb5
--- /dev/null
@@ -0,0 +1,90 @@
+From ffdbd4a55c81a5a0654463c6beeed360740ee7d1 Mon Sep 17 00:00:00 2001
+From: Marcus Folkesson <marcus.folkesson@gmail.com>
+Date: Tue, 8 May 2018 15:17:07 -0700
+Subject: Input: xpad - avoid using __set_bit() for capabilities
+
+[ Upstream commit a01308031c2647ed5f1c845104b73a8820a958a9 ]
+
+input_set_capability() and input_set_abs_param() will do it for you.
+
+Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index b6e172f22c16..5bf85c43e6d9 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -1579,8 +1579,6 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
+ {
+       struct usb_xpad *xpad = input_get_drvdata(input_dev);
+-      set_bit(abs, input_dev->absbit);
+-
+       switch (abs) {
+       case ABS_X:
+       case ABS_Y:
+@@ -1599,6 +1597,9 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
+       case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */
+               input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
+               break;
++      default:
++              input_set_abs_params(input_dev, abs, 0, 0, 0, 0);
++              break;
+       }
+ }
+@@ -1639,10 +1640,7 @@ static int xpad_init_input(struct usb_xpad *xpad)
+               input_dev->close = xpad_close;
+       }
+-      __set_bit(EV_KEY, input_dev->evbit);
+-
+       if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
+-              __set_bit(EV_ABS, input_dev->evbit);
+               /* set up axes */
+               for (i = 0; xpad_abs[i] >= 0; i++)
+                       xpad_set_up_abs(input_dev, xpad_abs[i]);
+@@ -1650,21 +1648,22 @@ static int xpad_init_input(struct usb_xpad *xpad)
+       /* set up standard buttons */
+       for (i = 0; xpad_common_btn[i] >= 0; i++)
+-              __set_bit(xpad_common_btn[i], input_dev->keybit);
++              input_set_capability(input_dev, EV_KEY, xpad_common_btn[i]);
+       /* set up model-specific ones */
+       if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W ||
+           xpad->xtype == XTYPE_XBOXONE) {
+               for (i = 0; xpad360_btn[i] >= 0; i++)
+-                      __set_bit(xpad360_btn[i], input_dev->keybit);
++                      input_set_capability(input_dev, EV_KEY, xpad360_btn[i]);
+       } else {
+               for (i = 0; xpad_btn[i] >= 0; i++)
+-                      __set_bit(xpad_btn[i], input_dev->keybit);
++                      input_set_capability(input_dev, EV_KEY, xpad_btn[i]);
+       }
+       if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
+               for (i = 0; xpad_btn_pad[i] >= 0; i++)
+-                      __set_bit(xpad_btn_pad[i], input_dev->keybit);
++                      input_set_capability(input_dev, EV_KEY,
++                                           xpad_btn_pad[i]);
+       }
+       /*
+@@ -1681,7 +1680,8 @@ static int xpad_init_input(struct usb_xpad *xpad)
+       if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
+               for (i = 0; xpad_btn_triggers[i] >= 0; i++)
+-                      __set_bit(xpad_btn_triggers[i], input_dev->keybit);
++                      input_set_capability(input_dev, EV_KEY,
++                                           xpad_btn_triggers[i]);
+       } else {
+               for (i = 0; xpad_abs_triggers[i] >= 0; i++)
+                       xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-clarify-led-enumeration.patch b/queue-3.18/input-xpad-clarify-led-enumeration.patch
new file mode 100644 (file)
index 0000000..d5d66b5
--- /dev/null
@@ -0,0 +1,85 @@
+From 4eb16b5b94ac17f47e56d5240e7d22188b76e494 Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Tue, 6 Oct 2015 17:06:16 -0700
+Subject: Input: xpad - clarify LED enumeration
+
+[ Upstream commit 1f6f02b728eef0d937d5138ae60dbf8fbd045f3e ]
+
+Rename led_no -> pad_nr: the number stored there is not the LED number - it
+gets translated later on to a LED number in xpad_identify_controller;
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 16 +++++++++-------
+ 1 file changed, 9 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index e9a2e2d89772..60ebd78a49a6 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -347,7 +347,7 @@ struct usb_xpad {
+       int mapping;                    /* map d-pad to buttons or to axes */
+       int xtype;                      /* type of xbox device */
+-      unsigned long led_no;           /* led to lit on xbox360 controllers */
++      unsigned long pad_nr;           /* the order x360 pads were attached */
+ };
+ /*
+@@ -359,7 +359,6 @@ struct usb_xpad {
+  *    The used report descriptor was taken from ITO Takayukis website:
+  *     http://euc.jp/periphs/xbox-controller.ja.html
+  */
+-
+ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
+ {
+       struct input_dev *dev = xpad->dev;
+@@ -508,7 +507,6 @@ static void xpad_identify_controller(struct usb_xpad *xpad);
+  * 01.1 - Pad state (Bytes 4+) valid
+  *
+  */
+-
+ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
+ {
+       /* Presence change */
+@@ -893,6 +891,7 @@ struct xpad_led {
+ };
+ /**
++ * set the LEDs on Xbox360 / Wireless Controllers
+  * @param command
+  *  0: off
+  *  1: all blink, then previous setting
+@@ -945,10 +944,13 @@ static void xpad_send_led_command(struct usb_xpad *xpad, int command)
+       mutex_unlock(&xpad->odata_mutex);
+ }
++/*
++ * Light up the segment corresponding to the pad number on
++ * Xbox 360 Controllers.
++ */
+ static void xpad_identify_controller(struct usb_xpad *xpad)
+ {
+-      /* Light up the segment corresponding to controller number */
+-      xpad_send_led_command(xpad, (xpad->led_no % 4) + 2);
++      xpad_send_led_command(xpad, (xpad->pad_nr % 4) + 2);
+ }
+ static void xpad_led_set(struct led_classdev *led_cdev,
+@@ -974,9 +976,9 @@ static int xpad_led_probe(struct usb_xpad *xpad)
+       if (!led)
+               return -ENOMEM;
+-      xpad->led_no = atomic_inc_return(&led_seq);
++      xpad->pad_nr = atomic_inc_return(&led_seq);
+-      snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no);
++      snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->pad_nr);
+       led->xpad = xpad;
+       led_cdev = &led->led_cdev;
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-constify-usb_device_id.patch b/queue-3.18/input-xpad-constify-usb_device_id.patch
new file mode 100644 (file)
index 0000000..94e0d14
--- /dev/null
@@ -0,0 +1,34 @@
+From 70c9b9e4a020a14c94ddfdb4d02b0f302717555e Mon Sep 17 00:00:00 2001
+From: Arvind Yadav <arvind.yadav.cs@gmail.com>
+Date: Mon, 7 Aug 2017 20:04:13 -0700
+Subject: Input: xpad - constify usb_device_id
+
+[ Upstream commit 94aef061c796d3d47f1a2eed41e651ffaaade402 ]
+
+usb_device_id are not supposed to change at runtime. All functions
+working with usb_device_id provided by <linux/usb.h> work with
+const usb_device_id. So mark the non-const structs as const.
+
+Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 298a6ba51411..2578a7677040 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -408,7 +408,7 @@ static const signed short xpad_abs_triggers[] = {
+ #define XPAD_XBOXONE_VENDOR(vend) \
+       { XPAD_XBOXONE_VENDOR_PROTOCOL(vend, 208) }
+-static struct usb_device_id xpad_table[] = {
++static const struct usb_device_id xpad_table[] = {
+       { USB_INTERFACE_INFO('X', 'B', 0) },    /* X-Box USB-IF not approved class */
+       XPAD_XBOX360_VENDOR(0x044f),            /* Thrustmaster X-Box 360 controllers */
+       XPAD_XBOX360_VENDOR(0x045e),            /* Microsoft X-Box 360 controllers */
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-correct-xbox-one-pad-device-name.patch b/queue-3.18/input-xpad-correct-xbox-one-pad-device-name.patch
new file mode 100644 (file)
index 0000000..3c840c9
--- /dev/null
@@ -0,0 +1,36 @@
+From da38003ddae19c5e28107077f5b97f0cea4d0889 Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Tue, 12 Jan 2016 14:35:51 -0800
+Subject: Input: xpad - correct xbox one pad device name
+
+[ Upstream commit 95162dc8493ed92e5f7dcc8874e58c2ba3836b43 ]
+
+Apparently the Covert Forces ID is not Covert Forces pad exclusive, but
+rather denotes a new firmware version that can be found on all new
+controllers and can be also updated on old hardware using Windows 10.
+
+see: https://github.com/paroj/xpad/issues/19
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index c196141f3735..02a9fe950f3f 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -128,7 +128,7 @@ static const struct xpad_device {
+       { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
+       { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
+       { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
+-      { 0x045e, 0x02dd, "Microsoft X-Box One pad (Covert Forces)", 0, XTYPE_XBOXONE },
++      { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
+       { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+       { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+       { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-correctly-handle-concurrent-led-and-ff-re.patch b/queue-3.18/input-xpad-correctly-handle-concurrent-led-and-ff-re.patch
new file mode 100644 (file)
index 0000000..020426e
--- /dev/null
@@ -0,0 +1,479 @@
+From 380ea61fba48e2fb86f4f9979c3edcccc5ce5fdb Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Wed, 9 Dec 2015 11:57:01 -0800
+Subject: Input: xpad - correctly handle concurrent LED and FF requests
+
+[ Upstream commit 7fc595f4c02636eadaeeecfe7bbc45b57c173004 ]
+
+Track the status of the irq_out URB to prevent submission iof new requests
+while current one is active. Failure to do so results in the "URB submitted
+while active" warning/stack trace.
+
+Store pending brightness and FF effect in the driver structure and replace
+it with the latest requests until the device is ready to process next
+request. Alternate serving LED vs FF requests to make sure one does not
+starve another. See [1] for discussion. Inspired by patch of Sarah Bessmer
+[2].
+
+[1]: http://www.spinics.net/lists/linux-input/msg40708.html
+[2]: http://www.spinics.net/lists/linux-input/msg31450.html
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 322 +++++++++++++++++++++++-----------
+ 1 file changed, 223 insertions(+), 99 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 15477de1608d..f2af62d18746 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -321,6 +321,19 @@ static struct usb_device_id xpad_table[] = {
+ MODULE_DEVICE_TABLE(usb, xpad_table);
++struct xpad_output_packet {
++      u8 data[XPAD_PKT_LEN];
++      u8 len;
++      bool pending;
++};
++
++#define XPAD_OUT_CMD_IDX      0
++#define XPAD_OUT_FF_IDX               1
++#define XPAD_OUT_LED_IDX      (1 + IS_ENABLED(CONFIG_JOYSTICK_XPAD_FF))
++#define XPAD_NUM_OUT_PACKETS  (1 + \
++                               IS_ENABLED(CONFIG_JOYSTICK_XPAD_FF) + \
++                               IS_ENABLED(CONFIG_JOYSTICK_XPAD_LEDS))
++
+ struct usb_xpad {
+       struct input_dev *dev;          /* input device interface */
+       struct input_dev __rcu *x360w_dev;
+@@ -335,9 +348,13 @@ struct usb_xpad {
+       dma_addr_t idata_dma;
+       struct urb *irq_out;            /* urb for interrupt out report */
++      bool irq_out_active;            /* we must not use an active URB */
+       unsigned char *odata;           /* output data */
+       dma_addr_t odata_dma;
+-      struct mutex odata_mutex;
++      spinlock_t odata_lock;
++
++      struct xpad_output_packet out_packets[XPAD_NUM_OUT_PACKETS];
++      int last_out_packet;
+ #if defined(CONFIG_JOYSTICK_XPAD_LEDS)
+       struct xpad_led *led;
+@@ -713,18 +730,71 @@ exit:
+                       __func__, retval);
+ }
++/* 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;
++
++      for (i = 0; i < XPAD_NUM_OUT_PACKETS; i++) {
++              if (++xpad->last_out_packet >= XPAD_NUM_OUT_PACKETS)
++                      xpad->last_out_packet = 0;
++
++              pkt = &xpad->out_packets[xpad->last_out_packet];
++              if (pkt->pending) {
++                      dev_dbg(&xpad->intf->dev,
++                              "%s - found pending output packet %d\n",
++                              __func__, xpad->last_out_packet);
++                      packet = pkt;
++                      break;
++              }
++      }
++
++      if (packet) {
++              memcpy(xpad->odata, packet->data, packet->len);
++              xpad->irq_out->transfer_buffer_length = packet->len;
++              return true;
++      }
++
++      return false;
++}
++
++/* Callers must hold xpad->odata_lock spinlock */
++static int xpad_try_sending_next_out_packet(struct usb_xpad *xpad)
++{
++      int error;
++
++      if (!xpad->irq_out_active && xpad_prepare_next_out_packet(xpad)) {
++              error = usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
++              if (error) {
++                      dev_err(&xpad->intf->dev,
++                              "%s - usb_submit_urb failed with result %d\n",
++                              __func__, error);
++                      return -EIO;
++              }
++
++              xpad->irq_out_active = true;
++      }
++
++      return 0;
++}
++
+ static void xpad_irq_out(struct urb *urb)
+ {
+       struct usb_xpad *xpad = urb->context;
+       struct device *dev = &xpad->intf->dev;
+-      int retval, status;
++      int status = urb->status;
++      int error;
++      unsigned long flags;
+-      status = urb->status;
++      spin_lock_irqsave(&xpad->odata_lock, flags);
+       switch (status) {
+       case 0:
+               /* success */
+-              return;
++              xpad->out_packets[xpad->last_out_packet].pending = false;
++              xpad->irq_out_active = xpad_prepare_next_out_packet(xpad);
++              break;
+       case -ECONNRESET:
+       case -ENOENT:
+@@ -732,19 +802,26 @@ static void xpad_irq_out(struct urb *urb)
+               /* this urb is terminated, clean up */
+               dev_dbg(dev, "%s - urb shutting down with status: %d\n",
+                       __func__, status);
+-              return;
++              xpad->irq_out_active = false;
++              break;
+       default:
+               dev_dbg(dev, "%s - nonzero urb status received: %d\n",
+                       __func__, status);
+-              goto exit;
++              break;
+       }
+-exit:
+-      retval = usb_submit_urb(urb, GFP_ATOMIC);
+-      if (retval)
+-              dev_err(dev, "%s - usb_submit_urb failed with result %d\n",
+-                      __func__, retval);
++      if (xpad->irq_out_active) {
++              error = usb_submit_urb(urb, GFP_ATOMIC);
++              if (error) {
++                      dev_err(dev,
++                              "%s - usb_submit_urb failed with result %d\n",
++                              __func__, error);
++                      xpad->irq_out_active = false;
++              }
++      }
++
++      spin_unlock_irqrestore(&xpad->odata_lock, flags);
+ }
+ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
+@@ -763,7 +840,7 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
+               goto fail1;
+       }
+-      mutex_init(&xpad->odata_mutex);
++      spin_lock_init(&xpad->odata_lock);
+       xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL);
+       if (!xpad->irq_out) {
+@@ -805,27 +882,57 @@ static void xpad_deinit_output(struct usb_xpad *xpad)
+ static int xpad_inquiry_pad_presence(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);
++
++      packet->data[0] = 0x08;
++      packet->data[1] = 0x00;
++      packet->data[2] = 0x0F;
++      packet->data[3] = 0xC0;
++      packet->data[4] = 0x00;
++      packet->data[5] = 0x00;
++      packet->data[6] = 0x00;
++      packet->data[7] = 0x00;
++      packet->data[8] = 0x00;
++      packet->data[9] = 0x00;
++      packet->data[10] = 0x00;
++      packet->data[11] = 0x00;
++      packet->len = 12;
++      packet->pending = true;
++
++      /* Reset the sequence so we send out presence first */
++      xpad->last_out_packet = -1;
++      retval = xpad_try_sending_next_out_packet(xpad);
++
++      spin_unlock_irqrestore(&xpad->odata_lock, flags);
++
++      return retval;
++}
++
++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;
+-      mutex_lock(&xpad->odata_mutex);
++      spin_lock_irqsave(&xpad->odata_lock, flags);
+-      xpad->odata[0] = 0x08;
+-      xpad->odata[1] = 0x00;
+-      xpad->odata[2] = 0x0F;
+-      xpad->odata[3] = 0xC0;
+-      xpad->odata[4] = 0x00;
+-      xpad->odata[5] = 0x00;
+-      xpad->odata[6] = 0x00;
+-      xpad->odata[7] = 0x00;
+-      xpad->odata[8] = 0x00;
+-      xpad->odata[9] = 0x00;
+-      xpad->odata[10] = 0x00;
+-      xpad->odata[11] = 0x00;
+-      xpad->irq_out->transfer_buffer_length = 12;
++      /* Xbox one controller needs to be initialized. */
++      packet->data[0] = 0x05;
++      packet->data[1] = 0x20;
++      packet->len = 2;
++      packet->pending = true;
+-      retval = usb_submit_urb(xpad->irq_out, GFP_KERNEL);
++      /* Reset the sequence so we send out start packet first */
++      xpad->last_out_packet = -1;
++      retval = xpad_try_sending_next_out_packet(xpad);
+-      mutex_unlock(&xpad->odata_mutex);
++      spin_unlock_irqrestore(&xpad->odata_lock, flags);
+       return retval;
+ }
+@@ -834,8 +941,11 @@ static int xpad_inquiry_pad_presence(struct usb_xpad *xpad)
+ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect)
+ {
+       struct usb_xpad *xpad = input_get_drvdata(dev);
++      struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_FF_IDX];
+       __u16 strong;
+       __u16 weak;
++      int retval;
++      unsigned long flags;
+       if (effect->type != FF_RUMBLE)
+               return 0;
+@@ -843,69 +953,80 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
+       strong = effect->u.rumble.strong_magnitude;
+       weak = effect->u.rumble.weak_magnitude;
++      spin_lock_irqsave(&xpad->odata_lock, flags);
++
+       switch (xpad->xtype) {
+       case XTYPE_XBOX:
+-              xpad->odata[0] = 0x00;
+-              xpad->odata[1] = 0x06;
+-              xpad->odata[2] = 0x00;
+-              xpad->odata[3] = strong / 256;  /* left actuator */
+-              xpad->odata[4] = 0x00;
+-              xpad->odata[5] = weak / 256;    /* right actuator */
+-              xpad->irq_out->transfer_buffer_length = 6;
++              packet->data[0] = 0x00;
++              packet->data[1] = 0x06;
++              packet->data[2] = 0x00;
++              packet->data[3] = strong / 256; /* left actuator */
++              packet->data[4] = 0x00;
++              packet->data[5] = weak / 256;   /* right actuator */
++              packet->len = 6;
++              packet->pending = true;
+               break;
+       case XTYPE_XBOX360:
+-              xpad->odata[0] = 0x00;
+-              xpad->odata[1] = 0x08;
+-              xpad->odata[2] = 0x00;
+-              xpad->odata[3] = strong / 256;  /* left actuator? */
+-              xpad->odata[4] = weak / 256;    /* right actuator? */
+-              xpad->odata[5] = 0x00;
+-              xpad->odata[6] = 0x00;
+-              xpad->odata[7] = 0x00;
+-              xpad->irq_out->transfer_buffer_length = 8;
++              packet->data[0] = 0x00;
++              packet->data[1] = 0x08;
++              packet->data[2] = 0x00;
++              packet->data[3] = strong / 256;  /* left actuator? */
++              packet->data[4] = weak / 256;   /* right actuator? */
++              packet->data[5] = 0x00;
++              packet->data[6] = 0x00;
++              packet->data[7] = 0x00;
++              packet->len = 8;
++              packet->pending = true;
+               break;
+       case XTYPE_XBOX360W:
+-              xpad->odata[0] = 0x00;
+-              xpad->odata[1] = 0x01;
+-              xpad->odata[2] = 0x0F;
+-              xpad->odata[3] = 0xC0;
+-              xpad->odata[4] = 0x00;
+-              xpad->odata[5] = strong / 256;
+-              xpad->odata[6] = weak / 256;
+-              xpad->odata[7] = 0x00;
+-              xpad->odata[8] = 0x00;
+-              xpad->odata[9] = 0x00;
+-              xpad->odata[10] = 0x00;
+-              xpad->odata[11] = 0x00;
+-              xpad->irq_out->transfer_buffer_length = 12;
++              packet->data[0] = 0x00;
++              packet->data[1] = 0x01;
++              packet->data[2] = 0x0F;
++              packet->data[3] = 0xC0;
++              packet->data[4] = 0x00;
++              packet->data[5] = strong / 256;
++              packet->data[6] = weak / 256;
++              packet->data[7] = 0x00;
++              packet->data[8] = 0x00;
++              packet->data[9] = 0x00;
++              packet->data[10] = 0x00;
++              packet->data[11] = 0x00;
++              packet->len = 12;
++              packet->pending = true;
+               break;
+       case XTYPE_XBOXONE:
+-              xpad->odata[0] = 0x09; /* activate rumble */
+-              xpad->odata[1] = 0x08;
+-              xpad->odata[2] = 0x00;
+-              xpad->odata[3] = 0x08; /* continuous effect */
+-              xpad->odata[4] = 0x00; /* simple rumble mode */
+-              xpad->odata[5] = 0x03; /* L and R actuator only */
+-              xpad->odata[6] = 0x00; /* TODO: LT actuator */
+-              xpad->odata[7] = 0x00; /* TODO: RT actuator */
+-              xpad->odata[8] = strong / 256;  /* left actuator */
+-              xpad->odata[9] = weak / 256;    /* right actuator */
+-              xpad->odata[10] = 0x80; /* length of pulse */
+-              xpad->odata[11] = 0x00; /* stop period of pulse */
+-              xpad->irq_out->transfer_buffer_length = 12;
++              packet->data[0] = 0x09; /* activate rumble */
++              packet->data[1] = 0x08;
++              packet->data[2] = 0x00;
++              packet->data[3] = 0x08; /* continuous effect */
++              packet->data[4] = 0x00; /* simple rumble mode */
++              packet->data[5] = 0x03; /* L and R actuator only */
++              packet->data[6] = 0x00; /* TODO: LT actuator */
++              packet->data[7] = 0x00; /* TODO: RT actuator */
++              packet->data[8] = strong / 256; /* left actuator */
++              packet->data[9] = weak / 256;   /* right actuator */
++              packet->data[10] = 0x80;        /* length of pulse */
++              packet->data[11] = 0x00;        /* stop period of pulse */
++              packet->len = 12;
++              packet->pending = true;
+               break;
+       default:
+               dev_dbg(&xpad->dev->dev,
+                       "%s - rumble command sent to unsupported xpad type: %d\n",
+                       __func__, xpad->xtype);
+-              return -EINVAL;
++              retval = -EINVAL;
++              goto out;
+       }
+-      return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
++      retval = xpad_try_sending_next_out_packet(xpad);
++
++out:
++      spin_unlock_irqrestore(&xpad->odata_lock, flags);
++      return retval;
+ }
+ static int xpad_init_ff(struct usb_xpad *xpad)
+@@ -956,36 +1077,44 @@ struct xpad_led {
+  */
+ static void xpad_send_led_command(struct usb_xpad *xpad, int command)
+ {
++      struct xpad_output_packet *packet =
++                      &xpad->out_packets[XPAD_OUT_LED_IDX];
++      unsigned long flags;
++
+       command %= 16;
+-      mutex_lock(&xpad->odata_mutex);
++      spin_lock_irqsave(&xpad->odata_lock, flags);
+       switch (xpad->xtype) {
+       case XTYPE_XBOX360:
+-              xpad->odata[0] = 0x01;
+-              xpad->odata[1] = 0x03;
+-              xpad->odata[2] = command;
+-              xpad->irq_out->transfer_buffer_length = 3;
++              packet->data[0] = 0x01;
++              packet->data[1] = 0x03;
++              packet->data[2] = command;
++              packet->len = 3;
++              packet->pending = true;
+               break;
++
+       case XTYPE_XBOX360W:
+-              xpad->odata[0] = 0x00;
+-              xpad->odata[1] = 0x00;
+-              xpad->odata[2] = 0x08;
+-              xpad->odata[3] = 0x40 + command;
+-              xpad->odata[4] = 0x00;
+-              xpad->odata[5] = 0x00;
+-              xpad->odata[6] = 0x00;
+-              xpad->odata[7] = 0x00;
+-              xpad->odata[8] = 0x00;
+-              xpad->odata[9] = 0x00;
+-              xpad->odata[10] = 0x00;
+-              xpad->odata[11] = 0x00;
+-              xpad->irq_out->transfer_buffer_length = 12;
++              packet->data[0] = 0x00;
++              packet->data[1] = 0x00;
++              packet->data[2] = 0x08;
++              packet->data[3] = 0x40 + command;
++              packet->data[4] = 0x00;
++              packet->data[5] = 0x00;
++              packet->data[6] = 0x00;
++              packet->data[7] = 0x00;
++              packet->data[8] = 0x00;
++              packet->data[9] = 0x00;
++              packet->data[10] = 0x00;
++              packet->data[11] = 0x00;
++              packet->len = 12;
++              packet->pending = true;
+               break;
+       }
+-      usb_submit_urb(xpad->irq_out, GFP_KERNEL);
+-      mutex_unlock(&xpad->odata_mutex);
++      xpad_try_sending_next_out_packet(xpad);
++
++      spin_unlock_irqrestore(&xpad->odata_lock, flags);
+ }
+ /*
+@@ -1076,13 +1205,8 @@ static int xpad_open(struct input_dev *dev)
+       if (usb_submit_urb(xpad->irq_in, GFP_KERNEL))
+               return -EIO;
+-      if (xpad->xtype == XTYPE_XBOXONE) {
+-              /* Xbox one controller needs to be initialized. */
+-              xpad->odata[0] = 0x05;
+-              xpad->odata[1] = 0x20;
+-              xpad->irq_out->transfer_buffer_length = 2;
+-              return usb_submit_urb(xpad->irq_out, GFP_KERNEL);
+-      }
++      if (xpad->xtype == XTYPE_XBOXONE)
++              return xpad_start_xbox_one(xpad);
+       return 0;
+ }
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-correctly-sort-vendor-id-s.patch b/queue-3.18/input-xpad-correctly-sort-vendor-id-s.patch
new file mode 100644 (file)
index 0000000..8290e90
--- /dev/null
@@ -0,0 +1,48 @@
+From 731a02fe1bdf7756ba0b72f8d8e032b11486a8ee Mon Sep 17 00:00:00 2001
+From: Daniel Tobias <dan.g.tob@gmail.com>
+Date: Fri, 27 May 2016 16:25:10 -0700
+Subject: Input: xpad - correctly sort vendor id's
+
+[ Upstream commit c02fc1d9e5d9f093296e43e13ec7f35f140784bd ]
+
+Signed-off-by: Daniel Tobias <dan.g.tob@gmail.com>
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index b9f48d4e155a..8b7fc47f7ffb 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -321,19 +321,19 @@ static struct usb_device_id xpad_table[] = {
+       XPAD_XBOXONE_VENDOR(0x0738),            /* Mad Catz FightStick TE 2 */
+       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(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(0x1bad),            /* Harminix Rock Band Guitar and Drums */
+-      XPAD_XBOX360_VENDOR(0x0f0d),            /* Hori Controllers */
+-      XPAD_XBOXONE_VENDOR(0x0f0d),            /* Hori Controllers */
+-      XPAD_XBOX360_VENDOR(0x1689),            /* Razer Onza */
+-      XPAD_XBOX360_VENDOR(0x24c6),            /* PowerA Controllers */
+-      XPAD_XBOXONE_VENDOR(0x24c6),            /* PowerA 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 */
++      XPAD_XBOX360_VENDOR(0x1bad),            /* Harminix Rock Band Guitar and Drums */
++      XPAD_XBOX360_VENDOR(0x24c6),            /* PowerA Controllers */
++      XPAD_XBOXONE_VENDOR(0x24c6),            /* PowerA Controllers */
+       { }
+ };
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-don-t-depend-on-endpoint-order.patch b/queue-3.18/input-xpad-don-t-depend-on-endpoint-order.patch
new file mode 100644 (file)
index 0000000..c1184ed
--- /dev/null
@@ -0,0 +1,96 @@
+From 354e72528e265280d665cbe1d39598c8962f5153 Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Tue, 3 Jan 2017 22:40:38 -0800
+Subject: Input: xpad - don't depend on endpoint order
+
+[ Upstream commit c01b5e7464f0cf20936d7467c7528163c4e2782d ]
+
+The order of endpoints is well defined on official Xbox pads, but
+we have found at least one 3rd-party pad that doesn't follow the
+standard ("Titanfall 2 Xbox One controller" 0e6f:0165).
+
+Fortunately, we get lucky with this specific pad because it uses
+endpoint addresses that differ only by direction. We know that
+there are other pads out where this is not true, so let's go
+ahead and fix this.
+
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 35 +++++++++++++++++++++--------------
+ 1 file changed, 21 insertions(+), 14 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index d837900d609e..dd0503562b1c 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -838,10 +838,9 @@ static void xpad_irq_out(struct urb *urb)
+       spin_unlock_irqrestore(&xpad->odata_lock, flags);
+ }
+-static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
++static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad,
++                      struct usb_endpoint_descriptor *ep_irq_out)
+ {
+-      struct usb_endpoint_descriptor *ep_irq_out;
+-      int ep_irq_out_idx;
+       int error;
+       if (xpad->xtype == XTYPE_UNKNOWN)
+@@ -862,10 +861,6 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
+               goto err_free_coherent;
+       }
+-      /* Xbox One controller has in/out endpoints swapped. */
+-      ep_irq_out_idx = xpad->xtype == XTYPE_XBOXONE ? 0 : 1;
+-      ep_irq_out = &intf->cur_altsetting->endpoint[ep_irq_out_idx].desc;
+-
+       usb_fill_int_urb(xpad->irq_out, xpad->udev,
+                        usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress),
+                        xpad->odata, XPAD_PKT_LEN,
+@@ -1455,8 +1450,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+ {
+       struct usb_device *udev = interface_to_usbdev(intf);
+       struct usb_xpad *xpad;
+-      struct usb_endpoint_descriptor *ep_irq_in;
+-      int ep_irq_in_idx;
++      struct usb_endpoint_descriptor *ep_irq_in, *ep_irq_out;
+       int i, error;
+       if (intf->cur_altsetting->desc.bNumEndpoints != 2)
+@@ -1526,13 +1520,26 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+               goto err_free_in_urb;
+       }
+-      error = xpad_init_output(intf, xpad);
+-      if (error)
++      ep_irq_in = ep_irq_out = NULL;
++
++      for (i = 0; i < 2; i++) {
++              struct usb_endpoint_descriptor *ep =
++                              &intf->cur_altsetting->endpoint[i].desc;
++
++              if (usb_endpoint_dir_in(ep))
++                      ep_irq_in = ep;
++              else
++                      ep_irq_out = ep;
++      }
++
++      if (!ep_irq_in || !ep_irq_out) {
++              error = -ENODEV;
+               goto err_free_in_urb;
++      }
+-      /* Xbox One controller has in/out endpoints swapped. */
+-      ep_irq_in_idx = xpad->xtype == XTYPE_XBOXONE ? 1 : 0;
+-      ep_irq_in = &intf->cur_altsetting->endpoint[ep_irq_in_idx].desc;
++      error = xpad_init_output(intf, xpad, ep_irq_out);
++      if (error)
++              goto err_free_in_urb;
+       usb_fill_int_urb(xpad->irq_in, udev,
+                        usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-factor-out-urb-submission-in-xpad_play_ef.patch b/queue-3.18/input-xpad-factor-out-urb-submission-in-xpad_play_ef.patch
new file mode 100644 (file)
index 0000000..df84ec7
--- /dev/null
@@ -0,0 +1,174 @@
+From bb74fd0ac45466775d397467def42cf0befb7d84 Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Sat, 10 Oct 2015 09:32:55 -0700
+Subject: Input: xpad - factor out URB submission in xpad_play_effect
+
+[ Upstream commit 060081529c64cfa9baa2748a4b949159e700da0d ]
+
+Move submission logic to a single point at the end of the function.
+This makes it easy to add locking/ queuing code later on.
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 140 +++++++++++++++++-----------------
+ 1 file changed, 69 insertions(+), 71 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index afa232b415a5..fc81473b6e35 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -764,80 +764,78 @@ static void xpad_deinit_output(struct usb_xpad *xpad)
+ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect)
+ {
+       struct usb_xpad *xpad = input_get_drvdata(dev);
++      __u16 strong;
++      __u16 weak;
+-      if (effect->type == FF_RUMBLE) {
+-              __u16 strong = effect->u.rumble.strong_magnitude;
+-              __u16 weak = effect->u.rumble.weak_magnitude;
+-
+-              switch (xpad->xtype) {
+-
+-              case XTYPE_XBOX:
+-                      xpad->odata[0] = 0x00;
+-                      xpad->odata[1] = 0x06;
+-                      xpad->odata[2] = 0x00;
+-                      xpad->odata[3] = strong / 256;  /* left actuator */
+-                      xpad->odata[4] = 0x00;
+-                      xpad->odata[5] = weak / 256;    /* right actuator */
+-                      xpad->irq_out->transfer_buffer_length = 6;
+-
+-                      return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
+-
+-              case XTYPE_XBOX360:
+-                      xpad->odata[0] = 0x00;
+-                      xpad->odata[1] = 0x08;
+-                      xpad->odata[2] = 0x00;
+-                      xpad->odata[3] = strong / 256;  /* left actuator? */
+-                      xpad->odata[4] = weak / 256;    /* right actuator? */
+-                      xpad->odata[5] = 0x00;
+-                      xpad->odata[6] = 0x00;
+-                      xpad->odata[7] = 0x00;
+-                      xpad->irq_out->transfer_buffer_length = 8;
+-
+-                      return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
+-
+-              case XTYPE_XBOX360W:
+-                      xpad->odata[0] = 0x00;
+-                      xpad->odata[1] = 0x01;
+-                      xpad->odata[2] = 0x0F;
+-                      xpad->odata[3] = 0xC0;
+-                      xpad->odata[4] = 0x00;
+-                      xpad->odata[5] = strong / 256;
+-                      xpad->odata[6] = weak / 256;
+-                      xpad->odata[7] = 0x00;
+-                      xpad->odata[8] = 0x00;
+-                      xpad->odata[9] = 0x00;
+-                      xpad->odata[10] = 0x00;
+-                      xpad->odata[11] = 0x00;
+-                      xpad->irq_out->transfer_buffer_length = 12;
+-
+-                      return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
+-
+-              case XTYPE_XBOXONE:
+-                      xpad->odata[0] = 0x09; /* activate rumble */
+-                      xpad->odata[1] = 0x08;
+-                      xpad->odata[2] = 0x00;
+-                      xpad->odata[3] = 0x08; /* continuous effect */
+-                      xpad->odata[4] = 0x00; /* simple rumble mode */
+-                      xpad->odata[5] = 0x03; /* L and R actuator only */
+-                      xpad->odata[6] = 0x00; /* TODO: LT actuator */
+-                      xpad->odata[7] = 0x00; /* TODO: RT actuator */
+-                      xpad->odata[8] = strong / 256;  /* left actuator */
+-                      xpad->odata[9] = weak / 256;    /* right actuator */
+-                      xpad->odata[10] = 0x80; /* length of pulse */
+-                      xpad->odata[11] = 0x00; /* stop period of pulse */
+-                      xpad->irq_out->transfer_buffer_length = 12;
+-
+-                      return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
+-
+-              default:
+-                      dev_dbg(&xpad->dev->dev,
+-                              "%s - rumble command sent to unsupported xpad type: %d\n",
+-                              __func__, xpad->xtype);
+-                      return -1;
+-              }
++      if (effect->type != FF_RUMBLE)
++              return 0;
++
++      strong = effect->u.rumble.strong_magnitude;
++      weak = effect->u.rumble.weak_magnitude;
++
++      switch (xpad->xtype) {
++      case XTYPE_XBOX:
++              xpad->odata[0] = 0x00;
++              xpad->odata[1] = 0x06;
++              xpad->odata[2] = 0x00;
++              xpad->odata[3] = strong / 256;  /* left actuator */
++              xpad->odata[4] = 0x00;
++              xpad->odata[5] = weak / 256;    /* right actuator */
++              xpad->irq_out->transfer_buffer_length = 6;
++              break;
++
++      case XTYPE_XBOX360:
++              xpad->odata[0] = 0x00;
++              xpad->odata[1] = 0x08;
++              xpad->odata[2] = 0x00;
++              xpad->odata[3] = strong / 256;  /* left actuator? */
++              xpad->odata[4] = weak / 256;    /* right actuator? */
++              xpad->odata[5] = 0x00;
++              xpad->odata[6] = 0x00;
++              xpad->odata[7] = 0x00;
++              xpad->irq_out->transfer_buffer_length = 8;
++              break;
++
++      case XTYPE_XBOX360W:
++              xpad->odata[0] = 0x00;
++              xpad->odata[1] = 0x01;
++              xpad->odata[2] = 0x0F;
++              xpad->odata[3] = 0xC0;
++              xpad->odata[4] = 0x00;
++              xpad->odata[5] = strong / 256;
++              xpad->odata[6] = weak / 256;
++              xpad->odata[7] = 0x00;
++              xpad->odata[8] = 0x00;
++              xpad->odata[9] = 0x00;
++              xpad->odata[10] = 0x00;
++              xpad->odata[11] = 0x00;
++              xpad->irq_out->transfer_buffer_length = 12;
++              break;
++
++      case XTYPE_XBOXONE:
++              xpad->odata[0] = 0x09; /* activate rumble */
++              xpad->odata[1] = 0x08;
++              xpad->odata[2] = 0x00;
++              xpad->odata[3] = 0x08; /* continuous effect */
++              xpad->odata[4] = 0x00; /* simple rumble mode */
++              xpad->odata[5] = 0x03; /* L and R actuator only */
++              xpad->odata[6] = 0x00; /* TODO: LT actuator */
++              xpad->odata[7] = 0x00; /* TODO: RT actuator */
++              xpad->odata[8] = strong / 256;  /* left actuator */
++              xpad->odata[9] = weak / 256;    /* right actuator */
++              xpad->odata[10] = 0x80; /* length of pulse */
++              xpad->odata[11] = 0x00; /* stop period of pulse */
++              xpad->irq_out->transfer_buffer_length = 12;
++              break;
++
++      default:
++              dev_dbg(&xpad->dev->dev,
++                      "%s - rumble command sent to unsupported xpad type: %d\n",
++                      __func__, xpad->xtype);
++              return -EINVAL;
+       }
+-      return 0;
++      return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
+ }
+ static int xpad_init_ff(struct usb_xpad *xpad)
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-fix-clash-of-presence-handling-with-led-s.patch b/queue-3.18/input-xpad-fix-clash-of-presence-handling-with-led-s.patch
new file mode 100644 (file)
index 0000000..13b32b9
--- /dev/null
@@ -0,0 +1,43 @@
+From 9e6414acfad87ac19f76cb4c48b43f9281bd58ec Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Mon, 19 Oct 2015 00:06:58 -0700
+Subject: Input: xpad - fix clash of presence handling with LED setting
+
+[ Upstream commit fbe6a3114471cccaeaeabfa56937731503ece545 ]
+
+Do not call xpad_identify_controller at init with wireless devices: it
+conflicts with the already sent presence packet and will be called by
+xpad360w_process_packet as needed anyway.
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index ff368860a5f9..1a66443f3cd5 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -1003,8 +1003,15 @@ static int xpad_led_probe(struct usb_xpad *xpad)
+       if (error)
+               goto err_free_id;
+-      /* Light up the segment corresponding to controller number */
+-      xpad_identify_controller(xpad);
++      if (xpad->xtype == XTYPE_XBOX360) {
++              /*
++               * Light up the segment corresponding to controller
++               * number on wired devices. On wireless we'll do that
++               * when they respond to "presence" packet.
++               */
++              xpad_identify_controller(xpad);
++      }
++
+       return 0;
+ err_free_id:
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-fix-gpd-win-2-controller-name.patch b/queue-3.18/input-xpad-fix-gpd-win-2-controller-name.patch
new file mode 100644 (file)
index 0000000..f212d7e
--- /dev/null
@@ -0,0 +1,42 @@
+From 16473ce8b517fa150d0d61bf248e05cf928e5280 Mon Sep 17 00:00:00 2001
+From: Enno Boland <gottox@voidlinux.eu>
+Date: Tue, 19 Jun 2018 11:55:33 -0700
+Subject: Input: xpad - fix GPD Win 2 controller name
+
+[ Upstream commit dd6bee81c942c0ea01030da9356026afb88f9d18 ]
+
+This fixes using the controller with SDL2.
+
+SDL2 has a naive algorithm to apply the correct settings to a controller.
+For X-Box compatible controllers it expects that the controller name
+contains a variation of a 'XBOX'-string.
+
+This patch changes the identifier to contain "X-Box" as substring.  Tested
+with Steam and C-Dogs-SDL which both detect the controller properly after
+adding this patch.
+
+Fixes: c1ba08390a8b ("Input: xpad - add GPD Win 2 Controller USB IDs")
+Cc: stable@vger.kernel.org
+Signed-off-by: Enno Boland <gottox@voidlinux.eu>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 66cc37b41113..69b44aebaf01 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -128,7 +128,7 @@ static const struct xpad_device {
+       u8 mapping;
+       u8 xtype;
+ } xpad_device[] = {
+-      { 0x0079, 0x18d4, "GPD Win 2 Controller", 0, XTYPE_XBOX360 },
++      { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 },
+       { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX },
+       { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX },
+       { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-fix-oops-when-attaching-an-unknown-xbox-o.patch b/queue-3.18/input-xpad-fix-oops-when-attaching-an-unknown-xbox-o.patch
new file mode 100644 (file)
index 0000000..59493ee
--- /dev/null
@@ -0,0 +1,82 @@
+From 25b85f9daddfbdca64c82e6abc172127b2063489 Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Thu, 23 Jun 2016 10:24:42 -0700
+Subject: Input: xpad - fix oops when attaching an unknown Xbox One gamepad
+
+[ Upstream commit c7f1429389ec1aa25e042bb13451385fbb596f8c ]
+
+Xbox One controllers have multiple interfaces which all have the
+same class, subclass, and protocol. One of the these interfaces
+has only a single endpoint. When Xpad attempts to bind to this
+interface, it causes an oops when trying initialize the output URB
+by trying to access the second endpoint's descriptor.
+
+This situation was avoided for known Xbox One devices by checking
+the XTYPE constant associated with the VID and PID tuple. However,
+this breaks when new or previously unknown Xbox One controllers
+are attached to the system.
+
+This change addresses the problem by deriving the XTYPE for Xbox
+One controllers based on the interface protocol before checking
+the interface number.
+
+Fixes: 1a48ff81b391 ("Input: xpad - add support for Xbox One controllers")
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 23 +++++++++++++----------
+ 1 file changed, 13 insertions(+), 10 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 6586d7ae0019..05a5c647ed36 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -1442,16 +1442,6 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+                       break;
+       }
+-      if (xpad_device[i].xtype == XTYPE_XBOXONE &&
+-          intf->cur_altsetting->desc.bInterfaceNumber != 0) {
+-              /*
+-               * The Xbox One controller lists three interfaces all with the
+-               * same interface class, subclass and protocol. Differentiate by
+-               * interface number.
+-               */
+-              return -ENODEV;
+-      }
+-
+       xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);
+       if (!xpad)
+               return -ENOMEM;
+@@ -1483,6 +1473,8 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+               if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
+                       if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)
+                               xpad->xtype = XTYPE_XBOX360W;
++                      else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208)
++                              xpad->xtype = XTYPE_XBOXONE;
+                       else
+                               xpad->xtype = XTYPE_XBOX360;
+               } else {
+@@ -1497,6 +1489,17 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+                       xpad->mapping |= MAP_STICKS_TO_NULL;
+       }
++      if (xpad->xtype == XTYPE_XBOXONE &&
++          intf->cur_altsetting->desc.bInterfaceNumber != 0) {
++              /*
++               * The Xbox One controller lists three interfaces all with the
++               * same interface class, subclass and protocol. Differentiate by
++               * interface number.
++               */
++              error = -ENODEV;
++              goto err_free_in_urb;
++      }
++
+       error = xpad_init_output(intf, xpad);
+       if (error)
+               goto err_free_in_urb;
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-fix-powera-init-quirk-for-some-gamepad-mo.patch b/queue-3.18/input-xpad-fix-powera-init-quirk-for-some-gamepad-mo.patch
new file mode 100644 (file)
index 0000000..2d0f648
--- /dev/null
@@ -0,0 +1,84 @@
+From 2ecab89862152528c472656e985fcc9d0cb3401e Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Thu, 31 Aug 2017 11:52:20 -0700
+Subject: Input: xpad - fix PowerA init quirk for some gamepad models
+
+[ Upstream commit f5308d1b83eba20e69df5e0926ba7257c8dd9074 ]
+
+The PowerA gamepad initialization quirk worked with the PowerA
+wired gamepad I had around (0x24c6:0x543a), but a user reported [0]
+that it didn't work for him, even though our gamepads shared the
+same vendor and product IDs.
+
+When I initially implemented the PowerA quirk, I wanted to avoid
+actually triggering the rumble action during init. My tests showed
+that my gamepad would work correctly even if it received a rumble
+of 0 intensity, so that's what I went with.
+
+Unfortunately, this apparently isn't true for all models (perhaps
+a firmware difference?). This non-working gamepad seems to require
+the real magic rumble packet that the Microsoft driver sends, which
+actually vibrates the gamepad. To counteract this effect, I still
+send the old zero-rumble PowerA quirk packet which cancels the
+rumble effect before the motors can spin up enough to vibrate.
+
+[0]: https://github.com/paroj/xpad/issues/48#issuecomment-313904867
+
+Reported-by: Kyle Beauchamp <kyleabeauchamp@gmail.com>
+Tested-by: Kyle Beauchamp <kyleabeauchamp@gmail.com>
+Fixes: 81093c9848a7 ("Input: xpad - support some quirky Xbox One pads")
+Cc: stable@vger.kernel.org # v4.12
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 24 +++++++++++++++++++-----
+ 1 file changed, 19 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 2578a7677040..f8e34ef643c7 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -476,10 +476,21 @@ static const u8 xboxone_hori_init[] = {
+ };
+ /*
+- * A rumble packet is required for some PowerA pads to start
++ * A specific 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[] = {
++static const u8 xboxone_rumblebegin_init[] = {
++      0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00,
++      0x1D, 0x1D, 0xFF, 0x00, 0x00
++};
++
++/*
++ * A rumble packet with zero FF intensity will immediately
++ * terminate the rumbling required to init PowerA pads.
++ * This should happen fast enough that the motors don't
++ * spin up to enough speed to actually vibrate the gamepad.
++ */
++static const u8 xboxone_rumbleend_init[] = {
+       0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00
+ };
+@@ -494,9 +505,12 @@ 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),
++      XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init),
++      XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init),
++      XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init),
++      XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumbleend_init),
++      XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumbleend_init),
++      XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumbleend_init),
+ };
+ struct xpad_output_packet {
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-fix-razer-atrox-arcade-stick-button-mappi.patch b/queue-3.18/input-xpad-fix-razer-atrox-arcade-stick-button-mappi.patch
new file mode 100644 (file)
index 0000000..9f1bddd
--- /dev/null
@@ -0,0 +1,35 @@
+From 966b580a11d5959f60f894e09b5689935d53a6db Mon Sep 17 00:00:00 2001
+From: Dario Scarpa <dario.scarpa@duskzone.it>
+Date: Tue, 6 Oct 2015 17:04:36 -0700
+Subject: Input: xpad - fix Razer Atrox Arcade Stick button mapping
+
+[ Upstream commit 470446ecef213b17b2c01df9879102948d77f999 ]
+
+The "Razer Atrox Arcade Stick" features 10 buttons, and two of them (LT/RT)
+don't work properly.  Change its definition in xpad_device[] (mapping
+field) to fix.
+
+Signed-off-by: Dario Scarpa <dario.scarpa@duskzone.it>
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 7657cf4f08d9..e9a2e2d89772 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -206,7 +206,7 @@ static const struct xpad_device {
+       { 0x1bad, 0xf900, "Harmonix Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf901, "Gamestop Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf903, "Tron Xbox 360 controller", 0, XTYPE_XBOX360 },
+-      { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5500, "Hori XBOX 360 EX 2 with Turbo", 0, XTYPE_XBOX360 },
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-fix-rumble-on-xbox-one-controllers-with-2.patch b/queue-3.18/input-xpad-fix-rumble-on-xbox-one-controllers-with-2.patch
new file mode 100644 (file)
index 0000000..d34603f
--- /dev/null
@@ -0,0 +1,55 @@
+From 78f680e5a40900e4f6da0e7a94ab9ab28867be81 Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Wed, 1 Jun 2016 11:32:51 -0700
+Subject: Input: xpad - fix rumble on Xbox One controllers with 2015 firmware
+
+[ Upstream commit 540c26087bfbad6ea72758b76b16ae6282a73fea ]
+
+Xbox One controllers that shipped with or were upgraded to the 2015
+firmware discard the current rumble packets we send. This patch changes
+the Xbox One rumble packet to a form that both the newer and older
+firmware will accept.
+
+It is based on changes made to support newer Xbox One controllers in
+the SteamOS brewmaster-4.1 kernel branch.
+
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index c8a20893d2d5..6586d7ae0019 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -1033,17 +1033,17 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
+       case XTYPE_XBOXONE:
+               packet->data[0] = 0x09; /* activate rumble */
+-              packet->data[1] = 0x08;
++              packet->data[1] = 0x00;
+               packet->data[2] = xpad->odata_serial++;
+-              packet->data[3] = 0x08; /* continuous effect */
+-              packet->data[4] = 0x00; /* simple rumble mode */
+-              packet->data[5] = 0x03; /* L and R actuator only */
+-              packet->data[6] = 0x00; /* TODO: LT actuator */
+-              packet->data[7] = 0x00; /* TODO: RT actuator */
++              packet->data[3] = 0x09;
++              packet->data[4] = 0x00;
++              packet->data[5] = 0x0F;
++              packet->data[6] = 0x00;
++              packet->data[7] = 0x00;
+               packet->data[8] = strong / 512; /* left actuator */
+               packet->data[9] = weak / 512;   /* right actuator */
+-              packet->data[10] = 0x80;        /* length of pulse */
+-              packet->data[11] = 0x00;        /* stop period of pulse */
++              packet->data[10] = 0xFF;
++              packet->data[11] = 0x00;
+               packet->data[12] = 0x00;
+               packet->len = 13;
+               packet->pending = true;
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-fix-some-coding-style-issues.patch b/queue-3.18/input-xpad-fix-some-coding-style-issues.patch
new file mode 100644 (file)
index 0000000..f500f99
--- /dev/null
@@ -0,0 +1,73 @@
+From 3c305615e358f4067b4574d51a5091954114728b Mon Sep 17 00:00:00 2001
+From: Leo Sperling <leosperling97@gmail.com>
+Date: Wed, 3 Aug 2016 17:31:09 -0700
+Subject: Input: xpad - fix some coding style issues
+
+[ Upstream commit 68c78d0155e37992268664e134996d2b140ddf38 ]
+
+Fix some coding style issues reported by checkpatch.pl. Mostly brackets
+in macros, spacing and comment style.
+
+Signed-off-by: Leo Sperling <leosperling97@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 15 +++++++++------
+ 1 file changed, 9 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 298581b0f6c1..b6e172f22c16 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -89,8 +89,10 @@
+ #define XPAD_PKT_LEN 64
+-/* xbox d-pads should map to buttons, as is required for DDR pads
+-   but we map them to axes when possible to simplify things */
++/*
++ * xbox d-pads should map to buttons, as is required for DDR pads
++ * but we map them to axes when possible to simplify things
++ */
+ #define MAP_DPAD_TO_BUTTONS           (1 << 0)
+ #define MAP_TRIGGERS_TO_BUTTONS               (1 << 1)
+ #define MAP_STICKS_TO_NULL            (1 << 2)
+@@ -390,15 +392,15 @@ static const signed short xpad_abs_triggers[] = {
+  * match against vendor id as well. Wired Xbox 360 devices have protocol 1,
+  * wireless controllers have protocol 129.
+  */
+-#define XPAD_XBOX360_VENDOR_PROTOCOL(vend,pr) \
++#define XPAD_XBOX360_VENDOR_PROTOCOL(vend, pr) \
+       .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO, \
+       .idVendor = (vend), \
+       .bInterfaceClass = USB_CLASS_VENDOR_SPEC, \
+       .bInterfaceSubClass = 93, \
+       .bInterfaceProtocol = (pr)
+ #define XPAD_XBOX360_VENDOR(vend) \
+-      { XPAD_XBOX360_VENDOR_PROTOCOL(vend,1) }, \
+-      { XPAD_XBOX360_VENDOR_PROTOCOL(vend,129) }
++      { XPAD_XBOX360_VENDOR_PROTOCOL((vend), 1) }, \
++      { XPAD_XBOX360_VENDOR_PROTOCOL((vend), 129) }
+ /* The Xbox One controller uses subclass 71 and protocol 208. */
+ #define XPAD_XBOXONE_VENDOR_PROTOCOL(vend, pr) \
+@@ -408,7 +410,7 @@ static const signed short xpad_abs_triggers[] = {
+       .bInterfaceSubClass = 71, \
+       .bInterfaceProtocol = (pr)
+ #define XPAD_XBOXONE_VENDOR(vend) \
+-      { XPAD_XBOXONE_VENDOR_PROTOCOL(vend, 208) }
++      { 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 */
+@@ -1576,6 +1578,7 @@ static void xpad_close(struct input_dev *dev)
+ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
+ {
+       struct usb_xpad *xpad = input_get_drvdata(input_dev);
++
+       set_bit(abs, input_dev->absbit);
+       switch (abs) {
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-fix-stuck-mode-button-on-xbox-one-s-pad.patch b/queue-3.18/input-xpad-fix-stuck-mode-button-on-xbox-one-s-pad.patch
new file mode 100644 (file)
index 0000000..a097d8f
--- /dev/null
@@ -0,0 +1,79 @@
+From 25bb255e3947d609886ef06bcad53eec0b92724e Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Mon, 6 Feb 2017 13:56:10 -0800
+Subject: Input: xpad - fix stuck mode button on Xbox One S pad
+
+[ Upstream commit 57b8443d3e5bd046a519ff714ca31c64c7f04309 ]
+
+The Xbox One S requires an ack to its mode button report, otherwise it
+continuously retransmits the report. This makes the mode button appear to
+be stuck down after it is pressed for the first time.
+
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 33 +++++++++++++++++++++++++++++++++
+ 1 file changed, 33 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index dd0503562b1c..14da79ead653 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -391,6 +391,7 @@ struct usb_xpad {
+ static int xpad_init_input(struct usb_xpad *xpad);
+ static void xpad_deinit_input(struct usb_xpad *xpad);
++static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num);
+ /*
+  *    xpad_process_packet
+@@ -624,6 +625,14 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
+       /* the xbox button has its own special report */
+       if (data[0] == 0X07) {
++              /*
++               * The Xbox One S controller requires these reports to be
++               * acked otherwise it continues sending them forever and
++               * won't report further mode button events.
++               */
++              if (data[1] == 0x30)
++                      xpadone_ack_mode_report(xpad, data[2]);
++
+               input_report_key(dev, BTN_MODE, data[4] & 0x01);
+               input_sync(dev);
+               return;
+@@ -956,6 +965,30 @@ static int xpad_start_xbox_one(struct usb_xpad *xpad)
+       return retval;
+ }
++static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num)
++{
++      unsigned long flags;
++      struct xpad_output_packet *packet =
++                      &xpad->out_packets[XPAD_OUT_CMD_IDX];
++      static const u8 mode_report_ack[] = {
++              0x01, 0x20, 0x00, 0x09, 0x00, 0x07, 0x20, 0x02,
++              0x00, 0x00, 0x00, 0x00, 0x00
++      };
++
++      spin_lock_irqsave(&xpad->odata_lock, flags);
++
++      packet->len = sizeof(mode_report_ack);
++      memcpy(packet->data, mode_report_ack, packet->len);
++      packet->data[2] = seq_num;
++      packet->pending = true;
++
++      /* Reset the sequence so we send out the ack now */
++      xpad->last_out_packet = -1;
++      xpad_try_sending_next_out_packet(xpad);
++
++      spin_unlock_irqrestore(&xpad->odata_lock, flags);
++}
++
+ #ifdef CONFIG_JOYSTICK_XPAD_FF
+ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect)
+ {
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-fix-xbox-one-rumble-stopping-after-2.5-se.patch b/queue-3.18/input-xpad-fix-xbox-one-rumble-stopping-after-2.5-se.patch
new file mode 100644 (file)
index 0000000..a7b5356
--- /dev/null
@@ -0,0 +1,51 @@
+From fe5847c140484d810bf3980063bbde0f8654b946 Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Sun, 27 Nov 2016 20:37:56 -0800
+Subject: Input: xpad - fix Xbox One rumble stopping after 2.5 secs
+
+[ Upstream commit ae3b4469dbcd3b842a9fd20940946e4d092d8731 ]
+
+Unlike previous Xbox pads, the Xbox One pad doesn't have "sticky" rumble
+packets. The duration is encoded into the command and expiration is handled
+by the pad firmware.
+
+ff-memless needs pseudo-sticky behavior for rumble effects to behave
+properly for long duration effects. We already specify the maximum rumble
+on duration in the command packets, but it's still only good for about 2.5
+seconds of rumble. This is easily reproducible running fftest's sine
+vibration test.
+
+It turns out there's a repeat count encoded in the rumble command. We can
+abuse that to get the pseudo-sticky behavior needed for rumble to behave as
+expected for effects with long duration.
+
+By my math, this change should allow a single ff_effect to rumble for 10
+minutes straight, which should be more than enough for most needs.
+
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 48a88d7cb513..fa6c72657f96 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -1047,9 +1047,9 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
+               packet->data[7] = 0x00;
+               packet->data[8] = strong / 512; /* left actuator */
+               packet->data[9] = weak / 512;   /* right actuator */
+-              packet->data[10] = 0xFF;
+-              packet->data[11] = 0x00;
+-              packet->data[12] = 0x00;
++              packet->data[10] = 0xFF; /* on period */
++              packet->data[11] = 0x00; /* off period */
++              packet->data[12] = 0xFF; /* repeat count */
+               packet->len = 13;
+               packet->pending = true;
+               break;
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-handle-present-and-gone-correctly.patch b/queue-3.18/input-xpad-handle-present-and-gone-correctly.patch
new file mode 100644 (file)
index 0000000..6ab48b0
--- /dev/null
@@ -0,0 +1,269 @@
+From c93077f83678d1461de8f7157d3149eafdda1fd5 Mon Sep 17 00:00:00 2001
+From: "Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>
+Date: Wed, 9 Dec 2015 11:46:25 -0800
+Subject: Input: xpad - handle "present" and "gone" correctly
+
+[ Upstream commit 09c8b00ae3e16c8d0fd4beb2ca064502a76c0f17 ]
+
+Handle the "a new device is present" message properly by dynamically
+creating the input device at this point in time. This means we now do not
+"preallocate" all 4 devices when a single wireless base station is seen.
+This requires a workqueue as we are in interrupt context when we learn
+about this.
+
+Also properly disconnect any devices that we are told are removed.
+
+Signed-off-by: "Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 107 ++++++++++++++++++++++------------
+ 1 file changed, 69 insertions(+), 38 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 33c3071c56f9..15477de1608d 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -76,6 +76,8 @@
+  */
+ #include <linux/kernel.h>
++#include <linux/input.h>
++#include <linux/rcupdate.h>
+ #include <linux/slab.h>
+ #include <linux/stat.h>
+ #include <linux/module.h>
+@@ -321,10 +323,12 @@ MODULE_DEVICE_TABLE(usb, xpad_table);
+ struct usb_xpad {
+       struct input_dev *dev;          /* input device interface */
++      struct input_dev __rcu *x360w_dev;
+       struct usb_device *udev;        /* usb device */
+       struct usb_interface *intf;     /* usb interface */
+-      int pad_present;
++      bool pad_present;
++      bool input_created;
+       struct urb *irq_in;             /* urb for interrupt in report */
+       unsigned char *idata;           /* input data */
+@@ -345,8 +349,12 @@ struct usb_xpad {
+       int xtype;                      /* type of xbox device */
+       int pad_nr;                     /* the order x360 pads were attached */
+       const char *name;               /* name of the device */
++      struct work_struct work;        /* init/remove device from callback */
+ };
++static int xpad_init_input(struct usb_xpad *xpad);
++static void xpad_deinit_input(struct usb_xpad *xpad);
++
+ /*
+  *    xpad_process_packet
+  *
+@@ -426,11 +434,9 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
+  *            http://www.free60.org/wiki/Gamepad
+  */
+-static void xpad360_process_packet(struct usb_xpad *xpad,
++static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev,
+                                  u16 cmd, unsigned char *data)
+ {
+-      struct input_dev *dev = xpad->dev;
+-
+       /* digital pad */
+       if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
+               /* dpad as buttons (left, right, up, down) */
+@@ -497,7 +503,30 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
+       input_sync(dev);
+ }
+-static void xpad_identify_controller(struct usb_xpad *xpad);
++static void xpad_presence_work(struct work_struct *work)
++{
++      struct usb_xpad *xpad = container_of(work, struct usb_xpad, work);
++      int error;
++
++      if (xpad->pad_present) {
++              error = xpad_init_input(xpad);
++              if (error) {
++                      /* complain only, not much else we can do here */
++                      dev_err(&xpad->dev->dev,
++                              "unable to init device: %d\n", error);
++              } else {
++                      rcu_assign_pointer(xpad->x360w_dev, xpad->dev);
++              }
++      } else {
++              RCU_INIT_POINTER(xpad->x360w_dev, NULL);
++              synchronize_rcu();
++              /*
++               * Now that we are sure xpad360w_process_packet is not
++               * using input device we can get rid of it.
++               */
++              xpad_deinit_input(xpad);
++      }
++}
+ /*
+  * xpad360w_process_packet
+@@ -515,24 +544,28 @@ static void xpad_identify_controller(struct usb_xpad *xpad);
+  */
+ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
+ {
++      struct input_dev *dev;
++      bool present;
++
+       /* Presence change */
+       if (data[0] & 0x08) {
+-              if (data[1] & 0x80) {
+-                      xpad->pad_present = 1;
+-                      /*
+-                       * Light up the segment corresponding to
+-                       * controller number.
+-                       */
+-                      xpad_identify_controller(xpad);
+-              } else
+-                      xpad->pad_present = 0;
++              present = (data[1] & 0x80) != 0;
++
++              if (xpad->pad_present != present) {
++                      xpad->pad_present = present;
++                      schedule_work(&xpad->work);
++              }
+       }
+       /* Valid pad data */
+       if (data[1] != 0x1)
+               return;
+-      xpad360_process_packet(xpad, cmd, &data[4]);
++      rcu_read_lock();
++      dev = rcu_dereference(xpad->x360w_dev);
++      if (dev)
++              xpad360_process_packet(xpad, dev, cmd, &data[4]);
++      rcu_read_unlock();
+ }
+ /*
+@@ -661,7 +694,7 @@ static void xpad_irq_in(struct urb *urb)
+       switch (xpad->xtype) {
+       case XTYPE_XBOX360:
+-              xpad360_process_packet(xpad, 0, xpad->idata);
++              xpad360_process_packet(xpad, xpad->dev, 0, xpad->idata);
+               break;
+       case XTYPE_XBOX360W:
+               xpad360w_process_packet(xpad, 0, xpad->idata);
+@@ -1003,14 +1036,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
+       if (error)
+               goto err_free_id;
+-      if (xpad->xtype == XTYPE_XBOX360) {
+-              /*
+-               * Light up the segment corresponding to controller
+-               * number on wired devices. On wireless we'll do that
+-               * when they respond to "presence" packet.
+-               */
+-              xpad_identify_controller(xpad);
+-      }
++      xpad_identify_controller(xpad);
+       return 0;
+@@ -1099,8 +1125,11 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
+ static void xpad_deinit_input(struct usb_xpad *xpad)
+ {
+-      xpad_led_disconnect(xpad);
+-      input_unregister_device(xpad->dev);
++      if (xpad->input_created) {
++              xpad->input_created = false;
++              xpad_led_disconnect(xpad);
++              input_unregister_device(xpad->dev);
++      }
+ }
+ static int xpad_init_input(struct usb_xpad *xpad)
+@@ -1183,6 +1212,7 @@ static int xpad_init_input(struct usb_xpad *xpad)
+       if (error)
+               goto err_disconnect_led;
++      xpad->input_created = true;
+       return 0;
+ err_disconnect_led:
+@@ -1246,6 +1276,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+       xpad->mapping = xpad_device[i].mapping;
+       xpad->xtype = xpad_device[i].xtype;
+       xpad->name = xpad_device[i].name;
++      INIT_WORK(&xpad->work, xpad_presence_work);
+       if (xpad->xtype == XTYPE_UNKNOWN) {
+               if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
+@@ -1282,10 +1313,6 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+       usb_set_intfdata(intf, xpad);
+-      error = xpad_init_input(xpad);
+-      if (error)
+-              goto err_deinit_output;
+-
+       if (xpad->xtype == XTYPE_XBOX360W) {
+               /*
+                * Submit the int URB immediately rather than waiting for open
+@@ -1297,7 +1324,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+               xpad->irq_in->dev = xpad->udev;
+               error = usb_submit_urb(xpad->irq_in, GFP_KERNEL);
+               if (error)
+-                      goto err_deinit_input;
++                      goto err_deinit_output;
+               /*
+                * Send presence packet.
+@@ -1309,13 +1336,15 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+               error = xpad_inquiry_pad_presence(xpad);
+               if (error)
+                       goto err_kill_in_urb;
++      } else {
++              error = xpad_init_input(xpad);
++              if (error)
++                      goto err_deinit_output;
+       }
+       return 0;
+ err_kill_in_urb:
+       usb_kill_urb(xpad->irq_in);
+-err_deinit_input:
+-      xpad_deinit_input(xpad);
+ err_deinit_output:
+       xpad_deinit_output(xpad);
+ err_free_in_urb:
+@@ -1332,17 +1361,19 @@ static void xpad_disconnect(struct usb_interface *intf)
+ {
+       struct usb_xpad *xpad = usb_get_intfdata (intf);
+-      xpad_deinit_input(xpad);
+-      xpad_deinit_output(xpad);
+-
+-      if (xpad->xtype == XTYPE_XBOX360W) {
++      if (xpad->xtype == XTYPE_XBOX360W)
+               usb_kill_urb(xpad->irq_in);
+-      }
++
++      cancel_work_sync(&xpad->work);
++
++      xpad_deinit_input(xpad);
+       usb_free_urb(xpad->irq_in);
+       usb_free_coherent(xpad->udev, XPAD_PKT_LEN,
+                       xpad->idata, xpad->idata_dma);
++      xpad_deinit_output(xpad);
++
+       kfree(xpad);
+       usb_set_intfdata(intf, NULL);
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-move-pending-clear-to-the-correct-locatio.patch b/queue-3.18/input-xpad-move-pending-clear-to-the-correct-locatio.patch
new file mode 100644 (file)
index 0000000..289f960
--- /dev/null
@@ -0,0 +1,40 @@
+From 11bdb3946d43f010e5b1c42f91f844245dedb1e3 Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Fri, 27 May 2016 16:22:25 -0700
+Subject: Input: xpad - move pending clear to the correct location
+
+[ Upstream commit 4efc6939a83c54fb3417541be48991afd0290ba3 ]
+
+otherwise we lose ff commands: https://github.com/paroj/xpad/issues/27
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 6e15ce40dbab..c8add0e425b5 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -758,6 +758,7 @@ static bool xpad_prepare_next_out_packet(struct usb_xpad *xpad)
+       if (packet) {
+               memcpy(xpad->odata, packet->data, packet->len);
+               xpad->irq_out->transfer_buffer_length = packet->len;
++              packet->pending = false;
+               return true;
+       }
+@@ -799,7 +800,6 @@ static void xpad_irq_out(struct urb *urb)
+       switch (status) {
+       case 0:
+               /* success */
+-              xpad->out_packets[xpad->last_out_packet].pending = false;
+               xpad->irq_out_active = xpad_prepare_next_out_packet(xpad);
+               break;
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-move-reporting-xbox-one-home-button-to-co.patch b/queue-3.18/input-xpad-move-reporting-xbox-one-home-button-to-co.patch
new file mode 100644 (file)
index 0000000..9c6ee06
--- /dev/null
@@ -0,0 +1,92 @@
+From 3bd846540483f88a6d7a909f39de04f059e057ec Mon Sep 17 00:00:00 2001
+From: Daniel Tobias <dan.g.tob@gmail.com>
+Date: Fri, 27 May 2016 16:25:32 -0700
+Subject: Input: xpad - move reporting xbox one home button to common function
+
+[ Upstream commit 4f88476c75429ba9ab71c428b4cd2f67575bc9c1 ]
+
+xbox one was the only device that has a *_process_buttons routine.
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 52 +++++++++++++----------------------
+ 1 file changed, 19 insertions(+), 33 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 8b7fc47f7ffb..b06f4b0785f7 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -610,14 +610,28 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha
+ }
+ /*
+- *    xpadone_process_buttons
++ *    xpadone_process_packet
+  *
+- *    Process a button update packet from an Xbox one controller.
++ *    Completes a request by converting the data into events for the
++ *    input subsystem. This version is for the Xbox One controller.
++ *
++ *    The report format was gleaned from
++ *    https://github.com/kylelemons/xbox/blob/master/xbox.go
+  */
+-static void xpadone_process_buttons(struct usb_xpad *xpad,
+-                              struct input_dev *dev,
+-                              unsigned char *data)
++static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
+ {
++      struct input_dev *dev = xpad->dev;
++
++      /* the xbox button has its own special report */
++      if (data[0] == 0X07) {
++              input_report_key(dev, BTN_MODE, data[4] & 0x01);
++              input_sync(dev);
++              return;
++      }
++      /* check invalid packet */
++      else if (data[0] != 0X20)
++              return;
++
+       /* menu/view buttons */
+       input_report_key(dev, BTN_START,  data[4] & 0x04);
+       input_report_key(dev, BTN_SELECT, data[4] & 0x08);
+@@ -680,34 +694,6 @@ static void xpadone_process_buttons(struct usb_xpad *xpad,
+       input_sync(dev);
+ }
+-/*
+- *    xpadone_process_packet
+- *
+- *    Completes a request by converting the data into events for the
+- *    input subsystem. This version is for the Xbox One controller.
+- *
+- *    The report format was gleaned from
+- *    https://github.com/kylelemons/xbox/blob/master/xbox.go
+- */
+-
+-static void xpadone_process_packet(struct usb_xpad *xpad,
+-                              u16 cmd, unsigned char *data)
+-{
+-      struct input_dev *dev = xpad->dev;
+-
+-      switch (data[0]) {
+-      case 0x20:
+-              xpadone_process_buttons(xpad, dev, data);
+-              break;
+-
+-      case 0x07:
+-              /* the xbox button has its own special report */
+-              input_report_key(dev, BTN_MODE, data[4] & 0x01);
+-              input_sync(dev);
+-              break;
+-      }
+-}
+-
+ static void xpad_irq_in(struct urb *urb)
+ {
+       struct usb_xpad *xpad = urb->context;
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-move-the-input-device-creation-to-a-new-f.patch b/queue-3.18/input-xpad-move-the-input-device-creation-to-a-new-f.patch
new file mode 100644 (file)
index 0000000..a765c43
--- /dev/null
@@ -0,0 +1,313 @@
+From 066f665cdf1c89eb03ff1292fd56264e7bc637a4 Mon Sep 17 00:00:00 2001
+From: "Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>
+Date: Sat, 10 Oct 2015 09:34:17 -0700
+Subject: Input: xpad - move the input device creation to a new function
+
+[ Upstream commit b8154002cbdfde1aed2f86bd27f5e2c7e832cabb ]
+
+To allow us to later create / destroy the input device from the urb
+callback, we need to initialize/ deinitialize the input device from a
+separate function.  So pull that logic out now to make later patches
+more "obvious" as to what they do.
+
+Signed-off-by: "Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 217 +++++++++++++++++++---------------
+ 1 file changed, 122 insertions(+), 95 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index f6e96741ff0e..652efb284e09 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -344,6 +344,7 @@ struct usb_xpad {
+       int mapping;                    /* map d-pad to buttons or to axes */
+       int xtype;                      /* type of xbox device */
+       int pad_nr;                     /* the order x360 pads were attached */
++      const char *name;               /* name of the device */
+ };
+ /*
+@@ -1062,94 +1063,36 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
+       }
+ }
+-static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id)
++static void xpad_deinit_input(struct usb_xpad *xpad)
++{
++      xpad_led_disconnect(xpad);
++      input_unregister_device(xpad->dev);
++}
++
++static int xpad_init_input(struct usb_xpad *xpad)
+ {
+-      struct usb_device *udev = interface_to_usbdev(intf);
+-      struct usb_xpad *xpad;
+       struct input_dev *input_dev;
+-      struct usb_endpoint_descriptor *ep_irq_in;
+-      int ep_irq_in_idx;
+       int i, error;
+-      if (intf->cur_altsetting->desc.bNumEndpoints != 2)
+-              return -ENODEV;
+-
+-      for (i = 0; xpad_device[i].idVendor; i++) {
+-              if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
+-                  (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))
+-                      break;
+-      }
+-
+-      if (xpad_device[i].xtype == XTYPE_XBOXONE &&
+-          intf->cur_altsetting->desc.bInterfaceNumber != 0) {
+-              /*
+-               * The Xbox One controller lists three interfaces all with the
+-               * same interface class, subclass and protocol. Differentiate by
+-               * interface number.
+-               */
+-              return -ENODEV;
+-      }
+-
+-      xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);
+       input_dev = input_allocate_device();
+-      if (!xpad || !input_dev) {
+-              error = -ENOMEM;
+-              goto fail1;
+-      }
+-
+-      xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN,
+-                                       GFP_KERNEL, &xpad->idata_dma);
+-      if (!xpad->idata) {
+-              error = -ENOMEM;
+-              goto fail1;
+-      }
+-
+-      xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL);
+-      if (!xpad->irq_in) {
+-              error = -ENOMEM;
+-              goto fail2;
+-      }
+-
+-      xpad->udev = udev;
+-      xpad->intf = intf;
+-      xpad->mapping = xpad_device[i].mapping;
+-      xpad->xtype = xpad_device[i].xtype;
+-
+-      if (xpad->xtype == XTYPE_UNKNOWN) {
+-              if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
+-                      if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)
+-                              xpad->xtype = XTYPE_XBOX360W;
+-                      else
+-                              xpad->xtype = XTYPE_XBOX360;
+-              } else
+-                      xpad->xtype = XTYPE_XBOX;
+-
+-              if (dpad_to_buttons)
+-                      xpad->mapping |= MAP_DPAD_TO_BUTTONS;
+-              if (triggers_to_buttons)
+-                      xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS;
+-              if (sticks_to_null)
+-                      xpad->mapping |= MAP_STICKS_TO_NULL;
+-      }
++      if (!input_dev)
++              return -ENOMEM;
+       xpad->dev = input_dev;
+-      usb_make_path(udev, xpad->phys, sizeof(xpad->phys));
+-      strlcat(xpad->phys, "/input0", sizeof(xpad->phys));
+-
+-      input_dev->name = xpad_device[i].name;
++      input_dev->name = xpad->name;
+       input_dev->phys = xpad->phys;
+-      usb_to_input_id(udev, &input_dev->id);
+-      input_dev->dev.parent = &intf->dev;
++      usb_to_input_id(xpad->udev, &input_dev->id);
++      input_dev->dev.parent = &xpad->intf->dev;
+       input_set_drvdata(input_dev, xpad);
+       input_dev->open = xpad_open;
+       input_dev->close = xpad_close;
+-      input_dev->evbit[0] = BIT_MASK(EV_KEY);
++      __set_bit(EV_KEY, input_dev->evbit);
+       if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
+-              input_dev->evbit[0] |= BIT_MASK(EV_ABS);
++              __set_bit(EV_ABS, input_dev->evbit);
+               /* set up axes */
+               for (i = 0; xpad_abs[i] >= 0; i++)
+                       xpad_set_up_abs(input_dev, xpad_abs[i]);
+@@ -1194,17 +1137,103 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+                       xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);
+       }
+-      error = xpad_init_output(intf, xpad);
+-      if (error)
+-              goto fail3;
+-
+       error = xpad_init_ff(xpad);
+       if (error)
+-              goto fail4;
++              goto err_free_input;
+       error = xpad_led_probe(xpad);
+       if (error)
+-              goto fail5;
++              goto err_destroy_ff;
++
++      error = input_register_device(xpad->dev);
++      if (error)
++              goto err_disconnect_led;
++
++      return 0;
++
++err_disconnect_led:
++      xpad_led_disconnect(xpad);
++err_destroy_ff:
++      input_ff_destroy(input_dev);
++err_free_input:
++      input_free_device(input_dev);
++      return error;
++}
++
++static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id)
++{
++      struct usb_device *udev = interface_to_usbdev(intf);
++      struct usb_xpad *xpad;
++      struct usb_endpoint_descriptor *ep_irq_in;
++      int ep_irq_in_idx;
++      int i, error;
++
++      if (intf->cur_altsetting->desc.bNumEndpoints != 2)
++              return -ENODEV;
++
++      for (i = 0; xpad_device[i].idVendor; i++) {
++              if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
++                  (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))
++                      break;
++      }
++
++      if (xpad_device[i].xtype == XTYPE_XBOXONE &&
++          intf->cur_altsetting->desc.bInterfaceNumber != 0) {
++              /*
++               * The Xbox One controller lists three interfaces all with the
++               * same interface class, subclass and protocol. Differentiate by
++               * interface number.
++               */
++              return -ENODEV;
++      }
++
++      xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);
++      if (!xpad)
++              return -ENOMEM;
++
++      usb_make_path(udev, xpad->phys, sizeof(xpad->phys));
++      strlcat(xpad->phys, "/input0", sizeof(xpad->phys));
++
++      xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN,
++                                       GFP_KERNEL, &xpad->idata_dma);
++      if (!xpad->idata) {
++              error = -ENOMEM;
++              goto err_free_mem;
++      }
++
++      xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL);
++      if (!xpad->irq_in) {
++              error = -ENOMEM;
++              goto err_free_idata;
++      }
++
++      xpad->udev = udev;
++      xpad->intf = intf;
++      xpad->mapping = xpad_device[i].mapping;
++      xpad->xtype = xpad_device[i].xtype;
++      xpad->name = xpad_device[i].name;
++
++      if (xpad->xtype == XTYPE_UNKNOWN) {
++              if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
++                      if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)
++                              xpad->xtype = XTYPE_XBOX360W;
++                      else
++                              xpad->xtype = XTYPE_XBOX360;
++              } else {
++                      xpad->xtype = XTYPE_XBOX;
++              }
++
++              if (dpad_to_buttons)
++                      xpad->mapping |= MAP_DPAD_TO_BUTTONS;
++              if (triggers_to_buttons)
++                      xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS;
++              if (sticks_to_null)
++                      xpad->mapping |= MAP_STICKS_TO_NULL;
++      }
++
++      error = xpad_init_output(intf, xpad);
++      if (error)
++              goto err_free_in_urb;
+       /* Xbox One controller has in/out endpoints swapped. */
+       ep_irq_in_idx = xpad->xtype == XTYPE_XBOXONE ? 1 : 0;
+@@ -1217,12 +1246,12 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+       xpad->irq_in->transfer_dma = xpad->idata_dma;
+       xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+-      error = input_register_device(xpad->dev);
+-      if (error)
+-              goto fail6;
+-
+       usb_set_intfdata(intf, xpad);
++      error = xpad_init_input(xpad);
++      if (error)
++              goto err_deinit_output;
++
+       if (xpad->xtype == XTYPE_XBOX360W) {
+               /*
+                * Submit the int URB immediately rather than waiting for open
+@@ -1234,20 +1263,19 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+               xpad->irq_in->dev = xpad->udev;
+               error = usb_submit_urb(xpad->irq_in, GFP_KERNEL);
+               if (error)
+-                      goto fail7;
++                      goto err_deinit_input;
+       }
+-
+       return 0;
+- fail7:       input_unregister_device(input_dev);
+-      input_dev = NULL;
+- fail6:       xpad_led_disconnect(xpad);
+- fail5:       if (input_dev)
+-              input_ff_destroy(input_dev);
+- fail4:       xpad_deinit_output(xpad);
+- fail3:       usb_free_urb(xpad->irq_in);
+- fail2:       usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
+- fail1:       input_free_device(input_dev);
++err_deinit_input:
++      xpad_deinit_input(xpad);
++err_deinit_output:
++      xpad_deinit_output(xpad);
++err_free_in_urb:
++      usb_free_urb(xpad->irq_in);
++err_free_idata:
++      usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
++err_free_mem:
+       kfree(xpad);
+       return error;
+@@ -1257,8 +1285,7 @@ static void xpad_disconnect(struct usb_interface *intf)
+ {
+       struct usb_xpad *xpad = usb_get_intfdata (intf);
+-      xpad_led_disconnect(xpad);
+-      input_unregister_device(xpad->dev);
++      xpad_deinit_input(xpad);
+       xpad_deinit_output(xpad);
+       if (xpad->xtype == XTYPE_XBOX360W) {
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-power-off-wireless-360-controllers-on-sus.patch b/queue-3.18/input-xpad-power-off-wireless-360-controllers-on-sus.patch
new file mode 100644 (file)
index 0000000..c0b28eb
--- /dev/null
@@ -0,0 +1,95 @@
+From 1d8ae45f6da6d339ca5481da5defb039d6cfd52a Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Wed, 27 Jul 2016 14:24:55 -0700
+Subject: Input: xpad - power off wireless 360 controllers on suspend
+
+[ Upstream commit f712a5a05228058f6b74635546549d4a46e117fc ]
+
+When the USB wireless adapter is suspended, the controllers
+lose their connection. This causes them to start flashing
+their LED rings and searching for the wireless adapter
+again, wasting the controller's battery power.
+
+Instead, we will tell the controllers to power down when
+we suspend. This mirrors the behavior of the controllers
+when connected to the console itself and how the official
+Xbox One wireless adapter behaves on Windows.
+
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 43 +++++++++++++++++++++++++++++++++++
+ 1 file changed, 43 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 05a5c647ed36..9cbd485c0f73 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -115,6 +115,10 @@ static bool sticks_to_null;
+ module_param(sticks_to_null, bool, S_IRUGO);
+ MODULE_PARM_DESC(sticks_to_null, "Do not map sticks at all for unknown pads");
++static bool auto_poweroff = true;
++module_param(auto_poweroff, bool, S_IWUSR | S_IRUGO);
++MODULE_PARM_DESC(auto_poweroff, "Power off wireless controllers on suspend");
++
+ static const struct xpad_device {
+       u16 idVendor;
+       u16 idProduct;
+@@ -1250,6 +1254,36 @@ static void xpad_stop_input(struct usb_xpad *xpad)
+       usb_kill_urb(xpad->irq_in);
+ }
++static void xpad360w_poweroff_controller(struct usb_xpad *xpad)
++{
++      unsigned long flags;
++      struct xpad_output_packet *packet =
++                      &xpad->out_packets[XPAD_OUT_CMD_IDX];
++
++      spin_lock_irqsave(&xpad->odata_lock, flags);
++
++      packet->data[0] = 0x00;
++      packet->data[1] = 0x00;
++      packet->data[2] = 0x08;
++      packet->data[3] = 0xC0;
++      packet->data[4] = 0x00;
++      packet->data[5] = 0x00;
++      packet->data[6] = 0x00;
++      packet->data[7] = 0x00;
++      packet->data[8] = 0x00;
++      packet->data[9] = 0x00;
++      packet->data[10] = 0x00;
++      packet->data[11] = 0x00;
++      packet->len = 12;
++      packet->pending = true;
++
++      /* Reset the sequence so we send out poweroff now */
++      xpad->last_out_packet = -1;
++      xpad_try_sending_next_out_packet(xpad);
++
++      spin_unlock_irqrestore(&xpad->odata_lock, flags);
++}
++
+ static int xpad360w_start_input(struct usb_xpad *xpad)
+ {
+       int error;
+@@ -1592,6 +1626,15 @@ static int xpad_suspend(struct usb_interface *intf, pm_message_t message)
+                * or goes away.
+                */
+               xpad360w_stop_input(xpad);
++
++              /*
++               * The wireless adapter is going off now, so the
++               * gamepads are going to become disconnected.
++               * Unless explicitly disabled, power them down
++               * so they don't just sit there flashing.
++               */
++              if (auto_poweroff && xpad->pad_present)
++                      xpad360w_poweroff_controller(xpad);
+       } else {
+               mutex_lock(&input->mutex);
+               if (input->users)
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-prevent-spurious-input-from-wired-xbox-36.patch b/queue-3.18/input-xpad-prevent-spurious-input-from-wired-xbox-36.patch
new file mode 100644 (file)
index 0000000..fd0b45a
--- /dev/null
@@ -0,0 +1,56 @@
+From 8be61ec9ef8fe69aec37888b3c6fed7312721ba2 Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Fri, 27 May 2016 16:23:50 -0700
+Subject: Input: xpad - prevent spurious input from wired Xbox 360 controllers
+
+[ Upstream commit 1ff5fa3c6732f08e01ae12f12286d4728c9e4d86 ]
+
+After initially connecting a wired Xbox 360 controller or sending it
+a command to change LEDs, a status/response packet is interpreted as
+controller input. This causes the state of buttons represented in
+byte 2 of the controller data packet to be incorrect until the next
+valid input packet. Wireless Xbox 360 controllers are not affected.
+
+Writing a new value to the LED device while holding the Start button
+and running jstest is sufficient to reproduce this bug. An event will
+come through with the Start button released.
+
+Xboxdrv also won't attempt to read controller input from a packet
+where byte 0 is non-zero. It also checks that byte 1 is 0x14, but
+that value differs between wired and wireless controllers and this
+code is shared by both. I think just checking byte 0 is enough to
+eliminate unwanted packets.
+
+The following are some examples of 3-byte status packets I saw:
+01 03 02
+02 03 00
+03 03 03
+08 03 00
+
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index c8add0e425b5..43b09dbacee6 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -459,6 +459,10 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
+ static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev,
+                                  u16 cmd, unsigned char *data)
+ {
++      /* valid pad data */
++      if (data[0] != 0x00)
++              return;
++
+       /* digital pad */
+       if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
+               /* dpad as buttons (left, right, up, down) */
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-query-wireless-controller-state-at-init.patch b/queue-3.18/input-xpad-query-wireless-controller-state-at-init.patch
new file mode 100644 (file)
index 0000000..6b0829e
--- /dev/null
@@ -0,0 +1,86 @@
+From a26b997ed71bd786e6176972d91b51fa34817a9c Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Sat, 10 Oct 2015 09:36:17 -0700
+Subject: Input: xpad - query wireless controller state at init
+
+[ Upstream commit aba54876bb38dde81abead1ed1936eb04fa30ca9 ]
+
+When we initialize the driver/device, we really don't know how many
+controllers are connected.  So send a "query presence" command to the
+base-station. (Command discovered by Zachary Lund)
+
+Presence packet taken from:
+
+https://github.com/computerquip/xpad5
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 40 +++++++++++++++++++++++++++++++++++
+ 1 file changed, 40 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 652efb284e09..ff368860a5f9 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -770,6 +770,33 @@ static void xpad_deinit_output(struct usb_xpad *xpad)
+       }
+ }
++static int xpad_inquiry_pad_presence(struct usb_xpad *xpad)
++{
++      int retval;
++
++      mutex_lock(&xpad->odata_mutex);
++
++      xpad->odata[0] = 0x08;
++      xpad->odata[1] = 0x00;
++      xpad->odata[2] = 0x0F;
++      xpad->odata[3] = 0xC0;
++      xpad->odata[4] = 0x00;
++      xpad->odata[5] = 0x00;
++      xpad->odata[6] = 0x00;
++      xpad->odata[7] = 0x00;
++      xpad->odata[8] = 0x00;
++      xpad->odata[9] = 0x00;
++      xpad->odata[10] = 0x00;
++      xpad->odata[11] = 0x00;
++      xpad->irq_out->transfer_buffer_length = 12;
++
++      retval = usb_submit_urb(xpad->irq_out, GFP_KERNEL);
++
++      mutex_unlock(&xpad->odata_mutex);
++
++      return retval;
++}
++
+ #ifdef CONFIG_JOYSTICK_XPAD_FF
+ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect)
+ {
+@@ -1264,9 +1291,22 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+               error = usb_submit_urb(xpad->irq_in, GFP_KERNEL);
+               if (error)
+                       goto err_deinit_input;
++
++              /*
++               * Send presence packet.
++               * This will force the controller to resend connection packets.
++               * This is useful in the case we activate the module after the
++               * adapter has been plugged in, as it won't automatically
++               * send us info about the controllers.
++               */
++              error = xpad_inquiry_pad_presence(xpad);
++              if (error)
++                      goto err_kill_in_urb;
+       }
+       return 0;
++err_kill_in_urb:
++      usb_kill_urb(xpad->irq_in);
+ err_deinit_input:
+       xpad_deinit_input(xpad);
+ err_deinit_output:
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-re-send-led-command-on-present-event.patch b/queue-3.18/input-xpad-re-send-led-command-on-present-event.patch
new file mode 100644 (file)
index 0000000..f8ed817
--- /dev/null
@@ -0,0 +1,110 @@
+From be92c7f6ae14965a4c44cb1e5cc94f6d8f2ce1d2 Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Mon, 22 Jun 2015 14:11:30 -0700
+Subject: Input: xpad - re-send LED command on present event
+
+[ Upstream commit cae705baa40b2c20de8f9bb79ef4bcc6b2418c7c ]
+
+The controller only receives commands when its present. So for the
+correct LED to be lit the LED command has to be sent on the present
+event.
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 28 ++++++++++++++++++++--------
+ 1 file changed, 20 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 5606e66ca5a5..a66720136290 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -346,6 +346,7 @@ struct usb_xpad {
+       int mapping;                    /* map d-pad to buttons or to axes */
+       int xtype;                      /* type of xbox device */
++      unsigned long led_no;           /* led to lit on xbox360 controllers */
+ };
+ /*
+@@ -490,6 +491,8 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
+       input_sync(dev);
+ }
++static void xpad_identify_controller(struct usb_xpad *xpad);
++
+ /*
+  * xpad360w_process_packet
+  *
+@@ -512,6 +515,11 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha
+               if (data[1] & 0x80) {
+                       xpad->pad_present = 1;
+                       usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
++                      /*
++                       * Light up the segment corresponding to
++                       * controller number.
++                       */
++                      xpad_identify_controller(xpad);
+               } else
+                       xpad->pad_present = 0;
+       }
+@@ -936,6 +944,12 @@ static void xpad_send_led_command(struct usb_xpad *xpad, int command)
+       mutex_unlock(&xpad->odata_mutex);
+ }
++static void xpad_identify_controller(struct usb_xpad *xpad)
++{
++      /* Light up the segment corresponding to controller number */
++      xpad_send_led_command(xpad, (xpad->led_no % 4) + 2);
++}
++
+ static void xpad_led_set(struct led_classdev *led_cdev,
+                        enum led_brightness value)
+ {
+@@ -947,8 +961,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
+ static int xpad_led_probe(struct usb_xpad *xpad)
+ {
+-      static atomic_t led_seq = ATOMIC_INIT(-1);
+-      unsigned long led_no;
++      static atomic_t led_seq = ATOMIC_INIT(-1);
+       struct xpad_led *led;
+       struct led_classdev *led_cdev;
+       int error;
+@@ -960,9 +973,9 @@ static int xpad_led_probe(struct usb_xpad *xpad)
+       if (!led)
+               return -ENOMEM;
+-      led_no = atomic_inc_return(&led_seq);
++      xpad->led_no = atomic_inc_return(&led_seq);
+-      snprintf(led->name, sizeof(led->name), "xpad%lu", led_no);
++      snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no);
+       led->xpad = xpad;
+       led_cdev = &led->led_cdev;
+@@ -976,10 +989,8 @@ static int xpad_led_probe(struct usb_xpad *xpad)
+               return error;
+       }
+-      /*
+-       * Light up the segment corresponding to controller number
+-       */
+-      xpad_send_led_command(xpad, (led_no % 4) + 2);
++      /* Light up the segment corresponding to controller number */
++      xpad_identify_controller(xpad);
+       return 0;
+ }
+@@ -996,6 +1007,7 @@ static void xpad_led_disconnect(struct usb_xpad *xpad)
+ #else
+ static int xpad_led_probe(struct usb_xpad *xpad) { return 0; }
+ static void xpad_led_disconnect(struct usb_xpad *xpad) { }
++static void xpad_identify_controller(struct usb_xpad *xpad) { }
+ #endif
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-remove-needless-bulk-out-urb-used-for-led.patch b/queue-3.18/input-xpad-remove-needless-bulk-out-urb-used-for-led.patch
new file mode 100644 (file)
index 0000000..57e427a
--- /dev/null
@@ -0,0 +1,162 @@
+From 3a1d0c9d09ee00131c1b9f1870fd2b7cbca15622 Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Tue, 6 Oct 2015 17:07:31 -0700
+Subject: Input: xpad - remove needless bulk out URB used for LED setup
+
+[ Upstream commit a306a65f46acb040d208523592a2d34f67d47a61 ]
+
+This code was probably wrong ever since and is redundant with
+xpad_send_led_command. Both try to send a similar command to the xbox360
+controller. However xpad_send_led_command correctly uses the pad_nr instead
+of bInterfaceNumber to select the led and re-uses the irq_out URB instead
+of creating a new one.
+
+Note that this change only affects the two supported wireless controllers.
+Tested using the xbox360 wireless controller (PC).
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 79 +----------------------------------
+ 1 file changed, 1 insertion(+), 78 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index a395980bb816..afa232b415a5 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -330,9 +330,6 @@ struct usb_xpad {
+       unsigned char *idata;           /* input data */
+       dma_addr_t idata_dma;
+-      struct urb *bulk_out;
+-      unsigned char *bdata;
+-
+       struct urb *irq_out;            /* urb for interrupt out report */
+       unsigned char *odata;           /* output data */
+       dma_addr_t odata_dma;
+@@ -512,7 +509,6 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha
+       if (data[0] & 0x08) {
+               if (data[1] & 0x80) {
+                       xpad->pad_present = 1;
+-                      usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
+                       /*
+                        * Light up the segment corresponding to
+                        * controller number.
+@@ -674,28 +670,6 @@ exit:
+                       __func__, retval);
+ }
+-static void xpad_bulk_out(struct urb *urb)
+-{
+-      struct usb_xpad *xpad = urb->context;
+-      struct device *dev = &xpad->intf->dev;
+-
+-      switch (urb->status) {
+-      case 0:
+-              /* success */
+-              break;
+-      case -ECONNRESET:
+-      case -ENOENT:
+-      case -ESHUTDOWN:
+-              /* this urb is terminated, clean up */
+-              dev_dbg(dev, "%s - urb shutting down with status: %d\n",
+-                      __func__, urb->status);
+-              break;
+-      default:
+-              dev_dbg(dev, "%s - nonzero urb status received: %d\n",
+-                      __func__, urb->status);
+-      }
+-}
+-
+ static void xpad_irq_out(struct urb *urb)
+ {
+       struct usb_xpad *xpad = urb->context;
+@@ -1234,52 +1208,6 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+       usb_set_intfdata(intf, xpad);
+       if (xpad->xtype == XTYPE_XBOX360W) {
+-              /*
+-               * Setup the message to set the LEDs on the
+-               * controller when it shows up
+-               */
+-              xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL);
+-              if (!xpad->bulk_out) {
+-                      error = -ENOMEM;
+-                      goto fail7;
+-              }
+-
+-              xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL);
+-              if (!xpad->bdata) {
+-                      error = -ENOMEM;
+-                      goto fail8;
+-              }
+-
+-              xpad->bdata[2] = 0x08;
+-              switch (intf->cur_altsetting->desc.bInterfaceNumber) {
+-              case 0:
+-                      xpad->bdata[3] = 0x42;
+-                      break;
+-              case 2:
+-                      xpad->bdata[3] = 0x43;
+-                      break;
+-              case 4:
+-                      xpad->bdata[3] = 0x44;
+-                      break;
+-              case 6:
+-                      xpad->bdata[3] = 0x45;
+-              }
+-
+-              ep_irq_in = &intf->cur_altsetting->endpoint[1].desc;
+-              if (usb_endpoint_is_bulk_out(ep_irq_in)) {
+-                      usb_fill_bulk_urb(xpad->bulk_out, udev,
+-                                        usb_sndbulkpipe(udev,
+-                                                        ep_irq_in->bEndpointAddress),
+-                                        xpad->bdata, XPAD_PKT_LEN,
+-                                        xpad_bulk_out, xpad);
+-              } else {
+-                      usb_fill_int_urb(xpad->bulk_out, udev,
+-                                       usb_sndintpipe(udev,
+-                                                      ep_irq_in->bEndpointAddress),
+-                                       xpad->bdata, XPAD_PKT_LEN,
+-                                       xpad_bulk_out, xpad, 0);
+-              }
+-
+               /*
+                * Submit the int URB immediately rather than waiting for open
+                * because we get status messages from the device whether
+@@ -1290,13 +1218,11 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+               xpad->irq_in->dev = xpad->udev;
+               error = usb_submit_urb(xpad->irq_in, GFP_KERNEL);
+               if (error)
+-                      goto fail9;
++                      goto fail7;
+       }
+       return 0;
+- fail9:       kfree(xpad->bdata);
+- fail8:       usb_free_urb(xpad->bulk_out);
+  fail7:       input_unregister_device(input_dev);
+       input_dev = NULL;
+  fail6:       xpad_led_disconnect(xpad);
+@@ -1320,8 +1246,6 @@ static void xpad_disconnect(struct usb_interface *intf)
+       xpad_deinit_output(xpad);
+       if (xpad->xtype == XTYPE_XBOX360W) {
+-              usb_kill_urb(xpad->bulk_out);
+-              usb_free_urb(xpad->bulk_out);
+               usb_kill_urb(xpad->irq_in);
+       }
+@@ -1329,7 +1253,6 @@ static void xpad_disconnect(struct usb_interface *intf)
+       usb_free_coherent(xpad->udev, XPAD_PKT_LEN,
+                       xpad->idata, xpad->idata_dma);
+-      kfree(xpad->bdata);
+       kfree(xpad);
+       usb_set_intfdata(intf, NULL);
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-remove-spurious-events-of-wireless-xpad-3.patch b/queue-3.18/input-xpad-remove-spurious-events-of-wireless-xpad-3.patch
new file mode 100644 (file)
index 0000000..109ed92
--- /dev/null
@@ -0,0 +1,47 @@
+From 089a3f0941902e21c5b4946ad821eed1496f6f4c Mon Sep 17 00:00:00 2001
+From: Clement Calmels <clement.calmels@free.fr>
+Date: Sat, 12 Dec 2015 21:20:11 -0800
+Subject: Input: xpad - remove spurious events of wireless xpad 360 controller
+
+[ Upstream commit 93a017aa2f77291752e637bfd83f2459dba714cb ]
+
+When powering up a wireless xbox 360 controller, some wrong joystick
+events are generated. It is annoying because, for example, it makes
+unwanted moves in Steam big picture mode's menu.
+
+When my controller is powering up, this packet is received by the
+driver:
+00000000: 00 0f 00 f0 00 cc ff cf 8b e0 86 6a 68 f0 00 20  ...........jh..
+00000010: 13 e3 20 1d 30 03 40 01 50 01 ff ff              .. .0.@.P...
+
+According to xboxdrv userspace driver source code, this packet is only
+dumping a serial id and should not be interpreted as joystick events.
+This issue can be easily seen with jstest:
+$ jstest --event /dev/input/js0
+
+This patch only adds a way to filter out this "serial" packet and as a
+result it removes the spurous events.
+
+Signed-off-by: Clement Calmels <clement.calmels@free.fr>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 1a66443f3cd5..33c3071c56f9 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -529,7 +529,7 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha
+       }
+       /* Valid pad data */
+-      if (!(data[1] & 0x1))
++      if (data[1] != 0x1)
+               return;
+       xpad360_process_packet(xpad, cmd, &data[4]);
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-remove-unused-function.patch b/queue-3.18/input-xpad-remove-unused-function.patch
new file mode 100644 (file)
index 0000000..a04d91c
--- /dev/null
@@ -0,0 +1,38 @@
+From 0b7208f79c528010ed5a153aa56286aede0da9a3 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Wed, 27 Jan 2016 15:42:25 -0800
+Subject: Input: xpad - remove unused function
+
+[ Upstream commit a6ed4a18ba6a6f5a01e024b9d221d6439bf6ca4c ]
+
+There are two definitions of xpad_identify_controller(), one is used
+when CONFIG_JOYSTICK_XPAD_LEDS is set, but the other one is empty
+and never used, and we get a gcc warning about it:
+
+drivers/input/joystick/xpad.c:1210:13: warning: 'xpad_identify_controller' defined but not used [-Wunused-function]
+
+This removes the second definition.
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Fixes: cae705baa40b ("Input: xpad - re-send LED command on present event")
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 02a9fe950f3f..5dc818aef2d1 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -1209,7 +1209,6 @@ static void xpad_led_disconnect(struct usb_xpad *xpad)
+ #else
+ static int xpad_led_probe(struct usb_xpad *xpad) { return 0; }
+ static void xpad_led_disconnect(struct usb_xpad *xpad) { }
+-static void xpad_identify_controller(struct usb_xpad *xpad) { }
+ #endif
+ static int xpad_start_input(struct usb_xpad *xpad)
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-restore-led-state-after-device-resume.patch b/queue-3.18/input-xpad-restore-led-state-after-device-resume.patch
new file mode 100644 (file)
index 0000000..b98ceb6
--- /dev/null
@@ -0,0 +1,53 @@
+From 789b31f84240142cc81c53bd3bb6c2e480309b5a Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Mon, 6 Feb 2017 17:03:03 -0800
+Subject: Input: xpad - restore LED state after device resume
+
+[ Upstream commit a1fbf5bbef025b4844162b3b8868888003a7ee9c ]
+
+Set the LED_CORE_SUSPENDRESUME flag on our LED device so the
+LED state will be automatically restored by LED core on resume.
+
+Since Xbox One pads stop flashing only when reinitialized, we'll
+send them the initialization packet so they calm down too.
+
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 14da79ead653..153b1ee13e03 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -1213,6 +1213,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
+       led_cdev = &led->led_cdev;
+       led_cdev->name = led->name;
+       led_cdev->brightness_set = xpad_led_set;
++      led_cdev->flags = LED_CORE_SUSPENDRESUME;
+       error = led_classdev_register(&xpad->udev->dev, led_cdev);
+       if (error)
+@@ -1689,8 +1690,16 @@ static int xpad_resume(struct usb_interface *intf)
+               retval = xpad360w_start_input(xpad);
+       } else {
+               mutex_lock(&input->mutex);
+-              if (input->users)
++              if (input->users) {
+                       retval = xpad_start_input(xpad);
++              } else if (xpad->xtype == XTYPE_XBOXONE) {
++                      /*
++                       * Even if there are no users, we'll send Xbox One pads
++                       * the startup sequence so they don't sit there and
++                       * blink until somebody opens the input device again.
++                       */
++                      retval = xpad_start_xbox_one(xpad);
++              }
+               mutex_unlock(&input->mutex);
+       }
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-set-the-leds-properly-on-xbox-wireless-co.patch b/queue-3.18/input-xpad-set-the-leds-properly-on-xbox-wireless-co.patch
new file mode 100644 (file)
index 0000000..214d2dd
--- /dev/null
@@ -0,0 +1,102 @@
+From e6f7f6f4f1ec0c2cdbacd62f980ca8508353c047 Mon Sep 17 00:00:00 2001
+From: "Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>
+Date: Mon, 22 Jun 2015 14:10:36 -0700
+Subject: Input: xpad - set the LEDs properly on XBox Wireless controllers
+
+[ Upstream commit 75b7f05d2798ee3a1cc5bbdd54acd0e318a80396 ]
+
+Based on Patch by Pierre-Loup A. Griffais <pgriffais@valvesoftware.com>:
+Add the logic to set the LEDs on XBox Wireless controllers.  Command
+sequence found by sniffing the Windows data stream when plugging the
+device in.
+
+Updated based on comments on linux-input:
+unify codepaths in xpad_send_led_command for wired/ wireless controller.
+Also document command values for clarification.
+All values tested on Xbox 360 Wireless Controller.
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 50 +++++++++++++++++++++++++++++++----
+ 1 file changed, 45 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index c4205ed022fd..5606e66ca5a5 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -883,17 +883,57 @@ struct xpad_led {
+       struct usb_xpad *xpad;
+ };
++/**
++ * @param command
++ *  0: off
++ *  1: all blink, then previous setting
++ *  2: 1/top-left blink, then on
++ *  3: 2/top-right blink, then on
++ *  4: 3/bottom-left blink, then on
++ *  5: 4/bottom-right blink, then on
++ *  6: 1/top-left on
++ *  7: 2/top-right on
++ *  8: 3/bottom-left on
++ *  9: 4/bottom-right on
++ * 10: rotate
++ * 11: blink, based on previous setting
++ * 12: slow blink, based on previous setting
++ * 13: rotate with two lights
++ * 14: persistent slow all blink
++ * 15: blink once, then previous setting
++ */
+ static void xpad_send_led_command(struct usb_xpad *xpad, int command)
+ {
+-      if (command >= 0 && command < 14) {
+-              mutex_lock(&xpad->odata_mutex);
++      command %= 16;
++
++      mutex_lock(&xpad->odata_mutex);
++
++      switch (xpad->xtype) {
++      case XTYPE_XBOX360:
+               xpad->odata[0] = 0x01;
+               xpad->odata[1] = 0x03;
+               xpad->odata[2] = command;
+               xpad->irq_out->transfer_buffer_length = 3;
+-              usb_submit_urb(xpad->irq_out, GFP_KERNEL);
+-              mutex_unlock(&xpad->odata_mutex);
++              break;
++      case XTYPE_XBOX360W:
++              xpad->odata[0] = 0x00;
++              xpad->odata[1] = 0x00;
++              xpad->odata[2] = 0x08;
++              xpad->odata[3] = 0x40 + command;
++              xpad->odata[4] = 0x00;
++              xpad->odata[5] = 0x00;
++              xpad->odata[6] = 0x00;
++              xpad->odata[7] = 0x00;
++              xpad->odata[8] = 0x00;
++              xpad->odata[9] = 0x00;
++              xpad->odata[10] = 0x00;
++              xpad->odata[11] = 0x00;
++              xpad->irq_out->transfer_buffer_length = 12;
++              break;
+       }
++
++      usb_submit_urb(xpad->irq_out, GFP_KERNEL);
++      mutex_unlock(&xpad->odata_mutex);
+ }
+ static void xpad_led_set(struct led_classdev *led_cdev,
+@@ -913,7 +953,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
+       struct led_classdev *led_cdev;
+       int error;
+-      if (xpad->xtype != XTYPE_XBOX360)
++      if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W)
+               return 0;
+       xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL);
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-simplify-error-condition-in-init_output.patch b/queue-3.18/input-xpad-simplify-error-condition-in-init_output.patch
new file mode 100644 (file)
index 0000000..48cbccc
--- /dev/null
@@ -0,0 +1,57 @@
+From 421987e69722a5ea55b514f5a712ef3f57418165 Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Fri, 27 May 2016 16:26:33 -0700
+Subject: Input: xpad - simplify error condition in init_output
+
+[ Upstream commit a8c34e27fb1ece928ec728bfe596aa6ca0b1928a ]
+
+Replace first goto with simple returns as we really are just returning
+one error code.
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 13 ++++++-------
+ 1 file changed, 6 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index b06f4b0785f7..d837900d609e 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -851,17 +851,15 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
+       xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN,
+                                        GFP_KERNEL, &xpad->odata_dma);
+-      if (!xpad->odata) {
+-              error = -ENOMEM;
+-              goto fail1;
+-      }
++      if (!xpad->odata)
++              return -ENOMEM;
+       spin_lock_init(&xpad->odata_lock);
+       xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL);
+       if (!xpad->irq_out) {
+               error = -ENOMEM;
+-              goto fail2;
++              goto err_free_coherent;
+       }
+       /* Xbox One controller has in/out endpoints swapped. */
+@@ -877,8 +875,9 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
+       return 0;
+- fail2:       usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma);
+- fail1:       return error;
++err_free_coherent:
++      usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma);
++      return error;
+ }
+ static void xpad_stop_output(struct usb_xpad *xpad)
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-sort-supported-devices-by-usb-id.patch b/queue-3.18/input-xpad-sort-supported-devices-by-usb-id.patch
new file mode 100644 (file)
index 0000000..db44ea8
--- /dev/null
@@ -0,0 +1,84 @@
+From b1e2b64ca27552e47e4d66ce813e953909627378 Mon Sep 17 00:00:00 2001
+From: Benjamin Valentin <benpicco@googlemail.com>
+Date: Sun, 7 May 2017 14:45:08 -0700
+Subject: Input: xpad - sort supported devices by USB ID
+
+[ Upstream commit 873cb582738fde338ecaeaca594560cde2ba42c3 ]
+
+Some entries in the table of supported devices are out of order.
+To not create a mess when adding new ones using a script, sort them first.
+
+Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
+Reviewed-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index df83fdc6c0e7..f600f6662063 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -126,19 +126,19 @@ static const struct xpad_device {
+       u8 mapping;
+       u8 xtype;
+ } xpad_device[] = {
++      { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
++      { 0x044f, 0xb326, "Thrustmaster Gamepad GP XID", 0, XTYPE_XBOX360 },
+       { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
+       { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
+       { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX },
+       { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
+       { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
++      { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+       { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
+       { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
+       { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE },
+       { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE },
+-      { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+       { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+-      { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
+-      { 0x044f, 0xb326, "Thrustmaster Gamepad GP XID", 0, XTYPE_XBOX360 },
+       { 0x046d, 0xc21d, "Logitech Gamepad F310", 0, XTYPE_XBOX360 },
+       { 0x046d, 0xc21e, "Logitech Gamepad F510", 0, XTYPE_XBOX360 },
+       { 0x046d, 0xc21f, "Logitech Gamepad F710", 0, XTYPE_XBOX360 },
+@@ -180,10 +180,10 @@ static const struct xpad_device {
+       { 0x0e6f, 0x0105, "HSM3 Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0113, "Afterglow AX.1 Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0139, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
++      { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+-      { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX },
+@@ -209,8 +209,6 @@ static const struct xpad_device {
+       { 0x162e, 0xbeef, "Joytech Neo-Se Take2", 0, XTYPE_XBOX360 },
+       { 0x1689, 0xfd00, "Razer Onza Tournament Edition", 0, XTYPE_XBOX360 },
+       { 0x1689, 0xfd01, "Razer Onza Classic Edition", 0, XTYPE_XBOX360 },
+-      { 0x24c6, 0x542a, "Xbox ONE spectra", 0, XTYPE_XBOXONE },
+-      { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
+@@ -224,12 +222,14 @@ static const struct xpad_device {
+       { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x541a, "PowerA Xbox One Mini Wired Controller", 0, XTYPE_XBOXONE },
++      { 0x24c6, 0x542a, "Xbox ONE spectra", 0, XTYPE_XBOXONE },
+       { 0x24c6, 0x543a, "PowerA Xbox One wired controller", 0, XTYPE_XBOXONE },
+       { 0x24c6, 0x5500, "Hori XBOX 360 EX 2 with Turbo", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5506, "Hori SOULCALIBUR V Stick", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5b02, "Thrustmaster, Inc. GPX Controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5b03, "Thrustmaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 },
+       { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
+       { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
+ };
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-support-some-quirky-xbox-one-pads.patch b/queue-3.18/input-xpad-support-some-quirky-xbox-one-pads.patch
new file mode 100644 (file)
index 0000000..b4764c2
--- /dev/null
@@ -0,0 +1,193 @@
+From 209cdafb1925f33202b90061cfee46a5bf989c12 Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Mon, 10 Apr 2017 20:43:04 -0700
+Subject: Input: xpad - support some quirky Xbox One pads
+
+[ Upstream commit 81093c9848a781b85163d06de92ef8f84528cf6a ]
+
+There are several quirky Xbox One pads that depend on initialization
+packets that the Microsoft pads don't require. To deal with these,
+I've added a mechanism for issuing device-specific initialization
+packets using a VID/PID-based quirks list.
+
+For the initial set of init quirks, I have added quirk handling from
+Valve's Steam Link xpad driver[0] and the 360Controller project[1] for
+macOS to enable some new pads to work properly.
+
+This should enable full functionality on the following quirky pads:
+0x0e6f:0x0165 - Titanfall 2 gamepad (previously fully non-functional)
+0x0f0d:0x0067 - Hori Horipad (analog sticks previously non-functional)
+0x24c6:0x541a - PowerA Xbox One pad (previously fully non-functional)
+0x24c6:0x542a - PowerA Xbox One pad (previously fully non-functional)
+0x24c6:0x543a - PowerA Xbox One pad (previously fully non-functional)
+
+[0]: https://github.com/ValveSoftware/steamlink-sdk/blob/master/kernel/drivers/input/joystick/xpad.c
+[1]: https://github.com/360Controller/360Controller
+
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 114 ++++++++++++++++++++++++++++++----
+ 1 file changed, 101 insertions(+), 13 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 153b1ee13e03..df83fdc6c0e7 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -339,6 +339,64 @@ static struct usb_device_id xpad_table[] = {
+ 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 +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;
+@@ -749,12 +808,48 @@ exit:
+                       __func__, retval);
+ }
++/* 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 +1035,17 @@ static int xpad_inquiry_pad_presence(struct usb_xpad *xpad)
+ 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);
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-sync-supported-devices-with-360controller.patch b/queue-3.18/input-xpad-sync-supported-devices-with-360controller.patch
new file mode 100644 (file)
index 0000000..5f251f5
--- /dev/null
@@ -0,0 +1,204 @@
+From 48e909139dbe280bc5e1f77135078d23c679460a Mon Sep 17 00:00:00 2001
+From: Benjamin Valentin <benpicco@googlemail.com>
+Date: Sun, 18 Jun 2017 15:40:37 -0700
+Subject: Input: xpad - sync supported devices with 360Controller
+
+[ Upstream commit c225370e01b87d3c4ef40d98295ac0bb1e5a3116 ]
+
+360Controller [0] is an OpenSource driver for Xbox/Xbox360/XboxOne
+controllers on macOS.
+
+It contains a couple device IDs unknown to the Linux driver, so I wrote a
+small Python script [1] to extract them and feed them into my previous
+script [2] to compare them with the IDs known to Linux.
+
+For most devices, this information is not really needed as xpad is able to
+automatically detect the type of an unknown Xbox Controller at run-time.
+I've therefore stripped all the generic/vague entries.
+
+I've excluded the Logitech G920, it's handled by a HID driver already.
+I've also excluded the Scene It! Big Button IR, it's handled by an
+out-of-tree driver. [3]
+
+[0] https://github.com/360Controller/360Controller
+[1] http://codepad.org/v9GyLKMq
+[2] http://codepad.org/qh7jclpD
+[3] https://github.com/micolous/xbox360bb
+
+Reviewed-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 57 +++++++++++++++++++++++++++++++++++
+ 1 file changed, 57 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index def96cd2479b..b8d08f2296ff 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -131,8 +131,10 @@ static const struct xpad_device {
+       { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
+       { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
+       { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX },
++      { 0x045e, 0x0288, "Microsoft Xbox Controller S v2", 0, XTYPE_XBOX },
+       { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
+       { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
++      { 0x045e, 0x028f, "Microsoft X-Box 360 pad v2", 0, XTYPE_XBOX360 },
+       { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+       { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
+       { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
+@@ -145,6 +147,7 @@ static const struct xpad_device {
+       { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
+       { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
+       { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
++      { 0x046d, 0xcaa3, "Logitech DriveFx Racing Wheel", 0, XTYPE_XBOX360 },
+       { 0x056e, 0x2004, "Elecom JC-U3613M", 0, XTYPE_XBOX360 },
+       { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX },
+       { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
+@@ -158,14 +161,19 @@ static const struct xpad_device {
+       { 0x0738, 0x4718, "Mad Catz Street Fighter IV FightStick SE", 0, XTYPE_XBOX360 },
+       { 0x0738, 0x4726, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x0738, 0x4728, "Mad Catz Street Fighter IV FightPad", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x0738, 0x4736, "Mad Catz MicroCon Gamepad", 0, XTYPE_XBOX360 },
+       { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0738, 0x4740, "Mad Catz Beat Pad", 0, XTYPE_XBOX360 },
++      { 0x0738, 0x4758, "Mad Catz Arcade Game Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0738, 0x4a01, "Mad Catz FightStick TE 2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+       { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
++      { 0x0738, 0x9871, "Mad Catz Portable Drum", 0, XTYPE_XBOX360 },
+       { 0x0738, 0xb726, "Mad Catz Xbox controller - MW2", 0, XTYPE_XBOX360 },
++      { 0x0738, 0xb738, "Mad Catz MVC2TE Stick 2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0738, 0xbeef, "Mad Catz JOYTECH NEO SE Advanced GamePad", XTYPE_XBOX360 },
+       { 0x0738, 0xcb02, "Saitek Cyborg Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0738, 0xcb03, "Saitek P3200 Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
++      { 0x0738, 0xcb29, "Saitek Aviator Stick AV8R02", 0, XTYPE_XBOX360 },
+       { 0x0738, 0xf738, "Super SFIV FightStick TE S", 0, XTYPE_XBOX360 },
+       { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
+       { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", DANCEPAD_MAP_CONFIG, XTYPE_XBOX },
+@@ -181,30 +189,52 @@ static const struct xpad_device {
+       { 0x0e6f, 0x0105, "HSM3 Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0113, "Afterglow AX.1 Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x011f, "Rock Candy Gamepad Wired Controller", 0, XTYPE_XBOX360 },
++      { 0x0e6f, 0x0131, "PDP EA Sports Controller", 0, XTYPE_XBOX360 },
++      { 0x0e6f, 0x0133, "Xbox 360 Wired Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0139, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
++      { 0x0e6f, 0x013a, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE },
++      { 0x0e6f, 0x0147, "PDP Marvel Xbox One Controller", 0, XTYPE_XBOXONE },
++      { 0x0e6f, 0x015c, "PDP Xbox One Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
++      { 0x0e6f, 0x0161, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
++      { 0x0e6f, 0x0162, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
++      { 0x0e6f, 0x0163, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
++      { 0x0e6f, 0x0164, "PDP Battlefield One", 0, XTYPE_XBOXONE },
++      { 0x0e6f, 0x0165, "PDP Titanfall 2", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
++      { 0x0e6f, 0x0246, "Rock Candy Gamepad for Xbox One 2015", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
++      { 0x0e6f, 0x0346, "Rock Candy Gamepad for Xbox One 2016", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0413, "Afterglow AX.1 Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
++      { 0x0e6f, 0x0501, "PDP Xbox 360 Controller", 0, XTYPE_XBOX360 },
++      { 0x0e6f, 0xf900, "PDP Afterglow AX.1", 0, XTYPE_XBOX360 },
+       { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX },
+       { 0x0e8f, 0x3008, "Generic xbox control (dealextreme)", 0, XTYPE_XBOX },
+       { 0x0f0d, 0x000a, "Hori Co. DOA4 FightStick", 0, XTYPE_XBOX360 },
++      { 0x0f0d, 0x000c, "Hori PadEX Turbo", 0, XTYPE_XBOX360 },
+       { 0x0f0d, 0x000d, "Hori Fighting Stick EX2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x0f0d, 0x001b, "Hori Real Arcade Pro VX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x0f0d, 0x0063, "Hori Real Arcade Pro Hayabusa (USA) Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+       { 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE },
++      { 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+       { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
+       { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
+       { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX },
++      { 0x11c9, 0x55f0, "Nacon GC-100XF", 0, XTYPE_XBOX360 },
+       { 0x12ab, 0x0004, "Honey Bee Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x12ab, 0x0301, "PDP AFTERGLOW AX.1", 0, XTYPE_XBOX360 },
++      { 0x12ab, 0x0303, "Mortal Kombat Klassic FightStick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
+       { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 },
+       { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
++      { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 },
+       { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 },
++      { 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+       { 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 },
+@@ -215,22 +245,42 @@ static const struct xpad_device {
+       { 0x1689, 0xfe00, "Razer Sabertooth", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0x0130, "Ion Drum Rocker", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf018, "Mad Catz Street Fighter IV SE Fighting Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf019, "Mad Catz Brawlstick for Xbox 360", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf021, "Mad Cats Ghost Recon FS GamePad", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf023, "MLG Pro Circuit Controller (Xbox)", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xf025, "Mad Catz Call Of Duty", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xf027, "Mad Catz FPS Pro", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf028, "Street Fighter IV FightPad", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf02e, "Mad Catz Fightpad", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf038, "Street Fighter IV FightStick TE", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xf039, "Mad Catz MvC2 TE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf03a, "Mad Catz SFxT Fightstick Pro", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf03d, "Street Fighter IV Arcade Stick TE - Chun Li", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf03e, "Mad Catz MLG FightStick TE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf03f, "Mad Catz FightStick SoulCaliber", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf042, "Mad Catz FightStick TES+", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf080, "Mad Catz FightStick TE2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf501, "HoriPad EX2 Turbo", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xf502, "Hori Real Arcade Pro.VX SA", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf503, "Hori Fighting Stick VX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf504, "Hori Real Arcade Pro. EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf505, "Hori Fighting Stick EX2B", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf506, "Hori Real Arcade Pro.EX Premium VLX", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf900, "Harmonix Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf901, "Gamestop Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf903, "Tron Xbox 360 controller", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xf904, "PDP Versus Fighting Pad", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xf906, "MortalKombat FightStick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xfa01, "MadCatz GamePad", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xfd00, "Razer Onza TE", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xfd01, "Razer Onza", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0x530a, "Xbox 360 Pro EX Controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x531a, "PowerA Pro Ex", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5397, "FUS1ON Tournament Controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x541a, "PowerA Xbox One Mini Wired Controller", 0, XTYPE_XBOXONE },
+@@ -238,12 +288,18 @@ static const struct xpad_device {
+       { 0x24c6, 0x543a, "PowerA Xbox One wired controller", 0, XTYPE_XBOXONE },
+       { 0x24c6, 0x5500, "Hori XBOX 360 EX 2 with Turbo", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0x5502, "Hori Fighting Stick VX Alt", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x24c6, 0x5503, "Hori Fighting Edge", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x24c6, 0x5506, "Hori SOULCALIBUR V Stick", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x550d, "Hori GEM Xbox controller", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0x550e, "Hori Real Arcade Pro V Kai 360", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x24c6, 0x551a, "PowerA FUSION Pro Controller", 0, XTYPE_XBOXONE },
++      { 0x24c6, 0x561a, "PowerA FUSION Controller", 0, XTYPE_XBOXONE },
++      { 0x24c6, 0x5b00, "ThrustMaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5b02, "Thrustmaster, Inc. GPX Controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5b03, "Thrustmaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0xfafe, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
+       { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
+ };
+@@ -338,6 +394,7 @@ static struct usb_device_id xpad_table[] = {
+       XPAD_XBOXONE_VENDOR(0x0e6f),            /* 0x0e6f X-Box One controllers */
+       XPAD_XBOX360_VENDOR(0x0f0d),            /* Hori Controllers */
+       XPAD_XBOXONE_VENDOR(0x0f0d),            /* Hori Controllers */
++      XPAD_XBOX360_VENDOR(0x11c9),            /* Nacon GC100XF */
+       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 */
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-sync-supported-devices-with-xbcd.patch b/queue-3.18/input-xpad-sync-supported-devices-with-xbcd.patch
new file mode 100644 (file)
index 0000000..8f02dc4
--- /dev/null
@@ -0,0 +1,147 @@
+From 4fb32571160530f317b7947bddfc9d103f477547 Mon Sep 17 00:00:00 2001
+From: Benjamin Valentin <benpicco@googlemail.com>
+Date: Sun, 18 Jun 2017 15:41:20 -0700
+Subject: Input: xpad - sync supported devices with XBCD
+
+[ Upstream commit be19788c73d382f66dd3fba3c5ccef59cf12a126 ]
+
+XBCD [0][1] is an OpenSource driver for Xbox controllers on Windows.
+Later it also started supporting Xbox360 controllers (presumably before
+the official Windows driver was released).
+
+It contains a couple device IDs unknown to the Linux driver, so I extracted
+those from xbcd.inf and added them to our list.
+
+It has a special type for Wheels and I have the feeling they might need
+some extra handling. They all have 'Wheel' in their name, so that
+information is available for future improvements.
+
+[0] https://www.s-config.com/xbcd-original-xbox-controllers-win10/
+[1] http://www.redcl0ud.com/xbcd.html
+
+Reviewed-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 30 ++++++++++++++++++++++++++++++
+ 1 file changed, 30 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index b8d08f2296ff..298a6ba51411 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -126,7 +126,10 @@ static const struct xpad_device {
+       u8 mapping;
+       u8 xtype;
+ } xpad_device[] = {
++      { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX },
++      { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX },
+       { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
++      { 0x044f, 0x0f10, "Thrustmaster Modena GT Wheel", 0, XTYPE_XBOX },
+       { 0x044f, 0xb326, "Thrustmaster Gamepad GP XID", 0, XTYPE_XBOX360 },
+       { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
+       { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
+@@ -147,16 +150,30 @@ static const struct xpad_device {
+       { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
+       { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
+       { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
++      { 0x046d, 0xca8a, "Logitech Precision Vibration Feedback Wheel", 0, XTYPE_XBOX },
+       { 0x046d, 0xcaa3, "Logitech DriveFx Racing Wheel", 0, XTYPE_XBOX360 },
+       { 0x056e, 0x2004, "Elecom JC-U3613M", 0, XTYPE_XBOX360 },
+       { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX },
+       { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
++      { 0x05fe, 0x3030, "Chic Controller", 0, XTYPE_XBOX },
++      { 0x05fe, 0x3031, "Chic Controller", 0, XTYPE_XBOX },
++      { 0x062a, 0x0020, "Logic3 Xbox GamePad", 0, XTYPE_XBOX },
++      { 0x062a, 0x0033, "Competition Pro Steering Wheel", 0, XTYPE_XBOX },
++      { 0x06a3, 0x0200, "Saitek Racing Wheel", 0, XTYPE_XBOX },
++      { 0x06a3, 0x0201, "Saitek Adrenalin", 0, XTYPE_XBOX },
++      { 0x06a3, 0xf51a, "Saitek P3600", 0, XTYPE_XBOX360 },
++      { 0x0738, 0x4506, "Mad Catz 4506 Wireless Controller", 0, XTYPE_XBOX },
+       { 0x0738, 0x4516, "Mad Catz Control Pad", 0, XTYPE_XBOX },
++      { 0x0738, 0x4520, "Mad Catz Control Pad Pro", 0, XTYPE_XBOX },
+       { 0x0738, 0x4522, "Mad Catz LumiCON", 0, XTYPE_XBOX },
+       { 0x0738, 0x4526, "Mad Catz Control Pad Pro", 0, XTYPE_XBOX },
++      { 0x0738, 0x4530, "Mad Catz Universal MC2 Racing Wheel and Pedals", 0, XTYPE_XBOX },
+       { 0x0738, 0x4536, "Mad Catz MicroCON", 0, XTYPE_XBOX },
+       { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
+       { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", 0, XTYPE_XBOX },
++      { 0x0738, 0x4586, "Mad Catz MicroCon Wireless Controller", 0, XTYPE_XBOX },
++      { 0x0738, 0x4588, "Mad Catz Blaster", 0, XTYPE_XBOX },
++      { 0x0738, 0x45ff, "Mad Catz Beat Pad (w/ Handle)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
+       { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x0738, 0x4718, "Mad Catz Street Fighter IV FightStick SE", 0, XTYPE_XBOX360 },
+       { 0x0738, 0x4726, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
+@@ -164,6 +181,7 @@ static const struct xpad_device {
+       { 0x0738, 0x4736, "Mad Catz MicroCon Gamepad", 0, XTYPE_XBOX360 },
+       { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0738, 0x4740, "Mad Catz Beat Pad", 0, XTYPE_XBOX360 },
++      { 0x0738, 0x4743, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
+       { 0x0738, 0x4758, "Mad Catz Arcade Game Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0738, 0x4a01, "Mad Catz FightStick TE 2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+       { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
+@@ -175,6 +193,9 @@ static const struct xpad_device {
+       { 0x0738, 0xcb03, "Saitek P3200 Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0738, 0xcb29, "Saitek Aviator Stick AV8R02", 0, XTYPE_XBOX360 },
+       { 0x0738, 0xf738, "Super SFIV FightStick TE S", 0, XTYPE_XBOX360 },
++      { 0x07ff, 0xffff, "Mad Catz GamePad", 0, XTYPE_XBOX360 },
++      { 0x0c12, 0x0005, "Intec wireless", 0, XTYPE_XBOX },
++      { 0x0c12, 0x8801, "Nyko Xbox Controller", 0, XTYPE_XBOX },
+       { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
+       { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", DANCEPAD_MAP_CONFIG, XTYPE_XBOX },
+       { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX },
+@@ -182,10 +203,13 @@ static const struct xpad_device {
+       { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX },
+       { 0x0d2f, 0x0002, "Andamiro Pump It Up pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
+       { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX },
++      { 0x0e4c, 0x1103, "Radica Gamester Reflex", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX },
+       { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX },
++      { 0x0e4c, 0x3510, "Radica Gamester", 0, XTYPE_XBOX },
+       { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX },
+       { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX },
+       { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX },
++      { 0x0e6f, 0x0008, "After Glow Pro Controller", 0, XTYPE_XBOX },
+       { 0x0e6f, 0x0105, "HSM3 Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0113, "Afterglow AX.1 Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x011f, "Rock Candy Gamepad Wired Controller", 0, XTYPE_XBOX360 },
+@@ -221,6 +245,7 @@ static const struct xpad_device {
+       { 0x0f0d, 0x0063, "Hori Real Arcade Pro Hayabusa (USA) Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+       { 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE },
+       { 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
++      { 0x0f30, 0x010b, "Philips Recoil", 0, XTYPE_XBOX },
+       { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
+       { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
+       { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX },
+@@ -255,6 +280,8 @@ static const struct xpad_device {
+       { 0x1bad, 0xf027, "Mad Catz FPS Pro", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf028, "Street Fighter IV FightPad", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf02e, "Mad Catz Fightpad", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf030, "Mad Catz Xbox 360 MC2 MicroCon Racing Wheel", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xf036, "Mad Catz MicroCon GamePad Pro", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf038, "Street Fighter IV FightStick TE", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf039, "Mad Catz MvC2 TE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf03a, "Mad Catz SFxT Fightstick Pro", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+@@ -300,6 +327,7 @@ static const struct xpad_device {
+       { 0x24c6, 0x5b03, "Thrustmaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0xfafe, "Rock Candy Gamepad for Xbox 360", 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 }
+ };
+@@ -387,9 +415,11 @@ static struct usb_device_id xpad_table[] = {
+       XPAD_XBOXONE_VENDOR(0x045e),            /* Microsoft X-Box One controllers */
+       XPAD_XBOX360_VENDOR(0x046d),            /* Logitech X-Box 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 */
+       { 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(0x0e6f),            /* 0x0e6f X-Box 360 controllers */
+       XPAD_XBOXONE_VENDOR(0x0e6f),            /* 0x0e6f X-Box One controllers */
+       XPAD_XBOX360_VENDOR(0x0f0d),            /* Hori Controllers */
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-sync-supported-devices-with-xboxdrv.patch b/queue-3.18/input-xpad-sync-supported-devices-with-xboxdrv.patch
new file mode 100644 (file)
index 0000000..d17b924
--- /dev/null
@@ -0,0 +1,100 @@
+From d99f304e8af391b07f2ea8805320afee75208d04 Mon Sep 17 00:00:00 2001
+From: Benjamin Valentin <benpicco@googlemail.com>
+Date: Sun, 7 May 2017 14:48:14 -0700
+Subject: Input: xpad - sync supported devices with xboxdrv
+
+[ Upstream commit 44bc722593201da43862b7200ee0b98155410b07 ]
+
+The userspace xboxdrv driver [0] contains some USB IDs unknown to the
+kernel driver. I have created a simple script [1] to extract the missing
+devices and add them to xpad.
+
+A quick google search confirmed that all the new devices called
+Fightstick/pad are Arcade-type devices [2] where the
+MAP_TRIGGERS_TO_BUTTONS option should apply.
+
+There are some similar devices in the existing device table where this
+flag is not set, but I did refrain from changing those.
+
+[0] https://github.com/xboxdrv/xboxdrv/blob/stable/src/xpad_device.cpp
+[1] http://codepad.org/CHV98BNH
+[2] https://www.google.com/search?q=SFxT+Fightstick+Pro&tbm=isch
+
+Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
+Reviewed-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index f600f6662063..16338f0b004f 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -145,6 +145,7 @@ static const struct xpad_device {
+       { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
+       { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
+       { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
++      { 0x056e, 0x2004, "Elecom JC-U3613M", 0, XTYPE_XBOX360 },
+       { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX },
+       { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
+       { 0x0738, 0x4516, "Mad Catz Control Pad", 0, XTYPE_XBOX },
+@@ -179,6 +180,7 @@ static const struct xpad_device {
+       { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX },
+       { 0x0e6f, 0x0105, "HSM3 Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0113, "Afterglow AX.1 Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
++      { 0x0e6f, 0x011f, "Rock Candy Gamepad Wired Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0139, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
+@@ -186,6 +188,7 @@ static const struct xpad_device {
+       { 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
+       { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
++      { 0x0e6f, 0x0413, "Afterglow AX.1 Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX },
+       { 0x0e8f, 0x3008, "Generic xbox control (dealextreme)", 0, XTYPE_XBOX },
+       { 0x0f0d, 0x000a, "Hori Co. DOA4 FightStick", 0, XTYPE_XBOX360 },
+@@ -212,21 +215,30 @@ static const struct xpad_device {
+       { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xf018, "Mad Catz Street Fighter IV SE Fighting Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
++      { 0x1bad, 0xf021, "Mad Cats Ghost Recon FS GamePad", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf023, "MLG Pro Circuit Controller (Xbox)", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf028, "Street Fighter IV FightPad", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xf02e, "Mad Catz Fightpad", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf038, "Street Fighter IV FightStick TE", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xf03a, "Mad Catz SFxT Fightstick Pro", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x1bad, 0xf900, "Harmonix Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf901, "Gamestop Xbox 360 Controller", 0, XTYPE_XBOX360 },
+       { 0x1bad, 0xf903, "Tron Xbox 360 controller", 0, XTYPE_XBOX360 },
++      { 0x1bad, 0xfa01, "MadCatz GamePad", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0x531a, "PowerA Pro Ex", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0x5397, "FUS1ON Tournament Controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x541a, "PowerA Xbox One Mini Wired Controller", 0, XTYPE_XBOXONE },
+       { 0x24c6, 0x542a, "Xbox ONE spectra", 0, XTYPE_XBOXONE },
+       { 0x24c6, 0x543a, "PowerA Xbox One wired controller", 0, XTYPE_XBOXONE },
+       { 0x24c6, 0x5500, "Hori XBOX 360 EX 2 with Turbo", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0x5503, "Hori Fighting Edge", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+       { 0x24c6, 0x5506, "Hori SOULCALIBUR V Stick", 0, XTYPE_XBOX360 },
++      { 0x24c6, 0x550d, "Hori GEM Xbox controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5b02, "Thrustmaster, Inc. GPX Controller", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5b03, "Thrustmaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 },
+       { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 },
+@@ -316,6 +328,7 @@ static struct usb_device_id xpad_table[] = {
+       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(0x056e),            /* Elecom JC-U3613M */
+       XPAD_XBOX360_VENDOR(0x0738),            /* Mad Catz X-Box 360 controllers */
+       { USB_DEVICE(0x0738, 0x4540) },         /* Mad Catz Beat Pad */
+       XPAD_XBOXONE_VENDOR(0x0738),            /* Mad Catz FightStick TE 2 */
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-update-xbox-one-force-feedback-support.patch b/queue-3.18/input-xpad-update-xbox-one-force-feedback-support.patch
new file mode 100644 (file)
index 0000000..a7a826b
--- /dev/null
@@ -0,0 +1,75 @@
+From e0ec350a5a88b70162757a515cdd5e6f9131fa86 Mon Sep 17 00:00:00 2001
+From: "Pierre-Loup A. Griffais" <githubpublic@plagman.net>
+Date: Wed, 9 Dec 2015 13:40:37 -0800
+Subject: Input: xpad - update Xbox One Force Feedback Support
+
+[ Upstream commit 2a6d7527b35cf987260800807e328d167aef22ac ]
+
+There's apparently a serial number woven into both input and output
+packets; neglecting to specify a valid serial number causes the controller
+to ignore the rumble packets.
+
+The scale of the rumble was also apparently halved in the packets.
+
+The initialization packet had to be changed to allow force feedback to
+work.
+
+see https://github.com/paroj/xpad/issues/7 for details.
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index f2af62d18746..68197239e327 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -350,6 +350,7 @@ struct usb_xpad {
+       struct urb *irq_out;            /* urb for interrupt out report */
+       bool irq_out_active;            /* we must not use an active URB */
+       unsigned char *odata;           /* output data */
++      u8 odata_serial;                /* serial number for xbox one protocol */
+       dma_addr_t odata_dma;
+       spinlock_t odata_lock;
+@@ -925,7 +926,10 @@ static int xpad_start_xbox_one(struct usb_xpad *xpad)
+       /* Xbox one controller needs to be initialized. */
+       packet->data[0] = 0x05;
+       packet->data[1] = 0x20;
+-      packet->len = 2;
++      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 */
+@@ -1000,17 +1004,18 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
+       case XTYPE_XBOXONE:
+               packet->data[0] = 0x09; /* activate rumble */
+               packet->data[1] = 0x08;
+-              packet->data[2] = 0x00;
++              packet->data[2] = xpad->odata_serial++;
+               packet->data[3] = 0x08; /* continuous effect */
+               packet->data[4] = 0x00; /* simple rumble mode */
+               packet->data[5] = 0x03; /* L and R actuator only */
+               packet->data[6] = 0x00; /* TODO: LT actuator */
+               packet->data[7] = 0x00; /* TODO: RT actuator */
+-              packet->data[8] = strong / 256; /* left actuator */
+-              packet->data[9] = weak / 256;   /* right actuator */
++              packet->data[8] = strong / 512; /* left actuator */
++              packet->data[9] = weak / 512;   /* right actuator */
+               packet->data[10] = 0x80;        /* length of pulse */
+               packet->data[11] = 0x00;        /* stop period of pulse */
+-              packet->len = 12;
++              packet->data[12] = 0x00;
++              packet->len = 13;
+               packet->pending = true;
+               break;
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-use-correct-product-id-for-x360w-controll.patch b/queue-3.18/input-xpad-use-correct-product-id-for-x360w-controll.patch
new file mode 100644 (file)
index 0000000..bc1dfc0
--- /dev/null
@@ -0,0 +1,44 @@
+From be83c7c46297a9e48b0ab55bbf2dafdf77b9ec2d Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Tue, 27 Dec 2016 11:44:51 -0800
+Subject: Input: xpad - use correct product id for x360w controllers
+
+[ Upstream commit b6fc513da50c5dbc457a8ad6b58b046a6a68fd9d ]
+
+currently the controllers get the same product id as the wireless
+receiver. However the controllers actually have their own product id.
+
+The patch makes the driver expose the same product id as the windows
+driver.
+
+This improves compatibility when running applications with WINE.
+
+see https://github.com/paroj/xpad/issues/54
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index fa6c72657f96..b9f48d4e155a 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -1379,6 +1379,12 @@ static int xpad_init_input(struct usb_xpad *xpad)
+       input_dev->name = xpad->name;
+       input_dev->phys = xpad->phys;
+       usb_to_input_id(xpad->udev, &input_dev->id);
++
++      if (xpad->xtype == XTYPE_XBOX360W) {
++              /* x360w controllers and the receiver have different ids */
++              input_dev->id.product = 0x02a1;
++      }
++
+       input_dev->dev.parent = &xpad->intf->dev;
+       input_set_drvdata(input_dev, xpad);
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-use-ida-for-finding-the-pad_nr.patch b/queue-3.18/input-xpad-use-ida-for-finding-the-pad_nr.patch
new file mode 100644 (file)
index 0000000..a5d97ba
--- /dev/null
@@ -0,0 +1,129 @@
+From 4b436346ab0259e57a4b7bf2f14098a3b0faa67f Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Sat, 10 Oct 2015 10:00:49 -0700
+Subject: Input: xpad - use ida() for finding the pad_nr
+
+[ Upstream commit e3b651745a03810efffd7ebf2a9b5be65fb70ec3 ]
+
+The pad_nr corresponds to the lit up LED on the controller. Therefore there
+should be no gaps when enumerating. Currently a LED is only re-assigned
+after a controller is re-connected 4 times.
+
+This patch uses ida to track connected pads - this way we can re-assign
+freed up pad number immediately.
+
+Consider the following case:
+1. pad A is connected and gets pad_nr = 0
+2. pad B is connected and gets pad_nr = 1
+3. pad A is disconnected
+4. pad A is connected again
+
+using ida_simple_get() controller A now correctly gets pad_nr = 0 again.
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 32 ++++++++++++++++++++------------
+ 1 file changed, 20 insertions(+), 12 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 60ebd78a49a6..a395980bb816 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -244,7 +244,6 @@ static const signed short xpad_btn_triggers[] = {
+       -1
+ };
+-
+ static const signed short xpad360_btn[] = {  /* buttons for x360 controller */
+       BTN_TL, BTN_TR,         /* Button LB/RB */
+       BTN_MODE,               /* The big X button */
+@@ -347,7 +346,7 @@ struct usb_xpad {
+       int mapping;                    /* map d-pad to buttons or to axes */
+       int xtype;                      /* type of xbox device */
+-      unsigned long pad_nr;           /* the order x360 pads were attached */
++      int pad_nr;                     /* the order x360 pads were attached */
+ };
+ /*
+@@ -883,6 +882,9 @@ static int xpad_init_ff(struct usb_xpad *xpad) { return 0; }
+ #if defined(CONFIG_JOYSTICK_XPAD_LEDS)
+ #include <linux/leds.h>
++#include <linux/idr.h>
++
++static DEFINE_IDA(xpad_pad_seq);
+ struct xpad_led {
+       char name[16];
+@@ -964,7 +966,6 @@ static void xpad_led_set(struct led_classdev *led_cdev,
+ static int xpad_led_probe(struct usb_xpad *xpad)
+ {
+-      static atomic_t led_seq = ATOMIC_INIT(-1);
+       struct xpad_led *led;
+       struct led_classdev *led_cdev;
+       int error;
+@@ -976,9 +977,13 @@ static int xpad_led_probe(struct usb_xpad *xpad)
+       if (!led)
+               return -ENOMEM;
+-      xpad->pad_nr = atomic_inc_return(&led_seq);
++      xpad->pad_nr = ida_simple_get(&xpad_pad_seq, 0, 0, GFP_KERNEL);
++      if (xpad->pad_nr < 0) {
++              error = xpad->pad_nr;
++              goto err_free_mem;
++      }
+-      snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->pad_nr);
++      snprintf(led->name, sizeof(led->name), "xpad%d", xpad->pad_nr);
+       led->xpad = xpad;
+       led_cdev = &led->led_cdev;
+@@ -986,16 +991,19 @@ static int xpad_led_probe(struct usb_xpad *xpad)
+       led_cdev->brightness_set = xpad_led_set;
+       error = led_classdev_register(&xpad->udev->dev, led_cdev);
+-      if (error) {
+-              kfree(led);
+-              xpad->led = NULL;
+-              return error;
+-      }
++      if (error)
++              goto err_free_id;
+       /* Light up the segment corresponding to controller number */
+       xpad_identify_controller(xpad);
+-
+       return 0;
++
++err_free_id:
++      ida_simple_remove(&xpad_pad_seq, xpad->pad_nr);
++err_free_mem:
++      kfree(led);
++      xpad->led = NULL;
++      return error;
+ }
+ static void xpad_led_disconnect(struct usb_xpad *xpad)
+@@ -1004,6 +1012,7 @@ static void xpad_led_disconnect(struct usb_xpad *xpad)
+       if (xpad_led) {
+               led_classdev_unregister(&xpad_led->led_cdev);
++              ida_simple_remove(&xpad_pad_seq, xpad->pad_nr);
+               kfree(xpad_led);
+       }
+ }
+@@ -1013,7 +1022,6 @@ static void xpad_led_disconnect(struct usb_xpad *xpad) { }
+ static void xpad_identify_controller(struct usb_xpad *xpad) { }
+ #endif
+-
+ static int xpad_open(struct input_dev *dev)
+ {
+       struct usb_xpad *xpad = input_get_drvdata(dev);
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-use-led-api-when-identifying-wireless-con.patch b/queue-3.18/input-xpad-use-led-api-when-identifying-wireless-con.patch
new file mode 100644 (file)
index 0000000..a6483b4
--- /dev/null
@@ -0,0 +1,34 @@
+From da9be916d7b27424976ad49f861ede6e10a46e1d Mon Sep 17 00:00:00 2001
+From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Date: Wed, 16 Dec 2015 14:24:58 -0800
+Subject: Input: xpad - use LED API when identifying wireless controllers
+
+[ Upstream commit d9be398afb2c3333716324352d062c50112e4e86 ]
+
+When lighting up the segment identifying wireless controller, Instead of
+sending command directly to the controller, let's do it via LED API (usinf
+led_set_brightness) so that LED object state is in sync with controller
+state and we'll light up the correct segment on resume as well.
+
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 41db1f2ed122..c196141f3735 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -1142,7 +1142,7 @@ static void xpad_send_led_command(struct usb_xpad *xpad, int command)
+  */
+ static void xpad_identify_controller(struct usb_xpad *xpad)
+ {
+-      xpad_send_led_command(xpad, (xpad->pad_nr % 4) + 2);
++      led_set_brightness(&xpad->led->led_cdev, (xpad->pad_nr % 4) + 2);
+ }
+ static void xpad_led_set(struct led_classdev *led_cdev,
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-validate-usb-endpoint-type-during-probe.patch b/queue-3.18/input-xpad-validate-usb-endpoint-type-during-probe.patch
new file mode 100644 (file)
index 0000000..42f48c2
--- /dev/null
@@ -0,0 +1,45 @@
+From 551225218bd60bc1f85feb09da2d3d6a2c5829de Mon Sep 17 00:00:00 2001
+From: Cameron Gutman <aicommander@gmail.com>
+Date: Tue, 12 Sep 2017 11:27:44 -0700
+Subject: Input: xpad - validate USB endpoint type during probe
+
+[ Upstream commit 122d6a347329818419b032c5a1776e6b3866d9b9 ]
+
+We should only see devices with interrupt endpoints. Ignore any other
+endpoints that we find, so we don't send try to send them interrupt URBs
+and trigger a WARN down in the USB stack.
+
+Reported-by: Andrey Konovalov <andreyknvl@google.com>
+Tested-by: Andrey Konovalov <andreyknvl@google.com>
+Cc: <stable@vger.kernel.org> # c01b5e7464f0 Input: xpad - don't depend on endpoint order
+Signed-off-by: Cameron Gutman <aicommander@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index f8e34ef643c7..d86e59515b9c 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -1764,10 +1764,12 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+               struct usb_endpoint_descriptor *ep =
+                               &intf->cur_altsetting->endpoint[i].desc;
+-              if (usb_endpoint_dir_in(ep))
+-                      ep_irq_in = ep;
+-              else
+-                      ep_irq_out = ep;
++              if (usb_endpoint_xfer_int(ep)) {
++                      if (usb_endpoint_dir_in(ep))
++                              ep_irq_in = ep;
++                      else
++                              ep_irq_out = ep;
++              }
+       }
+       if (!ep_irq_in || !ep_irq_out) {
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-workaround-dead-irq_out-after-suspend-res.patch b/queue-3.18/input-xpad-workaround-dead-irq_out-after-suspend-res.patch
new file mode 100644 (file)
index 0000000..4373b24
--- /dev/null
@@ -0,0 +1,331 @@
+From a6464655bfe9061059758e14432ce9b82f1ff338 Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Wed, 9 Dec 2015 13:30:34 -0800
+Subject: Input: xpad - workaround dead irq_out after suspend/ resume
+
+[ Upstream commit 4220f7db1e424f2a086ad41217b5770cc9f003a9 ]
+
+The irq_out urb is dead after suspend/ resume on my x360 wr pad. (also
+reproduced by Zachary Lund [0]) Work around this by implementing
+suspend, resume, and reset_resume callbacks and properly shutting down
+URBs on suspend and restarting them on resume.
+
+[0]: https://github.com/paroj/xpad/issues/6
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 175 ++++++++++++++++++++++++++--------
+ 1 file changed, 137 insertions(+), 38 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 68197239e327..41db1f2ed122 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -82,6 +82,7 @@
+ #include <linux/stat.h>
+ #include <linux/module.h>
+ #include <linux/usb/input.h>
++#include <linux/usb/quirks.h>
+ #define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>"
+ #define DRIVER_DESC "X-Box pad driver"
+@@ -348,9 +349,10 @@ struct usb_xpad {
+       dma_addr_t idata_dma;
+       struct urb *irq_out;            /* urb for interrupt out report */
++      struct usb_anchor irq_out_anchor;
+       bool irq_out_active;            /* we must not use an active URB */
+-      unsigned char *odata;           /* output data */
+       u8 odata_serial;                /* serial number for xbox one protocol */
++      unsigned char *odata;           /* output data */
+       dma_addr_t odata_dma;
+       spinlock_t odata_lock;
+@@ -766,11 +768,13 @@ static int xpad_try_sending_next_out_packet(struct usb_xpad *xpad)
+       int error;
+       if (!xpad->irq_out_active && xpad_prepare_next_out_packet(xpad)) {
++              usb_anchor_urb(xpad->irq_out, &xpad->irq_out_anchor);
+               error = usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
+               if (error) {
+                       dev_err(&xpad->intf->dev,
+                               "%s - usb_submit_urb failed with result %d\n",
+                               __func__, error);
++                      usb_unanchor_urb(xpad->irq_out);
+                       return -EIO;
+               }
+@@ -813,11 +817,13 @@ static void xpad_irq_out(struct urb *urb)
+       }
+       if (xpad->irq_out_active) {
++              usb_anchor_urb(urb, &xpad->irq_out_anchor);
+               error = usb_submit_urb(urb, GFP_ATOMIC);
+               if (error) {
+                       dev_err(dev,
+                               "%s - usb_submit_urb failed with result %d\n",
+                               __func__, error);
++                      usb_unanchor_urb(urb);
+                       xpad->irq_out_active = false;
+               }
+       }
+@@ -834,6 +840,8 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
+       if (xpad->xtype == XTYPE_UNKNOWN)
+               return 0;
++      init_usb_anchor(&xpad->irq_out_anchor);
++
+       xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN,
+                                        GFP_KERNEL, &xpad->odata_dma);
+       if (!xpad->odata) {
+@@ -868,8 +876,14 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
+ static void xpad_stop_output(struct usb_xpad *xpad)
+ {
+-      if (xpad->xtype != XTYPE_UNKNOWN)
+-              usb_kill_urb(xpad->irq_out);
++      if (xpad->xtype != XTYPE_UNKNOWN) {
++              if (!usb_wait_anchor_empty_timeout(&xpad->irq_out_anchor,
++                                                 5000)) {
++                      dev_warn(&xpad->intf->dev,
++                               "timed out waiting for output URB to complete, killing\n");
++                      usb_kill_anchored_urbs(&xpad->irq_out_anchor);
++              }
++      }
+ }
+ static void xpad_deinit_output(struct usb_xpad *xpad)
+@@ -1198,32 +1212,73 @@ static void xpad_led_disconnect(struct usb_xpad *xpad) { }
+ static void xpad_identify_controller(struct usb_xpad *xpad) { }
+ #endif
+-static int xpad_open(struct input_dev *dev)
++static int xpad_start_input(struct usb_xpad *xpad)
+ {
+-      struct usb_xpad *xpad = input_get_drvdata(dev);
+-
+-      /* URB was submitted in probe */
+-      if (xpad->xtype == XTYPE_XBOX360W)
+-              return 0;
++      int error;
+-      xpad->irq_in->dev = xpad->udev;
+       if (usb_submit_urb(xpad->irq_in, GFP_KERNEL))
+               return -EIO;
+-      if (xpad->xtype == XTYPE_XBOXONE)
+-              return xpad_start_xbox_one(xpad);
++      if (xpad->xtype == XTYPE_XBOXONE) {
++              error = xpad_start_xbox_one(xpad);
++              if (error) {
++                      usb_kill_urb(xpad->irq_in);
++                      return error;
++              }
++      }
+       return 0;
+ }
+-static void xpad_close(struct input_dev *dev)
++static void xpad_stop_input(struct usb_xpad *xpad)
+ {
+-      struct usb_xpad *xpad = input_get_drvdata(dev);
++      usb_kill_urb(xpad->irq_in);
++}
++
++static int xpad360w_start_input(struct usb_xpad *xpad)
++{
++      int error;
++
++      error = usb_submit_urb(xpad->irq_in, GFP_KERNEL);
++      if (error)
++              return -EIO;
+-      if (xpad->xtype != XTYPE_XBOX360W)
++      /*
++       * Send presence packet.
++       * This will force the controller to resend connection packets.
++       * This is useful in the case we activate the module after the
++       * adapter has been plugged in, as it won't automatically
++       * send us info about the controllers.
++       */
++      error = xpad_inquiry_pad_presence(xpad);
++      if (error) {
+               usb_kill_urb(xpad->irq_in);
++              return error;
++      }
+-      xpad_stop_output(xpad);
++      return 0;
++}
++
++static void xpad360w_stop_input(struct usb_xpad *xpad)
++{
++      usb_kill_urb(xpad->irq_in);
++
++      /* Make sure we are done with presence work if it was scheduled */
++      flush_work(&xpad->work);
++}
++
++static int xpad_open(struct input_dev *dev)
++{
++      struct usb_xpad *xpad = input_get_drvdata(dev);
++
++      return xpad_start_input(xpad);
++}
++
++static void xpad_close(struct input_dev *dev)
++{
++      struct usb_xpad *xpad = input_get_drvdata(dev);
++
++      xpad_stop_input(xpad);
+ }
+ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
+@@ -1278,8 +1333,10 @@ static int xpad_init_input(struct usb_xpad *xpad)
+       input_set_drvdata(input_dev, xpad);
+-      input_dev->open = xpad_open;
+-      input_dev->close = xpad_close;
++      if (xpad->xtype != XTYPE_XBOX360W) {
++              input_dev->open = xpad_open;
++              input_dev->close = xpad_close;
++      }
+       __set_bit(EV_KEY, input_dev->evbit);
+@@ -1450,21 +1507,17 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+                * exactly the message that a controller has arrived that
+                * we're waiting for.
+                */
+-              xpad->irq_in->dev = xpad->udev;
+-              error = usb_submit_urb(xpad->irq_in, GFP_KERNEL);
++              error = xpad360w_start_input(xpad);
+               if (error)
+                       goto err_deinit_output;
+-
+               /*
+-               * Send presence packet.
+-               * This will force the controller to resend connection packets.
+-               * This is useful in the case we activate the module after the
+-               * adapter has been plugged in, as it won't automatically
+-               * send us info about the controllers.
++               * Wireless controllers require RESET_RESUME to work properly
++               * after suspend. Ideally this quirk should be in usb core
++               * quirk list, but we have too many vendors producing these
++               * controllers and we'd need to maintain 2 identical lists
++               * here in this driver and in usb core.
+                */
+-              error = xpad_inquiry_pad_presence(xpad);
+-              if (error)
+-                      goto err_kill_in_urb;
++              udev->quirks |= USB_QUIRK_RESET_RESUME;
+       } else {
+               error = xpad_init_input(xpad);
+               if (error)
+@@ -1472,8 +1525,6 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+       }
+       return 0;
+-err_kill_in_urb:
+-      usb_kill_urb(xpad->irq_in);
+ err_deinit_output:
+       xpad_deinit_output(xpad);
+ err_free_in_urb:
+@@ -1483,35 +1534,83 @@ err_free_idata:
+ err_free_mem:
+       kfree(xpad);
+       return error;
+-
+ }
+ static void xpad_disconnect(struct usb_interface *intf)
+ {
+-      struct usb_xpad *xpad = usb_get_intfdata (intf);
++      struct usb_xpad *xpad = usb_get_intfdata(intf);
+       if (xpad->xtype == XTYPE_XBOX360W)
+-              usb_kill_urb(xpad->irq_in);
+-
+-      cancel_work_sync(&xpad->work);
++              xpad360w_stop_input(xpad);
+       xpad_deinit_input(xpad);
++      /*
++       * Now that both input device and LED device are gone we can
++       * stop output URB.
++       */
++      xpad_stop_output(xpad);
++
++      xpad_deinit_output(xpad);
++
+       usb_free_urb(xpad->irq_in);
+       usb_free_coherent(xpad->udev, XPAD_PKT_LEN,
+                       xpad->idata, xpad->idata_dma);
+-      xpad_deinit_output(xpad);
+-
+       kfree(xpad);
+       usb_set_intfdata(intf, NULL);
+ }
++static int xpad_suspend(struct usb_interface *intf, pm_message_t message)
++{
++      struct usb_xpad *xpad = usb_get_intfdata(intf);
++      struct input_dev *input = xpad->dev;
++
++      if (xpad->xtype == XTYPE_XBOX360W) {
++              /*
++               * Wireless controllers always listen to input so
++               * they are notified when controller shows up
++               * or goes away.
++               */
++              xpad360w_stop_input(xpad);
++      } else {
++              mutex_lock(&input->mutex);
++              if (input->users)
++                      xpad_stop_input(xpad);
++              mutex_unlock(&input->mutex);
++      }
++
++      xpad_stop_output(xpad);
++
++      return 0;
++}
++
++static int xpad_resume(struct usb_interface *intf)
++{
++      struct usb_xpad *xpad = usb_get_intfdata(intf);
++      struct input_dev *input = xpad->dev;
++      int retval = 0;
++
++      if (xpad->xtype == XTYPE_XBOX360W) {
++              retval = xpad360w_start_input(xpad);
++      } else {
++              mutex_lock(&input->mutex);
++              if (input->users)
++                      retval = xpad_start_input(xpad);
++              mutex_unlock(&input->mutex);
++      }
++
++      return retval;
++}
++
+ static struct usb_driver xpad_driver = {
+       .name           = "xpad",
+       .probe          = xpad_probe,
+       .disconnect     = xpad_disconnect,
++      .suspend        = xpad_suspend,
++      .resume         = xpad_resume,
++      .reset_resume   = xpad_resume,
+       .id_table       = xpad_table,
+ };
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-x360w-report-dpad-as-buttons-and-axes.patch b/queue-3.18/input-xpad-x360w-report-dpad-as-buttons-and-axes.patch
new file mode 100644 (file)
index 0000000..a19ec48
--- /dev/null
@@ -0,0 +1,68 @@
+From 5deda98185f35f9e5adf4e5de442905cba43f134 Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Sat, 10 Oct 2015 09:33:52 -0700
+Subject: Input: xpad - x360w: report dpad as buttons and axes
+
+[ Upstream commit 5ee8bda943de20017636845a5c8d7069a4a283b8 ]
+
+as discussed here[0], x360w is the only pad that maps dpad_to_button.
+This is bad for downstream developers as they have to differ between
+x360 and x360w which is not intuitive.
+
+This patch implements the suggested solution of exposing the dpad both
+as axes and as buttons. This retains backward compatibility with software
+already dealing with the difference while makes new software work as
+expected across x360/ x360w pads.
+
+[0] http://www.spinics.net/lists/linux-input/msg34421.html
+
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 22 ++++++++++++++++++++--
+ 1 file changed, 20 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index fc81473b6e35..f6e96741ff0e 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -437,7 +437,16 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
+               input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08);
+               input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01);
+               input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02);
+-      } else {
++      }
++
++      /*
++       * This should be a simple else block. However historically
++       * xbox360w has mapped DPAD to buttons while xbox360 did not. This
++       * made no sense, but now we can not just switch back and have to
++       * support both behaviors.
++       */
++      if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) ||
++          xpad->xtype == XTYPE_XBOX360W) {
+               input_report_abs(dev, ABS_HAT0X,
+                                !!(data[2] & 0x08) - !!(data[2] & 0x04));
+               input_report_abs(dev, ABS_HAT0Y,
+@@ -1163,7 +1172,16 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+       if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
+               for (i = 0; xpad_btn_pad[i] >= 0; i++)
+                       __set_bit(xpad_btn_pad[i], input_dev->keybit);
+-      } else {
++      }
++
++      /*
++       * This should be a simple else block. However historically
++       * xbox360w has mapped DPAD to buttons while xbox360 did not. This
++       * made no sense, but now we can not just switch back and have to
++       * support both behaviors.
++       */
++      if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) ||
++          xpad->xtype == XTYPE_XBOX360W) {
+               for (i = 0; xpad_abs_pad[i] >= 0; i++)
+                       xpad_set_up_abs(input_dev, xpad_abs_pad[i]);
+       }
+-- 
+2.17.1
+
diff --git a/queue-3.18/input-xpad-xbox-one-elite-controller-support.patch b/queue-3.18/input-xpad-xbox-one-elite-controller-support.patch
new file mode 100644 (file)
index 0000000..85275f5
--- /dev/null
@@ -0,0 +1,46 @@
+From 591452a633d65394aa76fd2074b3b0d87abb71fd Mon Sep 17 00:00:00 2001
+From: Pavel Rojtberg <rojtberg@gmail.com>
+Date: Fri, 27 May 2016 16:24:40 -0700
+Subject: Input: xpad - xbox one elite controller support
+
+[ Upstream commit 6f49a398b266d4895bd7e041db77a2b2ee1482a6 ]
+
+added the according id and incresed XPAD_PKT_LEN to 64 as the elite
+controller sends at least 33 byte messages [1].
+Verified to be working by [2].
+
+[1]: https://franticrain.github.io/sniffs/XboxOneSniff.html
+[2]: https://github.com/paroj/xpad/issues/23
+
+Signed-off-by: Pierre-Loup A. Griffais <eduke32@plagman.net>
+Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 2a0573eeadaa..c8a20893d2d5 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -87,7 +87,7 @@
+ #define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>"
+ #define DRIVER_DESC "X-Box pad driver"
+-#define XPAD_PKT_LEN 32
++#define XPAD_PKT_LEN 64
+ /* xbox d-pads should map to buttons, as is required for DDR pads
+    but we map them to axes when possible to simplify things */
+@@ -129,6 +129,7 @@ static const struct xpad_device {
+       { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
+       { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
+       { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
++      { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE },
+       { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+       { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
+       { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
+-- 
+2.17.1
+
index 7fd4d027292bc15b29e97e9dff60c922eaf4babc..39bc5fc196db6b9fd21712278fcad19b98be6806 100644 (file)
@@ -17,3 +17,58 @@ kdb-use-strscpy-with-destination-buffer-size.patch
 powerpc-numa-suppress-vphn-is-not-supported-messages.patch
 tmpfs-make-lseek-seek_data-sek_hole-return-enxio-wit.patch
 arm64-remove-no-op-p-linker-flag.patch
+input-initialize-device-counter-variables-with-1.patch
+input-xpad-add-rumble-support-for-xbox-one-controlle.patch
+input-xpad-set-the-leds-properly-on-xbox-wireless-co.patch
+input-xpad-re-send-led-command-on-present-event.patch
+input-xpad-add-covert-forces-edition-of-the-xbox-one.patch
+input-xpad-fix-razer-atrox-arcade-stick-button-mappi.patch
+input-xpad-clarify-led-enumeration.patch
+input-xpad-use-ida-for-finding-the-pad_nr.patch
+input-xpad-remove-needless-bulk-out-urb-used-for-led.patch
+input-xpad-factor-out-urb-submission-in-xpad_play_ef.patch
+input-xpad-x360w-report-dpad-as-buttons-and-axes.patch
+input-xpad-move-the-input-device-creation-to-a-new-f.patch
+input-xpad-query-wireless-controller-state-at-init.patch
+input-xpad-fix-clash-of-presence-handling-with-led-s.patch
+input-xpad-remove-spurious-events-of-wireless-xpad-3.patch
+input-xpad-handle-present-and-gone-correctly.patch
+input-xpad-correctly-handle-concurrent-led-and-ff-re.patch
+input-xpad-update-xbox-one-force-feedback-support.patch
+input-xpad-workaround-dead-irq_out-after-suspend-res.patch
+input-xpad-use-led-api-when-identifying-wireless-con.patch
+input-xpad-correct-xbox-one-pad-device-name.patch
+input-xpad-remove-unused-function.patch
+input-xpad-add-mad-catz-fightstick-te-2-vid-pid.patch
+input-xpad-move-pending-clear-to-the-correct-locatio.patch
+input-xpad-prevent-spurious-input-from-wired-xbox-36.patch
+input-xpad-add-more-third-party-controllers.patch
+input-xpad-xbox-one-elite-controller-support.patch
+input-xpad-fix-rumble-on-xbox-one-controllers-with-2.patch
+input-xpad-fix-oops-when-attaching-an-unknown-xbox-o.patch
+input-xpad-power-off-wireless-360-controllers-on-sus.patch
+input-xpad-add-product-id-for-xbox-one-s-pad.patch
+input-xpad-fix-xbox-one-rumble-stopping-after-2.5-se.patch
+input-xpad-use-correct-product-id-for-x360w-controll.patch
+input-xpad-correctly-sort-vendor-id-s.patch
+input-xpad-move-reporting-xbox-one-home-button-to-co.patch
+input-xpad-simplify-error-condition-in-init_output.patch
+input-xpad-don-t-depend-on-endpoint-order.patch
+input-xpad-fix-stuck-mode-button-on-xbox-one-s-pad.patch
+input-xpad-restore-led-state-after-device-resume.patch
+input-xpad-support-some-quirky-xbox-one-pads.patch
+input-xpad-sort-supported-devices-by-usb-id.patch
+input-xpad-sync-supported-devices-with-xboxdrv.patch
+input-xpad-add-usb-ids-for-mad-catz-brawlstick-and-r.patch
+input-xpad-sync-supported-devices-with-360controller.patch
+input-xpad-sync-supported-devices-with-xbcd.patch
+input-xpad-constify-usb_device_id.patch
+input-xpad-fix-powera-init-quirk-for-some-gamepad-mo.patch
+input-xpad-validate-usb-endpoint-type-during-probe.patch
+input-xpad-add-support-for-pdp-xbox-one-controllers.patch
+input-xpad-add-pdp-device-id-0x02a4.patch
+input-xpad-fix-some-coding-style-issues.patch
+input-xpad-avoid-using-__set_bit-for-capabilities.patch
+input-xpad-add-gpd-win-2-controller-usb-ids.patch
+input-xpad-fix-gpd-win-2-controller-name.patch
+input-xpad-add-support-for-xbox1-pdp-camo-series-gam.patch