aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/hid
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/Kconfig54
-rw-r--r--drivers/hid/Makefile9
-rw-r--r--drivers/hid/hid-3m-pct.c291
-rw-r--r--drivers/hid/hid-a4tech.c1
-rw-r--r--drivers/hid/hid-apple.c25
-rw-r--r--drivers/hid/hid-cherry.c1
-rw-r--r--drivers/hid/hid-core.c47
-rw-r--r--drivers/hid/hid-cypress.c2
-rw-r--r--drivers/hid/hid-debug.c13
-rw-r--r--drivers/hid/hid-drff.c1
-rw-r--r--drivers/hid/hid-gaff.c1
-rw-r--r--drivers/hid/hid-gyration.c5
-rw-r--r--drivers/hid/hid-ids.h52
-rw-r--r--drivers/hid/hid-input.c36
-rw-r--r--drivers/hid/hid-lg.c40
-rw-r--r--drivers/hid/hid-lg.h8
-rw-r--r--drivers/hid/hid-lg2ff.c1
-rw-r--r--drivers/hid/hid-lg3ff.c176
-rw-r--r--drivers/hid/hid-lgff.c1
-rw-r--r--drivers/hid/hid-magicmouse.c453
-rw-r--r--drivers/hid/hid-mosart.c274
-rw-r--r--drivers/hid/hid-ntrig.c230
-rw-r--r--drivers/hid/hid-ortek.c56
-rw-r--r--drivers/hid/hid-pl.c1
-rw-r--r--drivers/hid/hid-quanta.c261
-rw-r--r--drivers/hid/hid-samsung.c25
-rw-r--r--drivers/hid/hid-sjoy.c1
-rw-r--r--drivers/hid/hid-sony.c24
-rw-r--r--drivers/hid/hid-stantum.c284
-rw-r--r--drivers/hid/hid-tmff.c3
-rw-r--r--drivers/hid/hid-wacom.c34
-rw-r--r--drivers/hid/hid-zpff.c1
-rw-r--r--drivers/hid/hidraw.c3
-rw-r--r--drivers/hid/usbhid/hid-core.c75
-rw-r--r--drivers/hid/usbhid/hid-pidff.c6
-rw-r--r--drivers/hid/usbhid/hid-quirks.c10
-rw-r--r--drivers/hid/usbhid/hiddev.c12
-rw-r--r--drivers/hid/usbhid/usbhid.h2
-rw-r--r--drivers/hid/usbhid/usbkbd.c2
39 files changed, 2345 insertions, 176 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 24d90ea246ce..71d4c0703629 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -55,6 +55,12 @@ source "drivers/hid/usbhid/Kconfig"
55menu "Special HID drivers" 55menu "Special HID drivers"
56 depends on HID 56 depends on HID
57 57
58config HID_3M_PCT
59 tristate "3M PCT"
60 depends on USB_HID
61 ---help---
62 Support for 3M PCT touch screens.
63
58config HID_A4TECH 64config HID_A4TECH
59 tristate "A4 tech" if EMBEDDED 65 tristate "A4 tech" if EMBEDDED
60 depends on USB_HID 66 depends on USB_HID
@@ -183,6 +189,23 @@ config LOGIRUMBLEPAD2_FF
183 Say Y here if you want to enable force feedback support for Logitech 189 Say Y here if you want to enable force feedback support for Logitech
184 Rumblepad 2 devices. 190 Rumblepad 2 devices.
185 191
192config LOGIG940_FF
193 bool "Logitech Flight System G940 force feedback support"
194 depends on HID_LOGITECH
195 select INPUT_FF_MEMLESS
196 help
197 Say Y here if you want to enable force feedback support for Logitech
198 Flight System G940 devices.
199
200config HID_MAGICMOUSE
201 tristate "Apple MagicMouse multi-touch support"
202 depends on BT_HIDP
203 ---help---
204 Support for the Apple Magic Mouse multi-touch.
205
206 Say Y here if you want support for the multi-touch features of the
207 Apple Wireless "Magic" Mouse.
208
186config HID_MICROSOFT 209config HID_MICROSOFT
187 tristate "Microsoft" if EMBEDDED 210 tristate "Microsoft" if EMBEDDED
188 depends on USB_HID 211 depends on USB_HID
@@ -190,6 +213,12 @@ config HID_MICROSOFT
190 ---help--- 213 ---help---
191 Support for Microsoft devices that are not fully compliant with HID standard. 214 Support for Microsoft devices that are not fully compliant with HID standard.
192 215
216config HID_MOSART
217 tristate "MosArt"
218 depends on USB_HID
219 ---help---
220 Support for MosArt dual-touch panels.
221
193config HID_MONTEREY 222config HID_MONTEREY
194 tristate "Monterey" if EMBEDDED 223 tristate "Monterey" if EMBEDDED
195 depends on USB_HID 224 depends on USB_HID
@@ -198,12 +227,18 @@ config HID_MONTEREY
198 Support for Monterey Genius KB29E. 227 Support for Monterey Genius KB29E.
199 228
200config HID_NTRIG 229config HID_NTRIG
201 tristate "NTrig" if EMBEDDED 230 tristate "NTrig"
202 depends on USB_HID 231 depends on USB_HID
203 default !EMBEDDED
204 ---help--- 232 ---help---
205 Support for N-Trig touch screen. 233 Support for N-Trig touch screen.
206 234
235config HID_ORTEK
236 tristate "Ortek" if EMBEDDED
237 depends on USB_HID
238 default !EMBEDDED
239 ---help---
240 Support for Ortek WKB-2000 wireless keyboard + mouse trackpad.
241
207config HID_PANTHERLORD 242config HID_PANTHERLORD
208 tristate "Pantherlord support" if EMBEDDED 243 tristate "Pantherlord support" if EMBEDDED
209 depends on USB_HID 244 depends on USB_HID
@@ -227,6 +262,12 @@ config HID_PETALYNX
227 ---help--- 262 ---help---
228 Support for Petalynx Maxter remote control. 263 Support for Petalynx Maxter remote control.
229 264
265config HID_QUANTA
266 tristate "Quanta Optical Touch"
267 depends on USB_HID
268 ---help---
269 Support for Quanta Optical Touch dual-touch panels.
270
230config HID_SAMSUNG 271config HID_SAMSUNG
231 tristate "Samsung" if EMBEDDED 272 tristate "Samsung" if EMBEDDED
232 depends on USB_HID 273 depends on USB_HID
@@ -241,6 +282,12 @@ config HID_SONY
241 ---help--- 282 ---help---
242 Support for Sony PS3 controller. 283 Support for Sony PS3 controller.
243 284
285config HID_STANTUM
286 tristate "Stantum"
287 depends on USB_HID
288 ---help---
289 Support for Stantum multitouch panel.
290
244config HID_SUNPLUS 291config HID_SUNPLUS
245 tristate "Sunplus" if EMBEDDED 292 tristate "Sunplus" if EMBEDDED
246 depends on USB_HID 293 depends on USB_HID
@@ -305,9 +352,8 @@ config THRUSTMASTER_FF
305 Rumble Force or Force Feedback Wheel. 352 Rumble Force or Force Feedback Wheel.
306 353
307config HID_WACOM 354config HID_WACOM
308 tristate "Wacom Bluetooth devices support" if EMBEDDED 355 tristate "Wacom Bluetooth devices support"
309 depends on BT_HIDP 356 depends on BT_HIDP
310 default !EMBEDDED
311 ---help--- 357 ---help---
312 Support for Wacom Graphire Bluetooth tablet. 358 Support for Wacom Graphire Bluetooth tablet.
313 359
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 0de2dff5542c..0b2618f092ca 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -18,7 +18,11 @@ endif
18ifdef CONFIG_LOGIRUMBLEPAD2_FF 18ifdef CONFIG_LOGIRUMBLEPAD2_FF
19 hid-logitech-objs += hid-lg2ff.o 19 hid-logitech-objs += hid-lg2ff.o
20endif 20endif
21ifdef CONFIG_LOGIG940_FF
22 hid-logitech-objs += hid-lg3ff.o
23endif
21 24
25obj-$(CONFIG_HID_3M_PCT) += hid-3m-pct.o
22obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o 26obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
23obj-$(CONFIG_HID_APPLE) += hid-apple.o 27obj-$(CONFIG_HID_APPLE) += hid-apple.o
24obj-$(CONFIG_HID_BELKIN) += hid-belkin.o 28obj-$(CONFIG_HID_BELKIN) += hid-belkin.o
@@ -31,14 +35,19 @@ obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
31obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o 35obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o
32obj-$(CONFIG_HID_KYE) += hid-kye.o 36obj-$(CONFIG_HID_KYE) += hid-kye.o
33obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o 37obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o
38obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o
34obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o 39obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
35obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o 40obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o
41obj-$(CONFIG_HID_MOSART) += hid-mosart.o
36obj-$(CONFIG_HID_NTRIG) += hid-ntrig.o 42obj-$(CONFIG_HID_NTRIG) += hid-ntrig.o
43obj-$(CONFIG_HID_ORTEK) += hid-ortek.o
44obj-$(CONFIG_HID_QUANTA) += hid-quanta.o
37obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o 45obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o
38obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o 46obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
39obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o 47obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
40obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o 48obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o
41obj-$(CONFIG_HID_SONY) += hid-sony.o 49obj-$(CONFIG_HID_SONY) += hid-sony.o
50obj-$(CONFIG_HID_STANTUM) += hid-stantum.o
42obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o 51obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
43obj-$(CONFIG_HID_GREENASIA) += hid-gaff.o 52obj-$(CONFIG_HID_GREENASIA) += hid-gaff.o
44obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o 53obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o
diff --git a/drivers/hid/hid-3m-pct.c b/drivers/hid/hid-3m-pct.c
new file mode 100644
index 000000000000..c31e0be8ccea
--- /dev/null
+++ b/drivers/hid/hid-3m-pct.c
@@ -0,0 +1,291 @@
1/*
2 * HID driver for 3M PCT multitouch panels
3 *
4 * Copyright (c) 2009 Stephane Chatty <chatty@enac.fr>
5 *
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 */
14
15#include <linux/device.h>
16#include <linux/hid.h>
17#include <linux/module.h>
18#include <linux/slab.h>
19#include <linux/usb.h>
20
21MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
22MODULE_DESCRIPTION("3M PCT multitouch panels");
23MODULE_LICENSE("GPL");
24
25#include "hid-ids.h"
26
27struct mmm_finger {
28 __s32 x, y;
29 __u8 rank;
30 bool touch, valid;
31};
32
33struct mmm_data {
34 struct mmm_finger f[10];
35 __u8 curid, num;
36 bool touch, valid;
37};
38
39static int mmm_input_mapping(struct hid_device *hdev, struct hid_input *hi,
40 struct hid_field *field, struct hid_usage *usage,
41 unsigned long **bit, int *max)
42{
43 switch (usage->hid & HID_USAGE_PAGE) {
44
45 case HID_UP_BUTTON:
46 return -1;
47
48 case HID_UP_GENDESK:
49 switch (usage->hid) {
50 case HID_GD_X:
51 hid_map_usage(hi, usage, bit, max,
52 EV_ABS, ABS_MT_POSITION_X);
53 /* touchscreen emulation */
54 input_set_abs_params(hi->input, ABS_X,
55 field->logical_minimum,
56 field->logical_maximum, 0, 0);
57 return 1;
58 case HID_GD_Y:
59 hid_map_usage(hi, usage, bit, max,
60 EV_ABS, ABS_MT_POSITION_Y);
61 /* touchscreen emulation */
62 input_set_abs_params(hi->input, ABS_Y,
63 field->logical_minimum,
64 field->logical_maximum, 0, 0);
65 return 1;
66 }
67 return 0;
68
69 case HID_UP_DIGITIZER:
70 switch (usage->hid) {
71 /* we do not want to map these: no input-oriented meaning */
72 case 0x14:
73 case 0x23:
74 case HID_DG_INPUTMODE:
75 case HID_DG_DEVICEINDEX:
76 case HID_DG_CONTACTCOUNT:
77 case HID_DG_CONTACTMAX:
78 case HID_DG_INRANGE:
79 case HID_DG_CONFIDENCE:
80 return -1;
81 case HID_DG_TIPSWITCH:
82 /* touchscreen emulation */
83 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
84 return 1;
85 case HID_DG_CONTACTID:
86 hid_map_usage(hi, usage, bit, max,
87 EV_ABS, ABS_MT_TRACKING_ID);
88 return 1;
89 }
90 /* let hid-input decide for the others */
91 return 0;
92
93 case 0xff000000:
94 /* we do not want to map these: no input-oriented meaning */
95 return -1;
96 }
97
98 return 0;
99}
100
101static int mmm_input_mapped(struct hid_device *hdev, struct hid_input *hi,
102 struct hid_field *field, struct hid_usage *usage,
103 unsigned long **bit, int *max)
104{
105 if (usage->type == EV_KEY || usage->type == EV_ABS)
106 clear_bit(usage->code, *bit);
107
108 return 0;
109}
110
111/*
112 * this function is called when a whole packet has been received and processed,
113 * so that it can decide what to send to the input layer.
114 */
115static void mmm_filter_event(struct mmm_data *md, struct input_dev *input)
116{
117 struct mmm_finger *oldest = 0;
118 bool pressed = false, released = false;
119 int i;
120
121 /*
122 * we need to iterate on all fingers to decide if we have a press
123 * or a release event in our touchscreen emulation.
124 */
125 for (i = 0; i < 10; ++i) {
126 struct mmm_finger *f = &md->f[i];
127 if (!f->valid) {
128 /* this finger is just placeholder data, ignore */
129 } else if (f->touch) {
130 /* this finger is on the screen */
131 input_event(input, EV_ABS, ABS_MT_TRACKING_ID, i);
132 input_event(input, EV_ABS, ABS_MT_POSITION_X, f->x);
133 input_event(input, EV_ABS, ABS_MT_POSITION_Y, f->y);
134 input_mt_sync(input);
135 /*
136 * touchscreen emulation: maintain the age rank
137 * of this finger, decide if we have a press
138 */
139 if (f->rank == 0) {
140 f->rank = ++(md->num);
141 if (f->rank == 1)
142 pressed = true;
143 }
144 if (f->rank == 1)
145 oldest = f;
146 } else {
147 /* this finger took off the screen */
148 /* touchscreen emulation: maintain age rank of others */
149 int j;
150
151 for (j = 0; j < 10; ++j) {
152 struct mmm_finger *g = &md->f[j];
153 if (g->rank > f->rank) {
154 g->rank--;
155 if (g->rank == 1)
156 oldest = g;
157 }
158 }
159 f->rank = 0;
160 --(md->num);
161 if (md->num == 0)
162 released = true;
163 }
164 f->valid = 0;
165 }
166
167 /* touchscreen emulation */
168 if (oldest) {
169 if (pressed)
170 input_event(input, EV_KEY, BTN_TOUCH, 1);
171 input_event(input, EV_ABS, ABS_X, oldest->x);
172 input_event(input, EV_ABS, ABS_Y, oldest->y);
173 } else if (released) {
174 input_event(input, EV_KEY, BTN_TOUCH, 0);
175 }
176}
177
178/*
179 * this function is called upon all reports
180 * so that we can accumulate contact point information,
181 * and call input_mt_sync after each point.
182 */
183static int mmm_event(struct hid_device *hid, struct hid_field *field,
184 struct hid_usage *usage, __s32 value)
185{
186 struct mmm_data *md = hid_get_drvdata(hid);
187 /*
188 * strangely, this function can be called before
189 * field->hidinput is initialized!
190 */
191 if (hid->claimed & HID_CLAIMED_INPUT) {
192 struct input_dev *input = field->hidinput->input;
193 switch (usage->hid) {
194 case HID_DG_TIPSWITCH:
195 md->touch = value;
196 break;
197 case HID_DG_CONFIDENCE:
198 md->valid = value;
199 break;
200 case HID_DG_CONTACTID:
201 if (md->valid) {
202 md->curid = value;
203 md->f[value].touch = md->touch;
204 md->f[value].valid = 1;
205 }
206 break;
207 case HID_GD_X:
208 if (md->valid)
209 md->f[md->curid].x = value;
210 break;
211 case HID_GD_Y:
212 if (md->valid)
213 md->f[md->curid].y = value;
214 break;
215 case HID_DG_CONTACTCOUNT:
216 mmm_filter_event(md, input);
217 break;
218 }
219 }
220
221 /* we have handled the hidinput part, now remains hiddev */
222 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
223 hid->hiddev_hid_event(hid, field, usage, value);
224
225 return 1;
226}
227
228static int mmm_probe(struct hid_device *hdev, const struct hid_device_id *id)
229{
230 int ret;
231 struct mmm_data *md;
232
233 md = kzalloc(sizeof(struct mmm_data), GFP_KERNEL);
234 if (!md) {
235 dev_err(&hdev->dev, "cannot allocate 3M data\n");
236 return -ENOMEM;
237 }
238 hid_set_drvdata(hdev, md);
239
240 ret = hid_parse(hdev);
241 if (!ret)
242 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
243
244 if (ret)
245 kfree(md);
246 return ret;
247}
248
249static void mmm_remove(struct hid_device *hdev)
250{
251 hid_hw_stop(hdev);
252 kfree(hid_get_drvdata(hdev));
253 hid_set_drvdata(hdev, NULL);
254}
255
256static const struct hid_device_id mmm_devices[] = {
257 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) },
258 { }
259};
260MODULE_DEVICE_TABLE(hid, mmm_devices);
261
262static const struct hid_usage_id mmm_grabbed_usages[] = {
263 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
264 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
265};
266
267static struct hid_driver mmm_driver = {
268 .name = "3m-pct",
269 .id_table = mmm_devices,
270 .probe = mmm_probe,
271 .remove = mmm_remove,
272 .input_mapping = mmm_input_mapping,
273 .input_mapped = mmm_input_mapped,
274 .usage_table = mmm_grabbed_usages,
275 .event = mmm_event,
276};
277
278static int __init mmm_init(void)
279{
280 return hid_register_driver(&mmm_driver);
281}
282
283static void __exit mmm_exit(void)
284{
285 hid_unregister_driver(&mmm_driver);
286}
287
288module_init(mmm_init);
289module_exit(mmm_exit);
290MODULE_LICENSE("GPL");
291
diff --git a/drivers/hid/hid-a4tech.c b/drivers/hid/hid-a4tech.c
index df474c699fb8..3a2b223c1da4 100644
--- a/drivers/hid/hid-a4tech.c
+++ b/drivers/hid/hid-a4tech.c
@@ -20,6 +20,7 @@
20#include <linux/input.h> 20#include <linux/input.h>
21#include <linux/hid.h> 21#include <linux/hid.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h>
23 24
24#include "hid-ids.h" 25#include "hid-ids.h"
25 26
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 4b96e7a898cf..bba05d0a8980 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -19,6 +19,7 @@
19#include <linux/device.h> 19#include <linux/device.h>
20#include <linux/hid.h> 20#include <linux/hid.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22#include <linux/usb.h> 23#include <linux/usb.h>
23 24
24#include "hid-ids.h" 25#include "hid-ids.h"
@@ -40,6 +41,11 @@ module_param(fnmode, uint, 0644);
40MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, " 41MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
41 "[1] = fkeyslast, 2 = fkeysfirst)"); 42 "[1] = fkeyslast, 2 = fkeysfirst)");
42 43
44static unsigned int iso_layout = 1;
45module_param(iso_layout, uint, 0644);
46MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. "
47 "(0 = disabled, [1] = enabled)");
48
43struct apple_sc { 49struct apple_sc {
44 unsigned long quirks; 50 unsigned long quirks;
45 unsigned int fn_on; 51 unsigned int fn_on;
@@ -199,11 +205,13 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
199 } 205 }
200 } 206 }
201 207
202 if (asc->quirks & APPLE_ISO_KEYBOARD) { 208 if (iso_layout) {
203 trans = apple_find_translation(apple_iso_keyboard, usage->code); 209 if (asc->quirks & APPLE_ISO_KEYBOARD) {
204 if (trans) { 210 trans = apple_find_translation(apple_iso_keyboard, usage->code);
205 input_event(input, usage->type, trans->to, value); 211 if (trans) {
206 return 1; 212 input_event(input, usage->type, trans->to, value);
213 return 1;
214 }
207 } 215 }
208 } 216 }
209 217
@@ -431,6 +439,13 @@ static const struct hid_device_id apple_devices[] = {
431 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, 439 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
432 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), 440 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
433 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, 441 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
442 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
443 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
444 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
445 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
446 APPLE_ISO_KEYBOARD },
447 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
448 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
434 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY), 449 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
435 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 450 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
436 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), 451 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
diff --git a/drivers/hid/hid-cherry.c b/drivers/hid/hid-cherry.c
index 7e597d7f770f..24663a8717b1 100644
--- a/drivers/hid/hid-cherry.c
+++ b/drivers/hid/hid-cherry.c
@@ -59,6 +59,7 @@ static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
59 59
60static const struct hid_device_id ch_devices[] = { 60static const struct hid_device_id ch_devices[] = {
61 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 61 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
62 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) },
62 { } 63 { }
63}; 64};
64MODULE_DEVICE_TABLE(hid, ch_devices); 65MODULE_DEVICE_TABLE(hid, ch_devices);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 7d05c4bb201e..143e788b729b 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -4,7 +4,7 @@
4 * Copyright (c) 1999 Andreas Gal 4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina 7 * Copyright (c) 2006-2010 Jiri Kosina
8 */ 8 */
9 9
10/* 10/*
@@ -39,8 +39,6 @@
39 * Version Information 39 * Version Information
40 */ 40 */
41 41
42#define DRIVER_VERSION "v2.6"
43#define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik, Jiri Kosina"
44#define DRIVER_DESC "HID core driver" 42#define DRIVER_DESC "HID core driver"
45#define DRIVER_LICENSE "GPL" 43#define DRIVER_LICENSE "GPL"
46 44
@@ -53,7 +51,7 @@ EXPORT_SYMBOL_GPL(hid_debug);
53 * Register a new report for a device. 51 * Register a new report for a device.
54 */ 52 */
55 53
56static struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) 54struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id)
57{ 55{
58 struct hid_report_enum *report_enum = device->report_enum + type; 56 struct hid_report_enum *report_enum = device->report_enum + type;
59 struct hid_report *report; 57 struct hid_report *report;
@@ -77,6 +75,7 @@ static struct hid_report *hid_register_report(struct hid_device *device, unsigne
77 75
78 return report; 76 return report;
79} 77}
78EXPORT_SYMBOL_GPL(hid_register_report);
80 79
81/* 80/*
82 * Register a new field for this report. 81 * Register a new field for this report.
@@ -389,7 +388,8 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
389 __u32 data; 388 __u32 data;
390 unsigned n; 389 unsigned n;
391 390
392 if (item->size == 0) { 391 /* Local delimiter could have value 0, which allows size to be 0 */
392 if (item->size == 0 && item->tag != HID_LOCAL_ITEM_TAG_DELIMITER) {
393 dbg_hid("item data expected for local item\n"); 393 dbg_hid("item data expected for local item\n");
394 return -1; 394 return -1;
395 } 395 }
@@ -1043,13 +1043,8 @@ void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
1043 1043
1044 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) 1044 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
1045 hid->hiddev_report_event(hid, report); 1045 hid->hiddev_report_event(hid, report);
1046 if (hid->claimed & HID_CLAIMED_HIDRAW) { 1046 if (hid->claimed & HID_CLAIMED_HIDRAW)
1047 /* numbered reports need to be passed with the report num */ 1047 hidraw_report_event(hid, data, size);
1048 if (report_enum->numbered)
1049 hidraw_report_event(hid, data - 1, size + 1);
1050 else
1051 hidraw_report_event(hid, data, size);
1052 }
1053 1048
1054 for (a = 0; a < report->maxfield; a++) 1049 for (a = 0; a < report->maxfield; a++)
1055 hid_input_field(hid, report->field[a], cdata, interrupt); 1050 hid_input_field(hid, report->field[a], cdata, interrupt);
@@ -1250,11 +1245,13 @@ EXPORT_SYMBOL_GPL(hid_disconnect);
1250 1245
1251/* a list of devices for which there is a specialized driver on HID bus */ 1246/* a list of devices for which there is a specialized driver on HID bus */
1252static const struct hid_device_id hid_blacklist[] = { 1247static const struct hid_device_id hid_blacklist[] = {
1248 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) },
1253 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 1249 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
1254 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1250 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
1255 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, 1251 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) },
1256 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, 1252 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
1257 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, 1253 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) },
1254 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) },
1258 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 1255 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
1259 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 1256 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
1260 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 1257 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
@@ -1287,13 +1284,18 @@ static const struct hid_device_id hid_blacklist[] = {
1287 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1284 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
1288 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1285 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
1289 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 1286 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
1287 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
1288 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
1289 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
1290 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1290 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1291 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1291 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1292 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1292 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
1293 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 1293 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
1294 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) },
1294 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1295 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
1295 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 1296 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
1296 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, 1297 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) },
1298 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) },
1297 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, 1299 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
1298 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, 1300 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) },
1299 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 1301 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
@@ -1322,10 +1324,13 @@ static const struct hid_device_id hid_blacklist[] = {
1322 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, 1324 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) },
1323 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) }, 1325 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) },
1324 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, 1326 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) },
1327 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) },
1325 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) }, 1328 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) },
1326 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) }, 1329 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) },
1327 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) }, 1330 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) },
1328 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, 1331 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) },
1332 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) },
1333 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) },
1329 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, 1334 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
1330 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, 1335 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) },
1331 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, 1336 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
@@ -1333,16 +1338,22 @@ static const struct hid_device_id hid_blacklist[] = {
1333 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 1338 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
1334 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 1339 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
1335 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, 1340 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
1341 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },
1336 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 1342 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
1343 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
1344 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) },
1337 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1345 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
1338 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1346 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1347 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1339 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1348 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
1349 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) },
1340 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1350 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
1341 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1351 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
1342 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, 1352 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) },
1343 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, 1353 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) },
1344 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) }, 1354 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) },
1345 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, 1355 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
1356 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) },
1346 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, 1357 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
1347 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, 1358 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
1348 { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, 1359 { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) },
@@ -1539,8 +1550,9 @@ static const struct hid_device_id hid_ignore_list[] = {
1539 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, 1550 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
1540 { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, 1551 { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
1541 { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, 1552 { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
1542 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)}, 1553 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT)},
1543 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2)}, 1554 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)},
1555 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)},
1544 { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, 1556 { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },
1545 { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, 1557 { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) },
1546 { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, 1558 { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) },
@@ -1552,6 +1564,7 @@ static const struct hid_device_id hid_ignore_list[] = {
1552 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, 1564 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
1553 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 1565 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
1554 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 1566 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
1567 { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) },
1555 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, 1568 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) },
1556 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 1569 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) },
1557 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) }, 1570 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) },
@@ -1620,6 +1633,7 @@ static const struct hid_device_id hid_ignore_list[] = {
1620 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, 1633 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
1621 { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, 1634 { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) },
1622 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, 1635 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
1636 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) },
1623 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, 1637 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) },
1624 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, 1638 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) },
1625 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, 1639 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) },
@@ -1655,8 +1669,6 @@ static const struct hid_device_id hid_ignore_list[] = {
1655 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, 1669 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
1656 { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, 1670 { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) },
1657 { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, 1671 { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
1658 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) },
1659 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) },
1660 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, 1672 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
1661 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 1673 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
1662 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 1674 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
@@ -1918,5 +1930,8 @@ static void __exit hid_exit(void)
1918module_init(hid_init); 1930module_init(hid_init);
1919module_exit(hid_exit); 1931module_exit(hid_exit);
1920 1932
1933MODULE_AUTHOR("Andreas Gal");
1934MODULE_AUTHOR("Vojtech Pavlik");
1935MODULE_AUTHOR("Jiri Kosina");
1921MODULE_LICENSE(DRIVER_LICENSE); 1936MODULE_LICENSE(DRIVER_LICENSE);
1922 1937
diff --git a/drivers/hid/hid-cypress.c b/drivers/hid/hid-cypress.c
index 62e9cb10e88c..998b6f443d7d 100644
--- a/drivers/hid/hid-cypress.c
+++ b/drivers/hid/hid-cypress.c
@@ -126,6 +126,8 @@ static const struct hid_device_id cp_devices[] = {
126 .driver_data = CP_RDESC_SWAPPED_MIN_MAX }, 126 .driver_data = CP_RDESC_SWAPPED_MIN_MAX },
127 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2), 127 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2),
128 .driver_data = CP_RDESC_SWAPPED_MIN_MAX }, 128 .driver_data = CP_RDESC_SWAPPED_MIN_MAX },
129 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3),
130 .driver_data = CP_RDESC_SWAPPED_MIN_MAX },
129 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE), 131 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE),
130 .driver_data = CP_2WHEEL_MOUSE_HACK }, 132 .driver_data = CP_2WHEEL_MOUSE_HACK },
131 { } 133 { }
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 6abd0369aedb..56f314fbd4f9 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -29,6 +29,7 @@
29#include <linux/debugfs.h> 29#include <linux/debugfs.h>
30#include <linux/seq_file.h> 30#include <linux/seq_file.h>
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/slab.h>
32#include <linux/uaccess.h> 33#include <linux/uaccess.h>
33#include <linux/poll.h> 34#include <linux/poll.h>
34 35
@@ -564,10 +565,10 @@ void hid_debug_event(struct hid_device *hdev, char *buf)
564 struct hid_debug_list *list; 565 struct hid_debug_list *list;
565 566
566 list_for_each_entry(list, &hdev->debug_list, node) { 567 list_for_each_entry(list, &hdev->debug_list, node) {
567 for (i = 0; i <= strlen(buf); i++) 568 for (i = 0; i < strlen(buf); i++)
568 list->hid_debug_buf[(list->tail + i) % (HID_DEBUG_BUFSIZE - 1)] = 569 list->hid_debug_buf[(list->tail + i) % HID_DEBUG_BUFSIZE] =
569 buf[i]; 570 buf[i];
570 list->tail = (list->tail + i) % (HID_DEBUG_BUFSIZE - 1); 571 list->tail = (list->tail + i) % HID_DEBUG_BUFSIZE;
571 } 572 }
572} 573}
573EXPORT_SYMBOL_GPL(hid_debug_event); 574EXPORT_SYMBOL_GPL(hid_debug_event);
@@ -864,13 +865,13 @@ static const char **names[EV_MAX + 1] = {
864 [EV_SND] = sounds, [EV_REP] = repeats, 865 [EV_SND] = sounds, [EV_REP] = repeats,
865}; 866};
866 867
867void hid_resolv_event(__u8 type, __u16 code, struct seq_file *f) { 868static void hid_resolv_event(__u8 type, __u16 code, struct seq_file *f)
868 869{
869 seq_printf(f, "%s.%s", events[type] ? events[type] : "?", 870 seq_printf(f, "%s.%s", events[type] ? events[type] : "?",
870 names[type] ? (names[type][code] ? names[type][code] : "?") : "?"); 871 names[type] ? (names[type][code] ? names[type][code] : "?") : "?");
871} 872}
872 873
873void hid_dump_input_mapping(struct hid_device *hid, struct seq_file *f) 874static void hid_dump_input_mapping(struct hid_device *hid, struct seq_file *f)
874{ 875{
875 int i, j, k; 876 int i, j, k;
876 struct hid_report *report; 877 struct hid_report *report;
diff --git a/drivers/hid/hid-drff.c b/drivers/hid/hid-drff.c
index a239d20ad7a5..968b04f9b796 100644
--- a/drivers/hid/hid-drff.c
+++ b/drivers/hid/hid-drff.c
@@ -28,6 +28,7 @@
28 */ 28 */
29 29
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/slab.h>
31#include <linux/usb.h> 32#include <linux/usb.h>
32#include <linux/hid.h> 33#include <linux/hid.h>
33 34
diff --git a/drivers/hid/hid-gaff.c b/drivers/hid/hid-gaff.c
index 8a11ccddaf2e..88dfcf49a5d7 100644
--- a/drivers/hid/hid-gaff.c
+++ b/drivers/hid/hid-gaff.c
@@ -28,6 +28,7 @@
28 */ 28 */
29 29
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/slab.h>
31#include <linux/usb.h> 32#include <linux/usb.h>
32#include <linux/hid.h> 33#include <linux/hid.h>
33#include "hid-ids.h" 34#include "hid-ids.h"
diff --git a/drivers/hid/hid-gyration.c b/drivers/hid/hid-gyration.c
index cab13e8c7d29..62416e6baeca 100644
--- a/drivers/hid/hid-gyration.c
+++ b/drivers/hid/hid-gyration.c
@@ -53,10 +53,13 @@ static int gyration_input_mapping(struct hid_device *hdev, struct hid_input *hi,
53static int gyration_event(struct hid_device *hdev, struct hid_field *field, 53static int gyration_event(struct hid_device *hdev, struct hid_field *field,
54 struct hid_usage *usage, __s32 value) 54 struct hid_usage *usage, __s32 value)
55{ 55{
56 struct input_dev *input = field->hidinput->input; 56
57 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput)
58 return 0;
57 59
58 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK && 60 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK &&
59 (usage->hid & 0xff) == 0x82) { 61 (usage->hid & 0xff) == 0x82) {
62 struct input_dev *input = field->hidinput->input;
60 input_event(input, usage->type, usage->code, 1); 63 input_event(input, usage->type, usage->code, 1);
61 input_sync(input); 64 input_sync(input);
62 input_event(input, usage->type, usage->code, 0); 65 input_event(input, usage->type, usage->code, 0);
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index adbef5d069c4..09d27649a0f7 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -18,6 +18,9 @@
18#ifndef HID_IDS_H_FILE 18#ifndef HID_IDS_H_FILE
19#define HID_IDS_H_FILE 19#define HID_IDS_H_FILE
20 20
21#define USB_VENDOR_ID_3M 0x0596
22#define USB_DEVICE_ID_3M1968 0x0500
23
21#define USB_VENDOR_ID_A4TECH 0x09da 24#define USB_VENDOR_ID_A4TECH 0x09da
22#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 25#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006
23#define USB_DEVICE_ID_A4TECH_X5_005D 0x000a 26#define USB_DEVICE_ID_A4TECH_X5_005D 0x000a
@@ -56,6 +59,7 @@
56 59
57#define USB_VENDOR_ID_APPLE 0x05ac 60#define USB_VENDOR_ID_APPLE 0x05ac
58#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304 61#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304
62#define USB_DEVICE_ID_APPLE_MAGICMOUSE 0x030d
59#define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e 63#define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e
60#define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f 64#define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f
61#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214 65#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
@@ -88,14 +92,20 @@
88#define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 92#define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236
89#define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 93#define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237
90#define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 94#define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238
95#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239
96#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a
97#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b
91#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a 98#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
92#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b 99#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
93#define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241 100#define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241
94#define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242 101#define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242
95 102
96#define USB_VENDOR_ID_ASUS 0x0b05 103#define USB_VENDOR_ID_ASUS 0x0486
97#define USB_DEVICE_ID_ASUS_LCM 0x1726 104#define USB_DEVICE_ID_ASUS_T91MT 0x0185
98#define USB_DEVICE_ID_ASUS_LCM2 0x175b 105
106#define USB_VENDOR_ID_ASUSTEK 0x0b05
107#define USB_DEVICE_ID_ASUSTEK_LCM 0x1726
108#define USB_DEVICE_ID_ASUSTEK_LCM2 0x175b
99 109
100#define USB_VENDOR_ID_ATEN 0x0557 110#define USB_VENDOR_ID_ATEN 0x0557
101#define USB_DEVICE_ID_ATEN_UC100KM 0x2004 111#define USB_DEVICE_ID_ATEN_UC100KM 0x2004
@@ -117,9 +127,11 @@
117#define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2 127#define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2
118#define USB_DEVICE_ID_CH_COMBATSTICK 0x00f4 128#define USB_DEVICE_ID_CH_COMBATSTICK 0x00f4
119#define USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE 0x00ff 129#define USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE 0x00ff
130#define USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK 0x00d3
120 131
121#define USB_VENDOR_ID_CHERRY 0x046a 132#define USB_VENDOR_ID_CHERRY 0x046a
122#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 133#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
134#define USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR 0x0027
123 135
124#define USB_VENDOR_ID_CHIC 0x05fe 136#define USB_VENDOR_ID_CHIC 0x05fe
125#define USB_DEVICE_ID_CHIC_GAMEPAD 0x0014 137#define USB_DEVICE_ID_CHIC_GAMEPAD 0x0014
@@ -145,6 +157,7 @@
145#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 157#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417
146#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61 158#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61
147#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64 159#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64
160#define USB_DEVICE_ID_CYPRESS_BARCODE_3 0xbca1
148 161
149#define USB_VENDOR_ID_DEALEXTREAME 0x10c5 162#define USB_VENDOR_ID_DEALEXTREAME 0x10c5
150#define USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701 0x819a 163#define USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701 0x819a
@@ -164,6 +177,12 @@
164#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f 177#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f
165#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100 178#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100
166 179
180#define USB_VENDOR_ID_ETURBOTOUCH 0x22b9
181#define USB_DEVICE_ID_ETURBOTOUCH 0x0006
182
183#define USB_VENDOR_ID_ETT 0x0664
184#define USB_DEVICE_ID_TC5UH 0x0309
185
167#define USB_VENDOR_ID_EZKEY 0x0518 186#define USB_VENDOR_ID_EZKEY 0x0518
168#define USB_DEVICE_ID_BTC_8193 0x0002 187#define USB_DEVICE_ID_BTC_8193 0x0002
169 188
@@ -295,6 +314,7 @@
295#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2 0xc219 314#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2 0xc219
296#define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283 315#define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283
297#define USB_DEVICE_ID_LOGITECH_FORCE3D_PRO 0xc286 316#define USB_DEVICE_ID_LOGITECH_FORCE3D_PRO 0xc286
317#define USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940 0xc287
298#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294 318#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294
299#define USB_DEVICE_ID_LOGITECH_WINGMAN_FFG 0xc293 319#define USB_DEVICE_ID_LOGITECH_WINGMAN_FFG 0xc293
300#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295 320#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295
@@ -304,6 +324,8 @@
304#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 324#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517
305#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512 325#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512
306#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513 326#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513
327#define USB_DEVICE_ID_SPACETRAVELLER 0xc623
328#define USB_DEVICE_ID_SPACENAVIGATOR 0xc626
307#define USB_DEVICE_ID_DINOVO_DESKTOP 0xc704 329#define USB_DEVICE_ID_DINOVO_DESKTOP 0xc704
308#define USB_DEVICE_ID_DINOVO_EDGE 0xc714 330#define USB_DEVICE_ID_DINOVO_EDGE 0xc714
309#define USB_DEVICE_ID_DINOVO_MINI 0xc71f 331#define USB_DEVICE_ID_DINOVO_MINI 0xc71f
@@ -346,12 +368,18 @@
346#define USB_VENDOR_ID_NEC 0x073e 368#define USB_VENDOR_ID_NEC 0x073e
347#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301 369#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301
348 370
371#define USB_VENDOR_ID_NEXTWINDOW 0x1926
372#define USB_DEVICE_ID_NEXTWINDOW_TOUCHSCREEN 0x0003
373
349#define USB_VENDOR_ID_NTRIG 0x1b96 374#define USB_VENDOR_ID_NTRIG 0x1b96
350#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001 375#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001
351 376
352#define USB_VENDOR_ID_ONTRAK 0x0a07 377#define USB_VENDOR_ID_ONTRAK 0x0a07
353#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064 378#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064
354 379
380#define USB_VENDOR_ID_ORTEK 0x05a4
381#define USB_DEVICE_ID_ORTEK_WKB2000 0x2000
382
355#define USB_VENDOR_ID_PANJIT 0x134c 383#define USB_VENDOR_ID_PANJIT 0x134c
356 384
357#define USB_VENDOR_ID_PANTHERLORD 0x0810 385#define USB_VENDOR_ID_PANTHERLORD 0x0810
@@ -369,9 +397,16 @@
369#define USB_VENDOR_ID_POWERCOM 0x0d9f 397#define USB_VENDOR_ID_POWERCOM 0x0d9f
370#define USB_DEVICE_ID_POWERCOM_UPS 0x0002 398#define USB_DEVICE_ID_POWERCOM_UPS 0x0002
371 399
400#define USB_VENDOR_ID_PRODIGE 0x05af
401#define USB_DEVICE_ID_PRODIGE_CORDLESS 0x3062
402
372#define USB_VENDOR_ID_SAITEK 0x06a3 403#define USB_VENDOR_ID_SAITEK 0x06a3
373#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17 404#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17
374 405
406#define USB_VENDOR_ID_QUANTA 0x0408
407#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH 0x3000
408#define USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN 0x3001
409
375#define USB_VENDOR_ID_SAMSUNG 0x0419 410#define USB_VENDOR_ID_SAMSUNG 0x0419
376#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001 411#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001
377 412
@@ -383,18 +418,20 @@
383#define USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST 0x0034 418#define USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST 0x0034
384#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST 0x0046 419#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST 0x0046
385 420
421#define USB_VENDOR_ID_STANTUM 0x1f87
422#define USB_DEVICE_ID_MTP 0x0002
423
386#define USB_VENDOR_ID_SUN 0x0430 424#define USB_VENDOR_ID_SUN 0x0430
387#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab 425#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab
388 426
389#define USB_VENDOR_ID_SUNPLUS 0x04fc 427#define USB_VENDOR_ID_SUNPLUS 0x04fc
390#define USB_DEVICE_ID_SUNPLUS_WDESKTOP 0x05d8 428#define USB_DEVICE_ID_SUNPLUS_WDESKTOP 0x05d8
391 429
392#define USB_VENDOR_ID_TENX 0x1130
393#define USB_DEVICE_ID_TENX_IBUDDY1 0x0001
394#define USB_DEVICE_ID_TENX_IBUDDY2 0x0002
395
396#define USB_VENDOR_ID_THRUSTMASTER 0x044f 430#define USB_VENDOR_ID_THRUSTMASTER 0x044f
397 431
432#define USB_VENDOR_ID_TOUCHPACK 0x1bfd
433#define USB_DEVICE_ID_TOUCHPACK_RTS 0x1688
434
398#define USB_VENDOR_ID_TOPMAX 0x0663 435#define USB_VENDOR_ID_TOPMAX 0x0663
399#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103 436#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103
400 437
@@ -409,6 +446,7 @@
409 446
410#define USB_VENDOR_ID_UCLOGIC 0x5543 447#define USB_VENDOR_ID_UCLOGIC 0x5543
411#define USB_DEVICE_ID_UCLOGIC_TABLET_PF1209 0x0042 448#define USB_DEVICE_ID_UCLOGIC_TABLET_PF1209 0x0042
449#define USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U 0x0003
412 450
413#define USB_VENDOR_ID_VERNIER 0x08f7 451#define USB_VENDOR_ID_VERNIER 0x08f7
414#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001 452#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 5862b0f3b55d..7a0d2e4661a1 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Vojtech Pavlik 2 * Copyright (c) 2000-2001 Vojtech Pavlik
3 * Copyright (c) 2006-2007 Jiri Kosina 3 * Copyright (c) 2006-2010 Jiri Kosina
4 * 4 *
5 * HID to Linux Input mapping 5 * HID to Linux Input mapping
6 */ 6 */
@@ -68,22 +68,25 @@ static const struct {
68#define map_key_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \ 68#define map_key_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \
69 &max, EV_KEY, (c)) 69 &max, EV_KEY, (c))
70 70
71static inline int match_scancode(int code, int scancode) 71static inline int match_scancode(unsigned int code, unsigned int scancode)
72{ 72{
73 if (scancode == 0) 73 if (scancode == 0)
74 return 1; 74 return 1;
75 return ((code & (HID_USAGE_PAGE | HID_USAGE)) == scancode); 75
76 return (code & (HID_USAGE_PAGE | HID_USAGE)) == scancode;
76} 77}
77 78
78static inline int match_keycode(int code, int keycode) 79static inline int match_keycode(unsigned int code, unsigned int keycode)
79{ 80{
80 if (keycode == 0) 81 if (keycode == 0)
81 return 1; 82 return 1;
82 return (code == keycode); 83
84 return code == keycode;
83} 85}
84 86
85static struct hid_usage *hidinput_find_key(struct hid_device *hid, 87static struct hid_usage *hidinput_find_key(struct hid_device *hid,
86 int scancode, int keycode) 88 unsigned int scancode,
89 unsigned int keycode)
87{ 90{
88 int i, j, k; 91 int i, j, k;
89 struct hid_report *report; 92 struct hid_report *report;
@@ -105,8 +108,8 @@ static struct hid_usage *hidinput_find_key(struct hid_device *hid,
105 return NULL; 108 return NULL;
106} 109}
107 110
108static int hidinput_getkeycode(struct input_dev *dev, int scancode, 111static int hidinput_getkeycode(struct input_dev *dev,
109 int *keycode) 112 unsigned int scancode, unsigned int *keycode)
110{ 113{
111 struct hid_device *hid = input_get_drvdata(dev); 114 struct hid_device *hid = input_get_drvdata(dev);
112 struct hid_usage *usage; 115 struct hid_usage *usage;
@@ -119,16 +122,13 @@ static int hidinput_getkeycode(struct input_dev *dev, int scancode,
119 return -EINVAL; 122 return -EINVAL;
120} 123}
121 124
122static int hidinput_setkeycode(struct input_dev *dev, int scancode, 125static int hidinput_setkeycode(struct input_dev *dev,
123 int keycode) 126 unsigned int scancode, unsigned int keycode)
124{ 127{
125 struct hid_device *hid = input_get_drvdata(dev); 128 struct hid_device *hid = input_get_drvdata(dev);
126 struct hid_usage *usage; 129 struct hid_usage *usage;
127 int old_keycode; 130 int old_keycode;
128 131
129 if (keycode < 0 || keycode > KEY_MAX)
130 return -EINVAL;
131
132 usage = hidinput_find_key(hid, scancode, 0); 132 usage = hidinput_find_key(hid, scancode, 0);
133 if (usage) { 133 if (usage) {
134 old_keycode = usage->code; 134 old_keycode = usage->code;
@@ -193,12 +193,17 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
193 break; 193 break;
194 194
195 case HID_UP_BUTTON: 195 case HID_UP_BUTTON:
196 code = ((usage->hid - 1) & 0xf); 196 code = ((usage->hid - 1) & HID_USAGE);
197 197
198 switch (field->application) { 198 switch (field->application) {
199 case HID_GD_MOUSE: 199 case HID_GD_MOUSE:
200 case HID_GD_POINTER: code += 0x110; break; 200 case HID_GD_POINTER: code += 0x110; break;
201 case HID_GD_JOYSTICK: code += 0x120; break; 201 case HID_GD_JOYSTICK:
202 if (code <= 0xf)
203 code += BTN_JOYSTICK;
204 else
205 code += BTN_TRIGGER_HAPPY;
206 break;
202 case HID_GD_GAMEPAD: code += 0x130; break; 207 case HID_GD_GAMEPAD: code += 0x130; break;
203 default: 208 default:
204 switch (field->physical) { 209 switch (field->physical) {
@@ -400,6 +405,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
400 case 0x192: map_key_clear(KEY_CALC); break; 405 case 0x192: map_key_clear(KEY_CALC); break;
401 case 0x194: map_key_clear(KEY_FILE); break; 406 case 0x194: map_key_clear(KEY_FILE); break;
402 case 0x196: map_key_clear(KEY_WWW); break; 407 case 0x196: map_key_clear(KEY_WWW); break;
408 case 0x199: map_key_clear(KEY_CHAT); break;
403 case 0x19c: map_key_clear(KEY_LOGOFF); break; 409 case 0x19c: map_key_clear(KEY_LOGOFF); break;
404 case 0x19e: map_key_clear(KEY_COFFEE); break; 410 case 0x19e: map_key_clear(KEY_COFFEE); break;
405 case 0x1a6: map_key_clear(KEY_HELP); break; 411 case 0x1a6: map_key_clear(KEY_HELP); break;
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index 0f870a3243ed..3677c9037a11 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -33,6 +33,8 @@
33#define LG_NOGET 0x100 33#define LG_NOGET 0x100
34#define LG_FF 0x200 34#define LG_FF 0x200
35#define LG_FF2 0x400 35#define LG_FF2 0x400
36#define LG_RDESC_REL_ABS 0x800
37#define LG_FF3 0x1000
36 38
37/* 39/*
38 * Certain Logitech keyboards send in report #3 keys which are far 40 * Certain Logitech keyboards send in report #3 keys which are far
@@ -51,6 +53,13 @@ static void lg_report_fixup(struct hid_device *hdev, __u8 *rdesc,
51 rdesc[84] = rdesc[89] = 0x4d; 53 rdesc[84] = rdesc[89] = 0x4d;
52 rdesc[85] = rdesc[90] = 0x10; 54 rdesc[85] = rdesc[90] = 0x10;
53 } 55 }
56 if ((quirks & LG_RDESC_REL_ABS) && rsize >= 50 &&
57 rdesc[32] == 0x81 && rdesc[33] == 0x06 &&
58 rdesc[49] == 0x81 && rdesc[50] == 0x06) {
59 dev_info(&hdev->dev, "fixing up rel/abs in Logitech "
60 "report descriptor\n");
61 rdesc[33] = rdesc[50] = 0x02;
62 }
54} 63}
55 64
56#define lg_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \ 65#define lg_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
@@ -89,6 +98,22 @@ static int lg_ultrax_remote_mapping(struct hid_input *hi,
89 return 1; 98 return 1;
90} 99}
91 100
101static int lg_dinovo_mapping(struct hid_input *hi, struct hid_usage *usage,
102 unsigned long **bit, int *max)
103{
104 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR)
105 return 0;
106
107 switch (usage->hid & HID_USAGE) {
108
109 case 0x00d: lg_map_key_clear(KEY_MEDIA); break;
110 default:
111 return 0;
112
113 }
114 return 1;
115}
116
92static int lg_wireless_mapping(struct hid_input *hi, struct hid_usage *usage, 117static int lg_wireless_mapping(struct hid_input *hi, struct hid_usage *usage,
93 unsigned long **bit, int *max) 118 unsigned long **bit, int *max)
94{ 119{
@@ -164,6 +189,10 @@ static int lg_input_mapping(struct hid_device *hdev, struct hid_input *hi,
164 lg_ultrax_remote_mapping(hi, usage, bit, max)) 189 lg_ultrax_remote_mapping(hi, usage, bit, max))
165 return 1; 190 return 1;
166 191
192 if (hdev->product == USB_DEVICE_ID_DINOVO_MINI &&
193 lg_dinovo_mapping(hi, usage, bit, max))
194 return 1;
195
167 if ((quirks & LG_WIRELESS) && lg_wireless_mapping(hi, usage, bit, max)) 196 if ((quirks & LG_WIRELESS) && lg_wireless_mapping(hi, usage, bit, max))
168 return 1; 197 return 1;
169 198
@@ -238,7 +267,7 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
238 goto err_free; 267 goto err_free;
239 } 268 }
240 269
241 if (quirks & (LG_FF | LG_FF2)) 270 if (quirks & (LG_FF | LG_FF2 | LG_FF3))
242 connect_mask &= ~HID_CONNECT_FF; 271 connect_mask &= ~HID_CONNECT_FF;
243 272
244 ret = hid_hw_start(hdev, connect_mask); 273 ret = hid_hw_start(hdev, connect_mask);
@@ -251,6 +280,8 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
251 lgff_init(hdev); 280 lgff_init(hdev);
252 if (quirks & LG_FF2) 281 if (quirks & LG_FF2)
253 lg2ff_init(hdev); 282 lg2ff_init(hdev);
283 if (quirks & LG_FF3)
284 lg3ff_init(hdev);
254 285
255 return 0; 286 return 0;
256err_free: 287err_free:
@@ -303,8 +334,15 @@ static const struct hid_device_id lg_devices[] = {
303 .driver_data = LG_FF }, 334 .driver_data = LG_FF },
304 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2), 335 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2),
305 .driver_data = LG_FF2 }, 336 .driver_data = LG_FF2 },
337 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940),
338 .driver_data = LG_FF3 },
339 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR),
340 .driver_data = LG_RDESC_REL_ABS },
341 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER),
342 .driver_data = LG_RDESC_REL_ABS },
306 { } 343 { }
307}; 344};
345
308MODULE_DEVICE_TABLE(hid, lg_devices); 346MODULE_DEVICE_TABLE(hid, lg_devices);
309 347
310static struct hid_driver lg_driver = { 348static struct hid_driver lg_driver = {
diff --git a/drivers/hid/hid-lg.h b/drivers/hid/hid-lg.h
index 27ae750ca878..ce2ac8672624 100644
--- a/drivers/hid/hid-lg.h
+++ b/drivers/hid/hid-lg.h
@@ -1,8 +1,6 @@
1#ifndef __HID_LG_H 1#ifndef __HID_LG_H
2#define __HID_LG_H 2#define __HID_LG_H
3 3
4#include <linux/autoconf.h>
5
6#ifdef CONFIG_LOGITECH_FF 4#ifdef CONFIG_LOGITECH_FF
7int lgff_init(struct hid_device *hdev); 5int lgff_init(struct hid_device *hdev);
8#else 6#else
@@ -15,4 +13,10 @@ int lg2ff_init(struct hid_device *hdev);
15static inline int lg2ff_init(struct hid_device *hdev) { return -1; } 13static inline int lg2ff_init(struct hid_device *hdev) { return -1; }
16#endif 14#endif
17 15
16#ifdef CONFIG_LOGIG940_FF
17int lg3ff_init(struct hid_device *hdev);
18#else
19static inline int lg3ff_init(struct hid_device *hdev) { return -1; }
20#endif
21
18#endif 22#endif
diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c
index 4e6dc6e26523..d888f1e6794f 100644
--- a/drivers/hid/hid-lg2ff.c
+++ b/drivers/hid/hid-lg2ff.c
@@ -22,6 +22,7 @@
22 22
23 23
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/slab.h>
25#include <linux/usb.h> 26#include <linux/usb.h>
26#include <linux/hid.h> 27#include <linux/hid.h>
27 28
diff --git a/drivers/hid/hid-lg3ff.c b/drivers/hid/hid-lg3ff.c
new file mode 100644
index 000000000000..4002832ee4af
--- /dev/null
+++ b/drivers/hid/hid-lg3ff.c
@@ -0,0 +1,176 @@
1/*
2 * Force feedback support for Logitech Flight System G940
3 *
4 * Copyright (c) 2009 Gary Stein <LordCnidarian@gmail.com>
5 */
6
7/*
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23
24#include <linux/input.h>
25#include <linux/usb.h>
26#include <linux/hid.h>
27
28#include "usbhid/usbhid.h"
29#include "hid-lg.h"
30
31/*
32 * G940 Theory of Operation (from experimentation)
33 *
34 * There are 63 fields (only 3 of them currently used)
35 * 0 - seems to be command field
36 * 1 - 30 deal with the x axis
37 * 31 -60 deal with the y axis
38 *
39 * Field 1 is x axis constant force
40 * Field 31 is y axis constant force
41 *
42 * other interesting fields 1,2,3,4 on x axis
43 * (same for 31,32,33,34 on y axis)
44 *
45 * 0 0 127 127 makes the joystick autocenter hard
46 *
47 * 127 0 127 127 makes the joystick loose on the right,
48 * but stops all movemnt left
49 *
50 * -127 0 -127 -127 makes the joystick loose on the left,
51 * but stops all movement right
52 *
53 * 0 0 -127 -127 makes the joystick rattle very hard
54 *
55 * I'm sure these are effects that I don't know enough about them
56 */
57
58struct lg3ff_device {
59 struct hid_report *report;
60};
61
62static int hid_lg3ff_play(struct input_dev *dev, void *data,
63 struct ff_effect *effect)
64{
65 struct hid_device *hid = input_get_drvdata(dev);
66 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
67 struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
68 int x, y;
69
70/*
71 * Maxusage should always be 63 (maximum fields)
72 * likely a better way to ensure this data is clean
73 */
74 memset(report->field[0]->value, 0, sizeof(__s32)*report->field[0]->maxusage);
75
76 switch (effect->type) {
77 case FF_CONSTANT:
78/*
79 * Already clamped in ff_memless
80 * 0 is center (different then other logitech)
81 */
82 x = effect->u.ramp.start_level;
83 y = effect->u.ramp.end_level;
84
85 /* send command byte */
86 report->field[0]->value[0] = 0x51;
87
88/*
89 * Sign backwards from other Force3d pro
90 * which get recast here in two's complement 8 bits
91 */
92 report->field[0]->value[1] = (unsigned char)(-x);
93 report->field[0]->value[31] = (unsigned char)(-y);
94
95 usbhid_submit_report(hid, report, USB_DIR_OUT);
96 break;
97 }
98 return 0;
99}
100static void hid_lg3ff_set_autocenter(struct input_dev *dev, u16 magnitude)
101{
102 struct hid_device *hid = input_get_drvdata(dev);
103 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
104 struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
105
106/*
107 * Auto Centering probed from device
108 * NOTE: deadman's switch on G940 must be covered
109 * for effects to work
110 */
111 report->field[0]->value[0] = 0x51;
112 report->field[0]->value[1] = 0x00;
113 report->field[0]->value[2] = 0x00;
114 report->field[0]->value[3] = 0x7F;
115 report->field[0]->value[4] = 0x7F;
116 report->field[0]->value[31] = 0x00;
117 report->field[0]->value[32] = 0x00;
118 report->field[0]->value[33] = 0x7F;
119 report->field[0]->value[34] = 0x7F;
120
121 usbhid_submit_report(hid, report, USB_DIR_OUT);
122}
123
124
125static const signed short ff3_joystick_ac[] = {
126 FF_CONSTANT,
127 FF_AUTOCENTER,
128 -1
129};
130
131int lg3ff_init(struct hid_device *hid)
132{
133 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
134 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
135 struct input_dev *dev = hidinput->input;
136 struct hid_report *report;
137 struct hid_field *field;
138 const signed short *ff_bits = ff3_joystick_ac;
139 int error;
140 int i;
141
142 /* Find the report to use */
143 if (list_empty(report_list)) {
144 err_hid("No output report found");
145 return -1;
146 }
147
148 /* Check that the report looks ok */
149 report = list_entry(report_list->next, struct hid_report, list);
150 if (!report) {
151 err_hid("NULL output report");
152 return -1;
153 }
154
155 field = report->field[0];
156 if (!field) {
157 err_hid("NULL field");
158 return -1;
159 }
160
161 /* Assume single fixed device G940 */
162 for (i = 0; ff_bits[i] >= 0; i++)
163 set_bit(ff_bits[i], dev->ffbit);
164
165 error = input_ff_create_memless(dev, NULL, hid_lg3ff_play);
166 if (error)
167 return error;
168
169 if (test_bit(FF_AUTOCENTER, dev->ffbit))
170 dev->ff->set_autocenter = hid_lg3ff_set_autocenter;
171
172 dev_info(&hid->dev, "Force feedback for Logitech Flight System G940 by "
173 "Gary Stein <LordCnidarian@gmail.com>\n");
174 return 0;
175}
176
diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c
index 987abebe0829..61142b76a9b1 100644
--- a/drivers/hid/hid-lgff.c
+++ b/drivers/hid/hid-lgff.c
@@ -67,6 +67,7 @@ static const struct dev_type devices[] = {
67 { 0x046d, 0xc219, ff_rumble }, 67 { 0x046d, 0xc219, ff_rumble },
68 { 0x046d, 0xc283, ff_joystick }, 68 { 0x046d, 0xc283, ff_joystick },
69 { 0x046d, 0xc286, ff_joystick_ac }, 69 { 0x046d, 0xc286, ff_joystick_ac },
70 { 0x046d, 0xc287, ff_joystick_ac },
70 { 0x046d, 0xc293, ff_joystick }, 71 { 0x046d, 0xc293, ff_joystick },
71 { 0x046d, 0xc294, ff_wheel }, 72 { 0x046d, 0xc294, ff_wheel },
72 { 0x046d, 0xc295, ff_joystick }, 73 { 0x046d, 0xc295, ff_joystick },
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
new file mode 100644
index 000000000000..0d471fc2ab82
--- /dev/null
+++ b/drivers/hid/hid-magicmouse.c
@@ -0,0 +1,453 @@
1/*
2 * Apple "Magic" Wireless Mouse driver
3 *
4 * Copyright (c) 2010 Michael Poole <mdpoole@troilus.org>
5 */
6
7/*
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 */
13
14#include <linux/device.h>
15#include <linux/hid.h>
16#include <linux/module.h>
17#include <linux/slab.h>
18#include <linux/usb.h>
19
20#include "hid-ids.h"
21
22static bool emulate_3button = true;
23module_param(emulate_3button, bool, 0644);
24MODULE_PARM_DESC(emulate_3button, "Emulate a middle button");
25
26static int middle_button_start = -350;
27static int middle_button_stop = +350;
28
29static bool emulate_scroll_wheel = true;
30module_param(emulate_scroll_wheel, bool, 0644);
31MODULE_PARM_DESC(emulate_scroll_wheel, "Emulate a scroll wheel");
32
33static bool report_touches = true;
34module_param(report_touches, bool, 0644);
35MODULE_PARM_DESC(report_touches, "Emit touch records (otherwise, only use them for emulation)");
36
37static bool report_undeciphered;
38module_param(report_undeciphered, bool, 0644);
39MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state field using a MSC_RAW event");
40
41#define TOUCH_REPORT_ID 0x29
42/* These definitions are not precise, but they're close enough. (Bits
43 * 0x03 seem to indicate the aspect ratio of the touch, bits 0x70 seem
44 * to be some kind of bit mask -- 0x20 may be a near-field reading,
45 * and 0x40 is actual contact, and 0x10 may be a start/stop or change
46 * indication.)
47 */
48#define TOUCH_STATE_MASK 0xf0
49#define TOUCH_STATE_NONE 0x00
50#define TOUCH_STATE_START 0x30
51#define TOUCH_STATE_DRAG 0x40
52
53/**
54 * struct magicmouse_sc - Tracks Magic Mouse-specific data.
55 * @input: Input device through which we report events.
56 * @quirks: Currently unused.
57 * @last_timestamp: Timestamp from most recent (18-bit) touch report
58 * (units of milliseconds over short windows, but seems to
59 * increase faster when there are no touches).
60 * @delta_time: 18-bit difference between the two most recent touch
61 * reports from the mouse.
62 * @ntouches: Number of touches in most recent touch report.
63 * @scroll_accel: Number of consecutive scroll motions.
64 * @scroll_jiffies: Time of last scroll motion.
65 * @touches: Most recent data for a touch, indexed by tracking ID.
66 * @tracking_ids: Mapping of current touch input data to @touches.
67 */
68struct magicmouse_sc {
69 struct input_dev *input;
70 unsigned long quirks;
71
72 int last_timestamp;
73 int delta_time;
74 int ntouches;
75 int scroll_accel;
76 unsigned long scroll_jiffies;
77
78 struct {
79 short x;
80 short y;
81 short scroll_y;
82 u8 size;
83 } touches[16];
84 int tracking_ids[16];
85};
86
87static int magicmouse_firm_touch(struct magicmouse_sc *msc)
88{
89 int touch = -1;
90 int ii;
91
92 /* If there is only one "firm" touch, set touch to its
93 * tracking ID.
94 */
95 for (ii = 0; ii < msc->ntouches; ii++) {
96 int idx = msc->tracking_ids[ii];
97 if (msc->touches[idx].size < 8) {
98 /* Ignore this touch. */
99 } else if (touch >= 0) {
100 touch = -1;
101 break;
102 } else {
103 touch = idx;
104 }
105 }
106
107 return touch;
108}
109
110static void magicmouse_emit_buttons(struct magicmouse_sc *msc, int state)
111{
112 int last_state = test_bit(BTN_LEFT, msc->input->key) << 0 |
113 test_bit(BTN_RIGHT, msc->input->key) << 1 |
114 test_bit(BTN_MIDDLE, msc->input->key) << 2;
115
116 if (emulate_3button) {
117 int id;
118
119 /* If some button was pressed before, keep it held
120 * down. Otherwise, if there's exactly one firm
121 * touch, use that to override the mouse's guess.
122 */
123 if (state == 0) {
124 /* The button was released. */
125 } else if (last_state != 0) {
126 state = last_state;
127 } else if ((id = magicmouse_firm_touch(msc)) >= 0) {
128 int x = msc->touches[id].x;
129 if (x < middle_button_start)
130 state = 1;
131 else if (x > middle_button_stop)
132 state = 2;
133 else
134 state = 4;
135 } /* else: we keep the mouse's guess */
136
137 input_report_key(msc->input, BTN_MIDDLE, state & 4);
138 }
139
140 input_report_key(msc->input, BTN_LEFT, state & 1);
141 input_report_key(msc->input, BTN_RIGHT, state & 2);
142
143 if (state != last_state)
144 msc->scroll_accel = 0;
145}
146
147static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tdata)
148{
149 struct input_dev *input = msc->input;
150 __s32 x_y = tdata[0] << 8 | tdata[1] << 16 | tdata[2] << 24;
151 int misc = tdata[5] | tdata[6] << 8;
152 int id = (misc >> 6) & 15;
153 int x = x_y << 12 >> 20;
154 int y = -(x_y >> 20);
155
156 /* Store tracking ID and other fields. */
157 msc->tracking_ids[raw_id] = id;
158 msc->touches[id].x = x;
159 msc->touches[id].y = y;
160 msc->touches[id].size = misc & 63;
161
162 /* If requested, emulate a scroll wheel by detecting small
163 * vertical touch motions along the middle of the mouse.
164 */
165 if (emulate_scroll_wheel &&
166 middle_button_start < x && x < middle_button_stop) {
167 static const int accel_profile[] = {
168 256, 228, 192, 160, 128, 96, 64, 32,
169 };
170 unsigned long now = jiffies;
171 int step = msc->touches[id].scroll_y - y;
172
173 /* Reset acceleration after half a second. */
174 if (time_after(now, msc->scroll_jiffies + HZ / 2))
175 msc->scroll_accel = 0;
176
177 /* Calculate and apply the scroll motion. */
178 switch (tdata[7] & TOUCH_STATE_MASK) {
179 case TOUCH_STATE_START:
180 msc->touches[id].scroll_y = y;
181 msc->scroll_accel = min_t(int, msc->scroll_accel + 1,
182 ARRAY_SIZE(accel_profile) - 1);
183 break;
184 case TOUCH_STATE_DRAG:
185 step = step / accel_profile[msc->scroll_accel];
186 if (step != 0) {
187 msc->touches[id].scroll_y = y;
188 msc->scroll_jiffies = now;
189 input_report_rel(input, REL_WHEEL, step);
190 }
191 break;
192 }
193 }
194
195 /* Generate the input events for this touch. */
196 if (report_touches) {
197 int orientation = (misc >> 10) - 32;
198
199 input_report_abs(input, ABS_MT_TRACKING_ID, id);
200 input_report_abs(input, ABS_MT_TOUCH_MAJOR, tdata[3]);
201 input_report_abs(input, ABS_MT_TOUCH_MINOR, tdata[4]);
202 input_report_abs(input, ABS_MT_ORIENTATION, orientation);
203 input_report_abs(input, ABS_MT_POSITION_X, x);
204 input_report_abs(input, ABS_MT_POSITION_Y, y);
205
206 if (report_undeciphered)
207 input_event(input, EV_MSC, MSC_RAW, tdata[7]);
208
209 input_mt_sync(input);
210 }
211}
212
213static int magicmouse_raw_event(struct hid_device *hdev,
214 struct hid_report *report, u8 *data, int size)
215{
216 struct magicmouse_sc *msc = hid_get_drvdata(hdev);
217 struct input_dev *input = msc->input;
218 int x, y, ts, ii, clicks;
219
220 switch (data[0]) {
221 case 0x10:
222 if (size != 6)
223 return 0;
224 x = (__s16)(data[2] | data[3] << 8);
225 y = (__s16)(data[4] | data[5] << 8);
226 clicks = data[1];
227 break;
228 case TOUCH_REPORT_ID:
229 /* Expect six bytes of prefix, and N*8 bytes of touch data. */
230 if (size < 6 || ((size - 6) % 8) != 0)
231 return 0;
232 ts = data[3] >> 6 | data[4] << 2 | data[5] << 10;
233 msc->delta_time = (ts - msc->last_timestamp) & 0x3ffff;
234 msc->last_timestamp = ts;
235 msc->ntouches = (size - 6) / 8;
236 for (ii = 0; ii < msc->ntouches; ii++)
237 magicmouse_emit_touch(msc, ii, data + ii * 8 + 6);
238 /* When emulating three-button mode, it is important
239 * to have the current touch information before
240 * generating a click event.
241 */
242 x = (signed char)data[1];
243 y = (signed char)data[2];
244 clicks = data[3];
245 break;
246 case 0x20: /* Theoretically battery status (0-100), but I have
247 * never seen it -- maybe it is only upon request.
248 */
249 case 0x60: /* Unknown, maybe laser on/off. */
250 case 0x61: /* Laser reflection status change.
251 * data[1]: 0 = spotted, 1 = lost
252 */
253 default:
254 return 0;
255 }
256
257 magicmouse_emit_buttons(msc, clicks & 3);
258 input_report_rel(input, REL_X, x);
259 input_report_rel(input, REL_Y, y);
260 input_sync(input);
261 return 1;
262}
263
264static int magicmouse_input_open(struct input_dev *dev)
265{
266 struct hid_device *hid = input_get_drvdata(dev);
267
268 return hid->ll_driver->open(hid);
269}
270
271static void magicmouse_input_close(struct input_dev *dev)
272{
273 struct hid_device *hid = input_get_drvdata(dev);
274
275 hid->ll_driver->close(hid);
276}
277
278static void magicmouse_setup_input(struct input_dev *input, struct hid_device *hdev)
279{
280 input_set_drvdata(input, hdev);
281 input->event = hdev->ll_driver->hidinput_input_event;
282 input->open = magicmouse_input_open;
283 input->close = magicmouse_input_close;
284
285 input->name = hdev->name;
286 input->phys = hdev->phys;
287 input->uniq = hdev->uniq;
288 input->id.bustype = hdev->bus;
289 input->id.vendor = hdev->vendor;
290 input->id.product = hdev->product;
291 input->id.version = hdev->version;
292 input->dev.parent = hdev->dev.parent;
293
294 __set_bit(EV_KEY, input->evbit);
295 __set_bit(BTN_LEFT, input->keybit);
296 __set_bit(BTN_RIGHT, input->keybit);
297 if (emulate_3button)
298 __set_bit(BTN_MIDDLE, input->keybit);
299 __set_bit(BTN_TOOL_FINGER, input->keybit);
300
301 __set_bit(EV_REL, input->evbit);
302 __set_bit(REL_X, input->relbit);
303 __set_bit(REL_Y, input->relbit);
304 if (emulate_scroll_wheel)
305 __set_bit(REL_WHEEL, input->relbit);
306
307 if (report_touches) {
308 __set_bit(EV_ABS, input->evbit);
309
310 input_set_abs_params(input, ABS_MT_TRACKING_ID, 0, 15, 0, 0);
311 input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255, 4, 0);
312 input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 255, 4, 0);
313 input_set_abs_params(input, ABS_MT_ORIENTATION, -32, 31, 1, 0);
314 input_set_abs_params(input, ABS_MT_POSITION_X, -1100, 1358,
315 4, 0);
316 /* Note: Touch Y position from the device is inverted relative
317 * to how pointer motion is reported (and relative to how USB
318 * HID recommends the coordinates work). This driver keeps
319 * the origin at the same position, and just uses the additive
320 * inverse of the reported Y.
321 */
322 input_set_abs_params(input, ABS_MT_POSITION_Y, -1589, 2047,
323 4, 0);
324 }
325
326 if (report_undeciphered) {
327 __set_bit(EV_MSC, input->evbit);
328 __set_bit(MSC_RAW, input->mscbit);
329 }
330}
331
332static int magicmouse_probe(struct hid_device *hdev,
333 const struct hid_device_id *id)
334{
335 __u8 feature_1[] = { 0xd7, 0x01 };
336 __u8 feature_2[] = { 0xf8, 0x01, 0x32 };
337 struct input_dev *input;
338 struct magicmouse_sc *msc;
339 struct hid_report *report;
340 int ret;
341
342 msc = kzalloc(sizeof(*msc), GFP_KERNEL);
343 if (msc == NULL) {
344 dev_err(&hdev->dev, "can't alloc magicmouse descriptor\n");
345 return -ENOMEM;
346 }
347
348 msc->quirks = id->driver_data;
349 hid_set_drvdata(hdev, msc);
350
351 ret = hid_parse(hdev);
352 if (ret) {
353 dev_err(&hdev->dev, "magicmouse hid parse failed\n");
354 goto err_free;
355 }
356
357 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT);
358 if (ret) {
359 dev_err(&hdev->dev, "magicmouse hw start failed\n");
360 goto err_free;
361 }
362
363 report = hid_register_report(hdev, HID_INPUT_REPORT, TOUCH_REPORT_ID);
364 if (!report) {
365 dev_err(&hdev->dev, "unable to register touch report\n");
366 ret = -ENOMEM;
367 goto err_stop_hw;
368 }
369 report->size = 6;
370
371 ret = hdev->hid_output_raw_report(hdev, feature_1, sizeof(feature_1),
372 HID_FEATURE_REPORT);
373 if (ret != sizeof(feature_1)) {
374 dev_err(&hdev->dev, "unable to request touch data (1:%d)\n",
375 ret);
376 goto err_stop_hw;
377 }
378 ret = hdev->hid_output_raw_report(hdev, feature_2,
379 sizeof(feature_2), HID_FEATURE_REPORT);
380 if (ret != sizeof(feature_2)) {
381 dev_err(&hdev->dev, "unable to request touch data (2:%d)\n",
382 ret);
383 goto err_stop_hw;
384 }
385
386 input = input_allocate_device();
387 if (!input) {
388 dev_err(&hdev->dev, "can't alloc input device\n");
389 ret = -ENOMEM;
390 goto err_stop_hw;
391 }
392 magicmouse_setup_input(input, hdev);
393
394 ret = input_register_device(input);
395 if (ret) {
396 dev_err(&hdev->dev, "input device registration failed\n");
397 goto err_input;
398 }
399 msc->input = input;
400
401 return 0;
402err_input:
403 input_free_device(input);
404err_stop_hw:
405 hid_hw_stop(hdev);
406err_free:
407 kfree(msc);
408 return ret;
409}
410
411static void magicmouse_remove(struct hid_device *hdev)
412{
413 struct magicmouse_sc *msc = hid_get_drvdata(hdev);
414
415 hid_hw_stop(hdev);
416 input_unregister_device(msc->input);
417 kfree(msc);
418}
419
420static const struct hid_device_id magic_mice[] = {
421 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE),
422 .driver_data = 0 },
423 { }
424};
425MODULE_DEVICE_TABLE(hid, magic_mice);
426
427static struct hid_driver magicmouse_driver = {
428 .name = "magicmouse",
429 .id_table = magic_mice,
430 .probe = magicmouse_probe,
431 .remove = magicmouse_remove,
432 .raw_event = magicmouse_raw_event,
433};
434
435static int __init magicmouse_init(void)
436{
437 int ret;
438
439 ret = hid_register_driver(&magicmouse_driver);
440 if (ret)
441 printk(KERN_ERR "can't register magicmouse driver\n");
442
443 return ret;
444}
445
446static void __exit magicmouse_exit(void)
447{
448 hid_unregister_driver(&magicmouse_driver);
449}
450
451module_init(magicmouse_init);
452module_exit(magicmouse_exit);
453MODULE_LICENSE("GPL");
diff --git a/drivers/hid/hid-mosart.c b/drivers/hid/hid-mosart.c
new file mode 100644
index 000000000000..e91437c18906
--- /dev/null
+++ b/drivers/hid/hid-mosart.c
@@ -0,0 +1,274 @@
1/*
2 * HID driver for the multitouch panel on the ASUS EeePC T91MT
3 *
4 * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr>
5 * Copyright (c) 2010 Teemu Tuominen <teemu.tuominen@cybercom.com>
6 *
7 */
8
9/*
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 */
15
16#include <linux/device.h>
17#include <linux/hid.h>
18#include <linux/module.h>
19#include <linux/slab.h>
20#include <linux/usb.h>
21#include "usbhid/usbhid.h"
22
23MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
24MODULE_DESCRIPTION("MosArt dual-touch panel");
25MODULE_LICENSE("GPL");
26
27#include "hid-ids.h"
28
29struct mosart_data {
30 __u16 x, y;
31 __u8 id;
32 bool valid; /* valid finger data, or just placeholder? */
33 bool first; /* is this the first finger in this frame? */
34 bool activity_now; /* at least one active finger in this frame? */
35 bool activity; /* at least one active finger previously? */
36};
37
38static int mosart_input_mapping(struct hid_device *hdev, struct hid_input *hi,
39 struct hid_field *field, struct hid_usage *usage,
40 unsigned long **bit, int *max)
41{
42 switch (usage->hid & HID_USAGE_PAGE) {
43
44 case HID_UP_GENDESK:
45 switch (usage->hid) {
46 case HID_GD_X:
47 hid_map_usage(hi, usage, bit, max,
48 EV_ABS, ABS_MT_POSITION_X);
49 /* touchscreen emulation */
50 input_set_abs_params(hi->input, ABS_X,
51 field->logical_minimum,
52 field->logical_maximum, 0, 0);
53 return 1;
54 case HID_GD_Y:
55 hid_map_usage(hi, usage, bit, max,
56 EV_ABS, ABS_MT_POSITION_Y);
57 /* touchscreen emulation */
58 input_set_abs_params(hi->input, ABS_Y,
59 field->logical_minimum,
60 field->logical_maximum, 0, 0);
61 return 1;
62 }
63 return 0;
64
65 case HID_UP_DIGITIZER:
66 switch (usage->hid) {
67 case HID_DG_CONFIDENCE:
68 case HID_DG_TIPSWITCH:
69 case HID_DG_INPUTMODE:
70 case HID_DG_DEVICEINDEX:
71 case HID_DG_CONTACTCOUNT:
72 case HID_DG_CONTACTMAX:
73 case HID_DG_TIPPRESSURE:
74 case HID_DG_WIDTH:
75 case HID_DG_HEIGHT:
76 return -1;
77 case HID_DG_INRANGE:
78 /* touchscreen emulation */
79 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
80 return 1;
81
82 case HID_DG_CONTACTID:
83 hid_map_usage(hi, usage, bit, max,
84 EV_ABS, ABS_MT_TRACKING_ID);
85 return 1;
86
87 }
88 return 0;
89
90 case 0xff000000:
91 /* ignore HID features */
92 return -1;
93 }
94
95 return 0;
96}
97
98static int mosart_input_mapped(struct hid_device *hdev, struct hid_input *hi,
99 struct hid_field *field, struct hid_usage *usage,
100 unsigned long **bit, int *max)
101{
102 if (usage->type == EV_KEY || usage->type == EV_ABS)
103 clear_bit(usage->code, *bit);
104
105 return 0;
106}
107
108/*
109 * this function is called when a whole finger has been parsed,
110 * so that it can decide what to send to the input layer.
111 */
112static void mosart_filter_event(struct mosart_data *td, struct input_dev *input)
113{
114 td->first = !td->first; /* touchscreen emulation */
115
116 if (!td->valid) {
117 /*
118 * touchscreen emulation: if no finger in this frame is valid
119 * and there previously was finger activity, this is a release
120 */
121 if (!td->first && !td->activity_now && td->activity) {
122 input_event(input, EV_KEY, BTN_TOUCH, 0);
123 td->activity = false;
124 }
125 return;
126 }
127
128 input_event(input, EV_ABS, ABS_MT_TRACKING_ID, td->id);
129 input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x);
130 input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y);
131
132 input_mt_sync(input);
133 td->valid = false;
134
135 /* touchscreen emulation: if first active finger in this frame... */
136 if (!td->activity_now) {
137 /* if there was no previous activity, emit touch event */
138 if (!td->activity) {
139 input_event(input, EV_KEY, BTN_TOUCH, 1);
140 td->activity = true;
141 }
142 td->activity_now = true;
143 /* and in any case this is our preferred finger */
144 input_event(input, EV_ABS, ABS_X, td->x);
145 input_event(input, EV_ABS, ABS_Y, td->y);
146 }
147}
148
149
150static int mosart_event(struct hid_device *hid, struct hid_field *field,
151 struct hid_usage *usage, __s32 value)
152{
153 struct mosart_data *td = hid_get_drvdata(hid);
154
155 if (hid->claimed & HID_CLAIMED_INPUT) {
156 struct input_dev *input = field->hidinput->input;
157 switch (usage->hid) {
158 case HID_DG_INRANGE:
159 td->valid = !!value;
160 break;
161 case HID_GD_X:
162 td->x = value;
163 break;
164 case HID_GD_Y:
165 td->y = value;
166 mosart_filter_event(td, input);
167 break;
168 case HID_DG_CONTACTID:
169 td->id = value;
170 break;
171 case HID_DG_CONTACTCOUNT:
172 /* touch emulation: this is the last field in a frame */
173 td->first = false;
174 td->activity_now = false;
175 break;
176 case HID_DG_CONFIDENCE:
177 case HID_DG_TIPSWITCH:
178 /* avoid interference from generic hidinput handling */
179 break;
180
181 default:
182 /* fallback to the generic hidinput handling */
183 return 0;
184 }
185 }
186
187 /* we have handled the hidinput part, now remains hiddev */
188 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
189 hid->hiddev_hid_event(hid, field, usage, value);
190
191 return 1;
192}
193
194static int mosart_probe(struct hid_device *hdev, const struct hid_device_id *id)
195{
196 int ret;
197 struct mosart_data *td;
198
199
200 td = kmalloc(sizeof(struct mosart_data), GFP_KERNEL);
201 if (!td) {
202 dev_err(&hdev->dev, "cannot allocate MosArt data\n");
203 return -ENOMEM;
204 }
205 td->valid = false;
206 td->activity = false;
207 td->activity_now = false;
208 td->first = false;
209 hid_set_drvdata(hdev, td);
210
211 /* currently, it's better to have one evdev device only */
212#if 0
213 hdev->quirks |= HID_QUIRK_MULTI_INPUT;
214#endif
215
216 ret = hid_parse(hdev);
217 if (ret == 0)
218 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
219
220 if (ret == 0) {
221 struct hid_report_enum *re = hdev->report_enum
222 + HID_FEATURE_REPORT;
223 struct hid_report *r = re->report_id_hash[7];
224
225 r->field[0]->value[0] = 0x02;
226 usbhid_submit_report(hdev, r, USB_DIR_OUT);
227 } else
228 kfree(td);
229
230 return ret;
231}
232
233static void mosart_remove(struct hid_device *hdev)
234{
235 hid_hw_stop(hdev);
236 kfree(hid_get_drvdata(hdev));
237 hid_set_drvdata(hdev, NULL);
238}
239
240static const struct hid_device_id mosart_devices[] = {
241 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) },
242 { }
243};
244MODULE_DEVICE_TABLE(hid, mosart_devices);
245
246static const struct hid_usage_id mosart_grabbed_usages[] = {
247 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
248 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
249};
250
251static struct hid_driver mosart_driver = {
252 .name = "mosart",
253 .id_table = mosart_devices,
254 .probe = mosart_probe,
255 .remove = mosart_remove,
256 .input_mapping = mosart_input_mapping,
257 .input_mapped = mosart_input_mapped,
258 .usage_table = mosart_grabbed_usages,
259 .event = mosart_event,
260};
261
262static int __init mosart_init(void)
263{
264 return hid_register_driver(&mosart_driver);
265}
266
267static void __exit mosart_exit(void)
268{
269 hid_unregister_driver(&mosart_driver);
270}
271
272module_init(mosart_init);
273module_exit(mosart_exit);
274
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index 49ce69d7bba7..4777bbfa1cc2 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * HID driver for N-Trig touchscreens 2 * HID driver for N-Trig touchscreens
3 * 3 *
4 * Copyright (c) 2008 Rafi Rubin 4 * Copyright (c) 2008-2010 Rafi Rubin
5 * Copyright (c) 2009 Stephane Chatty 5 * Copyright (c) 2009-2010 Stephane Chatty
6 * 6 *
7 */ 7 */
8 8
@@ -15,21 +15,28 @@
15 15
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/hid.h> 17#include <linux/hid.h>
18#include <linux/usb.h>
19#include "usbhid/usbhid.h"
18#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/slab.h>
19 22
20#include "hid-ids.h" 23#include "hid-ids.h"
21 24
22#define NTRIG_DUPLICATE_USAGES 0x001 25#define NTRIG_DUPLICATE_USAGES 0x001
23 26
24#define nt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
25 EV_KEY, (c))
26
27struct ntrig_data { 27struct ntrig_data {
28 __s32 x, y, id, w, h; 28 /* Incoming raw values for a single contact */
29 char reading_a_point, found_contact_id; 29 __u16 x, y, w, h;
30 char pen_active; 30 __u16 id;
31 char finger_active; 31
32 char inverted; 32 bool tipswitch;
33 bool confidence;
34 bool first_contact_touch;
35
36 bool reading_mt;
37
38 __u8 mt_footer[4];
39 __u8 mt_foot_count;
33}; 40};
34 41
35/* 42/*
@@ -42,8 +49,11 @@ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi,
42 struct hid_field *field, struct hid_usage *usage, 49 struct hid_field *field, struct hid_usage *usage,
43 unsigned long **bit, int *max) 50 unsigned long **bit, int *max)
44{ 51{
45 switch (usage->hid & HID_USAGE_PAGE) { 52 /* No special mappings needed for the pen and single touch */
53 if (field->physical)
54 return 0;
46 55
56 switch (usage->hid & HID_USAGE_PAGE) {
47 case HID_UP_GENDESK: 57 case HID_UP_GENDESK:
48 switch (usage->hid) { 58 switch (usage->hid) {
49 case HID_GD_X: 59 case HID_GD_X:
@@ -66,18 +76,12 @@ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi,
66 case HID_UP_DIGITIZER: 76 case HID_UP_DIGITIZER:
67 switch (usage->hid) { 77 switch (usage->hid) {
68 /* we do not want to map these for now */ 78 /* we do not want to map these for now */
69 case HID_DG_CONTACTID: /* value is useless */ 79 case HID_DG_CONTACTID: /* Not trustworthy, squelch for now */
70 case HID_DG_INPUTMODE: 80 case HID_DG_INPUTMODE:
71 case HID_DG_DEVICEINDEX: 81 case HID_DG_DEVICEINDEX:
72 case HID_DG_CONTACTCOUNT:
73 case HID_DG_CONTACTMAX: 82 case HID_DG_CONTACTMAX:
74 return -1; 83 return -1;
75 84
76 /* original mapping by Rafi Rubin */
77 case HID_DG_CONFIDENCE:
78 nt_map_key_clear(BTN_TOOL_DOUBLETAP);
79 return 1;
80
81 /* width/height mapped on TouchMajor/TouchMinor/Orientation */ 85 /* width/height mapped on TouchMajor/TouchMinor/Orientation */
82 case HID_DG_WIDTH: 86 case HID_DG_WIDTH:
83 hid_map_usage(hi, usage, bit, max, 87 hid_map_usage(hi, usage, bit, max,
@@ -104,6 +108,10 @@ static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi,
104 struct hid_field *field, struct hid_usage *usage, 108 struct hid_field *field, struct hid_usage *usage,
105 unsigned long **bit, int *max) 109 unsigned long **bit, int *max)
106{ 110{
111 /* No special mappings needed for the pen and single touch */
112 if (field->physical)
113 return 0;
114
107 if (usage->type == EV_KEY || usage->type == EV_REL 115 if (usage->type == EV_KEY || usage->type == EV_REL
108 || usage->type == EV_ABS) 116 || usage->type == EV_ABS)
109 clear_bit(usage->code, *bit); 117 clear_bit(usage->code, *bit);
@@ -123,31 +131,34 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
123 struct input_dev *input = field->hidinput->input; 131 struct input_dev *input = field->hidinput->input;
124 struct ntrig_data *nd = hid_get_drvdata(hid); 132 struct ntrig_data *nd = hid_get_drvdata(hid);
125 133
134 /* No special handling needed for the pen */
135 if (field->application == HID_DG_PEN)
136 return 0;
137
126 if (hid->claimed & HID_CLAIMED_INPUT) { 138 if (hid->claimed & HID_CLAIMED_INPUT) {
127 switch (usage->hid) { 139 switch (usage->hid) {
128 140 case 0xff000001:
129 case HID_DG_INRANGE: 141 /* Tag indicating the start of a multitouch group */
130 if (field->application & 0x3) 142 nd->reading_mt = 1;
131 nd->pen_active = (value != 0); 143 nd->first_contact_touch = 0;
132 else 144 break;
133 nd->finger_active = (value != 0); 145 case HID_DG_TIPSWITCH:
134 return 0; 146 nd->tipswitch = value;
135 147 /* Prevent emission of touch until validated */
136 case HID_DG_INVERT: 148 return 1;
137 nd->inverted = value; 149 case HID_DG_CONFIDENCE:
138 return 0; 150 nd->confidence = value;
139 151 break;
140 case HID_GD_X: 152 case HID_GD_X:
141 nd->x = value; 153 nd->x = value;
142 nd->reading_a_point = 1; 154 /* Clear the contact footer */
155 nd->mt_foot_count = 0;
143 break; 156 break;
144 case HID_GD_Y: 157 case HID_GD_Y:
145 nd->y = value; 158 nd->y = value;
146 break; 159 break;
147 case HID_DG_CONTACTID: 160 case HID_DG_CONTACTID:
148 nd->id = value; 161 nd->id = value;
149 /* we receive this only when in multitouch mode */
150 nd->found_contact_id = 1;
151 break; 162 break;
152 case HID_DG_WIDTH: 163 case HID_DG_WIDTH:
153 nd->w = value; 164 nd->w = value;
@@ -159,33 +170,17 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
159 * report received in a finger event. We want 170 * report received in a finger event. We want
160 * to emit a normal (X, Y) position 171 * to emit a normal (X, Y) position
161 */ 172 */
162 if (!nd->found_contact_id) { 173 if (!nd->reading_mt) {
163 if (nd->pen_active && nd->finger_active) { 174 /*
164 input_report_key(input, BTN_TOOL_DOUBLETAP, 0); 175 * TipSwitch indicates the presence of a
165 input_report_key(input, BTN_TOOL_DOUBLETAP, 1); 176 * finger in single touch mode.
166 } 177 */
167 input_event(input, EV_ABS, ABS_X, nd->x); 178 input_report_key(input, BTN_TOUCH,
168 input_event(input, EV_ABS, ABS_Y, nd->y); 179 nd->tipswitch);
169 } 180 input_report_key(input, BTN_TOOL_DOUBLETAP,
170 break; 181 nd->tipswitch);
171 case HID_DG_TIPPRESSURE:
172 /*
173 * when in single touch mode, this is the last
174 * report received in a pen event. We want
175 * to emit a normal (X, Y) position
176 */
177 if (! nd->found_contact_id) {
178 if (nd->pen_active && nd->finger_active) {
179 input_report_key(input,
180 nd->inverted ? BTN_TOOL_RUBBER : BTN_TOOL_PEN
181 , 0);
182 input_report_key(input,
183 nd->inverted ? BTN_TOOL_RUBBER : BTN_TOOL_PEN
184 , 1);
185 }
186 input_event(input, EV_ABS, ABS_X, nd->x); 182 input_event(input, EV_ABS, ABS_X, nd->x);
187 input_event(input, EV_ABS, ABS_Y, nd->y); 183 input_event(input, EV_ABS, ABS_Y, nd->y);
188 input_event(input, EV_ABS, ABS_PRESSURE, value);
189 } 184 }
190 break; 185 break;
191 case 0xff000002: 186 case 0xff000002:
@@ -195,10 +190,40 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
195 * this usage tells if the contact point is real 190 * this usage tells if the contact point is real
196 * or a placeholder 191 * or a placeholder
197 */ 192 */
198 if (!nd->reading_a_point || value != 1) 193
194 /* Shouldn't get more than 4 footer packets, so skip */
195 if (nd->mt_foot_count >= 4)
199 break; 196 break;
197
198 nd->mt_footer[nd->mt_foot_count++] = value;
199
200 /* if the footer isn't complete break */
201 if (nd->mt_foot_count != 4)
202 break;
203
204 /* Pen activity signal, trigger end of touch. */
205 if (nd->mt_footer[2]) {
206 nd->confidence = 0;
207 break;
208 }
209
210 /* If the contact was invalid */
211 if (!(nd->confidence && nd->mt_footer[0])
212 || nd->w <= 250
213 || nd->h <= 190) {
214 nd->confidence = 0;
215 break;
216 }
217
200 /* emit a normal (X, Y) for the first point only */ 218 /* emit a normal (X, Y) for the first point only */
201 if (nd->id == 0) { 219 if (nd->id == 0) {
220 /*
221 * TipSwitch is superfluous in multitouch
222 * mode. The footer events tell us
223 * if there is a finger on the screen or
224 * not.
225 */
226 nd->first_contact_touch = nd->confidence;
202 input_event(input, EV_ABS, ABS_X, nd->x); 227 input_event(input, EV_ABS, ABS_X, nd->x);
203 input_event(input, EV_ABS, ABS_Y, nd->y); 228 input_event(input, EV_ABS, ABS_Y, nd->y);
204 } 229 }
@@ -220,8 +245,21 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
220 ABS_MT_TOUCH_MINOR, nd->w); 245 ABS_MT_TOUCH_MINOR, nd->w);
221 } 246 }
222 input_mt_sync(field->hidinput->input); 247 input_mt_sync(field->hidinput->input);
223 nd->reading_a_point = 0; 248 break;
224 nd->found_contact_id = 0; 249
250 case HID_DG_CONTACTCOUNT: /* End of a multitouch group */
251 if (!nd->reading_mt)
252 break;
253
254 nd->reading_mt = 0;
255
256 if (nd->first_contact_touch) {
257 input_report_key(input, BTN_TOOL_DOUBLETAP, 1);
258 input_report_key(input, BTN_TOUCH, 1);
259 } else {
260 input_report_key(input, BTN_TOOL_DOUBLETAP, 0);
261 input_report_key(input, BTN_TOUCH, 0);
262 }
225 break; 263 break;
226 264
227 default: 265 default:
@@ -231,8 +269,8 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
231 } 269 }
232 270
233 /* we have handled the hidinput part, now remains hiddev */ 271 /* we have handled the hidinput part, now remains hiddev */
234 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) 272 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_hid_event)
235 hid->hiddev_hid_event(hid, field, usage, value); 273 hid->hiddev_hid_event(hid, field, usage, value);
236 274
237 return 1; 275 return 1;
238} 276}
@@ -241,23 +279,75 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
241{ 279{
242 int ret; 280 int ret;
243 struct ntrig_data *nd; 281 struct ntrig_data *nd;
282 struct hid_input *hidinput;
283 struct input_dev *input;
284 struct hid_report *report;
285
286 if (id->driver_data)
287 hdev->quirks |= HID_QUIRK_MULTI_INPUT;
244 288
245 nd = kmalloc(sizeof(struct ntrig_data), GFP_KERNEL); 289 nd = kmalloc(sizeof(struct ntrig_data), GFP_KERNEL);
246 if (!nd) { 290 if (!nd) {
247 dev_err(&hdev->dev, "cannot allocate N-Trig data\n"); 291 dev_err(&hdev->dev, "cannot allocate N-Trig data\n");
248 return -ENOMEM; 292 return -ENOMEM;
249 } 293 }
250 nd->reading_a_point = 0; 294
251 nd->found_contact_id = 0; 295 nd->reading_mt = 0;
252 hid_set_drvdata(hdev, nd); 296 hid_set_drvdata(hdev, nd);
253 297
254 ret = hid_parse(hdev); 298 ret = hid_parse(hdev);
255 if (!ret) 299 if (ret) {
256 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 300 dev_err(&hdev->dev, "parse failed\n");
301 goto err_free;
302 }
303
304 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
305 if (ret) {
306 dev_err(&hdev->dev, "hw start failed\n");
307 goto err_free;
308 }
309
310
311 list_for_each_entry(hidinput, &hdev->inputs, list) {
312 if (hidinput->report->maxfield < 1)
313 continue;
314
315 input = hidinput->input;
316 switch (hidinput->report->field[0]->application) {
317 case HID_DG_PEN:
318 input->name = "N-Trig Pen";
319 break;
320 case HID_DG_TOUCHSCREEN:
321 /* These keys are redundant for fingers, clear them
322 * to prevent incorrect identification */
323 __clear_bit(BTN_TOOL_PEN, input->keybit);
324 __clear_bit(BTN_TOOL_FINGER, input->keybit);
325 __clear_bit(BTN_0, input->keybit);
326 __set_bit(BTN_TOOL_DOUBLETAP, input->keybit);
327 /*
328 * The physical touchscreen (single touch)
329 * input has a value for physical, whereas
330 * the multitouch only has logical input
331 * fields.
332 */
333 input->name =
334 (hidinput->report->field[0]
335 ->physical) ?
336 "N-Trig Touchscreen" :
337 "N-Trig MultiTouch";
338 break;
339 }
340 }
257 341
258 if (ret) 342 /* This is needed for devices with more recent firmware versions */
259 kfree (nd); 343 report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0x0a];
344 if (report)
345 usbhid_submit_report(hdev, report, USB_DIR_OUT);
260 346
347
348 return 0;
349err_free:
350 kfree(nd);
261 return ret; 351 return ret;
262} 352}
263 353
@@ -276,7 +366,7 @@ MODULE_DEVICE_TABLE(hid, ntrig_devices);
276 366
277static const struct hid_usage_id ntrig_grabbed_usages[] = { 367static const struct hid_usage_id ntrig_grabbed_usages[] = {
278 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID }, 368 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
279 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1} 369 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1 }
280}; 370};
281 371
282static struct hid_driver ntrig_driver = { 372static struct hid_driver ntrig_driver = {
diff --git a/drivers/hid/hid-ortek.c b/drivers/hid/hid-ortek.c
new file mode 100644
index 000000000000..aa9a960f73a4
--- /dev/null
+++ b/drivers/hid/hid-ortek.c
@@ -0,0 +1,56 @@
1/*
2 * HID driver for Ortek WKB-2000 (wireless keyboard + mouse trackpad).
3 * Fixes LogicalMaximum error in USB report description, see
4 * http://bugzilla.kernel.org/show_bug.cgi?id=14787
5 *
6 * Copyright (c) 2010 Johnathon Harris <jmharris@gmail.com>
7 */
8
9/*
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 */
15
16#include <linux/device.h>
17#include <linux/hid.h>
18#include <linux/module.h>
19
20#include "hid-ids.h"
21
22static void ortek_report_fixup(struct hid_device *hdev, __u8 *rdesc,
23 unsigned int rsize)
24{
25 if (rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x01) {
26 dev_info(&hdev->dev, "Fixing up Ortek WKB-2000 "
27 "report descriptor.\n");
28 rdesc[55] = 0x92;
29 }
30}
31
32static const struct hid_device_id ortek_devices[] = {
33 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },
34 { }
35};
36MODULE_DEVICE_TABLE(hid, ortek_devices);
37
38static struct hid_driver ortek_driver = {
39 .name = "ortek",
40 .id_table = ortek_devices,
41 .report_fixup = ortek_report_fixup
42};
43
44static int __init ortek_init(void)
45{
46 return hid_register_driver(&ortek_driver);
47}
48
49static void __exit ortek_exit(void)
50{
51 hid_unregister_driver(&ortek_driver);
52}
53
54module_init(ortek_init);
55module_exit(ortek_exit);
56MODULE_LICENSE("GPL");
diff --git a/drivers/hid/hid-pl.c b/drivers/hid/hid-pl.c
index c6d7dbc935b1..9f41e2bd8483 100644
--- a/drivers/hid/hid-pl.c
+++ b/drivers/hid/hid-pl.c
@@ -39,6 +39,7 @@
39#define debug(format, arg...) pr_debug("hid-plff: " format "\n" , ## arg) 39#define debug(format, arg...) pr_debug("hid-plff: " format "\n" , ## arg)
40 40
41#include <linux/input.h> 41#include <linux/input.h>
42#include <linux/slab.h>
42#include <linux/usb.h> 43#include <linux/usb.h>
43#include <linux/hid.h> 44#include <linux/hid.h>
44 45
diff --git a/drivers/hid/hid-quanta.c b/drivers/hid/hid-quanta.c
new file mode 100644
index 000000000000..54d3db50605b
--- /dev/null
+++ b/drivers/hid/hid-quanta.c
@@ -0,0 +1,261 @@
1/*
2 * HID driver for Quanta Optical Touch dual-touch panels
3 *
4 * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr>
5 *
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 */
14
15#include <linux/device.h>
16#include <linux/hid.h>
17#include <linux/module.h>
18#include <linux/slab.h>
19
20MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
21MODULE_DESCRIPTION("Quanta dual-touch panel");
22MODULE_LICENSE("GPL");
23
24#include "hid-ids.h"
25
26struct quanta_data {
27 __u16 x, y;
28 __u8 id;
29 bool valid; /* valid finger data, or just placeholder? */
30 bool first; /* is this the first finger in this frame? */
31 bool activity_now; /* at least one active finger in this frame? */
32 bool activity; /* at least one active finger previously? */
33};
34
35static int quanta_input_mapping(struct hid_device *hdev, struct hid_input *hi,
36 struct hid_field *field, struct hid_usage *usage,
37 unsigned long **bit, int *max)
38{
39 switch (usage->hid & HID_USAGE_PAGE) {
40
41 case HID_UP_GENDESK:
42 switch (usage->hid) {
43 case HID_GD_X:
44 hid_map_usage(hi, usage, bit, max,
45 EV_ABS, ABS_MT_POSITION_X);
46 /* touchscreen emulation */
47 input_set_abs_params(hi->input, ABS_X,
48 field->logical_minimum,
49 field->logical_maximum, 0, 0);
50 return 1;
51 case HID_GD_Y:
52 hid_map_usage(hi, usage, bit, max,
53 EV_ABS, ABS_MT_POSITION_Y);
54 /* touchscreen emulation */
55 input_set_abs_params(hi->input, ABS_Y,
56 field->logical_minimum,
57 field->logical_maximum, 0, 0);
58 return 1;
59 }
60 return 0;
61
62 case HID_UP_DIGITIZER:
63 switch (usage->hid) {
64 case HID_DG_CONFIDENCE:
65 case HID_DG_TIPSWITCH:
66 case HID_DG_INPUTMODE:
67 case HID_DG_DEVICEINDEX:
68 case HID_DG_CONTACTCOUNT:
69 case HID_DG_CONTACTMAX:
70 case HID_DG_TIPPRESSURE:
71 case HID_DG_WIDTH:
72 case HID_DG_HEIGHT:
73 return -1;
74 case HID_DG_INRANGE:
75 /* touchscreen emulation */
76 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
77 return 1;
78 case HID_DG_CONTACTID:
79 hid_map_usage(hi, usage, bit, max,
80 EV_ABS, ABS_MT_TRACKING_ID);
81 return 1;
82 }
83 return 0;
84
85 case 0xff000000:
86 /* ignore vendor-specific features */
87 return -1;
88 }
89
90 return 0;
91}
92
93static int quanta_input_mapped(struct hid_device *hdev, struct hid_input *hi,
94 struct hid_field *field, struct hid_usage *usage,
95 unsigned long **bit, int *max)
96{
97 if (usage->type == EV_KEY || usage->type == EV_ABS)
98 clear_bit(usage->code, *bit);
99
100 return 0;
101}
102
103/*
104 * this function is called when a whole finger has been parsed,
105 * so that it can decide what to send to the input layer.
106 */
107static void quanta_filter_event(struct quanta_data *td, struct input_dev *input)
108{
109
110 td->first = !td->first; /* touchscreen emulation */
111
112 if (!td->valid) {
113 /*
114 * touchscreen emulation: if no finger in this frame is valid
115 * and there previously was finger activity, this is a release
116 */
117 if (!td->first && !td->activity_now && td->activity) {
118 input_event(input, EV_KEY, BTN_TOUCH, 0);
119 td->activity = false;
120 }
121 return;
122 }
123
124 input_event(input, EV_ABS, ABS_MT_TRACKING_ID, td->id);
125 input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x);
126 input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y);
127
128 input_mt_sync(input);
129 td->valid = false;
130
131 /* touchscreen emulation: if first active finger in this frame... */
132 if (!td->activity_now) {
133 /* if there was no previous activity, emit touch event */
134 if (!td->activity) {
135 input_event(input, EV_KEY, BTN_TOUCH, 1);
136 td->activity = true;
137 }
138 td->activity_now = true;
139 /* and in any case this is our preferred finger */
140 input_event(input, EV_ABS, ABS_X, td->x);
141 input_event(input, EV_ABS, ABS_Y, td->y);
142 }
143}
144
145
146static int quanta_event(struct hid_device *hid, struct hid_field *field,
147 struct hid_usage *usage, __s32 value)
148{
149 struct quanta_data *td = hid_get_drvdata(hid);
150
151 if (hid->claimed & HID_CLAIMED_INPUT) {
152 struct input_dev *input = field->hidinput->input;
153
154 switch (usage->hid) {
155 case HID_DG_INRANGE:
156 td->valid = !!value;
157 break;
158 case HID_GD_X:
159 td->x = value;
160 break;
161 case HID_GD_Y:
162 td->y = value;
163 quanta_filter_event(td, input);
164 break;
165 case HID_DG_CONTACTID:
166 td->id = value;
167 break;
168 case HID_DG_CONTACTCOUNT:
169 /* touch emulation: this is the last field in a frame */
170 td->first = false;
171 td->activity_now = false;
172 break;
173 case HID_DG_CONFIDENCE:
174 case HID_DG_TIPSWITCH:
175 /* avoid interference from generic hidinput handling */
176 break;
177
178 default:
179 /* fallback to the generic hidinput handling */
180 return 0;
181 }
182 }
183
184 /* we have handled the hidinput part, now remains hiddev */
185 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
186 hid->hiddev_hid_event(hid, field, usage, value);
187
188 return 1;
189}
190
191static int quanta_probe(struct hid_device *hdev, const struct hid_device_id *id)
192{
193 int ret;
194 struct quanta_data *td;
195
196 td = kmalloc(sizeof(struct quanta_data), GFP_KERNEL);
197 if (!td) {
198 dev_err(&hdev->dev, "cannot allocate Quanta Touch data\n");
199 return -ENOMEM;
200 }
201 td->valid = false;
202 td->activity = false;
203 td->activity_now = false;
204 td->first = false;
205 hid_set_drvdata(hdev, td);
206
207 ret = hid_parse(hdev);
208 if (!ret)
209 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
210
211 if (ret)
212 kfree(td);
213
214 return ret;
215}
216
217static void quanta_remove(struct hid_device *hdev)
218{
219 hid_hw_stop(hdev);
220 kfree(hid_get_drvdata(hdev));
221 hid_set_drvdata(hdev, NULL);
222}
223
224static const struct hid_device_id quanta_devices[] = {
225 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,
226 USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
227 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,
228 USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) },
229 { }
230};
231MODULE_DEVICE_TABLE(hid, quanta_devices);
232
233static const struct hid_usage_id quanta_grabbed_usages[] = {
234 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
235 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
236};
237
238static struct hid_driver quanta_driver = {
239 .name = "quanta-touch",
240 .id_table = quanta_devices,
241 .probe = quanta_probe,
242 .remove = quanta_remove,
243 .input_mapping = quanta_input_mapping,
244 .input_mapped = quanta_input_mapped,
245 .usage_table = quanta_grabbed_usages,
246 .event = quanta_event,
247};
248
249static int __init quanta_init(void)
250{
251 return hid_register_driver(&quanta_driver);
252}
253
254static void __exit quanta_exit(void)
255{
256 hid_unregister_driver(&quanta_driver);
257}
258
259module_init(quanta_init);
260module_exit(quanta_exit);
261
diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c
index 5b222eed0692..510dd1340597 100644
--- a/drivers/hid/hid-samsung.c
+++ b/drivers/hid/hid-samsung.c
@@ -39,7 +39,17 @@
39 * 39 *
40 * 3. 135 byte report descriptor 40 * 3. 135 byte report descriptor
41 * Report #4 has an array field with logical range 0..17 instead of 1..14. 41 * Report #4 has an array field with logical range 0..17 instead of 1..14.
42 *
43 * 4. 171 byte report descriptor
44 * Report #3 has an array field with logical range 0..1 instead of 1..3.
42 */ 45 */
46static inline void samsung_dev_trace(struct hid_device *hdev,
47 unsigned int rsize)
48{
49 dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report "
50 "descriptor\n", rsize);
51}
52
43static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc, 53static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
44 unsigned int rsize) 54 unsigned int rsize)
45{ 55{
@@ -47,8 +57,7 @@ static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
47 rdesc[177] == 0x75 && rdesc[178] == 0x30 && 57 rdesc[177] == 0x75 && rdesc[178] == 0x30 &&
48 rdesc[179] == 0x95 && rdesc[180] == 0x01 && 58 rdesc[179] == 0x95 && rdesc[180] == 0x01 &&
49 rdesc[182] == 0x40) { 59 rdesc[182] == 0x40) {
50 dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report " 60 samsung_dev_trace(hdev, 184);
51 "descriptor\n", 184);
52 rdesc[176] = 0xff; 61 rdesc[176] = 0xff;
53 rdesc[178] = 0x08; 62 rdesc[178] = 0x08;
54 rdesc[180] = 0x06; 63 rdesc[180] = 0x06;
@@ -56,17 +65,21 @@ static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
56 } else 65 } else
57 if (rsize == 203 && rdesc[192] == 0x15 && rdesc[193] == 0x0 && 66 if (rsize == 203 && rdesc[192] == 0x15 && rdesc[193] == 0x0 &&
58 rdesc[194] == 0x25 && rdesc[195] == 0x12) { 67 rdesc[194] == 0x25 && rdesc[195] == 0x12) {
59 dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report " 68 samsung_dev_trace(hdev, 203);
60 "descriptor\n", 203);
61 rdesc[193] = 0x1; 69 rdesc[193] = 0x1;
62 rdesc[195] = 0xf; 70 rdesc[195] = 0xf;
63 } else 71 } else
64 if (rsize == 135 && rdesc[124] == 0x15 && rdesc[125] == 0x0 && 72 if (rsize == 135 && rdesc[124] == 0x15 && rdesc[125] == 0x0 &&
65 rdesc[126] == 0x25 && rdesc[127] == 0x11) { 73 rdesc[126] == 0x25 && rdesc[127] == 0x11) {
66 dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report " 74 samsung_dev_trace(hdev, 135);
67 "descriptor\n", 135);
68 rdesc[125] = 0x1; 75 rdesc[125] = 0x1;
69 rdesc[127] = 0xe; 76 rdesc[127] = 0xe;
77 } else
78 if (rsize == 171 && rdesc[160] == 0x15 && rdesc[161] == 0x0 &&
79 rdesc[162] == 0x25 && rdesc[163] == 0x01) {
80 samsung_dev_trace(hdev, 171);
81 rdesc[161] = 0x1;
82 rdesc[163] = 0x3;
70 } 83 }
71} 84}
72 85
diff --git a/drivers/hid/hid-sjoy.c b/drivers/hid/hid-sjoy.c
index 203c438b016f..e10a7687ebf2 100644
--- a/drivers/hid/hid-sjoy.c
+++ b/drivers/hid/hid-sjoy.c
@@ -27,6 +27,7 @@
27/* #define DEBUG */ 27/* #define DEBUG */
28 28
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/slab.h>
30#include <linux/usb.h> 31#include <linux/usb.h>
31#include <linux/hid.h> 32#include <linux/hid.h>
32#include "hid-ids.h" 33#include "hid-ids.h"
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 4e8450228a24..402d5574b574 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -19,6 +19,7 @@
19#include <linux/device.h> 19#include <linux/device.h>
20#include <linux/hid.h> 20#include <linux/hid.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22#include <linux/usb.h> 23#include <linux/usb.h>
23 24
24#include "hid-ids.h" 25#include "hid-ids.h"
@@ -48,7 +49,7 @@ static void sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
48 * to "operational". Without this, the ps3 controller will not report any 49 * to "operational". Without this, the ps3 controller will not report any
49 * events. 50 * events.
50 */ 51 */
51static int sony_set_operational(struct hid_device *hdev) 52static int sony_set_operational_usb(struct hid_device *hdev)
52{ 53{
53 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); 54 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
54 struct usb_device *dev = interface_to_usbdev(intf); 55 struct usb_device *dev = interface_to_usbdev(intf);
@@ -73,6 +74,12 @@ static int sony_set_operational(struct hid_device *hdev)
73 return ret; 74 return ret;
74} 75}
75 76
77static int sony_set_operational_bt(struct hid_device *hdev)
78{
79 unsigned char buf[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 };
80 return hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
81}
82
76static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) 83static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
77{ 84{
78 int ret; 85 int ret;
@@ -81,7 +88,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
81 88
82 sc = kzalloc(sizeof(*sc), GFP_KERNEL); 89 sc = kzalloc(sizeof(*sc), GFP_KERNEL);
83 if (sc == NULL) { 90 if (sc == NULL) {
84 dev_err(&hdev->dev, "can't alloc apple descriptor\n"); 91 dev_err(&hdev->dev, "can't alloc sony descriptor\n");
85 return -ENOMEM; 92 return -ENOMEM;
86 } 93 }
87 94
@@ -101,7 +108,17 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
101 goto err_free; 108 goto err_free;
102 } 109 }
103 110
104 ret = sony_set_operational(hdev); 111 switch (hdev->bus) {
112 case BUS_USB:
113 ret = sony_set_operational_usb(hdev);
114 break;
115 case BUS_BLUETOOTH:
116 ret = sony_set_operational_bt(hdev);
117 break;
118 default:
119 ret = 0;
120 }
121
105 if (ret < 0) 122 if (ret < 0)
106 goto err_stop; 123 goto err_stop;
107 124
@@ -121,6 +138,7 @@ static void sony_remove(struct hid_device *hdev)
121 138
122static const struct hid_device_id sony_devices[] = { 139static const struct hid_device_id sony_devices[] = {
123 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 140 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
141 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
124 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE), 142 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),
125 .driver_data = VAIO_RDESC_CONSTANT }, 143 .driver_data = VAIO_RDESC_CONSTANT },
126 { } 144 { }
diff --git a/drivers/hid/hid-stantum.c b/drivers/hid/hid-stantum.c
new file mode 100644
index 000000000000..90df886c5e04
--- /dev/null
+++ b/drivers/hid/hid-stantum.c
@@ -0,0 +1,284 @@
1/*
2 * HID driver for Stantum multitouch panels
3 *
4 * Copyright (c) 2009 Stephane Chatty <chatty@enac.fr>
5 *
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 */
14
15#include <linux/device.h>
16#include <linux/hid.h>
17#include <linux/module.h>
18#include <linux/slab.h>
19
20MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
21MODULE_DESCRIPTION("Stantum HID multitouch panels");
22MODULE_LICENSE("GPL");
23
24#include "hid-ids.h"
25
26struct stantum_data {
27 __s32 x, y, z, w, h; /* x, y, pressure, width, height */
28 __u16 id; /* touch id */
29 bool valid; /* valid finger data, or just placeholder? */
30 bool first; /* first finger in the HID packet? */
31 bool activity; /* at least one active finger so far? */
32};
33
34static int stantum_input_mapping(struct hid_device *hdev, struct hid_input *hi,
35 struct hid_field *field, struct hid_usage *usage,
36 unsigned long **bit, int *max)
37{
38 switch (usage->hid & HID_USAGE_PAGE) {
39
40 case HID_UP_GENDESK:
41 switch (usage->hid) {
42 case HID_GD_X:
43 hid_map_usage(hi, usage, bit, max,
44 EV_ABS, ABS_MT_POSITION_X);
45 /* touchscreen emulation */
46 input_set_abs_params(hi->input, ABS_X,
47 field->logical_minimum,
48 field->logical_maximum, 0, 0);
49 return 1;
50 case HID_GD_Y:
51 hid_map_usage(hi, usage, bit, max,
52 EV_ABS, ABS_MT_POSITION_Y);
53 /* touchscreen emulation */
54 input_set_abs_params(hi->input, ABS_Y,
55 field->logical_minimum,
56 field->logical_maximum, 0, 0);
57 return 1;
58 }
59 return 0;
60
61 case HID_UP_DIGITIZER:
62 switch (usage->hid) {
63 case HID_DG_INRANGE:
64 case HID_DG_CONFIDENCE:
65 case HID_DG_INPUTMODE:
66 case HID_DG_DEVICEINDEX:
67 case HID_DG_CONTACTCOUNT:
68 case HID_DG_CONTACTMAX:
69 return -1;
70
71 case HID_DG_TIPSWITCH:
72 /* touchscreen emulation */
73 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
74 return 1;
75
76 case HID_DG_WIDTH:
77 hid_map_usage(hi, usage, bit, max,
78 EV_ABS, ABS_MT_TOUCH_MAJOR);
79 return 1;
80 case HID_DG_HEIGHT:
81 hid_map_usage(hi, usage, bit, max,
82 EV_ABS, ABS_MT_TOUCH_MINOR);
83 input_set_abs_params(hi->input, ABS_MT_ORIENTATION,
84 1, 1, 0, 0);
85 return 1;
86 case HID_DG_TIPPRESSURE:
87 hid_map_usage(hi, usage, bit, max,
88 EV_ABS, ABS_MT_PRESSURE);
89 return 1;
90
91 case HID_DG_CONTACTID:
92 hid_map_usage(hi, usage, bit, max,
93 EV_ABS, ABS_MT_TRACKING_ID);
94 return 1;
95
96 }
97 return 0;
98
99 case 0xff000000:
100 /* no input-oriented meaning */
101 return -1;
102 }
103
104 return 0;
105}
106
107static int stantum_input_mapped(struct hid_device *hdev, struct hid_input *hi,
108 struct hid_field *field, struct hid_usage *usage,
109 unsigned long **bit, int *max)
110{
111 if (usage->type == EV_KEY || usage->type == EV_ABS)
112 clear_bit(usage->code, *bit);
113
114 return 0;
115}
116
117/*
118 * this function is called when a whole finger has been parsed,
119 * so that it can decide what to send to the input layer.
120 */
121static void stantum_filter_event(struct stantum_data *sd,
122 struct input_dev *input)
123{
124 bool wide;
125
126 if (!sd->valid) {
127 /*
128 * touchscreen emulation: if the first finger is not valid and
129 * there previously was finger activity, this is a release
130 */
131 if (sd->first && sd->activity) {
132 input_event(input, EV_KEY, BTN_TOUCH, 0);
133 sd->activity = false;
134 }
135 return;
136 }
137
138 input_event(input, EV_ABS, ABS_MT_TRACKING_ID, sd->id);
139 input_event(input, EV_ABS, ABS_MT_POSITION_X, sd->x);
140 input_event(input, EV_ABS, ABS_MT_POSITION_Y, sd->y);
141
142 wide = (sd->w > sd->h);
143 input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide);
144 input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, wide ? sd->w : sd->h);
145 input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, wide ? sd->h : sd->w);
146
147 input_event(input, EV_ABS, ABS_MT_PRESSURE, sd->z);
148
149 input_mt_sync(input);
150 sd->valid = false;
151
152 /* touchscreen emulation */
153 if (sd->first) {
154 if (!sd->activity) {
155 input_event(input, EV_KEY, BTN_TOUCH, 1);
156 sd->activity = true;
157 }
158 input_event(input, EV_ABS, ABS_X, sd->x);
159 input_event(input, EV_ABS, ABS_Y, sd->y);
160 }
161 sd->first = false;
162}
163
164
165static int stantum_event(struct hid_device *hid, struct hid_field *field,
166 struct hid_usage *usage, __s32 value)
167{
168 struct stantum_data *sd = hid_get_drvdata(hid);
169
170 if (hid->claimed & HID_CLAIMED_INPUT) {
171 struct input_dev *input = field->hidinput->input;
172
173 switch (usage->hid) {
174 case HID_DG_INRANGE:
175 /* this is the last field in a finger */
176 stantum_filter_event(sd, input);
177 break;
178 case HID_DG_WIDTH:
179 sd->w = value;
180 break;
181 case HID_DG_HEIGHT:
182 sd->h = value;
183 break;
184 case HID_GD_X:
185 sd->x = value;
186 break;
187 case HID_GD_Y:
188 sd->y = value;
189 break;
190 case HID_DG_TIPPRESSURE:
191 sd->z = value;
192 break;
193 case HID_DG_CONTACTID:
194 sd->id = value;
195 break;
196 case HID_DG_CONFIDENCE:
197 sd->valid = !!value;
198 break;
199 case 0xff000002:
200 /* this comes only before the first finger */
201 sd->first = true;
202 break;
203
204 default:
205 /* ignore the others */
206 return 1;
207 }
208 }
209
210 /* we have handled the hidinput part, now remains hiddev */
211 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
212 hid->hiddev_hid_event(hid, field, usage, value);
213
214 return 1;
215}
216
217static int stantum_probe(struct hid_device *hdev,
218 const struct hid_device_id *id)
219{
220 int ret;
221 struct stantum_data *sd;
222
223 sd = kmalloc(sizeof(struct stantum_data), GFP_KERNEL);
224 if (!sd) {
225 dev_err(&hdev->dev, "cannot allocate Stantum data\n");
226 return -ENOMEM;
227 }
228 sd->valid = false;
229 sd->first = false;
230 sd->activity = false;
231 hid_set_drvdata(hdev, sd);
232
233 ret = hid_parse(hdev);
234 if (!ret)
235 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
236
237 if (ret)
238 kfree(sd);
239
240 return ret;
241}
242
243static void stantum_remove(struct hid_device *hdev)
244{
245 hid_hw_stop(hdev);
246 kfree(hid_get_drvdata(hdev));
247 hid_set_drvdata(hdev, NULL);
248}
249
250static const struct hid_device_id stantum_devices[] = {
251 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) },
252 { }
253};
254MODULE_DEVICE_TABLE(hid, stantum_devices);
255
256static const struct hid_usage_id stantum_grabbed_usages[] = {
257 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
258 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
259};
260
261static struct hid_driver stantum_driver = {
262 .name = "stantum",
263 .id_table = stantum_devices,
264 .probe = stantum_probe,
265 .remove = stantum_remove,
266 .input_mapping = stantum_input_mapping,
267 .input_mapped = stantum_input_mapped,
268 .usage_table = stantum_grabbed_usages,
269 .event = stantum_event,
270};
271
272static int __init stantum_init(void)
273{
274 return hid_register_driver(&stantum_driver);
275}
276
277static void __exit stantum_exit(void)
278{
279 hid_unregister_driver(&stantum_driver);
280}
281
282module_init(stantum_init);
283module_exit(stantum_exit);
284
diff --git a/drivers/hid/hid-tmff.c b/drivers/hid/hid-tmff.c
index 167ea746fb9c..15434c814793 100644
--- a/drivers/hid/hid-tmff.c
+++ b/drivers/hid/hid-tmff.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/hid.h> 30#include <linux/hid.h>
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/slab.h>
32#include <linux/usb.h> 33#include <linux/usb.h>
33 34
34#include "hid-ids.h" 35#include "hid-ids.h"
@@ -251,6 +252,8 @@ static const struct hid_device_id tm_devices[] = {
251 .driver_data = (unsigned long)ff_rumble }, 252 .driver_data = (unsigned long)ff_rumble },
252 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651), /* FGT Rumble Force Wheel */ 253 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651), /* FGT Rumble Force Wheel */
253 .driver_data = (unsigned long)ff_rumble }, 254 .driver_data = (unsigned long)ff_rumble },
255 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653), /* RGT Force Feedback CLUTCH Raging Wheel */
256 .driver_data = (unsigned long)ff_joystick },
254 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654), /* FGT Force Feedback Wheel */ 257 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654), /* FGT Force Feedback Wheel */
255 .driver_data = (unsigned long)ff_joystick }, 258 .driver_data = (unsigned long)ff_joystick },
256 { } 259 { }
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index 747542172242..f947d8337e21 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -21,6 +21,7 @@
21#include <linux/device.h> 21#include <linux/device.h>
22#include <linux/hid.h> 22#include <linux/hid.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/slab.h>
24 25
25#include "hid-ids.h" 26#include "hid-ids.h"
26 27
@@ -142,6 +143,7 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
142 wdata->butstate = rw; 143 wdata->butstate = rw;
143 input_report_key(input, BTN_0, rw & 0x02); 144 input_report_key(input, BTN_0, rw & 0x02);
144 input_report_key(input, BTN_1, rw & 0x01); 145 input_report_key(input, BTN_1, rw & 0x01);
146 input_report_key(input, BTN_TOOL_FINGER, 0xf0);
145 input_event(input, EV_MSC, MSC_SERIAL, 0xf0); 147 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
146 input_sync(input); 148 input_sync(input);
147 } 149 }
@@ -155,7 +157,9 @@ static int wacom_probe(struct hid_device *hdev,
155 struct hid_input *hidinput; 157 struct hid_input *hidinput;
156 struct input_dev *input; 158 struct input_dev *input;
157 struct wacom_data *wdata; 159 struct wacom_data *wdata;
160 char rep_data[2];
158 int ret; 161 int ret;
162 int limit;
159 163
160 wdata = kzalloc(sizeof(*wdata), GFP_KERNEL); 164 wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);
161 if (wdata == NULL) { 165 if (wdata == NULL) {
@@ -165,6 +169,7 @@ static int wacom_probe(struct hid_device *hdev,
165 169
166 hid_set_drvdata(hdev, wdata); 170 hid_set_drvdata(hdev, wdata);
167 171
172 /* Parse the HID report now */
168 ret = hid_parse(hdev); 173 ret = hid_parse(hdev);
169 if (ret) { 174 if (ret) {
170 dev_err(&hdev->dev, "parse failed\n"); 175 dev_err(&hdev->dev, "parse failed\n");
@@ -177,6 +182,31 @@ static int wacom_probe(struct hid_device *hdev,
177 goto err_free; 182 goto err_free;
178 } 183 }
179 184
185 /*
186 * Note that if the raw queries fail, it's not a hard failure and it
187 * is safe to continue
188 */
189
190 /* Set Wacom mode2 */
191 rep_data[0] = 0x03; rep_data[1] = 0x00;
192 limit = 3;
193 do {
194 ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
195 HID_FEATURE_REPORT);
196 } while (ret < 0 && limit-- > 0);
197 if (ret < 0)
198 dev_warn(&hdev->dev, "failed to poke device #1, %d\n", ret);
199
200 /* 0x06 - high reporting speed, 0x05 - low speed */
201 rep_data[0] = 0x06; rep_data[1] = 0x00;
202 limit = 3;
203 do {
204 ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
205 HID_FEATURE_REPORT);
206 } while (ret < 0 && limit-- > 0);
207 if (ret < 0)
208 dev_warn(&hdev->dev, "failed to poke device #2, %d\n", ret);
209
180 hidinput = list_entry(hdev->inputs.next, struct hid_input, list); 210 hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
181 input = hidinput->input; 211 input = hidinput->input;
182 212
@@ -196,6 +226,9 @@ static int wacom_probe(struct hid_device *hdev,
196 /* Pad */ 226 /* Pad */
197 input->evbit[0] |= BIT(EV_MSC); 227 input->evbit[0] |= BIT(EV_MSC);
198 input->mscbit[0] |= BIT(MSC_SERIAL); 228 input->mscbit[0] |= BIT(MSC_SERIAL);
229 set_bit(BTN_0, input->keybit);
230 set_bit(BTN_1, input->keybit);
231 set_bit(BTN_TOOL_FINGER, input->keybit);
199 232
200 /* Distance, rubber and mouse */ 233 /* Distance, rubber and mouse */
201 input->absbit[0] |= BIT(ABS_DISTANCE); 234 input->absbit[0] |= BIT(ABS_DISTANCE);
@@ -244,7 +277,6 @@ static int __init wacom_init(void)
244 ret = hid_register_driver(&wacom_driver); 277 ret = hid_register_driver(&wacom_driver);
245 if (ret) 278 if (ret)
246 printk(KERN_ERR "can't register wacom driver\n"); 279 printk(KERN_ERR "can't register wacom driver\n");
247 printk(KERN_ERR "wacom driver registered\n");
248 return ret; 280 return ret;
249} 281}
250 282
diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c
index a79f0d78c6be..b7acceabba80 100644
--- a/drivers/hid/hid-zpff.c
+++ b/drivers/hid/hid-zpff.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/hid.h> 24#include <linux/hid.h>
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/slab.h>
26#include <linux/usb.h> 27#include <linux/usb.h>
27 28
28#include "hid-ids.h" 29#include "hid-ids.h"
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index cdd136942bca..6eadf1a9b3cc 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -28,6 +28,7 @@
28#include <linux/poll.h> 28#include <linux/poll.h>
29#include <linux/device.h> 29#include <linux/device.h>
30#include <linux/major.h> 30#include <linux/major.h>
31#include <linux/slab.h>
31#include <linux/hid.h> 32#include <linux/hid.h>
32#include <linux/mutex.h> 33#include <linux/mutex.h>
33#include <linux/sched.h> 34#include <linux/sched.h>
@@ -134,7 +135,7 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t
134 goto out; 135 goto out;
135 } 136 }
136 137
137 ret = dev->hid_output_raw_report(dev, buf, count); 138 ret = dev->hid_output_raw_report(dev, buf, count, HID_OUTPUT_REPORT);
138out: 139out:
139 kfree(buf); 140 kfree(buf);
140 return ret; 141 return ret;
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 03bd703255a3..7b85b696fdab 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -5,7 +5,7 @@
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2007-2008 Oliver Neukum 7 * Copyright (c) 2007-2008 Oliver Neukum
8 * Copyright (c) 2006-2009 Jiri Kosina 8 * Copyright (c) 2006-2010 Jiri Kosina
9 */ 9 */
10 10
11/* 11/*
@@ -41,8 +41,6 @@
41 * Version Information 41 * Version Information
42 */ 42 */
43 43
44#define DRIVER_VERSION "v2.6"
45#define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik, Jiri Kosina"
46#define DRIVER_DESC "USB HID core driver" 44#define DRIVER_DESC "USB HID core driver"
47#define DRIVER_LICENSE "GPL" 45#define DRIVER_LICENSE "GPL"
48 46
@@ -318,6 +316,7 @@ static int hid_submit_out(struct hid_device *hid)
318 err_hid("usb_submit_urb(out) failed"); 316 err_hid("usb_submit_urb(out) failed");
319 return -1; 317 return -1;
320 } 318 }
319 usbhid->last_out = jiffies;
321 } else { 320 } else {
322 /* 321 /*
323 * queue work to wake up the device. 322 * queue work to wake up the device.
@@ -379,6 +378,7 @@ static int hid_submit_ctrl(struct hid_device *hid)
379 err_hid("usb_submit_urb(ctrl) failed"); 378 err_hid("usb_submit_urb(ctrl) failed");
380 return -1; 379 return -1;
381 } 380 }
381 usbhid->last_ctrl = jiffies;
382 } else { 382 } else {
383 /* 383 /*
384 * queue work to wake up the device. 384 * queue work to wake up the device.
@@ -514,9 +514,20 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
514 usbhid->out[usbhid->outhead].report = report; 514 usbhid->out[usbhid->outhead].report = report;
515 usbhid->outhead = head; 515 usbhid->outhead = head;
516 516
517 if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl)) 517 if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl)) {
518 if (hid_submit_out(hid)) 518 if (hid_submit_out(hid))
519 clear_bit(HID_OUT_RUNNING, &usbhid->iofl); 519 clear_bit(HID_OUT_RUNNING, &usbhid->iofl);
520 } else {
521 /*
522 * the queue is known to run
523 * but an earlier request may be stuck
524 * we may need to time out
525 * no race because this is called under
526 * spinlock
527 */
528 if (time_after(jiffies, usbhid->last_out + HZ * 5))
529 usb_unlink_urb(usbhid->urbout);
530 }
520 return; 531 return;
521 } 532 }
522 533
@@ -537,9 +548,20 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
537 usbhid->ctrl[usbhid->ctrlhead].dir = dir; 548 usbhid->ctrl[usbhid->ctrlhead].dir = dir;
538 usbhid->ctrlhead = head; 549 usbhid->ctrlhead = head;
539 550
540 if (!test_and_set_bit(HID_CTRL_RUNNING, &usbhid->iofl)) 551 if (!test_and_set_bit(HID_CTRL_RUNNING, &usbhid->iofl)) {
541 if (hid_submit_ctrl(hid)) 552 if (hid_submit_ctrl(hid))
542 clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); 553 clear_bit(HID_CTRL_RUNNING, &usbhid->iofl);
554 } else {
555 /*
556 * the queue is known to run
557 * but an earlier request may be stuck
558 * we may need to time out
559 * no race because this is called under
560 * spinlock
561 */
562 if (time_after(jiffies, usbhid->last_ctrl + HZ * 5))
563 usb_unlink_urb(usbhid->urbctrl);
564 }
543} 565}
544 566
545void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir) 567void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir)
@@ -776,7 +798,8 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
776 return 0; 798 return 0;
777} 799}
778 800
779static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count) 801static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count,
802 unsigned char report_type)
780{ 803{
781 struct usbhid_device *usbhid = hid->driver_data; 804 struct usbhid_device *usbhid = hid->driver_data;
782 struct usb_device *dev = hid_to_usb_dev(hid); 805 struct usb_device *dev = hid_to_usb_dev(hid);
@@ -787,7 +810,7 @@ static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t co
787 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 810 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
788 HID_REQ_SET_REPORT, 811 HID_REQ_SET_REPORT,
789 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 812 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
790 ((HID_OUTPUT_REPORT + 1) << 8) | *buf, 813 ((report_type + 1) << 8) | *buf,
791 interface->desc.bInterfaceNumber, buf + 1, count - 1, 814 interface->desc.bInterfaceNumber, buf + 1, count - 1,
792 USB_CTRL_SET_TIMEOUT); 815 USB_CTRL_SET_TIMEOUT);
793 816
@@ -976,16 +999,6 @@ static int usbhid_start(struct hid_device *hid)
976 } 999 }
977 } 1000 }
978 1001
979 init_waitqueue_head(&usbhid->wait);
980 INIT_WORK(&usbhid->reset_work, hid_reset);
981 INIT_WORK(&usbhid->restart_work, __usbhid_restart_queues);
982 setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid);
983
984 spin_lock_init(&usbhid->lock);
985
986 usbhid->intf = intf;
987 usbhid->ifnum = interface->desc.bInterfaceNumber;
988
989 usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); 1002 usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL);
990 if (!usbhid->urbctrl) { 1003 if (!usbhid->urbctrl) {
991 ret = -ENOMEM; 1004 ret = -ENOMEM;
@@ -998,7 +1011,8 @@ static int usbhid_start(struct hid_device *hid)
998 usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma; 1011 usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma;
999 usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); 1012 usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
1000 1013
1001 usbhid_init_reports(hid); 1014 if (!(hid->quirks & HID_QUIRK_NO_INIT_REPORTS))
1015 usbhid_init_reports(hid);
1002 1016
1003 set_bit(HID_STARTED, &usbhid->iofl); 1017 set_bit(HID_STARTED, &usbhid->iofl);
1004 1018
@@ -1155,6 +1169,14 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
1155 1169
1156 hid->driver_data = usbhid; 1170 hid->driver_data = usbhid;
1157 usbhid->hid = hid; 1171 usbhid->hid = hid;
1172 usbhid->intf = intf;
1173 usbhid->ifnum = interface->desc.bInterfaceNumber;
1174
1175 init_waitqueue_head(&usbhid->wait);
1176 INIT_WORK(&usbhid->reset_work, hid_reset);
1177 INIT_WORK(&usbhid->restart_work, __usbhid_restart_queues);
1178 setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid);
1179 spin_lock_init(&usbhid->lock);
1158 1180
1159 ret = hid_add_device(hid); 1181 ret = hid_add_device(hid);
1160 if (ret) { 1182 if (ret) {
@@ -1254,10 +1276,9 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
1254{ 1276{
1255 struct hid_device *hid = usb_get_intfdata(intf); 1277 struct hid_device *hid = usb_get_intfdata(intf);
1256 struct usbhid_device *usbhid = hid->driver_data; 1278 struct usbhid_device *usbhid = hid->driver_data;
1257 struct usb_device *udev = interface_to_usbdev(intf);
1258 int status; 1279 int status;
1259 1280
1260 if (udev->auto_pm) { 1281 if (message.event & PM_EVENT_AUTO) {
1261 spin_lock_irq(&usbhid->lock); /* Sync with error handler */ 1282 spin_lock_irq(&usbhid->lock); /* Sync with error handler */
1262 if (!test_bit(HID_RESET_PENDING, &usbhid->iofl) 1283 if (!test_bit(HID_RESET_PENDING, &usbhid->iofl)
1263 && !test_bit(HID_CLEAR_HALT, &usbhid->iofl) 1284 && !test_bit(HID_CLEAR_HALT, &usbhid->iofl)
@@ -1282,7 +1303,7 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
1282 return -EIO; 1303 return -EIO;
1283 } 1304 }
1284 1305
1285 if (!ignoreled && udev->auto_pm) { 1306 if (!ignoreled && (message.event & PM_EVENT_AUTO)) {
1286 spin_lock_irq(&usbhid->lock); 1307 spin_lock_irq(&usbhid->lock);
1287 if (test_bit(HID_LED_ON, &usbhid->iofl)) { 1308 if (test_bit(HID_LED_ON, &usbhid->iofl)) {
1288 spin_unlock_irq(&usbhid->lock); 1309 spin_unlock_irq(&usbhid->lock);
@@ -1295,7 +1316,8 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
1295 hid_cancel_delayed_stuff(usbhid); 1316 hid_cancel_delayed_stuff(usbhid);
1296 hid_cease_io(usbhid); 1317 hid_cease_io(usbhid);
1297 1318
1298 if (udev->auto_pm && test_bit(HID_KEYS_PRESSED, &usbhid->iofl)) { 1319 if ((message.event & PM_EVENT_AUTO) &&
1320 test_bit(HID_KEYS_PRESSED, &usbhid->iofl)) {
1299 /* lost race against keypresses */ 1321 /* lost race against keypresses */
1300 status = hid_start_in(hid); 1322 status = hid_start_in(hid);
1301 if (status < 0) 1323 if (status < 0)
@@ -1343,7 +1365,7 @@ static int hid_reset_resume(struct usb_interface *intf)
1343 1365
1344#endif /* CONFIG_PM */ 1366#endif /* CONFIG_PM */
1345 1367
1346static struct usb_device_id hid_usb_ids [] = { 1368static const struct usb_device_id hid_usb_ids[] = {
1347 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS, 1369 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS,
1348 .bInterfaceClass = USB_INTERFACE_CLASS_HID }, 1370 .bInterfaceClass = USB_INTERFACE_CLASS_HID },
1349 { } /* Terminating entry */ 1371 { } /* Terminating entry */
@@ -1395,8 +1417,7 @@ static int __init hid_init(void)
1395 retval = usb_register(&hid_driver); 1417 retval = usb_register(&hid_driver);
1396 if (retval) 1418 if (retval)
1397 goto usb_register_fail; 1419 goto usb_register_fail;
1398 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 1420 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n");
1399 DRIVER_DESC "\n");
1400 1421
1401 return 0; 1422 return 0;
1402usb_register_fail: 1423usb_register_fail:
@@ -1423,6 +1444,8 @@ static void __exit hid_exit(void)
1423module_init(hid_init); 1444module_init(hid_init);
1424module_exit(hid_exit); 1445module_exit(hid_exit);
1425 1446
1426MODULE_AUTHOR(DRIVER_AUTHOR); 1447MODULE_AUTHOR("Andreas Gal");
1448MODULE_AUTHOR("Vojtech Pavlik");
1449MODULE_AUTHOR("Jiri Kosina");
1427MODULE_DESCRIPTION(DRIVER_DESC); 1450MODULE_DESCRIPTION(DRIVER_DESC);
1428MODULE_LICENSE(DRIVER_LICENSE); 1451MODULE_LICENSE(DRIVER_LICENSE);
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
index 484e3eec2f88..ef381d79cfa8 100644
--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -25,6 +25,7 @@
25#define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg) 25#define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg)
26 26
27#include <linux/input.h> 27#include <linux/input.h>
28#include <linux/slab.h>
28#include <linux/usb.h> 29#include <linux/usb.h>
29 30
30#include <linux/hid.h> 31#include <linux/hid.h>
@@ -1181,12 +1182,11 @@ static void pidff_reset(struct pidff_device *pidff)
1181 usbhid_wait_io(hid); 1182 usbhid_wait_io(hid);
1182 1183
1183 if (pidff->pool[PID_SIMULTANEOUS_MAX].value) { 1184 if (pidff->pool[PID_SIMULTANEOUS_MAX].value) {
1184 int sim_effects = pidff->pool[PID_SIMULTANEOUS_MAX].value[0]; 1185 while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) {
1185 while (sim_effects < 2) {
1186 if (i++ > 20) { 1186 if (i++ > 20) {
1187 printk(KERN_WARNING "hid-pidff: device reports " 1187 printk(KERN_WARNING "hid-pidff: device reports "
1188 "%d simultaneous effects\n", 1188 "%d simultaneous effects\n",
1189 sim_effects); 1189 pidff->pool[PID_SIMULTANEOUS_MAX].value[0]);
1190 break; 1190 break;
1191 } 1191 }
1192 debug("pid_pool requested again"); 1192 debug("pid_pool requested again");
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 0d9045aa2c4b..1152f9b5fd44 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/hid.h> 18#include <linux/hid.h>
19#include <linux/slab.h>
19 20
20#include "../hid-ids.h" 21#include "../hid-ids.h"
21 22
@@ -37,13 +38,16 @@ static const struct hid_blacklist {
37 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 38 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
38 { USB_VENDOR_ID_NATSU, USB_DEVICE_ID_NATSU_GAMEPAD, HID_QUIRK_BADPAD }, 39 { USB_VENDOR_ID_NATSU, USB_DEVICE_ID_NATSU_GAMEPAD, HID_QUIRK_BADPAD },
39 { USB_VENDOR_ID_NEC, USB_DEVICE_ID_NEC_USB_GAME_PAD, HID_QUIRK_BADPAD }, 40 { USB_VENDOR_ID_NEC, USB_DEVICE_ID_NEC_USB_GAME_PAD, HID_QUIRK_BADPAD },
41 { USB_VENDOR_ID_NEXTWINDOW, USB_DEVICE_ID_NEXTWINDOW_TOUCHSCREEN, HID_QUIRK_MULTI_INPUT},
40 { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD }, 42 { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD },
41 { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD }, 43 { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD },
42 44
43 { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL }, 45 { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL },
44 46
47 { USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH, HID_QUIRK_MULTI_INPUT },
45 { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, 48 { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
46 { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT }, 49 { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT },
50 { USB_VENDOR_ID_TOUCHPACK, USB_DEVICE_ID_TOUCHPACK_RTS, HID_QUIRK_MULTI_INPUT },
47 51
48 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET }, 52 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET },
49 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET }, 53 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET },
@@ -53,11 +57,15 @@ static const struct hid_blacklist {
53 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_COMBATSTICK, HID_QUIRK_NOGET }, 57 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_COMBATSTICK, HID_QUIRK_NOGET },
54 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE, HID_QUIRK_NOGET }, 58 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE, HID_QUIRK_NOGET },
55 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS, HID_QUIRK_NOGET }, 59 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS, HID_QUIRK_NOGET },
60 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET },
56 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, 61 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
57 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 62 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
63 { USB_VENDOR_ID_PRODIGE, USB_DEVICE_ID_PRODIGE_CORDLESS, HID_QUIRK_NOGET },
64 { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NOGET },
58 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, 65 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
59 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, 66 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
60 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT }, 67 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT },
68 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U, HID_QUIRK_MULTI_INPUT },
61 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, 69 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
62 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 70 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
63 71
@@ -280,7 +288,7 @@ u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct)
280 if (idVendor == USB_VENDOR_ID_NCR && 288 if (idVendor == USB_VENDOR_ID_NCR &&
281 idProduct >= USB_DEVICE_ID_NCR_FIRST && 289 idProduct >= USB_DEVICE_ID_NCR_FIRST &&
282 idProduct <= USB_DEVICE_ID_NCR_LAST) 290 idProduct <= USB_DEVICE_ID_NCR_LAST)
283 return HID_QUIRK_NOGET; 291 return HID_QUIRK_NO_INIT_REPORTS;
284 292
285 down_read(&dquirks_rwsem); 293 down_read(&dquirks_rwsem);
286 bl_entry = usbhid_exists_dquirk(idVendor, idProduct); 294 bl_entry = usbhid_exists_dquirk(idVendor, idProduct);
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 8b6ee247bfe4..433602aed468 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -265,9 +265,10 @@ static int hiddev_release(struct inode * inode, struct file * file)
265static int hiddev_open(struct inode *inode, struct file *file) 265static int hiddev_open(struct inode *inode, struct file *file)
266{ 266{
267 struct hiddev_list *list; 267 struct hiddev_list *list;
268 int res; 268 int res, i;
269 269
270 int i = iminor(inode) - HIDDEV_MINOR_BASE; 270 lock_kernel();
271 i = iminor(inode) - HIDDEV_MINOR_BASE;
271 272
272 if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i]) 273 if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i])
273 return -ENODEV; 274 return -ENODEV;
@@ -313,10 +314,12 @@ static int hiddev_open(struct inode *inode, struct file *file)
313 usbhid_open(hid); 314 usbhid_open(hid);
314 } 315 }
315 316
317 unlock_kernel();
316 return 0; 318 return 0;
317bail: 319bail:
318 file->private_data = NULL; 320 file->private_data = NULL;
319 kfree(list); 321 kfree(list);
322 unlock_kernel();
320 return res; 323 return res;
321} 324}
322 325
@@ -450,7 +453,6 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
450 uref_multi = kmalloc(sizeof(struct hiddev_usage_ref_multi), GFP_KERNEL); 453 uref_multi = kmalloc(sizeof(struct hiddev_usage_ref_multi), GFP_KERNEL);
451 if (!uref_multi) 454 if (!uref_multi)
452 return -ENOMEM; 455 return -ENOMEM;
453 lock_kernel();
454 uref = &uref_multi->uref; 456 uref = &uref_multi->uref;
455 if (cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) { 457 if (cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) {
456 if (copy_from_user(uref_multi, user_arg, 458 if (copy_from_user(uref_multi, user_arg,
@@ -528,7 +530,6 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
528 530
529 case HIDIOCGCOLLECTIONINDEX: 531 case HIDIOCGCOLLECTIONINDEX:
530 i = field->usage[uref->usage_index].collection_index; 532 i = field->usage[uref->usage_index].collection_index;
531 unlock_kernel();
532 kfree(uref_multi); 533 kfree(uref_multi);
533 return i; 534 return i;
534 case HIDIOCGUSAGES: 535 case HIDIOCGUSAGES:
@@ -547,15 +548,12 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
547 } 548 }
548 549
549goodreturn: 550goodreturn:
550 unlock_kernel();
551 kfree(uref_multi); 551 kfree(uref_multi);
552 return 0; 552 return 0;
553fault: 553fault:
554 unlock_kernel();
555 kfree(uref_multi); 554 kfree(uref_multi);
556 return -EFAULT; 555 return -EFAULT;
557inval: 556inval:
558 unlock_kernel();
559 kfree(uref_multi); 557 kfree(uref_multi);
560 return -EINVAL; 558 return -EINVAL;
561 } 559 }
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h
index 08f505ca2e3d..ec20400c7f29 100644
--- a/drivers/hid/usbhid/usbhid.h
+++ b/drivers/hid/usbhid/usbhid.h
@@ -80,12 +80,14 @@ struct usbhid_device {
80 unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */ 80 unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */
81 char *ctrlbuf; /* Control buffer */ 81 char *ctrlbuf; /* Control buffer */
82 dma_addr_t ctrlbuf_dma; /* Control buffer dma */ 82 dma_addr_t ctrlbuf_dma; /* Control buffer dma */
83 unsigned long last_ctrl; /* record of last output for timeouts */
83 84
84 struct urb *urbout; /* Output URB */ 85 struct urb *urbout; /* Output URB */
85 struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */ 86 struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */
86 unsigned char outhead, outtail; /* Output pipe fifo head & tail */ 87 unsigned char outhead, outtail; /* Output pipe fifo head & tail */
87 char *outbuf; /* Output buffer */ 88 char *outbuf; /* Output buffer */
88 dma_addr_t outbuf_dma; /* Output buffer dma */ 89 dma_addr_t outbuf_dma; /* Output buffer dma */
90 unsigned long last_out; /* record of last output for timeouts */
89 91
90 spinlock_t lock; /* fifo spinlock */ 92 spinlock_t lock; /* fifo spinlock */
91 unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ 93 unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
index b342926dd7fc..f843443ba5c3 100644
--- a/drivers/hid/usbhid/usbkbd.c
+++ b/drivers/hid/usbhid/usbkbd.c
@@ -266,7 +266,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
266 le16_to_cpu(dev->descriptor.idProduct)); 266 le16_to_cpu(dev->descriptor.idProduct));
267 267
268 usb_make_path(dev, kbd->phys, sizeof(kbd->phys)); 268 usb_make_path(dev, kbd->phys, sizeof(kbd->phys));
269 strlcpy(kbd->phys, "/input0", sizeof(kbd->phys)); 269 strlcat(kbd->phys, "/input0", sizeof(kbd->phys));
270 270
271 input_dev->name = kbd->name; 271 input_dev->name = kbd->name;
272 input_dev->phys = kbd->phys; 272 input_dev->phys = kbd->phys;