[edk2-devel] [edk2] [PATCH 1/2] MdeModulePkg/Usb/EfiKey: Fix endpoint selection

MrChromebox matt.devillier at gmail.com
Thu Dec 12 19:38:54 UTC 2019


>From e7648a8c3efae0540586ad497a5366ffd0c87fb7 Mon Sep 17 00:00:00 2001
From: Matt DeVillier <matt.devillier at gmail.com>
Date: Thu, 12 Dec 2019 12:46:47 -0600
Subject: [PATCH 1/2] MdeModulePkg/Usb/EfiKey: Fix endpoint selection

The endpoint selected by the driver needs to not
only be an interrupt type, but have direction IN
as required to set up an asynchronous interrupt transfer.

Currently, the driver assumes that the first INT endpoint
will be of type IN, but that is not true of all devices,
and will silently fail on devices which have the OUT endpoint
before the IN. Adjust the endpoint selection loop to explictly
check for direction IN.

Test: detachable keyboard on Google Pixel Slate now works.

Signed-off-by: Matt DeVillier <matt.devillier at gmail.com>
---
MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
index 40f8399942..f0544269de 100644
--- a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
+++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
@@ -221,7 +221,7 @@ USBKeyboardDriverBindingStart (
EndpointNumber = UsbKeyboardDevice->InterfaceDescriptor.NumEndpoints;

//
-  // Traverse endpoints to find interrupt endpoint
+  // Traverse endpoints to find interrupt endpoint IN
//
Found = FALSE;
for (Index = 0; Index < EndpointNumber; Index++) {
@@ -232,7 +232,8 @@ USBKeyboardDriverBindingStart (
&EndpointDescriptor
);

-    if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) {
+    if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT &&
+          (EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) ) {
//
// We only care interrupt endpoint here
//
--
2.20.1

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52175): https://edk2.groups.io/g/devel/message/52175
Mute This Topic: https://groups.io/mt/68284872/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20191212/c9cdc357/attachment.htm>


More information about the edk2-devel-archive mailing list