|
50 | 50 | #define ADB_INTERFACE "ADB Interface" |
51 | 51 | #define MAX_PACKET_SIZE_FS 64 |
52 | 52 | #define MAX_PACKET_SIZE_HS 512 |
| 53 | +#define MAX_PACKET_SIZE_SS 1024 |
53 | 54 |
|
54 | 55 | /* ADB Version */ |
55 | 56 | #define ADB_VERSION 0x1000000 |
@@ -193,23 +194,61 @@ struct adb_endpoint_descriptor_no_audio { |
193 | 194 | uint8_t bInterval; |
194 | 195 | } __bfdev_packed; |
195 | 196 |
|
| 197 | +struct adb_ss_ep_comp_descriptor { |
| 198 | + uint8_t bLength; |
| 199 | + uint8_t bDescriptorType; |
| 200 | + uint8_t bMaxBurst; |
| 201 | + uint8_t bmAttributes; |
| 202 | + bfdev_le16 wBytesPerInterval; |
| 203 | +} __bfdev_packed; |
| 204 | + |
| 205 | +struct adb_os_desc_header { |
| 206 | + uint8_t interface; |
| 207 | + bfdev_le32 dwLength; |
| 208 | + bfdev_le16 bcdVersion; |
| 209 | + bfdev_le16 wIndex; |
| 210 | + union { |
| 211 | + struct { |
| 212 | + uint8_t bCount; |
| 213 | + uint8_t Reserved; |
| 214 | + }; |
| 215 | + bfdev_le16 wCount; |
| 216 | + }; |
| 217 | +} __bfdev_packed; |
| 218 | + |
196 | 219 | static const struct { |
197 | 220 | struct adb_functionfs_descs_head header; |
198 | 221 | bfdev_le32 fs_count; |
199 | 222 | bfdev_le32 hs_count; |
| 223 | + bfdev_le32 ss_count; |
| 224 | + bfdev_le32 os_count; |
200 | 225 | struct { |
201 | 226 | struct usb_interface_descriptor intf; |
202 | 227 | struct adb_endpoint_descriptor_no_audio source; |
203 | 228 | struct adb_endpoint_descriptor_no_audio sink; |
204 | 229 | } __bfdev_packed fs_descs, hs_descs; |
| 230 | + struct { |
| 231 | + struct usb_interface_descriptor intf; |
| 232 | + struct adb_endpoint_descriptor_no_audio source; |
| 233 | + struct adb_ss_ep_comp_descriptor source_comp; |
| 234 | + struct adb_endpoint_descriptor_no_audio sink; |
| 235 | + struct adb_ss_ep_comp_descriptor sink_comp; |
| 236 | + } __bfdev_packed ss_descs; |
| 237 | + struct adb_os_desc_header os_header; |
| 238 | + struct usb_ext_compat_desc os_desc; |
205 | 239 | } __bfdev_packed adb_desc = { |
206 | 240 | .header = { |
207 | 241 | .magic = bfdev_cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2), |
208 | 242 | .length = bfdev_cpu_to_le32(sizeof(adb_desc)), |
209 | | - .flags = bfdev_cpu_to_le32(FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC), |
| 243 | + .flags = bfdev_cpu_to_le32( |
| 244 | + FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC | |
| 245 | + FUNCTIONFS_HAS_SS_DESC | FUNCTIONFS_HAS_MS_OS_DESC |
| 246 | + ), |
210 | 247 | }, |
211 | 248 | .fs_count = bfdev_cpu_to_le32(3), |
212 | 249 | .hs_count = bfdev_cpu_to_le32(3), |
| 250 | + .ss_count = bfdev_cpu_to_le32(5), |
| 251 | + .os_count = bfdev_cpu_to_le32(1), |
213 | 252 | .fs_descs = { |
214 | 253 | .intf = { |
215 | 254 | .bLength = sizeof(adb_desc.fs_descs.intf), |
@@ -268,6 +307,58 @@ static const struct { |
268 | 307 | .bInterval = 0, |
269 | 308 | }, |
270 | 309 | }, |
| 310 | + .ss_descs = { |
| 311 | + .intf = { |
| 312 | + .bLength = sizeof(adb_desc.ss_descs.intf), |
| 313 | + .bDescriptorType = USB_DT_INTERFACE, |
| 314 | + .bInterfaceNumber = 0, |
| 315 | + .bNumEndpoints = 2, |
| 316 | + .bInterfaceClass = USB_CLASS_VENDOR_SPEC, |
| 317 | + .bInterfaceSubClass = ADB_SUBCLASS, |
| 318 | + .bInterfaceProtocol = ADB_PROTOCOL, |
| 319 | + .iInterface = 1, |
| 320 | + }, |
| 321 | + .source = { |
| 322 | + .bLength = sizeof(adb_desc.ss_descs.source), |
| 323 | + .bDescriptorType = USB_DT_ENDPOINT, |
| 324 | + .bEndpointAddress = 1 | USB_DIR_OUT, |
| 325 | + .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 326 | + .wMaxPacketSize = bfdev_cpu_to_le16(MAX_PACKET_SIZE_SS), |
| 327 | + }, |
| 328 | + .source_comp = { |
| 329 | + .bLength = sizeof(adb_desc.ss_descs.source_comp), |
| 330 | + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, |
| 331 | + .bMaxBurst = 4, |
| 332 | + }, |
| 333 | + .sink = { |
| 334 | + .bLength = sizeof(adb_desc.ss_descs.sink), |
| 335 | + .bDescriptorType = USB_DT_ENDPOINT, |
| 336 | + .bEndpointAddress = 2 | USB_DIR_IN, |
| 337 | + .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 338 | + .wMaxPacketSize = bfdev_cpu_to_le16(MAX_PACKET_SIZE_SS), |
| 339 | + }, |
| 340 | + .sink_comp = { |
| 341 | + .bLength = sizeof(adb_desc.ss_descs.sink_comp), |
| 342 | + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, |
| 343 | + .bMaxBurst = 4, |
| 344 | + }, |
| 345 | + }, |
| 346 | + .os_header = { |
| 347 | + .interface = 1, |
| 348 | + .dwLength = bfdev_cpu_to_le32(sizeof(adb_desc.os_header) + |
| 349 | + sizeof(adb_desc.os_desc)), |
| 350 | + .bcdVersion = bfdev_cpu_to_le16(1), |
| 351 | + .wIndex = bfdev_cpu_to_le16(4), |
| 352 | + .bCount = 1, |
| 353 | + .Reserved = 0, |
| 354 | + }, |
| 355 | + .os_desc = { |
| 356 | + .bFirstInterfaceNumber = 0, |
| 357 | + .Reserved1 = 1, |
| 358 | + .CompatibleID = {0}, |
| 359 | + .SubCompatibleID = {0}, |
| 360 | + .Reserved2 = {0}, |
| 361 | + }, |
271 | 362 | }; |
272 | 363 |
|
273 | 364 | static const struct { |
@@ -2408,15 +2499,15 @@ sdbd(void) |
2408 | 2499 | goto error; |
2409 | 2500 | } |
2410 | 2501 |
|
| 2502 | + sctx.version = ADB_VERSION; |
| 2503 | + sctx.max_payload = MAX_PAYLOAD; |
| 2504 | + |
2411 | 2505 | retval = usb_init(&sctx); |
2412 | 2506 | if (retval < 0) { |
2413 | 2507 | bfdev_log_err("usb initialization failed\n"); |
2414 | 2508 | goto error; |
2415 | 2509 | } |
2416 | 2510 |
|
2417 | | - sctx.version = ADB_VERSION; |
2418 | | - sctx.max_payload = MAX_PAYLOAD; |
2419 | | - |
2420 | 2511 | for (;;) { |
2421 | 2512 | retval = bfenv_eproc_run(sctx.eproc, BFENV_TIMEOUT_MAX); |
2422 | 2513 | if (!retval) |
|
0 commit comments