]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add Usb Hid class request type into IndustryStandard/Usb.h, and replace the hard...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 8 Sep 2008 04:59:00 +0000 (04:59 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 8 Sep 2008 04:59:00 +0000 (04:59 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5834 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/IndustryStandard/Usb.h
MdePkg/Library/UefiUsbLib/Hid.c
MdePkg/Library/UefiUsbLib/UsbDxeLib.c

index ef4acc8999e2fbd43d442578ae41da6b4f4eead4..0d6da311f687b930034c61494dd51ab81e189a1d 100644 (file)
@@ -170,6 +170,7 @@ typedef enum {
   USB_DESC_TYPE_INTERFACE = 0x04,\r
   USB_DESC_TYPE_ENDPOINT  = 0x05,\r
   USB_DESC_TYPE_HID       = 0x21,\r
+  USB_DESC_TYPE_REPORT    = 0x22,\r
 \r
   //\r
   // Features to be cleared by CLEAR_FEATURE requests\r
@@ -198,6 +199,17 @@ typedef enum {
 // HID constants definition, see HID rev1.0\r
 //\r
 \r
+//\r
+// HID standard GET_DESCRIPTOR request.\r
+//\r
+#define USB_HID_GET_DESCRIPTOR_REQ_TYPE  0x81\r
+\r
+//\r
+// HID specific requests.\r
+//\r
+#define USB_HID_CLASS_GET_REQ_TYPE       0xa1\r
+#define USB_HID_CLASS_SET_REQ_TYPE       0x21\r
+\r
 //\r
 // HID report item format\r
 //\r
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
index 3e764a34a68867f5af3032b734ce73fe680dbe50..96466c75effc02d0a31bb2695481853a01582cf7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-  The library provides the USB descritor, interface and protocol\r
-  operations.\r
+  The library provides the USB Standard Device Requests defined \r
+  in Usb specification 9.4 section.\r
   \r
   Copyright (c) 2004 - 2007, Intel Corporation All rights\r
   reserved. This program and the accompanying materials are\r
@@ -12,7 +12,6 @@
   \r
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-  \r
 \r
 **/\r
 \r