USB: Add super speed descriptors for gadget functions

Update function drivers mtp and accessory to operate
in super speed.  The burst capability is not enabled for now.

Change-Id: Ie95cbfc9444c56c8268b70e2916713190699c71a
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
This commit is contained in:
Hemant Kumar 2016-05-01 22:37:02 -07:00 committed by Kyle Yan
parent 128668947a
commit be59d8985c
2 changed files with 131 additions and 2 deletions

View file

@ -136,12 +136,47 @@ static struct usb_interface_descriptor acc_interface_desc = {
.bInterfaceProtocol = 0,
};
static struct usb_endpoint_descriptor acc_superspeed_in_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = cpu_to_le16(1024),
};
static struct usb_ss_ep_comp_descriptor acc_superspeed_in_comp_desc = {
.bLength = sizeof(acc_superspeed_in_comp_desc),
.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
/* the following 2 values can be tweaked if necessary */
/* .bMaxBurst = 0, */
/* .bmAttributes = 0, */
};
static struct usb_endpoint_descriptor acc_superspeed_out_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = cpu_to_le16(1024),
};
static struct usb_ss_ep_comp_descriptor acc_superspeed_out_comp_desc = {
.bLength = sizeof(acc_superspeed_out_comp_desc),
.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
/* the following 2 values can be tweaked if necessary */
/* .bMaxBurst = 0, */
/* .bmAttributes = 0, */
};
static struct usb_endpoint_descriptor acc_highspeed_in_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = __constant_cpu_to_le16(512),
.wMaxPacketSize = cpu_to_le16(512),
};
static struct usb_endpoint_descriptor acc_highspeed_out_desc = {
@ -149,7 +184,7 @@ static struct usb_endpoint_descriptor acc_highspeed_out_desc = {
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = __constant_cpu_to_le16(512),
.wMaxPacketSize = cpu_to_le16(512),
};
static struct usb_endpoint_descriptor acc_fullspeed_in_desc = {
@ -180,6 +215,15 @@ static struct usb_descriptor_header *hs_acc_descs[] = {
NULL,
};
static struct usb_descriptor_header *ss_acc_descs[] = {
(struct usb_descriptor_header *) &acc_interface_desc,
(struct usb_descriptor_header *) &acc_superspeed_in_desc,
(struct usb_descriptor_header *) &acc_superspeed_in_comp_desc,
(struct usb_descriptor_header *) &acc_superspeed_out_desc,
(struct usb_descriptor_header *) &acc_superspeed_out_comp_desc,
NULL,
};
static struct usb_string acc_string_defs[] = {
[INTERFACE_STRING_INDEX].s = "Android Accessory Interface",
{ }, /* end of list */
@ -959,6 +1003,14 @@ __acc_function_bind(struct usb_configuration *c,
acc_fullspeed_out_desc.bEndpointAddress;
}
/* support super speed hardware */
if (gadget_is_superspeed(c->cdev->gadget)) {
acc_superspeed_in_desc.bEndpointAddress =
acc_fullspeed_in_desc.bEndpointAddress;
acc_superspeed_out_desc.bEndpointAddress =
acc_fullspeed_out_desc.bEndpointAddress;
}
DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n",
gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full",
f->name, dev->ep_in->name, dev->ep_out->name);
@ -1315,6 +1367,7 @@ static struct usb_function *acc_alloc(struct usb_function_instance *fi)
dev->function.strings = acc_strings,
dev->function.fs_descriptors = fs_acc_descs;
dev->function.hs_descriptors = hs_acc_descs;
dev->function.ss_descriptors = ss_acc_descs;
dev->function.bind = acc_function_bind_configfs;
dev->function.unbind = acc_function_unbind;
dev->function.set_alt = acc_function_set_alt;

View file

@ -144,6 +144,40 @@ static struct usb_interface_descriptor ptp_interface_desc = {
.bInterfaceProtocol = 1,
};
static struct usb_endpoint_descriptor mtp_superspeed_in_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = cpu_to_le16(1024),
};
static struct usb_ss_ep_comp_descriptor mtp_superspeed_in_comp_desc = {
.bLength = sizeof(mtp_superspeed_in_comp_desc),
.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
/* the following 2 values can be tweaked if necessary */
/* .bMaxBurst = 0, */
/* .bmAttributes = 0, */
};
static struct usb_endpoint_descriptor mtp_superspeed_out_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = cpu_to_le16(1024),
};
static struct usb_ss_ep_comp_descriptor mtp_superspeed_out_comp_desc = {
.bLength = sizeof(mtp_superspeed_out_comp_desc),
.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
/* the following 2 values can be tweaked if necessary */
/* .bMaxBurst = 0, */
/* .bmAttributes = 0, */
};
static struct usb_endpoint_descriptor mtp_highspeed_in_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
@ -183,6 +217,16 @@ static struct usb_endpoint_descriptor mtp_intr_desc = {
.bInterval = 6,
};
static struct usb_ss_ep_comp_descriptor mtp_superspeed_intr_comp_desc = {
.bLength = sizeof(mtp_superspeed_intr_comp_desc),
.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
/* the following 3 values can be tweaked if necessary */
/* .bMaxBurst = 0, */
/* .bmAttributes = 0, */
.wBytesPerInterval = cpu_to_le16(INTR_BUFFER_SIZE),
};
static struct usb_descriptor_header *fs_mtp_descs[] = {
(struct usb_descriptor_header *) &mtp_interface_desc,
(struct usb_descriptor_header *) &mtp_fullspeed_in_desc,
@ -199,6 +243,17 @@ static struct usb_descriptor_header *hs_mtp_descs[] = {
NULL,
};
static struct usb_descriptor_header *ss_mtp_descs[] = {
(struct usb_descriptor_header *) &mtp_interface_desc,
(struct usb_descriptor_header *) &mtp_superspeed_in_desc,
(struct usb_descriptor_header *) &mtp_superspeed_in_comp_desc,
(struct usb_descriptor_header *) &mtp_superspeed_out_desc,
(struct usb_descriptor_header *) &mtp_superspeed_out_comp_desc,
(struct usb_descriptor_header *) &mtp_intr_desc,
(struct usb_descriptor_header *) &mtp_superspeed_intr_comp_desc,
NULL,
};
static struct usb_descriptor_header *fs_ptp_descs[] = {
(struct usb_descriptor_header *) &ptp_interface_desc,
(struct usb_descriptor_header *) &mtp_fullspeed_in_desc,
@ -215,6 +270,17 @@ static struct usb_descriptor_header *hs_ptp_descs[] = {
NULL,
};
static struct usb_descriptor_header *ss_ptp_descs[] = {
(struct usb_descriptor_header *) &ptp_interface_desc,
(struct usb_descriptor_header *) &mtp_superspeed_in_desc,
(struct usb_descriptor_header *) &mtp_superspeed_in_comp_desc,
(struct usb_descriptor_header *) &mtp_superspeed_out_desc,
(struct usb_descriptor_header *) &mtp_superspeed_out_comp_desc,
(struct usb_descriptor_header *) &mtp_intr_desc,
(struct usb_descriptor_header *) &mtp_superspeed_intr_comp_desc,
NULL,
};
static struct usb_string mtp_string_defs[] = {
/* Naming interface "MTP" so libmtp will recognize us */
[INTERFACE_STRING_INDEX].s = "MTP",
@ -1200,6 +1266,14 @@ mtp_function_bind(struct usb_configuration *c, struct usb_function *f)
mtp_fullspeed_out_desc.bEndpointAddress;
}
/* support super speed hardware */
if (gadget_is_superspeed(c->cdev->gadget)) {
mtp_superspeed_in_desc.bEndpointAddress =
mtp_fullspeed_in_desc.bEndpointAddress;
mtp_superspeed_out_desc.bEndpointAddress =
mtp_fullspeed_out_desc.bEndpointAddress;
}
DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n",
gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full",
f->name, dev->ep_in->name, dev->ep_out->name);
@ -1478,9 +1552,11 @@ struct usb_function *function_alloc_mtp_ptp(struct usb_function_instance *fi,
if (mtp_config) {
dev->function.fs_descriptors = fs_mtp_descs;
dev->function.hs_descriptors = hs_mtp_descs;
dev->function.ss_descriptors = ss_mtp_descs;
} else {
dev->function.fs_descriptors = fs_ptp_descs;
dev->function.hs_descriptors = hs_ptp_descs;
dev->function.ss_descriptors = ss_ptp_descs;
}
dev->function.bind = mtp_function_bind;
dev->function.unbind = mtp_function_unbind;