3 Copyright (c) 2004, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include <UefiUsbLibInternal.h>
21 @param UsbIo EFI_USB_IO_PROTOCOL
22 @param InterfaceNum Hid interface number
23 @param HidDescriptor Caller allocated buffer to store Usb hid descriptor if
24 successfully returned.
27 @return EFI_DEVICE_ERROR
33 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
34 IN UINT8 InterfaceNum
,
35 OUT EFI_USB_HID_DESCRIPTOR
*HidDescriptor
40 EFI_USB_DEVICE_REQUEST Request
;
43 return EFI_INVALID_PARAMETER
;
46 Request
.RequestType
= 0x81;
47 Request
.Request
= 0x06;
48 Request
.Value
= (UINT16
) (0x21 << 8);
49 Request
.Index
= InterfaceNum
;
50 Request
.Length
= sizeof (EFI_USB_HID_DESCRIPTOR
);
52 Result
= UsbIo
->UsbControlTransfer (
58 sizeof (EFI_USB_HID_DESCRIPTOR
),
66 // Function to get Report Class descriptor
70 get Report Class descriptor
72 @param UsbIo EFI_USB_IO_PROTOCOL.
73 @param InterfaceNum Report interface number.
74 @param DescriptorSize Length of DescriptorBuffer.
75 @param DescriptorBuffer Caller allocated buffer to store Usb report descriptor
76 if successfully returned.
79 @return EFI_DEVICE_ERROR
84 UsbGetReportDescriptor (
85 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
86 IN UINT8 InterfaceNum
,
87 IN UINT16 DescriptorSize
,
88 OUT UINT8
*DescriptorBuffer
93 EFI_USB_DEVICE_REQUEST Request
;
96 return EFI_INVALID_PARAMETER
;
99 // Fill Device request packet
101 Request
.RequestType
= 0x81;
102 Request
.Request
= 0x06;
103 Request
.Value
= (UINT16
) (0x22 << 8);
104 Request
.Index
= InterfaceNum
;
105 Request
.Length
= DescriptorSize
;
107 Result
= UsbIo
->UsbControlTransfer (
121 // Following are HID class request
125 Get Hid Protocol Request
127 @param UsbIo EFI_USB_IO_PROTOCOL
128 @param Interface Which interface the caller wants to get protocol
129 @param Protocol Protocol value returned.
132 @return EFI_DEVICE_ERROR
137 UsbGetProtocolRequest (
138 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
145 EFI_USB_DEVICE_REQUEST Request
;
148 return EFI_INVALID_PARAMETER
;
151 // Fill Device request packet
153 Request
.RequestType
= 0xa1;
157 Request
.Request
= EFI_USB_GET_PROTOCOL_REQUEST
;
159 Request
.Index
= Interface
;
162 Result
= UsbIo
->UsbControlTransfer (
178 Set Hid Protocol Request
180 @param UsbIo EFI_USB_IO_PROTOCOL
181 @param Interface Which interface the caller wants to set protocol
182 @param Protocol Protocol value the caller wants to set.
185 @return EFI_DEVICE_ERROR
190 UsbSetProtocolRequest (
191 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
198 EFI_USB_DEVICE_REQUEST Request
;
201 return EFI_INVALID_PARAMETER
;
204 // Fill Device request packet
206 Request
.RequestType
= 0x21;
210 Request
.Request
= EFI_USB_SET_PROTOCOL_REQUEST
;
211 Request
.Value
= Protocol
;
212 Request
.Index
= Interface
;
215 Result
= UsbIo
->UsbControlTransfer (
232 @param UsbIo EFI_USB_IO_PROTOCOL
233 @param Interface Which interface the caller wants to set.
234 @param ReportId Which report the caller wants to set.
235 @param Duration Idle rate the caller wants to set.
238 @return EFI_DEVICE_ERROR
244 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
252 EFI_USB_DEVICE_REQUEST Request
;
255 return EFI_INVALID_PARAMETER
;
258 // Fill Device request packet
260 Request
.RequestType
= 0x21;
264 Request
.Request
= EFI_USB_SET_IDLE_REQUEST
;
265 Request
.Value
= (UINT16
) ((Duration
<< 8) | ReportId
);
266 Request
.Index
= Interface
;
269 Result
= UsbIo
->UsbControlTransfer (
285 @param UsbIo EFI_USB_IO_PROTOCOL
286 @param Interface Which interface the caller wants to get.
287 @param ReportId Which report the caller wants to get.
288 @param Duration Idle rate the caller wants to get.
291 @return EFI_DEVICE_ERROR
297 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
305 EFI_USB_DEVICE_REQUEST Request
;
308 return EFI_INVALID_PARAMETER
;
311 // Fill Device request packet
313 Request
.RequestType
= 0xa1;
317 Request
.Request
= EFI_USB_GET_IDLE_REQUEST
;
318 Request
.Value
= ReportId
;
319 Request
.Index
= Interface
;
322 Result
= UsbIo
->UsbControlTransfer (
338 Hid Set Report request.
340 @param UsbIo EFI_USB_IO_PROTOCOL
341 @param Interface Which interface the caller wants to set.
342 @param ReportId Which report the caller wants to set.
343 @param ReportType Type of report.
344 @param ReportLen Length of report descriptor.
345 @param Report Report Descriptor buffer.
348 @return EFI_DEVICE_ERROR
353 UsbSetReportRequest (
354 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
364 EFI_USB_DEVICE_REQUEST Request
;
367 return EFI_INVALID_PARAMETER
;
370 // Fill Device request packet
372 Request
.RequestType
= 0x21;
376 Request
.Request
= EFI_USB_SET_REPORT_REQUEST
;
377 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
378 Request
.Index
= Interface
;
379 Request
.Length
= ReportLen
;
381 Result
= UsbIo
->UsbControlTransfer (
396 Hid Set Report request.
398 @param UsbIo EFI_USB_IO_PROTOCOL
399 @param Interface Which interface the caller wants to set.
400 @param ReportId Which report the caller wants to set.
401 @param ReportType Type of report.
402 @param ReportLen Length of report descriptor.
403 @param Report Caller allocated buffer to store Report Descriptor.
406 @return EFI_DEVICE_ERROR
411 UsbGetReportRequest (
412 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
422 EFI_USB_DEVICE_REQUEST Request
;
425 return EFI_INVALID_PARAMETER
;
428 // Fill Device request packet
430 Request
.RequestType
= 0xa1;
434 Request
.Request
= EFI_USB_GET_REPORT_REQUEST
;
435 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
436 Request
.Index
= Interface
;
437 Request
.Length
= ReportLen
;
439 Result
= UsbIo
->UsbControlTransfer (