]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
MdeModulePkg/Usb/EfiKey: Fix endpoint selection
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / EfiKey.c
index fb2bf3fd814de47f3d2e719ed5326d9152d140d2..ccb389067a615142bb48d655a6304d5d1c8fa3cd 100644 (file)
@@ -2,14 +2,8 @@
   USB Keyboard Driver that manages USB keyboard and produces Simple Text Input\r
   Protocol and Simple Text Input Ex Protocol.\r
 \r
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\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
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -221,7 +215,7 @@ USBKeyboardDriverBindingStart (
   EndpointNumber = UsbKeyboardDevice->InterfaceDescriptor.NumEndpoints;\r
 \r
   //\r
-  // Traverse endpoints to find interrupt endpoint\r
+  // Traverse endpoints to find interrupt endpoint IN\r
   //\r
   Found = FALSE;\r
   for (Index = 0; Index < EndpointNumber; Index++) {\r
@@ -232,7 +226,8 @@ USBKeyboardDriverBindingStart (
              &EndpointDescriptor\r
              );\r
 \r
-    if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) {\r
+    if (((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) &&\r
+        ((EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) != 0)) {\r
       //\r
       // We only care interrupt endpoint here\r
       //\r
@@ -607,6 +602,8 @@ USBKeyboardReadKeyStrokeWorker (
   }\r
 \r
   if (IsQueueEmpty (&UsbKeyboardDevice->EfiKeyQueue)) {\r
+    ZeroMem (&KeyData->Key, sizeof (KeyData->Key));\r
+    InitializeKeyState (UsbKeyboardDevice, &KeyData->KeyState);\r
     return EFI_NOT_READY;\r
   }\r
 \r
@@ -763,9 +760,9 @@ USBKeyboardWaitForKey (
 \r
   //\r
   // Enter critical section\r
-  //  \r
+  //\r
   OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-  \r
+\r
   //\r
   // WaitforKey doesn't suppor the partial key.\r
   // Considering if the partial keystroke is enabled, there maybe a partial\r
@@ -1221,7 +1218,7 @@ KeyNotifyProcessHandler (
   while (TRUE) {\r
     //\r
     // Enter critical section\r
-    //  \r
+    //\r
     OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
     Status = Dequeue (&UsbKeyboardDevice->EfiKeyQueueForNotify, &KeyData, sizeof (KeyData));\r
     //\r