TianoCore EDK2 master
Loading...
Searching...
No Matches
Hid.c
Go to the documentation of this file.
1
11#include "UefiUsbLibInternal.h"
12
13//
14// Hid RequestType Bits specifying characteristics of request.
15// Valid values are 10100001b (0xa1) or 00100001b (0x21).
16// The following description:
17// 7 Data transfer direction
18// 0 = Host to device
19// 1 = Device to host
20// 6..5 Type
21// 1 = Class
22// 4..0 Recipient
23// 1 = Interface
24//
25
46EFIAPI
49 IN UINT8 Interface,
50 OUT EFI_USB_HID_DESCRIPTOR *HidDescriptor
51 )
52{
53 UINT32 Status;
54 EFI_STATUS Result;
56
57 ASSERT (UsbIo != NULL);
58 ASSERT (HidDescriptor != NULL);
59
60 Request.RequestType = USB_HID_GET_DESCRIPTOR_REQ_TYPE;
61 Request.Request = USB_REQ_GET_DESCRIPTOR;
62 Request.Value = (UINT16)(USB_DESC_TYPE_HID << 8);
63 Request.Index = Interface;
64 Request.Length = (UINT16)sizeof (EFI_USB_HID_DESCRIPTOR);
65
66 Result = UsbIo->UsbControlTransfer (
67 UsbIo,
68 &Request,
69 EfiUsbDataIn,
70 PcdGet32 (PcdUsbTransferTimeoutValue),
71 HidDescriptor,
73 &Status
74 );
75
76 return Result;
77}
78
101EFIAPI
103 IN EFI_USB_IO_PROTOCOL *UsbIo,
104 IN UINT8 Interface,
105 IN UINT16 DescriptorLength,
106 OUT UINT8 *DescriptorBuffer
107 )
108{
109 UINT32 Status;
110 EFI_STATUS Result;
112
113 ASSERT (UsbIo != NULL);
114 ASSERT (DescriptorBuffer != NULL);
115
116 //
117 // Fill Device request packet
118 //
119 Request.RequestType = USB_HID_GET_DESCRIPTOR_REQ_TYPE;
120 Request.Request = USB_REQ_GET_DESCRIPTOR;
121 Request.Value = (UINT16)(USB_DESC_TYPE_REPORT << 8);
122 Request.Index = Interface;
123 Request.Length = DescriptorLength;
124
125 Result = UsbIo->UsbControlTransfer (
126 UsbIo,
127 &Request,
128 EfiUsbDataIn,
129 PcdGet32 (PcdUsbTransferTimeoutValue),
130 DescriptorBuffer,
131 DescriptorLength,
132 &Status
133 );
134
135 return Result;
136}
137
156EFIAPI
158 IN EFI_USB_IO_PROTOCOL *UsbIo,
159 IN UINT8 Interface,
160 OUT UINT8 *Protocol
161 )
162{
163 UINT32 Status;
164 EFI_STATUS Result;
166
167 ASSERT (UsbIo != NULL);
168 ASSERT (Protocol != NULL);
169
170 //
171 // Fill Device request packet
172 //
173 Request.RequestType = USB_HID_CLASS_GET_REQ_TYPE;
174 Request.Request = EFI_USB_GET_PROTOCOL_REQUEST;
175 Request.Value = 0;
176 Request.Index = Interface;
177 Request.Length = 1;
178
179 Result = UsbIo->UsbControlTransfer (
180 UsbIo,
181 &Request,
182 EfiUsbDataIn,
183 PcdGet32 (PcdUsbTransferTimeoutValue),
184 Protocol,
185 sizeof (UINT8),
186 &Status
187 );
188
189 return Result;
190}
191
209EFIAPI
211 IN EFI_USB_IO_PROTOCOL *UsbIo,
212 IN UINT8 Interface,
213 IN UINT8 Protocol
214 )
215{
216 UINT32 Status;
217 EFI_STATUS Result;
219
220 ASSERT (UsbIo != NULL);
221
222 //
223 // Fill Device request packet
224 //
225 Request.RequestType = USB_HID_CLASS_SET_REQ_TYPE;
226 Request.Request = EFI_USB_SET_PROTOCOL_REQUEST;
227 Request.Value = Protocol;
228 Request.Index = Interface;
229 Request.Length = 0;
230
231 Result = UsbIo->UsbControlTransfer (
232 UsbIo,
233 &Request,
234 EfiUsbNoData,
235 PcdGet32 (PcdUsbTransferTimeoutValue),
236 NULL,
237 0,
238 &Status
239 );
240 return Result;
241}
242
261EFIAPI
263 IN EFI_USB_IO_PROTOCOL *UsbIo,
264 IN UINT8 Interface,
265 IN UINT8 ReportId,
266 IN UINT8 Duration
267 )
268{
269 UINT32 Status;
270 EFI_STATUS Result;
272
273 ASSERT (UsbIo != NULL);
274 //
275 // Fill Device request packet
276 //
277 Request.RequestType = USB_HID_CLASS_SET_REQ_TYPE;
278 Request.Request = EFI_USB_SET_IDLE_REQUEST;
279 Request.Value = (UINT16)((Duration << 8) | ReportId);
280 Request.Index = Interface;
281 Request.Length = 0;
282
283 Result = UsbIo->UsbControlTransfer (
284 UsbIo,
285 &Request,
286 EfiUsbNoData,
287 PcdGet32 (PcdUsbTransferTimeoutValue),
288 NULL,
289 0,
290 &Status
291 );
292 return Result;
293}
294
314EFIAPI
316 IN EFI_USB_IO_PROTOCOL *UsbIo,
317 IN UINT8 Interface,
318 IN UINT8 ReportId,
319 OUT UINT8 *Duration
320 )
321{
322 UINT32 Status;
323 EFI_STATUS Result;
325
326 ASSERT (UsbIo != NULL);
327 ASSERT (Duration != NULL);
328 //
329 // Fill Device request packet
330 //
331 Request.RequestType = USB_HID_CLASS_GET_REQ_TYPE;
332 Request.Request = EFI_USB_GET_IDLE_REQUEST;
333 Request.Value = ReportId;
334 Request.Index = Interface;
335 Request.Length = 1;
336
337 Result = UsbIo->UsbControlTransfer (
338 UsbIo,
339 &Request,
340 EfiUsbDataIn,
341 PcdGet32 (PcdUsbTransferTimeoutValue),
342 Duration,
343 1,
344 &Status
345 );
346
347 return Result;
348}
349
372EFIAPI
374 IN EFI_USB_IO_PROTOCOL *UsbIo,
375 IN UINT8 Interface,
376 IN UINT8 ReportId,
377 IN UINT8 ReportType,
378 IN UINT16 ReportLen,
379 IN UINT8 *Report
380 )
381{
382 UINT32 Status;
383 EFI_STATUS Result;
385
386 ASSERT (UsbIo != NULL);
387 ASSERT (Report != NULL);
388
389 //
390 // Fill Device request packet
391 //
392 Request.RequestType = USB_HID_CLASS_SET_REQ_TYPE;
393 Request.Request = EFI_USB_SET_REPORT_REQUEST;
394 Request.Value = (UINT16)((ReportType << 8) | ReportId);
395 Request.Index = Interface;
396 Request.Length = ReportLen;
397
398 Result = UsbIo->UsbControlTransfer (
399 UsbIo,
400 &Request,
401 EfiUsbDataOut,
402 PcdGet32 (PcdUsbTransferTimeoutValue),
403 Report,
404 ReportLen,
405 &Status
406 );
407
408 return Result;
409}
410
436EFIAPI
438 IN EFI_USB_IO_PROTOCOL *UsbIo,
439 IN UINT8 Interface,
440 IN UINT8 ReportId,
441 IN UINT8 ReportType,
442 IN UINT16 ReportLen,
443 OUT UINT8 *Report
444 )
445{
446 UINT32 Status;
447 EFI_STATUS Result;
449
450 ASSERT (UsbIo != NULL);
451 ASSERT (Report != NULL);
452
453 //
454 // Fill Device request packet
455 //
456 Request.RequestType = USB_HID_CLASS_GET_REQ_TYPE;
457 Request.Request = EFI_USB_GET_REPORT_REQUEST;
458 Request.Value = (UINT16)((ReportType << 8) | ReportId);
459 Request.Index = Interface;
460 Request.Length = ReportLen;
461
462 Result = UsbIo->UsbControlTransfer (
463 UsbIo,
464 &Request,
465 EfiUsbDataIn,
466 PcdGet32 (PcdUsbTransferTimeoutValue),
467 Report,
468 ReportLen,
469 &Status
470 );
471
472 return Result;
473}
EFI_STATUS EFIAPI UsbGetReportDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT16 DescriptorLength, OUT UINT8 *DescriptorBuffer)
Definition: Hid.c:102
EFI_STATUS EFIAPI UsbSetReportRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT8 ReportId, IN UINT8 ReportType, IN UINT16 ReportLen, IN UINT8 *Report)
Definition: Hid.c:373
EFI_STATUS EFIAPI UsbSetProtocolRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT8 Protocol)
Definition: Hid.c:210
EFI_STATUS EFIAPI UsbGetReportRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT8 ReportId, IN UINT8 ReportType, IN UINT16 ReportLen, OUT UINT8 *Report)
Definition: Hid.c:437
EFI_STATUS EFIAPI UsbGetProtocolRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, OUT UINT8 *Protocol)
Definition: Hid.c:157
EFI_STATUS EFIAPI UsbSetIdleRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT8 ReportId, IN UINT8 Duration)
Definition: Hid.c:262
EFI_STATUS EFIAPI UsbGetHidDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, OUT EFI_USB_HID_DESCRIPTOR *HidDescriptor)
Definition: Hid.c:47
EFI_STATUS EFIAPI UsbGetIdleRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT8 ReportId, OUT UINT8 *Duration)
Definition: Hid.c:315
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
struct hid_descriptor EFI_USB_HID_DESCRIPTOR