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.
25 #include <Library/UsbLib.h>
28 // Function to get HID descriptor
34 @param UsbIo EFI_USB_IO_PROTOCOL
35 @param InterfaceNum Hid interface number
36 @param HidDescriptor Caller allocated buffer to store Usb hid descriptor if
37 successfully returned.
40 @return EFI_DEVICE_ERROR
46 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
47 IN UINT8 InterfaceNum
,
48 OUT EFI_USB_HID_DESCRIPTOR
*HidDescriptor
53 EFI_USB_DEVICE_REQUEST Request
;
55 Request
.RequestType
= 0x81;
56 Request
.Request
= 0x06;
57 Request
.Value
= (UINT16
) (0x21 << 8);
58 Request
.Index
= InterfaceNum
;
59 Request
.Length
= sizeof (EFI_USB_HID_DESCRIPTOR
);
61 Result
= UsbIo
->UsbControlTransfer (
67 sizeof (EFI_USB_HID_DESCRIPTOR
),
75 // Function to get Report Class descriptor
79 get Report Class descriptor
81 @param UsbIo EFI_USB_IO_PROTOCOL.
82 @param InterfaceNum Report interface number.
83 @param DescriptorSize Length of DescriptorBuffer.
84 @param DescriptorBuffer Caller allocated buffer to store Usb report descriptor
85 if successfully returned.
88 @return EFI_DEVICE_ERROR
93 UsbGetReportDescriptor (
94 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
95 IN UINT8 InterfaceNum
,
96 IN UINT16 DescriptorSize
,
97 OUT UINT8
*DescriptorBuffer
102 EFI_USB_DEVICE_REQUEST Request
;
105 // Fill Device request packet
107 Request
.RequestType
= 0x81;
108 Request
.Request
= 0x06;
109 Request
.Value
= (UINT16
) (0x22 << 8);
110 Request
.Index
= InterfaceNum
;
111 Request
.Length
= DescriptorSize
;
113 Result
= UsbIo
->UsbControlTransfer (
127 // Following are HID class request
131 Get Hid Protocol Request
133 @param UsbIo EFI_USB_IO_PROTOCOL
134 @param Interface Which interface the caller wants to get protocol
135 @param Protocol Protocol value returned.
138 @return EFI_DEVICE_ERROR
143 UsbGetProtocolRequest (
144 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
151 EFI_USB_DEVICE_REQUEST Request
;
154 // Fill Device request packet
156 Request
.RequestType
= 0xa1;
160 Request
.Request
= EFI_USB_GET_PROTOCOL_REQUEST
;
162 Request
.Index
= Interface
;
165 Result
= UsbIo
->UsbControlTransfer (
181 Set Hid Protocol Request
183 @param UsbIo EFI_USB_IO_PROTOCOL
184 @param Interface Which interface the caller wants to set protocol
185 @param Protocol Protocol value the caller wants to set.
188 @return EFI_DEVICE_ERROR
193 UsbSetProtocolRequest (
194 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
201 EFI_USB_DEVICE_REQUEST Request
;
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 // Fill Device request packet
257 Request
.RequestType
= 0x21;
261 Request
.Request
= EFI_USB_SET_IDLE_REQUEST
;
262 Request
.Value
= (UINT16
) ((Duration
<< 8) | ReportId
);
263 Request
.Index
= Interface
;
266 Result
= UsbIo
->UsbControlTransfer (
282 @param UsbIo EFI_USB_IO_PROTOCOL
283 @param Interface Which interface the caller wants to get.
284 @param ReportId Which report the caller wants to get.
285 @param Duration Idle rate the caller wants to get.
288 @return EFI_DEVICE_ERROR
294 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
302 EFI_USB_DEVICE_REQUEST Request
;
305 // Fill Device request packet
307 Request
.RequestType
= 0xa1;
311 Request
.Request
= EFI_USB_GET_IDLE_REQUEST
;
312 Request
.Value
= ReportId
;
313 Request
.Index
= Interface
;
316 Result
= UsbIo
->UsbControlTransfer (
332 Hid Set Report request.
334 @param UsbIo EFI_USB_IO_PROTOCOL
335 @param Interface Which interface the caller wants to set.
336 @param ReportId Which report the caller wants to set.
337 @param ReportType Type of report.
338 @param ReportLen Length of report descriptor.
339 @param Report Report Descriptor buffer.
342 @return EFI_DEVICE_ERROR
347 UsbSetReportRequest (
348 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
358 EFI_USB_DEVICE_REQUEST Request
;
361 // Fill Device request packet
363 Request
.RequestType
= 0x21;
367 Request
.Request
= EFI_USB_SET_REPORT_REQUEST
;
368 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
369 Request
.Index
= Interface
;
370 Request
.Length
= ReportLen
;
372 Result
= UsbIo
->UsbControlTransfer (
387 Hid Set Report request.
389 @param UsbIo EFI_USB_IO_PROTOCOL
390 @param Interface Which interface the caller wants to set.
391 @param ReportId Which report the caller wants to set.
392 @param ReportType Type of report.
393 @param ReportLen Length of report descriptor.
394 @param Report Caller allocated buffer to store Report Descriptor.
397 @return EFI_DEVICE_ERROR
402 UsbGetReportRequest (
403 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
413 EFI_USB_DEVICE_REQUEST Request
;
416 // Fill Device request packet
418 Request
.RequestType
= 0xa1;
422 Request
.Request
= EFI_USB_GET_REPORT_REQUEST
;
423 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
424 Request
.Index
= Interface
;
425 Request
.Length
= ReportLen
;
427 Result
= UsbIo
->UsbControlTransfer (