Jump to content


Photo

USB audio cards support (drivers and libs)


  • Please log in to reply
31 replies to this topic

#1 tsynik

tsynik

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 75 posts

Posted 08 February 2012 - 01:44 PM

As my idea was installing NOVO7 in the car instead of stereo, i need quality audio support.

So, there it is. I compiled drivers and libraries with mod, which supports not only HDMI, but also USB audio output.

Output mode controlled by property "media.audio.out.mode". values are: codec, hdmi, usb.

For enable USB sound card, copy files to device, and add this to init.sun4i.rc:

# USB Audio
	insmod /drv/snd-hwdep.ko
	insmod /drv/snd-rawmidi.ko
	insmod /drv/snd-usbmidi-lib.ko
	insmod /drv/snd-usb-audio.ko

After installing drivers (note the order!) and connecting any USB audio card, you'll probably find new devices in /dev/snd.

So, now you can use it with NOVO7. Just set "media.audio.out.mode" to "usb" via init.sun4i.rc.

I do it automatically via Tasker app on AC power ON, and switch back to "codec" on AC power OFF.

Here is the archive with all files.

p.s. Only issue i found is poor performance with connected 3G Modem at the same time, but it's related to Allwinners USB host kernel implementation itself.

p.p.s. Fogot to mention libs are for 2.3.4 firmwares, based on released source, IE 2.0.3. Tested with Feiyu MOD from 25th January.

Edited by tsynik, 08 February 2012 - 07:45 PM.

  • jpcastle and freeman1987 like this

#2 jpcastle

jpcastle

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 95 posts

Posted 08 February 2012 - 07:58 PM

As my idea was installing NOVO7 in the car instead of stereo, i need quality audio support.

So, there it is. I compiled drivers and libraries with mod, which supports not only HDMI, but also USB audio output.

Output mode controlled by property "media.audio.out.mode". values are: codec, hdmi, usb.

For enable USB sound card, copy files to device, and add this to init.sun4i.rc:

# USB Audio
	insmod /drv/snd-hwdep.ko
	insmod /drv/snd-rawmidi.ko
	insmod /drv/snd-usbmidi-lib.ko
	insmod /drv/snd-usb-audio.ko

After installing drivers (note the order!) and connecting any USB audio card, you'll probably find new devices in /dev/snd.

So, now you can use it with NOVO7. Just set "media.audio.out.mode" to "usb" via init.sun4i.rc.

I do it automatically via Tasker app on AC power ON, and switch back to "codec" on AC power OFF.

Here is the archive with all files.

p.s. Only issue i found is poor performance with connected 3G Modem at the same time, but it's related to Allwinners USB host kernel implementation itself.

p.p.s. Fogot to mention libs are for 2.3.4 firmwares, based on released source, IE 2.0.3. Tested with Feiyu MOD from 25th January.


Nice work! Send us some pics when you get it installed.

~JPC
ainol NOVO 7 Advanced - ICS 4.0.4 (IVI) CM9

Some people are wise... Some are otherwise.

#3 Sergey_F1

Sergey_F1

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 97 posts

Posted 10 February 2012 - 04:56 AM

Just set "media.audio.out.mode" to "usb" via init.sun4i.rc.
I do it automatically via Tasker app on AC power ON, and switch back to "codec" on AC power OFF.


Can You explain how set "media.audio.out.mode" to "usb" via Tasker?

Edited by Sergey_F1, 12 February 2012 - 01:54 AM.


#4 tsynik

tsynik

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 75 posts

Posted 12 February 2012 - 05:00 AM

Can You explain how set "media.audio.out.mode" to "usb" via Tasker?


Tasker can run any shell scripts via "Locale Execute Plugin" (and natively, but on Novo 7 it doesn't detect root mode yet). You can install it from Market, it's free (only plugin needed for Tasker). So, I use Plugin - > Execute with "@! setprop media.audio.out.mode codec" as configuration on AC off, and "@! setprop media.audio.out.mode usb" on AC on.

#5 Sergey_F1

Sergey_F1

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 97 posts

Posted 12 February 2012 - 08:24 AM

Tasker can run any shell scripts via "Locale Execute Plugin" (and natively, but on Novo 7 it doesn't detect root mode yet). You can install it from Market, it's free (only plugin needed for Tasker). So, I use Plugin - > Execute with "@! setprop media.audio.out.mode codec" as configuration on AC off, and "@! setprop media.audio.out.mode usb" on AC on.

Thank You for information. So, I can use sh-script "setprop media.audio.out.mode usb" for change out to usb via GScript or Script Manager?
In example init.rc.example You wrote

# It's better to control it via frameworks etc.
#setprop media.audio.out.mode usb

How I can control it via frameworks?

#6 tsynik

tsynik

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 75 posts

Posted 12 February 2012 - 03:52 PM

Thank You for information. So, I can use sh-script "setprop media.audio.out.mode usb" for change out to usb via GScript or Script Manager?
In example init.rc.example You wrote
How I can control it via frameworks?


True. you can set this property via adb shell by hand, with GSript, Script Manager or any other software with shell support.

#7 Hgshgs

Hgshgs

    Newbie

  • Jr. Member
  • Pip
  • 6 posts

Posted 28 February 2012 - 09:41 AM

Hi, great work! Shame I dont have an Ainol Novo 7 Advanced, but I do have a Novo 8 Adv. Is it possible to modify libs in Ainol Novo 8 to get this working? libaudio.so dont have any prop called media.audio.out.mode like yours. I got working ALSA with aplay - l showing my USB DAC (Fiio E10) with proper modules but can´t route Android audio to the DAC, I tried to change card 0 to 1 in alsa.conf w/out success. I really appreciate your help, As far as I know you are the only dev who could make this work with 2 different devices, Wits and Ainol Novo 7 Adv. Thanks!

#8 tsynik

tsynik

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 75 posts

Posted 29 February 2012 - 05:44 PM

Hi, great work! Shame I dont have an Ainol Novo 7 Advanced, but I do have a Novo 8 Adv. Is it possible to modify libs in Ainol Novo 8 to get this working? libaudio.so dont have any prop called media.audio.out.mode like yours. I got working ALSA with aplay - l showing my USB DAC (Fiio E10) with proper modules but can´t route Android audio to the DAC, I tried to change card 0 to 1 in alsa.conf w/out success. I really appreciate your help, As far as I know you are the only dev who could make this work with 2 different devices, Wits and Ainol Novo 7 Adv. Thanks!


Hi! As I know, kernel for NOVO8 is public, but android source is not. So, it's hard to change libs there (we need source to make changes). But, in NOVO8 exist FULL alsa support, so, you can route audio via /system/etc/asound.conf. Every line is meaningful, so, if you make mistake, whole file will be discarded by OS and some failsafe defaults will apply. I made working one on WITS only after some time and faults. Try to understand logcat on boot (alsa lines), and on playback start (which Playback stream is in use). try to set default in asound.conf

pcm.?default { type hw card 1 }

and playback stream

pcm.AndroidPlayback {
   type hw
   card 1
   device 0
}
The last effort is to inspect libaudio.so in HEX redactor, finding there /dev/snd/pcmC0D0p and change it to /dev/snd/pcmC1D0p (or /dev/snd/pcmC2D0p) if you have HDMI and your DAC is 3rd card. One byte change is enough ;-) So, it will always try to stream audio to USB DAC, and you will have no sound if there is no USB card connected ;-) You don't need to change /dev/snd/pcmC0D0c - it's probably internal MIC, and /dev/snd/ctlC0D0p - it's mixer control of internal sound card.

I'm sure it will work 99.9%, but you need to make changes in overwrite mode, so result lib will have exact size as original one. Have fun ;-)

Edited by tsynik, 01 March 2012 - 03:44 PM.


#9 DanBa

DanBa

    Newbie

  • Jr. Member
  • Pip
  • 6 posts

Posted 01 March 2012 - 10:09 AM

Hi Tsynik,

Could you please submit the missing USB audio code to Google (i.e. jbqueru)?

Thanks!


"
@jbqueru [Software Engineer working on Android Open-Source at Google]
Any plan to review the well-starred issue 24614 Enable USB Audio?
http://bit.ly/zH0t9R
USB DAC should be standard Android devices.

@DanielBa78 If someone submits code to implement that feature, it'll eventually get looked at."
https://twitter.com/#!/jbqueru

#10 tsynik

tsynik

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 75 posts

Posted 01 March 2012 - 03:57 PM

Hi Tsynik,

Could you please submit the missing USB audio code to Google (i.e. jbqueru)?

Thanks!


Hm, there are no special code for support USB sound devices in Android itself. It's all in Hardware Abstraction Layer, so it's always device specific.
We just need 3 base things: 1st: USB Host support in Android kernel. 2nd. USB audio driver, in kernel, or compiled as a module. 3rd. Some logic to switch to USB audio card, or back to internal one. So, it can be checkbox in Android preferences, or automatic switching via init.rc and it's on-device-added events. Last thing is your choise, you can set it in many ways (as it's controlled by property change, or, on other devices, by asound.conf rules), but it's not universal yet.

Edited by tsynik, 01 March 2012 - 04:00 PM.


#11 DanBa

DanBa

    Newbie

  • Jr. Member
  • Pip
  • 6 posts

Posted 01 March 2012 - 04:10 PM

Thanks!

I will twitter your sentence to the Google engineer.

#12 freeman1987

freeman1987

    Newbie

  • Jr. Member
  • Pip
  • 1 posts

Posted 02 March 2012 - 08:15 AM

hello! its my first post here! can anyone explain step by step how to install the drivers etc, I'm not very proffessional android user so I have no idea how to do it, thanx in advance!

update- it took me about 5 hours to get it done, but now my tablet is working with FiiO E7 via USB :):):) thank you so muuuuuch!

Edited by freeman1987, 02 March 2012 - 12:23 PM.


#13 Hgshgs

Hgshgs

    Newbie

  • Jr. Member
  • Pip
  • 6 posts

Posted 02 March 2012 - 11:09 AM

Hi! As I know, kernel for NOVO8 is public, but android source is not. So, it's hard to change libs there (we need source to make changes). But, in NOVO8 exist FULL alsa support, so, you can route audio via /system/etc/asound.conf. Every line is meaningful, so, if you make mistake, whole file will be discarded by OS and some failsafe defaults will apply. I made working one on WITS only after some time and faults. Try to understand logcat on boot (alsa lines), and on playback start (which Playback stream is in use). try to set default in asound.conf

pcm.?default { type hw card 1 }

and playback stream

pcm.AndroidPlayback {
   type hw
   card 1
   device 0
}
The last effort is to inspect libaudio.so in HEX redactor, finding there /dev/snd/pcmC0D0p and change it to /dev/snd/pcmC1D0p (or /dev/snd/pcmC2D0p) if you have HDMI and your DAC is 3rd card. One byte change is enough ;-) So, it will always try to stream audio to USB DAC, and you will have no sound if there is no USB card connected ;-) You don't need to change /dev/snd/pcmC0D0c - it's probably internal MIC, and /dev/snd/ctlC0D0p - it's mixer control of internal sound card.

I'm sure it will work 99.9%, but you need to make changes in overwrite mode, so result lib will have exact size as original one. Have fun ;-)


tsynik, thanks a lot. This is very useful information for lots of people interested on this issue. I´m going to try with Novo 8. Thanks again.

#14 IanJames

IanJames

    Newbie

  • Jr. Member
  • Pip
  • 2 posts

Posted 09 March 2012 - 05:01 AM

Hi,

Reading your posts with regard to USB, I was wondering whether you have any ideas on the following:

Does the Novo 7 Paladin support USB host mode?

If so does it need to be enabled in the kernel and how can this be done?

I ask because I would like to be able to send and receive serial data (AT commands) to a serial cable plugged into the mini usb port.

Any advice would be gratefully appreciated.

Thanks

Ian James

#15 tsynik

tsynik

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 75 posts

Posted 14 March 2012 - 12:51 PM

Hi,

Reading your posts with regard to USB, I was wondering whether you have any ideas on the following:

Does the Novo 7 Paladin support USB host mode?

If so does it need to be enabled in the kernel and how can this be done?

I ask because I would like to be able to send and receive serial data (AT commands) to a serial cable plugged into the mini usb port.

Any advice would be gratefully appreciated.

Thanks

Ian James


If you can use 3G dongles or USB sticks on Paladin, then it have USB host mode. For AT commands on USB port you need CDC ACM support in kernel, which depends on USB HOST but different. Or some kind of serial converter and it's driver like pl2303. That's all i can say. And this thread is about USB audio, make new one in Paladin forum if you want some hints )

#16 DanBa

DanBa

    Newbie

  • Jr. Member
  • Pip
  • 6 posts

Posted 17 March 2012 - 03:38 PM

@tsynik

How about the Sound Quality of your USB audio rig?

Is it at the same level than the USB audio SQ from a (average) PC?

I am quite surprised about the occasional crackles and glitches from the USB audio-capable Archos G9:
http://forum.archosf...p?f=85&p=393834

"(1) USB audio playback shows some glitches (for example, during network access, harddisk access, high CPU load). I even observed some pitching under CPU load. But it generally works, best performance is with local file access. As expected, audio quality via external DAC is a lot better than the internal headphone connector (which - to my ears - sounds remarkably bad, even my old Nokia phone sounds significantly better)."

"(1) USB PCM2902 based DIY design (this is a standard USB chip used in many products):
This is a self powered device, and works immediately. Quality issues are as mentioned in my previous post (crackles and glitches). These occur very frequently, so this is not really what you want when you'd like to enjoy your audiophile HD FLAC files."

"(3) Creative X-Fi USB:
This is USB bus powered, and does not work when directly connected to the tablet. You need to connected via self-powered USB hub, then the USB link is established, and playback changes to the external DAC. Volume control is not active, so you need to use the tablet's volume control. Playback is occasionally interrupted by some nasty noise, USB link is lost (LED on X-Fi goes off), then it gets re-connected, and playback can be resumed. When it's stable then I still get crackles and glitches occasionally, like with the PCM2902."


By the way, what are the other components of your rig?

Thanks

Edited by DanBa, 17 March 2012 - 04:33 PM.


#17 zrz510new

zrz510new

    Newbie

  • Jr. Member
  • Pip
  • 1 posts

Posted 19 March 2012 - 08:45 AM

Hi tsynik,
I can't download the USB audio cards drivers and libs from http://dl.dropbox.co...A/USB-AUDIO.zip, I ask you can send these to my mail box:zrz510@yahoo.cn.
Thanks!

Best Regards,
Zou Zheng-Rong

#18 tsynik

tsynik

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 75 posts

Posted 19 March 2012 - 06:00 PM

@tsynik

How about the Sound Quality of your USB audio rig?

Is it at the same level than the USB audio SQ from a (average) PC?

I am quite surprised about the occasional crackles and glitches from the USB audio-capable Archos G9:
http://forum.archosf...p?f=85&p=393834

[skip]

By the way, what are the other components of your rig?

Thanks


Hi, I don't have any glitches with my DAC setup. I used Creative SB Live 24 USB before, but switched to Burr-Brown PCM2704 USB DAC (Chinese MUSE). It have USB 2.0 interface (Creative have 1.1), and there is no pump sound to external amplifier in my car on power on with it.

Craclies often related to USB hub / host / driver implementation. For example, current allwinner USB Host driver in Android 2.3 doesn't work fine with USB DAC and 3G modem, working in the same USB Hub. There are errors of USB transmission in dmesg and sound goes choppy when 3G connection works. Also, I have some crackles, when my 3D screensawer switched on and off, or on load Navigation software, probably it's related to interrupts or screen rendering. And i has no sound issues at all on Android 2.2 with omap4 tab and same DAC before.

#19 DanBa

DanBa

    Newbie

  • Jr. Member
  • Pip
  • 6 posts

Posted 20 March 2012 - 07:53 PM

Thanks!

#20 saanichtonian

saanichtonian

    Newbie

  • Jr. Member
  • Pip
  • 4 posts

Posted 24 March 2012 - 08:38 PM

Hi

This looks interesting.

Would it be possible to use these files to get A USB headset (with microphone) working with the novo7a ?

The headset presently shows up when plugged into the tablet, however it doesn't do anything except allow the tablet volume to be adjusted.

I'm just wondering if it's possible to get both reasonable sound and the microphone working for use with skype etc.


thanks
saanichtonian

Edited by saanichtonian, 28 March 2012 - 07:17 PM.