Skip to content

Instantly share code, notes, and snippets.

@jannau
Created August 25, 2022 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jannau/979955a15501b521ac7615879dafe206 to your computer and use it in GitHub Desktop.
Save jannau/979955a15501b521ac7615879dafe206 to your computer and use it in GitHub Desktop.
0001-usb-request-on-8-bytes-for-USB_SPEED_FULL-bMaxPacket.patch
From df9e5b78687fc4eed4988f99d3f195cba8b227e1 Mon Sep 17 00:00:00 2001
From: Janne Grunau <j@jannau.net>
Date: Fri, 26 Aug 2022 00:01:15 +0200
Subject: [PATCH 1/1] usb: request on 8 bytes for USB_SPEED_FULL
bMaxPacketSize0 probing
Fixes probing of Logitech Unifying receivers (bcdDevice 12.03 or 12.10)
with bMaxPacketSize0 == 8 on Apple silicon SoCs using DWC3 controllers.
Signed-off-by: Janne Grunau <j@jannau.net>
---
common/usb.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/common/usb.c b/common/usb.c
index aad13fd9c557..2d6d782f9103 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -999,8 +999,17 @@ static int usb_setup_descriptor(struct usb_device *dev, bool do_read)
* the number of packets in addition to the number of bytes.
* A request for 64 bytes of data with the maxpacket guessed
* as 64 (above) yields a request for 1 packet.
+ *
+ * The DWC3 controller integrated into Apple silicon SoCs like
+ * the M1 and M2 does not like to read 64 bytes for devices with
+ * bMaxPacketSize0 == 8. request only 8 bytes which should also
+ * result in a single packet.
+ * Fixes probing errors with Logitech Unifying receivers with
+ * bcdDevice 12.03 or 12.10.
+ * A delay of 1 ms after this get_descriptor_len() call fixes
+ * the issue as well.
*/
- err = get_descriptor_len(dev, 64, 8);
+ err = get_descriptor_len(dev, 8, 8);
if (err)
return err;
}
--
2.35.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment