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
),
68 Get Report Class descriptor.
70 @param UsbIo EFI_USB_IO_PROTOCOL.
71 @param InterfaceNum Report interface number.
72 @param DescriptorSize Length of DescriptorBuffer.
73 @param DescriptorBuffer Caller allocated buffer to store Usb report descriptor
74 if successfully returned.
77 @return EFI_DEVICE_ERROR
82 UsbGetReportDescriptor (
83 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
84 IN UINT8 InterfaceNum
,
85 IN UINT16 DescriptorSize
,
86 OUT UINT8
*DescriptorBuffer
91 EFI_USB_DEVICE_REQUEST Request
;
94 return EFI_INVALID_PARAMETER
;
97 // Fill Device request packet
99 Request
.RequestType
= 0x81;
100 Request
.Request
= 0x06;
101 Request
.Value
= (UINT16
) (0x22 << 8);
102 Request
.Index
= InterfaceNum
;
103 Request
.Length
= DescriptorSize
;
105 Result
= UsbIo
->UsbControlTransfer (
120 Get Hid Protocol Request.
122 @param UsbIo EFI_USB_IO_PROTOCOL.
123 @param Interface Which interface the caller wants to get protocol.
124 @param Protocol Protocol value returned.
127 @return EFI_DEVICE_ERROR
132 UsbGetProtocolRequest (
133 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
140 EFI_USB_DEVICE_REQUEST Request
;
143 return EFI_INVALID_PARAMETER
;
146 // Fill Device request packet
148 Request
.RequestType
= 0xa1;
152 Request
.Request
= EFI_USB_GET_PROTOCOL_REQUEST
;
154 Request
.Index
= Interface
;
157 Result
= UsbIo
->UsbControlTransfer (
172 Set Hid Protocol Request.
174 @param UsbIo EFI_USB_IO_PROTOCOL.
175 @param Interface Which interface the caller wants to set protocol.
176 @param Protocol Protocol value the caller wants to set.
179 @return EFI_DEVICE_ERROR
184 UsbSetProtocolRequest (
185 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
192 EFI_USB_DEVICE_REQUEST Request
;
195 return EFI_INVALID_PARAMETER
;
198 // Fill Device request packet
200 Request
.RequestType
= 0x21;
204 Request
.Request
= EFI_USB_SET_PROTOCOL_REQUEST
;
205 Request
.Value
= Protocol
;
206 Request
.Index
= Interface
;
209 Result
= UsbIo
->UsbControlTransfer (
225 @param UsbIo EFI_USB_IO_PROTOCOL.
226 @param Interface Which interface the caller wants to set.
227 @param ReportId Which report the caller wants to set.
228 @param Duration Idle rate the caller wants to set.
231 @return EFI_DEVICE_ERROR
237 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
245 EFI_USB_DEVICE_REQUEST Request
;
248 return EFI_INVALID_PARAMETER
;
251 // Fill Device request packet
253 Request
.RequestType
= 0x21;
257 Request
.Request
= EFI_USB_SET_IDLE_REQUEST
;
258 Request
.Value
= (UINT16
) ((Duration
<< 8) | ReportId
);
259 Request
.Index
= Interface
;
262 Result
= UsbIo
->UsbControlTransfer (
278 @param UsbIo EFI_USB_IO_PROTOCOL.
279 @param Interface Which interface the caller wants to get.
280 @param ReportId Which report the caller wants to get.
281 @param Duration Idle rate the caller wants to get.
284 @return EFI_DEVICE_ERROR
290 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
298 EFI_USB_DEVICE_REQUEST Request
;
301 return EFI_INVALID_PARAMETER
;
304 // Fill Device request packet
306 Request
.RequestType
= 0xa1;
310 Request
.Request
= EFI_USB_GET_IDLE_REQUEST
;
311 Request
.Value
= ReportId
;
312 Request
.Index
= Interface
;
315 Result
= UsbIo
->UsbControlTransfer (
330 Hid Set Report request.
332 @param UsbIo EFI_USB_IO_PROTOCOL.
333 @param Interface Which interface the caller wants to set.
334 @param ReportId Which report the caller wants to set.
335 @param ReportType Type of report.
336 @param ReportLen Length of report descriptor.
337 @param Report Report Descriptor buffer.
340 @return EFI_DEVICE_ERROR
345 UsbSetReportRequest (
346 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
356 EFI_USB_DEVICE_REQUEST Request
;
359 return EFI_INVALID_PARAMETER
;
362 // Fill Device request packet
364 Request
.RequestType
= 0x21;
368 Request
.Request
= EFI_USB_SET_REPORT_REQUEST
;
369 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
370 Request
.Index
= Interface
;
371 Request
.Length
= ReportLen
;
373 Result
= UsbIo
->UsbControlTransfer (
388 Hid Set Report request.
390 @param UsbIo EFI_USB_IO_PROTOCOL.
391 @param Interface Which interface the caller wants to set.
392 @param ReportId Which report the caller wants to set.
393 @param ReportType Type of report.
394 @param ReportLen Length of report descriptor.
395 @param Report Caller allocated buffer to store Report Descriptor.
398 @return EFI_DEVICE_ERROR
403 UsbGetReportRequest (
404 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
414 EFI_USB_DEVICE_REQUEST Request
;
417 return EFI_INVALID_PARAMETER
;
420 // Fill Device request packet
422 Request
.RequestType
= 0xa1;
426 Request
.Request
= EFI_USB_GET_REPORT_REQUEST
;
427 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
428 Request
.Index
= Interface
;
429 Request
.Length
= ReportLen
;
431 Result
= UsbIo
->UsbControlTransfer (