[alsa-devel] [PATCH 8/31] HDA patch_via.c: Change VT1708S & VT1702 hp mode controls

Li Bo liboat at gmail.com
Mon Oct 5 16:25:15 CEST 2009


[ALSA] HDA VIA: Change VT1708S & VT1702 hp mode controls

For VT1708S and VT1702, deactivate "Headphone Playback Volume" and
"Headphone Playback Mute" control if "Independent HP" mode is OFF.
and rename VT1702 "Independent HP" text.

Signed-off-by: Lydia Wang <lydiawang at viatech.com.cn>

Index: sound-2.6/sound/pci/hda/patch_via.c
===================================================================
--- sound-2.6.orig/sound/pci/hda/patch_via.c	2009-10-05 15:09:18.000000000 +0800
+++ sound-2.6/sound/pci/hda/patch_via.c	2009-10-05 15:09:33.000000000 +0800
@@ -566,9 +566,26 @@
 	unsigned int pinsel = snd_hda_codec_read(codec, nid, 0,
 						 AC_VERB_GET_CONNECT_SEL,
 						 0x00);
+	static int hp_ctl_initialized = -1;

 	ucontrol->value.enumerated.item[0] = pinsel;
-
+	/* update HP controls on first time */
+	if ((spec->codec_type == VT1708S
+	     || spec->codec_type == VT1702)
+	    && hp_ctl_initialized == -1) {
+		struct snd_card *card = codec->bus->card;
+		struct snd_kcontrol *kctl;
+		/* deactive hp volume & switch in independent mode */
+		list_for_each_entry(kctl, &card->controls, list)
+			if (spec->hp_independent_mode
+			    && (strcmp(kctl->id.name,
+				       "Headphone Playback Volume") == 0
+				|| strcmp(kctl->id.name,
+					  "Headphone Playback Switch") == 0))
+				kctl->vd[0].access |=
+					SNDRV_CTL_ELEM_ACCESS_INACTIVE;
+		hp_ctl_initialized = 1;
+	}
 	return 0;
 }

@@ -3342,11 +3359,13 @@

 static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
 {
-	int err;
-
+	int err, i;
+	struct hda_input_mux *imux;
+	static const char *texts[] = { "ON (need reboot)",
+				       "OFF (need reboot)",
+				       NULL};
 	if (!pin)
 		return 0;
-
 	spec->multiout.hp_nid = 0x1D;

 	err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
@@ -3361,8 +3380,18 @@
 	if (err < 0)
 		return err;

-	create_hp_imux(spec);
+	imux = &spec->private_imux[1];

+	/* for hp mode select */
+	i = 0;
+	while (texts[i] != NULL)	{
+		imux->items[imux->num_items].label =  texts[i];
+		imux->items[imux->num_items].index = i;
+		imux->num_items++;
+		i++;
+	}
+
+	spec->hp_mux = &spec->private_imux[1];
 	return 0;
 }


More information about the Alsa-devel mailing list