hid-core.c revision 734c660931095ae165c0db6ff60558fc4173bfd0
1/* 2 * HID support for Linux 3 * 4 * Copyright (c) 1999 Andreas Gal 5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 7 * Copyright (c) 2006-2012 Jiri Kosina 8 */ 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 17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18 19#include <linux/module.h> 20#include <linux/slab.h> 21#include <linux/init.h> 22#include <linux/kernel.h> 23#include <linux/list.h> 24#include <linux/mm.h> 25#include <linux/spinlock.h> 26#include <asm/unaligned.h> 27#include <asm/byteorder.h> 28#include <linux/input.h> 29#include <linux/wait.h> 30#include <linux/vmalloc.h> 31#include <linux/sched.h> 32#include <linux/semaphore.h> 33 34#include <linux/hid.h> 35#include <linux/hiddev.h> 36#include <linux/hid-debug.h> 37#include <linux/hidraw.h> 38 39#include "hid-ids.h" 40 41/* 42 * Version Information 43 */ 44 45#define DRIVER_DESC "HID core driver" 46#define DRIVER_LICENSE "GPL" 47 48int hid_debug = 0; 49module_param_named(debug, hid_debug, int, 0600); 50MODULE_PARM_DESC(debug, "toggle HID debugging messages"); 51EXPORT_SYMBOL_GPL(hid_debug); 52 53static int hid_ignore_special_drivers = 0; 54module_param_named(ignore_special_drivers, hid_ignore_special_drivers, int, 0600); 55MODULE_PARM_DESC(debug, "Ignore any special drivers and handle all devices by generic driver"); 56 57/* 58 * Register a new report for a device. 59 */ 60 61struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) 62{ 63 struct hid_report_enum *report_enum = device->report_enum + type; 64 struct hid_report *report; 65 66 if (report_enum->report_id_hash[id]) 67 return report_enum->report_id_hash[id]; 68 69 report = kzalloc(sizeof(struct hid_report), GFP_KERNEL); 70 if (!report) 71 return NULL; 72 73 if (id != 0) 74 report_enum->numbered = 1; 75 76 report->id = id; 77 report->type = type; 78 report->size = 0; 79 report->device = device; 80 report_enum->report_id_hash[id] = report; 81 82 list_add_tail(&report->list, &report_enum->report_list); 83 84 return report; 85} 86EXPORT_SYMBOL_GPL(hid_register_report); 87 88/* 89 * Register a new field for this report. 90 */ 91 92static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) 93{ 94 struct hid_field *field; 95 96 if (report->maxfield == HID_MAX_FIELDS) { 97 hid_err(report->device, "too many fields in report\n"); 98 return NULL; 99 } 100 101 field = kzalloc((sizeof(struct hid_field) + 102 usages * sizeof(struct hid_usage) + 103 values * sizeof(unsigned)), GFP_KERNEL); 104 if (!field) 105 return NULL; 106 107 field->index = report->maxfield++; 108 report->field[field->index] = field; 109 field->usage = (struct hid_usage *)(field + 1); 110 field->value = (s32 *)(field->usage + usages); 111 field->report = report; 112 113 return field; 114} 115 116/* 117 * Open a collection. The type/usage is pushed on the stack. 118 */ 119 120static int open_collection(struct hid_parser *parser, unsigned type) 121{ 122 struct hid_collection *collection; 123 unsigned usage; 124 125 usage = parser->local.usage[0]; 126 127 if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { 128 hid_err(parser->device, "collection stack overflow\n"); 129 return -1; 130 } 131 132 if (parser->device->maxcollection == parser->device->collection_size) { 133 collection = kmalloc(sizeof(struct hid_collection) * 134 parser->device->collection_size * 2, GFP_KERNEL); 135 if (collection == NULL) { 136 hid_err(parser->device, "failed to reallocate collection array\n"); 137 return -1; 138 } 139 memcpy(collection, parser->device->collection, 140 sizeof(struct hid_collection) * 141 parser->device->collection_size); 142 memset(collection + parser->device->collection_size, 0, 143 sizeof(struct hid_collection) * 144 parser->device->collection_size); 145 kfree(parser->device->collection); 146 parser->device->collection = collection; 147 parser->device->collection_size *= 2; 148 } 149 150 parser->collection_stack[parser->collection_stack_ptr++] = 151 parser->device->maxcollection; 152 153 collection = parser->device->collection + 154 parser->device->maxcollection++; 155 collection->type = type; 156 collection->usage = usage; 157 collection->level = parser->collection_stack_ptr - 1; 158 159 if (type == HID_COLLECTION_APPLICATION) 160 parser->device->maxapplication++; 161 162 return 0; 163} 164 165/* 166 * Close a collection. 167 */ 168 169static int close_collection(struct hid_parser *parser) 170{ 171 if (!parser->collection_stack_ptr) { 172 hid_err(parser->device, "collection stack underflow\n"); 173 return -1; 174 } 175 parser->collection_stack_ptr--; 176 return 0; 177} 178 179/* 180 * Climb up the stack, search for the specified collection type 181 * and return the usage. 182 */ 183 184static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) 185{ 186 struct hid_collection *collection = parser->device->collection; 187 int n; 188 189 for (n = parser->collection_stack_ptr - 1; n >= 0; n--) { 190 unsigned index = parser->collection_stack[n]; 191 if (collection[index].type == type) 192 return collection[index].usage; 193 } 194 return 0; /* we know nothing about this usage type */ 195} 196 197/* 198 * Add a usage to the temporary parser table. 199 */ 200 201static int hid_add_usage(struct hid_parser *parser, unsigned usage) 202{ 203 if (parser->local.usage_index >= HID_MAX_USAGES) { 204 hid_err(parser->device, "usage index exceeded\n"); 205 return -1; 206 } 207 parser->local.usage[parser->local.usage_index] = usage; 208 parser->local.collection_index[parser->local.usage_index] = 209 parser->collection_stack_ptr ? 210 parser->collection_stack[parser->collection_stack_ptr - 1] : 0; 211 parser->local.usage_index++; 212 return 0; 213} 214 215/* 216 * Register a new field for this report. 217 */ 218 219static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags) 220{ 221 struct hid_report *report; 222 struct hid_field *field; 223 int usages; 224 unsigned offset; 225 int i; 226 227 report = hid_register_report(parser->device, report_type, parser->global.report_id); 228 if (!report) { 229 hid_err(parser->device, "hid_register_report failed\n"); 230 return -1; 231 } 232 233 if (parser->global.logical_maximum < parser->global.logical_minimum) { 234 hid_err(parser->device, "logical range invalid %d %d\n", 235 parser->global.logical_minimum, parser->global.logical_maximum); 236 return -1; 237 } 238 239 offset = report->size; 240 report->size += parser->global.report_size * parser->global.report_count; 241 242 if (!parser->local.usage_index) /* Ignore padding fields */ 243 return 0; 244 245 usages = max_t(int, parser->local.usage_index, parser->global.report_count); 246 247 field = hid_register_field(report, usages, parser->global.report_count); 248 if (!field) 249 return 0; 250 251 field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); 252 field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL); 253 field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); 254 255 for (i = 0; i < usages; i++) { 256 int j = i; 257 /* Duplicate the last usage we parsed if we have excess values */ 258 if (i >= parser->local.usage_index) 259 j = parser->local.usage_index - 1; 260 field->usage[i].hid = parser->local.usage[j]; 261 field->usage[i].collection_index = 262 parser->local.collection_index[j]; 263 } 264 265 field->maxusage = usages; 266 field->flags = flags; 267 field->report_offset = offset; 268 field->report_type = report_type; 269 field->report_size = parser->global.report_size; 270 field->report_count = parser->global.report_count; 271 field->logical_minimum = parser->global.logical_minimum; 272 field->logical_maximum = parser->global.logical_maximum; 273 field->physical_minimum = parser->global.physical_minimum; 274 field->physical_maximum = parser->global.physical_maximum; 275 field->unit_exponent = parser->global.unit_exponent; 276 field->unit = parser->global.unit; 277 278 return 0; 279} 280 281/* 282 * Read data value from item. 283 */ 284 285static u32 item_udata(struct hid_item *item) 286{ 287 switch (item->size) { 288 case 1: return item->data.u8; 289 case 2: return item->data.u16; 290 case 4: return item->data.u32; 291 } 292 return 0; 293} 294 295static s32 item_sdata(struct hid_item *item) 296{ 297 switch (item->size) { 298 case 1: return item->data.s8; 299 case 2: return item->data.s16; 300 case 4: return item->data.s32; 301 } 302 return 0; 303} 304 305/* 306 * Process a global item. 307 */ 308 309static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) 310{ 311 switch (item->tag) { 312 case HID_GLOBAL_ITEM_TAG_PUSH: 313 314 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { 315 hid_err(parser->device, "global environment stack overflow\n"); 316 return -1; 317 } 318 319 memcpy(parser->global_stack + parser->global_stack_ptr++, 320 &parser->global, sizeof(struct hid_global)); 321 return 0; 322 323 case HID_GLOBAL_ITEM_TAG_POP: 324 325 if (!parser->global_stack_ptr) { 326 hid_err(parser->device, "global environment stack underflow\n"); 327 return -1; 328 } 329 330 memcpy(&parser->global, parser->global_stack + 331 --parser->global_stack_ptr, sizeof(struct hid_global)); 332 return 0; 333 334 case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: 335 parser->global.usage_page = item_udata(item); 336 return 0; 337 338 case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: 339 parser->global.logical_minimum = item_sdata(item); 340 return 0; 341 342 case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: 343 if (parser->global.logical_minimum < 0) 344 parser->global.logical_maximum = item_sdata(item); 345 else 346 parser->global.logical_maximum = item_udata(item); 347 return 0; 348 349 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: 350 parser->global.physical_minimum = item_sdata(item); 351 return 0; 352 353 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: 354 if (parser->global.physical_minimum < 0) 355 parser->global.physical_maximum = item_sdata(item); 356 else 357 parser->global.physical_maximum = item_udata(item); 358 return 0; 359 360 case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: 361 parser->global.unit_exponent = item_sdata(item); 362 return 0; 363 364 case HID_GLOBAL_ITEM_TAG_UNIT: 365 parser->global.unit = item_udata(item); 366 return 0; 367 368 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: 369 parser->global.report_size = item_udata(item); 370 if (parser->global.report_size > 96) { 371 hid_err(parser->device, "invalid report_size %d\n", 372 parser->global.report_size); 373 return -1; 374 } 375 return 0; 376 377 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: 378 parser->global.report_count = item_udata(item); 379 if (parser->global.report_count > HID_MAX_USAGES) { 380 hid_err(parser->device, "invalid report_count %d\n", 381 parser->global.report_count); 382 return -1; 383 } 384 return 0; 385 386 case HID_GLOBAL_ITEM_TAG_REPORT_ID: 387 parser->global.report_id = item_udata(item); 388 if (parser->global.report_id == 0) { 389 hid_err(parser->device, "report_id 0 is invalid\n"); 390 return -1; 391 } 392 return 0; 393 394 default: 395 hid_err(parser->device, "unknown global tag 0x%x\n", item->tag); 396 return -1; 397 } 398} 399 400/* 401 * Process a local item. 402 */ 403 404static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) 405{ 406 __u32 data; 407 unsigned n; 408 409 data = item_udata(item); 410 411 switch (item->tag) { 412 case HID_LOCAL_ITEM_TAG_DELIMITER: 413 414 if (data) { 415 /* 416 * We treat items before the first delimiter 417 * as global to all usage sets (branch 0). 418 * In the moment we process only these global 419 * items and the first delimiter set. 420 */ 421 if (parser->local.delimiter_depth != 0) { 422 hid_err(parser->device, "nested delimiters\n"); 423 return -1; 424 } 425 parser->local.delimiter_depth++; 426 parser->local.delimiter_branch++; 427 } else { 428 if (parser->local.delimiter_depth < 1) { 429 hid_err(parser->device, "bogus close delimiter\n"); 430 return -1; 431 } 432 parser->local.delimiter_depth--; 433 } 434 return 1; 435 436 case HID_LOCAL_ITEM_TAG_USAGE: 437 438 if (parser->local.delimiter_branch > 1) { 439 dbg_hid("alternative usage ignored\n"); 440 return 0; 441 } 442 443 if (item->size <= 2) 444 data = (parser->global.usage_page << 16) + data; 445 446 return hid_add_usage(parser, data); 447 448 case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: 449 450 if (parser->local.delimiter_branch > 1) { 451 dbg_hid("alternative usage ignored\n"); 452 return 0; 453 } 454 455 if (item->size <= 2) 456 data = (parser->global.usage_page << 16) + data; 457 458 parser->local.usage_minimum = data; 459 return 0; 460 461 case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: 462 463 if (parser->local.delimiter_branch > 1) { 464 dbg_hid("alternative usage ignored\n"); 465 return 0; 466 } 467 468 if (item->size <= 2) 469 data = (parser->global.usage_page << 16) + data; 470 471 for (n = parser->local.usage_minimum; n <= data; n++) 472 if (hid_add_usage(parser, n)) { 473 dbg_hid("hid_add_usage failed\n"); 474 return -1; 475 } 476 return 0; 477 478 default: 479 480 dbg_hid("unknown local item tag 0x%x\n", item->tag); 481 return 0; 482 } 483 return 0; 484} 485 486/* 487 * Process a main item. 488 */ 489 490static int hid_parser_main(struct hid_parser *parser, struct hid_item *item) 491{ 492 __u32 data; 493 int ret; 494 495 data = item_udata(item); 496 497 switch (item->tag) { 498 case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: 499 ret = open_collection(parser, data & 0xff); 500 break; 501 case HID_MAIN_ITEM_TAG_END_COLLECTION: 502 ret = close_collection(parser); 503 break; 504 case HID_MAIN_ITEM_TAG_INPUT: 505 ret = hid_add_field(parser, HID_INPUT_REPORT, data); 506 break; 507 case HID_MAIN_ITEM_TAG_OUTPUT: 508 ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); 509 break; 510 case HID_MAIN_ITEM_TAG_FEATURE: 511 ret = hid_add_field(parser, HID_FEATURE_REPORT, data); 512 break; 513 default: 514 hid_err(parser->device, "unknown main item tag 0x%x\n", item->tag); 515 ret = 0; 516 } 517 518 memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ 519 520 return ret; 521} 522 523/* 524 * Process a reserved item. 525 */ 526 527static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) 528{ 529 dbg_hid("reserved item type, tag 0x%x\n", item->tag); 530 return 0; 531} 532 533/* 534 * Free a report and all registered fields. The field->usage and 535 * field->value table's are allocated behind the field, so we need 536 * only to free(field) itself. 537 */ 538 539static void hid_free_report(struct hid_report *report) 540{ 541 unsigned n; 542 543 for (n = 0; n < report->maxfield; n++) 544 kfree(report->field[n]); 545 kfree(report); 546} 547 548/* 549 * Close report. This function returns the device 550 * state to the point prior to hid_open_report(). 551 */ 552static void hid_close_report(struct hid_device *device) 553{ 554 unsigned i, j; 555 556 for (i = 0; i < HID_REPORT_TYPES; i++) { 557 struct hid_report_enum *report_enum = device->report_enum + i; 558 559 for (j = 0; j < 256; j++) { 560 struct hid_report *report = report_enum->report_id_hash[j]; 561 if (report) 562 hid_free_report(report); 563 } 564 memset(report_enum, 0, sizeof(*report_enum)); 565 INIT_LIST_HEAD(&report_enum->report_list); 566 } 567 568 kfree(device->rdesc); 569 device->rdesc = NULL; 570 device->rsize = 0; 571 572 kfree(device->collection); 573 device->collection = NULL; 574 device->collection_size = 0; 575 device->maxcollection = 0; 576 device->maxapplication = 0; 577 578 device->status &= ~HID_STAT_PARSED; 579} 580 581/* 582 * Free a device structure, all reports, and all fields. 583 */ 584 585static void hid_device_release(struct device *dev) 586{ 587 struct hid_device *hid = container_of(dev, struct hid_device, dev); 588 589 hid_close_report(hid); 590 kfree(hid->dev_rdesc); 591 kfree(hid); 592} 593 594/* 595 * Fetch a report description item from the data stream. We support long 596 * items, though they are not used yet. 597 */ 598 599static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) 600{ 601 u8 b; 602 603 if ((end - start) <= 0) 604 return NULL; 605 606 b = *start++; 607 608 item->type = (b >> 2) & 3; 609 item->tag = (b >> 4) & 15; 610 611 if (item->tag == HID_ITEM_TAG_LONG) { 612 613 item->format = HID_ITEM_FORMAT_LONG; 614 615 if ((end - start) < 2) 616 return NULL; 617 618 item->size = *start++; 619 item->tag = *start++; 620 621 if ((end - start) < item->size) 622 return NULL; 623 624 item->data.longdata = start; 625 start += item->size; 626 return start; 627 } 628 629 item->format = HID_ITEM_FORMAT_SHORT; 630 item->size = b & 3; 631 632 switch (item->size) { 633 case 0: 634 return start; 635 636 case 1: 637 if ((end - start) < 1) 638 return NULL; 639 item->data.u8 = *start++; 640 return start; 641 642 case 2: 643 if ((end - start) < 2) 644 return NULL; 645 item->data.u16 = get_unaligned_le16(start); 646 start = (__u8 *)((__le16 *)start + 1); 647 return start; 648 649 case 3: 650 item->size++; 651 if ((end - start) < 4) 652 return NULL; 653 item->data.u32 = get_unaligned_le32(start); 654 start = (__u8 *)((__le32 *)start + 1); 655 return start; 656 } 657 658 return NULL; 659} 660 661static void hid_scan_usage(struct hid_device *hid, u32 usage) 662{ 663} 664 665/* 666 * Scan a report descriptor before the device is added to the bus. 667 * Sets device groups and other properties that determine what driver 668 * to load. 669 */ 670static int hid_scan_report(struct hid_device *hid) 671{ 672 unsigned int page = 0, delim = 0; 673 __u8 *start = hid->dev_rdesc; 674 __u8 *end = start + hid->dev_rsize; 675 unsigned int u, u_min = 0, u_max = 0; 676 struct hid_item item; 677 678 hid->group = HID_GROUP_GENERIC; 679 while ((start = fetch_item(start, end, &item)) != NULL) { 680 if (item.format != HID_ITEM_FORMAT_SHORT) 681 return -EINVAL; 682 if (item.type == HID_ITEM_TYPE_GLOBAL) { 683 if (item.tag == HID_GLOBAL_ITEM_TAG_USAGE_PAGE) 684 page = item_udata(&item) << 16; 685 } else if (item.type == HID_ITEM_TYPE_LOCAL) { 686 if (delim > 1) 687 break; 688 u = item_udata(&item); 689 if (item.size <= 2) 690 u += page; 691 switch (item.tag) { 692 case HID_LOCAL_ITEM_TAG_DELIMITER: 693 delim += !!u; 694 break; 695 case HID_LOCAL_ITEM_TAG_USAGE: 696 hid_scan_usage(hid, u); 697 break; 698 case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: 699 u_min = u; 700 break; 701 case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: 702 u_max = u; 703 for (u = u_min; u <= u_max; u++) 704 hid_scan_usage(hid, u); 705 break; 706 } 707 } 708 } 709 710 return 0; 711} 712 713/** 714 * hid_parse_report - parse device report 715 * 716 * @device: hid device 717 * @start: report start 718 * @size: report size 719 * 720 * Allocate the device report as read by the bus driver. This function should 721 * only be called from parse() in ll drivers. 722 */ 723int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size) 724{ 725 hid->dev_rdesc = kmemdup(start, size, GFP_KERNEL); 726 if (!hid->dev_rdesc) 727 return -ENOMEM; 728 hid->dev_rsize = size; 729 return 0; 730} 731EXPORT_SYMBOL_GPL(hid_parse_report); 732 733/** 734 * hid_open_report - open a driver-specific device report 735 * 736 * @device: hid device 737 * 738 * Parse a report description into a hid_device structure. Reports are 739 * enumerated, fields are attached to these reports. 740 * 0 returned on success, otherwise nonzero error value. 741 * 742 * This function (or the equivalent hid_parse() macro) should only be 743 * called from probe() in drivers, before starting the device. 744 */ 745int hid_open_report(struct hid_device *device) 746{ 747 struct hid_parser *parser; 748 struct hid_item item; 749 unsigned int size; 750 __u8 *start; 751 __u8 *end; 752 int ret; 753 static int (*dispatch_type[])(struct hid_parser *parser, 754 struct hid_item *item) = { 755 hid_parser_main, 756 hid_parser_global, 757 hid_parser_local, 758 hid_parser_reserved 759 }; 760 761 if (WARN_ON(device->status & HID_STAT_PARSED)) 762 return -EBUSY; 763 764 start = device->dev_rdesc; 765 if (WARN_ON(!start)) 766 return -ENODEV; 767 size = device->dev_rsize; 768 769 if (device->driver->report_fixup) 770 start = device->driver->report_fixup(device, start, &size); 771 772 device->rdesc = kmemdup(start, size, GFP_KERNEL); 773 if (device->rdesc == NULL) 774 return -ENOMEM; 775 device->rsize = size; 776 777 parser = vzalloc(sizeof(struct hid_parser)); 778 if (!parser) { 779 ret = -ENOMEM; 780 goto err; 781 } 782 783 parser->device = device; 784 785 end = start + size; 786 787 device->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, 788 sizeof(struct hid_collection), GFP_KERNEL); 789 if (!device->collection) { 790 ret = -ENOMEM; 791 goto err; 792 } 793 device->collection_size = HID_DEFAULT_NUM_COLLECTIONS; 794 795 ret = -EINVAL; 796 while ((start = fetch_item(start, end, &item)) != NULL) { 797 798 if (item.format != HID_ITEM_FORMAT_SHORT) { 799 hid_err(device, "unexpected long global item\n"); 800 goto err; 801 } 802 803 if (dispatch_type[item.type](parser, &item)) { 804 hid_err(device, "item %u %u %u %u parsing failed\n", 805 item.format, (unsigned)item.size, 806 (unsigned)item.type, (unsigned)item.tag); 807 goto err; 808 } 809 810 if (start == end) { 811 if (parser->collection_stack_ptr) { 812 hid_err(device, "unbalanced collection at end of report description\n"); 813 goto err; 814 } 815 if (parser->local.delimiter_depth) { 816 hid_err(device, "unbalanced delimiter at end of report description\n"); 817 goto err; 818 } 819 vfree(parser); 820 device->status |= HID_STAT_PARSED; 821 return 0; 822 } 823 } 824 825 hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); 826err: 827 vfree(parser); 828 hid_close_report(device); 829 return ret; 830} 831EXPORT_SYMBOL_GPL(hid_open_report); 832 833/* 834 * Convert a signed n-bit integer to signed 32-bit integer. Common 835 * cases are done through the compiler, the screwed things has to be 836 * done by hand. 837 */ 838 839static s32 snto32(__u32 value, unsigned n) 840{ 841 switch (n) { 842 case 8: return ((__s8)value); 843 case 16: return ((__s16)value); 844 case 32: return ((__s32)value); 845 } 846 return value & (1 << (n - 1)) ? value | (-1 << n) : value; 847} 848 849/* 850 * Convert a signed 32-bit integer to a signed n-bit integer. 851 */ 852 853static u32 s32ton(__s32 value, unsigned n) 854{ 855 s32 a = value >> (n - 1); 856 if (a && a != -1) 857 return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; 858 return value & ((1 << n) - 1); 859} 860 861/* 862 * Extract/implement a data field from/to a little endian report (bit array). 863 * 864 * Code sort-of follows HID spec: 865 * http://www.usb.org/developers/devclass_docs/HID1_11.pdf 866 * 867 * While the USB HID spec allows unlimited length bit fields in "report 868 * descriptors", most devices never use more than 16 bits. 869 * One model of UPS is claimed to report "LINEV" as a 32-bit field. 870 * Search linux-kernel and linux-usb-devel archives for "hid-core extract". 871 */ 872 873static __u32 extract(const struct hid_device *hid, __u8 *report, 874 unsigned offset, unsigned n) 875{ 876 u64 x; 877 878 if (n > 32) 879 hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n", 880 n, current->comm); 881 882 report += offset >> 3; /* adjust byte index */ 883 offset &= 7; /* now only need bit offset into one byte */ 884 x = get_unaligned_le64(report); 885 x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ 886 return (u32) x; 887} 888 889/* 890 * "implement" : set bits in a little endian bit stream. 891 * Same concepts as "extract" (see comments above). 892 * The data mangled in the bit stream remains in little endian 893 * order the whole time. It make more sense to talk about 894 * endianness of register values by considering a register 895 * a "cached" copy of the little endiad bit stream. 896 */ 897static void implement(const struct hid_device *hid, __u8 *report, 898 unsigned offset, unsigned n, __u32 value) 899{ 900 u64 x; 901 u64 m = (1ULL << n) - 1; 902 903 if (n > 32) 904 hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n", 905 __func__, n, current->comm); 906 907 if (value > m) 908 hid_warn(hid, "%s() called with too large value %d! (%s)\n", 909 __func__, value, current->comm); 910 WARN_ON(value > m); 911 value &= m; 912 913 report += offset >> 3; 914 offset &= 7; 915 916 x = get_unaligned_le64(report); 917 x &= ~(m << offset); 918 x |= ((u64)value) << offset; 919 put_unaligned_le64(x, report); 920} 921 922/* 923 * Search an array for a value. 924 */ 925 926static int search(__s32 *array, __s32 value, unsigned n) 927{ 928 while (n--) { 929 if (*array++ == value) 930 return 0; 931 } 932 return -1; 933} 934 935/** 936 * hid_match_report - check if driver's raw_event should be called 937 * 938 * @hid: hid device 939 * @report_type: type to match against 940 * 941 * compare hid->driver->report_table->report_type to report->type 942 */ 943static int hid_match_report(struct hid_device *hid, struct hid_report *report) 944{ 945 const struct hid_report_id *id = hid->driver->report_table; 946 947 if (!id) /* NULL means all */ 948 return 1; 949 950 for (; id->report_type != HID_TERMINATOR; id++) 951 if (id->report_type == HID_ANY_ID || 952 id->report_type == report->type) 953 return 1; 954 return 0; 955} 956 957/** 958 * hid_match_usage - check if driver's event should be called 959 * 960 * @hid: hid device 961 * @usage: usage to match against 962 * 963 * compare hid->driver->usage_table->usage_{type,code} to 964 * usage->usage_{type,code} 965 */ 966static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage) 967{ 968 const struct hid_usage_id *id = hid->driver->usage_table; 969 970 if (!id) /* NULL means all */ 971 return 1; 972 973 for (; id->usage_type != HID_ANY_ID - 1; id++) 974 if ((id->usage_hid == HID_ANY_ID || 975 id->usage_hid == usage->hid) && 976 (id->usage_type == HID_ANY_ID || 977 id->usage_type == usage->type) && 978 (id->usage_code == HID_ANY_ID || 979 id->usage_code == usage->code)) 980 return 1; 981 return 0; 982} 983 984static void hid_process_event(struct hid_device *hid, struct hid_field *field, 985 struct hid_usage *usage, __s32 value, int interrupt) 986{ 987 struct hid_driver *hdrv = hid->driver; 988 int ret; 989 990 hid_dump_input(hid, usage, value); 991 992 if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { 993 ret = hdrv->event(hid, field, usage, value); 994 if (ret != 0) { 995 if (ret < 0) 996 hid_err(hid, "%s's event failed with %d\n", 997 hdrv->name, ret); 998 return; 999 } 1000 } 1001 1002 if (hid->claimed & HID_CLAIMED_INPUT) 1003 hidinput_hid_event(hid, field, usage, value); 1004 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) 1005 hid->hiddev_hid_event(hid, field, usage, value); 1006} 1007 1008/* 1009 * Analyse a received field, and fetch the data from it. The field 1010 * content is stored for next report processing (we do differential 1011 * reporting to the layer). 1012 */ 1013 1014static void hid_input_field(struct hid_device *hid, struct hid_field *field, 1015 __u8 *data, int interrupt) 1016{ 1017 unsigned n; 1018 unsigned count = field->report_count; 1019 unsigned offset = field->report_offset; 1020 unsigned size = field->report_size; 1021 __s32 min = field->logical_minimum; 1022 __s32 max = field->logical_maximum; 1023 __s32 *value; 1024 1025 value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC); 1026 if (!value) 1027 return; 1028 1029 for (n = 0; n < count; n++) { 1030 1031 value[n] = min < 0 ? 1032 snto32(extract(hid, data, offset + n * size, size), 1033 size) : 1034 extract(hid, data, offset + n * size, size); 1035 1036 /* Ignore report if ErrorRollOver */ 1037 if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && 1038 value[n] >= min && value[n] <= max && 1039 field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) 1040 goto exit; 1041 } 1042 1043 for (n = 0; n < count; n++) { 1044 1045 if (HID_MAIN_ITEM_VARIABLE & field->flags) { 1046 hid_process_event(hid, field, &field->usage[n], value[n], interrupt); 1047 continue; 1048 } 1049 1050 if (field->value[n] >= min && field->value[n] <= max 1051 && field->usage[field->value[n] - min].hid 1052 && search(value, field->value[n], count)) 1053 hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); 1054 1055 if (value[n] >= min && value[n] <= max 1056 && field->usage[value[n] - min].hid 1057 && search(field->value, value[n], count)) 1058 hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); 1059 } 1060 1061 memcpy(field->value, value, count * sizeof(__s32)); 1062exit: 1063 kfree(value); 1064} 1065 1066/* 1067 * Output the field into the report. 1068 */ 1069 1070static void hid_output_field(const struct hid_device *hid, 1071 struct hid_field *field, __u8 *data) 1072{ 1073 unsigned count = field->report_count; 1074 unsigned offset = field->report_offset; 1075 unsigned size = field->report_size; 1076 unsigned n; 1077 1078 for (n = 0; n < count; n++) { 1079 if (field->logical_minimum < 0) /* signed values */ 1080 implement(hid, data, offset + n * size, size, 1081 s32ton(field->value[n], size)); 1082 else /* unsigned values */ 1083 implement(hid, data, offset + n * size, size, 1084 field->value[n]); 1085 } 1086} 1087 1088/* 1089 * Create a report. 1090 */ 1091 1092void hid_output_report(struct hid_report *report, __u8 *data) 1093{ 1094 unsigned n; 1095 1096 if (report->id > 0) 1097 *data++ = report->id; 1098 1099 memset(data, 0, ((report->size - 1) >> 3) + 1); 1100 for (n = 0; n < report->maxfield; n++) 1101 hid_output_field(report->device, report->field[n], data); 1102} 1103EXPORT_SYMBOL_GPL(hid_output_report); 1104 1105/* 1106 * Set a field value. The report this field belongs to has to be 1107 * created and transferred to the device, to set this value in the 1108 * device. 1109 */ 1110 1111int hid_set_field(struct hid_field *field, unsigned offset, __s32 value) 1112{ 1113 unsigned size = field->report_size; 1114 1115 hid_dump_input(field->report->device, field->usage + offset, value); 1116 1117 if (offset >= field->report_count) { 1118 hid_err(field->report->device, "offset (%d) exceeds report_count (%d)\n", 1119 offset, field->report_count); 1120 return -1; 1121 } 1122 if (field->logical_minimum < 0) { 1123 if (value != snto32(s32ton(value, size), size)) { 1124 hid_err(field->report->device, "value %d is out of range\n", value); 1125 return -1; 1126 } 1127 } 1128 field->value[offset] = value; 1129 return 0; 1130} 1131EXPORT_SYMBOL_GPL(hid_set_field); 1132 1133static struct hid_report *hid_get_report(struct hid_report_enum *report_enum, 1134 const u8 *data) 1135{ 1136 struct hid_report *report; 1137 unsigned int n = 0; /* Normally report number is 0 */ 1138 1139 /* Device uses numbered reports, data[0] is report number */ 1140 if (report_enum->numbered) 1141 n = *data; 1142 1143 report = report_enum->report_id_hash[n]; 1144 if (report == NULL) 1145 dbg_hid("undefined report_id %u received\n", n); 1146 1147 return report; 1148} 1149 1150void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, 1151 int interrupt) 1152{ 1153 struct hid_report_enum *report_enum = hid->report_enum + type; 1154 struct hid_report *report; 1155 unsigned int a; 1156 int rsize, csize = size; 1157 u8 *cdata = data; 1158 1159 report = hid_get_report(report_enum, data); 1160 if (!report) 1161 return; 1162 1163 if (report_enum->numbered) { 1164 cdata++; 1165 csize--; 1166 } 1167 1168 rsize = ((report->size - 1) >> 3) + 1; 1169 1170 if (rsize > HID_MAX_BUFFER_SIZE) 1171 rsize = HID_MAX_BUFFER_SIZE; 1172 1173 if (csize < rsize) { 1174 dbg_hid("report %d is too short, (%d < %d)\n", report->id, 1175 csize, rsize); 1176 memset(cdata + csize, 0, rsize - csize); 1177 } 1178 1179 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) 1180 hid->hiddev_report_event(hid, report); 1181 if (hid->claimed & HID_CLAIMED_HIDRAW) 1182 hidraw_report_event(hid, data, size); 1183 1184 for (a = 0; a < report->maxfield; a++) 1185 hid_input_field(hid, report->field[a], cdata, interrupt); 1186 1187 if (hid->claimed & HID_CLAIMED_INPUT) 1188 hidinput_report_event(hid, report); 1189} 1190EXPORT_SYMBOL_GPL(hid_report_raw_event); 1191 1192/** 1193 * hid_input_report - report data from lower layer (usb, bt...) 1194 * 1195 * @hid: hid device 1196 * @type: HID report type (HID_*_REPORT) 1197 * @data: report contents 1198 * @size: size of data parameter 1199 * @interrupt: distinguish between interrupt and control transfers 1200 * 1201 * This is data entry for lower layers. 1202 */ 1203int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) 1204{ 1205 struct hid_report_enum *report_enum; 1206 struct hid_driver *hdrv; 1207 struct hid_report *report; 1208 char *buf; 1209 unsigned int i; 1210 int ret = 0; 1211 1212 if (!hid) 1213 return -ENODEV; 1214 1215 if (down_trylock(&hid->driver_lock)) 1216 return -EBUSY; 1217 1218 if (!hid->driver) { 1219 ret = -ENODEV; 1220 goto unlock; 1221 } 1222 report_enum = hid->report_enum + type; 1223 hdrv = hid->driver; 1224 1225 if (!size) { 1226 dbg_hid("empty report\n"); 1227 ret = -1; 1228 goto unlock; 1229 } 1230 1231 buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC); 1232 1233 if (!buf) 1234 goto nomem; 1235 1236 /* dump the report */ 1237 snprintf(buf, HID_DEBUG_BUFSIZE - 1, 1238 "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un"); 1239 hid_debug_event(hid, buf); 1240 1241 for (i = 0; i < size; i++) { 1242 snprintf(buf, HID_DEBUG_BUFSIZE - 1, 1243 " %02x", data[i]); 1244 hid_debug_event(hid, buf); 1245 } 1246 hid_debug_event(hid, "\n"); 1247 kfree(buf); 1248 1249nomem: 1250 report = hid_get_report(report_enum, data); 1251 1252 if (!report) { 1253 ret = -1; 1254 goto unlock; 1255 } 1256 1257 if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { 1258 ret = hdrv->raw_event(hid, report, data, size); 1259 if (ret != 0) { 1260 ret = ret < 0 ? ret : 0; 1261 goto unlock; 1262 } 1263 } 1264 1265 hid_report_raw_event(hid, type, data, size, interrupt); 1266 1267unlock: 1268 up(&hid->driver_lock); 1269 return ret; 1270} 1271EXPORT_SYMBOL_GPL(hid_input_report); 1272 1273static bool hid_match_one_id(struct hid_device *hdev, 1274 const struct hid_device_id *id) 1275{ 1276 return id->bus == hdev->bus && 1277 (id->group == HID_GROUP_ANY || id->group == hdev->group) && 1278 (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && 1279 (id->product == HID_ANY_ID || id->product == hdev->product); 1280} 1281 1282const struct hid_device_id *hid_match_id(struct hid_device *hdev, 1283 const struct hid_device_id *id) 1284{ 1285 for (; id->bus; id++) 1286 if (hid_match_one_id(hdev, id)) 1287 return id; 1288 1289 return NULL; 1290} 1291 1292static const struct hid_device_id hid_hiddev_list[] = { 1293 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, 1294 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, 1295 { } 1296}; 1297 1298static bool hid_hiddev(struct hid_device *hdev) 1299{ 1300 return !!hid_match_id(hdev, hid_hiddev_list); 1301} 1302 1303 1304static ssize_t 1305read_report_descriptor(struct file *filp, struct kobject *kobj, 1306 struct bin_attribute *attr, 1307 char *buf, loff_t off, size_t count) 1308{ 1309 struct device *dev = container_of(kobj, struct device, kobj); 1310 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1311 1312 if (off >= hdev->rsize) 1313 return 0; 1314 1315 if (off + count > hdev->rsize) 1316 count = hdev->rsize - off; 1317 1318 memcpy(buf, hdev->rdesc + off, count); 1319 1320 return count; 1321} 1322 1323static struct bin_attribute dev_bin_attr_report_desc = { 1324 .attr = { .name = "report_descriptor", .mode = 0444 }, 1325 .read = read_report_descriptor, 1326 .size = HID_MAX_DESCRIPTOR_SIZE, 1327}; 1328 1329int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 1330{ 1331 static const char *types[] = { "Device", "Pointer", "Mouse", "Device", 1332 "Joystick", "Gamepad", "Keyboard", "Keypad", 1333 "Multi-Axis Controller" 1334 }; 1335 const char *type, *bus; 1336 char buf[64]; 1337 unsigned int i; 1338 int len; 1339 int ret; 1340 1341 if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) 1342 connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV); 1343 if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE) 1344 connect_mask |= HID_CONNECT_HIDINPUT_FORCE; 1345 if (hdev->bus != BUS_USB) 1346 connect_mask &= ~HID_CONNECT_HIDDEV; 1347 if (hid_hiddev(hdev)) 1348 connect_mask |= HID_CONNECT_HIDDEV_FORCE; 1349 1350 if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev, 1351 connect_mask & HID_CONNECT_HIDINPUT_FORCE)) 1352 hdev->claimed |= HID_CLAIMED_INPUT; 1353 if (hdev->quirks & HID_QUIRK_MULTITOUCH) { 1354 /* this device should be handled by hid-multitouch, skip it */ 1355 return -ENODEV; 1356 } 1357 1358 if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect && 1359 !hdev->hiddev_connect(hdev, 1360 connect_mask & HID_CONNECT_HIDDEV_FORCE)) 1361 hdev->claimed |= HID_CLAIMED_HIDDEV; 1362 if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev)) 1363 hdev->claimed |= HID_CLAIMED_HIDRAW; 1364 1365 if (!hdev->claimed) { 1366 hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n"); 1367 return -ENODEV; 1368 } 1369 1370 if ((hdev->claimed & HID_CLAIMED_INPUT) && 1371 (connect_mask & HID_CONNECT_FF) && hdev->ff_init) 1372 hdev->ff_init(hdev); 1373 1374 len = 0; 1375 if (hdev->claimed & HID_CLAIMED_INPUT) 1376 len += sprintf(buf + len, "input"); 1377 if (hdev->claimed & HID_CLAIMED_HIDDEV) 1378 len += sprintf(buf + len, "%shiddev%d", len ? "," : "", 1379 hdev->minor); 1380 if (hdev->claimed & HID_CLAIMED_HIDRAW) 1381 len += sprintf(buf + len, "%shidraw%d", len ? "," : "", 1382 ((struct hidraw *)hdev->hidraw)->minor); 1383 1384 type = "Device"; 1385 for (i = 0; i < hdev->maxcollection; i++) { 1386 struct hid_collection *col = &hdev->collection[i]; 1387 if (col->type == HID_COLLECTION_APPLICATION && 1388 (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK && 1389 (col->usage & 0xffff) < ARRAY_SIZE(types)) { 1390 type = types[col->usage & 0xffff]; 1391 break; 1392 } 1393 } 1394 1395 switch (hdev->bus) { 1396 case BUS_USB: 1397 bus = "USB"; 1398 break; 1399 case BUS_BLUETOOTH: 1400 bus = "BLUETOOTH"; 1401 break; 1402 default: 1403 bus = "<UNKNOWN>"; 1404 } 1405 1406 ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc); 1407 if (ret) 1408 hid_warn(hdev, 1409 "can't create sysfs report descriptor attribute err: %d\n", ret); 1410 1411 hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", 1412 buf, bus, hdev->version >> 8, hdev->version & 0xff, 1413 type, hdev->name, hdev->phys); 1414 1415 return 0; 1416} 1417EXPORT_SYMBOL_GPL(hid_connect); 1418 1419void hid_disconnect(struct hid_device *hdev) 1420{ 1421 device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc); 1422 if (hdev->claimed & HID_CLAIMED_INPUT) 1423 hidinput_disconnect(hdev); 1424 if (hdev->claimed & HID_CLAIMED_HIDDEV) 1425 hdev->hiddev_disconnect(hdev); 1426 if (hdev->claimed & HID_CLAIMED_HIDRAW) 1427 hidraw_disconnect(hdev); 1428} 1429EXPORT_SYMBOL_GPL(hid_disconnect); 1430 1431/* a list of devices for which there is a specialized driver on HID bus */ 1432static const struct hid_device_id hid_have_special_driver[] = { 1433 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, 1434 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, 1435 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 1436 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1437 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, 1438 { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) }, 1439 { HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR, USB_DEVICE_ID_ACTIONSTAR_1011) }, 1440 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, 1441 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, 1442 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, 1443 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) }, 1444 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) }, 1445 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 1446 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 1447 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 1448 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 1449 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 1450 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 1451 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 1452 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 1453 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 1454 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 1455 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1456 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI) }, 1457 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO) }, 1458 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS) }, 1459 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) }, 1460 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) }, 1461 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) }, 1462 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 1463 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 1464 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1465 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, 1466 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, 1467 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, 1468 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 1469 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 1470 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 1471 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1472 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1473 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1474 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1475 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1476 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 1477 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 1478 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 1479 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 1480 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 1481 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 1482 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 1483 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, 1484 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, 1485 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, 1486 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) }, 1487 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) }, 1488 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) }, 1489 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) }, 1490 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) }, 1491 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) }, 1492 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) }, 1493 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) }, 1494 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) }, 1495 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 1496 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 1497 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 1498 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, 1499 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, 1500 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 1501 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) }, 1502 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1503 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1504 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) }, 1505 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, 1506 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1507 { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, 1508 { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, 1509 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, 1510 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, 1511 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) }, 1512 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, 1513 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, 1514 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 1515 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, 1516 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1517 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, 1518 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) }, 1519 { HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, 1520 { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, 1521 { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, USB_DEVICE_ID_CVTOUCH_SCREEN) }, 1522 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 1523 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, 1524 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) }, 1525 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, 1526 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, 1527 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, 1528 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) }, 1529 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) }, 1530 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) }, 1531 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) }, 1532 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) }, 1533 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) }, 1534 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) }, 1535 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) }, 1536 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) }, 1537 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) }, 1538 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 1539 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2515) }, 1540 { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) }, 1541 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 1542 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_FRUCTEL, USB_DEVICE_ID_GAMETEL_MT_MODE) }, 1543 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, 1544 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, 1545 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, 1546 { HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, USB_DEVICE_ID_GOODTOUCH_000f) }, 1547 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, 1548 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) }, 1549 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, 1550 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, 1551 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, 1552 { HID_USB_DEVICE(USB_VENDOR_ID_HANVON, USB_DEVICE_ID_HANVON_MULTITOUCH) }, 1553 { HID_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, 1554 { HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM, USB_DEVICE_ID_IDEACOM_IDC6650) }, 1555 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) }, 1556 { HID_USB_DEVICE(USB_VENDOR_ID_ILITEK, USB_DEVICE_ID_ILITEK_MULTITOUCH) }, 1557 { HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS, USB_DEVICE_ID_IRTOUCH_INFRARED_USB) }, 1558 { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, 1559 { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, 1560 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, 1561 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) }, 1562 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) }, 1563 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) }, 1564 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 1565 { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) }, 1566 { HID_USB_DEVICE(USB_VENDOR_ID_LG, USB_DEVICE_ID_LG_MULTITOUCH) }, 1567 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, 1568 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, 1569 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, 1570 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, 1571 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, 1572 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, 1573 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, 1574 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, 1575 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, 1576 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, 1577 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) }, 1578 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) }, 1579 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) }, 1580 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) }, 1581 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, 1582 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) }, 1583 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, 1584 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) }, 1585 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) }, 1586 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) }, 1587 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL) }, 1588 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL) }, 1589 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) }, 1590 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G27_WHEEL) }, 1591#if IS_ENABLED(CONFIG_HID_LOGITECH_DJ) 1592 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER) }, 1593 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2) }, 1594#endif 1595 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) }, 1596 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, 1597 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) }, 1598 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) }, 1599 { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH) }, 1600 { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH_DUAL) }, 1601 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, 1602 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) }, 1603 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) }, 1604 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, 1605 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, 1606 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, 1607 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, 1608 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) }, 1609 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 1610 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 1611 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, 1612 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) }, 1613 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) }, 1614 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) }, 1615 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) }, 1616 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) }, 1617 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) }, 1618 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) }, 1619 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) }, 1620 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) }, 1621 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) }, 1622 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) }, 1623 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) }, 1624 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) }, 1625 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) }, 1626 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) }, 1627 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) }, 1628 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) }, 1629 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) }, 1630 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) }, 1631 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, 1632 { HID_USB_DEVICE(USB_VENDOR_ID_PANASONIC, USB_DEVICE_ID_PANABOARD_UBT780) }, 1633 { HID_USB_DEVICE(USB_VENDOR_ID_PANASONIC, USB_DEVICE_ID_PANABOARD_UBT880) }, 1634 { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_PCI) }, 1635 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 1636 { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) }, 1637 { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) }, 1638 { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) }, 1639 { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) }, 1640 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, 1641 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, 1642 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, 1643 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) }, 1644 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) }, 1645 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, 1646 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) }, 1647 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, 1648 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) }, 1649 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000) }, 1650 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1651 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, 1652 { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) }, 1653 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1654 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) }, 1655 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1656 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1657 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) }, 1658 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) }, 1659 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) }, 1660 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1661 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1662 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, 1663 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, 1664 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) }, 1665 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, 1666 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) }, 1667 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, 1668 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) }, 1669 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_BT) }, 1670 { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE) }, 1671 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, 1672 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) }, 1673 { HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, 1674 { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, 1675 { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, 1676 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, 1677 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) }, 1678 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) }, 1679 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) }, 1680 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) }, 1681 { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, 1682 { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, 1683 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, 1684 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SUPER_JOY_BOX_3) }, 1685 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) }, 1686 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) }, 1687 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) }, 1688 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) }, 1689 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, 1690 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, 1691 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, 1692 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, 1693 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_Q_PAD) }, 1694 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_PID_0038) }, 1695 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, 1696 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, 1697 { HID_USB_DEVICE(USB_VENDOR_ID_XAT, USB_DEVICE_ID_XAT_CSR) }, 1698 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX) }, 1699 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX) }, 1700 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR) }, 1701 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX1) }, 1702 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX1) }, 1703 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR1) }, 1704 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX2) }, 1705 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX2) }, 1706 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR2) }, 1707 { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) }, 1708 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, 1709 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, 1710 { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, 1711 1712 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, 1713 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) }, 1714 { } 1715}; 1716 1717struct hid_dynid { 1718 struct list_head list; 1719 struct hid_device_id id; 1720}; 1721 1722/** 1723 * store_new_id - add a new HID device ID to this driver and re-probe devices 1724 * @driver: target device driver 1725 * @buf: buffer for scanning device ID data 1726 * @count: input size 1727 * 1728 * Adds a new dynamic hid device ID to this driver, 1729 * and causes the driver to probe for all devices again. 1730 */ 1731static ssize_t store_new_id(struct device_driver *drv, const char *buf, 1732 size_t count) 1733{ 1734 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 1735 struct hid_dynid *dynid; 1736 __u32 bus, vendor, product; 1737 unsigned long driver_data = 0; 1738 int ret; 1739 1740 ret = sscanf(buf, "%x %x %x %lx", 1741 &bus, &vendor, &product, &driver_data); 1742 if (ret < 3) 1743 return -EINVAL; 1744 1745 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 1746 if (!dynid) 1747 return -ENOMEM; 1748 1749 dynid->id.bus = bus; 1750 dynid->id.group = HID_GROUP_ANY; 1751 dynid->id.vendor = vendor; 1752 dynid->id.product = product; 1753 dynid->id.driver_data = driver_data; 1754 1755 spin_lock(&hdrv->dyn_lock); 1756 list_add_tail(&dynid->list, &hdrv->dyn_list); 1757 spin_unlock(&hdrv->dyn_lock); 1758 1759 ret = driver_attach(&hdrv->driver); 1760 1761 return ret ? : count; 1762} 1763static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); 1764 1765static void hid_free_dynids(struct hid_driver *hdrv) 1766{ 1767 struct hid_dynid *dynid, *n; 1768 1769 spin_lock(&hdrv->dyn_lock); 1770 list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) { 1771 list_del(&dynid->list); 1772 kfree(dynid); 1773 } 1774 spin_unlock(&hdrv->dyn_lock); 1775} 1776 1777static const struct hid_device_id *hid_match_device(struct hid_device *hdev, 1778 struct hid_driver *hdrv) 1779{ 1780 struct hid_dynid *dynid; 1781 1782 spin_lock(&hdrv->dyn_lock); 1783 list_for_each_entry(dynid, &hdrv->dyn_list, list) { 1784 if (hid_match_one_id(hdev, &dynid->id)) { 1785 spin_unlock(&hdrv->dyn_lock); 1786 return &dynid->id; 1787 } 1788 } 1789 spin_unlock(&hdrv->dyn_lock); 1790 1791 return hid_match_id(hdev, hdrv->id_table); 1792} 1793 1794static int hid_bus_match(struct device *dev, struct device_driver *drv) 1795{ 1796 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 1797 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1798 1799 if ((hdev->quirks & HID_QUIRK_MULTITOUCH) && 1800 !strncmp(hdrv->name, "hid-multitouch", 14)) 1801 return 1; 1802 1803 if (!hid_match_device(hdev, hdrv)) 1804 return 0; 1805 1806 /* generic wants all that don't have specialized driver */ 1807 if (!strncmp(hdrv->name, "generic-", 8) && !hid_ignore_special_drivers) 1808 return !hid_match_id(hdev, hid_have_special_driver); 1809 1810 return 1; 1811} 1812 1813static int hid_device_probe(struct device *dev) 1814{ 1815 struct hid_driver *hdrv = container_of(dev->driver, 1816 struct hid_driver, driver); 1817 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1818 const struct hid_device_id *id; 1819 int ret = 0; 1820 1821 if (down_interruptible(&hdev->driver_lock)) 1822 return -EINTR; 1823 1824 if (!hdev->driver) { 1825 id = hid_match_device(hdev, hdrv); 1826 if (id == NULL) { 1827 if (!((hdev->quirks & HID_QUIRK_MULTITOUCH) && 1828 !strncmp(hdrv->name, "hid-multitouch", 14))) { 1829 ret = -ENODEV; 1830 goto unlock; 1831 } 1832 } 1833 1834 hdev->driver = hdrv; 1835 if (hdrv->probe) { 1836 ret = hdrv->probe(hdev, id); 1837 } else { /* default probe */ 1838 ret = hid_open_report(hdev); 1839 if (!ret) 1840 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 1841 } 1842 if (ret) { 1843 hid_close_report(hdev); 1844 hdev->driver = NULL; 1845 } 1846 } 1847unlock: 1848 up(&hdev->driver_lock); 1849 return ret; 1850} 1851 1852static int hid_device_remove(struct device *dev) 1853{ 1854 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1855 struct hid_driver *hdrv; 1856 1857 if (down_interruptible(&hdev->driver_lock)) 1858 return -EINTR; 1859 1860 hdrv = hdev->driver; 1861 if (hdrv) { 1862 if (hdrv->remove) 1863 hdrv->remove(hdev); 1864 else /* default remove */ 1865 hid_hw_stop(hdev); 1866 hid_close_report(hdev); 1867 hdev->driver = NULL; 1868 } 1869 1870 up(&hdev->driver_lock); 1871 return 0; 1872} 1873 1874static ssize_t modalias_show(struct device *dev, struct device_attribute *a, 1875 char *buf) 1876{ 1877 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1878 int len; 1879 1880 len = snprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n", 1881 hdev->bus, hdev->group, hdev->vendor, hdev->product); 1882 1883 return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; 1884} 1885 1886static struct device_attribute hid_dev_attrs[] = { 1887 __ATTR_RO(modalias), 1888 __ATTR_NULL, 1889}; 1890 1891static int hid_uevent(struct device *dev, struct kobj_uevent_env *env) 1892{ 1893 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1894 1895 if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", 1896 hdev->bus, hdev->vendor, hdev->product)) 1897 return -ENOMEM; 1898 1899 if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) 1900 return -ENOMEM; 1901 1902 if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) 1903 return -ENOMEM; 1904 1905 if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) 1906 return -ENOMEM; 1907 1908 if (add_uevent_var(env, "MODALIAS=hid:b%04Xg%04Xv%08Xp%08X", 1909 hdev->bus, hdev->group, hdev->vendor, hdev->product)) 1910 return -ENOMEM; 1911 1912 return 0; 1913} 1914 1915static struct bus_type hid_bus_type = { 1916 .name = "hid", 1917 .dev_attrs = hid_dev_attrs, 1918 .match = hid_bus_match, 1919 .probe = hid_device_probe, 1920 .remove = hid_device_remove, 1921 .uevent = hid_uevent, 1922}; 1923 1924/* a list of devices that shouldn't be handled by HID core at all */ 1925static const struct hid_device_id hid_ignore_list[] = { 1926 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, 1927 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, 1928 { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, 1929 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, 1930 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, 1931 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, 1932 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, 1933 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, 1934 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, 1935 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, 1936 { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, 1937 { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, 1938 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)}, 1939 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)}, 1940 { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, 1941 { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, 1942 { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, 1943 { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, 1944 { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, 1945 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, 1946 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, 1947 { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) }, 1948 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, 1949 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 1950 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) }, 1951 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x000a) }, 1952 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 1953 { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) }, 1954 { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) }, 1955 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, 1956 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 1957 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, 1958 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, 1959 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, 1960 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, 1961 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, 1962 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, 1963 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, 1964 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, 1965 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, 1966 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, 1967 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, 1968 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, 1969 { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, 1970 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, 1971 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, 1972 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, 1973 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, 1974 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, 1975 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, 1976 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, 1977 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, 1978 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, 1979 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, 1980 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, 1981 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, 1982 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, 1983 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, 1984 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, 1985 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, 1986 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, 1987 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, 1988 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, 1989 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, 1990 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, 1991 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, 1992 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, 1993 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, 1994 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, 1995 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, 1996 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, 1997 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, 1998 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, 1999 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, 2000 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, 2001 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, 2002 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, 2003 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, 2004 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, 2005 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, 2006 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, 2007 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, 2008 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, 2009 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, 2010 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, 2011 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, 2012 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, 2013 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, 2014 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, 2015 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, 2016 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, 2017 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, 2018 { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, 2019 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, 2020 { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, 2021 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, 2022 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) }, 2023 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, 2024 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) }, 2025 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, 2026 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) }, 2027 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, 2028 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) }, 2029 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) }, 2030 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) }, 2031 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, 2032 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, 2033 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, 2034 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, 2035 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, 2036 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, 2037 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) }, 2038 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) }, 2039 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) }, 2040 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, 2041 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, 2042 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) }, 2043 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, 2044 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, 2045 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, 2046 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, 2047 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, 2048 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) }, 2049 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) }, 2050 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) }, 2051 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) }, 2052 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) }, 2053 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) }, 2054 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) }, 2055 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, 2056 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, 2057 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, 2058 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, 2059 { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, 2060 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, 2061 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, 2062 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, 2063 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, 2064 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, 2065 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, 2066 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, 2067 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, 2068 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, 2069 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, 2070 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, 2071 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, 2072 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, 2073 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, 2074 { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, 2075 { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, 2076#if defined(CONFIG_MOUSE_SYNAPTICS_USB) || defined(CONFIG_MOUSE_SYNAPTICS_USB_MODULE) 2077 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP) }, 2078 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_INT_TP) }, 2079 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_CPAD) }, 2080 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_STICK) }, 2081 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WP) }, 2082 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_COMP_TP) }, 2083 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WTP) }, 2084 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DPAD) }, 2085#endif 2086 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, 2087 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 2088 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 2089 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 2090 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 2091 { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, 2092 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, 2093 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, 2094 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, 2095 { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, 2096 { } 2097}; 2098 2099/** 2100 * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer 2101 * 2102 * There are composite devices for which we want to ignore only a certain 2103 * interface. This is a list of devices for which only the mouse interface will 2104 * be ignored. This allows a dedicated driver to take care of the interface. 2105 */ 2106static const struct hid_device_id hid_mouse_ignore_list[] = { 2107 /* appletouch driver */ 2108 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 2109 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 2110 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 2111 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 2112 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 2113 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 2114 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 2115 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 2116 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 2117 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 2118 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 2119 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 2120 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 2121 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 2122 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 2123 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 2124 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 2125 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 2126 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 2127 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 2128 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 2129 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 2130 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 2131 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 2132 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 2133 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 2134 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 2135 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 2136 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 2137 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, 2138 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, 2139 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, 2140 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) }, 2141 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) }, 2142 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) }, 2143 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) }, 2144 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) }, 2145 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) }, 2146 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 2147 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 2148 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 2149 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 2150 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 2151 { } 2152}; 2153 2154static bool hid_ignore(struct hid_device *hdev) 2155{ 2156 switch (hdev->vendor) { 2157 case USB_VENDOR_ID_CODEMERCS: 2158 /* ignore all Code Mercenaries IOWarrior devices */ 2159 if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && 2160 hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) 2161 return true; 2162 break; 2163 case USB_VENDOR_ID_LOGITECH: 2164 if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && 2165 hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) 2166 return true; 2167 /* 2168 * The Keene FM transmitter USB device has the same USB ID as 2169 * the Logitech AudioHub Speaker, but it should ignore the hid. 2170 * Check if the name is that of the Keene device. 2171 * For reference: the name of the AudioHub is 2172 * "HOLTEK AudioHub Speaker". 2173 */ 2174 if (hdev->product == USB_DEVICE_ID_LOGITECH_AUDIOHUB && 2175 !strcmp(hdev->name, "HOLTEK B-LINK USB Audio ")) 2176 return true; 2177 break; 2178 case USB_VENDOR_ID_SOUNDGRAPH: 2179 if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST && 2180 hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST) 2181 return true; 2182 break; 2183 case USB_VENDOR_ID_HANWANG: 2184 if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST && 2185 hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST) 2186 return true; 2187 break; 2188 case USB_VENDOR_ID_JESS: 2189 if (hdev->product == USB_DEVICE_ID_JESS_YUREX && 2190 hdev->type == HID_TYPE_USBNONE) 2191 return true; 2192 break; 2193 } 2194 2195 if (hdev->type == HID_TYPE_USBMOUSE && 2196 hid_match_id(hdev, hid_mouse_ignore_list)) 2197 return true; 2198 2199 return !!hid_match_id(hdev, hid_ignore_list); 2200} 2201 2202int hid_add_device(struct hid_device *hdev) 2203{ 2204 static atomic_t id = ATOMIC_INIT(0); 2205 int ret; 2206 2207 if (WARN_ON(hdev->status & HID_STAT_ADDED)) 2208 return -EBUSY; 2209 2210 /* we need to kill them here, otherwise they will stay allocated to 2211 * wait for coming driver */ 2212 if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) 2213 && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE))) 2214 return -ENODEV; 2215 2216 /* 2217 * Read the device report descriptor once and use as template 2218 * for the driver-specific modifications. 2219 */ 2220 ret = hdev->ll_driver->parse(hdev); 2221 if (ret) 2222 return ret; 2223 if (!hdev->dev_rdesc) 2224 return -ENODEV; 2225 2226 /* 2227 * Scan generic devices for group information 2228 */ 2229 if (hid_ignore_special_drivers || 2230 !hid_match_id(hdev, hid_have_special_driver)) { 2231 ret = hid_scan_report(hdev); 2232 if (ret) 2233 hid_warn(hdev, "bad device descriptor (%d)\n", ret); 2234 } 2235 2236 /* XXX hack, any other cleaner solution after the driver core 2237 * is converted to allow more than 20 bytes as the device name? */ 2238 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, 2239 hdev->vendor, hdev->product, atomic_inc_return(&id)); 2240 2241 hid_debug_register(hdev, dev_name(&hdev->dev)); 2242 ret = device_add(&hdev->dev); 2243 if (!ret) 2244 hdev->status |= HID_STAT_ADDED; 2245 else 2246 hid_debug_unregister(hdev); 2247 2248 return ret; 2249} 2250EXPORT_SYMBOL_GPL(hid_add_device); 2251 2252/** 2253 * hid_allocate_device - allocate new hid device descriptor 2254 * 2255 * Allocate and initialize hid device, so that hid_destroy_device might be 2256 * used to free it. 2257 * 2258 * New hid_device pointer is returned on success, otherwise ERR_PTR encoded 2259 * error value. 2260 */ 2261struct hid_device *hid_allocate_device(void) 2262{ 2263 struct hid_device *hdev; 2264 int ret = -ENOMEM; 2265 2266 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); 2267 if (hdev == NULL) 2268 return ERR_PTR(ret); 2269 2270 device_initialize(&hdev->dev); 2271 hdev->dev.release = hid_device_release; 2272 hdev->dev.bus = &hid_bus_type; 2273 2274 hid_close_report(hdev); 2275 2276 init_waitqueue_head(&hdev->debug_wait); 2277 INIT_LIST_HEAD(&hdev->debug_list); 2278 sema_init(&hdev->driver_lock, 1); 2279 2280 return hdev; 2281} 2282EXPORT_SYMBOL_GPL(hid_allocate_device); 2283 2284static void hid_remove_device(struct hid_device *hdev) 2285{ 2286 if (hdev->status & HID_STAT_ADDED) { 2287 device_del(&hdev->dev); 2288 hid_debug_unregister(hdev); 2289 hdev->status &= ~HID_STAT_ADDED; 2290 } 2291 kfree(hdev->dev_rdesc); 2292 hdev->dev_rdesc = NULL; 2293 hdev->dev_rsize = 0; 2294} 2295 2296/** 2297 * hid_destroy_device - free previously allocated device 2298 * 2299 * @hdev: hid device 2300 * 2301 * If you allocate hid_device through hid_allocate_device, you should ever 2302 * free by this function. 2303 */ 2304void hid_destroy_device(struct hid_device *hdev) 2305{ 2306 hid_remove_device(hdev); 2307 put_device(&hdev->dev); 2308} 2309EXPORT_SYMBOL_GPL(hid_destroy_device); 2310 2311int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, 2312 const char *mod_name) 2313{ 2314 int ret; 2315 2316 hdrv->driver.name = hdrv->name; 2317 hdrv->driver.bus = &hid_bus_type; 2318 hdrv->driver.owner = owner; 2319 hdrv->driver.mod_name = mod_name; 2320 2321 INIT_LIST_HEAD(&hdrv->dyn_list); 2322 spin_lock_init(&hdrv->dyn_lock); 2323 2324 ret = driver_register(&hdrv->driver); 2325 if (ret) 2326 return ret; 2327 2328 ret = driver_create_file(&hdrv->driver, &driver_attr_new_id); 2329 if (ret) 2330 driver_unregister(&hdrv->driver); 2331 2332 return ret; 2333} 2334EXPORT_SYMBOL_GPL(__hid_register_driver); 2335 2336void hid_unregister_driver(struct hid_driver *hdrv) 2337{ 2338 driver_remove_file(&hdrv->driver, &driver_attr_new_id); 2339 driver_unregister(&hdrv->driver); 2340 hid_free_dynids(hdrv); 2341} 2342EXPORT_SYMBOL_GPL(hid_unregister_driver); 2343 2344int hid_check_keys_pressed(struct hid_device *hid) 2345{ 2346 struct hid_input *hidinput; 2347 int i; 2348 2349 if (!(hid->claimed & HID_CLAIMED_INPUT)) 2350 return 0; 2351 2352 list_for_each_entry(hidinput, &hid->inputs, list) { 2353 for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++) 2354 if (hidinput->input->key[i]) 2355 return 1; 2356 } 2357 2358 return 0; 2359} 2360 2361EXPORT_SYMBOL_GPL(hid_check_keys_pressed); 2362 2363static int __init hid_init(void) 2364{ 2365 int ret; 2366 2367 if (hid_debug) 2368 pr_warn("hid_debug is now used solely for parser and driver debugging.\n" 2369 "debugfs is now used for inspecting the device (report descriptor, reports)\n"); 2370 2371 ret = bus_register(&hid_bus_type); 2372 if (ret) { 2373 pr_err("can't register hid bus\n"); 2374 goto err; 2375 } 2376 2377 ret = hidraw_init(); 2378 if (ret) 2379 goto err_bus; 2380 2381 hid_debug_init(); 2382 2383 return 0; 2384err_bus: 2385 bus_unregister(&hid_bus_type); 2386err: 2387 return ret; 2388} 2389 2390static void __exit hid_exit(void) 2391{ 2392 hid_debug_exit(); 2393 hidraw_exit(); 2394 bus_unregister(&hid_bus_type); 2395} 2396 2397module_init(hid_init); 2398module_exit(hid_exit); 2399 2400MODULE_AUTHOR("Andreas Gal"); 2401MODULE_AUTHOR("Vojtech Pavlik"); 2402MODULE_AUTHOR("Jiri Kosina"); 2403MODULE_LICENSE(DRIVER_LICENSE); 2404 2405