[alsa-devel] Getting a notification of snd_kcontrol value change, defined in codec, in machine driver
Takashi Sakamoto
o-takashi at sakamocchi.jp
Sun Jul 8 03:00:24 CEST 2018
Hi,
On Jul 8 2018 08:10, Giedrius Trainavičius wrote:
> What would be the best way in machine driver to learn about changes of alsa
> mixer control values? The controls are defined in the codec driver.
>
> The intended use case would be to use the current volume setting for the
> codec on the board to forward to a dedicated microcontroller for visual
> feedback.
>
> I am aware that this could be bridged over via a user space program, but I
> will have to forward the current PCM stream format to the MCU anyway from
> hw_params, so ideally I would like all of this functionality contained in
> the machine driver.
By assigning a function to 'struct snd_kcontrol.put', in-kernel drivers
can receive any notification as a callback at changing value array of a
control element set including handled conntrol element. When calling
snd_ctl_new(), passing proper data for an argument of 'struct
snd_kcontrol_new'.
I note that for userspace applications, ALSA control core supports
notification mechanism for this purpose by typical I/O handling in UNIX
environment. With alsa-lib, at first, call 'snd_ctl_subscribe_events()',
then listen to file descriptor for opened ALSA control character device
(or call 'snd_ctl_wait()'). When any events are emitted, the
applications can read data of 'struct snd_ctl_event' from the descriptor
and handle the notification by parsing the data.
Regards
Takashi Sakamoto
More information about the Alsa-devel
mailing list