MdeModulePkg/Usb/Keyboard.c: Don't request protocol before setting

No need to check the interface protocol then conditionally setting,
just set it to BOOT_PROTOCOL and check for error.

This is what Linux does for HID devices as some don't follow the USB spec.
One example is the Aspeed BMC HID keyboard device, which adds a massive
boot delay without this patch as it doesn't respond to
'GetProtocolRequest'.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Sean Rhodes 2022-02-24 19:38:18 +08:00 committed by mergify[bot]
parent b422b0fcf9
commit 589d51df26

View File

@ -805,7 +805,6 @@ InitUSBKeyboard (
) )
{ {
UINT16 ConfigValue; UINT16 ConfigValue;
UINT8 Protocol;
EFI_STATUS Status; EFI_STATUS Status;
UINT32 TransferResult; UINT32 TransferResult;
@ -854,22 +853,15 @@ InitUSBKeyboard (
} }
} }
UsbGetProtocolRequest (
UsbKeyboardDevice->UsbIo,
UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,
&Protocol
);
// //
// Set boot protocol for the USB Keyboard. // Set boot protocol for the USB Keyboard.
// This driver only supports boot protocol. // This driver only supports boot protocol.
// //
if (Protocol != BOOT_PROTOCOL) { UsbSetProtocolRequest (
UsbSetProtocolRequest ( UsbKeyboardDevice->UsbIo,
UsbKeyboardDevice->UsbIo, UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,
UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber, BOOT_PROTOCOL
BOOT_PROTOCOL );
);
}
UsbKeyboardDevice->CtrlOn = FALSE; UsbKeyboardDevice->CtrlOn = FALSE;
UsbKeyboardDevice->AltOn = FALSE; UsbKeyboardDevice->AltOn = FALSE;