From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: [edk2] [PATCH 2/2] MdeModulePkg/Usb/UsbMouse: Fix endpoint selection To: devel@edk2.groups.io From: "MrChromebox" X-Originating-Location: Round Rock, Texas, US (69.212.114.66) X-Originating-Platform: Linux Chrome 78 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Thu, 12 Dec 2019 11:37:48 -0800 Message-ID: Content-Type: multipart/alternative; boundary="O7SSjGG3ks1tvk84AzY7" --O7SSjGG3ks1tvk84AzY7 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable >>From 2a8e343f8a5848825d3d12ba76df0fb4212ab5b8 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Thu, 12 Dec 2019 12:54:14 -0600 Subject: [PATCH 2/2] MdeModulePkg/Usb/UsbMouse: 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. Signed-off-by: Matt DeVillier --- MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c b/MdeModulePkg/Bu= s/Usb/UsbMouseDxe/UsbMouse.c index f4448bffe6..e9f74cec60 100644 --- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c +++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c @@ -209,7 +209,7 @@ USBMouseDriverBindingStart ( EndpointNumber =3D UsbMouseDevice->InterfaceDescriptor.NumEndpoints; // -=C2=A0 // Traverse endpoints to find interrupt endpoint +=C2=A0 // Traverse endpoints to find interrupt endpoint IN // Found =3D FALSE; for (Index =3D 0; Index < EndpointNumber; Index++) { @@ -219,7 +219,8 @@ USBMouseDriverBindingStart ( &EndpointDescriptor ); -=C2=A0 =C2=A0 if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) =3D=3D = USB_ENDPOINT_INTERRUPT) { +=C2=A0 =C2=A0 if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) =3D=3D = USB_ENDPOINT_INTERRUPT && +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (EndpointDescriptor.EndpointAddress & = USB_ENDPOINT_DIR_IN) ) { // // We only care interrupt endpoint here // -- 2.20.1 --O7SSjGG3ks1tvk84AzY7 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
From 2a8e343f8a5848825d3d12ba76df0fb4212ab5b8 Mon Sep 17 00:00:00 2001=
From: Matt DeVillier <matt.devillier@gmail.com>
Date: Thu, 12 Dec 2019 12:54:14 -0600
Subject: [PATCH 2/2] MdeModulePkg/Usb/UsbMouse: Fix endpoint selectio= n
 
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.
 
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
---
 MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
 
diff --git a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c b/MdeModuleP= kg/Bus/Usb/UsbMouseDxe/UsbMouse.c
index f4448bffe6..e9f74cec60 100644
--- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c
+++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c
@@ -209,7 +209,7 @@ USBMouseDriverBindingStart (
   EndpointNumber =3D UsbMouseDevice->InterfaceDescripto= r.NumEndpoints;
 
   //
-  // Traverse endpoints to find interrupt endpoint
+  // Traverse endpoints to find interrupt endpoint IN
   //
   Found =3D FALSE;
   for (Index =3D 0; Index < EndpointNumber; Index++) {<= /div>
@@ -219,7 +219,8 @@ USBMouseDriverBindingStart (
              &EndpointDescrip= tor
              );
 
-    if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)= ) =3D=3D USB_ENDPOINT_INTERRUPT) {
+    if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)= ) =3D=3D USB_ENDPOINT_INTERRUPT &&
+          (EndpointDescriptor.EndpointAddre= ss & USB_ENDPOINT_DIR_IN) ) {
       //
       // We only care interrupt endpoint here
       //
-- 
2.20.1
 
--O7SSjGG3ks1tvk84AzY7--