From: Pavel Rojtberg <rojtberg@gmail.com>
To: linux-input@vger.kernel.org, pgriffais@valvesoftware.com,
dmitry.torokhov@gmail.com, gregkh@linuxfoundation.org
Cc: Pavel Rojtberg <rojtberg@gmail.com>
Subject: [PATCH v2 2/2] Input: xpad: re-send LED command on present event
Date: Wed, 10 Jun 2015 00:56:19 +0200 [thread overview]
Message-ID: <1433890579-2124-3-git-send-email-rojtberg@gmail.com> (raw)
In-Reply-To: <1433890579-2124-1-git-send-email-rojtberg@gmail.com>
From: Pavel Rojtberg <rojtberg@gmail.com>
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. move led_no to xpad struct to remember the pad number.
Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
---
drivers/input/joystick/xpad.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 6f8755e..f8969a9 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 */
+ unsigned long led_no; /* led to lit on xbox360 controllers */
};
/*
@@ -488,6 +489,8 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
input_sync(dev);
}
+static void xpad_send_led_command(struct usb_xpad *xpad, int command);
+
/*
* xpad360w_process_packet
*
@@ -510,6 +513,8 @@ 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_send_led_command(xpad, (xpad->led_no % 4) + 2);
} else
xpad->pad_present = 0;
}
@@ -946,7 +951,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);
- unsigned long led_no;
struct xpad_led *led;
struct led_classdev *led_cdev;
int error;
@@ -958,9 +962,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;
@@ -974,10 +978,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_send_led_command(xpad, (xpad->led_no % 4) + 2);
return 0;
}
@@ -994,6 +996,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_send_led_command(struct usb_xpad *xpad, int command) { }
#endif
--
1.9.1
next prev parent reply other threads:[~2015-06-09 22:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 22:56 [PATCH v2 0/2] Input: xpad: fix 360 wireless controller blinking LEDs Pavel Rojtberg
2015-06-09 22:56 ` [PATCH v2 1/2] Input: xpad: set the LEDs properly on XBox Wireless controllers Pavel Rojtberg
2015-06-09 22:56 ` Pavel Rojtberg [this message]
2015-06-22 21:24 ` [PATCH v2 0/2] Input: xpad: fix 360 wireless controller blinking LEDs Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433890579-2124-3-git-send-email-rojtberg@gmail.com \
--to=rojtberg@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-input@vger.kernel.org \
--cc=pgriffais@valvesoftware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).