hid-core.c 74 KB

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