aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2006-12-08 12:40:44 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-12-08 13:43:01 -0500
commitdde5845a529ff753364a6d1aea61180946270bfa (patch)
treee0160fe45c047024b281a2805196a8c64242b59e /include
parent64bb67b1702958759f650adb64ab33496641e526 (diff)
[PATCH] Generic HID layer - code split
The "big main" split of USB HID code into generic HID code and USB-transport specific HID handling. Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/hid-debug.h757
-rw-r--r--include/linux/hid.h540
2 files changed, 1297 insertions, 0 deletions
diff --git a/include/linux/hid-debug.h b/include/linux/hid-debug.h
new file mode 100644
index 000000000000..f04d6d75c098
--- /dev/null
+++ b/include/linux/hid-debug.h
@@ -0,0 +1,757 @@
1/*
2 * $Id: hid-debug.h,v 1.8 2001/09/25 09:37:57 vojtech Exp $
3 *
4 * (c) 1999 Andreas Gal <gal@cs.uni-magdeburg.de>
5 * (c) 2000-2001 Vojtech Pavlik <vojtech@ucw.cz>
6 *
7 * Some debug stuff for the HID parser.
8 */
9
10/*
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 * Should you need to contact me, the author, you can do so either by
26 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
27 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
28 */
29
30#include <linux/input.h>
31
32struct hid_usage_entry {
33 unsigned page;
34 unsigned usage;
35 char *description;
36};
37
38static const struct hid_usage_entry hid_usage_table[] = {
39 { 0, 0, "Undefined" },
40 { 1, 0, "GenericDesktop" },
41 {0, 0x01, "Pointer"},
42 {0, 0x02, "Mouse"},
43 {0, 0x04, "Joystick"},
44 {0, 0x05, "GamePad"},
45 {0, 0x06, "Keyboard"},
46 {0, 0x07, "Keypad"},
47 {0, 0x08, "MultiAxis"},
48 {0, 0x30, "X"},
49 {0, 0x31, "Y"},
50 {0, 0x32, "Z"},
51 {0, 0x33, "Rx"},
52 {0, 0x34, "Ry"},
53 {0, 0x35, "Rz"},
54 {0, 0x36, "Slider"},
55 {0, 0x37, "Dial"},
56 {0, 0x38, "Wheel"},
57 {0, 0x39, "HatSwitch"},
58 {0, 0x3a, "CountedBuffer"},
59 {0, 0x3b, "ByteCount"},
60 {0, 0x3c, "MotionWakeup"},
61 {0, 0x3d, "Start"},
62 {0, 0x3e, "Select"},
63 {0, 0x40, "Vx"},
64 {0, 0x41, "Vy"},
65 {0, 0x42, "Vz"},
66 {0, 0x43, "Vbrx"},
67 {0, 0x44, "Vbry"},
68 {0, 0x45, "Vbrz"},
69 {0, 0x46, "Vno"},
70 {0, 0x80, "SystemControl"},
71 {0, 0x81, "SystemPowerDown"},
72 {0, 0x82, "SystemSleep"},
73 {0, 0x83, "SystemWakeUp"},
74 {0, 0x84, "SystemContextMenu"},
75 {0, 0x85, "SystemMainMenu"},
76 {0, 0x86, "SystemAppMenu"},
77 {0, 0x87, "SystemMenuHelp"},
78 {0, 0x88, "SystemMenuExit"},
79 {0, 0x89, "SystemMenuSelect"},
80 {0, 0x8a, "SystemMenuRight"},
81 {0, 0x8b, "SystemMenuLeft"},
82 {0, 0x8c, "SystemMenuUp"},
83 {0, 0x8d, "SystemMenuDown"},
84 {0, 0x90, "D-PadUp"},
85 {0, 0x91, "D-PadDown"},
86 {0, 0x92, "D-PadRight"},
87 {0, 0x93, "D-PadLeft"},
88 { 2, 0, "Simulation" },
89 {0, 0xb0, "Aileron"},
90 {0, 0xb1, "AileronTrim"},
91 {0, 0xb2, "Anti-Torque"},
92 {0, 0xb3, "Autopilot"},
93 {0, 0xb4, "Chaff"},
94 {0, 0xb5, "Collective"},
95 {0, 0xb6, "DiveBrake"},
96 {0, 0xb7, "ElectronicCountermeasures"},
97 {0, 0xb8, "Elevator"},
98 {0, 0xb9, "ElevatorTrim"},
99 {0, 0xba, "Rudder"},
100 {0, 0xbb, "Throttle"},
101 {0, 0xbc, "FlightCommunications"},
102 {0, 0xbd, "FlareRelease"},
103 {0, 0xbe, "LandingGear"},
104 {0, 0xbf, "ToeBrake"},
105 { 7, 0, "Keyboard" },
106 { 8, 0, "LED" },
107 {0, 0x01, "NumLock"},
108 {0, 0x02, "CapsLock"},
109 {0, 0x03, "ScrollLock"},
110 {0, 0x04, "Compose"},
111 {0, 0x05, "Kana"},
112 {0, 0x4b, "GenericIndicator"},
113 { 9, 0, "Button" },
114 { 10, 0, "Ordinal" },
115 { 12, 0, "Consumer" },
116 {0, 0x238, "HorizontalWheel"},
117 { 13, 0, "Digitizers" },
118 {0, 0x01, "Digitizer"},
119 {0, 0x02, "Pen"},
120 {0, 0x03, "LightPen"},
121 {0, 0x04, "TouchScreen"},
122 {0, 0x05, "TouchPad"},
123 {0, 0x20, "Stylus"},
124 {0, 0x21, "Puck"},
125 {0, 0x22, "Finger"},
126 {0, 0x30, "TipPressure"},
127 {0, 0x31, "BarrelPressure"},
128 {0, 0x32, "InRange"},
129 {0, 0x33, "Touch"},
130 {0, 0x34, "UnTouch"},
131 {0, 0x35, "Tap"},
132 {0, 0x39, "TabletFunctionKey"},
133 {0, 0x3a, "ProgramChangeKey"},
134 {0, 0x3c, "Invert"},
135 {0, 0x42, "TipSwitch"},
136 {0, 0x43, "SecondaryTipSwitch"},
137 {0, 0x44, "BarrelSwitch"},
138 {0, 0x45, "Eraser"},
139 {0, 0x46, "TabletPick"},
140 { 15, 0, "PhysicalInterfaceDevice" },
141 {0, 0x00, "Undefined"},
142 {0, 0x01, "Physical_Interface_Device"},
143 {0, 0x20, "Normal"},
144 {0, 0x21, "Set_Effect_Report"},
145 {0, 0x22, "Effect_Block_Index"},
146 {0, 0x23, "Parameter_Block_Offset"},
147 {0, 0x24, "ROM_Flag"},
148 {0, 0x25, "Effect_Type"},
149 {0, 0x26, "ET_Constant_Force"},
150 {0, 0x27, "ET_Ramp"},
151 {0, 0x28, "ET_Custom_Force_Data"},
152 {0, 0x30, "ET_Square"},
153 {0, 0x31, "ET_Sine"},
154 {0, 0x32, "ET_Triangle"},
155 {0, 0x33, "ET_Sawtooth_Up"},
156 {0, 0x34, "ET_Sawtooth_Down"},
157 {0, 0x40, "ET_Spring"},
158 {0, 0x41, "ET_Damper"},
159 {0, 0x42, "ET_Inertia"},
160 {0, 0x43, "ET_Friction"},
161 {0, 0x50, "Duration"},
162 {0, 0x51, "Sample_Period"},
163 {0, 0x52, "Gain"},
164 {0, 0x53, "Trigger_Button"},
165 {0, 0x54, "Trigger_Repeat_Interval"},
166 {0, 0x55, "Axes_Enable"},
167 {0, 0x56, "Direction_Enable"},
168 {0, 0x57, "Direction"},
169 {0, 0x58, "Type_Specific_Block_Offset"},
170 {0, 0x59, "Block_Type"},
171 {0, 0x5A, "Set_Envelope_Report"},
172 {0, 0x5B, "Attack_Level"},
173 {0, 0x5C, "Attack_Time"},
174 {0, 0x5D, "Fade_Level"},
175 {0, 0x5E, "Fade_Time"},
176 {0, 0x5F, "Set_Condition_Report"},
177 {0, 0x60, "CP_Offset"},
178 {0, 0x61, "Positive_Coefficient"},
179 {0, 0x62, "Negative_Coefficient"},
180 {0, 0x63, "Positive_Saturation"},
181 {0, 0x64, "Negative_Saturation"},
182 {0, 0x65, "Dead_Band"},
183 {0, 0x66, "Download_Force_Sample"},
184 {0, 0x67, "Isoch_Custom_Force_Enable"},
185 {0, 0x68, "Custom_Force_Data_Report"},
186 {0, 0x69, "Custom_Force_Data"},
187 {0, 0x6A, "Custom_Force_Vendor_Defined_Data"},
188 {0, 0x6B, "Set_Custom_Force_Report"},
189 {0, 0x6C, "Custom_Force_Data_Offset"},
190 {0, 0x6D, "Sample_Count"},
191 {0, 0x6E, "Set_Periodic_Report"},
192 {0, 0x6F, "Offset"},
193 {0, 0x70, "Magnitude"},
194 {0, 0x71, "Phase"},
195 {0, 0x72, "Period"},
196 {0, 0x73, "Set_Constant_Force_Report"},
197 {0, 0x74, "Set_Ramp_Force_Report"},
198 {0, 0x75, "Ramp_Start"},
199 {0, 0x76, "Ramp_End"},
200 {0, 0x77, "Effect_Operation_Report"},
201 {0, 0x78, "Effect_Operation"},
202 {0, 0x79, "Op_Effect_Start"},
203 {0, 0x7A, "Op_Effect_Start_Solo"},
204 {0, 0x7B, "Op_Effect_Stop"},
205 {0, 0x7C, "Loop_Count"},
206 {0, 0x7D, "Device_Gain_Report"},
207 {0, 0x7E, "Device_Gain"},
208 {0, 0x7F, "PID_Pool_Report"},
209 {0, 0x80, "RAM_Pool_Size"},
210 {0, 0x81, "ROM_Pool_Size"},
211 {0, 0x82, "ROM_Effect_Block_Count"},
212 {0, 0x83, "Simultaneous_Effects_Max"},
213 {0, 0x84, "Pool_Alignment"},
214 {0, 0x85, "PID_Pool_Move_Report"},
215 {0, 0x86, "Move_Source"},
216 {0, 0x87, "Move_Destination"},
217 {0, 0x88, "Move_Length"},
218 {0, 0x89, "PID_Block_Load_Report"},
219 {0, 0x8B, "Block_Load_Status"},
220 {0, 0x8C, "Block_Load_Success"},
221 {0, 0x8D, "Block_Load_Full"},
222 {0, 0x8E, "Block_Load_Error"},
223 {0, 0x8F, "Block_Handle"},
224 {0, 0x90, "PID_Block_Free_Report"},
225 {0, 0x91, "Type_Specific_Block_Handle"},
226 {0, 0x92, "PID_State_Report"},
227 {0, 0x94, "Effect_Playing"},
228 {0, 0x95, "PID_Device_Control_Report"},
229 {0, 0x96, "PID_Device_Control"},
230 {0, 0x97, "DC_Enable_Actuators"},
231 {0, 0x98, "DC_Disable_Actuators"},
232 {0, 0x99, "DC_Stop_All_Effects"},
233 {0, 0x9A, "DC_Device_Reset"},
234 {0, 0x9B, "DC_Device_Pause"},
235 {0, 0x9C, "DC_Device_Continue"},
236 {0, 0x9F, "Device_Paused"},
237 {0, 0xA0, "Actuators_Enabled"},
238 {0, 0xA4, "Safety_Switch"},
239 {0, 0xA5, "Actuator_Override_Switch"},
240 {0, 0xA6, "Actuator_Power"},
241 {0, 0xA7, "Start_Delay"},
242 {0, 0xA8, "Parameter_Block_Size"},
243 {0, 0xA9, "Device_Managed_Pool"},
244 {0, 0xAA, "Shared_Parameter_Blocks"},
245 {0, 0xAB, "Create_New_Effect_Report"},
246 {0, 0xAC, "RAM_Pool_Available"},
247 { 0x84, 0, "Power Device" },
248 { 0x84, 0x02, "PresentStatus" },
249 { 0x84, 0x03, "ChangeStatus" },
250 { 0x84, 0x04, "UPS" },
251 { 0x84, 0x05, "PowerSupply" },
252 { 0x84, 0x10, "BatterySystem" },
253 { 0x84, 0x11, "BatterySystemID" },
254 { 0x84, 0x12, "Battery" },
255 { 0x84, 0x13, "BatteryID" },
256 { 0x84, 0x14, "Charger" },
257 { 0x84, 0x15, "ChargerID" },
258 { 0x84, 0x16, "PowerConverter" },
259 { 0x84, 0x17, "PowerConverterID" },
260 { 0x84, 0x18, "OutletSystem" },
261 { 0x84, 0x19, "OutletSystemID" },
262 { 0x84, 0x1a, "Input" },
263 { 0x84, 0x1b, "InputID" },
264 { 0x84, 0x1c, "Output" },
265 { 0x84, 0x1d, "OutputID" },
266 { 0x84, 0x1e, "Flow" },
267 { 0x84, 0x1f, "FlowID" },
268 { 0x84, 0x20, "Outlet" },
269 { 0x84, 0x21, "OutletID" },
270 { 0x84, 0x22, "Gang" },
271 { 0x84, 0x24, "PowerSummary" },
272 { 0x84, 0x25, "PowerSummaryID" },
273 { 0x84, 0x30, "Voltage" },
274 { 0x84, 0x31, "Current" },
275 { 0x84, 0x32, "Frequency" },
276 { 0x84, 0x33, "ApparentPower" },
277 { 0x84, 0x35, "PercentLoad" },
278 { 0x84, 0x40, "ConfigVoltage" },
279 { 0x84, 0x41, "ConfigCurrent" },
280 { 0x84, 0x43, "ConfigApparentPower" },
281 { 0x84, 0x53, "LowVoltageTransfer" },
282 { 0x84, 0x54, "HighVoltageTransfer" },
283 { 0x84, 0x56, "DelayBeforeStartup" },
284 { 0x84, 0x57, "DelayBeforeShutdown" },
285 { 0x84, 0x58, "Test" },
286 { 0x84, 0x5a, "AudibleAlarmControl" },
287 { 0x84, 0x60, "Present" },
288 { 0x84, 0x61, "Good" },
289 { 0x84, 0x62, "InternalFailure" },
290 { 0x84, 0x65, "Overload" },
291 { 0x84, 0x66, "OverCharged" },
292 { 0x84, 0x67, "OverTemperature" },
293 { 0x84, 0x68, "ShutdownRequested" },
294 { 0x84, 0x69, "ShutdownImminent" },
295 { 0x84, 0x6b, "SwitchOn/Off" },
296 { 0x84, 0x6c, "Switchable" },
297 { 0x84, 0x6d, "Used" },
298 { 0x84, 0x6e, "Boost" },
299 { 0x84, 0x73, "CommunicationLost" },
300 { 0x84, 0xfd, "iManufacturer" },
301 { 0x84, 0xfe, "iProduct" },
302 { 0x84, 0xff, "iSerialNumber" },
303 { 0x85, 0, "Battery System" },
304 { 0x85, 0x01, "SMBBatteryMode" },
305 { 0x85, 0x02, "SMBBatteryStatus" },
306 { 0x85, 0x03, "SMBAlarmWarning" },
307 { 0x85, 0x04, "SMBChargerMode" },
308 { 0x85, 0x05, "SMBChargerStatus" },
309 { 0x85, 0x06, "SMBChargerSpecInfo" },
310 { 0x85, 0x07, "SMBSelectorState" },
311 { 0x85, 0x08, "SMBSelectorPresets" },
312 { 0x85, 0x09, "SMBSelectorInfo" },
313 { 0x85, 0x29, "RemainingCapacityLimit" },
314 { 0x85, 0x2c, "CapacityMode" },
315 { 0x85, 0x42, "BelowRemainingCapacityLimit" },
316 { 0x85, 0x44, "Charging" },
317 { 0x85, 0x45, "Discharging" },
318 { 0x85, 0x4b, "NeedReplacement" },
319 { 0x85, 0x66, "RemainingCapacity" },
320 { 0x85, 0x68, "RunTimeToEmpty" },
321 { 0x85, 0x6a, "AverageTimeToFull" },
322 { 0x85, 0x83, "DesignCapacity" },
323 { 0x85, 0x85, "ManufacturerDate" },
324 { 0x85, 0x89, "iDeviceChemistry" },
325 { 0x85, 0x8b, "Rechargable" },
326 { 0x85, 0x8f, "iOEMInformation" },
327 { 0x85, 0x8d, "CapacityGranularity1" },
328 { 0x85, 0xd0, "ACPresent" },
329 /* pages 0xff00 to 0xffff are vendor-specific */
330 { 0xffff, 0, "Vendor-specific-FF" },
331 { 0, 0, NULL }
332};
333
334static void resolv_usage_page(unsigned page) {
335 const struct hid_usage_entry *p;
336
337 for (p = hid_usage_table; p->description; p++)
338 if (p->page == page) {
339 printk("%s", p->description);
340 return;
341 }
342 printk("%04x", page);
343}
344
345static void resolv_usage(unsigned usage) {
346 const struct hid_usage_entry *p;
347
348 resolv_usage_page(usage >> 16);
349 printk(".");
350 for (p = hid_usage_table; p->description; p++)
351 if (p->page == (usage >> 16)) {
352 for(++p; p->description && p->usage != 0; p++)
353 if (p->usage == (usage & 0xffff)) {
354 printk("%s", p->description);
355 return;
356 }
357 break;
358 }
359 printk("%04x", usage & 0xffff);
360}
361
362__inline__ static void tab(int n) {
363 while (n--) printk(" ");
364}
365
366static void hid_dump_field(struct hid_field *field, int n) {
367 int j;
368
369 if (field->physical) {
370 tab(n);
371 printk("Physical(");
372 resolv_usage(field->physical); printk(")\n");
373 }
374 if (field->logical) {
375 tab(n);
376 printk("Logical(");
377 resolv_usage(field->logical); printk(")\n");
378 }
379 tab(n); printk("Usage(%d)\n", field->maxusage);
380 for (j = 0; j < field->maxusage; j++) {
381 tab(n+2);resolv_usage(field->usage[j].hid); printk("\n");
382 }
383 if (field->logical_minimum != field->logical_maximum) {
384 tab(n); printk("Logical Minimum(%d)\n", field->logical_minimum);
385 tab(n); printk("Logical Maximum(%d)\n", field->logical_maximum);
386 }
387 if (field->physical_minimum != field->physical_maximum) {
388 tab(n); printk("Physical Minimum(%d)\n", field->physical_minimum);
389 tab(n); printk("Physical Maximum(%d)\n", field->physical_maximum);
390 }
391 if (field->unit_exponent) {
392 tab(n); printk("Unit Exponent(%d)\n", field->unit_exponent);
393 }
394 if (field->unit) {
395 char *systems[5] = { "None", "SI Linear", "SI Rotation", "English Linear", "English Rotation" };
396 char *units[5][8] = {
397 { "None", "None", "None", "None", "None", "None", "None", "None" },
398 { "None", "Centimeter", "Gram", "Seconds", "Kelvin", "Ampere", "Candela", "None" },
399 { "None", "Radians", "Gram", "Seconds", "Kelvin", "Ampere", "Candela", "None" },
400 { "None", "Inch", "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" },
401 { "None", "Degrees", "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" }
402 };
403
404 int i;
405 int sys;
406 __u32 data = field->unit;
407
408 /* First nibble tells us which system we're in. */
409 sys = data & 0xf;
410 data >>= 4;
411
412 if(sys > 4) {
413 tab(n); printk("Unit(Invalid)\n");
414 }
415 else {
416 int earlier_unit = 0;
417
418 tab(n); printk("Unit(%s : ", systems[sys]);
419
420 for (i=1 ; i<sizeof(__u32)*2 ; i++) {
421 char nibble = data & 0xf;
422 data >>= 4;
423 if (nibble != 0) {
424 if(earlier_unit++ > 0)
425 printk("*");
426 printk("%s", units[sys][i]);
427 if(nibble != 1) {
428 /* This is a _signed_ nibble(!) */
429
430 int val = nibble & 0x7;
431 if(nibble & 0x08)
432 val = -((0x7 & ~val) +1);
433 printk("^%d", val);
434 }
435 }
436 }
437 printk(")\n");
438 }
439 }
440 tab(n); printk("Report Size(%u)\n", field->report_size);
441 tab(n); printk("Report Count(%u)\n", field->report_count);
442 tab(n); printk("Report Offset(%u)\n", field->report_offset);
443
444 tab(n); printk("Flags( ");
445 j = field->flags;
446 printk("%s", HID_MAIN_ITEM_CONSTANT & j ? "Constant " : "");
447 printk("%s", HID_MAIN_ITEM_VARIABLE & j ? "Variable " : "Array ");
448 printk("%s", HID_MAIN_ITEM_RELATIVE & j ? "Relative " : "Absolute ");
449 printk("%s", HID_MAIN_ITEM_WRAP & j ? "Wrap " : "");
450 printk("%s", HID_MAIN_ITEM_NONLINEAR & j ? "NonLinear " : "");
451 printk("%s", HID_MAIN_ITEM_NO_PREFERRED & j ? "NoPrefferedState " : "");
452 printk("%s", HID_MAIN_ITEM_NULL_STATE & j ? "NullState " : "");
453 printk("%s", HID_MAIN_ITEM_VOLATILE & j ? "Volatile " : "");
454 printk("%s", HID_MAIN_ITEM_BUFFERED_BYTE & j ? "BufferedByte " : "");
455 printk(")\n");
456}
457
458static void __attribute__((unused)) hid_dump_device(struct hid_device *device) {
459 struct hid_report_enum *report_enum;
460 struct hid_report *report;
461 struct list_head *list;
462 unsigned i,k;
463 static char *table[] = {"INPUT", "OUTPUT", "FEATURE"};
464
465 for (i = 0; i < HID_REPORT_TYPES; i++) {
466 report_enum = device->report_enum + i;
467 list = report_enum->report_list.next;
468 while (list != &report_enum->report_list) {
469 report = (struct hid_report *) list;
470 tab(2);
471 printk("%s", table[i]);
472 if (report->id)
473 printk("(%d)", report->id);
474 printk("[%s]", table[report->type]);
475 printk("\n");
476 for (k = 0; k < report->maxfield; k++) {
477 tab(4);
478 printk("Field(%d)\n", k);
479 hid_dump_field(report->field[k], 6);
480 }
481 list = list->next;
482 }
483 }
484}
485
486static void __attribute__((unused)) hid_dump_input(struct hid_usage *usage, __s32 value) {
487 printk("hid-debug: input ");
488 resolv_usage(usage->hid);
489 printk(" = %d\n", value);
490}
491
492
493static char *events[EV_MAX + 1] = {
494 [EV_SYN] = "Sync", [EV_KEY] = "Key",
495 [EV_REL] = "Relative", [EV_ABS] = "Absolute",
496 [EV_MSC] = "Misc", [EV_LED] = "LED",
497 [EV_SND] = "Sound", [EV_REP] = "Repeat",
498 [EV_FF] = "ForceFeedback", [EV_PWR] = "Power",
499 [EV_FF_STATUS] = "ForceFeedbackStatus",
500};
501
502static char *syncs[2] = {
503 [SYN_REPORT] = "Report", [SYN_CONFIG] = "Config",
504};
505static char *keys[KEY_MAX + 1] = {
506 [KEY_RESERVED] = "Reserved", [KEY_ESC] = "Esc",
507 [KEY_1] = "1", [KEY_2] = "2",
508 [KEY_3] = "3", [KEY_4] = "4",
509 [KEY_5] = "5", [KEY_6] = "6",
510 [KEY_7] = "7", [KEY_8] = "8",
511 [KEY_9] = "9", [KEY_0] = "0",
512 [KEY_MINUS] = "Minus", [KEY_EQUAL] = "Equal",
513 [KEY_BACKSPACE] = "Backspace", [KEY_TAB] = "Tab",
514 [KEY_Q] = "Q", [KEY_W] = "W",
515 [KEY_E] = "E", [KEY_R] = "R",
516 [KEY_T] = "T", [KEY_Y] = "Y",
517 [KEY_U] = "U", [KEY_I] = "I",
518 [KEY_O] = "O", [KEY_P] = "P",
519 [KEY_LEFTBRACE] = "LeftBrace", [KEY_RIGHTBRACE] = "RightBrace",
520 [KEY_ENTER] = "Enter", [KEY_LEFTCTRL] = "LeftControl",
521 [KEY_A] = "A", [KEY_S] = "S",
522 [KEY_D] = "D", [KEY_F] = "F",
523 [KEY_G] = "G", [KEY_H] = "H",
524 [KEY_J] = "J", [KEY_K] = "K",
525 [KEY_L] = "L", [KEY_SEMICOLON] = "Semicolon",
526 [KEY_APOSTROPHE] = "Apostrophe", [KEY_GRAVE] = "Grave",
527 [KEY_LEFTSHIFT] = "LeftShift", [KEY_BACKSLASH] = "BackSlash",
528 [KEY_Z] = "Z", [KEY_X] = "X",
529 [KEY_C] = "C", [KEY_V] = "V",
530 [KEY_B] = "B", [KEY_N] = "N",
531 [KEY_M] = "M", [KEY_COMMA] = "Comma",
532 [KEY_DOT] = "Dot", [KEY_SLASH] = "Slash",
533 [KEY_RIGHTSHIFT] = "RightShift", [KEY_KPASTERISK] = "KPAsterisk",
534 [KEY_LEFTALT] = "LeftAlt", [KEY_SPACE] = "Space",
535 [KEY_CAPSLOCK] = "CapsLock", [KEY_F1] = "F1",
536 [KEY_F2] = "F2", [KEY_F3] = "F3",
537 [KEY_F4] = "F4", [KEY_F5] = "F5",
538 [KEY_F6] = "F6", [KEY_F7] = "F7",
539 [KEY_F8] = "F8", [KEY_F9] = "F9",
540 [KEY_F10] = "F10", [KEY_NUMLOCK] = "NumLock",
541 [KEY_SCROLLLOCK] = "ScrollLock", [KEY_KP7] = "KP7",
542 [KEY_KP8] = "KP8", [KEY_KP9] = "KP9",
543 [KEY_KPMINUS] = "KPMinus", [KEY_KP4] = "KP4",
544 [KEY_KP5] = "KP5", [KEY_KP6] = "KP6",
545 [KEY_KPPLUS] = "KPPlus", [KEY_KP1] = "KP1",
546 [KEY_KP2] = "KP2", [KEY_KP3] = "KP3",
547 [KEY_KP0] = "KP0", [KEY_KPDOT] = "KPDot",
548 [KEY_ZENKAKUHANKAKU] = "Zenkaku/Hankaku", [KEY_102ND] = "102nd",
549 [KEY_F11] = "F11", [KEY_F12] = "F12",
550 [KEY_RO] = "RO", [KEY_KATAKANA] = "Katakana",
551 [KEY_HIRAGANA] = "HIRAGANA", [KEY_HENKAN] = "Henkan",
552 [KEY_KATAKANAHIRAGANA] = "Katakana/Hiragana", [KEY_MUHENKAN] = "Muhenkan",
553 [KEY_KPJPCOMMA] = "KPJpComma", [KEY_KPENTER] = "KPEnter",
554 [KEY_RIGHTCTRL] = "RightCtrl", [KEY_KPSLASH] = "KPSlash",
555 [KEY_SYSRQ] = "SysRq", [KEY_RIGHTALT] = "RightAlt",
556 [KEY_LINEFEED] = "LineFeed", [KEY_HOME] = "Home",
557 [KEY_UP] = "Up", [KEY_PAGEUP] = "PageUp",
558 [KEY_LEFT] = "Left", [KEY_RIGHT] = "Right",
559 [KEY_END] = "End", [KEY_DOWN] = "Down",
560 [KEY_PAGEDOWN] = "PageDown", [KEY_INSERT] = "Insert",
561 [KEY_DELETE] = "Delete", [KEY_MACRO] = "Macro",
562 [KEY_MUTE] = "Mute", [KEY_VOLUMEDOWN] = "VolumeDown",
563 [KEY_VOLUMEUP] = "VolumeUp", [KEY_POWER] = "Power",
564 [KEY_KPEQUAL] = "KPEqual", [KEY_KPPLUSMINUS] = "KPPlusMinus",
565 [KEY_PAUSE] = "Pause", [KEY_KPCOMMA] = "KPComma",
566 [KEY_HANGUEL] = "Hangeul", [KEY_HANJA] = "Hanja",
567 [KEY_YEN] = "Yen", [KEY_LEFTMETA] = "LeftMeta",
568 [KEY_RIGHTMETA] = "RightMeta", [KEY_COMPOSE] = "Compose",
569 [KEY_STOP] = "Stop", [KEY_AGAIN] = "Again",
570 [KEY_PROPS] = "Props", [KEY_UNDO] = "Undo",
571 [KEY_FRONT] = "Front", [KEY_COPY] = "Copy",
572 [KEY_OPEN] = "Open", [KEY_PASTE] = "Paste",
573 [KEY_FIND] = "Find", [KEY_CUT] = "Cut",
574 [KEY_HELP] = "Help", [KEY_MENU] = "Menu",
575 [KEY_CALC] = "Calc", [KEY_SETUP] = "Setup",
576 [KEY_SLEEP] = "Sleep", [KEY_WAKEUP] = "WakeUp",
577 [KEY_FILE] = "File", [KEY_SENDFILE] = "SendFile",
578 [KEY_DELETEFILE] = "DeleteFile", [KEY_XFER] = "X-fer",
579 [KEY_PROG1] = "Prog1", [KEY_PROG2] = "Prog2",
580 [KEY_WWW] = "WWW", [KEY_MSDOS] = "MSDOS",
581 [KEY_COFFEE] = "Coffee", [KEY_DIRECTION] = "Direction",
582 [KEY_CYCLEWINDOWS] = "CycleWindows", [KEY_MAIL] = "Mail",
583 [KEY_BOOKMARKS] = "Bookmarks", [KEY_COMPUTER] = "Computer",
584 [KEY_BACK] = "Back", [KEY_FORWARD] = "Forward",
585 [KEY_CLOSECD] = "CloseCD", [KEY_EJECTCD] = "EjectCD",
586 [KEY_EJECTCLOSECD] = "EjectCloseCD", [KEY_NEXTSONG] = "NextSong",
587 [KEY_PLAYPAUSE] = "PlayPause", [KEY_PREVIOUSSONG] = "PreviousSong",
588 [KEY_STOPCD] = "StopCD", [KEY_RECORD] = "Record",
589 [KEY_REWIND] = "Rewind", [KEY_PHONE] = "Phone",
590 [KEY_ISO] = "ISOKey", [KEY_CONFIG] = "Config",
591 [KEY_HOMEPAGE] = "HomePage", [KEY_REFRESH] = "Refresh",
592 [KEY_EXIT] = "Exit", [KEY_MOVE] = "Move",
593 [KEY_EDIT] = "Edit", [KEY_SCROLLUP] = "ScrollUp",
594 [KEY_SCROLLDOWN] = "ScrollDown", [KEY_KPLEFTPAREN] = "KPLeftParenthesis",
595 [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_NEW] = "New",
596 [KEY_REDO] = "Redo", [KEY_F13] = "F13",
597 [KEY_F14] = "F14", [KEY_F15] = "F15",
598 [KEY_F16] = "F16", [KEY_F17] = "F17",
599 [KEY_F18] = "F18", [KEY_F19] = "F19",
600 [KEY_F20] = "F20", [KEY_F21] = "F21",
601 [KEY_F22] = "F22", [KEY_F23] = "F23",
602 [KEY_F24] = "F24", [KEY_PLAYCD] = "PlayCD",
603 [KEY_PAUSECD] = "PauseCD", [KEY_PROG3] = "Prog3",
604 [KEY_PROG4] = "Prog4", [KEY_SUSPEND] = "Suspend",
605 [KEY_CLOSE] = "Close", [KEY_PLAY] = "Play",
606 [KEY_FASTFORWARD] = "FastForward", [KEY_BASSBOOST] = "BassBoost",
607 [KEY_PRINT] = "Print", [KEY_HP] = "HP",
608 [KEY_CAMERA] = "Camera", [KEY_SOUND] = "Sound",
609 [KEY_QUESTION] = "Question", [KEY_EMAIL] = "Email",
610 [KEY_CHAT] = "Chat", [KEY_SEARCH] = "Search",
611 [KEY_CONNECT] = "Connect", [KEY_FINANCE] = "Finance",
612 [KEY_SPORT] = "Sport", [KEY_SHOP] = "Shop",
613 [KEY_ALTERASE] = "AlternateErase", [KEY_CANCEL] = "Cancel",
614 [KEY_BRIGHTNESSDOWN] = "BrightnessDown", [KEY_BRIGHTNESSUP] = "BrightnessUp",
615 [KEY_MEDIA] = "Media", [KEY_UNKNOWN] = "Unknown",
616 [BTN_0] = "Btn0", [BTN_1] = "Btn1",
617 [BTN_2] = "Btn2", [BTN_3] = "Btn3",
618 [BTN_4] = "Btn4", [BTN_5] = "Btn5",
619 [BTN_6] = "Btn6", [BTN_7] = "Btn7",
620 [BTN_8] = "Btn8", [BTN_9] = "Btn9",
621 [BTN_LEFT] = "LeftBtn", [BTN_RIGHT] = "RightBtn",
622 [BTN_MIDDLE] = "MiddleBtn", [BTN_SIDE] = "SideBtn",
623 [BTN_EXTRA] = "ExtraBtn", [BTN_FORWARD] = "ForwardBtn",
624 [BTN_BACK] = "BackBtn", [BTN_TASK] = "TaskBtn",
625 [BTN_TRIGGER] = "Trigger", [BTN_THUMB] = "ThumbBtn",
626 [BTN_THUMB2] = "ThumbBtn2", [BTN_TOP] = "TopBtn",
627 [BTN_TOP2] = "TopBtn2", [BTN_PINKIE] = "PinkieBtn",
628 [BTN_BASE] = "BaseBtn", [BTN_BASE2] = "BaseBtn2",
629 [BTN_BASE3] = "BaseBtn3", [BTN_BASE4] = "BaseBtn4",
630 [BTN_BASE5] = "BaseBtn5", [BTN_BASE6] = "BaseBtn6",
631 [BTN_DEAD] = "BtnDead", [BTN_A] = "BtnA",
632 [BTN_B] = "BtnB", [BTN_C] = "BtnC",
633 [BTN_X] = "BtnX", [BTN_Y] = "BtnY",
634 [BTN_Z] = "BtnZ", [BTN_TL] = "BtnTL",
635 [BTN_TR] = "BtnTR", [BTN_TL2] = "BtnTL2",
636 [BTN_TR2] = "BtnTR2", [BTN_SELECT] = "BtnSelect",
637 [BTN_START] = "BtnStart", [BTN_MODE] = "BtnMode",
638 [BTN_THUMBL] = "BtnThumbL", [BTN_THUMBR] = "BtnThumbR",
639 [BTN_TOOL_PEN] = "ToolPen", [BTN_TOOL_RUBBER] = "ToolRubber",
640 [BTN_TOOL_BRUSH] = "ToolBrush", [BTN_TOOL_PENCIL] = "ToolPencil",
641 [BTN_TOOL_AIRBRUSH] = "ToolAirbrush", [BTN_TOOL_FINGER] = "ToolFinger",
642 [BTN_TOOL_MOUSE] = "ToolMouse", [BTN_TOOL_LENS] = "ToolLens",
643 [BTN_TOUCH] = "Touch", [BTN_STYLUS] = "Stylus",
644 [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "ToolDoubleTap",
645 [BTN_TOOL_TRIPLETAP] = "ToolTripleTap", [BTN_GEAR_DOWN] = "WheelBtn",
646 [BTN_GEAR_UP] = "Gear up", [KEY_OK] = "Ok",
647 [KEY_SELECT] = "Select", [KEY_GOTO] = "Goto",
648 [KEY_CLEAR] = "Clear", [KEY_POWER2] = "Power2",
649 [KEY_OPTION] = "Option", [KEY_INFO] = "Info",
650 [KEY_TIME] = "Time", [KEY_VENDOR] = "Vendor",
651 [KEY_ARCHIVE] = "Archive", [KEY_PROGRAM] = "Program",
652 [KEY_CHANNEL] = "Channel", [KEY_FAVORITES] = "Favorites",
653 [KEY_EPG] = "EPG", [KEY_PVR] = "PVR",
654 [KEY_MHP] = "MHP", [KEY_LANGUAGE] = "Language",
655 [KEY_TITLE] = "Title", [KEY_SUBTITLE] = "Subtitle",
656 [KEY_ANGLE] = "Angle", [KEY_ZOOM] = "Zoom",
657 [KEY_MODE] = "Mode", [KEY_KEYBOARD] = "Keyboard",
658 [KEY_SCREEN] = "Screen", [KEY_PC] = "PC",
659 [KEY_TV] = "TV", [KEY_TV2] = "TV2",
660 [KEY_VCR] = "VCR", [KEY_VCR2] = "VCR2",
661 [KEY_SAT] = "Sat", [KEY_SAT2] = "Sat2",
662 [KEY_CD] = "CD", [KEY_TAPE] = "Tape",
663 [KEY_RADIO] = "Radio", [KEY_TUNER] = "Tuner",
664 [KEY_PLAYER] = "Player", [KEY_TEXT] = "Text",
665 [KEY_DVD] = "DVD", [KEY_AUX] = "Aux",
666 [KEY_MP3] = "MP3", [KEY_AUDIO] = "Audio",
667 [KEY_VIDEO] = "Video", [KEY_DIRECTORY] = "Directory",
668 [KEY_LIST] = "List", [KEY_MEMO] = "Memo",
669 [KEY_CALENDAR] = "Calendar", [KEY_RED] = "Red",
670 [KEY_GREEN] = "Green", [KEY_YELLOW] = "Yellow",
671 [KEY_BLUE] = "Blue", [KEY_CHANNELUP] = "ChannelUp",
672 [KEY_CHANNELDOWN] = "ChannelDown", [KEY_FIRST] = "First",
673 [KEY_LAST] = "Last", [KEY_AB] = "AB",
674 [KEY_NEXT] = "Next", [KEY_RESTART] = "Restart",
675 [KEY_SLOW] = "Slow", [KEY_SHUFFLE] = "Shuffle",
676 [KEY_BREAK] = "Break", [KEY_PREVIOUS] = "Previous",
677 [KEY_DIGITS] = "Digits", [KEY_TEEN] = "TEEN",
678 [KEY_TWEN] = "TWEN", [KEY_DEL_EOL] = "DeleteEOL",
679 [KEY_DEL_EOS] = "DeleteEOS", [KEY_INS_LINE] = "InsertLine",
680 [KEY_DEL_LINE] = "DeleteLine",
681 [KEY_SEND] = "Send", [KEY_REPLY] = "Reply",
682 [KEY_FORWARDMAIL] = "ForwardMail", [KEY_SAVE] = "Save",
683 [KEY_DOCUMENTS] = "Documents",
684 [KEY_FN] = "Fn", [KEY_FN_ESC] = "Fn+ESC",
685 [KEY_FN_1] = "Fn+1", [KEY_FN_2] = "Fn+2",
686 [KEY_FN_B] = "Fn+B", [KEY_FN_D] = "Fn+D",
687 [KEY_FN_E] = "Fn+E", [KEY_FN_F] = "Fn+F",
688 [KEY_FN_S] = "Fn+S",
689 [KEY_FN_F1] = "Fn+F1", [KEY_FN_F2] = "Fn+F2",
690 [KEY_FN_F3] = "Fn+F3", [KEY_FN_F4] = "Fn+F4",
691 [KEY_FN_F5] = "Fn+F5", [KEY_FN_F6] = "Fn+F6",
692 [KEY_FN_F7] = "Fn+F7", [KEY_FN_F8] = "Fn+F8",
693 [KEY_FN_F9] = "Fn+F9", [KEY_FN_F10] = "Fn+F10",
694 [KEY_FN_F11] = "Fn+F11", [KEY_FN_F12] = "Fn+F12",
695 [KEY_KBDILLUMTOGGLE] = "KbdIlluminationToggle",
696 [KEY_KBDILLUMDOWN] = "KbdIlluminationDown",
697 [KEY_KBDILLUMUP] = "KbdIlluminationUp",
698 [KEY_SWITCHVIDEOMODE] = "SwitchVideoMode",
699};
700
701static char *relatives[REL_MAX + 1] = {
702 [REL_X] = "X", [REL_Y] = "Y",
703 [REL_Z] = "Z", [REL_HWHEEL] = "HWheel",
704 [REL_DIAL] = "Dial", [REL_WHEEL] = "Wheel",
705 [REL_MISC] = "Misc",
706};
707
708static char *absolutes[ABS_MAX + 1] = {
709 [ABS_X] = "X", [ABS_Y] = "Y",
710 [ABS_Z] = "Z", [ABS_RX] = "Rx",
711 [ABS_RY] = "Ry", [ABS_RZ] = "Rz",
712 [ABS_THROTTLE] = "Throttle", [ABS_RUDDER] = "Rudder",
713 [ABS_WHEEL] = "Wheel", [ABS_GAS] = "Gas",
714 [ABS_BRAKE] = "Brake", [ABS_HAT0X] = "Hat0X",
715 [ABS_HAT0Y] = "Hat0Y", [ABS_HAT1X] = "Hat1X",
716 [ABS_HAT1Y] = "Hat1Y", [ABS_HAT2X] = "Hat2X",
717 [ABS_HAT2Y] = "Hat2Y", [ABS_HAT3X] = "Hat3X",
718 [ABS_HAT3Y] = "Hat 3Y", [ABS_PRESSURE] = "Pressure",
719 [ABS_DISTANCE] = "Distance", [ABS_TILT_X] = "XTilt",
720 [ABS_TILT_Y] = "YTilt", [ABS_TOOL_WIDTH] = "Tool Width",
721 [ABS_VOLUME] = "Volume", [ABS_MISC] = "Misc",
722};
723
724static char *misc[MSC_MAX + 1] = {
725 [MSC_SERIAL] = "Serial", [MSC_PULSELED] = "Pulseled",
726 [MSC_GESTURE] = "Gesture", [MSC_RAW] = "RawData"
727};
728
729static char *leds[LED_MAX + 1] = {
730 [LED_NUML] = "NumLock", [LED_CAPSL] = "CapsLock",
731 [LED_SCROLLL] = "ScrollLock", [LED_COMPOSE] = "Compose",
732 [LED_KANA] = "Kana", [LED_SLEEP] = "Sleep",
733 [LED_SUSPEND] = "Suspend", [LED_MUTE] = "Mute",
734 [LED_MISC] = "Misc",
735};
736
737static char *repeats[REP_MAX + 1] = {
738 [REP_DELAY] = "Delay", [REP_PERIOD] = "Period"
739};
740
741static char *sounds[SND_MAX + 1] = {
742 [SND_CLICK] = "Click", [SND_BELL] = "Bell",
743 [SND_TONE] = "Tone"
744};
745
746static char **names[EV_MAX + 1] = {
747 [EV_SYN] = syncs, [EV_KEY] = keys,
748 [EV_REL] = relatives, [EV_ABS] = absolutes,
749 [EV_MSC] = misc, [EV_LED] = leds,
750 [EV_SND] = sounds, [EV_REP] = repeats,
751};
752
753static void __attribute__((unused)) resolv_event(__u8 type, __u16 code) {
754
755 printk("%s.%s", events[type] ? events[type] : "?",
756 names[type] ? (names[type][code] ? names[type][code] : "?") : "?");
757}
diff --git a/include/linux/hid.h b/include/linux/hid.h
new file mode 100644
index 000000000000..ee567ae6fec1
--- /dev/null
+++ b/include/linux/hid.h
@@ -0,0 +1,540 @@
1#ifndef __HID_H
2#define __HID_H
3
4/*
5 * $Id: hid.h,v 1.24 2001/12/27 10:37:41 vojtech Exp $
6 *
7 * Copyright (c) 1999 Andreas Gal
8 * Copyright (c) 2000-2001 Vojtech Pavlik
9 * Copyright (c) 2006 Jiri Kosina
10 */
11
12/*
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
30 */
31
32#include <linux/types.h>
33#include <linux/slab.h>
34#include <linux/list.h>
35#include <linux/timer.h>
36#include <linux/workqueue.h>
37#include <linux/input.h>
38
39/*
40 * USB HID (Human Interface Device) interface class code
41 */
42
43#define USB_INTERFACE_CLASS_HID 3
44
45/*
46 * USB HID interface subclass and protocol codes
47 */
48
49#define USB_INTERFACE_SUBCLASS_BOOT 1
50#define USB_INTERFACE_PROTOCOL_KEYBOARD 1
51#define USB_INTERFACE_PROTOCOL_MOUSE 2
52
53/*
54 * HID class requests
55 */
56
57#define HID_REQ_GET_REPORT 0x01
58#define HID_REQ_GET_IDLE 0x02
59#define HID_REQ_GET_PROTOCOL 0x03
60#define HID_REQ_SET_REPORT 0x09
61#define HID_REQ_SET_IDLE 0x0A
62#define HID_REQ_SET_PROTOCOL 0x0B
63
64/*
65 * HID class descriptor types
66 */
67
68#define HID_DT_HID (USB_TYPE_CLASS | 0x01)
69#define HID_DT_REPORT (USB_TYPE_CLASS | 0x02)
70#define HID_DT_PHYSICAL (USB_TYPE_CLASS | 0x03)
71
72/*
73 * We parse each description item into this structure. Short items data
74 * values are expanded to 32-bit signed int, long items contain a pointer
75 * into the data area.
76 */
77
78struct hid_item {
79 unsigned format;
80 __u8 size;
81 __u8 type;
82 __u8 tag;
83 union {
84 __u8 u8;
85 __s8 s8;
86 __u16 u16;
87 __s16 s16;
88 __u32 u32;
89 __s32 s32;
90 __u8 *longdata;
91 } data;
92};
93
94/*
95 * HID report item format
96 */
97
98#define HID_ITEM_FORMAT_SHORT 0
99#define HID_ITEM_FORMAT_LONG 1
100
101/*
102 * Special tag indicating long items
103 */
104
105#define HID_ITEM_TAG_LONG 15
106
107/*
108 * HID report descriptor item type (prefix bit 2,3)
109 */
110
111#define HID_ITEM_TYPE_MAIN 0
112#define HID_ITEM_TYPE_GLOBAL 1
113#define HID_ITEM_TYPE_LOCAL 2
114#define HID_ITEM_TYPE_RESERVED 3
115
116/*
117 * HID report descriptor main item tags
118 */
119
120#define HID_MAIN_ITEM_TAG_INPUT 8
121#define HID_MAIN_ITEM_TAG_OUTPUT 9
122#define HID_MAIN_ITEM_TAG_FEATURE 11
123#define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10
124#define HID_MAIN_ITEM_TAG_END_COLLECTION 12
125
126/*
127 * HID report descriptor main item contents
128 */
129
130#define HID_MAIN_ITEM_CONSTANT 0x001
131#define HID_MAIN_ITEM_VARIABLE 0x002
132#define HID_MAIN_ITEM_RELATIVE 0x004
133#define HID_MAIN_ITEM_WRAP 0x008
134#define HID_MAIN_ITEM_NONLINEAR 0x010
135#define HID_MAIN_ITEM_NO_PREFERRED 0x020
136#define HID_MAIN_ITEM_NULL_STATE 0x040
137#define HID_MAIN_ITEM_VOLATILE 0x080
138#define HID_MAIN_ITEM_BUFFERED_BYTE 0x100
139
140/*
141 * HID report descriptor collection item types
142 */
143
144#define HID_COLLECTION_PHYSICAL 0
145#define HID_COLLECTION_APPLICATION 1
146#define HID_COLLECTION_LOGICAL 2
147
148/*
149 * HID report descriptor global item tags
150 */
151
152#define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0
153#define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1
154#define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2
155#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3
156#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4
157#define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5
158#define HID_GLOBAL_ITEM_TAG_UNIT 6
159#define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7
160#define HID_GLOBAL_ITEM_TAG_REPORT_ID 8
161#define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9
162#define HID_GLOBAL_ITEM_TAG_PUSH 10
163#define HID_GLOBAL_ITEM_TAG_POP 11
164
165/*
166 * HID report descriptor local item tags
167 */
168
169#define HID_LOCAL_ITEM_TAG_USAGE 0
170#define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1
171#define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2
172#define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3
173#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4
174#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5
175#define HID_LOCAL_ITEM_TAG_STRING_INDEX 7
176#define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8
177#define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9
178#define HID_LOCAL_ITEM_TAG_DELIMITER 10
179
180/*
181 * HID usage tables
182 */
183
184#define HID_USAGE_PAGE 0xffff0000
185
186#define HID_UP_UNDEFINED 0x00000000
187#define HID_UP_GENDESK 0x00010000
188#define HID_UP_SIMULATION 0x00020000
189#define HID_UP_KEYBOARD 0x00070000
190#define HID_UP_LED 0x00080000
191#define HID_UP_BUTTON 0x00090000
192#define HID_UP_ORDINAL 0x000a0000
193#define HID_UP_CONSUMER 0x000c0000
194#define HID_UP_DIGITIZER 0x000d0000
195#define HID_UP_PID 0x000f0000
196#define HID_UP_HPVENDOR 0xff7f0000
197#define HID_UP_MSVENDOR 0xff000000
198#define HID_UP_CUSTOM 0x00ff0000
199#define HID_UP_LOGIVENDOR 0xffbc0000
200
201#define HID_USAGE 0x0000ffff
202
203#define HID_GD_POINTER 0x00010001
204#define HID_GD_MOUSE 0x00010002
205#define HID_GD_JOYSTICK 0x00010004
206#define HID_GD_GAMEPAD 0x00010005
207#define HID_GD_KEYBOARD 0x00010006
208#define HID_GD_KEYPAD 0x00010007
209#define HID_GD_MULTIAXIS 0x00010008
210#define HID_GD_X 0x00010030
211#define HID_GD_Y 0x00010031
212#define HID_GD_Z 0x00010032
213#define HID_GD_RX 0x00010033
214#define HID_GD_RY 0x00010034
215#define HID_GD_RZ 0x00010035
216#define HID_GD_SLIDER 0x00010036
217#define HID_GD_DIAL 0x00010037
218#define HID_GD_WHEEL 0x00010038
219#define HID_GD_HATSWITCH 0x00010039
220#define HID_GD_BUFFER 0x0001003a
221#define HID_GD_BYTECOUNT 0x0001003b
222#define HID_GD_MOTION 0x0001003c
223#define HID_GD_START 0x0001003d
224#define HID_GD_SELECT 0x0001003e
225#define HID_GD_VX 0x00010040
226#define HID_GD_VY 0x00010041
227#define HID_GD_VZ 0x00010042
228#define HID_GD_VBRX 0x00010043
229#define HID_GD_VBRY 0x00010044
230#define HID_GD_VBRZ 0x00010045
231#define HID_GD_VNO 0x00010046
232#define HID_GD_FEATURE 0x00010047
233#define HID_GD_UP 0x00010090
234#define HID_GD_DOWN 0x00010091
235#define HID_GD_RIGHT 0x00010092
236#define HID_GD_LEFT 0x00010093
237
238/*
239 * HID report types --- Ouch! HID spec says 1 2 3!
240 */
241
242#define HID_INPUT_REPORT 0
243#define HID_OUTPUT_REPORT 1
244#define HID_FEATURE_REPORT 2
245
246/*
247 * HID device quirks.
248 */
249
250#define HID_QUIRK_INVERT 0x00000001
251#define HID_QUIRK_NOTOUCH 0x00000002
252#define HID_QUIRK_IGNORE 0x00000004
253#define HID_QUIRK_NOGET 0x00000008
254#define HID_QUIRK_HIDDEV 0x00000010
255#define HID_QUIRK_BADPAD 0x00000020
256#define HID_QUIRK_MULTI_INPUT 0x00000040
257#define HID_QUIRK_2WHEEL_MOUSE_HACK_7 0x00000080
258#define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x00000100
259#define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x00000200
260#define HID_QUIRK_MIGHTYMOUSE 0x00000400
261#define HID_QUIRK_CYMOTION 0x00000800
262#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000
263#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000
264#define HID_QUIRK_INVERT_HWHEEL 0x00004000
265#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD 0x00008000
266#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00010000
267
268/*
269 * This is the global environment of the parser. This information is
270 * persistent for main-items. The global environment can be saved and
271 * restored with PUSH/POP statements.
272 */
273
274struct hid_global {
275 unsigned usage_page;
276 __s32 logical_minimum;
277 __s32 logical_maximum;
278 __s32 physical_minimum;
279 __s32 physical_maximum;
280 __s32 unit_exponent;
281 unsigned unit;
282 unsigned report_id;
283 unsigned report_size;
284 unsigned report_count;
285};
286
287/*
288 * This is the local environment. It is persistent up the next main-item.
289 */
290
291#define HID_MAX_DESCRIPTOR_SIZE 4096
292#define HID_MAX_USAGES 1024
293#define HID_DEFAULT_NUM_COLLECTIONS 16
294
295struct hid_local {
296 unsigned usage[HID_MAX_USAGES]; /* usage array */
297 unsigned collection_index[HID_MAX_USAGES]; /* collection index array */
298 unsigned usage_index;
299 unsigned usage_minimum;
300 unsigned delimiter_depth;
301 unsigned delimiter_branch;
302};
303
304/*
305 * This is the collection stack. We climb up the stack to determine
306 * application and function of each field.
307 */
308
309struct hid_collection {
310 unsigned type;
311 unsigned usage;
312 unsigned level;
313};
314
315struct hid_usage {
316 unsigned hid; /* hid usage code */
317 unsigned collection_index; /* index into collection array */
318 /* hidinput data */
319 __u16 code; /* input driver code */
320 __u8 type; /* input driver type */
321 __s8 hat_min; /* hat switch fun */
322 __s8 hat_max; /* ditto */
323 __s8 hat_dir; /* ditto */
324};
325
326struct hid_input;
327
328struct hid_field {
329 unsigned physical; /* physical usage for this field */
330 unsigned logical; /* logical usage for this field */
331 unsigned application; /* application usage for this field */
332 struct hid_usage *usage; /* usage table for this function */
333 unsigned maxusage; /* maximum usage index */
334 unsigned flags; /* main-item flags (i.e. volatile,array,constant) */
335 unsigned report_offset; /* bit offset in the report */
336 unsigned report_size; /* size of this field in the report */
337 unsigned report_count; /* number of this field in the report */
338 unsigned report_type; /* (input,output,feature) */
339 __s32 *value; /* last known value(s) */
340 __s32 logical_minimum;
341 __s32 logical_maximum;
342 __s32 physical_minimum;
343 __s32 physical_maximum;
344 __s32 unit_exponent;
345 unsigned unit;
346 struct hid_report *report; /* associated report */
347 unsigned index; /* index into report->field[] */
348 /* hidinput data */
349 struct hid_input *hidinput; /* associated input structure */
350 __u16 dpad; /* dpad input code */
351};
352
353#define HID_MAX_FIELDS 64
354
355struct hid_report {
356 struct list_head list;
357 unsigned id; /* id of this report */
358 unsigned type; /* report type */
359 struct hid_field *field[HID_MAX_FIELDS]; /* fields of the report */
360 unsigned maxfield; /* maximum valid field index */
361 unsigned size; /* size of the report (bits) */
362 struct hid_device *device; /* associated device */
363};
364
365struct hid_report_enum {
366 unsigned numbered;
367 struct list_head report_list;
368 struct hid_report *report_id_hash[256];
369};
370
371#define HID_REPORT_TYPES 3
372
373#define HID_MIN_BUFFER_SIZE 64 /* make sure there is at least a packet size of space */
374#define HID_MAX_BUFFER_SIZE 4096 /* 4kb */
375#define HID_CONTROL_FIFO_SIZE 256 /* to init devices with >100 reports */
376#define HID_OUTPUT_FIFO_SIZE 64
377
378struct hid_control_fifo {
379 unsigned char dir;
380 struct hid_report *report;
381};
382
383#define HID_CLAIMED_INPUT 1
384#define HID_CLAIMED_HIDDEV 2
385
386#define HID_CTRL_RUNNING 1
387#define HID_OUT_RUNNING 2
388#define HID_IN_RUNNING 3
389#define HID_RESET_PENDING 4
390#define HID_SUSPENDED 5
391#define HID_CLEAR_HALT 6
392
393struct hid_input {
394 struct list_head list;
395 struct hid_report *report;
396 struct input_dev *input;
397};
398
399struct hid_device { /* device report descriptor */
400 __u8 *rdesc;
401 unsigned rsize;
402 struct hid_collection *collection; /* List of HID collections */
403 unsigned collection_size; /* Number of allocated hid_collections */
404 unsigned maxcollection; /* Number of parsed collections */
405 unsigned maxapplication; /* Number of applications */
406 unsigned version; /* HID version */
407 unsigned country; /* HID country */
408 struct hid_report_enum report_enum[HID_REPORT_TYPES];
409
410 struct usb_device *dev; /* USB device */
411 struct usb_interface *intf; /* USB interface */
412 int ifnum; /* USB interface number */
413
414 unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
415 struct timer_list io_retry; /* Retry timer */
416 unsigned long stop_retry; /* Time to give up, in jiffies */
417 unsigned int retry_delay; /* Delay length in ms */
418 struct work_struct reset_work; /* Task context for resets */
419
420 unsigned int bufsize; /* URB buffer size */
421
422 struct urb *urbin; /* Input URB */
423 char *inbuf; /* Input buffer */
424 dma_addr_t inbuf_dma; /* Input buffer dma */
425 spinlock_t inlock; /* Input fifo spinlock */
426
427 struct urb *urbctrl; /* Control URB */
428 struct usb_ctrlrequest *cr; /* Control request struct */
429 dma_addr_t cr_dma; /* Control request struct dma */
430 struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */
431 unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */
432 char *ctrlbuf; /* Control buffer */
433 dma_addr_t ctrlbuf_dma; /* Control buffer dma */
434 spinlock_t ctrllock; /* Control fifo spinlock */
435
436 struct urb *urbout; /* Output URB */
437 struct hid_report *out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */
438 unsigned char outhead, outtail; /* Output pipe fifo head & tail */
439 char *outbuf; /* Output buffer */
440 dma_addr_t outbuf_dma; /* Output buffer dma */
441 spinlock_t outlock; /* Output fifo spinlock */
442
443 unsigned claimed; /* Claimed by hidinput, hiddev? */
444 unsigned quirks; /* Various quirks the device can pull on us */
445
446 struct list_head inputs; /* The list of inputs */
447 void *hiddev; /* The hiddev structure */
448 int minor; /* Hiddev minor number */
449
450 wait_queue_head_t wait; /* For sleeping */
451
452 int open; /* is the device open by anyone? */
453 char name[128]; /* Device name */
454 char phys[64]; /* Device physical location */
455 char uniq[64]; /* Device unique identifier (serial #) */
456
457#ifdef CONFIG_USB_HIDINPUT_POWERBOOK
458 unsigned long pb_pressed_fn[NBITS(KEY_MAX)];
459 unsigned long pb_pressed_numlock[NBITS(KEY_MAX)];
460#endif
461};
462
463#define HID_GLOBAL_STACK_SIZE 4
464#define HID_COLLECTION_STACK_SIZE 4
465
466struct hid_parser {
467 struct hid_global global;
468 struct hid_global global_stack[HID_GLOBAL_STACK_SIZE];
469 unsigned global_stack_ptr;
470 struct hid_local local;
471 unsigned collection_stack[HID_COLLECTION_STACK_SIZE];
472 unsigned collection_stack_ptr;
473 struct hid_device *device;
474};
475
476struct hid_class_descriptor {
477 __u8 bDescriptorType;
478 __u16 wDescriptorLength;
479} __attribute__ ((packed));
480
481struct hid_descriptor {
482 __u8 bLength;
483 __u8 bDescriptorType;
484 __u16 bcdHID;
485 __u8 bCountryCode;
486 __u8 bNumDescriptors;
487
488 struct hid_class_descriptor desc[1];
489} __attribute__ ((packed));
490
491#ifdef DEBUG
492#include "hid-debug.h"
493#else
494#define hid_dump_input(a,b) do { } while (0)
495#define hid_dump_device(c) do { } while (0)
496#define hid_dump_field(a,b) do { } while (0)
497#define resolv_usage(a) do { } while (0)
498#define resolv_event(a,b) do { } while (0)
499#endif
500
501#ifdef CONFIG_HID
502/* Applications from HID Usage Tables 4/8/99 Version 1.1 */
503/* We ignore a few input applications that are not widely used */
504#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001))
505extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
506extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report);
507extern int hidinput_connect(struct hid_device *);
508extern void hidinput_disconnect(struct hid_device *);
509#else
510#define IS_INPUT_APPLICATION(a) (0)
511static inline void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) { }
512static inline void hidinput_report_event(struct hid_device *hid, struct hid_report *report) { }
513static inline int hidinput_connect(struct hid_device *hid) { return -ENODEV; }
514static inline void hidinput_disconnect(struct hid_device *hid) { }
515#endif
516
517int hid_set_field(struct hid_field *, unsigned, __s32);
518int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field);
519void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt);
520void hid_output_report(struct hid_report *report, __u8 *data);
521void hid_free_device(struct hid_device *device);
522struct hid_device *hid_parse_report(__u8 *start, unsigned size);
523
524#ifdef CONFIG_HID_FF
525int hid_ff_init(struct hid_device *hid);
526
527int hid_lgff_init(struct hid_device *hid);
528int hid_tmff_init(struct hid_device *hid);
529int hid_zpff_init(struct hid_device *hid);
530#ifdef CONFIG_HID_PID
531int hid_pidff_init(struct hid_device *hid);
532#else
533static inline int hid_pidff_init(struct hid_device *hid) { return -ENODEV; }
534#endif
535
536#else
537static inline int hid_ff_init(struct hid_device *hid) { return -1; }
538#endif
539#endif
540