xref: /OK3568_Linux_fs/buildroot/package/android-tools/0013-adbd-Support-usb3.0.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 5701bed80c75ee2aabdbc896bd6e73157517e006 Mon Sep 17 00:00:00 2001
2From: Lin Huang <hl@rock-chips.com>
3Date: Fri, 26 Apr 2019 17:33:18 +0800
4Subject: [PATCH 13/20] adbd: Support usb3.0
5
6Signed-off-by: Lin Huang <hl@rock-chips.com>
7Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
8---
9 core/adbd/functionfs.h       | 12 +++++--
10 core/adbd/usb_linux_client.c | 63 ++++++++++++++++++++++++++++++++----
11 2 files changed, 66 insertions(+), 9 deletions(-)
12
13diff --git a/core/adbd/functionfs.h b/core/adbd/functionfs.h
14index 53a3f30..42993f2 100644
15--- a/core/adbd/functionfs.h
16+++ b/core/adbd/functionfs.h
17@@ -10,10 +10,18 @@
18
19 enum {
20 	FUNCTIONFS_DESCRIPTORS_MAGIC = 1,
21-	FUNCTIONFS_STRINGS_MAGIC     = 2
22+	FUNCTIONFS_STRINGS_MAGIC     = 2,
23+	FUNCTIONFS_DESCRIPTORS_MAGIC_V2 = 3,
24 };
25
26-
27+enum functionfs_flags {
28+	FUNCTIONFS_HAS_FS_DESC = 1,
29+	FUNCTIONFS_HAS_HS_DESC = 2,
30+	FUNCTIONFS_HAS_SS_DESC = 4,
31+	FUNCTIONFS_HAS_MS_OS_DESC = 8,
32+	FUNCTIONFS_VIRTUAL_ADDR = 16,
33+	FUNCTIONFS_EVENTFD = 32,
34+};
35
36 /* Descriptor of an non-audio endpoint */
37 struct usb_endpoint_descriptor_no_audio {
38diff --git a/core/adbd/usb_linux_client.c b/core/adbd/usb_linux_client.c
39index 0e4d200..a437ad1 100644
40--- a/core/adbd/usb_linux_client.c
41+++ b/core/adbd/usb_linux_client.c
42@@ -33,6 +33,7 @@
43
44 #define MAX_PACKET_SIZE_FS	64
45 #define MAX_PACKET_SIZE_HS	512
46+#define MAX_PACKET_SIZE_SS	1024
47
48 #if __BYTE_ORDER == __LITTLE_ENDIAN
49 # define cpu_to_le16(x) (x)
50@@ -63,19 +64,33 @@ struct usb_handle
51 };
52
53 static const struct {
54-    struct usb_functionfs_descs_head header;
55+    __le32 magic;
56+    __le32 length;
57+    __le32 flags;
58+    __le32 fs_count;
59+    __le32 hs_count;
60+    __le32 ss_count;
61     struct {
62         struct usb_interface_descriptor intf;
63         struct usb_endpoint_descriptor_no_audio source;
64         struct usb_endpoint_descriptor_no_audio sink;
65     } __attribute__((packed)) fs_descs, hs_descs;
66+    struct {
67+        struct usb_interface_descriptor intf;
68+	struct usb_endpoint_descriptor_no_audio source;
69+	struct usb_ss_ep_comp_descriptor source_comp;
70+	struct usb_endpoint_descriptor_no_audio sink;
71+	struct usb_ss_ep_comp_descriptor sink_comp;
72+    } __attribute__((packed)) ss_descs;
73 } __attribute__((packed)) descriptors = {
74-    .header = {
75-        .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC),
76-        .length = cpu_to_le32(sizeof(descriptors)),
77-        .fs_count = 3,
78-        .hs_count = 3,
79-    },
80+    .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2),
81+    .length = cpu_to_le32(sizeof(descriptors)),
82+    .flags = cpu_to_le32(FUNCTIONFS_HAS_FS_DESC |
83+                         FUNCTIONFS_HAS_HS_DESC |
84+                         FUNCTIONFS_HAS_SS_DESC),
85+    .fs_count = 3,
86+    .hs_count = 3,
87+    .ss_count = 5,
88     .fs_descs = {
89         .intf = {
90             .bLength = sizeof(descriptors.fs_descs.intf),
91@@ -128,6 +143,40 @@ static const struct {
92             .wMaxPacketSize = MAX_PACKET_SIZE_HS,
93         },
94     },
95+    .ss_descs = {
96+        .intf = {
97+            .bLength = sizeof(descriptors.ss_descs.intf),
98+            .bDescriptorType = USB_DT_INTERFACE,
99+            .bInterfaceNumber = 0,
100+            .bNumEndpoints = 2,
101+            .bInterfaceClass = ADB_CLASS,
102+            .bInterfaceSubClass = ADB_SUBCLASS,
103+            .bInterfaceProtocol = ADB_PROTOCOL,
104+            .iInterface = 1, /* first string from the provided table */
105+        },
106+        .source = {
107+            .bLength = sizeof(descriptors.ss_descs.source),
108+            .bDescriptorType = USB_DT_ENDPOINT,
109+            .bEndpointAddress = 1 | USB_DIR_OUT,
110+            .bmAttributes = USB_ENDPOINT_XFER_BULK,
111+            .wMaxPacketSize = MAX_PACKET_SIZE_SS,
112+        },
113+        .source_comp = {
114+            .bLength = sizeof(descriptors.ss_descs.source_comp),
115+            .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
116+        },
117+        .sink = {
118+            .bLength = sizeof(descriptors.ss_descs.sink),
119+            .bDescriptorType = USB_DT_ENDPOINT,
120+            .bEndpointAddress = 2 | USB_DIR_IN,
121+            .bmAttributes = USB_ENDPOINT_XFER_BULK,
122+            .wMaxPacketSize = MAX_PACKET_SIZE_SS,
123+        },
124+        .sink_comp = {
125+            .bLength = sizeof(descriptors.ss_descs.sink_comp),
126+            .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
127+        },
128+    },
129 };
130
131 #define STR_INTERFACE_ "ADB Interface"
132--
1332.20.1
134
135