diff options
Diffstat (limited to 'drivers/usb/input')
-rw-r--r-- | drivers/usb/input/Kconfig | 20 | ||||
-rw-r--r-- | drivers/usb/input/Makefile | 4 | ||||
-rw-r--r-- | drivers/usb/input/gtco.c | 1104 | ||||
-rw-r--r-- | drivers/usb/input/hid-core.c | 116 | ||||
-rw-r--r-- | drivers/usb/input/hid-ff.c | 3 | ||||
-rw-r--r-- | drivers/usb/input/hid-lgff.c | 4 | ||||
-rw-r--r-- | drivers/usb/input/hid-plff.c | 129 |
7 files changed, 1328 insertions, 52 deletions
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig index c7d887540d8d..2e71d3cca198 100644 --- a/drivers/usb/input/Kconfig +++ b/drivers/usb/input/Kconfig | |||
@@ -69,6 +69,14 @@ config LOGITECH_FF | |||
69 | Note: if you say N here, this device will still be supported, but without | 69 | Note: if you say N here, this device will still be supported, but without |
70 | force feedback. | 70 | force feedback. |
71 | 71 | ||
72 | config PANTHERLORD_FF | ||
73 | bool "PantherLord USB/PS2 2in1 Adapter support" | ||
74 | depends on HID_FF | ||
75 | select INPUT_FF_MEMLESS if USB_HID | ||
76 | help | ||
77 | Say Y here if you have a PantherLord USB/PS2 2in1 Adapter and want | ||
78 | to enable force feedback support for it. | ||
79 | |||
72 | config THRUSTMASTER_FF | 80 | config THRUSTMASTER_FF |
73 | bool "ThrustMaster FireStorm Dual Power 2 support (EXPERIMENTAL)" | 81 | bool "ThrustMaster FireStorm Dual Power 2 support (EXPERIMENTAL)" |
74 | depends on HID_FF && EXPERIMENTAL | 82 | depends on HID_FF && EXPERIMENTAL |
@@ -344,3 +352,15 @@ config USB_APPLETOUCH | |||
344 | 352 | ||
345 | To compile this driver as a module, choose M here: the | 353 | To compile this driver as a module, choose M here: the |
346 | module will be called appletouch. | 354 | module will be called appletouch. |
355 | |||
356 | config USB_GTCO | ||
357 | tristate "GTCO CalComp/InterWrite USB Support" | ||
358 | depends on USB && INPUT | ||
359 | ---help--- | ||
360 | Say Y here if you want to use the USB version of the GTCO | ||
361 | CalComp/InterWrite Tablet. Make sure to say Y to "Mouse support" | ||
362 | (CONFIG_INPUT_MOUSEDEV) and/or "Event interface support" | ||
363 | (CONFIG_INPUT_EVDEV) as well. | ||
364 | |||
365 | To compile this driver as a module, choose M here: the | ||
366 | module will be called gtco. | ||
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile index 1a24b5bfa05f..a9d206c945e9 100644 --- a/drivers/usb/input/Makefile +++ b/drivers/usb/input/Makefile | |||
@@ -17,6 +17,9 @@ endif | |||
17 | ifeq ($(CONFIG_LOGITECH_FF),y) | 17 | ifeq ($(CONFIG_LOGITECH_FF),y) |
18 | usbhid-objs += hid-lgff.o | 18 | usbhid-objs += hid-lgff.o |
19 | endif | 19 | endif |
20 | ifeq ($(CONFIG_PANTHERLORD_FF),y) | ||
21 | usbhid-objs += hid-plff.o | ||
22 | endif | ||
20 | ifeq ($(CONFIG_THRUSTMASTER_FF),y) | 23 | ifeq ($(CONFIG_THRUSTMASTER_FF),y) |
21 | usbhid-objs += hid-tmff.o | 24 | usbhid-objs += hid-tmff.o |
22 | endif | 25 | endif |
@@ -45,6 +48,7 @@ obj-$(CONFIG_USB_ACECAD) += acecad.o | |||
45 | obj-$(CONFIG_USB_YEALINK) += yealink.o | 48 | obj-$(CONFIG_USB_YEALINK) += yealink.o |
46 | obj-$(CONFIG_USB_XPAD) += xpad.o | 49 | obj-$(CONFIG_USB_XPAD) += xpad.o |
47 | obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o | 50 | obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o |
51 | obj-$(CONFIG_USB_GTCO) += gtco.o | ||
48 | 52 | ||
49 | ifeq ($(CONFIG_USB_DEBUG),y) | 53 | ifeq ($(CONFIG_USB_DEBUG),y) |
50 | EXTRA_CFLAGS += -DDEBUG | 54 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/usb/input/gtco.c b/drivers/usb/input/gtco.c new file mode 100644 index 000000000000..203cdc1bbba4 --- /dev/null +++ b/drivers/usb/input/gtco.c | |||
@@ -0,0 +1,1104 @@ | |||
1 | /* -*- linux-c -*- | ||
2 | |||
3 | GTCO digitizer USB driver | ||
4 | |||
5 | Use the err(), dbg() and info() macros from usb.h for system logging | ||
6 | |||
7 | TO CHECK: Is pressure done right on report 5? | ||
8 | |||
9 | Copyright (C) 2006 GTCO CalComp | ||
10 | |||
11 | This program is free software; you can redistribute it and/or | ||
12 | modify it under the terms of the GNU General Public License | ||
13 | as published by the Free Software Foundation; version 2 | ||
14 | of the License. | ||
15 | |||
16 | This program is distributed in the hope that it will be useful, | ||
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | GNU General Public License for more details. | ||
20 | |||
21 | You should have received a copy of the GNU General Public License | ||
22 | along with this program; if not, write to the Free Software | ||
23 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
24 | |||
25 | Permission to use, copy, modify, distribute, and sell this software and its | ||
26 | documentation for any purpose is hereby granted without fee, provided that | ||
27 | the above copyright notice appear in all copies and that both that | ||
28 | copyright notice and this permission notice appear in supporting | ||
29 | documentation, and that the name of GTCO-CalComp not be used in advertising | ||
30 | or publicity pertaining to distribution of the software without specific, | ||
31 | written prior permission. GTCO-CalComp makes no representations about the | ||
32 | suitability of this software for any purpose. It is provided "as is" | ||
33 | without express or implied warranty. | ||
34 | |||
35 | GTCO-CALCOMP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
36 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | ||
37 | EVENT SHALL GTCO-CALCOMP BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
38 | CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | ||
39 | DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | ||
40 | TORTIOUS ACTIONS, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
41 | PERFORMANCE OF THIS SOFTWARE. | ||
42 | |||
43 | GTCO CalComp, Inc. | ||
44 | 7125 Riverwood Drive | ||
45 | Columbia, MD 21046 | ||
46 | |||
47 | Jeremy Roberson jroberson@gtcocalcomp.com | ||
48 | Scott Hill shill@gtcocalcomp.com | ||
49 | */ | ||
50 | |||
51 | |||
52 | |||
53 | /*#define DEBUG*/ | ||
54 | |||
55 | #include <linux/kernel.h> | ||
56 | #include <linux/module.h> | ||
57 | #include <linux/errno.h> | ||
58 | #include <linux/init.h> | ||
59 | #include <linux/slab.h> | ||
60 | #include <linux/input.h> | ||
61 | #include <linux/usb.h> | ||
62 | #include <asm/uaccess.h> | ||
63 | #include <asm/unaligned.h> | ||
64 | #include <asm/byteorder.h> | ||
65 | |||
66 | |||
67 | #include <linux/version.h> | ||
68 | #include <linux/usb/input.h> | ||
69 | |||
70 | /* Version with a Major number of 2 is for kernel inclusion only. */ | ||
71 | #define GTCO_VERSION "2.00.0006" | ||
72 | |||
73 | |||
74 | /* MACROS */ | ||
75 | |||
76 | #define VENDOR_ID_GTCO 0x078C | ||
77 | #define PID_400 0x400 | ||
78 | #define PID_401 0x401 | ||
79 | #define PID_1000 0x1000 | ||
80 | #define PID_1001 0x1001 | ||
81 | #define PID_1002 0x1002 | ||
82 | |||
83 | /* Max size of a single report */ | ||
84 | #define REPORT_MAX_SIZE 10 | ||
85 | |||
86 | |||
87 | /* Bitmask whether pen is in range */ | ||
88 | #define MASK_INRANGE 0x20 | ||
89 | #define MASK_BUTTON 0x01F | ||
90 | |||
91 | #define PATHLENGTH 64 | ||
92 | |||
93 | /* DATA STRUCTURES */ | ||
94 | |||
95 | /* Device table */ | ||
96 | static struct usb_device_id gtco_usbid_table [] = { | ||
97 | { USB_DEVICE(VENDOR_ID_GTCO, PID_400) }, | ||
98 | { USB_DEVICE(VENDOR_ID_GTCO, PID_401) }, | ||
99 | { USB_DEVICE(VENDOR_ID_GTCO, PID_1000) }, | ||
100 | { USB_DEVICE(VENDOR_ID_GTCO, PID_1001) }, | ||
101 | { USB_DEVICE(VENDOR_ID_GTCO, PID_1002) }, | ||
102 | { } | ||
103 | }; | ||
104 | MODULE_DEVICE_TABLE (usb, gtco_usbid_table); | ||
105 | |||
106 | |||
107 | /* Structure to hold all of our device specific stuff */ | ||
108 | struct gtco { | ||
109 | |||
110 | struct input_dev *inputdevice; /* input device struct pointer */ | ||
111 | struct usb_device *usbdev; /* the usb device for this device */ | ||
112 | struct urb *urbinfo; /* urb for incoming reports */ | ||
113 | dma_addr_t buf_dma; /* dma addr of the data buffer*/ | ||
114 | unsigned char * buffer; /* databuffer for reports */ | ||
115 | |||
116 | char usbpath[PATHLENGTH]; | ||
117 | int openCount; | ||
118 | |||
119 | /* Information pulled from Report Descriptor */ | ||
120 | u32 usage; | ||
121 | u32 min_X; | ||
122 | u32 max_X; | ||
123 | u32 min_Y; | ||
124 | u32 max_Y; | ||
125 | s8 mintilt_X; | ||
126 | s8 maxtilt_X; | ||
127 | s8 mintilt_Y; | ||
128 | s8 maxtilt_Y; | ||
129 | u32 maxpressure; | ||
130 | u32 minpressure; | ||
131 | }; | ||
132 | |||
133 | |||
134 | |||
135 | /* Code for parsing the HID REPORT DESCRIPTOR */ | ||
136 | |||
137 | /* From HID1.11 spec */ | ||
138 | struct hid_descriptor | ||
139 | { | ||
140 | struct usb_descriptor_header header; | ||
141 | __le16 bcdHID; | ||
142 | u8 bCountryCode; | ||
143 | u8 bNumDescriptors; | ||
144 | u8 bDescriptorType; | ||
145 | __le16 wDescriptorLength; | ||
146 | } __attribute__ ((packed)); | ||
147 | |||
148 | |||
149 | #define HID_DESCRIPTOR_SIZE 9 | ||
150 | #define HID_DEVICE_TYPE 33 | ||
151 | #define REPORT_DEVICE_TYPE 34 | ||
152 | |||
153 | |||
154 | #define PREF_TAG(x) ((x)>>4) | ||
155 | #define PREF_TYPE(x) ((x>>2)&0x03) | ||
156 | #define PREF_SIZE(x) ((x)&0x03) | ||
157 | |||
158 | #define TYPE_MAIN 0 | ||
159 | #define TYPE_GLOBAL 1 | ||
160 | #define TYPE_LOCAL 2 | ||
161 | #define TYPE_RESERVED 3 | ||
162 | |||
163 | #define TAG_MAIN_INPUT 0x8 | ||
164 | #define TAG_MAIN_OUTPUT 0x9 | ||
165 | #define TAG_MAIN_FEATURE 0xB | ||
166 | #define TAG_MAIN_COL_START 0xA | ||
167 | #define TAG_MAIN_COL_END 0xC | ||
168 | |||
169 | #define TAG_GLOB_USAGE 0 | ||
170 | #define TAG_GLOB_LOG_MIN 1 | ||
171 | #define TAG_GLOB_LOG_MAX 2 | ||
172 | #define TAG_GLOB_PHYS_MIN 3 | ||
173 | #define TAG_GLOB_PHYS_MAX 4 | ||
174 | #define TAG_GLOB_UNIT_EXP 5 | ||
175 | #define TAG_GLOB_UNIT 6 | ||
176 | #define TAG_GLOB_REPORT_SZ 7 | ||
177 | #define TAG_GLOB_REPORT_ID 8 | ||
178 | #define TAG_GLOB_REPORT_CNT 9 | ||
179 | #define TAG_GLOB_PUSH 10 | ||
180 | #define TAG_GLOB_POP 11 | ||
181 | |||
182 | #define TAG_GLOB_MAX 12 | ||
183 | |||
184 | #define DIGITIZER_USAGE_TIP_PRESSURE 0x30 | ||
185 | #define DIGITIZER_USAGE_TILT_X 0x3D | ||
186 | #define DIGITIZER_USAGE_TILT_Y 0x3E | ||
187 | |||
188 | |||
189 | /* | ||
190 | * | ||
191 | * This is an abbreviated parser for the HID Report Descriptor. We | ||
192 | * know what devices we are talking to, so this is by no means meant | ||
193 | * to be generic. We can make some safe assumptions: | ||
194 | * | ||
195 | * - We know there are no LONG tags, all short | ||
196 | * - We know that we have no MAIN Feature and MAIN Output items | ||
197 | * - We know what the IRQ reports are supposed to look like. | ||
198 | * | ||
199 | * The main purpose of this is to use the HID report desc to figure | ||
200 | * out the mins and maxs of the fields in the IRQ reports. The IRQ | ||
201 | * reports for 400/401 change slightly if the max X is bigger than 64K. | ||
202 | * | ||
203 | */ | ||
204 | static void parse_hid_report_descriptor(struct gtco *device, char * report, | ||
205 | int length) | ||
206 | { | ||
207 | int x,i=0; | ||
208 | |||
209 | /* Tag primitive vars */ | ||
210 | __u8 prefix; | ||
211 | __u8 size; | ||
212 | __u8 tag; | ||
213 | __u8 type; | ||
214 | __u8 data = 0; | ||
215 | __u16 data16 = 0; | ||
216 | __u32 data32 = 0; | ||
217 | |||
218 | |||
219 | /* For parsing logic */ | ||
220 | int inputnum = 0; | ||
221 | __u32 usage = 0; | ||
222 | |||
223 | /* Global Values, indexed by TAG */ | ||
224 | __u32 globalval[TAG_GLOB_MAX]; | ||
225 | __u32 oldval[TAG_GLOB_MAX]; | ||
226 | |||
227 | /* Debug stuff */ | ||
228 | char maintype='x'; | ||
229 | char globtype[12]; | ||
230 | int indent=0; | ||
231 | char indentstr[10]=""; | ||
232 | |||
233 | |||
234 | |||
235 | dbg("======>>>>>>PARSE<<<<<<======"); | ||
236 | |||
237 | /* Walk this report and pull out the info we need */ | ||
238 | while (i<length){ | ||
239 | prefix=report[i]; | ||
240 | |||
241 | /* Skip over prefix */ | ||
242 | i++; | ||
243 | |||
244 | /* Determine data size and save the data in the proper variable */ | ||
245 | size = PREF_SIZE(prefix); | ||
246 | switch(size){ | ||
247 | case 1: | ||
248 | data = report[i]; | ||
249 | break; | ||
250 | case 2: | ||
251 | data16 = le16_to_cpu(get_unaligned((__le16*)(&(report[i])))); | ||
252 | break; | ||
253 | case 3: | ||
254 | size = 4; | ||
255 | data32 = le32_to_cpu(get_unaligned((__le32*)(&(report[i])))); | ||
256 | } | ||
257 | |||
258 | /* Skip size of data */ | ||
259 | i+=size; | ||
260 | |||
261 | /* What we do depends on the tag type */ | ||
262 | tag = PREF_TAG(prefix); | ||
263 | type = PREF_TYPE(prefix); | ||
264 | switch(type){ | ||
265 | case TYPE_MAIN: | ||
266 | strcpy(globtype,""); | ||
267 | switch(tag){ | ||
268 | |||
269 | case TAG_MAIN_INPUT: | ||
270 | /* | ||
271 | * The INPUT MAIN tag signifies this is | ||
272 | * information from a report. We need to | ||
273 | * figure out what it is and store the | ||
274 | * min/max values | ||
275 | */ | ||
276 | |||
277 | maintype='I'; | ||
278 | if (data==2){ | ||
279 | strcpy(globtype,"Variable"); | ||
280 | } | ||
281 | if (data==3){ | ||
282 | strcpy(globtype,"Var|Const"); | ||
283 | } | ||
284 | |||
285 | dbg("::::: Saving Report: %d input #%d Max: 0x%X(%d) Min:0x%X(%d) of %d bits", | ||
286 | globalval[TAG_GLOB_REPORT_ID],inputnum, | ||
287 | globalval[TAG_GLOB_LOG_MAX],globalval[TAG_GLOB_LOG_MAX], | ||
288 | globalval[TAG_GLOB_LOG_MIN],globalval[TAG_GLOB_LOG_MIN], | ||
289 | (globalval[TAG_GLOB_REPORT_SZ] * globalval[TAG_GLOB_REPORT_CNT])); | ||
290 | |||
291 | |||
292 | /* | ||
293 | We can assume that the first two input items | ||
294 | are always the X and Y coordinates. After | ||
295 | that, we look for everything else by | ||
296 | local usage value | ||
297 | */ | ||
298 | switch (inputnum){ | ||
299 | case 0: /* X coord */ | ||
300 | dbg("GER: X Usage: 0x%x",usage); | ||
301 | if (device->max_X == 0){ | ||
302 | device->max_X = globalval[TAG_GLOB_LOG_MAX]; | ||
303 | device->min_X = globalval[TAG_GLOB_LOG_MIN]; | ||
304 | } | ||
305 | |||
306 | break; | ||
307 | case 1: /* Y coord */ | ||
308 | dbg("GER: Y Usage: 0x%x",usage); | ||
309 | if (device->max_Y == 0){ | ||
310 | device->max_Y = globalval[TAG_GLOB_LOG_MAX]; | ||
311 | device->min_Y = globalval[TAG_GLOB_LOG_MIN]; | ||
312 | } | ||
313 | break; | ||
314 | default: | ||
315 | /* Tilt X */ | ||
316 | if (usage == DIGITIZER_USAGE_TILT_X){ | ||
317 | if (device->maxtilt_X == 0){ | ||
318 | device->maxtilt_X = globalval[TAG_GLOB_LOG_MAX]; | ||
319 | device->mintilt_X = globalval[TAG_GLOB_LOG_MIN]; | ||
320 | } | ||
321 | } | ||
322 | |||
323 | /* Tilt Y */ | ||
324 | if (usage == DIGITIZER_USAGE_TILT_Y){ | ||
325 | if (device->maxtilt_Y == 0){ | ||
326 | device->maxtilt_Y = globalval[TAG_GLOB_LOG_MAX]; | ||
327 | device->mintilt_Y = globalval[TAG_GLOB_LOG_MIN]; | ||
328 | } | ||
329 | } | ||
330 | |||
331 | |||
332 | /* Pressure */ | ||
333 | if (usage == DIGITIZER_USAGE_TIP_PRESSURE){ | ||
334 | if (device->maxpressure == 0){ | ||
335 | device->maxpressure = globalval[TAG_GLOB_LOG_MAX]; | ||
336 | device->minpressure = globalval[TAG_GLOB_LOG_MIN]; | ||
337 | } | ||
338 | } | ||
339 | |||
340 | break; | ||
341 | } | ||
342 | |||
343 | inputnum++; | ||
344 | |||
345 | |||
346 | break; | ||
347 | case TAG_MAIN_OUTPUT: | ||
348 | maintype='O'; | ||
349 | break; | ||
350 | case TAG_MAIN_FEATURE: | ||
351 | maintype='F'; | ||
352 | break; | ||
353 | case TAG_MAIN_COL_START: | ||
354 | maintype='S'; | ||
355 | |||
356 | if (data==0){ | ||
357 | dbg("======>>>>>> Physical"); | ||
358 | strcpy(globtype,"Physical"); | ||
359 | }else{ | ||
360 | dbg("======>>>>>>"); | ||
361 | } | ||
362 | |||
363 | /* Indent the debug output */ | ||
364 | indent++; | ||
365 | for (x=0;x<indent;x++){ | ||
366 | indentstr[x]='-'; | ||
367 | } | ||
368 | indentstr[x]=0; | ||
369 | |||
370 | /* Save global tags */ | ||
371 | for (x=0;x<TAG_GLOB_MAX;x++){ | ||
372 | oldval[x] = globalval[x]; | ||
373 | } | ||
374 | |||
375 | break; | ||
376 | case TAG_MAIN_COL_END: | ||
377 | dbg("<<<<<<======"); | ||
378 | maintype='E'; | ||
379 | indent--; | ||
380 | for (x=0;x<indent;x++){ | ||
381 | indentstr[x]='-'; | ||
382 | } | ||
383 | indentstr[x]=0; | ||
384 | |||
385 | /* Copy global tags back */ | ||
386 | for (x=0;x<TAG_GLOB_MAX;x++){ | ||
387 | globalval[x] = oldval[x]; | ||
388 | } | ||
389 | |||
390 | break; | ||
391 | } | ||
392 | |||
393 | switch (size){ | ||
394 | case 1: | ||
395 | dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", | ||
396 | indentstr,tag,maintype,size,globtype,data); | ||
397 | break; | ||
398 | case 2: | ||
399 | dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", | ||
400 | indentstr,tag,maintype,size,globtype, data16); | ||
401 | break; | ||
402 | case 4: | ||
403 | dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x", | ||
404 | indentstr,tag,maintype,size,globtype,data32); | ||
405 | break; | ||
406 | } | ||
407 | break; | ||
408 | case TYPE_GLOBAL: | ||
409 | switch(tag){ | ||
410 | case TAG_GLOB_USAGE: | ||
411 | /* | ||
412 | * First time we hit the global usage tag, | ||
413 | * it should tell us the type of device | ||
414 | */ | ||
415 | if (device->usage == 0){ | ||
416 | device->usage = data; | ||
417 | } | ||
418 | strcpy(globtype,"USAGE"); | ||
419 | break; | ||
420 | case TAG_GLOB_LOG_MIN : | ||
421 | strcpy(globtype,"LOG_MIN"); | ||
422 | break; | ||
423 | case TAG_GLOB_LOG_MAX : | ||
424 | strcpy(globtype,"LOG_MAX"); | ||
425 | break; | ||
426 | case TAG_GLOB_PHYS_MIN : | ||
427 | strcpy(globtype,"PHYS_MIN"); | ||
428 | break; | ||
429 | case TAG_GLOB_PHYS_MAX : | ||
430 | strcpy(globtype,"PHYS_MAX"); | ||
431 | break; | ||
432 | case TAG_GLOB_UNIT_EXP : | ||
433 | strcpy(globtype,"EXP"); | ||
434 | break; | ||
435 | case TAG_GLOB_UNIT : | ||
436 | strcpy(globtype,"UNIT"); | ||
437 | break; | ||
438 | case TAG_GLOB_REPORT_SZ : | ||
439 | strcpy(globtype,"REPORT_SZ"); | ||
440 | break; | ||
441 | case TAG_GLOB_REPORT_ID : | ||
442 | strcpy(globtype,"REPORT_ID"); | ||
443 | /* New report, restart numbering */ | ||
444 | inputnum=0; | ||
445 | break; | ||
446 | case TAG_GLOB_REPORT_CNT: | ||
447 | strcpy(globtype,"REPORT_CNT"); | ||
448 | break; | ||
449 | case TAG_GLOB_PUSH : | ||
450 | strcpy(globtype,"PUSH"); | ||
451 | break; | ||
452 | case TAG_GLOB_POP: | ||
453 | strcpy(globtype,"POP"); | ||
454 | break; | ||
455 | } | ||
456 | |||
457 | |||
458 | /* Check to make sure we have a good tag number | ||
459 | so we don't overflow array */ | ||
460 | if (tag < TAG_GLOB_MAX){ | ||
461 | switch (size){ | ||
462 | case 1: | ||
463 | dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data); | ||
464 | globalval[tag]=data; | ||
465 | break; | ||
466 | case 2: | ||
467 | dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data16); | ||
468 | globalval[tag]=data16; | ||
469 | break; | ||
470 | case 4: | ||
471 | dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data32); | ||
472 | globalval[tag]=data32; | ||
473 | break; | ||
474 | } | ||
475 | }else{ | ||
476 | dbg("%sGLOBALTAG: ILLEGAL TAG:%d SIZE: %d ", | ||
477 | indentstr,tag,size); | ||
478 | } | ||
479 | |||
480 | |||
481 | break; | ||
482 | |||
483 | case TYPE_LOCAL: | ||
484 | switch(tag){ | ||
485 | case TAG_GLOB_USAGE: | ||
486 | strcpy(globtype,"USAGE"); | ||
487 | /* Always 1 byte */ | ||
488 | usage = data; | ||
489 | break; | ||
490 | case TAG_GLOB_LOG_MIN : | ||
491 | strcpy(globtype,"MIN"); | ||
492 | break; | ||
493 | case TAG_GLOB_LOG_MAX : | ||
494 | strcpy(globtype,"MAX"); | ||
495 | break; | ||
496 | default: | ||
497 | strcpy(globtype,"UNKNOWN"); | ||
498 | } | ||
499 | |||
500 | switch (size){ | ||
501 | case 1: | ||
502 | dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", | ||
503 | indentstr,tag,globtype,size,data); | ||
504 | break; | ||
505 | case 2: | ||
506 | dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", | ||
507 | indentstr,tag,globtype,size,data16); | ||
508 | break; | ||
509 | case 4: | ||
510 | dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x", | ||
511 | indentstr,tag,globtype,size,data32); | ||
512 | break; | ||
513 | } | ||
514 | |||
515 | break; | ||
516 | } | ||
517 | |||
518 | } | ||
519 | |||
520 | } | ||
521 | |||
522 | |||
523 | |||
524 | /* INPUT DRIVER Routines */ | ||
525 | |||
526 | |||
527 | /* | ||
528 | * Called when opening the input device. This will submit the URB to | ||
529 | * the usb system so we start getting reports | ||
530 | */ | ||
531 | static int gtco_input_open(struct input_dev *inputdev) | ||
532 | { | ||
533 | struct gtco *device; | ||
534 | device = inputdev->private; | ||
535 | |||
536 | device->urbinfo->dev = device->usbdev; | ||
537 | if (usb_submit_urb(device->urbinfo, GFP_KERNEL)) { | ||
538 | return -EIO; | ||
539 | } | ||
540 | return 0; | ||
541 | } | ||
542 | |||
543 | /** | ||
544 | Called when closing the input device. This will unlink the URB | ||
545 | */ | ||
546 | static void gtco_input_close(struct input_dev *inputdev) | ||
547 | { | ||
548 | struct gtco *device = inputdev->private; | ||
549 | |||
550 | usb_kill_urb(device->urbinfo); | ||
551 | |||
552 | } | ||
553 | |||
554 | |||
555 | /* | ||
556 | * Setup input device capabilities. Tell the input system what this | ||
557 | * device is capable of generating. | ||
558 | * | ||
559 | * This information is based on what is read from the HID report and | ||
560 | * placed in the struct gtco structure | ||
561 | * | ||
562 | */ | ||
563 | static void gtco_setup_caps(struct input_dev *inputdev) | ||
564 | { | ||
565 | struct gtco *device = inputdev->private; | ||
566 | |||
567 | |||
568 | /* Which events */ | ||
569 | inputdev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); | ||
570 | |||
571 | |||
572 | /* Misc event menu block */ | ||
573 | inputdev->mscbit[0] = BIT(MSC_SCAN)|BIT(MSC_SERIAL)|BIT(MSC_RAW) ; | ||
574 | |||
575 | |||
576 | /* Absolute values based on HID report info */ | ||
577 | input_set_abs_params(inputdev, ABS_X, device->min_X, device->max_X, | ||
578 | 0, 0); | ||
579 | input_set_abs_params(inputdev, ABS_Y, device->min_Y, device->max_Y, | ||
580 | 0, 0); | ||
581 | |||
582 | /* Proximity */ | ||
583 | input_set_abs_params(inputdev, ABS_DISTANCE, 0, 1, 0, 0); | ||
584 | |||
585 | /* Tilt & pressure */ | ||
586 | input_set_abs_params(inputdev, ABS_TILT_X, device->mintilt_X, | ||
587 | device->maxtilt_X, 0, 0); | ||
588 | input_set_abs_params(inputdev, ABS_TILT_Y, device->mintilt_Y, | ||
589 | device->maxtilt_Y, 0, 0); | ||
590 | input_set_abs_params(inputdev, ABS_PRESSURE, device->minpressure, | ||
591 | device->maxpressure, 0, 0); | ||
592 | |||
593 | |||
594 | /* Transducer */ | ||
595 | input_set_abs_params(inputdev, ABS_MISC, 0,0xFF, 0, 0); | ||
596 | |||
597 | } | ||
598 | |||
599 | |||
600 | |||
601 | /* USB Routines */ | ||
602 | |||
603 | |||
604 | /* | ||
605 | * URB callback routine. Called when we get IRQ reports from the | ||
606 | * digitizer. | ||
607 | * | ||
608 | * This bridges the USB and input device worlds. It generates events | ||
609 | * on the input device based on the USB reports. | ||
610 | */ | ||
611 | static void gtco_urb_callback(struct urb *urbinfo) | ||
612 | { | ||
613 | |||
614 | |||
615 | struct gtco *device = urbinfo->context; | ||
616 | struct input_dev *inputdev; | ||
617 | int rc; | ||
618 | u32 val = 0; | ||
619 | s8 valsigned = 0; | ||
620 | char le_buffer[2]; | ||
621 | |||
622 | inputdev = device->inputdevice; | ||
623 | |||
624 | |||
625 | /* Was callback OK? */ | ||
626 | if ((urbinfo->status == -ECONNRESET ) || | ||
627 | (urbinfo->status == -ENOENT ) || | ||
628 | (urbinfo->status == -ESHUTDOWN )){ | ||
629 | |||
630 | /* Shutdown is occurring. Return and don't queue up any more */ | ||
631 | return; | ||
632 | } | ||
633 | |||
634 | if (urbinfo->status != 0 ) { | ||
635 | /* Some unknown error. Hopefully temporary. Just go and */ | ||
636 | /* requeue an URB */ | ||
637 | goto resubmit; | ||
638 | } | ||
639 | |||
640 | /* | ||
641 | * Good URB, now process | ||
642 | */ | ||
643 | |||
644 | /* PID dependent when we interpret the report */ | ||
645 | if ((inputdev->id.product == PID_1000 )|| | ||
646 | (inputdev->id.product == PID_1001 )|| | ||
647 | (inputdev->id.product == PID_1002 )) | ||
648 | { | ||
649 | |||
650 | /* | ||
651 | * Switch on the report ID | ||
652 | * Conveniently, the reports have more information, the higher | ||
653 | * the report number. We can just fall through the case | ||
654 | * statements if we start with the highest number report | ||
655 | */ | ||
656 | switch(device->buffer[0]){ | ||
657 | case 5: | ||
658 | /* Pressure is 9 bits */ | ||
659 | val = ((u16)(device->buffer[8]) << 1); | ||
660 | val |= (u16)(device->buffer[7] >> 7); | ||
661 | input_report_abs(inputdev, ABS_PRESSURE, | ||
662 | device->buffer[8]); | ||
663 | |||
664 | /* Mask out the Y tilt value used for pressure */ | ||
665 | device->buffer[7] = (u8)((device->buffer[7]) & 0x7F); | ||
666 | |||
667 | |||
668 | /* Fall thru */ | ||
669 | case 4: | ||
670 | /* Tilt */ | ||
671 | |||
672 | /* Sign extend these 7 bit numbers. */ | ||
673 | if (device->buffer[6] & 0x40) | ||
674 | device->buffer[6] |= 0x80; | ||
675 | |||
676 | if (device->buffer[7] & 0x40) | ||
677 | device->buffer[7] |= 0x80; | ||
678 | |||
679 | |||
680 | valsigned = (device->buffer[6]); | ||
681 | input_report_abs(inputdev, ABS_TILT_X, (s32)valsigned); | ||
682 | |||
683 | valsigned = (device->buffer[7]); | ||
684 | input_report_abs(inputdev, ABS_TILT_Y, (s32)valsigned); | ||
685 | |||
686 | /* Fall thru */ | ||
687 | |||
688 | case 2: | ||
689 | case 3: | ||
690 | /* Convert buttons, only 5 bits possible */ | ||
691 | val = (device->buffer[5])&MASK_BUTTON; | ||
692 | |||
693 | /* We don't apply any meaning to the bitmask, | ||
694 | just report */ | ||
695 | input_event(inputdev, EV_MSC, MSC_SERIAL, val); | ||
696 | |||
697 | /* Fall thru */ | ||
698 | case 1: | ||
699 | |||
700 | /* All reports have X and Y coords in the same place */ | ||
701 | val = le16_to_cpu(get_unaligned((__le16 *) &(device->buffer[1]))); | ||
702 | input_report_abs(inputdev, ABS_X, val); | ||
703 | |||
704 | val = le16_to_cpu(get_unaligned((__le16 *) &(device->buffer[3]))); | ||
705 | input_report_abs(inputdev, ABS_Y, val); | ||
706 | |||
707 | |||
708 | /* Ditto for proximity bit */ | ||
709 | if (device->buffer[5]& MASK_INRANGE){ | ||
710 | val = 1; | ||
711 | }else{ | ||
712 | val=0; | ||
713 | } | ||
714 | input_report_abs(inputdev, ABS_DISTANCE, val); | ||
715 | |||
716 | |||
717 | /* Report 1 is an exception to how we handle buttons */ | ||
718 | /* Buttons are an index, not a bitmask */ | ||
719 | if (device->buffer[0] == 1){ | ||
720 | |||
721 | /* Convert buttons, 5 bit index */ | ||
722 | /* Report value of index set as one, | ||
723 | the rest as 0 */ | ||
724 | val = device->buffer[5]& MASK_BUTTON; | ||
725 | dbg("======>>>>>>REPORT 1: val 0x%X(%d)", | ||
726 | val,val); | ||
727 | |||
728 | /* | ||
729 | * We don't apply any meaning to the button | ||
730 | * index, just report it | ||
731 | */ | ||
732 | input_event(inputdev, EV_MSC, MSC_SERIAL, val); | ||
733 | |||
734 | |||
735 | } | ||
736 | |||
737 | break; | ||
738 | case 7: | ||
739 | /* Menu blocks */ | ||
740 | input_event(inputdev, EV_MSC, MSC_SCAN, | ||
741 | device->buffer[1]); | ||
742 | |||
743 | |||
744 | break; | ||
745 | |||
746 | } | ||
747 | |||
748 | |||
749 | } | ||
750 | /* Other pid class */ | ||
751 | if ((inputdev->id.product == PID_400 )|| | ||
752 | (inputdev->id.product == PID_401 )) | ||
753 | { | ||
754 | |||
755 | /* Report 2 */ | ||
756 | if (device->buffer[0] == 2){ | ||
757 | /* Menu blocks */ | ||
758 | input_event(inputdev, EV_MSC, MSC_SCAN, | ||
759 | device->buffer[1]); | ||
760 | } | ||
761 | |||
762 | /* Report 1 */ | ||
763 | if (device->buffer[0] == 1){ | ||
764 | char buttonbyte; | ||
765 | |||
766 | |||
767 | /* IF X max > 64K, we still a bit from the y report */ | ||
768 | if (device->max_X > 0x10000){ | ||
769 | |||
770 | val = (u16)(((u16)(device->buffer[2]<<8))|((u8)(device->buffer[1]))); | ||
771 | val |= (u32)(((u8)device->buffer[3]&0x1)<< 16); | ||
772 | |||
773 | input_report_abs(inputdev, ABS_X, val); | ||
774 | |||
775 | le_buffer[0] = (u8)((u8)(device->buffer[3])>>1); | ||
776 | le_buffer[0] |= (u8)((device->buffer[3]&0x1)<<7); | ||
777 | |||
778 | le_buffer[1] = (u8)(device->buffer[4]>>1); | ||
779 | le_buffer[1] |= (u8)((device->buffer[5]&0x1)<<7); | ||
780 | |||
781 | val = le16_to_cpu(get_unaligned((__le16 *)(le_buffer))); | ||
782 | |||
783 | input_report_abs(inputdev, ABS_Y, val); | ||
784 | |||
785 | |||
786 | /* | ||
787 | * Shift the button byte right by one to | ||
788 | * make it look like the standard report | ||
789 | */ | ||
790 | buttonbyte = (device->buffer[5])>>1; | ||
791 | }else{ | ||
792 | |||
793 | val = le16_to_cpu(get_unaligned((__le16 *) (&(device->buffer[1])))); | ||
794 | input_report_abs(inputdev, ABS_X, val); | ||
795 | |||
796 | val = le16_to_cpu(get_unaligned((__le16 *) (&(device->buffer[3])))); | ||
797 | input_report_abs(inputdev, ABS_Y, val); | ||
798 | |||
799 | buttonbyte = device->buffer[5]; | ||
800 | |||
801 | } | ||
802 | |||
803 | |||
804 | /* BUTTONS and PROXIMITY */ | ||
805 | if (buttonbyte& MASK_INRANGE){ | ||
806 | val = 1; | ||
807 | }else{ | ||
808 | val=0; | ||
809 | } | ||
810 | input_report_abs(inputdev, ABS_DISTANCE, val); | ||
811 | |||
812 | /* Convert buttons, only 4 bits possible */ | ||
813 | val = buttonbyte&0x0F; | ||
814 | #ifdef USE_BUTTONS | ||
815 | for ( i=0;i<5;i++){ | ||
816 | input_report_key(inputdev, BTN_DIGI+i,val&(1<<i)); | ||
817 | } | ||
818 | #else | ||
819 | /* We don't apply any meaning to the bitmask, just report */ | ||
820 | input_event(inputdev, EV_MSC, MSC_SERIAL, val); | ||
821 | #endif | ||
822 | /* TRANSDUCER */ | ||
823 | input_report_abs(inputdev, ABS_MISC, device->buffer[6]); | ||
824 | |||
825 | } | ||
826 | } | ||
827 | |||
828 | /* Everybody gets report ID's */ | ||
829 | input_event(inputdev, EV_MSC, MSC_RAW, device->buffer[0]); | ||
830 | |||
831 | /* Sync it up */ | ||
832 | input_sync(inputdev); | ||
833 | |||
834 | resubmit: | ||
835 | rc = usb_submit_urb(urbinfo, GFP_ATOMIC); | ||
836 | if (rc != 0) { | ||
837 | err("usb_submit_urb failed rc=0x%x",rc); | ||
838 | } | ||
839 | |||
840 | } | ||
841 | |||
842 | /* | ||
843 | * The probe routine. This is called when the kernel find the matching USB | ||
844 | * vendor/product. We do the following: | ||
845 | * | ||
846 | * - Allocate mem for a local structure to manage the device | ||
847 | * - Request a HID Report Descriptor from the device and parse it to | ||
848 | * find out the device parameters | ||
849 | * - Create an input device and assign it attributes | ||
850 | * - Allocate an URB so the device can talk to us when the input | ||
851 | * queue is open | ||
852 | */ | ||
853 | static int gtco_probe(struct usb_interface *usbinterface, | ||
854 | const struct usb_device_id *id) | ||
855 | { | ||
856 | |||
857 | struct gtco *device = NULL; | ||
858 | char path[PATHLENGTH]; | ||
859 | struct input_dev *inputdev; | ||
860 | struct hid_descriptor *hid_desc; | ||
861 | char *report; | ||
862 | int result=0, retry; | ||
863 | struct usb_endpoint_descriptor *endpoint; | ||
864 | |||
865 | /* Allocate memory for device structure */ | ||
866 | device = kzalloc(sizeof(struct gtco), GFP_KERNEL); | ||
867 | if (device == NULL) { | ||
868 | err("No more memory"); | ||
869 | return -ENOMEM; | ||
870 | } | ||
871 | |||
872 | |||
873 | device->inputdevice = input_allocate_device(); | ||
874 | if (!device->inputdevice){ | ||
875 | kfree(device); | ||
876 | err("No more memory"); | ||
877 | return -ENOMEM; | ||
878 | } | ||
879 | |||
880 | /* Get pointer to the input device */ | ||
881 | inputdev = device->inputdevice; | ||
882 | |||
883 | /* Save interface information */ | ||
884 | device->usbdev = usb_get_dev(interface_to_usbdev(usbinterface)); | ||
885 | |||
886 | |||
887 | /* Allocate some data for incoming reports */ | ||
888 | device->buffer = usb_buffer_alloc(device->usbdev, REPORT_MAX_SIZE, | ||
889 | GFP_KERNEL, &(device->buf_dma)); | ||
890 | if (!device->buffer){ | ||
891 | input_free_device(device->inputdevice); | ||
892 | kfree(device); | ||
893 | err("No more memory"); | ||
894 | return -ENOMEM; | ||
895 | } | ||
896 | |||
897 | /* Allocate URB for reports */ | ||
898 | device->urbinfo = usb_alloc_urb(0, GFP_KERNEL); | ||
899 | if (!device->urbinfo) { | ||
900 | usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, | ||
901 | device->buffer, device->buf_dma); | ||
902 | input_free_device(device->inputdevice); | ||
903 | kfree(device); | ||
904 | err("No more memory"); | ||
905 | return -ENOMEM; | ||
906 | } | ||
907 | |||
908 | |||
909 | /* | ||
910 | * The endpoint is always altsetting 0, we know this since we know | ||
911 | * this device only has one interrupt endpoint | ||
912 | */ | ||
913 | endpoint = &usbinterface->altsetting[0].endpoint[0].desc; | ||
914 | |||
915 | /* Some debug */ | ||
916 | dbg("gtco # interfaces: %d",usbinterface->num_altsetting); | ||
917 | dbg("num endpoints: %d",usbinterface->cur_altsetting->desc.bNumEndpoints); | ||
918 | dbg("interface class: %d",usbinterface->cur_altsetting->desc.bInterfaceClass); | ||
919 | dbg("endpoint: attribute:0x%x type:0x%x",endpoint->bmAttributes,endpoint->bDescriptorType); | ||
920 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) | ||
921 | dbg("endpoint: we have interrupt endpoint\n"); | ||
922 | |||
923 | dbg("endpoint extra len:%d ",usbinterface->altsetting[0].extralen); | ||
924 | |||
925 | |||
926 | |||
927 | /* | ||
928 | * Find the HID descriptor so we can find out the size of the | ||
929 | * HID report descriptor | ||
930 | */ | ||
931 | if (usb_get_extra_descriptor(usbinterface->cur_altsetting, | ||
932 | HID_DEVICE_TYPE,&hid_desc) != 0){ | ||
933 | err("Can't retrieve exta USB descriptor to get hid report descriptor length"); | ||
934 | usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, | ||
935 | device->buffer, device->buf_dma); | ||
936 | input_free_device(device->inputdevice); | ||
937 | kfree(device); | ||
938 | return -EIO; | ||
939 | } | ||
940 | |||
941 | dbg("Extra descriptor success: type:%d len:%d", | ||
942 | hid_desc->bDescriptorType, hid_desc->wDescriptorLength); | ||
943 | |||
944 | if (!(report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL))) { | ||
945 | usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, | ||
946 | device->buffer, device->buf_dma); | ||
947 | |||
948 | input_free_device(device->inputdevice); | ||
949 | kfree(device); | ||
950 | err("No more memory"); | ||
951 | return -ENOMEM; | ||
952 | } | ||
953 | |||
954 | /* Couple of tries to get reply */ | ||
955 | for (retry=0;retry<3;retry++) { | ||
956 | result = usb_control_msg(device->usbdev, | ||
957 | usb_rcvctrlpipe(device->usbdev, 0), | ||
958 | USB_REQ_GET_DESCRIPTOR, | ||
959 | USB_RECIP_INTERFACE | USB_DIR_IN, | ||
960 | (REPORT_DEVICE_TYPE << 8), | ||
961 | 0, /* interface */ | ||
962 | report, | ||
963 | hid_desc->wDescriptorLength, | ||
964 | 5000); /* 5 secs */ | ||
965 | |||
966 | if (result == hid_desc->wDescriptorLength) | ||
967 | break; | ||
968 | } | ||
969 | |||
970 | /* If we didn't get the report, fail */ | ||
971 | dbg("usb_control_msg result: :%d", result); | ||
972 | if (result != hid_desc->wDescriptorLength){ | ||
973 | kfree(report); | ||
974 | usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, | ||
975 | device->buffer, device->buf_dma); | ||
976 | input_free_device(device->inputdevice); | ||
977 | kfree(device); | ||
978 | err("Failed to get HID Report Descriptor of size: %d", | ||
979 | hid_desc->wDescriptorLength); | ||
980 | return -EIO; | ||
981 | } | ||
982 | |||
983 | |||
984 | /* Now we parse the report */ | ||
985 | parse_hid_report_descriptor(device,report,result); | ||
986 | |||
987 | /* Now we delete it */ | ||
988 | kfree(report); | ||
989 | |||
990 | /* Create a device file node */ | ||
991 | usb_make_path(device->usbdev, path, PATHLENGTH); | ||
992 | sprintf(device->usbpath, "%s/input0", path); | ||
993 | |||
994 | |||
995 | /* Set Input device functions */ | ||
996 | inputdev->open = gtco_input_open; | ||
997 | inputdev->close = gtco_input_close; | ||
998 | |||
999 | /* Set input device information */ | ||
1000 | inputdev->name = "GTCO_CalComp"; | ||
1001 | inputdev->phys = device->usbpath; | ||
1002 | inputdev->private = device; | ||
1003 | |||
1004 | |||
1005 | /* Now set up all the input device capabilities */ | ||
1006 | gtco_setup_caps(inputdev); | ||
1007 | |||
1008 | /* Set input device required ID information */ | ||
1009 | usb_to_input_id(device->usbdev, &device->inputdevice->id); | ||
1010 | inputdev->cdev.dev = &usbinterface->dev; | ||
1011 | |||
1012 | /* Setup the URB, it will be posted later on open of input device */ | ||
1013 | endpoint = &usbinterface->altsetting[0].endpoint[0].desc; | ||
1014 | |||
1015 | usb_fill_int_urb(device->urbinfo, | ||
1016 | device->usbdev, | ||
1017 | usb_rcvintpipe(device->usbdev, | ||
1018 | endpoint->bEndpointAddress), | ||
1019 | device->buffer, | ||
1020 | REPORT_MAX_SIZE, | ||
1021 | gtco_urb_callback, | ||
1022 | device, | ||
1023 | endpoint->bInterval); | ||
1024 | |||
1025 | device->urbinfo->transfer_dma = device->buf_dma; | ||
1026 | device->urbinfo->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
1027 | |||
1028 | |||
1029 | /* Save device pointer in USB interface device */ | ||
1030 | usb_set_intfdata(usbinterface, device); | ||
1031 | |||
1032 | /* All done, now register the input device */ | ||
1033 | input_register_device(inputdev); | ||
1034 | |||
1035 | info( "gtco driver created usb: %s\n", path); | ||
1036 | return 0; | ||
1037 | |||
1038 | } | ||
1039 | |||
1040 | /* | ||
1041 | * This function is a standard USB function called when the USB device | ||
1042 | * is disconnected. We will get rid of the URV, de-register the input | ||
1043 | * device, and free up allocated memory | ||
1044 | */ | ||
1045 | static void gtco_disconnect(struct usb_interface *interface) | ||
1046 | { | ||
1047 | |||
1048 | /* Grab private device ptr */ | ||
1049 | struct gtco *device = usb_get_intfdata (interface); | ||
1050 | struct input_dev *inputdev; | ||
1051 | |||
1052 | inputdev = device->inputdevice; | ||
1053 | |||
1054 | /* Now reverse all the registration stuff */ | ||
1055 | if (device) { | ||
1056 | input_unregister_device(inputdev); | ||
1057 | usb_kill_urb(device->urbinfo); | ||
1058 | usb_free_urb(device->urbinfo); | ||
1059 | usb_buffer_free(device->usbdev, REPORT_MAX_SIZE, | ||
1060 | device->buffer, device->buf_dma); | ||
1061 | kfree(device); | ||
1062 | } | ||
1063 | |||
1064 | info("gtco driver disconnected"); | ||
1065 | } | ||
1066 | |||
1067 | |||
1068 | /* STANDARD MODULE LOAD ROUTINES */ | ||
1069 | |||
1070 | static struct usb_driver gtco_driverinfo_table = { | ||
1071 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) | ||
1072 | .owner = THIS_MODULE, | ||
1073 | #endif | ||
1074 | .name = "gtco", | ||
1075 | .id_table = gtco_usbid_table, | ||
1076 | .probe = gtco_probe, | ||
1077 | .disconnect = gtco_disconnect, | ||
1078 | }; | ||
1079 | /* | ||
1080 | * Register this module with the USB subsystem | ||
1081 | */ | ||
1082 | static int __init gtco_init(void) | ||
1083 | { | ||
1084 | int rc; | ||
1085 | rc = usb_register(>co_driverinfo_table); | ||
1086 | if (rc) { | ||
1087 | err("usb_register() failed rc=0x%x", rc); | ||
1088 | } | ||
1089 | printk("GTCO usb driver version: %s",GTCO_VERSION); | ||
1090 | return rc; | ||
1091 | } | ||
1092 | |||
1093 | /* | ||
1094 | * Deregister this module with the USB subsystem | ||
1095 | */ | ||
1096 | static void __exit gtco_exit(void) | ||
1097 | { | ||
1098 | usb_deregister(>co_driverinfo_table); | ||
1099 | } | ||
1100 | |||
1101 | module_init (gtco_init); | ||
1102 | module_exit (gtco_exit); | ||
1103 | |||
1104 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index c6c9e72e5fd9..84983d1b7164 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -35,6 +35,7 @@ | |||
35 | 35 | ||
36 | #include <linux/hid.h> | 36 | #include <linux/hid.h> |
37 | #include <linux/hiddev.h> | 37 | #include <linux/hiddev.h> |
38 | #include <linux/hid-debug.h> | ||
38 | #include "usbhid.h" | 39 | #include "usbhid.h" |
39 | 40 | ||
40 | /* | 41 | /* |
@@ -220,23 +221,6 @@ static void hid_irq_in(struct urb *urb) | |||
220 | } | 221 | } |
221 | } | 222 | } |
222 | 223 | ||
223 | /* | ||
224 | * Find a report field with a specified HID usage. | ||
225 | */ | ||
226 | #if 0 | ||
227 | struct hid_field *hid_find_field_by_usage(struct hid_device *hid, __u32 wanted_usage, int type) | ||
228 | { | ||
229 | struct hid_report *report; | ||
230 | int i; | ||
231 | |||
232 | list_for_each_entry(report, &hid->report_enum[type].report_list, list) | ||
233 | for (i = 0; i < report->maxfield; i++) | ||
234 | if (report->field[i]->logical == wanted_usage) | ||
235 | return report->field[i]; | ||
236 | return NULL; | ||
237 | } | ||
238 | #endif /* 0 */ | ||
239 | |||
240 | static int hid_submit_out(struct hid_device *hid) | 224 | static int hid_submit_out(struct hid_device *hid) |
241 | { | 225 | { |
242 | struct hid_report *report; | 226 | struct hid_report *report; |
@@ -501,7 +485,7 @@ static int hid_get_class_descriptor(struct usb_device *dev, int ifnum, | |||
501 | { | 485 | { |
502 | int result, retries = 4; | 486 | int result, retries = 4; |
503 | 487 | ||
504 | memset(buf,0,size); // Make sure we parse really received data | 488 | memset(buf, 0, size); |
505 | 489 | ||
506 | do { | 490 | do { |
507 | result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), | 491 | result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), |
@@ -528,18 +512,6 @@ void usbhid_close(struct hid_device *hid) | |||
528 | usb_kill_urb(usbhid->urbin); | 512 | usb_kill_urb(usbhid->urbin); |
529 | } | 513 | } |
530 | 514 | ||
531 | static int hidinput_open(struct input_dev *dev) | ||
532 | { | ||
533 | struct hid_device *hid = dev->private; | ||
534 | return usbhid_open(hid); | ||
535 | } | ||
536 | |||
537 | static void hidinput_close(struct input_dev *dev) | ||
538 | { | ||
539 | struct hid_device *hid = dev->private; | ||
540 | usbhid_close(hid); | ||
541 | } | ||
542 | |||
543 | #define USB_VENDOR_ID_PANJIT 0x134c | 515 | #define USB_VENDOR_ID_PANJIT 0x134c |
544 | 516 | ||
545 | #define USB_VENDOR_ID_TURBOX 0x062a | 517 | #define USB_VENDOR_ID_TURBOX 0x062a |
@@ -770,6 +742,7 @@ void usbhid_init_reports(struct hid_device *hid) | |||
770 | #define USB_DEVICE_ID_APPLE_GEYSER4_JIS 0x021c | 742 | #define USB_DEVICE_ID_APPLE_GEYSER4_JIS 0x021c |
771 | #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a | 743 | #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a |
772 | #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b | 744 | #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b |
745 | #define USB_DEVICE_ID_APPLE_IR 0x8240 | ||
773 | 746 | ||
774 | #define USB_VENDOR_ID_CHERRY 0x046a | 747 | #define USB_VENDOR_ID_CHERRY 0x046a |
775 | #define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 | 748 | #define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 |
@@ -792,6 +765,12 @@ void usbhid_init_reports(struct hid_device *hid) | |||
792 | #define USB_VENDOR_ID_IMATION 0x0718 | 765 | #define USB_VENDOR_ID_IMATION 0x0718 |
793 | #define USB_DEVICE_ID_DISC_STAKKA 0xd000 | 766 | #define USB_DEVICE_ID_DISC_STAKKA 0xd000 |
794 | 767 | ||
768 | #define USB_VENDOR_ID_PANTHERLORD 0x0810 | ||
769 | #define USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK 0x0001 | ||
770 | |||
771 | #define USB_VENDOR_ID_SONY 0x054c | ||
772 | #define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268 | ||
773 | |||
795 | /* | 774 | /* |
796 | * Alphabetically sorted blacklist by quirk type. | 775 | * Alphabetically sorted blacklist by quirk type. |
797 | */ | 776 | */ |
@@ -946,19 +925,21 @@ static const struct hid_blacklist { | |||
946 | 925 | ||
947 | { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_CYMOTION }, | 926 | { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_CYMOTION }, |
948 | 927 | ||
949 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI, HID_QUIRK_POWERBOOK_HAS_FN }, | 928 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
950 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO, HID_QUIRK_POWERBOOK_HAS_FN }, | 929 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
951 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_POWERBOOK_HAS_FN }, | 930 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
952 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, | 931 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, |
953 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_POWERBOOK_HAS_FN }, | 932 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
954 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_POWERBOOK_HAS_FN }, | 933 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
955 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, | 934 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, |
956 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_POWERBOOK_HAS_FN }, | 935 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
957 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI, HID_QUIRK_POWERBOOK_HAS_FN }, | 936 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
958 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, | 937 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, |
959 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_POWERBOOK_HAS_FN }, | 938 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
960 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN }, | 939 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
961 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN }, | 940 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
941 | |||
942 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IR, HID_QUIRK_IGNORE }, | ||
962 | 943 | ||
963 | { USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE }, | 944 | { USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE }, |
964 | { USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE }, | 945 | { USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE }, |
@@ -969,6 +950,10 @@ static const struct hid_blacklist { | |||
969 | 950 | ||
970 | { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_USB_RECEIVER, HID_QUIRK_BAD_RELATIVE_KEYS }, | 951 | { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_USB_RECEIVER, HID_QUIRK_BAD_RELATIVE_KEYS }, |
971 | 952 | ||
953 | { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, | ||
954 | |||
955 | { USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER, HID_QUIRK_SONY_PS3_CONTROLLER }, | ||
956 | |||
972 | { 0, 0 } | 957 | { 0, 0 } |
973 | }; | 958 | }; |
974 | 959 | ||
@@ -1033,6 +1018,32 @@ static void hid_fixup_cymotion_descriptor(char *rdesc, int rsize) | |||
1033 | } | 1018 | } |
1034 | } | 1019 | } |
1035 | 1020 | ||
1021 | /* | ||
1022 | * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller | ||
1023 | * to "operational". Without this, the ps3 controller will not report any | ||
1024 | * events. | ||
1025 | */ | ||
1026 | static void hid_fixup_sony_ps3_controller(struct usb_device *dev, int ifnum) | ||
1027 | { | ||
1028 | int result; | ||
1029 | char *buf = kmalloc(18, GFP_KERNEL); | ||
1030 | |||
1031 | if (!buf) | ||
1032 | return; | ||
1033 | |||
1034 | result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), | ||
1035 | HID_REQ_GET_REPORT, | ||
1036 | USB_DIR_IN | USB_TYPE_CLASS | | ||
1037 | USB_RECIP_INTERFACE, | ||
1038 | (3 << 8) | 0xf2, ifnum, buf, 17, | ||
1039 | USB_CTRL_GET_TIMEOUT); | ||
1040 | |||
1041 | if (result < 0) | ||
1042 | err("%s failed: %d\n", __func__, result); | ||
1043 | |||
1044 | kfree(buf); | ||
1045 | } | ||
1046 | |||
1036 | static struct hid_device *usb_hid_configure(struct usb_interface *intf) | 1047 | static struct hid_device *usb_hid_configure(struct usb_interface *intf) |
1037 | { | 1048 | { |
1038 | struct usb_host_interface *interface = intf->cur_altsetting; | 1049 | struct usb_host_interface *interface = intf->cur_altsetting; |
@@ -1064,6 +1075,11 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1064 | if (quirks & HID_QUIRK_IGNORE) | 1075 | if (quirks & HID_QUIRK_IGNORE) |
1065 | return NULL; | 1076 | return NULL; |
1066 | 1077 | ||
1078 | if ((quirks & HID_QUIRK_IGNORE_MOUSE) && | ||
1079 | (interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE)) | ||
1080 | return NULL; | ||
1081 | |||
1082 | |||
1067 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && | 1083 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && |
1068 | (!interface->desc.bNumEndpoints || | 1084 | (!interface->desc.bNumEndpoints || |
1069 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { | 1085 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { |
@@ -1235,8 +1251,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1235 | usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma; | 1251 | usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma; |
1236 | usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); | 1252 | usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); |
1237 | hid->hidinput_input_event = usb_hidinput_input_event; | 1253 | hid->hidinput_input_event = usb_hidinput_input_event; |
1238 | hid->hidinput_open = hidinput_open; | 1254 | hid->hid_open = usbhid_open; |
1239 | hid->hidinput_close = hidinput_close; | 1255 | hid->hid_close = usbhid_close; |
1240 | #ifdef CONFIG_USB_HIDDEV | 1256 | #ifdef CONFIG_USB_HIDDEV |
1241 | hid->hiddev_hid_event = hiddev_hid_event; | 1257 | hid->hiddev_hid_event = hiddev_hid_event; |
1242 | hid->hiddev_report_event = hiddev_report_event; | 1258 | hid->hiddev_report_event = hiddev_report_event; |
@@ -1315,13 +1331,13 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1315 | return -ENODEV; | 1331 | return -ENODEV; |
1316 | } | 1332 | } |
1317 | 1333 | ||
1318 | /* This only gets called when we are a single-input (most of the | 1334 | if ((hid->claimed & HID_CLAIMED_INPUT)) |
1319 | * time). IOW, not a HID_QUIRK_MULTI_INPUT. The hid_ff_init() is | ||
1320 | * only useful in this case, and not for multi-input quirks. */ | ||
1321 | if ((hid->claimed & HID_CLAIMED_INPUT) && | ||
1322 | !(hid->quirks & HID_QUIRK_MULTI_INPUT)) | ||
1323 | hid_ff_init(hid); | 1335 | hid_ff_init(hid); |
1324 | 1336 | ||
1337 | if (hid->quirks & HID_QUIRK_SONY_PS3_CONTROLLER) | ||
1338 | hid_fixup_sony_ps3_controller(interface_to_usbdev(intf), | ||
1339 | intf->cur_altsetting->desc.bInterfaceNumber); | ||
1340 | |||
1325 | printk(KERN_INFO); | 1341 | printk(KERN_INFO); |
1326 | 1342 | ||
1327 | if (hid->claimed & HID_CLAIMED_INPUT) | 1343 | if (hid->claimed & HID_CLAIMED_INPUT) |
diff --git a/drivers/usb/input/hid-ff.c b/drivers/usb/input/hid-ff.c index 59ed65e7a621..5d145058a5cb 100644 --- a/drivers/usb/input/hid-ff.c +++ b/drivers/usb/input/hid-ff.c | |||
@@ -58,6 +58,9 @@ static struct hid_ff_initializer inits[] = { | |||
58 | { 0x46d, 0xc295, hid_lgff_init }, /* Logitech MOMO force wheel */ | 58 | { 0x46d, 0xc295, hid_lgff_init }, /* Logitech MOMO force wheel */ |
59 | { 0x46d, 0xc219, hid_lgff_init }, /* Logitech Cordless rumble pad 2 */ | 59 | { 0x46d, 0xc219, hid_lgff_init }, /* Logitech Cordless rumble pad 2 */ |
60 | #endif | 60 | #endif |
61 | #ifdef CONFIG_PANTHERLORD_FF | ||
62 | { 0x810, 0x0001, hid_plff_init }, | ||
63 | #endif | ||
61 | #ifdef CONFIG_THRUSTMASTER_FF | 64 | #ifdef CONFIG_THRUSTMASTER_FF |
62 | { 0x44f, 0xb304, hid_tmff_init }, | 65 | { 0x44f, 0xb304, hid_tmff_init }, |
63 | #endif | 66 | #endif |
diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c index e47466268565..4f4fc3be192e 100644 --- a/drivers/usb/input/hid-lgff.c +++ b/drivers/usb/input/hid-lgff.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/hid.h> | 32 | #include <linux/hid.h> |
33 | #include "usbhid.h" | 33 | #include "usbhid.h" |
34 | 34 | ||
35 | struct device_type { | 35 | struct dev_type { |
36 | u16 idVendor; | 36 | u16 idVendor; |
37 | u16 idProduct; | 37 | u16 idProduct; |
38 | const signed short *ff; | 38 | const signed short *ff; |
@@ -48,7 +48,7 @@ static const signed short ff_joystick[] = { | |||
48 | -1 | 48 | -1 |
49 | }; | 49 | }; |
50 | 50 | ||
51 | static const struct device_type devices[] = { | 51 | static const struct dev_type devices[] = { |
52 | { 0x046d, 0xc211, ff_rumble }, | 52 | { 0x046d, 0xc211, ff_rumble }, |
53 | { 0x046d, 0xc219, ff_rumble }, | 53 | { 0x046d, 0xc219, ff_rumble }, |
54 | { 0x046d, 0xc283, ff_joystick }, | 54 | { 0x046d, 0xc283, ff_joystick }, |
diff --git a/drivers/usb/input/hid-plff.c b/drivers/usb/input/hid-plff.c new file mode 100644 index 000000000000..76d2e6e14db4 --- /dev/null +++ b/drivers/usb/input/hid-plff.c | |||
@@ -0,0 +1,129 @@ | |||
1 | /* | ||
2 | * Force feedback support for PantherLord USB/PS2 2in1 Adapter devices | ||
3 | * | ||
4 | * Copyright (c) 2007 Anssi Hannula <anssi.hannula@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 | /* #define DEBUG */ | ||
25 | |||
26 | #define debug(format, arg...) pr_debug("hid-plff: " format "\n" , ## arg) | ||
27 | |||
28 | #include <linux/input.h> | ||
29 | #include <linux/usb.h> | ||
30 | #include <linux/hid.h> | ||
31 | #include "usbhid.h" | ||
32 | |||
33 | struct plff_device { | ||
34 | struct hid_report *report; | ||
35 | }; | ||
36 | |||
37 | static int hid_plff_play(struct input_dev *dev, void *data, | ||
38 | struct ff_effect *effect) | ||
39 | { | ||
40 | struct hid_device *hid = dev->private; | ||
41 | struct plff_device *plff = data; | ||
42 | int left, right; | ||
43 | |||
44 | left = effect->u.rumble.strong_magnitude; | ||
45 | right = effect->u.rumble.weak_magnitude; | ||
46 | debug("called with 0x%04x 0x%04x", left, right); | ||
47 | |||
48 | left = left * 0x7f / 0xffff; | ||
49 | right = right * 0x7f / 0xffff; | ||
50 | |||
51 | plff->report->field[0]->value[2] = left; | ||
52 | plff->report->field[0]->value[3] = right; | ||
53 | debug("running with 0x%02x 0x%02x", left, right); | ||
54 | usbhid_submit_report(hid, plff->report, USB_DIR_OUT); | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | int hid_plff_init(struct hid_device *hid) | ||
60 | { | ||
61 | struct plff_device *plff; | ||
62 | struct hid_report *report; | ||
63 | struct hid_input *hidinput; | ||
64 | struct list_head *report_list = | ||
65 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
66 | struct list_head *report_ptr = report_list; | ||
67 | struct input_dev *dev; | ||
68 | int error; | ||
69 | |||
70 | /* The device contains 2 output reports (one for each | ||
71 | HID_QUIRK_MULTI_INPUT device), both containing 1 field, which | ||
72 | contains 4 ff00.0002 usages and 4 16bit absolute values. | ||
73 | |||
74 | The 2 input reports also contain a field which contains | ||
75 | 8 ff00.0001 usages and 8 boolean values. Their meaning is | ||
76 | currently unknown. */ | ||
77 | |||
78 | if (list_empty(report_list)) { | ||
79 | printk(KERN_ERR "hid-plff: no output reports found\n"); | ||
80 | return -ENODEV; | ||
81 | } | ||
82 | |||
83 | list_for_each_entry(hidinput, &hid->inputs, list) { | ||
84 | |||
85 | report_ptr = report_ptr->next; | ||
86 | |||
87 | if (report_ptr == report_list) { | ||
88 | printk(KERN_ERR "hid-plff: required output report is missing\n"); | ||
89 | return -ENODEV; | ||
90 | } | ||
91 | |||
92 | report = list_entry(report_ptr, struct hid_report, list); | ||
93 | if (report->maxfield < 1) { | ||
94 | printk(KERN_ERR "hid-plff: no fields in the report\n"); | ||
95 | return -ENODEV; | ||
96 | } | ||
97 | |||
98 | if (report->field[0]->report_count < 4) { | ||
99 | printk(KERN_ERR "hid-plff: not enough values in the field\n"); | ||
100 | return -ENODEV; | ||
101 | } | ||
102 | |||
103 | plff = kzalloc(sizeof(struct plff_device), GFP_KERNEL); | ||
104 | if (!plff) | ||
105 | return -ENOMEM; | ||
106 | |||
107 | dev = hidinput->input; | ||
108 | |||
109 | set_bit(FF_RUMBLE, dev->ffbit); | ||
110 | |||
111 | error = input_ff_create_memless(dev, plff, hid_plff_play); | ||
112 | if (error) { | ||
113 | kfree(plff); | ||
114 | return error; | ||
115 | } | ||
116 | |||
117 | plff->report = report; | ||
118 | plff->report->field[0]->value[0] = 0x00; | ||
119 | plff->report->field[0]->value[1] = 0x00; | ||
120 | plff->report->field[0]->value[2] = 0x00; | ||
121 | plff->report->field[0]->value[3] = 0x00; | ||
122 | usbhid_submit_report(hid, plff->report, USB_DIR_OUT); | ||
123 | } | ||
124 | |||
125 | printk(KERN_INFO "hid-plff: Force feedback for PantherLord USB/PS2 " | ||
126 | "2in1 Adapters by Anssi Hannula <anssi.hannula@gmail.com>\n"); | ||
127 | |||
128 | return 0; | ||
129 | } | ||