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.
25 // Include common header file for this module.
27 #include "CommonHeader.h"
30 // Function to get HID descriptor
34 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
35 IN UINT8 InterfaceNum
,
36 OUT EFI_USB_HID_DESCRIPTOR
*HidDescriptor
44 UsbIo - EFI_USB_IO_PROTOCOL
45 InterfaceNum - Hid interface number
46 HidDescriptor - Caller allocated buffer to store Usb hid descriptor
47 if successfully returned.
58 EFI_USB_DEVICE_REQUEST Request
;
60 Request
.RequestType
= 0x81;
61 Request
.Request
= 0x06;
62 Request
.Value
= (UINT16
) (0x21 << 8);
63 Request
.Index
= InterfaceNum
;
64 Request
.Length
= sizeof (EFI_USB_HID_DESCRIPTOR
);
66 Result
= UsbIo
->UsbControlTransfer (
72 sizeof (EFI_USB_HID_DESCRIPTOR
),
80 // Function to get Report Class descriptor
83 UsbGetReportDescriptor (
84 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
85 IN UINT8 InterfaceNum
,
86 IN UINT16 DescriptorSize
,
87 OUT UINT8
*DescriptorBuffer
92 get Report Class descriptor
95 UsbIo - EFI_USB_IO_PROTOCOL.
96 InterfaceNum - Report interface number.
97 DescriptorSize - Length of DescriptorBuffer.
98 DescriptorBuffer - Caller allocated buffer to store Usb report descriptor
99 if successfully returned.
110 EFI_USB_DEVICE_REQUEST Request
;
113 // Fill Device request packet
115 Request
.RequestType
= 0x81;
116 Request
.Request
= 0x06;
117 Request
.Value
= (UINT16
) (0x22 << 8);
118 Request
.Index
= InterfaceNum
;
119 Request
.Length
= DescriptorSize
;
121 Result
= UsbIo
->UsbControlTransfer (
135 // Following are HID class request
138 UsbGetProtocolRequest (
139 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
146 Get Hid Protocol Request
149 UsbIo - EFI_USB_IO_PROTOCOL
150 Interface - Which interface the caller wants to get protocol
151 Protocol - Protocol value returned.
162 EFI_USB_DEVICE_REQUEST Request
;
165 // Fill Device request packet
167 Request
.RequestType
= 0xa1;
171 Request
.Request
= EFI_USB_GET_PROTOCOL_REQUEST
;
173 Request
.Index
= Interface
;
176 Result
= UsbIo
->UsbControlTransfer (
191 UsbSetProtocolRequest (
192 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
199 Set Hid Protocol Request
202 UsbIo - EFI_USB_IO_PROTOCOL
203 Interface - Which interface the caller wants to set protocol
204 Protocol - Protocol value the caller wants to set.
215 EFI_USB_DEVICE_REQUEST Request
;
218 // Fill Device request packet
220 Request
.RequestType
= 0x21;
224 Request
.Request
= EFI_USB_SET_PROTOCOL_REQUEST
;
225 Request
.Value
= Protocol
;
226 Request
.Index
= Interface
;
229 Result
= UsbIo
->UsbControlTransfer (
244 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
255 UsbIo - EFI_USB_IO_PROTOCOL
256 Interface - Which interface the caller wants to set.
257 ReportId - Which report the caller wants to set.
258 Duration - Idle rate the caller wants to set.
269 EFI_USB_DEVICE_REQUEST Request
;
272 // Fill Device request packet
274 Request
.RequestType
= 0x21;
278 Request
.Request
= EFI_USB_SET_IDLE_REQUEST
;
279 Request
.Value
= (UINT16
) ((Duration
<< 8) | ReportId
);
280 Request
.Index
= Interface
;
283 Result
= UsbIo
->UsbControlTransfer (
297 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
308 UsbIo - EFI_USB_IO_PROTOCOL
309 Interface - Which interface the caller wants to get.
310 ReportId - Which report the caller wants to get.
311 Duration - Idle rate the caller wants to get.
322 EFI_USB_DEVICE_REQUEST Request
;
325 // Fill Device request packet
327 Request
.RequestType
= 0xa1;
331 Request
.Request
= EFI_USB_GET_IDLE_REQUEST
;
332 Request
.Value
= ReportId
;
333 Request
.Index
= Interface
;
336 Result
= UsbIo
->UsbControlTransfer (
351 UsbSetReportRequest (
352 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
362 Hid Set Report request.
365 UsbIo - EFI_USB_IO_PROTOCOL
366 Interface - Which interface the caller wants to set.
367 ReportId - Which report the caller wants to set.
368 ReportType - Type of report.
369 ReportLen - Length of report descriptor.
370 Report - Report Descriptor buffer.
381 EFI_USB_DEVICE_REQUEST Request
;
384 // Fill Device request packet
386 Request
.RequestType
= 0x21;
390 Request
.Request
= EFI_USB_SET_REPORT_REQUEST
;
391 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
392 Request
.Index
= Interface
;
393 Request
.Length
= ReportLen
;
395 Result
= UsbIo
->UsbControlTransfer (
409 UsbGetReportRequest (
410 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
420 Hid Set Report request.
423 UsbIo - EFI_USB_IO_PROTOCOL
424 Interface - Which interface the caller wants to set.
425 ReportId - Which report the caller wants to set.
426 ReportType - Type of report.
427 ReportLen - Length of report descriptor.
428 Report - Caller allocated buffer to store Report Descriptor.
439 EFI_USB_DEVICE_REQUEST Request
;
442 // Fill Device request packet
444 Request
.RequestType
= 0xa1;
448 Request
.Request
= EFI_USB_GET_REPORT_REQUEST
;
449 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
450 Request
.Index
= Interface
;
451 Request
.Length
= ReportLen
;
453 Result
= UsbIo
->UsbControlTransfer (