Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 22797
b: refs/heads/master
c: 82bc955
h: refs/heads/master
i:
  22795: 683ce5a
v: v3
  • Loading branch information
Takashi Iwai authored and Jaroslav Kysela committed Mar 22, 2006
1 parent a067b5f commit 476a214
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 76 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 19739fef0203d2f3eecc9c4b1ef25b57d85f2b30
refs/heads/master: 82bc955f6379135e6ce35ff90c7ac411fd412c4c
77 changes: 74 additions & 3 deletions trunk/sound/pci/hda/hda_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,13 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
if (mout->hp_nid)
/* headphone out will just decode front left/right (stereo) */
snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format);
/* extra outputs copied from front */
for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
if (mout->extra_out_nid[i])
snd_hda_codec_setup_stream(codec,
mout->extra_out_nid[i],
stream_tag, 0, format);

/* surrounds */
for (i = 1; i < mout->num_dacs; i++) {
if (chs >= (i + 1) * 2) /* independent out */
Expand All @@ -1923,6 +1930,11 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_o
snd_hda_codec_setup_stream(codec, nids[i], 0, 0, 0);
if (mout->hp_nid)
snd_hda_codec_setup_stream(codec, mout->hp_nid, 0, 0, 0);
for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
if (mout->extra_out_nid[i])
snd_hda_codec_setup_stream(codec,
mout->extra_out_nid[i],
0, 0, 0);
mutex_lock(&codec->spdif_mutex);
if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) {
snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
Expand All @@ -1944,13 +1956,29 @@ static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
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_pins[], 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)
{
hda_nid_t nid, nid_start;
int i, j, nodes;
short seq, sequences[4], assoc_line_out;
short seq, assoc_line_out, sequences[ARRAY_SIZE(cfg->line_out_pins)];

memset(cfg, 0, sizeof(*cfg));

Expand Down Expand Up @@ -1992,7 +2020,10 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
cfg->line_outs++;
break;
case AC_JACK_SPEAKER:
cfg->speaker_pin = nid;
if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins))
continue;
cfg->speaker_pins[cfg->speaker_outs] = nid;
cfg->speaker_outs++;
break;
case AC_JACK_HP_OUT:
cfg->hp_pin = nid;
Expand Down Expand Up @@ -2057,6 +2088,46 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
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_outs, 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_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
cfg->speaker_outs, cfg->speaker_pins[0],
cfg->speaker_pins[1], cfg->speaker_pins[2],
cfg->speaker_pins[3], cfg->speaker_pins[4]);
snd_printd(" hp=0x%x, dig_out=0x%x, din_in=0x%x\n",
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_outs) {
cfg->line_outs = cfg->speaker_outs;
memcpy(cfg->line_out_pins, cfg->speaker_pins,
sizeof(cfg->speaker_pins));
cfg->speaker_outs = 0;
memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
} else if (cfg->hp_pin) {
cfg->line_outs = 1;
cfg->line_out_pins[0] = cfg->hp_pin;
cfg->hp_pin = 0;
}
}

return 0;
}

Expand Down
4 changes: 3 additions & 1 deletion trunk/sound/pci/hda/hda_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ struct hda_multi_out {
int num_dacs; /* # of DACs, must be more than 1 */
hda_nid_t *dac_nids; /* DAC list */
hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */
hda_nid_t extra_out_nid[3]; /* optional DACs, 0 when not exists */
hda_nid_t dig_out_nid; /* digital out audio widget */
int max_channels; /* currently supported analog channels */
int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */
Expand Down Expand Up @@ -221,7 +222,8 @@ extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST];
struct auto_pin_cfg {
int line_outs;
hda_nid_t line_out_pins[5]; /* sorted in the order of Front/Surr/CLFE/Side */
hda_nid_t speaker_pin;
int speaker_outs;
hda_nid_t speaker_pins[5];
hda_nid_t hp_pin;
hda_nid_t input_pins[AUTO_PIN_LAST];
hda_nid_t dig_out_pin;
Expand Down
23 changes: 11 additions & 12 deletions trunk/sound/pci/hda/patch_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,8 @@ enum { AD1986A_6STACK, AD1986A_3STACK, AD1986A_LAPTOP, AD1986A_LAPTOP_EAPD };
static struct hda_board_config ad1986a_cfg_tbl[] = {
{ .modelname = "6stack", .config = AD1986A_6STACK },
{ .modelname = "3stack", .config = AD1986A_3STACK },
{ .pci_subvendor = 0x10de, .pci_subdevice = 0xcb84,
.config = AD1986A_3STACK }, /* ASUS A8N-VM CSM */
{ .modelname = "laptop", .config = AD1986A_LAPTOP },
{ .pci_subvendor = 0x144d, .pci_subdevice = 0xc01e,
.config = AD1986A_LAPTOP }, /* FSC V2060 */
Expand Down Expand Up @@ -2253,14 +2255,11 @@ static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,

idx = ad1988_pin_idx(pin);
nid = ad1988_idx_to_dac(codec, idx);
if (! spec->multiout.dac_nids[0]) {
/* use this as the primary output */
spec->multiout.dac_nids[0] = nid;
if (! spec->multiout.num_dacs)
spec->multiout.num_dacs = 1;
} else
/* specify the DAC as the extra output */
/* specify the DAC as the extra output */
if (! spec->multiout.hp_nid)
spec->multiout.hp_nid = nid;
else
spec->multiout.extra_out_nid[0] = nid;
/* control HP volume/switch on the output mixer amp */
sprintf(name, "%s Playback Volume", pfx);
if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
Expand Down Expand Up @@ -2379,7 +2378,7 @@ static void ad1988_auto_init_extra_out(struct hda_codec *codec)
struct ad198x_spec *spec = codec->spec;
hda_nid_t pin;

pin = spec->autocfg.speaker_pin;
pin = spec->autocfg.speaker_pins[0];
if (pin) /* connect to front */
ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
pin = spec->autocfg.hp_pin;
Expand Down Expand Up @@ -2428,13 +2427,13 @@ static int ad1988_parse_auto_config(struct hda_codec *codec)
return err;
if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
return err;
if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
! spec->autocfg.hp_pin)
if (! spec->autocfg.line_outs)
return 0; /* can't find valid BIOS pin config */
if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
(err = ad1988_auto_create_extra_out(codec, spec->autocfg.speaker_pin,
(err = ad1988_auto_create_extra_out(codec,
spec->autocfg.speaker_pins[0],
"Speaker")) < 0 ||
(err = ad1988_auto_create_extra_out(codec, spec->autocfg.speaker_pin,
(err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pin,
"Headphone")) < 0 ||
(err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
return err;
Expand Down
47 changes: 14 additions & 33 deletions trunk/sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -2431,14 +2431,11 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,

if (alc880_is_fixed_pin(pin)) {
nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
if (! spec->multiout.dac_nids[0]) {
/* use this as the primary output */
spec->multiout.dac_nids[0] = nid;
if (! spec->multiout.num_dacs)
spec->multiout.num_dacs = 1;
} else
/* specify the DAC as the extra output */
/* specify the DAC as the extra output */
if (! spec->multiout.hp_nid)
spec->multiout.hp_nid = nid;
else
spec->multiout.extra_out_nid[0] = nid;
/* control HP volume/switch on the output mixer amp */
nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
sprintf(name, "%s Playback Volume", pfx);
Expand All @@ -2451,12 +2448,6 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
return err;
} else if (alc880_is_multi_pin(pin)) {
/* set manual connection */
if (! spec->multiout.dac_nids[0]) {
/* use this as the primary output */
spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
if (! spec->multiout.num_dacs)
spec->multiout.num_dacs = 1;
}
/* we have only a switch on HP-out PIN */
sprintf(name, "%s Playback Switch", pfx);
if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Expand Down Expand Up @@ -2540,7 +2531,7 @@ static void alc880_auto_init_extra_out(struct hda_codec *codec)
struct alc_spec *spec = codec->spec;
hda_nid_t pin;

pin = spec->autocfg.speaker_pin;
pin = spec->autocfg.speaker_pins[0];
if (pin) /* connect to front */
alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
pin = spec->autocfg.hp_pin;
Expand Down Expand Up @@ -2576,15 +2567,15 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
alc880_ignore)) < 0)
return err;
if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
! spec->autocfg.hp_pin)
if (! spec->autocfg.line_outs)
return 0; /* can't find valid BIOS pin config */

if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
(err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
(err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
(err = alc880_auto_create_extra_out(spec,
spec->autocfg.speaker_pins[0],
"Speaker")) < 0 ||
(err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
(err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
"Headphone")) < 0 ||
(err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
return err;
Expand Down Expand Up @@ -3445,7 +3436,7 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
return err;
}

nid = cfg->speaker_pin;
nid = cfg->speaker_pins[0];
if (nid) {
err = alc260_add_playback_controls(spec, nid, "Speaker");
if (err < 0)
Expand Down Expand Up @@ -3518,7 +3509,7 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
if (nid)
alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);

nid = spec->autocfg.speaker_pin;
nid = spec->autocfg.speaker_pins[0];
if (nid)
alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);

Expand Down Expand Up @@ -4602,7 +4593,7 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
return err;
}

nid = cfg->speaker_pin;
nid = cfg->speaker_pins[0];
if (nid) {
if (nid == 0x16) {
if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
Expand All @@ -4612,10 +4603,6 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
return err;
} else {
if (! cfg->line_out_pins[0])
if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
return err;
if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
return err;
Expand All @@ -4632,10 +4619,6 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
return err;
} else {
if (! cfg->line_out_pins[0])
if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
return err;
if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
return err;
Expand Down Expand Up @@ -4729,8 +4712,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
alc262_ignore)) < 0)
return err;
if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
! spec->autocfg.hp_pin)
if (! spec->autocfg.line_outs)
return 0; /* can't find valid BIOS pin config */
if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
(err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Expand Down Expand Up @@ -5404,8 +5386,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
alc861_ignore)) < 0)
return err;
if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
! spec->autocfg.hp_pin)
if (! spec->autocfg.line_outs)
return 0; /* can't find valid BIOS pin config */

if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
Expand Down
Loading

0 comments on commit 476a214

Please sign in to comment.