All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lydia Wang <lydiawang@viatech.com.cn>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, HaraldWelte@viatech.com, lydiawang@viatech.com.cn
Subject: [PATCH 7/16] ALSA: VIA HDA: Modify notify_aa_path_ctls() function
Date: Mon, 21 Mar 2011 15:29:35 +0800	[thread overview]
Message-ID: <4D86FE5F.9030106@viatech.com.cn> (raw)

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;
+			}
+		}
 	}
 }

             reply	other threads:[~2011-03-21  7:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-21  7:29 Lydia Wang [this message]
2011-03-21  7:32 ` [PATCH 7/16] ALSA: VIA HDA: Modify notify_aa_path_ctls() function Jaroslav Kysela
2011-03-21 11:08   ` Takashi Iwai
     [not found]     ` <5B2BE0DB92BC8F4694F815C2F34E0D5F660B76@exchbj03.viatech.com.bj>
2011-03-24  7:55       ` 答复: " Takashi Iwai

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=4D86FE5F.9030106@viatech.com.cn \
    --to=lydiawang@viatech.com.cn \
    --cc=HaraldWelte@viatech.com \
    --cc=alsa-devel@alsa-project.org \
    --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.