Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932754AbWCQUk5 (ORCPT ); Fri, 17 Mar 2006 15:40:57 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932756AbWCQUk5 (ORCPT ); Fri, 17 Mar 2006 15:40:57 -0500 Received: from cantor2.suse.de ([195.135.220.15]:24717 "EHLO mx2.suse.de") by vger.kernel.org with ESMTP id S932754AbWCQUk4 (ORCPT ); Fri, 17 Mar 2006 15:40:56 -0500 Date: Fri, 17 Mar 2006 21:40:54 +0100 Message-ID: From: Takashi Iwai To: Parag Warudkar Cc: Linus Torvalds , Andrew Morton , Linux Kernel Mailing List , Adrian Bunk , "S. Umar" , perex@suse.cz, alsa-devel@lists.sourceforge.net Subject: Re: 2.6.16-rc6: known regressions (v2) In-Reply-To: References: <20060317143642.GJ3914@stusta.de> User-Agent: Wanderlust/2.12.0 (Your Wildest Dreams) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (=?ISO-8859-4?Q?Sanj=F2?=) APEL/10.6 MULE XEmacs/21.5 (beta25) (eggplant) (i386-suse-linux) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8727 Lines: 271 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 > > Handled-By : Takashi Iwai > > 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 --- 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; jnum_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; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/