hid-core.c 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192
  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 > 32) {
  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_ISKU) },
  1274. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) },
  1275. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) },
  1276. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
  1277. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) },
  1278. { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
  1279. { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
  1280. { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
  1281. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
  1282. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
  1283. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
  1284. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
  1285. { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) },
  1286. { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) },
  1287. { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) },
  1288. { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
  1289. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
  1290. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) },
  1291. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) },
  1292. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) },
  1293. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
  1294. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) },
  1295. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
  1296. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) },
  1297. { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
  1298. { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) },
  1299. { HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) },
  1300. { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) },
  1301. { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) },
  1302. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) },
  1303. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) },
  1304. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) },
  1305. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) },
  1306. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) },
  1307. { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) },
  1308. { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) },
  1309. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) },
  1310. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) },
  1311. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) },
  1312. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) },
  1313. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
  1314. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
  1315. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
  1316. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
  1317. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
  1318. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
  1319. { HID_USB_DEVICE(USB_VENDOR_ID_XAT, USB_DEVICE_ID_XAT_CSR) },
  1320. { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) },
  1321. { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
  1322. { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
  1323. { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
  1324. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) },
  1325. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) },
  1326. { }
  1327. };
  1328. struct hid_dynid {
  1329. struct list_head list;
  1330. struct hid_device_id id;
  1331. };
  1332. /**
  1333. * store_new_id - add a new HID device ID to this driver and re-probe devices
  1334. * @driver: target device driver
  1335. * @buf: buffer for scanning device ID data
  1336. * @count: input size
  1337. *
  1338. * Adds a new dynamic hid device ID to this driver,
  1339. * and causes the driver to probe for all devices again.
  1340. */
  1341. static ssize_t store_new_id(struct device_driver *drv, const char *buf,
  1342. size_t count)
  1343. {
  1344. struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
  1345. struct hid_dynid *dynid;
  1346. __u32 bus, vendor, product;
  1347. unsigned long driver_data = 0;
  1348. int ret;
  1349. ret = sscanf(buf, "%x %x %x %lx",
  1350. &bus, &vendor, &product, &driver_data);
  1351. if (ret < 3)
  1352. return -EINVAL;
  1353. dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
  1354. if (!dynid)
  1355. return -ENOMEM;
  1356. dynid->id.bus = bus;
  1357. dynid->id.vendor = vendor;
  1358. dynid->id.product = product;
  1359. dynid->id.driver_data = driver_data;
  1360. spin_lock(&hdrv->dyn_lock);
  1361. list_add_tail(&dynid->list, &hdrv->dyn_list);
  1362. spin_unlock(&hdrv->dyn_lock);
  1363. ret = 0;
  1364. if (get_driver(&hdrv->driver)) {
  1365. ret = driver_attach(&hdrv->driver);
  1366. put_driver(&hdrv->driver);
  1367. }
  1368. return ret ? : count;
  1369. }
  1370. static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
  1371. static void hid_free_dynids(struct hid_driver *hdrv)
  1372. {
  1373. struct hid_dynid *dynid, *n;
  1374. spin_lock(&hdrv->dyn_lock);
  1375. list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) {
  1376. list_del(&dynid->list);
  1377. kfree(dynid);
  1378. }
  1379. spin_unlock(&hdrv->dyn_lock);
  1380. }
  1381. static const struct hid_device_id *hid_match_device(struct hid_device *hdev,
  1382. struct hid_driver *hdrv)
  1383. {
  1384. struct hid_dynid *dynid;
  1385. spin_lock(&hdrv->dyn_lock);
  1386. list_for_each_entry(dynid, &hdrv->dyn_list, list) {
  1387. if (hid_match_one_id(hdev, &dynid->id)) {
  1388. spin_unlock(&hdrv->dyn_lock);
  1389. return &dynid->id;
  1390. }
  1391. }
  1392. spin_unlock(&hdrv->dyn_lock);
  1393. return hid_match_id(hdev, hdrv->id_table);
  1394. }
  1395. static int hid_bus_match(struct device *dev, struct device_driver *drv)
  1396. {
  1397. struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
  1398. struct hid_device *hdev = container_of(dev, struct hid_device, dev);
  1399. if (!hid_match_device(hdev, hdrv))
  1400. return 0;
  1401. /* generic wants all that don't have specialized driver */
  1402. if (!strncmp(hdrv->name, "generic-", 8))
  1403. return !hid_match_id(hdev, hid_have_special_driver);
  1404. return 1;
  1405. }
  1406. static int hid_device_probe(struct device *dev)
  1407. {
  1408. struct hid_driver *hdrv = container_of(dev->driver,
  1409. struct hid_driver, driver);
  1410. struct hid_device *hdev = container_of(dev, struct hid_device, dev);
  1411. const struct hid_device_id *id;
  1412. int ret = 0;
  1413. if (down_interruptible(&hdev->driver_lock))
  1414. return -EINTR;
  1415. if (!hdev->driver) {
  1416. id = hid_match_device(hdev, hdrv);
  1417. if (id == NULL) {
  1418. ret = -ENODEV;
  1419. goto unlock;
  1420. }
  1421. hdev->driver = hdrv;
  1422. if (hdrv->probe) {
  1423. ret = hdrv->probe(hdev, id);
  1424. } else { /* default probe */
  1425. ret = hid_parse(hdev);
  1426. if (!ret)
  1427. ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  1428. }
  1429. if (ret)
  1430. hdev->driver = NULL;
  1431. }
  1432. unlock:
  1433. up(&hdev->driver_lock);
  1434. return ret;
  1435. }
  1436. static int hid_device_remove(struct device *dev)
  1437. {
  1438. struct hid_device *hdev = container_of(dev, struct hid_device, dev);
  1439. struct hid_driver *hdrv;
  1440. if (down_interruptible(&hdev->driver_lock))
  1441. return -EINTR;
  1442. hdrv = hdev->driver;
  1443. if (hdrv) {
  1444. if (hdrv->remove)
  1445. hdrv->remove(hdev);
  1446. else /* default remove */
  1447. hid_hw_stop(hdev);
  1448. hdev->driver = NULL;
  1449. }
  1450. up(&hdev->driver_lock);
  1451. return 0;
  1452. }
  1453. static int hid_uevent(struct device *dev, struct kobj_uevent_env *env)
  1454. {
  1455. struct hid_device *hdev = container_of(dev, struct hid_device, dev);
  1456. if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X",
  1457. hdev->bus, hdev->vendor, hdev->product))
  1458. return -ENOMEM;
  1459. if (add_uevent_var(env, "HID_NAME=%s", hdev->name))
  1460. return -ENOMEM;
  1461. if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys))
  1462. return -ENOMEM;
  1463. if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq))
  1464. return -ENOMEM;
  1465. if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X",
  1466. hdev->bus, hdev->vendor, hdev->product))
  1467. return -ENOMEM;
  1468. return 0;
  1469. }
  1470. static struct bus_type hid_bus_type = {
  1471. .name = "hid",
  1472. .match = hid_bus_match,
  1473. .probe = hid_device_probe,
  1474. .remove = hid_device_remove,
  1475. .uevent = hid_uevent,
  1476. };
  1477. /* a list of devices that shouldn't be handled by HID core at all */
  1478. static const struct hid_device_id hid_ignore_list[] = {
  1479. { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) },
  1480. { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) },
  1481. { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) },
  1482. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) },
  1483. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) },
  1484. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) },
  1485. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) },
  1486. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) },
  1487. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) },
  1488. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
  1489. { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
  1490. { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
  1491. { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)},
  1492. { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)},
  1493. { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },
  1494. { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) },
  1495. { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) },
  1496. { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) },
  1497. { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) },
  1498. { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) },
  1499. { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) },
  1500. { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) },
  1501. { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
  1502. { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
  1503. { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) },
  1504. { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
  1505. { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) },
  1506. { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) },
  1507. { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) },
  1508. { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) },
  1509. { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) },
  1510. { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) },
  1511. { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) },
  1512. { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) },
  1513. { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) },
  1514. { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) },
  1515. { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) },
  1516. { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) },
  1517. { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) },
  1518. { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) },
  1519. { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) },
  1520. { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) },
  1521. { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) },
  1522. { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) },
  1523. { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) },
  1524. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) },
  1525. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) },
  1526. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) },
  1527. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) },
  1528. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) },
  1529. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) },
  1530. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) },
  1531. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) },
  1532. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) },
  1533. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) },
  1534. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) },
  1535. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) },
  1536. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) },
  1537. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) },
  1538. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) },
  1539. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) },
  1540. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) },
  1541. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) },
  1542. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) },
  1543. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) },
  1544. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) },
  1545. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) },
  1546. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) },
  1547. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) },
  1548. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) },
  1549. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) },
  1550. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) },
  1551. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) },
  1552. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) },
  1553. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) },
  1554. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) },
  1555. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) },
  1556. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) },
  1557. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) },
  1558. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) },
  1559. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) },
  1560. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) },
  1561. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) },
  1562. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) },
  1563. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) },
  1564. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) },
  1565. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) },
  1566. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) },
  1567. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) },
  1568. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) },
  1569. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
  1570. { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
  1571. { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
  1572. { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) },
  1573. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
  1574. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) },
  1575. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) },
  1576. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) },
  1577. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) },
  1578. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) },
  1579. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) },
  1580. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) },
  1581. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) },
  1582. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) },
  1583. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) },
  1584. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) },
  1585. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) },
  1586. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) },
  1587. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) },
  1588. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
  1589. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) },
  1590. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) },
  1591. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) },
  1592. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) },
  1593. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) },
  1594. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) },
  1595. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) },
  1596. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) },
  1597. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) },
  1598. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) },
  1599. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) },
  1600. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) },
  1601. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) },
  1602. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) },
  1603. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) },
  1604. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) },
  1605. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) },
  1606. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) },
  1607. { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) },
  1608. { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) },
  1609. { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) },
  1610. { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) },
  1611. { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) },
  1612. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) },
  1613. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) },
  1614. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) },
  1615. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) },
  1616. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) },
  1617. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) },
  1618. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) },
  1619. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) },
  1620. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) },
  1621. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) },
  1622. { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) },
  1623. { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) },
  1624. { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
  1625. { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
  1626. { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) },
  1627. { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
  1628. { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
  1629. { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
  1630. { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
  1631. { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
  1632. { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
  1633. { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) },
  1634. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) },
  1635. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) },
  1636. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) },
  1637. { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
  1638. { }
  1639. };
  1640. /**
  1641. * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer
  1642. *
  1643. * There are composite devices for which we want to ignore only a certain
  1644. * interface. This is a list of devices for which only the mouse interface will
  1645. * be ignored. This allows a dedicated driver to take care of the interface.
  1646. */
  1647. static const struct hid_device_id hid_mouse_ignore_list[] = {
  1648. /* appletouch driver */
  1649. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
  1650. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
  1651. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
  1652. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) },
  1653. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) },
  1654. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) },
  1655. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) },
  1656. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) },
  1657. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) },
  1658. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) },
  1659. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) },
  1660. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) },
  1661. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) },
  1662. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) },
  1663. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) },
  1664. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) },
  1665. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) },
  1666. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
  1667. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
  1668. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
  1669. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
  1670. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
  1671. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
  1672. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) },
  1673. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) },
  1674. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) },
  1675. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) },
  1676. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) },
  1677. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) },
  1678. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
  1679. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
  1680. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
  1681. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
  1682. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
  1683. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
  1684. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) },
  1685. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) },
  1686. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) },
  1687. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
  1688. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
  1689. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
  1690. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
  1691. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
  1692. { }
  1693. };
  1694. static bool hid_ignore(struct hid_device *hdev)
  1695. {
  1696. switch (hdev->vendor) {
  1697. case USB_VENDOR_ID_CODEMERCS:
  1698. /* ignore all Code Mercenaries IOWarrior devices */
  1699. if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST &&
  1700. hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST)
  1701. return true;
  1702. break;
  1703. case USB_VENDOR_ID_LOGITECH:
  1704. if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST &&
  1705. hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST)
  1706. return true;
  1707. break;
  1708. case USB_VENDOR_ID_SOUNDGRAPH:
  1709. if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST &&
  1710. hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST)
  1711. return true;
  1712. break;
  1713. case USB_VENDOR_ID_HANWANG:
  1714. if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST &&
  1715. hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST)
  1716. return true;
  1717. break;
  1718. case USB_VENDOR_ID_JESS:
  1719. if (hdev->product == USB_DEVICE_ID_JESS_YUREX &&
  1720. hdev->type == HID_TYPE_USBNONE)
  1721. return true;
  1722. break;
  1723. }
  1724. if (hdev->type == HID_TYPE_USBMOUSE &&
  1725. hid_match_id(hdev, hid_mouse_ignore_list))
  1726. return true;
  1727. return !!hid_match_id(hdev, hid_ignore_list);
  1728. }
  1729. int hid_add_device(struct hid_device *hdev)
  1730. {
  1731. static atomic_t id = ATOMIC_INIT(0);
  1732. int ret;
  1733. if (WARN_ON(hdev->status & HID_STAT_ADDED))
  1734. return -EBUSY;
  1735. /* we need to kill them here, otherwise they will stay allocated to
  1736. * wait for coming driver */
  1737. if (!(hdev->quirks & HID_QUIRK_NO_IGNORE)
  1738. && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE)))
  1739. return -ENODEV;
  1740. /* XXX hack, any other cleaner solution after the driver core
  1741. * is converted to allow more than 20 bytes as the device name? */
  1742. dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
  1743. hdev->vendor, hdev->product, atomic_inc_return(&id));
  1744. hid_debug_register(hdev, dev_name(&hdev->dev));
  1745. ret = device_add(&hdev->dev);
  1746. if (!ret)
  1747. hdev->status |= HID_STAT_ADDED;
  1748. else
  1749. hid_debug_unregister(hdev);
  1750. return ret;
  1751. }
  1752. EXPORT_SYMBOL_GPL(hid_add_device);
  1753. /**
  1754. * hid_allocate_device - allocate new hid device descriptor
  1755. *
  1756. * Allocate and initialize hid device, so that hid_destroy_device might be
  1757. * used to free it.
  1758. *
  1759. * New hid_device pointer is returned on success, otherwise ERR_PTR encoded
  1760. * error value.
  1761. */
  1762. struct hid_device *hid_allocate_device(void)
  1763. {
  1764. struct hid_device *hdev;
  1765. unsigned int i;
  1766. int ret = -ENOMEM;
  1767. hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
  1768. if (hdev == NULL)
  1769. return ERR_PTR(ret);
  1770. device_initialize(&hdev->dev);
  1771. hdev->dev.release = hid_device_release;
  1772. hdev->dev.bus = &hid_bus_type;
  1773. hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS,
  1774. sizeof(struct hid_collection), GFP_KERNEL);
  1775. if (hdev->collection == NULL)
  1776. goto err;
  1777. hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
  1778. for (i = 0; i < HID_REPORT_TYPES; i++)
  1779. INIT_LIST_HEAD(&hdev->report_enum[i].report_list);
  1780. init_waitqueue_head(&hdev->debug_wait);
  1781. INIT_LIST_HEAD(&hdev->debug_list);
  1782. sema_init(&hdev->driver_lock, 1);
  1783. return hdev;
  1784. err:
  1785. put_device(&hdev->dev);
  1786. return ERR_PTR(ret);
  1787. }
  1788. EXPORT_SYMBOL_GPL(hid_allocate_device);
  1789. static void hid_remove_device(struct hid_device *hdev)
  1790. {
  1791. if (hdev->status & HID_STAT_ADDED) {
  1792. device_del(&hdev->dev);
  1793. hid_debug_unregister(hdev);
  1794. hdev->status &= ~HID_STAT_ADDED;
  1795. }
  1796. }
  1797. /**
  1798. * hid_destroy_device - free previously allocated device
  1799. *
  1800. * @hdev: hid device
  1801. *
  1802. * If you allocate hid_device through hid_allocate_device, you should ever
  1803. * free by this function.
  1804. */
  1805. void hid_destroy_device(struct hid_device *hdev)
  1806. {
  1807. hid_remove_device(hdev);
  1808. put_device(&hdev->dev);
  1809. }
  1810. EXPORT_SYMBOL_GPL(hid_destroy_device);
  1811. int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
  1812. const char *mod_name)
  1813. {
  1814. int ret;
  1815. hdrv->driver.name = hdrv->name;
  1816. hdrv->driver.bus = &hid_bus_type;
  1817. hdrv->driver.owner = owner;
  1818. hdrv->driver.mod_name = mod_name;
  1819. INIT_LIST_HEAD(&hdrv->dyn_list);
  1820. spin_lock_init(&hdrv->dyn_lock);
  1821. ret = driver_register(&hdrv->driver);
  1822. if (ret)
  1823. return ret;
  1824. ret = driver_create_file(&hdrv->driver, &driver_attr_new_id);
  1825. if (ret)
  1826. driver_unregister(&hdrv->driver);
  1827. return ret;
  1828. }
  1829. EXPORT_SYMBOL_GPL(__hid_register_driver);
  1830. void hid_unregister_driver(struct hid_driver *hdrv)
  1831. {
  1832. driver_remove_file(&hdrv->driver, &driver_attr_new_id);
  1833. driver_unregister(&hdrv->driver);
  1834. hid_free_dynids(hdrv);
  1835. }
  1836. EXPORT_SYMBOL_GPL(hid_unregister_driver);
  1837. int hid_check_keys_pressed(struct hid_device *hid)
  1838. {
  1839. struct hid_input *hidinput;
  1840. int i;
  1841. if (!(hid->claimed & HID_CLAIMED_INPUT))
  1842. return 0;
  1843. list_for_each_entry(hidinput, &hid->inputs, list) {
  1844. for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++)
  1845. if (hidinput->input->key[i])
  1846. return 1;
  1847. }
  1848. return 0;
  1849. }
  1850. EXPORT_SYMBOL_GPL(hid_check_keys_pressed);
  1851. static int __init hid_init(void)
  1852. {
  1853. int ret;
  1854. if (hid_debug)
  1855. pr_warn("hid_debug is now used solely for parser and driver debugging.\n"
  1856. "debugfs is now used for inspecting the device (report descriptor, reports)\n");
  1857. ret = bus_register(&hid_bus_type);
  1858. if (ret) {
  1859. pr_err("can't register hid bus\n");
  1860. goto err;
  1861. }
  1862. ret = hidraw_init();
  1863. if (ret)
  1864. goto err_bus;
  1865. hid_debug_init();
  1866. return 0;
  1867. err_bus:
  1868. bus_unregister(&hid_bus_type);
  1869. err:
  1870. return ret;
  1871. }
  1872. static void __exit hid_exit(void)
  1873. {
  1874. hid_debug_exit();
  1875. hidraw_exit();
  1876. bus_unregister(&hid_bus_type);
  1877. }
  1878. module_init(hid_init);
  1879. module_exit(hid_exit);
  1880. MODULE_AUTHOR("Andreas Gal");
  1881. MODULE_AUTHOR("Vojtech Pavlik");
  1882. MODULE_AUTHOR("Jiri Kosina");
  1883. MODULE_LICENSE(DRIVER_LICENSE);