usb: change functionfs descriptor to v2 38/297838/2 accepted/tizen/unified/20231110.172139
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 8 Nov 2023 05:44:34 +0000 (14:44 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 8 Nov 2023 06:00:45 +0000 (15:00 +0900)
The functionfs v1 descriptor was deprecated, so change to v2
descriptor which has ss descriptor.

Change-Id: If79aeef0da7b4d09006ad768fc9e6f5bf0594101
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
src/usb.c

index 6eae41a..7db2065 100644 (file)
--- a/src/usb.c
+++ b/src/usb.c
@@ -81,7 +81,10 @@ struct usbg_config_strs c_strs = {
 /******************** Descriptors and Strings *******************************/
 
 static const struct {
-       struct usb_functionfs_descs_head header;
+       struct usb_functionfs_descs_head_v2 header;
+       __le32 fs_count;
+       __le32 hs_count;
+       __le32 ss_count;
        struct {
                struct usb_interface_descriptor acm;
                struct usb_endpoint_descriptor_no_audio int_in;
@@ -89,13 +92,26 @@ static const struct {
                struct usb_endpoint_descriptor_no_audio bulk_in;
                struct usb_endpoint_descriptor_no_audio bulk_out;
        } __attribute__ ((__packed__)) fs_descs, hs_descs;
+       struct {
+               struct usb_interface_descriptor acm;
+               struct usb_endpoint_descriptor_no_audio int_in;
+               struct usb_ss_ep_comp_descriptor int_in_comp;
+               struct usb_interface_descriptor intf;
+               struct usb_endpoint_descriptor_no_audio bulk_in;
+               struct usb_ss_ep_comp_descriptor bulk_in_comp;
+               struct usb_endpoint_descriptor_no_audio bulk_out;
+               struct usb_ss_ep_comp_descriptor bulk_out_comp;
+       } __attribute__ ((__packed__)) ss_descs;
 } __attribute__ ((__packed__)) descriptors = {
        .header = {
-               .magic = __cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC),
+               .magic = __cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2),
                .length = __cpu_to_le32(sizeof(descriptors)),
-               .fs_count = __cpu_to_le32(5),
-               .hs_count = __cpu_to_le32(5),
+               .flags = FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC |
+                        FUNCTIONFS_HAS_SS_DESC,
        },
+       .fs_count = __cpu_to_le32(5),
+       .hs_count = __cpu_to_le32(5),
+       .ss_count = __cpu_to_le32(8),
        .fs_descs = {
                .acm = {
                        .bLength = sizeof(descriptors.fs_descs.intf),
@@ -176,6 +192,60 @@ static const struct {
                        .wMaxPacketSize = __cpu_to_le16(512),
                },
        },
+       .ss_descs = {
+               .acm = {
+                       .bLength = sizeof(descriptors.ss_descs.intf),
+                       .bDescriptorType = USB_DT_INTERFACE,
+                       .bInterfaceNumber = 0,
+                       .bNumEndpoints = 1,
+                       .bInterfaceClass = USB_CLASS_COMM,
+                       .bInterfaceSubClass = USB_CDC_SUBCLASS_ACM,
+                       .bInterfaceProtocol = USB_CDC_ACM_PROTO_AT_V25TER,
+                       .iInterface = 1,
+               },
+               .int_in = {
+                       .bLength = sizeof(descriptors.ss_descs.int_in),
+                       .bDescriptorType = USB_DT_ENDPOINT,
+                       .bEndpointAddress = 3 | USB_DIR_IN,
+                       .bmAttributes = USB_ENDPOINT_XFER_INT,
+                       .wMaxPacketSize = __cpu_to_le16(16),
+                       .bInterval = 10,
+               },
+               .int_in_comp = {
+                       .bLength = sizeof(descriptors.ss_descs.int_in_comp),
+                       .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
+               },
+               .intf = {
+                       .bLength = sizeof(descriptors.ss_descs.intf),
+                       .bDescriptorType = USB_DT_INTERFACE,
+                       .bInterfaceNumber = 1,
+                       .bNumEndpoints = 2,
+                       .bInterfaceClass = USB_CLASS_CDC_DATA,
+                       .iInterface = 1,
+               },
+               .bulk_in = {
+                       .bLength = sizeof(descriptors.ss_descs.bulk_in),
+                       .bDescriptorType = USB_DT_ENDPOINT,
+                       .bEndpointAddress = 1 | USB_DIR_IN,
+                       .bmAttributes = USB_ENDPOINT_XFER_BULK,
+                       .wMaxPacketSize = __cpu_to_le16(1024),
+               },
+               .bulk_in_comp = {
+                       .bLength = sizeof(descriptors.ss_descs.bulk_in_comp),
+                       .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
+               },
+               .bulk_out = {
+                       .bLength = sizeof(descriptors.ss_descs.bulk_out),
+                       .bDescriptorType = USB_DT_ENDPOINT,
+                       .bEndpointAddress = 2 | USB_DIR_OUT,
+                       .bmAttributes = USB_ENDPOINT_XFER_BULK,
+                       .wMaxPacketSize = __cpu_to_le16(1024),
+               },
+               .bulk_out_comp = {
+                       .bLength = sizeof(descriptors.ss_descs.bulk_out_comp),
+                       .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
+               },
+       },
 };
 
 #define STR_INTERFACE "TIZEN USB DRIVER"