* [PATCH 7/16] ALSA: VIA HDA: Modify notify_aa_path_ctls() function
@ 2011-03-21 7:29 Lydia Wang
2011-03-21 7:32 ` Jaroslav Kysela
0 siblings, 1 reply; 4+ messages in thread
From: Lydia Wang @ 2011-03-21 7:29 UTC (permalink / raw)
To: alsa-devel; +Cc: tiwai, HaraldWelte, lydiawang
From: Lydia Wang <lydiawang@viatech.com.cn>
Subject: ALSA: VIA HDA: Modify notify_aa_path_ctls() function.
Modify notify_aa_path_ctls() function to get volume control items name
dynamically instead of by giving static item name.
Signed-off-by: Lydia Wang <lydiawang@viatech.com.cn>
---
sound/pci/hda/patch_via.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -832,16 +832,23 @@
static void notify_aa_path_ctls(struct hda_codec *codec)
{
- int i;
- struct snd_ctl_elem_id id;
- const char *labels[] = {"Mic", "Front Mic", "Line"};
-
- memset(&id, 0, sizeof(id));
- id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
- for (i = 0; i < ARRAY_SIZE(labels); i++) {
- sprintf(id.name, "%s Playback Volume", labels[i]);
- snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE,
- &id);
+ struct snd_card *card = codec->bus->card;
+ struct snd_kcontrol *kctl;
+ struct via_spec *spec = codec->spec;
+ const struct auto_pin_cfg *cfg = &spec->autocfg;
+ list_for_each_entry(kctl, &card->controls, list) {
+ int i;
+ for (i = 0; i < cfg->num_inputs; i++) {
+ char name[32];
+ const char *label;
+ label = hda_get_autocfg_input_label(codec, cfg, i);
+ sprintf(name, "%s Playback Volume", label);
+ if (strcmp(kctl->id.name, name) == 0) {
+ snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
+ &kctl->id);
+ break;
+ }
+ }
}
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 7/16] ALSA: VIA HDA: Modify notify_aa_path_ctls() function
2011-03-21 7:29 [PATCH 7/16] ALSA: VIA HDA: Modify notify_aa_path_ctls() function Lydia Wang
@ 2011-03-21 7:32 ` Jaroslav Kysela
2011-03-21 11:08 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: Jaroslav Kysela @ 2011-03-21 7:32 UTC (permalink / raw)
To: Lydia Wang; +Cc: tiwai, alsa-devel, HaraldWelte
On Mon, 21 Mar 2011, Lydia Wang wrote:
> From: Lydia Wang <lydiawang@viatech.com.cn>
> Subject: ALSA: VIA HDA: Modify notify_aa_path_ctls() function.
>
> Modify notify_aa_path_ctls() function to get volume control items name
> dynamically instead of by giving static item name.
This code looks ugly to me. If you like to have a dynamic set of notified
controls, create one using snd_array in via_spec.
Jaroslav
-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 7/16] ALSA: VIA HDA: Modify notify_aa_path_ctls() function
2011-03-21 7:32 ` Jaroslav Kysela
@ 2011-03-21 11:08 ` Takashi Iwai
[not found] ` <5B2BE0DB92BC8F4694F815C2F34E0D5F660B76@exchbj03.viatech.com.bj>
0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2011-03-21 11:08 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: alsa-devel, HaraldWelte, Lydia Wang
At Mon, 21 Mar 2011 08:32:43 +0100 (CET),
Jaroslav Kysela wrote:
>
> On Mon, 21 Mar 2011, Lydia Wang wrote:
>
> > From: Lydia Wang <lydiawang@viatech.com.cn>
> > Subject: ALSA: VIA HDA: Modify notify_aa_path_ctls() function.
> >
> > Modify notify_aa_path_ctls() function to get volume control items name
> > dynamically instead of by giving static item name.
>
> This code looks ugly to me. If you like to have a dynamic set of notified
> controls, create one using snd_array in via_spec.
Agreed. The current code is too fragile.
thanks,
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 答复: [PATCH 7/16] ALSA: VIA HDA: Modify notify_aa_path_ctls() function
[not found] ` <5B2BE0DB92BC8F4694F815C2F34E0D5F660B76@exchbj03.viatech.com.bj>
@ 2011-03-24 7:55 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2011-03-24 7:55 UTC (permalink / raw)
To: LydiaWang; +Cc: alsa-devel, HaraldWelte
At Thu, 24 Mar 2011 15:32:51 +0800,
<LydiaWang@viatech.com.cn> wrote:
>
>
>
> > -----邮件原件-----
> > 发件人: Takashi Iwai [mailto:tiwai@suse.de]
> > 发送时间: 2011年3月21日 19:08
> > 收件人: Jaroslav Kysela
> > 抄送: Lydia Wang; alsa-devel@alsa-project.org; Harald Welte
> > 主题: Re: [alsa-devel] [PATCH 7/16] ALSA: VIA HDA: Modify notify_aa_path_ctls()
> > function
> >
> > At Mon, 21 Mar 2011 08:32:43 +0100 (CET),
> > Jaroslav Kysela wrote:
> > >
> > > On Mon, 21 Mar 2011, Lydia Wang wrote:
> > >
> > > > From: Lydia Wang <lydiawang@viatech.com.cn>
> > > > Subject: ALSA: VIA HDA: Modify notify_aa_path_ctls() function.
> > > >
> > > > Modify notify_aa_path_ctls() function to get volume control items name
> > > > dynamically instead of by giving static item name.
> > >
> > > This code looks ugly to me. If you like to have a dynamic set of notified
> > > controls, create one using snd_array in via_spec.
> >
> > Agreed. The current code is too fragile.
> >
> >
> > thanks,
> >
> > Takashi
>
> I've created such control type of snd_array. When I want to update a-a path volume and mute control, I must find out the controls among all such ones. But in new alsa driver, I found the mic's a-a path name will be mic, or rear mic according to its pin position. In old driver, the a-a path name is static, but now it's dynamic. So I write this function to find out the actual name of controls. I'm not very clear why it's ugly. Please tell me. Thank you!
First off, looking over all controls of the card instance isn't
considered as a valid task for the local codec driver. If such a
feature is inevitably necessary, we should implement a helper function
in ALSA core.
Secondly, the controls you look at might not belong to your codec.
HD-audio bus can contain multiple codecs, and it might come from some
others.
HD-audio codec has already an array of mixer elements. codec->mixers
is an array for struct hda_nid_item. You can use this instead for
look-up. If more performance optimization is needed, create another
local array to point only the needed kctls.
thanks,
Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-24 7:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-21 7:29 [PATCH 7/16] ALSA: VIA HDA: Modify notify_aa_path_ctls() function Lydia Wang
2011-03-21 7:32 ` Jaroslav Kysela
2011-03-21 11:08 ` Takashi Iwai
[not found] ` <5B2BE0DB92BC8F4694F815C2F34E0D5F660B76@exchbj03.viatech.com.bj>
2011-03-24 7:55 ` 答复: " Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).