2 * $Id: hid-debug.h,v 1.2 2000/05/29 10:54:53 vojtech Exp $
4 * (c) 1999 Andreas Gal <gal@cs.uni-magdeburg.de>
5 * (c) 2000 Vojtech Pavlik <vojtech@suse.cz>
7 * Some debug stuff for the HID parser.
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.
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.
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
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
29 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
32 struct hid_usage_entry
{
38 static struct hid_usage_entry hid_usage_table
[] = {
39 { 1, 0, "GenericDesktop" },
42 {0, 0x04, "Joystick"},
44 {0, 0x06, "Keyboard"},
46 {0, 0x08, "MultiAxis"},
56 {0, 0x39, "HatSwitch"},
57 {0, 0x3a, "CountedBuffer"},
58 {0, 0x3b, "ByteCount"},
59 {0, 0x3c, "MotionWakeup"},
69 {0, 0x80, "SystemControl"},
70 {0, 0x81, "SystemPowerDown"},
71 {0, 0x82, "SystemSleep"},
72 {0, 0x83, "SystemWakeUp"},
73 {0, 0x84, "SystemContextMenu"},
74 {0, 0x85, "SystemMainMenu"},
75 {0, 0x86, "SystemAppMenu"},
76 {0, 0x87, "SystemMenuHelp"},
77 {0, 0x88, "SystemMenuExit"},
78 {0, 0x89, "SystemMenuSelect"},
79 {0, 0x8a, "SystemMenuRight"},
80 {0, 0x8b, "SystemMenuLeft"},
81 {0, 0x8c, "SystemMenuUp"},
82 {0, 0x8d, "SystemMenuDown"},
84 {0, 0x91, "D-padDown"},
85 {0, 0x92, "D-padRight"},
86 {0, 0x93, "D-padLeft"},
91 { 13, 0, "Digitizers" },
92 {0, 0x01, "Digitizer"},
94 {0, 0x03, "LightPen"},
95 {0, 0x04, "TouchScreen"},
96 {0, 0x05, "TouchPad"},
100 {0, 0x30, "TipPressure"},
101 {0, 0x31, "BarrelPressure"},
102 {0, 0x32, "InRange"},
104 {0, 0x34, "UnTouch"},
106 {0, 0x39, "TabletFunctionKey"},
107 {0, 0x3a, "ProgramChangeKey"},
109 {0, 0x42, "TipSwitch"},
110 {0, 0x43, "SecondaryTipSwitch"},
111 {0, 0x44, "BarrelSwitch"},
113 {0, 0x46, "TabletPick"},
114 { 15, 0, "PhysicalInterfaceDevice" },
118 static void resolv_usage_page(unsigned page
) {
119 struct hid_usage_entry
*p
;
121 for (p
= hid_usage_table
; p
->description
; p
++)
122 if (p
->page
== page
) {
123 printk("%s", p
->description
);
126 printk("%04x", page
);
129 static void resolv_usage(unsigned usage
) {
130 struct hid_usage_entry
*p
;
132 resolv_usage_page(usage
>> 16);
134 for (p
= hid_usage_table
; p
->description
; p
++)
135 if (p
->page
== (usage
>> 16)) {
136 for(++p
; p
->description
&& p
->page
== 0; p
++)
137 if (p
->usage
== (usage
& 0xffff)) {
138 printk("%s", p
->description
);
143 printk("%04x", usage
& 0xffff);
146 __inline__
static void tab(int n
) {
147 while (n
--) printk(" ");
150 static void hid_dump_field(struct hid_field
*field
, int n
) {
153 if (field
->physical
) {
156 resolv_usage(field
->physical
); printk(")\n");
158 if (field
->logical
) {
161 resolv_usage(field
->logical
); printk(")\n");
163 tab(n
); printk("Usage(%d)\n", field
->maxusage
);
164 for (j
= 0; j
< field
->maxusage
; j
++) {
165 tab(n
+2);resolv_usage(field
->usage
[j
].hid
); printk("\n");
167 if (field
->logical_minimum
!= field
->logical_maximum
) {
168 tab(n
); printk("Logical Minimum(%d)\n", field
->logical_minimum
);
169 tab(n
); printk("Logical Maximum(%d)\n", field
->logical_maximum
);
171 if (field
->physical_minimum
!= field
->physical_maximum
) {
172 tab(n
); printk("Physical Minimum(%d)\n", field
->physical_minimum
);
173 tab(n
); printk("Physical Maximum(%d)\n", field
->physical_maximum
);
175 if (field
->unit_exponent
) {
176 tab(n
); printk("Unit Exponent(%d)\n", field
->unit_exponent
);
179 tab(n
); printk("Unit(%u)\n", field
->unit
);
181 tab(n
); printk("Report Size(%u)\n", field
->report_size
);
182 tab(n
); printk("Report Count(%u)\n", field
->report_count
);
183 tab(n
); printk("Report Offset(%u)\n", field
->report_offset
);
185 tab(n
); printk("Flags( ");
187 printk("%s", HID_MAIN_ITEM_CONSTANT
& j
? "Constant " : "");
188 printk("%s", HID_MAIN_ITEM_VARIABLE
& j
? "Variable " : "Array ");
189 printk("%s", HID_MAIN_ITEM_RELATIVE
& j
? "Relative " : "Absolute ");
190 printk("%s", HID_MAIN_ITEM_WRAP
& j
? "Wrap " : "");
191 printk("%s", HID_MAIN_ITEM_NONLINEAR
& j
? "NonLinear " : "");
192 printk("%s", HID_MAIN_ITEM_NO_PREFERRED
& j
? "NoPrefferedState " : "");
193 printk("%s", HID_MAIN_ITEM_NULL_STATE
& j
? "NullState " : "");
194 printk("%s", HID_MAIN_ITEM_VOLATILE
& j
? "Volatile " : "");
195 printk("%s", HID_MAIN_ITEM_BUFFERED_BYTE
& j
? "BufferedByte " : "");
199 void hid_dump_device(struct hid_device
*device
) {
200 struct hid_report_enum
*report_enum
;
201 struct hid_report
*report
;
202 struct list_head
*list
;
204 static char *table
[] = {"INPUT", "OUTPUT", "FEATURE"};
206 printk("Application(");
207 resolv_usage(device
->application
);
210 for (i
= 0; i
< HID_REPORT_TYPES
; i
++) {
211 report_enum
= device
->report_enum
+ i
;
212 list
= report_enum
->report_list
.next
;
213 while (list
!= &report_enum
->report_list
) {
214 report
= (struct hid_report
*) list
;
216 printk("%s", table
[i
]);
218 printk("(%d)", report
->id
);
219 printk("[%s]", table
[report
->type
]);
221 for (k
= 0; k
< report
->maxfield
; k
++) {
223 printk("Field(%d)\n", k
);
224 hid_dump_field(report
->field
[k
], 6);
231 void hid_dump_input(struct hid_usage
*usage
, __s32 value
) {
232 printk("hidd: input ");
233 resolv_usage(usage
->hid
);
234 printk(" = %d\n", value
);