Bug 40792 - alsa+modules+udev+/proc/asound/cards=lottery
Summary: alsa+modules+udev+/proc/asound/cards=lottery
Status: RESOLVED DOCUMENTED
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-10 00:53 UTC by Andreas Steinmetz
Modified: 2012-08-30 09:40 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6+, 3+
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Andreas Steinmetz 2011-08-10 00:53:21 UTC
Here's a conceptual alsa problem:

Build all your sound cards as modules. Boot. Have udev handle the sound modules. Run this on an 8 core numa system. Result:

The sequence of cards in /proc/asound/cards is a lottery result that changes from boot to boot. Now if you need to define a sound card in /etc/asound.conf you're lost.

For type "hw" in the file I don't know any other "card" value than a number which breaks from boot to boot.

There needs to be a way that identifies cards in config files for alsa regardless how udev does load them.

This will be becoming more and more prominent as onboard and hdmi audio sound gets standard.

For me on the target system the problem is between "ICE1712 - M Audio Audiophile 24/96" and "HDA-Intel - HDA NVidia" for which the udev load sequence is undefined.

It is, with all respect, not acceptable to write a script that modifies asound.conf with respect to the contents of /proc/asound/cards. This is already due to the fact that asound.conf resides in /etc, not in /var, which strongly hints to a system constant configuration.
Comment 1 Andreas Steinmetz 2011-08-10 11:05:26 UTC
I forgot:
Please don't point to the "index" module parameter. On the one hand this is awkward to use and on the other hand somewhat broken when it comes to drivers like hda with more than one backend. In the latter case "index" is a numeric array with no reference to the actual backend. Thus it is again numbers only without a device name.

I do guess that this conceptual problem won't be changed. Even though it would be possible even to handle "names" in the alsa userspace libraries and thus making life easier for all users.
Comment 2 Takashi Iwai 2011-08-10 11:18:41 UTC
You can pass the id name string, and it's actually the recommended way, as "aplay -L" shows.  If you have multiple cards, don't use "hw" alone but always specify the card id.  For example,

    % cat /proc/asound/cards
     0 [Intel          ]: HDA-Intel - HDA Intel
                          HDA Intel at 0xd0500000 irq 42
     1 [HDMI           ]: HDA-Intel - HDA ATI HDMI
                          HDA ATI HDMI at 0xd0410000 irq 43
    % aplay -D hw:Intel foo.wav
    % aplay -D hdmi:HDMI foo.wav

Also, you can set the default card id in ~/.asoundrc like below, too:

    defaults.pcm.!card "Intel"

Note You need to log in before you can comment on or make changes to this bug.