[PATCH 3/4] usb: add options to identify the capabilities of OTG devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add independent options for identify the capabilities of
ADP/SRP/HNP feature for OTG devices.

Signed-off-by: Macpaul Lin <macpaul@xxxxxxxxx>
---
 drivers/usb/gadget/composite.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 13adfd1..57a7205 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1461,6 +1461,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
 	u16				w_length = le16_to_cpu(ctrl->wLength);
 	struct usb_function		*f = NULL;
 	u8				endp;
+	struct usb_otg_descriptor	*otg_desc = NULL;
 
 	/* partial re-init of the response message; the function or the
 	 * gadget might need to intercept e.g. a control-OUT completion
@@ -1480,6 +1481,21 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
 			goto unknown;
 		switch (w_value >> 8) {
 
+		case USB_DT_OTG:
+			otg_desc = (struct usb_otg_descriptor *)req->buf;
+			otg_desc->bLength = sizeof(*otg_desc);
+			otg_desc->bDescriptorType = USB_DT_OTG;
+			if (gadget->adp_support)
+				otg_desc->bmAttributes |= USB_OTG_ADP;
+			if (gadget->hnp_support)
+				otg_desc->bmAttributes |= USB_OTG_HNP;
+			if (gadget->srp_support)
+				otg_desc->bmAttributes |= USB_OTG_SRP;
+			if (gadget_is_otg20(gadget))
+				otg_desc->bcdOTG = cpu_to_le16(0x0200);
+			value = min_t(int, w_length,
+				sizeof(struct usb_otg_descriptor));
+			break;
 		case USB_DT_DEVICE:
 			cdev->desc.bNumConfigurations =
 				count_configs(cdev, USB_DT_DEVICE);
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux