Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Trouble with ALSA and multiple devices - one is USB [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
xenon
Guru
Guru


Joined: 25 Dec 2002
Posts: 430
Location: Europe

PostPosted: Tue Nov 24, 2009 4:50 pm    Post subject: Trouble with ALSA and multiple devices - one is USB [SOLVED] Reply with quote

I have an integrated audio device covered by the snd-hda-intel driver and an USB webcam with a microphone (aka a sound device with capture capabilites only in ALSA's eyes); both work correctly by themselves. However, more often than not, the USB mic gets the first place in the ALSA race, so that /dev/snd/control0 and /dev/snd/pcmC0D0c belong to it, while pcmC0D0p is not created at all (since the device has no playback capabilities). The problem is certain applications default to /dev/snd/pcmC0D0p. So I tried to force a device creation order through /etc/modprobe.d/alsa.conf, but my settings have been ignored. So i blacklisted snd-usb-audio in /etc/modprobe.d/blacklist.conf, and as one would expect, only the character devices from snd-hda-intel are created. Then, if I manually modprobe snd-usb-audio and restart the alsasound service, I get a character device for the mic. I'm almost done, but now I can't find a way to have the snd-usb-audio module automatically loaded.

Note: I'm pretty sure it doesn't make a difference, but the integrated audio device appears as two:

Does anyone have a solution, with or without blacklisting the module? Thanks in advance, please let me know if further information is needed.

/proc/asound/cards before modprobing usb-audio
Code:

 0 [SB             ]: HDA-Intel - HDA ATI SB
                      HDA ATI SB at 0xfe024000 irq 16
 2 [HDMI           ]: HDA-Intel - HDA ATI HDMI
                      HDA ATI HDMI at 0xfdffc000 irq 19


After:
Code:
 0 [SB             ]: HDA-Intel - HDA ATI SB
                      HDA ATI SB at 0xfe024000 irq 16
 1 [U0x4710x329    ]: USB-Audio - USB Device 0x471:0x329
                      USB Device 0x471:0x329 at usb-0000:00:12.0-2, full speed
 2 [HDMI           ]: HDA-Intel - HDA ATI HDMI
                      HDA ATI HDMI at 0xfdffc000 irq 19


/dev/snd/by-path:
Code:
by-path:
total 0
drwxr-xr-x 2 root root 100 Nov 24 17:43 .
drwxr-xr-x 4 root root 360 Nov 24 17:43 ..
lrwxrwxrwx 1 root root  12 Nov 24 17:43 pci-0000:00:12.0-usb-0:2:1.1 -> ../controlC1
lrwxrwxrwx 1 root root  12 Nov 24 17:34 pci-0000:00:14.2 -> ../controlC0
lrwxrwxrwx 1 root root  12 Nov 24 17:34 pci-0000:01:05.1 -> ../controlC2


Tentative, probably imperfect /etc/modprobe.d/alsa.conf:
Code:
alias char-major-116 snd

alias snd-card-0 snd-hda-intel
alias snd-card-1 snd-hda-intel
alias snd-card-2 snd-usb-audio

options snd slots=,snd-usb-audio

options snd-card-0 index=0,1
options snd-card-2 index=2


/etc/modprobe.d/blacklist.conf:
Code:

blacklist snd_usb_audio


Last edited by xenon on Wed Nov 25, 2009 10:29 am; edited 1 time in total
Back to top
View user's profile Send private message
MotivatedTea
Apprentice
Apprentice


Joined: 06 Nov 2006
Posts: 269
Location: Toronto, Canada

PostPosted: Wed Nov 25, 2009 4:07 am    Post subject: Reply with quote

You have a few problems that I can see. First of all, you're trying to combine two different methods of assigning indexes. According to the documentation at /usr/src/linux/Documentation/sound/alsa/ALSA-Configuration.txt, using "index=" is one way, and using "slots=" is another.

Attempt 1a
I have used "index=" before, although my HDA card only showed up as one device. Try this first:
Code:

alias char-major-116 snd

alias snd-card-0 snd-hda-intel
alias snd-card-1 snd-hda-intel
alias snd-card-2 snd-usb-audio

# Change this line:
options snd cards_limit=3

# Change these lines:
options snd-hda-intel index=0,1
options snd-usb-audio index=2


Note that I removed the "slots" parameter on "snd" (we'll try that separately), and I increased "cards_limit". If cards_limit is too low, you might have problems; if it is too high, it's ok -- you'll just waste a tiny bit of memory (reserving data structures for cards you don't have).

The run "update-modules" and reboot. (If you don't want to reboot, then you have to stop alsa and unload every single sound-related module. There are a lot of them; if you miss one, the changes might not take effect. Rebooting is easier.)


Attempt 1b
It might help to specify the "id" for your Intel devices. I only get one:
Code:
# cat /proc/asound/card0/id
Intel

I'm hoping that your two "different" HDA devices will have different ID's. I'm guessing you're going to get "SB" for the first one and "HDMI" for the second. Try adding an "id" parameter to snd-hda-intel:
Code:
options snd-hda-intel id=SB,HDMI index=0,1
options snd-usb-audio index=2


I'm not actually sure if that's the correct syntax. If it doesn't work, try using two lines instead:
Code:
options snd-hda-intel id=SB index=0
options snd-hda-intel id=HDMI index=1
options snd-usb-audio index=2


You can also add an "id" parameter to snd-usb-audio, although if you've only got one USB audio device, that shouldn't be necessary.

I have used this method successfully with one Intel device and three USB devices. I have no way of testing it with multiple Intel devices. (I didn't need to use "id=" for the Intel device, and I used "vid=" instead of "id=" for the USB devices. The snd-hda-intel modules does not have a "vid=" parameter, though.)


Attempt 2
The linux kernel documentation (as mentioned above) says that an alternate method is to use the "slots=" parameter on "snd". I have not tried this. However, if you wanted to do that, try this instead:

Code:

alias char-major-116 snd

alias snd-card-0 snd-hda-intel
alias snd-card-1 snd-hda-intel
alias snd-card-2 snd-usb-audio

# Change this line
options snd cards_limit=3 slots=snd-hda-intel,snd-usb-audio

# Remove or comment out the lines that had "index"
#options snd-hda-intel index=0,1
#options snd-usb-audio index=2


I haven't tried that, but if you open /usr/src/linux/Documentation/sound/alsa/ALSA-Configuration.txt (assuming your kernel source is under /usr/src) and search for "Module Autoloading Support", it says that should work.

Things to Note
- Don't forget to un-blacklist your module when trying these things! (Technically, it should be possible to do what you want without blacklisting anything.)
- When I was using "index=", it only worked if there were index= entries for all cards that were present when ALSA started. If I omitted any, then it appeared to ignore my settings.
- I have multiple snd-usb-audio devices, but I only seemed to need a single "alias-snd-card-0" line. I don't know a lot about what that line does, but according to ALSA-Configuration.txt, you might be able to leave them out entirely, especially if you're using the "slot=" method. Maybe try that.
- Don't forget to run update-modules whenever you make a change. Also, as I mentioned above, rebooting was the only reliably way I found to test the changes.
- I found this link, which might be helpful: http://sidux.com/index.php?module=Wikula&tag=MultipleAlsaEn
Back to top
View user's profile Send private message
xenon
Guru
Guru


Joined: 25 Dec 2002
Posts: 430
Location: Europe

PostPosted: Wed Nov 25, 2009 10:29 am    Post subject: Reply with quote

First of all, thanks a lot for your extensive and very helpful post. I suspected that by collecting and mixing various information from official and unofficial sources, my alsa.conf file had become a bit of a mess... :)

Anyway: I tried both solutions 1a and 1b, and they both work! I can't directly test audio functionality since I'm SSH-only right now, but the devices are there and they are created and named in the correct order:
Code:

 # l /dev/snd/*
crw-rw---- 1 root audio 116,  9 Nov 25  2009 /dev/snd/controlC0
crw-rw---- 1 root audio 116, 12 Nov 25  2009 /dev/snd/controlC1
crw-rw---- 1 root audio 116, 14 Nov 25 11:22 /dev/snd/controlC2
crw-rw---- 1 root audio 116,  8 Nov 25  2009 /dev/snd/hwC0D0
crw-rw---- 1 root audio 116, 11 Nov 25  2009 /dev/snd/hwC1D0
crw-rw---- 1 root audio 116,  7 Nov 25  2009 /dev/snd/pcmC0D0c
crw-rw---- 1 root audio 116,  6 Nov 25  2009 /dev/snd/pcmC0D0p
crw-rw---- 1 root audio 116,  5 Nov 25  2009 /dev/snd/pcmC0D1c
crw-rw---- 1 root audio 116,  4 Nov 25  2009 /dev/snd/pcmC0D1p
crw-rw---- 1 root audio 116,  3 Nov 25  2009 /dev/snd/pcmC0D2c
crw-rw---- 1 root audio 116, 10 Nov 25  2009 /dev/snd/pcmC1D3p
crw-rw---- 1 root audio 116, 13 Nov 25 11:22 /dev/snd/pcmC2D0c
crw-rw---- 1 root audio 116, 15 Nov 25 11:22 /dev/snd/seq
crw-rw---- 1 root audio 116,  2 Nov 25  2009 /dev/snd/timer

/dev/snd/by-id:
total 0
drwxr-xr-x 2 root root  60 Nov 25 11:22 .
drwxr-xr-x 4 root root 360 Nov 25 11:22 ..
lrwxrwxrwx 1 root root  12 Nov 25 11:22 usb-0471_0329_01690000B7020031-01 -> ../controlC2

/dev/snd/by-path:
total 0
drwxr-xr-x 2 root root 100 Nov 25 11:22 .
drwxr-xr-x 4 root root 360 Nov 25 11:22 ..
lrwxrwxrwx 1 root root  12 Nov 25 11:22 pci-0000:00:12.0-usb-0:2:1.1 -> ../controlC2
lrwxrwxrwx 1 root root  12 Nov 25  2009 pci-0000:00:14.2 -> ../controlC0
lrwxrwxrwx 1 root root  12 Nov 25  2009 pci-0000:01:05.1 -> ../controlC1


I do get two IDs for the Intel devices:
Code:

 cat /proc/asound/card0/id
SB

Code:

 cat /proc/asound/card1/id
HDMI

Code:

cat /proc/asound/card2/id
U0x4710x329


By the way, the ALSA guys should stop breaking syntax with such nonchalance: lines in alsa.conf starting with "options" where refused and ignored by 1.0.20, but happily accepted by 1.0.21, and yesterday I even found a configuration with an explicit modprobe command in it...

So thanks again, really, and I hope this thread will be helpful to someone else having my problems.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum