]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | UsbDxeLib.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Common Dxe Libarary for USB\r | |
19 | Add Constants & structure definitions for Usb HID\r | |
20 | \r | |
21 | Revision History\r | |
22 | \r | |
23 | --*/\r | |
24 | \r | |
25 | #ifndef _USB_DXE_LIB_H\r | |
26 | #define _USB_DXE_LIB_H\r | |
27 | \r | |
28 | //\r | |
29 | // define the timeout time as 3ms\r | |
30 | //\r | |
31 | #define TIMEOUT_VALUE 3 * 1000\r | |
32 | \r | |
33 | //\r | |
34 | // HID constants definition, see HID rev1.0\r | |
35 | //\r | |
36 | //\r | |
37 | // HID report item format\r | |
38 | //\r | |
39 | #define HID_ITEM_FORMAT_SHORT 0\r | |
40 | #define HID_ITEM_FORMAT_LONG 1\r | |
41 | \r | |
42 | //\r | |
43 | // Special tag indicating long items\r | |
44 | //\r | |
45 | #define HID_ITEM_TAG_LONG 15\r | |
46 | \r | |
47 | //\r | |
48 | // HID report descriptor item type (prefix bit 2,3)\r | |
49 | //\r | |
50 | #define HID_ITEM_TYPE_MAIN 0\r | |
51 | #define HID_ITEM_TYPE_GLOBAL 1\r | |
52 | #define HID_ITEM_TYPE_LOCAL 2\r | |
53 | #define HID_ITEM_TYPE_RESERVED 3\r | |
54 | \r | |
55 | //\r | |
56 | // HID report descriptor main item tags\r | |
57 | //\r | |
58 | #define HID_MAIN_ITEM_TAG_INPUT 8\r | |
59 | #define HID_MAIN_ITEM_TAG_OUTPUT 9\r | |
60 | #define HID_MAIN_ITEM_TAG_FEATURE 11\r | |
61 | #define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10\r | |
62 | #define HID_MAIN_ITEM_TAG_END_COLLECTION 12\r | |
63 | \r | |
64 | //\r | |
65 | // HID report descriptor main item contents\r | |
66 | //\r | |
67 | #define HID_MAIN_ITEM_CONSTANT 0x001\r | |
68 | #define HID_MAIN_ITEM_VARIABLE 0x002\r | |
69 | #define HID_MAIN_ITEM_RELATIVE 0x004\r | |
70 | #define HID_MAIN_ITEM_WRAP 0x008\r | |
71 | #define HID_MAIN_ITEM_NONLINEAR 0x010\r | |
72 | #define HID_MAIN_ITEM_NO_PREFERRED 0x020\r | |
73 | #define HID_MAIN_ITEM_NULL_STATE 0x040\r | |
74 | #define HID_MAIN_ITEM_VOLATILE 0x080\r | |
75 | #define HID_MAIN_ITEM_BUFFERED_BYTE 0x100\r | |
76 | \r | |
77 | //\r | |
78 | // HID report descriptor collection item types\r | |
79 | //\r | |
80 | #define HID_COLLECTION_PHYSICAL 0\r | |
81 | #define HID_COLLECTION_APPLICATION 1\r | |
82 | #define HID_COLLECTION_LOGICAL 2\r | |
83 | \r | |
84 | //\r | |
85 | // HID report descriptor global item tags\r | |
86 | //\r | |
87 | #define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0\r | |
88 | #define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1\r | |
89 | #define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2\r | |
90 | #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3\r | |
91 | #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4\r | |
92 | #define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5\r | |
93 | #define HID_GLOBAL_ITEM_TAG_UNIT 6\r | |
94 | #define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7\r | |
95 | #define HID_GLOBAL_ITEM_TAG_REPORT_ID 8\r | |
96 | #define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9\r | |
97 | #define HID_GLOBAL_ITEM_TAG_PUSH 10\r | |
98 | #define HID_GLOBAL_ITEM_TAG_POP 11\r | |
99 | \r | |
100 | //\r | |
101 | // HID report descriptor local item tags\r | |
102 | //\r | |
103 | #define HID_LOCAL_ITEM_TAG_USAGE 0\r | |
104 | #define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1\r | |
105 | #define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2\r | |
106 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3\r | |
107 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4\r | |
108 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5\r | |
109 | #define HID_LOCAL_ITEM_TAG_STRING_INDEX 7\r | |
110 | #define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8\r | |
111 | #define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9\r | |
112 | #define HID_LOCAL_ITEM_TAG_DELIMITER 10\r | |
113 | \r | |
114 | //\r | |
115 | // HID usage tables\r | |
116 | //\r | |
117 | #define HID_USAGE_PAGE 0xffff0000\r | |
118 | \r | |
119 | #define HID_UP_GENDESK 0x00010000\r | |
120 | #define HID_UP_KEYBOARD 0x00070000\r | |
121 | #define HID_UP_LED 0x00080000\r | |
122 | #define HID_UP_BUTTON 0x00090000\r | |
123 | #define HID_UP_CONSUMER 0x000c0000\r | |
124 | #define HID_UP_DIGITIZER 0x000d0000\r | |
125 | #define HID_UP_PID 0x000f0000\r | |
126 | \r | |
127 | #define HID_USAGE 0x0000ffff\r | |
128 | \r | |
129 | #define HID_GD_POINTER 0x00010001\r | |
130 | #define HID_GD_MOUSE 0x00010002\r | |
131 | #define HID_GD_JOYSTICK 0x00010004\r | |
132 | #define HID_GD_GAMEPAD 0x00010005\r | |
133 | #define HID_GD_HATSWITCH 0x00010039\r | |
134 | \r | |
135 | //\r | |
136 | // HID report types\r | |
137 | //\r | |
138 | #define HID_INPUT_REPORT 1\r | |
139 | #define HID_OUTPUT_REPORT 2\r | |
140 | #define HID_FEATURE_REPORT 3\r | |
141 | \r | |
142 | //\r | |
143 | // HID device quirks.\r | |
144 | //\r | |
145 | #define HID_QUIRK_INVERT 0x01\r | |
146 | #define HID_QUIRK_NOTOUCH 0x02\r | |
147 | \r | |
148 | //\r | |
149 | // HID class protocol request\r | |
150 | //\r | |
151 | #define EFI_USB_GET_REPORT_REQUEST 0x01\r | |
152 | #define EFI_USB_GET_IDLE_REQUEST 0x02\r | |
153 | #define EFI_USB_GET_PROTOCOL_REQUEST 0x03\r | |
154 | #define EFI_USB_SET_REPORT_REQUEST 0x09\r | |
155 | #define EFI_USB_SET_IDLE_REQUEST 0x0a\r | |
156 | #define EFI_USB_SET_PROTOCOL_REQUEST 0x0b\r | |
157 | \r | |
158 | #pragma pack(1)\r | |
159 | //\r | |
160 | // Descriptor header for Report/Physical Descriptors\r | |
161 | //\r | |
162 | typedef struct hid_class_descriptor {\r | |
163 | UINT8 DescriptorType;\r | |
164 | UINT16 DescriptorLength;\r | |
165 | } EFI_USB_HID_CLASS_DESCRIPTOR;\r | |
166 | \r | |
167 | typedef struct hid_descriptor {\r | |
168 | UINT8 Length;\r | |
169 | UINT8 DescriptorType;\r | |
170 | UINT16 BcdHID;\r | |
171 | UINT8 CountryCode;\r | |
172 | UINT8 NumDescriptors;\r | |
173 | EFI_USB_HID_CLASS_DESCRIPTOR HidClassDesc[1];\r | |
174 | } EFI_USB_HID_DESCRIPTOR;\r | |
175 | \r | |
176 | #pragma pack()\r | |
177 | \r | |
178 | EFI_STATUS\r | |
179 | UsbGetHidDescriptor (\r | |
180 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
181 | IN UINT8 InterfaceNum,\r | |
182 | OUT EFI_USB_HID_DESCRIPTOR *HidDescriptor\r | |
183 | );\r | |
184 | \r | |
185 | EFI_STATUS\r | |
186 | UsbGetReportDescriptor (\r | |
187 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
188 | IN UINT8 InterfaceNum,\r | |
189 | IN UINT16 DescriptorSize,\r | |
190 | OUT UINT8 *DescriptorBuffer\r | |
191 | );\r | |
192 | \r | |
193 | EFI_STATUS\r | |
194 | UsbGetProtocolRequest (\r | |
195 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
196 | IN UINT8 Interface,\r | |
197 | IN UINT8 *Protocol\r | |
198 | );\r | |
199 | \r | |
200 | EFI_STATUS\r | |
201 | UsbSetProtocolRequest (\r | |
202 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
203 | IN UINT8 Interface,\r | |
204 | IN UINT8 Protocol\r | |
205 | );\r | |
206 | \r | |
207 | EFI_STATUS\r | |
208 | UsbSetIdleRequest (\r | |
209 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
210 | IN UINT8 Interface,\r | |
211 | IN UINT8 ReportId,\r | |
212 | IN UINT8 Duration\r | |
213 | );\r | |
214 | \r | |
215 | EFI_STATUS\r | |
216 | UsbGetIdleRequest (\r | |
217 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
218 | IN UINT8 Interface,\r | |
219 | IN UINT8 ReportId,\r | |
220 | OUT UINT8 *Duration\r | |
221 | );\r | |
222 | \r | |
223 | EFI_STATUS\r | |
224 | UsbSetReportRequest (\r | |
225 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
226 | IN UINT8 Interface,\r | |
227 | IN UINT8 ReportId,\r | |
228 | IN UINT8 ReportType,\r | |
229 | IN UINT16 ReportLen,\r | |
230 | IN UINT8 *Report\r | |
231 | );\r | |
232 | \r | |
233 | EFI_STATUS\r | |
234 | UsbGetReportRequest (\r | |
235 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
236 | IN UINT8 Interface,\r | |
237 | IN UINT8 ReportId,\r | |
238 | IN UINT8 ReportType,\r | |
239 | IN UINT16 ReportLen,\r | |
240 | IN UINT8 *Report\r | |
241 | );\r | |
242 | \r | |
243 | //\r | |
244 | // Get Device Descriptor\r | |
245 | //\r | |
246 | EFI_STATUS\r | |
247 | UsbGetDescriptor (\r | |
248 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
249 | IN UINT16 Value,\r | |
250 | IN UINT16 Index,\r | |
251 | IN UINT16 DescriptorLength,\r | |
252 | OUT VOID *Descriptor,\r | |
253 | OUT UINT32 *Status\r | |
254 | );\r | |
255 | \r | |
256 | //\r | |
257 | // Set Device Descriptor\r | |
258 | //\r | |
259 | EFI_STATUS\r | |
260 | UsbSetDescriptor (\r | |
261 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
262 | IN UINT16 Value,\r | |
263 | IN UINT16 Index,\r | |
264 | IN UINT16 DescriptorLength,\r | |
265 | IN VOID *Descriptor,\r | |
266 | OUT UINT32 *Status\r | |
267 | );\r | |
268 | \r | |
269 | //\r | |
270 | // Get device Interface\r | |
271 | //\r | |
272 | EFI_STATUS\r | |
273 | UsbGetDeviceInterface (\r | |
274 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
275 | IN UINT16 Index,\r | |
276 | OUT UINT8 *AltSetting,\r | |
277 | OUT UINT32 *Status\r | |
278 | );\r | |
279 | \r | |
280 | //\r | |
281 | // Set device interface\r | |
282 | //\r | |
283 | EFI_STATUS\r | |
284 | UsbSetDeviceInterface (\r | |
285 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
286 | IN UINT16 InterfaceNo,\r | |
287 | IN UINT16 AltSetting,\r | |
288 | OUT UINT32 *Status\r | |
289 | );\r | |
290 | \r | |
291 | //\r | |
292 | // Get device configuration\r | |
293 | //\r | |
294 | EFI_STATUS\r | |
295 | UsbGetDeviceConfiguration (\r | |
296 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
297 | OUT UINT8 *ConfigValue,\r | |
298 | OUT UINT32 *Status\r | |
299 | );\r | |
300 | \r | |
301 | //\r | |
302 | // Set device configuration\r | |
303 | //\r | |
304 | EFI_STATUS\r | |
305 | UsbSetDeviceConfiguration (\r | |
306 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
307 | IN UINT16 Value,\r | |
308 | OUT UINT32 *Status\r | |
309 | );\r | |
310 | \r | |
311 | //\r | |
312 | // Set Device Feature\r | |
313 | //\r | |
314 | EFI_STATUS\r | |
315 | UsbSetDeviceFeature (\r | |
316 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
317 | IN EFI_USB_RECIPIENT Recipient,\r | |
318 | IN UINT16 Value,\r | |
319 | IN UINT16 Target,\r | |
320 | OUT UINT32 *Status\r | |
321 | );\r | |
322 | \r | |
323 | //\r | |
324 | // Clear Device Feature\r | |
325 | //\r | |
326 | EFI_STATUS\r | |
327 | UsbClearDeviceFeature (\r | |
328 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
329 | IN EFI_USB_RECIPIENT Recipient,\r | |
330 | IN UINT16 Value,\r | |
331 | IN UINT16 Target,\r | |
332 | OUT UINT32 *Status\r | |
333 | );\r | |
334 | \r | |
335 | //\r | |
336 | // Get Device Status\r | |
337 | //\r | |
338 | EFI_STATUS\r | |
339 | UsbGetDeviceStatus (\r | |
340 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
341 | IN EFI_USB_RECIPIENT Recipient,\r | |
342 | IN UINT16 Target,\r | |
343 | OUT UINT16 *DevStatus,\r | |
344 | OUT UINT32 *Status\r | |
345 | );\r | |
346 | \r | |
347 | //\r | |
348 | // The following APIs are not basic library, but they are common used.\r | |
349 | //\r | |
350 | //\r | |
351 | // Usb Get String\r | |
352 | //\r | |
353 | EFI_STATUS\r | |
354 | UsbGetString (\r | |
355 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
356 | IN UINT16 LangID,\r | |
357 | IN UINT8 Index,\r | |
358 | IN VOID *Buf,\r | |
359 | IN UINTN BufSize,\r | |
360 | OUT UINT32 *Status\r | |
361 | );\r | |
362 | \r | |
363 | //\r | |
364 | // Clear endpoint stall\r | |
365 | //\r | |
366 | EFI_STATUS\r | |
367 | UsbClearEndpointHalt (\r | |
368 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
369 | IN UINT8 EndpointNo,\r | |
370 | OUT UINT32 *Status\r | |
371 | );\r | |
372 | \r | |
373 | #endif\r |