]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/UefiUsbLib.h
synchronize the MdePkg/Include/Library/BaseLib.h and the MDE_Library_Spec.
[mirror_edk2.git] / MdePkg / Include / Library / UefiUsbLib.h
CommitLineData
842f5579 1/** @file\r
50a64e5b 2 Provides most usb APIs to support the Hid requests defined in Usb Hid 1.1 spec\r
3 and the standard requests defined in Usb 1.1 spec.\r
fb3df220 4\r
50a64e5b 5Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
6All rights reserved. This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
842f5579 10\r
50a64e5b 11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
842f5579
A
13\r
14**/\r
fb3df220 15\r
fb3df220 16\r
842f5579
A
17#ifndef __USB_DXE_LIB_H__\r
18#define __USB_DXE_LIB_H__\r
fb3df220 19\r
c7d265a9 20#include <Protocol/UsbIo.h>\r
ed838d0c 21\r
fc30687f 22///\r
23/// define the timeout time as 3ms\r
24///\r
fb3df220 25#define TIMEOUT_VALUE 3 * 1000\r
26\r
373b5cf9 27/**\r
2c8547ab 28 Get Hid Descriptor.\r
373b5cf9 29\r
2c8547ab 30 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
31 @param InterfaceNum Hid interface number.\r
373b5cf9 32 @param HidDescriptor Caller allocated buffer to store Usb hid descriptor if\r
33 successfully returned.\r
34\r
35 @return Status of getting HID descriptor through USB I/O\r
36 protocol's UsbControlTransfer().\r
37\r
38**/\r
fb3df220 39EFI_STATUS\r
f1787349 40EFIAPI\r
fb3df220 41UsbGetHidDescriptor (\r
42 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
43 IN UINT8 InterfaceNum,\r
44 OUT EFI_USB_HID_DESCRIPTOR *HidDescriptor\r
45 );\r
46\r
373b5cf9 47\r
48/**\r
2c8547ab 49 get Report Class descriptor.\r
373b5cf9 50\r
2c8547ab 51 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
373b5cf9 52 @param InterfaceNum Report interface number.\r
53 @param DescriptorSize Length of DescriptorBuffer.\r
54 @param DescriptorBuffer Caller allocated buffer to store Usb report descriptor\r
55 if successfully returned.\r
56\r
57 @return Status of getting Report Class descriptor through USB\r
58 I/O protocol's UsbControlTransfer().\r
59\r
60**/\r
fb3df220 61EFI_STATUS\r
f1787349 62EFIAPI\r
fb3df220 63UsbGetReportDescriptor (\r
64 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
65 IN UINT8 InterfaceNum,\r
66 IN UINT16 DescriptorSize,\r
67 OUT UINT8 *DescriptorBuffer\r
68 );\r
69\r
373b5cf9 70/**\r
2c8547ab 71 Get Hid Protocol Request.\r
373b5cf9 72\r
2c8547ab 73 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
74 @param Interface Which interface the caller wants to get protocol.\r
373b5cf9 75 @param Protocol Protocol value returned.\r
76\r
77 @return Status of getting Protocol Request through USB I/O\r
78 protocol's UsbControlTransfer().\r
79\r
80**/\r
fb3df220 81EFI_STATUS\r
f1787349 82EFIAPI\r
fb3df220 83UsbGetProtocolRequest (\r
84 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
85 IN UINT8 Interface,\r
86 IN UINT8 *Protocol\r
87 );\r
88\r
373b5cf9 89/**\r
2c8547ab 90 Set Hid Protocol Request.\r
373b5cf9 91\r
2c8547ab 92 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
93 @param Interface Which interface the caller wants to set protocol.\r
373b5cf9 94 @param Protocol Protocol value the caller wants to set.\r
95\r
96 @return Status of setting Protocol Request through USB I/O\r
97 protocol's UsbControlTransfer().\r
98\r
99**/\r
fb3df220 100EFI_STATUS\r
f1787349 101EFIAPI\r
fb3df220 102UsbSetProtocolRequest (\r
103 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
104 IN UINT8 Interface,\r
105 IN UINT8 Protocol\r
106 );\r
107\r
373b5cf9 108/**\r
109 Set Idel request.\r
110\r
2c8547ab 111 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
373b5cf9 112 @param Interface Which interface the caller wants to set.\r
113 @param ReportId Which report the caller wants to set.\r
114 @param Duration Idle rate the caller wants to set.\r
115\r
116 @return Status of setting IDLE Request through USB I/O\r
117 protocol's UsbControlTransfer().\r
118\r
119**/\r
fb3df220 120EFI_STATUS\r
f1787349 121EFIAPI\r
fb3df220 122UsbSetIdleRequest (\r
123 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
124 IN UINT8 Interface,\r
125 IN UINT8 ReportId,\r
126 IN UINT8 Duration\r
127 );\r
128\r
373b5cf9 129/**\r
130 Get Idel request.\r
131\r
2c8547ab 132 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
373b5cf9 133 @param Interface Which interface the caller wants to get.\r
134 @param ReportId Which report the caller wants to get.\r
135 @param Duration Idle rate the caller wants to get.\r
136\r
137 @return Status of getting IDLE Request through USB I/O\r
138 protocol's UsbControlTransfer().\r
139\r
140**/\r
fb3df220 141EFI_STATUS\r
f1787349 142EFIAPI\r
fb3df220 143UsbGetIdleRequest (\r
144 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
145 IN UINT8 Interface,\r
146 IN UINT8 ReportId,\r
147 OUT UINT8 *Duration\r
148 );\r
149\r
373b5cf9 150/**\r
151 Hid Set Report request.\r
152\r
2c8547ab 153 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
373b5cf9 154 @param Interface Which interface the caller wants to set.\r
155 @param ReportId Which report the caller wants to set.\r
156 @param ReportType Type of report.\r
157 @param ReportLen Length of report descriptor.\r
158 @param Report Report Descriptor buffer.\r
159\r
160 @return Status of setting Report Request through USB I/O\r
161 protocol's UsbControlTransfer().\r
162\r
163**/\r
fb3df220 164EFI_STATUS\r
f1787349 165EFIAPI\r
fb3df220 166UsbSetReportRequest (\r
167 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
168 IN UINT8 Interface,\r
169 IN UINT8 ReportId,\r
170 IN UINT8 ReportType,\r
171 IN UINT16 ReportLen,\r
172 IN UINT8 *Report\r
173 );\r
174\r
373b5cf9 175/**\r
176 Hid Set Report request.\r
177\r
2c8547ab 178 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
373b5cf9 179 @param Interface Which interface the caller wants to set.\r
180 @param ReportId Which report the caller wants to set.\r
181 @param ReportType Type of report.\r
182 @param ReportLen Length of report descriptor.\r
183 @param Report Caller allocated buffer to store Report Descriptor.\r
184\r
185 @return Status of getting Report Request through USB I/O\r
186 protocol's UsbControlTransfer().\r
187\r
188**/\r
fb3df220 189EFI_STATUS\r
f1787349 190EFIAPI\r
fb3df220 191UsbGetReportRequest (\r
192 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
193 IN UINT8 Interface,\r
194 IN UINT8 ReportId,\r
195 IN UINT8 ReportType,\r
196 IN UINT16 ReportLen,\r
197 IN UINT8 *Report\r
198 );\r
199\r
373b5cf9 200/**\r
2c8547ab 201 Usb Get Descriptor.\r
373b5cf9 202\r
2c8547ab 203 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
204 @param Value Device Request Value.\r
205 @param Index Device Request Index.\r
206 @param DescriptorLength Descriptor Length.\r
207 @param Descriptor Descriptor buffer to contain result.\r
208 @param Status Transfer Status.\r
373b5cf9 209\r
2c8547ab 210 @retval EFI_INVALID_PARAMETER Parameter is error.\r
211 @retval EFI_SUCCESS Success.\r
212 @retval EFI_TIMEOUT Device has no response.\r
373b5cf9 213\r
214**/\r
fb3df220 215EFI_STATUS\r
9199040c 216EFIAPI\r
fb3df220 217UsbGetDescriptor (\r
218 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
219 IN UINT16 Value,\r
220 IN UINT16 Index,\r
221 IN UINT16 DescriptorLength,\r
222 OUT VOID *Descriptor,\r
223 OUT UINT32 *Status\r
224 );\r
225\r
373b5cf9 226/**\r
2c8547ab 227 Usb Set Descriptor.\r
373b5cf9 228\r
2c8547ab 229 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
230 @param Value Device Request Value.\r
231 @param Index Device Request Index.\r
232 @param DescriptorLength Descriptor Length.\r
233 @param Descriptor Descriptor buffer to set.\r
234 @param Status Transfer Status.\r
373b5cf9 235\r
2c8547ab 236 @retval EFI_INVALID_PARAMETER Parameter is error.\r
237 @retval EFI_SUCCESS Success.\r
238 @retval EFI_TIMEOUT Device has no response.\r
373b5cf9 239\r
240**/\r
fb3df220 241EFI_STATUS\r
f1787349 242EFIAPI\r
fb3df220 243UsbSetDescriptor (\r
244 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
245 IN UINT16 Value,\r
246 IN UINT16 Index,\r
247 IN UINT16 DescriptorLength,\r
248 IN VOID *Descriptor,\r
249 OUT UINT32 *Status\r
250 );\r
251\r
373b5cf9 252/**\r
2c8547ab 253 Usb Get Device Interface.\r
373b5cf9 254\r
2c8547ab 255 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
256 @param Index Interface index value.\r
257 @param AltSetting Alternate setting.\r
258 @param Status Trasnsfer status.\r
373b5cf9 259\r
2c8547ab 260 @retval EFI_INVALID_PARAMETER Parameter is error.\r
261 @retval EFI_SUCCESS Success.\r
262 @retval EFI_TIMEOUT Device has no response.\r
373b5cf9 263\r
264**/\r
fb3df220 265EFI_STATUS\r
f1787349 266EFIAPI\r
ed838d0c 267UsbGetInterface (\r
fb3df220 268 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
269 IN UINT16 Index,\r
270 OUT UINT8 *AltSetting,\r
271 OUT UINT32 *Status\r
272 );\r
273\r
373b5cf9 274/**\r
2c8547ab 275 Usb Set Device Interface.\r
373b5cf9 276\r
2c8547ab 277 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
278 @param InterfaceNo Interface Number.\r
279 @param AltSetting Alternate setting.\r
280 @param Status Trasnsfer status.\r
373b5cf9 281\r
2c8547ab 282 @retval EFI_INVALID_PARAMETER Parameter is error.\r
283 @retval EFI_SUCCESS Success.\r
284 @retval EFI_TIMEOUT Device has no response.\r
373b5cf9 285\r
286**/\r
fb3df220 287EFI_STATUS\r
f1787349 288EFIAPI\r
ed838d0c 289UsbSetInterface (\r
fb3df220 290 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
291 IN UINT16 InterfaceNo,\r
292 IN UINT16 AltSetting,\r
293 OUT UINT32 *Status\r
294 );\r
295\r
373b5cf9 296/**\r
2c8547ab 297 Usb Get Device Configuration.\r
373b5cf9 298\r
2c8547ab 299 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
300 @param ConfigValue Config Value.\r
301 @param Status Transfer Status.\r
373b5cf9 302\r
2c8547ab 303 @retval EFI_INVALID_PARAMETER Parameter is error.\r
304 @retval EFI_SUCCESS Success.\r
305 @retval EFI_TIMEOUT Device has no response.\r
373b5cf9 306\r
307**/\r
fb3df220 308EFI_STATUS\r
f1787349 309EFIAPI\r
ed838d0c 310UsbGetConfiguration (\r
fb3df220 311 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
312 OUT UINT8 *ConfigValue,\r
313 OUT UINT32 *Status\r
314 );\r
315\r
373b5cf9 316/**\r
2c8547ab 317 Usb Set Device Configuration.\r
373b5cf9 318\r
2c8547ab 319 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
320 @param Value Configuration Value to set.\r
321 @param Status Transfer status.\r
373b5cf9 322\r
2c8547ab 323 @retval EFI_INVALID_PARAMETER Parameter is error.\r
324 @retval EFI_SUCCESS Success.\r
325 @retval EFI_TIMEOUT Device has no response.\r
373b5cf9 326\r
327**/\r
fb3df220 328EFI_STATUS\r
f1787349 329EFIAPI\r
ed838d0c 330UsbSetConfiguration (\r
fb3df220 331 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
332 IN UINT16 Value,\r
333 OUT UINT32 *Status\r
334 );\r
335\r
373b5cf9 336/**\r
2c8547ab 337 Usb Set Device Feature.\r
373b5cf9 338\r
2c8547ab 339 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
340 @param Recipient Interface/Device/Endpoint.\r
341 @param Value Request value.\r
342 @param Target Request Index.\r
343 @param Status Transfer status.\r
373b5cf9 344\r
2c8547ab 345 @retval EFI_INVALID_PARAMETER Parameter is error.\r
346 @retval EFI_SUCCESS Success.\r
347 @retval EFI_TIMEOUT Device has no response.\r
373b5cf9 348\r
349**/\r
fb3df220 350EFI_STATUS\r
f1787349 351EFIAPI\r
ed838d0c 352UsbSetFeature (\r
fb3df220 353 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
ed838d0c 354 IN UINTN Recipient,\r
fb3df220 355 IN UINT16 Value,\r
356 IN UINT16 Target,\r
357 OUT UINT32 *Status\r
358 );\r
359\r
373b5cf9 360/**\r
2c8547ab 361 Usb Clear Device Feature.\r
373b5cf9 362\r
2c8547ab 363 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
364 @param Recipient Interface/Device/Endpoint.\r
365 @param Value Request value.\r
366 @param Target Request Index.\r
367 @param Status Transfer status.\r
373b5cf9 368\r
2c8547ab 369 @retval EFI_INVALID_PARAMETER Parameter is error.\r
370 @retval EFI_SUCCESS Success.\r
371 @retval EFI_TIMEOUT Device has no response.\r
373b5cf9 372\r
373**/\r
fb3df220 374EFI_STATUS\r
f1787349 375EFIAPI\r
ed838d0c 376UsbClearFeature (\r
fb3df220 377 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
ed838d0c 378 IN UINTN Recipient,\r
fb3df220 379 IN UINT16 Value,\r
380 IN UINT16 Target,\r
381 OUT UINT32 *Status\r
382 );\r
383\r
373b5cf9 384/**\r
2c8547ab 385 Usb Get Device Status.\r
373b5cf9 386\r
2c8547ab 387 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
388 @param Recipient Interface/Device/Endpoint.\r
389 @param Target Request index.\r
390 @param DevStatus Device status.\r
391 @param Status Transfer status.\r
373b5cf9 392\r
2c8547ab 393 @retval EFI_INVALID_PARAMETER Parameter is error.\r
394 @retval EFI_SUCCESS Success.\r
395 @retval EFI_TIMEOUT Device has no response.\r
373b5cf9 396\r
397**/\r
fb3df220 398EFI_STATUS\r
f1787349 399EFIAPI\r
ed838d0c 400UsbGetStatus (\r
fb3df220 401 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
ed838d0c 402 IN UINTN Recipient,\r
fb3df220 403 IN UINT16 Target,\r
404 OUT UINT16 *DevStatus,\r
405 OUT UINT32 *Status\r
406 );\r
407\r
373b5cf9 408/**\r
2c8547ab 409 Clear endpoint stall.\r
373b5cf9 410\r
2c8547ab 411 @param UsbIo A pointer to EFI_USB_IO_PROTOCOL.\r
412 @param EndpointNo Endpoint Number.\r
413 @param Status Transfer Status.\r
373b5cf9 414\r
2c8547ab 415 @retval EFI_NOT_FOUND Can't find the Endpoint.\r
416 @retval EFI_DEVICE_ERROR Hardware error.\r
417 @retval EFI_SUCCESS Success.\r
373b5cf9 418\r
419**/\r
fb3df220 420EFI_STATUS\r
f1787349 421EFIAPI\r
fb3df220 422UsbClearEndpointHalt (\r
423 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
424 IN UINT8 EndpointNo,\r
425 OUT UINT32 *Status\r
426 );\r
427\r
428#endif\r