diff options
author | David Herrmann <dh.herrmann@googlemail.com> | 2011-07-05 07:45:17 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-07-11 08:30:23 -0400 |
commit | db3083467f1527816fca95ae2d8bfe5d81503a8e (patch) | |
tree | e0dc7e2476120e16d75a126f0e229a717810e56e /drivers/hid/hid-wiimote.c | |
parent | 1abb9ad389f037612b6ba6b0dede2095c59cd2fa (diff) |
HID: wiimote: Add wiimote led request
Add new request that sets the leds on the target device. Also, per
default, set led1 after initializing a device.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-wiimote.c')
-rw-r--r-- | drivers/hid/hid-wiimote.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/hid/hid-wiimote.c b/drivers/hid/hid-wiimote.c index efdf62b730f3..3fb18fbe080c 100644 --- a/drivers/hid/hid-wiimote.c +++ b/drivers/hid/hid-wiimote.c | |||
@@ -39,7 +39,13 @@ struct wiimote_data { | |||
39 | struct work_struct worker; | 39 | struct work_struct worker; |
40 | }; | 40 | }; |
41 | 41 | ||
42 | #define WIIPROTO_FLAG_LED1 0x01 | ||
43 | #define WIIPROTO_FLAG_LED2 0x02 | ||
44 | #define WIIPROTO_FLAG_LED3 0x04 | ||
45 | #define WIIPROTO_FLAG_LED4 0x08 | ||
46 | |||
42 | enum wiiproto_reqs { | 47 | enum wiiproto_reqs { |
48 | WIIPROTO_REQ_LED = 0x11, | ||
43 | WIIPROTO_REQ_DRM_K = 0x30, | 49 | WIIPROTO_REQ_DRM_K = 0x30, |
44 | }; | 50 | }; |
45 | 51 | ||
@@ -150,6 +156,25 @@ static void wiimote_queue(struct wiimote_data *wdata, const __u8 *buffer, | |||
150 | spin_unlock_irqrestore(&wdata->qlock, flags); | 156 | spin_unlock_irqrestore(&wdata->qlock, flags); |
151 | } | 157 | } |
152 | 158 | ||
159 | static void wiiproto_req_leds(struct wiimote_data *wdata, int leds) | ||
160 | { | ||
161 | __u8 cmd[2]; | ||
162 | |||
163 | cmd[0] = WIIPROTO_REQ_LED; | ||
164 | cmd[1] = 0; | ||
165 | |||
166 | if (leds & WIIPROTO_FLAG_LED1) | ||
167 | cmd[1] |= 0x10; | ||
168 | if (leds & WIIPROTO_FLAG_LED2) | ||
169 | cmd[1] |= 0x20; | ||
170 | if (leds & WIIPROTO_FLAG_LED3) | ||
171 | cmd[1] |= 0x40; | ||
172 | if (leds & WIIPROTO_FLAG_LED4) | ||
173 | cmd[1] |= 0x80; | ||
174 | |||
175 | wiimote_queue(wdata, cmd, sizeof(cmd)); | ||
176 | } | ||
177 | |||
153 | static int wiimote_input_event(struct input_dev *dev, unsigned int type, | 178 | static int wiimote_input_event(struct input_dev *dev, unsigned int type, |
154 | unsigned int code, int value) | 179 | unsigned int code, int value) |
155 | { | 180 | { |
@@ -301,6 +326,7 @@ static int wiimote_hid_probe(struct hid_device *hdev, | |||
301 | smp_wmb(); | 326 | smp_wmb(); |
302 | atomic_set(&wdata->ready, 1); | 327 | atomic_set(&wdata->ready, 1); |
303 | hid_info(hdev, "New device registered\n"); | 328 | hid_info(hdev, "New device registered\n"); |
329 | wiiproto_req_leds(wdata, WIIPROTO_FLAG_LED1); | ||
304 | return 0; | 330 | return 0; |
305 | 331 | ||
306 | err_stop: | 332 | err_stop: |