gadget-testing.txt 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. This file summarizes information on basic testing of USB functions
  2. provided by gadgets.
  3. 1. ACM function
  4. 2. ECM function
  5. 3. ECM subset function
  6. 4. EEM function
  7. 5. FFS function
  8. 6. HID function
  9. 7. LOOPBACK function
  10. 8. MASS STORAGE function
  11. 9. MIDI function
  12. 10. NCM function
  13. 11. OBEX function
  14. 12. PHONET function
  15. 13. RNDIS function
  16. 14. SERIAL function
  17. 15. SOURCESINK function
  18. 16. UAC1 function (legacy implementation)
  19. 17. UAC2 function
  20. 18. UVC function
  21. 19. PRINTER function
  22. 20. UAC1 function (new API)
  23. 1. ACM function
  24. ===============
  25. The function is provided by usb_f_acm.ko module.
  26. Function-specific configfs interface
  27. ------------------------------------
  28. The function name to use when creating the function directory is "acm".
  29. The ACM function provides just one attribute in its function directory:
  30. port_num
  31. The attribute is read-only.
  32. There can be at most 4 ACM/generic serial/OBEX ports in the system.
  33. Testing the ACM function
  34. ------------------------
  35. On the host: cat > /dev/ttyACM<X>
  36. On the device : cat /dev/ttyGS<Y>
  37. then the other way round
  38. On the device: cat > /dev/ttyGS<Y>
  39. On the host: cat /dev/ttyACM<X>
  40. 2. ECM function
  41. ===============
  42. The function is provided by usb_f_ecm.ko module.
  43. Function-specific configfs interface
  44. ------------------------------------
  45. The function name to use when creating the function directory is "ecm".
  46. The ECM function provides these attributes in its function directory:
  47. ifname - network device interface name associated with this
  48. function instance
  49. qmult - queue length multiplier for high and super speed
  50. host_addr - MAC address of host's end of this
  51. Ethernet over USB link
  52. dev_addr - MAC address of device's end of this
  53. Ethernet over USB link
  54. and after creating the functions/ecm.<instance name> they contain default
  55. values: qmult is 5, dev_addr and host_addr are randomly selected.
  56. Except for ifname they can be written to until the function is linked to a
  57. configuration. The ifname is read-only and contains the name of the interface
  58. which was assigned by the net core, e. g. usb0.
  59. Testing the ECM function
  60. ------------------------
  61. Configure IP addresses of the device and the host. Then:
  62. On the device: ping <host's IP>
  63. On the host: ping <device's IP>
  64. 3. ECM subset function
  65. ======================
  66. The function is provided by usb_f_ecm_subset.ko module.
  67. Function-specific configfs interface
  68. ------------------------------------
  69. The function name to use when creating the function directory is "geth".
  70. The ECM subset function provides these attributes in its function directory:
  71. ifname - network device interface name associated with this
  72. function instance
  73. qmult - queue length multiplier for high and super speed
  74. host_addr - MAC address of host's end of this
  75. Ethernet over USB link
  76. dev_addr - MAC address of device's end of this
  77. Ethernet over USB link
  78. and after creating the functions/ecm.<instance name> they contain default
  79. values: qmult is 5, dev_addr and host_addr are randomly selected.
  80. Except for ifname they can be written to until the function is linked to a
  81. configuration. The ifname is read-only and contains the name of the interface
  82. which was assigned by the net core, e. g. usb0.
  83. Testing the ECM subset function
  84. -------------------------------
  85. Configure IP addresses of the device and the host. Then:
  86. On the device: ping <host's IP>
  87. On the host: ping <device's IP>
  88. 4. EEM function
  89. ===============
  90. The function is provided by usb_f_eem.ko module.
  91. Function-specific configfs interface
  92. ------------------------------------
  93. The function name to use when creating the function directory is "eem".
  94. The EEM function provides these attributes in its function directory:
  95. ifname - network device interface name associated with this
  96. function instance
  97. qmult - queue length multiplier for high and super speed
  98. host_addr - MAC address of host's end of this
  99. Ethernet over USB link
  100. dev_addr - MAC address of device's end of this
  101. Ethernet over USB link
  102. and after creating the functions/eem.<instance name> they contain default
  103. values: qmult is 5, dev_addr and host_addr are randomly selected.
  104. Except for ifname they can be written to until the function is linked to a
  105. configuration. The ifname is read-only and contains the name of the interface
  106. which was assigned by the net core, e. g. usb0.
  107. Testing the EEM function
  108. ------------------------
  109. Configure IP addresses of the device and the host. Then:
  110. On the device: ping <host's IP>
  111. On the host: ping <device's IP>
  112. 5. FFS function
  113. ===============
  114. The function is provided by usb_f_fs.ko module.
  115. Function-specific configfs interface
  116. ------------------------------------
  117. The function name to use when creating the function directory is "ffs".
  118. The function directory is intentionally empty and not modifiable.
  119. After creating the directory there is a new instance (a "device") of FunctionFS
  120. available in the system. Once a "device" is available, the user should follow
  121. the standard procedure for using FunctionFS (mount it, run the userspace
  122. process which implements the function proper). The gadget should be enabled
  123. by writing a suitable string to usb_gadget/<gadget>/UDC.
  124. Testing the FFS function
  125. ------------------------
  126. On the device: start the function's userspace daemon, enable the gadget
  127. On the host: use the USB function provided by the device
  128. 6. HID function
  129. ===============
  130. The function is provided by usb_f_hid.ko module.
  131. Function-specific configfs interface
  132. ------------------------------------
  133. The function name to use when creating the function directory is "hid".
  134. The HID function provides these attributes in its function directory:
  135. protocol - HID protocol to use
  136. report_desc - data to be used in HID reports, except data
  137. passed with /dev/hidg<X>
  138. report_length - HID report length
  139. subclass - HID subclass to use
  140. For a keyboard the protocol and the subclass are 1, the report_length is 8,
  141. while the report_desc is:
  142. $ hd my_report_desc
  143. 00000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.|
  144. 00000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.|
  145. 00000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....|
  146. 00000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...|
  147. 0000003f
  148. Such a sequence of bytes can be stored to the attribute with echo:
  149. $ echo -ne \\x05\\x01\\x09\\x06\\xa1.....
  150. Testing the HID function
  151. ------------------------
  152. Device:
  153. - create the gadget
  154. - connect the gadget to a host, preferably not the one used
  155. to control the gadget
  156. - run a program which writes to /dev/hidg<N>, e.g.
  157. a userspace program found in Documentation/usb/gadget_hid.txt:
  158. $ ./hid_gadget_test /dev/hidg0 keyboard
  159. Host:
  160. - observe the keystrokes from the gadget
  161. 7. LOOPBACK function
  162. ====================
  163. The function is provided by usb_f_ss_lb.ko module.
  164. Function-specific configfs interface
  165. ------------------------------------
  166. The function name to use when creating the function directory is "Loopback".
  167. The LOOPBACK function provides these attributes in its function directory:
  168. qlen - depth of loopback queue
  169. bulk_buflen - buffer length
  170. Testing the LOOPBACK function
  171. -----------------------------
  172. device: run the gadget
  173. host: test-usb (tools/usb/testusb.c)
  174. 8. MASS STORAGE function
  175. ========================
  176. The function is provided by usb_f_mass_storage.ko module.
  177. Function-specific configfs interface
  178. ------------------------------------
  179. The function name to use when creating the function directory is "mass_storage".
  180. The MASS STORAGE function provides these attributes in its directory:
  181. files:
  182. stall - Set to permit function to halt bulk endpoints.
  183. Disabled on some USB devices known not to work
  184. correctly. You should set it to true.
  185. num_buffers - Number of pipeline buffers. Valid numbers
  186. are 2..4. Available only if
  187. CONFIG_USB_GADGET_DEBUG_FILES is set.
  188. and a default lun.0 directory corresponding to SCSI LUN #0.
  189. A new lun can be added with mkdir:
  190. $ mkdir functions/mass_storage.0/partition.5
  191. Lun numbering does not have to be continuous, except for lun #0 which is
  192. created by default. A maximum of 8 luns can be specified and they all must be
  193. named following the <name>.<number> scheme. The numbers can be 0..8.
  194. Probably a good convention is to name the luns "lun.<number>",
  195. although it is not mandatory.
  196. In each lun directory there are the following attribute files:
  197. file - The path to the backing file for the LUN.
  198. Required if LUN is not marked as removable.
  199. ro - Flag specifying access to the LUN shall be
  200. read-only. This is implied if CD-ROM emulation
  201. is enabled as well as when it was impossible
  202. to open "filename" in R/W mode.
  203. removable - Flag specifying that LUN shall be indicated as
  204. being removable.
  205. cdrom - Flag specifying that LUN shall be reported as
  206. being a CD-ROM.
  207. nofua - Flag specifying that FUA flag
  208. in SCSI WRITE(10,12)
  209. Testing the MASS STORAGE function
  210. ---------------------------------
  211. device: connect the gadget, enable it
  212. host: dmesg, see the USB drives appear (if system configured to automatically
  213. mount)
  214. 9. MIDI function
  215. ================
  216. The function is provided by usb_f_midi.ko module.
  217. Function-specific configfs interface
  218. ------------------------------------
  219. The function name to use when creating the function directory is "midi".
  220. The MIDI function provides these attributes in its function directory:
  221. buflen - MIDI buffer length
  222. id - ID string for the USB MIDI adapter
  223. in_ports - number of MIDI input ports
  224. index - index value for the USB MIDI adapter
  225. out_ports - number of MIDI output ports
  226. qlen - USB read request queue length
  227. Testing the MIDI function
  228. -------------------------
  229. There are two cases: playing a mid from the gadget to
  230. the host and playing a mid from the host to the gadget.
  231. 1) Playing a mid from the gadget to the host
  232. host)
  233. $ arecordmidi -l
  234. Port Client name Port name
  235. 14:0 Midi Through Midi Through Port-0
  236. 24:0 MIDI Gadget MIDI Gadget MIDI 1
  237. $ arecordmidi -p 24:0 from_gadget.mid
  238. gadget)
  239. $ aplaymidi -l
  240. Port Client name Port name
  241. 20:0 f_midi f_midi
  242. $ aplaymidi -p 20:0 to_host.mid
  243. 2) Playing a mid from the host to the gadget
  244. gadget)
  245. $ arecordmidi -l
  246. Port Client name Port name
  247. 20:0 f_midi f_midi
  248. $ arecordmidi -p 20:0 from_host.mid
  249. host)
  250. $ aplaymidi -l
  251. Port Client name Port name
  252. 14:0 Midi Through Midi Through Port-0
  253. 24:0 MIDI Gadget MIDI Gadget MIDI 1
  254. $ aplaymidi -p24:0 to_gadget.mid
  255. The from_gadget.mid should sound identical to the to_host.mid.
  256. The from_host.id should sound identical to the to_gadget.mid.
  257. MIDI files can be played to speakers/headphones with e.g. timidity installed
  258. $ aplaymidi -l
  259. Port Client name Port name
  260. 14:0 Midi Through Midi Through Port-0
  261. 24:0 MIDI Gadget MIDI Gadget MIDI 1
  262. 128:0 TiMidity TiMidity port 0
  263. 128:1 TiMidity TiMidity port 1
  264. 128:2 TiMidity TiMidity port 2
  265. 128:3 TiMidity TiMidity port 3
  266. $ aplaymidi -p 128:0 file.mid
  267. MIDI ports can be logically connected using the aconnect utility, e.g.:
  268. $ aconnect 24:0 128:0 # try it on the host
  269. After the gadget's MIDI port is connected to timidity's MIDI port,
  270. whatever is played at the gadget side with aplaymidi -l is audible
  271. in host's speakers/headphones.
  272. 10. NCM function
  273. ================
  274. The function is provided by usb_f_ncm.ko module.
  275. Function-specific configfs interface
  276. ------------------------------------
  277. The function name to use when creating the function directory is "ncm".
  278. The NCM function provides these attributes in its function directory:
  279. ifname - network device interface name associated with this
  280. function instance
  281. qmult - queue length multiplier for high and super speed
  282. host_addr - MAC address of host's end of this
  283. Ethernet over USB link
  284. dev_addr - MAC address of device's end of this
  285. Ethernet over USB link
  286. and after creating the functions/ncm.<instance name> they contain default
  287. values: qmult is 5, dev_addr and host_addr are randomly selected.
  288. Except for ifname they can be written to until the function is linked to a
  289. configuration. The ifname is read-only and contains the name of the interface
  290. which was assigned by the net core, e. g. usb0.
  291. Testing the NCM function
  292. ------------------------
  293. Configure IP addresses of the device and the host. Then:
  294. On the device: ping <host's IP>
  295. On the host: ping <device's IP>
  296. 11. OBEX function
  297. =================
  298. The function is provided by usb_f_obex.ko module.
  299. Function-specific configfs interface
  300. ------------------------------------
  301. The function name to use when creating the function directory is "obex".
  302. The OBEX function provides just one attribute in its function directory:
  303. port_num
  304. The attribute is read-only.
  305. There can be at most 4 ACM/generic serial/OBEX ports in the system.
  306. Testing the OBEX function
  307. -------------------------
  308. On device: seriald -f /dev/ttyGS<Y> -s 1024
  309. On host: serialc -v <vendorID> -p <productID> -i<interface#> -a1 -s1024 \
  310. -t<out endpoint addr> -r<in endpoint addr>
  311. where seriald and serialc are Felipe's utilities found here:
  312. https://github.com/felipebalbi/usb-tools.git master
  313. 12. PHONET function
  314. ===================
  315. The function is provided by usb_f_phonet.ko module.
  316. Function-specific configfs interface
  317. ------------------------------------
  318. The function name to use when creating the function directory is "phonet".
  319. The PHONET function provides just one attribute in its function directory:
  320. ifname - network device interface name associated with this
  321. function instance
  322. Testing the PHONET function
  323. ---------------------------
  324. It is not possible to test the SOCK_STREAM protocol without a specific piece
  325. of hardware, so only SOCK_DGRAM has been tested. For the latter to work,
  326. in the past I had to apply the patch mentioned here:
  327. http://www.spinics.net/lists/linux-usb/msg85689.html
  328. These tools are required:
  329. git://git.gitorious.org/meego-cellular/phonet-utils.git
  330. On the host:
  331. $ ./phonet -a 0x10 -i usbpn0
  332. $ ./pnroute add 0x6c usbpn0
  333. $./pnroute add 0x10 usbpn0
  334. $ ifconfig usbpn0 up
  335. On the device:
  336. $ ./phonet -a 0x6c -i upnlink0
  337. $ ./pnroute add 0x10 upnlink0
  338. $ ifconfig upnlink0 up
  339. Then a test program can be used:
  340. http://www.spinics.net/lists/linux-usb/msg85690.html
  341. On the device:
  342. $ ./pnxmit -a 0x6c -r
  343. On the host:
  344. $ ./pnxmit -a 0x10 -s 0x6c
  345. As a result some data should be sent from host to device.
  346. Then the other way round:
  347. On the host:
  348. $ ./pnxmit -a 0x10 -r
  349. On the device:
  350. $ ./pnxmit -a 0x6c -s 0x10
  351. 13. RNDIS function
  352. ==================
  353. The function is provided by usb_f_rndis.ko module.
  354. Function-specific configfs interface
  355. ------------------------------------
  356. The function name to use when creating the function directory is "rndis".
  357. The RNDIS function provides these attributes in its function directory:
  358. ifname - network device interface name associated with this
  359. function instance
  360. qmult - queue length multiplier for high and super speed
  361. host_addr - MAC address of host's end of this
  362. Ethernet over USB link
  363. dev_addr - MAC address of device's end of this
  364. Ethernet over USB link
  365. and after creating the functions/rndis.<instance name> they contain default
  366. values: qmult is 5, dev_addr and host_addr are randomly selected.
  367. Except for ifname they can be written to until the function is linked to a
  368. configuration. The ifname is read-only and contains the name of the interface
  369. which was assigned by the net core, e. g. usb0.
  370. Testing the RNDIS function
  371. --------------------------
  372. Configure IP addresses of the device and the host. Then:
  373. On the device: ping <host's IP>
  374. On the host: ping <device's IP>
  375. 14. SERIAL function
  376. ===================
  377. The function is provided by usb_f_gser.ko module.
  378. Function-specific configfs interface
  379. ------------------------------------
  380. The function name to use when creating the function directory is "gser".
  381. The SERIAL function provides just one attribute in its function directory:
  382. port_num
  383. The attribute is read-only.
  384. There can be at most 4 ACM/generic serial/OBEX ports in the system.
  385. Testing the SERIAL function
  386. ---------------------------
  387. On host: insmod usbserial
  388. echo VID PID >/sys/bus/usb-serial/drivers/generic/new_id
  389. On host: cat > /dev/ttyUSB<X>
  390. On target: cat /dev/ttyGS<Y>
  391. then the other way round
  392. On target: cat > /dev/ttyGS<Y>
  393. On host: cat /dev/ttyUSB<X>
  394. 15. SOURCESINK function
  395. =======================
  396. The function is provided by usb_f_ss_lb.ko module.
  397. Function-specific configfs interface
  398. ------------------------------------
  399. The function name to use when creating the function directory is "SourceSink".
  400. The SOURCESINK function provides these attributes in its function directory:
  401. pattern - 0 (all zeros), 1 (mod63), 2 (none)
  402. isoc_interval - 1..16
  403. isoc_maxpacket - 0 - 1023 (fs), 0 - 1024 (hs/ss)
  404. isoc_mult - 0..2 (hs/ss only)
  405. isoc_maxburst - 0..15 (ss only)
  406. bulk_buflen - buffer length
  407. bulk_qlen - depth of queue for bulk
  408. iso_qlen - depth of queue for iso
  409. Testing the SOURCESINK function
  410. -------------------------------
  411. device: run the gadget
  412. host: test-usb (tools/usb/testusb.c)
  413. 16. UAC1 function (legacy implementation)
  414. =================
  415. The function is provided by usb_f_uac1_legacy.ko module.
  416. Function-specific configfs interface
  417. ------------------------------------
  418. The function name to use when creating the function directory
  419. is "uac1_legacy".
  420. The uac1 function provides these attributes in its function directory:
  421. audio_buf_size - audio buffer size
  422. fn_cap - capture pcm device file name
  423. fn_cntl - control device file name
  424. fn_play - playback pcm device file name
  425. req_buf_size - ISO OUT endpoint request buffer size
  426. req_count - ISO OUT endpoint request count
  427. The attributes have sane default values.
  428. Testing the UAC1 function
  429. -------------------------
  430. device: run the gadget
  431. host: aplay -l # should list our USB Audio Gadget
  432. 17. UAC2 function
  433. =================
  434. The function is provided by usb_f_uac2.ko module.
  435. Function-specific configfs interface
  436. ------------------------------------
  437. The function name to use when creating the function directory is "uac2".
  438. The uac2 function provides these attributes in its function directory:
  439. c_chmask - capture channel mask
  440. c_srate - capture sampling rate
  441. c_ssize - capture sample size (bytes)
  442. p_chmask - playback channel mask
  443. p_srate - playback sampling rate
  444. p_ssize - playback sample size (bytes)
  445. req_number - the number of pre-allocated request for both capture
  446. and playback
  447. The attributes have sane default values.
  448. Testing the UAC2 function
  449. -------------------------
  450. device: run the gadget
  451. host: aplay -l # should list our USB Audio Gadget
  452. This function does not require real hardware support, it just
  453. sends a stream of audio data to/from the host. In order to
  454. actually hear something at the device side, a command similar
  455. to this must be used at the device side:
  456. $ arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 &
  457. e.g.:
  458. $ arecord -f dat -t wav -D hw:CARD=UAC2Gadget,DEV=0 | \
  459. aplay -D default:CARD=OdroidU3
  460. 18. UVC function
  461. ================
  462. The function is provided by usb_f_uvc.ko module.
  463. Function-specific configfs interface
  464. ------------------------------------
  465. The function name to use when creating the function directory is "uvc".
  466. The uvc function provides these attributes in its function directory:
  467. streaming_interval - interval for polling endpoint for data transfers
  468. streaming_maxburst - bMaxBurst for super speed companion descriptor
  469. streaming_maxpacket - maximum packet size this endpoint is capable of
  470. sending or receiving when this configuration is
  471. selected
  472. There are also "control" and "streaming" subdirectories, each of which contain
  473. a number of their subdirectories. There are some sane defaults provided, but
  474. the user must provide the following:
  475. control header - create in control/header, link from control/class/fs
  476. and/or control/class/ss
  477. streaming header - create in streaming/header, link from
  478. streaming/class/fs and/or streaming/class/hs and/or
  479. streaming/class/ss
  480. format description - create in streaming/mjpeg and/or
  481. streaming/uncompressed
  482. frame description - create in streaming/mjpeg/<format> and/or in
  483. streaming/uncompressed/<format>
  484. Each frame description contains frame interval specification, and each
  485. such specification consists of a number of lines with an inverval value
  486. in each line. The rules stated above are best illustrated with an example:
  487. # mkdir functions/uvc.usb0/control/header/h
  488. # cd functions/uvc.usb0/control/
  489. # ln -s header/h class/fs
  490. # ln -s header/h class/ss
  491. # mkdir -p functions/uvc.usb0/streaming/uncompressed/u/360p
  492. # cat <<EOF > functions/uvc.usb0/streaming/uncompressed/u/360p/dwFrameInterval
  493. 666666
  494. 1000000
  495. 5000000
  496. EOF
  497. # cd $GADGET_CONFIGFS_ROOT
  498. # mkdir functions/uvc.usb0/streaming/header/h
  499. # cd functions/uvc.usb0/streaming/header/h
  500. # ln -s ../../uncompressed/u
  501. # cd ../../class/fs
  502. # ln -s ../../header/h
  503. # cd ../../class/hs
  504. # ln -s ../../header/h
  505. # cd ../../class/ss
  506. # ln -s ../../header/h
  507. Testing the UVC function
  508. ------------------------
  509. device: run the gadget, modprobe vivid
  510. # uvc-gadget -u /dev/video<uvc video node #> -v /dev/video<vivid video node #>
  511. where uvc-gadget is this program:
  512. http://git.ideasonboard.org/uvc-gadget.git
  513. with these patches:
  514. http://www.spinics.net/lists/linux-usb/msg99220.html
  515. host: luvcview -f yuv
  516. 19. PRINTER function
  517. ====================
  518. The function is provided by usb_f_printer.ko module.
  519. Function-specific configfs interface
  520. ------------------------------------
  521. The function name to use when creating the function directory is "printer".
  522. The printer function provides these attributes in its function directory:
  523. pnp_string - Data to be passed to the host in pnp string
  524. q_len - Number of requests per endpoint
  525. Testing the PRINTER function
  526. ----------------------------
  527. The most basic testing:
  528. device: run the gadget
  529. # ls -l /devices/virtual/usb_printer_gadget/
  530. should show g_printer<number>.
  531. If udev is active, then /dev/g_printer<number> should appear automatically.
  532. host:
  533. If udev is active, then e.g. /dev/usb/lp0 should appear.
  534. host->device transmission:
  535. device:
  536. # cat /dev/g_printer<number>
  537. host:
  538. # cat > /dev/usb/lp0
  539. device->host transmission:
  540. # cat > /dev/g_printer<number>
  541. host:
  542. # cat /dev/usb/lp0
  543. More advanced testing can be done with the prn_example
  544. described in Documentation/usb/gadget_printer.txt.
  545. 20. UAC1 function (virtual ALSA card, using u_audio API)
  546. =================
  547. The function is provided by usb_f_uac1.ko module.
  548. It will create a virtual ALSA card and the audio streams are simply
  549. sinked to and sourced from it.
  550. Function-specific configfs interface
  551. ------------------------------------
  552. The function name to use when creating the function directory is "uac1".
  553. The uac1 function provides these attributes in its function directory:
  554. c_chmask - capture channel mask
  555. c_srate - capture sampling rate
  556. c_ssize - capture sample size (bytes)
  557. p_chmask - playback channel mask
  558. p_srate - playback sampling rate
  559. p_ssize - playback sample size (bytes)
  560. req_number - the number of pre-allocated request for both capture
  561. and playback
  562. The attributes have sane default values.
  563. Testing the UAC1 function
  564. -------------------------
  565. device: run the gadget
  566. host: aplay -l # should list our USB Audio Gadget
  567. This function does not require real hardware support, it just
  568. sends a stream of audio data to/from the host. In order to
  569. actually hear something at the device side, a command similar
  570. to this must be used at the device side:
  571. $ arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 &
  572. e.g.:
  573. $ arecord -f dat -t wav -D hw:CARD=UAC1Gadget,DEV=0 | \
  574. aplay -D default:CARD=OdroidU3