public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2] [PATCH 1/2] MdeModulePkg/Usb/EfiKey: Fix endpoint selection
@ 2019-12-12 19:38 MrChromebox
  2019-12-30  6:04 ` [edk2-devel] " newexplorerj
  2020-01-03  2:52 ` Wu, Hao A
  0 siblings, 2 replies; 3+ messages in thread
From: MrChromebox @ 2019-12-12 19:38 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 1826 bytes --]

>From e7648a8c3efae0540586ad497a5366ffd0c87fb7 Mon Sep 17 00:00:00 2001
From: Matt DeVillier <matt.devillier@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@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

[-- Attachment #2: Type: text/html, Size: 2751 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [edk2] [PATCH 1/2] MdeModulePkg/Usb/EfiKey: Fix endpoint selection
  2019-12-12 19:38 [edk2] [PATCH 1/2] MdeModulePkg/Usb/EfiKey: Fix endpoint selection MrChromebox
@ 2019-12-30  6:04 ` newexplorerj
  2020-01-03  2:52 ` Wu, Hao A
  1 sibling, 0 replies; 3+ messages in thread
From: newexplorerj @ 2019-12-30  6:04 UTC (permalink / raw)
  To: MrChromebox, devel

[-- Attachment #1: Type: text/plain, Size: 172 bytes --]

On Fri, Dec 13, 2019 at 03:38 AM, MrChromebox wrote:

> 
> (EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN)

Reviewed-by: GuoMinJ <newexplorerj@gmail.com>

[-- Attachment #2: Type: text/html, Size: 207 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [edk2] [PATCH 1/2] MdeModulePkg/Usb/EfiKey: Fix endpoint selection
  2019-12-12 19:38 [edk2] [PATCH 1/2] MdeModulePkg/Usb/EfiKey: Fix endpoint selection MrChromebox
  2019-12-30  6:04 ` [edk2-devel] " newexplorerj
@ 2020-01-03  2:52 ` Wu, Hao A
  1 sibling, 0 replies; 3+ messages in thread
From: Wu, Hao A @ 2020-01-03  2:52 UTC (permalink / raw)
  To: devel@edk2.groups.io, matt.devillier@gmail.com; +Cc: newexplorerj@gmail.com

[-- Attachment #1: Type: text/plain, Size: 2709 bytes --]

Sorry for the delayed response.
Just a minor coding style comment, could you help to change the modified 'if'
statement to:

if (((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) &&
    ((EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) != 0)) {

so that the 2nd condition can be aligned with others.

With the above change
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Also, could you help to send a new version of the series via the 'git send-email'
command. It would be helpful for me to push the changes.

Best Regards,
Hao Wu

From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of MrChromebox
Sent: Friday, December 13, 2019 3:39 AM
To: devel@edk2.groups.io
Subject: [edk2-devel] [edk2] [PATCH 1/2] MdeModulePkg/Usb/EfiKey: Fix endpoint selection

From e7648a8c3efae0540586ad497a5366ffd0c87fb7 Mon Sep 17 00:00:00 2001
From: Matt DeVillier <matt.devillier@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@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



[-- Attachment #2: Type: text/html, Size: 32079 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-03  2:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-12 19:38 [edk2] [PATCH 1/2] MdeModulePkg/Usb/EfiKey: Fix endpoint selection MrChromebox
2019-12-30  6:04 ` [edk2-devel] " newexplorerj
2020-01-03  2:52 ` Wu, Hao A

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox