summaryrefslogtreecommitdiff
path: root/drivers/input
diff options
context:
space:
mode:
authorPavel Rojtberg <rojtberg@gmail.com>2015-10-10 09:36:17 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-12-01 09:48:01 +0100
commit80426963a31247a59e3c1708c0c320ddc6153bc8 (patch)
tree5e7204a8bedd409fda06c4603675dde90daba6d6 /drivers/input
parent7e0f79ac79893d87906a8dc96a9255213dd32e05 (diff)
downloadlinux-80426963a31247a59e3c1708c0c320ddc6153bc8.tar.gz
linux-80426963a31247a59e3c1708c0c320ddc6153bc8.tar.bz2
linux-80426963a31247a59e3c1708c0c320ddc6153bc8.zip
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>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/joystick/xpad.c40
1 files changed, 40 insertions, 0 deletions
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: