3 Copyright (c) 2004, Intel Corporation
\r
4 All rights reserved. This program and the accompanying materials
\r
5 are licensed and made available under the terms and conditions of the BSD License
\r
6 which accompanies this distribution. The full text of the license may be found at
\r
7 http://opensource.org/licenses/bsd-license.php
\r
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
\r
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
\r
15 #include <UefiUsbLibInternal.h>
\r
21 @param UsbIo EFI_USB_IO_PROTOCOL
\r
22 @param InterfaceNum Hid interface number
\r
23 @param HidDescriptor Caller allocated buffer to store Usb hid descriptor if
\r
24 successfully returned.
\r
27 @return EFI_DEVICE_ERROR
\r
32 UsbGetHidDescriptor (
\r
33 IN EFI_USB_IO_PROTOCOL *UsbIo,
\r
34 IN UINT8 InterfaceNum,
\r
35 OUT EFI_USB_HID_DESCRIPTOR *HidDescriptor
\r
40 EFI_USB_DEVICE_REQUEST Request;
\r
42 Request.RequestType = 0x81;
\r
43 Request.Request = 0x06;
\r
44 Request.Value = (UINT16) (0x21 << 8);
\r
45 Request.Index = InterfaceNum;
\r
46 Request.Length = sizeof (EFI_USB_HID_DESCRIPTOR);
\r
48 Result = UsbIo->UsbControlTransfer (
\r
54 sizeof (EFI_USB_HID_DESCRIPTOR),
\r
62 // Function to get Report Class descriptor
\r
66 get Report Class descriptor
\r
68 @param UsbIo EFI_USB_IO_PROTOCOL.
\r
69 @param InterfaceNum Report interface number.
\r
70 @param DescriptorSize Length of DescriptorBuffer.
\r
71 @param DescriptorBuffer Caller allocated buffer to store Usb report descriptor
\r
72 if successfully returned.
\r
75 @return EFI_DEVICE_ERROR
\r
80 UsbGetReportDescriptor (
\r
81 IN EFI_USB_IO_PROTOCOL *UsbIo,
\r
82 IN UINT8 InterfaceNum,
\r
83 IN UINT16 DescriptorSize,
\r
84 OUT UINT8 *DescriptorBuffer
\r
89 EFI_USB_DEVICE_REQUEST Request;
\r
92 // Fill Device request packet
\r
94 Request.RequestType = 0x81;
\r
95 Request.Request = 0x06;
\r
96 Request.Value = (UINT16) (0x22 << 8);
\r
97 Request.Index = InterfaceNum;
\r
98 Request.Length = DescriptorSize;
\r
100 Result = UsbIo->UsbControlTransfer (
\r
114 // Following are HID class request
\r
118 Get Hid Protocol Request
\r
120 @param UsbIo EFI_USB_IO_PROTOCOL
\r
121 @param Interface Which interface the caller wants to get protocol
\r
122 @param Protocol Protocol value returned.
\r
124 @return EFI_SUCCESS
\r
125 @return EFI_DEVICE_ERROR
\r
126 @return EFI_TIMEOUT
\r
130 UsbGetProtocolRequest (
\r
131 IN EFI_USB_IO_PROTOCOL *UsbIo,
\r
132 IN UINT8 Interface,
\r
138 EFI_USB_DEVICE_REQUEST Request;
\r
141 // Fill Device request packet
\r
143 Request.RequestType = 0xa1;
\r
147 Request.Request = EFI_USB_GET_PROTOCOL_REQUEST;
\r
149 Request.Index = Interface;
\r
150 Request.Length = 1;
\r
152 Result = UsbIo->UsbControlTransfer (
\r
168 Set Hid Protocol Request
\r
170 @param UsbIo EFI_USB_IO_PROTOCOL
\r
171 @param Interface Which interface the caller wants to set protocol
\r
172 @param Protocol Protocol value the caller wants to set.
\r
174 @return EFI_SUCCESS
\r
175 @return EFI_DEVICE_ERROR
\r
176 @return EFI_TIMEOUT
\r
180 UsbSetProtocolRequest (
\r
181 IN EFI_USB_IO_PROTOCOL *UsbIo,
\r
182 IN UINT8 Interface,
\r
188 EFI_USB_DEVICE_REQUEST Request;
\r
191 // Fill Device request packet
\r
193 Request.RequestType = 0x21;
\r
197 Request.Request = EFI_USB_SET_PROTOCOL_REQUEST;
\r
198 Request.Value = Protocol;
\r
199 Request.Index = Interface;
\r
200 Request.Length = 0;
\r
202 Result = UsbIo->UsbControlTransfer (
\r
219 @param UsbIo EFI_USB_IO_PROTOCOL
\r
220 @param Interface Which interface the caller wants to set.
\r
221 @param ReportId Which report the caller wants to set.
\r
222 @param Duration Idle rate the caller wants to set.
\r
224 @return EFI_SUCCESS
\r
225 @return EFI_DEVICE_ERROR
\r
226 @return EFI_TIMEOUT
\r
230 UsbSetIdleRequest (
\r
231 IN EFI_USB_IO_PROTOCOL *UsbIo,
\r
232 IN UINT8 Interface,
\r
239 EFI_USB_DEVICE_REQUEST Request;
\r
242 // Fill Device request packet
\r
244 Request.RequestType = 0x21;
\r
248 Request.Request = EFI_USB_SET_IDLE_REQUEST;
\r
249 Request.Value = (UINT16) ((Duration << 8) | ReportId);
\r
250 Request.Index = Interface;
\r
251 Request.Length = 0;
\r
253 Result = UsbIo->UsbControlTransfer (
\r
269 @param UsbIo EFI_USB_IO_PROTOCOL
\r
270 @param Interface Which interface the caller wants to get.
\r
271 @param ReportId Which report the caller wants to get.
\r
272 @param Duration Idle rate the caller wants to get.
\r
274 @return EFI_SUCCESS
\r
275 @return EFI_DEVICE_ERROR
\r
276 @return EFI_TIMEOUT
\r
280 UsbGetIdleRequest (
\r
281 IN EFI_USB_IO_PROTOCOL *UsbIo,
\r
282 IN UINT8 Interface,
\r
284 OUT UINT8 *Duration
\r
289 EFI_USB_DEVICE_REQUEST Request;
\r
292 // Fill Device request packet
\r
294 Request.RequestType = 0xa1;
\r
298 Request.Request = EFI_USB_GET_IDLE_REQUEST;
\r
299 Request.Value = ReportId;
\r
300 Request.Index = Interface;
\r
301 Request.Length = 1;
\r
303 Result = UsbIo->UsbControlTransfer (
\r
319 Hid Set Report request.
\r
321 @param UsbIo EFI_USB_IO_PROTOCOL
\r
322 @param Interface Which interface the caller wants to set.
\r
323 @param ReportId Which report the caller wants to set.
\r
324 @param ReportType Type of report.
\r
325 @param ReportLen Length of report descriptor.
\r
326 @param Report Report Descriptor buffer.
\r
328 @return EFI_SUCCESS
\r
329 @return EFI_DEVICE_ERROR
\r
330 @return EFI_TIMEOUT
\r
334 UsbSetReportRequest (
\r
335 IN EFI_USB_IO_PROTOCOL *UsbIo,
\r
336 IN UINT8 Interface,
\r
338 IN UINT8 ReportType,
\r
339 IN UINT16 ReportLen,
\r
345 EFI_USB_DEVICE_REQUEST Request;
\r
348 // Fill Device request packet
\r
350 Request.RequestType = 0x21;
\r
354 Request.Request = EFI_USB_SET_REPORT_REQUEST;
\r
355 Request.Value = (UINT16) ((ReportType << 8) | ReportId);
\r
356 Request.Index = Interface;
\r
357 Request.Length = ReportLen;
\r
359 Result = UsbIo->UsbControlTransfer (
\r
374 Hid Set Report request.
\r
376 @param UsbIo EFI_USB_IO_PROTOCOL
\r
377 @param Interface Which interface the caller wants to set.
\r
378 @param ReportId Which report the caller wants to set.
\r
379 @param ReportType Type of report.
\r
380 @param ReportLen Length of report descriptor.
\r
381 @param Report Caller allocated buffer to store Report Descriptor.
\r
383 @return EFI_SUCCESS
\r
384 @return EFI_DEVICE_ERROR
\r
385 @return EFI_TIMEOUT
\r
389 UsbGetReportRequest (
\r
390 IN EFI_USB_IO_PROTOCOL *UsbIo,
\r
391 IN UINT8 Interface,
\r
393 IN UINT8 ReportType,
\r
394 IN UINT16 ReportLen,
\r
400 EFI_USB_DEVICE_REQUEST Request;
\r
403 // Fill Device request packet
\r
405 Request.RequestType = 0xa1;
\r
409 Request.Request = EFI_USB_GET_REPORT_REQUEST;
\r
410 Request.Value = (UINT16) ((ReportType << 8) | ReportId);
\r
411 Request.Index = Interface;
\r
412 Request.Length = ReportLen;
\r
414 Result = UsbIo->UsbControlTransfer (
\r