3 Copyright (c) 2004, 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.
15 #include <UefiUsbLibInternal.h>
21 @param UsbIo EFI_USB_IO_PROTOCOL
22 @param InterfaceNum Hid interface number
23 @param HidDescriptor Caller allocated buffer to store Usb hid descriptor if
24 successfully returned.
27 @return EFI_DEVICE_ERROR
33 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
34 IN UINT8 InterfaceNum
,
35 OUT EFI_USB_HID_DESCRIPTOR
*HidDescriptor
40 EFI_USB_DEVICE_REQUEST Request
;
42 Request
.RequestType
= 0x81;
43 Request
.Request
= 0x06;
44 Request
.Value
= (UINT16
) (0x21 << 8);
45 Request
.Index
= InterfaceNum
;
46 Request
.Length
= sizeof (EFI_USB_HID_DESCRIPTOR
);
48 Result
= UsbIo
->UsbControlTransfer (
54 sizeof (EFI_USB_HID_DESCRIPTOR
),
62 // Function to get Report Class descriptor
66 get Report Class descriptor
68 @param UsbIo EFI_USB_IO_PROTOCOL.
69 @param InterfaceNum Report interface number.
70 @param DescriptorSize Length of DescriptorBuffer.
71 @param DescriptorBuffer Caller allocated buffer to store Usb report descriptor
72 if successfully returned.
75 @return EFI_DEVICE_ERROR
80 UsbGetReportDescriptor (
81 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
82 IN UINT8 InterfaceNum
,
83 IN UINT16 DescriptorSize
,
84 OUT UINT8
*DescriptorBuffer
89 EFI_USB_DEVICE_REQUEST Request
;
92 // Fill Device request packet
94 Request
.RequestType
= 0x81;
95 Request
.Request
= 0x06;
96 Request
.Value
= (UINT16
) (0x22 << 8);
97 Request
.Index
= InterfaceNum
;
98 Request
.Length
= DescriptorSize
;
100 Result
= UsbIo
->UsbControlTransfer (
114 // Following are HID class request
118 Get Hid Protocol Request
120 @param UsbIo EFI_USB_IO_PROTOCOL
121 @param Interface Which interface the caller wants to get protocol
122 @param Protocol Protocol value returned.
125 @return EFI_DEVICE_ERROR
130 UsbGetProtocolRequest (
131 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
138 EFI_USB_DEVICE_REQUEST Request
;
141 // Fill Device request packet
143 Request
.RequestType
= 0xa1;
147 Request
.Request
= EFI_USB_GET_PROTOCOL_REQUEST
;
149 Request
.Index
= Interface
;
152 Result
= UsbIo
->UsbControlTransfer (
168 Set Hid Protocol Request
170 @param UsbIo EFI_USB_IO_PROTOCOL
171 @param Interface Which interface the caller wants to set protocol
172 @param Protocol Protocol value the caller wants to set.
175 @return EFI_DEVICE_ERROR
180 UsbSetProtocolRequest (
181 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
188 EFI_USB_DEVICE_REQUEST Request
;
191 // Fill Device request packet
193 Request
.RequestType
= 0x21;
197 Request
.Request
= EFI_USB_SET_PROTOCOL_REQUEST
;
198 Request
.Value
= Protocol
;
199 Request
.Index
= Interface
;
202 Result
= UsbIo
->UsbControlTransfer (
219 @param UsbIo EFI_USB_IO_PROTOCOL
220 @param Interface Which interface the caller wants to set.
221 @param ReportId Which report the caller wants to set.
222 @param Duration Idle rate the caller wants to set.
225 @return EFI_DEVICE_ERROR
231 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
239 EFI_USB_DEVICE_REQUEST Request
;
242 // Fill Device request packet
244 Request
.RequestType
= 0x21;
248 Request
.Request
= EFI_USB_SET_IDLE_REQUEST
;
249 Request
.Value
= (UINT16
) ((Duration
<< 8) | ReportId
);
250 Request
.Index
= Interface
;
253 Result
= UsbIo
->UsbControlTransfer (
269 @param UsbIo EFI_USB_IO_PROTOCOL
270 @param Interface Which interface the caller wants to get.
271 @param ReportId Which report the caller wants to get.
272 @param Duration Idle rate the caller wants to get.
275 @return EFI_DEVICE_ERROR
281 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
289 EFI_USB_DEVICE_REQUEST Request
;
292 // Fill Device request packet
294 Request
.RequestType
= 0xa1;
298 Request
.Request
= EFI_USB_GET_IDLE_REQUEST
;
299 Request
.Value
= ReportId
;
300 Request
.Index
= Interface
;
303 Result
= UsbIo
->UsbControlTransfer (
319 Hid Set Report request.
321 @param UsbIo EFI_USB_IO_PROTOCOL
322 @param Interface Which interface the caller wants to set.
323 @param ReportId Which report the caller wants to set.
324 @param ReportType Type of report.
325 @param ReportLen Length of report descriptor.
326 @param Report Report Descriptor buffer.
329 @return EFI_DEVICE_ERROR
334 UsbSetReportRequest (
335 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
345 EFI_USB_DEVICE_REQUEST Request
;
348 // Fill Device request packet
350 Request
.RequestType
= 0x21;
354 Request
.Request
= EFI_USB_SET_REPORT_REQUEST
;
355 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
356 Request
.Index
= Interface
;
357 Request
.Length
= ReportLen
;
359 Result
= UsbIo
->UsbControlTransfer (
374 Hid Set Report request.
376 @param UsbIo EFI_USB_IO_PROTOCOL
377 @param Interface Which interface the caller wants to set.
378 @param ReportId Which report the caller wants to set.
379 @param ReportType Type of report.
380 @param ReportLen Length of report descriptor.
381 @param Report Caller allocated buffer to store Report Descriptor.
384 @return EFI_DEVICE_ERROR
389 UsbGetReportRequest (
390 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
400 EFI_USB_DEVICE_REQUEST Request
;
403 // Fill Device request packet
405 Request
.RequestType
= 0xa1;
409 Request
.Request
= EFI_USB_GET_REPORT_REQUEST
;
410 Request
.Value
= (UINT16
) ((ReportType
<< 8) | ReportId
);
411 Request
.Index
= Interface
;
412 Request
.Length
= ReportLen
;
414 Result
= UsbIo
->UsbControlTransfer (