1 #ifndef _UAPI__LINUX_FUNCTIONFS_H__
2 #define _UAPI__LINUX_FUNCTIONFS_H__
5 #include <linux/types.h>
6 #include <linux/ioctl.h>
8 #include <linux/usb/ch9.h>
12 FUNCTIONFS_DESCRIPTORS_MAGIC = 1,
13 FUNCTIONFS_STRINGS_MAGIC = 2
19 /* Descriptor of an non-audio endpoint */
20 struct usb_endpoint_descriptor_no_audio {
24 __u8 bEndpointAddress;
26 __le16 wMaxPacketSize;
28 } __attribute__((packed));
30 /* Legacy format, deprecated as of 3.14. */
31 struct usb_functionfs_descs_head {
36 } __attribute__((packed, deprecated));
39 * All numbers must be in little endian order.
42 struct usb_functionfs_descs_head {
47 } __attribute__((packed));
52 * | off | name | type | description |
53 * |-----+-----------+--------------+--------------------------------------|
54 * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC |
55 * | 4 | length | LE32 | length of the whole data chunk |
56 * | 8 | fs_count | LE32 | number of full-speed descriptors |
57 * | 12 | hs_count | LE32 | number of high-speed descriptors |
58 * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors |
59 * | | hs_descrs | Descriptor[] | list of high-speed descriptors |
61 * descs are just valid USB descriptors and have the following format:
63 * | off | name | type | description |
64 * |-----+-----------------+------+--------------------------|
65 * | 0 | bLength | U8 | length of the descriptor |
66 * | 1 | bDescriptorType | U8 | descriptor type |
67 * | 2 | payload | | descriptor's payload |
70 struct usb_functionfs_strings_head {
75 } __attribute__((packed));
80 * | off | name | type | description |
81 * |-----+------------+-----------------------+----------------------------|
82 * | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC |
83 * | 4 | length | LE32 | length of the data chunk |
84 * | 8 | str_count | LE32 | number of strings |
85 * | 12 | lang_count | LE32 | number of languages |
86 * | 16 | stringtab | StringTab[lang_count] | table of strings per lang |
88 * For each language there is one stringtab entry (ie. there are lang_count
89 * stringtab entires). Each StringTab has following format:
91 * | off | name | type | description |
92 * |-----+---------+-------------------+------------------------------------|
93 * | 0 | lang | LE16 | language code |
94 * | 2 | strings | String[str_count] | array of strings in given language |
96 * For each string there is one strings entry (ie. there are str_count
97 * string entries). Each String is a NUL terminated string encoded in
105 * Events are delivered on the ep0 file descriptor, when the user mode driver
106 * reads from this file descriptor after writing the descriptors. Don't
107 * stop polling this descriptor.
110 enum usb_functionfs_event_type {
123 /* NOTE: this structure must stay the same size and layout on
124 * both 32-bit and 64-bit kernels.
126 struct usb_functionfs_event {
128 /* SETUP: packet; DATA phase i/o precedes next event
129 *(setup.bmRequestType & USB_DIR_IN) flags direction */
130 struct usb_ctrlrequest setup;
131 } __attribute__((packed)) u;
133 /* enum usb_functionfs_event_type */
136 } __attribute__((packed));
139 /* Endpoint ioctls */
140 /* The same as in gadgetfs */
142 /* IN transfers may be reported to the gadget driver as complete
143 * when the fifo is loaded, before the host reads the data;
144 * OUT transfers may be reported to the host's "client" driver as
145 * complete when they're sitting in the FIFO unread.
146 * THIS returns how many bytes are "unclaimed" in the endpoint fifo
147 * (needed for precise fault handling, when the hardware allows it)
149 #define FUNCTIONFS_FIFO_STATUS _IO('g', 1)
151 /* discards any unclaimed data in the fifo. */
152 #define FUNCTIONFS_FIFO_FLUSH _IO('g', 2)
154 /* resets endpoint halt+toggle; used to implement set_interface.
155 * some hardware (like pxa2xx) can't support this.
157 #define FUNCTIONFS_CLEAR_HALT _IO('g', 3)
159 /* Specific for functionfs */
162 * Returns reverse mapping of an interface. Called on EP0. If there
163 * is no such interface returns -EDOM. If function is not active
166 #define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128)
169 * Returns real bEndpointAddress of an endpoint. If function is not
170 * active returns -ENODEV.
172 #define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129)
176 #endif /* _UAPI__LINUX_FUNCTIONFS_H__ */