| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 58b01e01875e2f6ae593ded197430bc23713dd0a Mon Sep 17 00:00:00 2001 |
| 2 | From: Ingo Rohloff <lundril@gmx.de> |
| 3 | Date: Fri, 16 May 2014 21:51:41 +0200 |
| 4 | Subject: [PATCH] ADB on linux: Handle USB SuperSpeed extra Descriptors |
| 5 | |
| 6 | Under Linux, ADB manually parses USB Descriptors to check for |
| 7 | possible ADB USB Interfaces. USB Devices connected with SuperSpeed |
| 8 | will exhibit extra USB SuperSpeed Endpoint Companion Descriptors. |
| 9 | This patch handles these USB SuperSpeed specific USB Descriptors. |
| 10 | |
| 11 | Change-Id: Icd1e5fdde0b324c7df4f933583499f2c52a922f3 |
| 12 | Signed-off-by: Ingo Rohloff <lundril@gmx.de> |
| 13 | --- |
| 14 | adb/usb_linux.c | 12 ++++++++++++ |
| 15 | 1 file changed, 12 insertions(+) |
| 16 | |
| 17 | --- a/adb/usb_linux.c |
| 18 | +++ b/adb/usb_linux.c |
| 19 | @@ -238,8 +238,20 @@ static void find_usb_device(const char * |
| 20 | // looks like ADB... |
| 21 | ep1 = (struct usb_endpoint_descriptor *)bufptr; |
| 22 | bufptr += USB_DT_ENDPOINT_SIZE; |
| 23 | + // For USB 3.0 SuperSpeed devices, skip potential |
| 24 | + // USB 3.0 SuperSpeed Endpoint Companion descriptor |
| 25 | + if (bufptr+2 <= devdesc + desclength && |
| 26 | + bufptr[0] == USB_DT_SS_EP_COMP_SIZE && |
| 27 | + bufptr[1] == USB_DT_SS_ENDPOINT_COMP) { |
| 28 | + bufptr += USB_DT_SS_EP_COMP_SIZE; |
| 29 | + } |
| 30 | ep2 = (struct usb_endpoint_descriptor *)bufptr; |
| 31 | bufptr += USB_DT_ENDPOINT_SIZE; |
| 32 | + if (bufptr+2 <= devdesc + desclength && |
| 33 | + bufptr[0] == USB_DT_SS_EP_COMP_SIZE && |
| 34 | + bufptr[1] == USB_DT_SS_ENDPOINT_COMP) { |
| 35 | + bufptr += USB_DT_SS_EP_COMP_SIZE; |
| 36 | + } |
| 37 | |
| 38 | if (bufptr > devdesc + desclength || |
| 39 | ep1->bLength != USB_DT_ENDPOINT_SIZE || |