[alsa-devel] Device creation order

Jaroslav Kysela perex at perex.cz
Fri Apr 3 09:31:40 CEST 2009

On Fri, 3 Apr 2009, Daniel Mack wrote:

> On Fri, Apr 03, 2009 at 09:12:34AM +0200, Jaroslav Kysela wrote:
>>> PulseAudio listens for hotplugged audio devices via hal/udev. For each
>>> card ALSA creates a bunch of device nodes in /dev. Before PA can open
>>> the card it needs to make sure that all devices nodes of the card got
>>> properly created. I.e. to make sure that surround sound and SPDIF
>>> works it is not sufficient to wait until one PCM device is available,
>>> but instead that *all* devices that belong to the card are available,
>>> i.e. device nodes created with permissions and ACLs set up
>>> correctly. Unfortunately there is no signal from udev/hal/kernel that
>>> would tell me explicitly that all subdevices of a specific devices are
>>> completely enumerated and device files created for. I have been
>>> discussing this a bit with Kay Sievers and we came to the conclusion
>>> that a simple fix would be if we could rely that the control
>>> (i.e. /dev/snd/controlCxx) device is always the last device to be
>>> created for a card.
>>> Looking at the drivers this seems to be generally the case, so I was
>>> wondering if I can rely on this? Do all drivers behave like this? Do
>>> all drivers expose a control device? Can we officially declare it part
>>> of the userspace API that the control device is the last one to be
>>> created?
>> Unfortunately, driver may use more complex scenarios like:
>> - some hardware requires additional firmware - in this case devices
>>    might be created, but they are not useable until firmware is loaded
>> - dynamic device creation at runtime - for example we have an
>>    experimental HDA driver configuration code which might change
>>    the arrangement of PCM devices on request from the user space
>> I would suggest to wait awhile with some small timeout (0.5 sec?) for all
>> devices to get the usual static arrangement working and handle extra
>> dynamic cases, too.
> Wouldn't the real fix be to make sure that the event from hal/udev
> happens after all the initialization has finished, i.e. the device got
> its firmware, all connected layers finished their work etc? Before all
> that, the audio device is not really available, right?

But even with this extension, the user space should handle dynamic device 
reconfiguration (my second example case). The question is, if it makes 
sense to handle group of devices per card basis or just take single 
devices and dynamically handle device changes.

Lennart, why you need to enumerate all devices per card at one time? I 
think that having mixer access plus one PCM device is enough for minimal 
configuration for PA.


Jaroslav Kysela <perex at perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

More information about the Alsa-devel mailing list