[alsa-devel] Getting a notification of snd_kcontrol value change, defined in codec, in machine driver

Takashi Iwai tiwai at suse.de
Sun Jul 8 09:44:12 CEST 2018


On Sun, 08 Jul 2018 09:16:48 +0200,
Giedrius Trainavičius wrote:
> 
> I would like to 'hook into' controls defined in a codec driver from my
> machine driver - so I don't really have access to how these controls get
> created in the first place.
> 
> Would it be possible to iterate in my machine driver through all the
> controls defined by the codec, memorize the original 'put' callback,
> override it with my own which performs the task I need and calls the
> original put callback?

It's feasible, the virtual master (vmaster) code does something like
that, for example.  But no generic framework is provided, so far.


Takashi

> 
> On Sun, Jul 8, 2018 at 4:00 AM, Takashi Sakamoto <o-takashi at sakamocchi.jp>
> wrote:
> 
> > 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
> >
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel at alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel


More information about the Alsa-devel mailing list