Skip to contentSkip to conversation

ALSA: VIA HDA: Modify notify_aa_path_ctls() function

PATCH In review Lydia Wang 3 participants 4 messages Mar 21, 2011 – Mar 24, 2011 1 message not in the archive Sound

lore
Share & tools
lore

Lydia Wang

author
#0 lore raw

PATCH 7/16 ALSA: VIA HDA: Modify notify_aa_path_ctls() function

From: Lydia Wang <[email protected]>
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.

---
 sound/pci/hda/patch_via.c |   27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
sound/pci/hda/patch_via.c +17 -10
@@ -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;
+			}
+		}
 	}
 }
maintainer
#1 lore raw
Quoted 5 lines · Lydia Wang

From: Lydia Wang <[email protected]>
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 <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

#2 lore raw

At Mon, 21 Mar 2011 08:32:43 +0100 (CET),

Quoted 11 lines · Jaroslav Kysela
Quoted 5 lines · Lydia Wang

From: Lydia Wang <[email protected]>
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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

At Thu, 24 Mar 2011 15:32:51 +0800,

Quoted 25 lines · <[email protected]> wrote:
Quoted 25 lines

-----邮件原件-----
发件人: Takashi Iwai [mailto:[email protected]]
发送时间: 2011年3月21日 19:08
收件人: Jaroslav Kysela
抄送: Lydia Wang; [email protected]; 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),

Quoted 11 lines · Jaroslav Kysela
Quoted 5 lines · Lydia Wang

From: Lydia Wang <[email protected]>
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.

Quoted 8 lines
Quoted 6 lines

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
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel