3 The library provides USB descriptor, protocol operations.
5 Copyright (c) 2004, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <UefiUsbLibInternal.h>
22 @param UsbIo EFI_USB_IO_PROTOCOL.
23 @param InterfaceNum Hid interface number.
24 @param HidDescriptor Caller allocated buffer to store Usb hid descriptor if
25 successfully returned.
27 @return Status of getting HID descriptor through USB I/O
28 protocol's UsbControlTransfer().
34 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
35 IN UINT8 InterfaceNum
,
36 OUT EFI_USB_HID_DESCRIPTOR
*HidDescriptor
41 EFI_USB_DEVICE_REQUEST Request
;
44 return EFI_INVALID_PARAMETER
;
47 Request
.RequestType
= 0x81;
48 Request
.Request
= 0x06;
49 Request
.Value
= (UINT16
) (0x21 << 8);
50 Request
.Index
= InterfaceNum
;
51 Request
.Length
= sizeof (EFI_USB_HID_DESCRIPTOR
);
53 Result
= UsbIo
->UsbControlTransfer (
59 sizeof (EFI_USB_HID_DESCRIPTOR
),
68 Get Report Class descriptor.
70 @param UsbIo EFI_USB_IO_PROTOCOL.
71 @param InterfaceNum Report interface number.
72 @param DescriptorSize Length of DescriptorBuffer.
73 @param DescriptorBuffer Caller allocated buffer to store Usb report descriptor
74 if successfully returned.
76 @return Status of getting Report Class descriptor through USB
77 I/O protocol's UsbControlTransfer().
82 UsbGetReportDescriptor (
83 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
84 IN UINT8 InterfaceNum
,
85 IN UINT16 DescriptorSize
,
86 OUT UINT8
*DescriptorBuffer
91 EFI_USB_DEVICE_REQUEST Request
;
94 return EFI_INVALID_PARAMETER
;
97 // Fill Device request packet
99 Request
.RequestType
= 0x81;
100 Request
.Request
= 0x06;
101 Request
.Value
= (UINT16
) (0x22 << 8);
102 Request
.Index
= InterfaceNum
;
103 Request
.Length
= DescriptorSize
;
105 Result
= UsbIo
->UsbControlTransfer (
120 Get Hid Protocol Request
122 @param UsbIo EFI_USB_IO_PROTOCOL.
123 @param Interface Which interface the caller wants to get protocol
124 @param Protocol Protocol value returned.
126 @return Status of getting Protocol Request through USB I/O
127 protocol's UsbControlTransfer().
132 UsbGetProtocolRequest (
133 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
140 EFI_USB_DEVICE_REQUEST Request
;
143 return EFI_INVALID_PARAMETER
;
146 // Fill Device request packet
148 Request
.RequestType
= 0xa1;
152 Request
.Request
= EFI_USB_GET_PROTOCOL_REQUEST
;
154 Request
.Index
= Interface
;
157 Result
= UsbIo
->UsbControlTransfer (
173 Set Hid Protocol Request.
175 @param UsbIo EFI_USB_IO_PROTOCOL.
176 @param Interface Which interface the caller wants to
178 @param Protocol Protocol value the caller wants to set.
180 @return Status of setting Protocol Request through USB I/O
181 protocol's UsbControlTransfer().
186 UsbSetProtocolRequest (
187 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
194 EFI_USB_DEVICE_REQUEST Request
;
197 return EFI_INVALID_PARAMETER
;
200 // Fill Device request packet
202 Request
.RequestType
= 0x21;
206 Request
.Request
= EFI_USB_SET_PROTOCOL_REQUEST
;
207 Request
.Value
= Protocol
;
208 Request
.Index
= Interface
;
211 Result
= UsbIo
->UsbControlTransfer (
227 @param UsbIo EFI_USB_IO_PROTOCOL.
228 @param Interface Which interface the caller wants to set.
229 @param ReportId Which report the caller wants to set.
230 @param Duration Idle rate the caller wants to set.
232 @return Status of setting IDLE Request through USB I/O
233 protocol's UsbControlTransfer().
239 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
247 EFI_USB_DEVICE_REQUEST Request
;
250 return EFI_INVALID_PARAMETER
;
253 // Fill Device request packet
255 Request
.RequestType
= 0x21;
259 Request
.Request
= EFI_USB_SET_IDLE_REQUEST
;
260 Request
.Value
= (UINT16
) ((Duration
<< 8) | ReportId
);
261 Request
.Index
= Interface
;
264 Result
= UsbIo
->UsbControlTransfer (
280 @param UsbIo EFI_USB_IO_PROTOCOL.
281 @param Interface Which interface the caller wants to get.
282 @param ReportId Which report the caller wants to get.
283 @param Duration Idle rate the caller wants to get.
285 @return Status of getting IDLE Request through USB I/O
286 protocol's UsbControlTransfer().
292 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
300 EFI_USB_DEVICE_REQUEST Request
;
303 return EFI_INVALID_PARAMETER
;
306 // Fill Device request packet
308 Request
.RequestType
= 0xa1;
312 Request
.Request
= EFI_USB_GET_IDLE_REQUEST
;
313 Request
.Value
= ReportId
;
314 Request
.Index
= Interface
;
317 Result
= UsbIo
->UsbControlTransfer (
333 Hid Set Report request.
335 @param UsbIo EFI_USB_IO_PROTOCOL.
336 @param Interface Which interface the caller wants to set.
337 @param ReportId Which report the caller wants to set.
338 @param ReportType Type of report.
339 @param ReportLen Length of report descriptor.
340 @param Report Report Descriptor buffer.
342 @return Status of setting Report Request through USB I/O
343 protocol's UsbControlTransfer().
348 UsbSetReportRequest (
349 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
359 EFI_USB_DEVICE_REQUEST Request
;
362 return EFI_INVALID_PARAMETER
;
365 // Fill Device request packet
367 Request
.RequestType
= 0x21;
371 Request
.Request
= EFI_USB_SET_REPORT_REQUEST
;
372 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
373 Request
.Index
= Interface
;
374 Request
.Length
= ReportLen
;
376 Result
= UsbIo
->UsbControlTransfer (
391 Hid Set Report request.
393 @param UsbIo EFI_USB_IO_PROTOCOL.
394 @param Interface Which interface the caller wants to set.
395 @param ReportId Which report the caller wants to set.
396 @param ReportType Type of report.
397 @param ReportLen Length of report descriptor.
398 @param Report Caller allocated buffer to store Report Descriptor.
400 @return Status of getting Report Request through USB I/O
401 protocol's UsbControlTransfer().
406 UsbGetReportRequest (
407 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
417 EFI_USB_DEVICE_REQUEST Request
;
420 return EFI_INVALID_PARAMETER
;
423 // Fill Device request packet
425 Request
.RequestType
= 0xa1;
429 Request
.Request
= EFI_USB_GET_REPORT_REQUEST
;
430 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
431 Request
.Index
= Interface
;
432 Request
.Length
= ReportLen
;
434 Result
= UsbIo
->UsbControlTransfer (