[alsa-devel] [PATCH 1/2 v2] ALSA: Add snd_ctl_update() to dynamically update a control

Clemens Ladisch clemens at ladisch.de
Tue Mar 15 15:17:58 CET 2011

Dimitris Papastamos wrote:
> Add a function to dynamically update a given control.  If the
> control does not already exist, a third parameter is used to determine
> whether to actually add that control.  This is useful in cases where
> downloadable firmware at runtime can add or update existing controls.

> + * Updates the control instance created via snd_ctl_new() or
> + * snd_ctl_new1() of the given card.

This description was copied from snd_ctl_add(), and the "created ..."
part isn't really useful here.

It should be mentioned that the old control is destroyed, because some
drivers store volatile state in the control's private_data/_value, or
keep a pointer to the control('s ID) to be able to call snd_ctl_notify()
for it later.

> + * Returns zero if successful, or a negative error code on failure.
> + *

superfluous empty line

> +int snd_ctl_update(struct snd_card *card, struct snd_kcontrol *kcontrol,
> +		   int add_on_update)

add_on_update should be bool

> +	up_write(&card->controls_rwsem);
> +	ret = snd_ctl_add(card, kcontrol);

Doing this outside the semaphore doesn't look good.

I wonder whether snd_ctl_add() is the right function to use, because it
will assign a different numid event if the control didn't change.

> A separate patch needs to be made to make ALSA Mixer cope with this.

What happens?


More information about the Alsa-devel mailing list