From 1df22b4ea9d91b01267fb61c155c31fb65d6b8a0 Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Wed, 27 Aug 2014 22:58:45 +0200 Subject: usb: gadget: f_fs: add usb_functionfs_descs_head_v2 structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The structure can be used with user space tools that use the new functionfs description format, for example as follows: static const struct { struct usb_functionfs_descs_head_v2 header; __le32 fs_count; __le32 hs_count; struct { … } fs_desc; struct { … } hs_desc; } descriptors = { .header = { .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2), .length = cpu_to_le32(sizeof(descriptors)), .flags = cpu_to_le32(FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC) }, .fs_count = cpu_to_le32(X), .fs_desc = { … }, .hs_count = cpu_to_le32(Y), .hs_desc = { … } }; Signed-off-by: Michal Nazarewicz Signed-off-by: Felipe Balbi --- include/uapi/linux/usb/functionfs.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/uapi') diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h index 0154b2859fd7..3ca03de7c2a8 100644 --- a/include/uapi/linux/usb/functionfs.h +++ b/include/uapi/linux/usb/functionfs.h @@ -32,6 +32,16 @@ struct usb_endpoint_descriptor_no_audio { __u8 bInterval; } __attribute__((packed)); +struct usb_functionfs_descs_head_v2 { + __le32 magic; + __le32 length; + __le32 flags; + /* + * __le32 fs_count, hs_count, fs_count; must be included manually in + * the structure taking flags into consideration. + */ +} __attribute__((packed)); + /* Legacy format, deprecated as of 3.14. */ struct usb_functionfs_descs_head { __le32 magic; -- cgit v1.2.3 From 51c208c746e800dba37d1a54d3c5e601630266c4 Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Wed, 27 Aug 2014 22:58:46 +0200 Subject: tools: ffs-test: convert to new descriptor format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit [ac8dde11: “Add flags to descriptors block”] functionfs supports a new, more powerful and extensible, descriptor format. Since ffs-test is probably the first thing users of the functionfs interface see when they start writing functionfs user space daemons, convert it to use the new format thus promoting it. Signed-off-by: Michal Nazarewicz Signed-off-by: Felipe Balbi --- include/uapi/linux/usb/functionfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/uapi') diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h index 3ca03de7c2a8..6d2a16b834bf 100644 --- a/include/uapi/linux/usb/functionfs.h +++ b/include/uapi/linux/usb/functionfs.h @@ -102,7 +102,7 @@ struct usb_ext_prop_desc { * structure. Any flags that are not recognised cause the whole block to be * rejected with -ENOSYS. * - * Legacy descriptors format: + * Legacy descriptors format (deprecated as of 3.14): * * | off | name | type | description | * |-----+-----------+--------------+--------------------------------------| -- cgit v1.2.3 From c559a353410939c0884e83bdb0e2420a986ac53b Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Tue, 9 Sep 2014 08:23:16 +0200 Subject: usb: gadget: f_fs: add ioctl returning ep descriptor This patch introduces ioctl named FUNCTIONFS_ENDPOINT_DESC, which returns endpoint descriptor to userspace. It works only if function is active. Signed-off-by: Robert Baldyga Acked-by: Michal Nazarewicz Signed-off-by: Felipe Balbi --- include/uapi/linux/usb/functionfs.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/uapi') diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h index 6d2a16b834bf..7c7a2feb0e6e 100644 --- a/include/uapi/linux/usb/functionfs.h +++ b/include/uapi/linux/usb/functionfs.h @@ -275,6 +275,12 @@ struct usb_functionfs_event { */ #define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129) +/* + * Returns endpoint descriptor. If function is not active returns -ENODEV. + */ +#define FUNCTIONFS_ENDPOINT_DESC _IOR('g', 130, \ + struct usb_endpoint_descriptor) + #endif /* _UAPI__LINUX_FUNCTIONFS_H__ */ -- cgit v1.2.3 From 1b0bf88fd8b845aef4300c7c0feca774265dd1c4 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Tue, 9 Sep 2014 08:23:17 +0200 Subject: usb: gadget: f_fs: virtual endpoint address mapping This patch introduces virtual endpoint address mapping. It separates function logic form physical endpoint addresses making it more hardware independent. Following modifications changes user space API, so to enable them user have to switch on the FUNCTIONFS_VIRTUAL_ADDR flag in descriptors. Endpoints are now refered using virtual endpoint addresses chosen by user in endpoint descpriptors. This applies to each context when endpoint address can be used: - when accessing endpoint files in FunctionFS filesystemi (in file name), - in setup requests directed to specific endpoint (in wIndex field), - in descriptors returned by FUNCTIONFS_ENDPOINT_DESC ioctl. In endpoint file names the endpoint address number is formatted as double-digit hexadecimal value ("ep%02x") which has few advantages - it is easy to parse, allows to easly recognize endpoint direction basing on its name (IN endpoint number starts with digit 8, and OUT with 0) which can be useful for debugging purpose, and it makes easier to introduce further features allowing to use each endpoint number in both directions to have more endpoints available for function if hardware supports this (for example we could have ep01 which is endpoint 1 with OUT direction, and ep81 which is endpoint 1 with IN direction). Physical endpoint address can be still obtained using ioctl named FUNCTIONFS_ENDPOINT_REVMAP, but now it's not neccesary to handle USB transactions properly. Signed-off-by: Robert Baldyga Acked-by: Michal Nazarewicz Signed-off-by: Felipe Balbi --- include/uapi/linux/usb/functionfs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/uapi') diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h index 7c7a2feb0e6e..295ba299e7bd 100644 --- a/include/uapi/linux/usb/functionfs.h +++ b/include/uapi/linux/usb/functionfs.h @@ -19,6 +19,7 @@ enum functionfs_flags { FUNCTIONFS_HAS_HS_DESC = 2, FUNCTIONFS_HAS_SS_DESC = 4, FUNCTIONFS_HAS_MS_OS_DESC = 8, + FUNCTIONFS_VIRTUAL_ADDR = 16, }; /* Descriptor of an non-audio endpoint */ -- cgit v1.2.3