Skip to content

Commit e23832a

Browse files
committed
ALSA: hda - Support multiple headphones in Realtek auto-parser
Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent a06dbfc commit e23832a

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

‎sound/pci/hda/patch_realtek.c‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2813,7 +2813,7 @@ static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
28132813
if (found_in_nid_list(nid, spec->multiout.dac_nids,
28142814
spec->multiout.num_dacs))
28152815
continue;
2816-
if (spec->multiout.hp_nid == nid)
2816+
if (spec->multiout.hp_out_nid[0] == nid)
28172817
continue;
28182818
if (found_in_nid_list(nid, spec->multiout.extra_out_nid,
28192819
ARRAY_SIZE(spec->multiout.extra_out_nid)))
@@ -2842,7 +2842,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
28422842
again:
28432843
/* set num_dacs once to full for alc_auto_look_for_dac() */
28442844
spec->multiout.num_dacs = cfg->line_outs;
2845-
spec->multiout.hp_nid = 0;
2845+
spec->multiout.hp_out_nid[0] = 0;
28462846
spec->multiout.extra_out_nid[0] = 0;
28472847
memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids));
28482848
spec->multiout.dac_nids = spec->private_dac_nids;
@@ -2853,7 +2853,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
28532853
spec->private_dac_nids[i] =
28542854
get_dac_if_single(codec, cfg->line_out_pins[i]);
28552855
if (cfg->hp_outs)
2856-
spec->multiout.hp_nid =
2856+
spec->multiout.hp_out_nid[0] =
28572857
get_dac_if_single(codec, cfg->hp_pins[0]);
28582858
if (cfg->speaker_outs)
28592859
spec->multiout.extra_out_nid[0] =
@@ -2885,8 +2885,8 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
28852885
sizeof(hda_nid_t) * (cfg->line_outs - i - 1));
28862886
}
28872887

2888-
if (cfg->hp_outs && !spec->multiout.hp_nid)
2889-
spec->multiout.hp_nid =
2888+
if (cfg->hp_outs && !spec->multiout.hp_out_nid[0])
2889+
spec->multiout.hp_out_nid[0] =
28902890
alc_auto_look_for_dac(codec, cfg->hp_pins[0]);
28912891
if (cfg->speaker_outs && !spec->multiout.extra_out_nid[0])
28922892
spec->multiout.extra_out_nid[0] =
@@ -3155,9 +3155,10 @@ static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins,
31553155
static int alc_auto_create_hp_out(struct hda_codec *codec)
31563156
{
31573157
struct alc_spec *spec = codec->spec;
3158-
return alc_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
3159-
spec->multiout.hp_nid,
3160-
"Headphone");
3158+
return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs,
3159+
spec->autocfg.hp_pins,
3160+
spec->multiout.hp_out_nid,
3161+
"Headphone");
31613162
}
31623163

31633164
static int alc_auto_create_speaker_out(struct hda_codec *codec)
@@ -3226,11 +3227,17 @@ static void alc_auto_init_extra_out(struct hda_codec *codec)
32263227
int i;
32273228
hda_nid_t pin, dac;
32283229

3229-
pin = spec->autocfg.hp_pins[0];
3230-
if (pin) {
3231-
dac = spec->multiout.hp_nid;
3232-
if (!dac)
3233-
dac = spec->multiout.dac_nids[0];
3230+
for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3231+
pin = spec->autocfg.hp_pins[i];
3232+
if (!pin)
3233+
break;
3234+
dac = spec->multiout.hp_out_nid[i];
3235+
if (!dac) {
3236+
if (i > 0 && spec->multiout.hp_out_nid[0])
3237+
dac = spec->multiout.hp_out_nid[0];
3238+
else
3239+
dac = spec->multiout.dac_nids[0];
3240+
}
32343241
alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
32353242
}
32363243
for (i = 0; i < spec->autocfg.speaker_outs; i++) {
@@ -3696,7 +3703,7 @@ static int alc_parse_auto_config(struct hda_codec *codec,
36963703
return 0; /* can't find valid BIOS pin config */
36973704
}
36983705

3699-
if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && cfg->hp_outs == 1) {
3706+
if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && cfg->hp_outs > 0) {
37003707
/* use HP as primary out */
37013708
cfg->speaker_outs = cfg->line_outs;
37023709
memcpy(cfg->speaker_pins, cfg->line_out_pins,

0 commit comments

Comments
 (0)