diff mbox series

[V2,07/17] usb: gadget: add WCID support for mfgtool

Message ID 20210125134400.780-8-peng.fan@nxp.com
State New
Headers show
Series usb: gadget: update | expand

Commit Message

Peng Fan Jan. 25, 2021, 1:43 p.m. UTC
From: Li Jun <jun.li@nxp.com>


Enable WCID(Microsoft Compatible ID Feature Descriptor) for mfgtool.

Signed-off-by: Li Jun <jun.li@nxp.com>

Signed-off-by: Peng Fan <peng.fan@nxp.com>

---
 drivers/usb/gadget/composite.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

-- 
2.28.0
diff mbox series

Patch

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index a0c28dbe59..cd61bfec38 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -20,6 +20,10 @@ 
 typedef struct { __le16 val; } __packed __le16_packed;
 
 static struct usb_composite_driver *composite;
+static struct usb_configuration *os_desc_config;
+
+/* Microsoft OS String Descriptor */
+static char qw_sign_buf[OS_STRING_QW_SIGN_LEN / 2] = {'M', 'S', 'F', 'T', '1', '0', '0'};
 
 static inline void le16_add_cpu_packed(__le16_packed *var, u16 val)
 {
@@ -395,6 +399,10 @@  static int set_config(struct usb_composite_dev *cdev,
 		goto done;
 
 	cdev->config = c;
+	if (cdev->use_os_string) {
+		cdev->os_desc_config = c;
+		os_desc_config = c;
+	}
 
 	/* Initialize all interfaces by setting them to altsetting zero. */
 	for (tmp = 0; tmp < MAX_CONFIG_INTERFACES; tmp++) {
@@ -1358,6 +1366,18 @@  static int composite_bind(struct usb_gadget *gadget)
 	       sizeof(struct usb_device_descriptor));
 	cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
 
+	if (cdev->use_os_string) {
+		/* TODO: Do we want to pass this via platform? */
+		cdev->b_vendor_code = 0x40;
+
+		/* Microsoft OS String Descriptor */
+		utf8_to_utf16le(qw_sign_buf, (__le16 *)cdev->qw_sign,
+				OS_STRING_QW_SIGN_LEN / 2);
+
+		if (os_desc_config)
+			cdev->os_desc_config = os_desc_config;
+	}
+
 	debug("%s: ready\n", composite->name);
 	return 0;