diff options
author | Qi Zhou <atmgnd@outlook.com> | 2022-11-14 20:55:44 +0800 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2022-11-23 11:31:15 -0500 |
commit | 645a64b4911d7cadf5749d7375544fc2384e70ba (patch) | |
tree | e8d01f3c4ced5fc4858eb1d8e473ef5b11c73eae /src/hw/usb-hid.c | |
parent | 3208b098f51a9ef96d0dfa71d5ec3a3eaec88f0a (diff) | |
download | seabios-645a64b4911d7cadf5749d7375544fc2384e70ba.tar.gz |
usb: fix wrong init of keyboard/mouse's if first interface is not boot protocol
There is always some endpoint descriptors after each interface descriptor, We
should only decrement num_iface if interface type is USB_DT_INTERFACE, see
https://www.beyondlogic.org/usbnutshell/usb5.shtml#ConfigurationDescriptors
Signed-off-by: Qi Zhou <atmgnd@outlook.com>
Diffstat (limited to 'src/hw/usb-hid.c')
-rw-r--r-- | src/hw/usb-hid.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/hw/usb-hid.c b/src/hw/usb-hid.c index 92c6b197..dec198ac 100644 --- a/src/hw/usb-hid.c +++ b/src/hw/usb-hid.c @@ -22,13 +22,13 @@ struct usb_pipe *mouse_pipe VARFSEG; // Send USB HID protocol message. static int -set_protocol(struct usb_pipe *pipe, u16 val) +set_protocol(struct usb_pipe *pipe, u16 val, u16 inferface) { struct usb_ctrlrequest req; req.bRequestType = USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE; req.bRequest = HID_REQ_SET_PROTOCOL; req.wValue = val; - req.wIndex = 0; + req.wIndex = inferface; req.wLength = 0; return usb_send_default_control(pipe, &req, NULL); } @@ -76,9 +76,12 @@ usb_kbd_setup(struct usbdevice_s *usbdev } // Enable "boot" protocol. - int ret = set_protocol(usbdev->defpipe, 0); - if (ret) + int ret = set_protocol(usbdev->defpipe, 0, usbdev->iface->bInterfaceNumber); + if (ret) { + dprintf(3, "Failed to set boot protocol\n"); return -1; + } + // Periodically send reports to enable key repeat. ret = set_idle(usbdev->defpipe, KEYREPEATMS); if (ret) @@ -118,7 +121,7 @@ usb_mouse_setup(struct usbdevice_s *usbdev } // Enable "boot" protocol. - int ret = set_protocol(usbdev->defpipe, 0); + int ret = set_protocol(usbdev->defpipe, 0, usbdev->iface->bInterfaceNumber); if (ret) return -1; |