1dde5845aSJiri Kosina /* 2229695e5SJiri Kosina * HID support for Linux 3dde5845aSJiri Kosina * 4dde5845aSJiri Kosina * Copyright (c) 1999 Andreas Gal 5dde5845aSJiri Kosina * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 6dde5845aSJiri Kosina * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 76b1968d5SJiri Kosina * Copyright (c) 2006-2012 Jiri Kosina 8dde5845aSJiri Kosina */ 9dde5845aSJiri Kosina 10dde5845aSJiri Kosina /* 11dde5845aSJiri Kosina * This program is free software; you can redistribute it and/or modify it 12dde5845aSJiri Kosina * under the terms of the GNU General Public License as published by the Free 13dde5845aSJiri Kosina * Software Foundation; either version 2 of the License, or (at your option) 14dde5845aSJiri Kosina * any later version. 15dde5845aSJiri Kosina */ 16dde5845aSJiri Kosina 174291ee30SJoe Perches #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 184291ee30SJoe Perches 19dde5845aSJiri Kosina #include <linux/module.h> 20dde5845aSJiri Kosina #include <linux/slab.h> 21dde5845aSJiri Kosina #include <linux/init.h> 22dde5845aSJiri Kosina #include <linux/kernel.h> 23dde5845aSJiri Kosina #include <linux/list.h> 24dde5845aSJiri Kosina #include <linux/mm.h> 25dde5845aSJiri Kosina #include <linux/spinlock.h> 26dde5845aSJiri Kosina #include <asm/unaligned.h> 27dde5845aSJiri Kosina #include <asm/byteorder.h> 28dde5845aSJiri Kosina #include <linux/input.h> 29dde5845aSJiri Kosina #include <linux/wait.h> 3047a80edbSJiri Kosina #include <linux/vmalloc.h> 31c4124c9bSJiri Kosina #include <linux/sched.h> 324ea54542SDavid Herrmann #include <linux/semaphore.h> 33dde5845aSJiri Kosina 34dde5845aSJiri Kosina #include <linux/hid.h> 35dde5845aSJiri Kosina #include <linux/hiddev.h> 36c080d89aSJiri Kosina #include <linux/hid-debug.h> 3786166b7bSJiri Kosina #include <linux/hidraw.h> 38dde5845aSJiri Kosina 395f22a799SJiri Slaby #include "hid-ids.h" 405f22a799SJiri Slaby 41dde5845aSJiri Kosina /* 42dde5845aSJiri Kosina * Version Information 43dde5845aSJiri Kosina */ 44dde5845aSJiri Kosina 4553149801SJiri Kosina #define DRIVER_DESC "HID core driver" 46dde5845aSJiri Kosina #define DRIVER_LICENSE "GPL" 47dde5845aSJiri Kosina 4858037eb9SJiri Kosina int hid_debug = 0; 49377e10fbSAnssi Hannula module_param_named(debug, hid_debug, int, 0600); 50cd667ce2SJiri Kosina MODULE_PARM_DESC(debug, "toggle HID debugging messages"); 5158037eb9SJiri Kosina EXPORT_SYMBOL_GPL(hid_debug); 5258037eb9SJiri Kosina 536b1968d5SJiri Kosina static int hid_ignore_special_drivers = 0; 546b1968d5SJiri Kosina module_param_named(ignore_special_drivers, hid_ignore_special_drivers, int, 0600); 556b1968d5SJiri Kosina MODULE_PARM_DESC(debug, "Ignore any special drivers and handle all devices by generic driver"); 566b1968d5SJiri Kosina 57dde5845aSJiri Kosina /* 58dde5845aSJiri Kosina * Register a new report for a device. 59dde5845aSJiri Kosina */ 60dde5845aSJiri Kosina 6190a006abSMichael Poole struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) 62dde5845aSJiri Kosina { 63dde5845aSJiri Kosina struct hid_report_enum *report_enum = device->report_enum + type; 64dde5845aSJiri Kosina struct hid_report *report; 65dde5845aSJiri Kosina 66dde5845aSJiri Kosina if (report_enum->report_id_hash[id]) 67dde5845aSJiri Kosina return report_enum->report_id_hash[id]; 68dde5845aSJiri Kosina 69a3789a17SJoe Perches report = kzalloc(sizeof(struct hid_report), GFP_KERNEL); 70a3789a17SJoe Perches if (!report) 71dde5845aSJiri Kosina return NULL; 72dde5845aSJiri Kosina 73dde5845aSJiri Kosina if (id != 0) 74dde5845aSJiri Kosina report_enum->numbered = 1; 75dde5845aSJiri Kosina 76dde5845aSJiri Kosina report->id = id; 77dde5845aSJiri Kosina report->type = type; 78dde5845aSJiri Kosina report->size = 0; 79dde5845aSJiri Kosina report->device = device; 80dde5845aSJiri Kosina report_enum->report_id_hash[id] = report; 81dde5845aSJiri Kosina 82dde5845aSJiri Kosina list_add_tail(&report->list, &report_enum->report_list); 83dde5845aSJiri Kosina 84dde5845aSJiri Kosina return report; 85dde5845aSJiri Kosina } 8690a006abSMichael Poole EXPORT_SYMBOL_GPL(hid_register_report); 87dde5845aSJiri Kosina 88dde5845aSJiri Kosina /* 89dde5845aSJiri Kosina * Register a new field for this report. 90dde5845aSJiri Kosina */ 91dde5845aSJiri Kosina 92dde5845aSJiri Kosina static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) 93dde5845aSJiri Kosina { 94dde5845aSJiri Kosina struct hid_field *field; 95dde5845aSJiri Kosina 96dde5845aSJiri Kosina if (report->maxfield == HID_MAX_FIELDS) { 978c3d52fcSJiri Kosina hid_err(report->device, "too many fields in report\n"); 98dde5845aSJiri Kosina return NULL; 99dde5845aSJiri Kosina } 100dde5845aSJiri Kosina 101a3789a17SJoe Perches field = kzalloc((sizeof(struct hid_field) + 102a3789a17SJoe Perches usages * sizeof(struct hid_usage) + 103a3789a17SJoe Perches values * sizeof(unsigned)), GFP_KERNEL); 104a3789a17SJoe Perches if (!field) 105a3789a17SJoe Perches return NULL; 106dde5845aSJiri Kosina 107dde5845aSJiri Kosina field->index = report->maxfield++; 108dde5845aSJiri Kosina report->field[field->index] = field; 109dde5845aSJiri Kosina field->usage = (struct hid_usage *)(field + 1); 110282bfd4cSJiri Slaby field->value = (s32 *)(field->usage + usages); 111dde5845aSJiri Kosina field->report = report; 112dde5845aSJiri Kosina 113dde5845aSJiri Kosina return field; 114dde5845aSJiri Kosina } 115dde5845aSJiri Kosina 116dde5845aSJiri Kosina /* 117dde5845aSJiri Kosina * Open a collection. The type/usage is pushed on the stack. 118dde5845aSJiri Kosina */ 119dde5845aSJiri Kosina 120dde5845aSJiri Kosina static int open_collection(struct hid_parser *parser, unsigned type) 121dde5845aSJiri Kosina { 122dde5845aSJiri Kosina struct hid_collection *collection; 123dde5845aSJiri Kosina unsigned usage; 124dde5845aSJiri Kosina 125dde5845aSJiri Kosina usage = parser->local.usage[0]; 126dde5845aSJiri Kosina 127dde5845aSJiri Kosina if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { 1288c3d52fcSJiri Kosina hid_err(parser->device, "collection stack overflow\n"); 129dde5845aSJiri Kosina return -1; 130dde5845aSJiri Kosina } 131dde5845aSJiri Kosina 132dde5845aSJiri Kosina if (parser->device->maxcollection == parser->device->collection_size) { 133dde5845aSJiri Kosina collection = kmalloc(sizeof(struct hid_collection) * 134dde5845aSJiri Kosina parser->device->collection_size * 2, GFP_KERNEL); 135dde5845aSJiri Kosina if (collection == NULL) { 1368c3d52fcSJiri Kosina hid_err(parser->device, "failed to reallocate collection array\n"); 137dde5845aSJiri Kosina return -1; 138dde5845aSJiri Kosina } 139dde5845aSJiri Kosina memcpy(collection, parser->device->collection, 140dde5845aSJiri Kosina sizeof(struct hid_collection) * 141dde5845aSJiri Kosina parser->device->collection_size); 142dde5845aSJiri Kosina memset(collection + parser->device->collection_size, 0, 143dde5845aSJiri Kosina sizeof(struct hid_collection) * 144dde5845aSJiri Kosina parser->device->collection_size); 145dde5845aSJiri Kosina kfree(parser->device->collection); 146dde5845aSJiri Kosina parser->device->collection = collection; 147dde5845aSJiri Kosina parser->device->collection_size *= 2; 148dde5845aSJiri Kosina } 149dde5845aSJiri Kosina 150dde5845aSJiri Kosina parser->collection_stack[parser->collection_stack_ptr++] = 151dde5845aSJiri Kosina parser->device->maxcollection; 152dde5845aSJiri Kosina 153dde5845aSJiri Kosina collection = parser->device->collection + 154dde5845aSJiri Kosina parser->device->maxcollection++; 155dde5845aSJiri Kosina collection->type = type; 156dde5845aSJiri Kosina collection->usage = usage; 157dde5845aSJiri Kosina collection->level = parser->collection_stack_ptr - 1; 158dde5845aSJiri Kosina 159dde5845aSJiri Kosina if (type == HID_COLLECTION_APPLICATION) 160dde5845aSJiri Kosina parser->device->maxapplication++; 161dde5845aSJiri Kosina 162dde5845aSJiri Kosina return 0; 163dde5845aSJiri Kosina } 164dde5845aSJiri Kosina 165dde5845aSJiri Kosina /* 166dde5845aSJiri Kosina * Close a collection. 167dde5845aSJiri Kosina */ 168dde5845aSJiri Kosina 169dde5845aSJiri Kosina static int close_collection(struct hid_parser *parser) 170dde5845aSJiri Kosina { 171dde5845aSJiri Kosina if (!parser->collection_stack_ptr) { 1728c3d52fcSJiri Kosina hid_err(parser->device, "collection stack underflow\n"); 173dde5845aSJiri Kosina return -1; 174dde5845aSJiri Kosina } 175dde5845aSJiri Kosina parser->collection_stack_ptr--; 176dde5845aSJiri Kosina return 0; 177dde5845aSJiri Kosina } 178dde5845aSJiri Kosina 179dde5845aSJiri Kosina /* 180dde5845aSJiri Kosina * Climb up the stack, search for the specified collection type 181dde5845aSJiri Kosina * and return the usage. 182dde5845aSJiri Kosina */ 183dde5845aSJiri Kosina 184dde5845aSJiri Kosina static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) 185dde5845aSJiri Kosina { 186504499f2SJoe Perches struct hid_collection *collection = parser->device->collection; 187dde5845aSJiri Kosina int n; 188504499f2SJoe Perches 189504499f2SJoe Perches for (n = parser->collection_stack_ptr - 1; n >= 0; n--) { 190504499f2SJoe Perches unsigned index = parser->collection_stack[n]; 191504499f2SJoe Perches if (collection[index].type == type) 192504499f2SJoe Perches return collection[index].usage; 193504499f2SJoe Perches } 194dde5845aSJiri Kosina return 0; /* we know nothing about this usage type */ 195dde5845aSJiri Kosina } 196dde5845aSJiri Kosina 197dde5845aSJiri Kosina /* 198dde5845aSJiri Kosina * Add a usage to the temporary parser table. 199dde5845aSJiri Kosina */ 200dde5845aSJiri Kosina 201dde5845aSJiri Kosina static int hid_add_usage(struct hid_parser *parser, unsigned usage) 202dde5845aSJiri Kosina { 203dde5845aSJiri Kosina if (parser->local.usage_index >= HID_MAX_USAGES) { 2048c3d52fcSJiri Kosina hid_err(parser->device, "usage index exceeded\n"); 205dde5845aSJiri Kosina return -1; 206dde5845aSJiri Kosina } 207dde5845aSJiri Kosina parser->local.usage[parser->local.usage_index] = usage; 208dde5845aSJiri Kosina parser->local.collection_index[parser->local.usage_index] = 209dde5845aSJiri Kosina parser->collection_stack_ptr ? 210dde5845aSJiri Kosina parser->collection_stack[parser->collection_stack_ptr - 1] : 0; 211dde5845aSJiri Kosina parser->local.usage_index++; 212dde5845aSJiri Kosina return 0; 213dde5845aSJiri Kosina } 214dde5845aSJiri Kosina 215dde5845aSJiri Kosina /* 216dde5845aSJiri Kosina * Register a new field for this report. 217dde5845aSJiri Kosina */ 218dde5845aSJiri Kosina 219dde5845aSJiri Kosina static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags) 220dde5845aSJiri Kosina { 221dde5845aSJiri Kosina struct hid_report *report; 222dde5845aSJiri Kosina struct hid_field *field; 223dde5845aSJiri Kosina int usages; 224dde5845aSJiri Kosina unsigned offset; 225dde5845aSJiri Kosina int i; 226dde5845aSJiri Kosina 227a3789a17SJoe Perches report = hid_register_report(parser->device, report_type, parser->global.report_id); 228a3789a17SJoe Perches if (!report) { 2298c3d52fcSJiri Kosina hid_err(parser->device, "hid_register_report failed\n"); 230dde5845aSJiri Kosina return -1; 231dde5845aSJiri Kosina } 232dde5845aSJiri Kosina 233dde5845aSJiri Kosina if (parser->global.logical_maximum < parser->global.logical_minimum) { 2348c3d52fcSJiri Kosina hid_err(parser->device, "logical range invalid %d %d\n", 2358c3d52fcSJiri Kosina parser->global.logical_minimum, parser->global.logical_maximum); 236dde5845aSJiri Kosina return -1; 237dde5845aSJiri Kosina } 238dde5845aSJiri Kosina 239dde5845aSJiri Kosina offset = report->size; 240dde5845aSJiri Kosina report->size += parser->global.report_size * parser->global.report_count; 241dde5845aSJiri Kosina 242dde5845aSJiri Kosina if (!parser->local.usage_index) /* Ignore padding fields */ 243dde5845aSJiri Kosina return 0; 244dde5845aSJiri Kosina 245dde5845aSJiri Kosina usages = max_t(int, parser->local.usage_index, parser->global.report_count); 246dde5845aSJiri Kosina 247a3789a17SJoe Perches field = hid_register_field(report, usages, parser->global.report_count); 248a3789a17SJoe Perches if (!field) 249dde5845aSJiri Kosina return 0; 250dde5845aSJiri Kosina 251dde5845aSJiri Kosina field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); 252dde5845aSJiri Kosina field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL); 253dde5845aSJiri Kosina field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); 254dde5845aSJiri Kosina 255dde5845aSJiri Kosina for (i = 0; i < usages; i++) { 256dde5845aSJiri Kosina int j = i; 257dde5845aSJiri Kosina /* Duplicate the last usage we parsed if we have excess values */ 258dde5845aSJiri Kosina if (i >= parser->local.usage_index) 259dde5845aSJiri Kosina j = parser->local.usage_index - 1; 260dde5845aSJiri Kosina field->usage[i].hid = parser->local.usage[j]; 261dde5845aSJiri Kosina field->usage[i].collection_index = 262dde5845aSJiri Kosina parser->local.collection_index[j]; 263dde5845aSJiri Kosina } 264dde5845aSJiri Kosina 265dde5845aSJiri Kosina field->maxusage = usages; 266dde5845aSJiri Kosina field->flags = flags; 267dde5845aSJiri Kosina field->report_offset = offset; 268dde5845aSJiri Kosina field->report_type = report_type; 269dde5845aSJiri Kosina field->report_size = parser->global.report_size; 270dde5845aSJiri Kosina field->report_count = parser->global.report_count; 271dde5845aSJiri Kosina field->logical_minimum = parser->global.logical_minimum; 272dde5845aSJiri Kosina field->logical_maximum = parser->global.logical_maximum; 273dde5845aSJiri Kosina field->physical_minimum = parser->global.physical_minimum; 274dde5845aSJiri Kosina field->physical_maximum = parser->global.physical_maximum; 275dde5845aSJiri Kosina field->unit_exponent = parser->global.unit_exponent; 276dde5845aSJiri Kosina field->unit = parser->global.unit; 277dde5845aSJiri Kosina 278dde5845aSJiri Kosina return 0; 279dde5845aSJiri Kosina } 280dde5845aSJiri Kosina 281dde5845aSJiri Kosina /* 282dde5845aSJiri Kosina * Read data value from item. 283dde5845aSJiri Kosina */ 284dde5845aSJiri Kosina 285dde5845aSJiri Kosina static u32 item_udata(struct hid_item *item) 286dde5845aSJiri Kosina { 287dde5845aSJiri Kosina switch (item->size) { 288dde5845aSJiri Kosina case 1: return item->data.u8; 289dde5845aSJiri Kosina case 2: return item->data.u16; 290dde5845aSJiri Kosina case 4: return item->data.u32; 291dde5845aSJiri Kosina } 292dde5845aSJiri Kosina return 0; 293dde5845aSJiri Kosina } 294dde5845aSJiri Kosina 295dde5845aSJiri Kosina static s32 item_sdata(struct hid_item *item) 296dde5845aSJiri Kosina { 297dde5845aSJiri Kosina switch (item->size) { 298dde5845aSJiri Kosina case 1: return item->data.s8; 299dde5845aSJiri Kosina case 2: return item->data.s16; 300dde5845aSJiri Kosina case 4: return item->data.s32; 301dde5845aSJiri Kosina } 302dde5845aSJiri Kosina return 0; 303dde5845aSJiri Kosina } 304dde5845aSJiri Kosina 305dde5845aSJiri Kosina /* 306dde5845aSJiri Kosina * Process a global item. 307dde5845aSJiri Kosina */ 308dde5845aSJiri Kosina 309dde5845aSJiri Kosina static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) 310dde5845aSJiri Kosina { 311dde5845aSJiri Kosina switch (item->tag) { 312dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_PUSH: 313dde5845aSJiri Kosina 314dde5845aSJiri Kosina if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { 3158c3d52fcSJiri Kosina hid_err(parser->device, "global environment stack overflow\n"); 316dde5845aSJiri Kosina return -1; 317dde5845aSJiri Kosina } 318dde5845aSJiri Kosina 319dde5845aSJiri Kosina memcpy(parser->global_stack + parser->global_stack_ptr++, 320dde5845aSJiri Kosina &parser->global, sizeof(struct hid_global)); 321dde5845aSJiri Kosina return 0; 322dde5845aSJiri Kosina 323dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_POP: 324dde5845aSJiri Kosina 325dde5845aSJiri Kosina if (!parser->global_stack_ptr) { 3268c3d52fcSJiri Kosina hid_err(parser->device, "global environment stack underflow\n"); 327dde5845aSJiri Kosina return -1; 328dde5845aSJiri Kosina } 329dde5845aSJiri Kosina 330880d29f1SJiri Slaby memcpy(&parser->global, parser->global_stack + 331880d29f1SJiri Slaby --parser->global_stack_ptr, sizeof(struct hid_global)); 332dde5845aSJiri Kosina return 0; 333dde5845aSJiri Kosina 334dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: 335dde5845aSJiri Kosina parser->global.usage_page = item_udata(item); 336dde5845aSJiri Kosina return 0; 337dde5845aSJiri Kosina 338dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: 339dde5845aSJiri Kosina parser->global.logical_minimum = item_sdata(item); 340dde5845aSJiri Kosina return 0; 341dde5845aSJiri Kosina 342dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: 343dde5845aSJiri Kosina if (parser->global.logical_minimum < 0) 344dde5845aSJiri Kosina parser->global.logical_maximum = item_sdata(item); 345dde5845aSJiri Kosina else 346dde5845aSJiri Kosina parser->global.logical_maximum = item_udata(item); 347dde5845aSJiri Kosina return 0; 348dde5845aSJiri Kosina 349dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: 350dde5845aSJiri Kosina parser->global.physical_minimum = item_sdata(item); 351dde5845aSJiri Kosina return 0; 352dde5845aSJiri Kosina 353dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: 354dde5845aSJiri Kosina if (parser->global.physical_minimum < 0) 355dde5845aSJiri Kosina parser->global.physical_maximum = item_sdata(item); 356dde5845aSJiri Kosina else 357dde5845aSJiri Kosina parser->global.physical_maximum = item_udata(item); 358dde5845aSJiri Kosina return 0; 359dde5845aSJiri Kosina 360dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: 361dde5845aSJiri Kosina parser->global.unit_exponent = item_sdata(item); 362dde5845aSJiri Kosina return 0; 363dde5845aSJiri Kosina 364dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_UNIT: 365dde5845aSJiri Kosina parser->global.unit = item_udata(item); 366dde5845aSJiri Kosina return 0; 367dde5845aSJiri Kosina 368dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: 369880d29f1SJiri Slaby parser->global.report_size = item_udata(item); 370e46e927bSChase Douglas if (parser->global.report_size > 96) { 3718c3d52fcSJiri Kosina hid_err(parser->device, "invalid report_size %d\n", 372880d29f1SJiri Slaby parser->global.report_size); 373dde5845aSJiri Kosina return -1; 374dde5845aSJiri Kosina } 375dde5845aSJiri Kosina return 0; 376dde5845aSJiri Kosina 377dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: 378880d29f1SJiri Slaby parser->global.report_count = item_udata(item); 379880d29f1SJiri Slaby if (parser->global.report_count > HID_MAX_USAGES) { 3808c3d52fcSJiri Kosina hid_err(parser->device, "invalid report_count %d\n", 381880d29f1SJiri Slaby parser->global.report_count); 382dde5845aSJiri Kosina return -1; 383dde5845aSJiri Kosina } 384dde5845aSJiri Kosina return 0; 385dde5845aSJiri Kosina 386dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_REPORT_ID: 387880d29f1SJiri Slaby parser->global.report_id = item_udata(item); 388880d29f1SJiri Slaby if (parser->global.report_id == 0) { 3898c3d52fcSJiri Kosina hid_err(parser->device, "report_id 0 is invalid\n"); 390dde5845aSJiri Kosina return -1; 391dde5845aSJiri Kosina } 392dde5845aSJiri Kosina return 0; 393dde5845aSJiri Kosina 394dde5845aSJiri Kosina default: 3958c3d52fcSJiri Kosina hid_err(parser->device, "unknown global tag 0x%x\n", item->tag); 396dde5845aSJiri Kosina return -1; 397dde5845aSJiri Kosina } 398dde5845aSJiri Kosina } 399dde5845aSJiri Kosina 400dde5845aSJiri Kosina /* 401dde5845aSJiri Kosina * Process a local item. 402dde5845aSJiri Kosina */ 403dde5845aSJiri Kosina 404dde5845aSJiri Kosina static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) 405dde5845aSJiri Kosina { 406dde5845aSJiri Kosina __u32 data; 407dde5845aSJiri Kosina unsigned n; 408dde5845aSJiri Kosina 409dde5845aSJiri Kosina data = item_udata(item); 410dde5845aSJiri Kosina 411dde5845aSJiri Kosina switch (item->tag) { 412dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_DELIMITER: 413dde5845aSJiri Kosina 414dde5845aSJiri Kosina if (data) { 415dde5845aSJiri Kosina /* 416dde5845aSJiri Kosina * We treat items before the first delimiter 417dde5845aSJiri Kosina * as global to all usage sets (branch 0). 418dde5845aSJiri Kosina * In the moment we process only these global 419dde5845aSJiri Kosina * items and the first delimiter set. 420dde5845aSJiri Kosina */ 421dde5845aSJiri Kosina if (parser->local.delimiter_depth != 0) { 4228c3d52fcSJiri Kosina hid_err(parser->device, "nested delimiters\n"); 423dde5845aSJiri Kosina return -1; 424dde5845aSJiri Kosina } 425dde5845aSJiri Kosina parser->local.delimiter_depth++; 426dde5845aSJiri Kosina parser->local.delimiter_branch++; 427dde5845aSJiri Kosina } else { 428dde5845aSJiri Kosina if (parser->local.delimiter_depth < 1) { 4298c3d52fcSJiri Kosina hid_err(parser->device, "bogus close delimiter\n"); 430dde5845aSJiri Kosina return -1; 431dde5845aSJiri Kosina } 432dde5845aSJiri Kosina parser->local.delimiter_depth--; 433dde5845aSJiri Kosina } 434dde5845aSJiri Kosina return 1; 435dde5845aSJiri Kosina 436dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_USAGE: 437dde5845aSJiri Kosina 438dde5845aSJiri Kosina if (parser->local.delimiter_branch > 1) { 43958037eb9SJiri Kosina dbg_hid("alternative usage ignored\n"); 440dde5845aSJiri Kosina return 0; 441dde5845aSJiri Kosina } 442dde5845aSJiri Kosina 443dde5845aSJiri Kosina if (item->size <= 2) 444dde5845aSJiri Kosina data = (parser->global.usage_page << 16) + data; 445dde5845aSJiri Kosina 446dde5845aSJiri Kosina return hid_add_usage(parser, data); 447dde5845aSJiri Kosina 448dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: 449dde5845aSJiri Kosina 450dde5845aSJiri Kosina if (parser->local.delimiter_branch > 1) { 45158037eb9SJiri Kosina dbg_hid("alternative usage ignored\n"); 452dde5845aSJiri Kosina return 0; 453dde5845aSJiri Kosina } 454dde5845aSJiri Kosina 455dde5845aSJiri Kosina if (item->size <= 2) 456dde5845aSJiri Kosina data = (parser->global.usage_page << 16) + data; 457dde5845aSJiri Kosina 458dde5845aSJiri Kosina parser->local.usage_minimum = data; 459dde5845aSJiri Kosina return 0; 460dde5845aSJiri Kosina 461dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: 462dde5845aSJiri Kosina 463dde5845aSJiri Kosina if (parser->local.delimiter_branch > 1) { 46458037eb9SJiri Kosina dbg_hid("alternative usage ignored\n"); 465dde5845aSJiri Kosina return 0; 466dde5845aSJiri Kosina } 467dde5845aSJiri Kosina 468dde5845aSJiri Kosina if (item->size <= 2) 469dde5845aSJiri Kosina data = (parser->global.usage_page << 16) + data; 470dde5845aSJiri Kosina 471dde5845aSJiri Kosina for (n = parser->local.usage_minimum; n <= data; n++) 472dde5845aSJiri Kosina if (hid_add_usage(parser, n)) { 47358037eb9SJiri Kosina dbg_hid("hid_add_usage failed\n"); 474dde5845aSJiri Kosina return -1; 475dde5845aSJiri Kosina } 476dde5845aSJiri Kosina return 0; 477dde5845aSJiri Kosina 478dde5845aSJiri Kosina default: 479dde5845aSJiri Kosina 48058037eb9SJiri Kosina dbg_hid("unknown local item tag 0x%x\n", item->tag); 481dde5845aSJiri Kosina return 0; 482dde5845aSJiri Kosina } 483dde5845aSJiri Kosina return 0; 484dde5845aSJiri Kosina } 485dde5845aSJiri Kosina 486dde5845aSJiri Kosina /* 487dde5845aSJiri Kosina * Process a main item. 488dde5845aSJiri Kosina */ 489dde5845aSJiri Kosina 490dde5845aSJiri Kosina static int hid_parser_main(struct hid_parser *parser, struct hid_item *item) 491dde5845aSJiri Kosina { 492dde5845aSJiri Kosina __u32 data; 493dde5845aSJiri Kosina int ret; 494dde5845aSJiri Kosina 495dde5845aSJiri Kosina data = item_udata(item); 496dde5845aSJiri Kosina 497dde5845aSJiri Kosina switch (item->tag) { 498dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: 499dde5845aSJiri Kosina ret = open_collection(parser, data & 0xff); 500dde5845aSJiri Kosina break; 501dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_END_COLLECTION: 502dde5845aSJiri Kosina ret = close_collection(parser); 503dde5845aSJiri Kosina break; 504dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_INPUT: 505dde5845aSJiri Kosina ret = hid_add_field(parser, HID_INPUT_REPORT, data); 506dde5845aSJiri Kosina break; 507dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_OUTPUT: 508dde5845aSJiri Kosina ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); 509dde5845aSJiri Kosina break; 510dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_FEATURE: 511dde5845aSJiri Kosina ret = hid_add_field(parser, HID_FEATURE_REPORT, data); 512dde5845aSJiri Kosina break; 513dde5845aSJiri Kosina default: 5148c3d52fcSJiri Kosina hid_err(parser->device, "unknown main item tag 0x%x\n", item->tag); 515dde5845aSJiri Kosina ret = 0; 516dde5845aSJiri Kosina } 517dde5845aSJiri Kosina 518dde5845aSJiri Kosina memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ 519dde5845aSJiri Kosina 520dde5845aSJiri Kosina return ret; 521dde5845aSJiri Kosina } 522dde5845aSJiri Kosina 523dde5845aSJiri Kosina /* 524dde5845aSJiri Kosina * Process a reserved item. 525dde5845aSJiri Kosina */ 526dde5845aSJiri Kosina 527dde5845aSJiri Kosina static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) 528dde5845aSJiri Kosina { 52958037eb9SJiri Kosina dbg_hid("reserved item type, tag 0x%x\n", item->tag); 530dde5845aSJiri Kosina return 0; 531dde5845aSJiri Kosina } 532dde5845aSJiri Kosina 533dde5845aSJiri Kosina /* 534dde5845aSJiri Kosina * Free a report and all registered fields. The field->usage and 535dde5845aSJiri Kosina * field->value table's are allocated behind the field, so we need 536dde5845aSJiri Kosina * only to free(field) itself. 537dde5845aSJiri Kosina */ 538dde5845aSJiri Kosina 539dde5845aSJiri Kosina static void hid_free_report(struct hid_report *report) 540dde5845aSJiri Kosina { 541dde5845aSJiri Kosina unsigned n; 542dde5845aSJiri Kosina 543dde5845aSJiri Kosina for (n = 0; n < report->maxfield; n++) 544dde5845aSJiri Kosina kfree(report->field[n]); 545dde5845aSJiri Kosina kfree(report); 546dde5845aSJiri Kosina } 547dde5845aSJiri Kosina 548dde5845aSJiri Kosina /* 549dde5845aSJiri Kosina * Free a device structure, all reports, and all fields. 550dde5845aSJiri Kosina */ 551dde5845aSJiri Kosina 55285cdaf52SJiri Slaby static void hid_device_release(struct device *dev) 553dde5845aSJiri Kosina { 55485cdaf52SJiri Slaby struct hid_device *device = container_of(dev, struct hid_device, dev); 555dde5845aSJiri Kosina unsigned i, j; 556dde5845aSJiri Kosina 557dde5845aSJiri Kosina for (i = 0; i < HID_REPORT_TYPES; i++) { 558dde5845aSJiri Kosina struct hid_report_enum *report_enum = device->report_enum + i; 559dde5845aSJiri Kosina 560dde5845aSJiri Kosina for (j = 0; j < 256; j++) { 561dde5845aSJiri Kosina struct hid_report *report = report_enum->report_id_hash[j]; 562dde5845aSJiri Kosina if (report) 563dde5845aSJiri Kosina hid_free_report(report); 564dde5845aSJiri Kosina } 565dde5845aSJiri Kosina } 566dde5845aSJiri Kosina 567dde5845aSJiri Kosina kfree(device->rdesc); 568767fe787SJiri Kosina kfree(device->collection); 569dde5845aSJiri Kosina kfree(device); 570dde5845aSJiri Kosina } 571dde5845aSJiri Kosina 572dde5845aSJiri Kosina /* 573dde5845aSJiri Kosina * Fetch a report description item from the data stream. We support long 574dde5845aSJiri Kosina * items, though they are not used yet. 575dde5845aSJiri Kosina */ 576dde5845aSJiri Kosina 577dde5845aSJiri Kosina static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) 578dde5845aSJiri Kosina { 579dde5845aSJiri Kosina u8 b; 580dde5845aSJiri Kosina 581dde5845aSJiri Kosina if ((end - start) <= 0) 582dde5845aSJiri Kosina return NULL; 583dde5845aSJiri Kosina 584dde5845aSJiri Kosina b = *start++; 585dde5845aSJiri Kosina 586dde5845aSJiri Kosina item->type = (b >> 2) & 3; 587dde5845aSJiri Kosina item->tag = (b >> 4) & 15; 588dde5845aSJiri Kosina 589dde5845aSJiri Kosina if (item->tag == HID_ITEM_TAG_LONG) { 590dde5845aSJiri Kosina 591dde5845aSJiri Kosina item->format = HID_ITEM_FORMAT_LONG; 592dde5845aSJiri Kosina 593dde5845aSJiri Kosina if ((end - start) < 2) 594dde5845aSJiri Kosina return NULL; 595dde5845aSJiri Kosina 596dde5845aSJiri Kosina item->size = *start++; 597dde5845aSJiri Kosina item->tag = *start++; 598dde5845aSJiri Kosina 599dde5845aSJiri Kosina if ((end - start) < item->size) 600dde5845aSJiri Kosina return NULL; 601dde5845aSJiri Kosina 602dde5845aSJiri Kosina item->data.longdata = start; 603dde5845aSJiri Kosina start += item->size; 604dde5845aSJiri Kosina return start; 605dde5845aSJiri Kosina } 606dde5845aSJiri Kosina 607dde5845aSJiri Kosina item->format = HID_ITEM_FORMAT_SHORT; 608dde5845aSJiri Kosina item->size = b & 3; 609dde5845aSJiri Kosina 610dde5845aSJiri Kosina switch (item->size) { 611dde5845aSJiri Kosina case 0: 612dde5845aSJiri Kosina return start; 613dde5845aSJiri Kosina 614dde5845aSJiri Kosina case 1: 615dde5845aSJiri Kosina if ((end - start) < 1) 616dde5845aSJiri Kosina return NULL; 617dde5845aSJiri Kosina item->data.u8 = *start++; 618dde5845aSJiri Kosina return start; 619dde5845aSJiri Kosina 620dde5845aSJiri Kosina case 2: 621dde5845aSJiri Kosina if ((end - start) < 2) 622dde5845aSJiri Kosina return NULL; 623c105068fSHarvey Harrison item->data.u16 = get_unaligned_le16(start); 624dde5845aSJiri Kosina start = (__u8 *)((__le16 *)start + 1); 625dde5845aSJiri Kosina return start; 626dde5845aSJiri Kosina 627dde5845aSJiri Kosina case 3: 628dde5845aSJiri Kosina item->size++; 629dde5845aSJiri Kosina if ((end - start) < 4) 630dde5845aSJiri Kosina return NULL; 631c105068fSHarvey Harrison item->data.u32 = get_unaligned_le32(start); 632dde5845aSJiri Kosina start = (__u8 *)((__le32 *)start + 1); 633dde5845aSJiri Kosina return start; 634dde5845aSJiri Kosina } 635dde5845aSJiri Kosina 636dde5845aSJiri Kosina return NULL; 637dde5845aSJiri Kosina } 638dde5845aSJiri Kosina 63985cdaf52SJiri Slaby /** 64085cdaf52SJiri Slaby * hid_parse_report - parse device report 64185cdaf52SJiri Slaby * 64285cdaf52SJiri Slaby * @device: hid device 64385cdaf52SJiri Slaby * @start: report start 64485cdaf52SJiri Slaby * @size: report size 64585cdaf52SJiri Slaby * 646dde5845aSJiri Kosina * Parse a report description into a hid_device structure. Reports are 647dde5845aSJiri Kosina * enumerated, fields are attached to these reports. 64885cdaf52SJiri Slaby * 0 returned on success, otherwise nonzero error value. 649dde5845aSJiri Kosina */ 65085cdaf52SJiri Slaby int hid_parse_report(struct hid_device *device, __u8 *start, 65185cdaf52SJiri Slaby unsigned size) 652dde5845aSJiri Kosina { 653dde5845aSJiri Kosina struct hid_parser *parser; 654dde5845aSJiri Kosina struct hid_item item; 655dde5845aSJiri Kosina __u8 *end; 65685cdaf52SJiri Slaby int ret; 657dde5845aSJiri Kosina static int (*dispatch_type[])(struct hid_parser *parser, 658dde5845aSJiri Kosina struct hid_item *item) = { 659dde5845aSJiri Kosina hid_parser_main, 660dde5845aSJiri Kosina hid_parser_global, 661dde5845aSJiri Kosina hid_parser_local, 662dde5845aSJiri Kosina hid_parser_reserved 663dde5845aSJiri Kosina }; 664dde5845aSJiri Kosina 665c500c971SJiri Slaby if (device->driver->report_fixup) 66673e4008dSNikolai Kondrashov start = device->driver->report_fixup(device, start, &size); 667c500c971SJiri Slaby 6681721a238SJulia Lawall device->rdesc = kmemdup(start, size, GFP_KERNEL); 66985cdaf52SJiri Slaby if (device->rdesc == NULL) 67085cdaf52SJiri Slaby return -ENOMEM; 671dde5845aSJiri Kosina device->rsize = size; 672dde5845aSJiri Kosina 673fe258020SJoe Perches parser = vzalloc(sizeof(struct hid_parser)); 67485cdaf52SJiri Slaby if (!parser) { 67585cdaf52SJiri Slaby ret = -ENOMEM; 67685cdaf52SJiri Slaby goto err; 677dde5845aSJiri Kosina } 67885cdaf52SJiri Slaby 679dde5845aSJiri Kosina parser->device = device; 680dde5845aSJiri Kosina 681dde5845aSJiri Kosina end = start + size; 68285cdaf52SJiri Slaby ret = -EINVAL; 683dde5845aSJiri Kosina while ((start = fetch_item(start, end, &item)) != NULL) { 684dde5845aSJiri Kosina 685dde5845aSJiri Kosina if (item.format != HID_ITEM_FORMAT_SHORT) { 6868c3d52fcSJiri Kosina hid_err(device, "unexpected long global item\n"); 68785cdaf52SJiri Slaby goto err; 688dde5845aSJiri Kosina } 689dde5845aSJiri Kosina 690dde5845aSJiri Kosina if (dispatch_type[item.type](parser, &item)) { 6918c3d52fcSJiri Kosina hid_err(device, "item %u %u %u %u parsing failed\n", 6924291ee30SJoe Perches item.format, (unsigned)item.size, 6934291ee30SJoe Perches (unsigned)item.type, (unsigned)item.tag); 69485cdaf52SJiri Slaby goto err; 695dde5845aSJiri Kosina } 696dde5845aSJiri Kosina 697dde5845aSJiri Kosina if (start == end) { 698dde5845aSJiri Kosina if (parser->collection_stack_ptr) { 6998c3d52fcSJiri Kosina hid_err(device, "unbalanced collection at end of report description\n"); 70085cdaf52SJiri Slaby goto err; 701dde5845aSJiri Kosina } 702dde5845aSJiri Kosina if (parser->local.delimiter_depth) { 7038c3d52fcSJiri Kosina hid_err(device, "unbalanced delimiter at end of report description\n"); 70485cdaf52SJiri Slaby goto err; 705dde5845aSJiri Kosina } 70647a80edbSJiri Kosina vfree(parser); 70785cdaf52SJiri Slaby return 0; 708dde5845aSJiri Kosina } 709dde5845aSJiri Kosina } 710dde5845aSJiri Kosina 7118c3d52fcSJiri Kosina hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); 71285cdaf52SJiri Slaby err: 71347a80edbSJiri Kosina vfree(parser); 71485cdaf52SJiri Slaby return ret; 715dde5845aSJiri Kosina } 716229695e5SJiri Kosina EXPORT_SYMBOL_GPL(hid_parse_report); 717dde5845aSJiri Kosina 718dde5845aSJiri Kosina /* 719dde5845aSJiri Kosina * Convert a signed n-bit integer to signed 32-bit integer. Common 720dde5845aSJiri Kosina * cases are done through the compiler, the screwed things has to be 721dde5845aSJiri Kosina * done by hand. 722dde5845aSJiri Kosina */ 723dde5845aSJiri Kosina 724dde5845aSJiri Kosina static s32 snto32(__u32 value, unsigned n) 725dde5845aSJiri Kosina { 726dde5845aSJiri Kosina switch (n) { 727dde5845aSJiri Kosina case 8: return ((__s8)value); 728dde5845aSJiri Kosina case 16: return ((__s16)value); 729dde5845aSJiri Kosina case 32: return ((__s32)value); 730dde5845aSJiri Kosina } 731dde5845aSJiri Kosina return value & (1 << (n - 1)) ? value | (-1 << n) : value; 732dde5845aSJiri Kosina } 733dde5845aSJiri Kosina 734dde5845aSJiri Kosina /* 735dde5845aSJiri Kosina * Convert a signed 32-bit integer to a signed n-bit integer. 736dde5845aSJiri Kosina */ 737dde5845aSJiri Kosina 738dde5845aSJiri Kosina static u32 s32ton(__s32 value, unsigned n) 739dde5845aSJiri Kosina { 740dde5845aSJiri Kosina s32 a = value >> (n - 1); 741dde5845aSJiri Kosina if (a && a != -1) 742dde5845aSJiri Kosina return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; 743dde5845aSJiri Kosina return value & ((1 << n) - 1); 744dde5845aSJiri Kosina } 745dde5845aSJiri Kosina 746dde5845aSJiri Kosina /* 747dde5845aSJiri Kosina * Extract/implement a data field from/to a little endian report (bit array). 748dde5845aSJiri Kosina * 749dde5845aSJiri Kosina * Code sort-of follows HID spec: 750dde5845aSJiri Kosina * http://www.usb.org/developers/devclass_docs/HID1_11.pdf 751dde5845aSJiri Kosina * 752dde5845aSJiri Kosina * While the USB HID spec allows unlimited length bit fields in "report 753dde5845aSJiri Kosina * descriptors", most devices never use more than 16 bits. 754dde5845aSJiri Kosina * One model of UPS is claimed to report "LINEV" as a 32-bit field. 755dde5845aSJiri Kosina * Search linux-kernel and linux-usb-devel archives for "hid-core extract". 756dde5845aSJiri Kosina */ 757dde5845aSJiri Kosina 75816ee4cc8SJoe Perches static __u32 extract(const struct hid_device *hid, __u8 *report, 7594291ee30SJoe Perches unsigned offset, unsigned n) 760dde5845aSJiri Kosina { 761dde5845aSJiri Kosina u64 x; 762dde5845aSJiri Kosina 763c4124c9bSJiri Kosina if (n > 32) 7644291ee30SJoe Perches hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n", 765c4124c9bSJiri Kosina n, current->comm); 766dde5845aSJiri Kosina 767dde5845aSJiri Kosina report += offset >> 3; /* adjust byte index */ 768dde5845aSJiri Kosina offset &= 7; /* now only need bit offset into one byte */ 769c105068fSHarvey Harrison x = get_unaligned_le64(report); 770dde5845aSJiri Kosina x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ 771dde5845aSJiri Kosina return (u32) x; 772dde5845aSJiri Kosina } 773dde5845aSJiri Kosina 774dde5845aSJiri Kosina /* 775dde5845aSJiri Kosina * "implement" : set bits in a little endian bit stream. 776dde5845aSJiri Kosina * Same concepts as "extract" (see comments above). 777dde5845aSJiri Kosina * The data mangled in the bit stream remains in little endian 778dde5845aSJiri Kosina * order the whole time. It make more sense to talk about 779dde5845aSJiri Kosina * endianness of register values by considering a register 780dde5845aSJiri Kosina * a "cached" copy of the little endiad bit stream. 781dde5845aSJiri Kosina */ 78216ee4cc8SJoe Perches static void implement(const struct hid_device *hid, __u8 *report, 7834291ee30SJoe Perches unsigned offset, unsigned n, __u32 value) 784dde5845aSJiri Kosina { 7856f0168d2SHarvey Harrison u64 x; 786dde5845aSJiri Kosina u64 m = (1ULL << n) - 1; 787dde5845aSJiri Kosina 788c4124c9bSJiri Kosina if (n > 32) 7894291ee30SJoe Perches hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n", 7904291ee30SJoe Perches __func__, n, current->comm); 791dde5845aSJiri Kosina 792c4124c9bSJiri Kosina if (value > m) 7934291ee30SJoe Perches hid_warn(hid, "%s() called with too large value %d! (%s)\n", 7944291ee30SJoe Perches __func__, value, current->comm); 795dde5845aSJiri Kosina WARN_ON(value > m); 796dde5845aSJiri Kosina value &= m; 797dde5845aSJiri Kosina 798dde5845aSJiri Kosina report += offset >> 3; 799dde5845aSJiri Kosina offset &= 7; 800dde5845aSJiri Kosina 8016f0168d2SHarvey Harrison x = get_unaligned_le64(report); 8026f0168d2SHarvey Harrison x &= ~(m << offset); 8036f0168d2SHarvey Harrison x |= ((u64)value) << offset; 8046f0168d2SHarvey Harrison put_unaligned_le64(x, report); 805dde5845aSJiri Kosina } 806dde5845aSJiri Kosina 807dde5845aSJiri Kosina /* 808dde5845aSJiri Kosina * Search an array for a value. 809dde5845aSJiri Kosina */ 810dde5845aSJiri Kosina 81116ee4cc8SJoe Perches static int search(__s32 *array, __s32 value, unsigned n) 812dde5845aSJiri Kosina { 813dde5845aSJiri Kosina while (n--) { 814dde5845aSJiri Kosina if (*array++ == value) 815dde5845aSJiri Kosina return 0; 816dde5845aSJiri Kosina } 817dde5845aSJiri Kosina return -1; 818dde5845aSJiri Kosina } 819dde5845aSJiri Kosina 82085cdaf52SJiri Slaby /** 82185cdaf52SJiri Slaby * hid_match_report - check if driver's raw_event should be called 82285cdaf52SJiri Slaby * 82385cdaf52SJiri Slaby * @hid: hid device 82485cdaf52SJiri Slaby * @report_type: type to match against 82585cdaf52SJiri Slaby * 82685cdaf52SJiri Slaby * compare hid->driver->report_table->report_type to report->type 82785cdaf52SJiri Slaby */ 82885cdaf52SJiri Slaby static int hid_match_report(struct hid_device *hid, struct hid_report *report) 829dde5845aSJiri Kosina { 83085cdaf52SJiri Slaby const struct hid_report_id *id = hid->driver->report_table; 83185cdaf52SJiri Slaby 83285cdaf52SJiri Slaby if (!id) /* NULL means all */ 83385cdaf52SJiri Slaby return 1; 83485cdaf52SJiri Slaby 83585cdaf52SJiri Slaby for (; id->report_type != HID_TERMINATOR; id++) 83685cdaf52SJiri Slaby if (id->report_type == HID_ANY_ID || 83785cdaf52SJiri Slaby id->report_type == report->type) 83885cdaf52SJiri Slaby return 1; 83985cdaf52SJiri Slaby return 0; 84085cdaf52SJiri Slaby } 84185cdaf52SJiri Slaby 84285cdaf52SJiri Slaby /** 84385cdaf52SJiri Slaby * hid_match_usage - check if driver's event should be called 84485cdaf52SJiri Slaby * 84585cdaf52SJiri Slaby * @hid: hid device 84685cdaf52SJiri Slaby * @usage: usage to match against 84785cdaf52SJiri Slaby * 84885cdaf52SJiri Slaby * compare hid->driver->usage_table->usage_{type,code} to 84985cdaf52SJiri Slaby * usage->usage_{type,code} 85085cdaf52SJiri Slaby */ 85185cdaf52SJiri Slaby static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage) 85285cdaf52SJiri Slaby { 85385cdaf52SJiri Slaby const struct hid_usage_id *id = hid->driver->usage_table; 85485cdaf52SJiri Slaby 85585cdaf52SJiri Slaby if (!id) /* NULL means all */ 85685cdaf52SJiri Slaby return 1; 85785cdaf52SJiri Slaby 85885cdaf52SJiri Slaby for (; id->usage_type != HID_ANY_ID - 1; id++) 85985cdaf52SJiri Slaby if ((id->usage_hid == HID_ANY_ID || 86085cdaf52SJiri Slaby id->usage_hid == usage->hid) && 86185cdaf52SJiri Slaby (id->usage_type == HID_ANY_ID || 86285cdaf52SJiri Slaby id->usage_type == usage->type) && 86385cdaf52SJiri Slaby (id->usage_code == HID_ANY_ID || 86485cdaf52SJiri Slaby id->usage_code == usage->code)) 86585cdaf52SJiri Slaby return 1; 86685cdaf52SJiri Slaby return 0; 86785cdaf52SJiri Slaby } 86885cdaf52SJiri Slaby 86985cdaf52SJiri Slaby static void hid_process_event(struct hid_device *hid, struct hid_field *field, 87085cdaf52SJiri Slaby struct hid_usage *usage, __s32 value, int interrupt) 87185cdaf52SJiri Slaby { 87285cdaf52SJiri Slaby struct hid_driver *hdrv = hid->driver; 87385cdaf52SJiri Slaby int ret; 87485cdaf52SJiri Slaby 875cd667ce2SJiri Kosina hid_dump_input(hid, usage, value); 87685cdaf52SJiri Slaby 87785cdaf52SJiri Slaby if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { 87885cdaf52SJiri Slaby ret = hdrv->event(hid, field, usage, value); 87985cdaf52SJiri Slaby if (ret != 0) { 88085cdaf52SJiri Slaby if (ret < 0) 8818c3d52fcSJiri Kosina hid_err(hid, "%s's event failed with %d\n", 88285cdaf52SJiri Slaby hdrv->name, ret); 88385cdaf52SJiri Slaby return; 88485cdaf52SJiri Slaby } 88585cdaf52SJiri Slaby } 88685cdaf52SJiri Slaby 887dde5845aSJiri Kosina if (hid->claimed & HID_CLAIMED_INPUT) 888dde5845aSJiri Kosina hidinput_hid_event(hid, field, usage, value); 889aa938f79SJiri Kosina if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) 890aa938f79SJiri Kosina hid->hiddev_hid_event(hid, field, usage, value); 891dde5845aSJiri Kosina } 892dde5845aSJiri Kosina 893dde5845aSJiri Kosina /* 894dde5845aSJiri Kosina * Analyse a received field, and fetch the data from it. The field 895dde5845aSJiri Kosina * content is stored for next report processing (we do differential 896dde5845aSJiri Kosina * reporting to the layer). 897dde5845aSJiri Kosina */ 898dde5845aSJiri Kosina 899abdff0f7SAdrian Bunk static void hid_input_field(struct hid_device *hid, struct hid_field *field, 900abdff0f7SAdrian Bunk __u8 *data, int interrupt) 901dde5845aSJiri Kosina { 902dde5845aSJiri Kosina unsigned n; 903dde5845aSJiri Kosina unsigned count = field->report_count; 904dde5845aSJiri Kosina unsigned offset = field->report_offset; 905dde5845aSJiri Kosina unsigned size = field->report_size; 906dde5845aSJiri Kosina __s32 min = field->logical_minimum; 907dde5845aSJiri Kosina __s32 max = field->logical_maximum; 908dde5845aSJiri Kosina __s32 *value; 909dde5845aSJiri Kosina 910a3789a17SJoe Perches value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC); 911a3789a17SJoe Perches if (!value) 912dde5845aSJiri Kosina return; 913dde5845aSJiri Kosina 914dde5845aSJiri Kosina for (n = 0; n < count; n++) { 915dde5845aSJiri Kosina 9164291ee30SJoe Perches value[n] = min < 0 ? 9174291ee30SJoe Perches snto32(extract(hid, data, offset + n * size, size), 9184291ee30SJoe Perches size) : 9194291ee30SJoe Perches extract(hid, data, offset + n * size, size); 920dde5845aSJiri Kosina 9214291ee30SJoe Perches /* Ignore report if ErrorRollOver */ 9224291ee30SJoe Perches if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && 9234291ee30SJoe Perches value[n] >= min && value[n] <= max && 9244291ee30SJoe Perches field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) 925dde5845aSJiri Kosina goto exit; 926dde5845aSJiri Kosina } 927dde5845aSJiri Kosina 928dde5845aSJiri Kosina for (n = 0; n < count; n++) { 929dde5845aSJiri Kosina 930dde5845aSJiri Kosina if (HID_MAIN_ITEM_VARIABLE & field->flags) { 931dde5845aSJiri Kosina hid_process_event(hid, field, &field->usage[n], value[n], interrupt); 932dde5845aSJiri Kosina continue; 933dde5845aSJiri Kosina } 934dde5845aSJiri Kosina 935dde5845aSJiri Kosina if (field->value[n] >= min && field->value[n] <= max 936dde5845aSJiri Kosina && field->usage[field->value[n] - min].hid 937dde5845aSJiri Kosina && search(value, field->value[n], count)) 938dde5845aSJiri Kosina hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); 939dde5845aSJiri Kosina 940dde5845aSJiri Kosina if (value[n] >= min && value[n] <= max 941dde5845aSJiri Kosina && field->usage[value[n] - min].hid 942dde5845aSJiri Kosina && search(field->value, value[n], count)) 943dde5845aSJiri Kosina hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); 944dde5845aSJiri Kosina } 945dde5845aSJiri Kosina 946dde5845aSJiri Kosina memcpy(field->value, value, count * sizeof(__s32)); 947dde5845aSJiri Kosina exit: 948dde5845aSJiri Kosina kfree(value); 949dde5845aSJiri Kosina } 950dde5845aSJiri Kosina 951dde5845aSJiri Kosina /* 952dde5845aSJiri Kosina * Output the field into the report. 953dde5845aSJiri Kosina */ 954dde5845aSJiri Kosina 9554291ee30SJoe Perches static void hid_output_field(const struct hid_device *hid, 9564291ee30SJoe Perches struct hid_field *field, __u8 *data) 957dde5845aSJiri Kosina { 958dde5845aSJiri Kosina unsigned count = field->report_count; 959dde5845aSJiri Kosina unsigned offset = field->report_offset; 960dde5845aSJiri Kosina unsigned size = field->report_size; 961dde5845aSJiri Kosina unsigned n; 962dde5845aSJiri Kosina 963dde5845aSJiri Kosina for (n = 0; n < count; n++) { 964dde5845aSJiri Kosina if (field->logical_minimum < 0) /* signed values */ 9654291ee30SJoe Perches implement(hid, data, offset + n * size, size, 9664291ee30SJoe Perches s32ton(field->value[n], size)); 967dde5845aSJiri Kosina else /* unsigned values */ 9684291ee30SJoe Perches implement(hid, data, offset + n * size, size, 9694291ee30SJoe Perches field->value[n]); 970dde5845aSJiri Kosina } 971dde5845aSJiri Kosina } 972dde5845aSJiri Kosina 973dde5845aSJiri Kosina /* 974dde5845aSJiri Kosina * Create a report. 975dde5845aSJiri Kosina */ 976dde5845aSJiri Kosina 977229695e5SJiri Kosina void hid_output_report(struct hid_report *report, __u8 *data) 978dde5845aSJiri Kosina { 979dde5845aSJiri Kosina unsigned n; 980dde5845aSJiri Kosina 981dde5845aSJiri Kosina if (report->id > 0) 982dde5845aSJiri Kosina *data++ = report->id; 983dde5845aSJiri Kosina 98475c28df8SPete Zaitcev memset(data, 0, ((report->size - 1) >> 3) + 1); 985dde5845aSJiri Kosina for (n = 0; n < report->maxfield; n++) 9864291ee30SJoe Perches hid_output_field(report->device, report->field[n], data); 987dde5845aSJiri Kosina } 988229695e5SJiri Kosina EXPORT_SYMBOL_GPL(hid_output_report); 989dde5845aSJiri Kosina 990dde5845aSJiri Kosina /* 991dde5845aSJiri Kosina * Set a field value. The report this field belongs to has to be 992dde5845aSJiri Kosina * created and transferred to the device, to set this value in the 993dde5845aSJiri Kosina * device. 994dde5845aSJiri Kosina */ 995dde5845aSJiri Kosina 996dde5845aSJiri Kosina int hid_set_field(struct hid_field *field, unsigned offset, __s32 value) 997dde5845aSJiri Kosina { 998dde5845aSJiri Kosina unsigned size = field->report_size; 999dde5845aSJiri Kosina 1000cd667ce2SJiri Kosina hid_dump_input(field->report->device, field->usage + offset, value); 1001dde5845aSJiri Kosina 1002dde5845aSJiri Kosina if (offset >= field->report_count) { 10038c3d52fcSJiri Kosina hid_err(field->report->device, "offset (%d) exceeds report_count (%d)\n", 10048c3d52fcSJiri Kosina offset, field->report_count); 1005dde5845aSJiri Kosina return -1; 1006dde5845aSJiri Kosina } 1007dde5845aSJiri Kosina if (field->logical_minimum < 0) { 1008dde5845aSJiri Kosina if (value != snto32(s32ton(value, size), size)) { 10098c3d52fcSJiri Kosina hid_err(field->report->device, "value %d is out of range\n", value); 1010dde5845aSJiri Kosina return -1; 1011dde5845aSJiri Kosina } 1012dde5845aSJiri Kosina } 1013dde5845aSJiri Kosina field->value[offset] = value; 1014dde5845aSJiri Kosina return 0; 1015dde5845aSJiri Kosina } 1016229695e5SJiri Kosina EXPORT_SYMBOL_GPL(hid_set_field); 1017dde5845aSJiri Kosina 101885cdaf52SJiri Slaby static struct hid_report *hid_get_report(struct hid_report_enum *report_enum, 101985cdaf52SJiri Slaby const u8 *data) 102085cdaf52SJiri Slaby { 102185cdaf52SJiri Slaby struct hid_report *report; 102285cdaf52SJiri Slaby unsigned int n = 0; /* Normally report number is 0 */ 102385cdaf52SJiri Slaby 102485cdaf52SJiri Slaby /* Device uses numbered reports, data[0] is report number */ 102585cdaf52SJiri Slaby if (report_enum->numbered) 102685cdaf52SJiri Slaby n = *data; 102785cdaf52SJiri Slaby 102885cdaf52SJiri Slaby report = report_enum->report_id_hash[n]; 102985cdaf52SJiri Slaby if (report == NULL) 103085cdaf52SJiri Slaby dbg_hid("undefined report_id %u received\n", n); 103185cdaf52SJiri Slaby 103285cdaf52SJiri Slaby return report; 103385cdaf52SJiri Slaby } 103485cdaf52SJiri Slaby 103585cdaf52SJiri Slaby void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, 103685cdaf52SJiri Slaby int interrupt) 1037aa8de2f0SJiri Kosina { 1038aa8de2f0SJiri Kosina struct hid_report_enum *report_enum = hid->report_enum + type; 1039aa8de2f0SJiri Kosina struct hid_report *report; 104085cdaf52SJiri Slaby unsigned int a; 104185cdaf52SJiri Slaby int rsize, csize = size; 104285cdaf52SJiri Slaby u8 *cdata = data; 1043aa8de2f0SJiri Kosina 104485cdaf52SJiri Slaby report = hid_get_report(report_enum, data); 104585cdaf52SJiri Slaby if (!report) 104685cdaf52SJiri Slaby return; 1047aa8de2f0SJiri Kosina 104885cdaf52SJiri Slaby if (report_enum->numbered) { 104985cdaf52SJiri Slaby cdata++; 105085cdaf52SJiri Slaby csize--; 1051aa8de2f0SJiri Kosina } 1052aa8de2f0SJiri Kosina 1053aa8de2f0SJiri Kosina rsize = ((report->size - 1) >> 3) + 1; 1054aa8de2f0SJiri Kosina 1055966922f2SArmando Visconti if (rsize > HID_MAX_BUFFER_SIZE) 1056966922f2SArmando Visconti rsize = HID_MAX_BUFFER_SIZE; 1057966922f2SArmando Visconti 105885cdaf52SJiri Slaby if (csize < rsize) { 105985cdaf52SJiri Slaby dbg_hid("report %d is too short, (%d < %d)\n", report->id, 106085cdaf52SJiri Slaby csize, rsize); 106185cdaf52SJiri Slaby memset(cdata + csize, 0, rsize - csize); 1062aa8de2f0SJiri Kosina } 1063aa8de2f0SJiri Kosina 1064aa8de2f0SJiri Kosina if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) 1065aa8de2f0SJiri Kosina hid->hiddev_report_event(hid, report); 10665a38f2c7SAlan Ott if (hid->claimed & HID_CLAIMED_HIDRAW) 106786166b7bSJiri Kosina hidraw_report_event(hid, data, size); 1068aa8de2f0SJiri Kosina 106985cdaf52SJiri Slaby for (a = 0; a < report->maxfield; a++) 107085cdaf52SJiri Slaby hid_input_field(hid, report->field[a], cdata, interrupt); 1071aa8de2f0SJiri Kosina 1072aa8de2f0SJiri Kosina if (hid->claimed & HID_CLAIMED_INPUT) 1073aa8de2f0SJiri Kosina hidinput_report_event(hid, report); 107485cdaf52SJiri Slaby } 107585cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_report_raw_event); 107685cdaf52SJiri Slaby 107785cdaf52SJiri Slaby /** 107885cdaf52SJiri Slaby * hid_input_report - report data from lower layer (usb, bt...) 107985cdaf52SJiri Slaby * 108085cdaf52SJiri Slaby * @hid: hid device 108185cdaf52SJiri Slaby * @type: HID report type (HID_*_REPORT) 108285cdaf52SJiri Slaby * @data: report contents 108385cdaf52SJiri Slaby * @size: size of data parameter 1084ff9b00a2SJiri Kosina * @interrupt: distinguish between interrupt and control transfers 108585cdaf52SJiri Slaby * 108685cdaf52SJiri Slaby * This is data entry for lower layers. 108785cdaf52SJiri Slaby */ 108885cdaf52SJiri Slaby int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) 108985cdaf52SJiri Slaby { 109076c317d6SJulia Lawall struct hid_report_enum *report_enum; 109176c317d6SJulia Lawall struct hid_driver *hdrv; 109285cdaf52SJiri Slaby struct hid_report *report; 1093cd667ce2SJiri Kosina char *buf; 109485cdaf52SJiri Slaby unsigned int i; 109545dc1ac7SJiri Kosina int ret = 0; 109685cdaf52SJiri Slaby 10974ea54542SDavid Herrmann if (!hid) 109885cdaf52SJiri Slaby return -ENODEV; 10994ea54542SDavid Herrmann 11004ea54542SDavid Herrmann if (down_trylock(&hid->driver_lock)) 11014ea54542SDavid Herrmann return -EBUSY; 11024ea54542SDavid Herrmann 11034ea54542SDavid Herrmann if (!hid->driver) { 11044ea54542SDavid Herrmann ret = -ENODEV; 11054ea54542SDavid Herrmann goto unlock; 11064ea54542SDavid Herrmann } 110776c317d6SJulia Lawall report_enum = hid->report_enum + type; 110876c317d6SJulia Lawall hdrv = hid->driver; 110985cdaf52SJiri Slaby 111085cdaf52SJiri Slaby if (!size) { 111185cdaf52SJiri Slaby dbg_hid("empty report\n"); 11124ea54542SDavid Herrmann ret = -1; 11134ea54542SDavid Herrmann goto unlock; 111485cdaf52SJiri Slaby } 111585cdaf52SJiri Slaby 1116d1ff6522SJiri Kosina buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC); 1117cd667ce2SJiri Kosina 1118f77e347bSJiri Kosina if (!buf) 1119cd667ce2SJiri Kosina goto nomem; 112085cdaf52SJiri Slaby 112185cdaf52SJiri Slaby /* dump the report */ 1122cd667ce2SJiri Kosina snprintf(buf, HID_DEBUG_BUFSIZE - 1, 11231caea61eSJiri Kosina "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un"); 1124cd667ce2SJiri Kosina hid_debug_event(hid, buf); 11251caea61eSJiri Kosina 1126cd667ce2SJiri Kosina for (i = 0; i < size; i++) { 1127cd667ce2SJiri Kosina snprintf(buf, HID_DEBUG_BUFSIZE - 1, 1128cd667ce2SJiri Kosina " %02x", data[i]); 1129cd667ce2SJiri Kosina hid_debug_event(hid, buf); 1130cd667ce2SJiri Kosina } 1131cd667ce2SJiri Kosina hid_debug_event(hid, "\n"); 1132cd667ce2SJiri Kosina kfree(buf); 1133cd667ce2SJiri Kosina 1134cd667ce2SJiri Kosina nomem: 1135f77e347bSJiri Kosina report = hid_get_report(report_enum, data); 1136f77e347bSJiri Kosina 11374ea54542SDavid Herrmann if (!report) { 11384ea54542SDavid Herrmann ret = -1; 11394ea54542SDavid Herrmann goto unlock; 11404ea54542SDavid Herrmann } 1141f77e347bSJiri Kosina 114285cdaf52SJiri Slaby if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { 114385cdaf52SJiri Slaby ret = hdrv->raw_event(hid, report, data, size); 11444ea54542SDavid Herrmann if (ret != 0) { 11454ea54542SDavid Herrmann ret = ret < 0 ? ret : 0; 11464ea54542SDavid Herrmann goto unlock; 11474ea54542SDavid Herrmann } 114885cdaf52SJiri Slaby } 114985cdaf52SJiri Slaby 115085cdaf52SJiri Slaby hid_report_raw_event(hid, type, data, size, interrupt); 1151aa8de2f0SJiri Kosina 11524ea54542SDavid Herrmann unlock: 11534ea54542SDavid Herrmann up(&hid->driver_lock); 115445dc1ac7SJiri Kosina return ret; 1155aa8de2f0SJiri Kosina } 1156aa8de2f0SJiri Kosina EXPORT_SYMBOL_GPL(hid_input_report); 1157aa8de2f0SJiri Kosina 11580f37cd03SJiri Kosina static bool hid_match_one_id(struct hid_device *hdev, 11590f37cd03SJiri Kosina const struct hid_device_id *id) 11600f37cd03SJiri Kosina { 11610f37cd03SJiri Kosina return id->bus == hdev->bus && 11620f37cd03SJiri Kosina (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && 11630f37cd03SJiri Kosina (id->product == HID_ANY_ID || id->product == hdev->product); 11640f37cd03SJiri Kosina } 11650f37cd03SJiri Kosina 1166bbc21cfdSJeremy Fitzhardinge const struct hid_device_id *hid_match_id(struct hid_device *hdev, 11670f37cd03SJiri Kosina const struct hid_device_id *id) 11680f37cd03SJiri Kosina { 11690f37cd03SJiri Kosina for (; id->bus; id++) 11700f37cd03SJiri Kosina if (hid_match_one_id(hdev, id)) 11710f37cd03SJiri Kosina return id; 11720f37cd03SJiri Kosina 11730f37cd03SJiri Kosina return NULL; 11740f37cd03SJiri Kosina } 11750f37cd03SJiri Kosina 11760f37cd03SJiri Kosina static const struct hid_device_id hid_hiddev_list[] = { 1177c0bd6a42SRichard Hughes { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, 1178c0bd6a42SRichard Hughes { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, 11790f37cd03SJiri Kosina { } 11800f37cd03SJiri Kosina }; 11810f37cd03SJiri Kosina 11820f37cd03SJiri Kosina static bool hid_hiddev(struct hid_device *hdev) 11830f37cd03SJiri Kosina { 11840f37cd03SJiri Kosina return !!hid_match_id(hdev, hid_hiddev_list); 11850f37cd03SJiri Kosina } 11860f37cd03SJiri Kosina 11876d3bfb74SAlan Ott 11886d3bfb74SAlan Ott static ssize_t 11896d3bfb74SAlan Ott read_report_descriptor(struct file *filp, struct kobject *kobj, 11906d3bfb74SAlan Ott struct bin_attribute *attr, 11916d3bfb74SAlan Ott char *buf, loff_t off, size_t count) 11926d3bfb74SAlan Ott { 11936d3bfb74SAlan Ott struct device *dev = container_of(kobj, struct device, kobj); 11946d3bfb74SAlan Ott struct hid_device *hdev = container_of(dev, struct hid_device, dev); 11956d3bfb74SAlan Ott 11966d3bfb74SAlan Ott if (off >= hdev->rsize) 11976d3bfb74SAlan Ott return 0; 11986d3bfb74SAlan Ott 11996d3bfb74SAlan Ott if (off + count > hdev->rsize) 12006d3bfb74SAlan Ott count = hdev->rsize - off; 12016d3bfb74SAlan Ott 12026d3bfb74SAlan Ott memcpy(buf, hdev->rdesc + off, count); 12036d3bfb74SAlan Ott 12046d3bfb74SAlan Ott return count; 12056d3bfb74SAlan Ott } 12066d3bfb74SAlan Ott 12076d3bfb74SAlan Ott static struct bin_attribute dev_bin_attr_report_desc = { 12086d3bfb74SAlan Ott .attr = { .name = "report_descriptor", .mode = 0444 }, 12096d3bfb74SAlan Ott .read = read_report_descriptor, 12106d3bfb74SAlan Ott .size = HID_MAX_DESCRIPTOR_SIZE, 12116d3bfb74SAlan Ott }; 12126d3bfb74SAlan Ott 121393c10132SJiri Slaby int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 121493c10132SJiri Slaby { 121593c10132SJiri Slaby static const char *types[] = { "Device", "Pointer", "Mouse", "Device", 121693c10132SJiri Slaby "Joystick", "Gamepad", "Keyboard", "Keypad", 121793c10132SJiri Slaby "Multi-Axis Controller" 121893c10132SJiri Slaby }; 121993c10132SJiri Slaby const char *type, *bus; 122093c10132SJiri Slaby char buf[64]; 122193c10132SJiri Slaby unsigned int i; 122293c10132SJiri Slaby int len; 12236d3bfb74SAlan Ott int ret; 122493c10132SJiri Slaby 1225b5e5a37eSBastien Nocera if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) 1226b5e5a37eSBastien Nocera connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV); 12273a343ee4SDaniel Mack if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE) 12283a343ee4SDaniel Mack connect_mask |= HID_CONNECT_HIDINPUT_FORCE; 122993c10132SJiri Slaby if (hdev->bus != BUS_USB) 123093c10132SJiri Slaby connect_mask &= ~HID_CONNECT_HIDDEV; 12310f37cd03SJiri Kosina if (hid_hiddev(hdev)) 12320f37cd03SJiri Kosina connect_mask |= HID_CONNECT_HIDDEV_FORCE; 123393c10132SJiri Slaby 123493c10132SJiri Slaby if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev, 123593c10132SJiri Slaby connect_mask & HID_CONNECT_HIDINPUT_FORCE)) 123693c10132SJiri Slaby hdev->claimed |= HID_CLAIMED_INPUT; 1237b77c3920SBenjamin Tissoires if (hdev->quirks & HID_QUIRK_MULTITOUCH) { 1238b77c3920SBenjamin Tissoires /* this device should be handled by hid-multitouch, skip it */ 1239b77c3920SBenjamin Tissoires hdev->quirks &= ~HID_QUIRK_MULTITOUCH; 1240b77c3920SBenjamin Tissoires return -ENODEV; 1241b77c3920SBenjamin Tissoires } 1242b77c3920SBenjamin Tissoires 124393c10132SJiri Slaby if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect && 124493c10132SJiri Slaby !hdev->hiddev_connect(hdev, 124593c10132SJiri Slaby connect_mask & HID_CONNECT_HIDDEV_FORCE)) 124693c10132SJiri Slaby hdev->claimed |= HID_CLAIMED_HIDDEV; 124793c10132SJiri Slaby if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev)) 124893c10132SJiri Slaby hdev->claimed |= HID_CLAIMED_HIDRAW; 124993c10132SJiri Slaby 125093c10132SJiri Slaby if (!hdev->claimed) { 12514291ee30SJoe Perches hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n"); 125293c10132SJiri Slaby return -ENODEV; 125393c10132SJiri Slaby } 125493c10132SJiri Slaby 125593c10132SJiri Slaby if ((hdev->claimed & HID_CLAIMED_INPUT) && 125693c10132SJiri Slaby (connect_mask & HID_CONNECT_FF) && hdev->ff_init) 125793c10132SJiri Slaby hdev->ff_init(hdev); 125893c10132SJiri Slaby 125993c10132SJiri Slaby len = 0; 126093c10132SJiri Slaby if (hdev->claimed & HID_CLAIMED_INPUT) 126193c10132SJiri Slaby len += sprintf(buf + len, "input"); 126293c10132SJiri Slaby if (hdev->claimed & HID_CLAIMED_HIDDEV) 126393c10132SJiri Slaby len += sprintf(buf + len, "%shiddev%d", len ? "," : "", 126493c10132SJiri Slaby hdev->minor); 126593c10132SJiri Slaby if (hdev->claimed & HID_CLAIMED_HIDRAW) 126693c10132SJiri Slaby len += sprintf(buf + len, "%shidraw%d", len ? "," : "", 126793c10132SJiri Slaby ((struct hidraw *)hdev->hidraw)->minor); 126893c10132SJiri Slaby 126993c10132SJiri Slaby type = "Device"; 127093c10132SJiri Slaby for (i = 0; i < hdev->maxcollection; i++) { 127193c10132SJiri Slaby struct hid_collection *col = &hdev->collection[i]; 127293c10132SJiri Slaby if (col->type == HID_COLLECTION_APPLICATION && 127393c10132SJiri Slaby (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK && 127493c10132SJiri Slaby (col->usage & 0xffff) < ARRAY_SIZE(types)) { 127593c10132SJiri Slaby type = types[col->usage & 0xffff]; 127693c10132SJiri Slaby break; 127793c10132SJiri Slaby } 127893c10132SJiri Slaby } 127993c10132SJiri Slaby 128093c10132SJiri Slaby switch (hdev->bus) { 128193c10132SJiri Slaby case BUS_USB: 128293c10132SJiri Slaby bus = "USB"; 128393c10132SJiri Slaby break; 128493c10132SJiri Slaby case BUS_BLUETOOTH: 128593c10132SJiri Slaby bus = "BLUETOOTH"; 128693c10132SJiri Slaby break; 128793c10132SJiri Slaby default: 128893c10132SJiri Slaby bus = "<UNKNOWN>"; 128993c10132SJiri Slaby } 129093c10132SJiri Slaby 12916d3bfb74SAlan Ott ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc); 12926d3bfb74SAlan Ott if (ret) 12936d3bfb74SAlan Ott hid_warn(hdev, 12946d3bfb74SAlan Ott "can't create sysfs report descriptor attribute err: %d\n", ret); 12956d3bfb74SAlan Ott 12964291ee30SJoe Perches hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", 129793c10132SJiri Slaby buf, bus, hdev->version >> 8, hdev->version & 0xff, 129893c10132SJiri Slaby type, hdev->name, hdev->phys); 129993c10132SJiri Slaby 130093c10132SJiri Slaby return 0; 130193c10132SJiri Slaby } 130293c10132SJiri Slaby EXPORT_SYMBOL_GPL(hid_connect); 130393c10132SJiri Slaby 1304c4c259bcSJiri Kosina void hid_disconnect(struct hid_device *hdev) 1305c4c259bcSJiri Kosina { 13066d3bfb74SAlan Ott device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc); 1307c4c259bcSJiri Kosina if (hdev->claimed & HID_CLAIMED_INPUT) 1308c4c259bcSJiri Kosina hidinput_disconnect(hdev); 1309c4c259bcSJiri Kosina if (hdev->claimed & HID_CLAIMED_HIDDEV) 1310c4c259bcSJiri Kosina hdev->hiddev_disconnect(hdev); 1311c4c259bcSJiri Kosina if (hdev->claimed & HID_CLAIMED_HIDRAW) 1312c4c259bcSJiri Kosina hidraw_disconnect(hdev); 1313c4c259bcSJiri Kosina } 1314c4c259bcSJiri Kosina EXPORT_SYMBOL_GPL(hid_disconnect); 1315c4c259bcSJiri Kosina 1316bae7eb33SJiri Kosina /* a list of devices for which there is a specialized driver on HID bus */ 1317ce06b9d6SDmitry Torokhov static const struct hid_device_id hid_have_special_driver[] = { 1318b6353f4fSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, 13196dec143aSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, 132014a21cd4SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 132114a21cd4SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1322b7e1b203SLech Perczak { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, 1323c0dbcc33SSergei Kolzun { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) }, 1324e6aac342SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR, USB_DEVICE_ID_ACTIONSTAR_1011) }, 1325df9bcaceSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, 13268c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, 13278c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, 1328128537ceSMichael Poole { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) }, 1329a462230eSChase Douglas { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) }, 13308c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 13318c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 13328c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 13338c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 13348c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 13358c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 13368c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 13378c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 13388c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 13398c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 13408c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1341fef3f571SRyan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI) }, 1342fef3f571SRyan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO) }, 1343fef3f571SRyan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS) }, 13448c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) }, 13458c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) }, 13468c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) }, 13478c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 13488c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 13498c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1350ee8a1a0aSJan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, 1351ee8a1a0aSJan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, 1352ee8a1a0aSJan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, 13538c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 13548c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 13558c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 13568c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 13578c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 13588c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1359a96d6ef3SHenrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1360a96d6ef3SHenrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1361a96d6ef3SHenrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 136299b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 136399b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 136499b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 136599b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 136699b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 136799b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 136847340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, 136947340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, 137047340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, 1371213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) }, 1372213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) }, 1373213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) }, 13744a4c8799SDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) }, 13754a4c8799SDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) }, 13764a4c8799SDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) }, 1377f6f554f0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) }, 1378f6f554f0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) }, 1379f6f554f0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) }, 1380d762cc29SNobuhiro Iwamatsu { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 1381d762cc29SNobuhiro Iwamatsu { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 1382d762cc29SNobuhiro Iwamatsu { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 138323aeb61eSChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, 138423aeb61eSChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, 138523aeb61eSChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 1386ad734bc1SAndreas Krist { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) }, 13878c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 13888c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1389eaca1386SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) }, 1390cec15a0eSRoland Baum { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, 1391b5635b12SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1392bf280628SWayne Thomas { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, 1393c3dc66deSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, 13945519cab4SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, 139536213e1eSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, 1396bc5ab083SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) }, 1397ba4d8abbSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, 1398272036edSFrançois Jaouen { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, 13993b239cd7SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 14001ce31b25SRaphaël Doursenaud { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, 1401fcfacfd3SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1402b9e4b1e0SDennis Kügler { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, 14033596bb92SKeng-Yu Lin { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) }, 1404942fd422SAustin Zhang { HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, 14053a370ca1SDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, 140679603dc9SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, USB_DEVICE_ID_CVTOUCH_SCREEN) }, 14070f221320SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 14080f221320SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, 1409e8d0eab4SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) }, 14100f221320SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, 1411a3b5e577SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, 14123f866fbdSRichard Walmsley { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, 1413e05eefb9SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) }, 1414e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) }, 1415e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) }, 1416e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) }, 1417e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) }, 1418e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) }, 1419bb9ff210SMarek Vasut { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) }, 1420e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) }, 142164b386eaSRichard Nauber { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 1422c04abeefSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2515) }, 142304561c5aSIgnaz Forster { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) }, 14241f243e30SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 1425*4d5df5d1SAndreas Nielsen { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_FRUCTEL, USB_DEVICE_ID_GAMETEL_MT_MODE) }, 14265181e594SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, 1427578f3a35SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, 14285572da08SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, 1429ee0fbd14SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, USB_DEVICE_ID_GOODTOUCH_000f) }, 14305181e594SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, 143142859e0bSLukasz Lubojanski { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) }, 1432949f8fefSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, 14331e093206SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, 1434c2fd1a4eSCory Maccarrone { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, 14355519cab4SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_HANVON, USB_DEVICE_ID_HANVON_MULTITOUCH) }, 143654580365SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, 1437a062cc5aSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM, USB_DEVICE_ID_IDEACOM_IDC6650) }, 1438d946e65eSAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) }, 14394e61f0d7SAustin Zhang { HID_USB_DEVICE(USB_VENDOR_ID_ILITEK, USB_DEVICE_ID_ILITEK_MULTITOUCH) }, 1440b2e7617eSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS, USB_DEVICE_ID_IRTOUCH_INFRARED_USB) }, 1441fdf93aa3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, 1442177900e8SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, 144379422741SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, 144422ca20b2SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) }, 144522ca20b2SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) }, 144622ca20b2SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) }, 1447b5635b12SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 144875b07022SChris Schlund { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) }, 1449c50bb1a4SJeff Brown { HID_USB_DEVICE(USB_VENDOR_ID_LG, USB_DEVICE_ID_LG_MULTITOUCH) }, 14505f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, 14515f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, 14525f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, 14535f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, 14545f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, 14555f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, 14565f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, 14575f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, 14585f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, 14595f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, 14605f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) }, 14612c6118e4SHendrik Iben { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) }, 1462606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) }, 1463606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) }, 1464606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, 1465fd30ea8cSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) }, 1466606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, 146774f292caSGary Stein { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) }, 1468606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) }, 1469606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) }, 14705623a24aSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL) }, 1471e00ddc9bSMichal Malý { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL) }, 1472243b706dSChristophe Borivant { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) }, 1473fdc6807fSPeter Gundermann { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G27_WHEEL) }, 14740944e964SKonstantin Khlebnikov #if IS_ENABLED(CONFIG_HID_LOGITECH_DJ) 1475534a7b8eSNestor Lopez Casado { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER) }, 1476534a7b8eSNestor Lopez Casado { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2) }, 14770944e964SKonstantin Khlebnikov #endif 147832c88cbcSSimon Wood { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) }, 1479606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, 148024985cf6SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) }, 148124985cf6SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) }, 1482df167c4aSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH) }, 1483c3ead6deSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH_DUAL) }, 1484236db47cSBruno Prémont { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, 1485236db47cSBruno Prémont { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) }, 1486b580169aSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) }, 148778a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, 148878a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, 148978a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, 149078a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, 1491f3b83d71SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) }, 149278a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 14933b8006e5SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 149494011f93SRafi Rubin { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, 14956e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) }, 14966e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) }, 14976e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) }, 14986e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) }, 14996e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) }, 15006e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) }, 15016e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) }, 15026e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) }, 15036e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) }, 15046e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) }, 15056e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) }, 15066e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) }, 15076e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) }, 15086e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) }, 15096e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) }, 15106e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) }, 15116e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) }, 15126e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) }, 1513270fdc07SHerton Ronaldo Krzesinski { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) }, 1514cd9ec30dSJohnathon Harris { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, 15156ab3a9a6SJohn Sung { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_PCI) }, 15161e762532SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 1517b7ea95ffSAaron Tian { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) }, 1518b7ea95ffSAaron Tian { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) }, 1519b7ea95ffSAaron Tian { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) }, 1520f6a04605STerry Lambert { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) }, 152149e4739aSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, 1522f54405dbSAlex Neblett { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, 152314bf62cdSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, 1524e68cc603SStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) }, 1525d41c2a70SStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) }, 152647dbdbffSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, 15270e70f97fSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) }, 1528cb7cf3daSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, 15293fce2246SStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) }, 15301e93674aSAndreas Hübner { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000) }, 1531980a3da6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1532b355850bSDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, 1533d586dca0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) }, 1534bd28ce00SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 153535dca5b4SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) }, 1536f9ce7c28SBastien Nocera { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1537cc6e0bbbSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1538d3fb5454SStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) }, 1539b6dc7992SPascal Auriel - Stantum { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) }, 1540b6dc7992SPascal Auriel - Stantum { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) }, 154190231e7eSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1542daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1543daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, 15447a84b133SRuben Aos Garralda { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, 15457a84b133SRuben Aos Garralda { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) }, 1546daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, 15473ee8f0a2SMarkus Rathgeb { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) }, 1548daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, 1549d65c3768SSimon Wood { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) }, 1550740363fbSJiri Kosina { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_BT) }, 155144ea35c1SJarod Wilson { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE) }, 1552f14f526dSLev Babiev { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, 155354001081SKees Bakker { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) }, 15545e74e56dSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, 1555711a680eSBruno Premont { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, 1556c64f6f93SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, 155741fa9230SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, 1558f8a489ccSNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) }, 1559f8a489ccSNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) }, 1560f8a489ccSNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) }, 15616be914f1SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) }, 1562617b64f9SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, 1563617b64f9SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, 1564fac733f0SJussi Kivilinna { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, 156542fc04e5SSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SUPER_JOY_BOX_3) }, 1566ad395ccaSSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) }, 15671bcc2067SSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) }, 15681bcc2067SSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) }, 15691bcc2067SSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) }, 1570ca2dcd40SBastien Nocera { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, 157178761ff9SPrzemo Firszt { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, 157272a46344SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, 157300e7f964SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, 15744fdc18d1SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_Q_PAD) }, 1575a786e83cSNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_PID_0038) }, 157672a46344SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, 15778f1acc32SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, 1578bc8a2a9bSice chien { HID_USB_DEVICE(USB_VENDOR_ID_XAT, USB_DEVICE_ID_XAT_CSR) }, 157911576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX) }, 158011576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX) }, 158111576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR) }, 158211576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX1) }, 158311576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX1) }, 158411576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR1) }, 158511576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX2) }, 158611576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX2) }, 158711576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR2) }, 158874bc6953SStefan Kriwanek { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) }, 1589daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, 1590daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, 1591a9885c8fSDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, 15928c19a515SJiri Slaby 159378a849a6SJiri Slaby { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, 159402fb72a0SDavid Herrmann { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) }, 159585cdaf52SJiri Slaby { } 159685cdaf52SJiri Slaby }; 159785cdaf52SJiri Slaby 15983a6f82f7SJiri Slaby struct hid_dynid { 15993a6f82f7SJiri Slaby struct list_head list; 16003a6f82f7SJiri Slaby struct hid_device_id id; 16013a6f82f7SJiri Slaby }; 16023a6f82f7SJiri Slaby 16033a6f82f7SJiri Slaby /** 16043a6f82f7SJiri Slaby * store_new_id - add a new HID device ID to this driver and re-probe devices 16053a6f82f7SJiri Slaby * @driver: target device driver 16063a6f82f7SJiri Slaby * @buf: buffer for scanning device ID data 16073a6f82f7SJiri Slaby * @count: input size 16083a6f82f7SJiri Slaby * 16093a6f82f7SJiri Slaby * Adds a new dynamic hid device ID to this driver, 16103a6f82f7SJiri Slaby * and causes the driver to probe for all devices again. 16113a6f82f7SJiri Slaby */ 16123a6f82f7SJiri Slaby static ssize_t store_new_id(struct device_driver *drv, const char *buf, 16133a6f82f7SJiri Slaby size_t count) 16143a6f82f7SJiri Slaby { 16153a6f82f7SJiri Slaby struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 16163a6f82f7SJiri Slaby struct hid_dynid *dynid; 16173a6f82f7SJiri Slaby __u32 bus, vendor, product; 16183a6f82f7SJiri Slaby unsigned long driver_data = 0; 16193a6f82f7SJiri Slaby int ret; 16203a6f82f7SJiri Slaby 16213a6f82f7SJiri Slaby ret = sscanf(buf, "%x %x %x %lx", 16223a6f82f7SJiri Slaby &bus, &vendor, &product, &driver_data); 16233a6f82f7SJiri Slaby if (ret < 3) 16243a6f82f7SJiri Slaby return -EINVAL; 16253a6f82f7SJiri Slaby 16263a6f82f7SJiri Slaby dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 16273a6f82f7SJiri Slaby if (!dynid) 16283a6f82f7SJiri Slaby return -ENOMEM; 16293a6f82f7SJiri Slaby 16303a6f82f7SJiri Slaby dynid->id.bus = bus; 16313a6f82f7SJiri Slaby dynid->id.vendor = vendor; 16323a6f82f7SJiri Slaby dynid->id.product = product; 16333a6f82f7SJiri Slaby dynid->id.driver_data = driver_data; 16343a6f82f7SJiri Slaby 16353a6f82f7SJiri Slaby spin_lock(&hdrv->dyn_lock); 16363a6f82f7SJiri Slaby list_add_tail(&dynid->list, &hdrv->dyn_list); 16373a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16383a6f82f7SJiri Slaby 16393a6f82f7SJiri Slaby ret = 0; 16403a6f82f7SJiri Slaby if (get_driver(&hdrv->driver)) { 16413a6f82f7SJiri Slaby ret = driver_attach(&hdrv->driver); 16423a6f82f7SJiri Slaby put_driver(&hdrv->driver); 16433a6f82f7SJiri Slaby } 16443a6f82f7SJiri Slaby 16453a6f82f7SJiri Slaby return ret ? : count; 16463a6f82f7SJiri Slaby } 16473a6f82f7SJiri Slaby static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); 16483a6f82f7SJiri Slaby 16493a6f82f7SJiri Slaby static void hid_free_dynids(struct hid_driver *hdrv) 16503a6f82f7SJiri Slaby { 16513a6f82f7SJiri Slaby struct hid_dynid *dynid, *n; 16523a6f82f7SJiri Slaby 16533a6f82f7SJiri Slaby spin_lock(&hdrv->dyn_lock); 16543a6f82f7SJiri Slaby list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) { 16553a6f82f7SJiri Slaby list_del(&dynid->list); 16563a6f82f7SJiri Slaby kfree(dynid); 16573a6f82f7SJiri Slaby } 16583a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16593a6f82f7SJiri Slaby } 16603a6f82f7SJiri Slaby 16613a6f82f7SJiri Slaby static const struct hid_device_id *hid_match_device(struct hid_device *hdev, 16623a6f82f7SJiri Slaby struct hid_driver *hdrv) 16633a6f82f7SJiri Slaby { 16643a6f82f7SJiri Slaby struct hid_dynid *dynid; 16653a6f82f7SJiri Slaby 16663a6f82f7SJiri Slaby spin_lock(&hdrv->dyn_lock); 16673a6f82f7SJiri Slaby list_for_each_entry(dynid, &hdrv->dyn_list, list) { 16683a6f82f7SJiri Slaby if (hid_match_one_id(hdev, &dynid->id)) { 16693a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16703a6f82f7SJiri Slaby return &dynid->id; 16713a6f82f7SJiri Slaby } 16723a6f82f7SJiri Slaby } 16733a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16743a6f82f7SJiri Slaby 16753a6f82f7SJiri Slaby return hid_match_id(hdev, hdrv->id_table); 16763a6f82f7SJiri Slaby } 16773a6f82f7SJiri Slaby 167885cdaf52SJiri Slaby static int hid_bus_match(struct device *dev, struct device_driver *drv) 167985cdaf52SJiri Slaby { 168085cdaf52SJiri Slaby struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 168185cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 168285cdaf52SJiri Slaby 16833a6f82f7SJiri Slaby if (!hid_match_device(hdev, hdrv)) 168485cdaf52SJiri Slaby return 0; 168585cdaf52SJiri Slaby 1686ce06b9d6SDmitry Torokhov /* generic wants all that don't have specialized driver */ 16876b1968d5SJiri Kosina if (!strncmp(hdrv->name, "generic-", 8) && !hid_ignore_special_drivers) 1688ce06b9d6SDmitry Torokhov return !hid_match_id(hdev, hid_have_special_driver); 168985cdaf52SJiri Slaby 169085cdaf52SJiri Slaby return 1; 169185cdaf52SJiri Slaby } 169285cdaf52SJiri Slaby 169385cdaf52SJiri Slaby static int hid_device_probe(struct device *dev) 169485cdaf52SJiri Slaby { 169585cdaf52SJiri Slaby struct hid_driver *hdrv = container_of(dev->driver, 169685cdaf52SJiri Slaby struct hid_driver, driver); 169785cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 169885cdaf52SJiri Slaby const struct hid_device_id *id; 169985cdaf52SJiri Slaby int ret = 0; 170085cdaf52SJiri Slaby 17014ea54542SDavid Herrmann if (down_interruptible(&hdev->driver_lock)) 17024ea54542SDavid Herrmann return -EINTR; 17034ea54542SDavid Herrmann 170485cdaf52SJiri Slaby if (!hdev->driver) { 17053a6f82f7SJiri Slaby id = hid_match_device(hdev, hdrv); 1706ba623a77SDan Carpenter if (id == NULL) { 1707ba623a77SDan Carpenter ret = -ENODEV; 1708ba623a77SDan Carpenter goto unlock; 1709ba623a77SDan Carpenter } 1710c500c971SJiri Slaby 171185cdaf52SJiri Slaby hdev->driver = hdrv; 1712c500c971SJiri Slaby if (hdrv->probe) { 1713c500c971SJiri Slaby ret = hdrv->probe(hdev, id); 1714c500c971SJiri Slaby } else { /* default probe */ 1715c500c971SJiri Slaby ret = hid_parse(hdev); 1716c500c971SJiri Slaby if (!ret) 171793c10132SJiri Slaby ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 1718c500c971SJiri Slaby } 1719c500c971SJiri Slaby if (ret) 1720c500c971SJiri Slaby hdev->driver = NULL; 172185cdaf52SJiri Slaby } 1722ba623a77SDan Carpenter unlock: 17234ea54542SDavid Herrmann up(&hdev->driver_lock); 172485cdaf52SJiri Slaby return ret; 172585cdaf52SJiri Slaby } 172685cdaf52SJiri Slaby 172785cdaf52SJiri Slaby static int hid_device_remove(struct device *dev) 172885cdaf52SJiri Slaby { 172985cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 17304ea54542SDavid Herrmann struct hid_driver *hdrv; 173185cdaf52SJiri Slaby 17324ea54542SDavid Herrmann if (down_interruptible(&hdev->driver_lock)) 17334ea54542SDavid Herrmann return -EINTR; 17344ea54542SDavid Herrmann 17354ea54542SDavid Herrmann hdrv = hdev->driver; 173685cdaf52SJiri Slaby if (hdrv) { 173785cdaf52SJiri Slaby if (hdrv->remove) 173885cdaf52SJiri Slaby hdrv->remove(hdev); 1739c500c971SJiri Slaby else /* default remove */ 1740c500c971SJiri Slaby hid_hw_stop(hdev); 174185cdaf52SJiri Slaby hdev->driver = NULL; 174285cdaf52SJiri Slaby } 174385cdaf52SJiri Slaby 17444ea54542SDavid Herrmann up(&hdev->driver_lock); 174585cdaf52SJiri Slaby return 0; 174685cdaf52SJiri Slaby } 174785cdaf52SJiri Slaby 174885cdaf52SJiri Slaby static int hid_uevent(struct device *dev, struct kobj_uevent_env *env) 174985cdaf52SJiri Slaby { 175085cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 175185cdaf52SJiri Slaby 175285cdaf52SJiri Slaby if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", 175385cdaf52SJiri Slaby hdev->bus, hdev->vendor, hdev->product)) 175485cdaf52SJiri Slaby return -ENOMEM; 175585cdaf52SJiri Slaby 175685cdaf52SJiri Slaby if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) 175785cdaf52SJiri Slaby return -ENOMEM; 175885cdaf52SJiri Slaby 175985cdaf52SJiri Slaby if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) 176085cdaf52SJiri Slaby return -ENOMEM; 176185cdaf52SJiri Slaby 176285cdaf52SJiri Slaby if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) 176385cdaf52SJiri Slaby return -ENOMEM; 176485cdaf52SJiri Slaby 176585cdaf52SJiri Slaby if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X", 176685cdaf52SJiri Slaby hdev->bus, hdev->vendor, hdev->product)) 176785cdaf52SJiri Slaby return -ENOMEM; 176885cdaf52SJiri Slaby 176985cdaf52SJiri Slaby return 0; 177085cdaf52SJiri Slaby } 177185cdaf52SJiri Slaby 177285cdaf52SJiri Slaby static struct bus_type hid_bus_type = { 177385cdaf52SJiri Slaby .name = "hid", 177485cdaf52SJiri Slaby .match = hid_bus_match, 177585cdaf52SJiri Slaby .probe = hid_device_probe, 177685cdaf52SJiri Slaby .remove = hid_device_remove, 177785cdaf52SJiri Slaby .uevent = hid_uevent, 177885cdaf52SJiri Slaby }; 177985cdaf52SJiri Slaby 1780bae7eb33SJiri Kosina /* a list of devices that shouldn't be handled by HID core at all */ 1781d458a9dfSJiri Slaby static const struct hid_device_id hid_ignore_list[] = { 1782d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, 1783d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, 1784d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, 1785d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, 1786d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, 1787d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, 1788d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, 1789d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, 1790d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, 1791d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, 1792d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, 1793d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, 179477f720b7SStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)}, 179577f720b7SStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)}, 179662a56582SAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, 1797d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, 1798d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, 1799d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, 1800d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, 1801d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, 1802d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, 18035f6108cfSAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) }, 1804d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, 1805d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 180673bc7d31SMelchior FRANZ { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) }, 1807789aaa2eSDan Delaney { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x000a) }, 1808d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 180970c66567SPetr Štetiar { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) }, 1810df506f2cSPetr Štetiar { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) }, 1811b1807719SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, 1812d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 1813d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, 1814d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, 1815d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, 1816d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, 1817d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, 1818d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, 1819d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, 1820d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, 1821d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, 1822d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, 1823d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, 1824d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, 1825d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, 1826d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, 1827d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, 1828d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, 1829d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, 1830d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, 1831d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, 1832d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, 1833d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, 1834d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, 1835d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, 1836d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, 1837d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, 1838d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, 1839d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, 1840d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, 1841d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, 1842d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, 1843d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, 1844d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, 1845d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, 1846d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, 1847d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, 1848d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, 1849d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, 1850d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, 1851d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, 1852d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, 1853d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, 1854d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, 1855d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, 1856d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, 1857d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, 1858d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, 1859d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, 1860d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, 1861d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, 1862d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, 1863d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, 1864d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, 1865d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, 1866d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, 1867d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, 1868d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, 1869d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, 1870d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, 1871d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, 1872d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, 1873d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, 1874d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, 1875d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, 1876c91c21c5SAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, 1877d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, 1878eb8141ccSLamarque Vieira Souza { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) }, 1879d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, 1880ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) }, 1881d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, 1882ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) }, 1883d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, 1884ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) }, 1885ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) }, 1886ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) }, 1887ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, 1888ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, 1889ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, 1890d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, 1891d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, 1892d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, 1893ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) }, 1894ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) }, 1895ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) }, 1896d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, 1897d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, 1898ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) }, 1899d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, 1900d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, 1901d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, 1902d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, 1903d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, 1904ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) }, 1905ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) }, 1906ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) }, 1907ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) }, 1908ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) }, 1909ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) }, 1910ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) }, 1911d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, 1912d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, 1913d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, 1914d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, 1915d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, 1916d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, 1917d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, 1918d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, 1919d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, 1920d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, 1921d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, 1922d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, 1923d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, 1924d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, 1925d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, 1926d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, 1927d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, 1928d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, 1929d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, 19304cfae3e8SHenning Glawe { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, 193135cfd1d9SMichael Tokarev { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, 1932d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, 1933d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 1934d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 1935d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 1936d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 1937d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, 1938d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, 1939d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, 1940d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, 1941d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, 1942d458a9dfSJiri Slaby { } 1943d458a9dfSJiri Slaby }; 1944d458a9dfSJiri Slaby 1945b4d8e473SJiri Slaby /** 1946b4d8e473SJiri Slaby * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer 1947b4d8e473SJiri Slaby * 1948b4d8e473SJiri Slaby * There are composite devices for which we want to ignore only a certain 1949b4d8e473SJiri Slaby * interface. This is a list of devices for which only the mouse interface will 1950b4d8e473SJiri Slaby * be ignored. This allows a dedicated driver to take care of the interface. 1951b4d8e473SJiri Slaby */ 1952b4d8e473SJiri Slaby static const struct hid_device_id hid_mouse_ignore_list[] = { 1953b4d8e473SJiri Slaby /* appletouch driver */ 1954b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 1955b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 1956b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 1957b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 1958b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 1959b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 1960b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 1961b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 1962b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 1963b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 1964b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1965b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 1966b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 1967b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1968b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 1969b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 1970b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 1971b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1972b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1973b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1974ac26fca3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1975ac26fca3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1976ac26fca3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 197799b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 197899b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 197999b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 198099b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 198199b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 198299b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 198347340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, 198447340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, 198547340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, 1986213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) }, 1987213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) }, 1988213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) }, 19894b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) }, 19904b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) }, 19914b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) }, 19924b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 19934b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 19944b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 1995b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1996b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1997b4d8e473SJiri Slaby { } 1998b4d8e473SJiri Slaby }; 1999b4d8e473SJiri Slaby 2000d458a9dfSJiri Slaby static bool hid_ignore(struct hid_device *hdev) 2001d458a9dfSJiri Slaby { 2002d458a9dfSJiri Slaby switch (hdev->vendor) { 2003d458a9dfSJiri Slaby case USB_VENDOR_ID_CODEMERCS: 2004d458a9dfSJiri Slaby /* ignore all Code Mercenaries IOWarrior devices */ 2005d458a9dfSJiri Slaby if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && 2006d458a9dfSJiri Slaby hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) 2007d458a9dfSJiri Slaby return true; 2008d458a9dfSJiri Slaby break; 2009d458a9dfSJiri Slaby case USB_VENDOR_ID_LOGITECH: 2010d458a9dfSJiri Slaby if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && 2011d458a9dfSJiri Slaby hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) 2012d458a9dfSJiri Slaby return true; 2013d458a9dfSJiri Slaby break; 201431f7fd79SJarod Wilson case USB_VENDOR_ID_SOUNDGRAPH: 201531f7fd79SJarod Wilson if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST && 201631f7fd79SJarod Wilson hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST) 201731f7fd79SJarod Wilson return true; 201831f7fd79SJarod Wilson break; 2019bba5394aSXing Wei case USB_VENDOR_ID_HANWANG: 2020bba5394aSXing Wei if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST && 2021bba5394aSXing Wei hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST) 2022bba5394aSXing Wei return true; 2023bba5394aSXing Wei break; 20246dc1418eSTomoki Sekiyama case USB_VENDOR_ID_JESS: 20256dc1418eSTomoki Sekiyama if (hdev->product == USB_DEVICE_ID_JESS_YUREX && 20266dc1418eSTomoki Sekiyama hdev->type == HID_TYPE_USBNONE) 20276dc1418eSTomoki Sekiyama return true; 20286dc1418eSTomoki Sekiyama break; 2029d458a9dfSJiri Slaby } 2030d458a9dfSJiri Slaby 2031b4d8e473SJiri Slaby if (hdev->type == HID_TYPE_USBMOUSE && 2032b4d8e473SJiri Slaby hid_match_id(hdev, hid_mouse_ignore_list)) 2033b4d8e473SJiri Slaby return true; 2034b4d8e473SJiri Slaby 2035d458a9dfSJiri Slaby return !!hid_match_id(hdev, hid_ignore_list); 2036d458a9dfSJiri Slaby } 2037d458a9dfSJiri Slaby 203885cdaf52SJiri Slaby int hid_add_device(struct hid_device *hdev) 203985cdaf52SJiri Slaby { 204085cdaf52SJiri Slaby static atomic_t id = ATOMIC_INIT(0); 204185cdaf52SJiri Slaby int ret; 204285cdaf52SJiri Slaby 204385cdaf52SJiri Slaby if (WARN_ON(hdev->status & HID_STAT_ADDED)) 204485cdaf52SJiri Slaby return -EBUSY; 204585cdaf52SJiri Slaby 2046d458a9dfSJiri Slaby /* we need to kill them here, otherwise they will stay allocated to 2047d458a9dfSJiri Slaby * wait for coming driver */ 2048e5a2a04cSJindrich Makovicka if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) 2049e5a2a04cSJindrich Makovicka && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE))) 2050d458a9dfSJiri Slaby return -ENODEV; 2051d458a9dfSJiri Slaby 20526bbe586fSKay Sievers /* XXX hack, any other cleaner solution after the driver core 20536bbe586fSKay Sievers * is converted to allow more than 20 bytes as the device name? */ 20546bbe586fSKay Sievers dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, 205585cdaf52SJiri Slaby hdev->vendor, hdev->product, atomic_inc_return(&id)); 205685cdaf52SJiri Slaby 20574da361b6SBruno Prémont hid_debug_register(hdev, dev_name(&hdev->dev)); 205885cdaf52SJiri Slaby ret = device_add(&hdev->dev); 205985cdaf52SJiri Slaby if (!ret) 206085cdaf52SJiri Slaby hdev->status |= HID_STAT_ADDED; 20614da361b6SBruno Prémont else 20624da361b6SBruno Prémont hid_debug_unregister(hdev); 2063a635f9ddSJiri Kosina 206485cdaf52SJiri Slaby return ret; 206585cdaf52SJiri Slaby } 206685cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_add_device); 206785cdaf52SJiri Slaby 206885cdaf52SJiri Slaby /** 206985cdaf52SJiri Slaby * hid_allocate_device - allocate new hid device descriptor 207085cdaf52SJiri Slaby * 207185cdaf52SJiri Slaby * Allocate and initialize hid device, so that hid_destroy_device might be 207285cdaf52SJiri Slaby * used to free it. 207385cdaf52SJiri Slaby * 207485cdaf52SJiri Slaby * New hid_device pointer is returned on success, otherwise ERR_PTR encoded 207585cdaf52SJiri Slaby * error value. 207685cdaf52SJiri Slaby */ 207785cdaf52SJiri Slaby struct hid_device *hid_allocate_device(void) 207885cdaf52SJiri Slaby { 207985cdaf52SJiri Slaby struct hid_device *hdev; 208085cdaf52SJiri Slaby unsigned int i; 208185cdaf52SJiri Slaby int ret = -ENOMEM; 208285cdaf52SJiri Slaby 208385cdaf52SJiri Slaby hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); 208485cdaf52SJiri Slaby if (hdev == NULL) 208585cdaf52SJiri Slaby return ERR_PTR(ret); 208685cdaf52SJiri Slaby 208785cdaf52SJiri Slaby device_initialize(&hdev->dev); 208885cdaf52SJiri Slaby hdev->dev.release = hid_device_release; 208985cdaf52SJiri Slaby hdev->dev.bus = &hid_bus_type; 209085cdaf52SJiri Slaby 209185cdaf52SJiri Slaby hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, 209285cdaf52SJiri Slaby sizeof(struct hid_collection), GFP_KERNEL); 209385cdaf52SJiri Slaby if (hdev->collection == NULL) 209485cdaf52SJiri Slaby goto err; 209585cdaf52SJiri Slaby hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS; 209685cdaf52SJiri Slaby 209785cdaf52SJiri Slaby for (i = 0; i < HID_REPORT_TYPES; i++) 209885cdaf52SJiri Slaby INIT_LIST_HEAD(&hdev->report_enum[i].report_list); 209985cdaf52SJiri Slaby 2100cd667ce2SJiri Kosina init_waitqueue_head(&hdev->debug_wait); 2101cd667ce2SJiri Kosina INIT_LIST_HEAD(&hdev->debug_list); 21024ea54542SDavid Herrmann sema_init(&hdev->driver_lock, 1); 2103cd667ce2SJiri Kosina 210485cdaf52SJiri Slaby return hdev; 210585cdaf52SJiri Slaby err: 210685cdaf52SJiri Slaby put_device(&hdev->dev); 210785cdaf52SJiri Slaby return ERR_PTR(ret); 210885cdaf52SJiri Slaby } 210985cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_allocate_device); 211085cdaf52SJiri Slaby 211185cdaf52SJiri Slaby static void hid_remove_device(struct hid_device *hdev) 211285cdaf52SJiri Slaby { 211385cdaf52SJiri Slaby if (hdev->status & HID_STAT_ADDED) { 211485cdaf52SJiri Slaby device_del(&hdev->dev); 2115a635f9ddSJiri Kosina hid_debug_unregister(hdev); 211685cdaf52SJiri Slaby hdev->status &= ~HID_STAT_ADDED; 211785cdaf52SJiri Slaby } 211885cdaf52SJiri Slaby } 211985cdaf52SJiri Slaby 212085cdaf52SJiri Slaby /** 212185cdaf52SJiri Slaby * hid_destroy_device - free previously allocated device 212285cdaf52SJiri Slaby * 212385cdaf52SJiri Slaby * @hdev: hid device 212485cdaf52SJiri Slaby * 212585cdaf52SJiri Slaby * If you allocate hid_device through hid_allocate_device, you should ever 212685cdaf52SJiri Slaby * free by this function. 212785cdaf52SJiri Slaby */ 212885cdaf52SJiri Slaby void hid_destroy_device(struct hid_device *hdev) 212985cdaf52SJiri Slaby { 213085cdaf52SJiri Slaby hid_remove_device(hdev); 213185cdaf52SJiri Slaby put_device(&hdev->dev); 213285cdaf52SJiri Slaby } 213385cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_destroy_device); 213485cdaf52SJiri Slaby 213585cdaf52SJiri Slaby int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, 213685cdaf52SJiri Slaby const char *mod_name) 213785cdaf52SJiri Slaby { 21383a6f82f7SJiri Slaby int ret; 21393a6f82f7SJiri Slaby 214085cdaf52SJiri Slaby hdrv->driver.name = hdrv->name; 214185cdaf52SJiri Slaby hdrv->driver.bus = &hid_bus_type; 214285cdaf52SJiri Slaby hdrv->driver.owner = owner; 214385cdaf52SJiri Slaby hdrv->driver.mod_name = mod_name; 214485cdaf52SJiri Slaby 21453a6f82f7SJiri Slaby INIT_LIST_HEAD(&hdrv->dyn_list); 21463a6f82f7SJiri Slaby spin_lock_init(&hdrv->dyn_lock); 21473a6f82f7SJiri Slaby 21483a6f82f7SJiri Slaby ret = driver_register(&hdrv->driver); 21493a6f82f7SJiri Slaby if (ret) 21503a6f82f7SJiri Slaby return ret; 21513a6f82f7SJiri Slaby 21523a6f82f7SJiri Slaby ret = driver_create_file(&hdrv->driver, &driver_attr_new_id); 21533a6f82f7SJiri Slaby if (ret) 21543a6f82f7SJiri Slaby driver_unregister(&hdrv->driver); 21553a6f82f7SJiri Slaby 21563a6f82f7SJiri Slaby return ret; 215785cdaf52SJiri Slaby } 215885cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(__hid_register_driver); 215985cdaf52SJiri Slaby 216085cdaf52SJiri Slaby void hid_unregister_driver(struct hid_driver *hdrv) 216185cdaf52SJiri Slaby { 21623a6f82f7SJiri Slaby driver_remove_file(&hdrv->driver, &driver_attr_new_id); 216385cdaf52SJiri Slaby driver_unregister(&hdrv->driver); 21643a6f82f7SJiri Slaby hid_free_dynids(hdrv); 216585cdaf52SJiri Slaby } 216685cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_unregister_driver); 216785cdaf52SJiri Slaby 21680361a28dSOliver Neukum int hid_check_keys_pressed(struct hid_device *hid) 21690361a28dSOliver Neukum { 21700361a28dSOliver Neukum struct hid_input *hidinput; 21710361a28dSOliver Neukum int i; 21720361a28dSOliver Neukum 2173e5288eb5SJiri Kosina if (!(hid->claimed & HID_CLAIMED_INPUT)) 2174e5288eb5SJiri Kosina return 0; 2175e5288eb5SJiri Kosina 21760361a28dSOliver Neukum list_for_each_entry(hidinput, &hid->inputs, list) { 21770361a28dSOliver Neukum for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++) 21780361a28dSOliver Neukum if (hidinput->input->key[i]) 21790361a28dSOliver Neukum return 1; 21800361a28dSOliver Neukum } 21810361a28dSOliver Neukum 21820361a28dSOliver Neukum return 0; 21830361a28dSOliver Neukum } 21840361a28dSOliver Neukum 21850361a28dSOliver Neukum EXPORT_SYMBOL_GPL(hid_check_keys_pressed); 21860361a28dSOliver Neukum 218786166b7bSJiri Kosina static int __init hid_init(void) 218886166b7bSJiri Kosina { 218985cdaf52SJiri Slaby int ret; 219085cdaf52SJiri Slaby 2191a635f9ddSJiri Kosina if (hid_debug) 21924291ee30SJoe Perches pr_warn("hid_debug is now used solely for parser and driver debugging.\n" 21934291ee30SJoe Perches "debugfs is now used for inspecting the device (report descriptor, reports)\n"); 2194a635f9ddSJiri Kosina 219585cdaf52SJiri Slaby ret = bus_register(&hid_bus_type); 219685cdaf52SJiri Slaby if (ret) { 21974291ee30SJoe Perches pr_err("can't register hid bus\n"); 219885cdaf52SJiri Slaby goto err; 219985cdaf52SJiri Slaby } 220085cdaf52SJiri Slaby 220185cdaf52SJiri Slaby ret = hidraw_init(); 220285cdaf52SJiri Slaby if (ret) 220385cdaf52SJiri Slaby goto err_bus; 220485cdaf52SJiri Slaby 2205a635f9ddSJiri Kosina hid_debug_init(); 2206a635f9ddSJiri Kosina 220785cdaf52SJiri Slaby return 0; 220885cdaf52SJiri Slaby err_bus: 220985cdaf52SJiri Slaby bus_unregister(&hid_bus_type); 221085cdaf52SJiri Slaby err: 221185cdaf52SJiri Slaby return ret; 221286166b7bSJiri Kosina } 221386166b7bSJiri Kosina 221486166b7bSJiri Kosina static void __exit hid_exit(void) 221586166b7bSJiri Kosina { 2216a635f9ddSJiri Kosina hid_debug_exit(); 221786166b7bSJiri Kosina hidraw_exit(); 221885cdaf52SJiri Slaby bus_unregister(&hid_bus_type); 221986166b7bSJiri Kosina } 222086166b7bSJiri Kosina 222186166b7bSJiri Kosina module_init(hid_init); 222286166b7bSJiri Kosina module_exit(hid_exit); 222386166b7bSJiri Kosina 222488adb72bSJiri Kosina MODULE_AUTHOR("Andreas Gal"); 222588adb72bSJiri Kosina MODULE_AUTHOR("Vojtech Pavlik"); 222688adb72bSJiri Kosina MODULE_AUTHOR("Jiri Kosina"); 2227aa938f79SJiri Kosina MODULE_LICENSE(DRIVER_LICENSE); 2228aa938f79SJiri Kosina 2229