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 77d39e849SJiri Kosina * Copyright (c) 2006-2010 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 53dde5845aSJiri Kosina /* 54dde5845aSJiri Kosina * Register a new report for a device. 55dde5845aSJiri Kosina */ 56dde5845aSJiri Kosina 5790a006abSMichael Poole struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) 58dde5845aSJiri Kosina { 59dde5845aSJiri Kosina struct hid_report_enum *report_enum = device->report_enum + type; 60dde5845aSJiri Kosina struct hid_report *report; 61dde5845aSJiri Kosina 62dde5845aSJiri Kosina if (report_enum->report_id_hash[id]) 63dde5845aSJiri Kosina return report_enum->report_id_hash[id]; 64dde5845aSJiri Kosina 65a3789a17SJoe Perches report = kzalloc(sizeof(struct hid_report), GFP_KERNEL); 66a3789a17SJoe Perches if (!report) 67dde5845aSJiri Kosina return NULL; 68dde5845aSJiri Kosina 69dde5845aSJiri Kosina if (id != 0) 70dde5845aSJiri Kosina report_enum->numbered = 1; 71dde5845aSJiri Kosina 72dde5845aSJiri Kosina report->id = id; 73dde5845aSJiri Kosina report->type = type; 74dde5845aSJiri Kosina report->size = 0; 75dde5845aSJiri Kosina report->device = device; 76dde5845aSJiri Kosina report_enum->report_id_hash[id] = report; 77dde5845aSJiri Kosina 78dde5845aSJiri Kosina list_add_tail(&report->list, &report_enum->report_list); 79dde5845aSJiri Kosina 80dde5845aSJiri Kosina return report; 81dde5845aSJiri Kosina } 8290a006abSMichael Poole EXPORT_SYMBOL_GPL(hid_register_report); 83dde5845aSJiri Kosina 84dde5845aSJiri Kosina /* 85dde5845aSJiri Kosina * Register a new field for this report. 86dde5845aSJiri Kosina */ 87dde5845aSJiri Kosina 88dde5845aSJiri Kosina static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) 89dde5845aSJiri Kosina { 90dde5845aSJiri Kosina struct hid_field *field; 91dde5845aSJiri Kosina 92dde5845aSJiri Kosina if (report->maxfield == HID_MAX_FIELDS) { 938c3d52fcSJiri Kosina hid_err(report->device, "too many fields in report\n"); 94dde5845aSJiri Kosina return NULL; 95dde5845aSJiri Kosina } 96dde5845aSJiri Kosina 97a3789a17SJoe Perches field = kzalloc((sizeof(struct hid_field) + 98a3789a17SJoe Perches usages * sizeof(struct hid_usage) + 99a3789a17SJoe Perches values * sizeof(unsigned)), GFP_KERNEL); 100a3789a17SJoe Perches if (!field) 101a3789a17SJoe Perches return NULL; 102dde5845aSJiri Kosina 103dde5845aSJiri Kosina field->index = report->maxfield++; 104dde5845aSJiri Kosina report->field[field->index] = field; 105dde5845aSJiri Kosina field->usage = (struct hid_usage *)(field + 1); 106282bfd4cSJiri Slaby field->value = (s32 *)(field->usage + usages); 107dde5845aSJiri Kosina field->report = report; 108dde5845aSJiri Kosina 109dde5845aSJiri Kosina return field; 110dde5845aSJiri Kosina } 111dde5845aSJiri Kosina 112dde5845aSJiri Kosina /* 113dde5845aSJiri Kosina * Open a collection. The type/usage is pushed on the stack. 114dde5845aSJiri Kosina */ 115dde5845aSJiri Kosina 116dde5845aSJiri Kosina static int open_collection(struct hid_parser *parser, unsigned type) 117dde5845aSJiri Kosina { 118dde5845aSJiri Kosina struct hid_collection *collection; 119dde5845aSJiri Kosina unsigned usage; 120dde5845aSJiri Kosina 121dde5845aSJiri Kosina usage = parser->local.usage[0]; 122dde5845aSJiri Kosina 123dde5845aSJiri Kosina if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { 1248c3d52fcSJiri Kosina hid_err(parser->device, "collection stack overflow\n"); 125dde5845aSJiri Kosina return -1; 126dde5845aSJiri Kosina } 127dde5845aSJiri Kosina 128dde5845aSJiri Kosina if (parser->device->maxcollection == parser->device->collection_size) { 129dde5845aSJiri Kosina collection = kmalloc(sizeof(struct hid_collection) * 130dde5845aSJiri Kosina parser->device->collection_size * 2, GFP_KERNEL); 131dde5845aSJiri Kosina if (collection == NULL) { 1328c3d52fcSJiri Kosina hid_err(parser->device, "failed to reallocate collection array\n"); 133dde5845aSJiri Kosina return -1; 134dde5845aSJiri Kosina } 135dde5845aSJiri Kosina memcpy(collection, parser->device->collection, 136dde5845aSJiri Kosina sizeof(struct hid_collection) * 137dde5845aSJiri Kosina parser->device->collection_size); 138dde5845aSJiri Kosina memset(collection + parser->device->collection_size, 0, 139dde5845aSJiri Kosina sizeof(struct hid_collection) * 140dde5845aSJiri Kosina parser->device->collection_size); 141dde5845aSJiri Kosina kfree(parser->device->collection); 142dde5845aSJiri Kosina parser->device->collection = collection; 143dde5845aSJiri Kosina parser->device->collection_size *= 2; 144dde5845aSJiri Kosina } 145dde5845aSJiri Kosina 146dde5845aSJiri Kosina parser->collection_stack[parser->collection_stack_ptr++] = 147dde5845aSJiri Kosina parser->device->maxcollection; 148dde5845aSJiri Kosina 149dde5845aSJiri Kosina collection = parser->device->collection + 150dde5845aSJiri Kosina parser->device->maxcollection++; 151dde5845aSJiri Kosina collection->type = type; 152dde5845aSJiri Kosina collection->usage = usage; 153dde5845aSJiri Kosina collection->level = parser->collection_stack_ptr - 1; 154dde5845aSJiri Kosina 155dde5845aSJiri Kosina if (type == HID_COLLECTION_APPLICATION) 156dde5845aSJiri Kosina parser->device->maxapplication++; 157dde5845aSJiri Kosina 158dde5845aSJiri Kosina return 0; 159dde5845aSJiri Kosina } 160dde5845aSJiri Kosina 161dde5845aSJiri Kosina /* 162dde5845aSJiri Kosina * Close a collection. 163dde5845aSJiri Kosina */ 164dde5845aSJiri Kosina 165dde5845aSJiri Kosina static int close_collection(struct hid_parser *parser) 166dde5845aSJiri Kosina { 167dde5845aSJiri Kosina if (!parser->collection_stack_ptr) { 1688c3d52fcSJiri Kosina hid_err(parser->device, "collection stack underflow\n"); 169dde5845aSJiri Kosina return -1; 170dde5845aSJiri Kosina } 171dde5845aSJiri Kosina parser->collection_stack_ptr--; 172dde5845aSJiri Kosina return 0; 173dde5845aSJiri Kosina } 174dde5845aSJiri Kosina 175dde5845aSJiri Kosina /* 176dde5845aSJiri Kosina * Climb up the stack, search for the specified collection type 177dde5845aSJiri Kosina * and return the usage. 178dde5845aSJiri Kosina */ 179dde5845aSJiri Kosina 180dde5845aSJiri Kosina static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) 181dde5845aSJiri Kosina { 182504499f2SJoe Perches struct hid_collection *collection = parser->device->collection; 183dde5845aSJiri Kosina int n; 184504499f2SJoe Perches 185504499f2SJoe Perches for (n = parser->collection_stack_ptr - 1; n >= 0; n--) { 186504499f2SJoe Perches unsigned index = parser->collection_stack[n]; 187504499f2SJoe Perches if (collection[index].type == type) 188504499f2SJoe Perches return collection[index].usage; 189504499f2SJoe Perches } 190dde5845aSJiri Kosina return 0; /* we know nothing about this usage type */ 191dde5845aSJiri Kosina } 192dde5845aSJiri Kosina 193dde5845aSJiri Kosina /* 194dde5845aSJiri Kosina * Add a usage to the temporary parser table. 195dde5845aSJiri Kosina */ 196dde5845aSJiri Kosina 197dde5845aSJiri Kosina static int hid_add_usage(struct hid_parser *parser, unsigned usage) 198dde5845aSJiri Kosina { 199dde5845aSJiri Kosina if (parser->local.usage_index >= HID_MAX_USAGES) { 2008c3d52fcSJiri Kosina hid_err(parser->device, "usage index exceeded\n"); 201dde5845aSJiri Kosina return -1; 202dde5845aSJiri Kosina } 203dde5845aSJiri Kosina parser->local.usage[parser->local.usage_index] = usage; 204dde5845aSJiri Kosina parser->local.collection_index[parser->local.usage_index] = 205dde5845aSJiri Kosina parser->collection_stack_ptr ? 206dde5845aSJiri Kosina parser->collection_stack[parser->collection_stack_ptr - 1] : 0; 207dde5845aSJiri Kosina parser->local.usage_index++; 208dde5845aSJiri Kosina return 0; 209dde5845aSJiri Kosina } 210dde5845aSJiri Kosina 211dde5845aSJiri Kosina /* 212dde5845aSJiri Kosina * Register a new field for this report. 213dde5845aSJiri Kosina */ 214dde5845aSJiri Kosina 215dde5845aSJiri Kosina static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags) 216dde5845aSJiri Kosina { 217dde5845aSJiri Kosina struct hid_report *report; 218dde5845aSJiri Kosina struct hid_field *field; 219dde5845aSJiri Kosina int usages; 220dde5845aSJiri Kosina unsigned offset; 221dde5845aSJiri Kosina int i; 222dde5845aSJiri Kosina 223a3789a17SJoe Perches report = hid_register_report(parser->device, report_type, parser->global.report_id); 224a3789a17SJoe Perches if (!report) { 2258c3d52fcSJiri Kosina hid_err(parser->device, "hid_register_report failed\n"); 226dde5845aSJiri Kosina return -1; 227dde5845aSJiri Kosina } 228dde5845aSJiri Kosina 229dde5845aSJiri Kosina if (parser->global.logical_maximum < parser->global.logical_minimum) { 2308c3d52fcSJiri Kosina hid_err(parser->device, "logical range invalid %d %d\n", 2318c3d52fcSJiri Kosina parser->global.logical_minimum, parser->global.logical_maximum); 232dde5845aSJiri Kosina return -1; 233dde5845aSJiri Kosina } 234dde5845aSJiri Kosina 235dde5845aSJiri Kosina offset = report->size; 236dde5845aSJiri Kosina report->size += parser->global.report_size * parser->global.report_count; 237dde5845aSJiri Kosina 238dde5845aSJiri Kosina if (!parser->local.usage_index) /* Ignore padding fields */ 239dde5845aSJiri Kosina return 0; 240dde5845aSJiri Kosina 241dde5845aSJiri Kosina usages = max_t(int, parser->local.usage_index, parser->global.report_count); 242dde5845aSJiri Kosina 243a3789a17SJoe Perches field = hid_register_field(report, usages, parser->global.report_count); 244a3789a17SJoe Perches if (!field) 245dde5845aSJiri Kosina return 0; 246dde5845aSJiri Kosina 247dde5845aSJiri Kosina field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); 248dde5845aSJiri Kosina field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL); 249dde5845aSJiri Kosina field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); 250dde5845aSJiri Kosina 251dde5845aSJiri Kosina for (i = 0; i < usages; i++) { 252dde5845aSJiri Kosina int j = i; 253dde5845aSJiri Kosina /* Duplicate the last usage we parsed if we have excess values */ 254dde5845aSJiri Kosina if (i >= parser->local.usage_index) 255dde5845aSJiri Kosina j = parser->local.usage_index - 1; 256dde5845aSJiri Kosina field->usage[i].hid = parser->local.usage[j]; 257dde5845aSJiri Kosina field->usage[i].collection_index = 258dde5845aSJiri Kosina parser->local.collection_index[j]; 259dde5845aSJiri Kosina } 260dde5845aSJiri Kosina 261dde5845aSJiri Kosina field->maxusage = usages; 262dde5845aSJiri Kosina field->flags = flags; 263dde5845aSJiri Kosina field->report_offset = offset; 264dde5845aSJiri Kosina field->report_type = report_type; 265dde5845aSJiri Kosina field->report_size = parser->global.report_size; 266dde5845aSJiri Kosina field->report_count = parser->global.report_count; 267dde5845aSJiri Kosina field->logical_minimum = parser->global.logical_minimum; 268dde5845aSJiri Kosina field->logical_maximum = parser->global.logical_maximum; 269dde5845aSJiri Kosina field->physical_minimum = parser->global.physical_minimum; 270dde5845aSJiri Kosina field->physical_maximum = parser->global.physical_maximum; 271dde5845aSJiri Kosina field->unit_exponent = parser->global.unit_exponent; 272dde5845aSJiri Kosina field->unit = parser->global.unit; 273dde5845aSJiri Kosina 274dde5845aSJiri Kosina return 0; 275dde5845aSJiri Kosina } 276dde5845aSJiri Kosina 277dde5845aSJiri Kosina /* 278dde5845aSJiri Kosina * Read data value from item. 279dde5845aSJiri Kosina */ 280dde5845aSJiri Kosina 281dde5845aSJiri Kosina static u32 item_udata(struct hid_item *item) 282dde5845aSJiri Kosina { 283dde5845aSJiri Kosina switch (item->size) { 284dde5845aSJiri Kosina case 1: return item->data.u8; 285dde5845aSJiri Kosina case 2: return item->data.u16; 286dde5845aSJiri Kosina case 4: return item->data.u32; 287dde5845aSJiri Kosina } 288dde5845aSJiri Kosina return 0; 289dde5845aSJiri Kosina } 290dde5845aSJiri Kosina 291dde5845aSJiri Kosina static s32 item_sdata(struct hid_item *item) 292dde5845aSJiri Kosina { 293dde5845aSJiri Kosina switch (item->size) { 294dde5845aSJiri Kosina case 1: return item->data.s8; 295dde5845aSJiri Kosina case 2: return item->data.s16; 296dde5845aSJiri Kosina case 4: return item->data.s32; 297dde5845aSJiri Kosina } 298dde5845aSJiri Kosina return 0; 299dde5845aSJiri Kosina } 300dde5845aSJiri Kosina 301dde5845aSJiri Kosina /* 302dde5845aSJiri Kosina * Process a global item. 303dde5845aSJiri Kosina */ 304dde5845aSJiri Kosina 305dde5845aSJiri Kosina static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) 306dde5845aSJiri Kosina { 307dde5845aSJiri Kosina switch (item->tag) { 308dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_PUSH: 309dde5845aSJiri Kosina 310dde5845aSJiri Kosina if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { 3118c3d52fcSJiri Kosina hid_err(parser->device, "global environment stack overflow\n"); 312dde5845aSJiri Kosina return -1; 313dde5845aSJiri Kosina } 314dde5845aSJiri Kosina 315dde5845aSJiri Kosina memcpy(parser->global_stack + parser->global_stack_ptr++, 316dde5845aSJiri Kosina &parser->global, sizeof(struct hid_global)); 317dde5845aSJiri Kosina return 0; 318dde5845aSJiri Kosina 319dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_POP: 320dde5845aSJiri Kosina 321dde5845aSJiri Kosina if (!parser->global_stack_ptr) { 3228c3d52fcSJiri Kosina hid_err(parser->device, "global environment stack underflow\n"); 323dde5845aSJiri Kosina return -1; 324dde5845aSJiri Kosina } 325dde5845aSJiri Kosina 326880d29f1SJiri Slaby memcpy(&parser->global, parser->global_stack + 327880d29f1SJiri Slaby --parser->global_stack_ptr, sizeof(struct hid_global)); 328dde5845aSJiri Kosina return 0; 329dde5845aSJiri Kosina 330dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: 331dde5845aSJiri Kosina parser->global.usage_page = item_udata(item); 332dde5845aSJiri Kosina return 0; 333dde5845aSJiri Kosina 334dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: 335dde5845aSJiri Kosina parser->global.logical_minimum = item_sdata(item); 336dde5845aSJiri Kosina return 0; 337dde5845aSJiri Kosina 338dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: 339dde5845aSJiri Kosina if (parser->global.logical_minimum < 0) 340dde5845aSJiri Kosina parser->global.logical_maximum = item_sdata(item); 341dde5845aSJiri Kosina else 342dde5845aSJiri Kosina parser->global.logical_maximum = item_udata(item); 343dde5845aSJiri Kosina return 0; 344dde5845aSJiri Kosina 345dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: 346dde5845aSJiri Kosina parser->global.physical_minimum = item_sdata(item); 347dde5845aSJiri Kosina return 0; 348dde5845aSJiri Kosina 349dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: 350dde5845aSJiri Kosina if (parser->global.physical_minimum < 0) 351dde5845aSJiri Kosina parser->global.physical_maximum = item_sdata(item); 352dde5845aSJiri Kosina else 353dde5845aSJiri Kosina parser->global.physical_maximum = item_udata(item); 354dde5845aSJiri Kosina return 0; 355dde5845aSJiri Kosina 356dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: 357dde5845aSJiri Kosina parser->global.unit_exponent = item_sdata(item); 358dde5845aSJiri Kosina return 0; 359dde5845aSJiri Kosina 360dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_UNIT: 361dde5845aSJiri Kosina parser->global.unit = item_udata(item); 362dde5845aSJiri Kosina return 0; 363dde5845aSJiri Kosina 364dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: 365880d29f1SJiri Slaby parser->global.report_size = item_udata(item); 366e46e927bSChase Douglas if (parser->global.report_size > 96) { 3678c3d52fcSJiri Kosina hid_err(parser->device, "invalid report_size %d\n", 368880d29f1SJiri Slaby parser->global.report_size); 369dde5845aSJiri Kosina return -1; 370dde5845aSJiri Kosina } 371dde5845aSJiri Kosina return 0; 372dde5845aSJiri Kosina 373dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: 374880d29f1SJiri Slaby parser->global.report_count = item_udata(item); 375880d29f1SJiri Slaby if (parser->global.report_count > HID_MAX_USAGES) { 3768c3d52fcSJiri Kosina hid_err(parser->device, "invalid report_count %d\n", 377880d29f1SJiri Slaby parser->global.report_count); 378dde5845aSJiri Kosina return -1; 379dde5845aSJiri Kosina } 380dde5845aSJiri Kosina return 0; 381dde5845aSJiri Kosina 382dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_REPORT_ID: 383880d29f1SJiri Slaby parser->global.report_id = item_udata(item); 384880d29f1SJiri Slaby if (parser->global.report_id == 0) { 3858c3d52fcSJiri Kosina hid_err(parser->device, "report_id 0 is invalid\n"); 386dde5845aSJiri Kosina return -1; 387dde5845aSJiri Kosina } 388dde5845aSJiri Kosina return 0; 389dde5845aSJiri Kosina 390dde5845aSJiri Kosina default: 3918c3d52fcSJiri Kosina hid_err(parser->device, "unknown global tag 0x%x\n", item->tag); 392dde5845aSJiri Kosina return -1; 393dde5845aSJiri Kosina } 394dde5845aSJiri Kosina } 395dde5845aSJiri Kosina 396dde5845aSJiri Kosina /* 397dde5845aSJiri Kosina * Process a local item. 398dde5845aSJiri Kosina */ 399dde5845aSJiri Kosina 400dde5845aSJiri Kosina static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) 401dde5845aSJiri Kosina { 402dde5845aSJiri Kosina __u32 data; 403dde5845aSJiri Kosina unsigned n; 404dde5845aSJiri Kosina 405dde5845aSJiri Kosina data = item_udata(item); 406dde5845aSJiri Kosina 407dde5845aSJiri Kosina switch (item->tag) { 408dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_DELIMITER: 409dde5845aSJiri Kosina 410dde5845aSJiri Kosina if (data) { 411dde5845aSJiri Kosina /* 412dde5845aSJiri Kosina * We treat items before the first delimiter 413dde5845aSJiri Kosina * as global to all usage sets (branch 0). 414dde5845aSJiri Kosina * In the moment we process only these global 415dde5845aSJiri Kosina * items and the first delimiter set. 416dde5845aSJiri Kosina */ 417dde5845aSJiri Kosina if (parser->local.delimiter_depth != 0) { 4188c3d52fcSJiri Kosina hid_err(parser->device, "nested delimiters\n"); 419dde5845aSJiri Kosina return -1; 420dde5845aSJiri Kosina } 421dde5845aSJiri Kosina parser->local.delimiter_depth++; 422dde5845aSJiri Kosina parser->local.delimiter_branch++; 423dde5845aSJiri Kosina } else { 424dde5845aSJiri Kosina if (parser->local.delimiter_depth < 1) { 4258c3d52fcSJiri Kosina hid_err(parser->device, "bogus close delimiter\n"); 426dde5845aSJiri Kosina return -1; 427dde5845aSJiri Kosina } 428dde5845aSJiri Kosina parser->local.delimiter_depth--; 429dde5845aSJiri Kosina } 430dde5845aSJiri Kosina return 1; 431dde5845aSJiri Kosina 432dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_USAGE: 433dde5845aSJiri Kosina 434dde5845aSJiri Kosina if (parser->local.delimiter_branch > 1) { 43558037eb9SJiri Kosina dbg_hid("alternative usage ignored\n"); 436dde5845aSJiri Kosina return 0; 437dde5845aSJiri Kosina } 438dde5845aSJiri Kosina 439dde5845aSJiri Kosina if (item->size <= 2) 440dde5845aSJiri Kosina data = (parser->global.usage_page << 16) + data; 441dde5845aSJiri Kosina 442dde5845aSJiri Kosina return hid_add_usage(parser, data); 443dde5845aSJiri Kosina 444dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: 445dde5845aSJiri Kosina 446dde5845aSJiri Kosina if (parser->local.delimiter_branch > 1) { 44758037eb9SJiri Kosina dbg_hid("alternative usage ignored\n"); 448dde5845aSJiri Kosina return 0; 449dde5845aSJiri Kosina } 450dde5845aSJiri Kosina 451dde5845aSJiri Kosina if (item->size <= 2) 452dde5845aSJiri Kosina data = (parser->global.usage_page << 16) + data; 453dde5845aSJiri Kosina 454dde5845aSJiri Kosina parser->local.usage_minimum = data; 455dde5845aSJiri Kosina return 0; 456dde5845aSJiri Kosina 457dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: 458dde5845aSJiri Kosina 459dde5845aSJiri Kosina if (parser->local.delimiter_branch > 1) { 46058037eb9SJiri Kosina dbg_hid("alternative usage ignored\n"); 461dde5845aSJiri Kosina return 0; 462dde5845aSJiri Kosina } 463dde5845aSJiri Kosina 464dde5845aSJiri Kosina if (item->size <= 2) 465dde5845aSJiri Kosina data = (parser->global.usage_page << 16) + data; 466dde5845aSJiri Kosina 467dde5845aSJiri Kosina for (n = parser->local.usage_minimum; n <= data; n++) 468dde5845aSJiri Kosina if (hid_add_usage(parser, n)) { 46958037eb9SJiri Kosina dbg_hid("hid_add_usage failed\n"); 470dde5845aSJiri Kosina return -1; 471dde5845aSJiri Kosina } 472dde5845aSJiri Kosina return 0; 473dde5845aSJiri Kosina 474dde5845aSJiri Kosina default: 475dde5845aSJiri Kosina 47658037eb9SJiri Kosina dbg_hid("unknown local item tag 0x%x\n", item->tag); 477dde5845aSJiri Kosina return 0; 478dde5845aSJiri Kosina } 479dde5845aSJiri Kosina return 0; 480dde5845aSJiri Kosina } 481dde5845aSJiri Kosina 482dde5845aSJiri Kosina /* 483dde5845aSJiri Kosina * Process a main item. 484dde5845aSJiri Kosina */ 485dde5845aSJiri Kosina 486dde5845aSJiri Kosina static int hid_parser_main(struct hid_parser *parser, struct hid_item *item) 487dde5845aSJiri Kosina { 488dde5845aSJiri Kosina __u32 data; 489dde5845aSJiri Kosina int ret; 490dde5845aSJiri Kosina 491dde5845aSJiri Kosina data = item_udata(item); 492dde5845aSJiri Kosina 493dde5845aSJiri Kosina switch (item->tag) { 494dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: 495dde5845aSJiri Kosina ret = open_collection(parser, data & 0xff); 496dde5845aSJiri Kosina break; 497dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_END_COLLECTION: 498dde5845aSJiri Kosina ret = close_collection(parser); 499dde5845aSJiri Kosina break; 500dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_INPUT: 501dde5845aSJiri Kosina ret = hid_add_field(parser, HID_INPUT_REPORT, data); 502dde5845aSJiri Kosina break; 503dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_OUTPUT: 504dde5845aSJiri Kosina ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); 505dde5845aSJiri Kosina break; 506dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_FEATURE: 507dde5845aSJiri Kosina ret = hid_add_field(parser, HID_FEATURE_REPORT, data); 508dde5845aSJiri Kosina break; 509dde5845aSJiri Kosina default: 5108c3d52fcSJiri Kosina hid_err(parser->device, "unknown main item tag 0x%x\n", item->tag); 511dde5845aSJiri Kosina ret = 0; 512dde5845aSJiri Kosina } 513dde5845aSJiri Kosina 514dde5845aSJiri Kosina memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ 515dde5845aSJiri Kosina 516dde5845aSJiri Kosina return ret; 517dde5845aSJiri Kosina } 518dde5845aSJiri Kosina 519dde5845aSJiri Kosina /* 520dde5845aSJiri Kosina * Process a reserved item. 521dde5845aSJiri Kosina */ 522dde5845aSJiri Kosina 523dde5845aSJiri Kosina static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) 524dde5845aSJiri Kosina { 52558037eb9SJiri Kosina dbg_hid("reserved item type, tag 0x%x\n", item->tag); 526dde5845aSJiri Kosina return 0; 527dde5845aSJiri Kosina } 528dde5845aSJiri Kosina 529dde5845aSJiri Kosina /* 530dde5845aSJiri Kosina * Free a report and all registered fields. The field->usage and 531dde5845aSJiri Kosina * field->value table's are allocated behind the field, so we need 532dde5845aSJiri Kosina * only to free(field) itself. 533dde5845aSJiri Kosina */ 534dde5845aSJiri Kosina 535dde5845aSJiri Kosina static void hid_free_report(struct hid_report *report) 536dde5845aSJiri Kosina { 537dde5845aSJiri Kosina unsigned n; 538dde5845aSJiri Kosina 539dde5845aSJiri Kosina for (n = 0; n < report->maxfield; n++) 540dde5845aSJiri Kosina kfree(report->field[n]); 541dde5845aSJiri Kosina kfree(report); 542dde5845aSJiri Kosina } 543dde5845aSJiri Kosina 544dde5845aSJiri Kosina /* 545dde5845aSJiri Kosina * Free a device structure, all reports, and all fields. 546dde5845aSJiri Kosina */ 547dde5845aSJiri Kosina 54885cdaf52SJiri Slaby static void hid_device_release(struct device *dev) 549dde5845aSJiri Kosina { 55085cdaf52SJiri Slaby struct hid_device *device = container_of(dev, struct hid_device, dev); 551dde5845aSJiri Kosina unsigned i, j; 552dde5845aSJiri Kosina 553dde5845aSJiri Kosina for (i = 0; i < HID_REPORT_TYPES; i++) { 554dde5845aSJiri Kosina struct hid_report_enum *report_enum = device->report_enum + i; 555dde5845aSJiri Kosina 556dde5845aSJiri Kosina for (j = 0; j < 256; j++) { 557dde5845aSJiri Kosina struct hid_report *report = report_enum->report_id_hash[j]; 558dde5845aSJiri Kosina if (report) 559dde5845aSJiri Kosina hid_free_report(report); 560dde5845aSJiri Kosina } 561dde5845aSJiri Kosina } 562dde5845aSJiri Kosina 563dde5845aSJiri Kosina kfree(device->rdesc); 564767fe787SJiri Kosina kfree(device->collection); 565dde5845aSJiri Kosina kfree(device); 566dde5845aSJiri Kosina } 567dde5845aSJiri Kosina 568dde5845aSJiri Kosina /* 569dde5845aSJiri Kosina * Fetch a report description item from the data stream. We support long 570dde5845aSJiri Kosina * items, though they are not used yet. 571dde5845aSJiri Kosina */ 572dde5845aSJiri Kosina 573dde5845aSJiri Kosina static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) 574dde5845aSJiri Kosina { 575dde5845aSJiri Kosina u8 b; 576dde5845aSJiri Kosina 577dde5845aSJiri Kosina if ((end - start) <= 0) 578dde5845aSJiri Kosina return NULL; 579dde5845aSJiri Kosina 580dde5845aSJiri Kosina b = *start++; 581dde5845aSJiri Kosina 582dde5845aSJiri Kosina item->type = (b >> 2) & 3; 583dde5845aSJiri Kosina item->tag = (b >> 4) & 15; 584dde5845aSJiri Kosina 585dde5845aSJiri Kosina if (item->tag == HID_ITEM_TAG_LONG) { 586dde5845aSJiri Kosina 587dde5845aSJiri Kosina item->format = HID_ITEM_FORMAT_LONG; 588dde5845aSJiri Kosina 589dde5845aSJiri Kosina if ((end - start) < 2) 590dde5845aSJiri Kosina return NULL; 591dde5845aSJiri Kosina 592dde5845aSJiri Kosina item->size = *start++; 593dde5845aSJiri Kosina item->tag = *start++; 594dde5845aSJiri Kosina 595dde5845aSJiri Kosina if ((end - start) < item->size) 596dde5845aSJiri Kosina return NULL; 597dde5845aSJiri Kosina 598dde5845aSJiri Kosina item->data.longdata = start; 599dde5845aSJiri Kosina start += item->size; 600dde5845aSJiri Kosina return start; 601dde5845aSJiri Kosina } 602dde5845aSJiri Kosina 603dde5845aSJiri Kosina item->format = HID_ITEM_FORMAT_SHORT; 604dde5845aSJiri Kosina item->size = b & 3; 605dde5845aSJiri Kosina 606dde5845aSJiri Kosina switch (item->size) { 607dde5845aSJiri Kosina case 0: 608dde5845aSJiri Kosina return start; 609dde5845aSJiri Kosina 610dde5845aSJiri Kosina case 1: 611dde5845aSJiri Kosina if ((end - start) < 1) 612dde5845aSJiri Kosina return NULL; 613dde5845aSJiri Kosina item->data.u8 = *start++; 614dde5845aSJiri Kosina return start; 615dde5845aSJiri Kosina 616dde5845aSJiri Kosina case 2: 617dde5845aSJiri Kosina if ((end - start) < 2) 618dde5845aSJiri Kosina return NULL; 619c105068fSHarvey Harrison item->data.u16 = get_unaligned_le16(start); 620dde5845aSJiri Kosina start = (__u8 *)((__le16 *)start + 1); 621dde5845aSJiri Kosina return start; 622dde5845aSJiri Kosina 623dde5845aSJiri Kosina case 3: 624dde5845aSJiri Kosina item->size++; 625dde5845aSJiri Kosina if ((end - start) < 4) 626dde5845aSJiri Kosina return NULL; 627c105068fSHarvey Harrison item->data.u32 = get_unaligned_le32(start); 628dde5845aSJiri Kosina start = (__u8 *)((__le32 *)start + 1); 629dde5845aSJiri Kosina return start; 630dde5845aSJiri Kosina } 631dde5845aSJiri Kosina 632dde5845aSJiri Kosina return NULL; 633dde5845aSJiri Kosina } 634dde5845aSJiri Kosina 63585cdaf52SJiri Slaby /** 63685cdaf52SJiri Slaby * hid_parse_report - parse device report 63785cdaf52SJiri Slaby * 63885cdaf52SJiri Slaby * @device: hid device 63985cdaf52SJiri Slaby * @start: report start 64085cdaf52SJiri Slaby * @size: report size 64185cdaf52SJiri Slaby * 642dde5845aSJiri Kosina * Parse a report description into a hid_device structure. Reports are 643dde5845aSJiri Kosina * enumerated, fields are attached to these reports. 64485cdaf52SJiri Slaby * 0 returned on success, otherwise nonzero error value. 645dde5845aSJiri Kosina */ 64685cdaf52SJiri Slaby int hid_parse_report(struct hid_device *device, __u8 *start, 64785cdaf52SJiri Slaby unsigned size) 648dde5845aSJiri Kosina { 649dde5845aSJiri Kosina struct hid_parser *parser; 650dde5845aSJiri Kosina struct hid_item item; 651dde5845aSJiri Kosina __u8 *end; 65285cdaf52SJiri Slaby int ret; 653dde5845aSJiri Kosina static int (*dispatch_type[])(struct hid_parser *parser, 654dde5845aSJiri Kosina struct hid_item *item) = { 655dde5845aSJiri Kosina hid_parser_main, 656dde5845aSJiri Kosina hid_parser_global, 657dde5845aSJiri Kosina hid_parser_local, 658dde5845aSJiri Kosina hid_parser_reserved 659dde5845aSJiri Kosina }; 660dde5845aSJiri Kosina 661c500c971SJiri Slaby if (device->driver->report_fixup) 66273e4008dSNikolai Kondrashov start = device->driver->report_fixup(device, start, &size); 663c500c971SJiri Slaby 6641721a238SJulia Lawall device->rdesc = kmemdup(start, size, GFP_KERNEL); 66585cdaf52SJiri Slaby if (device->rdesc == NULL) 66685cdaf52SJiri Slaby return -ENOMEM; 667dde5845aSJiri Kosina device->rsize = size; 668dde5845aSJiri Kosina 669fe258020SJoe Perches parser = vzalloc(sizeof(struct hid_parser)); 67085cdaf52SJiri Slaby if (!parser) { 67185cdaf52SJiri Slaby ret = -ENOMEM; 67285cdaf52SJiri Slaby goto err; 673dde5845aSJiri Kosina } 67485cdaf52SJiri Slaby 675dde5845aSJiri Kosina parser->device = device; 676dde5845aSJiri Kosina 677dde5845aSJiri Kosina end = start + size; 67885cdaf52SJiri Slaby ret = -EINVAL; 679dde5845aSJiri Kosina while ((start = fetch_item(start, end, &item)) != NULL) { 680dde5845aSJiri Kosina 681dde5845aSJiri Kosina if (item.format != HID_ITEM_FORMAT_SHORT) { 6828c3d52fcSJiri Kosina hid_err(device, "unexpected long global item\n"); 68385cdaf52SJiri Slaby goto err; 684dde5845aSJiri Kosina } 685dde5845aSJiri Kosina 686dde5845aSJiri Kosina if (dispatch_type[item.type](parser, &item)) { 6878c3d52fcSJiri Kosina hid_err(device, "item %u %u %u %u parsing failed\n", 6884291ee30SJoe Perches item.format, (unsigned)item.size, 6894291ee30SJoe Perches (unsigned)item.type, (unsigned)item.tag); 69085cdaf52SJiri Slaby goto err; 691dde5845aSJiri Kosina } 692dde5845aSJiri Kosina 693dde5845aSJiri Kosina if (start == end) { 694dde5845aSJiri Kosina if (parser->collection_stack_ptr) { 6958c3d52fcSJiri Kosina hid_err(device, "unbalanced collection at end of report description\n"); 69685cdaf52SJiri Slaby goto err; 697dde5845aSJiri Kosina } 698dde5845aSJiri Kosina if (parser->local.delimiter_depth) { 6998c3d52fcSJiri Kosina hid_err(device, "unbalanced delimiter at end of report description\n"); 70085cdaf52SJiri Slaby goto err; 701dde5845aSJiri Kosina } 70247a80edbSJiri Kosina vfree(parser); 70385cdaf52SJiri Slaby return 0; 704dde5845aSJiri Kosina } 705dde5845aSJiri Kosina } 706dde5845aSJiri Kosina 7078c3d52fcSJiri Kosina hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); 70885cdaf52SJiri Slaby err: 70947a80edbSJiri Kosina vfree(parser); 71085cdaf52SJiri Slaby return ret; 711dde5845aSJiri Kosina } 712229695e5SJiri Kosina EXPORT_SYMBOL_GPL(hid_parse_report); 713dde5845aSJiri Kosina 714dde5845aSJiri Kosina /* 715dde5845aSJiri Kosina * Convert a signed n-bit integer to signed 32-bit integer. Common 716dde5845aSJiri Kosina * cases are done through the compiler, the screwed things has to be 717dde5845aSJiri Kosina * done by hand. 718dde5845aSJiri Kosina */ 719dde5845aSJiri Kosina 720dde5845aSJiri Kosina static s32 snto32(__u32 value, unsigned n) 721dde5845aSJiri Kosina { 722dde5845aSJiri Kosina switch (n) { 723dde5845aSJiri Kosina case 8: return ((__s8)value); 724dde5845aSJiri Kosina case 16: return ((__s16)value); 725dde5845aSJiri Kosina case 32: return ((__s32)value); 726dde5845aSJiri Kosina } 727dde5845aSJiri Kosina return value & (1 << (n - 1)) ? value | (-1 << n) : value; 728dde5845aSJiri Kosina } 729dde5845aSJiri Kosina 730dde5845aSJiri Kosina /* 731dde5845aSJiri Kosina * Convert a signed 32-bit integer to a signed n-bit integer. 732dde5845aSJiri Kosina */ 733dde5845aSJiri Kosina 734dde5845aSJiri Kosina static u32 s32ton(__s32 value, unsigned n) 735dde5845aSJiri Kosina { 736dde5845aSJiri Kosina s32 a = value >> (n - 1); 737dde5845aSJiri Kosina if (a && a != -1) 738dde5845aSJiri Kosina return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; 739dde5845aSJiri Kosina return value & ((1 << n) - 1); 740dde5845aSJiri Kosina } 741dde5845aSJiri Kosina 742dde5845aSJiri Kosina /* 743dde5845aSJiri Kosina * Extract/implement a data field from/to a little endian report (bit array). 744dde5845aSJiri Kosina * 745dde5845aSJiri Kosina * Code sort-of follows HID spec: 746dde5845aSJiri Kosina * http://www.usb.org/developers/devclass_docs/HID1_11.pdf 747dde5845aSJiri Kosina * 748dde5845aSJiri Kosina * While the USB HID spec allows unlimited length bit fields in "report 749dde5845aSJiri Kosina * descriptors", most devices never use more than 16 bits. 750dde5845aSJiri Kosina * One model of UPS is claimed to report "LINEV" as a 32-bit field. 751dde5845aSJiri Kosina * Search linux-kernel and linux-usb-devel archives for "hid-core extract". 752dde5845aSJiri Kosina */ 753dde5845aSJiri Kosina 75416ee4cc8SJoe Perches static __u32 extract(const struct hid_device *hid, __u8 *report, 7554291ee30SJoe Perches unsigned offset, unsigned n) 756dde5845aSJiri Kosina { 757dde5845aSJiri Kosina u64 x; 758dde5845aSJiri Kosina 759c4124c9bSJiri Kosina if (n > 32) 7604291ee30SJoe Perches hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n", 761c4124c9bSJiri Kosina n, current->comm); 762dde5845aSJiri Kosina 763dde5845aSJiri Kosina report += offset >> 3; /* adjust byte index */ 764dde5845aSJiri Kosina offset &= 7; /* now only need bit offset into one byte */ 765c105068fSHarvey Harrison x = get_unaligned_le64(report); 766dde5845aSJiri Kosina x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ 767dde5845aSJiri Kosina return (u32) x; 768dde5845aSJiri Kosina } 769dde5845aSJiri Kosina 770dde5845aSJiri Kosina /* 771dde5845aSJiri Kosina * "implement" : set bits in a little endian bit stream. 772dde5845aSJiri Kosina * Same concepts as "extract" (see comments above). 773dde5845aSJiri Kosina * The data mangled in the bit stream remains in little endian 774dde5845aSJiri Kosina * order the whole time. It make more sense to talk about 775dde5845aSJiri Kosina * endianness of register values by considering a register 776dde5845aSJiri Kosina * a "cached" copy of the little endiad bit stream. 777dde5845aSJiri Kosina */ 77816ee4cc8SJoe Perches static void implement(const struct hid_device *hid, __u8 *report, 7794291ee30SJoe Perches unsigned offset, unsigned n, __u32 value) 780dde5845aSJiri Kosina { 7816f0168d2SHarvey Harrison u64 x; 782dde5845aSJiri Kosina u64 m = (1ULL << n) - 1; 783dde5845aSJiri Kosina 784c4124c9bSJiri Kosina if (n > 32) 7854291ee30SJoe Perches hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n", 7864291ee30SJoe Perches __func__, n, current->comm); 787dde5845aSJiri Kosina 788c4124c9bSJiri Kosina if (value > m) 7894291ee30SJoe Perches hid_warn(hid, "%s() called with too large value %d! (%s)\n", 7904291ee30SJoe Perches __func__, value, current->comm); 791dde5845aSJiri Kosina WARN_ON(value > m); 792dde5845aSJiri Kosina value &= m; 793dde5845aSJiri Kosina 794dde5845aSJiri Kosina report += offset >> 3; 795dde5845aSJiri Kosina offset &= 7; 796dde5845aSJiri Kosina 7976f0168d2SHarvey Harrison x = get_unaligned_le64(report); 7986f0168d2SHarvey Harrison x &= ~(m << offset); 7996f0168d2SHarvey Harrison x |= ((u64)value) << offset; 8006f0168d2SHarvey Harrison put_unaligned_le64(x, report); 801dde5845aSJiri Kosina } 802dde5845aSJiri Kosina 803dde5845aSJiri Kosina /* 804dde5845aSJiri Kosina * Search an array for a value. 805dde5845aSJiri Kosina */ 806dde5845aSJiri Kosina 80716ee4cc8SJoe Perches static int search(__s32 *array, __s32 value, unsigned n) 808dde5845aSJiri Kosina { 809dde5845aSJiri Kosina while (n--) { 810dde5845aSJiri Kosina if (*array++ == value) 811dde5845aSJiri Kosina return 0; 812dde5845aSJiri Kosina } 813dde5845aSJiri Kosina return -1; 814dde5845aSJiri Kosina } 815dde5845aSJiri Kosina 81685cdaf52SJiri Slaby /** 81785cdaf52SJiri Slaby * hid_match_report - check if driver's raw_event should be called 81885cdaf52SJiri Slaby * 81985cdaf52SJiri Slaby * @hid: hid device 82085cdaf52SJiri Slaby * @report_type: type to match against 82185cdaf52SJiri Slaby * 82285cdaf52SJiri Slaby * compare hid->driver->report_table->report_type to report->type 82385cdaf52SJiri Slaby */ 82485cdaf52SJiri Slaby static int hid_match_report(struct hid_device *hid, struct hid_report *report) 825dde5845aSJiri Kosina { 82685cdaf52SJiri Slaby const struct hid_report_id *id = hid->driver->report_table; 82785cdaf52SJiri Slaby 82885cdaf52SJiri Slaby if (!id) /* NULL means all */ 82985cdaf52SJiri Slaby return 1; 83085cdaf52SJiri Slaby 83185cdaf52SJiri Slaby for (; id->report_type != HID_TERMINATOR; id++) 83285cdaf52SJiri Slaby if (id->report_type == HID_ANY_ID || 83385cdaf52SJiri Slaby id->report_type == report->type) 83485cdaf52SJiri Slaby return 1; 83585cdaf52SJiri Slaby return 0; 83685cdaf52SJiri Slaby } 83785cdaf52SJiri Slaby 83885cdaf52SJiri Slaby /** 83985cdaf52SJiri Slaby * hid_match_usage - check if driver's event should be called 84085cdaf52SJiri Slaby * 84185cdaf52SJiri Slaby * @hid: hid device 84285cdaf52SJiri Slaby * @usage: usage to match against 84385cdaf52SJiri Slaby * 84485cdaf52SJiri Slaby * compare hid->driver->usage_table->usage_{type,code} to 84585cdaf52SJiri Slaby * usage->usage_{type,code} 84685cdaf52SJiri Slaby */ 84785cdaf52SJiri Slaby static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage) 84885cdaf52SJiri Slaby { 84985cdaf52SJiri Slaby const struct hid_usage_id *id = hid->driver->usage_table; 85085cdaf52SJiri Slaby 85185cdaf52SJiri Slaby if (!id) /* NULL means all */ 85285cdaf52SJiri Slaby return 1; 85385cdaf52SJiri Slaby 85485cdaf52SJiri Slaby for (; id->usage_type != HID_ANY_ID - 1; id++) 85585cdaf52SJiri Slaby if ((id->usage_hid == HID_ANY_ID || 85685cdaf52SJiri Slaby id->usage_hid == usage->hid) && 85785cdaf52SJiri Slaby (id->usage_type == HID_ANY_ID || 85885cdaf52SJiri Slaby id->usage_type == usage->type) && 85985cdaf52SJiri Slaby (id->usage_code == HID_ANY_ID || 86085cdaf52SJiri Slaby id->usage_code == usage->code)) 86185cdaf52SJiri Slaby return 1; 86285cdaf52SJiri Slaby return 0; 86385cdaf52SJiri Slaby } 86485cdaf52SJiri Slaby 86585cdaf52SJiri Slaby static void hid_process_event(struct hid_device *hid, struct hid_field *field, 86685cdaf52SJiri Slaby struct hid_usage *usage, __s32 value, int interrupt) 86785cdaf52SJiri Slaby { 86885cdaf52SJiri Slaby struct hid_driver *hdrv = hid->driver; 86985cdaf52SJiri Slaby int ret; 87085cdaf52SJiri Slaby 871cd667ce2SJiri Kosina hid_dump_input(hid, usage, value); 87285cdaf52SJiri Slaby 87385cdaf52SJiri Slaby if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { 87485cdaf52SJiri Slaby ret = hdrv->event(hid, field, usage, value); 87585cdaf52SJiri Slaby if (ret != 0) { 87685cdaf52SJiri Slaby if (ret < 0) 8778c3d52fcSJiri Kosina hid_err(hid, "%s's event failed with %d\n", 87885cdaf52SJiri Slaby hdrv->name, ret); 87985cdaf52SJiri Slaby return; 88085cdaf52SJiri Slaby } 88185cdaf52SJiri Slaby } 88285cdaf52SJiri Slaby 883dde5845aSJiri Kosina if (hid->claimed & HID_CLAIMED_INPUT) 884dde5845aSJiri Kosina hidinput_hid_event(hid, field, usage, value); 885aa938f79SJiri Kosina if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) 886aa938f79SJiri Kosina hid->hiddev_hid_event(hid, field, usage, value); 887dde5845aSJiri Kosina } 888dde5845aSJiri Kosina 889dde5845aSJiri Kosina /* 890dde5845aSJiri Kosina * Analyse a received field, and fetch the data from it. The field 891dde5845aSJiri Kosina * content is stored for next report processing (we do differential 892dde5845aSJiri Kosina * reporting to the layer). 893dde5845aSJiri Kosina */ 894dde5845aSJiri Kosina 895abdff0f7SAdrian Bunk static void hid_input_field(struct hid_device *hid, struct hid_field *field, 896abdff0f7SAdrian Bunk __u8 *data, int interrupt) 897dde5845aSJiri Kosina { 898dde5845aSJiri Kosina unsigned n; 899dde5845aSJiri Kosina unsigned count = field->report_count; 900dde5845aSJiri Kosina unsigned offset = field->report_offset; 901dde5845aSJiri Kosina unsigned size = field->report_size; 902dde5845aSJiri Kosina __s32 min = field->logical_minimum; 903dde5845aSJiri Kosina __s32 max = field->logical_maximum; 904dde5845aSJiri Kosina __s32 *value; 905dde5845aSJiri Kosina 906a3789a17SJoe Perches value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC); 907a3789a17SJoe Perches if (!value) 908dde5845aSJiri Kosina return; 909dde5845aSJiri Kosina 910dde5845aSJiri Kosina for (n = 0; n < count; n++) { 911dde5845aSJiri Kosina 9124291ee30SJoe Perches value[n] = min < 0 ? 9134291ee30SJoe Perches snto32(extract(hid, data, offset + n * size, size), 9144291ee30SJoe Perches size) : 9154291ee30SJoe Perches extract(hid, data, offset + n * size, size); 916dde5845aSJiri Kosina 9174291ee30SJoe Perches /* Ignore report if ErrorRollOver */ 9184291ee30SJoe Perches if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && 9194291ee30SJoe Perches value[n] >= min && value[n] <= max && 9204291ee30SJoe Perches field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) 921dde5845aSJiri Kosina goto exit; 922dde5845aSJiri Kosina } 923dde5845aSJiri Kosina 924dde5845aSJiri Kosina for (n = 0; n < count; n++) { 925dde5845aSJiri Kosina 926dde5845aSJiri Kosina if (HID_MAIN_ITEM_VARIABLE & field->flags) { 927dde5845aSJiri Kosina hid_process_event(hid, field, &field->usage[n], value[n], interrupt); 928dde5845aSJiri Kosina continue; 929dde5845aSJiri Kosina } 930dde5845aSJiri Kosina 931dde5845aSJiri Kosina if (field->value[n] >= min && field->value[n] <= max 932dde5845aSJiri Kosina && field->usage[field->value[n] - min].hid 933dde5845aSJiri Kosina && search(value, field->value[n], count)) 934dde5845aSJiri Kosina hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); 935dde5845aSJiri Kosina 936dde5845aSJiri Kosina if (value[n] >= min && value[n] <= max 937dde5845aSJiri Kosina && field->usage[value[n] - min].hid 938dde5845aSJiri Kosina && search(field->value, value[n], count)) 939dde5845aSJiri Kosina hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); 940dde5845aSJiri Kosina } 941dde5845aSJiri Kosina 942dde5845aSJiri Kosina memcpy(field->value, value, count * sizeof(__s32)); 943dde5845aSJiri Kosina exit: 944dde5845aSJiri Kosina kfree(value); 945dde5845aSJiri Kosina } 946dde5845aSJiri Kosina 947dde5845aSJiri Kosina /* 948dde5845aSJiri Kosina * Output the field into the report. 949dde5845aSJiri Kosina */ 950dde5845aSJiri Kosina 9514291ee30SJoe Perches static void hid_output_field(const struct hid_device *hid, 9524291ee30SJoe Perches struct hid_field *field, __u8 *data) 953dde5845aSJiri Kosina { 954dde5845aSJiri Kosina unsigned count = field->report_count; 955dde5845aSJiri Kosina unsigned offset = field->report_offset; 956dde5845aSJiri Kosina unsigned size = field->report_size; 957dde5845aSJiri Kosina unsigned n; 958dde5845aSJiri Kosina 959dde5845aSJiri Kosina for (n = 0; n < count; n++) { 960dde5845aSJiri Kosina if (field->logical_minimum < 0) /* signed values */ 9614291ee30SJoe Perches implement(hid, data, offset + n * size, size, 9624291ee30SJoe Perches s32ton(field->value[n], size)); 963dde5845aSJiri Kosina else /* unsigned values */ 9644291ee30SJoe Perches implement(hid, data, offset + n * size, size, 9654291ee30SJoe Perches field->value[n]); 966dde5845aSJiri Kosina } 967dde5845aSJiri Kosina } 968dde5845aSJiri Kosina 969dde5845aSJiri Kosina /* 970dde5845aSJiri Kosina * Create a report. 971dde5845aSJiri Kosina */ 972dde5845aSJiri Kosina 973229695e5SJiri Kosina void hid_output_report(struct hid_report *report, __u8 *data) 974dde5845aSJiri Kosina { 975dde5845aSJiri Kosina unsigned n; 976dde5845aSJiri Kosina 977dde5845aSJiri Kosina if (report->id > 0) 978dde5845aSJiri Kosina *data++ = report->id; 979dde5845aSJiri Kosina 98075c28df8SPete Zaitcev memset(data, 0, ((report->size - 1) >> 3) + 1); 981dde5845aSJiri Kosina for (n = 0; n < report->maxfield; n++) 9824291ee30SJoe Perches hid_output_field(report->device, report->field[n], data); 983dde5845aSJiri Kosina } 984229695e5SJiri Kosina EXPORT_SYMBOL_GPL(hid_output_report); 985dde5845aSJiri Kosina 986dde5845aSJiri Kosina /* 987dde5845aSJiri Kosina * Set a field value. The report this field belongs to has to be 988dde5845aSJiri Kosina * created and transferred to the device, to set this value in the 989dde5845aSJiri Kosina * device. 990dde5845aSJiri Kosina */ 991dde5845aSJiri Kosina 992dde5845aSJiri Kosina int hid_set_field(struct hid_field *field, unsigned offset, __s32 value) 993dde5845aSJiri Kosina { 994dde5845aSJiri Kosina unsigned size = field->report_size; 995dde5845aSJiri Kosina 996cd667ce2SJiri Kosina hid_dump_input(field->report->device, field->usage + offset, value); 997dde5845aSJiri Kosina 998dde5845aSJiri Kosina if (offset >= field->report_count) { 9998c3d52fcSJiri Kosina hid_err(field->report->device, "offset (%d) exceeds report_count (%d)\n", 10008c3d52fcSJiri Kosina offset, field->report_count); 1001dde5845aSJiri Kosina return -1; 1002dde5845aSJiri Kosina } 1003dde5845aSJiri Kosina if (field->logical_minimum < 0) { 1004dde5845aSJiri Kosina if (value != snto32(s32ton(value, size), size)) { 10058c3d52fcSJiri Kosina hid_err(field->report->device, "value %d is out of range\n", value); 1006dde5845aSJiri Kosina return -1; 1007dde5845aSJiri Kosina } 1008dde5845aSJiri Kosina } 1009dde5845aSJiri Kosina field->value[offset] = value; 1010dde5845aSJiri Kosina return 0; 1011dde5845aSJiri Kosina } 1012229695e5SJiri Kosina EXPORT_SYMBOL_GPL(hid_set_field); 1013dde5845aSJiri Kosina 101485cdaf52SJiri Slaby static struct hid_report *hid_get_report(struct hid_report_enum *report_enum, 101585cdaf52SJiri Slaby const u8 *data) 101685cdaf52SJiri Slaby { 101785cdaf52SJiri Slaby struct hid_report *report; 101885cdaf52SJiri Slaby unsigned int n = 0; /* Normally report number is 0 */ 101985cdaf52SJiri Slaby 102085cdaf52SJiri Slaby /* Device uses numbered reports, data[0] is report number */ 102185cdaf52SJiri Slaby if (report_enum->numbered) 102285cdaf52SJiri Slaby n = *data; 102385cdaf52SJiri Slaby 102485cdaf52SJiri Slaby report = report_enum->report_id_hash[n]; 102585cdaf52SJiri Slaby if (report == NULL) 102685cdaf52SJiri Slaby dbg_hid("undefined report_id %u received\n", n); 102785cdaf52SJiri Slaby 102885cdaf52SJiri Slaby return report; 102985cdaf52SJiri Slaby } 103085cdaf52SJiri Slaby 103185cdaf52SJiri Slaby void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, 103285cdaf52SJiri Slaby int interrupt) 1033aa8de2f0SJiri Kosina { 1034aa8de2f0SJiri Kosina struct hid_report_enum *report_enum = hid->report_enum + type; 1035aa8de2f0SJiri Kosina struct hid_report *report; 103685cdaf52SJiri Slaby unsigned int a; 103785cdaf52SJiri Slaby int rsize, csize = size; 103885cdaf52SJiri Slaby u8 *cdata = data; 1039aa8de2f0SJiri Kosina 104085cdaf52SJiri Slaby report = hid_get_report(report_enum, data); 104185cdaf52SJiri Slaby if (!report) 104285cdaf52SJiri Slaby return; 1043aa8de2f0SJiri Kosina 104485cdaf52SJiri Slaby if (report_enum->numbered) { 104585cdaf52SJiri Slaby cdata++; 104685cdaf52SJiri Slaby csize--; 1047aa8de2f0SJiri Kosina } 1048aa8de2f0SJiri Kosina 1049aa8de2f0SJiri Kosina rsize = ((report->size - 1) >> 3) + 1; 1050aa8de2f0SJiri Kosina 1051966922f2SArmando Visconti if (rsize > HID_MAX_BUFFER_SIZE) 1052966922f2SArmando Visconti rsize = HID_MAX_BUFFER_SIZE; 1053966922f2SArmando Visconti 105485cdaf52SJiri Slaby if (csize < rsize) { 105585cdaf52SJiri Slaby dbg_hid("report %d is too short, (%d < %d)\n", report->id, 105685cdaf52SJiri Slaby csize, rsize); 105785cdaf52SJiri Slaby memset(cdata + csize, 0, rsize - csize); 1058aa8de2f0SJiri Kosina } 1059aa8de2f0SJiri Kosina 1060aa8de2f0SJiri Kosina if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) 1061aa8de2f0SJiri Kosina hid->hiddev_report_event(hid, report); 10625a38f2c7SAlan Ott if (hid->claimed & HID_CLAIMED_HIDRAW) 106386166b7bSJiri Kosina hidraw_report_event(hid, data, size); 1064aa8de2f0SJiri Kosina 106585cdaf52SJiri Slaby for (a = 0; a < report->maxfield; a++) 106685cdaf52SJiri Slaby hid_input_field(hid, report->field[a], cdata, interrupt); 1067aa8de2f0SJiri Kosina 1068aa8de2f0SJiri Kosina if (hid->claimed & HID_CLAIMED_INPUT) 1069aa8de2f0SJiri Kosina hidinput_report_event(hid, report); 107085cdaf52SJiri Slaby } 107185cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_report_raw_event); 107285cdaf52SJiri Slaby 107385cdaf52SJiri Slaby /** 107485cdaf52SJiri Slaby * hid_input_report - report data from lower layer (usb, bt...) 107585cdaf52SJiri Slaby * 107685cdaf52SJiri Slaby * @hid: hid device 107785cdaf52SJiri Slaby * @type: HID report type (HID_*_REPORT) 107885cdaf52SJiri Slaby * @data: report contents 107985cdaf52SJiri Slaby * @size: size of data parameter 1080ff9b00a2SJiri Kosina * @interrupt: distinguish between interrupt and control transfers 108185cdaf52SJiri Slaby * 108285cdaf52SJiri Slaby * This is data entry for lower layers. 108385cdaf52SJiri Slaby */ 108485cdaf52SJiri Slaby int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) 108585cdaf52SJiri Slaby { 108676c317d6SJulia Lawall struct hid_report_enum *report_enum; 108776c317d6SJulia Lawall struct hid_driver *hdrv; 108885cdaf52SJiri Slaby struct hid_report *report; 1089cd667ce2SJiri Kosina char *buf; 109085cdaf52SJiri Slaby unsigned int i; 109145dc1ac7SJiri Kosina int ret = 0; 109285cdaf52SJiri Slaby 10934ea54542SDavid Herrmann if (!hid) 109485cdaf52SJiri Slaby return -ENODEV; 10954ea54542SDavid Herrmann 10964ea54542SDavid Herrmann if (down_trylock(&hid->driver_lock)) 10974ea54542SDavid Herrmann return -EBUSY; 10984ea54542SDavid Herrmann 10994ea54542SDavid Herrmann if (!hid->driver) { 11004ea54542SDavid Herrmann ret = -ENODEV; 11014ea54542SDavid Herrmann goto unlock; 11024ea54542SDavid Herrmann } 110376c317d6SJulia Lawall report_enum = hid->report_enum + type; 110476c317d6SJulia Lawall hdrv = hid->driver; 110585cdaf52SJiri Slaby 110685cdaf52SJiri Slaby if (!size) { 110785cdaf52SJiri Slaby dbg_hid("empty report\n"); 11084ea54542SDavid Herrmann ret = -1; 11094ea54542SDavid Herrmann goto unlock; 111085cdaf52SJiri Slaby } 111185cdaf52SJiri Slaby 1112d1ff6522SJiri Kosina buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC); 1113cd667ce2SJiri Kosina 1114f77e347bSJiri Kosina if (!buf) 1115cd667ce2SJiri Kosina goto nomem; 111685cdaf52SJiri Slaby 111785cdaf52SJiri Slaby /* dump the report */ 1118cd667ce2SJiri Kosina snprintf(buf, HID_DEBUG_BUFSIZE - 1, 11191caea61eSJiri Kosina "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un"); 1120cd667ce2SJiri Kosina hid_debug_event(hid, buf); 11211caea61eSJiri Kosina 1122cd667ce2SJiri Kosina for (i = 0; i < size; i++) { 1123cd667ce2SJiri Kosina snprintf(buf, HID_DEBUG_BUFSIZE - 1, 1124cd667ce2SJiri Kosina " %02x", data[i]); 1125cd667ce2SJiri Kosina hid_debug_event(hid, buf); 1126cd667ce2SJiri Kosina } 1127cd667ce2SJiri Kosina hid_debug_event(hid, "\n"); 1128cd667ce2SJiri Kosina kfree(buf); 1129cd667ce2SJiri Kosina 1130cd667ce2SJiri Kosina nomem: 1131f77e347bSJiri Kosina report = hid_get_report(report_enum, data); 1132f77e347bSJiri Kosina 11334ea54542SDavid Herrmann if (!report) { 11344ea54542SDavid Herrmann ret = -1; 11354ea54542SDavid Herrmann goto unlock; 11364ea54542SDavid Herrmann } 1137f77e347bSJiri Kosina 113885cdaf52SJiri Slaby if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { 113985cdaf52SJiri Slaby ret = hdrv->raw_event(hid, report, data, size); 11404ea54542SDavid Herrmann if (ret != 0) { 11414ea54542SDavid Herrmann ret = ret < 0 ? ret : 0; 11424ea54542SDavid Herrmann goto unlock; 11434ea54542SDavid Herrmann } 114485cdaf52SJiri Slaby } 114585cdaf52SJiri Slaby 114685cdaf52SJiri Slaby hid_report_raw_event(hid, type, data, size, interrupt); 1147aa8de2f0SJiri Kosina 11484ea54542SDavid Herrmann unlock: 11494ea54542SDavid Herrmann up(&hid->driver_lock); 115045dc1ac7SJiri Kosina return ret; 1151aa8de2f0SJiri Kosina } 1152aa8de2f0SJiri Kosina EXPORT_SYMBOL_GPL(hid_input_report); 1153aa8de2f0SJiri Kosina 11540f37cd03SJiri Kosina static bool hid_match_one_id(struct hid_device *hdev, 11550f37cd03SJiri Kosina const struct hid_device_id *id) 11560f37cd03SJiri Kosina { 11570f37cd03SJiri Kosina return id->bus == hdev->bus && 11580f37cd03SJiri Kosina (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && 11590f37cd03SJiri Kosina (id->product == HID_ANY_ID || id->product == hdev->product); 11600f37cd03SJiri Kosina } 11610f37cd03SJiri Kosina 1162bbc21cfdSJeremy Fitzhardinge const struct hid_device_id *hid_match_id(struct hid_device *hdev, 11630f37cd03SJiri Kosina const struct hid_device_id *id) 11640f37cd03SJiri Kosina { 11650f37cd03SJiri Kosina for (; id->bus; id++) 11660f37cd03SJiri Kosina if (hid_match_one_id(hdev, id)) 11670f37cd03SJiri Kosina return id; 11680f37cd03SJiri Kosina 11690f37cd03SJiri Kosina return NULL; 11700f37cd03SJiri Kosina } 11710f37cd03SJiri Kosina 11720f37cd03SJiri Kosina static const struct hid_device_id hid_hiddev_list[] = { 1173c0bd6a42SRichard Hughes { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, 1174c0bd6a42SRichard Hughes { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, 11750f37cd03SJiri Kosina { } 11760f37cd03SJiri Kosina }; 11770f37cd03SJiri Kosina 11780f37cd03SJiri Kosina static bool hid_hiddev(struct hid_device *hdev) 11790f37cd03SJiri Kosina { 11800f37cd03SJiri Kosina return !!hid_match_id(hdev, hid_hiddev_list); 11810f37cd03SJiri Kosina } 11820f37cd03SJiri Kosina 11836d3bfb74SAlan Ott 11846d3bfb74SAlan Ott static ssize_t 11856d3bfb74SAlan Ott read_report_descriptor(struct file *filp, struct kobject *kobj, 11866d3bfb74SAlan Ott struct bin_attribute *attr, 11876d3bfb74SAlan Ott char *buf, loff_t off, size_t count) 11886d3bfb74SAlan Ott { 11896d3bfb74SAlan Ott struct device *dev = container_of(kobj, struct device, kobj); 11906d3bfb74SAlan Ott struct hid_device *hdev = container_of(dev, struct hid_device, dev); 11916d3bfb74SAlan Ott 11926d3bfb74SAlan Ott if (off >= hdev->rsize) 11936d3bfb74SAlan Ott return 0; 11946d3bfb74SAlan Ott 11956d3bfb74SAlan Ott if (off + count > hdev->rsize) 11966d3bfb74SAlan Ott count = hdev->rsize - off; 11976d3bfb74SAlan Ott 11986d3bfb74SAlan Ott memcpy(buf, hdev->rdesc + off, count); 11996d3bfb74SAlan Ott 12006d3bfb74SAlan Ott return count; 12016d3bfb74SAlan Ott } 12026d3bfb74SAlan Ott 12036d3bfb74SAlan Ott static struct bin_attribute dev_bin_attr_report_desc = { 12046d3bfb74SAlan Ott .attr = { .name = "report_descriptor", .mode = 0444 }, 12056d3bfb74SAlan Ott .read = read_report_descriptor, 12066d3bfb74SAlan Ott .size = HID_MAX_DESCRIPTOR_SIZE, 12076d3bfb74SAlan Ott }; 12086d3bfb74SAlan Ott 120993c10132SJiri Slaby int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 121093c10132SJiri Slaby { 121193c10132SJiri Slaby static const char *types[] = { "Device", "Pointer", "Mouse", "Device", 121293c10132SJiri Slaby "Joystick", "Gamepad", "Keyboard", "Keypad", 121393c10132SJiri Slaby "Multi-Axis Controller" 121493c10132SJiri Slaby }; 121593c10132SJiri Slaby const char *type, *bus; 121693c10132SJiri Slaby char buf[64]; 121793c10132SJiri Slaby unsigned int i; 121893c10132SJiri Slaby int len; 12196d3bfb74SAlan Ott int ret; 122093c10132SJiri Slaby 1221b5e5a37eSBastien Nocera if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) 1222b5e5a37eSBastien Nocera connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV); 12233a343ee4SDaniel Mack if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE) 12243a343ee4SDaniel Mack connect_mask |= HID_CONNECT_HIDINPUT_FORCE; 122593c10132SJiri Slaby if (hdev->bus != BUS_USB) 122693c10132SJiri Slaby connect_mask &= ~HID_CONNECT_HIDDEV; 12270f37cd03SJiri Kosina if (hid_hiddev(hdev)) 12280f37cd03SJiri Kosina connect_mask |= HID_CONNECT_HIDDEV_FORCE; 122993c10132SJiri Slaby 123093c10132SJiri Slaby if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev, 123193c10132SJiri Slaby connect_mask & HID_CONNECT_HIDINPUT_FORCE)) 123293c10132SJiri Slaby hdev->claimed |= HID_CLAIMED_INPUT; 1233b77c3920SBenjamin Tissoires if (hdev->quirks & HID_QUIRK_MULTITOUCH) { 1234b77c3920SBenjamin Tissoires /* this device should be handled by hid-multitouch, skip it */ 1235b77c3920SBenjamin Tissoires hdev->quirks &= ~HID_QUIRK_MULTITOUCH; 1236b77c3920SBenjamin Tissoires return -ENODEV; 1237b77c3920SBenjamin Tissoires } 1238b77c3920SBenjamin Tissoires 123993c10132SJiri Slaby if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect && 124093c10132SJiri Slaby !hdev->hiddev_connect(hdev, 124193c10132SJiri Slaby connect_mask & HID_CONNECT_HIDDEV_FORCE)) 124293c10132SJiri Slaby hdev->claimed |= HID_CLAIMED_HIDDEV; 124393c10132SJiri Slaby if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev)) 124493c10132SJiri Slaby hdev->claimed |= HID_CLAIMED_HIDRAW; 124593c10132SJiri Slaby 124693c10132SJiri Slaby if (!hdev->claimed) { 12474291ee30SJoe Perches hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n"); 124893c10132SJiri Slaby return -ENODEV; 124993c10132SJiri Slaby } 125093c10132SJiri Slaby 125193c10132SJiri Slaby if ((hdev->claimed & HID_CLAIMED_INPUT) && 125293c10132SJiri Slaby (connect_mask & HID_CONNECT_FF) && hdev->ff_init) 125393c10132SJiri Slaby hdev->ff_init(hdev); 125493c10132SJiri Slaby 125593c10132SJiri Slaby len = 0; 125693c10132SJiri Slaby if (hdev->claimed & HID_CLAIMED_INPUT) 125793c10132SJiri Slaby len += sprintf(buf + len, "input"); 125893c10132SJiri Slaby if (hdev->claimed & HID_CLAIMED_HIDDEV) 125993c10132SJiri Slaby len += sprintf(buf + len, "%shiddev%d", len ? "," : "", 126093c10132SJiri Slaby hdev->minor); 126193c10132SJiri Slaby if (hdev->claimed & HID_CLAIMED_HIDRAW) 126293c10132SJiri Slaby len += sprintf(buf + len, "%shidraw%d", len ? "," : "", 126393c10132SJiri Slaby ((struct hidraw *)hdev->hidraw)->minor); 126493c10132SJiri Slaby 126593c10132SJiri Slaby type = "Device"; 126693c10132SJiri Slaby for (i = 0; i < hdev->maxcollection; i++) { 126793c10132SJiri Slaby struct hid_collection *col = &hdev->collection[i]; 126893c10132SJiri Slaby if (col->type == HID_COLLECTION_APPLICATION && 126993c10132SJiri Slaby (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK && 127093c10132SJiri Slaby (col->usage & 0xffff) < ARRAY_SIZE(types)) { 127193c10132SJiri Slaby type = types[col->usage & 0xffff]; 127293c10132SJiri Slaby break; 127393c10132SJiri Slaby } 127493c10132SJiri Slaby } 127593c10132SJiri Slaby 127693c10132SJiri Slaby switch (hdev->bus) { 127793c10132SJiri Slaby case BUS_USB: 127893c10132SJiri Slaby bus = "USB"; 127993c10132SJiri Slaby break; 128093c10132SJiri Slaby case BUS_BLUETOOTH: 128193c10132SJiri Slaby bus = "BLUETOOTH"; 128293c10132SJiri Slaby break; 128393c10132SJiri Slaby default: 128493c10132SJiri Slaby bus = "<UNKNOWN>"; 128593c10132SJiri Slaby } 128693c10132SJiri Slaby 12876d3bfb74SAlan Ott ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc); 12886d3bfb74SAlan Ott if (ret) 12896d3bfb74SAlan Ott hid_warn(hdev, 12906d3bfb74SAlan Ott "can't create sysfs report descriptor attribute err: %d\n", ret); 12916d3bfb74SAlan Ott 12924291ee30SJoe Perches hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", 129393c10132SJiri Slaby buf, bus, hdev->version >> 8, hdev->version & 0xff, 129493c10132SJiri Slaby type, hdev->name, hdev->phys); 129593c10132SJiri Slaby 129693c10132SJiri Slaby return 0; 129793c10132SJiri Slaby } 129893c10132SJiri Slaby EXPORT_SYMBOL_GPL(hid_connect); 129993c10132SJiri Slaby 1300c4c259bcSJiri Kosina void hid_disconnect(struct hid_device *hdev) 1301c4c259bcSJiri Kosina { 13026d3bfb74SAlan Ott device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc); 1303c4c259bcSJiri Kosina if (hdev->claimed & HID_CLAIMED_INPUT) 1304c4c259bcSJiri Kosina hidinput_disconnect(hdev); 1305c4c259bcSJiri Kosina if (hdev->claimed & HID_CLAIMED_HIDDEV) 1306c4c259bcSJiri Kosina hdev->hiddev_disconnect(hdev); 1307c4c259bcSJiri Kosina if (hdev->claimed & HID_CLAIMED_HIDRAW) 1308c4c259bcSJiri Kosina hidraw_disconnect(hdev); 1309c4c259bcSJiri Kosina } 1310c4c259bcSJiri Kosina EXPORT_SYMBOL_GPL(hid_disconnect); 1311c4c259bcSJiri Kosina 1312bae7eb33SJiri Kosina /* a list of devices for which there is a specialized driver on HID bus */ 1313ce06b9d6SDmitry Torokhov static const struct hid_device_id hid_have_special_driver[] = { 1314b6353f4fSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, 13156dec143aSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, 131614a21cd4SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 131714a21cd4SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1318b7e1b203SLech Perczak { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, 1319c0dbcc33SSergei Kolzun { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) }, 1320e6aac342SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR, USB_DEVICE_ID_ACTIONSTAR_1011) }, 1321df9bcaceSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, 13228c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, 13238c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, 1324128537ceSMichael Poole { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) }, 1325a462230eSChase Douglas { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) }, 13268c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 13278c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 13288c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 13298c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 13308c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 13318c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 13328c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 13338c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 13348c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 13358c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 13368c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1337fef3f571SRyan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI) }, 1338fef3f571SRyan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO) }, 1339fef3f571SRyan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS) }, 13408c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) }, 13418c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) }, 13428c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) }, 13438c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 13448c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 13458c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1346ee8a1a0aSJan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, 1347ee8a1a0aSJan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, 1348ee8a1a0aSJan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, 13498c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 13508c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 13518c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 13528c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 13538c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 13548c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1355a96d6ef3SHenrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1356a96d6ef3SHenrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1357a96d6ef3SHenrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 135899b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 135999b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 136099b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 136199b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 136299b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 136399b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 136447340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, 136547340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, 136647340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, 1367213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) }, 1368213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) }, 1369213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) }, 13704a4c8799SDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) }, 13714a4c8799SDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) }, 13724a4c8799SDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) }, 1373f6f554f0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) }, 1374f6f554f0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) }, 1375f6f554f0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) }, 1376d762cc29SNobuhiro Iwamatsu { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 1377d762cc29SNobuhiro Iwamatsu { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 1378d762cc29SNobuhiro Iwamatsu { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 137923aeb61eSChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, 138023aeb61eSChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, 138123aeb61eSChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 1382ad734bc1SAndreas Krist { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) }, 13838c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 13848c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1385eaca1386SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) }, 1386cec15a0eSRoland Baum { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, 1387b5635b12SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1388bf280628SWayne Thomas { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, 1389c3dc66deSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, 13905519cab4SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, 139136213e1eSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, 1392bc5ab083SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) }, 1393ba4d8abbSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, 1394272036edSFrançois Jaouen { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, 13953b239cd7SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 13961ce31b25SRaphaël Doursenaud { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, 1397fcfacfd3SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1398b9e4b1e0SDennis Kügler { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, 1399942fd422SAustin Zhang { HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, 14003a370ca1SDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, 140179603dc9SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, USB_DEVICE_ID_CVTOUCH_SCREEN) }, 14020f221320SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 14030f221320SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, 1404e8d0eab4SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) }, 14050f221320SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, 1406a3b5e577SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, 14073f866fbdSRichard Walmsley { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, 1408e05eefb9SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) }, 1409e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) }, 1410e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) }, 1411e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) }, 1412*fd1d1525SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) }, 1413*fd1d1525SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) }, 1414e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) }, 1415e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) }, 1416bb9ff210SMarek Vasut { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) }, 1417e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) }, 141864b386eaSRichard Nauber { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 1419c04abeefSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2515) }, 142004561c5aSIgnaz Forster { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) }, 14211f243e30SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 14225181e594SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, 1423578f3a35SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, 14245572da08SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, 1425ee0fbd14SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, USB_DEVICE_ID_GOODTOUCH_000f) }, 14265181e594SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, 142742859e0bSLukasz Lubojanski { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) }, 1428949f8fefSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, 14291e093206SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, 1430c2fd1a4eSCory Maccarrone { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, 14315519cab4SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_HANVON, USB_DEVICE_ID_HANVON_MULTITOUCH) }, 143254580365SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, 1433a062cc5aSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM, USB_DEVICE_ID_IDEACOM_IDC6650) }, 1434d946e65eSAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) }, 14354e61f0d7SAustin Zhang { HID_USB_DEVICE(USB_VENDOR_ID_ILITEK, USB_DEVICE_ID_ILITEK_MULTITOUCH) }, 1436b2e7617eSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS, USB_DEVICE_ID_IRTOUCH_INFRARED_USB) }, 1437fdf93aa3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, 1438177900e8SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, 143979422741SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, 1440b5635b12SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 144175b07022SChris Schlund { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) }, 1442c50bb1a4SJeff Brown { HID_USB_DEVICE(USB_VENDOR_ID_LG, USB_DEVICE_ID_LG_MULTITOUCH) }, 14435f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, 14445f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, 14455f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, 14465f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, 14475f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, 14485f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, 14495f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, 14505f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, 14515f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, 14525f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, 14535f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) }, 14542c6118e4SHendrik Iben { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) }, 1455606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) }, 1456606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) }, 1457606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, 1458fd30ea8cSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) }, 1459606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, 146074f292caSGary Stein { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) }, 1461606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) }, 1462606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) }, 14635623a24aSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL) }, 1464e00ddc9bSMichal Malý { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL) }, 1465243b706dSChristophe Borivant { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) }, 1466fdc6807fSPeter Gundermann { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G27_WHEEL) }, 1467534a7b8eSNestor Lopez Casado { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER) }, 1468534a7b8eSNestor Lopez Casado { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2) }, 146932c88cbcSSimon Wood { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) }, 1470606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, 147124985cf6SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) }, 147224985cf6SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) }, 1473df167c4aSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH) }, 1474c3ead6deSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH_DUAL) }, 1475236db47cSBruno Prémont { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, 1476236db47cSBruno Prémont { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) }, 1477b580169aSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) }, 147878a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, 147978a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, 148078a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, 148178a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, 1482f3b83d71SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) }, 148378a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 14843b8006e5SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 148594011f93SRafi Rubin { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, 14866e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) }, 14876e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) }, 14886e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) }, 14896e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) }, 14906e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) }, 14916e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) }, 14926e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) }, 14936e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) }, 14946e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) }, 14956e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) }, 14966e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) }, 14976e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) }, 14986e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) }, 14996e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) }, 15006e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) }, 15016e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) }, 15026e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) }, 15036e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) }, 1504270fdc07SHerton Ronaldo Krzesinski { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) }, 1505cd9ec30dSJohnathon Harris { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, 15062258e863SDenis Kovalev { HID_USB_DEVICE(USB_VENDOR_ID_PANASONIC, USB_DEVICE_ID_PANABOARD_UBT780) }, 15072258e863SDenis Kovalev { HID_USB_DEVICE(USB_VENDOR_ID_PANASONIC, USB_DEVICE_ID_PANABOARD_UBT880) }, 15086ab3a9a6SJohn Sung { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_PCI) }, 15091e762532SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 1510b7ea95ffSAaron Tian { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) }, 1511b7ea95ffSAaron Tian { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) }, 1512b7ea95ffSAaron Tian { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) }, 1513f6a04605STerry Lambert { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) }, 151449e4739aSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, 1515f54405dbSAlex Neblett { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, 151614bf62cdSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, 1517e68cc603SStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) }, 1518d41c2a70SStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) }, 151947dbdbffSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, 15200e70f97fSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) }, 1521cb7cf3daSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, 15223fce2246SStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) }, 1523980a3da6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1524b355850bSDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, 1525d586dca0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) }, 1526bd28ce00SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 152735dca5b4SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) }, 1528f9ce7c28SBastien Nocera { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1529cc6e0bbbSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1530d3fb5454SStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) }, 1531b6dc7992SPascal Auriel - Stantum { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) }, 1532b6dc7992SPascal Auriel - Stantum { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) }, 153390231e7eSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1534daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1535daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, 15367a84b133SRuben Aos Garralda { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, 15377a84b133SRuben Aos Garralda { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) }, 1538daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, 15393ee8f0a2SMarkus Rathgeb { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) }, 1540daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, 1541d65c3768SSimon Wood { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) }, 1542f14f526dSLev Babiev { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, 154354001081SKees Bakker { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) }, 15445e74e56dSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, 1545711a680eSBruno Premont { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, 1546c64f6f93SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, 154741fa9230SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, 1548f8a489ccSNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) }, 1549f8a489ccSNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) }, 1550f8a489ccSNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) }, 15516be914f1SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) }, 1552617b64f9SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, 1553617b64f9SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, 1554fac733f0SJussi Kivilinna { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, 1555ad395ccaSSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) }, 15561bcc2067SSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) }, 15571bcc2067SSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) }, 15581bcc2067SSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) }, 1559ca2dcd40SBastien Nocera { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, 156078761ff9SPrzemo Firszt { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, 156172a46344SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, 156200e7f964SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, 156372a46344SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, 15648f1acc32SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, 1565bc8a2a9bSice chien { HID_USB_DEVICE(USB_VENDOR_ID_XAT, USB_DEVICE_ID_XAT_CSR) }, 156611576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX) }, 156711576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX) }, 156811576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR) }, 156911576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX1) }, 157011576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX1) }, 157111576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR1) }, 157211576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX2) }, 157311576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX2) }, 157411576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR2) }, 157574bc6953SStefan Kriwanek { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) }, 1576daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, 1577daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, 1578a9885c8fSDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, 15798c19a515SJiri Slaby 158078a849a6SJiri Slaby { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, 158102fb72a0SDavid Herrmann { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) }, 158285cdaf52SJiri Slaby { } 158385cdaf52SJiri Slaby }; 158485cdaf52SJiri Slaby 15853a6f82f7SJiri Slaby struct hid_dynid { 15863a6f82f7SJiri Slaby struct list_head list; 15873a6f82f7SJiri Slaby struct hid_device_id id; 15883a6f82f7SJiri Slaby }; 15893a6f82f7SJiri Slaby 15903a6f82f7SJiri Slaby /** 15913a6f82f7SJiri Slaby * store_new_id - add a new HID device ID to this driver and re-probe devices 15923a6f82f7SJiri Slaby * @driver: target device driver 15933a6f82f7SJiri Slaby * @buf: buffer for scanning device ID data 15943a6f82f7SJiri Slaby * @count: input size 15953a6f82f7SJiri Slaby * 15963a6f82f7SJiri Slaby * Adds a new dynamic hid device ID to this driver, 15973a6f82f7SJiri Slaby * and causes the driver to probe for all devices again. 15983a6f82f7SJiri Slaby */ 15993a6f82f7SJiri Slaby static ssize_t store_new_id(struct device_driver *drv, const char *buf, 16003a6f82f7SJiri Slaby size_t count) 16013a6f82f7SJiri Slaby { 16023a6f82f7SJiri Slaby struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 16033a6f82f7SJiri Slaby struct hid_dynid *dynid; 16043a6f82f7SJiri Slaby __u32 bus, vendor, product; 16053a6f82f7SJiri Slaby unsigned long driver_data = 0; 16063a6f82f7SJiri Slaby int ret; 16073a6f82f7SJiri Slaby 16083a6f82f7SJiri Slaby ret = sscanf(buf, "%x %x %x %lx", 16093a6f82f7SJiri Slaby &bus, &vendor, &product, &driver_data); 16103a6f82f7SJiri Slaby if (ret < 3) 16113a6f82f7SJiri Slaby return -EINVAL; 16123a6f82f7SJiri Slaby 16133a6f82f7SJiri Slaby dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 16143a6f82f7SJiri Slaby if (!dynid) 16153a6f82f7SJiri Slaby return -ENOMEM; 16163a6f82f7SJiri Slaby 16173a6f82f7SJiri Slaby dynid->id.bus = bus; 16183a6f82f7SJiri Slaby dynid->id.vendor = vendor; 16193a6f82f7SJiri Slaby dynid->id.product = product; 16203a6f82f7SJiri Slaby dynid->id.driver_data = driver_data; 16213a6f82f7SJiri Slaby 16223a6f82f7SJiri Slaby spin_lock(&hdrv->dyn_lock); 16233a6f82f7SJiri Slaby list_add_tail(&dynid->list, &hdrv->dyn_list); 16243a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16253a6f82f7SJiri Slaby 16263a6f82f7SJiri Slaby ret = 0; 16273a6f82f7SJiri Slaby if (get_driver(&hdrv->driver)) { 16283a6f82f7SJiri Slaby ret = driver_attach(&hdrv->driver); 16293a6f82f7SJiri Slaby put_driver(&hdrv->driver); 16303a6f82f7SJiri Slaby } 16313a6f82f7SJiri Slaby 16323a6f82f7SJiri Slaby return ret ? : count; 16333a6f82f7SJiri Slaby } 16343a6f82f7SJiri Slaby static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); 16353a6f82f7SJiri Slaby 16363a6f82f7SJiri Slaby static void hid_free_dynids(struct hid_driver *hdrv) 16373a6f82f7SJiri Slaby { 16383a6f82f7SJiri Slaby struct hid_dynid *dynid, *n; 16393a6f82f7SJiri Slaby 16403a6f82f7SJiri Slaby spin_lock(&hdrv->dyn_lock); 16413a6f82f7SJiri Slaby list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) { 16423a6f82f7SJiri Slaby list_del(&dynid->list); 16433a6f82f7SJiri Slaby kfree(dynid); 16443a6f82f7SJiri Slaby } 16453a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16463a6f82f7SJiri Slaby } 16473a6f82f7SJiri Slaby 16483a6f82f7SJiri Slaby static const struct hid_device_id *hid_match_device(struct hid_device *hdev, 16493a6f82f7SJiri Slaby struct hid_driver *hdrv) 16503a6f82f7SJiri Slaby { 16513a6f82f7SJiri Slaby struct hid_dynid *dynid; 16523a6f82f7SJiri Slaby 16533a6f82f7SJiri Slaby spin_lock(&hdrv->dyn_lock); 16543a6f82f7SJiri Slaby list_for_each_entry(dynid, &hdrv->dyn_list, list) { 16553a6f82f7SJiri Slaby if (hid_match_one_id(hdev, &dynid->id)) { 16563a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16573a6f82f7SJiri Slaby return &dynid->id; 16583a6f82f7SJiri Slaby } 16593a6f82f7SJiri Slaby } 16603a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16613a6f82f7SJiri Slaby 16623a6f82f7SJiri Slaby return hid_match_id(hdev, hdrv->id_table); 16633a6f82f7SJiri Slaby } 16643a6f82f7SJiri Slaby 166585cdaf52SJiri Slaby static int hid_bus_match(struct device *dev, struct device_driver *drv) 166685cdaf52SJiri Slaby { 166785cdaf52SJiri Slaby struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 166885cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 166985cdaf52SJiri Slaby 16703a6f82f7SJiri Slaby if (!hid_match_device(hdev, hdrv)) 167185cdaf52SJiri Slaby return 0; 167285cdaf52SJiri Slaby 1673ce06b9d6SDmitry Torokhov /* generic wants all that don't have specialized driver */ 167485cdaf52SJiri Slaby if (!strncmp(hdrv->name, "generic-", 8)) 1675ce06b9d6SDmitry Torokhov return !hid_match_id(hdev, hid_have_special_driver); 167685cdaf52SJiri Slaby 167785cdaf52SJiri Slaby return 1; 167885cdaf52SJiri Slaby } 167985cdaf52SJiri Slaby 168085cdaf52SJiri Slaby static int hid_device_probe(struct device *dev) 168185cdaf52SJiri Slaby { 168285cdaf52SJiri Slaby struct hid_driver *hdrv = container_of(dev->driver, 168385cdaf52SJiri Slaby struct hid_driver, driver); 168485cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 168585cdaf52SJiri Slaby const struct hid_device_id *id; 168685cdaf52SJiri Slaby int ret = 0; 168785cdaf52SJiri Slaby 16884ea54542SDavid Herrmann if (down_interruptible(&hdev->driver_lock)) 16894ea54542SDavid Herrmann return -EINTR; 16904ea54542SDavid Herrmann 169185cdaf52SJiri Slaby if (!hdev->driver) { 16923a6f82f7SJiri Slaby id = hid_match_device(hdev, hdrv); 1693ba623a77SDan Carpenter if (id == NULL) { 1694ba623a77SDan Carpenter ret = -ENODEV; 1695ba623a77SDan Carpenter goto unlock; 1696ba623a77SDan Carpenter } 1697c500c971SJiri Slaby 169885cdaf52SJiri Slaby hdev->driver = hdrv; 1699c500c971SJiri Slaby if (hdrv->probe) { 1700c500c971SJiri Slaby ret = hdrv->probe(hdev, id); 1701c500c971SJiri Slaby } else { /* default probe */ 1702c500c971SJiri Slaby ret = hid_parse(hdev); 1703c500c971SJiri Slaby if (!ret) 170493c10132SJiri Slaby ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 1705c500c971SJiri Slaby } 1706c500c971SJiri Slaby if (ret) 1707c500c971SJiri Slaby hdev->driver = NULL; 170885cdaf52SJiri Slaby } 1709ba623a77SDan Carpenter unlock: 17104ea54542SDavid Herrmann up(&hdev->driver_lock); 171185cdaf52SJiri Slaby return ret; 171285cdaf52SJiri Slaby } 171385cdaf52SJiri Slaby 171485cdaf52SJiri Slaby static int hid_device_remove(struct device *dev) 171585cdaf52SJiri Slaby { 171685cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 17174ea54542SDavid Herrmann struct hid_driver *hdrv; 171885cdaf52SJiri Slaby 17194ea54542SDavid Herrmann if (down_interruptible(&hdev->driver_lock)) 17204ea54542SDavid Herrmann return -EINTR; 17214ea54542SDavid Herrmann 17224ea54542SDavid Herrmann hdrv = hdev->driver; 172385cdaf52SJiri Slaby if (hdrv) { 172485cdaf52SJiri Slaby if (hdrv->remove) 172585cdaf52SJiri Slaby hdrv->remove(hdev); 1726c500c971SJiri Slaby else /* default remove */ 1727c500c971SJiri Slaby hid_hw_stop(hdev); 172885cdaf52SJiri Slaby hdev->driver = NULL; 172985cdaf52SJiri Slaby } 173085cdaf52SJiri Slaby 17314ea54542SDavid Herrmann up(&hdev->driver_lock); 173285cdaf52SJiri Slaby return 0; 173385cdaf52SJiri Slaby } 173485cdaf52SJiri Slaby 173585cdaf52SJiri Slaby static int hid_uevent(struct device *dev, struct kobj_uevent_env *env) 173685cdaf52SJiri Slaby { 173785cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 173885cdaf52SJiri Slaby 173985cdaf52SJiri Slaby if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", 174085cdaf52SJiri Slaby hdev->bus, hdev->vendor, hdev->product)) 174185cdaf52SJiri Slaby return -ENOMEM; 174285cdaf52SJiri Slaby 174385cdaf52SJiri Slaby if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) 174485cdaf52SJiri Slaby return -ENOMEM; 174585cdaf52SJiri Slaby 174685cdaf52SJiri Slaby if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) 174785cdaf52SJiri Slaby return -ENOMEM; 174885cdaf52SJiri Slaby 174985cdaf52SJiri Slaby if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) 175085cdaf52SJiri Slaby return -ENOMEM; 175185cdaf52SJiri Slaby 175285cdaf52SJiri Slaby if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X", 175385cdaf52SJiri Slaby hdev->bus, hdev->vendor, hdev->product)) 175485cdaf52SJiri Slaby return -ENOMEM; 175585cdaf52SJiri Slaby 175685cdaf52SJiri Slaby return 0; 175785cdaf52SJiri Slaby } 175885cdaf52SJiri Slaby 175985cdaf52SJiri Slaby static struct bus_type hid_bus_type = { 176085cdaf52SJiri Slaby .name = "hid", 176185cdaf52SJiri Slaby .match = hid_bus_match, 176285cdaf52SJiri Slaby .probe = hid_device_probe, 176385cdaf52SJiri Slaby .remove = hid_device_remove, 176485cdaf52SJiri Slaby .uevent = hid_uevent, 176585cdaf52SJiri Slaby }; 176685cdaf52SJiri Slaby 1767bae7eb33SJiri Kosina /* a list of devices that shouldn't be handled by HID core at all */ 1768d458a9dfSJiri Slaby static const struct hid_device_id hid_ignore_list[] = { 1769d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, 1770d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, 1771d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, 1772d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, 1773d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, 1774d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, 1775d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, 1776d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, 1777d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, 1778d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, 1779d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, 1780d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, 178177f720b7SStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)}, 178277f720b7SStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)}, 178362a56582SAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, 1784d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, 1785d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, 1786d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, 1787d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, 1788d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, 1789d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, 17905f6108cfSAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) }, 1791d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, 1792d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 179373bc7d31SMelchior FRANZ { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) }, 1794789aaa2eSDan Delaney { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x000a) }, 1795d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 179670c66567SPetr Štetiar { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) }, 1797df506f2cSPetr Štetiar { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) }, 1798b1807719SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, 1799d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 1800d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, 1801d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, 1802d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, 1803d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, 1804d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, 1805d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, 1806d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, 1807d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, 1808d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, 1809d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, 1810d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, 1811d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, 1812d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, 1813d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, 1814d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, 1815d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, 1816d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, 1817d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, 1818d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, 1819d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, 1820d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, 1821d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, 1822d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, 1823d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, 1824d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, 1825d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, 1826d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, 1827d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, 1828d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, 1829d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, 1830d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, 1831d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, 1832d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, 1833d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, 1834d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, 1835d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, 1836d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, 1837d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, 1838d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, 1839d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, 1840d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, 1841d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, 1842d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, 1843d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, 1844d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, 1845d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, 1846d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, 1847d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, 1848d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, 1849d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, 1850d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, 1851d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, 1852d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, 1853d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, 1854d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, 1855d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, 1856d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, 1857d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, 1858d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, 1859d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, 1860d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, 1861d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, 1862d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, 1863c91c21c5SAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, 1864d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, 1865eb8141ccSLamarque Vieira Souza { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) }, 1866d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, 1867ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) }, 1868d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, 1869ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) }, 1870d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, 1871ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) }, 1872ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) }, 1873ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) }, 1874ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, 1875ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, 1876ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, 1877d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, 1878d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, 1879d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, 1880ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) }, 1881ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) }, 1882ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) }, 1883d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, 1884d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, 1885ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) }, 1886d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, 1887d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, 1888d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, 1889d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, 1890d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, 1891ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) }, 1892ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) }, 1893ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) }, 1894ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) }, 1895ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) }, 1896ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) }, 1897ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) }, 1898d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, 1899d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, 1900d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, 1901d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, 1902d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, 1903d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, 1904d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, 1905d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, 1906d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, 1907d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, 1908d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, 1909d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, 1910d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, 1911d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, 1912d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, 1913d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, 1914d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, 1915d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, 1916d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, 19174cfae3e8SHenning Glawe { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, 191835cfd1d9SMichael Tokarev { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, 1919d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, 1920d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 1921d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 1922d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 1923d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 1924d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, 1925d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, 1926d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, 1927d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, 1928d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, 1929d458a9dfSJiri Slaby { } 1930d458a9dfSJiri Slaby }; 1931d458a9dfSJiri Slaby 1932b4d8e473SJiri Slaby /** 1933b4d8e473SJiri Slaby * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer 1934b4d8e473SJiri Slaby * 1935b4d8e473SJiri Slaby * There are composite devices for which we want to ignore only a certain 1936b4d8e473SJiri Slaby * interface. This is a list of devices for which only the mouse interface will 1937b4d8e473SJiri Slaby * be ignored. This allows a dedicated driver to take care of the interface. 1938b4d8e473SJiri Slaby */ 1939b4d8e473SJiri Slaby static const struct hid_device_id hid_mouse_ignore_list[] = { 1940b4d8e473SJiri Slaby /* appletouch driver */ 1941b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 1942b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 1943b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 1944b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 1945b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 1946b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 1947b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 1948b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 1949b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 1950b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 1951b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1952b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 1953b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 1954b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1955b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 1956b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 1957b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 1958b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1959b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1960b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1961ac26fca3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1962ac26fca3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1963ac26fca3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 196499b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 196599b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 196699b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 196799b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 196899b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 196999b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 197047340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, 197147340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, 197247340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, 1973213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) }, 1974213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) }, 1975213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) }, 19764b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) }, 19774b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) }, 19784b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) }, 19794b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 19804b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 19814b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 1982b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1983b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1984b4d8e473SJiri Slaby { } 1985b4d8e473SJiri Slaby }; 1986b4d8e473SJiri Slaby 1987d458a9dfSJiri Slaby static bool hid_ignore(struct hid_device *hdev) 1988d458a9dfSJiri Slaby { 1989d458a9dfSJiri Slaby switch (hdev->vendor) { 1990d458a9dfSJiri Slaby case USB_VENDOR_ID_CODEMERCS: 1991d458a9dfSJiri Slaby /* ignore all Code Mercenaries IOWarrior devices */ 1992d458a9dfSJiri Slaby if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && 1993d458a9dfSJiri Slaby hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) 1994d458a9dfSJiri Slaby return true; 1995d458a9dfSJiri Slaby break; 1996d458a9dfSJiri Slaby case USB_VENDOR_ID_LOGITECH: 1997d458a9dfSJiri Slaby if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && 1998d458a9dfSJiri Slaby hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) 1999d458a9dfSJiri Slaby return true; 2000d458a9dfSJiri Slaby break; 200131f7fd79SJarod Wilson case USB_VENDOR_ID_SOUNDGRAPH: 200231f7fd79SJarod Wilson if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST && 200331f7fd79SJarod Wilson hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST) 200431f7fd79SJarod Wilson return true; 200531f7fd79SJarod Wilson break; 2006bba5394aSXing Wei case USB_VENDOR_ID_HANWANG: 2007bba5394aSXing Wei if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST && 2008bba5394aSXing Wei hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST) 2009bba5394aSXing Wei return true; 2010bba5394aSXing Wei break; 20116dc1418eSTomoki Sekiyama case USB_VENDOR_ID_JESS: 20126dc1418eSTomoki Sekiyama if (hdev->product == USB_DEVICE_ID_JESS_YUREX && 20136dc1418eSTomoki Sekiyama hdev->type == HID_TYPE_USBNONE) 20146dc1418eSTomoki Sekiyama return true; 20156dc1418eSTomoki Sekiyama break; 2016d458a9dfSJiri Slaby } 2017d458a9dfSJiri Slaby 2018b4d8e473SJiri Slaby if (hdev->type == HID_TYPE_USBMOUSE && 2019b4d8e473SJiri Slaby hid_match_id(hdev, hid_mouse_ignore_list)) 2020b4d8e473SJiri Slaby return true; 2021b4d8e473SJiri Slaby 2022d458a9dfSJiri Slaby return !!hid_match_id(hdev, hid_ignore_list); 2023d458a9dfSJiri Slaby } 2024d458a9dfSJiri Slaby 202585cdaf52SJiri Slaby int hid_add_device(struct hid_device *hdev) 202685cdaf52SJiri Slaby { 202785cdaf52SJiri Slaby static atomic_t id = ATOMIC_INIT(0); 202885cdaf52SJiri Slaby int ret; 202985cdaf52SJiri Slaby 203085cdaf52SJiri Slaby if (WARN_ON(hdev->status & HID_STAT_ADDED)) 203185cdaf52SJiri Slaby return -EBUSY; 203285cdaf52SJiri Slaby 2033d458a9dfSJiri Slaby /* we need to kill them here, otherwise they will stay allocated to 2034d458a9dfSJiri Slaby * wait for coming driver */ 2035e5a2a04cSJindrich Makovicka if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) 2036e5a2a04cSJindrich Makovicka && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE))) 2037d458a9dfSJiri Slaby return -ENODEV; 2038d458a9dfSJiri Slaby 20396bbe586fSKay Sievers /* XXX hack, any other cleaner solution after the driver core 20406bbe586fSKay Sievers * is converted to allow more than 20 bytes as the device name? */ 20416bbe586fSKay Sievers dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, 204285cdaf52SJiri Slaby hdev->vendor, hdev->product, atomic_inc_return(&id)); 204385cdaf52SJiri Slaby 20444da361b6SBruno Prémont hid_debug_register(hdev, dev_name(&hdev->dev)); 204585cdaf52SJiri Slaby ret = device_add(&hdev->dev); 204685cdaf52SJiri Slaby if (!ret) 204785cdaf52SJiri Slaby hdev->status |= HID_STAT_ADDED; 20484da361b6SBruno Prémont else 20494da361b6SBruno Prémont hid_debug_unregister(hdev); 2050a635f9ddSJiri Kosina 205185cdaf52SJiri Slaby return ret; 205285cdaf52SJiri Slaby } 205385cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_add_device); 205485cdaf52SJiri Slaby 205585cdaf52SJiri Slaby /** 205685cdaf52SJiri Slaby * hid_allocate_device - allocate new hid device descriptor 205785cdaf52SJiri Slaby * 205885cdaf52SJiri Slaby * Allocate and initialize hid device, so that hid_destroy_device might be 205985cdaf52SJiri Slaby * used to free it. 206085cdaf52SJiri Slaby * 206185cdaf52SJiri Slaby * New hid_device pointer is returned on success, otherwise ERR_PTR encoded 206285cdaf52SJiri Slaby * error value. 206385cdaf52SJiri Slaby */ 206485cdaf52SJiri Slaby struct hid_device *hid_allocate_device(void) 206585cdaf52SJiri Slaby { 206685cdaf52SJiri Slaby struct hid_device *hdev; 206785cdaf52SJiri Slaby unsigned int i; 206885cdaf52SJiri Slaby int ret = -ENOMEM; 206985cdaf52SJiri Slaby 207085cdaf52SJiri Slaby hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); 207185cdaf52SJiri Slaby if (hdev == NULL) 207285cdaf52SJiri Slaby return ERR_PTR(ret); 207385cdaf52SJiri Slaby 207485cdaf52SJiri Slaby device_initialize(&hdev->dev); 207585cdaf52SJiri Slaby hdev->dev.release = hid_device_release; 207685cdaf52SJiri Slaby hdev->dev.bus = &hid_bus_type; 207785cdaf52SJiri Slaby 207885cdaf52SJiri Slaby hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, 207985cdaf52SJiri Slaby sizeof(struct hid_collection), GFP_KERNEL); 208085cdaf52SJiri Slaby if (hdev->collection == NULL) 208185cdaf52SJiri Slaby goto err; 208285cdaf52SJiri Slaby hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS; 208385cdaf52SJiri Slaby 208485cdaf52SJiri Slaby for (i = 0; i < HID_REPORT_TYPES; i++) 208585cdaf52SJiri Slaby INIT_LIST_HEAD(&hdev->report_enum[i].report_list); 208685cdaf52SJiri Slaby 2087cd667ce2SJiri Kosina init_waitqueue_head(&hdev->debug_wait); 2088cd667ce2SJiri Kosina INIT_LIST_HEAD(&hdev->debug_list); 20894ea54542SDavid Herrmann sema_init(&hdev->driver_lock, 1); 2090cd667ce2SJiri Kosina 209185cdaf52SJiri Slaby return hdev; 209285cdaf52SJiri Slaby err: 209385cdaf52SJiri Slaby put_device(&hdev->dev); 209485cdaf52SJiri Slaby return ERR_PTR(ret); 209585cdaf52SJiri Slaby } 209685cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_allocate_device); 209785cdaf52SJiri Slaby 209885cdaf52SJiri Slaby static void hid_remove_device(struct hid_device *hdev) 209985cdaf52SJiri Slaby { 210085cdaf52SJiri Slaby if (hdev->status & HID_STAT_ADDED) { 210185cdaf52SJiri Slaby device_del(&hdev->dev); 2102a635f9ddSJiri Kosina hid_debug_unregister(hdev); 210385cdaf52SJiri Slaby hdev->status &= ~HID_STAT_ADDED; 210485cdaf52SJiri Slaby } 210585cdaf52SJiri Slaby } 210685cdaf52SJiri Slaby 210785cdaf52SJiri Slaby /** 210885cdaf52SJiri Slaby * hid_destroy_device - free previously allocated device 210985cdaf52SJiri Slaby * 211085cdaf52SJiri Slaby * @hdev: hid device 211185cdaf52SJiri Slaby * 211285cdaf52SJiri Slaby * If you allocate hid_device through hid_allocate_device, you should ever 211385cdaf52SJiri Slaby * free by this function. 211485cdaf52SJiri Slaby */ 211585cdaf52SJiri Slaby void hid_destroy_device(struct hid_device *hdev) 211685cdaf52SJiri Slaby { 211785cdaf52SJiri Slaby hid_remove_device(hdev); 211885cdaf52SJiri Slaby put_device(&hdev->dev); 211985cdaf52SJiri Slaby } 212085cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_destroy_device); 212185cdaf52SJiri Slaby 212285cdaf52SJiri Slaby int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, 212385cdaf52SJiri Slaby const char *mod_name) 212485cdaf52SJiri Slaby { 21253a6f82f7SJiri Slaby int ret; 21263a6f82f7SJiri Slaby 212785cdaf52SJiri Slaby hdrv->driver.name = hdrv->name; 212885cdaf52SJiri Slaby hdrv->driver.bus = &hid_bus_type; 212985cdaf52SJiri Slaby hdrv->driver.owner = owner; 213085cdaf52SJiri Slaby hdrv->driver.mod_name = mod_name; 213185cdaf52SJiri Slaby 21323a6f82f7SJiri Slaby INIT_LIST_HEAD(&hdrv->dyn_list); 21333a6f82f7SJiri Slaby spin_lock_init(&hdrv->dyn_lock); 21343a6f82f7SJiri Slaby 21353a6f82f7SJiri Slaby ret = driver_register(&hdrv->driver); 21363a6f82f7SJiri Slaby if (ret) 21373a6f82f7SJiri Slaby return ret; 21383a6f82f7SJiri Slaby 21393a6f82f7SJiri Slaby ret = driver_create_file(&hdrv->driver, &driver_attr_new_id); 21403a6f82f7SJiri Slaby if (ret) 21413a6f82f7SJiri Slaby driver_unregister(&hdrv->driver); 21423a6f82f7SJiri Slaby 21433a6f82f7SJiri Slaby return ret; 214485cdaf52SJiri Slaby } 214585cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(__hid_register_driver); 214685cdaf52SJiri Slaby 214785cdaf52SJiri Slaby void hid_unregister_driver(struct hid_driver *hdrv) 214885cdaf52SJiri Slaby { 21493a6f82f7SJiri Slaby driver_remove_file(&hdrv->driver, &driver_attr_new_id); 215085cdaf52SJiri Slaby driver_unregister(&hdrv->driver); 21513a6f82f7SJiri Slaby hid_free_dynids(hdrv); 215285cdaf52SJiri Slaby } 215385cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_unregister_driver); 215485cdaf52SJiri Slaby 21550361a28dSOliver Neukum int hid_check_keys_pressed(struct hid_device *hid) 21560361a28dSOliver Neukum { 21570361a28dSOliver Neukum struct hid_input *hidinput; 21580361a28dSOliver Neukum int i; 21590361a28dSOliver Neukum 2160e5288eb5SJiri Kosina if (!(hid->claimed & HID_CLAIMED_INPUT)) 2161e5288eb5SJiri Kosina return 0; 2162e5288eb5SJiri Kosina 21630361a28dSOliver Neukum list_for_each_entry(hidinput, &hid->inputs, list) { 21640361a28dSOliver Neukum for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++) 21650361a28dSOliver Neukum if (hidinput->input->key[i]) 21660361a28dSOliver Neukum return 1; 21670361a28dSOliver Neukum } 21680361a28dSOliver Neukum 21690361a28dSOliver Neukum return 0; 21700361a28dSOliver Neukum } 21710361a28dSOliver Neukum 21720361a28dSOliver Neukum EXPORT_SYMBOL_GPL(hid_check_keys_pressed); 21730361a28dSOliver Neukum 217486166b7bSJiri Kosina static int __init hid_init(void) 217586166b7bSJiri Kosina { 217685cdaf52SJiri Slaby int ret; 217785cdaf52SJiri Slaby 2178a635f9ddSJiri Kosina if (hid_debug) 21794291ee30SJoe Perches pr_warn("hid_debug is now used solely for parser and driver debugging.\n" 21804291ee30SJoe Perches "debugfs is now used for inspecting the device (report descriptor, reports)\n"); 2181a635f9ddSJiri Kosina 218285cdaf52SJiri Slaby ret = bus_register(&hid_bus_type); 218385cdaf52SJiri Slaby if (ret) { 21844291ee30SJoe Perches pr_err("can't register hid bus\n"); 218585cdaf52SJiri Slaby goto err; 218685cdaf52SJiri Slaby } 218785cdaf52SJiri Slaby 218885cdaf52SJiri Slaby ret = hidraw_init(); 218985cdaf52SJiri Slaby if (ret) 219085cdaf52SJiri Slaby goto err_bus; 219185cdaf52SJiri Slaby 2192a635f9ddSJiri Kosina hid_debug_init(); 2193a635f9ddSJiri Kosina 219485cdaf52SJiri Slaby return 0; 219585cdaf52SJiri Slaby err_bus: 219685cdaf52SJiri Slaby bus_unregister(&hid_bus_type); 219785cdaf52SJiri Slaby err: 219885cdaf52SJiri Slaby return ret; 219986166b7bSJiri Kosina } 220086166b7bSJiri Kosina 220186166b7bSJiri Kosina static void __exit hid_exit(void) 220286166b7bSJiri Kosina { 2203a635f9ddSJiri Kosina hid_debug_exit(); 220486166b7bSJiri Kosina hidraw_exit(); 220585cdaf52SJiri Slaby bus_unregister(&hid_bus_type); 220686166b7bSJiri Kosina } 220786166b7bSJiri Kosina 220886166b7bSJiri Kosina module_init(hid_init); 220986166b7bSJiri Kosina module_exit(hid_exit); 221086166b7bSJiri Kosina 221188adb72bSJiri Kosina MODULE_AUTHOR("Andreas Gal"); 221288adb72bSJiri Kosina MODULE_AUTHOR("Vojtech Pavlik"); 221388adb72bSJiri Kosina MODULE_AUTHOR("Jiri Kosina"); 2214aa938f79SJiri Kosina MODULE_LICENSE(DRIVER_LICENSE); 2215aa938f79SJiri Kosina 2216