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.
28 @return EFI_DEVICE_ERROR
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
),
67 // Function to get Report Class descriptor
71 get Report Class descriptor
73 @param UsbIo EFI_USB_IO_PROTOCOL.
74 @param InterfaceNum Report interface number.
75 @param DescriptorSize Length of DescriptorBuffer.
76 @param DescriptorBuffer Caller allocated buffer to store Usb report descriptor
77 if successfully returned.
80 @return EFI_DEVICE_ERROR
85 UsbGetReportDescriptor (
86 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
87 IN UINT8 InterfaceNum
,
88 IN UINT16 DescriptorSize
,
89 OUT UINT8
*DescriptorBuffer
94 EFI_USB_DEVICE_REQUEST Request
;
97 return EFI_INVALID_PARAMETER
;
100 // Fill Device request packet
102 Request
.RequestType
= 0x81;
103 Request
.Request
= 0x06;
104 Request
.Value
= (UINT16
) (0x22 << 8);
105 Request
.Index
= InterfaceNum
;
106 Request
.Length
= DescriptorSize
;
108 Result
= UsbIo
->UsbControlTransfer (
122 // Following are HID class request
126 Get Hid Protocol Request
128 @param UsbIo EFI_USB_IO_PROTOCOL
129 @param Interface Which interface the caller wants to get protocol
130 @param Protocol Protocol value returned.
133 @return EFI_DEVICE_ERROR
138 UsbGetProtocolRequest (
139 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
146 EFI_USB_DEVICE_REQUEST Request
;
149 return EFI_INVALID_PARAMETER
;
152 // Fill Device request packet
154 Request
.RequestType
= 0xa1;
158 Request
.Request
= EFI_USB_GET_PROTOCOL_REQUEST
;
160 Request
.Index
= Interface
;
163 Result
= UsbIo
->UsbControlTransfer (
179 Set Hid Protocol Request
181 @param UsbIo EFI_USB_IO_PROTOCOL
182 @param Interface Which interface the caller wants to set protocol
183 @param Protocol Protocol value the caller wants to set.
186 @return EFI_DEVICE_ERROR
191 UsbSetProtocolRequest (
192 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
199 EFI_USB_DEVICE_REQUEST Request
;
202 return EFI_INVALID_PARAMETER
;
205 // Fill Device request packet
207 Request
.RequestType
= 0x21;
211 Request
.Request
= EFI_USB_SET_PROTOCOL_REQUEST
;
212 Request
.Value
= Protocol
;
213 Request
.Index
= Interface
;
216 Result
= UsbIo
->UsbControlTransfer (
233 @param UsbIo EFI_USB_IO_PROTOCOL
234 @param Interface Which interface the caller wants to set.
235 @param ReportId Which report the caller wants to set.
236 @param Duration Idle rate the caller wants to set.
239 @return EFI_DEVICE_ERROR
245 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
253 EFI_USB_DEVICE_REQUEST Request
;
256 return EFI_INVALID_PARAMETER
;
259 // Fill Device request packet
261 Request
.RequestType
= 0x21;
265 Request
.Request
= EFI_USB_SET_IDLE_REQUEST
;
266 Request
.Value
= (UINT16
) ((Duration
<< 8) | ReportId
);
267 Request
.Index
= Interface
;
270 Result
= UsbIo
->UsbControlTransfer (
286 @param UsbIo EFI_USB_IO_PROTOCOL
287 @param Interface Which interface the caller wants to get.
288 @param ReportId Which report the caller wants to get.
289 @param Duration Idle rate the caller wants to get.
292 @return EFI_DEVICE_ERROR
298 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
306 EFI_USB_DEVICE_REQUEST Request
;
309 return EFI_INVALID_PARAMETER
;
312 // Fill Device request packet
314 Request
.RequestType
= 0xa1;
318 Request
.Request
= EFI_USB_GET_IDLE_REQUEST
;
319 Request
.Value
= ReportId
;
320 Request
.Index
= Interface
;
323 Result
= UsbIo
->UsbControlTransfer (
339 Hid Set Report request.
341 @param UsbIo EFI_USB_IO_PROTOCOL
342 @param Interface Which interface the caller wants to set.
343 @param ReportId Which report the caller wants to set.
344 @param ReportType Type of report.
345 @param ReportLen Length of report descriptor.
346 @param Report Report Descriptor buffer.
349 @return EFI_DEVICE_ERROR
354 UsbSetReportRequest (
355 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
365 EFI_USB_DEVICE_REQUEST Request
;
368 return EFI_INVALID_PARAMETER
;
371 // Fill Device request packet
373 Request
.RequestType
= 0x21;
377 Request
.Request
= EFI_USB_SET_REPORT_REQUEST
;
378 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
379 Request
.Index
= Interface
;
380 Request
.Length
= ReportLen
;
382 Result
= UsbIo
->UsbControlTransfer (
397 Hid Set Report request.
399 @param UsbIo EFI_USB_IO_PROTOCOL
400 @param Interface Which interface the caller wants to set.
401 @param ReportId Which report the caller wants to set.
402 @param ReportType Type of report.
403 @param ReportLen Length of report descriptor.
404 @param Report Caller allocated buffer to store Report Descriptor.
407 @return EFI_DEVICE_ERROR
412 UsbGetReportRequest (
413 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
423 EFI_USB_DEVICE_REQUEST Request
;
426 return EFI_INVALID_PARAMETER
;
429 // Fill Device request packet
431 Request
.RequestType
= 0xa1;
435 Request
.Request
= EFI_USB_GET_REPORT_REQUEST
;
436 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
437 Request
.Index
= Interface
;
438 Request
.Length
= ReportLen
;
440 Result
= UsbIo
->UsbControlTransfer (