Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Liam Girdwood <lrg@kernel.org>
To: Takashi Iwai <tiwai@suse.de>, Harald Radke <harryrat@postnuklear.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: get rid of controls with snd_ctl_remove
Date: Fri, 29 Aug 2008 14:16:52 +0100	[thread overview]
Message-ID: <1220015812.6499.42.camel@odin> (raw)
In-Reply-To: <s5hhc94gel4.wl%tiwai@suse.de>

On Fri, 2008-08-29 at 15:01 +0200, Takashi Iwai wrote:
> At Fri, 29 Aug 2008 14:54:42 +0200,
> Harald Radke wrote:
> > 
> > Hi there!
> > 
> > Please be patient with me, I am quite inexperienced with alsa programming, so 
> > this might be a dumb question:
> > 
> > We have a WM8750 working in our PDA, the codec is working so far but I want to 
> > remove some of the control since they aren't needed.
> > 
> > Instead of copying the wm8750.c file and adjusting it, I want to write another 
> > module which basically get rid of those controls, something like:
> > 
> > [...]
> > 
> > static const char* unused_controls[] = {"AAAA", "BBBB,"CCCC"};
> > 
> >         struct snd_kcontrol *ctl;
> > 
> >         list_for_each_entry(ctl, &card->controls, list)
> 
> You can't use list_for_each_entry() together with removal.
> Use list_for_each_entry_safe() for such a purpose.
> 
> But...
> 
> >           for(i=0; i <  ARRAY_SIZE(unused_controls); i++)
> >             if (!strcmp(unused_controls[i],ctl->id.name)) {
> >               down_write(&card->controls_rwsem);
> >               snd_ctl_remove(card,ctl);
> >               up_write(&card->controls_rwsem);
> >               break;
> >             }
> 
> It'd be easier like the following:
> 
> 	for (i = 0; i < ARRAY_SIZE(unused_controls); i++) {
> 		struct snd_ctl_elem_id id;
> 		memset(&id, 0, sizeof(id));
> 		strcpy(id.name, unused_controls[i]);
> 		id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
> 		snd_ctl_remove_id(card, &id);
> 	}

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.

Liam

  reply	other threads:[~2008-08-29 13:16 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 [this message]
2008-08-29 13:41     ` Takashi Iwai
2008-08-29 13:56       ` Liam Girdwood
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=1220015812.6499.42.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox