|
|
|
|
@ -20,6 +20,59 @@
|
|
|
|
|
|
|
|
|
|
#include "u_os_desc.h"
|
|
|
|
|
|
|
|
|
|
//#if defined (CONFIG_GAOYANG)
|
|
|
|
|
// (struct usb_descriptor_header *) &WINUSB_WCIDDescriptor,
|
|
|
|
|
//#endif // defined (CONFIG_GAOYANG)
|
|
|
|
|
#if defined (CONFIG_GAOYANG)
|
|
|
|
|
|
|
|
|
|
#define WINUSB_IF0_WCID_PROPERTIES_SIZE (162)
|
|
|
|
|
|
|
|
|
|
const uint8_t WINUSB20_WCIDDescriptorSet [162] = {
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
/// WCID20 descriptor set descriptor
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
0x0a, 0x00, /* wLength */
|
|
|
|
|
0x00, 0x00, /* wDescriptorType */
|
|
|
|
|
0x00, 0x00, 0x03, 0x06, /* dwWindowsVersion */
|
|
|
|
|
0xa2, 0x00, /* wDescriptorSetTotalLength */
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
/// WCID20 compatible ID descriptor
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
0x14, 0x00, /* wLength */
|
|
|
|
|
0x03, 0x00, /* wDescriptorType */
|
|
|
|
|
/* WINUSB */
|
|
|
|
|
'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00, /* cCID_8 */
|
|
|
|
|
/* */
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* cSubCID_8 */
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
/// WCID20 registry property descriptor
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
0x84, 0x00, /* wLength */
|
|
|
|
|
0x04, 0x00, /* wDescriptorType */
|
|
|
|
|
0x07, 0x00, /* wPropertyDataType */
|
|
|
|
|
0x2a, 0x00, /* wPropertyNameLength */
|
|
|
|
|
/* DeviceInterfaceGUIDs */
|
|
|
|
|
'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, /* wcPropertyName_21 */
|
|
|
|
|
'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, /* wcPropertyName_21 */
|
|
|
|
|
't', 0x00, 'e', 0x00, 'r', 0x00, 'f', 0x00, /* wcPropertyName_21 */
|
|
|
|
|
'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, /* wcPropertyName_21 */
|
|
|
|
|
'U', 0x00, 'I', 0x00, 'D', 0x00, 's', 0x00, /* wcPropertyName_21 */
|
|
|
|
|
0x00, 0x00, /* wcPropertyName_21 */
|
|
|
|
|
0x50, 0x00, /* wPropertyDataLength */
|
|
|
|
|
/* {1D4B2365-4749-48EA-B38A-7C6FDDDD7E26} */
|
|
|
|
|
'{', 0x00, '1', 0x00, 'D', 0x00, '4', 0x00, /* wcPropertyData_40 */
|
|
|
|
|
'B', 0x00, '2', 0x00, '3', 0x00, '6', 0x00, /* wcPropertyData_40 */
|
|
|
|
|
'5', 0x00, '-', 0x00, '4', 0x00, '7', 0x00, /* wcPropertyData_40 */
|
|
|
|
|
'4', 0x00, '9', 0x00, '-', 0x00, '4', 0x00, /* wcPropertyData_40 */
|
|
|
|
|
'8', 0x00, 'E', 0x00, 'A', 0x00, '-', 0x00, /* wcPropertyData_40 */
|
|
|
|
|
'B', 0x00, '3', 0x00, '8', 0x00, 'A', 0x00, /* wcPropertyData_40 */
|
|
|
|
|
'-', 0x00, '7', 0x00, 'C', 0x00, '6', 0x00, /* wcPropertyData_40 */
|
|
|
|
|
'F', 0x00, 'D', 0x00, 'D', 0x00, 'D', 0x00, /* wcPropertyData_40 */
|
|
|
|
|
'D', 0x00, '7', 0x00, 'E', 0x00, '2', 0x00, /* wcPropertyData_40 */
|
|
|
|
|
'6', 0x00, '}', 0x00, 0x00, 0x00, 0x00, 0x00, /* wcPropertyData_40 */
|
|
|
|
|
};
|
|
|
|
|
#endif // defined (CONFIG_GAOYANG)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* struct usb_os_string - represents OS String to be reported by a gadget
|
|
|
|
|
* @bLength: total length of the entire descritor, always 0x12
|
|
|
|
|
@ -664,6 +717,35 @@ static int bos_desc(struct usb_composite_dev *cdev)
|
|
|
|
|
struct usb_ext_cap_descriptor *usb_ext;
|
|
|
|
|
struct usb_dcd_config_params dcd_config_params;
|
|
|
|
|
struct usb_bos_descriptor *bos = cdev->req->buf;
|
|
|
|
|
#if defined (CONFIG_GAOYANG)
|
|
|
|
|
/* WCID20 device capability descriptor */
|
|
|
|
|
#define USB_CAP_TYPE_WCID 5
|
|
|
|
|
#define USB_CAP_WCID_SIZE 0x1C
|
|
|
|
|
#define WINUSB20_WCID_VENDOR_CODE 0x00
|
|
|
|
|
#define WINUSB20_WCID_DESC_SET_SIZE 162
|
|
|
|
|
|
|
|
|
|
struct usb_cap_wcid20_descriptor {
|
|
|
|
|
__u8 bLength;
|
|
|
|
|
__u8 bDescriptorType;
|
|
|
|
|
__u8 bDevCapabilityType;
|
|
|
|
|
__u8 bReserved ;
|
|
|
|
|
__u8 bPlatformCapabilityUUID_16[16];
|
|
|
|
|
__u32 dwWindowsVersion;
|
|
|
|
|
__le32 wDescriptorSetTotalLength;
|
|
|
|
|
__u8 bVendorCode;
|
|
|
|
|
__u8 bAltEnumCode;
|
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
|
|
char winusb20_wcidbos_uuid[] = {
|
|
|
|
|
0xdf, 0x60, 0xdd, 0xd8, 0x89, 0x45, 0xc7, 0x4c,
|
|
|
|
|
0x9c, 0xd2, 0x65, 0x9d, 0x9e, 0x64, 0x8a, 0x9f,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
uint32_t winusb20_wcidbos_version = 0x06030000;
|
|
|
|
|
|
|
|
|
|
struct usb_cap_wcid20_descriptor *usb_cap_wcid;
|
|
|
|
|
|
|
|
|
|
#endif // defined (CONFIG_GAOYANG)
|
|
|
|
|
unsigned int besl = 0;
|
|
|
|
|
|
|
|
|
|
bos->bLength = USB_DT_BOS_SIZE;
|
|
|
|
|
@ -694,7 +776,6 @@ static int bos_desc(struct usb_composite_dev *cdev)
|
|
|
|
|
if (dcd_config_params.besl_deep != USB_DEFAULT_BESL_UNSPECIFIED)
|
|
|
|
|
besl |= USB_BESL_DEEP_VALID |
|
|
|
|
|
USB_SET_BESL_DEEP(dcd_config_params.besl_deep);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* A SuperSpeed device shall include the USB2.0 extension descriptor
|
|
|
|
|
* and shall support LPM when operating in USB2.0 HS mode.
|
|
|
|
|
@ -708,6 +789,19 @@ static int bos_desc(struct usb_composite_dev *cdev)
|
|
|
|
|
usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT |
|
|
|
|
|
USB_BESL_SUPPORT | besl);
|
|
|
|
|
|
|
|
|
|
#if defined (CONFIG_GAOYANG)
|
|
|
|
|
usb_cap_wcid = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
|
|
|
|
|
le16_add_cpu(&bos->wTotalLength, USB_CAP_WCID_SIZE);
|
|
|
|
|
bos->bNumDeviceCaps++;
|
|
|
|
|
|
|
|
|
|
usb_cap_wcid->bLength = USB_CAP_WCID_SIZE;
|
|
|
|
|
usb_cap_wcid->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
|
|
|
|
|
usb_cap_wcid->bDevCapabilityType = USB_CAP_TYPE_WCID;
|
|
|
|
|
usb_cap_wcid->dwWindowsVersion = winusb20_wcidbos_version;
|
|
|
|
|
usb_cap_wcid->wDescriptorSetTotalLength = cpu_to_le32(WINUSB20_WCID_DESC_SET_SIZE);
|
|
|
|
|
usb_cap_wcid->bVendorCode = WINUSB20_WCID_VENDOR_CODE;
|
|
|
|
|
memcpy(usb_cap_wcid->bPlatformCapabilityUUID_16, winusb20_wcidbos_uuid, sizeof(winusb20_wcidbos_uuid));
|
|
|
|
|
#endif // defined (CONFIG_GAOYANG)
|
|
|
|
|
/*
|
|
|
|
|
* The Superspeed USB Capability descriptor shall be implemented by all
|
|
|
|
|
* SuperSpeed devices.
|
|
|
|
|
@ -1685,7 +1779,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
|
|
|
|
|
if (gadget->lpm_capable)
|
|
|
|
|
cdev->desc.bcdUSB = cpu_to_le16(0x0201);
|
|
|
|
|
else
|
|
|
|
|
cdev->desc.bcdUSB = cpu_to_le16(0x0200);
|
|
|
|
|
cdev->desc.bcdUSB = cpu_to_le16(0x0201);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
value = min(w_length, (u16) sizeof cdev->desc);
|
|
|
|
|
@ -1716,11 +1810,16 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
|
|
|
|
|
value = min(w_length, (u16) value);
|
|
|
|
|
break;
|
|
|
|
|
case USB_DT_BOS:
|
|
|
|
|
#if !defined (CONFIG_GAOYANG)
|
|
|
|
|
if (gadget_is_superspeed(gadget) ||
|
|
|
|
|
gadget->lpm_capable) {
|
|
|
|
|
value = bos_desc(cdev);
|
|
|
|
|
value = min(w_length, (u16) value);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
value = bos_desc(cdev);
|
|
|
|
|
value = min(w_length, (u16) value);
|
|
|
|
|
#endif // defined (CONFIG_GAOYANG)
|
|
|
|
|
break;
|
|
|
|
|
case USB_DT_OTG:
|
|
|
|
|
if (gadget_is_otg(gadget)) {
|
|
|
|
|
@ -1891,6 +1990,14 @@ unknown:
|
|
|
|
|
/*
|
|
|
|
|
* OS descriptors handling
|
|
|
|
|
*/
|
|
|
|
|
#if defined (CONFIG_GAOYANG)
|
|
|
|
|
if (ctrl->bRequestType == 0xC0) {
|
|
|
|
|
value = min_t(int, w_length, sizeof(WINUSB20_WCIDDescriptorSet));
|
|
|
|
|
memcpy(req->buf, WINUSB20_WCIDDescriptorSet, value);
|
|
|
|
|
|
|
|
|
|
goto check_value;
|
|
|
|
|
}
|
|
|
|
|
#endif // defined (CONFIG_GAOYANG)
|
|
|
|
|
if (cdev->use_os_string && cdev->os_desc_config &&
|
|
|
|
|
(ctrl->bRequestType & USB_TYPE_VENDOR) &&
|
|
|
|
|
ctrl->bRequest == cdev->b_vendor_code) {
|
|
|
|
|
|