Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 1 | /* |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 2 | * HID support for Linux |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 3 | * |
| 4 | * Copyright (c) 1999 Andreas Gal |
| 5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> |
| 6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc |
Jiri Kosina | 7d39e84 | 2010-02-02 20:46:34 +0100 | [diff] [blame] | 7 | * Copyright (c) 2006-2010 Jiri Kosina |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | /* |
| 11 | * This program is free software; you can redistribute it and/or modify it |
| 12 | * under the terms of the GNU General Public License as published by the Free |
| 13 | * Software Foundation; either version 2 of the License, or (at your option) |
| 14 | * any later version. |
| 15 | */ |
| 16 | |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 18 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 19 | #include <linux/module.h> |
| 20 | #include <linux/slab.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/kernel.h> |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 23 | #include <linux/list.h> |
| 24 | #include <linux/mm.h> |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 25 | #include <linux/spinlock.h> |
| 26 | #include <asm/unaligned.h> |
| 27 | #include <asm/byteorder.h> |
| 28 | #include <linux/input.h> |
| 29 | #include <linux/wait.h> |
Jiri Kosina | 47a80ed | 2007-03-12 14:55:12 +0100 | [diff] [blame] | 30 | #include <linux/vmalloc.h> |
Jiri Kosina | c4124c9 | 2007-11-30 11:12:58 +0100 | [diff] [blame] | 31 | #include <linux/sched.h> |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 32 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 33 | #include <linux/hid.h> |
| 34 | #include <linux/hiddev.h> |
Jiri Kosina | c080d89 | 2007-01-25 11:43:31 +0100 | [diff] [blame] | 35 | #include <linux/hid-debug.h> |
Jiri Kosina | 86166b7 | 2007-05-14 09:57:40 +0200 | [diff] [blame] | 36 | #include <linux/hidraw.h> |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 37 | |
Jiri Slaby | 5f22a79 | 2008-05-16 11:49:19 +0200 | [diff] [blame] | 38 | #include "hid-ids.h" |
| 39 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 40 | /* |
| 41 | * Version Information |
| 42 | */ |
| 43 | |
Jiri Kosina | 5314980 | 2007-01-09 13:24:25 +0100 | [diff] [blame] | 44 | #define DRIVER_DESC "HID core driver" |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 45 | #define DRIVER_LICENSE "GPL" |
| 46 | |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 47 | int hid_debug = 0; |
Anssi Hannula | 377e10f | 2008-03-22 23:50:13 +0100 | [diff] [blame] | 48 | module_param_named(debug, hid_debug, int, 0600); |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 49 | MODULE_PARM_DESC(debug, "toggle HID debugging messages"); |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 50 | EXPORT_SYMBOL_GPL(hid_debug); |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 51 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 52 | /* |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 53 | * Register a new report for a device. |
| 54 | */ |
| 55 | |
Michael Poole | 90a006a | 2010-01-24 22:32:29 -0500 | [diff] [blame] | 56 | struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 57 | { |
| 58 | struct hid_report_enum *report_enum = device->report_enum + type; |
| 59 | struct hid_report *report; |
| 60 | |
| 61 | if (report_enum->report_id_hash[id]) |
| 62 | return report_enum->report_id_hash[id]; |
| 63 | |
Joe Perches | a3789a17 | 2010-12-09 19:29:07 -0800 | [diff] [blame] | 64 | report = kzalloc(sizeof(struct hid_report), GFP_KERNEL); |
| 65 | if (!report) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 66 | return NULL; |
| 67 | |
| 68 | if (id != 0) |
| 69 | report_enum->numbered = 1; |
| 70 | |
| 71 | report->id = id; |
| 72 | report->type = type; |
| 73 | report->size = 0; |
| 74 | report->device = device; |
| 75 | report_enum->report_id_hash[id] = report; |
| 76 | |
| 77 | list_add_tail(&report->list, &report_enum->report_list); |
| 78 | |
| 79 | return report; |
| 80 | } |
Michael Poole | 90a006a | 2010-01-24 22:32:29 -0500 | [diff] [blame] | 81 | EXPORT_SYMBOL_GPL(hid_register_report); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 82 | |
| 83 | /* |
| 84 | * Register a new field for this report. |
| 85 | */ |
| 86 | |
| 87 | static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) |
| 88 | { |
| 89 | struct hid_field *field; |
| 90 | |
| 91 | if (report->maxfield == HID_MAX_FIELDS) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 92 | dbg_hid("too many fields in report\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 93 | return NULL; |
| 94 | } |
| 95 | |
Joe Perches | a3789a17 | 2010-12-09 19:29:07 -0800 | [diff] [blame] | 96 | field = kzalloc((sizeof(struct hid_field) + |
| 97 | usages * sizeof(struct hid_usage) + |
| 98 | values * sizeof(unsigned)), GFP_KERNEL); |
| 99 | if (!field) |
| 100 | return NULL; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 101 | |
| 102 | field->index = report->maxfield++; |
| 103 | report->field[field->index] = field; |
| 104 | field->usage = (struct hid_usage *)(field + 1); |
Jiri Slaby | 282bfd4 | 2008-03-28 17:06:41 +0100 | [diff] [blame] | 105 | field->value = (s32 *)(field->usage + usages); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 106 | field->report = report; |
| 107 | |
| 108 | return field; |
| 109 | } |
| 110 | |
| 111 | /* |
| 112 | * Open a collection. The type/usage is pushed on the stack. |
| 113 | */ |
| 114 | |
| 115 | static int open_collection(struct hid_parser *parser, unsigned type) |
| 116 | { |
| 117 | struct hid_collection *collection; |
| 118 | unsigned usage; |
| 119 | |
| 120 | usage = parser->local.usage[0]; |
| 121 | |
| 122 | if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 123 | dbg_hid("collection stack overflow\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 124 | return -1; |
| 125 | } |
| 126 | |
| 127 | if (parser->device->maxcollection == parser->device->collection_size) { |
| 128 | collection = kmalloc(sizeof(struct hid_collection) * |
| 129 | parser->device->collection_size * 2, GFP_KERNEL); |
| 130 | if (collection == NULL) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 131 | dbg_hid("failed to reallocate collection array\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 132 | return -1; |
| 133 | } |
| 134 | memcpy(collection, parser->device->collection, |
| 135 | sizeof(struct hid_collection) * |
| 136 | parser->device->collection_size); |
| 137 | memset(collection + parser->device->collection_size, 0, |
| 138 | sizeof(struct hid_collection) * |
| 139 | parser->device->collection_size); |
| 140 | kfree(parser->device->collection); |
| 141 | parser->device->collection = collection; |
| 142 | parser->device->collection_size *= 2; |
| 143 | } |
| 144 | |
| 145 | parser->collection_stack[parser->collection_stack_ptr++] = |
| 146 | parser->device->maxcollection; |
| 147 | |
| 148 | collection = parser->device->collection + |
| 149 | parser->device->maxcollection++; |
| 150 | collection->type = type; |
| 151 | collection->usage = usage; |
| 152 | collection->level = parser->collection_stack_ptr - 1; |
| 153 | |
| 154 | if (type == HID_COLLECTION_APPLICATION) |
| 155 | parser->device->maxapplication++; |
| 156 | |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | * Close a collection. |
| 162 | */ |
| 163 | |
| 164 | static int close_collection(struct hid_parser *parser) |
| 165 | { |
| 166 | if (!parser->collection_stack_ptr) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 167 | dbg_hid("collection stack underflow\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 168 | return -1; |
| 169 | } |
| 170 | parser->collection_stack_ptr--; |
| 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | /* |
| 175 | * Climb up the stack, search for the specified collection type |
| 176 | * and return the usage. |
| 177 | */ |
| 178 | |
| 179 | static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) |
| 180 | { |
Joe Perches | 504499f | 2010-12-09 19:29:08 -0800 | [diff] [blame] | 181 | struct hid_collection *collection = parser->device->collection; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 182 | int n; |
Joe Perches | 504499f | 2010-12-09 19:29:08 -0800 | [diff] [blame] | 183 | |
| 184 | for (n = parser->collection_stack_ptr - 1; n >= 0; n--) { |
| 185 | unsigned index = parser->collection_stack[n]; |
| 186 | if (collection[index].type == type) |
| 187 | return collection[index].usage; |
| 188 | } |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 189 | return 0; /* we know nothing about this usage type */ |
| 190 | } |
| 191 | |
| 192 | /* |
| 193 | * Add a usage to the temporary parser table. |
| 194 | */ |
| 195 | |
| 196 | static int hid_add_usage(struct hid_parser *parser, unsigned usage) |
| 197 | { |
| 198 | if (parser->local.usage_index >= HID_MAX_USAGES) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 199 | dbg_hid("usage index exceeded\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 200 | return -1; |
| 201 | } |
| 202 | parser->local.usage[parser->local.usage_index] = usage; |
| 203 | parser->local.collection_index[parser->local.usage_index] = |
| 204 | parser->collection_stack_ptr ? |
| 205 | parser->collection_stack[parser->collection_stack_ptr - 1] : 0; |
| 206 | parser->local.usage_index++; |
| 207 | return 0; |
| 208 | } |
| 209 | |
| 210 | /* |
| 211 | * Register a new field for this report. |
| 212 | */ |
| 213 | |
| 214 | static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags) |
| 215 | { |
| 216 | struct hid_report *report; |
| 217 | struct hid_field *field; |
| 218 | int usages; |
| 219 | unsigned offset; |
| 220 | int i; |
| 221 | |
Joe Perches | a3789a17 | 2010-12-09 19:29:07 -0800 | [diff] [blame] | 222 | report = hid_register_report(parser->device, report_type, parser->global.report_id); |
| 223 | if (!report) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 224 | dbg_hid("hid_register_report failed\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 225 | return -1; |
| 226 | } |
| 227 | |
| 228 | if (parser->global.logical_maximum < parser->global.logical_minimum) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 229 | dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 230 | return -1; |
| 231 | } |
| 232 | |
| 233 | offset = report->size; |
| 234 | report->size += parser->global.report_size * parser->global.report_count; |
| 235 | |
| 236 | if (!parser->local.usage_index) /* Ignore padding fields */ |
| 237 | return 0; |
| 238 | |
| 239 | usages = max_t(int, parser->local.usage_index, parser->global.report_count); |
| 240 | |
Joe Perches | a3789a17 | 2010-12-09 19:29:07 -0800 | [diff] [blame] | 241 | field = hid_register_field(report, usages, parser->global.report_count); |
| 242 | if (!field) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 243 | return 0; |
| 244 | |
| 245 | field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); |
| 246 | field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL); |
| 247 | field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); |
| 248 | |
| 249 | for (i = 0; i < usages; i++) { |
| 250 | int j = i; |
| 251 | /* Duplicate the last usage we parsed if we have excess values */ |
| 252 | if (i >= parser->local.usage_index) |
| 253 | j = parser->local.usage_index - 1; |
| 254 | field->usage[i].hid = parser->local.usage[j]; |
| 255 | field->usage[i].collection_index = |
| 256 | parser->local.collection_index[j]; |
| 257 | } |
| 258 | |
| 259 | field->maxusage = usages; |
| 260 | field->flags = flags; |
| 261 | field->report_offset = offset; |
| 262 | field->report_type = report_type; |
| 263 | field->report_size = parser->global.report_size; |
| 264 | field->report_count = parser->global.report_count; |
| 265 | field->logical_minimum = parser->global.logical_minimum; |
| 266 | field->logical_maximum = parser->global.logical_maximum; |
| 267 | field->physical_minimum = parser->global.physical_minimum; |
| 268 | field->physical_maximum = parser->global.physical_maximum; |
| 269 | field->unit_exponent = parser->global.unit_exponent; |
| 270 | field->unit = parser->global.unit; |
| 271 | |
| 272 | return 0; |
| 273 | } |
| 274 | |
| 275 | /* |
| 276 | * Read data value from item. |
| 277 | */ |
| 278 | |
| 279 | static u32 item_udata(struct hid_item *item) |
| 280 | { |
| 281 | switch (item->size) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 282 | case 1: return item->data.u8; |
| 283 | case 2: return item->data.u16; |
| 284 | case 4: return item->data.u32; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 285 | } |
| 286 | return 0; |
| 287 | } |
| 288 | |
| 289 | static s32 item_sdata(struct hid_item *item) |
| 290 | { |
| 291 | switch (item->size) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 292 | case 1: return item->data.s8; |
| 293 | case 2: return item->data.s16; |
| 294 | case 4: return item->data.s32; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 295 | } |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | /* |
| 300 | * Process a global item. |
| 301 | */ |
| 302 | |
| 303 | static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) |
| 304 | { |
| 305 | switch (item->tag) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 306 | case HID_GLOBAL_ITEM_TAG_PUSH: |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 307 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 308 | if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { |
| 309 | dbg_hid("global enviroment stack overflow\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 310 | return -1; |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | memcpy(parser->global_stack + parser->global_stack_ptr++, |
| 314 | &parser->global, sizeof(struct hid_global)); |
| 315 | return 0; |
| 316 | |
| 317 | case HID_GLOBAL_ITEM_TAG_POP: |
| 318 | |
| 319 | if (!parser->global_stack_ptr) { |
| 320 | dbg_hid("global enviroment stack underflow\n"); |
| 321 | return -1; |
| 322 | } |
| 323 | |
| 324 | memcpy(&parser->global, parser->global_stack + |
| 325 | --parser->global_stack_ptr, sizeof(struct hid_global)); |
| 326 | return 0; |
| 327 | |
| 328 | case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: |
| 329 | parser->global.usage_page = item_udata(item); |
| 330 | return 0; |
| 331 | |
| 332 | case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: |
| 333 | parser->global.logical_minimum = item_sdata(item); |
| 334 | return 0; |
| 335 | |
| 336 | case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: |
| 337 | if (parser->global.logical_minimum < 0) |
| 338 | parser->global.logical_maximum = item_sdata(item); |
| 339 | else |
| 340 | parser->global.logical_maximum = item_udata(item); |
| 341 | return 0; |
| 342 | |
| 343 | case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: |
| 344 | parser->global.physical_minimum = item_sdata(item); |
| 345 | return 0; |
| 346 | |
| 347 | case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: |
| 348 | if (parser->global.physical_minimum < 0) |
| 349 | parser->global.physical_maximum = item_sdata(item); |
| 350 | else |
| 351 | parser->global.physical_maximum = item_udata(item); |
| 352 | return 0; |
| 353 | |
| 354 | case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: |
| 355 | parser->global.unit_exponent = item_sdata(item); |
| 356 | return 0; |
| 357 | |
| 358 | case HID_GLOBAL_ITEM_TAG_UNIT: |
| 359 | parser->global.unit = item_udata(item); |
| 360 | return 0; |
| 361 | |
| 362 | case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: |
| 363 | parser->global.report_size = item_udata(item); |
| 364 | if (parser->global.report_size > 32) { |
| 365 | dbg_hid("invalid report_size %d\n", |
| 366 | parser->global.report_size); |
| 367 | return -1; |
| 368 | } |
| 369 | return 0; |
| 370 | |
| 371 | case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: |
| 372 | parser->global.report_count = item_udata(item); |
| 373 | if (parser->global.report_count > HID_MAX_USAGES) { |
| 374 | dbg_hid("invalid report_count %d\n", |
| 375 | parser->global.report_count); |
| 376 | return -1; |
| 377 | } |
| 378 | return 0; |
| 379 | |
| 380 | case HID_GLOBAL_ITEM_TAG_REPORT_ID: |
| 381 | parser->global.report_id = item_udata(item); |
| 382 | if (parser->global.report_id == 0) { |
| 383 | dbg_hid("report_id 0 is invalid\n"); |
| 384 | return -1; |
| 385 | } |
| 386 | return 0; |
| 387 | |
| 388 | default: |
| 389 | dbg_hid("unknown global tag 0x%x\n", item->tag); |
| 390 | return -1; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 391 | } |
| 392 | } |
| 393 | |
| 394 | /* |
| 395 | * Process a local item. |
| 396 | */ |
| 397 | |
| 398 | static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) |
| 399 | { |
| 400 | __u32 data; |
| 401 | unsigned n; |
| 402 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 403 | data = item_udata(item); |
| 404 | |
| 405 | switch (item->tag) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 406 | case HID_LOCAL_ITEM_TAG_DELIMITER: |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 407 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 408 | if (data) { |
| 409 | /* |
| 410 | * We treat items before the first delimiter |
| 411 | * as global to all usage sets (branch 0). |
| 412 | * In the moment we process only these global |
| 413 | * items and the first delimiter set. |
| 414 | */ |
| 415 | if (parser->local.delimiter_depth != 0) { |
| 416 | dbg_hid("nested delimiters\n"); |
| 417 | return -1; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 418 | } |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 419 | parser->local.delimiter_depth++; |
| 420 | parser->local.delimiter_branch++; |
| 421 | } else { |
| 422 | if (parser->local.delimiter_depth < 1) { |
| 423 | dbg_hid("bogus close delimiter\n"); |
| 424 | return -1; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 425 | } |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 426 | parser->local.delimiter_depth--; |
| 427 | } |
| 428 | return 1; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 429 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 430 | case HID_LOCAL_ITEM_TAG_USAGE: |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 431 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 432 | if (parser->local.delimiter_branch > 1) { |
| 433 | dbg_hid("alternative usage ignored\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 434 | return 0; |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 435 | } |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 436 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 437 | if (item->size <= 2) |
| 438 | data = (parser->global.usage_page << 16) + data; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 439 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 440 | return hid_add_usage(parser, data); |
| 441 | |
| 442 | case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: |
| 443 | |
| 444 | if (parser->local.delimiter_branch > 1) { |
| 445 | dbg_hid("alternative usage ignored\n"); |
| 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | if (item->size <= 2) |
| 450 | data = (parser->global.usage_page << 16) + data; |
| 451 | |
| 452 | parser->local.usage_minimum = data; |
| 453 | return 0; |
| 454 | |
| 455 | case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: |
| 456 | |
| 457 | if (parser->local.delimiter_branch > 1) { |
| 458 | dbg_hid("alternative usage ignored\n"); |
| 459 | return 0; |
| 460 | } |
| 461 | |
| 462 | if (item->size <= 2) |
| 463 | data = (parser->global.usage_page << 16) + data; |
| 464 | |
| 465 | for (n = parser->local.usage_minimum; n <= data; n++) |
| 466 | if (hid_add_usage(parser, n)) { |
| 467 | dbg_hid("hid_add_usage failed\n"); |
| 468 | return -1; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 469 | } |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 470 | return 0; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 471 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 472 | default: |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 473 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 474 | dbg_hid("unknown local item tag 0x%x\n", item->tag); |
| 475 | return 0; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 476 | } |
| 477 | return 0; |
| 478 | } |
| 479 | |
| 480 | /* |
| 481 | * Process a main item. |
| 482 | */ |
| 483 | |
| 484 | static int hid_parser_main(struct hid_parser *parser, struct hid_item *item) |
| 485 | { |
| 486 | __u32 data; |
| 487 | int ret; |
| 488 | |
| 489 | data = item_udata(item); |
| 490 | |
| 491 | switch (item->tag) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 492 | case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: |
| 493 | ret = open_collection(parser, data & 0xff); |
| 494 | break; |
| 495 | case HID_MAIN_ITEM_TAG_END_COLLECTION: |
| 496 | ret = close_collection(parser); |
| 497 | break; |
| 498 | case HID_MAIN_ITEM_TAG_INPUT: |
| 499 | ret = hid_add_field(parser, HID_INPUT_REPORT, data); |
| 500 | break; |
| 501 | case HID_MAIN_ITEM_TAG_OUTPUT: |
| 502 | ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); |
| 503 | break; |
| 504 | case HID_MAIN_ITEM_TAG_FEATURE: |
| 505 | ret = hid_add_field(parser, HID_FEATURE_REPORT, data); |
| 506 | break; |
| 507 | default: |
| 508 | dbg_hid("unknown main item tag 0x%x\n", item->tag); |
| 509 | ret = 0; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ |
| 513 | |
| 514 | return ret; |
| 515 | } |
| 516 | |
| 517 | /* |
| 518 | * Process a reserved item. |
| 519 | */ |
| 520 | |
| 521 | static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) |
| 522 | { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 523 | dbg_hid("reserved item type, tag 0x%x\n", item->tag); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 524 | return 0; |
| 525 | } |
| 526 | |
| 527 | /* |
| 528 | * Free a report and all registered fields. The field->usage and |
| 529 | * field->value table's are allocated behind the field, so we need |
| 530 | * only to free(field) itself. |
| 531 | */ |
| 532 | |
| 533 | static void hid_free_report(struct hid_report *report) |
| 534 | { |
| 535 | unsigned n; |
| 536 | |
| 537 | for (n = 0; n < report->maxfield; n++) |
| 538 | kfree(report->field[n]); |
| 539 | kfree(report); |
| 540 | } |
| 541 | |
| 542 | /* |
| 543 | * Free a device structure, all reports, and all fields. |
| 544 | */ |
| 545 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 546 | static void hid_device_release(struct device *dev) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 547 | { |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 548 | struct hid_device *device = container_of(dev, struct hid_device, dev); |
| 549 | unsigned i, j; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 550 | |
| 551 | for (i = 0; i < HID_REPORT_TYPES; i++) { |
| 552 | struct hid_report_enum *report_enum = device->report_enum + i; |
| 553 | |
| 554 | for (j = 0; j < 256; j++) { |
| 555 | struct hid_report *report = report_enum->report_id_hash[j]; |
| 556 | if (report) |
| 557 | hid_free_report(report); |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | kfree(device->rdesc); |
Jiri Kosina | 767fe78 | 2007-01-24 23:05:07 +0100 | [diff] [blame] | 562 | kfree(device->collection); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 563 | kfree(device); |
| 564 | } |
| 565 | |
| 566 | /* |
| 567 | * Fetch a report description item from the data stream. We support long |
| 568 | * items, though they are not used yet. |
| 569 | */ |
| 570 | |
| 571 | static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) |
| 572 | { |
| 573 | u8 b; |
| 574 | |
| 575 | if ((end - start) <= 0) |
| 576 | return NULL; |
| 577 | |
| 578 | b = *start++; |
| 579 | |
| 580 | item->type = (b >> 2) & 3; |
| 581 | item->tag = (b >> 4) & 15; |
| 582 | |
| 583 | if (item->tag == HID_ITEM_TAG_LONG) { |
| 584 | |
| 585 | item->format = HID_ITEM_FORMAT_LONG; |
| 586 | |
| 587 | if ((end - start) < 2) |
| 588 | return NULL; |
| 589 | |
| 590 | item->size = *start++; |
| 591 | item->tag = *start++; |
| 592 | |
| 593 | if ((end - start) < item->size) |
| 594 | return NULL; |
| 595 | |
| 596 | item->data.longdata = start; |
| 597 | start += item->size; |
| 598 | return start; |
| 599 | } |
| 600 | |
| 601 | item->format = HID_ITEM_FORMAT_SHORT; |
| 602 | item->size = b & 3; |
| 603 | |
| 604 | switch (item->size) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 605 | case 0: |
| 606 | return start; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 607 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 608 | case 1: |
| 609 | if ((end - start) < 1) |
| 610 | return NULL; |
| 611 | item->data.u8 = *start++; |
| 612 | return start; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 613 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 614 | case 2: |
| 615 | if ((end - start) < 2) |
| 616 | return NULL; |
| 617 | item->data.u16 = get_unaligned_le16(start); |
| 618 | start = (__u8 *)((__le16 *)start + 1); |
| 619 | return start; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 620 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 621 | case 3: |
| 622 | item->size++; |
| 623 | if ((end - start) < 4) |
| 624 | return NULL; |
| 625 | item->data.u32 = get_unaligned_le32(start); |
| 626 | start = (__u8 *)((__le32 *)start + 1); |
| 627 | return start; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | return NULL; |
| 631 | } |
| 632 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 633 | /** |
| 634 | * hid_parse_report - parse device report |
| 635 | * |
| 636 | * @device: hid device |
| 637 | * @start: report start |
| 638 | * @size: report size |
| 639 | * |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 640 | * Parse a report description into a hid_device structure. Reports are |
| 641 | * enumerated, fields are attached to these reports. |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 642 | * 0 returned on success, otherwise nonzero error value. |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 643 | */ |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 644 | int hid_parse_report(struct hid_device *device, __u8 *start, |
| 645 | unsigned size) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 646 | { |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 647 | struct hid_parser *parser; |
| 648 | struct hid_item item; |
| 649 | __u8 *end; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 650 | int ret; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 651 | static int (*dispatch_type[])(struct hid_parser *parser, |
| 652 | struct hid_item *item) = { |
| 653 | hid_parser_main, |
| 654 | hid_parser_global, |
| 655 | hid_parser_local, |
| 656 | hid_parser_reserved |
| 657 | }; |
| 658 | |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 659 | if (device->driver->report_fixup) |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 660 | start = device->driver->report_fixup(device, start, &size); |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 661 | |
Julia Lawall | 1721a23 | 2010-05-15 23:19:30 +0200 | [diff] [blame] | 662 | device->rdesc = kmemdup(start, size, GFP_KERNEL); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 663 | if (device->rdesc == NULL) |
| 664 | return -ENOMEM; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 665 | device->rsize = size; |
| 666 | |
Joe Perches | fe25802 | 2010-12-09 19:29:04 -0800 | [diff] [blame] | 667 | parser = vzalloc(sizeof(struct hid_parser)); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 668 | if (!parser) { |
| 669 | ret = -ENOMEM; |
| 670 | goto err; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 671 | } |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 672 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 673 | parser->device = device; |
| 674 | |
| 675 | end = start + size; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 676 | ret = -EINVAL; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 677 | while ((start = fetch_item(start, end, &item)) != NULL) { |
| 678 | |
| 679 | if (item.format != HID_ITEM_FORMAT_SHORT) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 680 | dbg_hid("unexpected long global item\n"); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 681 | goto err; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | if (dispatch_type[item.type](parser, &item)) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 685 | dbg_hid("item %u %u %u %u parsing failed\n", |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 686 | item.format, (unsigned)item.size, |
| 687 | (unsigned)item.type, (unsigned)item.tag); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 688 | goto err; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 689 | } |
| 690 | |
| 691 | if (start == end) { |
| 692 | if (parser->collection_stack_ptr) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 693 | dbg_hid("unbalanced collection at end of report description\n"); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 694 | goto err; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 695 | } |
| 696 | if (parser->local.delimiter_depth) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 697 | dbg_hid("unbalanced delimiter at end of report description\n"); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 698 | goto err; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 699 | } |
Jiri Kosina | 47a80ed | 2007-03-12 14:55:12 +0100 | [diff] [blame] | 700 | vfree(parser); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 701 | return 0; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 702 | } |
| 703 | } |
| 704 | |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 705 | dbg_hid("item fetching failed at offset %d\n", (int)(end - start)); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 706 | err: |
Jiri Kosina | 47a80ed | 2007-03-12 14:55:12 +0100 | [diff] [blame] | 707 | vfree(parser); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 708 | return ret; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 709 | } |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 710 | EXPORT_SYMBOL_GPL(hid_parse_report); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 711 | |
| 712 | /* |
| 713 | * Convert a signed n-bit integer to signed 32-bit integer. Common |
| 714 | * cases are done through the compiler, the screwed things has to be |
| 715 | * done by hand. |
| 716 | */ |
| 717 | |
| 718 | static s32 snto32(__u32 value, unsigned n) |
| 719 | { |
| 720 | switch (n) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 721 | case 8: return ((__s8)value); |
| 722 | case 16: return ((__s16)value); |
| 723 | case 32: return ((__s32)value); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 724 | } |
| 725 | return value & (1 << (n - 1)) ? value | (-1 << n) : value; |
| 726 | } |
| 727 | |
| 728 | /* |
| 729 | * Convert a signed 32-bit integer to a signed n-bit integer. |
| 730 | */ |
| 731 | |
| 732 | static u32 s32ton(__s32 value, unsigned n) |
| 733 | { |
| 734 | s32 a = value >> (n - 1); |
| 735 | if (a && a != -1) |
| 736 | return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; |
| 737 | return value & ((1 << n) - 1); |
| 738 | } |
| 739 | |
| 740 | /* |
| 741 | * Extract/implement a data field from/to a little endian report (bit array). |
| 742 | * |
| 743 | * Code sort-of follows HID spec: |
| 744 | * http://www.usb.org/developers/devclass_docs/HID1_11.pdf |
| 745 | * |
| 746 | * While the USB HID spec allows unlimited length bit fields in "report |
| 747 | * descriptors", most devices never use more than 16 bits. |
| 748 | * One model of UPS is claimed to report "LINEV" as a 32-bit field. |
| 749 | * Search linux-kernel and linux-usb-devel archives for "hid-core extract". |
| 750 | */ |
| 751 | |
Joe Perches | 16ee4cc | 2010-12-09 19:29:05 -0800 | [diff] [blame] | 752 | static __u32 extract(const struct hid_device *hid, __u8 *report, |
| 753 | unsigned offset, unsigned n) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 754 | { |
| 755 | u64 x; |
| 756 | |
Jiri Kosina | c4124c9 | 2007-11-30 11:12:58 +0100 | [diff] [blame] | 757 | if (n > 32) |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 758 | hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n", |
| 759 | n, current->comm); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 760 | |
| 761 | report += offset >> 3; /* adjust byte index */ |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 762 | offset &= 7; /* now only need bit offset into one byte */ |
Harvey Harrison | c105068 | 2008-04-29 01:03:31 -0700 | [diff] [blame] | 763 | x = get_unaligned_le64(report); |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 764 | x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 765 | return (u32) x; |
| 766 | } |
| 767 | |
| 768 | /* |
| 769 | * "implement" : set bits in a little endian bit stream. |
| 770 | * Same concepts as "extract" (see comments above). |
| 771 | * The data mangled in the bit stream remains in little endian |
| 772 | * order the whole time. It make more sense to talk about |
| 773 | * endianness of register values by considering a register |
| 774 | * a "cached" copy of the little endiad bit stream. |
| 775 | */ |
Joe Perches | 16ee4cc | 2010-12-09 19:29:05 -0800 | [diff] [blame] | 776 | static void implement(const struct hid_device *hid, __u8 *report, |
| 777 | unsigned offset, unsigned n, __u32 value) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 778 | { |
Harvey Harrison | 6f0168d | 2008-05-16 11:00:23 +0200 | [diff] [blame] | 779 | u64 x; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 780 | u64 m = (1ULL << n) - 1; |
| 781 | |
Jiri Kosina | c4124c9 | 2007-11-30 11:12:58 +0100 | [diff] [blame] | 782 | if (n > 32) |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 783 | hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n", |
| 784 | __func__, n, current->comm); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 785 | |
Jiri Kosina | c4124c9 | 2007-11-30 11:12:58 +0100 | [diff] [blame] | 786 | if (value > m) |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 787 | hid_warn(hid, "%s() called with too large value %d! (%s)\n", |
| 788 | __func__, value, current->comm); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 789 | WARN_ON(value > m); |
| 790 | value &= m; |
| 791 | |
| 792 | report += offset >> 3; |
| 793 | offset &= 7; |
| 794 | |
Harvey Harrison | 6f0168d | 2008-05-16 11:00:23 +0200 | [diff] [blame] | 795 | x = get_unaligned_le64(report); |
| 796 | x &= ~(m << offset); |
| 797 | x |= ((u64)value) << offset; |
| 798 | put_unaligned_le64(x, report); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | /* |
| 802 | * Search an array for a value. |
| 803 | */ |
| 804 | |
Joe Perches | 16ee4cc | 2010-12-09 19:29:05 -0800 | [diff] [blame] | 805 | static int search(__s32 *array, __s32 value, unsigned n) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 806 | { |
| 807 | while (n--) { |
| 808 | if (*array++ == value) |
| 809 | return 0; |
| 810 | } |
| 811 | return -1; |
| 812 | } |
| 813 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 814 | /** |
| 815 | * hid_match_report - check if driver's raw_event should be called |
| 816 | * |
| 817 | * @hid: hid device |
| 818 | * @report_type: type to match against |
| 819 | * |
| 820 | * compare hid->driver->report_table->report_type to report->type |
| 821 | */ |
| 822 | static int hid_match_report(struct hid_device *hid, struct hid_report *report) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 823 | { |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 824 | const struct hid_report_id *id = hid->driver->report_table; |
| 825 | |
| 826 | if (!id) /* NULL means all */ |
| 827 | return 1; |
| 828 | |
| 829 | for (; id->report_type != HID_TERMINATOR; id++) |
| 830 | if (id->report_type == HID_ANY_ID || |
| 831 | id->report_type == report->type) |
| 832 | return 1; |
| 833 | return 0; |
| 834 | } |
| 835 | |
| 836 | /** |
| 837 | * hid_match_usage - check if driver's event should be called |
| 838 | * |
| 839 | * @hid: hid device |
| 840 | * @usage: usage to match against |
| 841 | * |
| 842 | * compare hid->driver->usage_table->usage_{type,code} to |
| 843 | * usage->usage_{type,code} |
| 844 | */ |
| 845 | static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage) |
| 846 | { |
| 847 | const struct hid_usage_id *id = hid->driver->usage_table; |
| 848 | |
| 849 | if (!id) /* NULL means all */ |
| 850 | return 1; |
| 851 | |
| 852 | for (; id->usage_type != HID_ANY_ID - 1; id++) |
| 853 | if ((id->usage_hid == HID_ANY_ID || |
| 854 | id->usage_hid == usage->hid) && |
| 855 | (id->usage_type == HID_ANY_ID || |
| 856 | id->usage_type == usage->type) && |
| 857 | (id->usage_code == HID_ANY_ID || |
| 858 | id->usage_code == usage->code)) |
| 859 | return 1; |
| 860 | return 0; |
| 861 | } |
| 862 | |
| 863 | static void hid_process_event(struct hid_device *hid, struct hid_field *field, |
| 864 | struct hid_usage *usage, __s32 value, int interrupt) |
| 865 | { |
| 866 | struct hid_driver *hdrv = hid->driver; |
| 867 | int ret; |
| 868 | |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 869 | hid_dump_input(hid, usage, value); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 870 | |
| 871 | if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { |
| 872 | ret = hdrv->event(hid, field, usage, value); |
| 873 | if (ret != 0) { |
| 874 | if (ret < 0) |
| 875 | dbg_hid("%s's event failed with %d\n", |
| 876 | hdrv->name, ret); |
| 877 | return; |
| 878 | } |
| 879 | } |
| 880 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 881 | if (hid->claimed & HID_CLAIMED_INPUT) |
| 882 | hidinput_hid_event(hid, field, usage, value); |
Jiri Kosina | aa938f7 | 2006-12-08 18:41:10 +0100 | [diff] [blame] | 883 | if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) |
| 884 | hid->hiddev_hid_event(hid, field, usage, value); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 885 | } |
| 886 | |
| 887 | /* |
| 888 | * Analyse a received field, and fetch the data from it. The field |
| 889 | * content is stored for next report processing (we do differential |
| 890 | * reporting to the layer). |
| 891 | */ |
| 892 | |
Adrian Bunk | abdff0f | 2008-03-31 01:53:56 +0200 | [diff] [blame] | 893 | static void hid_input_field(struct hid_device *hid, struct hid_field *field, |
| 894 | __u8 *data, int interrupt) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 895 | { |
| 896 | unsigned n; |
| 897 | unsigned count = field->report_count; |
| 898 | unsigned offset = field->report_offset; |
| 899 | unsigned size = field->report_size; |
| 900 | __s32 min = field->logical_minimum; |
| 901 | __s32 max = field->logical_maximum; |
| 902 | __s32 *value; |
| 903 | |
Joe Perches | a3789a17 | 2010-12-09 19:29:07 -0800 | [diff] [blame] | 904 | value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC); |
| 905 | if (!value) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 906 | return; |
| 907 | |
| 908 | for (n = 0; n < count; n++) { |
| 909 | |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 910 | value[n] = min < 0 ? |
| 911 | snto32(extract(hid, data, offset + n * size, size), |
| 912 | size) : |
| 913 | extract(hid, data, offset + n * size, size); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 914 | |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 915 | /* Ignore report if ErrorRollOver */ |
| 916 | if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && |
| 917 | value[n] >= min && value[n] <= max && |
| 918 | field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) |
| 919 | goto exit; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 920 | } |
| 921 | |
| 922 | for (n = 0; n < count; n++) { |
| 923 | |
| 924 | if (HID_MAIN_ITEM_VARIABLE & field->flags) { |
| 925 | hid_process_event(hid, field, &field->usage[n], value[n], interrupt); |
| 926 | continue; |
| 927 | } |
| 928 | |
| 929 | if (field->value[n] >= min && field->value[n] <= max |
| 930 | && field->usage[field->value[n] - min].hid |
| 931 | && search(value, field->value[n], count)) |
| 932 | hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); |
| 933 | |
| 934 | if (value[n] >= min && value[n] <= max |
| 935 | && field->usage[value[n] - min].hid |
| 936 | && search(field->value, value[n], count)) |
| 937 | hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); |
| 938 | } |
| 939 | |
| 940 | memcpy(field->value, value, count * sizeof(__s32)); |
| 941 | exit: |
| 942 | kfree(value); |
| 943 | } |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 944 | |
| 945 | /* |
| 946 | * Output the field into the report. |
| 947 | */ |
| 948 | |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 949 | static void hid_output_field(const struct hid_device *hid, |
| 950 | struct hid_field *field, __u8 *data) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 951 | { |
| 952 | unsigned count = field->report_count; |
| 953 | unsigned offset = field->report_offset; |
| 954 | unsigned size = field->report_size; |
| 955 | unsigned n; |
| 956 | |
| 957 | for (n = 0; n < count; n++) { |
| 958 | if (field->logical_minimum < 0) /* signed values */ |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 959 | implement(hid, data, offset + n * size, size, |
| 960 | s32ton(field->value[n], size)); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 961 | else /* unsigned values */ |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 962 | implement(hid, data, offset + n * size, size, |
| 963 | field->value[n]); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 964 | } |
| 965 | } |
| 966 | |
| 967 | /* |
| 968 | * Create a report. |
| 969 | */ |
| 970 | |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 971 | void hid_output_report(struct hid_report *report, __u8 *data) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 972 | { |
| 973 | unsigned n; |
| 974 | |
| 975 | if (report->id > 0) |
| 976 | *data++ = report->id; |
| 977 | |
Pete Zaitcev | 75c28df | 2010-04-12 12:16:11 -0600 | [diff] [blame] | 978 | memset(data, 0, ((report->size - 1) >> 3) + 1); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 979 | for (n = 0; n < report->maxfield; n++) |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 980 | hid_output_field(report->device, report->field[n], data); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 981 | } |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 982 | EXPORT_SYMBOL_GPL(hid_output_report); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 983 | |
| 984 | /* |
| 985 | * Set a field value. The report this field belongs to has to be |
| 986 | * created and transferred to the device, to set this value in the |
| 987 | * device. |
| 988 | */ |
| 989 | |
| 990 | int hid_set_field(struct hid_field *field, unsigned offset, __s32 value) |
| 991 | { |
| 992 | unsigned size = field->report_size; |
| 993 | |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 994 | hid_dump_input(field->report->device, field->usage + offset, value); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 995 | |
| 996 | if (offset >= field->report_count) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 997 | dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 998 | return -1; |
| 999 | } |
| 1000 | if (field->logical_minimum < 0) { |
| 1001 | if (value != snto32(s32ton(value, size), size)) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 1002 | dbg_hid("value %d is out of range\n", value); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 1003 | return -1; |
| 1004 | } |
| 1005 | } |
| 1006 | field->value[offset] = value; |
| 1007 | return 0; |
| 1008 | } |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 1009 | EXPORT_SYMBOL_GPL(hid_set_field); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 1010 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1011 | static struct hid_report *hid_get_report(struct hid_report_enum *report_enum, |
| 1012 | const u8 *data) |
| 1013 | { |
| 1014 | struct hid_report *report; |
| 1015 | unsigned int n = 0; /* Normally report number is 0 */ |
| 1016 | |
| 1017 | /* Device uses numbered reports, data[0] is report number */ |
| 1018 | if (report_enum->numbered) |
| 1019 | n = *data; |
| 1020 | |
| 1021 | report = report_enum->report_id_hash[n]; |
| 1022 | if (report == NULL) |
| 1023 | dbg_hid("undefined report_id %u received\n", n); |
| 1024 | |
| 1025 | return report; |
| 1026 | } |
| 1027 | |
| 1028 | void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, |
| 1029 | int interrupt) |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1030 | { |
| 1031 | struct hid_report_enum *report_enum = hid->report_enum + type; |
| 1032 | struct hid_report *report; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1033 | unsigned int a; |
| 1034 | int rsize, csize = size; |
| 1035 | u8 *cdata = data; |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1036 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1037 | report = hid_get_report(report_enum, data); |
| 1038 | if (!report) |
| 1039 | return; |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1040 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1041 | if (report_enum->numbered) { |
| 1042 | cdata++; |
| 1043 | csize--; |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1044 | } |
| 1045 | |
| 1046 | rsize = ((report->size - 1) >> 3) + 1; |
| 1047 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1048 | if (csize < rsize) { |
| 1049 | dbg_hid("report %d is too short, (%d < %d)\n", report->id, |
| 1050 | csize, rsize); |
| 1051 | memset(cdata + csize, 0, rsize - csize); |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) |
| 1055 | hid->hiddev_report_event(hid, report); |
Alan Ott | 5a38f2c | 2010-04-26 18:34:46 -0400 | [diff] [blame] | 1056 | if (hid->claimed & HID_CLAIMED_HIDRAW) |
| 1057 | hidraw_report_event(hid, data, size); |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1058 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1059 | for (a = 0; a < report->maxfield; a++) |
| 1060 | hid_input_field(hid, report->field[a], cdata, interrupt); |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1061 | |
| 1062 | if (hid->claimed & HID_CLAIMED_INPUT) |
| 1063 | hidinput_report_event(hid, report); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1064 | } |
| 1065 | EXPORT_SYMBOL_GPL(hid_report_raw_event); |
| 1066 | |
| 1067 | /** |
| 1068 | * hid_input_report - report data from lower layer (usb, bt...) |
| 1069 | * |
| 1070 | * @hid: hid device |
| 1071 | * @type: HID report type (HID_*_REPORT) |
| 1072 | * @data: report contents |
| 1073 | * @size: size of data parameter |
Jiri Kosina | ff9b00a | 2009-10-01 16:03:13 +0200 | [diff] [blame] | 1074 | * @interrupt: distinguish between interrupt and control transfers |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1075 | * |
| 1076 | * This is data entry for lower layers. |
| 1077 | */ |
| 1078 | int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) |
| 1079 | { |
Julia Lawall | 76c317d | 2009-07-19 17:26:13 +0200 | [diff] [blame] | 1080 | struct hid_report_enum *report_enum; |
| 1081 | struct hid_driver *hdrv; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1082 | struct hid_report *report; |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1083 | char *buf; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1084 | unsigned int i; |
| 1085 | int ret; |
| 1086 | |
| 1087 | if (!hid || !hid->driver) |
| 1088 | return -ENODEV; |
Julia Lawall | 76c317d | 2009-07-19 17:26:13 +0200 | [diff] [blame] | 1089 | report_enum = hid->report_enum + type; |
| 1090 | hdrv = hid->driver; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1091 | |
| 1092 | if (!size) { |
| 1093 | dbg_hid("empty report\n"); |
| 1094 | return -1; |
| 1095 | } |
| 1096 | |
Jiri Kosina | d1ff652 | 2009-09-15 11:59:49 +0200 | [diff] [blame] | 1097 | buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC); |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1098 | |
Jiri Kosina | f77e347 | 2010-03-18 14:11:53 +0100 | [diff] [blame] | 1099 | if (!buf) |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1100 | goto nomem; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1101 | |
| 1102 | /* dump the report */ |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1103 | snprintf(buf, HID_DEBUG_BUFSIZE - 1, |
Jiri Kosina | 1caea61 | 2010-03-18 12:09:53 +0100 | [diff] [blame] | 1104 | "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un"); |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1105 | hid_debug_event(hid, buf); |
Jiri Kosina | 1caea61 | 2010-03-18 12:09:53 +0100 | [diff] [blame] | 1106 | |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1107 | for (i = 0; i < size; i++) { |
| 1108 | snprintf(buf, HID_DEBUG_BUFSIZE - 1, |
| 1109 | " %02x", data[i]); |
| 1110 | hid_debug_event(hid, buf); |
| 1111 | } |
| 1112 | hid_debug_event(hid, "\n"); |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1113 | kfree(buf); |
| 1114 | |
| 1115 | nomem: |
Jiri Kosina | f77e347 | 2010-03-18 14:11:53 +0100 | [diff] [blame] | 1116 | report = hid_get_report(report_enum, data); |
| 1117 | |
| 1118 | if (!report) |
| 1119 | return -1; |
| 1120 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1121 | if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { |
| 1122 | ret = hdrv->raw_event(hid, report, data, size); |
| 1123 | if (ret != 0) |
| 1124 | return ret < 0 ? ret : 0; |
| 1125 | } |
| 1126 | |
| 1127 | hid_report_raw_event(hid, type, data, size, interrupt); |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1128 | |
| 1129 | return 0; |
| 1130 | } |
| 1131 | EXPORT_SYMBOL_GPL(hid_input_report); |
| 1132 | |
Jiri Kosina | 0f37cd0 | 2008-08-20 19:13:52 +0200 | [diff] [blame] | 1133 | static bool hid_match_one_id(struct hid_device *hdev, |
| 1134 | const struct hid_device_id *id) |
| 1135 | { |
| 1136 | return id->bus == hdev->bus && |
| 1137 | (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && |
| 1138 | (id->product == HID_ANY_ID || id->product == hdev->product); |
| 1139 | } |
| 1140 | |
| 1141 | static const struct hid_device_id *hid_match_id(struct hid_device *hdev, |
| 1142 | const struct hid_device_id *id) |
| 1143 | { |
| 1144 | for (; id->bus; id++) |
| 1145 | if (hid_match_one_id(hdev, id)) |
| 1146 | return id; |
| 1147 | |
| 1148 | return NULL; |
| 1149 | } |
| 1150 | |
| 1151 | static const struct hid_device_id hid_hiddev_list[] = { |
Richard Hughes | c0bd6a4 | 2008-08-27 11:19:37 +0200 | [diff] [blame] | 1152 | { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, |
| 1153 | { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, |
Jiri Kosina | 0f37cd0 | 2008-08-20 19:13:52 +0200 | [diff] [blame] | 1154 | { } |
| 1155 | }; |
| 1156 | |
| 1157 | static bool hid_hiddev(struct hid_device *hdev) |
| 1158 | { |
| 1159 | return !!hid_match_id(hdev, hid_hiddev_list); |
| 1160 | } |
| 1161 | |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1162 | int hid_connect(struct hid_device *hdev, unsigned int connect_mask) |
| 1163 | { |
| 1164 | static const char *types[] = { "Device", "Pointer", "Mouse", "Device", |
| 1165 | "Joystick", "Gamepad", "Keyboard", "Keypad", |
| 1166 | "Multi-Axis Controller" |
| 1167 | }; |
| 1168 | const char *type, *bus; |
| 1169 | char buf[64]; |
| 1170 | unsigned int i; |
| 1171 | int len; |
| 1172 | |
Bastien Nocera | b5e5a37 | 2010-04-16 17:19:50 +0100 | [diff] [blame] | 1173 | if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) |
| 1174 | connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV); |
Daniel Mack | 3a343ee | 2010-07-12 19:28:27 +0200 | [diff] [blame] | 1175 | if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE) |
| 1176 | connect_mask |= HID_CONNECT_HIDINPUT_FORCE; |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1177 | if (hdev->bus != BUS_USB) |
| 1178 | connect_mask &= ~HID_CONNECT_HIDDEV; |
Jiri Kosina | 0f37cd0 | 2008-08-20 19:13:52 +0200 | [diff] [blame] | 1179 | if (hid_hiddev(hdev)) |
| 1180 | connect_mask |= HID_CONNECT_HIDDEV_FORCE; |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1181 | |
| 1182 | if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev, |
| 1183 | connect_mask & HID_CONNECT_HIDINPUT_FORCE)) |
| 1184 | hdev->claimed |= HID_CLAIMED_INPUT; |
| 1185 | if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect && |
| 1186 | !hdev->hiddev_connect(hdev, |
| 1187 | connect_mask & HID_CONNECT_HIDDEV_FORCE)) |
| 1188 | hdev->claimed |= HID_CLAIMED_HIDDEV; |
| 1189 | if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev)) |
| 1190 | hdev->claimed |= HID_CLAIMED_HIDRAW; |
| 1191 | |
| 1192 | if (!hdev->claimed) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 1193 | hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n"); |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1194 | return -ENODEV; |
| 1195 | } |
| 1196 | |
| 1197 | if ((hdev->claimed & HID_CLAIMED_INPUT) && |
| 1198 | (connect_mask & HID_CONNECT_FF) && hdev->ff_init) |
| 1199 | hdev->ff_init(hdev); |
| 1200 | |
| 1201 | len = 0; |
| 1202 | if (hdev->claimed & HID_CLAIMED_INPUT) |
| 1203 | len += sprintf(buf + len, "input"); |
| 1204 | if (hdev->claimed & HID_CLAIMED_HIDDEV) |
| 1205 | len += sprintf(buf + len, "%shiddev%d", len ? "," : "", |
| 1206 | hdev->minor); |
| 1207 | if (hdev->claimed & HID_CLAIMED_HIDRAW) |
| 1208 | len += sprintf(buf + len, "%shidraw%d", len ? "," : "", |
| 1209 | ((struct hidraw *)hdev->hidraw)->minor); |
| 1210 | |
| 1211 | type = "Device"; |
| 1212 | for (i = 0; i < hdev->maxcollection; i++) { |
| 1213 | struct hid_collection *col = &hdev->collection[i]; |
| 1214 | if (col->type == HID_COLLECTION_APPLICATION && |
| 1215 | (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK && |
| 1216 | (col->usage & 0xffff) < ARRAY_SIZE(types)) { |
| 1217 | type = types[col->usage & 0xffff]; |
| 1218 | break; |
| 1219 | } |
| 1220 | } |
| 1221 | |
| 1222 | switch (hdev->bus) { |
| 1223 | case BUS_USB: |
| 1224 | bus = "USB"; |
| 1225 | break; |
| 1226 | case BUS_BLUETOOTH: |
| 1227 | bus = "BLUETOOTH"; |
| 1228 | break; |
| 1229 | default: |
| 1230 | bus = "<UNKNOWN>"; |
| 1231 | } |
| 1232 | |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 1233 | hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", |
| 1234 | buf, bus, hdev->version >> 8, hdev->version & 0xff, |
| 1235 | type, hdev->name, hdev->phys); |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1236 | |
| 1237 | return 0; |
| 1238 | } |
| 1239 | EXPORT_SYMBOL_GPL(hid_connect); |
| 1240 | |
Jiri Kosina | c4c259b | 2009-09-15 16:27:45 +0200 | [diff] [blame] | 1241 | void hid_disconnect(struct hid_device *hdev) |
| 1242 | { |
| 1243 | if (hdev->claimed & HID_CLAIMED_INPUT) |
| 1244 | hidinput_disconnect(hdev); |
| 1245 | if (hdev->claimed & HID_CLAIMED_HIDDEV) |
| 1246 | hdev->hiddev_disconnect(hdev); |
| 1247 | if (hdev->claimed & HID_CLAIMED_HIDRAW) |
| 1248 | hidraw_disconnect(hdev); |
| 1249 | } |
| 1250 | EXPORT_SYMBOL_GPL(hid_disconnect); |
| 1251 | |
Jiri Kosina | bae7eb3 | 2009-01-28 23:06:37 +0100 | [diff] [blame] | 1252 | /* a list of devices for which there is a specialized driver on HID bus */ |
Dmitry Torokhov | ce06b9d | 2010-11-28 16:37:14 +0100 | [diff] [blame] | 1253 | static const struct hid_device_id hid_have_special_driver[] = { |
Stephane Chatty | b6353f4 | 2009-12-22 23:04:17 +0100 | [diff] [blame] | 1254 | { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, |
Stephane Chatty | 6dec143 | 2010-04-11 14:51:24 +0200 | [diff] [blame] | 1255 | { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, |
Jiri Slaby | 14a21cd | 2008-06-23 23:31:09 +0200 | [diff] [blame] | 1256 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, |
| 1257 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, |
Lech Perczak | b7e1b20 | 2010-09-16 23:19:33 +0200 | [diff] [blame] | 1258 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, |
Sergei Kolzun | c0dbcc3 | 2010-07-19 12:13:23 +0200 | [diff] [blame] | 1259 | #if defined(CONFIG_HID_ACRUX_FF) || defined(CONFIG_HID_ACRUX_FF_MODULE) |
| 1260 | { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) }, |
| 1261 | #endif |
Jiri Kosina | df9bcac | 2008-10-14 22:45:40 +0200 | [diff] [blame] | 1262 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1263 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, |
| 1264 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, |
Michael Poole | 128537c | 2010-02-06 12:24:36 -0500 | [diff] [blame] | 1265 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) }, |
Chase Douglas | a462230 | 2010-08-31 21:56:23 -0400 | [diff] [blame] | 1266 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1267 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, |
| 1268 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, |
| 1269 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, |
| 1270 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, |
| 1271 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, |
| 1272 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, |
| 1273 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, |
| 1274 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, |
| 1275 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, |
| 1276 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, |
| 1277 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, |
Ryan Finnie | fef3f57 | 2009-03-05 10:18:01 +0100 | [diff] [blame] | 1278 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI) }, |
| 1279 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO) }, |
| 1280 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1281 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) }, |
| 1282 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) }, |
| 1283 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) }, |
| 1284 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, |
| 1285 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, |
| 1286 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, |
Jan Scholz | ee8a1a0 | 2008-11-26 15:33:45 +0100 | [diff] [blame] | 1287 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, |
| 1288 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, |
| 1289 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1290 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, |
| 1291 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, |
| 1292 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, |
| 1293 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, |
| 1294 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, |
| 1295 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, |
Henrik Rydberg | a96d6ef | 2008-11-04 20:03:45 +0100 | [diff] [blame] | 1296 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, |
| 1297 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, |
| 1298 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, |
Edgar (gimli) Hucek | 99b9f75 | 2010-11-03 10:36:18 -0400 | [diff] [blame] | 1299 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, |
| 1300 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, |
| 1301 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, |
| 1302 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, |
| 1303 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, |
| 1304 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, |
Christian Schuerer-Waldheim | 23aeb61 | 2010-01-06 14:49:57 +0100 | [diff] [blame] | 1305 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, |
| 1306 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, |
| 1307 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1308 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
| 1309 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
Jiri Kosina | eaca138 | 2010-09-08 14:31:47 +0200 | [diff] [blame] | 1310 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) }, |
Roland Baum | cec15a0 | 2010-09-08 14:27:55 +0200 | [diff] [blame] | 1311 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, |
Jiri Slaby | b5635b1 | 2008-06-24 23:24:57 +0200 | [diff] [blame] | 1312 | { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, |
Wayne Thomas | bf28062 | 2010-04-29 00:45:01 +0200 | [diff] [blame] | 1313 | { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, |
Jiri Kosina | c3dc66d | 2010-08-30 15:43:25 +0200 | [diff] [blame] | 1314 | { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1315 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, |
Stephane Chatty | 36213e1 | 2010-04-15 00:28:11 +0200 | [diff] [blame] | 1316 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, |
Benjamin Tissoires | bc5ab08 | 2011-01-08 12:15:41 +0100 | [diff] [blame] | 1317 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) }, |
Stephane Chatty | ba4d8ab | 2010-04-22 23:24:36 +0200 | [diff] [blame] | 1318 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, |
François Jaouen | 272036e | 2010-10-13 10:47:32 +0200 | [diff] [blame] | 1319 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, |
Jiri Slaby | 3b239cd | 2008-06-24 20:42:25 +0200 | [diff] [blame] | 1320 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, |
Raphaël Doursenaud | 1ce31b2 | 2010-04-08 13:40:52 +0200 | [diff] [blame] | 1321 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, |
Jiri Slaby | fcfacfd | 2008-06-24 22:48:52 +0200 | [diff] [blame] | 1322 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, |
Dennis Kügler | b9e4b1e | 2010-11-23 21:40:09 +0100 | [diff] [blame] | 1323 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, |
Don Prince | 3a370ca | 2010-05-12 15:18:59 +0200 | [diff] [blame] | 1324 | { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, |
Jiri Slaby | 0f22132 | 2008-06-23 22:54:08 +0200 | [diff] [blame] | 1325 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, |
| 1326 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, |
Jiri Kosina | e8d0eab | 2009-12-02 22:54:11 +0100 | [diff] [blame] | 1327 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) }, |
Jiri Slaby | 0f22132 | 2008-06-23 22:54:08 +0200 | [diff] [blame] | 1328 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, |
Benjamin Tissoires | a3b5e57 | 2011-01-07 23:46:30 +0100 | [diff] [blame] | 1329 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, |
Richard Walmsley | 3f866fb | 2009-03-04 22:12:04 +1300 | [diff] [blame] | 1330 | { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, |
Stephane Chatty | 0c3910c | 2010-04-10 16:43:08 +0200 | [diff] [blame] | 1331 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) }, |
Chris Ball | 83e4491 | 2010-08-16 16:01:28 +0200 | [diff] [blame] | 1332 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) }, |
Henrik Rydberg | 4e93db2 | 2010-11-29 07:27:49 +0100 | [diff] [blame] | 1333 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) }, |
Richard Nauber | 28906ad | 2010-12-14 22:36:18 +0100 | [diff] [blame] | 1334 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) }, |
Andy Ross | 4dd295a | 2010-12-16 15:53:19 -0800 | [diff] [blame] | 1335 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) }, |
Richard Nauber | 64b386e | 2010-06-28 18:54:25 +0200 | [diff] [blame] | 1336 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, |
Ignaz Forster | 04561c5 | 2010-11-01 15:13:37 -0400 | [diff] [blame] | 1337 | { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) }, |
Jiri Slaby | 1f243e3 | 2008-06-24 21:11:21 +0200 | [diff] [blame] | 1338 | { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, |
Jiri Kosina | 5181e59 | 2008-11-17 01:44:38 +0100 | [diff] [blame] | 1339 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, |
Jiri Kosina | 578f3a3 | 2008-11-20 15:55:38 +0100 | [diff] [blame] | 1340 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, |
Benjamin Tissoires | 5572da0 | 2011-01-07 23:47:27 +0100 | [diff] [blame] | 1341 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, |
Jiri Kosina | 5181e59 | 2008-11-17 01:44:38 +0100 | [diff] [blame] | 1342 | { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, |
Lukasz Lubojanski | 42859e0 | 2008-12-11 22:07:59 +0100 | [diff] [blame] | 1343 | { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) }, |
Jiri Slaby | 949f8fe | 2008-07-24 23:35:13 +0200 | [diff] [blame] | 1344 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, |
Jiri Kosina | 1e09320 | 2008-10-17 11:52:23 +0200 | [diff] [blame] | 1345 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, |
Cory Maccarrone | c2fd1a4 | 2010-05-22 13:00:28 -0700 | [diff] [blame] | 1346 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, |
Benjamin Tissoires | 5519cab | 2011-01-07 23:45:50 +0100 | [diff] [blame] | 1347 | { HID_USB_DEVICE(USB_VENDOR_ID_HANVON, USB_DEVICE_ID_HANVON_MULTITOUCH) }, |
Jiri Kosina | fdf93aa | 2009-03-04 16:09:40 +0100 | [diff] [blame] | 1348 | { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, |
Jiri Kosina | 7942274 | 2009-03-11 11:43:27 +0100 | [diff] [blame] | 1349 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, |
Jiri Slaby | b5635b1 | 2008-06-24 23:24:57 +0200 | [diff] [blame] | 1350 | { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, |
Jiri Slaby | 5f22a79 | 2008-05-16 11:49:19 +0200 | [diff] [blame] | 1351 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, |
| 1352 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, |
| 1353 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, |
| 1354 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, |
| 1355 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, |
| 1356 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, |
| 1357 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, |
Jiri Slaby | 5f22a79 | 2008-05-16 11:49:19 +0200 | [diff] [blame] | 1358 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, |
| 1359 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, |
Jiri Slaby | 5f22a79 | 2008-05-16 11:49:19 +0200 | [diff] [blame] | 1360 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, |
| 1361 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) }, |
Hendrik Iben | 2c6118e | 2010-10-04 15:39:49 +0200 | [diff] [blame] | 1362 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) }, |
Jiri Slaby | 606bd0a | 2008-07-04 23:06:45 +0200 | [diff] [blame] | 1363 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) }, |
| 1364 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) }, |
| 1365 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, |
Jiri Kosina | fd30ea8 | 2009-06-23 12:11:31 +0200 | [diff] [blame] | 1366 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) }, |
Jiri Slaby | 606bd0a | 2008-07-04 23:06:45 +0200 | [diff] [blame] | 1367 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, |
Gary Stein | 74f292c | 2010-01-13 00:25:58 +0100 | [diff] [blame] | 1368 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) }, |
Jiri Slaby | 606bd0a | 2008-07-04 23:06:45 +0200 | [diff] [blame] | 1369 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) }, |
| 1370 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) }, |
Christophe Borivant | 243b706 | 2009-04-17 11:39:39 +0200 | [diff] [blame] | 1371 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) }, |
Simon Wood | 32c88cb | 2010-09-22 13:19:42 +0200 | [diff] [blame] | 1372 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) }, |
Jiri Slaby | 606bd0a | 2008-07-04 23:06:45 +0200 | [diff] [blame] | 1373 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, |
Jiri Kosina | 24985cf | 2009-11-13 10:45:53 +0100 | [diff] [blame] | 1374 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) }, |
| 1375 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) }, |
Bruno Prémont | 236db47 | 2010-03-30 22:33:50 +0200 | [diff] [blame] | 1376 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, |
| 1377 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) }, |
Jiri Slaby | 78a849a | 2008-06-20 21:26:11 +0200 | [diff] [blame] | 1378 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, |
| 1379 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, |
| 1380 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, |
| 1381 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, |
| 1382 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, |
Jiri Slaby | 3b8006e | 2008-06-25 00:07:50 +0200 | [diff] [blame] | 1383 | { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 1384 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, |
micki | 6e32819 | 2010-06-19 11:37:29 +0300 | [diff] [blame] | 1385 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) }, |
| 1386 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) }, |
| 1387 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) }, |
| 1388 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) }, |
| 1389 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) }, |
| 1390 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) }, |
| 1391 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) }, |
| 1392 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) }, |
| 1393 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) }, |
| 1394 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) }, |
| 1395 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) }, |
| 1396 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) }, |
| 1397 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) }, |
| 1398 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) }, |
| 1399 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) }, |
| 1400 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) }, |
| 1401 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) }, |
| 1402 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) }, |
Johnathon Harris | cd9ec30 | 2010-01-21 14:36:52 +0000 | [diff] [blame] | 1403 | { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, |
Jiri Slaby | 1e76253 | 2008-06-24 23:46:21 +0200 | [diff] [blame] | 1404 | { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, |
Stephane Chatty | 49e4739 | 2010-01-13 00:29:16 +0100 | [diff] [blame] | 1405 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, |
Alex Neblett | f54405d | 2010-02-02 21:16:03 -0800 | [diff] [blame] | 1406 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, |
Stefan Achatz | 14bf62c | 2010-03-18 16:19:43 +0100 | [diff] [blame] | 1407 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, |
Stefan Achatz | 47dbdbf | 2010-11-26 19:57:42 +0000 | [diff] [blame] | 1408 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 1409 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, |
Jiri Slaby | 980a3da | 2008-06-25 22:31:48 +0200 | [diff] [blame] | 1410 | { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, |
Don Prince | b355850 | 2010-05-17 11:42:39 +0100 | [diff] [blame] | 1411 | { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, |
Jiri Slaby | bd28ce0 | 2008-06-25 23:47:04 +0200 | [diff] [blame] | 1412 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, |
Bastien Nocera | f9ce7c2 | 2010-01-20 12:01:53 +0000 | [diff] [blame] | 1413 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, |
Jiri Kosina | cc6e0bb | 2008-10-23 12:58:38 +0200 | [diff] [blame] | 1414 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, |
Stephane Chatty | d3fb545 | 2010-01-04 12:04:08 +0100 | [diff] [blame] | 1415 | { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) }, |
Pascal Auriel - Stantum | b6dc799 | 2010-10-01 16:01:28 +0200 | [diff] [blame] | 1416 | { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) }, |
| 1417 | { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) }, |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 1418 | { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, |
Anssi Hannula | daedb3d | 2009-02-14 11:45:05 +0200 | [diff] [blame] | 1419 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, |
| 1420 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, |
Ruben Aos Garralda | 7a84b13 | 2009-06-29 09:41:29 +0200 | [diff] [blame] | 1421 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, |
| 1422 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) }, |
Anssi Hannula | daedb3d | 2009-02-14 11:45:05 +0200 | [diff] [blame] | 1423 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, |
Markus Rathgeb | 3ee8f0a | 2010-03-13 17:29:43 +0100 | [diff] [blame] | 1424 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) }, |
Anssi Hannula | daedb3d | 2009-02-14 11:45:05 +0200 | [diff] [blame] | 1425 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, |
Simon Wood | d65c376 | 2010-11-29 17:41:23 +0100 | [diff] [blame] | 1426 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) }, |
Lev Babiev | f14f526 | 2009-01-04 00:36:56 +0100 | [diff] [blame] | 1427 | { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, |
Kees Bakker | 5400108 | 2010-07-13 22:50:51 +0200 | [diff] [blame] | 1428 | { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) }, |
Bruno Premont | 711a680 | 2009-07-13 14:19:58 +0200 | [diff] [blame] | 1429 | { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, |
Benjamin Tissoires | c64f6f9 | 2011-01-08 12:15:42 +0100 | [diff] [blame] | 1430 | { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, |
Nikolai Kondrashov | 41fa923 | 2010-08-23 15:09:01 +0400 | [diff] [blame] | 1431 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, |
Nikolai Kondrashov | f8a489c | 2010-08-09 20:44:17 +0400 | [diff] [blame] | 1432 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) }, |
| 1433 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) }, |
| 1434 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) }, |
Jussi Kivilinna | fac733f | 2009-05-13 11:54:38 +0300 | [diff] [blame] | 1435 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, |
Bastien Nocera | ca2dcd4 | 2009-05-11 17:18:12 +0200 | [diff] [blame] | 1436 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, |
Nikolai Kondrashov | 72a4634 | 2010-08-20 19:21:11 +0400 | [diff] [blame] | 1437 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, |
Nikolai Kondrashov | 00e7f96 | 2010-09-25 23:16:58 +0400 | [diff] [blame] | 1438 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, |
Nikolai Kondrashov | 72a4634 | 2010-08-20 19:21:11 +0400 | [diff] [blame] | 1439 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, |
Nikolai Kondrashov | 8f1acc3 | 2010-08-30 14:06:36 +0400 | [diff] [blame] | 1440 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, |
Anssi Hannula | daedb3d | 2009-02-14 11:45:05 +0200 | [diff] [blame] | 1441 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, |
| 1442 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, |
Don Prince | a9885c8 | 2010-05-14 17:30:59 +0100 | [diff] [blame] | 1443 | { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1444 | |
Jiri Slaby | 78a849a | 2008-06-20 21:26:11 +0200 | [diff] [blame] | 1445 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1446 | { } |
| 1447 | }; |
| 1448 | |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1449 | struct hid_dynid { |
| 1450 | struct list_head list; |
| 1451 | struct hid_device_id id; |
| 1452 | }; |
| 1453 | |
| 1454 | /** |
| 1455 | * store_new_id - add a new HID device ID to this driver and re-probe devices |
| 1456 | * @driver: target device driver |
| 1457 | * @buf: buffer for scanning device ID data |
| 1458 | * @count: input size |
| 1459 | * |
| 1460 | * Adds a new dynamic hid device ID to this driver, |
| 1461 | * and causes the driver to probe for all devices again. |
| 1462 | */ |
| 1463 | static ssize_t store_new_id(struct device_driver *drv, const char *buf, |
| 1464 | size_t count) |
| 1465 | { |
| 1466 | struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); |
| 1467 | struct hid_dynid *dynid; |
| 1468 | __u32 bus, vendor, product; |
| 1469 | unsigned long driver_data = 0; |
| 1470 | int ret; |
| 1471 | |
| 1472 | ret = sscanf(buf, "%x %x %x %lx", |
| 1473 | &bus, &vendor, &product, &driver_data); |
| 1474 | if (ret < 3) |
| 1475 | return -EINVAL; |
| 1476 | |
| 1477 | dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); |
| 1478 | if (!dynid) |
| 1479 | return -ENOMEM; |
| 1480 | |
| 1481 | dynid->id.bus = bus; |
| 1482 | dynid->id.vendor = vendor; |
| 1483 | dynid->id.product = product; |
| 1484 | dynid->id.driver_data = driver_data; |
| 1485 | |
| 1486 | spin_lock(&hdrv->dyn_lock); |
| 1487 | list_add_tail(&dynid->list, &hdrv->dyn_list); |
| 1488 | spin_unlock(&hdrv->dyn_lock); |
| 1489 | |
| 1490 | ret = 0; |
| 1491 | if (get_driver(&hdrv->driver)) { |
| 1492 | ret = driver_attach(&hdrv->driver); |
| 1493 | put_driver(&hdrv->driver); |
| 1494 | } |
| 1495 | |
| 1496 | return ret ? : count; |
| 1497 | } |
| 1498 | static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); |
| 1499 | |
| 1500 | static void hid_free_dynids(struct hid_driver *hdrv) |
| 1501 | { |
| 1502 | struct hid_dynid *dynid, *n; |
| 1503 | |
| 1504 | spin_lock(&hdrv->dyn_lock); |
| 1505 | list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) { |
| 1506 | list_del(&dynid->list); |
| 1507 | kfree(dynid); |
| 1508 | } |
| 1509 | spin_unlock(&hdrv->dyn_lock); |
| 1510 | } |
| 1511 | |
| 1512 | static const struct hid_device_id *hid_match_device(struct hid_device *hdev, |
| 1513 | struct hid_driver *hdrv) |
| 1514 | { |
| 1515 | struct hid_dynid *dynid; |
| 1516 | |
| 1517 | spin_lock(&hdrv->dyn_lock); |
| 1518 | list_for_each_entry(dynid, &hdrv->dyn_list, list) { |
| 1519 | if (hid_match_one_id(hdev, &dynid->id)) { |
| 1520 | spin_unlock(&hdrv->dyn_lock); |
| 1521 | return &dynid->id; |
| 1522 | } |
| 1523 | } |
| 1524 | spin_unlock(&hdrv->dyn_lock); |
| 1525 | |
| 1526 | return hid_match_id(hdev, hdrv->id_table); |
| 1527 | } |
| 1528 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1529 | static int hid_bus_match(struct device *dev, struct device_driver *drv) |
| 1530 | { |
| 1531 | struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); |
| 1532 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 1533 | |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1534 | if (!hid_match_device(hdev, hdrv)) |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1535 | return 0; |
| 1536 | |
Dmitry Torokhov | ce06b9d | 2010-11-28 16:37:14 +0100 | [diff] [blame] | 1537 | /* generic wants all that don't have specialized driver */ |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1538 | if (!strncmp(hdrv->name, "generic-", 8)) |
Dmitry Torokhov | ce06b9d | 2010-11-28 16:37:14 +0100 | [diff] [blame] | 1539 | return !hid_match_id(hdev, hid_have_special_driver); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1540 | |
| 1541 | return 1; |
| 1542 | } |
| 1543 | |
| 1544 | static int hid_device_probe(struct device *dev) |
| 1545 | { |
| 1546 | struct hid_driver *hdrv = container_of(dev->driver, |
| 1547 | struct hid_driver, driver); |
| 1548 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 1549 | const struct hid_device_id *id; |
| 1550 | int ret = 0; |
| 1551 | |
| 1552 | if (!hdev->driver) { |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1553 | id = hid_match_device(hdev, hdrv); |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 1554 | if (id == NULL) |
| 1555 | return -ENODEV; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1556 | |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 1557 | hdev->driver = hdrv; |
| 1558 | if (hdrv->probe) { |
| 1559 | ret = hdrv->probe(hdev, id); |
| 1560 | } else { /* default probe */ |
| 1561 | ret = hid_parse(hdev); |
| 1562 | if (!ret) |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1563 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1564 | } |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 1565 | if (ret) |
| 1566 | hdev->driver = NULL; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1567 | } |
| 1568 | return ret; |
| 1569 | } |
| 1570 | |
| 1571 | static int hid_device_remove(struct device *dev) |
| 1572 | { |
| 1573 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 1574 | struct hid_driver *hdrv = hdev->driver; |
| 1575 | |
| 1576 | if (hdrv) { |
| 1577 | if (hdrv->remove) |
| 1578 | hdrv->remove(hdev); |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 1579 | else /* default remove */ |
| 1580 | hid_hw_stop(hdev); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1581 | hdev->driver = NULL; |
| 1582 | } |
| 1583 | |
| 1584 | return 0; |
| 1585 | } |
| 1586 | |
| 1587 | static int hid_uevent(struct device *dev, struct kobj_uevent_env *env) |
| 1588 | { |
| 1589 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 1590 | |
| 1591 | if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", |
| 1592 | hdev->bus, hdev->vendor, hdev->product)) |
| 1593 | return -ENOMEM; |
| 1594 | |
| 1595 | if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) |
| 1596 | return -ENOMEM; |
| 1597 | |
| 1598 | if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) |
| 1599 | return -ENOMEM; |
| 1600 | |
| 1601 | if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) |
| 1602 | return -ENOMEM; |
| 1603 | |
| 1604 | if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X", |
| 1605 | hdev->bus, hdev->vendor, hdev->product)) |
| 1606 | return -ENOMEM; |
| 1607 | |
| 1608 | return 0; |
| 1609 | } |
| 1610 | |
| 1611 | static struct bus_type hid_bus_type = { |
| 1612 | .name = "hid", |
| 1613 | .match = hid_bus_match, |
| 1614 | .probe = hid_device_probe, |
| 1615 | .remove = hid_device_remove, |
| 1616 | .uevent = hid_uevent, |
| 1617 | }; |
| 1618 | |
Jiri Kosina | bae7eb3 | 2009-01-28 23:06:37 +0100 | [diff] [blame] | 1619 | /* a list of devices that shouldn't be handled by HID core at all */ |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1620 | static const struct hid_device_id hid_ignore_list[] = { |
| 1621 | { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, |
| 1622 | { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, |
| 1623 | { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, |
| 1624 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, |
| 1625 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, |
| 1626 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, |
| 1627 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, |
| 1628 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, |
| 1629 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, |
| 1630 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, |
| 1631 | { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, |
| 1632 | { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, |
Stephane Chatty | 77f720b | 2010-02-06 15:17:13 +0100 | [diff] [blame] | 1633 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)}, |
| 1634 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)}, |
Alexey Klimov | 62a5658 | 2008-11-13 05:44:50 +0300 | [diff] [blame] | 1635 | { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1636 | { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, |
| 1637 | { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, |
| 1638 | { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, |
| 1639 | { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, |
| 1640 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, |
| 1641 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, |
Alexey Klimov | 5f6108c | 2008-12-08 12:40:14 +0100 | [diff] [blame] | 1642 | { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1643 | { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, |
| 1644 | { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, |
Melchior FRANZ | 73bc7d3 | 2010-12-22 02:04:33 +0100 | [diff] [blame] | 1645 | { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1646 | { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, |
Petr Å tetiar | 70c6656 | 2009-12-09 22:09:53 +0100 | [diff] [blame] | 1647 | { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) }, |
Petr Å tetiar | df506f2 | 2010-06-28 09:38:54 -0700 | [diff] [blame] | 1648 | { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1649 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, |
| 1650 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) }, |
| 1651 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, |
| 1652 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, |
| 1653 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, |
| 1654 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, |
| 1655 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, |
| 1656 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, |
| 1657 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, |
| 1658 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, |
| 1659 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, |
| 1660 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, |
| 1661 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, |
| 1662 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, |
| 1663 | { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, |
| 1664 | { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, |
| 1665 | { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, |
| 1666 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, |
| 1667 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, |
| 1668 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, |
| 1669 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, |
| 1670 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, |
| 1671 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, |
| 1672 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, |
| 1673 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, |
| 1674 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, |
| 1675 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, |
| 1676 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, |
| 1677 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, |
| 1678 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, |
| 1679 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, |
| 1680 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, |
| 1681 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, |
| 1682 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, |
| 1683 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, |
| 1684 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, |
| 1685 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, |
| 1686 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, |
| 1687 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, |
| 1688 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, |
| 1689 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, |
| 1690 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, |
| 1691 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, |
| 1692 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, |
| 1693 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, |
| 1694 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, |
| 1695 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, |
| 1696 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, |
| 1697 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, |
| 1698 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, |
| 1699 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, |
| 1700 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, |
| 1701 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, |
| 1702 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, |
| 1703 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, |
| 1704 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, |
| 1705 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, |
| 1706 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, |
| 1707 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, |
| 1708 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, |
| 1709 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, |
| 1710 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, |
| 1711 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, |
| 1712 | { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, |
Tomoki Sekiyama | 6bc235a | 2010-09-29 12:16:50 +0900 | [diff] [blame] | 1713 | { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_JESS_YUREX) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1714 | { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, |
Alexey Klimov | c91c21c | 2008-11-13 10:36:11 +0100 | [diff] [blame] | 1715 | { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1716 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, |
Lamarque Vieira Souza | eb8141c | 2009-10-02 15:04:44 +0200 | [diff] [blame] | 1717 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1718 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, |
| 1719 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, |
| 1720 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, |
| 1721 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, |
| 1722 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, |
| 1723 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, |
| 1724 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY1) }, |
| 1725 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, |
| 1726 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, |
| 1727 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, |
| 1728 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, |
| 1729 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, |
| 1730 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, |
| 1731 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, |
| 1732 | { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, |
| 1733 | { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1734 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, |
| 1735 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, |
| 1736 | { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, |
| 1737 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, |
| 1738 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, |
| 1739 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, |
| 1740 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, |
| 1741 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, |
| 1742 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, |
| 1743 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, |
| 1744 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, |
| 1745 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, |
| 1746 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, |
| 1747 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, |
| 1748 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, |
| 1749 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, |
| 1750 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, |
Henning Glawe | 4cfae3e | 2009-08-02 22:18:12 +0200 | [diff] [blame] | 1751 | { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, |
Michael Tokarev | 35cfd1d | 2009-02-01 16:11:04 +0100 | [diff] [blame] | 1752 | { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1753 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, |
| 1754 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, |
| 1755 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, |
| 1756 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, |
| 1757 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, |
| 1758 | { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, |
| 1759 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, |
| 1760 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, |
| 1761 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, |
| 1762 | { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, |
| 1763 | { } |
| 1764 | }; |
| 1765 | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 1766 | /** |
| 1767 | * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer |
| 1768 | * |
| 1769 | * There are composite devices for which we want to ignore only a certain |
| 1770 | * interface. This is a list of devices for which only the mouse interface will |
| 1771 | * be ignored. This allows a dedicated driver to take care of the interface. |
| 1772 | */ |
| 1773 | static const struct hid_device_id hid_mouse_ignore_list[] = { |
| 1774 | /* appletouch driver */ |
| 1775 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, |
| 1776 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, |
| 1777 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, |
| 1778 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, |
| 1779 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, |
| 1780 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, |
| 1781 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, |
| 1782 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, |
| 1783 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, |
| 1784 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, |
| 1785 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, |
| 1786 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, |
| 1787 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, |
| 1788 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, |
| 1789 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, |
| 1790 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, |
| 1791 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, |
| 1792 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, |
| 1793 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, |
| 1794 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, |
Jiri Kosina | ac26fca | 2008-11-20 11:27:02 +0100 | [diff] [blame] | 1795 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, |
| 1796 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, |
| 1797 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, |
Edgar (gimli) Hucek | 99b9f75 | 2010-11-03 10:36:18 -0400 | [diff] [blame] | 1798 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, |
| 1799 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, |
| 1800 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, |
| 1801 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, |
| 1802 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, |
| 1803 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 1804 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
| 1805 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
| 1806 | { } |
| 1807 | }; |
| 1808 | |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1809 | static bool hid_ignore(struct hid_device *hdev) |
| 1810 | { |
| 1811 | switch (hdev->vendor) { |
| 1812 | case USB_VENDOR_ID_CODEMERCS: |
| 1813 | /* ignore all Code Mercenaries IOWarrior devices */ |
| 1814 | if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && |
| 1815 | hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) |
| 1816 | return true; |
| 1817 | break; |
| 1818 | case USB_VENDOR_ID_LOGITECH: |
| 1819 | if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && |
| 1820 | hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) |
| 1821 | return true; |
| 1822 | break; |
Jarod Wilson | 31f7fd7 | 2009-07-31 10:56:36 -0400 | [diff] [blame] | 1823 | case USB_VENDOR_ID_SOUNDGRAPH: |
| 1824 | if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST && |
| 1825 | hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST) |
| 1826 | return true; |
| 1827 | break; |
Xing Wei | bba5394 | 2010-09-01 23:25:35 -0700 | [diff] [blame] | 1828 | case USB_VENDOR_ID_HANWANG: |
| 1829 | if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST && |
| 1830 | hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST) |
| 1831 | return true; |
| 1832 | break; |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1833 | } |
| 1834 | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 1835 | if (hdev->type == HID_TYPE_USBMOUSE && |
| 1836 | hid_match_id(hdev, hid_mouse_ignore_list)) |
| 1837 | return true; |
| 1838 | |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1839 | return !!hid_match_id(hdev, hid_ignore_list); |
| 1840 | } |
| 1841 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1842 | int hid_add_device(struct hid_device *hdev) |
| 1843 | { |
| 1844 | static atomic_t id = ATOMIC_INIT(0); |
| 1845 | int ret; |
| 1846 | |
| 1847 | if (WARN_ON(hdev->status & HID_STAT_ADDED)) |
| 1848 | return -EBUSY; |
| 1849 | |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1850 | /* we need to kill them here, otherwise they will stay allocated to |
| 1851 | * wait for coming driver */ |
Jindrich Makovicka | e5a2a04 | 2010-06-03 12:50:42 +0200 | [diff] [blame] | 1852 | if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) |
| 1853 | && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE))) |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1854 | return -ENODEV; |
| 1855 | |
Kay Sievers | 6bbe586 | 2008-10-31 00:12:32 +0100 | [diff] [blame] | 1856 | /* XXX hack, any other cleaner solution after the driver core |
| 1857 | * is converted to allow more than 20 bytes as the device name? */ |
| 1858 | dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, |
| 1859 | hdev->vendor, hdev->product, atomic_inc_return(&id)); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1860 | |
Bruno Prémont | 4da361b | 2010-03-15 14:55:40 +0100 | [diff] [blame] | 1861 | hid_debug_register(hdev, dev_name(&hdev->dev)); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1862 | ret = device_add(&hdev->dev); |
| 1863 | if (!ret) |
| 1864 | hdev->status |= HID_STAT_ADDED; |
Bruno Prémont | 4da361b | 2010-03-15 14:55:40 +0100 | [diff] [blame] | 1865 | else |
| 1866 | hid_debug_unregister(hdev); |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 1867 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1868 | return ret; |
| 1869 | } |
| 1870 | EXPORT_SYMBOL_GPL(hid_add_device); |
| 1871 | |
| 1872 | /** |
| 1873 | * hid_allocate_device - allocate new hid device descriptor |
| 1874 | * |
| 1875 | * Allocate and initialize hid device, so that hid_destroy_device might be |
| 1876 | * used to free it. |
| 1877 | * |
| 1878 | * New hid_device pointer is returned on success, otherwise ERR_PTR encoded |
| 1879 | * error value. |
| 1880 | */ |
| 1881 | struct hid_device *hid_allocate_device(void) |
| 1882 | { |
| 1883 | struct hid_device *hdev; |
| 1884 | unsigned int i; |
| 1885 | int ret = -ENOMEM; |
| 1886 | |
| 1887 | hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); |
| 1888 | if (hdev == NULL) |
| 1889 | return ERR_PTR(ret); |
| 1890 | |
| 1891 | device_initialize(&hdev->dev); |
| 1892 | hdev->dev.release = hid_device_release; |
| 1893 | hdev->dev.bus = &hid_bus_type; |
| 1894 | |
| 1895 | hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, |
| 1896 | sizeof(struct hid_collection), GFP_KERNEL); |
| 1897 | if (hdev->collection == NULL) |
| 1898 | goto err; |
| 1899 | hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS; |
| 1900 | |
| 1901 | for (i = 0; i < HID_REPORT_TYPES; i++) |
| 1902 | INIT_LIST_HEAD(&hdev->report_enum[i].report_list); |
| 1903 | |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1904 | init_waitqueue_head(&hdev->debug_wait); |
| 1905 | INIT_LIST_HEAD(&hdev->debug_list); |
| 1906 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1907 | return hdev; |
| 1908 | err: |
| 1909 | put_device(&hdev->dev); |
| 1910 | return ERR_PTR(ret); |
| 1911 | } |
| 1912 | EXPORT_SYMBOL_GPL(hid_allocate_device); |
| 1913 | |
| 1914 | static void hid_remove_device(struct hid_device *hdev) |
| 1915 | { |
| 1916 | if (hdev->status & HID_STAT_ADDED) { |
| 1917 | device_del(&hdev->dev); |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 1918 | hid_debug_unregister(hdev); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1919 | hdev->status &= ~HID_STAT_ADDED; |
| 1920 | } |
| 1921 | } |
| 1922 | |
| 1923 | /** |
| 1924 | * hid_destroy_device - free previously allocated device |
| 1925 | * |
| 1926 | * @hdev: hid device |
| 1927 | * |
| 1928 | * If you allocate hid_device through hid_allocate_device, you should ever |
| 1929 | * free by this function. |
| 1930 | */ |
| 1931 | void hid_destroy_device(struct hid_device *hdev) |
| 1932 | { |
| 1933 | hid_remove_device(hdev); |
| 1934 | put_device(&hdev->dev); |
| 1935 | } |
| 1936 | EXPORT_SYMBOL_GPL(hid_destroy_device); |
| 1937 | |
| 1938 | int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, |
| 1939 | const char *mod_name) |
| 1940 | { |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1941 | int ret; |
| 1942 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1943 | hdrv->driver.name = hdrv->name; |
| 1944 | hdrv->driver.bus = &hid_bus_type; |
| 1945 | hdrv->driver.owner = owner; |
| 1946 | hdrv->driver.mod_name = mod_name; |
| 1947 | |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1948 | INIT_LIST_HEAD(&hdrv->dyn_list); |
| 1949 | spin_lock_init(&hdrv->dyn_lock); |
| 1950 | |
| 1951 | ret = driver_register(&hdrv->driver); |
| 1952 | if (ret) |
| 1953 | return ret; |
| 1954 | |
| 1955 | ret = driver_create_file(&hdrv->driver, &driver_attr_new_id); |
| 1956 | if (ret) |
| 1957 | driver_unregister(&hdrv->driver); |
| 1958 | |
| 1959 | return ret; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1960 | } |
| 1961 | EXPORT_SYMBOL_GPL(__hid_register_driver); |
| 1962 | |
| 1963 | void hid_unregister_driver(struct hid_driver *hdrv) |
| 1964 | { |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1965 | driver_remove_file(&hdrv->driver, &driver_attr_new_id); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1966 | driver_unregister(&hdrv->driver); |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1967 | hid_free_dynids(hdrv); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1968 | } |
| 1969 | EXPORT_SYMBOL_GPL(hid_unregister_driver); |
| 1970 | |
Oliver Neukum | 0361a28 | 2008-12-17 15:38:03 +0100 | [diff] [blame] | 1971 | int hid_check_keys_pressed(struct hid_device *hid) |
| 1972 | { |
| 1973 | struct hid_input *hidinput; |
| 1974 | int i; |
| 1975 | |
Jiri Kosina | e5288eb | 2009-05-02 00:02:57 +0200 | [diff] [blame] | 1976 | if (!(hid->claimed & HID_CLAIMED_INPUT)) |
| 1977 | return 0; |
| 1978 | |
Oliver Neukum | 0361a28 | 2008-12-17 15:38:03 +0100 | [diff] [blame] | 1979 | list_for_each_entry(hidinput, &hid->inputs, list) { |
| 1980 | for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++) |
| 1981 | if (hidinput->input->key[i]) |
| 1982 | return 1; |
| 1983 | } |
| 1984 | |
| 1985 | return 0; |
| 1986 | } |
| 1987 | |
| 1988 | EXPORT_SYMBOL_GPL(hid_check_keys_pressed); |
| 1989 | |
Jiri Kosina | 86166b7 | 2007-05-14 09:57:40 +0200 | [diff] [blame] | 1990 | static int __init hid_init(void) |
| 1991 | { |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1992 | int ret; |
| 1993 | |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 1994 | if (hid_debug) |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 1995 | pr_warn("hid_debug is now used solely for parser and driver debugging.\n" |
| 1996 | "debugfs is now used for inspecting the device (report descriptor, reports)\n"); |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 1997 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1998 | ret = bus_register(&hid_bus_type); |
| 1999 | if (ret) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 2000 | pr_err("can't register hid bus\n"); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 2001 | goto err; |
| 2002 | } |
| 2003 | |
| 2004 | ret = hidraw_init(); |
| 2005 | if (ret) |
| 2006 | goto err_bus; |
| 2007 | |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 2008 | hid_debug_init(); |
| 2009 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 2010 | return 0; |
| 2011 | err_bus: |
| 2012 | bus_unregister(&hid_bus_type); |
| 2013 | err: |
| 2014 | return ret; |
Jiri Kosina | 86166b7 | 2007-05-14 09:57:40 +0200 | [diff] [blame] | 2015 | } |
| 2016 | |
| 2017 | static void __exit hid_exit(void) |
| 2018 | { |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 2019 | hid_debug_exit(); |
Jiri Kosina | 86166b7 | 2007-05-14 09:57:40 +0200 | [diff] [blame] | 2020 | hidraw_exit(); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 2021 | bus_unregister(&hid_bus_type); |
Jiri Kosina | 86166b7 | 2007-05-14 09:57:40 +0200 | [diff] [blame] | 2022 | } |
| 2023 | |
| 2024 | module_init(hid_init); |
| 2025 | module_exit(hid_exit); |
| 2026 | |
Jiri Kosina | 88adb72 | 2009-10-02 18:29:34 +0200 | [diff] [blame] | 2027 | MODULE_AUTHOR("Andreas Gal"); |
| 2028 | MODULE_AUTHOR("Vojtech Pavlik"); |
| 2029 | MODULE_AUTHOR("Jiri Kosina"); |
Jiri Kosina | aa938f7 | 2006-12-08 18:41:10 +0100 | [diff] [blame] | 2030 | MODULE_LICENSE(DRIVER_LICENSE); |
| 2031 | |