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

Commit 4b5d8ea0 authored by Pratham Pratap's avatar Pratham Pratap
Browse files

usb: gadget: qti: Add support for MBIM OS descriptor handling



In order to support MBIM for qti gadget in a multi-config usb
composition driver has to support OS descriptor.
This change adds signature field, vendor code, compatibleID and
subCompatibleID in qti gadget and gsi driver for early enumeration
of USB since there is no dependency in userspace.

Change-Id: Ia68ac2d79338fdd6580c7ac906378742d3aaa74e
Signed-off-by: default avatarPratham Pratap <prathampratap@codeaurora.org>
parent f238b45a
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2915,6 +2915,7 @@ static int gsi_bind(struct usb_configuration *c, struct usb_function *f)
	struct gsi_function_bind_info info = {0};
	struct f_gsi *gsi = func_to_gsi(f);
	struct rndis_params *params;
	struct usb_os_desc *descs[1];
	struct gsi_opts *opts;
	struct net_device *net;
	char *name = NULL;
@@ -3134,6 +3135,14 @@ static int gsi_bind(struct usb_configuration *c, struct usb_function *f)
			f->os_desc_n = 1;
			f->os_desc_table[0].os_desc = &opts->os_desc;
			f->os_desc_table[0].if_id = gsi->data_id;
			opts->os_desc.ext_compat_id = opts->ext_compat_id;
			descs[0] = &opts->os_desc;
			snprintf(sub_compatible_id, sizeof(sub_compatible_id),
					"%u", c->bConfigurationValue);
			memcpy(descs[0]->ext_compat_id, compatible_id,
					strlen(compatible_id));
			memcpy(descs[0]->ext_compat_id + 8, sub_compatible_id,
					strlen(sub_compatible_id));
		}
		break;
	case USB_PROT_RMNET_IPA:
+3 −0
Original line number Diff line number Diff line
@@ -80,6 +80,9 @@
/* ID for Microsoft OS String */
#define GSI_MBIM_OS_STRING_ID 0xEE

static char compatible_id[256] = "ALTRCFG";
static char sub_compatible_id[8];

#define EVT_NONE			0
#define EVT_UNINITIALIZED		1
#define EVT_INITIALIZED			2
+18 −0
Original line number Diff line number Diff line
@@ -28,6 +28,10 @@ struct qti_usb_function {
#define MAX_FUNC_NAME_LEN	48
#define MAX_CFG_NAME_LEN       128

#define QW_SIGN_LEN		14

char qw_sign[QW_SIGN_LEN] = "MSFT100";

struct qti_usb_config {
	struct usb_configuration c;

@@ -175,6 +179,12 @@ static int qti_composite_bind(struct usb_gadget *gadget,
		usb_ep_autoconfig_reset(cdev->gadget);
	}

	if (cdev->use_os_string) {
		ret = composite_os_desc_req_prepare(cdev, gadget->ep0);
		if (ret)
			goto remove_funcs;
	}

	usb_ep_autoconfig_reset(cdev->gadget);

	return 0;
@@ -261,6 +271,7 @@ static int qti_usb_func_alloc(struct qti_usb_config *qcfg,
{
	struct qti_usb_function *qf;
	struct usb_function_instance *fi;
	struct usb_composite_dev *cdev = qcfg->c.cdev;
	struct usb_function *f;
	char buf[MAX_FUNC_NAME_LEN];
	char *func_name;
@@ -312,6 +323,13 @@ static int qti_usb_func_alloc(struct qti_usb_config *qcfg,
	/* stash the function until we bind it to the gadget */
	list_add_tail(&f->list, &qcfg->func_list);

	if (!strcmp(instance_name, "mbim")) {
		cdev->os_desc_config = &qcfg->c;
		cdev->use_os_string = true;
		cdev->b_vendor_code = 0xA5;
		memcpy(cdev->qw_sign, qw_sign, QW_SIGN_LEN);
	}

	return 0;
}