From: Liam Girdwood <lrg@kernel.org>
To: Takashi Iwai <tiwai@suse.de>
Cc: Harald Radke <harryrat@postnuklear.de>, alsa-devel@alsa-project.org
Subject: Re: get rid of controls with snd_ctl_remove
Date: Fri, 29 Aug 2008 14:56:33 +0100 [thread overview]
Message-ID: <1220018193.6499.49.camel@odin> (raw)
In-Reply-To: <s5h8wuggcqm.wl%tiwai@suse.de>
On Fri, 2008-08-29 at 15:41 +0200, Takashi Iwai wrote:
> At Fri, 29 Aug 2008 14:16:52 +0100,
> Liam Girdwood wrote:
> > I'd prefer an addition to our API to handle this more _common_ case
> > rather than just removing controls.
> >
> > Something where we can mark controls as "disabled" so alsamixer and
> > friends wont render/get them. This would also allow scenario code to
> > disable relevant mixers and then re-enable when required.
>
> Something like below?
>
>
> Takashi
>
> diff --git a/sound/core/control.c b/sound/core/control.c
> index 3c5e746..c6f7062 100644
> --- a/sound/core/control.c
> +++ b/sound/core/control.c
> @@ -410,6 +410,52 @@ int snd_ctl_remove_id(struct snd_card *card, struct snd_ctl_elem_id *id)
> EXPORT_SYMBOL(snd_ctl_remove_id);
>
> /**
> + * snd_ctl_activate_id - activate/inactivate the control of the given id
> + * @card: the card instance
> + * @id: the control id to activate/inactivate
> + * @active: non-zero to activate
> + *
> + * Finds the control instance with the given id, and activate or
> + * inactivate the control together with notification, if changed.
> + *
> + * Returns 0 if unchanged, 1 if changed, or a negative error code on failure.
> + */
> +int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
> + int active)
> +{
> + struct snd_kcontrol *kctl;
> + struct snd_kcontrol_volatile *vd;
> + unsigned int index_offset;
> + int ret;
> +
> + down_write(&card->controls_rwsem);
> + kctl = snd_ctl_find_id(card, id);
> + if (kctl == NULL) {
> + up_write(&card->controls_rwsem);
> + return -ENOENT;
> + }
> + index_offset = snd_ctl_get_ioff(kctl, &control->id);
> + vd = &kctl->vd[index_offset];
> + ret = 0;
> + if (active) {
> + if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE))
> + goto unlock;
> + vd->access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> + } else {
> + if (vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE)
> + goto unlock;
> + vd->access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> + }
> + ret = 1;
> + unlock:
> + up_write(&card->controls_rwsem);
> + if (ret)
> + snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, id);
> + return ret;
> +}
> +EXPORT_SYMBOL(snd_ctl_activate_id);
> +
> +/**
> * snd_ctl_remove_unlocked_id - remove the unlocked control of the given id and release it
> * @file: active control handle
> * @id: the control id to remove
Wow - that was quick !
Yes, exactly :) We can now add this to our machine drivers to disable
never used controls (for each machine) and also call this when scenario
changes too.
Even more interestingly, it could also be called by DAPM......
Cheers
Liam
next prev parent reply other threads:[~2008-08-29 13:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-29 12:54 get rid of controls with snd_ctl_remove Harald Radke
2008-08-29 13:01 ` Takashi Iwai
2008-08-29 13:16 ` Liam Girdwood
2008-08-29 13:41 ` Takashi Iwai
2008-08-29 13:56 ` Liam Girdwood [this message]
2008-08-29 16:42 ` Takashi Iwai
2008-08-29 20:10 ` Liam Girdwood
2008-08-29 22:19 ` Harald Radke
2008-09-01 5:56 ` Takashi Iwai
2008-09-01 11:04 ` Harald Radke
2008-09-01 11:09 ` CORRECTION (get rid of controls with snd_ctl_remove) Harald Radke
2008-09-01 11:51 ` Liam Girdwood
2008-09-02 8:02 ` CORRECTION (get rid of controls with snd_ctl_remove ) Harald Radke
2008-09-02 9:46 ` CORRECTION (get rid of controls with?snd_ctl_remove ) Mark Brown
2008-09-02 10:05 ` Harald Radke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1220018193.6499.49.camel@odin \
--to=lrg@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=harryrat@postnuklear.de \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.