3 The library provides USB HID Class standard and specific requests defined
4 in USB HID Firmware Specification 7 section : Requests.
6 Copyright (c) 2004, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "UefiUsbLibInternal.h"
20 // Hid RequestType Bits specifying characteristics of request.
21 // Valid values are 10100001b (0xa1) or 00100001b (0x21).
22 // The following description:
23 // 7 Data transfer direction
35 @param UsbIo EFI_USB_IO_PROTOCOL.
36 @param InterfaceNum Hid interface number.
37 @param HidDescriptor Caller allocated buffer to store Usb hid descriptor if
38 successfully returned.
40 @return Status of getting HID descriptor through USB I/O
41 protocol's UsbControlTransfer().
47 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
48 IN UINT8 InterfaceNum
,
49 OUT EFI_USB_HID_DESCRIPTOR
*HidDescriptor
54 EFI_USB_DEVICE_REQUEST Request
;
57 return EFI_INVALID_PARAMETER
;
60 Request
.RequestType
= USB_HID_GET_DESCRIPTOR_REQ_TYPE
;
61 Request
.Request
= USB_REQ_GET_DESCRIPTOR
;
62 Request
.Value
= (UINT16
) (USB_DESC_TYPE_HID
<< 8);
63 Request
.Index
= InterfaceNum
;
64 Request
.Length
= sizeof (EFI_USB_HID_DESCRIPTOR
);
66 Result
= UsbIo
->UsbControlTransfer (
72 sizeof (EFI_USB_HID_DESCRIPTOR
),
81 Get Report Class descriptor.
83 @param UsbIo EFI_USB_IO_PROTOCOL.
84 @param InterfaceNum Report interface number.
85 @param DescriptorSize Length of DescriptorBuffer.
86 @param DescriptorBuffer Caller allocated buffer to store Usb report descriptor
87 if successfully returned.
89 @return Status of getting Report Class descriptor through USB
90 I/O protocol's UsbControlTransfer().
95 UsbGetReportDescriptor (
96 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
97 IN UINT8 InterfaceNum
,
98 IN UINT16 DescriptorSize
,
99 OUT UINT8
*DescriptorBuffer
104 EFI_USB_DEVICE_REQUEST Request
;
107 return EFI_INVALID_PARAMETER
;
110 // Fill Device request packet
112 Request
.RequestType
= USB_HID_GET_DESCRIPTOR_REQ_TYPE
;
113 Request
.Request
= USB_REQ_GET_DESCRIPTOR
;
114 Request
.Value
= (UINT16
) (USB_DESC_TYPE_REPORT
<< 8);
115 Request
.Index
= InterfaceNum
;
116 Request
.Length
= DescriptorSize
;
118 Result
= UsbIo
->UsbControlTransfer (
133 Get Hid Protocol Request
135 @param UsbIo EFI_USB_IO_PROTOCOL.
136 @param Interface Which interface the caller wants to get protocol
137 @param Protocol Protocol value returned.
139 @return Status of getting Protocol Request through USB I/O
140 protocol's UsbControlTransfer().
145 UsbGetProtocolRequest (
146 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
153 EFI_USB_DEVICE_REQUEST Request
;
156 return EFI_INVALID_PARAMETER
;
159 // Fill Device request packet
161 Request
.RequestType
= USB_HID_CLASS_GET_REQ_TYPE
;
162 Request
.Request
= EFI_USB_GET_PROTOCOL_REQUEST
;
164 Request
.Index
= Interface
;
167 Result
= UsbIo
->UsbControlTransfer (
183 Set Hid Protocol Request.
185 @param UsbIo EFI_USB_IO_PROTOCOL.
186 @param Interface Which interface the caller wants to
188 @param Protocol Protocol value the caller wants to set.
190 @return Status of setting Protocol Request through USB I/O
191 protocol's UsbControlTransfer().
196 UsbSetProtocolRequest (
197 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
204 EFI_USB_DEVICE_REQUEST Request
;
207 return EFI_INVALID_PARAMETER
;
210 // Fill Device request packet
212 Request
.RequestType
= USB_HID_CLASS_SET_REQ_TYPE
;
213 Request
.Request
= EFI_USB_SET_PROTOCOL_REQUEST
;
214 Request
.Value
= Protocol
;
215 Request
.Index
= Interface
;
218 Result
= UsbIo
->UsbControlTransfer (
234 @param UsbIo EFI_USB_IO_PROTOCOL.
235 @param Interface Which interface the caller wants to set.
236 @param ReportId Which report the caller wants to set.
237 @param Duration Idle rate the caller wants to set.
239 @return Status of setting IDLE Request through USB I/O
240 protocol's UsbControlTransfer().
246 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
254 EFI_USB_DEVICE_REQUEST Request
;
257 return EFI_INVALID_PARAMETER
;
260 // Fill Device request packet
262 Request
.RequestType
= USB_HID_CLASS_SET_REQ_TYPE
;
263 Request
.Request
= EFI_USB_SET_IDLE_REQUEST
;
264 Request
.Value
= (UINT16
) ((Duration
<< 8) | ReportId
);
265 Request
.Index
= Interface
;
268 Result
= UsbIo
->UsbControlTransfer (
284 @param UsbIo EFI_USB_IO_PROTOCOL.
285 @param Interface Which interface the caller wants to get.
286 @param ReportId Which report the caller wants to get.
287 @param Duration Idle rate the caller wants to get.
289 @return Status of getting IDLE Request through USB I/O
290 protocol's UsbControlTransfer().
296 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
304 EFI_USB_DEVICE_REQUEST Request
;
307 return EFI_INVALID_PARAMETER
;
310 // Fill Device request packet
312 Request
.RequestType
= USB_HID_CLASS_GET_REQ_TYPE
;
313 Request
.Request
= EFI_USB_GET_IDLE_REQUEST
;
314 Request
.Value
= ReportId
;
315 Request
.Index
= Interface
;
318 Result
= UsbIo
->UsbControlTransfer (
334 Hid Set Report request.
336 @param UsbIo EFI_USB_IO_PROTOCOL.
337 @param Interface Which interface the caller wants to set.
338 @param ReportId Which report the caller wants to set.
339 @param ReportType Type of report.
340 @param ReportLen Length of report descriptor.
341 @param Report Report Descriptor buffer.
343 @return Status of setting Report Request through USB I/O
344 protocol's UsbControlTransfer().
349 UsbSetReportRequest (
350 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
360 EFI_USB_DEVICE_REQUEST Request
;
363 return EFI_INVALID_PARAMETER
;
366 // Fill Device request packet
368 Request
.RequestType
= USB_HID_CLASS_SET_REQ_TYPE
;
369 Request
.Request
= EFI_USB_SET_REPORT_REQUEST
;
370 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
371 Request
.Index
= Interface
;
372 Request
.Length
= ReportLen
;
374 Result
= UsbIo
->UsbControlTransfer (
389 Hid Set Report request.
391 @param UsbIo EFI_USB_IO_PROTOCOL.
392 @param Interface Which interface the caller wants to set.
393 @param ReportId Which report the caller wants to set.
394 @param ReportType Type of report.
395 @param ReportLen Length of report descriptor.
396 @param Report Caller allocated buffer to store Report Descriptor.
398 @return Status of getting Report Request through USB I/O
399 protocol's UsbControlTransfer().
404 UsbGetReportRequest (
405 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
415 EFI_USB_DEVICE_REQUEST Request
;
418 return EFI_INVALID_PARAMETER
;
421 // Fill Device request packet
423 Request
.RequestType
= USB_HID_CLASS_GET_REQ_TYPE
;
424 Request
.Request
= EFI_USB_GET_REPORT_REQUEST
;
425 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
426 Request
.Index
= Interface
;
427 Request
.Length
= ReportLen
;
429 Result
= UsbIo
->UsbControlTransfer (