Thanks to the trinity kernel, morfic and a very nice FiiO E10 USB dac, I have excellent audio quality in my car through my dash mounted nexus 7. It has worked flawlessly for weeks without issue.
Unfortunately as morfic pointed out in his kernel thread, with a USB DAC enabled and his asound.conf changes, we destroy the audio input. No IP phone calls/ video recording... they crash since the audio input configuration is messed up.
We need to merge the asound.conf USB DAC output changes with the stock asound.conf. I've tried all permutations of this that I think make sense and I've had zero luck. Heck, if I go back to the stock asound.conf my USB DAC still works and audio input is still broken.
If there are any alsa gurus out there, please speak up and give us 10 minutes of your time. I've spent hours on this, reading alsa docs and trying asound.conf changes.
Not sure if it matters, but I'm using the stock JB rom with just the upgraded trinity kernel.
for reference: the stock asound.conf is:
#
# ALSA library configuration file
#
pcm.!default {
type plug
slave {
pcm "hw:tegrart5640,0"
channels 2
rate 48000
}
}
ctl.!default {
type hw
card tegrart5640
}
pcm.music {
type plug
slave {
pcm "hw:tegrart5640,0"
channels 2
rate 48000
}
}
pcm.aux {
type hw
card "Tegra"
device 3
}
pcm.voice {
type plug
slave {
pcm "hw:tegrart5640,2"
channels 1
rate 8000
}
}
pcm.aux_plug {
type plug
slave.pcm "aux"
}
pcm.music_and_voice {
type asym
playback.pcm {
type plug
slave.pcm {
type multi
slaves.a.pcm music
slaves.b.pcm voice
slaves.a.channels 2
slaves.b.channels 1
bindings.0.slave a
bindings.0.channel 0
bindings.1.slave a
bindings.1.channel 1
bindings.2.slave b
bindings.2.channel 0
}
route_policy duplicate
}
capture.pcm "voice"
}
Click to expand...
Click to collapse
The updated changes from morfic are:
pcm.usbdac {
type hw;
card Audio;
}
ctl.usbdac {
type hw;
card Audio;
}
pcm.!default usbdac
Click to expand...
Click to collapse
Thanks!
did you have a look at this yet?
http://rootzwiki.com/topic/30129-kernel-nexus-7-cifsnfsusb-otg-gpu-oc-cpu-oc-072912/
Tried that kernel, same results as trinity.
I'm pretty well stuck in the same situation. My main reason for wanting usb audio is for connecting a better mic to the nexus 7.
I tried some variations in the asound.conf with no impact either.
It is supposed to be asound.conf in /system/etc correct? I ask, because I completely emptied the file, and everything still works exactly the same. Normal mic and internal sound, and usb sound out after a reboot.... my asound.conf still currently sits empty.
Maybe this information will help get things started. Here's stuff from my /proc/asound directory with the usb device plugged in.
Code:
sh-3.2# ls -a /proc/asound/
. Tegra card2 hwdep timers
.. card0 cards pcm version
Device card1 devices tegrart5640
Code:
sh-3.2# cat /proc/asound/devices
2: [ 0- 3]: digital audio playback
3: [ 0] : control
4: [ 1- 0]: digital audio playback
5: [ 1- 0]: digital audio capture
6: [ 1] : control
7: [ 2- 2]: digital audio playback
8: [ 2- 2]: digital audio capture
9: [ 2- 1]: digital audio playback
10: [ 2- 1]: digital audio capture
11: [ 2- 0]: digital audio playback
12: [ 2- 0]: digital audio capture
13: [ 2- 0]: hardware dependent
14: [ 2] : control
33: : timer
Code:
sh-3.2# cat cards
0 [Tegra ]: HDA-Intel - HDA NVIDIA Tegra
HDA NVIDIA Tegra at 0x70038000 irq 113
1 [Device ]: USB-Audio - USB PnP Sound Device
C-Media Electronics Inc. USB PnP Sound Device at usb-tegra-ehci.0-1, full speed
2 [tegrart5640 ]: tegra-rt5640 - tegra-rt5640
tegra-rt5640
Code:
sh-3.2# ls Device
id pcm0c pcm0p stream0 usbbus usbid usbmixer
Code:
sh-3.2# cat pcm
00-03: HDMI 0 : HDMI 0 : playback 1
01-00: USB Audio : USB Audio : playback 1 : capture 1
02-00: RT5640 PCM rt5640-aif1-0 : : playback 1 : capture 1
02-01: SPDIF PCM dit-hifi-1 : : playback 1 : capture 1
02-02: BT SCO PCM dit-hifi-2 : : playback 1 : capture 1
More information.
Code:
bash-3.2# lsusb
Bus 002 Device 001: ID 1d6b:0002
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 002: ID 0d8c:0139
First device is present in lsusb before I plug the usb device in. Dmesg seems to show the second as the host controller..
Some dmesg output right after plugging in.
Code:
[ 586.426776] usb 2-1: new full speed USB device number 2 using tegra-ehci
[ 586.473084] usb 2-1: New USB device found, idVendor=0d8c, idProduct=0139
[ 586.473493] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 586.473712] usb 2-1: Product: USB PnP Sound Device
[ 586.474095] usb 2-1: Manufacturer: C-Media Electronics Inc.
[ 586.499589] input: C-Media Electronics Inc. USB PnP Sound Device as /devices/platform/tegra-ehci.0/usb2/2-1/2-1:1.3/input/input4
[ 586.500399] keychord: using input dev C-Media Electronics Inc. USB PnP Sound Device for fevent
[ 586.500701] generic-usb 0003:0D8C:0139.0002: input: USB HID v1.00 Device [C-Media Electronics Inc. USB PnP Sound Device] on usb-tegra-ehci.0-1/input3
This is my first time participating in any forum. I've always been an irc geek. So I'm not entirely sure how to promote an interest in this topic, or if we need a new specific thread. Also.. excuse any newb annoyances on my part as I adjust...
I'm pretty well willing to try anything with my nexus 7. No consern for loosing data or starting from scratch... any rom, kernel, tweak.. if anybody has suggestions or want me to try/test something.
I have a feeling this is configuration related, maybe not asound.conf... I messed with audio_policy.conf no luck, but it did have an impact on my input when I tried a few input lines similar to top lines for internal, but in USB section at bottom. I ended up with a continuous buzz on input, and it was still buzzing on input when I pulled the USB device. No change in wave form when tapping mics.. so no good, but I was excited that I had an impact on the input channel at all. Might just be bad lines I used.. was just guessing at config based on rest of file.
I'll try to remember to post what I put in audio_policy.conf later.
Wish I had aplay and arecord to test each device. Tried tinycap with no luck.
Sent from my Nexus 7 using XDA Premium HD app
Glad someone else is excited about getting this working!
I believe you can grab alsa binaries from the play store for free. I played with it a few weeks back and the alsa tools seem to work.
I haven't seen those? I was looking for alsa tools for android tools the other day and could only come up with tinycap, tinymix, and tinyplay with a libtinyalsa.so on another forum... but they aren't utilizing the right devices when I give them device numbers and only throw errors. If you could point me at the tools, that'd be cool.
Do you think we need to start a thread on a different part of the forum? like in a development section? or... ionno...
I honestly don't really know how this works. I am seeing the importance of threads vs just sharing info on irc as I get older... and if/when I do a little bit of work towards something or digging of information.. I do like that it gets passed along to somebody else, is discoverable by others using google, and that it is a contribution to the geek community that I have always been proud to consider myself a part of.
I think here is a good place to start. Someone out there definitely knows exactly how to do this and the more exposure the better. XDA is awesome for that.
As per your previous question, search for alsa mixer in the market. You'll need to install busy box as well.
Can you post your audio_policy.conf changes? I'll try to fiddle with it as well.
OP, the problem that I'm seeing that you now have two default devices, i.e. two definitions of "pcm.!default" (BTW, the exclamation mark overrides built-in defaults) and the latter one takes precedence, I think. Hence, any application using the sound card using the default parameters, as most apps (minus built-in ones) would probably do will grab your DAC which does not have a microphone input. If you had a DAC+ADC you can make this probably work fairly easily. I'm not an ALSA "guru", but someone who has had quite some exposure. I hesitate giving you blind suggestions, but a good place to start is the asoundrc documentation on the alsa-project web pages (can't post links yet)
You may want to look into setting up "multi", "dmix", and/or "dnsoop" devices that combine your DAC with the built-in one. Good luck.
Thanks for the pointers. I've read through much of that documentation but I'll be honest I really got lost. I'll try it again.
I only have one pcm.!default definition in each config file. I do not append the changes from morfic, I replace the entire file.
I'm a little concerned that as we've discovered, we can delete the asound.conf file or put completely invalid junk in it and we are unable to change the behavior... I don't want to spend hours perhaps crossing over a correct asound.conf only to realize something else was preventing my configuration from being successful...
Right now, I'm just trying to get any change from asound.conf to reflect the audio configuration of android. Maybe asound.conf is ignored if there is an invalid config and I've yet to put a valid config?
I'll post the audio_policy.conf tomorrow when I get to work. I'll have a little extra time, I really just based what I added on how the entries above it looked... I'm probably way off.
Also... I do honestly believe the asound.conf has no impact on the audio at all... Mine's still empty... works the same...
papatel said:
I think here is a good place to start. Someone out there definitely knows exactly how to do this and the more exposure the better. XDA is awesome for that.
As per your previous question, search for alsa mixer in the market. You'll need to install busy box as well.
Can you post your audio_policy.conf changes? I'll try to fiddle with it as well.
Click to expand...
Click to collapse
The changes I made, just the bottom usb section of audio_policy.conf. I left everything above it the same.
Code:
usb {
inputs {
usb_accessory {
sampling_rates 44100
channel_masks AUDIO_CHANNEL_IN_MONO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_IN_USB_ACCESSORY
}
usb_device {
sampling_rates 44100
channel_masks AUDIO_CHANNEL_IN_MONO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_IN_USB_DEVICE
}
}
outputs {
usb_accessory {
sampling_rates 44100
channel_masks AUDIO_CHANNEL_OUT_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_OUT_USB_ACCESSORY
}
usb_device {
sampling_rates 44100
channel_masks AUDIO_CHANNEL_OUT_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_OUT_USB_DEVICE
}
}
}
}
Like I said, this did nothing except create a continuous buzz on the input channel, even after checking it with usb device in, and then pulling the device and checking again without the device.... still buzzing... but as I said, I was just pleased that I managed to find something that actually had an impact on the input channel at all. Maybe with a little more fiddling, the right settings, maybe this is the file to focus on... until somebody more informed tells me otherwise.. lol.
---------- Post added at 03:43 PM ---------- Previous post was at 03:35 PM ----------
ah... sorry. There's an extra close bracket, it's cause I pasted the whole bottom of the file, and that last bracket closes off the configuration for the entire file, not just the usb section. Just noticed that and didn't want anybody to get messed up or confused... just make sure each section is opened and closed I guess when you're done editing.
Just in case anybody is interested, I just built the necessary kernel modules (and the snd-aloop device that we may need to get this to work) for the stock kernel (3.1.10-g52027f9) to allow USB audio without having to install a custom kernel. The modules load fine.
I currently don't have access to my USB sound card to test further, but I'll play around with it once I get it back.
(I'm not sure I can attach files yet, so PM me if you are interested.)
chdloc said:
Just in case anybody is interested, I just build the necessary kernel modules (and the snd-aloop device that we may need to get this to work) for the stock kernel (3.1.10-g52027f9) to allow USB audio without having to install a custom kernel. The modules load fine.
I currently don't have access to my USB sound card to test further, but I'll play around with it once I get it back.
(I'm not sure I can attach files yet, so PM me if you are interested.)
Click to expand...
Click to collapse
That sounds good, I'd be willing to give it a shot. I will hit you up when I have a little time. Perhaps you could consider hosting them on dropbox or something similar. I find myself using it a lot these days.
Any update on this? Getting my N7 prepped for car use.
Have it set up so I can do full USB OTG with USB audio through a DAC, and charge simultaneously (I can even run the N7 in this configuration with the battery connector disconnected). I thought this was the hard part.
But with this installation going into my car, having the ability to control functions with my voice will be very critical! So... has anybody successfully enabled hooking a microphone up to the DAC for audio-in to their Nexus 7?
MetalMan2 said:
Any update on this? Getting my N7 prepped for car use.
Have it set up so I can do full USB OTG with USB audio through a DAC, and charge simultaneously (I can even run the N7 in this configuration with the battery connector disconnected). I thought this was the hard part.
But with this installation going into my car, having the ability to control functions with my voice will be very critical! So... has anybody successfully enabled hooking a microphone up to the DAC for audio-in to their Nexus 7?
Click to expand...
Click to collapse
I've been juggling a lot of things lately and can't even get to my "GOOD" pc... but as soon as I get myself organized, I'm jumping right back into trying to solve this.
I really hope some other people are interested enough to be working on it still too.
It's a pretty important issue to me as a musician... I'm thinking the N7 could be the first android device to do some light multi-tracking on... Not looking for a pocket studio, but it sure would be nice to sit down with just my guitar and a good mic hooked to the n7 to work out some ideas.
So, I compiled the modules for usb-audio for my tf101 too, loaded them into kernel and played some noise via aplay. Then I checked lsof and noticed that the sound is handled by the "mediaserver" process, then I went to grep the android sources.
I found that android has hardcoded it's audio devices files, so it's pretty hard to make usb audio work with asoundrc (i.e. impossible), but also I noticed that there is actually support of usb audio (that has hardcoded to the card number 1 though, but this is something and better than nothing) and the system has to be built with the QCOM_USBAUDIO_ENABLED flag to get this work.
Who will test it first?
hm. this code is specific for the qcom hardware... so need dive deeper to the code...
jbinary said:
So, I compiled the modules for usb-audio for my tf101 too, loaded them into kernel and played some noise via aplay. Then I checked lsof and noticed that the sound is handled by the "mediaserver" process, then I went to grep the android sources.
I found that android has hardcoded it's audio devices files, so it's pretty hard to make usb audio work with asoundrc (i.e. impossible), but also I noticed that there is actually support of usb audio (that has hardcoded to the card number 1 though, but this is something and better than nothing) and the system has to be built with the QCOM_USBAUDIO_ENABLED flag to get this work.
Who will test it first?
Click to expand...
Click to collapse
Does anyone know of a kernel allowing users to "hot plug" a USB DAC to get audio out?
Poitee and Trinity seems to support at least USB audio after a reboot, but so far I have had no luck identifying something that will simply allow me to place my Nexus 7 in my dock (with OTG USB DAC connected) and have the audio automatically routed through the external USB DAC.
Therefore, does anyone know of a rom/kernel allowing this (since my Samsung Galaxy S3 can do this)?
No one out there who knows? :crying:
I'll second this. I am installing my Nexus 7 semi-permanent in my Car, and i'd like to take it out and use internal sound without rebooting it every single time.
// Per.
Yeah, I was keen on making a car install too, but this is for a dock I am building.
I can tell you it involves B&O design and pure awesomeness, guess I cannot post images or give links until I reach 10 posts though.
Hotplug USB audio is indeed possible on the Nexus 7, it seems that a few of us all have similar plans for our Nexus's
Give this a try -> http://forum.xda-developers.com/showthread.php?t=2029728
If you have any issues try and reply in that thread so we keep them all in the same place.
Hey guys! A soon to be newcomer to the Android world! I plan to buy a Nexus 7 Gen 2 LTE to install in my dash (I have a Cruze), right now, my car can control my iPhone through the radio (I can browse, play, etc...) and it'll also display my song title, artist, etc... I can also do this with Flash Drives and I want it available through the Nexus 7, I've read many post and all the information is scattered and I need a concrete answer before I buy the Nexus 7 and what I need, as far as I can tell is:
1) Nexus 7 (derp)
2) USB OTG Cable
3) USB Y Cable (usb port is 0.5 amps and wont charge, plan to use a 2 amp charger and the other output for the music)
I need to know which Kernel and OS to use (please use full names ) and if you could recommend me a good audio player, please do.
I also want to make a custom GUI to mimic an OEM headunit, with a Chevy bowtie background and buttons for NAV, Music, Browser, etc...
Also, I've made custom GUI's for Blackberries, I can't remember the name of the tool you used to create them, but it was really easy to use, is there a program like that one?
Bump