mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Parag Warudkar <kernel-stuff@comcast.net>
Cc: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Adrian Bunk <bunk@stusta.de>,
	"S. Umar" <umar@compsci.cas.vanderbilt.edu>,
	perex@suse.cz, alsa-devel@lists.sourceforge.net
Subject: Re: 2.6.16-rc6: known regressions (v2)
Date: Fri, 17 Mar 2006 21:40:54 +0100	[thread overview]
Message-ID: <s5hmzfost2h.wl%tiwai@suse.de> (raw)
In-Reply-To: <s5h7j6tt4qx.wl%tiwai@suse.de>

At Fri, 17 Mar 2006 17:28:38 +0100,
I wrote:
> 
> At Fri, 17 Mar 2006 15:36:42 +0100,
> Adrian Bunk wrote:
> > 
> > 
> > Subject    : snd-intel-hda stopped working on a Dell E1705 Laptop
> > References : http://lkml.org/lkml/2006/3/12/16
> > Submitter  : Parag Warudkar <kernel-stuff@comcast.net>
> > Handled-By : Takashi Iwai <tiwai@suse.de>
> > Status     : Takashi Iwai: This looks like a problem of the latest sigmatel
> >                            codec code in general. The author of original
> >                            code is investigating.
> 
> Could you try the patch below?
> It's a part of a patch in ALSA bugtrack #1843.

The last patch seems incomplete.  Please try the patch below instead.
(This time with a changelog :)


Takashi


[PATCH] Fix the output on laptops with STAC92xx codecs

Fix the output on laptops with STAC92xx codecs, such as Dell.
Also fixes the headphone jack sensing with STAC9200.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 4a6dd97..0ef5503 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1935,7 +1935,23 @@ static int is_in_nid_list(hda_nid_t nid,
 	return 0;
 }
 
-/* parse all pin widgets and store the useful pin nids to cfg */
+/*
+ * Parse all pin widgets and store the useful pin nids to cfg
+ *
+ * The number of line-outs or any primary output is stored in line_outs,
+ * and the corresponding output pins are assigned to line_out_pins[],
+ * in the order of front, rear, CLFE, side, ...
+ *
+ * If more extra outputs (speaker and headphone) are found, the pins are
+ * assisnged to hp_pin and speaker_pin, respectively.  If no line-out jack
+ * is detected, one of speaker of HP pins is assigned as the primary
+ * output, i.e. to line_out_pins[0].  So, line_outs is always positive
+ * if any analog output exists.
+ * 
+ * The analog input pins are assigned to input_pins array.
+ * The digital input/output pins are assigned to dig_in_pin and dig_out_pin,
+ * respectively.
+ */
 int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg,
 				 hda_nid_t *ignore_nids)
 {
@@ -2048,6 +2064,41 @@ int snd_hda_parse_pin_def_config(struct 
 		break;
 	}
 
+	/*
+	 * debug prints of the parsed results
+	 */
+	snd_printd("autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
+		   cfg->line_out_pins[0], cfg->line_out_pins[1],
+		   cfg->line_out_pins[2], cfg->line_out_pins[3],
+		   cfg->line_out_pins[4]);
+	snd_printd("   speaker=0x%x, hp=0x%x, dig_out=0x%x, din_in=0x%x\n",
+		   cfg->speaker_pin, cfg->hp_pin, cfg->dig_out_pin,
+		   cfg->dig_in_pin);
+	snd_printd("   inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x,"
+		   " cd=0x%x, aux=0x%x\n",
+		   cfg->input_pins[AUTO_PIN_MIC],
+		   cfg->input_pins[AUTO_PIN_FRONT_MIC],
+		   cfg->input_pins[AUTO_PIN_LINE],
+		   cfg->input_pins[AUTO_PIN_FRONT_LINE],
+		   cfg->input_pins[AUTO_PIN_CD],
+		   cfg->input_pins[AUTO_PIN_AUX]);
+
+	/*
+	 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin
+	 * as a primary output
+	 */
+	if (! cfg->line_outs) {
+		if (cfg->speaker_pin) {
+			cfg->line_outs = 1;
+			cfg->line_out_pins[0] = cfg->speaker_pin;
+			cfg->speaker_pin = 0;
+		} else if (cfg->hp_pin) {
+			cfg->line_outs = 1;
+			cfg->line_out_pins[0] = cfg->hp_pin;
+			cfg->hp_pin = 0;
+		}
+	}
+
 	return 0;
 }
 
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 35c2823..51ddf95 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -51,6 +51,7 @@ struct sigmatel_spec {
 	unsigned int line_switch: 1;
 	unsigned int mic_switch: 1;
 	unsigned int alt_switch: 1;
+	unsigned int hp_detect: 1;
 
 	/* playback */
 	struct hda_multi_out multiout;
@@ -691,13 +692,7 @@ static int stac92xx_auto_fill_dac_nids(s
 					AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
 	}
 
-	if (cfg->line_outs)
-		spec->multiout.num_dacs = cfg->line_outs;
-	else if (cfg->hp_pin) {
-		spec->multiout.dac_nids[0] = snd_hda_codec_read(codec, cfg->hp_pin, 0,
-					AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
-		spec->multiout.num_dacs = 1;
-	}
+	spec->multiout.num_dacs = cfg->line_outs;
 
 	return 0;
 }
@@ -766,11 +761,13 @@ static int stac92xx_auto_create_hp_ctls(
 		return 0;
 
 	wid_caps = get_wcaps(codec, pin);
-	if (wid_caps & AC_WCAP_UNSOL_CAP)
+	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);
+		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++) {
@@ -804,9 +801,6 @@ static int stac92xx_auto_create_analog_i
 	for (i = 0; i < AUTO_PIN_LAST; i++) {
 		int index = -1;
 		if (cfg->input_pins[i]) {
-			/* Enable active pin widget as an input */
-			stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN);
-
 			imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
 
 			for (j=0; j<spec->num_muxes; j++) {
@@ -855,10 +849,8 @@ static int stac92xx_parse_auto_config(st
 
 	if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
 		return err;
-	if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
+	if (! spec->autocfg.line_outs)
 		return 0; /* can't find valid pin config */
-	stac92xx_auto_init_multi_out(codec);
-	stac92xx_auto_init_hp_out(codec);
 	if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
 		return err;
 	if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
@@ -873,14 +865,10 @@ static int stac92xx_parse_auto_config(st
 	if (spec->multiout.max_channels > 2)
 		spec->surr_switch = 1;
 
-	if (spec->autocfg.dig_out_pin) {
+	if (spec->autocfg.dig_out_pin)
 		spec->multiout.dig_out_nid = dig_out;
-		stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN);
-	}
-	if (spec->autocfg.dig_in_pin) {
+	if (spec->autocfg.dig_in_pin)
 		spec->dig_in_nid = dig_in;
-		stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN);
-	}
 
 	if (spec->kctl_alloc)
 		spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
@@ -890,6 +878,29 @@ static int stac92xx_parse_auto_config(st
 	return 1;
 }
 
+/* add playback controls for HP output */
+static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
+					struct auto_pin_cfg *cfg)
+{
+	struct sigmatel_spec *spec = codec->spec;
+	hda_nid_t pin = cfg->hp_pin;
+	unsigned int wid_caps;
+
+	if (! pin)
+		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);
+		spec->hp_detect = 1;
+	}
+
+	return 0;
+}
+
 static int stac9200_parse_auto_config(struct hda_codec *codec)
 {
 	struct sigmatel_spec *spec = codec->spec;
@@ -901,14 +912,13 @@ static int stac9200_parse_auto_config(st
 	if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
 		return err;
 
-	if (spec->autocfg.dig_out_pin) {
+	if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
+		return err;
+
+	if (spec->autocfg.dig_out_pin)
 		spec->multiout.dig_out_nid = 0x05;
-		stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN);
-	}
-	if (spec->autocfg.dig_in_pin) {
+	if (spec->autocfg.dig_in_pin)
 		spec->dig_in_nid = 0x04;
-		stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN);
-	}
 
 	if (spec->kctl_alloc)
 		spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
@@ -921,9 +931,31 @@ static int stac9200_parse_auto_config(st
 static int stac92xx_init(struct hda_codec *codec)
 {
 	struct sigmatel_spec *spec = codec->spec;
+	struct auto_pin_cfg *cfg = &spec->autocfg;
+	int i;
 
 	snd_hda_sequence_write(codec, spec->init);
 
+	/* set up pins */
+	if (spec->hp_detect) {
+		/* fake event to set up pins */
+		codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
+	} else {
+		stac92xx_auto_init_multi_out(codec);
+		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);
+	}
+	if (cfg->dig_out_pin)
+		stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
+					 AC_PINCTL_OUT_EN);
+	if (cfg->dig_in_pin)
+		stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
+					 AC_PINCTL_IN_EN);
+
 	return 0;
 }
 

  reply	other threads:[~2006-03-17 20:40 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-11 23:58 Linux v2.6.16-rc6 Linus Torvalds
2006-03-12  1:51 ` Michal Piotrowski
2006-03-12  2:39   ` David S. Miller
2006-03-12  3:28     ` Chris Adams
2006-03-12  3:35       ` Lee Revell
2006-03-12 10:57       ` Michal Feix
2006-03-12  8:35     ` Willy Tarreau
2006-03-12 12:04     ` Michal Piotrowski
2006-04-09 12:08     ` Andy Furniss
2006-03-12  9:03 ` Christoph Hellwig
2006-03-13 19:54   ` Bjorn Helgaas
2006-03-13 21:57     ` Christoph Hellwig
2006-03-13 19:07 ` 2.6.16-rc6: all psmouse regressions fixed? Adrian Bunk
2006-03-14  4:59   ` Benoit Boissinot
2006-03-15  3:38   ` Ryan Phillips
2006-03-13 20:05 ` 2.6.16-rc6: known regressions Adrian Bunk
2006-03-13 12:09   ` Greg KH
2006-03-13 12:12   ` Greg KH
2006-03-13 21:06     ` Jiri Slaby
2006-03-14  9:36       ` Tom Seeley
2006-03-13 21:22     ` [v4l-dvb-maintainer] " Johannes Stezenbach
2006-03-13 22:14       ` Nathan Laredo
2006-03-13 20:09   ` Olaf Hering
2006-03-13 22:42   ` Andrew Morton
2006-03-14  1:06     ` Adrian Bunk
2006-03-14 13:32       ` [Alsa-devel] " Takashi Iwai
2006-03-14 22:18     ` Alan Cox
2006-03-14 22:38       ` Paul Fulghum
2006-03-16  1:42       ` Paul Fulghum
2006-03-14 23:01     ` Jeremy Fitzhardinge
2006-03-17 17:30   ` Jiri Slaby
2006-03-16 22:12 ` Linux v2.6.16-rc6 Bill Davidsen
2006-03-17 14:36 ` 2.6.16-rc6: known regressions (v2) Adrian Bunk
2006-03-17 16:28   ` Takashi Iwai
2006-03-17 20:40     ` Takashi Iwai [this message]
2006-03-18 19:27       ` Parag Warudkar
2006-03-18 19:46         ` Parag Warudkar
2006-03-20 10:25           ` Takashi Iwai
2006-03-20 10:47             ` Adrian Bunk
2006-03-20 10:57               ` Takashi Iwai
2006-03-20 10:59             ` Takashi Iwai
2006-03-18 20:57   ` Claudio Martins
2006-03-19 22:49     ` Nathan Scott

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=s5hmzfost2h.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=akpm@osdl.org \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=bunk@stusta.de \
    --cc=kernel-stuff@comcast.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@suse.cz \
    --cc=torvalds@osdl.org \
    --cc=umar@compsci.cas.vanderbilt.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome