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 // Function to get HID descriptor
29 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
30 IN UINT8 InterfaceNum
,
31 OUT EFI_USB_HID_DESCRIPTOR
*HidDescriptor
39 UsbIo - EFI_USB_IO_PROTOCOL
40 InterfaceNum - Hid interface number
41 HidDescriptor - Caller allocated buffer to store Usb hid descriptor
42 if successfully returned.
53 EFI_USB_DEVICE_REQUEST Request
;
55 Request
.RequestType
= 0x81;
56 Request
.Request
= 0x06;
57 Request
.Value
= (UINT16
) (0x21 << 8);
58 Request
.Index
= InterfaceNum
;
59 Request
.Length
= sizeof (EFI_USB_HID_DESCRIPTOR
);
61 Result
= UsbIo
->UsbControlTransfer (
67 sizeof (EFI_USB_HID_DESCRIPTOR
),
75 // Function to get Report Class descriptor
78 UsbGetReportDescriptor (
79 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
80 IN UINT8 InterfaceNum
,
81 IN UINT16 DescriptorSize
,
82 OUT UINT8
*DescriptorBuffer
87 get Report Class descriptor
90 UsbIo - EFI_USB_IO_PROTOCOL.
91 InterfaceNum - Report interface number.
92 DescriptorSize - Length of DescriptorBuffer.
93 DescriptorBuffer - Caller allocated buffer to store Usb report descriptor
94 if successfully returned.
105 EFI_USB_DEVICE_REQUEST Request
;
108 // Fill Device request packet
110 Request
.RequestType
= 0x81;
111 Request
.Request
= 0x06;
112 Request
.Value
= (UINT16
) (0x22 << 8);
113 Request
.Index
= InterfaceNum
;
114 Request
.Length
= DescriptorSize
;
116 Result
= UsbIo
->UsbControlTransfer (
130 // Following are HID class request
133 UsbGetProtocolRequest (
134 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
141 Get Hid Protocol Request
144 UsbIo - EFI_USB_IO_PROTOCOL
145 Interface - Which interface the caller wants to get protocol
146 Protocol - Protocol value returned.
157 EFI_USB_DEVICE_REQUEST Request
;
160 // Fill Device request packet
162 Request
.RequestType
= 0xa1;
166 Request
.Request
= EFI_USB_GET_PROTOCOL_REQUEST
;
168 Request
.Index
= Interface
;
171 Result
= UsbIo
->UsbControlTransfer (
186 UsbSetProtocolRequest (
187 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
194 Set Hid Protocol Request
197 UsbIo - EFI_USB_IO_PROTOCOL
198 Interface - Which interface the caller wants to set protocol
199 Protocol - Protocol value the caller wants to set.
210 EFI_USB_DEVICE_REQUEST Request
;
213 // Fill Device request packet
215 Request
.RequestType
= 0x21;
219 Request
.Request
= EFI_USB_SET_PROTOCOL_REQUEST
;
220 Request
.Value
= Protocol
;
221 Request
.Index
= Interface
;
224 Result
= UsbIo
->UsbControlTransfer (
239 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
250 UsbIo - EFI_USB_IO_PROTOCOL
251 Interface - Which interface the caller wants to set.
252 ReportId - Which report the caller wants to set.
253 Duration - Idle rate the caller wants to set.
264 EFI_USB_DEVICE_REQUEST Request
;
267 // Fill Device request packet
269 Request
.RequestType
= 0x21;
273 Request
.Request
= EFI_USB_SET_IDLE_REQUEST
;
274 Request
.Value
= (UINT16
) ((Duration
<< 8) | ReportId
);
275 Request
.Index
= Interface
;
278 Result
= UsbIo
->UsbControlTransfer (
292 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
303 UsbIo - EFI_USB_IO_PROTOCOL
304 Interface - Which interface the caller wants to get.
305 ReportId - Which report the caller wants to get.
306 Duration - Idle rate the caller wants to get.
317 EFI_USB_DEVICE_REQUEST Request
;
320 // Fill Device request packet
322 Request
.RequestType
= 0xa1;
326 Request
.Request
= EFI_USB_GET_IDLE_REQUEST
;
327 Request
.Value
= ReportId
;
328 Request
.Index
= Interface
;
331 Result
= UsbIo
->UsbControlTransfer (
346 UsbSetReportRequest (
347 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
357 Hid Set Report request.
360 UsbIo - EFI_USB_IO_PROTOCOL
361 Interface - Which interface the caller wants to set.
362 ReportId - Which report the caller wants to set.
363 ReportType - Type of report.
364 ReportLen - Length of report descriptor.
365 Report - Report Descriptor buffer.
376 EFI_USB_DEVICE_REQUEST Request
;
379 // Fill Device request packet
381 Request
.RequestType
= 0x21;
385 Request
.Request
= EFI_USB_SET_REPORT_REQUEST
;
386 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
387 Request
.Index
= Interface
;
388 Request
.Length
= ReportLen
;
390 Result
= UsbIo
->UsbControlTransfer (
404 UsbGetReportRequest (
405 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
415 Hid Set Report request.
418 UsbIo - EFI_USB_IO_PROTOCOL
419 Interface - Which interface the caller wants to set.
420 ReportId - Which report the caller wants to set.
421 ReportType - Type of report.
422 ReportLen - Length of report descriptor.
423 Report - Caller allocated buffer to store Report Descriptor.
434 EFI_USB_DEVICE_REQUEST Request
;
437 // Fill Device request packet
439 Request
.RequestType
= 0xa1;
443 Request
.Request
= EFI_USB_GET_REPORT_REQUEST
;
444 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
445 Request
.Index
= Interface
;
446 Request
.Length
= ReportLen
;
448 Result
= UsbIo
->UsbControlTransfer (