Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94c657fd authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: gadget: ncm: Add super speed descriptors for NCM function"

parents f8e05f97 01e6dd57
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1054,7 +1054,7 @@ ncm_function_bind_config(struct android_usb_function *f,
		ncm->ethaddr[3], ncm->ethaddr[4], ncm->ethaddr[5]);

	ncm_opts = container_of(ncm->fi, struct f_ncm_opts, func_inst);
	strlcpy(ncm_opts->net->name, "ncm%%d", sizeof(ncm_opts->net->name));
	strlcpy(ncm_opts->net->name, "ncm%d", sizeof(ncm_opts->net->name));

	gether_set_qmult(ncm_opts->net, qmult);
	if (!gether_set_host_addr(ncm_opts->net, host_addr))
@@ -2429,7 +2429,7 @@ static int ecm_function_bind_config(struct android_usb_function *f,
		ecm->ethaddr[3], ecm->ethaddr[4], ecm->ethaddr[5]);

	ecm_opts = container_of(ecm->fi, struct f_ecm_opts, func_inst);
	strlcpy(ecm_opts->net->name, "ecm%%d", sizeof(ecm_opts->net->name));
	strlcpy(ecm_opts->net->name, "ecm%d", sizeof(ecm_opts->net->name));
	gether_set_qmult(ecm_opts->net, qmult);
	if (!gether_set_host_addr(ecm_opts->net, host_addr))
		pr_info("using host ethernet address: %s", host_addr);
+82 −1
Original line number Diff line number Diff line
@@ -333,6 +333,77 @@ static struct usb_descriptor_header *ncm_hs_function[] = {
	NULL,
};

/* Super Speed Support */
static struct usb_endpoint_descriptor ncm_ss_notify_desc = {
	.bLength =		USB_DT_ENDPOINT_SIZE,
	.bDescriptorType =	USB_DT_ENDPOINT,
	.bEndpointAddress =	USB_DIR_IN,
	.bmAttributes =		USB_ENDPOINT_XFER_INT,
	.wMaxPacketSize =	cpu_to_le16(NCM_STATUS_BYTECOUNT),
	.bInterval =		USB_MS_TO_HS_INTERVAL(NCM_STATUS_INTERVAL_MS),
};

static struct usb_ss_ep_comp_descriptor ncm_ss_notify_comp_desc = {
	.bLength =		sizeof(ncm_ss_notify_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(NCM_STATUS_BYTECOUNT),
};

static struct usb_endpoint_descriptor ncm_ss_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 ncm_ss_in_comp_desc = {
	.bLength =		sizeof(ncm_ss_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 ncm_ss_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 ncm_ss_out_comp_desc = {
	.bLength =		sizeof(ncm_ss_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_descriptor_header *ncm_ss_function[] = {
	(struct usb_descriptor_header *) &ncm_iad_desc,
	/* CDC NCM control descriptors */
	(struct usb_descriptor_header *) &ncm_control_intf,
	(struct usb_descriptor_header *) &ncm_header_desc,
	(struct usb_descriptor_header *) &ncm_union_desc,
	(struct usb_descriptor_header *) &ecm_desc,
	(struct usb_descriptor_header *) &ncm_desc,
	(struct usb_descriptor_header *) &ncm_ss_notify_desc,
	(struct usb_descriptor_header *) &ncm_ss_notify_comp_desc,
	/* data interface, altsettings 0 and 1 */
	(struct usb_descriptor_header *) &ncm_data_nop_intf,
	(struct usb_descriptor_header *) &ncm_data_intf,
	(struct usb_descriptor_header *) &ncm_ss_in_desc,
	(struct usb_descriptor_header *) &ncm_ss_in_comp_desc,
	(struct usb_descriptor_header *) &ncm_ss_out_desc,
	(struct usb_descriptor_header *) &ncm_ss_out_comp_desc,
	NULL,
};

/* string descriptors: */

#define STRING_CTRL_IDX	0
@@ -458,6 +529,7 @@ static inline unsigned get_ncm(__le16 **p, unsigned size)
static inline void ncm_reset_values(struct f_ncm *ncm)
{
	ncm->parser_opts = &ndp16_opts;
	ncm->ndp_sign = ncm->parser_opts->ndp_sign;
	ncm->is_crc = false;
	ncm->port.cdc_filter = DEFAULT_FILTER;

@@ -1439,8 +1511,17 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f)
	hs_ncm_notify_desc.bEndpointAddress =
		fs_ncm_notify_desc.bEndpointAddress;

	if (gadget_is_superspeed(c->cdev->gadget)) {
		ncm_ss_in_desc.bEndpointAddress =
					fs_ncm_in_desc.bEndpointAddress;
		ncm_ss_out_desc.bEndpointAddress =
					fs_ncm_out_desc.bEndpointAddress;
		ncm_ss_notify_desc.bEndpointAddress =
					fs_ncm_notify_desc.bEndpointAddress;
	}

	status = usb_assign_descriptors(f, ncm_fs_function, ncm_hs_function,
			NULL);
					ncm_ss_function);
	/*
	 * NOTE:  all that is done without knowing or caring about
	 * the network link ... which is unavailable to this code