Merge tag 'dmaengine-fix-5.1-rc3' of git://git.infradead.org/users/vkoul/slave-dma
[linux-2.6-block.git] / drivers / hid / hid-lg.c
CommitLineData
5f22a799
JS
1/*
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
5f22a799 8 * Copyright (c) 2008 Jiri Slaby
2c6118e4 9 * Copyright (c) 2010 Hendrik Iben
5f22a799
JS
10 */
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>
32c88cbc
SW
22#include <linux/random.h>
23#include <linux/sched.h>
54bfe3f0 24#include <linux/usb.h>
32c88cbc 25#include <linux/wait.h>
5f22a799 26
54bfe3f0 27#include "usbhid/usbhid.h"
5f22a799 28#include "hid-ids.h"
606bd0a8 29#include "hid-lg.h"
a54dc779 30#include "hid-lg4ff.h"
5f22a799
JS
31
32#define LG_RDESC 0x001
33#define LG_BAD_RELATIVE_KEYS 0x002
34#define LG_DUPLICATE_USAGES 0x004
5f22a799
JS
35#define LG_EXPANDED_KEYMAP 0x010
36#define LG_IGNORE_DOUBLED_WHEEL 0x020
37#define LG_WIRELESS 0x040
38#define LG_INVERT_HWHEEL 0x080
39#define LG_NOGET 0x100
606bd0a8
JS
40#define LG_FF 0x200
41#define LG_FF2 0x400
24985cf6 42#define LG_RDESC_REL_ABS 0x800
74f292ca 43#define LG_FF3 0x1000
32c88cbc 44#define LG_FF4 0x2000
5f22a799 45
54bfe3f0
PS
46/* Size of the original descriptors of the Driving Force (and Pro) wheels */
47#define DF_RDESC_ORIG_SIZE 130
dc0a4f0c 48#define DFP_RDESC_ORIG_SIZE 97
7f505470 49#define FV_RDESC_ORIG_SIZE 130
270baef1 50#define MOMO_RDESC_ORIG_SIZE 87
348cbaa8 51#define MOMO2_RDESC_ORIG_SIZE 87
560bea30 52#define FFG_RDESC_ORIG_SIZE 85
e41b3cda 53#define FG_RDESC_ORIG_SIZE 82
dc0a4f0c 54
54bfe3f0
PS
55/* Fixed report descriptors for Logitech Driving Force (and Pro)
56 * wheel controllers
dc0a4f0c 57 *
54bfe3f0 58 * The original descriptors hide the separate throttle and brake axes in
dc0a4f0c
MB
59 * a custom vendor usage page, providing only a combined value as
60 * GenericDesktop.Y.
54bfe3f0 61 * These descriptors remove the combined Y axis and instead report
dc0a4f0c
MB
62 * separate throttle (Y) and brake (RZ).
63 */
54bfe3f0
PS
64static __u8 df_rdesc_fixed[] = {
650x05, 0x01, /* Usage Page (Desktop), */
bfb61abf 660x09, 0x04, /* Usage (Joystick), */
54bfe3f0
PS
670xA1, 0x01, /* Collection (Application), */
680xA1, 0x02, /* Collection (Logical), */
690x95, 0x01, /* Report Count (1), */
700x75, 0x0A, /* Report Size (10), */
710x14, /* Logical Minimum (0), */
720x26, 0xFF, 0x03, /* Logical Maximum (1023), */
730x34, /* Physical Minimum (0), */
740x46, 0xFF, 0x03, /* Physical Maximum (1023), */
750x09, 0x30, /* Usage (X), */
760x81, 0x02, /* Input (Variable), */
770x95, 0x0C, /* Report Count (12), */
780x75, 0x01, /* Report Size (1), */
790x25, 0x01, /* Logical Maximum (1), */
800x45, 0x01, /* Physical Maximum (1), */
810x05, 0x09, /* Usage (Buttons), */
820x19, 0x01, /* Usage Minimum (1), */
830x29, 0x0c, /* Usage Maximum (12), */
840x81, 0x02, /* Input (Variable), */
850x95, 0x02, /* Report Count (2), */
860x06, 0x00, 0xFF, /* Usage Page (Vendor: 65280), */
870x09, 0x01, /* Usage (?: 1), */
880x81, 0x02, /* Input (Variable), */
890x05, 0x01, /* Usage Page (Desktop), */
54bfe3f0
PS
900x26, 0xFF, 0x00, /* Logical Maximum (255), */
910x46, 0xFF, 0x00, /* Physical Maximum (255), */
920x95, 0x01, /* Report Count (1), */
930x75, 0x08, /* Report Size (8), */
940x81, 0x02, /* Input (Variable), */
950x25, 0x07, /* Logical Maximum (7), */
960x46, 0x3B, 0x01, /* Physical Maximum (315), */
970x75, 0x04, /* Report Size (4), */
980x65, 0x14, /* Unit (Degrees), */
990x09, 0x39, /* Usage (Hat Switch), */
1000x81, 0x42, /* Input (Variable, Null State), */
1010x75, 0x01, /* Report Size (1), */
1020x95, 0x04, /* Report Count (4), */
1030x65, 0x00, /* Unit (none), */
1040x06, 0x00, 0xFF, /* Usage Page (Vendor: 65280), */
1050x09, 0x01, /* Usage (?: 1), */
1060x25, 0x01, /* Logical Maximum (1), */
1070x45, 0x01, /* Physical Maximum (1), */
1080x81, 0x02, /* Input (Variable), */
5a9b571b
PS
1090x05, 0x01, /* Usage Page (Desktop), */
1100x95, 0x01, /* Report Count (1), */
54bfe3f0
PS
1110x75, 0x08, /* Report Size (8), */
1120x26, 0xFF, 0x00, /* Logical Maximum (255), */
1130x46, 0xFF, 0x00, /* Physical Maximum (255), */
5a9b571b
PS
1140x09, 0x31, /* Usage (Y), */
1150x81, 0x02, /* Input (Variable), */
1160x09, 0x35, /* Usage (Rz), */
54bfe3f0
PS
1170x81, 0x02, /* Input (Variable), */
1180xC0, /* End Collection, */
1190xA1, 0x02, /* Collection (Logical), */
1200x26, 0xFF, 0x00, /* Logical Maximum (255), */
1210x46, 0xFF, 0x00, /* Physical Maximum (255), */
1220x95, 0x07, /* Report Count (7), */
1230x75, 0x08, /* Report Size (8), */
1240x09, 0x03, /* Usage (?: 3), */
1250x91, 0x02, /* Output (Variable), */
1260xC0, /* End Collection, */
1270xC0 /* End Collection */
128};
129
dc0a4f0c
MB
130static __u8 dfp_rdesc_fixed[] = {
1310x05, 0x01, /* Usage Page (Desktop), */
bfb61abf 1320x09, 0x04, /* Usage (Joystick), */
dc0a4f0c
MB
1330xA1, 0x01, /* Collection (Application), */
1340xA1, 0x02, /* Collection (Logical), */
1350x95, 0x01, /* Report Count (1), */
1360x75, 0x0E, /* Report Size (14), */
1370x14, /* Logical Minimum (0), */
1380x26, 0xFF, 0x3F, /* Logical Maximum (16383), */
1390x34, /* Physical Minimum (0), */
1400x46, 0xFF, 0x3F, /* Physical Maximum (16383), */
1410x09, 0x30, /* Usage (X), */
1420x81, 0x02, /* Input (Variable), */
1430x95, 0x0E, /* Report Count (14), */
1440x75, 0x01, /* Report Size (1), */
1450x25, 0x01, /* Logical Maximum (1), */
1460x45, 0x01, /* Physical Maximum (1), */
1470x05, 0x09, /* Usage Page (Button), */
1480x19, 0x01, /* Usage Minimum (01h), */
1490x29, 0x0E, /* Usage Maximum (0Eh), */
1500x81, 0x02, /* Input (Variable), */
1510x05, 0x01, /* Usage Page (Desktop), */
1520x95, 0x01, /* Report Count (1), */
1530x75, 0x04, /* Report Size (4), */
1540x25, 0x07, /* Logical Maximum (7), */
1550x46, 0x3B, 0x01, /* Physical Maximum (315), */
1560x65, 0x14, /* Unit (Degrees), */
1570x09, 0x39, /* Usage (Hat Switch), */
1580x81, 0x42, /* Input (Variable, Nullstate), */
1590x65, 0x00, /* Unit, */
1600x26, 0xFF, 0x00, /* Logical Maximum (255), */
1610x46, 0xFF, 0x00, /* Physical Maximum (255), */
1620x75, 0x08, /* Report Size (8), */
1630x81, 0x01, /* Input (Constant), */
1640x09, 0x31, /* Usage (Y), */
1650x81, 0x02, /* Input (Variable), */
1660x09, 0x35, /* Usage (Rz), */
1670x81, 0x02, /* Input (Variable), */
1680x81, 0x01, /* Input (Constant), */
1690xC0, /* End Collection, */
1700xA1, 0x02, /* Collection (Logical), */
1710x09, 0x02, /* Usage (02h), */
1720x95, 0x07, /* Report Count (7), */
1730x91, 0x02, /* Output (Variable), */
1740xC0, /* End Collection, */
1750xC0 /* End Collection */
176};
177
7f505470
SW
178static __u8 fv_rdesc_fixed[] = {
1790x05, 0x01, /* Usage Page (Desktop), */
bfb61abf 1800x09, 0x04, /* Usage (Joystick), */
7f505470
SW
1810xA1, 0x01, /* Collection (Application), */
1820xA1, 0x02, /* Collection (Logical), */
1830x95, 0x01, /* Report Count (1), */
1840x75, 0x0A, /* Report Size (10), */
1850x15, 0x00, /* Logical Minimum (0), */
1860x26, 0xFF, 0x03, /* Logical Maximum (1023), */
1870x35, 0x00, /* Physical Minimum (0), */
1880x46, 0xFF, 0x03, /* Physical Maximum (1023), */
1890x09, 0x30, /* Usage (X), */
1900x81, 0x02, /* Input (Variable), */
1910x95, 0x0C, /* Report Count (12), */
1920x75, 0x01, /* Report Size (1), */
1930x25, 0x01, /* Logical Maximum (1), */
1940x45, 0x01, /* Physical Maximum (1), */
1950x05, 0x09, /* Usage Page (Button), */
1960x19, 0x01, /* Usage Minimum (01h), */
1970x29, 0x0C, /* Usage Maximum (0Ch), */
1980x81, 0x02, /* Input (Variable), */
1990x95, 0x02, /* Report Count (2), */
2000x06, 0x00, 0xFF, /* Usage Page (FF00h), */
2010x09, 0x01, /* Usage (01h), */
2020x81, 0x02, /* Input (Variable), */
2030x09, 0x02, /* Usage (02h), */
2040x26, 0xFF, 0x00, /* Logical Maximum (255), */
2050x46, 0xFF, 0x00, /* Physical Maximum (255), */
2060x95, 0x01, /* Report Count (1), */
2070x75, 0x08, /* Report Size (8), */
2080x81, 0x02, /* Input (Variable), */
2090x05, 0x01, /* Usage Page (Desktop), */
2100x25, 0x07, /* Logical Maximum (7), */
2110x46, 0x3B, 0x01, /* Physical Maximum (315), */
2120x75, 0x04, /* Report Size (4), */
2130x65, 0x14, /* Unit (Degrees), */
2140x09, 0x39, /* Usage (Hat Switch), */
2150x81, 0x42, /* Input (Variable, Null State), */
2160x75, 0x01, /* Report Size (1), */
2170x95, 0x04, /* Report Count (4), */
2180x65, 0x00, /* Unit, */
2190x06, 0x00, 0xFF, /* Usage Page (FF00h), */
2200x09, 0x01, /* Usage (01h), */
2210x25, 0x01, /* Logical Maximum (1), */
2220x45, 0x01, /* Physical Maximum (1), */
2230x81, 0x02, /* Input (Variable), */
2240x05, 0x01, /* Usage Page (Desktop), */
2250x95, 0x01, /* Report Count (1), */
2260x75, 0x08, /* Report Size (8), */
2270x26, 0xFF, 0x00, /* Logical Maximum (255), */
2280x46, 0xFF, 0x00, /* Physical Maximum (255), */
2290x09, 0x31, /* Usage (Y), */
2300x81, 0x02, /* Input (Variable), */
2310x09, 0x32, /* Usage (Z), */
2320x81, 0x02, /* Input (Variable), */
2330xC0, /* End Collection, */
2340xA1, 0x02, /* Collection (Logical), */
2350x26, 0xFF, 0x00, /* Logical Maximum (255), */
2360x46, 0xFF, 0x00, /* Physical Maximum (255), */
2370x95, 0x07, /* Report Count (7), */
2380x75, 0x08, /* Report Size (8), */
2390x09, 0x03, /* Usage (03h), */
2400x91, 0x02, /* Output (Variable), */
2410xC0, /* End Collection, */
2420xC0 /* End Collection */
243};
244
270baef1
SW
245static __u8 momo_rdesc_fixed[] = {
2460x05, 0x01, /* Usage Page (Desktop), */
bfb61abf 2470x09, 0x04, /* Usage (Joystick), */
270baef1
SW
2480xA1, 0x01, /* Collection (Application), */
2490xA1, 0x02, /* Collection (Logical), */
2500x95, 0x01, /* Report Count (1), */
2510x75, 0x0A, /* Report Size (10), */
2520x15, 0x00, /* Logical Minimum (0), */
2530x26, 0xFF, 0x03, /* Logical Maximum (1023), */
2540x35, 0x00, /* Physical Minimum (0), */
2550x46, 0xFF, 0x03, /* Physical Maximum (1023), */
2560x09, 0x30, /* Usage (X), */
2570x81, 0x02, /* Input (Variable), */
2580x95, 0x08, /* Report Count (8), */
2590x75, 0x01, /* Report Size (1), */
2600x25, 0x01, /* Logical Maximum (1), */
2610x45, 0x01, /* Physical Maximum (1), */
2620x05, 0x09, /* Usage Page (Button), */
2630x19, 0x01, /* Usage Minimum (01h), */
2640x29, 0x08, /* Usage Maximum (08h), */
2650x81, 0x02, /* Input (Variable), */
2660x06, 0x00, 0xFF, /* Usage Page (FF00h), */
2670x75, 0x0E, /* Report Size (14), */
2680x95, 0x01, /* Report Count (1), */
2690x26, 0xFF, 0x00, /* Logical Maximum (255), */
2700x46, 0xFF, 0x00, /* Physical Maximum (255), */
2710x09, 0x00, /* Usage (00h), */
2720x81, 0x02, /* Input (Variable), */
2730x05, 0x01, /* Usage Page (Desktop), */
2740x75, 0x08, /* Report Size (8), */
2750x09, 0x31, /* Usage (Y), */
2760x81, 0x02, /* Input (Variable), */
2770x09, 0x32, /* Usage (Z), */
2780x81, 0x02, /* Input (Variable), */
2790x06, 0x00, 0xFF, /* Usage Page (FF00h), */
2800x09, 0x01, /* Usage (01h), */
2810x81, 0x02, /* Input (Variable), */
2820xC0, /* End Collection, */
2830xA1, 0x02, /* Collection (Logical), */
2840x09, 0x02, /* Usage (02h), */
2850x95, 0x07, /* Report Count (7), */
2860x91, 0x02, /* Output (Variable), */
2870xC0, /* End Collection, */
2880xC0 /* End Collection */
289};
dc0a4f0c 290
348cbaa8
SW
291static __u8 momo2_rdesc_fixed[] = {
2920x05, 0x01, /* Usage Page (Desktop), */
bfb61abf 2930x09, 0x04, /* Usage (Joystick), */
348cbaa8
SW
2940xA1, 0x01, /* Collection (Application), */
2950xA1, 0x02, /* Collection (Logical), */
2960x95, 0x01, /* Report Count (1), */
2970x75, 0x0A, /* Report Size (10), */
2980x15, 0x00, /* Logical Minimum (0), */
2990x26, 0xFF, 0x03, /* Logical Maximum (1023), */
3000x35, 0x00, /* Physical Minimum (0), */
3010x46, 0xFF, 0x03, /* Physical Maximum (1023), */
3020x09, 0x30, /* Usage (X), */
3030x81, 0x02, /* Input (Variable), */
3040x95, 0x0A, /* Report Count (10), */
3050x75, 0x01, /* Report Size (1), */
3060x25, 0x01, /* Logical Maximum (1), */
3070x45, 0x01, /* Physical Maximum (1), */
3080x05, 0x09, /* Usage Page (Button), */
3090x19, 0x01, /* Usage Minimum (01h), */
3100x29, 0x0A, /* Usage Maximum (0Ah), */
3110x81, 0x02, /* Input (Variable), */
3120x06, 0x00, 0xFF, /* Usage Page (FF00h), */
3130x09, 0x00, /* Usage (00h), */
3140x95, 0x04, /* Report Count (4), */
3150x81, 0x02, /* Input (Variable), */
3160x95, 0x01, /* Report Count (1), */
3170x75, 0x08, /* Report Size (8), */
3180x26, 0xFF, 0x00, /* Logical Maximum (255), */
3190x46, 0xFF, 0x00, /* Physical Maximum (255), */
3200x09, 0x01, /* Usage (01h), */
3210x81, 0x02, /* Input (Variable), */
3220x05, 0x01, /* Usage Page (Desktop), */
3230x09, 0x31, /* Usage (Y), */
3240x81, 0x02, /* Input (Variable), */
3250x09, 0x32, /* Usage (Z), */
3260x81, 0x02, /* Input (Variable), */
3270x06, 0x00, 0xFF, /* Usage Page (FF00h), */
3280x09, 0x00, /* Usage (00h), */
3290x81, 0x02, /* Input (Variable), */
3300xC0, /* End Collection, */
3310xA1, 0x02, /* Collection (Logical), */
3320x09, 0x02, /* Usage (02h), */
3330x95, 0x07, /* Report Count (7), */
3340x91, 0x02, /* Output (Variable), */
3350xC0, /* End Collection, */
3360xC0 /* End Collection */
337};
338
560bea30
SW
339static __u8 ffg_rdesc_fixed[] = {
3400x05, 0x01, /* Usage Page (Desktop), */
3410x09, 0x04, /* Usage (Joystik), */
3420xA1, 0x01, /* Collection (Application), */
3430xA1, 0x02, /* Collection (Logical), */
3440x95, 0x01, /* Report Count (1), */
3450x75, 0x0A, /* Report Size (10), */
3460x15, 0x00, /* Logical Minimum (0), */
3470x26, 0xFF, 0x03, /* Logical Maximum (1023), */
3480x35, 0x00, /* Physical Minimum (0), */
3490x46, 0xFF, 0x03, /* Physical Maximum (1023), */
3500x09, 0x30, /* Usage (X), */
3510x81, 0x02, /* Input (Variable), */
3520x95, 0x06, /* Report Count (6), */
3530x75, 0x01, /* Report Size (1), */
3540x25, 0x01, /* Logical Maximum (1), */
3550x45, 0x01, /* Physical Maximum (1), */
3560x05, 0x09, /* Usage Page (Button), */
3570x19, 0x01, /* Usage Minimum (01h), */
3580x29, 0x06, /* Usage Maximum (06h), */
3590x81, 0x02, /* Input (Variable), */
3600x95, 0x01, /* Report Count (1), */
3610x75, 0x08, /* Report Size (8), */
3620x26, 0xFF, 0x00, /* Logical Maximum (255), */
3630x46, 0xFF, 0x00, /* Physical Maximum (255), */
3640x06, 0x00, 0xFF, /* Usage Page (FF00h), */
3650x09, 0x01, /* Usage (01h), */
3660x81, 0x02, /* Input (Variable), */
3670x05, 0x01, /* Usage Page (Desktop), */
3680x81, 0x01, /* Input (Constant), */
3690x09, 0x31, /* Usage (Y), */
3700x81, 0x02, /* Input (Variable), */
3710x09, 0x32, /* Usage (Z), */
3720x81, 0x02, /* Input (Variable), */
3730x06, 0x00, 0xFF, /* Usage Page (FF00h), */
3740x09, 0x01, /* Usage (01h), */
3750x81, 0x02, /* Input (Variable), */
3760xC0, /* End Collection, */
3770xA1, 0x02, /* Collection (Logical), */
3780x09, 0x02, /* Usage (02h), */
3790x95, 0x07, /* Report Count (7), */
3800x91, 0x02, /* Output (Variable), */
3810xC0, /* End Collection, */
3820xC0 /* End Collection */
383};
384
e41b3cda
JW
385static __u8 fg_rdesc_fixed[] = {
3860x05, 0x01, /* Usage Page (Desktop), */
3870x09, 0x04, /* Usage (Joystik), */
3880xA1, 0x01, /* Collection (Application), */
3890xA1, 0x02, /* Collection (Logical), */
3900x15, 0x00, /* Logical Minimum (0), */
3910x26, 0xFF, 0x00, /* Logical Maximum (255), */
3920x35, 0x00, /* Physical Minimum (0), */
3930x46, 0xFF, 0x00, /* Physical Maximum (255), */
3940x75, 0x08, /* Report Size (8), */
3950x95, 0x01, /* Report Count (1), */
3960x09, 0x30, /* Usage (X), */
3970x81, 0x02, /* Input (Variable), */
3980xA4, /* Push, */
3990x25, 0x01, /* Logical Maximum (1), */
4000x45, 0x01, /* Physical Maximum (1), */
4010x75, 0x01, /* Report Size (1), */
4020x95, 0x02, /* Report Count (2), */
4030x81, 0x01, /* Input (Constant), */
4040x95, 0x06, /* Report Count (6), */
4050x05, 0x09, /* Usage Page (Button), */
4060x19, 0x01, /* Usage Minimum (01h), */
4070x29, 0x06, /* Usage Maximum (06h), */
4080x81, 0x02, /* Input (Variable), */
4090x05, 0x01, /* Usage Page (Desktop), */
4100xB4, /* Pop, */
4110x81, 0x02, /* Input (Constant), */
4120x09, 0x31, /* Usage (Y), */
4130x81, 0x02, /* Input (Variable), */
4140x09, 0x32, /* Usage (Z), */
4150x81, 0x02, /* Input (Variable), */
4160xC0, /* End Collection, */
4170xA1, 0x02, /* Collection (Logical), */
4180x26, 0xFF, 0x00, /* Logical Maximum (255), */
4190x46, 0xFF, 0x00, /* Physical Maximum (255), */
4200x75, 0x08, /* Report Size (8), */
4210x95, 0x04, /* Report Count (4), */
4220x09, 0x02, /* Usage (02h), */
4230xB1, 0x02, /* Feature (Variable), */
4240xC0, /* End Collection, */
4250xC0 /* End Collection, */
426};
427
5f22a799
JS
428/*
429 * Certain Logitech keyboards send in report #3 keys which are far
430 * above the logical maximum described in descriptor. This extends
431 * the original value of 0x28c of logical maximum to 0x104d
432 */
73e4008d
NK
433static __u8 *lg_report_fixup(struct hid_device *hdev, __u8 *rdesc,
434 unsigned int *rsize)
5f22a799 435{
25751553 436 struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
5f22a799 437
4ab25786 438 if ((drv_data->quirks & LG_RDESC) && *rsize >= 91 && rdesc[83] == 0x26 &&
5f22a799 439 rdesc[84] == 0x8c && rdesc[85] == 0x02) {
4291ee30
JP
440 hid_info(hdev,
441 "fixing up Logitech keyboard report descriptor\n");
5f22a799
JS
442 rdesc[84] = rdesc[89] = 0x4d;
443 rdesc[85] = rdesc[90] = 0x10;
444 }
4ab25786 445 if ((drv_data->quirks & LG_RDESC_REL_ABS) && *rsize >= 51 &&
24985cf6
JK
446 rdesc[32] == 0x81 && rdesc[33] == 0x06 &&
447 rdesc[49] == 0x81 && rdesc[50] == 0x06) {
4291ee30
JP
448 hid_info(hdev,
449 "fixing up rel/abs in Logitech report descriptor\n");
24985cf6
JK
450 rdesc[33] = rdesc[50] = 0x02;
451 }
dc0a4f0c
MB
452
453 switch (hdev->product) {
54bfe3f0 454
e41b3cda
JW
455 case USB_DEVICE_ID_LOGITECH_WINGMAN_FG:
456 if (*rsize == FG_RDESC_ORIG_SIZE) {
457 hid_info(hdev,
458 "fixing up Logitech Wingman Formula GP report descriptor\n");
459 rdesc = fg_rdesc_fixed;
460 *rsize = sizeof(fg_rdesc_fixed);
461 } else {
462 hid_info(hdev,
463 "rdesc size test failed for formula gp\n");
464 }
465 break;
466
467
560bea30
SW
468 case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG:
469 if (*rsize == FFG_RDESC_ORIG_SIZE) {
470 hid_info(hdev,
471 "fixing up Logitech Wingman Formula Force GP report descriptor\n");
472 rdesc = ffg_rdesc_fixed;
473 *rsize = sizeof(ffg_rdesc_fixed);
474 }
475 break;
476
54bfe3f0
PS
477 /* Several wheels report as this id when operating in emulation mode. */
478 case USB_DEVICE_ID_LOGITECH_WHEEL:
7363b25a 479 if (*rsize == DF_RDESC_ORIG_SIZE) {
54bfe3f0
PS
480 hid_info(hdev,
481 "fixing up Logitech Driving Force report descriptor\n");
482 rdesc = df_rdesc_fixed;
483 *rsize = sizeof(df_rdesc_fixed);
484 }
485 break;
486
270baef1
SW
487 case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
488 if (*rsize == MOMO_RDESC_ORIG_SIZE) {
489 hid_info(hdev,
490 "fixing up Logitech Momo Force (Red) report descriptor\n");
491 rdesc = momo_rdesc_fixed;
492 *rsize = sizeof(momo_rdesc_fixed);
493 }
494 break;
495
348cbaa8
SW
496 case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2:
497 if (*rsize == MOMO2_RDESC_ORIG_SIZE) {
498 hid_info(hdev,
499 "fixing up Logitech Momo Racing Force (Black) report descriptor\n");
500 rdesc = momo2_rdesc_fixed;
501 *rsize = sizeof(momo2_rdesc_fixed);
502 }
503 break;
504
7f505470
SW
505 case USB_DEVICE_ID_LOGITECH_VIBRATION_WHEEL:
506 if (*rsize == FV_RDESC_ORIG_SIZE) {
507 hid_info(hdev,
508 "fixing up Logitech Formula Vibration report descriptor\n");
509 rdesc = fv_rdesc_fixed;
510 *rsize = sizeof(fv_rdesc_fixed);
511 }
512 break;
513
dc0a4f0c
MB
514 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
515 if (*rsize == DFP_RDESC_ORIG_SIZE) {
516 hid_info(hdev,
517 "fixing up Logitech Driving Force Pro report descriptor\n");
518 rdesc = dfp_rdesc_fixed;
519 *rsize = sizeof(dfp_rdesc_fixed);
520 }
521 break;
b5836246
SW
522
523 case USB_DEVICE_ID_LOGITECH_WII_WHEEL:
524 if (*rsize >= 101 && rdesc[41] == 0x95 && rdesc[42] == 0x0B &&
525 rdesc[47] == 0x05 && rdesc[48] == 0x09) {
526 hid_info(hdev, "fixing up Logitech Speed Force Wireless report descriptor\n");
527 rdesc[41] = 0x05;
528 rdesc[42] = 0x09;
529 rdesc[47] = 0x95;
530 rdesc[48] = 0x0B;
531 }
532 break;
dc0a4f0c
MB
533 }
534
73e4008d 535 return rdesc;
5f22a799
JS
536}
537
538#define lg_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
539 EV_KEY, (c))
540
541static int lg_ultrax_remote_mapping(struct hid_input *hi,
542 struct hid_usage *usage, unsigned long **bit, int *max)
543{
544 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR)
545 return 0;
546
547 set_bit(EV_REP, hi->input->evbit);
548 switch (usage->hid & HID_USAGE) {
549 /* Reported on Logitech Ultra X Media Remote */
550 case 0x004: lg_map_key_clear(KEY_AGAIN); break;
551 case 0x00d: lg_map_key_clear(KEY_HOME); break;
552 case 0x024: lg_map_key_clear(KEY_SHUFFLE); break;
553 case 0x025: lg_map_key_clear(KEY_TV); break;
554 case 0x026: lg_map_key_clear(KEY_MENU); break;
555 case 0x031: lg_map_key_clear(KEY_AUDIO); break;
556 case 0x032: lg_map_key_clear(KEY_TEXT); break;
557 case 0x033: lg_map_key_clear(KEY_LAST); break;
558 case 0x047: lg_map_key_clear(KEY_MP3); break;
559 case 0x048: lg_map_key_clear(KEY_DVD); break;
560 case 0x049: lg_map_key_clear(KEY_MEDIA); break;
561 case 0x04a: lg_map_key_clear(KEY_VIDEO); break;
562 case 0x04b: lg_map_key_clear(KEY_ANGLE); break;
563 case 0x04c: lg_map_key_clear(KEY_LANGUAGE); break;
564 case 0x04d: lg_map_key_clear(KEY_SUBTITLE); break;
565 case 0x051: lg_map_key_clear(KEY_RED); break;
566 case 0x052: lg_map_key_clear(KEY_CLOSE); break;
567
568 default:
569 return 0;
570 }
571 return 1;
572}
573
66d61bec
JK
574static int lg_dinovo_mapping(struct hid_input *hi, struct hid_usage *usage,
575 unsigned long **bit, int *max)
576{
577 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR)
578 return 0;
579
580 switch (usage->hid & HID_USAGE) {
581
582 case 0x00d: lg_map_key_clear(KEY_MEDIA); break;
583 default:
584 return 0;
585
586 }
587 return 1;
588}
589
5f22a799
JS
590static int lg_wireless_mapping(struct hid_input *hi, struct hid_usage *usage,
591 unsigned long **bit, int *max)
592{
593 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
594 return 0;
595
596 switch (usage->hid & HID_USAGE) {
597 case 0x1001: lg_map_key_clear(KEY_MESSENGER); break;
598 case 0x1003: lg_map_key_clear(KEY_SOUND); break;
599 case 0x1004: lg_map_key_clear(KEY_VIDEO); break;
600 case 0x1005: lg_map_key_clear(KEY_AUDIO); break;
601 case 0x100a: lg_map_key_clear(KEY_DOCUMENTS); break;
18392212
LC
602 /* The following two entries are Playlist 1 and 2 on the MX3200 */
603 case 0x100f: lg_map_key_clear(KEY_FN_1); break;
604 case 0x1010: lg_map_key_clear(KEY_FN_2); break;
5f22a799
JS
605 case 0x1011: lg_map_key_clear(KEY_PREVIOUSSONG); break;
606 case 0x1012: lg_map_key_clear(KEY_NEXTSONG); break;
607 case 0x1013: lg_map_key_clear(KEY_CAMERA); break;
608 case 0x1014: lg_map_key_clear(KEY_MESSENGER); break;
609 case 0x1015: lg_map_key_clear(KEY_RECORD); break;
610 case 0x1016: lg_map_key_clear(KEY_PLAYER); break;
611 case 0x1017: lg_map_key_clear(KEY_EJECTCD); break;
612 case 0x1018: lg_map_key_clear(KEY_MEDIA); break;
613 case 0x1019: lg_map_key_clear(KEY_PROG1); break;
614 case 0x101a: lg_map_key_clear(KEY_PROG2); break;
615 case 0x101b: lg_map_key_clear(KEY_PROG3); break;
18392212 616 case 0x101c: lg_map_key_clear(KEY_CYCLEWINDOWS); break;
5f22a799
JS
617 case 0x101f: lg_map_key_clear(KEY_ZOOMIN); break;
618 case 0x1020: lg_map_key_clear(KEY_ZOOMOUT); break;
619 case 0x1021: lg_map_key_clear(KEY_ZOOMRESET); break;
620 case 0x1023: lg_map_key_clear(KEY_CLOSE); break;
621 case 0x1027: lg_map_key_clear(KEY_MENU); break;
622 /* this one is marked as 'Rotate' */
623 case 0x1028: lg_map_key_clear(KEY_ANGLE); break;
624 case 0x1029: lg_map_key_clear(KEY_SHUFFLE); break;
625 case 0x102a: lg_map_key_clear(KEY_BACK); break;
626 case 0x102b: lg_map_key_clear(KEY_CYCLEWINDOWS); break;
18392212
LC
627 case 0x102d: lg_map_key_clear(KEY_WWW); break;
628 /* The following two are 'Start/answer call' and 'End/reject call'
629 on the MX3200 */
630 case 0x1031: lg_map_key_clear(KEY_OK); break;
631 case 0x1032: lg_map_key_clear(KEY_CANCEL); break;
5f22a799
JS
632 case 0x1041: lg_map_key_clear(KEY_BATTERY); break;
633 case 0x1042: lg_map_key_clear(KEY_WORDPROCESSOR); break;
634 case 0x1043: lg_map_key_clear(KEY_SPREADSHEET); break;
635 case 0x1044: lg_map_key_clear(KEY_PRESENTATION); break;
636 case 0x1045: lg_map_key_clear(KEY_UNDO); break;
637 case 0x1046: lg_map_key_clear(KEY_REDO); break;
638 case 0x1047: lg_map_key_clear(KEY_PRINT); break;
639 case 0x1048: lg_map_key_clear(KEY_SAVE); break;
640 case 0x1049: lg_map_key_clear(KEY_PROG1); break;
641 case 0x104a: lg_map_key_clear(KEY_PROG2); break;
642 case 0x104b: lg_map_key_clear(KEY_PROG3); break;
643 case 0x104c: lg_map_key_clear(KEY_PROG4); break;
644
645 default:
646 return 0;
647 }
648 return 1;
649}
650
651static int lg_input_mapping(struct hid_device *hdev, struct hid_input *hi,
652 struct hid_field *field, struct hid_usage *usage,
653 unsigned long **bit, int *max)
654{
655 /* extended mapping for certain Logitech hardware (Logitech cordless
656 desktop LX500) */
657 static const u8 e_keymap[] = {
658 0,216, 0,213,175,156, 0, 0, 0, 0,
659 144, 0, 0, 0, 0, 0, 0, 0, 0,212,
660 174,167,152,161,112, 0, 0, 0,154, 0,
661 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
662 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
663 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
664 0, 0, 0, 0, 0,183,184,185,186,187,
665 188,189,190,191,192,193,194, 0, 0, 0
666 };
25751553 667 struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
5f22a799
JS
668 unsigned int hid = usage->hid;
669
670 if (hdev->product == USB_DEVICE_ID_LOGITECH_RECEIVER &&
671 lg_ultrax_remote_mapping(hi, usage, bit, max))
672 return 1;
673
66d61bec
JK
674 if (hdev->product == USB_DEVICE_ID_DINOVO_MINI &&
675 lg_dinovo_mapping(hi, usage, bit, max))
676 return 1;
677
8577dbf9 678 if ((drv_data->quirks & LG_WIRELESS) && lg_wireless_mapping(hi, usage, bit, max))
5f22a799
JS
679 return 1;
680
681 if ((hid & HID_USAGE_PAGE) != HID_UP_BUTTON)
682 return 0;
683
684 hid &= HID_USAGE;
685
686 /* Special handling for Logitech Cordless Desktop */
687 if (field->application == HID_GD_MOUSE) {
8577dbf9 688 if ((drv_data->quirks & LG_IGNORE_DOUBLED_WHEEL) &&
5f22a799
JS
689 (hid == 7 || hid == 8))
690 return -1;
691 } else {
8577dbf9 692 if ((drv_data->quirks & LG_EXPANDED_KEYMAP) &&
5f22a799
JS
693 hid < ARRAY_SIZE(e_keymap) &&
694 e_keymap[hid] != 0) {
695 hid_map_usage(hi, usage, bit, max, EV_KEY,
696 e_keymap[hid]);
697 return 1;
698 }
699 }
700
701 return 0;
702}
703
704static int lg_input_mapped(struct hid_device *hdev, struct hid_input *hi,
705 struct hid_field *field, struct hid_usage *usage,
706 unsigned long **bit, int *max)
707{
25751553 708 struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
5f22a799 709
8577dbf9 710 if ((drv_data->quirks & LG_BAD_RELATIVE_KEYS) && usage->type == EV_KEY &&
5f22a799
JS
711 (field->flags & HID_MAIN_ITEM_RELATIVE))
712 field->flags &= ~HID_MAIN_ITEM_RELATIVE;
713
8577dbf9 714 if ((drv_data->quirks & LG_DUPLICATE_USAGES) && (usage->type == EV_KEY ||
5f22a799
JS
715 usage->type == EV_REL || usage->type == EV_ABS))
716 clear_bit(usage->code, *bit);
717
94b3f712
SW
718 /* Ensure that Logitech wheels are not given a default fuzz/flat value */
719 if (usage->type == EV_ABS && (usage->code == ABS_X ||
720 usage->code == ABS_Y || usage->code == ABS_Z ||
721 usage->code == ABS_RZ)) {
722 switch (hdev->product) {
29fae1c8 723 case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
e41b3cda 724 case USB_DEVICE_ID_LOGITECH_WINGMAN_FG:
560bea30 725 case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG:
94b3f712
SW
726 case USB_DEVICE_ID_LOGITECH_WHEEL:
727 case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
728 case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
729 case USB_DEVICE_ID_LOGITECH_G25_WHEEL:
730 case USB_DEVICE_ID_LOGITECH_DFGT_WHEEL:
731 case USB_DEVICE_ID_LOGITECH_G27_WHEEL:
732 case USB_DEVICE_ID_LOGITECH_WII_WHEEL:
733 case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2:
bd04363d 734 case USB_DEVICE_ID_LOGITECH_VIBRATION_WHEEL:
94b3f712
SW
735 field->application = HID_GD_MULTIAXIS;
736 break;
737 default:
738 break;
739 }
740 }
741
5f22a799
JS
742 return 0;
743}
744
745static int lg_event(struct hid_device *hdev, struct hid_field *field,
746 struct hid_usage *usage, __s32 value)
747{
25751553 748 struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
5f22a799 749
8577dbf9 750 if ((drv_data->quirks & LG_INVERT_HWHEEL) && usage->code == REL_HWHEEL) {
5f22a799
JS
751 input_event(field->hidinput->input, usage->type, usage->code,
752 -value);
753 return 1;
754 }
2b24a960
MM
755 if (drv_data->quirks & LG_FF4) {
756 return lg4ff_adjust_input_event(hdev, field, usage, value, drv_data);
757 }
5f22a799
JS
758
759 return 0;
760}
761
c832f86e
SW
762static int lg_raw_event(struct hid_device *hdev, struct hid_report *report,
763 u8 *rd, int size)
764{
765 struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
766
767 if (drv_data->quirks & LG_FF4)
768 return lg4ff_raw_event(hdev, report, rd, size, drv_data);
769
770 return 0;
771}
772
5f22a799
JS
773static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
774{
29fae1c8
SW
775 struct usb_interface *iface = to_usb_interface(hdev->dev.parent);
776 __u8 iface_num = iface->cur_altsetting->desc.bInterfaceNumber;
606bd0a8 777 unsigned int connect_mask = HID_CONNECT_DEFAULT;
8577dbf9 778 struct lg_drv_data *drv_data;
5f22a799
JS
779 int ret;
780
2078665a
BT
781 /* G29 only work with the 1st interface */
782 if ((hdev->product == USB_DEVICE_ID_LOGITECH_G29_WHEEL) &&
783 (iface_num != 0)) {
29fae1c8
SW
784 dbg_hid("%s: ignoring ifnum %d\n", __func__, iface_num);
785 return -ENODEV;
786 }
787
8577dbf9
MM
788 drv_data = kzalloc(sizeof(struct lg_drv_data), GFP_KERNEL);
789 if (!drv_data) {
790 hid_err(hdev, "Insufficient memory, cannot allocate driver data\n");
791 return -ENOMEM;
792 }
793 drv_data->quirks = id->driver_data;
a80fe5d6 794
8577dbf9 795 hid_set_drvdata(hdev, (void *)drv_data);
5f22a799 796
8577dbf9 797 if (drv_data->quirks & LG_NOGET)
5f22a799
JS
798 hdev->quirks |= HID_QUIRK_NOGET;
799
800 ret = hid_parse(hdev);
801 if (ret) {
4291ee30 802 hid_err(hdev, "parse failed\n");
5f22a799
JS
803 goto err_free;
804 }
805
8577dbf9 806 if (drv_data->quirks & (LG_FF | LG_FF2 | LG_FF3 | LG_FF4))
606bd0a8
JS
807 connect_mask &= ~HID_CONNECT_FF;
808
809 ret = hid_hw_start(hdev, connect_mask);
5f22a799 810 if (ret) {
4291ee30 811 hid_err(hdev, "hw start failed\n");
5f22a799
JS
812 goto err_free;
813 }
814
7362cd22 815 /* Setup wireless link with Logitech Wii wheel */
a80fe5d6 816 if (hdev->product == USB_DEVICE_ID_LOGITECH_WII_WHEEL) {
47af1cdb
CIK
817 static const unsigned char cbuf[] = {
818 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
819 };
061232f0 820 u8 *buf = kmemdup(cbuf, sizeof(cbuf), GFP_KERNEL);
32c88cbc 821
061232f0
BT
822 if (!buf) {
823 ret = -ENOMEM;
824 goto err_free;
825 }
32c88cbc 826
061232f0
BT
827 ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf),
828 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
32c88cbc
SW
829 if (ret >= 0) {
830 /* insert a little delay of 10 jiffies ~ 40ms */
831 wait_queue_head_t wait;
832 init_waitqueue_head (&wait);
e0393062
NMG
833 wait_event_interruptible_timeout(wait, 0,
834 msecs_to_jiffies(40));
32c88cbc
SW
835
836 /* Select random Address */
837 buf[1] = 0xB2;
838 get_random_bytes(&buf[2], 2);
839
061232f0 840 ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf),
b0dd72aa 841 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
32c88cbc 842 }
061232f0 843 kfree(buf);
32c88cbc
SW
844 }
845
8577dbf9 846 if (drv_data->quirks & LG_FF)
2dbf635e 847 ret = lgff_init(hdev);
f4e1eb96 848 else if (drv_data->quirks & LG_FF2)
2dbf635e 849 ret = lg2ff_init(hdev);
f4e1eb96 850 else if (drv_data->quirks & LG_FF3)
2dbf635e 851 ret = lg3ff_init(hdev);
f4e1eb96 852 else if (drv_data->quirks & LG_FF4)
2dbf635e
MM
853 ret = lg4ff_init(hdev);
854
855 if (ret)
856 goto err_free;
606bd0a8 857
5f22a799
JS
858 return 0;
859err_free:
8577dbf9 860 kfree(drv_data);
5f22a799
JS
861 return ret;
862}
863
30bb75d7
MM
864static void lg_remove(struct hid_device *hdev)
865{
25751553 866 struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
8577dbf9 867 if (drv_data->quirks & LG_FF4)
30bb75d7 868 lg4ff_deinit(hdev);
b211a638
MM
869 else
870 hid_hw_stop(hdev);
8577dbf9 871 kfree(drv_data);
30bb75d7
MM
872}
873
5f22a799
JS
874static const struct hid_device_id lg_devices[] = {
875 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER),
876 .driver_data = LG_RDESC | LG_WIRELESS },
877 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER),
878 .driver_data = LG_RDESC | LG_WIRELESS },
879 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2),
880 .driver_data = LG_RDESC | LG_WIRELESS },
881
882 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER),
883 .driver_data = LG_BAD_RELATIVE_KEYS },
884
885 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP),
886 .driver_data = LG_DUPLICATE_USAGES },
887 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE),
888 .driver_data = LG_DUPLICATE_USAGES },
889 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI),
890 .driver_data = LG_DUPLICATE_USAGES },
891
5f22a799
JS
892 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD),
893 .driver_data = LG_IGNORE_DOUBLED_WHEEL | LG_EXPANDED_KEYMAP },
894 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500),
895 .driver_data = LG_IGNORE_DOUBLED_WHEEL | LG_EXPANDED_KEYMAP },
896
5f22a799
JS
897 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D),
898 .driver_data = LG_NOGET },
56d0c8b7
VK
899 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DUAL_ACTION),
900 .driver_data = LG_NOGET },
5f22a799 901 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL),
7362cd22 902 .driver_data = LG_NOGET | LG_FF4 },
606bd0a8 903
2c6118e4
HI
904 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD),
905 .driver_data = LG_FF2 },
606bd0a8
JS
906 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD),
907 .driver_data = LG_FF },
908 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2),
909 .driver_data = LG_FF },
c873d9ab
SW
910 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G29_WHEEL),
911 .driver_data = LG_FF4 },
606bd0a8
JS
912 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D),
913 .driver_data = LG_FF },
914 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO),
915 .driver_data = LG_FF },
916 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL),
270baef1 917 .driver_data = LG_NOGET | LG_FF4 },
606bd0a8 918 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2),
7362cd22 919 .driver_data = LG_FF4 },
bd04363d
EV
920 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_VIBRATION_WHEEL),
921 .driver_data = LG_FF2 },
243b706d 922 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL),
7362cd22
MM
923 .driver_data = LG_FF4 },
924 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL),
925 .driver_data = LG_FF4 },
fdc6807f 926 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G27_WHEEL),
7362cd22 927 .driver_data = LG_FF4 },
5623a24a 928 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL),
7362cd22 929 .driver_data = LG_NOGET | LG_FF4 },
32c88cbc
SW
930 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL),
931 .driver_data = LG_FF4 },
e41b3cda
JW
932 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FG),
933 .driver_data = LG_NOGET },
a80fe5d6 934 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG),
560bea30 935 .driver_data = LG_NOGET | LG_FF4 },
606bd0a8 936 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2),
877a021e 937 .driver_data = LG_NOGET | LG_FF2 },
74f292ca
GS
938 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940),
939 .driver_data = LG_FF3 },
24985cf6
JK
940 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR),
941 .driver_data = LG_RDESC_REL_ABS },
942 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER),
943 .driver_data = LG_RDESC_REL_ABS },
5f22a799
JS
944 { }
945};
24985cf6 946
5f22a799
JS
947MODULE_DEVICE_TABLE(hid, lg_devices);
948
949static struct hid_driver lg_driver = {
950 .name = "logitech",
951 .id_table = lg_devices,
952 .report_fixup = lg_report_fixup,
953 .input_mapping = lg_input_mapping,
954 .input_mapped = lg_input_mapped,
955 .event = lg_event,
c832f86e 956 .raw_event = lg_raw_event,
5f22a799 957 .probe = lg_probe,
30bb75d7 958 .remove = lg_remove,
5f22a799 959};
f425458e 960module_hid_driver(lg_driver);
5f22a799 961
a54dc779
MM
962#ifdef CONFIG_LOGIWHEELS_FF
963int lg4ff_no_autoswitch = 0;
964module_param_named(lg4ff_no_autoswitch, lg4ff_no_autoswitch, int, S_IRUGO);
965MODULE_PARM_DESC(lg4ff_no_autoswitch, "Do not switch multimode wheels to their native mode automatically");
966#endif
967
5f22a799 968MODULE_LICENSE("GPL");