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 <Library/UsbLib.h>
18 // Function to get HID descriptor
24 @param UsbIo EFI_USB_IO_PROTOCOL
25 @param InterfaceNum Hid interface number
26 @param HidDescriptor Caller allocated buffer to store Usb hid descriptor if
27 successfully returned.
30 @return EFI_DEVICE_ERROR
36 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
37 IN UINT8 InterfaceNum
,
38 OUT EFI_USB_HID_DESCRIPTOR
*HidDescriptor
43 EFI_USB_DEVICE_REQUEST Request
;
45 Request
.RequestType
= 0x81;
46 Request
.Request
= 0x06;
47 Request
.Value
= (UINT16
) (0x21 << 8);
48 Request
.Index
= InterfaceNum
;
49 Request
.Length
= sizeof (EFI_USB_HID_DESCRIPTOR
);
51 Result
= UsbIo
->UsbControlTransfer (
57 sizeof (EFI_USB_HID_DESCRIPTOR
),
65 // Function to get Report Class descriptor
69 get Report Class descriptor
71 @param UsbIo EFI_USB_IO_PROTOCOL.
72 @param InterfaceNum Report interface number.
73 @param DescriptorSize Length of DescriptorBuffer.
74 @param DescriptorBuffer Caller allocated buffer to store Usb report descriptor
75 if successfully returned.
78 @return EFI_DEVICE_ERROR
83 UsbGetReportDescriptor (
84 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
85 IN UINT8 InterfaceNum
,
86 IN UINT16 DescriptorSize
,
87 OUT UINT8
*DescriptorBuffer
92 EFI_USB_DEVICE_REQUEST Request
;
95 // Fill Device request packet
97 Request
.RequestType
= 0x81;
98 Request
.Request
= 0x06;
99 Request
.Value
= (UINT16
) (0x22 << 8);
100 Request
.Index
= InterfaceNum
;
101 Request
.Length
= DescriptorSize
;
103 Result
= UsbIo
->UsbControlTransfer (
117 // Following are HID class request
121 Get Hid Protocol Request
123 @param UsbIo EFI_USB_IO_PROTOCOL
124 @param Interface Which interface the caller wants to get protocol
125 @param Protocol Protocol value returned.
128 @return EFI_DEVICE_ERROR
133 UsbGetProtocolRequest (
134 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
141 EFI_USB_DEVICE_REQUEST Request
;
144 // Fill Device request packet
146 Request
.RequestType
= 0xa1;
150 Request
.Request
= EFI_USB_GET_PROTOCOL_REQUEST
;
152 Request
.Index
= Interface
;
155 Result
= UsbIo
->UsbControlTransfer (
171 Set Hid Protocol Request
173 @param UsbIo EFI_USB_IO_PROTOCOL
174 @param Interface Which interface the caller wants to set protocol
175 @param Protocol Protocol value the caller wants to set.
178 @return EFI_DEVICE_ERROR
183 UsbSetProtocolRequest (
184 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
191 EFI_USB_DEVICE_REQUEST Request
;
194 // Fill Device request packet
196 Request
.RequestType
= 0x21;
200 Request
.Request
= EFI_USB_SET_PROTOCOL_REQUEST
;
201 Request
.Value
= Protocol
;
202 Request
.Index
= Interface
;
205 Result
= UsbIo
->UsbControlTransfer (
222 @param UsbIo EFI_USB_IO_PROTOCOL
223 @param Interface Which interface the caller wants to set.
224 @param ReportId Which report the caller wants to set.
225 @param Duration Idle rate the caller wants to set.
228 @return EFI_DEVICE_ERROR
234 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
242 EFI_USB_DEVICE_REQUEST Request
;
245 // Fill Device request packet
247 Request
.RequestType
= 0x21;
251 Request
.Request
= EFI_USB_SET_IDLE_REQUEST
;
252 Request
.Value
= (UINT16
) ((Duration
<< 8) | ReportId
);
253 Request
.Index
= Interface
;
256 Result
= UsbIo
->UsbControlTransfer (
272 @param UsbIo EFI_USB_IO_PROTOCOL
273 @param Interface Which interface the caller wants to get.
274 @param ReportId Which report the caller wants to get.
275 @param Duration Idle rate the caller wants to get.
278 @return EFI_DEVICE_ERROR
284 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
292 EFI_USB_DEVICE_REQUEST Request
;
295 // Fill Device request packet
297 Request
.RequestType
= 0xa1;
301 Request
.Request
= EFI_USB_GET_IDLE_REQUEST
;
302 Request
.Value
= ReportId
;
303 Request
.Index
= Interface
;
306 Result
= UsbIo
->UsbControlTransfer (
322 Hid Set Report request.
324 @param UsbIo EFI_USB_IO_PROTOCOL
325 @param Interface Which interface the caller wants to set.
326 @param ReportId Which report the caller wants to set.
327 @param ReportType Type of report.
328 @param ReportLen Length of report descriptor.
329 @param Report Report Descriptor buffer.
332 @return EFI_DEVICE_ERROR
337 UsbSetReportRequest (
338 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
348 EFI_USB_DEVICE_REQUEST Request
;
351 // Fill Device request packet
353 Request
.RequestType
= 0x21;
357 Request
.Request
= EFI_USB_SET_REPORT_REQUEST
;
358 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
359 Request
.Index
= Interface
;
360 Request
.Length
= ReportLen
;
362 Result
= UsbIo
->UsbControlTransfer (
377 Hid Set Report request.
379 @param UsbIo EFI_USB_IO_PROTOCOL
380 @param Interface Which interface the caller wants to set.
381 @param ReportId Which report the caller wants to set.
382 @param ReportType Type of report.
383 @param ReportLen Length of report descriptor.
384 @param Report Caller allocated buffer to store Report Descriptor.
387 @return EFI_DEVICE_ERROR
392 UsbGetReportRequest (
393 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
403 EFI_USB_DEVICE_REQUEST Request
;
406 // Fill Device request packet
408 Request
.RequestType
= 0xa1;
412 Request
.Request
= EFI_USB_GET_REPORT_REQUEST
;
413 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
414 Request
.Index
= Interface
;
415 Request
.Length
= ReportLen
;
417 Result
= UsbIo
->UsbControlTransfer (