[PATCH 3/3] [UBUNTU:sound/pci/hda] Fix mic input and erroneous post-resume reinitialization for STAC92xx codecs

crimsun at fungus.sh.nu crimsun at fungus.sh.nu
Thu Mar 30 23:20:31 BST 2006


Subject: [PATCH 3/3] [UBUNTU:sound/pci/hda] Fix mic input and erroneous post-resume reinitialization for STAC92xx codecs

UpstreamStatus: Added in upstream pci/hda/patch_sigmatel.c r1.2[12]

Takashi Iwai committed the above patch(es) to fix VREF mic level and
unnecessary post-resume reinitialization for STAC92xx codecs.

Signed-off-by: Daniel T Chen <crimsun at ubuntu.com>

---

 sound/pci/hda/patch_sigmatel.c |   53 ++++++++++++++++++++++++++--------------
 1 files changed, 35 insertions(+), 18 deletions(-)

9836be99754efbd5b167b938b0553b8e5acc5da4
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index b92bf16..d9ac5c7 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -534,6 +534,22 @@ static int stac92xx_build_pcms(struct hd
 	return 0;
 }
 
+static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
+{
+	unsigned int pincap = snd_hda_param_read(codec, nid,
+						 AC_PAR_PIN_CAP);
+	pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
+	if (pincap & AC_PINCAP_VREF_100)
+		return AC_PINCTL_VREF_100;
+	if (pincap & AC_PINCAP_VREF_80)
+		return AC_PINCTL_VREF_80;
+	if (pincap & AC_PINCAP_VREF_50)
+		return AC_PINCTL_VREF_50;
+	if (pincap & AC_PINCAP_VREF_GRD)
+		return AC_PINCTL_VREF_GRD;
+	return 0;
+}
+
 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
 {
 	snd_hda_codec_write(codec, nid, 0,
@@ -572,9 +588,12 @@ static int stac92xx_io_switch_put(snd_kc
 	if (val)
 		stac92xx_auto_set_pinctl(codec, nid,
 				AC_PINCTL_OUT_EN);
-	else
-		stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
-
+	else {
+		unsigned int pinctl = AC_PINCTL_IN_EN;
+		if (io_idx) /* set VREF for mic */
+			pinctl |= stac92xx_get_vref(codec, nid);
+		stac92xx_auto_set_pinctl(codec, nid, pinctl);
+	}
 	return 1;
 }
 
@@ -768,13 +787,8 @@ static int stac92xx_auto_create_hp_ctls(
 
 	wid_caps = get_wcaps(codec, pin);
 
-	if (wid_caps & AC_WCAP_UNSOL_CAP) {
-		/* Enable unsolicited responses on the HP widget */
-		snd_hda_codec_write(codec, pin, 0,
-				AC_VERB_SET_UNSOLICITED_ENABLE,
-				STAC_UNSOL_ENABLE);
+	if (wid_caps & AC_WCAP_UNSOL_CAP)
 		spec->hp_detect = 1;
-	}
 
 	nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
 	for (i = 0; i < cfg->line_outs; i++) {
@@ -897,13 +911,8 @@ static int stac9200_auto_create_hp_ctls(
 		return 0;
 
 	wid_caps = get_wcaps(codec, pin);
-	if (wid_caps & AC_WCAP_UNSOL_CAP) {
-		/* Enable unsolicited responses on the HP widget */
-		snd_hda_codec_write(codec, pin, 0,
-				AC_VERB_SET_UNSOLICITED_ENABLE,
-				STAC_UNSOL_ENABLE);
+	if (wid_caps & AC_WCAP_UNSOL_CAP)
 		spec->hp_detect = 1;
-	}
 
 	return 0;
 }
@@ -945,6 +954,10 @@ static int stac92xx_init(struct hda_code
 
 	/* set up pins */
 	if (spec->hp_detect) {
+		/* Enable unsolicited responses on the HP widget */
+		snd_hda_codec_write(codec, cfg->hp_pin, 0,
+				AC_VERB_SET_UNSOLICITED_ENABLE,
+				STAC_UNSOL_ENABLE);
 		/* fake event to set up pins */
 		codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
 	} else {
@@ -952,9 +965,13 @@ static int stac92xx_init(struct hda_code
 		stac92xx_auto_init_hp_out(codec);
 	}
 	for (i = 0; i < AUTO_PIN_LAST; i++) {
-		if (cfg->input_pins[i])
-			stac92xx_auto_set_pinctl(codec, cfg->input_pins[i],
-						 AC_PINCTL_IN_EN);
+		hda_nid_t nid = cfg->input_pins[i];
+		if (nid) {
+			unsigned int pinctl = AC_PINCTL_IN_EN;
+			if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
+				pinctl |= stac92xx_get_vref(codec, nid);
+			stac92xx_auto_set_pinctl(codec, nid, pinctl);
+		}
 	}
 	if (cfg->dig_out_pin)
 		stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
-- 
1.1.3


-- 
Daniel T. Chen            crimsun at ubuntu.com
GPG key:   www.sh.nu/~crimsun/pubkey.gpg.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/kernel-team/attachments/20060330/e0220388/attachment.pgp


More information about the kernel-team mailing list