blob: 55ce2bfe51fafecfde782c7a9d74c4f678f60fa2 [file] [log] [blame]
Jiri Slaby5f22a792008-05-16 11:49:19 +02001/*
2 * HID driver for some logitech "special" devices
3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
Jiri Slaby5f22a792008-05-16 11:49:19 +02008 * Copyright (c) 2008 Jiri Slaby
Hendrik Iben2c6118e2010-10-04 15:39:49 +02009 * Copyright (c) 2010 Hendrik Iben
Jiri Slaby5f22a792008-05-16 11:49:19 +020010 */
11
12/*
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the Free
15 * Software Foundation; either version 2 of the License, or (at your option)
16 * any later version.
17 */
18
19#include <linux/device.h>
20#include <linux/hid.h>
21#include <linux/module.h>
Simon Wood32c88cb2010-09-22 13:19:42 +020022#include <linux/random.h>
23#include <linux/sched.h>
24#include <linux/wait.h>
Jiri Slaby5f22a792008-05-16 11:49:19 +020025
26#include "hid-ids.h"
Jiri Slaby606bd0a2008-07-04 23:06:45 +020027#include "hid-lg.h"
Jiri Slaby5f22a792008-05-16 11:49:19 +020028
29#define LG_RDESC 0x001
30#define LG_BAD_RELATIVE_KEYS 0x002
31#define LG_DUPLICATE_USAGES 0x004
Jiri Slaby5f22a792008-05-16 11:49:19 +020032#define LG_EXPANDED_KEYMAP 0x010
33#define LG_IGNORE_DOUBLED_WHEEL 0x020
34#define LG_WIRELESS 0x040
35#define LG_INVERT_HWHEEL 0x080
36#define LG_NOGET 0x100
Jiri Slaby606bd0a2008-07-04 23:06:45 +020037#define LG_FF 0x200
38#define LG_FF2 0x400
Jiri Kosina24985cf2009-11-13 10:45:53 +010039#define LG_RDESC_REL_ABS 0x800
Gary Stein74f292c2010-01-13 00:25:58 +010040#define LG_FF3 0x1000
Simon Wood32c88cb2010-09-22 13:19:42 +020041#define LG_FF4 0x2000
Jiri Slaby5f22a792008-05-16 11:49:19 +020042
Michael Bauerdc0a4f02011-06-02 15:40:14 -070043/* Size of the original descriptor of the Driving Force Pro wheel */
44#define DFP_RDESC_ORIG_SIZE 97
45
46/* Fixed report descriptor for Logitech Driving Force Pro wheel controller
47 *
48 * The original descriptor hides the separate throttle and brake axes in
49 * a custom vendor usage page, providing only a combined value as
50 * GenericDesktop.Y.
51 * This descriptor removes the combined Y axis and instead reports
52 * separate throttle (Y) and brake (RZ).
53 */
54static __u8 dfp_rdesc_fixed[] = {
550x05, 0x01, /* Usage Page (Desktop), */
560x09, 0x04, /* Usage (Joystik), */
570xA1, 0x01, /* Collection (Application), */
580xA1, 0x02, /* Collection (Logical), */
590x95, 0x01, /* Report Count (1), */
600x75, 0x0E, /* Report Size (14), */
610x14, /* Logical Minimum (0), */
620x26, 0xFF, 0x3F, /* Logical Maximum (16383), */
630x34, /* Physical Minimum (0), */
640x46, 0xFF, 0x3F, /* Physical Maximum (16383), */
650x09, 0x30, /* Usage (X), */
660x81, 0x02, /* Input (Variable), */
670x95, 0x0E, /* Report Count (14), */
680x75, 0x01, /* Report Size (1), */
690x25, 0x01, /* Logical Maximum (1), */
700x45, 0x01, /* Physical Maximum (1), */
710x05, 0x09, /* Usage Page (Button), */
720x19, 0x01, /* Usage Minimum (01h), */
730x29, 0x0E, /* Usage Maximum (0Eh), */
740x81, 0x02, /* Input (Variable), */
750x05, 0x01, /* Usage Page (Desktop), */
760x95, 0x01, /* Report Count (1), */
770x75, 0x04, /* Report Size (4), */
780x25, 0x07, /* Logical Maximum (7), */
790x46, 0x3B, 0x01, /* Physical Maximum (315), */
800x65, 0x14, /* Unit (Degrees), */
810x09, 0x39, /* Usage (Hat Switch), */
820x81, 0x42, /* Input (Variable, Nullstate), */
830x65, 0x00, /* Unit, */
840x26, 0xFF, 0x00, /* Logical Maximum (255), */
850x46, 0xFF, 0x00, /* Physical Maximum (255), */
860x75, 0x08, /* Report Size (8), */
870x81, 0x01, /* Input (Constant), */
880x09, 0x31, /* Usage (Y), */
890x81, 0x02, /* Input (Variable), */
900x09, 0x35, /* Usage (Rz), */
910x81, 0x02, /* Input (Variable), */
920x81, 0x01, /* Input (Constant), */
930xC0, /* End Collection, */
940xA1, 0x02, /* Collection (Logical), */
950x09, 0x02, /* Usage (02h), */
960x95, 0x07, /* Report Count (7), */
970x91, 0x02, /* Output (Variable), */
980xC0, /* End Collection, */
990xC0 /* End Collection */
100};
101
102
Jiri Slaby5f22a792008-05-16 11:49:19 +0200103/*
104 * Certain Logitech keyboards send in report #3 keys which are far
105 * above the logical maximum described in descriptor. This extends
106 * the original value of 0x28c of logical maximum to 0x104d
107 */
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400108static __u8 *lg_report_fixup(struct hid_device *hdev, __u8 *rdesc,
109 unsigned int *rsize)
Jiri Slaby5f22a792008-05-16 11:49:19 +0200110{
Axel Lin25751552012-09-13 14:08:32 +0800111 struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
Jiri Slaby5f22a792008-05-16 11:49:19 +0200112
Michal Malý8577dbf2012-03-31 11:17:25 +0200113 if ((drv_data->quirks & LG_RDESC) && *rsize >= 90 && rdesc[83] == 0x26 &&
Jiri Slaby5f22a792008-05-16 11:49:19 +0200114 rdesc[84] == 0x8c && rdesc[85] == 0x02) {
Joe Perches4291ee32010-12-09 19:29:03 -0800115 hid_info(hdev,
116 "fixing up Logitech keyboard report descriptor\n");
Jiri Slaby5f22a792008-05-16 11:49:19 +0200117 rdesc[84] = rdesc[89] = 0x4d;
118 rdesc[85] = rdesc[90] = 0x10;
119 }
Michal Malý8577dbf2012-03-31 11:17:25 +0200120 if ((drv_data->quirks & LG_RDESC_REL_ABS) && *rsize >= 50 &&
Jiri Kosina24985cf2009-11-13 10:45:53 +0100121 rdesc[32] == 0x81 && rdesc[33] == 0x06 &&
122 rdesc[49] == 0x81 && rdesc[50] == 0x06) {
Joe Perches4291ee32010-12-09 19:29:03 -0800123 hid_info(hdev,
124 "fixing up rel/abs in Logitech report descriptor\n");
Jiri Kosina24985cf2009-11-13 10:45:53 +0100125 rdesc[33] = rdesc[50] = 0x02;
126 }
Michal Malý8577dbf2012-03-31 11:17:25 +0200127 if ((drv_data->quirks & LG_FF4) && *rsize >= 101 &&
Simon Wood32c88cb2010-09-22 13:19:42 +0200128 rdesc[41] == 0x95 && rdesc[42] == 0x0B &&
129 rdesc[47] == 0x05 && rdesc[48] == 0x09) {
Joe Perches4291ee32010-12-09 19:29:03 -0800130 hid_info(hdev, "fixing up Logitech Speed Force Wireless button descriptor\n");
Simon Wood32c88cb2010-09-22 13:19:42 +0200131 rdesc[41] = 0x05;
132 rdesc[42] = 0x09;
133 rdesc[47] = 0x95;
134 rdesc[48] = 0x0B;
135 }
Michael Bauerdc0a4f02011-06-02 15:40:14 -0700136
137 switch (hdev->product) {
138 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
139 if (*rsize == DFP_RDESC_ORIG_SIZE) {
140 hid_info(hdev,
141 "fixing up Logitech Driving Force Pro report descriptor\n");
142 rdesc = dfp_rdesc_fixed;
143 *rsize = sizeof(dfp_rdesc_fixed);
144 }
145 break;
146 }
147
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400148 return rdesc;
Jiri Slaby5f22a792008-05-16 11:49:19 +0200149}
150
151#define lg_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
152 EV_KEY, (c))
153
154static int lg_ultrax_remote_mapping(struct hid_input *hi,
155 struct hid_usage *usage, unsigned long **bit, int *max)
156{
157 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR)
158 return 0;
159
160 set_bit(EV_REP, hi->input->evbit);
161 switch (usage->hid & HID_USAGE) {
162 /* Reported on Logitech Ultra X Media Remote */
163 case 0x004: lg_map_key_clear(KEY_AGAIN); break;
164 case 0x00d: lg_map_key_clear(KEY_HOME); break;
165 case 0x024: lg_map_key_clear(KEY_SHUFFLE); break;
166 case 0x025: lg_map_key_clear(KEY_TV); break;
167 case 0x026: lg_map_key_clear(KEY_MENU); break;
168 case 0x031: lg_map_key_clear(KEY_AUDIO); break;
169 case 0x032: lg_map_key_clear(KEY_TEXT); break;
170 case 0x033: lg_map_key_clear(KEY_LAST); break;
171 case 0x047: lg_map_key_clear(KEY_MP3); break;
172 case 0x048: lg_map_key_clear(KEY_DVD); break;
173 case 0x049: lg_map_key_clear(KEY_MEDIA); break;
174 case 0x04a: lg_map_key_clear(KEY_VIDEO); break;
175 case 0x04b: lg_map_key_clear(KEY_ANGLE); break;
176 case 0x04c: lg_map_key_clear(KEY_LANGUAGE); break;
177 case 0x04d: lg_map_key_clear(KEY_SUBTITLE); break;
178 case 0x051: lg_map_key_clear(KEY_RED); break;
179 case 0x052: lg_map_key_clear(KEY_CLOSE); break;
180
181 default:
182 return 0;
183 }
184 return 1;
185}
186
Jiri Kosina66d61be2009-11-24 18:22:20 +0100187static int lg_dinovo_mapping(struct hid_input *hi, struct hid_usage *usage,
188 unsigned long **bit, int *max)
189{
190 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR)
191 return 0;
192
193 switch (usage->hid & HID_USAGE) {
194
195 case 0x00d: lg_map_key_clear(KEY_MEDIA); break;
196 default:
197 return 0;
198
199 }
200 return 1;
201}
202
Jiri Slaby5f22a792008-05-16 11:49:19 +0200203static int lg_wireless_mapping(struct hid_input *hi, struct hid_usage *usage,
204 unsigned long **bit, int *max)
205{
206 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
207 return 0;
208
209 switch (usage->hid & HID_USAGE) {
210 case 0x1001: lg_map_key_clear(KEY_MESSENGER); break;
211 case 0x1003: lg_map_key_clear(KEY_SOUND); break;
212 case 0x1004: lg_map_key_clear(KEY_VIDEO); break;
213 case 0x1005: lg_map_key_clear(KEY_AUDIO); break;
214 case 0x100a: lg_map_key_clear(KEY_DOCUMENTS); break;
Lorenzo Castelli183922122010-04-16 19:00:31 +0200215 /* The following two entries are Playlist 1 and 2 on the MX3200 */
216 case 0x100f: lg_map_key_clear(KEY_FN_1); break;
217 case 0x1010: lg_map_key_clear(KEY_FN_2); break;
Jiri Slaby5f22a792008-05-16 11:49:19 +0200218 case 0x1011: lg_map_key_clear(KEY_PREVIOUSSONG); break;
219 case 0x1012: lg_map_key_clear(KEY_NEXTSONG); break;
220 case 0x1013: lg_map_key_clear(KEY_CAMERA); break;
221 case 0x1014: lg_map_key_clear(KEY_MESSENGER); break;
222 case 0x1015: lg_map_key_clear(KEY_RECORD); break;
223 case 0x1016: lg_map_key_clear(KEY_PLAYER); break;
224 case 0x1017: lg_map_key_clear(KEY_EJECTCD); break;
225 case 0x1018: lg_map_key_clear(KEY_MEDIA); break;
226 case 0x1019: lg_map_key_clear(KEY_PROG1); break;
227 case 0x101a: lg_map_key_clear(KEY_PROG2); break;
228 case 0x101b: lg_map_key_clear(KEY_PROG3); break;
Lorenzo Castelli183922122010-04-16 19:00:31 +0200229 case 0x101c: lg_map_key_clear(KEY_CYCLEWINDOWS); break;
Jiri Slaby5f22a792008-05-16 11:49:19 +0200230 case 0x101f: lg_map_key_clear(KEY_ZOOMIN); break;
231 case 0x1020: lg_map_key_clear(KEY_ZOOMOUT); break;
232 case 0x1021: lg_map_key_clear(KEY_ZOOMRESET); break;
233 case 0x1023: lg_map_key_clear(KEY_CLOSE); break;
234 case 0x1027: lg_map_key_clear(KEY_MENU); break;
235 /* this one is marked as 'Rotate' */
236 case 0x1028: lg_map_key_clear(KEY_ANGLE); break;
237 case 0x1029: lg_map_key_clear(KEY_SHUFFLE); break;
238 case 0x102a: lg_map_key_clear(KEY_BACK); break;
239 case 0x102b: lg_map_key_clear(KEY_CYCLEWINDOWS); break;
Lorenzo Castelli183922122010-04-16 19:00:31 +0200240 case 0x102d: lg_map_key_clear(KEY_WWW); break;
241 /* The following two are 'Start/answer call' and 'End/reject call'
242 on the MX3200 */
243 case 0x1031: lg_map_key_clear(KEY_OK); break;
244 case 0x1032: lg_map_key_clear(KEY_CANCEL); break;
Jiri Slaby5f22a792008-05-16 11:49:19 +0200245 case 0x1041: lg_map_key_clear(KEY_BATTERY); break;
246 case 0x1042: lg_map_key_clear(KEY_WORDPROCESSOR); break;
247 case 0x1043: lg_map_key_clear(KEY_SPREADSHEET); break;
248 case 0x1044: lg_map_key_clear(KEY_PRESENTATION); break;
249 case 0x1045: lg_map_key_clear(KEY_UNDO); break;
250 case 0x1046: lg_map_key_clear(KEY_REDO); break;
251 case 0x1047: lg_map_key_clear(KEY_PRINT); break;
252 case 0x1048: lg_map_key_clear(KEY_SAVE); break;
253 case 0x1049: lg_map_key_clear(KEY_PROG1); break;
254 case 0x104a: lg_map_key_clear(KEY_PROG2); break;
255 case 0x104b: lg_map_key_clear(KEY_PROG3); break;
256 case 0x104c: lg_map_key_clear(KEY_PROG4); break;
257
258 default:
259 return 0;
260 }
261 return 1;
262}
263
264static int lg_input_mapping(struct hid_device *hdev, struct hid_input *hi,
265 struct hid_field *field, struct hid_usage *usage,
266 unsigned long **bit, int *max)
267{
268 /* extended mapping for certain Logitech hardware (Logitech cordless
269 desktop LX500) */
270 static const u8 e_keymap[] = {
271 0,216, 0,213,175,156, 0, 0, 0, 0,
272 144, 0, 0, 0, 0, 0, 0, 0, 0,212,
273 174,167,152,161,112, 0, 0, 0,154, 0,
274 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
275 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
276 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
277 0, 0, 0, 0, 0,183,184,185,186,187,
278 188,189,190,191,192,193,194, 0, 0, 0
279 };
Axel Lin25751552012-09-13 14:08:32 +0800280 struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
Jiri Slaby5f22a792008-05-16 11:49:19 +0200281 unsigned int hid = usage->hid;
282
283 if (hdev->product == USB_DEVICE_ID_LOGITECH_RECEIVER &&
284 lg_ultrax_remote_mapping(hi, usage, bit, max))
285 return 1;
286
Jiri Kosina66d61be2009-11-24 18:22:20 +0100287 if (hdev->product == USB_DEVICE_ID_DINOVO_MINI &&
288 lg_dinovo_mapping(hi, usage, bit, max))
289 return 1;
290
Michal Malý8577dbf2012-03-31 11:17:25 +0200291 if ((drv_data->quirks & LG_WIRELESS) && lg_wireless_mapping(hi, usage, bit, max))
Jiri Slaby5f22a792008-05-16 11:49:19 +0200292 return 1;
293
294 if ((hid & HID_USAGE_PAGE) != HID_UP_BUTTON)
295 return 0;
296
297 hid &= HID_USAGE;
298
299 /* Special handling for Logitech Cordless Desktop */
300 if (field->application == HID_GD_MOUSE) {
Michal Malý8577dbf2012-03-31 11:17:25 +0200301 if ((drv_data->quirks & LG_IGNORE_DOUBLED_WHEEL) &&
Jiri Slaby5f22a792008-05-16 11:49:19 +0200302 (hid == 7 || hid == 8))
303 return -1;
304 } else {
Michal Malý8577dbf2012-03-31 11:17:25 +0200305 if ((drv_data->quirks & LG_EXPANDED_KEYMAP) &&
Jiri Slaby5f22a792008-05-16 11:49:19 +0200306 hid < ARRAY_SIZE(e_keymap) &&
307 e_keymap[hid] != 0) {
308 hid_map_usage(hi, usage, bit, max, EV_KEY,
309 e_keymap[hid]);
310 return 1;
311 }
312 }
313
314 return 0;
315}
316
317static int lg_input_mapped(struct hid_device *hdev, struct hid_input *hi,
318 struct hid_field *field, struct hid_usage *usage,
319 unsigned long **bit, int *max)
320{
Axel Lin25751552012-09-13 14:08:32 +0800321 struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
Jiri Slaby5f22a792008-05-16 11:49:19 +0200322
Michal Malý8577dbf2012-03-31 11:17:25 +0200323 if ((drv_data->quirks & LG_BAD_RELATIVE_KEYS) && usage->type == EV_KEY &&
Jiri Slaby5f22a792008-05-16 11:49:19 +0200324 (field->flags & HID_MAIN_ITEM_RELATIVE))
325 field->flags &= ~HID_MAIN_ITEM_RELATIVE;
326
Michal Malý8577dbf2012-03-31 11:17:25 +0200327 if ((drv_data->quirks & LG_DUPLICATE_USAGES) && (usage->type == EV_KEY ||
Jiri Slaby5f22a792008-05-16 11:49:19 +0200328 usage->type == EV_REL || usage->type == EV_ABS))
329 clear_bit(usage->code, *bit);
330
331 return 0;
332}
333
334static int lg_event(struct hid_device *hdev, struct hid_field *field,
335 struct hid_usage *usage, __s32 value)
336{
Axel Lin25751552012-09-13 14:08:32 +0800337 struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
Jiri Slaby5f22a792008-05-16 11:49:19 +0200338
Michal Malý8577dbf2012-03-31 11:17:25 +0200339 if ((drv_data->quirks & LG_INVERT_HWHEEL) && usage->code == REL_HWHEEL) {
Jiri Slaby5f22a792008-05-16 11:49:19 +0200340 input_event(field->hidinput->input, usage->type, usage->code,
341 -value);
342 return 1;
343 }
344
345 return 0;
346}
347
348static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
349{
Jiri Slaby606bd0a2008-07-04 23:06:45 +0200350 unsigned int connect_mask = HID_CONNECT_DEFAULT;
Michal Malý8577dbf2012-03-31 11:17:25 +0200351 struct lg_drv_data *drv_data;
Jiri Slaby5f22a792008-05-16 11:49:19 +0200352 int ret;
353
Michal Malý8577dbf2012-03-31 11:17:25 +0200354 drv_data = kzalloc(sizeof(struct lg_drv_data), GFP_KERNEL);
355 if (!drv_data) {
356 hid_err(hdev, "Insufficient memory, cannot allocate driver data\n");
357 return -ENOMEM;
358 }
359 drv_data->quirks = id->driver_data;
360
361 hid_set_drvdata(hdev, (void *)drv_data);
Jiri Slaby5f22a792008-05-16 11:49:19 +0200362
Michal Malý8577dbf2012-03-31 11:17:25 +0200363 if (drv_data->quirks & LG_NOGET)
Jiri Slaby5f22a792008-05-16 11:49:19 +0200364 hdev->quirks |= HID_QUIRK_NOGET;
365
366 ret = hid_parse(hdev);
367 if (ret) {
Joe Perches4291ee32010-12-09 19:29:03 -0800368 hid_err(hdev, "parse failed\n");
Jiri Slaby5f22a792008-05-16 11:49:19 +0200369 goto err_free;
370 }
371
Michal Malý8577dbf2012-03-31 11:17:25 +0200372 if (drv_data->quirks & (LG_FF | LG_FF2 | LG_FF3 | LG_FF4))
Jiri Slaby606bd0a2008-07-04 23:06:45 +0200373 connect_mask &= ~HID_CONNECT_FF;
374
375 ret = hid_hw_start(hdev, connect_mask);
Jiri Slaby5f22a792008-05-16 11:49:19 +0200376 if (ret) {
Joe Perches4291ee32010-12-09 19:29:03 -0800377 hid_err(hdev, "hw start failed\n");
Jiri Slaby5f22a792008-05-16 11:49:19 +0200378 goto err_free;
379 }
380
Michal Malý7362cd22011-08-04 16:16:09 +0200381 /* Setup wireless link with Logitech Wii wheel */
382 if(hdev->product == USB_DEVICE_ID_LOGITECH_WII_WHEEL) {
Simon Wood32c88cb2010-09-22 13:19:42 +0200383 unsigned char buf[] = { 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
384
385 ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
386
387 if (ret >= 0) {
388 /* insert a little delay of 10 jiffies ~ 40ms */
389 wait_queue_head_t wait;
390 init_waitqueue_head (&wait);
391 wait_event_interruptible_timeout(wait, 0, 10);
392
393 /* Select random Address */
394 buf[1] = 0xB2;
395 get_random_bytes(&buf[2], 2);
396
397 ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
398 }
399 }
400
Michal Malý8577dbf2012-03-31 11:17:25 +0200401 if (drv_data->quirks & LG_FF)
Jiri Slaby606bd0a2008-07-04 23:06:45 +0200402 lgff_init(hdev);
Michal Malý8577dbf2012-03-31 11:17:25 +0200403 if (drv_data->quirks & LG_FF2)
Jiri Slaby606bd0a2008-07-04 23:06:45 +0200404 lg2ff_init(hdev);
Michal Malý8577dbf2012-03-31 11:17:25 +0200405 if (drv_data->quirks & LG_FF3)
Gary Stein74f292c2010-01-13 00:25:58 +0100406 lg3ff_init(hdev);
Michal Malý8577dbf2012-03-31 11:17:25 +0200407 if (drv_data->quirks & LG_FF4)
Simon Wood32c88cb2010-09-22 13:19:42 +0200408 lg4ff_init(hdev);
Jiri Slaby606bd0a2008-07-04 23:06:45 +0200409
Jiri Slaby5f22a792008-05-16 11:49:19 +0200410 return 0;
411err_free:
Michal Malý8577dbf2012-03-31 11:17:25 +0200412 kfree(drv_data);
Jiri Slaby5f22a792008-05-16 11:49:19 +0200413 return ret;
414}
415
Michal Malý30bb75d2011-08-04 16:20:40 +0200416static void lg_remove(struct hid_device *hdev)
417{
Axel Lin25751552012-09-13 14:08:32 +0800418 struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
Michal Malý8577dbf2012-03-31 11:17:25 +0200419 if (drv_data->quirks & LG_FF4)
Michal Malý30bb75d2011-08-04 16:20:40 +0200420 lg4ff_deinit(hdev);
421
422 hid_hw_stop(hdev);
Michal Malý8577dbf2012-03-31 11:17:25 +0200423 kfree(drv_data);
Michal Malý30bb75d2011-08-04 16:20:40 +0200424}
425
Jiri Slaby5f22a792008-05-16 11:49:19 +0200426static const struct hid_device_id lg_devices[] = {
427 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER),
428 .driver_data = LG_RDESC | LG_WIRELESS },
429 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER),
430 .driver_data = LG_RDESC | LG_WIRELESS },
431 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2),
432 .driver_data = LG_RDESC | LG_WIRELESS },
433
434 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER),
435 .driver_data = LG_BAD_RELATIVE_KEYS },
436
437 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP),
438 .driver_data = LG_DUPLICATE_USAGES },
439 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE),
440 .driver_data = LG_DUPLICATE_USAGES },
441 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI),
442 .driver_data = LG_DUPLICATE_USAGES },
443
Jiri Slaby5f22a792008-05-16 11:49:19 +0200444 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD),
445 .driver_data = LG_IGNORE_DOUBLED_WHEEL | LG_EXPANDED_KEYMAP },
446 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500),
447 .driver_data = LG_IGNORE_DOUBLED_WHEEL | LG_EXPANDED_KEYMAP },
448
Jiri Slaby5f22a792008-05-16 11:49:19 +0200449 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D),
450 .driver_data = LG_NOGET },
451 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL),
Michal Malý7362cd22011-08-04 16:16:09 +0200452 .driver_data = LG_NOGET | LG_FF4 },
Jiri Slaby606bd0a2008-07-04 23:06:45 +0200453
Hendrik Iben2c6118e2010-10-04 15:39:49 +0200454 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD),
455 .driver_data = LG_FF2 },
Jiri Slaby606bd0a2008-07-04 23:06:45 +0200456 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD),
457 .driver_data = LG_FF },
458 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2),
459 .driver_data = LG_FF },
460 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D),
461 .driver_data = LG_FF },
462 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO),
463 .driver_data = LG_FF },
464 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL),
Michal Malý7362cd22011-08-04 16:16:09 +0200465 .driver_data = LG_FF4 },
Jiri Slaby606bd0a2008-07-04 23:06:45 +0200466 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2),
Michal Malý7362cd22011-08-04 16:16:09 +0200467 .driver_data = LG_FF4 },
Christophe Borivant243b7062009-04-17 11:39:39 +0200468 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL),
Michal Malý7362cd22011-08-04 16:16:09 +0200469 .driver_data = LG_FF4 },
470 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL),
471 .driver_data = LG_FF4 },
Peter Gundermannfdc68072011-05-03 10:15:03 +0200472 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G27_WHEEL),
Michal Malý7362cd22011-08-04 16:16:09 +0200473 .driver_data = LG_FF4 },
Jiri Kosina5623a242011-03-17 00:43:23 +0100474 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL),
Michal Malý7362cd22011-08-04 16:16:09 +0200475 .driver_data = LG_NOGET | LG_FF4 },
Simon Wood32c88cb2010-09-22 13:19:42 +0200476 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL),
477 .driver_data = LG_FF4 },
Jiri Kosinafd30ea82009-06-23 12:11:31 +0200478 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ),
479 .driver_data = LG_FF },
Jiri Slaby606bd0a2008-07-04 23:06:45 +0200480 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2),
481 .driver_data = LG_FF2 },
Gary Stein74f292c2010-01-13 00:25:58 +0100482 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940),
483 .driver_data = LG_FF3 },
Jiri Kosina24985cf2009-11-13 10:45:53 +0100484 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR),
485 .driver_data = LG_RDESC_REL_ABS },
486 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER),
487 .driver_data = LG_RDESC_REL_ABS },
Jiri Slaby5f22a792008-05-16 11:49:19 +0200488 { }
489};
Jiri Kosina24985cf2009-11-13 10:45:53 +0100490
Jiri Slaby5f22a792008-05-16 11:49:19 +0200491MODULE_DEVICE_TABLE(hid, lg_devices);
492
493static struct hid_driver lg_driver = {
494 .name = "logitech",
495 .id_table = lg_devices,
496 .report_fixup = lg_report_fixup,
497 .input_mapping = lg_input_mapping,
498 .input_mapped = lg_input_mapped,
499 .event = lg_event,
500 .probe = lg_probe,
Michal Malý30bb75d2011-08-04 16:20:40 +0200501 .remove = lg_remove,
Jiri Slaby5f22a792008-05-16 11:49:19 +0200502};
503
Peter Huewea24f4232009-07-02 19:08:38 +0200504static int __init lg_init(void)
Jiri Slaby5f22a792008-05-16 11:49:19 +0200505{
506 return hid_register_driver(&lg_driver);
507}
508
Peter Huewea24f4232009-07-02 19:08:38 +0200509static void __exit lg_exit(void)
Jiri Slaby5f22a792008-05-16 11:49:19 +0200510{
511 hid_unregister_driver(&lg_driver);
512}
513
514module_init(lg_init);
515module_exit(lg_exit);
516MODULE_LICENSE("GPL");