diff options
author | William Wu <william.wu@rock-chips.com> | 2018-07-02 17:34:17 +0800 |
---|---|---|
committer | Tao Huang <huangtao@rock-chips.com> | 2018-07-03 19:22:36 +0800 |
commit | 2434000a47ae7d984ad3a8219284754ad2729d1a (patch) | |
tree | 52c733826a3de472058538b55cc6b94e620a086a /tools/usb | |
parent | be328c224dea1375078091cfdb375d219f32a3b1 (diff) |
tools: ffs-aio-example: add superspeed descriptors
This patch adds superspeed descriptors in device
applications to support USB 3.0 ffs gadget.
Change-Id: I5a364c935b1d30e2e929791ff16a34cf0d1c87e1
Signed-off-by: William Wu <william.wu@rock-chips.com>
Diffstat (limited to 'tools/usb')
-rw-r--r-- | tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c | 68 | ||||
-rw-r--r-- | tools/usb/ffs-aio-example/simple/device_app/aio_simple.c | 68 |
2 files changed, 134 insertions, 2 deletions
diff --git a/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c b/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c index aaca1f44e788..8643beaf25a1 100644 --- a/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c +++ b/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c @@ -57,16 +57,30 @@ static const struct { struct usb_functionfs_descs_head_v2 header; __le32 fs_count; __le32 hs_count; + __le32 ss_count; + __le32 os_count; struct { struct usb_interface_descriptor intf; struct usb_endpoint_descriptor_no_audio bulk_sink; struct usb_endpoint_descriptor_no_audio bulk_source; } __attribute__ ((__packed__)) fs_descs, hs_descs; + struct { + struct usb_interface_descriptor intf; + struct usb_endpoint_descriptor_no_audio sink; + struct usb_ss_ep_comp_descriptor sink_comp; + struct usb_endpoint_descriptor_no_audio source; + struct usb_ss_ep_comp_descriptor source_comp; + } __attribute__ ((__packed__)) ss_descs; + struct usb_os_desc_header os_header; + struct usb_ext_compat_desc os_desc; + } __attribute__ ((__packed__)) descriptors = { .header = { .magic = htole32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2), .flags = htole32(FUNCTIONFS_HAS_FS_DESC | - FUNCTIONFS_HAS_HS_DESC), + FUNCTIONFS_HAS_HS_DESC | + FUNCTIONFS_HAS_SS_DESC | + FUNCTIONFS_HAS_MS_OS_DESC), .length = htole32(sizeof(descriptors)), }, .fs_count = htole32(3), @@ -115,6 +129,58 @@ static const struct { .wMaxPacketSize = htole16(512), }, }, + .ss_count = htole32(5), + .ss_descs = { + .intf = { + .bLength = sizeof(descriptors.ss_descs.intf), + .bDescriptorType = USB_DT_INTERFACE, + .bInterfaceNumber = 0, + .bNumEndpoints = 2, + .bInterfaceClass = USB_CLASS_VENDOR_SPEC, + .iInterface = 1, + }, + .sink = { + .bLength = sizeof(descriptors.ss_descs.sink), + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 1 | USB_DIR_IN, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = htole16(1024), + }, + .sink_comp = { + .bLength = sizeof(descriptors.ss_descs.sink_comp), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + .bMaxBurst = 4, + }, + .source = { + .bLength = sizeof(descriptors.ss_descs.source), + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 2 | USB_DIR_OUT, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = htole16(1024), + }, + .source_comp = { + .bLength = sizeof(descriptors.ss_descs.source_comp), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + .bMaxBurst = 4, + }, + }, + .os_count = htole32(1), + .os_header = { + .interface = htole32(1), + .dwLength = htole32(sizeof(descriptors.os_header) + + sizeof(descriptors.os_desc)), + .bcdVersion = htole32(1), + .wIndex = htole32(4), + .bCount = htole32(1), + .Reserved = htole32(0), + }, + .os_desc = { + .bFirstInterfaceNumber = 0, + .Reserved1 = htole32(1), + .CompatibleID = {0}, + .SubCompatibleID = {0}, + .Reserved2 = {0}, + }, }; #define STR_INTERFACE "AIO Test" diff --git a/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c b/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c index 1f44a29818bf..51574379ff91 100644 --- a/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c +++ b/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c @@ -55,16 +55,30 @@ static const struct { struct usb_functionfs_descs_head_v2 header; __le32 fs_count; __le32 hs_count; + __le32 ss_count; + __le32 os_count; struct { struct usb_interface_descriptor intf; struct usb_endpoint_descriptor_no_audio bulk_sink; struct usb_endpoint_descriptor_no_audio bulk_source; } __attribute__ ((__packed__)) fs_descs, hs_descs; + struct { + struct usb_interface_descriptor intf; + struct usb_endpoint_descriptor_no_audio sink; + struct usb_ss_ep_comp_descriptor sink_comp; + struct usb_endpoint_descriptor_no_audio source; + struct usb_ss_ep_comp_descriptor source_comp; + } __attribute__ ((__packed__)) ss_descs; + struct usb_os_desc_header os_header; + struct usb_ext_compat_desc os_desc; + } __attribute__ ((__packed__)) descriptors = { .header = { .magic = htole32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2), .flags = htole32(FUNCTIONFS_HAS_FS_DESC | - FUNCTIONFS_HAS_HS_DESC), + FUNCTIONFS_HAS_HS_DESC | + FUNCTIONFS_HAS_SS_DESC | + FUNCTIONFS_HAS_MS_OS_DESC), .length = htole32(sizeof(descriptors)), }, .fs_count = htole32(3), @@ -113,6 +127,58 @@ static const struct { .wMaxPacketSize = htole16(512), }, }, + .ss_count = htole32(5), + .ss_descs = { + .intf = { + .bLength = sizeof(descriptors.ss_descs.intf), + .bDescriptorType = USB_DT_INTERFACE, + .bInterfaceNumber = 0, + .bNumEndpoints = 2, + .bInterfaceClass = USB_CLASS_VENDOR_SPEC, + .iInterface = 1, + }, + .sink = { + .bLength = sizeof(descriptors.ss_descs.sink), + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 1 | USB_DIR_IN, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = htole16(1024), + }, + .sink_comp = { + .bLength = sizeof(descriptors.ss_descs.sink_comp), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + .bMaxBurst = 4, + }, + .source = { + .bLength = sizeof(descriptors.ss_descs.source), + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 2 | USB_DIR_OUT, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = htole16(1024), + }, + .source_comp = { + .bLength = sizeof(descriptors.ss_descs.source_comp), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + .bMaxBurst = 4, + }, + }, + .os_count = htole32(1), + .os_header = { + .interface = htole32(1), + .dwLength = htole32(sizeof(descriptors.os_header) + + sizeof(descriptors.os_desc)), + .bcdVersion = htole32(1), + .wIndex = htole32(4), + .bCount = htole32(1), + .Reserved = htole32(0), + }, + .os_desc = { + .bFirstInterfaceNumber = 0, + .Reserved1 = htole32(1), + .CompatibleID = {0}, + .SubCompatibleID = {0}, + .Reserved2 = {0}, + }, }; #define STR_INTERFACE "AIO Test" |