diff options
author | Stefan Brüns <stefan.bruens@rwth-aachen.de> | 2021-02-20 17:26:06 +0100 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2021-02-26 15:30:55 +0100 |
commit | ba0b984bb0246b5ceea29fd0ac9d8b011a30f77b (patch) | |
tree | c1332932196b2b55f1b970688d6bceb5e5d32664 /common/usb_kbd.c | |
parent | bc820d5bcc507366677c592e400e120481748c05 (diff) | |
download | u-boot-ba0b984bb0246b5ceea29fd0ac9d8b011a30f77b.tar.gz u-boot-ba0b984bb0246b5ceea29fd0ac9d8b011a30f77b.tar.bz2 u-boot-ba0b984bb0246b5ceea29fd0ac9d8b011a30f77b.zip |
usb: kbd: Also accept keyboards with Interrupt OUT endpoint
The OUT endpoint can just be ignored as it is not used, just as the
corresponding Set_Report request for IN-only interfaces. E.g. the
Linux gadget hid keyboard also provides an interrupt endpoint.
Also cleanup confusing debug messages like "found set protocol", which
is printed when a keyboard device is found, while the Set_Protocol request
is issued quite some time later.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Diffstat (limited to 'common/usb_kbd.c')
-rw-r--r-- | common/usb_kbd.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 60c6027e04..afad260d3d 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -443,6 +443,7 @@ static int usb_kbd_probe_dev(struct usb_device *dev, unsigned int ifnum) struct usb_interface *iface; struct usb_endpoint_descriptor *ep; struct usb_kbd_pdata *data; + int epNum; if (dev->descriptor.bNumConfigurations != 1) return 0; @@ -458,19 +459,21 @@ static int usb_kbd_probe_dev(struct usb_device *dev, unsigned int ifnum) if (iface->desc.bInterfaceProtocol != USB_PROT_HID_KEYBOARD) return 0; - if (iface->desc.bNumEndpoints != 1) - return 0; + for (epNum = 0; epNum < iface->desc.bNumEndpoints; epNum++) { + ep = &iface->ep_desc[epNum]; - ep = &iface->ep_desc[0]; + /* Check if endpoint is interrupt IN endpoint */ + if ((ep->bmAttributes & 3) != 3) + continue; - /* Check if endpoint 1 is interrupt endpoint */ - if (!(ep->bEndpointAddress & 0x80)) - return 0; + if (ep->bEndpointAddress & 0x80) + break; + } - if ((ep->bmAttributes & 3) != 3) + if (epNum == iface->desc.bNumEndpoints) return 0; - debug("USB KBD: found set protocol...\n"); + debug("USB KBD: found interrupt EP: 0x%x\n", ep->bEndpointAddress); data = malloc(sizeof(struct usb_kbd_pdata)); if (!data) { @@ -498,13 +501,15 @@ static int usb_kbd_probe_dev(struct usb_device *dev, unsigned int ifnum) data->last_report = -1; /* We found a USB Keyboard, install it. */ + debug("USB KBD: set boot protocol\n"); usb_set_protocol(dev, iface->desc.bInterfaceNumber, 0); - debug("USB KBD: found set idle...\n"); #if !defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP) && \ !defined(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE) + debug("USB KBD: set idle interval...\n"); usb_set_idle(dev, iface->desc.bInterfaceNumber, REPEAT_RATE / 4, 0); #else + debug("USB KBD: set idle interval=0...\n"); usb_set_idle(dev, iface->desc.bInterfaceNumber, 0, 0); #endif |