[LAD] More on alsa card order and udev

Simon Fielding s.fielding at wmcce.org
Fri May 1 12:48:20 UTC 2009


Slow day at work so I've been doing some testing.

I'm using Fedora 11 preview on my spare R&D PC. I've got a Behringer
UMA25S which is a 25 key MIDI keyboard with built in USB soundcard. I
haven't removed anything from F11 so pulseaudio et al is still
installed.

Problem 1
F11 no longer loads snd_seq (oss support which loads snd_seq conflicts
with PA). I just manually modprobe'd snd_seq pending a proper fix.

Action 1
Plug everything in. Run the following command for each device
in /dev/snd

udevadm info -a -p $(udevadm info -q path -n /dev/snd/DEVICE_NAME)

and save the outputs. You can use these to determine how to specify an
individual device/card in the udev rules.

Action 2
I added the following lines to /etc/udev/rules/90-alsa.rules (each line
starts with either # (for a comment) or KERNEL so if your mail reader
breaks them up, join them back together. You will need different tests
to identify your individual cards using the information gathered
above :-

# Make HDA Intel Card0 always
KERNEL=="controlC*", SUBSYSTEM=="sound", DRIVERS=="HDA Intel",
NAME="snd/controlC0"
KERNEL=="hw*", SUBSYSTEM=="sound", ATTR{name}=="Realtek ALC880",
NAME="snd/hwC0D2"
KERNEL=="pcmC*c", SUBSYSTEM=="sound", DRIVERS=="HDA Intel",
NAME="snd/pcmC0D0c"
KERNEL=="pcmC*p", SUBSYSTEM=="sound", DRIVERS=="HDA Intel",
NAME="snd/pcmC0D0p"

# Make UMA25S Midi Card3
KERNEL=="midi*", SUBSYSTEM=="sound", ATTRS{product}=="UMA25S",
ATTRS{manufacturer}=="BEHRINGER", NAME="snd/midiC3D0"
KERNEL=="controlC*", SUBSYSTEM=="sound", ATTRS{product}=="UMA25S",
ATTRS{manufacturer}=="BEHRINGER", NAME="snd/controlC3"

# Make UMA25S Sound Card1 if in left front USB port
KERNEL=="controlC*", SUBSYSTEM=="sound", ATTRS{busnum}=="2",
ATTRS{devnum}=="5", ATTRS{product}=="USB Audio CODEC*",
ATTRS{manufacturer}=="Burr-Brown from TI*", NAME="snd/controlC1"
KERNEL=="pcmC*c", SUBSYSTEM=="sound", ATTRS{busnum}=="2",
ATTRS{devnum}=="5", ATTRS{product}=="USB Audio CODEC*",
ATTRS{manufacturer}=="Burr-Brown from TI*", NAME="snd/pcmC1D0c"
KERNEL=="pcmC*p", SUBSYSTEM=="sound", ATTRS{busnum}=="2",
ATTRS{devnum}=="5", ATTRS{product}=="USB Audio CODEC*",
ATTRS{manufacturer}=="Burr-Brown from TI*", NAME="snd/pcmC1D0p"

# Make UMA25S Sound Card2 if NOT in left front USB port
# On a different USB bus
KERNEL=="controlC*", SUBSYSTEM=="sound", ATTRS{busnum}!="2",
ATTRS{product}=="USB Audio CODEC*", ATTRS{manufacturer}=="Burr-Brown
from TI*", NAME="snd/controlC2"
KERNEL=="pcmC*c", SUBSYSTEM=="sound", ATTRS{busnum}!="2",
ATTRS{product}=="USB Audio CODEC*", ATTRS{manufacturer}=="Burr-Brown
from TI*", NAME="snd/pcmC2D0c"
KERNEL=="pcmC*p", SUBSYSTEM=="sound", ATTRS{busnum}!="2",
ATTRS{product}=="USB Audio CODEC*", ATTRS{manufacturer}=="Burr-Brown
from TI*", NAME="snd/pcmC2D0p"
# Same USB bus, Different port
KERNEL=="controlC*", SUBSYSTEM=="sound", ATTRS{busnum}=="2",
ATTRS{devnum}!="5", ATTRS{product}=="USB Audio CODEC*",
ATTRS{manufacturer}=="Burr-Brown from TI*", NAME="snd/controlC2"
KERNEL=="pcmC*c", SUBSYSTEM=="sound", ATTRS{busnum}=="2", ATTRS{devnum}!
="5", ATTRS{product}=="USB Audio CODEC*",
ATTRS{manufacturer}=="Burr-Brown from TI*", NAME="snd/pcmC2D0c"
KERNEL=="pcmC*p", SUBSYSTEM=="sound", ATTRS{busnum}=="2", ATTRS{devnum}!
="5", ATTRS{product}=="USB Audio CODEC*",
ATTRS{manufacturer}=="Burr-Brown from TI*", NAME="snd/pcmC2D0p"

Action 3
Reboot and test it all. I started qjackctl and the USB soundcard showed
up fine as card 1. I fired up a whysynth and connected the keyboard
through jack - sound worked fine.

Then I stopped jack, unplugged the UMA25 and tried a different USB port
- even better, it now showed up as card2 in qjackctl and still worked
once I told qjackctl to use card2 now.

Problem 2
Move the card back to the original USB port and try again. It still
shows as card2 ! A little investigation (lsusb) showed that although the
card was back in the same place, it no longer had devnum==5. Each time
you unplug and replug the device, even into the same physical socket, it
gets a new devnum. This means that the usb devnum is not a reliable way
of uniquely identifying a usb soundcard.

Problem 3
/proc/asound/cards etc no longer correctly reflect the card
numbers/names. This doesn't seem to affect Jack but I'm not sure where
to start tracking this down to fix it. Perhaps someone with a bit more
knowledge could take a look at this.

Conclusion
All told, a bit of a mixed bag of results but hopefully this may help
someone to start a little further investigation and maybe we can make
the udev/alsa combination do what is needed.

Cheers,
Simon




More information about the Linux-audio-dev mailing list