{"id":1870,"date":"2016-05-09T20:15:03","date_gmt":"2016-05-09T12:15:03","guid":{"rendered":"http:\/\/www.51cos.com\/?p=1870"},"modified":"2016-05-21T18:59:35","modified_gmt":"2016-05-21T10:59:35","slug":"turn-your-linux-computer-into-a-huge-android-usb-accessory","status":"publish","type":"post","link":"http:\/\/www.51cos.com\/?p=1870","title":{"rendered":"TURN YOUR LINUX COMPUTER INTO A HUGE ANDROID USB ACCESSORY"},"content":{"rendered":"<p>\u53c2\u8003\u6587\u7ae0\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p><b class=\"Blog_b1\"><\/b> <a href=\"http:\/\/blog.chinaunix.net\/uid-25272011-id-3153434.html\">\u5173\u4e8eUSB-AUDIO\u4f7f\u7528ALSA\u7f16\u7a0b\u7684\u4e00\u70b9\u95ee\u9898<\/a>:http:\/\/blog.chinaunix.net\/uid-25272011-id-3153434.html<\/p>\n<p>&nbsp;<br \/>\n\u624b\u628a\u624b\u6559\u4f60\u7528\u6811\u8393\u6d3e(Raspberry Pi)\u6253\u9020\u5b87\u5b99\u7ffb\u8bd1\u673a :<br \/>\nhttp:\/\/oszine.com\/universal-translator\/<br \/>\nCreating a Simple USB Audio and HID Accesory for Android using a Raspberry Pi:<br \/>\nhttp:\/\/tcorley.me\/simple-aoa-raspberry-pi\/<br \/>\nhttps:\/\/bugzilla.kernel.org\/show_bug.cgi?id=60769<br \/>\nhttps:\/\/source.android.com\/devices\/accessories\/aoa2.html#hid-support<br \/>\nhttps:\/\/source.android.com\/devices\/input\/overview.html<\/p>\n<p>http:\/\/wiki.audacityteam.org\/index.php?title=USB_mic_on_Linux<br \/>\nhttps:\/\/wiki.archlinux.org\/index.php\/Advanced_Linux_Sound_Architecture#Configuration<br \/>\nhttp:\/\/wiki.audacityteam.org\/wiki\/USB_mic_on_Linux<br \/>\nhttps:\/\/help.ubuntu.com\/community\/UbuntuStudio\/UsbAudioDevices<\/p>\n<p>http:\/\/www.alsa-project.org\/main\/index.php\/Matrix:Module-usb-audio<br \/>\nhttp:\/\/raspberrypi.stackexchange.com\/questions\/40831\/how-do-i-configure-my-sound-for-jasper-on-raspbian-jessie<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>http:\/\/android.serverbox.ch\/?p=262<\/p>\n<p>http:\/\/forum.xda-developers.com\/showthread.php?t=1852343<\/p>\n<p>https:\/\/github.com\/KunYi\/pcaoa\/blob\/master\/sw_droid_accessory_mode.cpp<\/p>\n<p>http:\/\/oszine.com\/universal-translator\/<br \/>\nhttp:\/\/wiki.audacityteam.org\/index.php?title=USB_mic_on_Linux<\/p>\n<p>http:\/\/users.suse.com\/~mana\/alsa090_howto.html<\/p>\n<p>http:\/\/equalarea.com\/paul\/alsa-audio.html<\/p>\n<p><a href=\"http:\/\/www.51cos.com\/wp-content\/uploads\/2016\/05\/Linux-ALSA\u58f0\u5361\u9a71\u52a8.pdf\">Linux-ALSA\u58f0\u5361\u9a71\u52a8<\/a><\/p>\n<p><a href=\"http:\/\/www.51cos.com\/wp-content\/uploads\/2016\/05\/Linux_ALSA\u58f0\u5361\u9a71\u52a8\u539f\u7406\u5206\u6790.pdf\">Linux_ALSA\u58f0\u5361\u9a71\u52a8\u539f\u7406\u5206\u6790<\/a><br \/>\n\u53c2\u8003\u4ee3\u7801\uff1a<br \/>\n<a href=\"http:\/\/www.51cos.com\/wp-content\/uploads\/2016\/05\/sw_droid_accessory_mode.zip\">sw_droid_accessory_mode<\/a><\/p>\n<pre class=\"prettyprint linenums\">root@clq-ubuntu:~# sudo apt-get install mtpfs libfuse-dev libmad0-dev<br \/>\napt-get source libusb<br \/>\napt-get install libusb-dev<br \/>\napt-get install libusb-1.0-0-dev<br \/>\ngcc simplectrl.c -I\/usr\/include\/ -o simplectrl -lusb-1.0 -I\/usr\/include\/ -I\/usr\/include\/libusb-1.0<\/p>\n<p>\u5982\u4f55\u5224\u65ad\u662f\u5426\u652f\u6301Audio\uff1a<\/p>\n<pre class=\"prettyprint linenums\">sudo lsusb -d 18d1:2d04 -v | grep \"Audio\"<\/p>\n<p>      bInterfaceClass         1 Audio # \u8868\u793a\u652f\u6301Audio<br \/>\n      AudioControl Interface Descriptor:<br \/>\n      AudioControl Interface Descriptor:<br \/>\n      AudioControl Interface Descriptor:<br \/>\n      AudioControl Interface Descriptor:<br \/>\n      bInterfaceClass         1 Audio<br \/>\n      bInterfaceClass         1 Audio<br \/>\n      AudioStreaming Interface Descriptor:<br \/>\n      AudioStreaming Interface Descriptor:<br \/>\n        AudioControl Endpoint Descriptor:<\/p>\n<pre class=\"prettyprint linenums\">cat \/proc\/asound\/cards<br \/>\n 0 [AudioPCI       ]: ENS1371 - Ensoniq AudioPCI<br \/>\n                      Ensoniq AudioPCI ENS1371 at 0x2080, irq 16<br \/>\n 1 [Pro            ]: USB-Audio - MX4 Pro<br \/>\n                      MEIZU MX4 Pro at usb-0000:02:03.0-1, high speed<\/p>\n<pre class=\"prettyprint linenums\">cat \/proc\/asound\/modules<br \/>\n 0 snd_ens1371<br \/>\n 1 snd_usb_audio<\/p>\n<p>card 0\uff08\u9884\u8bbe\u8f93\u51fa\uff09\u7684\u9a71\u52a8\u7a0b\u5e8f\u662fsnd_ens1371\uff0c\u3002card 1\u7684\u9a71\u52a8\u7a0b\u5e8f\u662fsnd_usb_audio<\/p>\n<p>\u8c03\u8bd5ALSA\u5e38\u7528\u547d\u4ee4\uff1a<\/p>\n<pre class=\"prettyprint linenums\">aplay -l<\/p>\n<p>ls -lart \/dev\/snd<br \/>\ncat \/dev\/sndstat<br \/>\nlsmod | grep snd<br \/>\nalsactl -v \/\/\u67e5\u770bALSA\u7248\u672c<br \/>\nlsusb -vvv<br \/>\nwget -O alsa-info.sh http:\/\/www.alsa-project.org\/alsa-info.sh &amp;&amp; chmod +x .\/alsa-info.sh &amp;&amp; .\/alsa-info.sh<\/p>\n<pre class=\"prettyprint linenums\">\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 AlsaMixer v1.0.22 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 Card: MX4 Pro                                        F1:  Help               \u2502<br \/>\n\u2502 Chip: USB Mixer                                      F2:  System information \u2502<br \/>\n\u2502 View: F3: Playback  F4: Capture  F5: All             F6:  Select sound card  \u2502<br \/>\n\u2502 Item:                                                Esc: Exit               \u2502<br \/>\n\u2502                                                                              \u2502<br \/>\n\u2502                                                                              \u2502<br \/>\n\u2502                                                                              \u2502<br \/>\n\u2502                This sound device does not have any controls.  <\/p>\n<p>\u5b89\u88c5alsa-driver,alsa-utils,alsa-lib<br \/>\n\u53c2\u8003\uff1ahttp:\/\/www.360doc.com\/content\/12\/0913\/22\/9615799_235991212.shtml<br \/>\nhttp:\/\/www.alsa-project.org\/main\/index.php\/Download<\/p>\n<pre class=\"prettyprint linenums\">\/\/\u67e5\u770b\u5f53\u524d\u7248\u672c\u53f7<br \/>\ncat \/proc\/asound\/version<br \/>\nAdvanced Linux Sound Architecture Driver Version 1.0.21.<\/p>\n<p>\/\/\u505c\u6b62ALSA\u5e94\u7528<br \/>\nsudo \/sbin\/alsa-utils stop<\/p>\n<p>\/\/\u5b89\u88c5\u7f16\u8bd1\u6240\u4f9d\u8d56\u7684\u5de5\u5177<br \/>\nsudo apt-get -y install build-essential ncurses-dev gettext xmlto libasound2-dev<br \/>\nsudo apt-get -y install linux-headers-`uname -r` libncursesw5-dev<\/p>\n<p>\/\/\u4e0b\u8f7d\u6e90\u6587\u4ef6<br \/>\ncd ~<br \/>\nrm -rf ~\/alsa* ~\/.pulse*<br \/>\nwget ftp:\/\/ftp.alsa-project.org\/pub\/driver\/alsa-driver-1.0.23.tar.bz2<br \/>\nwget ftp:\/\/ftp.alsa-project.org\/pub\/lib\/alsa-lib-1.0.23.tar.bz2<br \/>\nwget ftp:\/\/ftp.alsa-project.org\/pub\/utils\/alsa-utils-1.0.23.tar.bz2<\/p>\n<p>\/\/\u5220\u9664\u539f\u6765\u7684\u76ee\u5f55\uff0c\u5e76\u62f7\u8d1d\u6e90\u6587\u4ef6\u8fc7\u6765<br \/>\nsudo rm -rf \/usr\/src\/alsa<br \/>\nsudo mkdir -p \/usr\/src\/alsa<br \/>\ncd \/usr\/src\/alsa<br \/>\nsudo cp ~\/alsa* .<\/p>\n<p>\/\/\u89e3\u538b<br \/>\nsudo tar xjf alsa-driver*<br \/>\nsudo tar xjf alsa-lib*<br \/>\nsudo tar xjf alsa-utils*<\/p>\n<p>\/\/\u7f16\u8bd1driver<br \/>\ncd alsa-driver*<br \/>\nsudo .\/configure<br \/>\nsudo make<br \/>\nsudo make install<\/p>\n<p>\/\/\u7f16\u8bd1library<br \/>\ncd ..\/alsa-lib*<br \/>\nsudo .\/configure<br \/>\nsudo make<br \/>\nsudo make install<\/p>\n<p>\/\/\u7f16\u8bd1\u5e94\u7528<br \/>\ncd ..\/alsa-utils*<br \/>\nsudo .\/configure<br \/>\nsudo make<br \/>\nsudo make install<\/p>\n<p>\/\/\u5220\u9664\u6e90\u6587\u4ef6<br \/>\nrm -f ~\/alsa-driver*<br \/>\nrm -f ~\/alsa-lib*<br \/>\nrm -f ~\/alsa-utils*<br \/>\n\/\/\u91cd\u542f\u7cfb\u7edf<br \/>\nsudo reboot<br \/>\n\/\/\u67e5\u770b\u7248\u672c\u53f7<br \/>\ncat \/proc\/asound\/version<br \/>\nAdvanced Linux Sound Architecture Driver Version 1.0.23.<br \/>\nCompiled on May 2 2010 for kernel 2.6.32-21-generic (SMP).<\/p>\n<p>\u4f46\u662f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u5374\u6ca1\u6709\u751f\u6548   \u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u3002<\/p>\n<pre class=\"prettyprint linenums\">denny@ubuntu:\/dev\/snd<span class=\"katex math inline\">dpkg -l | grep asou<br \/>\nii  libasound2                           1.0.22-0ubuntu7                                 shared library for ALSA applications<br \/>\nii  libasound2-dev                       1.0.22-0ubuntu7                                 shared library for ALSA applications -- deve<br \/>\nii  libasound2-plugins                   1.0.22-0ubuntu6                                 ALSA library additional plugins<br \/>\ndenny@ubuntu:\/dev\/snd<\/span> dpkg -l | grep alsa<br \/>\nii  alsa-base                            1.0.22.1+dfsg-0ubuntu3                          ALSA driver configuration files<br \/>\nii  alsa-firmware-loaders                1.0.22-0ubuntu1                                 ALSA software loaders for specific hardware<br \/>\nii  alsa-source                          1.0.22.1+dfsg-0ubuntu3                          ALSA driver sources<br \/>\nii  alsa-utils                           1.0.22-0ubuntu5                                 ALSA utilities<br \/>\nii  alsamixergui                         0.9.0rc2-1-9                                    graphical soundcard mixer for ALSA soundcard<br \/>\nii  bluez-alsa                           4.60-0ubuntu8                                   Bluetooth audio support<br \/>\nii  gstreamer0.10-alsa                   0.10.28-1                                       GStreamer plugin for ALSA<\/p>\n<p>\/\/\u786e\u8ba4\u529f\u80fd\u662f\u5426\u6b63\u5e38<br \/>\nsudo alsaconf<\/p>\n<p>When I use Ubuntu 10.04, after switch LG G4 to Audio mode:<\/p>\n<pre class=\"prettyprint linenums\">ls \/dev\/snd<br \/>\nby-id    controlC0  midiC0D0  pcmC0D0p    timer<br \/>\nby-path  controlC1  pcmC0D0c  pcmC0D1p  seq<\/p>\n<pre class=\"prettyprint linenums\"> sudo arecord -l<br \/>\n[sudo] password for denny:<br \/>\n**** List of CAPTURE Hardware Devices ****<br \/>\ncard 0: AudioPCI [Ensoniq AudioPCI], device 0: ES1371\/1 [ES1371 DAC2\/ADC]<br \/>\n  Subdevices: 1\/1<br \/>\n  Subdevice #0: subdevice #0<\/p>\n<p>I can not find my USB Audio device,only controlC1 is shown but no pcmC1D0c.<\/p>\n<p>So I have to update my Ubuntu from 10.04 to 12.04 ,then my USB Audio device appear:<\/p>\n<pre class=\"prettyprint linenums\">ls \/dev\/snd<br \/>\nby-id    controlC0  midiC0D0  pcmC0D0p  pcmC1D0c  timer<br \/>\nby-path  controlC1  pcmC0D0c  pcmC0D1p  seq<\/p>\n<pre class=\"prettyprint linenums\"> sudo arecord -l<br \/>\n[sudo] password for denny:<br \/>\n**** List of CAPTURE Hardware Devices ****<br \/>\ncard 0: AudioPCI [Ensoniq AudioPCI], device 0: ES1371\/1 [ES1371 DAC2\/ADC]<br \/>\n  Subdevices: 1\/1<br \/>\n  Subdevice #0: subdevice #0<br \/>\ncard 1: Phone [LGE Android Phone], device 0: USB Audio [USB Audio]<br \/>\n  Subdevices: 1\/1<br \/>\n  Subdevice #0: subdevice #0<\/p>\n<p>But I have another issue:<\/p>\n<p>&nbsp;<\/p>\n<p>http:\/\/comments.gmane.org\/gmane.linux.usb.general\/71286<\/p>\n<pre class=\"prettyprint linenums\">sudo arecord  -f cd -d 5  -D hw:1,0<br \/>\nRecording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo<br \/>\narecord: pcm_read:1801: read error: Input\/output error<\/p>\n<pre class=\"prettyprint linenums\">#dmesg<br \/>\n[ 5092.841145] capture write error (DMA or IRQ trouble?)<br \/>\n[ 5093.840767] timeout: still 11 active urbs on EP #82<br \/>\n[ 5094.840698] timeout: still 10 active urbs on EP #82<br \/>\n[ 5095.840688] timeout: still 9 active urbs on EP #82<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u8003\u6587\u7ae0\uff1a &nbsp; \u5173\u4e8eUSB-AUDIO\u4f7f\u7528ALSA\u7f16\u7a0b\u7684\u4e00\u70b9\u95ee\u9898:http:\/\/blog.china [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1870","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1870"}],"version-history":[{"count":19,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1870\/revisions"}],"predecessor-version":[{"id":1913,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1870\/revisions\/1913"}],"wp:attachment":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1870"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}