[WATCHDOG] mv64x60_wdt: Support the WDIOF_MAGICCLOSE feature
[linux-2.6] / drivers / hid / hid-debug.c
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  *  (c) 2007 Jiri Kosina
7  *
8  *  Some debug stuff for the HID parser.
9  */
10
11 /*
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Should you need to contact me, the author, you can do so either by
27  * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
28  * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
29  */
30
31 #include <linux/hid.h>
32 #include <linux/hid-debug.h>
33
34 struct hid_usage_entry {
35         unsigned  page;
36         unsigned  usage;
37         char     *description;
38 };
39
40 static const struct hid_usage_entry hid_usage_table[] = {
41   {  0,      0, "Undefined" },
42   {  1,      0, "GenericDesktop" },
43     {0, 0x01, "Pointer"},
44     {0, 0x02, "Mouse"},
45     {0, 0x04, "Joystick"},
46     {0, 0x05, "GamePad"},
47     {0, 0x06, "Keyboard"},
48     {0, 0x07, "Keypad"},
49     {0, 0x08, "MultiAxis"},
50       {0, 0x30, "X"},
51       {0, 0x31, "Y"},
52       {0, 0x32, "Z"},
53       {0, 0x33, "Rx"},
54       {0, 0x34, "Ry"},
55       {0, 0x35, "Rz"},
56       {0, 0x36, "Slider"},
57       {0, 0x37, "Dial"},
58       {0, 0x38, "Wheel"},
59       {0, 0x39, "HatSwitch"},
60     {0, 0x3a, "CountedBuffer"},
61       {0, 0x3b, "ByteCount"},
62       {0, 0x3c, "MotionWakeup"},
63       {0, 0x3d, "Start"},
64       {0, 0x3e, "Select"},
65       {0, 0x40, "Vx"},
66       {0, 0x41, "Vy"},
67       {0, 0x42, "Vz"},
68       {0, 0x43, "Vbrx"},
69       {0, 0x44, "Vbry"},
70       {0, 0x45, "Vbrz"},
71       {0, 0x46, "Vno"},
72     {0, 0x80, "SystemControl"},
73       {0, 0x81, "SystemPowerDown"},
74       {0, 0x82, "SystemSleep"},
75       {0, 0x83, "SystemWakeUp"},
76       {0, 0x84, "SystemContextMenu"},
77       {0, 0x85, "SystemMainMenu"},
78       {0, 0x86, "SystemAppMenu"},
79       {0, 0x87, "SystemMenuHelp"},
80       {0, 0x88, "SystemMenuExit"},
81       {0, 0x89, "SystemMenuSelect"},
82       {0, 0x8a, "SystemMenuRight"},
83       {0, 0x8b, "SystemMenuLeft"},
84       {0, 0x8c, "SystemMenuUp"},
85       {0, 0x8d, "SystemMenuDown"},
86       {0, 0x90, "D-PadUp"},
87       {0, 0x91, "D-PadDown"},
88       {0, 0x92, "D-PadRight"},
89       {0, 0x93, "D-PadLeft"},
90   {  2, 0, "Simulation" },
91       {0, 0xb0, "Aileron"},
92       {0, 0xb1, "AileronTrim"},
93       {0, 0xb2, "Anti-Torque"},
94       {0, 0xb3, "Autopilot"},
95       {0, 0xb4, "Chaff"},
96       {0, 0xb5, "Collective"},
97       {0, 0xb6, "DiveBrake"},
98       {0, 0xb7, "ElectronicCountermeasures"},
99       {0, 0xb8, "Elevator"},
100       {0, 0xb9, "ElevatorTrim"},
101       {0, 0xba, "Rudder"},
102       {0, 0xbb, "Throttle"},
103       {0, 0xbc, "FlightCommunications"},
104       {0, 0xbd, "FlareRelease"},
105       {0, 0xbe, "LandingGear"},
106       {0, 0xbf, "ToeBrake"},
107   {  7, 0, "Keyboard" },
108   {  8, 0, "LED" },
109       {0, 0x01, "NumLock"},
110       {0, 0x02, "CapsLock"},
111       {0, 0x03, "ScrollLock"},
112       {0, 0x04, "Compose"},
113       {0, 0x05, "Kana"},
114       {0, 0x4b, "GenericIndicator"},
115   {  9, 0, "Button" },
116   { 10, 0, "Ordinal" },
117   { 12, 0, "Consumer" },
118       {0, 0x238, "HorizontalWheel"},
119   { 13, 0, "Digitizers" },
120     {0, 0x01, "Digitizer"},
121     {0, 0x02, "Pen"},
122     {0, 0x03, "LightPen"},
123     {0, 0x04, "TouchScreen"},
124     {0, 0x05, "TouchPad"},
125     {0, 0x20, "Stylus"},
126     {0, 0x21, "Puck"},
127     {0, 0x22, "Finger"},
128     {0, 0x30, "TipPressure"},
129     {0, 0x31, "BarrelPressure"},
130     {0, 0x32, "InRange"},
131     {0, 0x33, "Touch"},
132     {0, 0x34, "UnTouch"},
133     {0, 0x35, "Tap"},
134     {0, 0x39, "TabletFunctionKey"},
135     {0, 0x3a, "ProgramChangeKey"},
136     {0, 0x3c, "Invert"},
137     {0, 0x42, "TipSwitch"},
138     {0, 0x43, "SecondaryTipSwitch"},
139     {0, 0x44, "BarrelSwitch"},
140     {0, 0x45, "Eraser"},
141     {0, 0x46, "TabletPick"},
142   { 15, 0, "PhysicalInterfaceDevice" },
143     {0, 0x00, "Undefined"},
144     {0, 0x01, "Physical_Interface_Device"},
145       {0, 0x20, "Normal"},
146     {0, 0x21, "Set_Effect_Report"},
147       {0, 0x22, "Effect_Block_Index"},
148       {0, 0x23, "Parameter_Block_Offset"},
149       {0, 0x24, "ROM_Flag"},
150       {0, 0x25, "Effect_Type"},
151         {0, 0x26, "ET_Constant_Force"},
152         {0, 0x27, "ET_Ramp"},
153         {0, 0x28, "ET_Custom_Force_Data"},
154         {0, 0x30, "ET_Square"},
155         {0, 0x31, "ET_Sine"},
156         {0, 0x32, "ET_Triangle"},
157         {0, 0x33, "ET_Sawtooth_Up"},
158         {0, 0x34, "ET_Sawtooth_Down"},
159         {0, 0x40, "ET_Spring"},
160         {0, 0x41, "ET_Damper"},
161         {0, 0x42, "ET_Inertia"},
162         {0, 0x43, "ET_Friction"},
163       {0, 0x50, "Duration"},
164       {0, 0x51, "Sample_Period"},
165       {0, 0x52, "Gain"},
166       {0, 0x53, "Trigger_Button"},
167       {0, 0x54, "Trigger_Repeat_Interval"},
168       {0, 0x55, "Axes_Enable"},
169         {0, 0x56, "Direction_Enable"},
170       {0, 0x57, "Direction"},
171       {0, 0x58, "Type_Specific_Block_Offset"},
172         {0, 0x59, "Block_Type"},
173         {0, 0x5A, "Set_Envelope_Report"},
174           {0, 0x5B, "Attack_Level"},
175           {0, 0x5C, "Attack_Time"},
176           {0, 0x5D, "Fade_Level"},
177           {0, 0x5E, "Fade_Time"},
178         {0, 0x5F, "Set_Condition_Report"},
179         {0, 0x60, "CP_Offset"},
180         {0, 0x61, "Positive_Coefficient"},
181         {0, 0x62, "Negative_Coefficient"},
182         {0, 0x63, "Positive_Saturation"},
183         {0, 0x64, "Negative_Saturation"},
184         {0, 0x65, "Dead_Band"},
185       {0, 0x66, "Download_Force_Sample"},
186       {0, 0x67, "Isoch_Custom_Force_Enable"},
187       {0, 0x68, "Custom_Force_Data_Report"},
188         {0, 0x69, "Custom_Force_Data"},
189         {0, 0x6A, "Custom_Force_Vendor_Defined_Data"},
190       {0, 0x6B, "Set_Custom_Force_Report"},
191         {0, 0x6C, "Custom_Force_Data_Offset"},
192         {0, 0x6D, "Sample_Count"},
193       {0, 0x6E, "Set_Periodic_Report"},
194         {0, 0x6F, "Offset"},
195         {0, 0x70, "Magnitude"},
196         {0, 0x71, "Phase"},
197         {0, 0x72, "Period"},
198       {0, 0x73, "Set_Constant_Force_Report"},
199         {0, 0x74, "Set_Ramp_Force_Report"},
200         {0, 0x75, "Ramp_Start"},
201         {0, 0x76, "Ramp_End"},
202       {0, 0x77, "Effect_Operation_Report"},
203         {0, 0x78, "Effect_Operation"},
204           {0, 0x79, "Op_Effect_Start"},
205           {0, 0x7A, "Op_Effect_Start_Solo"},
206           {0, 0x7B, "Op_Effect_Stop"},
207           {0, 0x7C, "Loop_Count"},
208       {0, 0x7D, "Device_Gain_Report"},
209         {0, 0x7E, "Device_Gain"},
210     {0, 0x7F, "PID_Pool_Report"},
211       {0, 0x80, "RAM_Pool_Size"},
212       {0, 0x81, "ROM_Pool_Size"},
213       {0, 0x82, "ROM_Effect_Block_Count"},
214       {0, 0x83, "Simultaneous_Effects_Max"},
215       {0, 0x84, "Pool_Alignment"},
216     {0, 0x85, "PID_Pool_Move_Report"},
217       {0, 0x86, "Move_Source"},
218       {0, 0x87, "Move_Destination"},
219       {0, 0x88, "Move_Length"},
220     {0, 0x89, "PID_Block_Load_Report"},
221       {0, 0x8B, "Block_Load_Status"},
222       {0, 0x8C, "Block_Load_Success"},
223       {0, 0x8D, "Block_Load_Full"},
224       {0, 0x8E, "Block_Load_Error"},
225       {0, 0x8F, "Block_Handle"},
226       {0, 0x90, "PID_Block_Free_Report"},
227       {0, 0x91, "Type_Specific_Block_Handle"},
228     {0, 0x92, "PID_State_Report"},
229       {0, 0x94, "Effect_Playing"},
230       {0, 0x95, "PID_Device_Control_Report"},
231         {0, 0x96, "PID_Device_Control"},
232         {0, 0x97, "DC_Enable_Actuators"},
233         {0, 0x98, "DC_Disable_Actuators"},
234         {0, 0x99, "DC_Stop_All_Effects"},
235         {0, 0x9A, "DC_Device_Reset"},
236         {0, 0x9B, "DC_Device_Pause"},
237         {0, 0x9C, "DC_Device_Continue"},
238       {0, 0x9F, "Device_Paused"},
239       {0, 0xA0, "Actuators_Enabled"},
240       {0, 0xA4, "Safety_Switch"},
241       {0, 0xA5, "Actuator_Override_Switch"},
242       {0, 0xA6, "Actuator_Power"},
243     {0, 0xA7, "Start_Delay"},
244     {0, 0xA8, "Parameter_Block_Size"},
245     {0, 0xA9, "Device_Managed_Pool"},
246     {0, 0xAA, "Shared_Parameter_Blocks"},
247     {0, 0xAB, "Create_New_Effect_Report"},
248     {0, 0xAC, "RAM_Pool_Available"},
249   { 0x84, 0, "Power Device" },
250     { 0x84, 0x02, "PresentStatus" },
251     { 0x84, 0x03, "ChangeStatus" },
252     { 0x84, 0x04, "UPS" },
253     { 0x84, 0x05, "PowerSupply" },
254     { 0x84, 0x10, "BatterySystem" },
255     { 0x84, 0x11, "BatterySystemID" },
256     { 0x84, 0x12, "Battery" },
257     { 0x84, 0x13, "BatteryID" },
258     { 0x84, 0x14, "Charger" },
259     { 0x84, 0x15, "ChargerID" },
260     { 0x84, 0x16, "PowerConverter" },
261     { 0x84, 0x17, "PowerConverterID" },
262     { 0x84, 0x18, "OutletSystem" },
263     { 0x84, 0x19, "OutletSystemID" },
264     { 0x84, 0x1a, "Input" },
265     { 0x84, 0x1b, "InputID" },
266     { 0x84, 0x1c, "Output" },
267     { 0x84, 0x1d, "OutputID" },
268     { 0x84, 0x1e, "Flow" },
269     { 0x84, 0x1f, "FlowID" },
270     { 0x84, 0x20, "Outlet" },
271     { 0x84, 0x21, "OutletID" },
272     { 0x84, 0x22, "Gang" },
273     { 0x84, 0x24, "PowerSummary" },
274     { 0x84, 0x25, "PowerSummaryID" },
275     { 0x84, 0x30, "Voltage" },
276     { 0x84, 0x31, "Current" },
277     { 0x84, 0x32, "Frequency" },
278     { 0x84, 0x33, "ApparentPower" },
279     { 0x84, 0x35, "PercentLoad" },
280     { 0x84, 0x40, "ConfigVoltage" },
281     { 0x84, 0x41, "ConfigCurrent" },
282     { 0x84, 0x43, "ConfigApparentPower" },
283     { 0x84, 0x53, "LowVoltageTransfer" },
284     { 0x84, 0x54, "HighVoltageTransfer" },
285     { 0x84, 0x56, "DelayBeforeStartup" },
286     { 0x84, 0x57, "DelayBeforeShutdown" },
287     { 0x84, 0x58, "Test" },
288     { 0x84, 0x5a, "AudibleAlarmControl" },
289     { 0x84, 0x60, "Present" },
290     { 0x84, 0x61, "Good" },
291     { 0x84, 0x62, "InternalFailure" },
292     { 0x84, 0x65, "Overload" },
293     { 0x84, 0x66, "OverCharged" },
294     { 0x84, 0x67, "OverTemperature" },
295     { 0x84, 0x68, "ShutdownRequested" },
296     { 0x84, 0x69, "ShutdownImminent" },
297     { 0x84, 0x6b, "SwitchOn/Off" },
298     { 0x84, 0x6c, "Switchable" },
299     { 0x84, 0x6d, "Used" },
300     { 0x84, 0x6e, "Boost" },
301     { 0x84, 0x73, "CommunicationLost" },
302     { 0x84, 0xfd, "iManufacturer" },
303     { 0x84, 0xfe, "iProduct" },
304     { 0x84, 0xff, "iSerialNumber" },
305   { 0x85, 0, "Battery System" },
306     { 0x85, 0x01, "SMBBatteryMode" },
307     { 0x85, 0x02, "SMBBatteryStatus" },
308     { 0x85, 0x03, "SMBAlarmWarning" },
309     { 0x85, 0x04, "SMBChargerMode" },
310     { 0x85, 0x05, "SMBChargerStatus" },
311     { 0x85, 0x06, "SMBChargerSpecInfo" },
312     { 0x85, 0x07, "SMBSelectorState" },
313     { 0x85, 0x08, "SMBSelectorPresets" },
314     { 0x85, 0x09, "SMBSelectorInfo" },
315     { 0x85, 0x29, "RemainingCapacityLimit" },
316     { 0x85, 0x2c, "CapacityMode" },
317     { 0x85, 0x42, "BelowRemainingCapacityLimit" },
318     { 0x85, 0x44, "Charging" },
319     { 0x85, 0x45, "Discharging" },
320     { 0x85, 0x4b, "NeedReplacement" },
321     { 0x85, 0x66, "RemainingCapacity" },
322     { 0x85, 0x68, "RunTimeToEmpty" },
323     { 0x85, 0x6a, "AverageTimeToFull" },
324     { 0x85, 0x83, "DesignCapacity" },
325     { 0x85, 0x85, "ManufacturerDate" },
326     { 0x85, 0x89, "iDeviceChemistry" },
327     { 0x85, 0x8b, "Rechargable" },
328     { 0x85, 0x8f, "iOEMInformation" },
329     { 0x85, 0x8d, "CapacityGranularity1" },
330     { 0x85, 0xd0, "ACPresent" },
331   /* pages 0xff00 to 0xffff are vendor-specific */
332   { 0xffff, 0, "Vendor-specific-FF" },
333   { 0, 0, NULL }
334 };
335
336 static void resolv_usage_page(unsigned page) {
337         const struct hid_usage_entry *p;
338
339         for (p = hid_usage_table; p->description; p++)
340                 if (p->page == page) {
341                         printk("%s", p->description);
342                         return;
343                 }
344         printk("%04x", page);
345 }
346
347 void hid_resolv_usage(unsigned usage) {
348         const struct hid_usage_entry *p;
349
350         if (!hid_debug)
351                 return;
352
353         resolv_usage_page(usage >> 16);
354         printk(".");
355         for (p = hid_usage_table; p->description; p++)
356                 if (p->page == (usage >> 16)) {
357                         for(++p; p->description && p->usage != 0; p++)
358                                 if (p->usage == (usage & 0xffff)) {
359                                         printk("%s", p->description);
360                                         return;
361                                 }
362                         break;
363                 }
364         printk("%04x", usage & 0xffff);
365 }
366 EXPORT_SYMBOL_GPL(hid_resolv_usage);
367
368 __inline__ static void tab(int n) {
369         while (n--) printk(" ");
370 }
371
372 void hid_dump_field(struct hid_field *field, int n) {
373         int j;
374
375         if (!hid_debug)
376                 return;
377
378         if (field->physical) {
379                 tab(n);
380                 printk("Physical(");
381                 hid_resolv_usage(field->physical); printk(")\n");
382         }
383         if (field->logical) {
384                 tab(n);
385                 printk("Logical(");
386                 hid_resolv_usage(field->logical); printk(")\n");
387         }
388         tab(n); printk("Usage(%d)\n", field->maxusage);
389         for (j = 0; j < field->maxusage; j++) {
390                 tab(n+2); hid_resolv_usage(field->usage[j].hid); printk("\n");
391         }
392         if (field->logical_minimum != field->logical_maximum) {
393                 tab(n); printk("Logical Minimum(%d)\n", field->logical_minimum);
394                 tab(n); printk("Logical Maximum(%d)\n", field->logical_maximum);
395         }
396         if (field->physical_minimum != field->physical_maximum) {
397                 tab(n); printk("Physical Minimum(%d)\n", field->physical_minimum);
398                 tab(n); printk("Physical Maximum(%d)\n", field->physical_maximum);
399         }
400         if (field->unit_exponent) {
401                 tab(n); printk("Unit Exponent(%d)\n", field->unit_exponent);
402         }
403         if (field->unit) {
404                 char *systems[5] = { "None", "SI Linear", "SI Rotation", "English Linear", "English Rotation" };
405                 char *units[5][8] = {
406                         { "None", "None", "None", "None", "None", "None", "None", "None" },
407                         { "None", "Centimeter", "Gram", "Seconds", "Kelvin",     "Ampere", "Candela", "None" },
408                         { "None", "Radians",    "Gram", "Seconds", "Kelvin",     "Ampere", "Candela", "None" },
409                         { "None", "Inch",       "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" },
410                         { "None", "Degrees",    "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" }
411                 };
412
413                 int i;
414                 int sys;
415                 __u32 data = field->unit;
416
417                 /* First nibble tells us which system we're in. */
418                 sys = data & 0xf;
419                 data >>= 4;
420
421                 if(sys > 4) {
422                         tab(n); printk("Unit(Invalid)\n");
423                 }
424                 else {
425                         int earlier_unit = 0;
426
427                         tab(n); printk("Unit(%s : ", systems[sys]);
428
429                         for (i=1 ; i<sizeof(__u32)*2 ; i++) {
430                                 char nibble = data & 0xf;
431                                 data >>= 4;
432                                 if (nibble != 0) {
433                                         if(earlier_unit++ > 0)
434                                                 printk("*");
435                                         printk("%s", units[sys][i]);
436                                         if(nibble != 1) {
437                                                 /* This is a _signed_ nibble(!) */
438
439                                                 int val = nibble & 0x7;
440                                                 if(nibble & 0x08)
441                                                         val = -((0x7 & ~val) +1);
442                                                 printk("^%d", val);
443                                         }
444                                 }
445                         }
446                         printk(")\n");
447                 }
448         }
449         tab(n); printk("Report Size(%u)\n", field->report_size);
450         tab(n); printk("Report Count(%u)\n", field->report_count);
451         tab(n); printk("Report Offset(%u)\n", field->report_offset);
452
453         tab(n); printk("Flags( ");
454         j = field->flags;
455         printk("%s", HID_MAIN_ITEM_CONSTANT & j ? "Constant " : "");
456         printk("%s", HID_MAIN_ITEM_VARIABLE & j ? "Variable " : "Array ");
457         printk("%s", HID_MAIN_ITEM_RELATIVE & j ? "Relative " : "Absolute ");
458         printk("%s", HID_MAIN_ITEM_WRAP & j ? "Wrap " : "");
459         printk("%s", HID_MAIN_ITEM_NONLINEAR & j ? "NonLinear " : "");
460         printk("%s", HID_MAIN_ITEM_NO_PREFERRED & j ? "NoPrefferedState " : "");
461         printk("%s", HID_MAIN_ITEM_NULL_STATE & j ? "NullState " : "");
462         printk("%s", HID_MAIN_ITEM_VOLATILE & j ? "Volatile " : "");
463         printk("%s", HID_MAIN_ITEM_BUFFERED_BYTE & j ? "BufferedByte " : "");
464         printk(")\n");
465 }
466 EXPORT_SYMBOL_GPL(hid_dump_field);
467
468 void hid_dump_device(struct hid_device *device) {
469         struct hid_report_enum *report_enum;
470         struct hid_report *report;
471         struct list_head *list;
472         unsigned i,k;
473         static char *table[] = {"INPUT", "OUTPUT", "FEATURE"};
474
475         if (!hid_debug)
476                 return;
477
478         for (i = 0; i < HID_REPORT_TYPES; i++) {
479                 report_enum = device->report_enum + i;
480                 list = report_enum->report_list.next;
481                 while (list != &report_enum->report_list) {
482                         report = (struct hid_report *) list;
483                         tab(2);
484                         printk("%s", table[i]);
485                         if (report->id)
486                                 printk("(%d)", report->id);
487                         printk("[%s]", table[report->type]);
488                         printk("\n");
489                         for (k = 0; k < report->maxfield; k++) {
490                                 tab(4);
491                                 printk("Field(%d)\n", k);
492                                 hid_dump_field(report->field[k], 6);
493                         }
494                         list = list->next;
495                 }
496         }
497 }
498 EXPORT_SYMBOL_GPL(hid_dump_device);
499
500 void hid_dump_input(struct hid_usage *usage, __s32 value) {
501         if (!hid_debug)
502                 return;
503
504         printk("hid-debug: input ");
505         hid_resolv_usage(usage->hid);
506         printk(" = %d\n", value);
507 }
508 EXPORT_SYMBOL_GPL(hid_dump_input);
509
510 static char *events[EV_MAX + 1] = {
511         [EV_SYN] = "Sync",                      [EV_KEY] = "Key",
512         [EV_REL] = "Relative",                  [EV_ABS] = "Absolute",
513         [EV_MSC] = "Misc",                      [EV_LED] = "LED",
514         [EV_SND] = "Sound",                     [EV_REP] = "Repeat",
515         [EV_FF] = "ForceFeedback",              [EV_PWR] = "Power",
516         [EV_FF_STATUS] = "ForceFeedbackStatus",
517 };
518
519 static char *syncs[2] = {
520         [SYN_REPORT] = "Report",                [SYN_CONFIG] = "Config",
521 };
522 static char *keys[KEY_MAX + 1] = {
523         [KEY_RESERVED] = "Reserved",            [KEY_ESC] = "Esc",
524         [KEY_1] = "1",                          [KEY_2] = "2",
525         [KEY_3] = "3",                          [KEY_4] = "4",
526         [KEY_5] = "5",                          [KEY_6] = "6",
527         [KEY_7] = "7",                          [KEY_8] = "8",
528         [KEY_9] = "9",                          [KEY_0] = "0",
529         [KEY_MINUS] = "Minus",                  [KEY_EQUAL] = "Equal",
530         [KEY_BACKSPACE] = "Backspace",          [KEY_TAB] = "Tab",
531         [KEY_Q] = "Q",                          [KEY_W] = "W",
532         [KEY_E] = "E",                          [KEY_R] = "R",
533         [KEY_T] = "T",                          [KEY_Y] = "Y",
534         [KEY_U] = "U",                          [KEY_I] = "I",
535         [KEY_O] = "O",                          [KEY_P] = "P",
536         [KEY_LEFTBRACE] = "LeftBrace",          [KEY_RIGHTBRACE] = "RightBrace",
537         [KEY_ENTER] = "Enter",                  [KEY_LEFTCTRL] = "LeftControl",
538         [KEY_A] = "A",                          [KEY_S] = "S",
539         [KEY_D] = "D",                          [KEY_F] = "F",
540         [KEY_G] = "G",                          [KEY_H] = "H",
541         [KEY_J] = "J",                          [KEY_K] = "K",
542         [KEY_L] = "L",                          [KEY_SEMICOLON] = "Semicolon",
543         [KEY_APOSTROPHE] = "Apostrophe",        [KEY_GRAVE] = "Grave",
544         [KEY_LEFTSHIFT] = "LeftShift",          [KEY_BACKSLASH] = "BackSlash",
545         [KEY_Z] = "Z",                          [KEY_X] = "X",
546         [KEY_C] = "C",                          [KEY_V] = "V",
547         [KEY_B] = "B",                          [KEY_N] = "N",
548         [KEY_M] = "M",                          [KEY_COMMA] = "Comma",
549         [KEY_DOT] = "Dot",                      [KEY_SLASH] = "Slash",
550         [KEY_RIGHTSHIFT] = "RightShift",        [KEY_KPASTERISK] = "KPAsterisk",
551         [KEY_LEFTALT] = "LeftAlt",              [KEY_SPACE] = "Space",
552         [KEY_CAPSLOCK] = "CapsLock",            [KEY_F1] = "F1",
553         [KEY_F2] = "F2",                        [KEY_F3] = "F3",
554         [KEY_F4] = "F4",                        [KEY_F5] = "F5",
555         [KEY_F6] = "F6",                        [KEY_F7] = "F7",
556         [KEY_F8] = "F8",                        [KEY_F9] = "F9",
557         [KEY_F10] = "F10",                      [KEY_NUMLOCK] = "NumLock",
558         [KEY_SCROLLLOCK] = "ScrollLock",        [KEY_KP7] = "KP7",
559         [KEY_KP8] = "KP8",                      [KEY_KP9] = "KP9",
560         [KEY_KPMINUS] = "KPMinus",              [KEY_KP4] = "KP4",
561         [KEY_KP5] = "KP5",                      [KEY_KP6] = "KP6",
562         [KEY_KPPLUS] = "KPPlus",                [KEY_KP1] = "KP1",
563         [KEY_KP2] = "KP2",                      [KEY_KP3] = "KP3",
564         [KEY_KP0] = "KP0",                      [KEY_KPDOT] = "KPDot",
565         [KEY_ZENKAKUHANKAKU] = "Zenkaku/Hankaku", [KEY_102ND] = "102nd",
566         [KEY_F11] = "F11",                      [KEY_F12] = "F12",
567         [KEY_RO] = "RO",                        [KEY_KATAKANA] = "Katakana",
568         [KEY_HIRAGANA] = "HIRAGANA",            [KEY_HENKAN] = "Henkan",
569         [KEY_KATAKANAHIRAGANA] = "Katakana/Hiragana", [KEY_MUHENKAN] = "Muhenkan",
570         [KEY_KPJPCOMMA] = "KPJpComma",          [KEY_KPENTER] = "KPEnter",
571         [KEY_RIGHTCTRL] = "RightCtrl",          [KEY_KPSLASH] = "KPSlash",
572         [KEY_SYSRQ] = "SysRq",                  [KEY_RIGHTALT] = "RightAlt",
573         [KEY_LINEFEED] = "LineFeed",            [KEY_HOME] = "Home",
574         [KEY_UP] = "Up",                        [KEY_PAGEUP] = "PageUp",
575         [KEY_LEFT] = "Left",                    [KEY_RIGHT] = "Right",
576         [KEY_END] = "End",                      [KEY_DOWN] = "Down",
577         [KEY_PAGEDOWN] = "PageDown",            [KEY_INSERT] = "Insert",
578         [KEY_DELETE] = "Delete",                [KEY_MACRO] = "Macro",
579         [KEY_MUTE] = "Mute",                    [KEY_VOLUMEDOWN] = "VolumeDown",
580         [KEY_VOLUMEUP] = "VolumeUp",            [KEY_POWER] = "Power",
581         [KEY_KPEQUAL] = "KPEqual",              [KEY_KPPLUSMINUS] = "KPPlusMinus",
582         [KEY_PAUSE] = "Pause",                  [KEY_KPCOMMA] = "KPComma",
583         [KEY_HANGUEL] = "Hangeul",              [KEY_HANJA] = "Hanja",
584         [KEY_YEN] = "Yen",                      [KEY_LEFTMETA] = "LeftMeta",
585         [KEY_RIGHTMETA] = "RightMeta",          [KEY_COMPOSE] = "Compose",
586         [KEY_STOP] = "Stop",                    [KEY_AGAIN] = "Again",
587         [KEY_PROPS] = "Props",                  [KEY_UNDO] = "Undo",
588         [KEY_FRONT] = "Front",                  [KEY_COPY] = "Copy",
589         [KEY_OPEN] = "Open",                    [KEY_PASTE] = "Paste",
590         [KEY_FIND] = "Find",                    [KEY_CUT] = "Cut",
591         [KEY_HELP] = "Help",                    [KEY_MENU] = "Menu",
592         [KEY_CALC] = "Calc",                    [KEY_SETUP] = "Setup",
593         [KEY_SLEEP] = "Sleep",                  [KEY_WAKEUP] = "WakeUp",
594         [KEY_FILE] = "File",                    [KEY_SENDFILE] = "SendFile",
595         [KEY_DELETEFILE] = "DeleteFile",        [KEY_XFER] = "X-fer",
596         [KEY_PROG1] = "Prog1",                  [KEY_PROG2] = "Prog2",
597         [KEY_WWW] = "WWW",                      [KEY_MSDOS] = "MSDOS",
598         [KEY_COFFEE] = "Coffee",                [KEY_DIRECTION] = "Direction",
599         [KEY_CYCLEWINDOWS] = "CycleWindows",    [KEY_MAIL] = "Mail",
600         [KEY_BOOKMARKS] = "Bookmarks",          [KEY_COMPUTER] = "Computer",
601         [KEY_BACK] = "Back",                    [KEY_FORWARD] = "Forward",
602         [KEY_CLOSECD] = "CloseCD",              [KEY_EJECTCD] = "EjectCD",
603         [KEY_EJECTCLOSECD] = "EjectCloseCD",    [KEY_NEXTSONG] = "NextSong",
604         [KEY_PLAYPAUSE] = "PlayPause",          [KEY_PREVIOUSSONG] = "PreviousSong",
605         [KEY_STOPCD] = "StopCD",                [KEY_RECORD] = "Record",
606         [KEY_REWIND] = "Rewind",                [KEY_PHONE] = "Phone",
607         [KEY_ISO] = "ISOKey",                   [KEY_CONFIG] = "Config",
608         [KEY_HOMEPAGE] = "HomePage",            [KEY_REFRESH] = "Refresh",
609         [KEY_EXIT] = "Exit",                    [KEY_MOVE] = "Move",
610         [KEY_EDIT] = "Edit",                    [KEY_SCROLLUP] = "ScrollUp",
611         [KEY_SCROLLDOWN] = "ScrollDown",        [KEY_KPLEFTPAREN] = "KPLeftParenthesis",
612         [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_NEW] = "New",
613         [KEY_REDO] = "Redo",                    [KEY_F13] = "F13",
614         [KEY_F14] = "F14",                      [KEY_F15] = "F15",
615         [KEY_F16] = "F16",                      [KEY_F17] = "F17",
616         [KEY_F18] = "F18",                      [KEY_F19] = "F19",
617         [KEY_F20] = "F20",                      [KEY_F21] = "F21",
618         [KEY_F22] = "F22",                      [KEY_F23] = "F23",
619         [KEY_F24] = "F24",                      [KEY_PLAYCD] = "PlayCD",
620         [KEY_PAUSECD] = "PauseCD",              [KEY_PROG3] = "Prog3",
621         [KEY_PROG4] = "Prog4",                  [KEY_SUSPEND] = "Suspend",
622         [KEY_CLOSE] = "Close",                  [KEY_PLAY] = "Play",
623         [KEY_FASTFORWARD] = "FastForward",      [KEY_BASSBOOST] = "BassBoost",
624         [KEY_PRINT] = "Print",                  [KEY_HP] = "HP",
625         [KEY_CAMERA] = "Camera",                [KEY_SOUND] = "Sound",
626         [KEY_QUESTION] = "Question",            [KEY_EMAIL] = "Email",
627         [KEY_CHAT] = "Chat",                    [KEY_SEARCH] = "Search",
628         [KEY_CONNECT] = "Connect",              [KEY_FINANCE] = "Finance",
629         [KEY_SPORT] = "Sport",                  [KEY_SHOP] = "Shop",
630         [KEY_ALTERASE] = "AlternateErase",      [KEY_CANCEL] = "Cancel",
631         [KEY_BRIGHTNESSDOWN] = "BrightnessDown", [KEY_BRIGHTNESSUP] = "BrightnessUp",
632         [KEY_MEDIA] = "Media",                  [KEY_UNKNOWN] = "Unknown",
633         [BTN_0] = "Btn0",                       [BTN_1] = "Btn1",
634         [BTN_2] = "Btn2",                       [BTN_3] = "Btn3",
635         [BTN_4] = "Btn4",                       [BTN_5] = "Btn5",
636         [BTN_6] = "Btn6",                       [BTN_7] = "Btn7",
637         [BTN_8] = "Btn8",                       [BTN_9] = "Btn9",
638         [BTN_LEFT] = "LeftBtn",                 [BTN_RIGHT] = "RightBtn",
639         [BTN_MIDDLE] = "MiddleBtn",             [BTN_SIDE] = "SideBtn",
640         [BTN_EXTRA] = "ExtraBtn",               [BTN_FORWARD] = "ForwardBtn",
641         [BTN_BACK] = "BackBtn",                 [BTN_TASK] = "TaskBtn",
642         [BTN_TRIGGER] = "Trigger",              [BTN_THUMB] = "ThumbBtn",
643         [BTN_THUMB2] = "ThumbBtn2",             [BTN_TOP] = "TopBtn",
644         [BTN_TOP2] = "TopBtn2",                 [BTN_PINKIE] = "PinkieBtn",
645         [BTN_BASE] = "BaseBtn",                 [BTN_BASE2] = "BaseBtn2",
646         [BTN_BASE3] = "BaseBtn3",               [BTN_BASE4] = "BaseBtn4",
647         [BTN_BASE5] = "BaseBtn5",               [BTN_BASE6] = "BaseBtn6",
648         [BTN_DEAD] = "BtnDead",                 [BTN_A] = "BtnA",
649         [BTN_B] = "BtnB",                       [BTN_C] = "BtnC",
650         [BTN_X] = "BtnX",                       [BTN_Y] = "BtnY",
651         [BTN_Z] = "BtnZ",                       [BTN_TL] = "BtnTL",
652         [BTN_TR] = "BtnTR",                     [BTN_TL2] = "BtnTL2",
653         [BTN_TR2] = "BtnTR2",                   [BTN_SELECT] = "BtnSelect",
654         [BTN_START] = "BtnStart",               [BTN_MODE] = "BtnMode",
655         [BTN_THUMBL] = "BtnThumbL",             [BTN_THUMBR] = "BtnThumbR",
656         [BTN_TOOL_PEN] = "ToolPen",             [BTN_TOOL_RUBBER] = "ToolRubber",
657         [BTN_TOOL_BRUSH] = "ToolBrush",         [BTN_TOOL_PENCIL] = "ToolPencil",
658         [BTN_TOOL_AIRBRUSH] = "ToolAirbrush",   [BTN_TOOL_FINGER] = "ToolFinger",
659         [BTN_TOOL_MOUSE] = "ToolMouse",         [BTN_TOOL_LENS] = "ToolLens",
660         [BTN_TOUCH] = "Touch",                  [BTN_STYLUS] = "Stylus",
661         [BTN_STYLUS2] = "Stylus2",              [BTN_TOOL_DOUBLETAP] = "ToolDoubleTap",
662         [BTN_TOOL_TRIPLETAP] = "ToolTripleTap", [BTN_GEAR_DOWN] = "WheelBtn",
663         [BTN_GEAR_UP] = "Gear up",              [KEY_OK] = "Ok",
664         [KEY_SELECT] = "Select",                [KEY_GOTO] = "Goto",
665         [KEY_CLEAR] = "Clear",                  [KEY_POWER2] = "Power2",
666         [KEY_OPTION] = "Option",                [KEY_INFO] = "Info",
667         [KEY_TIME] = "Time",                    [KEY_VENDOR] = "Vendor",
668         [KEY_ARCHIVE] = "Archive",              [KEY_PROGRAM] = "Program",
669         [KEY_CHANNEL] = "Channel",              [KEY_FAVORITES] = "Favorites",
670         [KEY_EPG] = "EPG",                      [KEY_PVR] = "PVR",
671         [KEY_MHP] = "MHP",                      [KEY_LANGUAGE] = "Language",
672         [KEY_TITLE] = "Title",                  [KEY_SUBTITLE] = "Subtitle",
673         [KEY_ANGLE] = "Angle",                  [KEY_ZOOM] = "Zoom",
674         [KEY_MODE] = "Mode",                    [KEY_KEYBOARD] = "Keyboard",
675         [KEY_SCREEN] = "Screen",                [KEY_PC] = "PC",
676         [KEY_TV] = "TV",                        [KEY_TV2] = "TV2",
677         [KEY_VCR] = "VCR",                      [KEY_VCR2] = "VCR2",
678         [KEY_SAT] = "Sat",                      [KEY_SAT2] = "Sat2",
679         [KEY_CD] = "CD",                        [KEY_TAPE] = "Tape",
680         [KEY_RADIO] = "Radio",                  [KEY_TUNER] = "Tuner",
681         [KEY_PLAYER] = "Player",                [KEY_TEXT] = "Text",
682         [KEY_DVD] = "DVD",                      [KEY_AUX] = "Aux",
683         [KEY_MP3] = "MP3",                      [KEY_AUDIO] = "Audio",
684         [KEY_VIDEO] = "Video",                  [KEY_DIRECTORY] = "Directory",
685         [KEY_LIST] = "List",                    [KEY_MEMO] = "Memo",
686         [KEY_CALENDAR] = "Calendar",            [KEY_RED] = "Red",
687         [KEY_GREEN] = "Green",                  [KEY_YELLOW] = "Yellow",
688         [KEY_BLUE] = "Blue",                    [KEY_CHANNELUP] = "ChannelUp",
689         [KEY_CHANNELDOWN] = "ChannelDown",      [KEY_FIRST] = "First",
690         [KEY_LAST] = "Last",                    [KEY_AB] = "AB",
691         [KEY_NEXT] = "Next",                    [KEY_RESTART] = "Restart",
692         [KEY_SLOW] = "Slow",                    [KEY_SHUFFLE] = "Shuffle",
693         [KEY_BREAK] = "Break",                  [KEY_PREVIOUS] = "Previous",
694         [KEY_DIGITS] = "Digits",                [KEY_TEEN] = "TEEN",
695         [KEY_TWEN] = "TWEN",                    [KEY_DEL_EOL] = "DeleteEOL",
696         [KEY_DEL_EOS] = "DeleteEOS",            [KEY_INS_LINE] = "InsertLine",
697         [KEY_DEL_LINE] = "DeleteLine",
698         [KEY_SEND] = "Send",                    [KEY_REPLY] = "Reply",
699         [KEY_FORWARDMAIL] = "ForwardMail",      [KEY_SAVE] = "Save",
700         [KEY_DOCUMENTS] = "Documents",
701         [KEY_FN] = "Fn",                        [KEY_FN_ESC] = "Fn+ESC",
702         [KEY_FN_1] = "Fn+1",                    [KEY_FN_2] = "Fn+2",
703         [KEY_FN_B] = "Fn+B",                    [KEY_FN_D] = "Fn+D",
704         [KEY_FN_E] = "Fn+E",                    [KEY_FN_F] = "Fn+F",
705         [KEY_FN_S] = "Fn+S",
706         [KEY_FN_F1] = "Fn+F1",                  [KEY_FN_F2] = "Fn+F2",
707         [KEY_FN_F3] = "Fn+F3",                  [KEY_FN_F4] = "Fn+F4",
708         [KEY_FN_F5] = "Fn+F5",                  [KEY_FN_F6] = "Fn+F6",
709         [KEY_FN_F7] = "Fn+F7",                  [KEY_FN_F8] = "Fn+F8",
710         [KEY_FN_F9] = "Fn+F9",                  [KEY_FN_F10] = "Fn+F10",
711         [KEY_FN_F11] = "Fn+F11",                [KEY_FN_F12] = "Fn+F12",
712         [KEY_KBDILLUMTOGGLE] = "KbdIlluminationToggle",
713         [KEY_KBDILLUMDOWN] = "KbdIlluminationDown",
714         [KEY_KBDILLUMUP] = "KbdIlluminationUp",
715         [KEY_SWITCHVIDEOMODE] = "SwitchVideoMode",
716 };
717
718 static char *relatives[REL_MAX + 1] = {
719         [REL_X] = "X",                  [REL_Y] = "Y",
720         [REL_Z] = "Z",                  [REL_RX] = "Rx",
721         [REL_RY] = "Ry",                [REL_RZ] = "Rz",
722         [REL_HWHEEL] = "HWheel",        [REL_DIAL] = "Dial",
723         [REL_WHEEL] = "Wheel",          [REL_MISC] = "Misc",
724 };
725
726 static char *absolutes[ABS_MAX + 1] = {
727         [ABS_X] = "X",                  [ABS_Y] = "Y",
728         [ABS_Z] = "Z",                  [ABS_RX] = "Rx",
729         [ABS_RY] = "Ry",                [ABS_RZ] = "Rz",
730         [ABS_THROTTLE] = "Throttle",    [ABS_RUDDER] = "Rudder",
731         [ABS_WHEEL] = "Wheel",          [ABS_GAS] = "Gas",
732         [ABS_BRAKE] = "Brake",          [ABS_HAT0X] = "Hat0X",
733         [ABS_HAT0Y] = "Hat0Y",          [ABS_HAT1X] = "Hat1X",
734         [ABS_HAT1Y] = "Hat1Y",          [ABS_HAT2X] = "Hat2X",
735         [ABS_HAT2Y] = "Hat2Y",          [ABS_HAT3X] = "Hat3X",
736         [ABS_HAT3Y] = "Hat 3Y",         [ABS_PRESSURE] = "Pressure",
737         [ABS_DISTANCE] = "Distance",    [ABS_TILT_X] = "XTilt",
738         [ABS_TILT_Y] = "YTilt",         [ABS_TOOL_WIDTH] = "Tool Width",
739         [ABS_VOLUME] = "Volume",        [ABS_MISC] = "Misc",
740 };
741
742 static char *misc[MSC_MAX + 1] = {
743         [MSC_SERIAL] = "Serial",        [MSC_PULSELED] = "Pulseled",
744         [MSC_GESTURE] = "Gesture",      [MSC_RAW] = "RawData"
745 };
746
747 static char *leds[LED_MAX + 1] = {
748         [LED_NUML] = "NumLock",         [LED_CAPSL] = "CapsLock",
749         [LED_SCROLLL] = "ScrollLock",   [LED_COMPOSE] = "Compose",
750         [LED_KANA] = "Kana",            [LED_SLEEP] = "Sleep",
751         [LED_SUSPEND] = "Suspend",      [LED_MUTE] = "Mute",
752         [LED_MISC] = "Misc",
753 };
754
755 static char *repeats[REP_MAX + 1] = {
756         [REP_DELAY] = "Delay",          [REP_PERIOD] = "Period"
757 };
758
759 static char *sounds[SND_MAX + 1] = {
760         [SND_CLICK] = "Click",          [SND_BELL] = "Bell",
761         [SND_TONE] = "Tone"
762 };
763
764 static char **names[EV_MAX + 1] = {
765         [EV_SYN] = syncs,                       [EV_KEY] = keys,
766         [EV_REL] = relatives,                   [EV_ABS] = absolutes,
767         [EV_MSC] = misc,                        [EV_LED] = leds,
768         [EV_SND] = sounds,                      [EV_REP] = repeats,
769 };
770
771 void hid_resolv_event(__u8 type, __u16 code) {
772
773         if (!hid_debug)
774                 return;
775
776         printk("%s.%s", events[type] ? events[type] : "?",
777                 names[type] ? (names[type][code] ? names[type][code] : "?") : "?");
778 }
779 EXPORT_SYMBOL_GPL(hid_resolv_event);
780