]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c
1. Correct File header to ## @file
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / KeyBoard.c
index 7a8ee00d3c69bb083ff149e1d3c9ef3952ca2e65..c7b48b2a87ce4ef8a104c32046e4920079ab09cc 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Helper functions for USB Keyboard Driver.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation\r
+Copyright (c) 2004 - 2010, Intel Corporation\r
 All rights reserved. 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
@@ -318,7 +318,6 @@ InstallDefaultKeyboardLayout (
   EFI_STATUS                   Status;\r
   EFI_HII_DATABASE_PROTOCOL    *HiiDatabase;\r
   EFI_HII_HANDLE               HiiHandle;\r
-  EFI_HII_PACKAGE_LIST_HEADER  *PackageList;\r
 \r
   //\r
   // Locate Hii database protocol\r
@@ -335,13 +334,14 @@ InstallDefaultKeyboardLayout (
   //\r
   // Install Keyboard Layout package to HII database\r
   //\r
-  PackageList = HiiLibPreparePackageList (1, &mUsbKeyboardLayoutPackageGuid, &mUsbKeyboardLayoutBin);\r
-  ASSERT (PackageList != NULL);\r
-\r
-  Status = HiiDatabase->NewPackageList (HiiDatabase, PackageList, UsbKeyboardDevice->ControllerHandle, &HiiHandle);\r
-  FreePool (PackageList);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  HiiHandle = HiiAddPackages (\r
+                &mUsbKeyboardLayoutPackageGuid,\r
+                UsbKeyboardDevice->ControllerHandle,\r
+                &mUsbKeyboardLayoutBin,\r
+                NULL\r
+                );\r
+  if (HiiHandle == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   //\r
@@ -598,6 +598,9 @@ SetKeyboardLayoutEvent (
   UINT8                     KeyCode;\r
 \r
   UsbKeyboardDevice = (USB_KB_DEV *) Context;\r
+  if (UsbKeyboardDevice->Signature != USB_KB_DEV_SIGNATURE) {\r
+    return;\r
+  }\r
 \r
   //\r
   // Try to get current keyboard layout from HII database\r
@@ -799,7 +802,7 @@ InitUSBKeyboard (
   IN OUT USB_KB_DEV   *UsbKeyboardDevice\r
   )\r
 {\r
-  UINT              ConfigValue;\r
+  UINT16              ConfigValue;\r
   UINT8               Protocol;\r
   UINT8               ReportId;\r
   UINT8               Duration;\r
@@ -808,19 +811,31 @@ InitUSBKeyboard (
 \r
   REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
     EFI_PROGRESS_CODE,\r
-    PcdGet32 (PcdStatusCodeValueKeyboardSelfTest),\r
+    (EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_SELF_TEST),\r
     UsbKeyboardDevice->DevicePath\r
     );\r
 \r
   InitUSBKeyBuffer (&(UsbKeyboardDevice->KeyboardBuffer));\r
 \r
   //\r
-  // Uses default configuration to configure the USB keyboard device.\r
+  // Use the config out of the descriptor\r
+  // Assumed the first config is the correct one and this is not always the case\r
+  //\r
+  Status = UsbGetConfiguration (\r
+             UsbKeyboardDevice->UsbIo, \r
+             &ConfigValue, \r
+             &TransferResult\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    ConfigValue = 0x01;\r
+  }\r
+  \r
+  //\r
+  // Uses default configuration to configure the USB Keyboard device.\r
   //\r
-  ConfigValue = 0x01;\r
   Status = UsbSetConfiguration (\r
              UsbKeyboardDevice->UsbIo,\r
-             (UINT16) ConfigValue,\r
+             ConfigValue,\r
              &TransferResult\r
              );\r
   if (EFI_ERROR (Status)) {\r
@@ -831,7 +846,7 @@ InitUSBKeyboard (
     //\r
     REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
       EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      PcdGet32 (PcdStatusCodeValueKeyboardInterfaceError),\r
+      (EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_INTERFACE_ERROR),\r
       UsbKeyboardDevice->DevicePath\r
       );\r
 \r
@@ -911,7 +926,7 @@ InitUSBKeyboard (
 \r
   gBS->CreateEvent (\r
          EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
-         TPL_NOTIFY,\r
+         TPL_CALLBACK,\r
          USBKeyboardRepeatHandler,\r
          UsbKeyboardDevice,\r
          &UsbKeyboardDevice->RepeatTimer\r
@@ -997,7 +1012,7 @@ KeyboardHandler (
     //\r
     REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
       EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      PcdGet32 (PcdStatusCodeValueKeyboardInputError),\r
+      (EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_INPUT_ERROR),\r
       UsbKeyboardDevice->DevicePath\r
       );\r
 \r