xref: /linux/Documentation/usb/gadget-testing.rst (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
1ecefae6dSMauro Carvalho Chehab==============
2ecefae6dSMauro Carvalho ChehabGadget Testing
3ecefae6dSMauro Carvalho Chehab==============
4ecefae6dSMauro Carvalho Chehab
5ecefae6dSMauro Carvalho ChehabThis file summarizes information on basic testing of USB functions
6ecefae6dSMauro Carvalho Chehabprovided by gadgets.
7ecefae6dSMauro Carvalho Chehab
8ecefae6dSMauro Carvalho Chehab.. contents
9ecefae6dSMauro Carvalho Chehab
10ecefae6dSMauro Carvalho Chehab   1. ACM function
11ecefae6dSMauro Carvalho Chehab   2. ECM function
12ecefae6dSMauro Carvalho Chehab   3. ECM subset function
13ecefae6dSMauro Carvalho Chehab   4. EEM function
14ecefae6dSMauro Carvalho Chehab   5. FFS function
15ecefae6dSMauro Carvalho Chehab   6. HID function
16ecefae6dSMauro Carvalho Chehab   7. LOOPBACK function
17ecefae6dSMauro Carvalho Chehab   8. MASS STORAGE function
18ecefae6dSMauro Carvalho Chehab   9. MIDI function
19ecefae6dSMauro Carvalho Chehab   10. NCM function
20ecefae6dSMauro Carvalho Chehab   11. OBEX function
21ecefae6dSMauro Carvalho Chehab   12. PHONET function
22ecefae6dSMauro Carvalho Chehab   13. RNDIS function
23ecefae6dSMauro Carvalho Chehab   14. SERIAL function
24ecefae6dSMauro Carvalho Chehab   15. SOURCESINK function
25ecefae6dSMauro Carvalho Chehab   16. UAC1 function (legacy implementation)
26ecefae6dSMauro Carvalho Chehab   17. UAC2 function
27ecefae6dSMauro Carvalho Chehab   18. UVC function
28ecefae6dSMauro Carvalho Chehab   19. PRINTER function
29ecefae6dSMauro Carvalho Chehab   20. UAC1 function (new API)
308559caa9STakashi Iwai   21. MIDI2 function
31ecefae6dSMauro Carvalho Chehab
32ecefae6dSMauro Carvalho Chehab
33ecefae6dSMauro Carvalho Chehab1. ACM function
34ecefae6dSMauro Carvalho Chehab===============
35ecefae6dSMauro Carvalho Chehab
36ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_acm.ko module.
37ecefae6dSMauro Carvalho Chehab
38ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
39ecefae6dSMauro Carvalho Chehab------------------------------------
40ecefae6dSMauro Carvalho Chehab
41ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "acm".
42ecefae6dSMauro Carvalho ChehabThe ACM function provides just one attribute in its function directory:
43ecefae6dSMauro Carvalho Chehab
44ecefae6dSMauro Carvalho Chehab	port_num
45ecefae6dSMauro Carvalho Chehab
46ecefae6dSMauro Carvalho ChehabThe attribute is read-only.
47ecefae6dSMauro Carvalho Chehab
48ecefae6dSMauro Carvalho ChehabThere can be at most 4 ACM/generic serial/OBEX ports in the system.
49ecefae6dSMauro Carvalho Chehab
50ecefae6dSMauro Carvalho Chehab
51ecefae6dSMauro Carvalho ChehabTesting the ACM function
52ecefae6dSMauro Carvalho Chehab------------------------
53ecefae6dSMauro Carvalho Chehab
54ecefae6dSMauro Carvalho ChehabOn the host::
55ecefae6dSMauro Carvalho Chehab
56ecefae6dSMauro Carvalho Chehab	cat > /dev/ttyACM<X>
57ecefae6dSMauro Carvalho Chehab
58ecefae6dSMauro Carvalho ChehabOn the device::
59ecefae6dSMauro Carvalho Chehab
60ecefae6dSMauro Carvalho Chehab	cat /dev/ttyGS<Y>
61ecefae6dSMauro Carvalho Chehab
62ecefae6dSMauro Carvalho Chehabthen the other way round
63ecefae6dSMauro Carvalho Chehab
64ecefae6dSMauro Carvalho ChehabOn the device::
65ecefae6dSMauro Carvalho Chehab
66ecefae6dSMauro Carvalho Chehab	cat > /dev/ttyGS<Y>
67ecefae6dSMauro Carvalho Chehab
68ecefae6dSMauro Carvalho ChehabOn the host::
69ecefae6dSMauro Carvalho Chehab
70ecefae6dSMauro Carvalho Chehab	cat /dev/ttyACM<X>
71ecefae6dSMauro Carvalho Chehab
72ecefae6dSMauro Carvalho Chehab2. ECM function
73ecefae6dSMauro Carvalho Chehab===============
74ecefae6dSMauro Carvalho Chehab
75ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_ecm.ko module.
76ecefae6dSMauro Carvalho Chehab
77ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
78ecefae6dSMauro Carvalho Chehab------------------------------------
79ecefae6dSMauro Carvalho Chehab
80ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "ecm".
81ecefae6dSMauro Carvalho ChehabThe ECM function provides these attributes in its function directory:
82ecefae6dSMauro Carvalho Chehab
83ecefae6dSMauro Carvalho Chehab	=============== ==================================================
84ecefae6dSMauro Carvalho Chehab	ifname		network device interface name associated with this
85ecefae6dSMauro Carvalho Chehab			function instance
86ecefae6dSMauro Carvalho Chehab	qmult		queue length multiplier for high and super speed
87ecefae6dSMauro Carvalho Chehab	host_addr	MAC address of host's end of this
88ecefae6dSMauro Carvalho Chehab			Ethernet over USB link
89ecefae6dSMauro Carvalho Chehab	dev_addr	MAC address of device's end of this
90ecefae6dSMauro Carvalho Chehab			Ethernet over USB link
91ecefae6dSMauro Carvalho Chehab	=============== ==================================================
92ecefae6dSMauro Carvalho Chehab
93ecefae6dSMauro Carvalho Chehaband after creating the functions/ecm.<instance name> they contain default
94ecefae6dSMauro Carvalho Chehabvalues: qmult is 5, dev_addr and host_addr are randomly selected.
9563d15214SLorenzo ColittiThe ifname can be written to if the function is not bound. A write must be an
9663d15214SLorenzo Colittiinterface pattern such as "usb%d", which will cause the net core to choose the
9763d15214SLorenzo Colittinext free usbX interface. By default, it is set to "usb%d".
98ecefae6dSMauro Carvalho Chehab
99ecefae6dSMauro Carvalho ChehabTesting the ECM function
100ecefae6dSMauro Carvalho Chehab------------------------
101ecefae6dSMauro Carvalho Chehab
102ecefae6dSMauro Carvalho ChehabConfigure IP addresses of the device and the host. Then:
103ecefae6dSMauro Carvalho Chehab
104ecefae6dSMauro Carvalho ChehabOn the device::
105ecefae6dSMauro Carvalho Chehab
106ecefae6dSMauro Carvalho Chehab	ping <host's IP>
107ecefae6dSMauro Carvalho Chehab
108ecefae6dSMauro Carvalho ChehabOn the host::
109ecefae6dSMauro Carvalho Chehab
110ecefae6dSMauro Carvalho Chehab	ping <device's IP>
111ecefae6dSMauro Carvalho Chehab
112ecefae6dSMauro Carvalho Chehab3. ECM subset function
113ecefae6dSMauro Carvalho Chehab======================
114ecefae6dSMauro Carvalho Chehab
115ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_ecm_subset.ko module.
116ecefae6dSMauro Carvalho Chehab
117ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
118ecefae6dSMauro Carvalho Chehab------------------------------------
119ecefae6dSMauro Carvalho Chehab
120ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "geth".
121ecefae6dSMauro Carvalho ChehabThe ECM subset function provides these attributes in its function directory:
122ecefae6dSMauro Carvalho Chehab
123ecefae6dSMauro Carvalho Chehab	=============== ==================================================
124ecefae6dSMauro Carvalho Chehab	ifname		network device interface name associated with this
125ecefae6dSMauro Carvalho Chehab			function instance
126ecefae6dSMauro Carvalho Chehab	qmult		queue length multiplier for high and super speed
127ecefae6dSMauro Carvalho Chehab	host_addr	MAC address of host's end of this
128ecefae6dSMauro Carvalho Chehab			Ethernet over USB link
129ecefae6dSMauro Carvalho Chehab	dev_addr	MAC address of device's end of this
130ecefae6dSMauro Carvalho Chehab			Ethernet over USB link
131ecefae6dSMauro Carvalho Chehab	=============== ==================================================
132ecefae6dSMauro Carvalho Chehab
133ecefae6dSMauro Carvalho Chehaband after creating the functions/ecm.<instance name> they contain default
134ecefae6dSMauro Carvalho Chehabvalues: qmult is 5, dev_addr and host_addr are randomly selected.
13563d15214SLorenzo ColittiThe ifname can be written to if the function is not bound. A write must be an
13663d15214SLorenzo Colittiinterface pattern such as "usb%d", which will cause the net core to choose the
13763d15214SLorenzo Colittinext free usbX interface. By default, it is set to "usb%d".
138ecefae6dSMauro Carvalho Chehab
139ecefae6dSMauro Carvalho ChehabTesting the ECM subset function
140ecefae6dSMauro Carvalho Chehab-------------------------------
141ecefae6dSMauro Carvalho Chehab
142ecefae6dSMauro Carvalho ChehabConfigure IP addresses of the device and the host. Then:
143ecefae6dSMauro Carvalho Chehab
144ecefae6dSMauro Carvalho ChehabOn the device::
145ecefae6dSMauro Carvalho Chehab
146ecefae6dSMauro Carvalho Chehab	ping <host's IP>
147ecefae6dSMauro Carvalho Chehab
148ecefae6dSMauro Carvalho ChehabOn the host::
149ecefae6dSMauro Carvalho Chehab
150ecefae6dSMauro Carvalho Chehab	ping <device's IP>
151ecefae6dSMauro Carvalho Chehab
152ecefae6dSMauro Carvalho Chehab4. EEM function
153ecefae6dSMauro Carvalho Chehab===============
154ecefae6dSMauro Carvalho Chehab
155ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_eem.ko module.
156ecefae6dSMauro Carvalho Chehab
157ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
158ecefae6dSMauro Carvalho Chehab------------------------------------
159ecefae6dSMauro Carvalho Chehab
160ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "eem".
161ecefae6dSMauro Carvalho ChehabThe EEM function provides these attributes in its function directory:
162ecefae6dSMauro Carvalho Chehab
163ecefae6dSMauro Carvalho Chehab	=============== ==================================================
164ecefae6dSMauro Carvalho Chehab	ifname		network device interface name associated with this
165ecefae6dSMauro Carvalho Chehab			function instance
166ecefae6dSMauro Carvalho Chehab	qmult		queue length multiplier for high and super speed
167ecefae6dSMauro Carvalho Chehab	host_addr	MAC address of host's end of this
168ecefae6dSMauro Carvalho Chehab			Ethernet over USB link
169ecefae6dSMauro Carvalho Chehab	dev_addr	MAC address of device's end of this
170ecefae6dSMauro Carvalho Chehab			Ethernet over USB link
171ecefae6dSMauro Carvalho Chehab	=============== ==================================================
172ecefae6dSMauro Carvalho Chehab
173ecefae6dSMauro Carvalho Chehaband after creating the functions/eem.<instance name> they contain default
174ecefae6dSMauro Carvalho Chehabvalues: qmult is 5, dev_addr and host_addr are randomly selected.
17563d15214SLorenzo ColittiThe ifname can be written to if the function is not bound. A write must be an
17663d15214SLorenzo Colittiinterface pattern such as "usb%d", which will cause the net core to choose the
17763d15214SLorenzo Colittinext free usbX interface. By default, it is set to "usb%d".
178ecefae6dSMauro Carvalho Chehab
179ecefae6dSMauro Carvalho ChehabTesting the EEM function
180ecefae6dSMauro Carvalho Chehab------------------------
181ecefae6dSMauro Carvalho Chehab
182ecefae6dSMauro Carvalho ChehabConfigure IP addresses of the device and the host. Then:
183ecefae6dSMauro Carvalho Chehab
184ecefae6dSMauro Carvalho ChehabOn the device::
185ecefae6dSMauro Carvalho Chehab
186ecefae6dSMauro Carvalho Chehab	ping <host's IP>
187ecefae6dSMauro Carvalho Chehab
188ecefae6dSMauro Carvalho ChehabOn the host::
189ecefae6dSMauro Carvalho Chehab
190ecefae6dSMauro Carvalho Chehab	ping <device's IP>
191ecefae6dSMauro Carvalho Chehab
192ecefae6dSMauro Carvalho Chehab5. FFS function
193ecefae6dSMauro Carvalho Chehab===============
194ecefae6dSMauro Carvalho Chehab
195ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_fs.ko module.
196ecefae6dSMauro Carvalho Chehab
197ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
198ecefae6dSMauro Carvalho Chehab------------------------------------
199ecefae6dSMauro Carvalho Chehab
200ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "ffs".
201ecefae6dSMauro Carvalho ChehabThe function directory is intentionally empty and not modifiable.
202ecefae6dSMauro Carvalho Chehab
203ecefae6dSMauro Carvalho ChehabAfter creating the directory there is a new instance (a "device") of FunctionFS
204ecefae6dSMauro Carvalho Chehabavailable in the system. Once a "device" is available, the user should follow
205ecefae6dSMauro Carvalho Chehabthe standard procedure for using FunctionFS (mount it, run the userspace
206ecefae6dSMauro Carvalho Chehabprocess which implements the function proper). The gadget should be enabled
207ecefae6dSMauro Carvalho Chehabby writing a suitable string to usb_gadget/<gadget>/UDC.
208ecefae6dSMauro Carvalho Chehab
209*43a02972SPeter KorsgaardThe FFS function provides just one attribute in its function directory:
210*43a02972SPeter Korsgaard
211*43a02972SPeter Korsgaard	ready
212*43a02972SPeter Korsgaard
213*43a02972SPeter KorsgaardThe attribute is read-only and signals if the function is ready (1) to be
214*43a02972SPeter Korsgaardused, E.G. if userspace has written descriptors and strings to ep0, so
215*43a02972SPeter Korsgaardthe gadget can be enabled.
216*43a02972SPeter Korsgaard
217ecefae6dSMauro Carvalho ChehabTesting the FFS function
218ecefae6dSMauro Carvalho Chehab------------------------
219ecefae6dSMauro Carvalho Chehab
220ecefae6dSMauro Carvalho ChehabOn the device: start the function's userspace daemon, enable the gadget
221ecefae6dSMauro Carvalho Chehab
222ecefae6dSMauro Carvalho ChehabOn the host: use the USB function provided by the device
223ecefae6dSMauro Carvalho Chehab
224ecefae6dSMauro Carvalho Chehab6. HID function
225ecefae6dSMauro Carvalho Chehab===============
226ecefae6dSMauro Carvalho Chehab
227ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_hid.ko module.
228ecefae6dSMauro Carvalho Chehab
229ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
230ecefae6dSMauro Carvalho Chehab------------------------------------
231ecefae6dSMauro Carvalho Chehab
232ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "hid".
233ecefae6dSMauro Carvalho ChehabThe HID function provides these attributes in its function directory:
234ecefae6dSMauro Carvalho Chehab
235ecefae6dSMauro Carvalho Chehab	=============== ===========================================
236ecefae6dSMauro Carvalho Chehab	protocol	HID protocol to use
237ecefae6dSMauro Carvalho Chehab	report_desc	data to be used in HID reports, except data
238ecefae6dSMauro Carvalho Chehab			passed with /dev/hidg<X>
239ecefae6dSMauro Carvalho Chehab	report_length	HID report length
240ecefae6dSMauro Carvalho Chehab	subclass	HID subclass to use
241ecefae6dSMauro Carvalho Chehab	=============== ===========================================
242ecefae6dSMauro Carvalho Chehab
243ecefae6dSMauro Carvalho ChehabFor a keyboard the protocol and the subclass are 1, the report_length is 8,
244ecefae6dSMauro Carvalho Chehabwhile the report_desc is::
245ecefae6dSMauro Carvalho Chehab
246ecefae6dSMauro Carvalho Chehab  $ hd my_report_desc
247ecefae6dSMauro Carvalho Chehab  00000000  05 01 09 06 a1 01 05 07  19 e0 29 e7 15 00 25 01  |..........)...%.|
248ecefae6dSMauro Carvalho Chehab  00000010  75 01 95 08 81 02 95 01  75 08 81 03 95 05 75 01  |u.......u.....u.|
249ecefae6dSMauro Carvalho Chehab  00000020  05 08 19 01 29 05 91 02  95 01 75 03 91 03 95 06  |....).....u.....|
250ecefae6dSMauro Carvalho Chehab  00000030  75 08 15 00 25 65 05 07  19 00 29 65 81 00 c0     |u...%e....)e...|
251ecefae6dSMauro Carvalho Chehab  0000003f
252ecefae6dSMauro Carvalho Chehab
253ecefae6dSMauro Carvalho ChehabSuch a sequence of bytes can be stored to the attribute with echo::
254ecefae6dSMauro Carvalho Chehab
255ecefae6dSMauro Carvalho Chehab  $ echo -ne \\x05\\x01\\x09\\x06\\xa1.....
256ecefae6dSMauro Carvalho Chehab
257ecefae6dSMauro Carvalho ChehabTesting the HID function
258ecefae6dSMauro Carvalho Chehab------------------------
259ecefae6dSMauro Carvalho Chehab
260ecefae6dSMauro Carvalho ChehabDevice:
261ecefae6dSMauro Carvalho Chehab
262ecefae6dSMauro Carvalho Chehab- create the gadget
263ecefae6dSMauro Carvalho Chehab- connect the gadget to a host, preferably not the one used
264ecefae6dSMauro Carvalho Chehab  to control the gadget
265ecefae6dSMauro Carvalho Chehab- run a program which writes to /dev/hidg<N>, e.g.
266ecefae6dSMauro Carvalho Chehab  a userspace program found in Documentation/usb/gadget_hid.rst::
267ecefae6dSMauro Carvalho Chehab
268ecefae6dSMauro Carvalho Chehab	$ ./hid_gadget_test /dev/hidg0 keyboard
269ecefae6dSMauro Carvalho Chehab
270ecefae6dSMauro Carvalho ChehabHost:
271ecefae6dSMauro Carvalho Chehab
272ecefae6dSMauro Carvalho Chehab- observe the keystrokes from the gadget
273ecefae6dSMauro Carvalho Chehab
274ecefae6dSMauro Carvalho Chehab7. LOOPBACK function
275ecefae6dSMauro Carvalho Chehab====================
276ecefae6dSMauro Carvalho Chehab
277ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_ss_lb.ko module.
278ecefae6dSMauro Carvalho Chehab
279ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
280ecefae6dSMauro Carvalho Chehab------------------------------------
281ecefae6dSMauro Carvalho Chehab
282ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "Loopback".
283ecefae6dSMauro Carvalho ChehabThe LOOPBACK function provides these attributes in its function directory:
284ecefae6dSMauro Carvalho Chehab
285ecefae6dSMauro Carvalho Chehab	=============== =======================
286ecefae6dSMauro Carvalho Chehab	qlen		depth of loopback queue
287ecefae6dSMauro Carvalho Chehab	bulk_buflen	buffer length
288ecefae6dSMauro Carvalho Chehab	=============== =======================
289ecefae6dSMauro Carvalho Chehab
290ecefae6dSMauro Carvalho ChehabTesting the LOOPBACK function
291ecefae6dSMauro Carvalho Chehab-----------------------------
292ecefae6dSMauro Carvalho Chehab
293ecefae6dSMauro Carvalho Chehabdevice: run the gadget
294ecefae6dSMauro Carvalho Chehab
295ecefae6dSMauro Carvalho Chehabhost: test-usb (tools/usb/testusb.c)
296ecefae6dSMauro Carvalho Chehab
297ecefae6dSMauro Carvalho Chehab8. MASS STORAGE function
298ecefae6dSMauro Carvalho Chehab========================
299ecefae6dSMauro Carvalho Chehab
300ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_mass_storage.ko module.
301ecefae6dSMauro Carvalho Chehab
302ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
303ecefae6dSMauro Carvalho Chehab------------------------------------
304ecefae6dSMauro Carvalho Chehab
305ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "mass_storage".
306ecefae6dSMauro Carvalho ChehabThe MASS STORAGE function provides these attributes in its directory:
307ecefae6dSMauro Carvalho Chehabfiles:
308ecefae6dSMauro Carvalho Chehab
309ecefae6dSMauro Carvalho Chehab	=============== ==============================================
310ecefae6dSMauro Carvalho Chehab	stall		Set to permit function to halt bulk endpoints.
311ecefae6dSMauro Carvalho Chehab			Disabled on some USB devices known not to work
312ecefae6dSMauro Carvalho Chehab			correctly. You should set it to true.
313ecefae6dSMauro Carvalho Chehab	num_buffers	Number of pipeline buffers. Valid numbers
314ecefae6dSMauro Carvalho Chehab			are 2..4. Available only if
315ecefae6dSMauro Carvalho Chehab			CONFIG_USB_GADGET_DEBUG_FILES is set.
316ecefae6dSMauro Carvalho Chehab	=============== ==============================================
317ecefae6dSMauro Carvalho Chehab
318ecefae6dSMauro Carvalho Chehaband a default lun.0 directory corresponding to SCSI LUN #0.
319ecefae6dSMauro Carvalho Chehab
320ecefae6dSMauro Carvalho ChehabA new lun can be added with mkdir::
321ecefae6dSMauro Carvalho Chehab
322ecefae6dSMauro Carvalho Chehab	$ mkdir functions/mass_storage.0/partition.5
323ecefae6dSMauro Carvalho Chehab
324ecefae6dSMauro Carvalho ChehabLun numbering does not have to be continuous, except for lun #0 which is
325ecefae6dSMauro Carvalho Chehabcreated by default. A maximum of 8 luns can be specified and they all must be
326ecefae6dSMauro Carvalho Chehabnamed following the <name>.<number> scheme. The numbers can be 0..8.
327ecefae6dSMauro Carvalho ChehabProbably a good convention is to name the luns "lun.<number>",
328ecefae6dSMauro Carvalho Chehabalthough it is not mandatory.
329ecefae6dSMauro Carvalho Chehab
330ecefae6dSMauro Carvalho ChehabIn each lun directory there are the following attribute files:
331ecefae6dSMauro Carvalho Chehab
332ecefae6dSMauro Carvalho Chehab	=============== ==============================================
333ecefae6dSMauro Carvalho Chehab	file		The path to the backing file for the LUN.
334ecefae6dSMauro Carvalho Chehab			Required if LUN is not marked as removable.
335ecefae6dSMauro Carvalho Chehab	ro		Flag specifying access to the LUN shall be
336ecefae6dSMauro Carvalho Chehab			read-only. This is implied if CD-ROM emulation
337ecefae6dSMauro Carvalho Chehab			is enabled as well as when it was impossible
338ecefae6dSMauro Carvalho Chehab			to open "filename" in R/W mode.
339ecefae6dSMauro Carvalho Chehab	removable	Flag specifying that LUN shall be indicated as
340ecefae6dSMauro Carvalho Chehab			being removable.
341ecefae6dSMauro Carvalho Chehab	cdrom		Flag specifying that LUN shall be reported as
342ecefae6dSMauro Carvalho Chehab			being a CD-ROM.
343ecefae6dSMauro Carvalho Chehab	nofua		Flag specifying that FUA flag
344ecefae6dSMauro Carvalho Chehab			in SCSI WRITE(10,12)
345421c8d9aSMaxim Devaev	forced_eject	This write-only file is useful only when
346421c8d9aSMaxim Devaev			the function is active. It causes the backing
347421c8d9aSMaxim Devaev			file to be forcibly detached from the LUN,
348421c8d9aSMaxim Devaev			regardless of whether the host has allowed it.
349421c8d9aSMaxim Devaev			Any non-zero number of bytes written will
350421c8d9aSMaxim Devaev			result in ejection.
351ecefae6dSMauro Carvalho Chehab	=============== ==============================================
352ecefae6dSMauro Carvalho Chehab
353ecefae6dSMauro Carvalho ChehabTesting the MASS STORAGE function
354ecefae6dSMauro Carvalho Chehab---------------------------------
355ecefae6dSMauro Carvalho Chehab
356ecefae6dSMauro Carvalho Chehabdevice: connect the gadget, enable it
357ecefae6dSMauro Carvalho Chehabhost: dmesg, see the USB drives appear (if system configured to automatically
358ecefae6dSMauro Carvalho Chehabmount)
359ecefae6dSMauro Carvalho Chehab
360ecefae6dSMauro Carvalho Chehab9. MIDI function
361ecefae6dSMauro Carvalho Chehab================
362ecefae6dSMauro Carvalho Chehab
363ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_midi.ko module.
364ecefae6dSMauro Carvalho Chehab
365ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
366ecefae6dSMauro Carvalho Chehab------------------------------------
367ecefae6dSMauro Carvalho Chehab
368ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "midi".
369ecefae6dSMauro Carvalho ChehabThe MIDI function provides these attributes in its function directory:
370ecefae6dSMauro Carvalho Chehab
371ecefae6dSMauro Carvalho Chehab	=============== ====================================
372ecefae6dSMauro Carvalho Chehab	buflen		MIDI buffer length
373ecefae6dSMauro Carvalho Chehab	id		ID string for the USB MIDI adapter
374ecefae6dSMauro Carvalho Chehab	in_ports	number of MIDI input ports
375ecefae6dSMauro Carvalho Chehab	index		index value for the USB MIDI adapter
376ecefae6dSMauro Carvalho Chehab	out_ports	number of MIDI output ports
377ecefae6dSMauro Carvalho Chehab	qlen		USB read request queue length
378ecefae6dSMauro Carvalho Chehab	=============== ====================================
379ecefae6dSMauro Carvalho Chehab
380ecefae6dSMauro Carvalho ChehabTesting the MIDI function
381ecefae6dSMauro Carvalho Chehab-------------------------
382ecefae6dSMauro Carvalho Chehab
383ecefae6dSMauro Carvalho ChehabThere are two cases: playing a mid from the gadget to
384ecefae6dSMauro Carvalho Chehabthe host and playing a mid from the host to the gadget.
385ecefae6dSMauro Carvalho Chehab
386ecefae6dSMauro Carvalho Chehab1) Playing a mid from the gadget to the host:
387ecefae6dSMauro Carvalho Chehab
388ecefae6dSMauro Carvalho Chehabhost::
389ecefae6dSMauro Carvalho Chehab
390ecefae6dSMauro Carvalho Chehab  $ arecordmidi -l
391ecefae6dSMauro Carvalho Chehab   Port    Client name                      Port name
392ecefae6dSMauro Carvalho Chehab   14:0    Midi Through                     Midi Through Port-0
393ecefae6dSMauro Carvalho Chehab   24:0    MIDI Gadget                      MIDI Gadget MIDI 1
394ecefae6dSMauro Carvalho Chehab  $ arecordmidi -p 24:0 from_gadget.mid
395ecefae6dSMauro Carvalho Chehab
396ecefae6dSMauro Carvalho Chehabgadget::
397ecefae6dSMauro Carvalho Chehab
398ecefae6dSMauro Carvalho Chehab  $ aplaymidi -l
399ecefae6dSMauro Carvalho Chehab   Port    Client name                      Port name
400ecefae6dSMauro Carvalho Chehab   20:0    f_midi                           f_midi
401ecefae6dSMauro Carvalho Chehab
402ecefae6dSMauro Carvalho Chehab  $ aplaymidi -p 20:0 to_host.mid
403ecefae6dSMauro Carvalho Chehab
404ecefae6dSMauro Carvalho Chehab2) Playing a mid from the host to the gadget
405ecefae6dSMauro Carvalho Chehab
406ecefae6dSMauro Carvalho Chehabgadget::
407ecefae6dSMauro Carvalho Chehab
408ecefae6dSMauro Carvalho Chehab  $ arecordmidi -l
409ecefae6dSMauro Carvalho Chehab   Port    Client name                      Port name
410ecefae6dSMauro Carvalho Chehab   20:0    f_midi                           f_midi
411ecefae6dSMauro Carvalho Chehab
412ecefae6dSMauro Carvalho Chehab  $ arecordmidi -p 20:0 from_host.mid
413ecefae6dSMauro Carvalho Chehab
414ecefae6dSMauro Carvalho Chehabhost::
415ecefae6dSMauro Carvalho Chehab
416ecefae6dSMauro Carvalho Chehab  $ aplaymidi -l
417ecefae6dSMauro Carvalho Chehab   Port    Client name                      Port name
418ecefae6dSMauro Carvalho Chehab   14:0    Midi Through                     Midi Through Port-0
419ecefae6dSMauro Carvalho Chehab   24:0    MIDI Gadget                      MIDI Gadget MIDI 1
420ecefae6dSMauro Carvalho Chehab
421ecefae6dSMauro Carvalho Chehab  $ aplaymidi -p24:0 to_gadget.mid
422ecefae6dSMauro Carvalho Chehab
423ecefae6dSMauro Carvalho ChehabThe from_gadget.mid should sound identical to the to_host.mid.
424ecefae6dSMauro Carvalho Chehab
425ecefae6dSMauro Carvalho ChehabThe from_host.id should sound identical to the to_gadget.mid.
426ecefae6dSMauro Carvalho Chehab
427ecefae6dSMauro Carvalho ChehabMIDI files can be played to speakers/headphones with e.g. timidity installed::
428ecefae6dSMauro Carvalho Chehab
429ecefae6dSMauro Carvalho Chehab  $ aplaymidi -l
430ecefae6dSMauro Carvalho Chehab   Port    Client name                      Port name
431ecefae6dSMauro Carvalho Chehab   14:0    Midi Through                     Midi Through Port-0
432ecefae6dSMauro Carvalho Chehab   24:0    MIDI Gadget                      MIDI Gadget MIDI 1
433ecefae6dSMauro Carvalho Chehab  128:0    TiMidity                         TiMidity port 0
434ecefae6dSMauro Carvalho Chehab  128:1    TiMidity                         TiMidity port 1
435ecefae6dSMauro Carvalho Chehab  128:2    TiMidity                         TiMidity port 2
436ecefae6dSMauro Carvalho Chehab  128:3    TiMidity                         TiMidity port 3
437ecefae6dSMauro Carvalho Chehab
438ecefae6dSMauro Carvalho Chehab  $ aplaymidi -p 128:0 file.mid
439ecefae6dSMauro Carvalho Chehab
440ecefae6dSMauro Carvalho ChehabMIDI ports can be logically connected using the aconnect utility, e.g.::
441ecefae6dSMauro Carvalho Chehab
442ecefae6dSMauro Carvalho Chehab  $ aconnect 24:0 128:0 # try it on the host
443ecefae6dSMauro Carvalho Chehab
444ecefae6dSMauro Carvalho ChehabAfter the gadget's MIDI port is connected to timidity's MIDI port,
445ecefae6dSMauro Carvalho Chehabwhatever is played at the gadget side with aplaymidi -l is audible
446ecefae6dSMauro Carvalho Chehabin host's speakers/headphones.
447ecefae6dSMauro Carvalho Chehab
448ecefae6dSMauro Carvalho Chehab10. NCM function
449ecefae6dSMauro Carvalho Chehab================
450ecefae6dSMauro Carvalho Chehab
451ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_ncm.ko module.
452ecefae6dSMauro Carvalho Chehab
453ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
454ecefae6dSMauro Carvalho Chehab------------------------------------
455ecefae6dSMauro Carvalho Chehab
456ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "ncm".
457ecefae6dSMauro Carvalho ChehabThe NCM function provides these attributes in its function directory:
458ecefae6dSMauro Carvalho Chehab
45920d03ae3SUdipto Goswami	======================= ==================================================
460ecefae6dSMauro Carvalho Chehab	ifname			network device interface name associated with this
461ecefae6dSMauro Carvalho Chehab				function instance
462ecefae6dSMauro Carvalho Chehab	qmult			queue length multiplier for high and super speed
463ecefae6dSMauro Carvalho Chehab	host_addr		MAC address of host's end of this
464ecefae6dSMauro Carvalho Chehab				Ethernet over USB link
465ecefae6dSMauro Carvalho Chehab	dev_addr		MAC address of device's end of this
466ecefae6dSMauro Carvalho Chehab				Ethernet over USB link
4671900daeeSKrishna Kurapati	max_segment_size	Segment size required for P2P connections. This
46820d03ae3SUdipto Goswami				will set MTU to 14 bytes
46920d03ae3SUdipto Goswami	======================= ==================================================
470ecefae6dSMauro Carvalho Chehab
471ecefae6dSMauro Carvalho Chehaband after creating the functions/ncm.<instance name> they contain default
472ecefae6dSMauro Carvalho Chehabvalues: qmult is 5, dev_addr and host_addr are randomly selected.
47363d15214SLorenzo ColittiThe ifname can be written to if the function is not bound. A write must be an
47463d15214SLorenzo Colittiinterface pattern such as "usb%d", which will cause the net core to choose the
47563d15214SLorenzo Colittinext free usbX interface. By default, it is set to "usb%d".
476ecefae6dSMauro Carvalho Chehab
477ecefae6dSMauro Carvalho ChehabTesting the NCM function
478ecefae6dSMauro Carvalho Chehab------------------------
479ecefae6dSMauro Carvalho Chehab
480ecefae6dSMauro Carvalho ChehabConfigure IP addresses of the device and the host. Then:
481ecefae6dSMauro Carvalho Chehab
482ecefae6dSMauro Carvalho ChehabOn the device::
483ecefae6dSMauro Carvalho Chehab
484ecefae6dSMauro Carvalho Chehab	ping <host's IP>
485ecefae6dSMauro Carvalho Chehab
486ecefae6dSMauro Carvalho ChehabOn the host::
487ecefae6dSMauro Carvalho Chehab
488ecefae6dSMauro Carvalho Chehab	ping <device's IP>
489ecefae6dSMauro Carvalho Chehab
490ecefae6dSMauro Carvalho Chehab11. OBEX function
491ecefae6dSMauro Carvalho Chehab=================
492ecefae6dSMauro Carvalho Chehab
493ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_obex.ko module.
494ecefae6dSMauro Carvalho Chehab
495ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
496ecefae6dSMauro Carvalho Chehab------------------------------------
497ecefae6dSMauro Carvalho Chehab
498ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "obex".
499ecefae6dSMauro Carvalho ChehabThe OBEX function provides just one attribute in its function directory:
500ecefae6dSMauro Carvalho Chehab
501ecefae6dSMauro Carvalho Chehab	port_num
502ecefae6dSMauro Carvalho Chehab
503ecefae6dSMauro Carvalho ChehabThe attribute is read-only.
504ecefae6dSMauro Carvalho Chehab
505ecefae6dSMauro Carvalho ChehabThere can be at most 4 ACM/generic serial/OBEX ports in the system.
506ecefae6dSMauro Carvalho Chehab
507ecefae6dSMauro Carvalho ChehabTesting the OBEX function
508ecefae6dSMauro Carvalho Chehab-------------------------
509ecefae6dSMauro Carvalho Chehab
510ecefae6dSMauro Carvalho ChehabOn device::
511ecefae6dSMauro Carvalho Chehab
512ecefae6dSMauro Carvalho Chehab	seriald -f /dev/ttyGS<Y> -s 1024
513ecefae6dSMauro Carvalho Chehab
514ecefae6dSMauro Carvalho ChehabOn host::
515ecefae6dSMauro Carvalho Chehab
516ecefae6dSMauro Carvalho Chehab	serialc -v <vendorID> -p <productID> -i<interface#> -a1 -s1024 \
517ecefae6dSMauro Carvalho Chehab                -t<out endpoint addr> -r<in endpoint addr>
518ecefae6dSMauro Carvalho Chehab
519ecefae6dSMauro Carvalho Chehabwhere seriald and serialc are Felipe's utilities found here:
520ecefae6dSMauro Carvalho Chehab
521ecefae6dSMauro Carvalho Chehab	https://github.com/felipebalbi/usb-tools.git master
522ecefae6dSMauro Carvalho Chehab
523ecefae6dSMauro Carvalho Chehab12. PHONET function
524ecefae6dSMauro Carvalho Chehab===================
525ecefae6dSMauro Carvalho Chehab
526ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_phonet.ko module.
527ecefae6dSMauro Carvalho Chehab
528ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
529ecefae6dSMauro Carvalho Chehab------------------------------------
530ecefae6dSMauro Carvalho Chehab
531ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "phonet".
532ecefae6dSMauro Carvalho ChehabThe PHONET function provides just one attribute in its function directory:
533ecefae6dSMauro Carvalho Chehab
534ecefae6dSMauro Carvalho Chehab	=============== ==================================================
535ecefae6dSMauro Carvalho Chehab	ifname		network device interface name associated with this
536ecefae6dSMauro Carvalho Chehab			function instance
537ecefae6dSMauro Carvalho Chehab	=============== ==================================================
538ecefae6dSMauro Carvalho Chehab
539ecefae6dSMauro Carvalho ChehabTesting the PHONET function
540ecefae6dSMauro Carvalho Chehab---------------------------
541ecefae6dSMauro Carvalho Chehab
542ecefae6dSMauro Carvalho ChehabIt is not possible to test the SOCK_STREAM protocol without a specific piece
543ecefae6dSMauro Carvalho Chehabof hardware, so only SOCK_DGRAM has been tested. For the latter to work,
544ecefae6dSMauro Carvalho Chehabin the past I had to apply the patch mentioned here:
545ecefae6dSMauro Carvalho Chehab
546ecefae6dSMauro Carvalho Chehabhttp://www.spinics.net/lists/linux-usb/msg85689.html
547ecefae6dSMauro Carvalho Chehab
548ecefae6dSMauro Carvalho ChehabThese tools are required:
549ecefae6dSMauro Carvalho Chehab
550ecefae6dSMauro Carvalho Chehabgit://git.gitorious.org/meego-cellular/phonet-utils.git
551ecefae6dSMauro Carvalho Chehab
552ecefae6dSMauro Carvalho ChehabOn the host::
553ecefae6dSMauro Carvalho Chehab
554ecefae6dSMauro Carvalho Chehab	$ ./phonet -a 0x10 -i usbpn0
555ecefae6dSMauro Carvalho Chehab	$ ./pnroute add 0x6c usbpn0
556ecefae6dSMauro Carvalho Chehab	$./pnroute add 0x10 usbpn0
557ecefae6dSMauro Carvalho Chehab	$ ifconfig usbpn0 up
558ecefae6dSMauro Carvalho Chehab
559ecefae6dSMauro Carvalho ChehabOn the device::
560ecefae6dSMauro Carvalho Chehab
561ecefae6dSMauro Carvalho Chehab	$ ./phonet -a 0x6c -i upnlink0
562ecefae6dSMauro Carvalho Chehab	$ ./pnroute add 0x10 upnlink0
563ecefae6dSMauro Carvalho Chehab	$ ifconfig upnlink0 up
564ecefae6dSMauro Carvalho Chehab
565ecefae6dSMauro Carvalho ChehabThen a test program can be used::
566ecefae6dSMauro Carvalho Chehab
567ecefae6dSMauro Carvalho Chehab	http://www.spinics.net/lists/linux-usb/msg85690.html
568ecefae6dSMauro Carvalho Chehab
569ecefae6dSMauro Carvalho ChehabOn the device::
570ecefae6dSMauro Carvalho Chehab
571ecefae6dSMauro Carvalho Chehab	$ ./pnxmit -a 0x6c -r
572ecefae6dSMauro Carvalho Chehab
573ecefae6dSMauro Carvalho ChehabOn the host::
574ecefae6dSMauro Carvalho Chehab
575ecefae6dSMauro Carvalho Chehab	$ ./pnxmit -a 0x10 -s 0x6c
576ecefae6dSMauro Carvalho Chehab
577ecefae6dSMauro Carvalho ChehabAs a result some data should be sent from host to device.
578ecefae6dSMauro Carvalho ChehabThen the other way round:
579ecefae6dSMauro Carvalho Chehab
580ecefae6dSMauro Carvalho ChehabOn the host::
581ecefae6dSMauro Carvalho Chehab
582ecefae6dSMauro Carvalho Chehab	$ ./pnxmit -a 0x10 -r
583ecefae6dSMauro Carvalho Chehab
584ecefae6dSMauro Carvalho ChehabOn the device::
585ecefae6dSMauro Carvalho Chehab
586ecefae6dSMauro Carvalho Chehab	$ ./pnxmit -a 0x6c -s 0x10
587ecefae6dSMauro Carvalho Chehab
588ecefae6dSMauro Carvalho Chehab13. RNDIS function
589ecefae6dSMauro Carvalho Chehab==================
590ecefae6dSMauro Carvalho Chehab
591ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_rndis.ko module.
592ecefae6dSMauro Carvalho Chehab
593ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
594ecefae6dSMauro Carvalho Chehab------------------------------------
595ecefae6dSMauro Carvalho Chehab
596ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "rndis".
597ecefae6dSMauro Carvalho ChehabThe RNDIS function provides these attributes in its function directory:
598ecefae6dSMauro Carvalho Chehab
599ecefae6dSMauro Carvalho Chehab	=============== ==================================================
600ecefae6dSMauro Carvalho Chehab	ifname		network device interface name associated with this
601ecefae6dSMauro Carvalho Chehab			function instance
602ecefae6dSMauro Carvalho Chehab	qmult		queue length multiplier for high and super speed
603ecefae6dSMauro Carvalho Chehab	host_addr	MAC address of host's end of this
604ecefae6dSMauro Carvalho Chehab			Ethernet over USB link
605ecefae6dSMauro Carvalho Chehab	dev_addr	MAC address of device's end of this
606ecefae6dSMauro Carvalho Chehab			Ethernet over USB link
607ecefae6dSMauro Carvalho Chehab	=============== ==================================================
608ecefae6dSMauro Carvalho Chehab
609ecefae6dSMauro Carvalho Chehaband after creating the functions/rndis.<instance name> they contain default
610ecefae6dSMauro Carvalho Chehabvalues: qmult is 5, dev_addr and host_addr are randomly selected.
61163d15214SLorenzo ColittiThe ifname can be written to if the function is not bound. A write must be an
61263d15214SLorenzo Colittiinterface pattern such as "usb%d", which will cause the net core to choose the
61363d15214SLorenzo Colittinext free usbX interface. By default, it is set to "usb%d".
614ecefae6dSMauro Carvalho Chehab
615ecefae6dSMauro Carvalho ChehabTesting the RNDIS function
616ecefae6dSMauro Carvalho Chehab--------------------------
617ecefae6dSMauro Carvalho Chehab
618ecefae6dSMauro Carvalho ChehabConfigure IP addresses of the device and the host. Then:
619ecefae6dSMauro Carvalho Chehab
620ecefae6dSMauro Carvalho ChehabOn the device::
621ecefae6dSMauro Carvalho Chehab
622ecefae6dSMauro Carvalho Chehab	ping <host's IP>
623ecefae6dSMauro Carvalho Chehab
624ecefae6dSMauro Carvalho ChehabOn the host::
625ecefae6dSMauro Carvalho Chehab
626ecefae6dSMauro Carvalho Chehab	ping <device's IP>
627ecefae6dSMauro Carvalho Chehab
628ecefae6dSMauro Carvalho Chehab14. SERIAL function
629ecefae6dSMauro Carvalho Chehab===================
630ecefae6dSMauro Carvalho Chehab
631ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_gser.ko module.
632ecefae6dSMauro Carvalho Chehab
633ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
634ecefae6dSMauro Carvalho Chehab------------------------------------
635ecefae6dSMauro Carvalho Chehab
636ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "gser".
637ecefae6dSMauro Carvalho ChehabThe SERIAL function provides just one attribute in its function directory:
638ecefae6dSMauro Carvalho Chehab
639ecefae6dSMauro Carvalho Chehab	port_num
640ecefae6dSMauro Carvalho Chehab
641ecefae6dSMauro Carvalho ChehabThe attribute is read-only.
642ecefae6dSMauro Carvalho Chehab
643ecefae6dSMauro Carvalho ChehabThere can be at most 4 ACM/generic serial/OBEX ports in the system.
644ecefae6dSMauro Carvalho Chehab
645ecefae6dSMauro Carvalho ChehabTesting the SERIAL function
646ecefae6dSMauro Carvalho Chehab---------------------------
647ecefae6dSMauro Carvalho Chehab
648ecefae6dSMauro Carvalho ChehabOn host::
649ecefae6dSMauro Carvalho Chehab
650ecefae6dSMauro Carvalho Chehab	insmod usbserial
651ecefae6dSMauro Carvalho Chehab	echo VID PID >/sys/bus/usb-serial/drivers/generic/new_id
652ecefae6dSMauro Carvalho Chehab
653ecefae6dSMauro Carvalho ChehabOn host::
654ecefae6dSMauro Carvalho Chehab
655ecefae6dSMauro Carvalho Chehab	cat > /dev/ttyUSB<X>
656ecefae6dSMauro Carvalho Chehab
657ecefae6dSMauro Carvalho ChehabOn target::
658ecefae6dSMauro Carvalho Chehab
659ecefae6dSMauro Carvalho Chehab	cat /dev/ttyGS<Y>
660ecefae6dSMauro Carvalho Chehab
661ecefae6dSMauro Carvalho Chehabthen the other way round
662ecefae6dSMauro Carvalho Chehab
663ecefae6dSMauro Carvalho ChehabOn target::
664ecefae6dSMauro Carvalho Chehab
665ecefae6dSMauro Carvalho Chehab	cat > /dev/ttyGS<Y>
666ecefae6dSMauro Carvalho Chehab
667ecefae6dSMauro Carvalho ChehabOn host::
668ecefae6dSMauro Carvalho Chehab
669ecefae6dSMauro Carvalho Chehab	cat /dev/ttyUSB<X>
670ecefae6dSMauro Carvalho Chehab
671ecefae6dSMauro Carvalho Chehab15. SOURCESINK function
672ecefae6dSMauro Carvalho Chehab=======================
673ecefae6dSMauro Carvalho Chehab
674ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_ss_lb.ko module.
675ecefae6dSMauro Carvalho Chehab
676ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
677ecefae6dSMauro Carvalho Chehab------------------------------------
678ecefae6dSMauro Carvalho Chehab
679ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "SourceSink".
680ecefae6dSMauro Carvalho ChehabThe SOURCESINK function provides these attributes in its function directory:
681ecefae6dSMauro Carvalho Chehab
682ecefae6dSMauro Carvalho Chehab	=============== ==================================
683ecefae6dSMauro Carvalho Chehab	pattern		0 (all zeros), 1 (mod63), 2 (none)
684ecefae6dSMauro Carvalho Chehab	isoc_interval	1..16
685ecefae6dSMauro Carvalho Chehab	isoc_maxpacket	0 - 1023 (fs), 0 - 1024 (hs/ss)
686ecefae6dSMauro Carvalho Chehab	isoc_mult	0..2 (hs/ss only)
687ecefae6dSMauro Carvalho Chehab	isoc_maxburst	0..15 (ss only)
688ecefae6dSMauro Carvalho Chehab	bulk_buflen	buffer length
689ecefae6dSMauro Carvalho Chehab	bulk_qlen	depth of queue for bulk
690ecefae6dSMauro Carvalho Chehab	iso_qlen	depth of queue for iso
691ecefae6dSMauro Carvalho Chehab	=============== ==================================
692ecefae6dSMauro Carvalho Chehab
693ecefae6dSMauro Carvalho ChehabTesting the SOURCESINK function
694ecefae6dSMauro Carvalho Chehab-------------------------------
695ecefae6dSMauro Carvalho Chehab
696ecefae6dSMauro Carvalho Chehabdevice: run the gadget
697ecefae6dSMauro Carvalho Chehab
698ecefae6dSMauro Carvalho Chehabhost: test-usb (tools/usb/testusb.c)
699ecefae6dSMauro Carvalho Chehab
700ecefae6dSMauro Carvalho Chehab
701ecefae6dSMauro Carvalho Chehab16. UAC1 function (legacy implementation)
702ecefae6dSMauro Carvalho Chehab=========================================
703ecefae6dSMauro Carvalho Chehab
704ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_uac1_legacy.ko module.
705ecefae6dSMauro Carvalho Chehab
706ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
707ecefae6dSMauro Carvalho Chehab------------------------------------
708ecefae6dSMauro Carvalho Chehab
709ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory
710ecefae6dSMauro Carvalho Chehabis "uac1_legacy".
711ecefae6dSMauro Carvalho ChehabThe uac1 function provides these attributes in its function directory:
712ecefae6dSMauro Carvalho Chehab
713ecefae6dSMauro Carvalho Chehab	=============== ====================================
714ecefae6dSMauro Carvalho Chehab	audio_buf_size	audio buffer size
715ecefae6dSMauro Carvalho Chehab	fn_cap		capture pcm device file name
716ecefae6dSMauro Carvalho Chehab	fn_cntl		control device file name
717ecefae6dSMauro Carvalho Chehab	fn_play		playback pcm device file name
718ecefae6dSMauro Carvalho Chehab	req_buf_size	ISO OUT endpoint request buffer size
719ecefae6dSMauro Carvalho Chehab	req_count	ISO OUT endpoint request count
720ecefae6dSMauro Carvalho Chehab	=============== ====================================
721ecefae6dSMauro Carvalho Chehab
722ecefae6dSMauro Carvalho ChehabThe attributes have sane default values.
723ecefae6dSMauro Carvalho Chehab
724ecefae6dSMauro Carvalho ChehabTesting the UAC1 function
725ecefae6dSMauro Carvalho Chehab-------------------------
726ecefae6dSMauro Carvalho Chehab
727ecefae6dSMauro Carvalho Chehabdevice: run the gadget
728ecefae6dSMauro Carvalho Chehab
729ecefae6dSMauro Carvalho Chehabhost::
730ecefae6dSMauro Carvalho Chehab
731ecefae6dSMauro Carvalho Chehab	aplay -l # should list our USB Audio Gadget
732ecefae6dSMauro Carvalho Chehab
733ecefae6dSMauro Carvalho Chehab17. UAC2 function
734ecefae6dSMauro Carvalho Chehab=================
735ecefae6dSMauro Carvalho Chehab
736ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_uac2.ko module.
737ecefae6dSMauro Carvalho Chehab
738ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
739ecefae6dSMauro Carvalho Chehab------------------------------------
740ecefae6dSMauro Carvalho Chehab
741ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "uac2".
742ecefae6dSMauro Carvalho ChehabThe uac2 function provides these attributes in its function directory:
743ecefae6dSMauro Carvalho Chehab
7449c0edd56SHu Haowen	================ ====================================================
745ecefae6dSMauro Carvalho Chehab	c_chmask         capture channel mask
746a7339e4fSJulian Scheel	c_srate          list of capture sampling rates (comma-separated)
747ecefae6dSMauro Carvalho Chehab	c_ssize          capture sample size (bytes)
74840c73b30SRuslan Bilovol	c_sync           capture synchronization type (async/adaptive)
749eaf6cbe0SRuslan Bilovol	c_mute_present   capture mute control enable
750eaf6cbe0SRuslan Bilovol	c_volume_present capture volume control enable
751eaf6cbe0SRuslan Bilovol	c_volume_min     capture volume control min value (in 1/256 dB)
752eaf6cbe0SRuslan Bilovol	c_volume_max     capture volume control max value (in 1/256 dB)
753eaf6cbe0SRuslan Bilovol	c_volume_res     capture volume control resolution (in 1/256 dB)
754355a05dcSPavel Hofman	c_hs_bint        capture bInterval for HS/SS (1-4: fixed, 0: auto)
755e89bb428SRuslan Bilovol	fb_max           maximum extra bandwidth in async mode
756ecefae6dSMauro Carvalho Chehab	p_chmask         playback channel mask
757a7339e4fSJulian Scheel	p_srate          list of playback sampling rates (comma-separated)
758ecefae6dSMauro Carvalho Chehab	p_ssize          playback sample size (bytes)
759eaf6cbe0SRuslan Bilovol	p_mute_present   playback mute control enable
760eaf6cbe0SRuslan Bilovol	p_volume_present playback volume control enable
761eaf6cbe0SRuslan Bilovol	p_volume_min     playback volume control min value (in 1/256 dB)
762eaf6cbe0SRuslan Bilovol	p_volume_max     playback volume control max value (in 1/256 dB)
763eaf6cbe0SRuslan Bilovol	p_volume_res     playback volume control resolution (in 1/256 dB)
764355a05dcSPavel Hofman	p_hs_bint        playback bInterval for HS/SS (1-4: fixed, 0: auto)
765ecefae6dSMauro Carvalho Chehab	req_number       the number of pre-allocated request for both capture
766ecefae6dSMauro Carvalho Chehab	                 and playback
767dfb05b5dSYunhao Tian	function_name    name of the interface
768de2eb28cSJames Gruber	c_terminal_type  code of the capture terminal type
769de2eb28cSJames Gruber	p_terminal_type  code of the playback terminal type
7709c0edd56SHu Haowen	================ ====================================================
771ecefae6dSMauro Carvalho Chehab
772ecefae6dSMauro Carvalho ChehabThe attributes have sane default values.
773ecefae6dSMauro Carvalho Chehab
774ecefae6dSMauro Carvalho ChehabTesting the UAC2 function
775ecefae6dSMauro Carvalho Chehab-------------------------
776ecefae6dSMauro Carvalho Chehab
777ecefae6dSMauro Carvalho Chehabdevice: run the gadget
778ecefae6dSMauro Carvalho Chehabhost: aplay -l # should list our USB Audio Gadget
779ecefae6dSMauro Carvalho Chehab
780ecefae6dSMauro Carvalho ChehabThis function does not require real hardware support, it just
781ecefae6dSMauro Carvalho Chehabsends a stream of audio data to/from the host. In order to
782ecefae6dSMauro Carvalho Chehabactually hear something at the device side, a command similar
783ecefae6dSMauro Carvalho Chehabto this must be used at the device side::
784ecefae6dSMauro Carvalho Chehab
785ecefae6dSMauro Carvalho Chehab	$ arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 &
786ecefae6dSMauro Carvalho Chehab
787ecefae6dSMauro Carvalho Chehabe.g.::
788ecefae6dSMauro Carvalho Chehab
789ecefae6dSMauro Carvalho Chehab	$ arecord -f dat -t wav -D hw:CARD=UAC2Gadget,DEV=0 | \
790ecefae6dSMauro Carvalho Chehab	  aplay -D default:CARD=OdroidU3
791ecefae6dSMauro Carvalho Chehab
792ecefae6dSMauro Carvalho Chehab18. UVC function
793ecefae6dSMauro Carvalho Chehab================
794ecefae6dSMauro Carvalho Chehab
795ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_uvc.ko module.
796ecefae6dSMauro Carvalho Chehab
797ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
798ecefae6dSMauro Carvalho Chehab------------------------------------
799ecefae6dSMauro Carvalho Chehab
800ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "uvc".
801ecefae6dSMauro Carvalho ChehabThe uvc function provides these attributes in its function directory:
802ecefae6dSMauro Carvalho Chehab
803ecefae6dSMauro Carvalho Chehab	=================== ================================================
804ecefae6dSMauro Carvalho Chehab	streaming_interval  interval for polling endpoint for data transfers
805ecefae6dSMauro Carvalho Chehab	streaming_maxburst  bMaxBurst for super speed companion descriptor
806ecefae6dSMauro Carvalho Chehab	streaming_maxpacket maximum packet size this endpoint is capable of
807ecefae6dSMauro Carvalho Chehab			    sending or receiving when this configuration is
808ecefae6dSMauro Carvalho Chehab			    selected
809324e4f85SDan Vacura	function_name       name of the interface
810ecefae6dSMauro Carvalho Chehab	=================== ================================================
811ecefae6dSMauro Carvalho Chehab
812ecefae6dSMauro Carvalho ChehabThere are also "control" and "streaming" subdirectories, each of which contain
813ecefae6dSMauro Carvalho Chehaba number of their subdirectories. There are some sane defaults provided, but
814ecefae6dSMauro Carvalho Chehabthe user must provide the following:
815ecefae6dSMauro Carvalho Chehab
816ecefae6dSMauro Carvalho Chehab	================== ====================================================
817ecefae6dSMauro Carvalho Chehab	control header     create in control/header, link from control/class/fs
818ecefae6dSMauro Carvalho Chehab			   and/or control/class/ss
819ecefae6dSMauro Carvalho Chehab	streaming header   create in streaming/header, link from
820ecefae6dSMauro Carvalho Chehab			   streaming/class/fs and/or streaming/class/hs and/or
821ecefae6dSMauro Carvalho Chehab			   streaming/class/ss
822ecefae6dSMauro Carvalho Chehab	format description create in streaming/mjpeg and/or
823ecefae6dSMauro Carvalho Chehab			   streaming/uncompressed
824ecefae6dSMauro Carvalho Chehab	frame description  create in streaming/mjpeg/<format> and/or in
825ecefae6dSMauro Carvalho Chehab			   streaming/uncompressed/<format>
826ecefae6dSMauro Carvalho Chehab	================== ====================================================
827ecefae6dSMauro Carvalho Chehab
828ecefae6dSMauro Carvalho ChehabEach frame description contains frame interval specification, and each
829e4157519SRandy Dunlapsuch specification consists of a number of lines with an interval value
830ecefae6dSMauro Carvalho Chehabin each line. The rules stated above are best illustrated with an example::
831ecefae6dSMauro Carvalho Chehab
832ecefae6dSMauro Carvalho Chehab  # mkdir functions/uvc.usb0/control/header/h
833ecefae6dSMauro Carvalho Chehab  # cd functions/uvc.usb0/control/
834ecefae6dSMauro Carvalho Chehab  # ln -s header/h class/fs
835ecefae6dSMauro Carvalho Chehab  # ln -s header/h class/ss
836ecefae6dSMauro Carvalho Chehab  # mkdir -p functions/uvc.usb0/streaming/uncompressed/u/360p
837ecefae6dSMauro Carvalho Chehab  # cat <<EOF > functions/uvc.usb0/streaming/uncompressed/u/360p/dwFrameInterval
838ecefae6dSMauro Carvalho Chehab  666666
839ecefae6dSMauro Carvalho Chehab  1000000
840ecefae6dSMauro Carvalho Chehab  5000000
841ecefae6dSMauro Carvalho Chehab  EOF
842ecefae6dSMauro Carvalho Chehab  # cd $GADGET_CONFIGFS_ROOT
843ecefae6dSMauro Carvalho Chehab  # mkdir functions/uvc.usb0/streaming/header/h
844ecefae6dSMauro Carvalho Chehab  # cd functions/uvc.usb0/streaming/header/h
845ecefae6dSMauro Carvalho Chehab  # ln -s ../../uncompressed/u
846ecefae6dSMauro Carvalho Chehab  # cd ../../class/fs
847ecefae6dSMauro Carvalho Chehab  # ln -s ../../header/h
848ecefae6dSMauro Carvalho Chehab  # cd ../../class/hs
849ecefae6dSMauro Carvalho Chehab  # ln -s ../../header/h
850ecefae6dSMauro Carvalho Chehab  # cd ../../class/ss
851ecefae6dSMauro Carvalho Chehab  # ln -s ../../header/h
852ecefae6dSMauro Carvalho Chehab
853ecefae6dSMauro Carvalho Chehab
854ecefae6dSMauro Carvalho ChehabTesting the UVC function
855ecefae6dSMauro Carvalho Chehab------------------------
856ecefae6dSMauro Carvalho Chehab
857ecefae6dSMauro Carvalho Chehabdevice: run the gadget, modprobe vivid::
858ecefae6dSMauro Carvalho Chehab
859ecefae6dSMauro Carvalho Chehab  # uvc-gadget -u /dev/video<uvc video node #> -v /dev/video<vivid video node #>
860ecefae6dSMauro Carvalho Chehab
861ecefae6dSMauro Carvalho Chehabwhere uvc-gadget is this program:
862ecefae6dSMauro Carvalho Chehab	http://git.ideasonboard.org/uvc-gadget.git
863ecefae6dSMauro Carvalho Chehab
864ecefae6dSMauro Carvalho Chehabwith these patches:
865ecefae6dSMauro Carvalho Chehab
866ecefae6dSMauro Carvalho Chehab	http://www.spinics.net/lists/linux-usb/msg99220.html
867ecefae6dSMauro Carvalho Chehab
868ecefae6dSMauro Carvalho Chehabhost::
869ecefae6dSMauro Carvalho Chehab
870ecefae6dSMauro Carvalho Chehab	luvcview -f yuv
871ecefae6dSMauro Carvalho Chehab
872ecefae6dSMauro Carvalho Chehab19. PRINTER function
873ecefae6dSMauro Carvalho Chehab====================
874ecefae6dSMauro Carvalho Chehab
875ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_printer.ko module.
876ecefae6dSMauro Carvalho Chehab
877ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
878ecefae6dSMauro Carvalho Chehab------------------------------------
879ecefae6dSMauro Carvalho Chehab
880ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "printer".
881ecefae6dSMauro Carvalho ChehabThe printer function provides these attributes in its function directory:
882ecefae6dSMauro Carvalho Chehab
883ecefae6dSMauro Carvalho Chehab	==========	===========================================
884ecefae6dSMauro Carvalho Chehab	pnp_string	Data to be passed to the host in pnp string
885ecefae6dSMauro Carvalho Chehab	q_len		Number of requests per endpoint
886ecefae6dSMauro Carvalho Chehab	==========	===========================================
887ecefae6dSMauro Carvalho Chehab
888ecefae6dSMauro Carvalho ChehabTesting the PRINTER function
889ecefae6dSMauro Carvalho Chehab----------------------------
890ecefae6dSMauro Carvalho Chehab
891ecefae6dSMauro Carvalho ChehabThe most basic testing:
892ecefae6dSMauro Carvalho Chehab
893ecefae6dSMauro Carvalho Chehabdevice: run the gadget::
894ecefae6dSMauro Carvalho Chehab
895ecefae6dSMauro Carvalho Chehab	# ls -l /devices/virtual/usb_printer_gadget/
896ecefae6dSMauro Carvalho Chehab
897ecefae6dSMauro Carvalho Chehabshould show g_printer<number>.
898ecefae6dSMauro Carvalho Chehab
899ecefae6dSMauro Carvalho ChehabIf udev is active, then /dev/g_printer<number> should appear automatically.
900ecefae6dSMauro Carvalho Chehab
901ecefae6dSMauro Carvalho Chehabhost:
902ecefae6dSMauro Carvalho Chehab
903ecefae6dSMauro Carvalho ChehabIf udev is active, then e.g. /dev/usb/lp0 should appear.
904ecefae6dSMauro Carvalho Chehab
905ecefae6dSMauro Carvalho Chehabhost->device transmission:
906ecefae6dSMauro Carvalho Chehab
907ecefae6dSMauro Carvalho Chehabdevice::
908ecefae6dSMauro Carvalho Chehab
909ecefae6dSMauro Carvalho Chehab	# cat /dev/g_printer<number>
910ecefae6dSMauro Carvalho Chehab
911ecefae6dSMauro Carvalho Chehabhost::
912ecefae6dSMauro Carvalho Chehab
913ecefae6dSMauro Carvalho Chehab	# cat > /dev/usb/lp0
914ecefae6dSMauro Carvalho Chehab
915ecefae6dSMauro Carvalho Chehabdevice->host transmission::
916ecefae6dSMauro Carvalho Chehab
917ecefae6dSMauro Carvalho Chehab	# cat > /dev/g_printer<number>
918ecefae6dSMauro Carvalho Chehab
919ecefae6dSMauro Carvalho Chehabhost::
920ecefae6dSMauro Carvalho Chehab
921ecefae6dSMauro Carvalho Chehab	# cat /dev/usb/lp0
922ecefae6dSMauro Carvalho Chehab
923ecefae6dSMauro Carvalho ChehabMore advanced testing can be done with the prn_example
924ecefae6dSMauro Carvalho Chehabdescribed in Documentation/usb/gadget_printer.rst.
925ecefae6dSMauro Carvalho Chehab
926ecefae6dSMauro Carvalho Chehab
927ecefae6dSMauro Carvalho Chehab20. UAC1 function (virtual ALSA card, using u_audio API)
928ecefae6dSMauro Carvalho Chehab========================================================
929ecefae6dSMauro Carvalho Chehab
930ecefae6dSMauro Carvalho ChehabThe function is provided by usb_f_uac1.ko module.
931ecefae6dSMauro Carvalho ChehabIt will create a virtual ALSA card and the audio streams are simply
932ecefae6dSMauro Carvalho Chehabsinked to and sourced from it.
933ecefae6dSMauro Carvalho Chehab
934ecefae6dSMauro Carvalho ChehabFunction-specific configfs interface
935ecefae6dSMauro Carvalho Chehab------------------------------------
936ecefae6dSMauro Carvalho Chehab
937ecefae6dSMauro Carvalho ChehabThe function name to use when creating the function directory is "uac1".
938ecefae6dSMauro Carvalho ChehabThe uac1 function provides these attributes in its function directory:
939ecefae6dSMauro Carvalho Chehab
9409c0edd56SHu Haowen	================ ====================================================
941ecefae6dSMauro Carvalho Chehab	c_chmask         capture channel mask
942695d39ffSJulian Scheel	c_srate          list of capture sampling rates (comma-separated)
943ecefae6dSMauro Carvalho Chehab	c_ssize          capture sample size (bytes)
9440356e628SRuslan Bilovol	c_mute_present   capture mute control enable
9450356e628SRuslan Bilovol	c_volume_present capture volume control enable
9460356e628SRuslan Bilovol	c_volume_min     capture volume control min value (in 1/256 dB)
9470356e628SRuslan Bilovol	c_volume_max     capture volume control max value (in 1/256 dB)
9480356e628SRuslan Bilovol	c_volume_res     capture volume control resolution (in 1/256 dB)
949ecefae6dSMauro Carvalho Chehab	p_chmask         playback channel mask
950695d39ffSJulian Scheel	p_srate          list of playback sampling rates (comma-separated)
951ecefae6dSMauro Carvalho Chehab	p_ssize          playback sample size (bytes)
9520356e628SRuslan Bilovol	p_mute_present   playback mute control enable
9530356e628SRuslan Bilovol	p_volume_present playback volume control enable
9540356e628SRuslan Bilovol	p_volume_min     playback volume control min value (in 1/256 dB)
9550356e628SRuslan Bilovol	p_volume_max     playback volume control max value (in 1/256 dB)
9560356e628SRuslan Bilovol	p_volume_res     playback volume control resolution (in 1/256 dB)
957a8cf0516SPavel Hofman	req_number       the number of pre-allocated requests for both capture
958ecefae6dSMauro Carvalho Chehab	                 and playback
959993a44faSYunhao Tian	function_name    name of the interface
9609c0edd56SHu Haowen	================ ====================================================
961ecefae6dSMauro Carvalho Chehab
962ecefae6dSMauro Carvalho ChehabThe attributes have sane default values.
963ecefae6dSMauro Carvalho Chehab
964ecefae6dSMauro Carvalho ChehabTesting the UAC1 function
965ecefae6dSMauro Carvalho Chehab-------------------------
966ecefae6dSMauro Carvalho Chehab
967ecefae6dSMauro Carvalho Chehabdevice: run the gadget
968ecefae6dSMauro Carvalho Chehabhost: aplay -l # should list our USB Audio Gadget
969ecefae6dSMauro Carvalho Chehab
970ecefae6dSMauro Carvalho ChehabThis function does not require real hardware support, it just
971ecefae6dSMauro Carvalho Chehabsends a stream of audio data to/from the host. In order to
972ecefae6dSMauro Carvalho Chehabactually hear something at the device side, a command similar
973ecefae6dSMauro Carvalho Chehabto this must be used at the device side::
974ecefae6dSMauro Carvalho Chehab
975ecefae6dSMauro Carvalho Chehab	$ arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 &
976ecefae6dSMauro Carvalho Chehab
977ecefae6dSMauro Carvalho Chehabe.g.::
978ecefae6dSMauro Carvalho Chehab
979ecefae6dSMauro Carvalho Chehab	$ arecord -f dat -t wav -D hw:CARD=UAC1Gadget,DEV=0 | \
980ecefae6dSMauro Carvalho Chehab	  aplay -D default:CARD=OdroidU3
9818559caa9STakashi Iwai
9828559caa9STakashi Iwai
9838559caa9STakashi Iwai21. MIDI2 function
9848559caa9STakashi Iwai==================
9858559caa9STakashi Iwai
9868559caa9STakashi IwaiThe function is provided by usb_f_midi2.ko module.
9878559caa9STakashi IwaiIt will create a virtual ALSA card containing a UMP rawmidi device
9888559caa9STakashi Iwaiwhere the UMP packet is looped back. In addition, a legacy rawmidi
9898559caa9STakashi Iwaidevice is created. The UMP rawmidi is bound with ALSA sequencer
9908559caa9STakashi Iwaiclients, too.
9918559caa9STakashi Iwai
9928559caa9STakashi IwaiFunction-specific configfs interface
9938559caa9STakashi Iwai------------------------------------
9948559caa9STakashi Iwai
9958559caa9STakashi IwaiThe function name to use when creating the function directory is "midi2".
9968559caa9STakashi IwaiThe midi2 function provides these attributes in its function directory
9978559caa9STakashi Iwaias the card top-level information:
9988559caa9STakashi Iwai
9998559caa9STakashi Iwai	=============	=================================================
10008559caa9STakashi Iwai	process_ump	Bool flag to process UMP Stream messages (0 or 1)
10018559caa9STakashi Iwai	static_block	Bool flag for static blocks (0 or 1)
10028559caa9STakashi Iwai	iface_name	Optional interface name string
10038559caa9STakashi Iwai	=============	=================================================
10048559caa9STakashi Iwai
10058559caa9STakashi IwaiThe directory contains a subdirectory "ep.0", and this provides the
10068559caa9STakashi Iwaiattributes for a UMP Endpoint (which is a pair of USB MIDI Endpoints):
10078559caa9STakashi Iwai
10088559caa9STakashi Iwai	=============	=================================================
10098559caa9STakashi Iwai	protocol_caps	MIDI protocol capabilities;
10108559caa9STakashi Iwai			1: MIDI 1.0, 2: MIDI 2.0, or 3: both protocols
10118559caa9STakashi Iwai	protocol	Default MIDI protocol (either 1 or 2)
10128559caa9STakashi Iwai	ep_name		UMP Endpoint name string
10138559caa9STakashi Iwai	product_id	Product ID string
10148559caa9STakashi Iwai	manufacturer	Manufacture ID number (24 bit)
10158559caa9STakashi Iwai	family		Device family ID number (16 bit)
10168559caa9STakashi Iwai	model		Device model ID number (16 bit)
10178559caa9STakashi Iwai	sw_revision	Software revision (32 bit)
10188559caa9STakashi Iwai	=============	=================================================
10198559caa9STakashi Iwai
10208559caa9STakashi IwaiEach Endpoint subdirectory contains a subdirectory "block.0", which
10218559caa9STakashi Iwairepresents the Function Block for Block 0 information.
10228559caa9STakashi IwaiIts attributes are:
10238559caa9STakashi Iwai
1024a85ff0dbSTakashi Iwai	=================	===============================================
10258559caa9STakashi Iwai	name			Function Block name string
10268559caa9STakashi Iwai	direction		Direction of this FB
10278559caa9STakashi Iwai				1: input, 2: output, or 3: bidirectional
10288559caa9STakashi Iwai	first_group		The first UMP Group number (0-15)
10298559caa9STakashi Iwai	num_groups		The number of groups in this FB (1-16)
1030a85ff0dbSTakashi Iwai	midi1_first_group	The first UMP Group number for MIDI 1.0 (0-15)
1031a85ff0dbSTakashi Iwai	midi1_num_groups	The number of groups for MIDI 1.0 (0-16)
10328559caa9STakashi Iwai	ui_hint			UI-hint of this FB
10338559caa9STakashi Iwai				0: unknown, 1: receiver, 2: sender, 3: both
10348559caa9STakashi Iwai	midi_ci_verison		Supported MIDI-CI version number (8 bit)
10358559caa9STakashi Iwai	is_midi1		Legacy MIDI 1.0 device (0-2)
10368559caa9STakashi Iwai				0: MIDI 2.0 device,
10378559caa9STakashi Iwai				1: MIDI 1.0 without restriction, or
10388559caa9STakashi Iwai				2: MIDI 1.0 with low speed
10398559caa9STakashi Iwai	sysex8_streams		Max number of SysEx8 streams (8 bit)
10408559caa9STakashi Iwai	active			Bool flag for FB activity (0 or 1)
1041a85ff0dbSTakashi Iwai	=================	===============================================
10428559caa9STakashi Iwai
10438559caa9STakashi IwaiIf multiple Function Blocks are required, you can add more Function
10448559caa9STakashi IwaiBlocks by creating subdirectories "block.<num>" with the corresponding
10458559caa9STakashi IwaiFunction Block number (1, 2, ....). The FB subdirectories can be
10468559caa9STakashi Iwaidynamically removed, too. Note that the Function Block numbers must be
10478559caa9STakashi Iwaicontinuous.
10488559caa9STakashi Iwai
10498559caa9STakashi IwaiSimilarly, if you multiple UMP Endpoints are required, you can add
10508559caa9STakashi Iwaimore Endpoints by creating subdirectories "ep.<num>". The number must
10518559caa9STakashi Iwaibe continuous.
10528559caa9STakashi Iwai
10538559caa9STakashi IwaiFor emulating the old MIDI 2.0 device without UMP v1.1 support, pass 0
10548559caa9STakashi Iwaito `process_ump` flag. Then the whole UMP v1.1 requests are ignored.
10558559caa9STakashi Iwai
10568559caa9STakashi IwaiTesting the MIDI2 function
10578559caa9STakashi Iwai--------------------------
10588559caa9STakashi Iwai
10598559caa9STakashi IwaiOn the device: run the gadget, and running::
10608559caa9STakashi Iwai
10618559caa9STakashi Iwai  $ cat /proc/asound/cards
10628559caa9STakashi Iwai
10638559caa9STakashi Iwaiwill show a new sound card containing a MIDI2 device.
10648559caa9STakashi Iwai
10658559caa9STakashi IwaiOTOH, on the host::
10668559caa9STakashi Iwai
10678559caa9STakashi Iwai  $ cat /proc/asound/cards
10688559caa9STakashi Iwai
10698559caa9STakashi Iwaiwill show a new sound card containing either MIDI1 or MIDI2 device,
10708559caa9STakashi Iwaidepending on the USB audio driver configuration.
10718559caa9STakashi Iwai
10728559caa9STakashi IwaiOn both, when ALSA sequencer is enabled on the host, you can find the
10738559caa9STakashi IwaiUMP MIDI client such as "MIDI 2.0 Gadget".
10748559caa9STakashi Iwai
10758559caa9STakashi IwaiAs the driver simply loops back the data, there is no need for a real
10768559caa9STakashi Iwaidevice just for testing.
10778559caa9STakashi Iwai
10788559caa9STakashi IwaiFor testing a MIDI input from the gadget to the host (e.g. emulating a
10798559caa9STakashi IwaiMIDI keyboard), you can send a MIDI stream like the following.
10808559caa9STakashi Iwai
10818559caa9STakashi IwaiOn the gadget::
10828559caa9STakashi Iwai
10838559caa9STakashi Iwai  $ aconnect -o
10848559caa9STakashi Iwai  ....
10858559caa9STakashi Iwai  client 20: 'MIDI 2.0 Gadget' [type=kernel,card=1]
10868559caa9STakashi Iwai      0 'MIDI 2.0        '
10878559caa9STakashi Iwai      1 'Group 1 (MIDI 2.0 Gadget I/O)'
10888559caa9STakashi Iwai  $ aplaymidi -p 20:1 to_host.mid
10898559caa9STakashi Iwai
10908559caa9STakashi IwaiOn the host::
10918559caa9STakashi Iwai
10928559caa9STakashi Iwai  $ aconnect -i
10938559caa9STakashi Iwai  ....
10948559caa9STakashi Iwai  client 24: 'MIDI 2.0 Gadget' [type=kernel,card=2]
10958559caa9STakashi Iwai      0 'MIDI 2.0        '
10968559caa9STakashi Iwai      1 'Group 1 (MIDI 2.0 Gadget I/O)'
10978559caa9STakashi Iwai  $ arecordmidi -p 24:1 from_gadget.mid
10988559caa9STakashi Iwai
10998559caa9STakashi IwaiIf you have a UMP-capable application, you can use the UMP port to
11008559caa9STakashi Iwaisend/receive the raw UMP packets, too. For example, aseqdump program
11018559caa9STakashi Iwaiwith UMP support can receive from UMP port. On the host::
11028559caa9STakashi Iwai
11038559caa9STakashi Iwai  $ aseqdump -u 2 -p 24:1
11048559caa9STakashi Iwai  Waiting for data. Press Ctrl+C to end.
11058559caa9STakashi Iwai  Source  Group    Event                  Ch  Data
11068559caa9STakashi Iwai   24:1   Group  0, Program change          0, program 0, Bank select 0:0
11078559caa9STakashi Iwai   24:1   Group  0, Channel pressure        0, value 0x80000000
11088559caa9STakashi Iwai
11098559caa9STakashi IwaiFor testing a MIDI output to the gadget to the host (e.g. emulating a
11108559caa9STakashi IwaiMIDI synth), it'll be just other way round.
11118559caa9STakashi Iwai
11128559caa9STakashi IwaiOn the gadget::
11138559caa9STakashi Iwai
11148559caa9STakashi Iwai  $ arecordmidi -p 20:1 from_host.mid
11158559caa9STakashi Iwai
11168559caa9STakashi IwaiOn the host::
11178559caa9STakashi Iwai
11188559caa9STakashi Iwai  $ aplaymidi -p 24:1 to_gadget.mid
11198559caa9STakashi Iwai
11208559caa9STakashi IwaiThe access to MIDI 1.0 on altset 0 on the host is supported, and it's
11218559caa9STakashi Iwaitranslated from/to UMP packets on the gadget. It's bound to only
11228559caa9STakashi IwaiFunction Block 0.
11231b437d2fSTakashi Iwai
11241b437d2fSTakashi IwaiThe current operation mode can be observed in ALSA control element
11251b437d2fSTakashi Iwai"Operation Mode" for SND_CTL_IFACE_RAWMIDI.  For example::
11261b437d2fSTakashi Iwai
11271b437d2fSTakashi Iwai  $ amixer -c1 contents
11281b437d2fSTakashi Iwai  numid=1,iface=RAWMIDI,name='Operation Mode'
11291b437d2fSTakashi Iwai    ; type=INTEGER,access=r--v----,values=1,min=0,max=2,step=0
11301b437d2fSTakashi Iwai    : values=2
11311b437d2fSTakashi Iwai
11321b437d2fSTakashi Iwaiwhere 0 = unused, 1 = MIDI 1.0 (altset 0), 2 = MIDI 2.0 (altset 1).
11331b437d2fSTakashi IwaiThe example above shows it's running in 2, i.e. MIDI 2.0.
1134