Hi, W dniu 25.01.2023 o 09:23, Yuta Hayama pisze:
Hi, I have a question about MS OS descriptor support in FunctionFS. I understand that the current FunctionFS supports OS descriptors and that the FunctionFS user mode driver can optionally be set up with a configuration that includes OS descriptors. Here, there are several versions of the OS descriptor, but the current FunctionFS (or gadget framework?) supports only v1.0, I think. Indeed, __ffs_do_os_desc_header() in drivers/usb/gadget/function/f_fs.c rejects OS descriptors other than v1.0 in the following way: static int __ffs_do_os_desc_header(enum ffs_os_desc_type *next_type, struct usb_os_desc_header *desc) { u16 bcd_version = le16_to_cpu(desc->bcdVersion); u16 w_index = le16_to_cpu(desc->wIndex); if (bcd_version != 1) { pr_vdebug("unsupported os descriptors version: %d", bcd_version); return -EINVAL; } /* ... */ Here's a question: isn't it wrong to assume that the value of desc->bcdVersion in OS descriptor v1.0 is 0x0001? From reference to the following document on OS descriptor v1.0, it looks like the value 0x0100 is assumed. (Well, I don't think v1.0 will be 0x0001 since it would be in BCD form as the name suggests.) [Microsoft OS 1.0 Descriptors Specification] https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-os-1-0-descriptors-specification Page 6 of OS_Desc_CompatID.doc and page 5 of OS_Desc_Ext_Prop.doc explain the header section, which can be found there. The examples of descriptors also show bcdVersion=0x0100. Would the fix be something like the following? if (bcd_version == 0x0001) { pr_debug(" ... "); /* * Pass through for compatibility, but notify to fix the user * mode driver? */ } else if (bcd_version != 0x0100) { pr_vdebug("unsupported os descriptors version: %d", bcd_version); return -EINVAL; } By the way, with the current FunctionFS code, we have to set bcd_version=0x0001 in the OS descriptor, but it looks like the Windows host(USB host) won't complain about that.
Are you able to check what does Windows host actually see in bcd_version if it is set as "0x0001" at the FunctionFS gadget side? And then, whether it does not complain because it sees what it expects or because it does not care even though it sees something it doesn't expect? Regards, Andrzej