aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-09 18:50:31 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-09 18:50:31 -0400
commit36b774102e5ede8d0384684bd394c8285dce5a53 (patch)
tree15e44ae97f635db6a5dbe84bd4e730cfe49a86d5
parent71ba22fa739029bb158144813b9e82c00326497c (diff)
parentfeb485d4010e450183bd422d90c0d0f6be98f932 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: HID: handle cases of volume knobs generating relative values HID: Logitech keyboard 0xc311 needs reset leds quirk HID: support for logitech cordless desktop LX500 special mapping HID: fix autocentering of PID devices HID: separate quirks for report descriptor fixup HID: Add NOGET quirk for all NCR devices HID: support for Petalynx Maxter remote control HID: fix mismatch between hid-input HUT find/search mapping and the HUT HID: support for Gameron dual psx adaptor USB HID: avoid flush_scheduled_work() HID: Use menuconfig objects HID: force hid-input for Microsoft SideWinder GameVoice device HID: input mapping for Chicony KU-0418 tactical pad HID: make debugging output runtime-configurable
-rw-r--r--drivers/hid/Kconfig10
-rw-r--r--drivers/hid/hid-core.c93
-rw-r--r--drivers/hid/hid-debug.c15
-rw-r--r--drivers/hid/hid-input.c125
-rw-r--r--drivers/hid/usbhid/hid-core.c111
-rw-r--r--drivers/hid/usbhid/hid-lgff.c10
-rw-r--r--drivers/hid/usbhid/hid-pidff.c1
-rw-r--r--drivers/hid/usbhid/hid-quirks.c185
-rw-r--r--drivers/hid/usbhid/hid-tmff.c2
-rw-r--r--drivers/hid/usbhid/hid-zpff.c8
-rw-r--r--drivers/hid/usbhid/hiddev.c2
-rw-r--r--drivers/hid/usbhid/usbkbd.c6
-rw-r--r--include/linux/hid.h56
13 files changed, 425 insertions, 199 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 8fbe9fdac128..3b63b0b78122 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -1,8 +1,12 @@
1# 1#
2# HID driver configuration 2# HID driver configuration
3# 3#
4menu "HID Devices" 4menuconfig HID_SUPPORT
5 bool "HID Devices"
5 depends on INPUT 6 depends on INPUT
7 default y
8
9if HID_SUPPORT
6 10
7config HID 11config HID
8 tristate "Generic HID support" 12 tristate "Generic HID support"
@@ -24,6 +28,7 @@ config HID
24 28
25config HID_DEBUG 29config HID_DEBUG
26 bool "HID debugging support" 30 bool "HID debugging support"
31 default y if !EMBEDDED
27 depends on HID 32 depends on HID
28 ---help--- 33 ---help---
29 This option lets the HID layer output diagnostics about its internal 34 This option lets the HID layer output diagnostics about its internal
@@ -38,5 +43,4 @@ config HID_DEBUG
38 43
39source "drivers/hid/usbhid/Kconfig" 44source "drivers/hid/usbhid/Kconfig"
40 45
41endmenu 46endif # HID_SUPPORT
42
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 6ec04e79f685..317cf8a7b63c 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -40,6 +40,13 @@
40#define DRIVER_DESC "HID core driver" 40#define DRIVER_DESC "HID core driver"
41#define DRIVER_LICENSE "GPL" 41#define DRIVER_LICENSE "GPL"
42 42
43#ifdef CONFIG_HID_DEBUG
44int hid_debug = 0;
45module_param_named(debug, hid_debug, bool, 0600);
46MODULE_PARM_DESC(debug, "Turn HID debugging mode on and off");
47EXPORT_SYMBOL_GPL(hid_debug);
48#endif
49
43/* 50/*
44 * Register a new report for a device. 51 * Register a new report for a device.
45 */ 52 */
@@ -78,7 +85,7 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned
78 struct hid_field *field; 85 struct hid_field *field;
79 86
80 if (report->maxfield == HID_MAX_FIELDS) { 87 if (report->maxfield == HID_MAX_FIELDS) {
81 dbg("too many fields in report"); 88 dbg_hid("too many fields in report\n");
82 return NULL; 89 return NULL;
83 } 90 }
84 91
@@ -106,7 +113,7 @@ static int open_collection(struct hid_parser *parser, unsigned type)
106 usage = parser->local.usage[0]; 113 usage = parser->local.usage[0];
107 114
108 if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { 115 if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) {
109 dbg("collection stack overflow"); 116 dbg_hid("collection stack overflow\n");
110 return -1; 117 return -1;
111 } 118 }
112 119
@@ -114,7 +121,7 @@ static int open_collection(struct hid_parser *parser, unsigned type)
114 collection = kmalloc(sizeof(struct hid_collection) * 121 collection = kmalloc(sizeof(struct hid_collection) *
115 parser->device->collection_size * 2, GFP_KERNEL); 122 parser->device->collection_size * 2, GFP_KERNEL);
116 if (collection == NULL) { 123 if (collection == NULL) {
117 dbg("failed to reallocate collection array"); 124 dbg_hid("failed to reallocate collection array\n");
118 return -1; 125 return -1;
119 } 126 }
120 memcpy(collection, parser->device->collection, 127 memcpy(collection, parser->device->collection,
@@ -150,7 +157,7 @@ static int open_collection(struct hid_parser *parser, unsigned type)
150static int close_collection(struct hid_parser *parser) 157static int close_collection(struct hid_parser *parser)
151{ 158{
152 if (!parser->collection_stack_ptr) { 159 if (!parser->collection_stack_ptr) {
153 dbg("collection stack underflow"); 160 dbg_hid("collection stack underflow\n");
154 return -1; 161 return -1;
155 } 162 }
156 parser->collection_stack_ptr--; 163 parser->collection_stack_ptr--;
@@ -178,7 +185,7 @@ static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
178static int hid_add_usage(struct hid_parser *parser, unsigned usage) 185static int hid_add_usage(struct hid_parser *parser, unsigned usage)
179{ 186{
180 if (parser->local.usage_index >= HID_MAX_USAGES) { 187 if (parser->local.usage_index >= HID_MAX_USAGES) {
181 dbg("usage index exceeded"); 188 dbg_hid("usage index exceeded\n");
182 return -1; 189 return -1;
183 } 190 }
184 parser->local.usage[parser->local.usage_index] = usage; 191 parser->local.usage[parser->local.usage_index] = usage;
@@ -202,12 +209,12 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
202 int i; 209 int i;
203 210
204 if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) { 211 if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) {
205 dbg("hid_register_report failed"); 212 dbg_hid("hid_register_report failed\n");
206 return -1; 213 return -1;
207 } 214 }
208 215
209 if (parser->global.logical_maximum < parser->global.logical_minimum) { 216 if (parser->global.logical_maximum < parser->global.logical_minimum) {
210 dbg("logical range invalid %d %d", parser->global.logical_minimum, parser->global.logical_maximum); 217 dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum);
211 return -1; 218 return -1;
212 } 219 }
213 220
@@ -287,7 +294,7 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
287 case HID_GLOBAL_ITEM_TAG_PUSH: 294 case HID_GLOBAL_ITEM_TAG_PUSH:
288 295
289 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { 296 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) {
290 dbg("global enviroment stack overflow"); 297 dbg_hid("global enviroment stack overflow\n");
291 return -1; 298 return -1;
292 } 299 }
293 300
@@ -298,7 +305,7 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
298 case HID_GLOBAL_ITEM_TAG_POP: 305 case HID_GLOBAL_ITEM_TAG_POP:
299 306
300 if (!parser->global_stack_ptr) { 307 if (!parser->global_stack_ptr) {
301 dbg("global enviroment stack underflow"); 308 dbg_hid("global enviroment stack underflow\n");
302 return -1; 309 return -1;
303 } 310 }
304 311
@@ -342,27 +349,27 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
342 349
343 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: 350 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
344 if ((parser->global.report_size = item_udata(item)) > 32) { 351 if ((parser->global.report_size = item_udata(item)) > 32) {
345 dbg("invalid report_size %d", parser->global.report_size); 352 dbg_hid("invalid report_size %d\n", parser->global.report_size);
346 return -1; 353 return -1;
347 } 354 }
348 return 0; 355 return 0;
349 356
350 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: 357 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT:
351 if ((parser->global.report_count = item_udata(item)) > HID_MAX_USAGES) { 358 if ((parser->global.report_count = item_udata(item)) > HID_MAX_USAGES) {
352 dbg("invalid report_count %d", parser->global.report_count); 359 dbg_hid("invalid report_count %d\n", parser->global.report_count);
353 return -1; 360 return -1;
354 } 361 }
355 return 0; 362 return 0;
356 363
357 case HID_GLOBAL_ITEM_TAG_REPORT_ID: 364 case HID_GLOBAL_ITEM_TAG_REPORT_ID:
358 if ((parser->global.report_id = item_udata(item)) == 0) { 365 if ((parser->global.report_id = item_udata(item)) == 0) {
359 dbg("report_id 0 is invalid"); 366 dbg_hid("report_id 0 is invalid\n");
360 return -1; 367 return -1;
361 } 368 }
362 return 0; 369 return 0;
363 370
364 default: 371 default:
365 dbg("unknown global tag 0x%x", item->tag); 372 dbg_hid("unknown global tag 0x%x\n", item->tag);
366 return -1; 373 return -1;
367 } 374 }
368} 375}
@@ -377,7 +384,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
377 unsigned n; 384 unsigned n;
378 385
379 if (item->size == 0) { 386 if (item->size == 0) {
380 dbg("item data expected for local item"); 387 dbg_hid("item data expected for local item\n");
381 return -1; 388 return -1;
382 } 389 }
383 390
@@ -395,14 +402,14 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
395 * items and the first delimiter set. 402 * items and the first delimiter set.
396 */ 403 */
397 if (parser->local.delimiter_depth != 0) { 404 if (parser->local.delimiter_depth != 0) {
398 dbg("nested delimiters"); 405 dbg_hid("nested delimiters\n");
399 return -1; 406 return -1;
400 } 407 }
401 parser->local.delimiter_depth++; 408 parser->local.delimiter_depth++;
402 parser->local.delimiter_branch++; 409 parser->local.delimiter_branch++;
403 } else { 410 } else {
404 if (parser->local.delimiter_depth < 1) { 411 if (parser->local.delimiter_depth < 1) {
405 dbg("bogus close delimiter"); 412 dbg_hid("bogus close delimiter\n");
406 return -1; 413 return -1;
407 } 414 }
408 parser->local.delimiter_depth--; 415 parser->local.delimiter_depth--;
@@ -412,7 +419,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
412 case HID_LOCAL_ITEM_TAG_USAGE: 419 case HID_LOCAL_ITEM_TAG_USAGE:
413 420
414 if (parser->local.delimiter_branch > 1) { 421 if (parser->local.delimiter_branch > 1) {
415 dbg("alternative usage ignored"); 422 dbg_hid("alternative usage ignored\n");
416 return 0; 423 return 0;
417 } 424 }
418 425
@@ -424,7 +431,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
424 case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: 431 case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
425 432
426 if (parser->local.delimiter_branch > 1) { 433 if (parser->local.delimiter_branch > 1) {
427 dbg("alternative usage ignored"); 434 dbg_hid("alternative usage ignored\n");
428 return 0; 435 return 0;
429 } 436 }
430 437
@@ -437,7 +444,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
437 case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: 444 case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
438 445
439 if (parser->local.delimiter_branch > 1) { 446 if (parser->local.delimiter_branch > 1) {
440 dbg("alternative usage ignored"); 447 dbg_hid("alternative usage ignored\n");
441 return 0; 448 return 0;
442 } 449 }
443 450
@@ -446,14 +453,14 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
446 453
447 for (n = parser->local.usage_minimum; n <= data; n++) 454 for (n = parser->local.usage_minimum; n <= data; n++)
448 if (hid_add_usage(parser, n)) { 455 if (hid_add_usage(parser, n)) {
449 dbg("hid_add_usage failed\n"); 456 dbg_hid("hid_add_usage failed\n");
450 return -1; 457 return -1;
451 } 458 }
452 return 0; 459 return 0;
453 460
454 default: 461 default:
455 462
456 dbg("unknown local item tag 0x%x", item->tag); 463 dbg_hid("unknown local item tag 0x%x\n", item->tag);
457 return 0; 464 return 0;
458 } 465 }
459 return 0; 466 return 0;
@@ -487,7 +494,7 @@ static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
487 ret = hid_add_field(parser, HID_FEATURE_REPORT, data); 494 ret = hid_add_field(parser, HID_FEATURE_REPORT, data);
488 break; 495 break;
489 default: 496 default:
490 dbg("unknown main item tag 0x%x", item->tag); 497 dbg_hid("unknown main item tag 0x%x\n", item->tag);
491 ret = 0; 498 ret = 0;
492 } 499 }
493 500
@@ -502,7 +509,7 @@ static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
502 509
503static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) 510static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item)
504{ 511{
505 dbg("reserved item type, tag 0x%x", item->tag); 512 dbg_hid("reserved item type, tag 0x%x\n", item->tag);
506 return 0; 513 return 0;
507} 514}
508 515
@@ -667,14 +674,14 @@ struct hid_device *hid_parse_report(__u8 *start, unsigned size)
667 while ((start = fetch_item(start, end, &item)) != NULL) { 674 while ((start = fetch_item(start, end, &item)) != NULL) {
668 675
669 if (item.format != HID_ITEM_FORMAT_SHORT) { 676 if (item.format != HID_ITEM_FORMAT_SHORT) {
670 dbg("unexpected long global item"); 677 dbg_hid("unexpected long global item\n");
671 hid_free_device(device); 678 hid_free_device(device);
672 vfree(parser); 679 vfree(parser);
673 return NULL; 680 return NULL;
674 } 681 }
675 682
676 if (dispatch_type[item.type](parser, &item)) { 683 if (dispatch_type[item.type](parser, &item)) {
677 dbg("item %u %u %u %u parsing failed\n", 684 dbg_hid("item %u %u %u %u parsing failed\n",
678 item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag); 685 item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag);
679 hid_free_device(device); 686 hid_free_device(device);
680 vfree(parser); 687 vfree(parser);
@@ -683,13 +690,13 @@ struct hid_device *hid_parse_report(__u8 *start, unsigned size)
683 690
684 if (start == end) { 691 if (start == end) {
685 if (parser->collection_stack_ptr) { 692 if (parser->collection_stack_ptr) {
686 dbg("unbalanced collection at end of report description"); 693 dbg_hid("unbalanced collection at end of report description\n");
687 hid_free_device(device); 694 hid_free_device(device);
688 vfree(parser); 695 vfree(parser);
689 return NULL; 696 return NULL;
690 } 697 }
691 if (parser->local.delimiter_depth) { 698 if (parser->local.delimiter_depth) {
692 dbg("unbalanced delimiter at end of report description"); 699 dbg_hid("unbalanced delimiter at end of report description\n");
693 hid_free_device(device); 700 hid_free_device(device);
694 vfree(parser); 701 vfree(parser);
695 return NULL; 702 return NULL;
@@ -699,7 +706,7 @@ struct hid_device *hid_parse_report(__u8 *start, unsigned size)
699 } 706 }
700 } 707 }
701 708
702 dbg("item fetching failed at offset %d\n", (int)(end - start)); 709 dbg_hid("item fetching failed at offset %d\n", (int)(end - start));
703 hid_free_device(device); 710 hid_free_device(device);
704 vfree(parser); 711 vfree(parser);
705 return NULL; 712 return NULL;
@@ -915,13 +922,13 @@ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
915 hid_dump_input(field->usage + offset, value); 922 hid_dump_input(field->usage + offset, value);
916 923
917 if (offset >= field->report_count) { 924 if (offset >= field->report_count) {
918 dbg("offset (%d) exceeds report_count (%d)", offset, field->report_count); 925 dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count);
919 hid_dump_field(field, 8); 926 hid_dump_field(field, 8);
920 return -1; 927 return -1;
921 } 928 }
922 if (field->logical_minimum < 0) { 929 if (field->logical_minimum < 0) {
923 if (value != snto32(s32ton(value, size), size)) { 930 if (value != snto32(s32ton(value, size), size)) {
924 dbg("value %d is out of range", value); 931 dbg_hid("value %d is out of range\n", value);
925 return -1; 932 return -1;
926 } 933 }
927 } 934 }
@@ -934,19 +941,17 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
934{ 941{
935 struct hid_report_enum *report_enum = hid->report_enum + type; 942 struct hid_report_enum *report_enum = hid->report_enum + type;
936 struct hid_report *report; 943 struct hid_report *report;
937 int n, rsize; 944 int n, rsize, i;
938 945
939 if (!hid) 946 if (!hid)
940 return -ENODEV; 947 return -ENODEV;
941 948
942 if (!size) { 949 if (!size) {
943 dbg("empty report"); 950 dbg_hid("empty report\n");
944 return -1; 951 return -1;
945 } 952 }
946 953
947#ifdef CONFIG_HID_DEBUG 954 dbg_hid("report (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un");
948 printk(KERN_DEBUG __FILE__ ": report (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un");
949#endif
950 955
951 n = 0; /* Normally report number is 0 */ 956 n = 0; /* Normally report number is 0 */
952 if (report_enum->numbered) { /* Device uses numbered reports, data[0] is report number */ 957 if (report_enum->numbered) { /* Device uses numbered reports, data[0] is report number */
@@ -954,25 +959,21 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
954 size--; 959 size--;
955 } 960 }
956 961
957#ifdef CONFIG_HID_DEBUG 962 /* dump the report descriptor */
958 { 963 dbg_hid("report %d (size %u) = ", n, size);
959 int i; 964 for (i = 0; i < size; i++)
960 printk(KERN_DEBUG __FILE__ ": report %d (size %u) = ", n, size); 965 dbg_hid_line(" %02x", data[i]);
961 for (i = 0; i < size; i++) 966 dbg_hid_line("\n");
962 printk(" %02x", data[i]);
963 printk("\n");
964 }
965#endif
966 967
967 if (!(report = report_enum->report_id_hash[n])) { 968 if (!(report = report_enum->report_id_hash[n])) {
968 dbg("undefined report_id %d received", n); 969 dbg_hid("undefined report_id %d received\n", n);
969 return -1; 970 return -1;
970 } 971 }
971 972
972 rsize = ((report->size - 1) >> 3) + 1; 973 rsize = ((report->size - 1) >> 3) + 1;
973 974
974 if (size < rsize) { 975 if (size < rsize) {
975 dbg("report %d is too short, (%d < %d)", report->id, size, rsize); 976 dbg_hid("report %d is too short, (%d < %d)\n", report->id, size, rsize);
976 memset(data + size, 0, rsize - size); 977 memset(data + size, 0, rsize - size);
977 } 978 }
978 979
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 83c4126b37c3..a13757b78980 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -347,6 +347,9 @@ static void resolv_usage_page(unsigned page) {
347void hid_resolv_usage(unsigned usage) { 347void hid_resolv_usage(unsigned usage) {
348 const struct hid_usage_entry *p; 348 const struct hid_usage_entry *p;
349 349
350 if (!hid_debug)
351 return;
352
350 resolv_usage_page(usage >> 16); 353 resolv_usage_page(usage >> 16);
351 printk("."); 354 printk(".");
352 for (p = hid_usage_table; p->description; p++) 355 for (p = hid_usage_table; p->description; p++)
@@ -369,6 +372,9 @@ __inline__ static void tab(int n) {
369void hid_dump_field(struct hid_field *field, int n) { 372void hid_dump_field(struct hid_field *field, int n) {
370 int j; 373 int j;
371 374
375 if (!hid_debug)
376 return;
377
372 if (field->physical) { 378 if (field->physical) {
373 tab(n); 379 tab(n);
374 printk("Physical("); 380 printk("Physical(");
@@ -466,6 +472,9 @@ void hid_dump_device(struct hid_device *device) {
466 unsigned i,k; 472 unsigned i,k;
467 static char *table[] = {"INPUT", "OUTPUT", "FEATURE"}; 473 static char *table[] = {"INPUT", "OUTPUT", "FEATURE"};
468 474
475 if (!hid_debug)
476 return;
477
469 for (i = 0; i < HID_REPORT_TYPES; i++) { 478 for (i = 0; i < HID_REPORT_TYPES; i++) {
470 report_enum = device->report_enum + i; 479 report_enum = device->report_enum + i;
471 list = report_enum->report_list.next; 480 list = report_enum->report_list.next;
@@ -489,6 +498,9 @@ void hid_dump_device(struct hid_device *device) {
489EXPORT_SYMBOL_GPL(hid_dump_device); 498EXPORT_SYMBOL_GPL(hid_dump_device);
490 499
491void hid_dump_input(struct hid_usage *usage, __s32 value) { 500void hid_dump_input(struct hid_usage *usage, __s32 value) {
501 if (!hid_debug)
502 return;
503
492 printk("hid-debug: input "); 504 printk("hid-debug: input ");
493 hid_resolv_usage(usage->hid); 505 hid_resolv_usage(usage->hid);
494 printk(" = %d\n", value); 506 printk(" = %d\n", value);
@@ -758,6 +770,9 @@ static char **names[EV_MAX + 1] = {
758 770
759void hid_resolv_event(__u8 type, __u16 code) { 771void hid_resolv_event(__u8 type, __u16 code) {
760 772
773 if (!hid_debug)
774 return;
775
761 printk("%s.%s", events[type] ? events[type] : "?", 776 printk("%s.%s", events[type] ? events[type] : "?",
762 names[type] ? (names[type][code] ? names[type][code] : "?") : "?"); 777 names[type] ? (names[type][code] ? names[type][code] : "?") : "?");
763} 778}
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 7f817897b178..8edbd30cf795 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -60,6 +60,19 @@ static const unsigned char hid_keyboard[256] = {
60 150,158,159,128,136,177,178,176,142,152,173,140,unk,unk,unk,unk 60 150,158,159,128,136,177,178,176,142,152,173,140,unk,unk,unk,unk
61}; 61};
62 62
63/* extended mapping for certain Logitech hardware (Logitech cordless desktop LX500) */
64#define LOGITECH_EXPANDED_KEYMAP_SIZE 80
65static int logitech_expanded_keymap[LOGITECH_EXPANDED_KEYMAP_SIZE] = {
66 0,216, 0,213,175,156, 0, 0, 0, 0,
67 144, 0, 0, 0, 0, 0, 0, 0, 0,212,
68 174,167,152,161,112, 0, 0, 0,154, 0,
69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
70 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
71 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
72 0, 0, 0, 0, 0,183,184,185,186,187,
73 188,189,190,191,192,193,194, 0, 0, 0
74};
75
63static const struct { 76static const struct {
64 __s32 x; 77 __s32 x;
65 __s32 y; 78 __s32 y;
@@ -308,9 +321,7 @@ static int hidinput_setkeycode(struct input_dev *dev, int scancode,
308 321
309 clear_bit(old_keycode, dev->keybit); 322 clear_bit(old_keycode, dev->keybit);
310 set_bit(usage->code, dev->keybit); 323 set_bit(usage->code, dev->keybit);
311#ifdef CONFIG_HID_DEBUG 324 dbg_hid(KERN_DEBUG "Assigned keycode %d to HID usage code %x\n", keycode, scancode);
312 printk (KERN_DEBUG "Assigned keycode %d to HID usage code %x\n", keycode, scancode);
313#endif
314 /* Set the keybit for the old keycode if the old keycode is used 325 /* Set the keybit for the old keycode if the old keycode is used
315 * by another key */ 326 * by another key */
316 if (hidinput_find_key (hid, 0, old_keycode)) 327 if (hidinput_find_key (hid, 0, old_keycode))
@@ -333,11 +344,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
333 344
334 field->hidinput = hidinput; 345 field->hidinput = hidinput;
335 346
336#ifdef CONFIG_HID_DEBUG 347 dbg_hid("Mapping: ");
337 printk(KERN_DEBUG "Mapping: ");
338 hid_resolv_usage(usage->hid); 348 hid_resolv_usage(usage->hid);
339 printk(" ---> "); 349 dbg_hid_line(" ---> ");
340#endif
341 350
342 if (field->flags & HID_MAIN_ITEM_CONSTANT) 351 if (field->flags & HID_MAIN_ITEM_CONSTANT)
343 goto ignore; 352 goto ignore;
@@ -378,6 +387,21 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
378 } 387 }
379 } 388 }
380 389
390 /* Special handling for Logitech Cordless Desktop */
391 if (field->application != HID_GD_MOUSE) {
392 if (device->quirks & HID_QUIRK_LOGITECH_EXPANDED_KEYMAP) {
393 int hid = usage->hid & HID_USAGE;
394 if (hid < LOGITECH_EXPANDED_KEYMAP_SIZE && logitech_expanded_keymap[hid] != 0)
395 code = logitech_expanded_keymap[hid];
396 }
397 } else {
398 if (device->quirks & HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL) {
399 int hid = usage->hid & HID_USAGE;
400 if (hid == 7 || hid == 8)
401 goto ignore;
402 }
403 }
404
381 map_key(code); 405 map_key(code);
382 break; 406 break;
383 407
@@ -566,6 +590,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
566 case 0x0e5: map_key_clear(KEY_BASSBOOST); break; 590 case 0x0e5: map_key_clear(KEY_BASSBOOST); break;
567 case 0x0e9: map_key_clear(KEY_VOLUMEUP); break; 591 case 0x0e9: map_key_clear(KEY_VOLUMEUP); break;
568 case 0x0ea: map_key_clear(KEY_VOLUMEDOWN); break; 592 case 0x0ea: map_key_clear(KEY_VOLUMEDOWN); break;
593
594 /* reserved in HUT 1.12. Reported on Petalynx remote */
595 case 0x0f6: map_key_clear(KEY_NEXT); break;
596 case 0x0fa: map_key_clear(KEY_BACK); break;
597
569 case 0x183: map_key_clear(KEY_CONFIG); break; 598 case 0x183: map_key_clear(KEY_CONFIG); break;
570 case 0x184: map_key_clear(KEY_WORDPROCESSOR); break; 599 case 0x184: map_key_clear(KEY_WORDPROCESSOR); break;
571 case 0x185: map_key_clear(KEY_EDITOR); break; 600 case 0x185: map_key_clear(KEY_EDITOR); break;
@@ -598,7 +627,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
598 case 0x21b: map_key_clear(KEY_COPY); break; 627 case 0x21b: map_key_clear(KEY_COPY); break;
599 case 0x21c: map_key_clear(KEY_CUT); break; 628 case 0x21c: map_key_clear(KEY_CUT); break;
600 case 0x21d: map_key_clear(KEY_PASTE); break; 629 case 0x21d: map_key_clear(KEY_PASTE); break;
601 case 0x221: map_key_clear(KEY_FIND); break; 630 case 0x21f: map_key_clear(KEY_FIND); break;
631 case 0x221: map_key_clear(KEY_SEARCH); break;
632 case 0x222: map_key_clear(KEY_GOTO); break;
602 case 0x223: map_key_clear(KEY_HOMEPAGE); break; 633 case 0x223: map_key_clear(KEY_HOMEPAGE); break;
603 case 0x224: map_key_clear(KEY_BACK); break; 634 case 0x224: map_key_clear(KEY_BACK); break;
604 case 0x225: map_key_clear(KEY_FORWARD); break; 635 case 0x225: map_key_clear(KEY_FORWARD); break;
@@ -688,7 +719,28 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
688 break; 719 break;
689 720
690 case HID_UP_MSVENDOR: 721 case HID_UP_MSVENDOR:
691 goto ignore; 722
723 /* special case - Chicony Chicony KU-0418 tactical pad */
724 if (device->vendor == 0x04f2 && device->product == 0x0418) {
725 set_bit(EV_REP, input->evbit);
726 switch(usage->hid & HID_USAGE) {
727 case 0xff01: map_key_clear(BTN_1); break;
728 case 0xff02: map_key_clear(BTN_2); break;
729 case 0xff03: map_key_clear(BTN_3); break;
730 case 0xff04: map_key_clear(BTN_4); break;
731 case 0xff05: map_key_clear(BTN_5); break;
732 case 0xff06: map_key_clear(BTN_6); break;
733 case 0xff07: map_key_clear(BTN_7); break;
734 case 0xff08: map_key_clear(BTN_8); break;
735 case 0xff09: map_key_clear(BTN_9); break;
736 case 0xff0a: map_key_clear(BTN_A); break;
737 case 0xff0b: map_key_clear(BTN_B); break;
738 default: goto ignore;
739 }
740 } else {
741 goto ignore;
742 }
743 break;
692 744
693 case HID_UP_CUSTOM: /* Reported on Logitech and Powerbook USB keyboards */ 745 case HID_UP_CUSTOM: /* Reported on Logitech and Powerbook USB keyboards */
694 746
@@ -704,10 +756,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
704 } 756 }
705 break; 757 break;
706 758
707 case HID_UP_LOGIVENDOR: /* Reported on Logitech Ultra X Media Remote */ 759 case HID_UP_LOGIVENDOR:
708
709 set_bit(EV_REP, input->evbit); 760 set_bit(EV_REP, input->evbit);
710 switch(usage->hid & HID_USAGE) { 761 switch(usage->hid & HID_USAGE) {
762 /* Reported on Logitech Ultra X Media Remote */
711 case 0x004: map_key_clear(KEY_AGAIN); break; 763 case 0x004: map_key_clear(KEY_AGAIN); break;
712 case 0x00d: map_key_clear(KEY_HOME); break; 764 case 0x00d: map_key_clear(KEY_HOME); break;
713 case 0x024: map_key_clear(KEY_SHUFFLE); break; 765 case 0x024: map_key_clear(KEY_SHUFFLE); break;
@@ -725,6 +777,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
725 case 0x04d: map_key_clear(KEY_SUBTITLE); break; 777 case 0x04d: map_key_clear(KEY_SUBTITLE); break;
726 case 0x051: map_key_clear(KEY_RED); break; 778 case 0x051: map_key_clear(KEY_RED); break;
727 case 0x052: map_key_clear(KEY_CLOSE); break; 779 case 0x052: map_key_clear(KEY_CLOSE); break;
780
781 /* Reported on Petalynx Maxter remote */
782 case 0x05a: map_key_clear(KEY_TEXT); break;
783 case 0x05b: map_key_clear(KEY_RED); break;
784 case 0x05c: map_key_clear(KEY_GREEN); break;
785 case 0x05d: map_key_clear(KEY_YELLOW); break;
786 case 0x05e: map_key_clear(KEY_BLUE); break;
787
728 default: goto ignore; 788 default: goto ignore;
729 } 789 }
730 break; 790 break;
@@ -818,16 +878,24 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
818 field->dpad = usage->code; 878 field->dpad = usage->code;
819 } 879 }
820 880
881 /* for those devices which produce Consumer volume usage as relative,
882 * we emulate pressing volumeup/volumedown appropriate number of times
883 * in hidinput_hid_event()
884 */
885 if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) &&
886 (usage->code == ABS_VOLUME)) {
887 set_bit(KEY_VOLUMEUP, input->keybit);
888 set_bit(KEY_VOLUMEDOWN, input->keybit);
889 }
890
821 hid_resolv_event(usage->type, usage->code); 891 hid_resolv_event(usage->type, usage->code);
822#ifdef CONFIG_HID_DEBUG 892
823 printk("\n"); 893 dbg_hid_line("\n");
824#endif 894
825 return; 895 return;
826 896
827ignore: 897ignore:
828#ifdef CONFIG_HID_DEBUG 898 dbg_hid_line("IGNORED\n");
829 printk("IGNORED\n");
830#endif
831 return; 899 return;
832} 900}
833 901
@@ -896,18 +964,33 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
896 } 964 }
897 965
898 if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects Max */ 966 if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects Max */
899 dbg("Maximum Effects - %d",value); 967 dbg_hid("Maximum Effects - %d\n",value);
900 return; 968 return;
901 } 969 }
902 970
903 if (usage->hid == (HID_UP_PID | 0x7fUL)) { 971 if (usage->hid == (HID_UP_PID | 0x7fUL)) {
904 dbg("PID Pool Report\n"); 972 dbg_hid("PID Pool Report\n");
905 return; 973 return;
906 } 974 }
907 975
908 if ((usage->type == EV_KEY) && (usage->code == 0)) /* Key 0 is "unassigned", not KEY_UNKNOWN */ 976 if ((usage->type == EV_KEY) && (usage->code == 0)) /* Key 0 is "unassigned", not KEY_UNKNOWN */
909 return; 977 return;
910 978
979 if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) &&
980 (usage->code == ABS_VOLUME)) {
981 int count = abs(value);
982 int direction = value > 0 ? KEY_VOLUMEUP : KEY_VOLUMEDOWN;
983 int i;
984
985 for (i = 0; i < count; i++) {
986 input_event(input, EV_KEY, direction, 1);
987 input_sync(input);
988 input_event(input, EV_KEY, direction, 0);
989 input_sync(input);
990 }
991 return;
992 }
993
911 input_event(input, usage->type, usage->code, value); 994 input_event(input, usage->type, usage->code, value);
912 995
913 if ((field->flags & HID_MAIN_ITEM_RELATIVE) && (usage->type == EV_KEY)) 996 if ((field->flags & HID_MAIN_ITEM_RELATIVE) && (usage->type == EV_KEY))
@@ -976,7 +1059,7 @@ int hidinput_connect(struct hid_device *hid)
976 if (IS_INPUT_APPLICATION(hid->collection[i].usage)) 1059 if (IS_INPUT_APPLICATION(hid->collection[i].usage))
977 break; 1060 break;
978 1061
979 if (i == hid->maxcollection) 1062 if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDINPUT) == 0)
980 return -1; 1063 return -1;
981 1064
982 if (hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS) 1065 if (hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS)
@@ -994,7 +1077,7 @@ int hidinput_connect(struct hid_device *hid)
994 if (!hidinput || !input_dev) { 1077 if (!hidinput || !input_dev) {
995 kfree(hidinput); 1078 kfree(hidinput);
996 input_free_device(input_dev); 1079 input_free_device(input_dev);
997 err("Out of memory during hid input probe"); 1080 err_hid("Out of memory during hid input probe");
998 return -1; 1081 return -1;
999 } 1082 }
1000 1083
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index d91b9dac6dff..3afa4a5035b7 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -60,6 +60,12 @@ MODULE_PARM_DESC(quirks, "Add/modify USB HID quirks by specifying "
60 " quirks=vendorID:productID:quirks" 60 " quirks=vendorID:productID:quirks"
61 " where vendorID, productID, and quirks are all in" 61 " where vendorID, productID, and quirks are all in"
62 " 0x-prefixed hex"); 62 " 0x-prefixed hex");
63static char *rdesc_quirks_param[MAX_USBHID_BOOT_QUIRKS] = { [ 0 ... (MAX_USBHID_BOOT_QUIRKS - 1) ] = NULL };
64module_param_array_named(rdesc_quirks, rdesc_quirks_param, charp, NULL, 0444);
65MODULE_PARM_DESC(rdesc_quirks, "Add/modify report descriptor quirks by specifying "
66 " rdesc_quirks=vendorID:productID:rdesc_quirks"
67 " where vendorID, productID, and rdesc_quirks are all in"
68 " 0x-prefixed hex");
63/* 69/*
64 * Input submission and I/O error handler. 70 * Input submission and I/O error handler.
65 */ 71 */
@@ -127,7 +133,7 @@ static void hid_reset(struct work_struct *work)
127 hid_io_error(hid); 133 hid_io_error(hid);
128 break; 134 break;
129 default: 135 default:
130 err("can't reset device, %s-%s/input%d, status %d", 136 err_hid("can't reset device, %s-%s/input%d, status %d",
131 hid_to_usb_dev(hid)->bus->bus_name, 137 hid_to_usb_dev(hid)->bus->bus_name,
132 hid_to_usb_dev(hid)->devpath, 138 hid_to_usb_dev(hid)->devpath,
133 usbhid->ifnum, rc); 139 usbhid->ifnum, rc);
@@ -220,7 +226,7 @@ static void hid_irq_in(struct urb *urb)
220 if (status) { 226 if (status) {
221 clear_bit(HID_IN_RUNNING, &usbhid->iofl); 227 clear_bit(HID_IN_RUNNING, &usbhid->iofl);
222 if (status != -EPERM) { 228 if (status != -EPERM) {
223 err("can't resubmit intr, %s-%s/input%d, status %d", 229 err_hid("can't resubmit intr, %s-%s/input%d, status %d",
224 hid_to_usb_dev(hid)->bus->bus_name, 230 hid_to_usb_dev(hid)->bus->bus_name,
225 hid_to_usb_dev(hid)->devpath, 231 hid_to_usb_dev(hid)->devpath,
226 usbhid->ifnum, status); 232 usbhid->ifnum, status);
@@ -240,10 +246,10 @@ static int hid_submit_out(struct hid_device *hid)
240 usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0); 246 usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0);
241 usbhid->urbout->dev = hid_to_usb_dev(hid); 247 usbhid->urbout->dev = hid_to_usb_dev(hid);
242 248
243 dbg("submitting out urb"); 249 dbg_hid("submitting out urb\n");
244 250
245 if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) { 251 if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) {
246 err("usb_submit_urb(out) failed"); 252 err_hid("usb_submit_urb(out) failed");
247 return -1; 253 return -1;
248 } 254 }
249 255
@@ -287,12 +293,12 @@ static int hid_submit_ctrl(struct hid_device *hid)
287 usbhid->cr->wIndex = cpu_to_le16(usbhid->ifnum); 293 usbhid->cr->wIndex = cpu_to_le16(usbhid->ifnum);
288 usbhid->cr->wLength = cpu_to_le16(len); 294 usbhid->cr->wLength = cpu_to_le16(len);
289 295
290 dbg("submitting ctrl urb: %s wValue=0x%04x wIndex=0x%04x wLength=%u", 296 dbg_hid("submitting ctrl urb: %s wValue=0x%04x wIndex=0x%04x wLength=%u\n",
291 usbhid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : "Get_Report", 297 usbhid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : "Get_Report",
292 usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength); 298 usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength);
293 299
294 if (usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC)) { 300 if (usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC)) {
295 err("usb_submit_urb(ctrl) failed"); 301 err_hid("usb_submit_urb(ctrl) failed");
296 return -1; 302 return -1;
297 } 303 }
298 304
@@ -474,7 +480,7 @@ int usbhid_wait_io(struct hid_device *hid)
474 if (!wait_event_timeout(hid->wait, (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl) && 480 if (!wait_event_timeout(hid->wait, (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl) &&
475 !test_bit(HID_OUT_RUNNING, &usbhid->iofl)), 481 !test_bit(HID_OUT_RUNNING, &usbhid->iofl)),
476 10*HZ)) { 482 10*HZ)) {
477 dbg("timeout waiting for ctrl or out queue to clear"); 483 dbg_hid("timeout waiting for ctrl or out queue to clear\n");
478 return -1; 484 return -1;
479 } 485 }
480 486
@@ -633,20 +639,6 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
633} 639}
634 640
635/* 641/*
636 * Cherry Cymotion keyboard have an invalid HID report descriptor,
637 * that needs fixing before we can parse it.
638 */
639
640static void hid_fixup_cymotion_descriptor(char *rdesc, int rsize)
641{
642 if (rsize >= 17 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
643 info("Fixing up Cherry Cymotion report descriptor");
644 rdesc[11] = rdesc[16] = 0xff;
645 rdesc[12] = rdesc[17] = 0x03;
646 }
647}
648
649/*
650 * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller 642 * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
651 * to "operational". Without this, the ps3 controller will not report any 643 * to "operational". Without this, the ps3 controller will not report any
652 * events. 644 * events.
@@ -667,51 +659,11 @@ static void hid_fixup_sony_ps3_controller(struct usb_device *dev, int ifnum)
667 USB_CTRL_GET_TIMEOUT); 659 USB_CTRL_GET_TIMEOUT);
668 660
669 if (result < 0) 661 if (result < 0)
670 err("%s failed: %d\n", __func__, result); 662 err_hid("%s failed: %d\n", __func__, result);
671 663
672 kfree(buf); 664 kfree(buf);
673} 665}
674 666
675/*
676 * Certain Logitech keyboards send in report #3 keys which are far
677 * above the logical maximum described in descriptor. This extends
678 * the original value of 0x28c of logical maximum to 0x104d
679 */
680static void hid_fixup_logitech_descriptor(unsigned char *rdesc, int rsize)
681{
682 if (rsize >= 90 && rdesc[83] == 0x26
683 && rdesc[84] == 0x8c
684 && rdesc[85] == 0x02) {
685 info("Fixing up Logitech keyboard report descriptor");
686 rdesc[84] = rdesc[89] = 0x4d;
687 rdesc[85] = rdesc[90] = 0x10;
688 }
689}
690
691/*
692 * Some USB barcode readers from cypress have usage min and usage max in
693 * the wrong order
694 */
695static void hid_fixup_cypress_descriptor(unsigned char *rdesc, int rsize)
696{
697 short fixed = 0;
698 int i;
699
700 for (i = 0; i < rsize - 4; i++) {
701 if (rdesc[i] == 0x29 && rdesc [i+2] == 0x19) {
702 unsigned char tmp;
703
704 rdesc[i] = 0x19; rdesc[i+2] = 0x29;
705 tmp = rdesc[i+3];
706 rdesc[i+3] = rdesc[i+1];
707 rdesc[i+1] = tmp;
708 }
709 }
710
711 if (fixed)
712 info("Fixing up Cypress report descriptor");
713}
714
715static struct hid_device *usb_hid_configure(struct usb_interface *intf) 667static struct hid_device *usb_hid_configure(struct usb_interface *intf)
716{ 668{
717 struct usb_host_interface *interface = intf->cur_altsetting; 669 struct usb_host_interface *interface = intf->cur_altsetting;
@@ -746,7 +698,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
746 if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && 698 if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) &&
747 (!interface->desc.bNumEndpoints || 699 (!interface->desc.bNumEndpoints ||
748 usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { 700 usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) {
749 dbg("class descriptor not present\n"); 701 dbg_hid("class descriptor not present\n");
750 return NULL; 702 return NULL;
751 } 703 }
752 704
@@ -755,41 +707,34 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
755 rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength); 707 rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength);
756 708
757 if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) { 709 if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) {
758 dbg("weird size of report descriptor (%u)", rsize); 710 dbg_hid("weird size of report descriptor (%u)\n", rsize);
759 return NULL; 711 return NULL;
760 } 712 }
761 713
762 if (!(rdesc = kmalloc(rsize, GFP_KERNEL))) { 714 if (!(rdesc = kmalloc(rsize, GFP_KERNEL))) {
763 dbg("couldn't allocate rdesc memory"); 715 dbg_hid("couldn't allocate rdesc memory\n");
764 return NULL; 716 return NULL;
765 } 717 }
766 718
767 hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0); 719 hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0);
768 720
769 if ((n = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) { 721 if ((n = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) {
770 dbg("reading report descriptor failed"); 722 dbg_hid("reading report descriptor failed\n");
771 kfree(rdesc); 723 kfree(rdesc);
772 return NULL; 724 return NULL;
773 } 725 }
774 726
775 if ((quirks & HID_QUIRK_CYMOTION)) 727 usbhid_fixup_report_descriptor(le16_to_cpu(dev->descriptor.idVendor),
776 hid_fixup_cymotion_descriptor(rdesc, rsize); 728 le16_to_cpu(dev->descriptor.idProduct), rdesc,
729 rsize, rdesc_quirks_param);
777 730
778 if (quirks & HID_QUIRK_LOGITECH_DESCRIPTOR) 731 dbg_hid("report descriptor (size %u, read %d) = ", rsize, n);
779 hid_fixup_logitech_descriptor(rdesc, rsize);
780
781 if (quirks & HID_QUIRK_SWAPPED_MIN_MAX)
782 hid_fixup_cypress_descriptor(rdesc, rsize);
783
784#ifdef CONFIG_HID_DEBUG
785 printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n);
786 for (n = 0; n < rsize; n++) 732 for (n = 0; n < rsize; n++)
787 printk(" %02x", (unsigned char) rdesc[n]); 733 dbg_hid_line(" %02x", (unsigned char) rdesc[n]);
788 printk("\n"); 734 dbg_hid_line("\n");
789#endif
790 735
791 if (!(hid = hid_parse_report(rdesc, n))) { 736 if (!(hid = hid_parse_report(rdesc, n))) {
792 dbg("parsing report descriptor failed"); 737 dbg_hid("parsing report descriptor failed\n");
793 kfree(rdesc); 738 kfree(rdesc);
794 return NULL; 739 return NULL;
795 } 740 }
@@ -861,7 +806,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
861 } 806 }
862 807
863 if (!usbhid->urbin) { 808 if (!usbhid->urbin) {
864 err("couldn't find an input interrupt endpoint"); 809 err_hid("couldn't find an input interrupt endpoint");
865 goto fail; 810 goto fail;
866 } 811 }
867 812
@@ -956,7 +901,7 @@ static void hid_disconnect(struct usb_interface *intf)
956 usb_kill_urb(usbhid->urbctrl); 901 usb_kill_urb(usbhid->urbctrl);
957 902
958 del_timer_sync(&usbhid->io_retry); 903 del_timer_sync(&usbhid->io_retry);
959 flush_scheduled_work(); 904 cancel_work_sync(&usbhid->reset_work);
960 905
961 if (hid->claimed & HID_CLAIMED_INPUT) 906 if (hid->claimed & HID_CLAIMED_INPUT)
962 hidinput_disconnect(hid); 907 hidinput_disconnect(hid);
@@ -978,7 +923,7 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
978 int i; 923 int i;
979 char *c; 924 char *c;
980 925
981 dbg("HID probe called for ifnum %d", 926 dbg_hid("HID probe called for ifnum %d\n",
982 intf->altsetting->desc.bInterfaceNumber); 927 intf->altsetting->desc.bInterfaceNumber);
983 928
984 if (!(hid = usb_hid_configure(intf))) 929 if (!(hid = usb_hid_configure(intf)))
diff --git a/drivers/hid/usbhid/hid-lgff.c b/drivers/hid/usbhid/hid-lgff.c
index c5cd4107d6af..4b7ab6a46d93 100644
--- a/drivers/hid/usbhid/hid-lgff.c
+++ b/drivers/hid/usbhid/hid-lgff.c
@@ -78,7 +78,7 @@ static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *ef
78 report->field[0]->value[1] = 0x08; 78 report->field[0]->value[1] = 0x08;
79 report->field[0]->value[2] = x; 79 report->field[0]->value[2] = x;
80 report->field[0]->value[3] = y; 80 report->field[0]->value[3] = y;
81 dbg("(x, y)=(%04x, %04x)", x, y); 81 dbg_hid("(x, y)=(%04x, %04x)\n", x, y);
82 usbhid_submit_report(hid, report, USB_DIR_OUT); 82 usbhid_submit_report(hid, report, USB_DIR_OUT);
83 break; 83 break;
84 84
@@ -93,7 +93,7 @@ static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *ef
93 report->field[0]->value[1] = 0x00; 93 report->field[0]->value[1] = 0x00;
94 report->field[0]->value[2] = left; 94 report->field[0]->value[2] = left;
95 report->field[0]->value[3] = right; 95 report->field[0]->value[3] = right;
96 dbg("(left, right)=(%04x, %04x)", left, right); 96 dbg_hid("(left, right)=(%04x, %04x)\n", left, right);
97 usbhid_submit_report(hid, report, USB_DIR_OUT); 97 usbhid_submit_report(hid, report, USB_DIR_OUT);
98 break; 98 break;
99 } 99 }
@@ -113,20 +113,20 @@ int hid_lgff_init(struct hid_device* hid)
113 113
114 /* Find the report to use */ 114 /* Find the report to use */
115 if (list_empty(report_list)) { 115 if (list_empty(report_list)) {
116 err("No output report found"); 116 err_hid("No output report found");
117 return -1; 117 return -1;
118 } 118 }
119 119
120 /* Check that the report looks ok */ 120 /* Check that the report looks ok */
121 report = list_entry(report_list->next, struct hid_report, list); 121 report = list_entry(report_list->next, struct hid_report, list);
122 if (!report) { 122 if (!report) {
123 err("NULL output report"); 123 err_hid("NULL output report");
124 return -1; 124 return -1;
125 } 125 }
126 126
127 field = report->field[0]; 127 field = report->field[0];
128 if (!field) { 128 if (!field) {
129 err("NULL field"); 129 err_hid("NULL field");
130 return -1; 130 return -1;
131 } 131 }
132 132
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
index f5a90e950e6b..011326178c06 100644
--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -738,6 +738,7 @@ static void pidff_autocenter(struct pidff_device *pidff, u16 magnitude)
738 pidff->set_effect[PID_TRIGGER_BUTTON].value[0] = 0; 738 pidff->set_effect[PID_TRIGGER_BUTTON].value[0] = 0;
739 pidff->set_effect[PID_TRIGGER_REPEAT_INT].value[0] = 0; 739 pidff->set_effect[PID_TRIGGER_REPEAT_INT].value[0] = 0;
740 pidff_set(&pidff->set_effect[PID_GAIN], magnitude); 740 pidff_set(&pidff->set_effect[PID_GAIN], magnitude);
741 pidff->set_effect[PID_DIRECTION_ENABLE].value[0] = 1;
741 pidff->set_effect[PID_START_DELAY].value[0] = 0; 742 pidff->set_effect[PID_START_DELAY].value[0] = 0;
742 743
743 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT], 744 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT],
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index f6c4145dc202..775b9f3b8ce3 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -105,6 +105,9 @@
105#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f 105#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f
106#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100 106#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100
107 107
108#define USB_VENDOR_ID_GAMERON 0x0810
109#define USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR 0x0001
110
108#define USB_VENDOR_ID_GLAB 0x06c2 111#define USB_VENDOR_ID_GLAB 0x06c2
109#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038 112#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038
110#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039 113#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039
@@ -196,8 +199,10 @@
196#define USB_VENDOR_ID_LOGITECH 0x046d 199#define USB_VENDOR_ID_LOGITECH 0x046d
197#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101 200#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101
198#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294 201#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294
202#define USB_DEVICE_ID_LOGITECH_KBD 0xc311
199#define USB_DEVICE_ID_S510_RECEIVER 0xc50c 203#define USB_DEVICE_ID_S510_RECEIVER 0xc50c
200#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 204#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517
205#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512
201#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513 206#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513
202#define USB_DEVICE_ID_DINOVO_EDGE 0xc714 207#define USB_DEVICE_ID_DINOVO_EDGE 0xc714
203 208
@@ -209,6 +214,13 @@
209#define USB_DEVICE_ID_MGE_UPS 0xffff 214#define USB_DEVICE_ID_MGE_UPS 0xffff
210#define USB_DEVICE_ID_MGE_UPS1 0x0001 215#define USB_DEVICE_ID_MGE_UPS1 0x0001
211 216
217#define USB_VENDOR_ID_MICROSOFT 0x045e
218#define USB_DEVICE_ID_SIDEWINDER_GV 0x003b
219
220#define USB_VENDOR_ID_NCR 0x0404
221#define USB_DEVICE_ID_NCR_FIRST 0x0300
222#define USB_DEVICE_ID_NCR_LAST 0x03ff
223
212#define USB_VENDOR_ID_NEC 0x073e 224#define USB_VENDOR_ID_NEC 0x073e
213#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301 225#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301
214 226
@@ -220,6 +232,9 @@
220#define USB_VENDOR_ID_PANTHERLORD 0x0810 232#define USB_VENDOR_ID_PANTHERLORD 0x0810
221#define USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK 0x0001 233#define USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK 0x0001
222 234
235#define USB_VENDOR_ID_PETALYNX 0x18b1
236#define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037
237
223#define USB_VENDOR_ID_PLAYDOTCOM 0x0b43 238#define USB_VENDOR_ID_PLAYDOTCOM 0x0b43
224#define USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII 0x0003 239#define USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII 0x0003
225 240
@@ -278,6 +293,7 @@ static const struct hid_blacklist {
278 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, 293 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD },
279 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, 294 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD },
280 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, 295 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD },
296 { USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR, HID_QUIRK_MULTI_INPUT },
281 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 297 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
282 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 298 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
283 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 299 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
@@ -285,11 +301,10 @@ static const struct hid_blacklist {
285 { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD }, 301 { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD },
286 { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD }, 302 { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD },
287 303
288 { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_CYMOTION },
289
290 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE, HID_QUIRK_DUPLICATE_USAGES }, 304 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE, HID_QUIRK_DUPLICATE_USAGES },
291 305
292 { USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM, HID_QUIRK_HIDDEV }, 306 { USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM, HID_QUIRK_HIDDEV },
307 { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV, HID_QUIRK_HIDINPUT },
293 308
294 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01, HID_QUIRK_IGNORE }, 309 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01, HID_QUIRK_IGNORE },
295 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10, HID_QUIRK_IGNORE }, 310 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10, HID_QUIRK_IGNORE },
@@ -409,9 +424,7 @@ static const struct hid_blacklist {
409 { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR, HID_QUIRK_IGNORE }, 424 { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR, HID_QUIRK_IGNORE },
410 { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302, HID_QUIRK_IGNORE }, 425 { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302, HID_QUIRK_IGNORE },
411 426
412 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER, HID_QUIRK_LOGITECH_DESCRIPTOR }, 427 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500, HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL | HID_QUIRK_LOGITECH_EXPANDED_KEYMAP },
413 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER, HID_QUIRK_LOGITECH_DESCRIPTOR },
414 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2, HID_QUIRK_LOGITECH_DESCRIPTOR },
415 428
416 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL }, 429 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL },
417 430
@@ -426,6 +439,7 @@ static const struct hid_blacklist {
426 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, 439 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET },
427 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, 440 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
428 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL, HID_QUIRK_NOGET }, 441 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL, HID_QUIRK_NOGET },
442 { USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE, HID_QUIRK_NOGET },
429 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, 443 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
430 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, 444 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
431 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 445 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
@@ -448,9 +462,28 @@ static const struct hid_blacklist {
448 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 462 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
449 463
450 { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS }, 464 { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS },
465 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD, HID_QUIRK_RESET_LEDS },
451 466
452 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1, HID_QUIRK_SWAPPED_MIN_MAX }, 467 { 0, 0 }
453 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2, HID_QUIRK_SWAPPED_MIN_MAX }, 468};
469
470/* Quirks for devices which require report descriptor fixup go here */
471static const struct hid_rdesc_blacklist {
472 __u16 idVendor;
473 __u16 idProduct;
474 __u32 quirks;
475} hid_rdesc_blacklist[] = {
476
477 { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_RDESC_CYMOTION },
478
479 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER, HID_QUIRK_RDESC_LOGITECH },
480 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER, HID_QUIRK_RDESC_LOGITECH },
481 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2, HID_QUIRK_RDESC_LOGITECH },
482
483 { USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE, HID_QUIRK_RDESC_PETALYNX },
484
485 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1, HID_QUIRK_RDESC_SWAPPED_MIN_MAX },
486 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2, HID_QUIRK_RDESC_SWAPPED_MIN_MAX },
454 487
455 { 0, 0 } 488 { 0, 0 }
456}; 489};
@@ -493,7 +526,7 @@ static struct hid_blacklist *usbhid_exists_dquirk(const u16 idVendor,
493 } 526 }
494 527
495 if (bl_entry != NULL) 528 if (bl_entry != NULL)
496 dbg("Found dynamic quirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n", 529 dbg_hid("Found dynamic quirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n",
497 bl_entry->quirks, bl_entry->idVendor, 530 bl_entry->quirks, bl_entry->idVendor,
498 bl_entry->idProduct); 531 bl_entry->idProduct);
499 532
@@ -521,13 +554,13 @@ int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct,
521 int list_edited = 0; 554 int list_edited = 0;
522 555
523 if (!idVendor) { 556 if (!idVendor) {
524 dbg("Cannot add a quirk with idVendor = 0"); 557 dbg_hid("Cannot add a quirk with idVendor = 0\n");
525 return -EINVAL; 558 return -EINVAL;
526 } 559 }
527 560
528 q_new = kmalloc(sizeof(struct quirks_list_struct), GFP_KERNEL); 561 q_new = kmalloc(sizeof(struct quirks_list_struct), GFP_KERNEL);
529 if (!q_new) { 562 if (!q_new) {
530 dbg("Could not allocate quirks_list_struct"); 563 dbg_hid("Could not allocate quirks_list_struct\n");
531 return -ENOMEM; 564 return -ENOMEM;
532 } 565 }
533 566
@@ -559,7 +592,6 @@ int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct,
559 return 0; 592 return 0;
560} 593}
561 594
562
563/** 595/**
564 * usbhid_remove_all_dquirks: remove all runtime HID quirks from memory 596 * usbhid_remove_all_dquirks: remove all runtime HID quirks from memory
565 * 597 *
@@ -643,7 +675,7 @@ static const struct hid_blacklist *usbhid_exists_squirk(const u16 idVendor,
643 bl_entry = &hid_blacklist[n]; 675 bl_entry = &hid_blacklist[n];
644 676
645 if (bl_entry != NULL) 677 if (bl_entry != NULL)
646 dbg("Found squirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n", 678 dbg_hid("Found squirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n",
647 bl_entry->quirks, bl_entry->idVendor, 679 bl_entry->quirks, bl_entry->idVendor,
648 bl_entry->idProduct); 680 bl_entry->idProduct);
649 return bl_entry; 681 return bl_entry;
@@ -675,6 +707,12 @@ u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct)
675 idProduct <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) 707 idProduct <= USB_DEVICE_ID_CODEMERCS_IOW_LAST)
676 return HID_QUIRK_IGNORE; 708 return HID_QUIRK_IGNORE;
677 709
710 /* NCR devices must not be queried for reports */
711 if (idVendor == USB_VENDOR_ID_NCR &&
712 idProduct >= USB_DEVICE_ID_NCR_FIRST &&
713 idProduct <= USB_DEVICE_ID_NCR_LAST)
714 return HID_QUIRK_NOGET;
715
678 down_read(&dquirks_rwsem); 716 down_read(&dquirks_rwsem);
679 bl_entry = usbhid_exists_dquirk(idVendor, idProduct); 717 bl_entry = usbhid_exists_dquirk(idVendor, idProduct);
680 if (!bl_entry) 718 if (!bl_entry)
@@ -686,3 +724,126 @@ u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct)
686 return quirks; 724 return quirks;
687} 725}
688 726
727/*
728 * Cherry Cymotion keyboard have an invalid HID report descriptor,
729 * that needs fixing before we can parse it.
730 */
731static void usbhid_fixup_cymotion_descriptor(char *rdesc, int rsize)
732{
733 if (rsize >= 17 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
734 printk(KERN_INFO "Fixing up Cherry Cymotion report descriptor\n");
735 rdesc[11] = rdesc[16] = 0xff;
736 rdesc[12] = rdesc[17] = 0x03;
737 }
738}
739
740
741/*
742 * Certain Logitech keyboards send in report #3 keys which are far
743 * above the logical maximum described in descriptor. This extends
744 * the original value of 0x28c of logical maximum to 0x104d
745 */
746static void usbhid_fixup_logitech_descriptor(unsigned char *rdesc, int rsize)
747{
748 if (rsize >= 90 && rdesc[83] == 0x26
749 && rdesc[84] == 0x8c
750 && rdesc[85] == 0x02) {
751 printk(KERN_INFO "Fixing up Logitech keyboard report descriptor\n");
752 rdesc[84] = rdesc[89] = 0x4d;
753 rdesc[85] = rdesc[90] = 0x10;
754 }
755}
756
757/* Petalynx Maxter Remote has maximum for consumer page set too low */
758static void usbhid_fixup_petalynx_descriptor(unsigned char *rdesc, int rsize)
759{
760 if (rsize >= 60 && rdesc[39] == 0x2a
761 && rdesc[40] == 0xf5
762 && rdesc[41] == 0x00
763 && rdesc[59] == 0x26
764 && rdesc[60] == 0xf9
765 && rdesc[61] == 0x00) {
766 printk(KERN_INFO "Fixing up Petalynx Maxter Remote report descriptor\n");
767 rdesc[60] = 0xfa;
768 rdesc[40] = 0xfa;
769 }
770}
771
772/*
773 * Some USB barcode readers from cypress have usage min and usage max in
774 * the wrong order
775 */
776static void usbhid_fixup_cypress_descriptor(unsigned char *rdesc, int rsize)
777{
778 short fixed = 0;
779 int i;
780
781 for (i = 0; i < rsize - 4; i++) {
782 if (rdesc[i] == 0x29 && rdesc [i+2] == 0x19) {
783 unsigned char tmp;
784
785 rdesc[i] = 0x19; rdesc[i+2] = 0x29;
786 tmp = rdesc[i+3];
787 rdesc[i+3] = rdesc[i+1];
788 rdesc[i+1] = tmp;
789 }
790 }
791
792 if (fixed)
793 printk(KERN_INFO "Fixing up Cypress report descriptor\n");
794}
795
796
797static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned rsize)
798{
799 if ((quirks & HID_QUIRK_RDESC_CYMOTION))
800 usbhid_fixup_cymotion_descriptor(rdesc, rsize);
801
802 if (quirks & HID_QUIRK_RDESC_LOGITECH)
803 usbhid_fixup_logitech_descriptor(rdesc, rsize);
804
805 if (quirks & HID_QUIRK_RDESC_SWAPPED_MIN_MAX)
806 usbhid_fixup_cypress_descriptor(rdesc, rsize);
807
808 if (quirks & HID_QUIRK_RDESC_PETALYNX)
809 usbhid_fixup_petalynx_descriptor(rdesc, rsize);
810}
811
812/**
813 * usbhid_fixup_report_descriptor: check if report descriptor needs fixup
814 *
815 * Description:
816 * Walks the hid_rdesc_blacklist[] array and checks whether the device
817 * is known to have broken report descriptor that needs to be fixed up
818 * prior to entering the HID parser
819 *
820 * Returns: nothing
821 */
822void usbhid_fixup_report_descriptor(const u16 idVendor, const u16 idProduct,
823 char *rdesc, unsigned rsize, char **quirks_param)
824{
825 int n, m;
826 u16 paramVendor, paramProduct;
827 u32 quirks;
828
829 /* static rdesc quirk entries */
830 for (n = 0; hid_rdesc_blacklist[n].idVendor; n++)
831 if (hid_rdesc_blacklist[n].idVendor == idVendor &&
832 hid_rdesc_blacklist[n].idProduct == idProduct)
833 __usbhid_fixup_report_descriptor(hid_rdesc_blacklist[n].quirks,
834 rdesc, rsize);
835
836 /* runtime rdesc quirk entries handling */
837 for (n = 0; quirks_param[n] && n < MAX_USBHID_BOOT_QUIRKS; n++) {
838 m = sscanf(quirks_param[n], "0x%hx:0x%hx:0x%x",
839 &paramVendor, &paramProduct, &quirks);
840
841 if (m != 3)
842 printk(KERN_WARNING
843 "Could not parse HID quirk module param %s\n",
844 quirks_param[n]);
845 else if (paramVendor == idVendor && paramProduct == idProduct)
846 __usbhid_fixup_report_descriptor(quirks, rdesc, rsize);
847 }
848
849}
diff --git a/drivers/hid/usbhid/hid-tmff.c b/drivers/hid/usbhid/hid-tmff.c
index ab5ba6ef891c..555bb48b4295 100644
--- a/drivers/hid/usbhid/hid-tmff.c
+++ b/drivers/hid/usbhid/hid-tmff.c
@@ -70,7 +70,7 @@ static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *ef
70 70
71 tmff->rumble->value[0] = left; 71 tmff->rumble->value[0] = left;
72 tmff->rumble->value[1] = right; 72 tmff->rumble->value[1] = right;
73 dbg("(left,right)=(%08x, %08x)", left, right); 73 dbg_hid("(left,right)=(%08x, %08x)\n", left, right);
74 usbhid_submit_report(hid, tmff->report, USB_DIR_OUT); 74 usbhid_submit_report(hid, tmff->report, USB_DIR_OUT);
75 75
76 return 0; 76 return 0;
diff --git a/drivers/hid/usbhid/hid-zpff.c b/drivers/hid/usbhid/hid-zpff.c
index a7fbffcdaf36..5a688274f6a3 100644
--- a/drivers/hid/usbhid/hid-zpff.c
+++ b/drivers/hid/usbhid/hid-zpff.c
@@ -21,10 +21,6 @@
21 */ 21 */
22 22
23 23
24/* #define DEBUG */
25
26#define debug(format, arg...) pr_debug("hid-zpff: " format "\n" , ## arg)
27
28#include <linux/input.h> 24#include <linux/input.h>
29#include <linux/usb.h> 25#include <linux/usb.h>
30#include <linux/hid.h> 26#include <linux/hid.h>
@@ -49,14 +45,14 @@ static int hid_zpff_play(struct input_dev *dev, void *data,
49 45
50 left = effect->u.rumble.strong_magnitude; 46 left = effect->u.rumble.strong_magnitude;
51 right = effect->u.rumble.weak_magnitude; 47 right = effect->u.rumble.weak_magnitude;
52 debug("called with 0x%04x 0x%04x", left, right); 48 dbg_hid("called with 0x%04x 0x%04x\n", left, right);
53 49
54 left = left * 0x7f / 0xffff; 50 left = left * 0x7f / 0xffff;
55 right = right * 0x7f / 0xffff; 51 right = right * 0x7f / 0xffff;
56 52
57 zpff->report->field[2]->value[0] = left; 53 zpff->report->field[2]->value[0] = left;
58 zpff->report->field[3]->value[0] = right; 54 zpff->report->field[3]->value[0] = right;
59 debug("running with 0x%02x 0x%02x", left, right); 55 dbg_hid("running with 0x%02x 0x%02x\n", left, right);
60 usbhid_submit_report(hid, zpff->report, USB_DIR_OUT); 56 usbhid_submit_report(hid, zpff->report, USB_DIR_OUT);
61 57
62 return 0; 58 return 0;
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 488d61bdbf2c..e793127f971e 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -779,7 +779,7 @@ int hiddev_connect(struct hid_device *hid)
779 779
780 retval = usb_register_dev(usbhid->intf, &hiddev_class); 780 retval = usb_register_dev(usbhid->intf, &hiddev_class);
781 if (retval) { 781 if (retval) {
782 err("Not able to get a minor for this device."); 782 err_hid("Not able to get a minor for this device.");
783 kfree(hiddev); 783 kfree(hiddev);
784 return -1; 784 return -1;
785 } 785 }
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
index 130978780713..b76b02f7b52d 100644
--- a/drivers/hid/usbhid/usbkbd.c
+++ b/drivers/hid/usbhid/usbkbd.c
@@ -125,7 +125,7 @@ static void usb_kbd_irq(struct urb *urb)
125resubmit: 125resubmit:
126 i = usb_submit_urb (urb, GFP_ATOMIC); 126 i = usb_submit_urb (urb, GFP_ATOMIC);
127 if (i) 127 if (i)
128 err ("can't resubmit intr, %s-%s/input0, status %d", 128 err_hid ("can't resubmit intr, %s-%s/input0, status %d",
129 kbd->usbdev->bus->bus_name, 129 kbd->usbdev->bus->bus_name,
130 kbd->usbdev->devpath, i); 130 kbd->usbdev->devpath, i);
131} 131}
@@ -151,7 +151,7 @@ static int usb_kbd_event(struct input_dev *dev, unsigned int type,
151 *(kbd->leds) = kbd->newleds; 151 *(kbd->leds) = kbd->newleds;
152 kbd->led->dev = kbd->usbdev; 152 kbd->led->dev = kbd->usbdev;
153 if (usb_submit_urb(kbd->led, GFP_ATOMIC)) 153 if (usb_submit_urb(kbd->led, GFP_ATOMIC))
154 err("usb_submit_urb(leds) failed"); 154 err_hid("usb_submit_urb(leds) failed");
155 155
156 return 0; 156 return 0;
157} 157}
@@ -169,7 +169,7 @@ static void usb_kbd_led(struct urb *urb)
169 *(kbd->leds) = kbd->newleds; 169 *(kbd->leds) = kbd->newleds;
170 kbd->led->dev = kbd->usbdev; 170 kbd->led->dev = kbd->usbdev;
171 if (usb_submit_urb(kbd->led, GFP_ATOMIC)) 171 if (usb_submit_urb(kbd->led, GFP_ATOMIC))
172 err("usb_submit_urb(leds) failed"); 172 err_hid("usb_submit_urb(leds) failed");
173} 173}
174 174
175static int usb_kbd_open(struct input_dev *dev) 175static int usb_kbd_open(struct input_dev *dev)
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 827ee748fd4c..898103b401f1 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -263,19 +263,28 @@ struct hid_item {
263#define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x00000100 263#define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x00000100
264#define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x00000200 264#define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x00000200
265#define HID_QUIRK_MIGHTYMOUSE 0x00000400 265#define HID_QUIRK_MIGHTYMOUSE 0x00000400
266#define HID_QUIRK_CYMOTION 0x00000800 266#define HID_QUIRK_POWERBOOK_HAS_FN 0x00000800
267#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000 267#define HID_QUIRK_POWERBOOK_FN_ON 0x00001000
268#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000 268#define HID_QUIRK_INVERT_HWHEEL 0x00002000
269#define HID_QUIRK_INVERT_HWHEEL 0x00004000 269#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD 0x00004000
270#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD 0x00008000 270#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00008000
271#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00010000 271#define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000
272#define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00020000 272#define HID_QUIRK_IGNORE_MOUSE 0x00020000
273#define HID_QUIRK_IGNORE_MOUSE 0x00040000 273#define HID_QUIRK_SONY_PS3_CONTROLLER 0x00040000
274#define HID_QUIRK_SONY_PS3_CONTROLLER 0x00080000 274#define HID_QUIRK_DUPLICATE_USAGES 0x00080000
275#define HID_QUIRK_LOGITECH_DESCRIPTOR 0x00100000 275#define HID_QUIRK_RESET_LEDS 0x00100000
276#define HID_QUIRK_DUPLICATE_USAGES 0x00200000 276#define HID_QUIRK_HIDINPUT 0x00200000
277#define HID_QUIRK_RESET_LEDS 0x00400000 277#define HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL 0x00400000
278#define HID_QUIRK_SWAPPED_MIN_MAX 0x00800000 278#define HID_QUIRK_LOGITECH_EXPANDED_KEYMAP 0x00800000
279
280/*
281 * Separate quirks for runtime report descriptor fixup
282 */
283
284#define HID_QUIRK_RDESC_CYMOTION 0x00000001
285#define HID_QUIRK_RDESC_LOGITECH 0x00000002
286#define HID_QUIRK_RDESC_SWAPPED_MIN_MAX 0x00000004
287#define HID_QUIRK_RDESC_PETALYNX 0x00000008
279 288
280/* 289/*
281 * This is the global environment of the parser. This information is 290 * This is the global environment of the parser. This information is
@@ -488,6 +497,11 @@ struct hid_descriptor {
488#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001)) 497#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001))
489 498
490/* HID core API */ 499/* HID core API */
500
501#ifdef CONFIG_HID_DEBUG
502extern int hid_debug;
503#endif
504
491extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); 505extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
492extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report); 506extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report);
493extern int hidinput_connect(struct hid_device *); 507extern int hidinput_connect(struct hid_device *);
@@ -506,6 +520,7 @@ u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct);
506int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct, const u32 quirks); 520int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct, const u32 quirks);
507int usbhid_quirks_init(char **quirks_param); 521int usbhid_quirks_init(char **quirks_param);
508void usbhid_quirks_exit(void); 522void usbhid_quirks_exit(void);
523void usbhid_fixup_report_descriptor(const u16, const u16, char *, unsigned, char **);
509 524
510#ifdef CONFIG_HID_FF 525#ifdef CONFIG_HID_FF
511int hid_ff_init(struct hid_device *hid); 526int hid_ff_init(struct hid_device *hid);
@@ -523,14 +538,19 @@ static inline int hid_pidff_init(struct hid_device *hid) { return -ENODEV; }
523#else 538#else
524static inline int hid_ff_init(struct hid_device *hid) { return -1; } 539static inline int hid_ff_init(struct hid_device *hid) { return -1; }
525#endif 540#endif
526#ifdef DEBUG 541
527#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , \ 542#ifdef CONFIG_HID_DEBUG
528 __FILE__ , ## arg) 543#define dbg_hid(format, arg...) if (hid_debug) \
544 printk(KERN_DEBUG "%s: " format ,\
545 __FILE__ , ## arg)
546#define dbg_hid_line(format, arg...) if (hid_debug) \
547 printk(format, ## arg)
529#else 548#else
530#define dbg(format, arg...) do {} while (0) 549#define dbg_hid(format, arg...) do {} while (0)
550#define dbg_hid_line dbg_hid
531#endif 551#endif
532 552
533#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \ 553#define err_hid(format, arg...) printk(KERN_ERR "%s: " format "\n" , \
534 __FILE__ , ## arg) 554 __FILE__ , ## arg)
535#endif 555#endif
536 556