Search code examples
driveralsa

Need help understanding alsa drivers


I'm trying to debug the sound system on a amlogic device. amixer and alsamixer aren't working as expected and amixer can crash the system. What I'm struggling with is that the drivers pass methods for accessing the hardware registers by constructing a snd_kcontrol object all as described in Writing an ALSA Driver on the ALSA website. But amixer cset calls snd_ctl_elem_write from control.c which refers to element_write in a snd_ctl_t object.

I can't see any link between the defined snd_kcontrol and any snd_ctl_t objects so can't see how amixer is supposed to be writing to the hardware. How is it normally done?


Solution

  • In user space, a control device is represented by snd_ctl_t, which contains the file handle of the device node. element_write points to snd_ctl_hw_elem_write(), which issues a system call.

    In the kernel, an opened device file is represented by a struct snd_ctl_file, which is linked to the struct snd_card.