OS Descriptor version in FunctionFS

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

 



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.


Thank you.

Yuta Hayama



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

  Powered by Linux