hid.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  1. /*
  2. * Copyright (c) 1999 Andreas Gal
  3. * Copyright (c) 2000-2001 Vojtech Pavlik
  4. * Copyright (c) 2006-2007 Jiri Kosina
  5. */
  6. /*
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. * Should you need to contact me, the author, you can do so either by
  22. * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
  23. * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
  24. */
  25. #ifndef __HID_H
  26. #define __HID_H
  27. #include <linux/types.h>
  28. #include <linux/slab.h>
  29. #include <linux/list.h>
  30. #include <linux/mod_devicetable.h> /* hid_device_id */
  31. #include <linux/timer.h>
  32. #include <linux/workqueue.h>
  33. #include <linux/input.h>
  34. #include <linux/semaphore.h>
  35. #include <linux/mutex.h>
  36. #include <linux/power_supply.h>
  37. #include <uapi/linux/hid.h>
  38. /*
  39. * We parse each description item into this structure. Short items data
  40. * values are expanded to 32-bit signed int, long items contain a pointer
  41. * into the data area.
  42. */
  43. struct hid_item {
  44. unsigned format;
  45. __u8 size;
  46. __u8 type;
  47. __u8 tag;
  48. union {
  49. __u8 u8;
  50. __s8 s8;
  51. __u16 u16;
  52. __s16 s16;
  53. __u32 u32;
  54. __s32 s32;
  55. __u8 *longdata;
  56. } data;
  57. };
  58. /*
  59. * HID report item format
  60. */
  61. #define HID_ITEM_FORMAT_SHORT 0
  62. #define HID_ITEM_FORMAT_LONG 1
  63. /*
  64. * Special tag indicating long items
  65. */
  66. #define HID_ITEM_TAG_LONG 15
  67. /*
  68. * HID report descriptor item type (prefix bit 2,3)
  69. */
  70. #define HID_ITEM_TYPE_MAIN 0
  71. #define HID_ITEM_TYPE_GLOBAL 1
  72. #define HID_ITEM_TYPE_LOCAL 2
  73. #define HID_ITEM_TYPE_RESERVED 3
  74. /*
  75. * HID report descriptor main item tags
  76. */
  77. #define HID_MAIN_ITEM_TAG_INPUT 8
  78. #define HID_MAIN_ITEM_TAG_OUTPUT 9
  79. #define HID_MAIN_ITEM_TAG_FEATURE 11
  80. #define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10
  81. #define HID_MAIN_ITEM_TAG_END_COLLECTION 12
  82. /*
  83. * HID report descriptor main item contents
  84. */
  85. #define HID_MAIN_ITEM_CONSTANT 0x001
  86. #define HID_MAIN_ITEM_VARIABLE 0x002
  87. #define HID_MAIN_ITEM_RELATIVE 0x004
  88. #define HID_MAIN_ITEM_WRAP 0x008
  89. #define HID_MAIN_ITEM_NONLINEAR 0x010
  90. #define HID_MAIN_ITEM_NO_PREFERRED 0x020
  91. #define HID_MAIN_ITEM_NULL_STATE 0x040
  92. #define HID_MAIN_ITEM_VOLATILE 0x080
  93. #define HID_MAIN_ITEM_BUFFERED_BYTE 0x100
  94. /*
  95. * HID report descriptor collection item types
  96. */
  97. #define HID_COLLECTION_PHYSICAL 0
  98. #define HID_COLLECTION_APPLICATION 1
  99. #define HID_COLLECTION_LOGICAL 2
  100. /*
  101. * HID report descriptor global item tags
  102. */
  103. #define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0
  104. #define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1
  105. #define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2
  106. #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3
  107. #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4
  108. #define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5
  109. #define HID_GLOBAL_ITEM_TAG_UNIT 6
  110. #define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7
  111. #define HID_GLOBAL_ITEM_TAG_REPORT_ID 8
  112. #define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9
  113. #define HID_GLOBAL_ITEM_TAG_PUSH 10
  114. #define HID_GLOBAL_ITEM_TAG_POP 11
  115. /*
  116. * HID report descriptor local item tags
  117. */
  118. #define HID_LOCAL_ITEM_TAG_USAGE 0
  119. #define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1
  120. #define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2
  121. #define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3
  122. #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4
  123. #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5
  124. #define HID_LOCAL_ITEM_TAG_STRING_INDEX 7
  125. #define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8
  126. #define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9
  127. #define HID_LOCAL_ITEM_TAG_DELIMITER 10
  128. /*
  129. * HID usage tables
  130. */
  131. #define HID_USAGE_PAGE 0xffff0000
  132. #define HID_UP_UNDEFINED 0x00000000
  133. #define HID_UP_GENDESK 0x00010000
  134. #define HID_UP_SIMULATION 0x00020000
  135. #define HID_UP_GENDEVCTRLS 0x00060000
  136. #define HID_UP_KEYBOARD 0x00070000
  137. #define HID_UP_LED 0x00080000
  138. #define HID_UP_BUTTON 0x00090000
  139. #define HID_UP_ORDINAL 0x000a0000
  140. #define HID_UP_TELEPHONY 0x000b0000
  141. #define HID_UP_CONSUMER 0x000c0000
  142. #define HID_UP_DIGITIZER 0x000d0000
  143. #define HID_UP_PID 0x000f0000
  144. #define HID_UP_HPVENDOR 0xff7f0000
  145. #define HID_UP_HPVENDOR2 0xff010000
  146. #define HID_UP_MSVENDOR 0xff000000
  147. #define HID_UP_CUSTOM 0x00ff0000
  148. #define HID_UP_LOGIVENDOR 0xffbc0000
  149. #define HID_UP_LOGIVENDOR2 0xff090000
  150. #define HID_UP_LOGIVENDOR3 0xff430000
  151. #define HID_UP_LNVENDOR 0xffa00000
  152. #define HID_UP_SENSOR 0x00200000
  153. #define HID_UP_ASUSVENDOR 0xff310000
  154. #define HID_USAGE 0x0000ffff
  155. #define HID_GD_POINTER 0x00010001
  156. #define HID_GD_MOUSE 0x00010002
  157. #define HID_GD_JOYSTICK 0x00010004
  158. #define HID_GD_GAMEPAD 0x00010005
  159. #define HID_GD_KEYBOARD 0x00010006
  160. #define HID_GD_KEYPAD 0x00010007
  161. #define HID_GD_MULTIAXIS 0x00010008
  162. /*
  163. * Microsoft Win8 Wireless Radio Controls extensions CA, see:
  164. * http://www.usb.org/developers/hidpage/HUTRR40RadioHIDUsagesFinal.pdf
  165. */
  166. #define HID_GD_WIRELESS_RADIO_CTLS 0x0001000c
  167. #define HID_GD_X 0x00010030
  168. #define HID_GD_Y 0x00010031
  169. #define HID_GD_Z 0x00010032
  170. #define HID_GD_RX 0x00010033
  171. #define HID_GD_RY 0x00010034
  172. #define HID_GD_RZ 0x00010035
  173. #define HID_GD_SLIDER 0x00010036
  174. #define HID_GD_DIAL 0x00010037
  175. #define HID_GD_WHEEL 0x00010038
  176. #define HID_GD_HATSWITCH 0x00010039
  177. #define HID_GD_BUFFER 0x0001003a
  178. #define HID_GD_BYTECOUNT 0x0001003b
  179. #define HID_GD_MOTION 0x0001003c
  180. #define HID_GD_START 0x0001003d
  181. #define HID_GD_SELECT 0x0001003e
  182. #define HID_GD_VX 0x00010040
  183. #define HID_GD_VY 0x00010041
  184. #define HID_GD_VZ 0x00010042
  185. #define HID_GD_VBRX 0x00010043
  186. #define HID_GD_VBRY 0x00010044
  187. #define HID_GD_VBRZ 0x00010045
  188. #define HID_GD_VNO 0x00010046
  189. #define HID_GD_FEATURE 0x00010047
  190. #define HID_GD_SYSTEM_CONTROL 0x00010080
  191. #define HID_GD_UP 0x00010090
  192. #define HID_GD_DOWN 0x00010091
  193. #define HID_GD_RIGHT 0x00010092
  194. #define HID_GD_LEFT 0x00010093
  195. /* Microsoft Win8 Wireless Radio Controls CA usage codes */
  196. #define HID_GD_RFKILL_BTN 0x000100c6
  197. #define HID_GD_RFKILL_LED 0x000100c7
  198. #define HID_GD_RFKILL_SWITCH 0x000100c8
  199. #define HID_DC_BATTERYSTRENGTH 0x00060020
  200. #define HID_CP_CONSUMER_CONTROL 0x000c0001
  201. #define HID_DG_DIGITIZER 0x000d0001
  202. #define HID_DG_PEN 0x000d0002
  203. #define HID_DG_LIGHTPEN 0x000d0003
  204. #define HID_DG_TOUCHSCREEN 0x000d0004
  205. #define HID_DG_TOUCHPAD 0x000d0005
  206. #define HID_DG_STYLUS 0x000d0020
  207. #define HID_DG_PUCK 0x000d0021
  208. #define HID_DG_FINGER 0x000d0022
  209. #define HID_DG_TIPPRESSURE 0x000d0030
  210. #define HID_DG_BARRELPRESSURE 0x000d0031
  211. #define HID_DG_INRANGE 0x000d0032
  212. #define HID_DG_TOUCH 0x000d0033
  213. #define HID_DG_UNTOUCH 0x000d0034
  214. #define HID_DG_TAP 0x000d0035
  215. #define HID_DG_TABLETFUNCTIONKEY 0x000d0039
  216. #define HID_DG_PROGRAMCHANGEKEY 0x000d003a
  217. #define HID_DG_BATTERYSTRENGTH 0x000d003b
  218. #define HID_DG_INVERT 0x000d003c
  219. #define HID_DG_TILT_X 0x000d003d
  220. #define HID_DG_TILT_Y 0x000d003e
  221. #define HID_DG_TWIST 0x000d0041
  222. #define HID_DG_TIPSWITCH 0x000d0042
  223. #define HID_DG_TIPSWITCH2 0x000d0043
  224. #define HID_DG_BARRELSWITCH 0x000d0044
  225. #define HID_DG_ERASER 0x000d0045
  226. #define HID_DG_TABLETPICK 0x000d0046
  227. #define HID_CP_CONSUMERCONTROL 0x000c0001
  228. #define HID_CP_NUMERICKEYPAD 0x000c0002
  229. #define HID_CP_PROGRAMMABLEBUTTONS 0x000c0003
  230. #define HID_CP_MICROPHONE 0x000c0004
  231. #define HID_CP_HEADPHONE 0x000c0005
  232. #define HID_CP_GRAPHICEQUALIZER 0x000c0006
  233. #define HID_CP_FUNCTIONBUTTONS 0x000c0036
  234. #define HID_CP_SELECTION 0x000c0080
  235. #define HID_CP_MEDIASELECTION 0x000c0087
  236. #define HID_CP_SELECTDISC 0x000c00ba
  237. #define HID_CP_PLAYBACKSPEED 0x000c00f1
  238. #define HID_CP_PROXIMITY 0x000c0109
  239. #define HID_CP_SPEAKERSYSTEM 0x000c0160
  240. #define HID_CP_CHANNELLEFT 0x000c0161
  241. #define HID_CP_CHANNELRIGHT 0x000c0162
  242. #define HID_CP_CHANNELCENTER 0x000c0163
  243. #define HID_CP_CHANNELFRONT 0x000c0164
  244. #define HID_CP_CHANNELCENTERFRONT 0x000c0165
  245. #define HID_CP_CHANNELSIDE 0x000c0166
  246. #define HID_CP_CHANNELSURROUND 0x000c0167
  247. #define HID_CP_CHANNELLOWFREQUENCYENHANCEMENT 0x000c0168
  248. #define HID_CP_CHANNELTOP 0x000c0169
  249. #define HID_CP_CHANNELUNKNOWN 0x000c016a
  250. #define HID_CP_APPLICATIONLAUNCHBUTTONS 0x000c0180
  251. #define HID_CP_GENERICGUIAPPLICATIONCONTROLS 0x000c0200
  252. #define HID_DG_DEVICECONFIG 0x000d000e
  253. #define HID_DG_DEVICESETTINGS 0x000d0023
  254. #define HID_DG_CONFIDENCE 0x000d0047
  255. #define HID_DG_WIDTH 0x000d0048
  256. #define HID_DG_HEIGHT 0x000d0049
  257. #define HID_DG_CONTACTID 0x000d0051
  258. #define HID_DG_INPUTMODE 0x000d0052
  259. #define HID_DG_DEVICEINDEX 0x000d0053
  260. #define HID_DG_CONTACTCOUNT 0x000d0054
  261. #define HID_DG_CONTACTMAX 0x000d0055
  262. #define HID_DG_SCANTIME 0x000d0056
  263. #define HID_DG_BUTTONTYPE 0x000d0059
  264. #define HID_DG_BARRELSWITCH2 0x000d005a
  265. #define HID_DG_TOOLSERIALNUMBER 0x000d005b
  266. #define HID_VD_ASUS_CUSTOM_MEDIA_KEYS 0xff310076
  267. /*
  268. * HID report types --- Ouch! HID spec says 1 2 3!
  269. */
  270. #define HID_INPUT_REPORT 0
  271. #define HID_OUTPUT_REPORT 1
  272. #define HID_FEATURE_REPORT 2
  273. #define HID_REPORT_TYPES 3
  274. /*
  275. * HID connect requests
  276. */
  277. #define HID_CONNECT_HIDINPUT 0x01
  278. #define HID_CONNECT_HIDINPUT_FORCE 0x02
  279. #define HID_CONNECT_HIDRAW 0x04
  280. #define HID_CONNECT_HIDDEV 0x08
  281. #define HID_CONNECT_HIDDEV_FORCE 0x10
  282. #define HID_CONNECT_FF 0x20
  283. #define HID_CONNECT_DRIVER 0x40
  284. #define HID_CONNECT_DEFAULT (HID_CONNECT_HIDINPUT|HID_CONNECT_HIDRAW| \
  285. HID_CONNECT_HIDDEV|HID_CONNECT_FF)
  286. /*
  287. * HID device quirks.
  288. */
  289. /*
  290. * Increase this if you need to configure more HID quirks at module load time
  291. */
  292. #define MAX_USBHID_BOOT_QUIRKS 4
  293. #define HID_QUIRK_INVERT 0x00000001
  294. #define HID_QUIRK_NOTOUCH 0x00000002
  295. #define HID_QUIRK_IGNORE 0x00000004
  296. #define HID_QUIRK_NOGET 0x00000008
  297. #define HID_QUIRK_HIDDEV_FORCE 0x00000010
  298. #define HID_QUIRK_BADPAD 0x00000020
  299. #define HID_QUIRK_MULTI_INPUT 0x00000040
  300. #define HID_QUIRK_HIDINPUT_FORCE 0x00000080
  301. #define HID_QUIRK_NO_EMPTY_INPUT 0x00000100
  302. /* 0x00000200 reserved for backward compatibility, was NO_INIT_INPUT_REPORTS */
  303. #define HID_QUIRK_ALWAYS_POLL 0x00000400
  304. #define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000
  305. #define HID_QUIRK_SKIP_OUTPUT_REPORT_ID 0x00020000
  306. #define HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP 0x00040000
  307. #define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000
  308. #define HID_QUIRK_NO_INIT_REPORTS 0x20000000
  309. #define HID_QUIRK_NO_IGNORE 0x40000000
  310. #define HID_QUIRK_NO_INPUT_SYNC 0x80000000
  311. /*
  312. * HID device groups
  313. *
  314. * Note: HID_GROUP_ANY is declared in linux/mod_devicetable.h
  315. * and has a value of 0x0000
  316. */
  317. #define HID_GROUP_GENERIC 0x0001
  318. #define HID_GROUP_MULTITOUCH 0x0002
  319. #define HID_GROUP_SENSOR_HUB 0x0003
  320. #define HID_GROUP_MULTITOUCH_WIN_8 0x0004
  321. /*
  322. * Vendor specific HID device groups
  323. */
  324. #define HID_GROUP_RMI 0x0100
  325. #define HID_GROUP_WACOM 0x0101
  326. #define HID_GROUP_LOGITECH_DJ_DEVICE 0x0102
  327. /*
  328. * HID protocol status
  329. */
  330. #define HID_REPORT_PROTOCOL 1
  331. #define HID_BOOT_PROTOCOL 0
  332. /*
  333. * This is the global environment of the parser. This information is
  334. * persistent for main-items. The global environment can be saved and
  335. * restored with PUSH/POP statements.
  336. */
  337. struct hid_global {
  338. unsigned usage_page;
  339. __s32 logical_minimum;
  340. __s32 logical_maximum;
  341. __s32 physical_minimum;
  342. __s32 physical_maximum;
  343. __s32 unit_exponent;
  344. unsigned unit;
  345. unsigned report_id;
  346. unsigned report_size;
  347. unsigned report_count;
  348. };
  349. /*
  350. * This is the local environment. It is persistent up the next main-item.
  351. */
  352. #define HID_MAX_USAGES 12288
  353. #define HID_DEFAULT_NUM_COLLECTIONS 16
  354. struct hid_local {
  355. unsigned usage[HID_MAX_USAGES]; /* usage array */
  356. unsigned collection_index[HID_MAX_USAGES]; /* collection index array */
  357. unsigned usage_index;
  358. unsigned usage_minimum;
  359. unsigned delimiter_depth;
  360. unsigned delimiter_branch;
  361. };
  362. /*
  363. * This is the collection stack. We climb up the stack to determine
  364. * application and function of each field.
  365. */
  366. struct hid_collection {
  367. unsigned type;
  368. unsigned usage;
  369. unsigned level;
  370. };
  371. struct hid_usage {
  372. unsigned hid; /* hid usage code */
  373. unsigned collection_index; /* index into collection array */
  374. unsigned usage_index; /* index into usage array */
  375. /* hidinput data */
  376. __u16 code; /* input driver code */
  377. __u8 type; /* input driver type */
  378. __s8 hat_min; /* hat switch fun */
  379. __s8 hat_max; /* ditto */
  380. __s8 hat_dir; /* ditto */
  381. };
  382. struct hid_input;
  383. struct hid_field {
  384. unsigned physical; /* physical usage for this field */
  385. unsigned logical; /* logical usage for this field */
  386. unsigned application; /* application usage for this field */
  387. struct hid_usage *usage; /* usage table for this function */
  388. unsigned maxusage; /* maximum usage index */
  389. unsigned flags; /* main-item flags (i.e. volatile,array,constant) */
  390. unsigned report_offset; /* bit offset in the report */
  391. unsigned report_size; /* size of this field in the report */
  392. unsigned report_count; /* number of this field in the report */
  393. unsigned report_type; /* (input,output,feature) */
  394. __s32 *value; /* last known value(s) */
  395. __s32 logical_minimum;
  396. __s32 logical_maximum;
  397. __s32 physical_minimum;
  398. __s32 physical_maximum;
  399. __s32 unit_exponent;
  400. unsigned unit;
  401. struct hid_report *report; /* associated report */
  402. unsigned index; /* index into report->field[] */
  403. /* hidinput data */
  404. struct hid_input *hidinput; /* associated input structure */
  405. __u16 dpad; /* dpad input code */
  406. };
  407. #define HID_MAX_FIELDS 256
  408. struct hid_report {
  409. struct list_head list;
  410. unsigned id; /* id of this report */
  411. unsigned type; /* report type */
  412. struct hid_field *field[HID_MAX_FIELDS]; /* fields of the report */
  413. unsigned maxfield; /* maximum valid field index */
  414. unsigned size; /* size of the report (bits) */
  415. struct hid_device *device; /* associated device */
  416. };
  417. #define HID_MAX_IDS 256
  418. struct hid_report_enum {
  419. unsigned numbered;
  420. struct list_head report_list;
  421. struct hid_report *report_id_hash[HID_MAX_IDS];
  422. };
  423. #define HID_MIN_BUFFER_SIZE 64 /* make sure there is at least a packet size of space */
  424. #define HID_MAX_BUFFER_SIZE 4096 /* 4kb */
  425. #define HID_CONTROL_FIFO_SIZE 256 /* to init devices with >100 reports */
  426. #define HID_OUTPUT_FIFO_SIZE 64
  427. struct hid_control_fifo {
  428. unsigned char dir;
  429. struct hid_report *report;
  430. char *raw_report;
  431. };
  432. struct hid_output_fifo {
  433. struct hid_report *report;
  434. char *raw_report;
  435. };
  436. #define HID_CLAIMED_INPUT 1
  437. #define HID_CLAIMED_HIDDEV 2
  438. #define HID_CLAIMED_HIDRAW 4
  439. #define HID_CLAIMED_DRIVER 8
  440. #define HID_STAT_ADDED 1
  441. #define HID_STAT_PARSED 2
  442. struct hid_input {
  443. struct list_head list;
  444. struct hid_report *report;
  445. struct input_dev *input;
  446. bool registered;
  447. };
  448. enum hid_type {
  449. HID_TYPE_OTHER = 0,
  450. HID_TYPE_USBMOUSE,
  451. HID_TYPE_USBNONE
  452. };
  453. struct hid_driver;
  454. struct hid_ll_driver;
  455. struct hid_device { /* device report descriptor */
  456. __u8 *dev_rdesc;
  457. unsigned dev_rsize;
  458. __u8 *rdesc;
  459. unsigned rsize;
  460. struct hid_collection *collection; /* List of HID collections */
  461. unsigned collection_size; /* Number of allocated hid_collections */
  462. unsigned maxcollection; /* Number of parsed collections */
  463. unsigned maxapplication; /* Number of applications */
  464. __u16 bus; /* BUS ID */
  465. __u16 group; /* Report group */
  466. __u32 vendor; /* Vendor ID */
  467. __u32 product; /* Product ID */
  468. __u32 version; /* HID version */
  469. enum hid_type type; /* device type (mouse, kbd, ...) */
  470. unsigned country; /* HID country */
  471. struct hid_report_enum report_enum[HID_REPORT_TYPES];
  472. struct work_struct led_work; /* delayed LED worker */
  473. struct semaphore driver_input_lock; /* protects the current driver */
  474. struct device dev; /* device */
  475. struct hid_driver *driver;
  476. struct hid_ll_driver *ll_driver;
  477. struct mutex ll_open_lock;
  478. unsigned int ll_open_count;
  479. #ifdef CONFIG_HID_BATTERY_STRENGTH
  480. /*
  481. * Power supply information for HID devices which report
  482. * battery strength. power_supply was successfully registered if
  483. * battery is non-NULL.
  484. */
  485. struct power_supply *battery;
  486. __s32 battery_capacity;
  487. __s32 battery_min;
  488. __s32 battery_max;
  489. __s32 battery_report_type;
  490. __s32 battery_report_id;
  491. bool battery_reported;
  492. #endif
  493. unsigned int status; /* see STAT flags above */
  494. unsigned claimed; /* Claimed by hidinput, hiddev? */
  495. unsigned quirks; /* Various quirks the device can pull on us */
  496. bool io_started; /* If IO has started */
  497. struct list_head inputs; /* The list of inputs */
  498. void *hiddev; /* The hiddev structure */
  499. void *hidraw;
  500. char name[128]; /* Device name */
  501. char phys[64]; /* Device physical location */
  502. char uniq[64]; /* Device unique identifier (serial #) */
  503. void *driver_data;
  504. /* temporary hid_ff handling (until moved to the drivers) */
  505. int (*ff_init)(struct hid_device *);
  506. /* hiddev event handler */
  507. int (*hiddev_connect)(struct hid_device *, unsigned int);
  508. void (*hiddev_disconnect)(struct hid_device *);
  509. void (*hiddev_hid_event) (struct hid_device *, struct hid_field *field,
  510. struct hid_usage *, __s32);
  511. void (*hiddev_report_event) (struct hid_device *, struct hid_report *);
  512. /* debugging support via debugfs */
  513. unsigned short debug;
  514. struct dentry *debug_dir;
  515. struct dentry *debug_rdesc;
  516. struct dentry *debug_events;
  517. struct list_head debug_list;
  518. spinlock_t debug_list_lock;
  519. wait_queue_head_t debug_wait;
  520. };
  521. #define to_hid_device(pdev) \
  522. container_of(pdev, struct hid_device, dev)
  523. static inline void *hid_get_drvdata(struct hid_device *hdev)
  524. {
  525. return dev_get_drvdata(&hdev->dev);
  526. }
  527. static inline void hid_set_drvdata(struct hid_device *hdev, void *data)
  528. {
  529. dev_set_drvdata(&hdev->dev, data);
  530. }
  531. #define HID_GLOBAL_STACK_SIZE 4
  532. #define HID_COLLECTION_STACK_SIZE 4
  533. #define HID_SCAN_FLAG_MT_WIN_8 BIT(0)
  534. #define HID_SCAN_FLAG_VENDOR_SPECIFIC BIT(1)
  535. #define HID_SCAN_FLAG_GD_POINTER BIT(2)
  536. struct hid_parser {
  537. struct hid_global global;
  538. struct hid_global global_stack[HID_GLOBAL_STACK_SIZE];
  539. unsigned global_stack_ptr;
  540. struct hid_local local;
  541. unsigned collection_stack[HID_COLLECTION_STACK_SIZE];
  542. unsigned collection_stack_ptr;
  543. struct hid_device *device;
  544. unsigned scan_flags;
  545. };
  546. struct hid_class_descriptor {
  547. __u8 bDescriptorType;
  548. __le16 wDescriptorLength;
  549. } __attribute__ ((packed));
  550. struct hid_descriptor {
  551. __u8 bLength;
  552. __u8 bDescriptorType;
  553. __le16 bcdHID;
  554. __u8 bCountryCode;
  555. __u8 bNumDescriptors;
  556. struct hid_class_descriptor desc[1];
  557. } __attribute__ ((packed));
  558. #define HID_DEVICE(b, g, ven, prod) \
  559. .bus = (b), .group = (g), .vendor = (ven), .product = (prod)
  560. #define HID_USB_DEVICE(ven, prod) \
  561. .bus = BUS_USB, .vendor = (ven), .product = (prod)
  562. #define HID_BLUETOOTH_DEVICE(ven, prod) \
  563. .bus = BUS_BLUETOOTH, .vendor = (ven), .product = (prod)
  564. #define HID_I2C_DEVICE(ven, prod) \
  565. .bus = BUS_I2C, .vendor = (ven), .product = (prod)
  566. #define HID_REPORT_ID(rep) \
  567. .report_type = (rep)
  568. #define HID_USAGE_ID(uhid, utype, ucode) \
  569. .usage_hid = (uhid), .usage_type = (utype), .usage_code = (ucode)
  570. /* we don't want to catch types and codes equal to 0 */
  571. #define HID_TERMINATOR (HID_ANY_ID - 1)
  572. struct hid_report_id {
  573. __u32 report_type;
  574. };
  575. struct hid_usage_id {
  576. __u32 usage_hid;
  577. __u32 usage_type;
  578. __u32 usage_code;
  579. };
  580. /**
  581. * struct hid_driver
  582. * @name: driver name (e.g. "Footech_bar-wheel")
  583. * @id_table: which devices is this driver for (must be non-NULL for probe
  584. * to be called)
  585. * @dyn_list: list of dynamically added device ids
  586. * @dyn_lock: lock protecting @dyn_list
  587. * @probe: new device inserted
  588. * @remove: device removed (NULL if not a hot-plug capable driver)
  589. * @report_table: on which reports to call raw_event (NULL means all)
  590. * @raw_event: if report in report_table, this hook is called (NULL means nop)
  591. * @usage_table: on which events to call event (NULL means all)
  592. * @event: if usage in usage_table, this hook is called (NULL means nop)
  593. * @report: this hook is called after parsing a report (NULL means nop)
  594. * @report_fixup: called before report descriptor parsing (NULL means nop)
  595. * @input_mapping: invoked on input registering before mapping an usage
  596. * @input_mapped: invoked on input registering after mapping an usage
  597. * @input_configured: invoked just before the device is registered
  598. * @feature_mapping: invoked on feature registering
  599. * @suspend: invoked on suspend (NULL means nop)
  600. * @resume: invoked on resume if device was not reset (NULL means nop)
  601. * @reset_resume: invoked on resume if device was reset (NULL means nop)
  602. *
  603. * probe should return -errno on error, or 0 on success. During probe,
  604. * input will not be passed to raw_event unless hid_device_io_start is
  605. * called.
  606. *
  607. * raw_event and event should return 0 on no action performed, 1 when no
  608. * further processing should be done and negative on error
  609. *
  610. * input_mapping shall return a negative value to completely ignore this usage
  611. * (e.g. doubled or invalid usage), zero to continue with parsing of this
  612. * usage by generic code (no special handling needed) or positive to skip
  613. * generic parsing (needed special handling which was done in the hook already)
  614. * input_mapped shall return negative to inform the layer that this usage
  615. * should not be considered for further processing or zero to notify that
  616. * no processing was performed and should be done in a generic manner
  617. * Both these functions may be NULL which means the same behavior as returning
  618. * zero from them.
  619. */
  620. struct hid_driver {
  621. char *name;
  622. const struct hid_device_id *id_table;
  623. struct list_head dyn_list;
  624. spinlock_t dyn_lock;
  625. int (*probe)(struct hid_device *dev, const struct hid_device_id *id);
  626. void (*remove)(struct hid_device *dev);
  627. const struct hid_report_id *report_table;
  628. int (*raw_event)(struct hid_device *hdev, struct hid_report *report,
  629. u8 *data, int size);
  630. const struct hid_usage_id *usage_table;
  631. int (*event)(struct hid_device *hdev, struct hid_field *field,
  632. struct hid_usage *usage, __s32 value);
  633. void (*report)(struct hid_device *hdev, struct hid_report *report);
  634. __u8 *(*report_fixup)(struct hid_device *hdev, __u8 *buf,
  635. unsigned int *size);
  636. int (*input_mapping)(struct hid_device *hdev,
  637. struct hid_input *hidinput, struct hid_field *field,
  638. struct hid_usage *usage, unsigned long **bit, int *max);
  639. int (*input_mapped)(struct hid_device *hdev,
  640. struct hid_input *hidinput, struct hid_field *field,
  641. struct hid_usage *usage, unsigned long **bit, int *max);
  642. int (*input_configured)(struct hid_device *hdev,
  643. struct hid_input *hidinput);
  644. void (*feature_mapping)(struct hid_device *hdev,
  645. struct hid_field *field,
  646. struct hid_usage *usage);
  647. #ifdef CONFIG_PM
  648. int (*suspend)(struct hid_device *hdev, pm_message_t message);
  649. int (*resume)(struct hid_device *hdev);
  650. int (*reset_resume)(struct hid_device *hdev);
  651. #endif
  652. /* private: */
  653. struct device_driver driver;
  654. };
  655. #define to_hid_driver(pdrv) \
  656. container_of(pdrv, struct hid_driver, driver)
  657. /**
  658. * hid_ll_driver - low level driver callbacks
  659. * @start: called on probe to start the device
  660. * @stop: called on remove
  661. * @open: called by input layer on open
  662. * @close: called by input layer on close
  663. * @power: request underlying hardware to enter requested power mode
  664. * @parse: this method is called only once to parse the device data,
  665. * shouldn't allocate anything to not leak memory
  666. * @request: send report request to device (e.g. feature report)
  667. * @wait: wait for buffered io to complete (send/recv reports)
  668. * @raw_request: send raw report request to device (e.g. feature report)
  669. * @output_report: send output report to device
  670. * @idle: send idle request to device
  671. */
  672. struct hid_ll_driver {
  673. int (*start)(struct hid_device *hdev);
  674. void (*stop)(struct hid_device *hdev);
  675. int (*open)(struct hid_device *hdev);
  676. void (*close)(struct hid_device *hdev);
  677. int (*power)(struct hid_device *hdev, int level);
  678. int (*parse)(struct hid_device *hdev);
  679. void (*request)(struct hid_device *hdev,
  680. struct hid_report *report, int reqtype);
  681. int (*wait)(struct hid_device *hdev);
  682. int (*raw_request) (struct hid_device *hdev, unsigned char reportnum,
  683. __u8 *buf, size_t len, unsigned char rtype,
  684. int reqtype);
  685. int (*output_report) (struct hid_device *hdev, __u8 *buf, size_t len);
  686. int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype);
  687. };
  688. extern struct hid_ll_driver i2c_hid_ll_driver;
  689. extern struct hid_ll_driver hidp_hid_driver;
  690. extern struct hid_ll_driver uhid_hid_driver;
  691. extern struct hid_ll_driver usb_hid_driver;
  692. static inline bool hid_is_using_ll_driver(struct hid_device *hdev,
  693. struct hid_ll_driver *driver)
  694. {
  695. return hdev->ll_driver == driver;
  696. }
  697. #define PM_HINT_FULLON 1<<5
  698. #define PM_HINT_NORMAL 1<<1
  699. /* Applications from HID Usage Tables 4/8/99 Version 1.1 */
  700. /* We ignore a few input applications that are not widely used */
  701. #define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001) || ((a >= 0x000d0002) && (a <= 0x000d0006)))
  702. /* HID core API */
  703. extern int hid_debug;
  704. extern bool hid_ignore(struct hid_device *);
  705. extern int hid_add_device(struct hid_device *);
  706. extern void hid_destroy_device(struct hid_device *);
  707. extern int __must_check __hid_register_driver(struct hid_driver *,
  708. struct module *, const char *mod_name);
  709. /* use a define to avoid include chaining to get THIS_MODULE & friends */
  710. #define hid_register_driver(driver) \
  711. __hid_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
  712. extern void hid_unregister_driver(struct hid_driver *);
  713. /**
  714. * module_hid_driver() - Helper macro for registering a HID driver
  715. * @__hid_driver: hid_driver struct
  716. *
  717. * Helper macro for HID drivers which do not do anything special in module
  718. * init/exit. This eliminates a lot of boilerplate. Each module may only
  719. * use this macro once, and calling it replaces module_init() and module_exit()
  720. */
  721. #define module_hid_driver(__hid_driver) \
  722. module_driver(__hid_driver, hid_register_driver, \
  723. hid_unregister_driver)
  724. extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
  725. extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report);
  726. extern int hidinput_connect(struct hid_device *hid, unsigned int force);
  727. extern void hidinput_disconnect(struct hid_device *);
  728. int hid_set_field(struct hid_field *, unsigned, __s32);
  729. int hid_input_report(struct hid_device *, int type, u8 *, int, int);
  730. int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field);
  731. struct hid_field *hidinput_get_led_field(struct hid_device *hid);
  732. unsigned int hidinput_count_leds(struct hid_device *hid);
  733. __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code);
  734. void hid_output_report(struct hid_report *report, __u8 *data);
  735. void __hid_request(struct hid_device *hid, struct hid_report *rep, int reqtype);
  736. u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags);
  737. struct hid_device *hid_allocate_device(void);
  738. struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id);
  739. int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
  740. struct hid_report *hid_validate_values(struct hid_device *hid,
  741. unsigned int type, unsigned int id,
  742. unsigned int field_index,
  743. unsigned int report_counts);
  744. int hid_open_report(struct hid_device *device);
  745. int hid_check_keys_pressed(struct hid_device *hid);
  746. int hid_connect(struct hid_device *hid, unsigned int connect_mask);
  747. void hid_disconnect(struct hid_device *hid);
  748. const struct hid_device_id *hid_match_id(struct hid_device *hdev,
  749. const struct hid_device_id *id);
  750. s32 hid_snto32(__u32 value, unsigned n);
  751. __u32 hid_field_extract(const struct hid_device *hid, __u8 *report,
  752. unsigned offset, unsigned n);
  753. /**
  754. * hid_device_io_start - enable HID input during probe, remove
  755. *
  756. * @hid - the device
  757. *
  758. * This should only be called during probe or remove and only be
  759. * called by the thread calling probe or remove. It will allow
  760. * incoming packets to be delivered to the driver.
  761. */
  762. static inline void hid_device_io_start(struct hid_device *hid) {
  763. if (hid->io_started) {
  764. dev_warn(&hid->dev, "io already started\n");
  765. return;
  766. }
  767. hid->io_started = true;
  768. up(&hid->driver_input_lock);
  769. }
  770. /**
  771. * hid_device_io_stop - disable HID input during probe, remove
  772. *
  773. * @hid - the device
  774. *
  775. * Should only be called after hid_device_io_start. It will prevent
  776. * incoming packets from going to the driver for the duration of
  777. * probe, remove. If called during probe, packets will still go to the
  778. * driver after probe is complete. This function should only be called
  779. * by the thread calling probe or remove.
  780. */
  781. static inline void hid_device_io_stop(struct hid_device *hid) {
  782. if (!hid->io_started) {
  783. dev_warn(&hid->dev, "io already stopped\n");
  784. return;
  785. }
  786. hid->io_started = false;
  787. down(&hid->driver_input_lock);
  788. }
  789. /**
  790. * hid_map_usage - map usage input bits
  791. *
  792. * @hidinput: hidinput which we are interested in
  793. * @usage: usage to fill in
  794. * @bit: pointer to input->{}bit (out parameter)
  795. * @max: maximal valid usage->code to consider later (out parameter)
  796. * @type: input event type (EV_KEY, EV_REL, ...)
  797. * @c: code which corresponds to this usage and type
  798. */
  799. static inline void hid_map_usage(struct hid_input *hidinput,
  800. struct hid_usage *usage, unsigned long **bit, int *max,
  801. __u8 type, __u16 c)
  802. {
  803. struct input_dev *input = hidinput->input;
  804. usage->type = type;
  805. usage->code = c;
  806. switch (type) {
  807. case EV_ABS:
  808. *bit = input->absbit;
  809. *max = ABS_MAX;
  810. break;
  811. case EV_REL:
  812. *bit = input->relbit;
  813. *max = REL_MAX;
  814. break;
  815. case EV_KEY:
  816. *bit = input->keybit;
  817. *max = KEY_MAX;
  818. break;
  819. case EV_LED:
  820. *bit = input->ledbit;
  821. *max = LED_MAX;
  822. break;
  823. }
  824. }
  825. /**
  826. * hid_map_usage_clear - map usage input bits and clear the input bit
  827. *
  828. * The same as hid_map_usage, except the @c bit is also cleared in supported
  829. * bits (@bit).
  830. */
  831. static inline void hid_map_usage_clear(struct hid_input *hidinput,
  832. struct hid_usage *usage, unsigned long **bit, int *max,
  833. __u8 type, __u16 c)
  834. {
  835. hid_map_usage(hidinput, usage, bit, max, type, c);
  836. clear_bit(c, *bit);
  837. }
  838. /**
  839. * hid_parse - parse HW reports
  840. *
  841. * @hdev: hid device
  842. *
  843. * Call this from probe after you set up the device (if needed). Your
  844. * report_fixup will be called (if non-NULL) after reading raw report from
  845. * device before passing it to hid layer for real parsing.
  846. */
  847. static inline int __must_check hid_parse(struct hid_device *hdev)
  848. {
  849. return hid_open_report(hdev);
  850. }
  851. int __must_check hid_hw_start(struct hid_device *hdev,
  852. unsigned int connect_mask);
  853. void hid_hw_stop(struct hid_device *hdev);
  854. int __must_check hid_hw_open(struct hid_device *hdev);
  855. void hid_hw_close(struct hid_device *hdev);
  856. /**
  857. * hid_hw_power - requests underlying HW to go into given power mode
  858. *
  859. * @hdev: hid device
  860. * @level: requested power level (one of %PM_HINT_* defines)
  861. *
  862. * This function requests underlying hardware to enter requested power
  863. * mode.
  864. */
  865. static inline int hid_hw_power(struct hid_device *hdev, int level)
  866. {
  867. return hdev->ll_driver->power ? hdev->ll_driver->power(hdev, level) : 0;
  868. }
  869. /**
  870. * hid_hw_request - send report request to device
  871. *
  872. * @hdev: hid device
  873. * @report: report to send
  874. * @reqtype: hid request type
  875. */
  876. static inline void hid_hw_request(struct hid_device *hdev,
  877. struct hid_report *report, int reqtype)
  878. {
  879. if (hdev->ll_driver->request)
  880. return hdev->ll_driver->request(hdev, report, reqtype);
  881. __hid_request(hdev, report, reqtype);
  882. }
  883. /**
  884. * hid_hw_raw_request - send report request to device
  885. *
  886. * @hdev: hid device
  887. * @reportnum: report ID
  888. * @buf: in/out data to transfer
  889. * @len: length of buf
  890. * @rtype: HID report type
  891. * @reqtype: HID_REQ_GET_REPORT or HID_REQ_SET_REPORT
  892. *
  893. * @return: count of data transfered, negative if error
  894. *
  895. * Same behavior as hid_hw_request, but with raw buffers instead.
  896. */
  897. static inline int hid_hw_raw_request(struct hid_device *hdev,
  898. unsigned char reportnum, __u8 *buf,
  899. size_t len, unsigned char rtype, int reqtype)
  900. {
  901. if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf)
  902. return -EINVAL;
  903. return hdev->ll_driver->raw_request(hdev, reportnum, buf, len,
  904. rtype, reqtype);
  905. }
  906. /**
  907. * hid_hw_output_report - send output report to device
  908. *
  909. * @hdev: hid device
  910. * @buf: raw data to transfer
  911. * @len: length of buf
  912. *
  913. * @return: count of data transfered, negative if error
  914. */
  915. static inline int hid_hw_output_report(struct hid_device *hdev, __u8 *buf,
  916. size_t len)
  917. {
  918. if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf)
  919. return -EINVAL;
  920. if (hdev->ll_driver->output_report)
  921. return hdev->ll_driver->output_report(hdev, buf, len);
  922. return -ENOSYS;
  923. }
  924. /**
  925. * hid_hw_idle - send idle request to device
  926. *
  927. * @hdev: hid device
  928. * @report: report to control
  929. * @idle: idle state
  930. * @reqtype: hid request type
  931. */
  932. static inline int hid_hw_idle(struct hid_device *hdev, int report, int idle,
  933. int reqtype)
  934. {
  935. if (hdev->ll_driver->idle)
  936. return hdev->ll_driver->idle(hdev, report, idle, reqtype);
  937. return 0;
  938. }
  939. /**
  940. * hid_hw_wait - wait for buffered io to complete
  941. *
  942. * @hdev: hid device
  943. */
  944. static inline void hid_hw_wait(struct hid_device *hdev)
  945. {
  946. if (hdev->ll_driver->wait)
  947. hdev->ll_driver->wait(hdev);
  948. }
  949. /**
  950. * hid_report_len - calculate the report length
  951. *
  952. * @report: the report we want to know the length
  953. */
  954. static inline int hid_report_len(struct hid_report *report)
  955. {
  956. /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */
  957. return ((report->size - 1) >> 3) + 1 + (report->id > 0);
  958. }
  959. int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
  960. int interrupt);
  961. /* HID quirks API */
  962. u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct);
  963. int usbhid_quirks_init(char **quirks_param);
  964. void usbhid_quirks_exit(void);
  965. #ifdef CONFIG_HID_PID
  966. int hid_pidff_init(struct hid_device *hid);
  967. #else
  968. #define hid_pidff_init NULL
  969. #endif
  970. #define dbg_hid(format, arg...) \
  971. do { \
  972. if (hid_debug) \
  973. printk(KERN_DEBUG "%s: " format, __FILE__, ##arg); \
  974. } while (0)
  975. #define hid_printk(level, hid, fmt, arg...) \
  976. dev_printk(level, &(hid)->dev, fmt, ##arg)
  977. #define hid_emerg(hid, fmt, arg...) \
  978. dev_emerg(&(hid)->dev, fmt, ##arg)
  979. #define hid_crit(hid, fmt, arg...) \
  980. dev_crit(&(hid)->dev, fmt, ##arg)
  981. #define hid_alert(hid, fmt, arg...) \
  982. dev_alert(&(hid)->dev, fmt, ##arg)
  983. #define hid_err(hid, fmt, arg...) \
  984. dev_err(&(hid)->dev, fmt, ##arg)
  985. #define hid_notice(hid, fmt, arg...) \
  986. dev_notice(&(hid)->dev, fmt, ##arg)
  987. #define hid_warn(hid, fmt, arg...) \
  988. dev_warn(&(hid)->dev, fmt, ##arg)
  989. #define hid_info(hid, fmt, arg...) \
  990. dev_info(&(hid)->dev, fmt, ##arg)
  991. #define hid_dbg(hid, fmt, arg...) \
  992. dev_dbg(&(hid)->dev, fmt, ##arg)
  993. #endif