diff --git a/MdePkg/Include/IndustryStandard/Usb.h b/MdePkg/Include/IndustryStandard/Usb.h index ef4acc8999..0d6da311f6 100644 --- a/MdePkg/Include/IndustryStandard/Usb.h +++ b/MdePkg/Include/IndustryStandard/Usb.h @@ -170,6 +170,7 @@ typedef enum { USB_DESC_TYPE_INTERFACE = 0x04, USB_DESC_TYPE_ENDPOINT = 0x05, USB_DESC_TYPE_HID = 0x21, + USB_DESC_TYPE_REPORT = 0x22, // // Features to be cleared by CLEAR_FEATURE requests @@ -198,6 +199,17 @@ typedef enum { // HID constants definition, see HID rev1.0 // +// +// HID standard GET_DESCRIPTOR request. +// +#define USB_HID_GET_DESCRIPTOR_REQ_TYPE 0x81 + +// +// HID specific requests. +// +#define USB_HID_CLASS_GET_REQ_TYPE 0xa1 +#define USB_HID_CLASS_SET_REQ_TYPE 0x21 + // // HID report item format // diff --git a/MdePkg/Library/UefiUsbLib/Hid.c b/MdePkg/Library/UefiUsbLib/Hid.c index 3a62d523f1..ad2c158401 100644 --- a/MdePkg/Library/UefiUsbLib/Hid.c +++ b/MdePkg/Library/UefiUsbLib/Hid.c @@ -1,6 +1,7 @@ /** @file - The library provides USB descriptor, protocol operations. + The library provides USB HID Class standard and specific requests defined + in USB HID Firmware Specification 7 section : Requests. Copyright (c) 2004, Intel Corporation All rights reserved. This program and the accompanying materials @@ -15,6 +16,18 @@ #include +// +// Hid RequestType Bits specifying characteristics of request. +// Valid values are 10100001b (0xa1) or 00100001b (0x21). +// The following description: +// 7 Data transfer direction +// 0 = Host to device +// 1 = Device to host +// 6..5 Type +// 1 = Class +// 4..0 Recipient +// 1 = Interface +// /** Get Hid Descriptor. @@ -44,9 +57,9 @@ UsbGetHidDescriptor ( return EFI_INVALID_PARAMETER; } - Request.RequestType = 0x81; - Request.Request = 0x06; - Request.Value = (UINT16) (0x21 << 8); + Request.RequestType = USB_HID_GET_DESCRIPTOR_REQ_TYPE; + Request.Request = USB_REQ_GET_DESCRIPTOR; + Request.Value = (UINT16) (USB_DESC_TYPE_HID << 8); Request.Index = InterfaceNum; Request.Length = sizeof (EFI_USB_HID_DESCRIPTOR); @@ -96,9 +109,9 @@ UsbGetReportDescriptor ( // // Fill Device request packet // - Request.RequestType = 0x81; - Request.Request = 0x06; - Request.Value = (UINT16) (0x22 << 8); + Request.RequestType = USB_HID_GET_DESCRIPTOR_REQ_TYPE; + Request.Request = USB_REQ_GET_DESCRIPTOR; + Request.Value = (UINT16) (USB_DESC_TYPE_REPORT << 8); Request.Index = InterfaceNum; Request.Length = DescriptorSize; @@ -145,10 +158,7 @@ UsbGetProtocolRequest ( // // Fill Device request packet // - Request.RequestType = 0xa1; - // - // 10100001b; - // + Request.RequestType = USB_HID_CLASS_GET_REQ_TYPE; Request.Request = EFI_USB_GET_PROTOCOL_REQUEST; Request.Value = 0; Request.Index = Interface; @@ -199,10 +209,7 @@ UsbSetProtocolRequest ( // // Fill Device request packet // - Request.RequestType = 0x21; - // - // 00100001b; - // + Request.RequestType = USB_HID_CLASS_SET_REQ_TYPE; Request.Request = EFI_USB_SET_PROTOCOL_REQUEST; Request.Value = Protocol; Request.Index = Interface; @@ -252,10 +259,7 @@ UsbSetIdleRequest ( // // Fill Device request packet // - Request.RequestType = 0x21; - // - // 00100001b; - // + Request.RequestType = USB_HID_CLASS_SET_REQ_TYPE; Request.Request = EFI_USB_SET_IDLE_REQUEST; Request.Value = (UINT16) ((Duration << 8) | ReportId); Request.Index = Interface; @@ -305,10 +309,7 @@ UsbGetIdleRequest ( // // Fill Device request packet // - Request.RequestType = 0xa1; - // - // 10100001b; - // + Request.RequestType = USB_HID_CLASS_GET_REQ_TYPE; Request.Request = EFI_USB_GET_IDLE_REQUEST; Request.Value = ReportId; Request.Index = Interface; @@ -364,10 +365,7 @@ UsbSetReportRequest ( // // Fill Device request packet // - Request.RequestType = 0x21; - // - // 00100001b; - // + Request.RequestType = USB_HID_CLASS_SET_REQ_TYPE; Request.Request = EFI_USB_SET_REPORT_REQUEST; Request.Value = (UINT16) ((ReportType << 8) | ReportId); Request.Index = Interface; @@ -422,10 +420,7 @@ UsbGetReportRequest ( // // Fill Device request packet // - Request.RequestType = 0xa1; - // - // 10100001b; - // + Request.RequestType = USB_HID_CLASS_GET_REQ_TYPE; Request.Request = EFI_USB_GET_REPORT_REQUEST; Request.Value = (UINT16) ((ReportType << 8) | ReportId); Request.Index = Interface; diff --git a/MdePkg/Library/UefiUsbLib/UsbDxeLib.c b/MdePkg/Library/UefiUsbLib/UsbDxeLib.c index 3e764a34a6..96466c75ef 100644 --- a/MdePkg/Library/UefiUsbLib/UsbDxeLib.c +++ b/MdePkg/Library/UefiUsbLib/UsbDxeLib.c @@ -1,7 +1,7 @@ /** @file - The library provides the USB descritor, interface and protocol - operations. + The library provides the USB Standard Device Requests defined + in Usb specification 9.4 section. Copyright (c) 2004 - 2007, Intel Corporation All rights reserved. This program and the accompanying materials are @@ -12,7 +12,6 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - **/