blob: 848a56c0279c8ac61687340c732521094428e541 [file] [log] [blame]
Jiri Kosinadde58452006-12-08 18:40:44 +01001/*
Jiri Kosina229695e2006-12-08 18:40:53 +01002 * HID support for Linux
Jiri Kosinadde58452006-12-08 18:40:44 +01003 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
Jiri Kosina7d39e842010-02-02 20:46:34 +01007 * Copyright (c) 2006-2010 Jiri Kosina
Jiri Kosinadde58452006-12-08 18:40:44 +01008 */
9
10/*
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2 of the License, or (at your option)
14 * any later version.
15 */
16
Joe Perches4291ee32010-12-09 19:29:03 -080017#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
Jiri Kosinadde58452006-12-08 18:40:44 +010019#include <linux/module.h>
20#include <linux/slab.h>
21#include <linux/init.h>
22#include <linux/kernel.h>
Jiri Kosinadde58452006-12-08 18:40:44 +010023#include <linux/list.h>
24#include <linux/mm.h>
Jiri Kosinadde58452006-12-08 18:40:44 +010025#include <linux/spinlock.h>
26#include <asm/unaligned.h>
27#include <asm/byteorder.h>
28#include <linux/input.h>
29#include <linux/wait.h>
Jiri Kosina47a80ed2007-03-12 14:55:12 +010030#include <linux/vmalloc.h>
Jiri Kosinac4124c92007-11-30 11:12:58 +010031#include <linux/sched.h>
David Herrmann4ea54542011-08-10 14:02:07 +020032#include <linux/semaphore.h>
Jiri Kosinadde58452006-12-08 18:40:44 +010033
Jiri Kosinadde58452006-12-08 18:40:44 +010034#include <linux/hid.h>
35#include <linux/hiddev.h>
Jiri Kosinac080d892007-01-25 11:43:31 +010036#include <linux/hid-debug.h>
Jiri Kosina86166b72007-05-14 09:57:40 +020037#include <linux/hidraw.h>
Jiri Kosinadde58452006-12-08 18:40:44 +010038
Jiri Slaby5f22a792008-05-16 11:49:19 +020039#include "hid-ids.h"
40
Jiri Kosinadde58452006-12-08 18:40:44 +010041/*
42 * Version Information
43 */
44
Jiri Kosina53149802007-01-09 13:24:25 +010045#define DRIVER_DESC "HID core driver"
Jiri Kosinadde58452006-12-08 18:40:44 +010046#define DRIVER_LICENSE "GPL"
47
Jiri Kosina58037eb2007-05-30 15:07:13 +020048int hid_debug = 0;
Anssi Hannula377e10f2008-03-22 23:50:13 +010049module_param_named(debug, hid_debug, int, 0600);
Jiri Kosinacd667ce2009-06-12 15:20:57 +020050MODULE_PARM_DESC(debug, "toggle HID debugging messages");
Jiri Kosina58037eb2007-05-30 15:07:13 +020051EXPORT_SYMBOL_GPL(hid_debug);
Jiri Kosina58037eb2007-05-30 15:07:13 +020052
Jiri Kosinadde58452006-12-08 18:40:44 +010053/*
Jiri Kosinadde58452006-12-08 18:40:44 +010054 * Register a new report for a device.
55 */
56
Michael Poole90a006a2010-01-24 22:32:29 -050057struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id)
Jiri Kosinadde58452006-12-08 18:40:44 +010058{
59 struct hid_report_enum *report_enum = device->report_enum + type;
60 struct hid_report *report;
61
62 if (report_enum->report_id_hash[id])
63 return report_enum->report_id_hash[id];
64
Joe Perchesa3789a172010-12-09 19:29:07 -080065 report = kzalloc(sizeof(struct hid_report), GFP_KERNEL);
66 if (!report)
Jiri Kosinadde58452006-12-08 18:40:44 +010067 return NULL;
68
69 if (id != 0)
70 report_enum->numbered = 1;
71
72 report->id = id;
73 report->type = type;
74 report->size = 0;
75 report->device = device;
76 report_enum->report_id_hash[id] = report;
77
78 list_add_tail(&report->list, &report_enum->report_list);
79
80 return report;
81}
Michael Poole90a006a2010-01-24 22:32:29 -050082EXPORT_SYMBOL_GPL(hid_register_report);
Jiri Kosinadde58452006-12-08 18:40:44 +010083
84/*
85 * Register a new field for this report.
86 */
87
88static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
89{
90 struct hid_field *field;
91
92 if (report->maxfield == HID_MAX_FIELDS) {
Jiri Kosina58037eb2007-05-30 15:07:13 +020093 dbg_hid("too many fields in report\n");
Jiri Kosinadde58452006-12-08 18:40:44 +010094 return NULL;
95 }
96
Joe Perchesa3789a172010-12-09 19:29:07 -080097 field = kzalloc((sizeof(struct hid_field) +
98 usages * sizeof(struct hid_usage) +
99 values * sizeof(unsigned)), GFP_KERNEL);
100 if (!field)
101 return NULL;
Jiri Kosinadde58452006-12-08 18:40:44 +0100102
103 field->index = report->maxfield++;
104 report->field[field->index] = field;
105 field->usage = (struct hid_usage *)(field + 1);
Jiri Slaby282bfd42008-03-28 17:06:41 +0100106 field->value = (s32 *)(field->usage + usages);
Jiri Kosinadde58452006-12-08 18:40:44 +0100107 field->report = report;
108
109 return field;
110}
111
112/*
113 * Open a collection. The type/usage is pushed on the stack.
114 */
115
116static int open_collection(struct hid_parser *parser, unsigned type)
117{
118 struct hid_collection *collection;
119 unsigned usage;
120
121 usage = parser->local.usage[0];
122
123 if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) {
Jiri Kosina58037eb2007-05-30 15:07:13 +0200124 dbg_hid("collection stack overflow\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100125 return -1;
126 }
127
128 if (parser->device->maxcollection == parser->device->collection_size) {
129 collection = kmalloc(sizeof(struct hid_collection) *
130 parser->device->collection_size * 2, GFP_KERNEL);
131 if (collection == NULL) {
Jiri Kosina58037eb2007-05-30 15:07:13 +0200132 dbg_hid("failed to reallocate collection array\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100133 return -1;
134 }
135 memcpy(collection, parser->device->collection,
136 sizeof(struct hid_collection) *
137 parser->device->collection_size);
138 memset(collection + parser->device->collection_size, 0,
139 sizeof(struct hid_collection) *
140 parser->device->collection_size);
141 kfree(parser->device->collection);
142 parser->device->collection = collection;
143 parser->device->collection_size *= 2;
144 }
145
146 parser->collection_stack[parser->collection_stack_ptr++] =
147 parser->device->maxcollection;
148
149 collection = parser->device->collection +
150 parser->device->maxcollection++;
151 collection->type = type;
152 collection->usage = usage;
153 collection->level = parser->collection_stack_ptr - 1;
154
155 if (type == HID_COLLECTION_APPLICATION)
156 parser->device->maxapplication++;
157
158 return 0;
159}
160
161/*
162 * Close a collection.
163 */
164
165static int close_collection(struct hid_parser *parser)
166{
167 if (!parser->collection_stack_ptr) {
Jiri Kosina58037eb2007-05-30 15:07:13 +0200168 dbg_hid("collection stack underflow\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100169 return -1;
170 }
171 parser->collection_stack_ptr--;
172 return 0;
173}
174
175/*
176 * Climb up the stack, search for the specified collection type
177 * and return the usage.
178 */
179
180static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
181{
Joe Perches504499f2010-12-09 19:29:08 -0800182 struct hid_collection *collection = parser->device->collection;
Jiri Kosinadde58452006-12-08 18:40:44 +0100183 int n;
Joe Perches504499f2010-12-09 19:29:08 -0800184
185 for (n = parser->collection_stack_ptr - 1; n >= 0; n--) {
186 unsigned index = parser->collection_stack[n];
187 if (collection[index].type == type)
188 return collection[index].usage;
189 }
Jiri Kosinadde58452006-12-08 18:40:44 +0100190 return 0; /* we know nothing about this usage type */
191}
192
193/*
194 * Add a usage to the temporary parser table.
195 */
196
197static int hid_add_usage(struct hid_parser *parser, unsigned usage)
198{
199 if (parser->local.usage_index >= HID_MAX_USAGES) {
Jiri Kosina58037eb2007-05-30 15:07:13 +0200200 dbg_hid("usage index exceeded\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100201 return -1;
202 }
203 parser->local.usage[parser->local.usage_index] = usage;
204 parser->local.collection_index[parser->local.usage_index] =
205 parser->collection_stack_ptr ?
206 parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
207 parser->local.usage_index++;
208 return 0;
209}
210
211/*
212 * Register a new field for this report.
213 */
214
215static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags)
216{
217 struct hid_report *report;
218 struct hid_field *field;
219 int usages;
220 unsigned offset;
221 int i;
222
Joe Perchesa3789a172010-12-09 19:29:07 -0800223 report = hid_register_report(parser->device, report_type, parser->global.report_id);
224 if (!report) {
Jiri Kosina58037eb2007-05-30 15:07:13 +0200225 dbg_hid("hid_register_report failed\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100226 return -1;
227 }
228
229 if (parser->global.logical_maximum < parser->global.logical_minimum) {
Jiri Kosina58037eb2007-05-30 15:07:13 +0200230 dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum);
Jiri Kosinadde58452006-12-08 18:40:44 +0100231 return -1;
232 }
233
234 offset = report->size;
235 report->size += parser->global.report_size * parser->global.report_count;
236
237 if (!parser->local.usage_index) /* Ignore padding fields */
238 return 0;
239
240 usages = max_t(int, parser->local.usage_index, parser->global.report_count);
241
Joe Perchesa3789a172010-12-09 19:29:07 -0800242 field = hid_register_field(report, usages, parser->global.report_count);
243 if (!field)
Jiri Kosinadde58452006-12-08 18:40:44 +0100244 return 0;
245
246 field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL);
247 field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL);
248 field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION);
249
250 for (i = 0; i < usages; i++) {
251 int j = i;
252 /* Duplicate the last usage we parsed if we have excess values */
253 if (i >= parser->local.usage_index)
254 j = parser->local.usage_index - 1;
255 field->usage[i].hid = parser->local.usage[j];
256 field->usage[i].collection_index =
257 parser->local.collection_index[j];
258 }
259
260 field->maxusage = usages;
261 field->flags = flags;
262 field->report_offset = offset;
263 field->report_type = report_type;
264 field->report_size = parser->global.report_size;
265 field->report_count = parser->global.report_count;
266 field->logical_minimum = parser->global.logical_minimum;
267 field->logical_maximum = parser->global.logical_maximum;
268 field->physical_minimum = parser->global.physical_minimum;
269 field->physical_maximum = parser->global.physical_maximum;
270 field->unit_exponent = parser->global.unit_exponent;
271 field->unit = parser->global.unit;
272
273 return 0;
274}
275
276/*
277 * Read data value from item.
278 */
279
280static u32 item_udata(struct hid_item *item)
281{
282 switch (item->size) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200283 case 1: return item->data.u8;
284 case 2: return item->data.u16;
285 case 4: return item->data.u32;
Jiri Kosinadde58452006-12-08 18:40:44 +0100286 }
287 return 0;
288}
289
290static s32 item_sdata(struct hid_item *item)
291{
292 switch (item->size) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200293 case 1: return item->data.s8;
294 case 2: return item->data.s16;
295 case 4: return item->data.s32;
Jiri Kosinadde58452006-12-08 18:40:44 +0100296 }
297 return 0;
298}
299
300/*
301 * Process a global item.
302 */
303
304static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
305{
306 switch (item->tag) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200307 case HID_GLOBAL_ITEM_TAG_PUSH:
Jiri Kosinadde58452006-12-08 18:40:44 +0100308
Jiri Slaby880d29f2008-06-18 23:55:41 +0200309 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300310 dbg_hid("global environment stack overflow\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100311 return -1;
Jiri Slaby880d29f2008-06-18 23:55:41 +0200312 }
313
314 memcpy(parser->global_stack + parser->global_stack_ptr++,
315 &parser->global, sizeof(struct hid_global));
316 return 0;
317
318 case HID_GLOBAL_ITEM_TAG_POP:
319
320 if (!parser->global_stack_ptr) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300321 dbg_hid("global environment stack underflow\n");
Jiri Slaby880d29f2008-06-18 23:55:41 +0200322 return -1;
323 }
324
325 memcpy(&parser->global, parser->global_stack +
326 --parser->global_stack_ptr, sizeof(struct hid_global));
327 return 0;
328
329 case HID_GLOBAL_ITEM_TAG_USAGE_PAGE:
330 parser->global.usage_page = item_udata(item);
331 return 0;
332
333 case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM:
334 parser->global.logical_minimum = item_sdata(item);
335 return 0;
336
337 case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM:
338 if (parser->global.logical_minimum < 0)
339 parser->global.logical_maximum = item_sdata(item);
340 else
341 parser->global.logical_maximum = item_udata(item);
342 return 0;
343
344 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM:
345 parser->global.physical_minimum = item_sdata(item);
346 return 0;
347
348 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM:
349 if (parser->global.physical_minimum < 0)
350 parser->global.physical_maximum = item_sdata(item);
351 else
352 parser->global.physical_maximum = item_udata(item);
353 return 0;
354
355 case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT:
356 parser->global.unit_exponent = item_sdata(item);
357 return 0;
358
359 case HID_GLOBAL_ITEM_TAG_UNIT:
360 parser->global.unit = item_udata(item);
361 return 0;
362
363 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
364 parser->global.report_size = item_udata(item);
365 if (parser->global.report_size > 32) {
366 dbg_hid("invalid report_size %d\n",
367 parser->global.report_size);
368 return -1;
369 }
370 return 0;
371
372 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT:
373 parser->global.report_count = item_udata(item);
374 if (parser->global.report_count > HID_MAX_USAGES) {
375 dbg_hid("invalid report_count %d\n",
376 parser->global.report_count);
377 return -1;
378 }
379 return 0;
380
381 case HID_GLOBAL_ITEM_TAG_REPORT_ID:
382 parser->global.report_id = item_udata(item);
383 if (parser->global.report_id == 0) {
384 dbg_hid("report_id 0 is invalid\n");
385 return -1;
386 }
387 return 0;
388
389 default:
390 dbg_hid("unknown global tag 0x%x\n", item->tag);
391 return -1;
Jiri Kosinadde58452006-12-08 18:40:44 +0100392 }
393}
394
395/*
396 * Process a local item.
397 */
398
399static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
400{
401 __u32 data;
402 unsigned n;
403
Jiri Kosinadde58452006-12-08 18:40:44 +0100404 data = item_udata(item);
405
406 switch (item->tag) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200407 case HID_LOCAL_ITEM_TAG_DELIMITER:
Jiri Kosinadde58452006-12-08 18:40:44 +0100408
Jiri Slaby880d29f2008-06-18 23:55:41 +0200409 if (data) {
410 /*
411 * We treat items before the first delimiter
412 * as global to all usage sets (branch 0).
413 * In the moment we process only these global
414 * items and the first delimiter set.
415 */
416 if (parser->local.delimiter_depth != 0) {
417 dbg_hid("nested delimiters\n");
418 return -1;
Jiri Kosinadde58452006-12-08 18:40:44 +0100419 }
Jiri Slaby880d29f2008-06-18 23:55:41 +0200420 parser->local.delimiter_depth++;
421 parser->local.delimiter_branch++;
422 } else {
423 if (parser->local.delimiter_depth < 1) {
424 dbg_hid("bogus close delimiter\n");
425 return -1;
Jiri Kosinadde58452006-12-08 18:40:44 +0100426 }
Jiri Slaby880d29f2008-06-18 23:55:41 +0200427 parser->local.delimiter_depth--;
428 }
429 return 1;
Jiri Kosinadde58452006-12-08 18:40:44 +0100430
Jiri Slaby880d29f2008-06-18 23:55:41 +0200431 case HID_LOCAL_ITEM_TAG_USAGE:
Jiri Kosinadde58452006-12-08 18:40:44 +0100432
Jiri Slaby880d29f2008-06-18 23:55:41 +0200433 if (parser->local.delimiter_branch > 1) {
434 dbg_hid("alternative usage ignored\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100435 return 0;
Jiri Slaby880d29f2008-06-18 23:55:41 +0200436 }
Jiri Kosinadde58452006-12-08 18:40:44 +0100437
Jiri Slaby880d29f2008-06-18 23:55:41 +0200438 if (item->size <= 2)
439 data = (parser->global.usage_page << 16) + data;
Jiri Kosinadde58452006-12-08 18:40:44 +0100440
Jiri Slaby880d29f2008-06-18 23:55:41 +0200441 return hid_add_usage(parser, data);
442
443 case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
444
445 if (parser->local.delimiter_branch > 1) {
446 dbg_hid("alternative usage ignored\n");
447 return 0;
448 }
449
450 if (item->size <= 2)
451 data = (parser->global.usage_page << 16) + data;
452
453 parser->local.usage_minimum = data;
454 return 0;
455
456 case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
457
458 if (parser->local.delimiter_branch > 1) {
459 dbg_hid("alternative usage ignored\n");
460 return 0;
461 }
462
463 if (item->size <= 2)
464 data = (parser->global.usage_page << 16) + data;
465
466 for (n = parser->local.usage_minimum; n <= data; n++)
467 if (hid_add_usage(parser, n)) {
468 dbg_hid("hid_add_usage failed\n");
469 return -1;
Jiri Kosinadde58452006-12-08 18:40:44 +0100470 }
Jiri Slaby880d29f2008-06-18 23:55:41 +0200471 return 0;
Jiri Kosinadde58452006-12-08 18:40:44 +0100472
Jiri Slaby880d29f2008-06-18 23:55:41 +0200473 default:
Jiri Kosinadde58452006-12-08 18:40:44 +0100474
Jiri Slaby880d29f2008-06-18 23:55:41 +0200475 dbg_hid("unknown local item tag 0x%x\n", item->tag);
476 return 0;
Jiri Kosinadde58452006-12-08 18:40:44 +0100477 }
478 return 0;
479}
480
481/*
482 * Process a main item.
483 */
484
485static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
486{
487 __u32 data;
488 int ret;
489
490 data = item_udata(item);
491
492 switch (item->tag) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200493 case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION:
494 ret = open_collection(parser, data & 0xff);
495 break;
496 case HID_MAIN_ITEM_TAG_END_COLLECTION:
497 ret = close_collection(parser);
498 break;
499 case HID_MAIN_ITEM_TAG_INPUT:
500 ret = hid_add_field(parser, HID_INPUT_REPORT, data);
501 break;
502 case HID_MAIN_ITEM_TAG_OUTPUT:
503 ret = hid_add_field(parser, HID_OUTPUT_REPORT, data);
504 break;
505 case HID_MAIN_ITEM_TAG_FEATURE:
506 ret = hid_add_field(parser, HID_FEATURE_REPORT, data);
507 break;
508 default:
509 dbg_hid("unknown main item tag 0x%x\n", item->tag);
510 ret = 0;
Jiri Kosinadde58452006-12-08 18:40:44 +0100511 }
512
513 memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */
514
515 return ret;
516}
517
518/*
519 * Process a reserved item.
520 */
521
522static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item)
523{
Jiri Kosina58037eb2007-05-30 15:07:13 +0200524 dbg_hid("reserved item type, tag 0x%x\n", item->tag);
Jiri Kosinadde58452006-12-08 18:40:44 +0100525 return 0;
526}
527
528/*
529 * Free a report and all registered fields. The field->usage and
530 * field->value table's are allocated behind the field, so we need
531 * only to free(field) itself.
532 */
533
534static void hid_free_report(struct hid_report *report)
535{
536 unsigned n;
537
538 for (n = 0; n < report->maxfield; n++)
539 kfree(report->field[n]);
540 kfree(report);
541}
542
543/*
544 * Free a device structure, all reports, and all fields.
545 */
546
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200547static void hid_device_release(struct device *dev)
Jiri Kosinadde58452006-12-08 18:40:44 +0100548{
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200549 struct hid_device *device = container_of(dev, struct hid_device, dev);
550 unsigned i, j;
Jiri Kosinadde58452006-12-08 18:40:44 +0100551
552 for (i = 0; i < HID_REPORT_TYPES; i++) {
553 struct hid_report_enum *report_enum = device->report_enum + i;
554
555 for (j = 0; j < 256; j++) {
556 struct hid_report *report = report_enum->report_id_hash[j];
557 if (report)
558 hid_free_report(report);
559 }
560 }
561
562 kfree(device->rdesc);
Jiri Kosina767fe782007-01-24 23:05:07 +0100563 kfree(device->collection);
Jiri Kosinadde58452006-12-08 18:40:44 +0100564 kfree(device);
565}
566
567/*
568 * Fetch a report description item from the data stream. We support long
569 * items, though they are not used yet.
570 */
571
572static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
573{
574 u8 b;
575
576 if ((end - start) <= 0)
577 return NULL;
578
579 b = *start++;
580
581 item->type = (b >> 2) & 3;
582 item->tag = (b >> 4) & 15;
583
584 if (item->tag == HID_ITEM_TAG_LONG) {
585
586 item->format = HID_ITEM_FORMAT_LONG;
587
588 if ((end - start) < 2)
589 return NULL;
590
591 item->size = *start++;
592 item->tag = *start++;
593
594 if ((end - start) < item->size)
595 return NULL;
596
597 item->data.longdata = start;
598 start += item->size;
599 return start;
600 }
601
602 item->format = HID_ITEM_FORMAT_SHORT;
603 item->size = b & 3;
604
605 switch (item->size) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200606 case 0:
607 return start;
Jiri Kosinadde58452006-12-08 18:40:44 +0100608
Jiri Slaby880d29f2008-06-18 23:55:41 +0200609 case 1:
610 if ((end - start) < 1)
611 return NULL;
612 item->data.u8 = *start++;
613 return start;
Jiri Kosinadde58452006-12-08 18:40:44 +0100614
Jiri Slaby880d29f2008-06-18 23:55:41 +0200615 case 2:
616 if ((end - start) < 2)
617 return NULL;
618 item->data.u16 = get_unaligned_le16(start);
619 start = (__u8 *)((__le16 *)start + 1);
620 return start;
Jiri Kosinadde58452006-12-08 18:40:44 +0100621
Jiri Slaby880d29f2008-06-18 23:55:41 +0200622 case 3:
623 item->size++;
624 if ((end - start) < 4)
625 return NULL;
626 item->data.u32 = get_unaligned_le32(start);
627 start = (__u8 *)((__le32 *)start + 1);
628 return start;
Jiri Kosinadde58452006-12-08 18:40:44 +0100629 }
630
631 return NULL;
632}
633
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200634/**
635 * hid_parse_report - parse device report
636 *
637 * @device: hid device
638 * @start: report start
639 * @size: report size
640 *
Jiri Kosinadde58452006-12-08 18:40:44 +0100641 * Parse a report description into a hid_device structure. Reports are
642 * enumerated, fields are attached to these reports.
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200643 * 0 returned on success, otherwise nonzero error value.
Jiri Kosinadde58452006-12-08 18:40:44 +0100644 */
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200645int hid_parse_report(struct hid_device *device, __u8 *start,
646 unsigned size)
Jiri Kosinadde58452006-12-08 18:40:44 +0100647{
Jiri Kosinadde58452006-12-08 18:40:44 +0100648 struct hid_parser *parser;
649 struct hid_item item;
650 __u8 *end;
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200651 int ret;
Jiri Kosinadde58452006-12-08 18:40:44 +0100652 static int (*dispatch_type[])(struct hid_parser *parser,
653 struct hid_item *item) = {
654 hid_parser_main,
655 hid_parser_global,
656 hid_parser_local,
657 hid_parser_reserved
658 };
659
Jiri Slabyc500c972008-05-16 11:49:16 +0200660 if (device->driver->report_fixup)
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400661 start = device->driver->report_fixup(device, start, &size);
Jiri Slabyc500c972008-05-16 11:49:16 +0200662
Julia Lawall1721a232010-05-15 23:19:30 +0200663 device->rdesc = kmemdup(start, size, GFP_KERNEL);
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200664 if (device->rdesc == NULL)
665 return -ENOMEM;
Jiri Kosinadde58452006-12-08 18:40:44 +0100666 device->rsize = size;
667
Joe Perchesfe258022010-12-09 19:29:04 -0800668 parser = vzalloc(sizeof(struct hid_parser));
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200669 if (!parser) {
670 ret = -ENOMEM;
671 goto err;
Jiri Kosinadde58452006-12-08 18:40:44 +0100672 }
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200673
Jiri Kosinadde58452006-12-08 18:40:44 +0100674 parser->device = device;
675
676 end = start + size;
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200677 ret = -EINVAL;
Jiri Kosinadde58452006-12-08 18:40:44 +0100678 while ((start = fetch_item(start, end, &item)) != NULL) {
679
680 if (item.format != HID_ITEM_FORMAT_SHORT) {
Jiri Kosina58037eb2007-05-30 15:07:13 +0200681 dbg_hid("unexpected long global item\n");
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200682 goto err;
Jiri Kosinadde58452006-12-08 18:40:44 +0100683 }
684
685 if (dispatch_type[item.type](parser, &item)) {
Jiri Kosina58037eb2007-05-30 15:07:13 +0200686 dbg_hid("item %u %u %u %u parsing failed\n",
Joe Perches4291ee32010-12-09 19:29:03 -0800687 item.format, (unsigned)item.size,
688 (unsigned)item.type, (unsigned)item.tag);
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200689 goto err;
Jiri Kosinadde58452006-12-08 18:40:44 +0100690 }
691
692 if (start == end) {
693 if (parser->collection_stack_ptr) {
Jiri Kosina58037eb2007-05-30 15:07:13 +0200694 dbg_hid("unbalanced collection at end of report description\n");
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200695 goto err;
Jiri Kosinadde58452006-12-08 18:40:44 +0100696 }
697 if (parser->local.delimiter_depth) {
Jiri Kosina58037eb2007-05-30 15:07:13 +0200698 dbg_hid("unbalanced delimiter at end of report description\n");
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200699 goto err;
Jiri Kosinadde58452006-12-08 18:40:44 +0100700 }
Jiri Kosina47a80ed2007-03-12 14:55:12 +0100701 vfree(parser);
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200702 return 0;
Jiri Kosinadde58452006-12-08 18:40:44 +0100703 }
704 }
705
Jiri Kosina58037eb2007-05-30 15:07:13 +0200706 dbg_hid("item fetching failed at offset %d\n", (int)(end - start));
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200707err:
Jiri Kosina47a80ed2007-03-12 14:55:12 +0100708 vfree(parser);
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200709 return ret;
Jiri Kosinadde58452006-12-08 18:40:44 +0100710}
Jiri Kosina229695e2006-12-08 18:40:53 +0100711EXPORT_SYMBOL_GPL(hid_parse_report);
Jiri Kosinadde58452006-12-08 18:40:44 +0100712
713/*
714 * Convert a signed n-bit integer to signed 32-bit integer. Common
715 * cases are done through the compiler, the screwed things has to be
716 * done by hand.
717 */
718
719static s32 snto32(__u32 value, unsigned n)
720{
721 switch (n) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200722 case 8: return ((__s8)value);
723 case 16: return ((__s16)value);
724 case 32: return ((__s32)value);
Jiri Kosinadde58452006-12-08 18:40:44 +0100725 }
726 return value & (1 << (n - 1)) ? value | (-1 << n) : value;
727}
728
729/*
730 * Convert a signed 32-bit integer to a signed n-bit integer.
731 */
732
733static u32 s32ton(__s32 value, unsigned n)
734{
735 s32 a = value >> (n - 1);
736 if (a && a != -1)
737 return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
738 return value & ((1 << n) - 1);
739}
740
741/*
742 * Extract/implement a data field from/to a little endian report (bit array).
743 *
744 * Code sort-of follows HID spec:
745 * http://www.usb.org/developers/devclass_docs/HID1_11.pdf
746 *
747 * While the USB HID spec allows unlimited length bit fields in "report
748 * descriptors", most devices never use more than 16 bits.
749 * One model of UPS is claimed to report "LINEV" as a 32-bit field.
750 * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
751 */
752
Joe Perches16ee4cc2010-12-09 19:29:05 -0800753static __u32 extract(const struct hid_device *hid, __u8 *report,
754 unsigned offset, unsigned n)
Jiri Kosinadde58452006-12-08 18:40:44 +0100755{
756 u64 x;
757
Jiri Kosinac4124c92007-11-30 11:12:58 +0100758 if (n > 32)
Joe Perches4291ee32010-12-09 19:29:03 -0800759 hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n",
760 n, current->comm);
Jiri Kosinadde58452006-12-08 18:40:44 +0100761
762 report += offset >> 3; /* adjust byte index */
Jiri Kosina229695e2006-12-08 18:40:53 +0100763 offset &= 7; /* now only need bit offset into one byte */
Harvey Harrisonc1050682008-04-29 01:03:31 -0700764 x = get_unaligned_le64(report);
Jiri Kosina229695e2006-12-08 18:40:53 +0100765 x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */
Jiri Kosinadde58452006-12-08 18:40:44 +0100766 return (u32) x;
767}
768
769/*
770 * "implement" : set bits in a little endian bit stream.
771 * Same concepts as "extract" (see comments above).
772 * The data mangled in the bit stream remains in little endian
773 * order the whole time. It make more sense to talk about
774 * endianness of register values by considering a register
775 * a "cached" copy of the little endiad bit stream.
776 */
Joe Perches16ee4cc2010-12-09 19:29:05 -0800777static void implement(const struct hid_device *hid, __u8 *report,
778 unsigned offset, unsigned n, __u32 value)
Jiri Kosinadde58452006-12-08 18:40:44 +0100779{
Harvey Harrison6f0168d2008-05-16 11:00:23 +0200780 u64 x;
Jiri Kosinadde58452006-12-08 18:40:44 +0100781 u64 m = (1ULL << n) - 1;
782
Jiri Kosinac4124c92007-11-30 11:12:58 +0100783 if (n > 32)
Joe Perches4291ee32010-12-09 19:29:03 -0800784 hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n",
785 __func__, n, current->comm);
Jiri Kosinadde58452006-12-08 18:40:44 +0100786
Jiri Kosinac4124c92007-11-30 11:12:58 +0100787 if (value > m)
Joe Perches4291ee32010-12-09 19:29:03 -0800788 hid_warn(hid, "%s() called with too large value %d! (%s)\n",
789 __func__, value, current->comm);
Jiri Kosinadde58452006-12-08 18:40:44 +0100790 WARN_ON(value > m);
791 value &= m;
792
793 report += offset >> 3;
794 offset &= 7;
795
Harvey Harrison6f0168d2008-05-16 11:00:23 +0200796 x = get_unaligned_le64(report);
797 x &= ~(m << offset);
798 x |= ((u64)value) << offset;
799 put_unaligned_le64(x, report);
Jiri Kosinadde58452006-12-08 18:40:44 +0100800}
801
802/*
803 * Search an array for a value.
804 */
805
Joe Perches16ee4cc2010-12-09 19:29:05 -0800806static int search(__s32 *array, __s32 value, unsigned n)
Jiri Kosinadde58452006-12-08 18:40:44 +0100807{
808 while (n--) {
809 if (*array++ == value)
810 return 0;
811 }
812 return -1;
813}
814
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200815/**
816 * hid_match_report - check if driver's raw_event should be called
817 *
818 * @hid: hid device
819 * @report_type: type to match against
820 *
821 * compare hid->driver->report_table->report_type to report->type
822 */
823static int hid_match_report(struct hid_device *hid, struct hid_report *report)
Jiri Kosinadde58452006-12-08 18:40:44 +0100824{
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200825 const struct hid_report_id *id = hid->driver->report_table;
826
827 if (!id) /* NULL means all */
828 return 1;
829
830 for (; id->report_type != HID_TERMINATOR; id++)
831 if (id->report_type == HID_ANY_ID ||
832 id->report_type == report->type)
833 return 1;
834 return 0;
835}
836
837/**
838 * hid_match_usage - check if driver's event should be called
839 *
840 * @hid: hid device
841 * @usage: usage to match against
842 *
843 * compare hid->driver->usage_table->usage_{type,code} to
844 * usage->usage_{type,code}
845 */
846static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage)
847{
848 const struct hid_usage_id *id = hid->driver->usage_table;
849
850 if (!id) /* NULL means all */
851 return 1;
852
853 for (; id->usage_type != HID_ANY_ID - 1; id++)
854 if ((id->usage_hid == HID_ANY_ID ||
855 id->usage_hid == usage->hid) &&
856 (id->usage_type == HID_ANY_ID ||
857 id->usage_type == usage->type) &&
858 (id->usage_code == HID_ANY_ID ||
859 id->usage_code == usage->code))
860 return 1;
861 return 0;
862}
863
864static void hid_process_event(struct hid_device *hid, struct hid_field *field,
865 struct hid_usage *usage, __s32 value, int interrupt)
866{
867 struct hid_driver *hdrv = hid->driver;
868 int ret;
869
Jiri Kosinacd667ce2009-06-12 15:20:57 +0200870 hid_dump_input(hid, usage, value);
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200871
872 if (hdrv && hdrv->event && hid_match_usage(hid, usage)) {
873 ret = hdrv->event(hid, field, usage, value);
874 if (ret != 0) {
875 if (ret < 0)
876 dbg_hid("%s's event failed with %d\n",
877 hdrv->name, ret);
878 return;
879 }
880 }
881
Jiri Kosinadde58452006-12-08 18:40:44 +0100882 if (hid->claimed & HID_CLAIMED_INPUT)
883 hidinput_hid_event(hid, field, usage, value);
Jiri Kosinaaa938f72006-12-08 18:41:10 +0100884 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event)
885 hid->hiddev_hid_event(hid, field, usage, value);
Jiri Kosinadde58452006-12-08 18:40:44 +0100886}
887
888/*
889 * Analyse a received field, and fetch the data from it. The field
890 * content is stored for next report processing (we do differential
891 * reporting to the layer).
892 */
893
Adrian Bunkabdff0f2008-03-31 01:53:56 +0200894static void hid_input_field(struct hid_device *hid, struct hid_field *field,
895 __u8 *data, int interrupt)
Jiri Kosinadde58452006-12-08 18:40:44 +0100896{
897 unsigned n;
898 unsigned count = field->report_count;
899 unsigned offset = field->report_offset;
900 unsigned size = field->report_size;
901 __s32 min = field->logical_minimum;
902 __s32 max = field->logical_maximum;
903 __s32 *value;
904
Joe Perchesa3789a172010-12-09 19:29:07 -0800905 value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC);
906 if (!value)
Jiri Kosinadde58452006-12-08 18:40:44 +0100907 return;
908
909 for (n = 0; n < count; n++) {
910
Joe Perches4291ee32010-12-09 19:29:03 -0800911 value[n] = min < 0 ?
912 snto32(extract(hid, data, offset + n * size, size),
913 size) :
914 extract(hid, data, offset + n * size, size);
Jiri Kosinadde58452006-12-08 18:40:44 +0100915
Joe Perches4291ee32010-12-09 19:29:03 -0800916 /* Ignore report if ErrorRollOver */
917 if (!(field->flags & HID_MAIN_ITEM_VARIABLE) &&
918 value[n] >= min && value[n] <= max &&
919 field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1)
920 goto exit;
Jiri Kosinadde58452006-12-08 18:40:44 +0100921 }
922
923 for (n = 0; n < count; n++) {
924
925 if (HID_MAIN_ITEM_VARIABLE & field->flags) {
926 hid_process_event(hid, field, &field->usage[n], value[n], interrupt);
927 continue;
928 }
929
930 if (field->value[n] >= min && field->value[n] <= max
931 && field->usage[field->value[n] - min].hid
932 && search(value, field->value[n], count))
933 hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt);
934
935 if (value[n] >= min && value[n] <= max
936 && field->usage[value[n] - min].hid
937 && search(field->value, value[n], count))
938 hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt);
939 }
940
941 memcpy(field->value, value, count * sizeof(__s32));
942exit:
943 kfree(value);
944}
Jiri Kosinadde58452006-12-08 18:40:44 +0100945
946/*
947 * Output the field into the report.
948 */
949
Joe Perches4291ee32010-12-09 19:29:03 -0800950static void hid_output_field(const struct hid_device *hid,
951 struct hid_field *field, __u8 *data)
Jiri Kosinadde58452006-12-08 18:40:44 +0100952{
953 unsigned count = field->report_count;
954 unsigned offset = field->report_offset;
955 unsigned size = field->report_size;
956 unsigned n;
957
958 for (n = 0; n < count; n++) {
959 if (field->logical_minimum < 0) /* signed values */
Joe Perches4291ee32010-12-09 19:29:03 -0800960 implement(hid, data, offset + n * size, size,
961 s32ton(field->value[n], size));
Jiri Kosinadde58452006-12-08 18:40:44 +0100962 else /* unsigned values */
Joe Perches4291ee32010-12-09 19:29:03 -0800963 implement(hid, data, offset + n * size, size,
964 field->value[n]);
Jiri Kosinadde58452006-12-08 18:40:44 +0100965 }
966}
967
968/*
969 * Create a report.
970 */
971
Jiri Kosina229695e2006-12-08 18:40:53 +0100972void hid_output_report(struct hid_report *report, __u8 *data)
Jiri Kosinadde58452006-12-08 18:40:44 +0100973{
974 unsigned n;
975
976 if (report->id > 0)
977 *data++ = report->id;
978
Pete Zaitcev75c28df2010-04-12 12:16:11 -0600979 memset(data, 0, ((report->size - 1) >> 3) + 1);
Jiri Kosinadde58452006-12-08 18:40:44 +0100980 for (n = 0; n < report->maxfield; n++)
Joe Perches4291ee32010-12-09 19:29:03 -0800981 hid_output_field(report->device, report->field[n], data);
Jiri Kosinadde58452006-12-08 18:40:44 +0100982}
Jiri Kosina229695e2006-12-08 18:40:53 +0100983EXPORT_SYMBOL_GPL(hid_output_report);
Jiri Kosinadde58452006-12-08 18:40:44 +0100984
985/*
986 * Set a field value. The report this field belongs to has to be
987 * created and transferred to the device, to set this value in the
988 * device.
989 */
990
991int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
992{
993 unsigned size = field->report_size;
994
Jiri Kosinacd667ce2009-06-12 15:20:57 +0200995 hid_dump_input(field->report->device, field->usage + offset, value);
Jiri Kosinadde58452006-12-08 18:40:44 +0100996
997 if (offset >= field->report_count) {
Jiri Kosina58037eb2007-05-30 15:07:13 +0200998 dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count);
Jiri Kosinadde58452006-12-08 18:40:44 +0100999 return -1;
1000 }
1001 if (field->logical_minimum < 0) {
1002 if (value != snto32(s32ton(value, size), size)) {
Jiri Kosina58037eb2007-05-30 15:07:13 +02001003 dbg_hid("value %d is out of range\n", value);
Jiri Kosinadde58452006-12-08 18:40:44 +01001004 return -1;
1005 }
1006 }
1007 field->value[offset] = value;
1008 return 0;
1009}
Jiri Kosina229695e2006-12-08 18:40:53 +01001010EXPORT_SYMBOL_GPL(hid_set_field);
Jiri Kosinadde58452006-12-08 18:40:44 +01001011
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001012static struct hid_report *hid_get_report(struct hid_report_enum *report_enum,
1013 const u8 *data)
1014{
1015 struct hid_report *report;
1016 unsigned int n = 0; /* Normally report number is 0 */
1017
1018 /* Device uses numbered reports, data[0] is report number */
1019 if (report_enum->numbered)
1020 n = *data;
1021
1022 report = report_enum->report_id_hash[n];
1023 if (report == NULL)
1024 dbg_hid("undefined report_id %u received\n", n);
1025
1026 return report;
1027}
1028
1029void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
1030 int interrupt)
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001031{
1032 struct hid_report_enum *report_enum = hid->report_enum + type;
1033 struct hid_report *report;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001034 unsigned int a;
1035 int rsize, csize = size;
1036 u8 *cdata = data;
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001037
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001038 report = hid_get_report(report_enum, data);
1039 if (!report)
1040 return;
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001041
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001042 if (report_enum->numbered) {
1043 cdata++;
1044 csize--;
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001045 }
1046
1047 rsize = ((report->size - 1) >> 3) + 1;
1048
Armando Visconti966922f2011-05-19 21:41:22 +02001049 if (rsize > HID_MAX_BUFFER_SIZE)
1050 rsize = HID_MAX_BUFFER_SIZE;
1051
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001052 if (csize < rsize) {
1053 dbg_hid("report %d is too short, (%d < %d)\n", report->id,
1054 csize, rsize);
1055 memset(cdata + csize, 0, rsize - csize);
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001056 }
1057
1058 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
1059 hid->hiddev_report_event(hid, report);
Alan Ott5a38f2c2010-04-26 18:34:46 -04001060 if (hid->claimed & HID_CLAIMED_HIDRAW)
1061 hidraw_report_event(hid, data, size);
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001062
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001063 for (a = 0; a < report->maxfield; a++)
1064 hid_input_field(hid, report->field[a], cdata, interrupt);
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001065
1066 if (hid->claimed & HID_CLAIMED_INPUT)
1067 hidinput_report_event(hid, report);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001068}
1069EXPORT_SYMBOL_GPL(hid_report_raw_event);
1070
1071/**
1072 * hid_input_report - report data from lower layer (usb, bt...)
1073 *
1074 * @hid: hid device
1075 * @type: HID report type (HID_*_REPORT)
1076 * @data: report contents
1077 * @size: size of data parameter
Jiri Kosinaff9b00a2009-10-01 16:03:13 +02001078 * @interrupt: distinguish between interrupt and control transfers
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001079 *
1080 * This is data entry for lower layers.
1081 */
1082int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt)
1083{
Julia Lawall76c317d2009-07-19 17:26:13 +02001084 struct hid_report_enum *report_enum;
1085 struct hid_driver *hdrv;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001086 struct hid_report *report;
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001087 char *buf;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001088 unsigned int i;
Jiri Kosina45dc1ac2011-08-10 14:02:59 +02001089 int ret = 0;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001090
David Herrmann4ea54542011-08-10 14:02:07 +02001091 if (!hid)
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001092 return -ENODEV;
David Herrmann4ea54542011-08-10 14:02:07 +02001093
1094 if (down_trylock(&hid->driver_lock))
1095 return -EBUSY;
1096
1097 if (!hid->driver) {
1098 ret = -ENODEV;
1099 goto unlock;
1100 }
Julia Lawall76c317d2009-07-19 17:26:13 +02001101 report_enum = hid->report_enum + type;
1102 hdrv = hid->driver;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001103
1104 if (!size) {
1105 dbg_hid("empty report\n");
David Herrmann4ea54542011-08-10 14:02:07 +02001106 ret = -1;
1107 goto unlock;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001108 }
1109
Jiri Kosinad1ff6522009-09-15 11:59:49 +02001110 buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001111
Jiri Kosinaf77e3472010-03-18 14:11:53 +01001112 if (!buf)
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001113 goto nomem;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001114
1115 /* dump the report */
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001116 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
Jiri Kosina1caea612010-03-18 12:09:53 +01001117 "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un");
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001118 hid_debug_event(hid, buf);
Jiri Kosina1caea612010-03-18 12:09:53 +01001119
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001120 for (i = 0; i < size; i++) {
1121 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
1122 " %02x", data[i]);
1123 hid_debug_event(hid, buf);
1124 }
1125 hid_debug_event(hid, "\n");
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001126 kfree(buf);
1127
1128nomem:
Jiri Kosinaf77e3472010-03-18 14:11:53 +01001129 report = hid_get_report(report_enum, data);
1130
David Herrmann4ea54542011-08-10 14:02:07 +02001131 if (!report) {
1132 ret = -1;
1133 goto unlock;
1134 }
Jiri Kosinaf77e3472010-03-18 14:11:53 +01001135
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001136 if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) {
1137 ret = hdrv->raw_event(hid, report, data, size);
David Herrmann4ea54542011-08-10 14:02:07 +02001138 if (ret != 0) {
1139 ret = ret < 0 ? ret : 0;
1140 goto unlock;
1141 }
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001142 }
1143
1144 hid_report_raw_event(hid, type, data, size, interrupt);
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001145
David Herrmann4ea54542011-08-10 14:02:07 +02001146unlock:
1147 up(&hid->driver_lock);
Jiri Kosina45dc1ac2011-08-10 14:02:59 +02001148 return ret;
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001149}
1150EXPORT_SYMBOL_GPL(hid_input_report);
1151
Jiri Kosina0f37cd02008-08-20 19:13:52 +02001152static bool hid_match_one_id(struct hid_device *hdev,
1153 const struct hid_device_id *id)
1154{
1155 return id->bus == hdev->bus &&
1156 (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) &&
1157 (id->product == HID_ANY_ID || id->product == hdev->product);
1158}
1159
1160static const struct hid_device_id *hid_match_id(struct hid_device *hdev,
1161 const struct hid_device_id *id)
1162{
1163 for (; id->bus; id++)
1164 if (hid_match_one_id(hdev, id))
1165 return id;
1166
1167 return NULL;
1168}
1169
1170static const struct hid_device_id hid_hiddev_list[] = {
Richard Hughesc0bd6a42008-08-27 11:19:37 +02001171 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) },
1172 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) },
Jiri Kosina0f37cd02008-08-20 19:13:52 +02001173 { }
1174};
1175
1176static bool hid_hiddev(struct hid_device *hdev)
1177{
1178 return !!hid_match_id(hdev, hid_hiddev_list);
1179}
1180
Alan Ott6d3bfb72011-01-23 22:50:18 -05001181
1182static ssize_t
1183read_report_descriptor(struct file *filp, struct kobject *kobj,
1184 struct bin_attribute *attr,
1185 char *buf, loff_t off, size_t count)
1186{
1187 struct device *dev = container_of(kobj, struct device, kobj);
1188 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1189
1190 if (off >= hdev->rsize)
1191 return 0;
1192
1193 if (off + count > hdev->rsize)
1194 count = hdev->rsize - off;
1195
1196 memcpy(buf, hdev->rdesc + off, count);
1197
1198 return count;
1199}
1200
1201static struct bin_attribute dev_bin_attr_report_desc = {
1202 .attr = { .name = "report_descriptor", .mode = 0444 },
1203 .read = read_report_descriptor,
1204 .size = HID_MAX_DESCRIPTOR_SIZE,
1205};
1206
Jiri Slaby93c10132008-06-27 00:04:24 +02001207int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
1208{
1209 static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
1210 "Joystick", "Gamepad", "Keyboard", "Keypad",
1211 "Multi-Axis Controller"
1212 };
1213 const char *type, *bus;
1214 char buf[64];
1215 unsigned int i;
1216 int len;
Alan Ott6d3bfb72011-01-23 22:50:18 -05001217 int ret;
Jiri Slaby93c10132008-06-27 00:04:24 +02001218
Bastien Nocerab5e5a372010-04-16 17:19:50 +01001219 if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE)
1220 connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV);
Daniel Mack3a343ee2010-07-12 19:28:27 +02001221 if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE)
1222 connect_mask |= HID_CONNECT_HIDINPUT_FORCE;
Jiri Slaby93c10132008-06-27 00:04:24 +02001223 if (hdev->bus != BUS_USB)
1224 connect_mask &= ~HID_CONNECT_HIDDEV;
Jiri Kosina0f37cd02008-08-20 19:13:52 +02001225 if (hid_hiddev(hdev))
1226 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
Jiri Slaby93c10132008-06-27 00:04:24 +02001227
1228 if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev,
1229 connect_mask & HID_CONNECT_HIDINPUT_FORCE))
1230 hdev->claimed |= HID_CLAIMED_INPUT;
Benjamin Tissoiresb77c3922011-09-21 16:56:54 +02001231 if (hdev->quirks & HID_QUIRK_MULTITOUCH) {
1232 /* this device should be handled by hid-multitouch, skip it */
1233 hdev->quirks &= ~HID_QUIRK_MULTITOUCH;
1234 return -ENODEV;
1235 }
1236
Jiri Slaby93c10132008-06-27 00:04:24 +02001237 if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect &&
1238 !hdev->hiddev_connect(hdev,
1239 connect_mask & HID_CONNECT_HIDDEV_FORCE))
1240 hdev->claimed |= HID_CLAIMED_HIDDEV;
1241 if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev))
1242 hdev->claimed |= HID_CLAIMED_HIDRAW;
1243
1244 if (!hdev->claimed) {
Joe Perches4291ee32010-12-09 19:29:03 -08001245 hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n");
Jiri Slaby93c10132008-06-27 00:04:24 +02001246 return -ENODEV;
1247 }
1248
1249 if ((hdev->claimed & HID_CLAIMED_INPUT) &&
1250 (connect_mask & HID_CONNECT_FF) && hdev->ff_init)
1251 hdev->ff_init(hdev);
1252
1253 len = 0;
1254 if (hdev->claimed & HID_CLAIMED_INPUT)
1255 len += sprintf(buf + len, "input");
1256 if (hdev->claimed & HID_CLAIMED_HIDDEV)
1257 len += sprintf(buf + len, "%shiddev%d", len ? "," : "",
1258 hdev->minor);
1259 if (hdev->claimed & HID_CLAIMED_HIDRAW)
1260 len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
1261 ((struct hidraw *)hdev->hidraw)->minor);
1262
1263 type = "Device";
1264 for (i = 0; i < hdev->maxcollection; i++) {
1265 struct hid_collection *col = &hdev->collection[i];
1266 if (col->type == HID_COLLECTION_APPLICATION &&
1267 (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK &&
1268 (col->usage & 0xffff) < ARRAY_SIZE(types)) {
1269 type = types[col->usage & 0xffff];
1270 break;
1271 }
1272 }
1273
1274 switch (hdev->bus) {
1275 case BUS_USB:
1276 bus = "USB";
1277 break;
1278 case BUS_BLUETOOTH:
1279 bus = "BLUETOOTH";
1280 break;
1281 default:
1282 bus = "<UNKNOWN>";
1283 }
1284
Alan Ott6d3bfb72011-01-23 22:50:18 -05001285 ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
1286 if (ret)
1287 hid_warn(hdev,
1288 "can't create sysfs report descriptor attribute err: %d\n", ret);
1289
Joe Perches4291ee32010-12-09 19:29:03 -08001290 hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
1291 buf, bus, hdev->version >> 8, hdev->version & 0xff,
1292 type, hdev->name, hdev->phys);
Jiri Slaby93c10132008-06-27 00:04:24 +02001293
1294 return 0;
1295}
1296EXPORT_SYMBOL_GPL(hid_connect);
1297
Jiri Kosinac4c259b2009-09-15 16:27:45 +02001298void hid_disconnect(struct hid_device *hdev)
1299{
Alan Ott6d3bfb72011-01-23 22:50:18 -05001300 device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
Jiri Kosinac4c259b2009-09-15 16:27:45 +02001301 if (hdev->claimed & HID_CLAIMED_INPUT)
1302 hidinput_disconnect(hdev);
1303 if (hdev->claimed & HID_CLAIMED_HIDDEV)
1304 hdev->hiddev_disconnect(hdev);
1305 if (hdev->claimed & HID_CLAIMED_HIDRAW)
1306 hidraw_disconnect(hdev);
1307}
1308EXPORT_SYMBOL_GPL(hid_disconnect);
1309
Jiri Kosinabae7eb32009-01-28 23:06:37 +01001310/* a list of devices for which there is a specialized driver on HID bus */
Dmitry Torokhovce06b9d2010-11-28 16:37:14 +01001311static const struct hid_device_id hid_have_special_driver[] = {
Stephane Chattyb6353f42009-12-22 23:04:17 +01001312 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) },
Stephane Chatty6dec1432010-04-11 14:51:24 +02001313 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) },
Jiri Slaby14a21cd2008-06-23 23:31:09 +02001314 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
1315 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
Lech Perczakb7e1b202010-09-16 23:19:33 +02001316 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) },
Sergei Kolzunc0dbcc32010-07-19 12:13:23 +02001317 { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) },
Benjamin Tissoirese6aac342011-05-19 14:18:13 +02001318 { HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR, USB_DEVICE_ID_ACTIONSTAR_1011) },
Jiri Kosinadf9bcac2008-10-14 22:45:40 +02001319 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001320 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
1321 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) },
Michael Poole128537c2010-02-06 12:24:36 -05001322 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) },
Chase Douglasa4622302010-08-31 21:56:23 -04001323 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001324 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
1325 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
1326 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
1327 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) },
1328 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) },
1329 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) },
1330 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) },
1331 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) },
1332 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) },
1333 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) },
1334 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) },
Ryan Finniefef3f572009-03-05 10:18:01 +01001335 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI) },
1336 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO) },
1337 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001338 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) },
1339 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) },
1340 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) },
1341 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) },
1342 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) },
1343 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) },
Jan Scholzee8a1a02008-11-26 15:33:45 +01001344 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) },
1345 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) },
1346 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001347 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) },
1348 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) },
1349 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) },
1350 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
1351 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
1352 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
Henrik Rydberga96d6ef2008-11-04 20:03:45 +01001353 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
1354 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
1355 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
Edgar (gimli) Hucek99b9f752010-11-03 10:36:18 -04001356 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) },
1357 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) },
1358 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) },
1359 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) },
1360 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) },
1361 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) },
Andy Botting47340bd2011-03-12 20:27:22 -08001362 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
1363 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
1364 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
Gökçen Eraslan213f9da2011-10-22 22:39:06 +03001365 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
1366 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
1367 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
Dan Bastone4a4c8792011-07-31 07:40:49 -04001368 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) },
1369 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) },
1370 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) },
Jiri Kosinaf6f554f2011-08-10 14:12:52 +02001371 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) },
1372 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) },
1373 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) },
Jiri Kosinab3aec7b2011-10-25 09:59:04 +02001374 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
1375 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
1376 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
Christian Schuerer-Waldheim23aeb612010-01-06 14:49:57 +01001377 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
1378 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
1379 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
Andreas Kristad734bc2011-10-28 18:50:39 +02001380 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001381 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1382 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
Jiri Kosinaeaca1382010-09-08 14:31:47 +02001383 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) },
Roland Baumcec15a02010-09-08 14:27:55 +02001384 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) },
Jiri Slabyb5635b12008-06-24 23:24:57 +02001385 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
Wayne Thomasbf280622010-04-29 00:45:01 +02001386 { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) },
Jiri Kosinac3dc66d2010-08-30 15:43:25 +02001387 { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) },
Benjamin Tissoires5519cab2011-01-07 23:45:50 +01001388 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) },
Stephane Chatty36213e12010-04-15 00:28:11 +02001389 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) },
Benjamin Tissoiresbc5ab082011-01-08 12:15:41 +01001390 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) },
Stephane Chattyba4d8ab2010-04-22 23:24:36 +02001391 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) },
François Jaouen272036e2010-10-13 10:47:32 +02001392 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) },
Jiri Slaby3b239cd2008-06-24 20:42:25 +02001393 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
Raphaël Doursenaud1ce31b22010-04-08 13:40:52 +02001394 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) },
Jiri Slabyfcfacfd2008-06-24 22:48:52 +02001395 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
Dennis Küglerb9e4b1e2010-11-23 21:40:09 +01001396 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) },
Austin Zhang942fd422011-05-28 02:03:47 +08001397 { HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) },
Don Prince3a370ca2010-05-12 15:18:59 +02001398 { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
Benjamin Tissoires79603dc2011-05-19 14:18:14 +02001399 { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, USB_DEVICE_ID_CVTOUCH_SCREEN) },
Jiri Slaby0f221322008-06-23 22:54:08 +02001400 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
1401 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) },
Jiri Kosinae8d0eab2009-12-02 22:54:11 +01001402 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) },
Jiri Slaby0f221322008-06-23 22:54:08 +02001403 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
Benjamin Tissoiresa3b5e572011-01-07 23:46:30 +01001404 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) },
Richard Walmsley3f866fb2009-03-04 22:12:04 +13001405 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) },
Nikolai Kondrashove05eefb2011-01-28 14:50:52 +03001406 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) },
Stephane Chatty0c3910c2010-04-10 16:43:08 +02001407 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) },
Chris Ball83e44912010-08-16 16:01:28 +02001408 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) },
Henrik Rydberg4e93db22010-11-29 07:27:49 +01001409 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) },
Richard Nauber28906ad2010-12-14 22:36:18 +01001410 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) },
Andy Ross4dd295a2010-12-16 15:53:19 -08001411 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) },
Richard Nauber64b386e2010-06-28 18:54:25 +02001412 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
Benjamin Tissoiresc04abee2011-05-19 11:37:29 +02001413 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2515) },
Ignaz Forster04561c52010-11-01 15:13:37 -04001414 { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) },
Jiri Slaby1f243e32008-06-24 21:11:21 +02001415 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
Jiri Kosina5181e592008-11-17 01:44:38 +01001416 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
Jiri Kosina578f3a32008-11-20 15:55:38 +01001417 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) },
Benjamin Tissoires5572da02011-01-07 23:47:27 +01001418 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) },
Benjamin Tissoiresee0fbd12011-05-19 14:18:15 +02001419 { HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, USB_DEVICE_ID_GOODTOUCH_000f) },
Jiri Kosina5181e592008-11-17 01:44:38 +01001420 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
Lukasz Lubojanski42859e02008-12-11 22:07:59 +01001421 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) },
Jiri Slaby949f8fe2008-07-24 23:35:13 +02001422 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
Jiri Kosina1e093202008-10-17 11:52:23 +02001423 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) },
Cory Maccarronec2fd1a42010-05-22 13:00:28 -07001424 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) },
Benjamin Tissoires5519cab2011-01-07 23:45:50 +01001425 { HID_USB_DEVICE(USB_VENDOR_ID_HANVON, USB_DEVICE_ID_HANVON_MULTITOUCH) },
Stephane Chattya062cc52011-09-17 22:27:30 +02001426 { HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM, USB_DEVICE_ID_IDEACOM_IDC6650) },
Anssi Hannulad946e652011-06-27 00:07:31 +03001427 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) },
Austin Zhang4e61f0d2011-05-09 23:54:14 +08001428 { HID_USB_DEVICE(USB_VENDOR_ID_ILITEK, USB_DEVICE_ID_ILITEK_MULTITOUCH) },
Benjamin Tissoiresb2e76172011-02-15 15:33:48 +01001429 { HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS, USB_DEVICE_ID_IRTOUCH_INFRARED_USB) },
Jiri Kosinafdf93aa2009-03-04 16:09:40 +01001430 { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) },
Jiri Kosina177900e2011-02-17 15:12:45 +01001431 { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) },
Jiri Kosina79422742009-03-11 11:43:27 +01001432 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) },
Jiri Slabyb5635b12008-06-24 23:24:57 +02001433 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
Chris Schlund75b07022011-02-03 16:41:47 +01001434 { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) },
Jeff Brownc50bb1a2011-08-15 21:12:09 -07001435 { HID_USB_DEVICE(USB_VENDOR_ID_LG, USB_DEVICE_ID_LG_MULTITOUCH) },
Jiri Slaby5f22a792008-05-16 11:49:19 +02001436 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) },
1437 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) },
1438 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) },
1439 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) },
1440 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) },
1441 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) },
1442 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) },
Jiri Slaby5f22a792008-05-16 11:49:19 +02001443 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) },
1444 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) },
Jiri Slaby5f22a792008-05-16 11:49:19 +02001445 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) },
1446 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) },
Hendrik Iben2c6118e2010-10-04 15:39:49 +02001447 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) },
Jiri Slaby606bd0a2008-07-04 23:06:45 +02001448 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) },
1449 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) },
1450 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) },
Jiri Kosinafd30ea82009-06-23 12:11:31 +02001451 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) },
Jiri Slaby606bd0a2008-07-04 23:06:45 +02001452 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) },
Gary Stein74f292c2010-01-13 00:25:58 +01001453 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) },
Jiri Slaby606bd0a2008-07-04 23:06:45 +02001454 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) },
1455 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) },
Jiri Kosina5623a242011-03-17 00:43:23 +01001456 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL) },
Michal Malýe00ddc92011-09-10 21:28:23 +02001457 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL) },
Christophe Borivant243b7062009-04-17 11:39:39 +02001458 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) },
Peter Gundermannfdc68072011-05-03 10:15:03 +02001459 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G27_WHEEL) },
Nestor Lopez Casado534a7b82011-09-15 11:34:49 +02001460 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER) },
1461 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2) },
Simon Wood32c88cb2010-09-22 13:19:42 +02001462 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) },
Jiri Slaby606bd0a2008-07-04 23:06:45 +02001463 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) },
Jiri Kosina24985cf2009-11-13 10:45:53 +01001464 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) },
1465 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) },
Benjamin Tissoiresdf167c42011-05-18 15:27:24 +02001466 { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH) },
Benjamin Tissoiresc3ead6d2011-06-21 15:01:55 +02001467 { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH_DUAL) },
Bruno Prémont236db472010-03-30 22:33:50 +02001468 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) },
1469 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) },
Jiri Kosinab5801692011-07-22 12:11:15 +02001470 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) },
Jiri Slaby78a849a2008-06-20 21:26:11 +02001471 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
1472 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) },
1473 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
1474 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) },
Jiri Kosinaf3b83d72011-06-13 23:08:18 +03001475 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) },
Jiri Slaby78a849a2008-06-20 21:26:11 +02001476 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
Jiri Slaby3b8006e2008-06-25 00:07:50 +02001477 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
Rafi Rubin94011f92008-11-19 15:54:46 +01001478 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
micki6e328192010-06-19 11:37:29 +03001479 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) },
1480 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) },
1481 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) },
1482 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) },
1483 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) },
1484 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) },
1485 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) },
1486 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) },
1487 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) },
1488 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) },
1489 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) },
1490 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) },
1491 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) },
1492 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) },
1493 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) },
1494 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) },
1495 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) },
1496 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) },
Herton Ronaldo Krzesinski270fdc02011-03-16 14:13:53 -03001497 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) },
Johnathon Harriscd9ec302010-01-21 14:36:52 +00001498 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },
John Sung6ab3a9a2011-04-21 16:21:52 +02001499 { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_PCI) },
Jiri Slaby1e762532008-06-24 23:46:21 +02001500 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
Terry Lambertf6a04602011-10-14 17:18:54 -07001501 { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) },
Stephane Chatty49e47392010-01-13 00:29:16 +01001502 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
Alex Neblettf54405d2010-02-02 21:16:03 -08001503 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) },
Stefan Achatz14bf62c2010-03-18 16:19:43 +01001504 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) },
Stefan Achatze68cc602011-01-06 09:00:34 +01001505 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) },
Stefan Achatz47dbdbf2010-11-26 19:57:42 +00001506 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) },
Stefan Achatz0e70f972011-01-30 13:38:24 +01001507 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) },
Stefan Achatzcb7cf3d2010-08-29 12:30:18 +02001508 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
Stefan Achatz3fce2242011-03-23 18:11:36 +01001509 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) },
Jiri Slaby980a3da2008-06-25 22:31:48 +02001510 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
Don Princeb3558502010-05-17 11:42:39 +01001511 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
Jiri Kosinad586dca2011-03-21 13:54:22 +01001512 { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
Jiri Slabybd28ce02008-06-25 23:47:04 +02001513 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
Jiri Kosina35dca5b2011-04-28 15:43:13 +02001514 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
Bastien Noceraf9ce7c22010-01-20 12:01:53 +00001515 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +02001516 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
Stephane Chattyd3fb5452010-01-04 12:04:08 +01001517 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) },
Pascal Auriel - Stantumb6dc7992010-10-01 16:01:28 +02001518 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) },
1519 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) },
Jiri Slaby90231e72008-06-23 21:56:07 +02001520 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
Anssi Hannuladaedb3d2009-02-14 11:45:05 +02001521 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
1522 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) },
Ruben Aos Garralda7a84b132009-06-29 09:41:29 +02001523 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) },
1524 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) },
Anssi Hannuladaedb3d2009-02-14 11:45:05 +02001525 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
Markus Rathgeb3ee8f0a2010-03-13 17:29:43 +01001526 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) },
Anssi Hannuladaedb3d2009-02-14 11:45:05 +02001527 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
Simon Woodd65c3762010-11-29 17:41:23 +01001528 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) },
Lev Babievf14f5262009-01-04 00:36:56 +01001529 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
Kees Bakker54001082010-07-13 22:50:51 +02001530 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) },
Benjamin Tissoires5e74e562011-05-19 14:18:16 +02001531 { HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) },
Bruno Premont711a6802009-07-13 14:19:58 +02001532 { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) },
Benjamin Tissoiresc64f6f92011-01-08 12:15:42 +01001533 { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) },
Nikolai Kondrashov41fa9232010-08-23 15:09:01 +04001534 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) },
Nikolai Kondrashovf8a489c2010-08-09 20:44:17 +04001535 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) },
1536 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) },
1537 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) },
Nikolai Kondrashov6be914f2011-07-06 09:23:41 +03001538 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) },
Benjamin Tissoires617b64f2011-05-19 14:18:17 +02001539 { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) },
1540 { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) },
Jussi Kivilinnafac733f2009-05-13 11:54:38 +03001541 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) },
Sean Youngad395cc2011-08-14 20:42:05 +01001542 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) },
Sean Young1bcc2062011-10-20 21:26:21 +01001543 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) },
1544 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) },
1545 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
Bastien Noceraca2dcd42009-05-11 17:18:12 +02001546 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
Nikolai Kondrashov72a46342010-08-20 19:21:11 +04001547 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
Nikolai Kondrashov00e7f962010-09-25 23:16:58 +04001548 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
Nikolai Kondrashov72a46342010-08-20 19:21:11 +04001549 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
Nikolai Kondrashov8f1acc32010-08-30 14:06:36 +04001550 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
ice chienbc8a2a92011-07-15 16:58:06 +08001551 { HID_USB_DEVICE(USB_VENDOR_ID_XAT, USB_DEVICE_ID_XAT_CSR) },
Stefan Kriwanek74bc6952011-05-27 18:40:29 +02001552 { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) },
Anssi Hannuladaedb3d2009-02-14 11:45:05 +02001553 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
1554 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
Don Princea9885c82010-05-14 17:30:59 +01001555 { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001556
Jiri Slaby78a849a2008-06-20 21:26:11 +02001557 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) },
David Herrmann02fb72a2011-07-05 13:45:09 +02001558 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) },
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001559 { }
1560};
1561
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01001562struct hid_dynid {
1563 struct list_head list;
1564 struct hid_device_id id;
1565};
1566
1567/**
1568 * store_new_id - add a new HID device ID to this driver and re-probe devices
1569 * @driver: target device driver
1570 * @buf: buffer for scanning device ID data
1571 * @count: input size
1572 *
1573 * Adds a new dynamic hid device ID to this driver,
1574 * and causes the driver to probe for all devices again.
1575 */
1576static ssize_t store_new_id(struct device_driver *drv, const char *buf,
1577 size_t count)
1578{
1579 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
1580 struct hid_dynid *dynid;
1581 __u32 bus, vendor, product;
1582 unsigned long driver_data = 0;
1583 int ret;
1584
1585 ret = sscanf(buf, "%x %x %x %lx",
1586 &bus, &vendor, &product, &driver_data);
1587 if (ret < 3)
1588 return -EINVAL;
1589
1590 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
1591 if (!dynid)
1592 return -ENOMEM;
1593
1594 dynid->id.bus = bus;
1595 dynid->id.vendor = vendor;
1596 dynid->id.product = product;
1597 dynid->id.driver_data = driver_data;
1598
1599 spin_lock(&hdrv->dyn_lock);
1600 list_add_tail(&dynid->list, &hdrv->dyn_list);
1601 spin_unlock(&hdrv->dyn_lock);
1602
1603 ret = 0;
1604 if (get_driver(&hdrv->driver)) {
1605 ret = driver_attach(&hdrv->driver);
1606 put_driver(&hdrv->driver);
1607 }
1608
1609 return ret ? : count;
1610}
1611static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
1612
1613static void hid_free_dynids(struct hid_driver *hdrv)
1614{
1615 struct hid_dynid *dynid, *n;
1616
1617 spin_lock(&hdrv->dyn_lock);
1618 list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) {
1619 list_del(&dynid->list);
1620 kfree(dynid);
1621 }
1622 spin_unlock(&hdrv->dyn_lock);
1623}
1624
1625static const struct hid_device_id *hid_match_device(struct hid_device *hdev,
1626 struct hid_driver *hdrv)
1627{
1628 struct hid_dynid *dynid;
1629
1630 spin_lock(&hdrv->dyn_lock);
1631 list_for_each_entry(dynid, &hdrv->dyn_list, list) {
1632 if (hid_match_one_id(hdev, &dynid->id)) {
1633 spin_unlock(&hdrv->dyn_lock);
1634 return &dynid->id;
1635 }
1636 }
1637 spin_unlock(&hdrv->dyn_lock);
1638
1639 return hid_match_id(hdev, hdrv->id_table);
1640}
1641
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001642static int hid_bus_match(struct device *dev, struct device_driver *drv)
1643{
1644 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
1645 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1646
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01001647 if (!hid_match_device(hdev, hdrv))
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001648 return 0;
1649
Dmitry Torokhovce06b9d2010-11-28 16:37:14 +01001650 /* generic wants all that don't have specialized driver */
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001651 if (!strncmp(hdrv->name, "generic-", 8))
Dmitry Torokhovce06b9d2010-11-28 16:37:14 +01001652 return !hid_match_id(hdev, hid_have_special_driver);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001653
1654 return 1;
1655}
1656
1657static int hid_device_probe(struct device *dev)
1658{
1659 struct hid_driver *hdrv = container_of(dev->driver,
1660 struct hid_driver, driver);
1661 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1662 const struct hid_device_id *id;
1663 int ret = 0;
1664
David Herrmann4ea54542011-08-10 14:02:07 +02001665 if (down_interruptible(&hdev->driver_lock))
1666 return -EINTR;
1667
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001668 if (!hdev->driver) {
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01001669 id = hid_match_device(hdev, hdrv);
Dan Carpenterba623a72011-08-24 14:27:46 +03001670 if (id == NULL) {
1671 ret = -ENODEV;
1672 goto unlock;
1673 }
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001674
Jiri Slabyc500c972008-05-16 11:49:16 +02001675 hdev->driver = hdrv;
1676 if (hdrv->probe) {
1677 ret = hdrv->probe(hdev, id);
1678 } else { /* default probe */
1679 ret = hid_parse(hdev);
1680 if (!ret)
Jiri Slaby93c10132008-06-27 00:04:24 +02001681 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001682 }
Jiri Slabyc500c972008-05-16 11:49:16 +02001683 if (ret)
1684 hdev->driver = NULL;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001685 }
Dan Carpenterba623a72011-08-24 14:27:46 +03001686unlock:
David Herrmann4ea54542011-08-10 14:02:07 +02001687 up(&hdev->driver_lock);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001688 return ret;
1689}
1690
1691static int hid_device_remove(struct device *dev)
1692{
1693 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
David Herrmann4ea54542011-08-10 14:02:07 +02001694 struct hid_driver *hdrv;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001695
David Herrmann4ea54542011-08-10 14:02:07 +02001696 if (down_interruptible(&hdev->driver_lock))
1697 return -EINTR;
1698
1699 hdrv = hdev->driver;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001700 if (hdrv) {
1701 if (hdrv->remove)
1702 hdrv->remove(hdev);
Jiri Slabyc500c972008-05-16 11:49:16 +02001703 else /* default remove */
1704 hid_hw_stop(hdev);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001705 hdev->driver = NULL;
1706 }
1707
David Herrmann4ea54542011-08-10 14:02:07 +02001708 up(&hdev->driver_lock);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001709 return 0;
1710}
1711
1712static int hid_uevent(struct device *dev, struct kobj_uevent_env *env)
1713{
1714 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1715
1716 if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X",
1717 hdev->bus, hdev->vendor, hdev->product))
1718 return -ENOMEM;
1719
1720 if (add_uevent_var(env, "HID_NAME=%s", hdev->name))
1721 return -ENOMEM;
1722
1723 if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys))
1724 return -ENOMEM;
1725
1726 if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq))
1727 return -ENOMEM;
1728
1729 if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X",
1730 hdev->bus, hdev->vendor, hdev->product))
1731 return -ENOMEM;
1732
1733 return 0;
1734}
1735
1736static struct bus_type hid_bus_type = {
1737 .name = "hid",
1738 .match = hid_bus_match,
1739 .probe = hid_device_probe,
1740 .remove = hid_device_remove,
1741 .uevent = hid_uevent,
1742};
1743
Jiri Kosinabae7eb32009-01-28 23:06:37 +01001744/* a list of devices that shouldn't be handled by HID core at all */
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001745static const struct hid_device_id hid_ignore_list[] = {
1746 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) },
1747 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) },
1748 { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) },
1749 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) },
1750 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) },
1751 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) },
1752 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) },
1753 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) },
1754 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) },
1755 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
1756 { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
1757 { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
Stephane Chatty77f720b2010-02-06 15:17:13 +01001758 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)},
1759 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)},
Alexey Klimov62a56582008-11-13 05:44:50 +03001760 { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001761 { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) },
1762 { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) },
1763 { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) },
1764 { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) },
1765 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) },
1766 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) },
Alexey Klimov5f6108c2008-12-08 12:40:14 +01001767 { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001768 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
1769 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
Melchior FRANZ73bc7d32010-12-22 02:04:33 +01001770 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001771 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
Petr Å tetiar70c66562009-12-09 22:09:53 +01001772 { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) },
Petr Å tetiardf506f22010-06-28 09:38:54 -07001773 { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001774 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) },
1775 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) },
1776 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) },
1777 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) },
1778 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) },
1779 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) },
1780 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) },
1781 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) },
1782 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) },
1783 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) },
1784 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) },
1785 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) },
1786 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) },
1787 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) },
1788 { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) },
1789 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) },
1790 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) },
1791 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) },
1792 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) },
1793 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) },
1794 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) },
1795 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) },
1796 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) },
1797 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) },
1798 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) },
1799 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) },
1800 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) },
1801 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) },
1802 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) },
1803 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) },
1804 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) },
1805 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) },
1806 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) },
1807 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) },
1808 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) },
1809 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) },
1810 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) },
1811 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) },
1812 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) },
1813 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) },
1814 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) },
1815 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) },
1816 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) },
1817 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) },
1818 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) },
1819 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) },
1820 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) },
1821 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) },
1822 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) },
1823 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) },
1824 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) },
1825 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) },
1826 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) },
1827 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) },
1828 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) },
1829 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) },
1830 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) },
1831 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) },
1832 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) },
1833 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) },
1834 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) },
1835 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) },
1836 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
1837 { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
1838 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
Alexey Klimovc91c21c2008-11-13 10:36:11 +01001839 { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001840 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
Lamarque Vieira Souzaeb8141c2009-10-02 15:04:44 +02001841 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001842 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) },
Michael Hundce97cac2011-05-03 10:12:00 -07001843 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001844 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) },
Michael Hundce97cac2011-05-03 10:12:00 -07001845 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001846 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) },
Michael Hundce97cac2011-05-03 10:12:00 -07001847 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) },
1848 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) },
1849 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) },
1850 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) },
1851 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) },
1852 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001853 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) },
1854 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) },
1855 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
Michael Hundce97cac2011-05-03 10:12:00 -07001856 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) },
1857 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) },
1858 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001859 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) },
1860 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) },
Michael Hundce97cac2011-05-03 10:12:00 -07001861 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001862 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) },
1863 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) },
1864 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) },
1865 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) },
1866 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) },
Michael Hundce97cac2011-05-03 10:12:00 -07001867 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) },
1868 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) },
1869 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) },
1870 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) },
1871 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) },
1872 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) },
1873 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001874 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) },
1875 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001876 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) },
1877 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) },
1878 { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) },
1879 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) },
1880 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) },
1881 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) },
1882 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) },
1883 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) },
1884 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) },
1885 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) },
1886 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) },
1887 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) },
1888 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) },
1889 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) },
1890 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) },
1891 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
1892 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
Henning Glawe4cfae3e2009-08-02 22:18:12 +02001893 { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) },
Michael Tokarev35cfd1d2009-02-01 16:11:04 +01001894 { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001895 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
1896 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
1897 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
1898 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
1899 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
1900 { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) },
1901 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) },
1902 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) },
1903 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) },
1904 { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
1905 { }
1906};
1907
Jiri Slabyb4d8e472008-10-22 14:47:18 +02001908/**
1909 * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer
1910 *
1911 * There are composite devices for which we want to ignore only a certain
1912 * interface. This is a list of devices for which only the mouse interface will
1913 * be ignored. This allows a dedicated driver to take care of the interface.
1914 */
1915static const struct hid_device_id hid_mouse_ignore_list[] = {
1916 /* appletouch driver */
1917 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
1918 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
1919 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
1920 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) },
1921 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) },
1922 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) },
1923 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) },
1924 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) },
1925 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) },
1926 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) },
1927 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) },
1928 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) },
1929 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) },
1930 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) },
1931 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) },
1932 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) },
1933 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) },
1934 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
1935 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
1936 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
Jiri Kosinaac26fca2008-11-20 11:27:02 +01001937 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
1938 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
1939 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
Edgar (gimli) Hucek99b9f752010-11-03 10:36:18 -04001940 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) },
1941 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) },
1942 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) },
1943 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) },
1944 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) },
1945 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) },
Andy Botting47340bd2011-03-12 20:27:22 -08001946 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
1947 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
1948 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
Gökçen Eraslan213f9da2011-10-22 22:39:06 +03001949 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
1950 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
1951 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
Jiri Kosina4b086912011-10-04 14:01:12 +02001952 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) },
1953 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) },
1954 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) },
1955 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
1956 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
1957 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
Jiri Slabyb4d8e472008-10-22 14:47:18 +02001958 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1959 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1960 { }
1961};
1962
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001963static bool hid_ignore(struct hid_device *hdev)
1964{
1965 switch (hdev->vendor) {
1966 case USB_VENDOR_ID_CODEMERCS:
1967 /* ignore all Code Mercenaries IOWarrior devices */
1968 if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST &&
1969 hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST)
1970 return true;
1971 break;
1972 case USB_VENDOR_ID_LOGITECH:
1973 if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST &&
1974 hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST)
1975 return true;
1976 break;
Jarod Wilson31f7fd72009-07-31 10:56:36 -04001977 case USB_VENDOR_ID_SOUNDGRAPH:
1978 if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST &&
1979 hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST)
1980 return true;
1981 break;
Xing Weibba53942010-09-01 23:25:35 -07001982 case USB_VENDOR_ID_HANWANG:
1983 if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST &&
1984 hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST)
1985 return true;
1986 break;
Tomoki Sekiyama6dc14182011-05-23 15:45:44 -07001987 case USB_VENDOR_ID_JESS:
1988 if (hdev->product == USB_DEVICE_ID_JESS_YUREX &&
1989 hdev->type == HID_TYPE_USBNONE)
1990 return true;
1991 break;
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001992 }
1993
Jiri Slabyb4d8e472008-10-22 14:47:18 +02001994 if (hdev->type == HID_TYPE_USBMOUSE &&
1995 hid_match_id(hdev, hid_mouse_ignore_list))
1996 return true;
1997
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001998 return !!hid_match_id(hdev, hid_ignore_list);
1999}
2000
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002001int hid_add_device(struct hid_device *hdev)
2002{
2003 static atomic_t id = ATOMIC_INIT(0);
2004 int ret;
2005
2006 if (WARN_ON(hdev->status & HID_STAT_ADDED))
2007 return -EBUSY;
2008
Jiri Slabyd458a9d2008-05-16 11:49:20 +02002009 /* we need to kill them here, otherwise they will stay allocated to
2010 * wait for coming driver */
Jindrich Makovickae5a2a042010-06-03 12:50:42 +02002011 if (!(hdev->quirks & HID_QUIRK_NO_IGNORE)
2012 && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE)))
Jiri Slabyd458a9d2008-05-16 11:49:20 +02002013 return -ENODEV;
2014
Kay Sievers6bbe5862008-10-31 00:12:32 +01002015 /* XXX hack, any other cleaner solution after the driver core
2016 * is converted to allow more than 20 bytes as the device name? */
2017 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
2018 hdev->vendor, hdev->product, atomic_inc_return(&id));
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002019
Bruno Prémont4da361b2010-03-15 14:55:40 +01002020 hid_debug_register(hdev, dev_name(&hdev->dev));
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002021 ret = device_add(&hdev->dev);
2022 if (!ret)
2023 hdev->status |= HID_STAT_ADDED;
Bruno Prémont4da361b2010-03-15 14:55:40 +01002024 else
2025 hid_debug_unregister(hdev);
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002026
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002027 return ret;
2028}
2029EXPORT_SYMBOL_GPL(hid_add_device);
2030
2031/**
2032 * hid_allocate_device - allocate new hid device descriptor
2033 *
2034 * Allocate and initialize hid device, so that hid_destroy_device might be
2035 * used to free it.
2036 *
2037 * New hid_device pointer is returned on success, otherwise ERR_PTR encoded
2038 * error value.
2039 */
2040struct hid_device *hid_allocate_device(void)
2041{
2042 struct hid_device *hdev;
2043 unsigned int i;
2044 int ret = -ENOMEM;
2045
2046 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
2047 if (hdev == NULL)
2048 return ERR_PTR(ret);
2049
2050 device_initialize(&hdev->dev);
2051 hdev->dev.release = hid_device_release;
2052 hdev->dev.bus = &hid_bus_type;
2053
2054 hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS,
2055 sizeof(struct hid_collection), GFP_KERNEL);
2056 if (hdev->collection == NULL)
2057 goto err;
2058 hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
2059
2060 for (i = 0; i < HID_REPORT_TYPES; i++)
2061 INIT_LIST_HEAD(&hdev->report_enum[i].report_list);
2062
Jiri Kosinacd667ce2009-06-12 15:20:57 +02002063 init_waitqueue_head(&hdev->debug_wait);
2064 INIT_LIST_HEAD(&hdev->debug_list);
David Herrmann4ea54542011-08-10 14:02:07 +02002065 sema_init(&hdev->driver_lock, 1);
Jiri Kosinacd667ce2009-06-12 15:20:57 +02002066
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002067 return hdev;
2068err:
2069 put_device(&hdev->dev);
2070 return ERR_PTR(ret);
2071}
2072EXPORT_SYMBOL_GPL(hid_allocate_device);
2073
2074static void hid_remove_device(struct hid_device *hdev)
2075{
2076 if (hdev->status & HID_STAT_ADDED) {
2077 device_del(&hdev->dev);
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002078 hid_debug_unregister(hdev);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002079 hdev->status &= ~HID_STAT_ADDED;
2080 }
2081}
2082
2083/**
2084 * hid_destroy_device - free previously allocated device
2085 *
2086 * @hdev: hid device
2087 *
2088 * If you allocate hid_device through hid_allocate_device, you should ever
2089 * free by this function.
2090 */
2091void hid_destroy_device(struct hid_device *hdev)
2092{
2093 hid_remove_device(hdev);
2094 put_device(&hdev->dev);
2095}
2096EXPORT_SYMBOL_GPL(hid_destroy_device);
2097
2098int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
2099 const char *mod_name)
2100{
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01002101 int ret;
2102
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002103 hdrv->driver.name = hdrv->name;
2104 hdrv->driver.bus = &hid_bus_type;
2105 hdrv->driver.owner = owner;
2106 hdrv->driver.mod_name = mod_name;
2107
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01002108 INIT_LIST_HEAD(&hdrv->dyn_list);
2109 spin_lock_init(&hdrv->dyn_lock);
2110
2111 ret = driver_register(&hdrv->driver);
2112 if (ret)
2113 return ret;
2114
2115 ret = driver_create_file(&hdrv->driver, &driver_attr_new_id);
2116 if (ret)
2117 driver_unregister(&hdrv->driver);
2118
2119 return ret;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002120}
2121EXPORT_SYMBOL_GPL(__hid_register_driver);
2122
2123void hid_unregister_driver(struct hid_driver *hdrv)
2124{
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01002125 driver_remove_file(&hdrv->driver, &driver_attr_new_id);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002126 driver_unregister(&hdrv->driver);
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01002127 hid_free_dynids(hdrv);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002128}
2129EXPORT_SYMBOL_GPL(hid_unregister_driver);
2130
Oliver Neukum0361a282008-12-17 15:38:03 +01002131int hid_check_keys_pressed(struct hid_device *hid)
2132{
2133 struct hid_input *hidinput;
2134 int i;
2135
Jiri Kosinae5288eb2009-05-02 00:02:57 +02002136 if (!(hid->claimed & HID_CLAIMED_INPUT))
2137 return 0;
2138
Oliver Neukum0361a282008-12-17 15:38:03 +01002139 list_for_each_entry(hidinput, &hid->inputs, list) {
2140 for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++)
2141 if (hidinput->input->key[i])
2142 return 1;
2143 }
2144
2145 return 0;
2146}
2147
2148EXPORT_SYMBOL_GPL(hid_check_keys_pressed);
2149
Jiri Kosina86166b72007-05-14 09:57:40 +02002150static int __init hid_init(void)
2151{
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002152 int ret;
2153
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002154 if (hid_debug)
Joe Perches4291ee32010-12-09 19:29:03 -08002155 pr_warn("hid_debug is now used solely for parser and driver debugging.\n"
2156 "debugfs is now used for inspecting the device (report descriptor, reports)\n");
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002157
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002158 ret = bus_register(&hid_bus_type);
2159 if (ret) {
Joe Perches4291ee32010-12-09 19:29:03 -08002160 pr_err("can't register hid bus\n");
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002161 goto err;
2162 }
2163
2164 ret = hidraw_init();
2165 if (ret)
2166 goto err_bus;
2167
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002168 hid_debug_init();
2169
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002170 return 0;
2171err_bus:
2172 bus_unregister(&hid_bus_type);
2173err:
2174 return ret;
Jiri Kosina86166b72007-05-14 09:57:40 +02002175}
2176
2177static void __exit hid_exit(void)
2178{
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002179 hid_debug_exit();
Jiri Kosina86166b72007-05-14 09:57:40 +02002180 hidraw_exit();
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002181 bus_unregister(&hid_bus_type);
Jiri Kosina86166b72007-05-14 09:57:40 +02002182}
2183
2184module_init(hid_init);
2185module_exit(hid_exit);
2186
Jiri Kosina88adb722009-10-02 18:29:34 +02002187MODULE_AUTHOR("Andreas Gal");
2188MODULE_AUTHOR("Vojtech Pavlik");
2189MODULE_AUTHOR("Jiri Kosina");
Jiri Kosinaaa938f72006-12-08 18:41:10 +01002190MODULE_LICENSE(DRIVER_LICENSE);
2191