2 Provides most USB APIs to support the Hid requests defined in USB Hid 1.1 spec
3 and the standard requests defined in USB 1.1 spec.
5 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #ifndef __USB_DXE_LIB_H__
12 #define __USB_DXE_LIB_H__
14 #include <Protocol/UsbIo.h>
17 Get the descriptor of the specified USB HID interface.
19 Submit a UsbGetHidDescriptor() request for the USB device specified by UsbIo
20 and Interface, and return the HID descriptor in HidDescriptor.
21 If UsbIo is NULL, then ASSERT().
22 If HidDescriptor is NULL, then ASSERT().
24 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
25 @param Interface The index of the HID interface on the USB target.
26 @param HidDescriptor Pointer to the USB HID descriptor that was retrieved from
27 the specified USB target and interface. Type EFI_USB_HID_DESCRIPTOR
28 is defined in the MDE Package Industry Standard include file Usb.h.
30 @retval EFI_SUCCESS The request executed successfully.
31 @retval EFI_TIMEOUT A timeout occurred executing the request.
32 @retval EFI_DEVICE_ERROR The request failed due to a device error.
38 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
40 OUT EFI_USB_HID_DESCRIPTOR
*HidDescriptor
45 Get the report descriptor of the specified USB HID interface.
47 Submit a USB get HID report descriptor request for the USB device specified by
48 UsbIo and Interface, and return the report descriptor in DescriptorBuffer.
49 If UsbIo is NULL, then ASSERT().
50 If DescriptorBuffer is NULL, then ASSERT().
52 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
53 @param Interface The index of the report interface on the USB target.
54 @param DescriptorLength The size, in bytes, of DescriptorBuffer.
55 @param DescriptorBuffer A pointer to the buffer to store the report class descriptor.
57 @retval EFI_SUCCESS The request executed successfully.
58 @retval EFI_OUT_OF_RESOURCES The request could not be completed because the
59 buffer specified by DescriptorLength and DescriptorBuffer
60 is not large enough to hold the result of the request.
61 @retval EFI_TIMEOUT A timeout occurred executing the request.
62 @retval EFI_DEVICE_ERROR The request failed due to a device error.
67 UsbGetReportDescriptor (
68 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
70 IN UINT16 DescriptorLength
,
71 OUT UINT8
*DescriptorBuffer
75 Get the HID protocol of the specified USB HID interface.
77 Submit a USB get HID protocol request for the USB device specified by UsbIo
78 and Interface, and return the protocol retrieved in Protocol.
79 If UsbIo is NULL, then ASSERT().
80 If Protocol is NULL, then ASSERT().
82 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
83 @param Interface The index of the report interface on the USB target.
84 @param Protocol A pointer to the protocol for the specified USB target.
86 @retval EFI_SUCCESS The request executed successfully.
87 @retval EFI_TIMEOUT A timeout occurred executing the request.
88 @retval EFI_DEVICE_ERROR The request failed due to a device error.
93 UsbGetProtocolRequest (
94 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
100 Set the HID protocol of the specified USB HID interface.
102 Submit a USB set HID protocol request for the USB device specified by UsbIo
103 and Interface, and set the protocol to the value specified by Protocol.
104 If UsbIo is NULL, then ASSERT().
106 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
107 @param Interface The index of the report interface on the USB target.
108 @param Protocol The protocol value to set for the specified USB target.
110 @retval EFI_SUCCESS The request executed successfully.
111 @retval EFI_TIMEOUT A timeout occurred executing the request.
112 @retval EFI_DEVICE_ERROR The request failed due to a device error.
117 UsbSetProtocolRequest (
118 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
124 Set the idle rate of the specified USB HID report.
126 Submit a USB set HID report idle request for the USB device specified by UsbIo,
127 Interface, and ReportId, and set the idle rate to the value specified by Duration.
128 If UsbIo is NULL, then ASSERT().
130 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
131 @param Interface The index of the report interface on the USB target.
132 @param ReportId The identifier of the report to retrieve.
133 @param Duration The idle rate to set for the specified USB target.
135 @retval EFI_SUCCESS The request executed successfully.
136 @retval EFI_TIMEOUT A timeout occurred executing the request.
137 @retval EFI_DEVICE_ERROR The request failed due to a device error.
143 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
150 Get the idle rate of the specified USB HID report.
152 Submit a USB get HID report idle request for the USB device specified by UsbIo,
153 Interface, and ReportId, and return the ide rate in Duration.
154 If UsbIo is NULL, then ASSERT().
155 If Duration is NULL, then ASSERT().
157 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
158 @param Interface The index of the report interface on the USB target.
159 @param ReportId The identifier of the report to retrieve.
160 @param Duration A pointer to the idle rate retrieved from the specified USB target.
162 @retval EFI_SUCCESS The request executed successfully.
163 @retval EFI_TIMEOUT A timeout occurred executing the request.
164 @retval EFI_DEVICE_ERROR The request failed due to a device error.
170 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
177 Set the report descriptor of the specified USB HID interface.
179 Submit a USB set HID report request for the USB device specified by UsbIo,
180 Interface, ReportId, and ReportType, and set the report descriptor using the
181 buffer specified by ReportLength and Report.
182 If UsbIo is NULL, then ASSERT().
183 If Report is NULL, then ASSERT().
185 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
186 @param Interface The index of the report interface on the USB target.
187 @param ReportId The identifier of the report to retrieve.
188 @param ReportType The type of report to retrieve.
189 @param ReportLength The size, in bytes, of Report.
190 @param Report A pointer to the report descriptor buffer to set.
192 @retval EFI_SUCCESS The request executed successfully.
193 @retval EFI_TIMEOUT A timeout occurred executing the request.
194 @retval EFI_DEVICE_ERROR The request failed due to a device error.
199 UsbSetReportRequest (
200 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
209 Get the report descriptor of the specified USB HID interface.
211 Submit a USB get HID report request for the USB device specified by UsbIo,
212 Interface, ReportId, and ReportType, and return the report in the buffer
214 If UsbIo is NULL, then ASSERT().
215 If Report is NULL, then ASSERT().
217 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
218 @param Interface The index of the report interface on the USB target.
219 @param ReportId The identifier of the report to retrieve.
220 @param ReportType The type of report to retrieve.
221 @param ReportLength The size, in bytes, of Report.
222 @param Report A pointer to the buffer to store the report descriptor.
224 @retval EFI_SUCCESS The request executed successfully.
225 @retval EFI_OUT_OF_RESOURCES The request could not be completed because the
226 buffer specified by ReportLength and Report is not
227 large enough to hold the result of the request.
228 @retval EFI_TIMEOUT A timeout occurred executing the request.
229 @retval EFI_DEVICE_ERROR The request failed due to a device error.
234 UsbGetReportRequest (
235 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
244 Get the descriptor of the specified USB device.
246 Submit a USB get descriptor request for the USB device specified by UsbIo, Value,
247 and Index, and return the descriptor in the buffer specified by Descriptor.
248 The status of the transfer is returned in Status.
249 If UsbIo is NULL, then ASSERT().
250 If Descriptor is NULL, then ASSERT().
251 If Status is NULL, then ASSERT().
253 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
254 @param Value The device request value.
255 @param Index The device request index.
256 @param DescriptorLength The size, in bytes, of Descriptor.
257 @param Descriptor A pointer to the descriptor buffer to get.
258 @param Status A pointer to the status of the transfer.
260 @retval EFI_SUCCESS The request executed successfully.
261 @retval EFI_OUT_OF_RESOURCES The request could not be completed because the
262 buffer specified by DescriptorLength and Descriptor
263 is not large enough to hold the result of the request.
264 @retval EFI_TIMEOUT A timeout occurred executing the request.
265 @retval EFI_DEVICE_ERROR The request failed due to a device error. The transfer
266 status is returned in Status.
272 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
275 IN UINT16 DescriptorLength
,
276 OUT VOID
*Descriptor
,
281 Set the descriptor of the specified USB device.
283 Submit a USB set descriptor request for the USB device specified by UsbIo,
284 Value, and Index, and set the descriptor using the buffer specified by DesriptorLength
285 and Descriptor. The status of the transfer is returned in Status.
286 If UsbIo is NULL, then ASSERT().
287 If Descriptor is NULL, then ASSERT().
288 If Status is NULL, then ASSERT().
290 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
291 @param Value The device request value.
292 @param Index The device request index.
293 @param DescriptorLength The size, in bytes, of Descriptor.
294 @param Descriptor A pointer to the descriptor buffer to set.
295 @param Status A pointer to the status of the transfer.
297 @retval EFI_SUCCESS The request executed successfully.
298 @retval EFI_TIMEOUT A timeout occurred executing the request.
299 @retval EFI_DEVICE_ERROR The request failed due to a device error.
300 The transfer status is returned in Status.
306 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
309 IN UINT16 DescriptorLength
,
315 Get the interface setting of the specified USB device.
317 Submit a USB get interface request for the USB device specified by UsbIo,
318 and Interface, and place the result in the buffer specified by AlternateSetting.
319 The status of the transfer is returned in Status.
320 If UsbIo is NULL, then ASSERT().
321 If AlternateSetting is NULL, then ASSERT().
322 If Status is NULL, then ASSERT().
324 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
325 @param Interface The interface index value.
326 @param AlternateSetting A pointer to the alternate setting to be retrieved.
327 @param Status A pointer to the status of the transfer.
329 @retval EFI_SUCCESS The request executed successfully.
330 @retval EFI_TIMEOUT A timeout occurred executing the request.
331 @retval EFI_DEVICE_ERROR The request failed due to a device error.
332 The transfer status is returned in Status.
338 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
340 OUT UINT16
*AlternateSetting
,
345 Set the interface setting of the specified USB device.
347 Submit a USB set interface request for the USB device specified by UsbIo, and
348 Interface, and set the alternate setting to the value specified by AlternateSetting.
349 The status of the transfer is returned in Status.
350 If UsbIo is NULL, then ASSERT().
351 If Status is NULL, then ASSERT().
353 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
354 @param Interface The interface index value.
355 @param AlternateSetting The alternate setting to be set.
356 @param Status A pointer to the status of the transfer.
358 @retval EFI_SUCCESS The request executed successfully.
359 @retval EFI_TIMEOUT A timeout occurred executing the request.
360 @retval EFI_SUCCESS The request failed due to a device error.
361 The transfer status is returned in Status.
367 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
369 IN UINT16 AlternateSetting
,
374 Get the device configuration.
376 Submit a USB get configuration request for the USB device specified by UsbIo
377 and place the result in the buffer specified by ConfigurationValue. The status
378 of the transfer is returned in Status.
379 If UsbIo is NULL, then ASSERT().
380 If ConfigurationValue is NULL, then ASSERT().
381 If Status is NULL, then ASSERT().
383 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
384 @param ConfigurationValue A pointer to the device configuration to be retrieved.
385 @param Status A pointer to the status of the transfer.
387 @retval EFI_SUCCESS The request executed successfully.
388 @retval EFI_TIMEOUT A timeout occurred executing the request.
389 @retval EFI_DEVICE_ERROR The request failed due to a device error.
390 The transfer status is returned in Status.
395 UsbGetConfiguration (
396 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
397 OUT UINT16
*ConfigurationValue
,
402 Set the device configuration.
404 Submit a USB set configuration request for the USB device specified by UsbIo
405 and set the device configuration to the value specified by ConfigurationValue.
406 The status of the transfer is returned in Status.
407 If UsbIo is NULL, then ASSERT().
408 If Status is NULL, then ASSERT().
410 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
411 @param ConfigurationValue The device configuration value to be set.
412 @param Status A pointer to the status of the transfer.
414 @retval EFI_SUCCESS The request executed successfully.
415 @retval EFI_TIMEOUT A timeout occurred executing the request.
416 @retval EFI_DEVICE_ERROR The request failed due to a device error.
417 The transfer status is returned in Status.
422 UsbSetConfiguration (
423 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
424 IN UINT16 ConfigurationValue
,
429 Set the specified feature of the specified device.
431 Submit a USB set device feature request for the USB device specified by UsbIo,
432 Recipient, and Target to the value specified by Value. The status of the
433 transfer is returned in Status.
434 If UsbIo is NULL, then ASSERT().
435 If Status is NULL, then ASSERT().
437 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
438 @param Recipient The USB data recipient type (i.e. Device, Interface, Endpoint).
439 Type USB_TYPES_DEFINITION is defined in the MDE Package Industry
440 Standard include file Usb.h.
441 @param Value The value of the feature to be set.
442 @param Target The index of the device to be set.
443 @param Status A pointer to the status of the transfer.
445 @retval EFI_SUCCESS The request executed successfully.
446 @retval EFI_TIMEOUT A timeout occurred executing the request.
447 @retval EFI_DEVICE_ERROR The request failed due to a device error.
448 The transfer status is returned in Status.
454 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
455 IN USB_TYPES_DEFINITION Recipient
,
462 Clear the specified feature of the specified device.
464 Submit a USB clear device feature request for the USB device specified by UsbIo,
465 Recipient, and Target to the value specified by Value. The status of the transfer
466 is returned in Status.
467 If UsbIo is NULL, then ASSERT().
468 If Status is NULL, then ASSERT().
470 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
471 @param Recipient The USB data recipient type (i.e. Device, Interface, Endpoint).
472 Type USB_TYPES_DEFINITION is defined in the MDE Package Industry Standard
474 @param Value The value of the feature to be cleared.
475 @param Target The index of the device to be cleared.
476 @param Status A pointer to the status of the transfer.
478 @retval EFI_SUCCESS The request executed successfully.
479 @retval EFI_TIMEOUT A timeout occurred executing the request.
480 @retval EFI_DEVICE_ERROR The request failed due to a device error.
481 The transfer status is returned in Status.
487 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
488 IN USB_TYPES_DEFINITION Recipient
,
495 Get the status of the specified device.
497 Submit a USB device get status request for the USB device specified by UsbIo,
498 Recipient, and Target, and place the result in the buffer specified by DeviceStatus.
499 The status of the transfer is returned in Status.
500 If UsbIo is NULL, then ASSERT().
501 If DeviceStatus is NULL, then ASSERT().
502 If Status is NULL, then ASSERT().
504 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
505 @param Recipient The USB data recipient type (i.e. Device, Interface, Endpoint).
506 Type USB_TYPES_DEFINITION is defined in the MDE Package Industry Standard
508 @param Target The index of the device to be get the status of.
509 @param DeviceStatus A pointer to the device status to be retrieved.
510 @param Status A pointer to the status of the transfer.
512 @retval EFI_SUCCESS The request executed successfully.
513 @retval EFI_TIMEOUT A timeout occurred executing the request.
514 @retval EFI_DEVICE_ERROR The request failed due to a device error.
515 The transfer status is returned in Status.
521 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
522 IN USB_TYPES_DEFINITION Recipient
,
524 OUT UINT16
*DeviceStatus
,
529 Clear halt feature of the specified usb endpoint.
531 Retrieve the USB endpoint descriptor specified by UsbIo and EndPoint.
532 If the USB endpoint descriptor can not be retrieved, then return EFI_NOT_FOUND.
533 If the endpoint descriptor is found, then clear the halt feature of this USB endpoint.
534 The status of the transfer is returned in Status.
535 If UsbIo is NULL, then ASSERT().
536 If Status is NULL, then ASSERT().
538 @param UsbIo A pointer to the USB I/O Protocol instance for the specific USB target.
539 @param Endpoint The endpoint address.
540 @param Status A pointer to the status of the transfer.
542 @retval EFI_SUCCESS The request executed successfully.
543 @retval EFI_TIMEOUT A timeout occurred executing the request.
544 @retval EFI_DEVICE_ERROR The request failed due to a device error.
545 The transfer status is returned in Status.
546 @retval EFI_NOT_FOUND The specified USB endpoint descriptor can not be found
551 UsbClearEndpointHalt (
552 IN EFI_USB_IO_PROTOCOL
*UsbIo
,