3 Copyright (c) 2006, 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.
24 #include "UefiUsbLibInternal.h"
27 // Function to get HID descriptor
31 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
32 IN UINT8 InterfaceNum
,
33 OUT EFI_USB_HID_DESCRIPTOR
*HidDescriptor
41 UsbIo - EFI_USB_IO_PROTOCOL
42 InterfaceNum - Hid interface number
43 HidDescriptor - Caller allocated buffer to store Usb hid descriptor
44 if successfully returned.
55 EFI_USB_DEVICE_REQUEST Request
;
57 Request
.RequestType
= 0x81;
58 Request
.Request
= 0x06;
59 Request
.Value
= (UINT16
) (0x21 << 8);
60 Request
.Index
= InterfaceNum
;
61 Request
.Length
= sizeof (EFI_USB_HID_DESCRIPTOR
);
63 Result
= UsbIo
->UsbControlTransfer (
69 sizeof (EFI_USB_HID_DESCRIPTOR
),
77 // Function to get Report Class descriptor
80 UsbGetReportDescriptor (
81 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
82 IN UINT8 InterfaceNum
,
83 IN UINT16 DescriptorSize
,
84 OUT UINT8
*DescriptorBuffer
89 get Report Class descriptor
92 UsbIo - EFI_USB_IO_PROTOCOL.
93 InterfaceNum - Report interface number.
94 DescriptorSize - Length of DescriptorBuffer.
95 DescriptorBuffer - Caller allocated buffer to store Usb report descriptor
96 if successfully returned.
107 EFI_USB_DEVICE_REQUEST Request
;
110 // Fill Device request packet
112 Request
.RequestType
= 0x81;
113 Request
.Request
= 0x06;
114 Request
.Value
= (UINT16
) (0x22 << 8);
115 Request
.Index
= InterfaceNum
;
116 Request
.Length
= DescriptorSize
;
118 Result
= UsbIo
->UsbControlTransfer (
132 // Following are HID class request
135 UsbGetProtocolRequest (
136 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
143 Get Hid Protocol Request
146 UsbIo - EFI_USB_IO_PROTOCOL
147 Interface - Which interface the caller wants to get protocol
148 Protocol - Protocol value returned.
159 EFI_USB_DEVICE_REQUEST Request
;
162 // Fill Device request packet
164 Request
.RequestType
= 0xa1;
168 Request
.Request
= EFI_USB_GET_PROTOCOL_REQUEST
;
170 Request
.Index
= Interface
;
173 Result
= UsbIo
->UsbControlTransfer (
188 UsbSetProtocolRequest (
189 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
196 Set Hid Protocol Request
199 UsbIo - EFI_USB_IO_PROTOCOL
200 Interface - Which interface the caller wants to set protocol
201 Protocol - Protocol value the caller wants to set.
212 EFI_USB_DEVICE_REQUEST Request
;
215 // Fill Device request packet
217 Request
.RequestType
= 0x21;
221 Request
.Request
= EFI_USB_SET_PROTOCOL_REQUEST
;
222 Request
.Value
= Protocol
;
223 Request
.Index
= Interface
;
226 Result
= UsbIo
->UsbControlTransfer (
241 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
252 UsbIo - EFI_USB_IO_PROTOCOL
253 Interface - Which interface the caller wants to set.
254 ReportId - Which report the caller wants to set.
255 Duration - Idle rate the caller wants to set.
266 EFI_USB_DEVICE_REQUEST Request
;
269 // Fill Device request packet
271 Request
.RequestType
= 0x21;
275 Request
.Request
= EFI_USB_SET_IDLE_REQUEST
;
276 Request
.Value
= (UINT16
) ((Duration
<< 8) | ReportId
);
277 Request
.Index
= Interface
;
280 Result
= UsbIo
->UsbControlTransfer (
294 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
305 UsbIo - EFI_USB_IO_PROTOCOL
306 Interface - Which interface the caller wants to get.
307 ReportId - Which report the caller wants to get.
308 Duration - Idle rate the caller wants to get.
319 EFI_USB_DEVICE_REQUEST Request
;
322 // Fill Device request packet
324 Request
.RequestType
= 0xa1;
328 Request
.Request
= EFI_USB_GET_IDLE_REQUEST
;
329 Request
.Value
= ReportId
;
330 Request
.Index
= Interface
;
333 Result
= UsbIo
->UsbControlTransfer (
348 UsbSetReportRequest (
349 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
359 Hid Set Report request.
362 UsbIo - EFI_USB_IO_PROTOCOL
363 Interface - Which interface the caller wants to set.
364 ReportId - Which report the caller wants to set.
365 ReportType - Type of report.
366 ReportLen - Length of report descriptor.
367 Report - Report Descriptor buffer.
378 EFI_USB_DEVICE_REQUEST Request
;
381 // Fill Device request packet
383 Request
.RequestType
= 0x21;
387 Request
.Request
= EFI_USB_SET_REPORT_REQUEST
;
388 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
389 Request
.Index
= Interface
;
390 Request
.Length
= ReportLen
;
392 Result
= UsbIo
->UsbControlTransfer (
406 UsbGetReportRequest (
407 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
417 Hid Set Report request.
420 UsbIo - EFI_USB_IO_PROTOCOL
421 Interface - Which interface the caller wants to set.
422 ReportId - Which report the caller wants to set.
423 ReportType - Type of report.
424 ReportLen - Length of report descriptor.
425 Report - Caller allocated buffer to store Report Descriptor.
436 EFI_USB_DEVICE_REQUEST Request
;
439 // Fill Device request packet
441 Request
.RequestType
= 0xa1;
445 Request
.Request
= EFI_USB_GET_REPORT_REQUEST
;
446 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
447 Request
.Index
= Interface
;
448 Request
.Length
= ReportLen
;
450 Result
= UsbIo
->UsbControlTransfer (