]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiUsbLib/Hid.c
Add Usb Hid class request type into IndustryStandard/Usb.h, and replace the hard...
[mirror_edk2.git] / MdePkg / Library / UefiUsbLib / Hid.c
index 3a62d523f1964be51609bf47f0aa5a85d7302e8d..ad2c158401acc541964c55edc618db066f9455ff 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
 \r
-  The library provides USB descriptor, protocol operations.\r
+  The library provides USB HID Class standard and specific requests defined\r
+  in USB HID Firmware Specification 7 section : Requests.\r
   \r
   Copyright (c) 2004, Intel Corporation\r
   All rights reserved. This program and the accompanying materials\r
 \r
 #include <UefiUsbLibInternal.h>\r
 \r
+//  \r
+//  Hid RequestType Bits specifying characteristics of request.\r
+//  Valid values are 10100001b (0xa1) or 00100001b (0x21).\r
+//  The following description:\r
+//    7 Data transfer direction\r
+//        0 = Host to device\r
+//        1 = Device to host\r
+//    6..5 Type\r
+//        1 = Class\r
+//    4..0 Recipient\r
+//        1 = Interface\r
+//\r
 \r
 /**\r
   Get Hid Descriptor.\r
@@ -44,9 +57,9 @@ UsbGetHidDescriptor (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  Request.RequestType = 0x81;\r
-  Request.Request     = 0x06;\r
-  Request.Value       = (UINT16) (0x21 << 8);\r
+  Request.RequestType = USB_HID_GET_DESCRIPTOR_REQ_TYPE;\r
+  Request.Request     = USB_REQ_GET_DESCRIPTOR;\r
+  Request.Value       = (UINT16) (USB_DESC_TYPE_HID << 8);\r
   Request.Index       = InterfaceNum;\r
   Request.Length      = sizeof (EFI_USB_HID_DESCRIPTOR);\r
 \r
@@ -96,9 +109,9 @@ UsbGetReportDescriptor (
   //\r
   // Fill Device request packet\r
   //\r
-  Request.RequestType = 0x81;\r
-  Request.Request     = 0x06;\r
-  Request.Value       = (UINT16) (0x22 << 8);\r
+  Request.RequestType = USB_HID_GET_DESCRIPTOR_REQ_TYPE;\r
+  Request.Request     = USB_REQ_GET_DESCRIPTOR;\r
+  Request.Value       = (UINT16) (USB_DESC_TYPE_REPORT << 8);\r
   Request.Index       = InterfaceNum;\r
   Request.Length      = DescriptorSize;\r
 \r
@@ -145,10 +158,7 @@ UsbGetProtocolRequest (
   //\r
   // Fill Device request packet\r
   //\r
-  Request.RequestType = 0xa1;\r
-  //\r
-  // 10100001b;\r
-  //\r
+  Request.RequestType = USB_HID_CLASS_GET_REQ_TYPE;\r
   Request.Request = EFI_USB_GET_PROTOCOL_REQUEST;\r
   Request.Value   = 0;\r
   Request.Index   = Interface;\r
@@ -199,10 +209,7 @@ UsbSetProtocolRequest (
   //\r
   // Fill Device request packet\r
   //\r
-  Request.RequestType = 0x21;\r
-  //\r
-  // 00100001b;\r
-  //\r
+  Request.RequestType = USB_HID_CLASS_SET_REQ_TYPE;\r
   Request.Request = EFI_USB_SET_PROTOCOL_REQUEST;\r
   Request.Value   = Protocol;\r
   Request.Index   = Interface;\r
@@ -252,10 +259,7 @@ UsbSetIdleRequest (
   //\r
   // Fill Device request packet\r
   //\r
-  Request.RequestType = 0x21;\r
-  //\r
-  // 00100001b;\r
-  //\r
+  Request.RequestType = USB_HID_CLASS_SET_REQ_TYPE;\r
   Request.Request = EFI_USB_SET_IDLE_REQUEST;\r
   Request.Value   = (UINT16) ((Duration << 8) | ReportId);\r
   Request.Index   = Interface;\r
@@ -305,10 +309,7 @@ UsbGetIdleRequest (
   //\r
   // Fill Device request packet\r
   //\r
-  Request.RequestType = 0xa1;\r
-  //\r
-  // 10100001b;\r
-  //\r
+  Request.RequestType = USB_HID_CLASS_GET_REQ_TYPE;\r
   Request.Request = EFI_USB_GET_IDLE_REQUEST;\r
   Request.Value   = ReportId;\r
   Request.Index   = Interface;\r
@@ -364,10 +365,7 @@ UsbSetReportRequest (
   //\r
   // Fill Device request packet\r
   //\r
-  Request.RequestType = 0x21;\r
-  //\r
-  // 00100001b;\r
-  //\r
+  Request.RequestType = USB_HID_CLASS_SET_REQ_TYPE;\r
   Request.Request = EFI_USB_SET_REPORT_REQUEST;\r
   Request.Value   = (UINT16) ((ReportType << 8) | ReportId);\r
   Request.Index   = Interface;\r
@@ -422,10 +420,7 @@ UsbGetReportRequest (
   //\r
   // Fill Device request packet\r
   //\r
-  Request.RequestType = 0xa1;\r
-  //\r
-  // 10100001b;\r
-  //\r
+  Request.RequestType = USB_HID_CLASS_GET_REQ_TYPE;\r
   Request.Request = EFI_USB_GET_REPORT_REQUEST;\r
   Request.Value   = (UINT16) ((ReportType << 8) | ReportId);\r
   Request.Index   = Interface;\r