From 716eef032cdc7604ae3a1a5ad80521f4afa4b3e6 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 21 Oct 2011 15:07:42 +0200
Subject: [PATCH] ALSA: hda/realtek - Fix DAC assignments of multiple speakers
Git-commit: 716eef032cdc7604ae3a1a5ad80521f4afa4b3e6
Patch-mainline: 3.2-rc1
References: FATE#314311

When a device has multiple speakers and still has the auto-mute support,
the driver copies line_outs[] to speaker_outs[].  And then it tries to
assign DACs for both.  This ended up with the assignment only to the
primary DAC to all speakers.

This patch fixes the situation by checking the duplicated LO/SPK case
appropriately.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 sound/pci/hda/patch_realtek.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3000,9 +3000,11 @@ static int alc_auto_fill_dac_nids(struct
 		}
 	}
 
-	alc_auto_fill_extra_dacs(codec, cfg->hp_outs, cfg->hp_pins,
+	if (cfg->line_out_type != AUTO_PIN_HP_OUT)
+		alc_auto_fill_extra_dacs(codec, cfg->hp_outs, cfg->hp_pins,
 				 spec->multiout.hp_out_nid);
-	alc_auto_fill_extra_dacs(codec, cfg->speaker_outs, cfg->speaker_pins,
+	if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
+		alc_auto_fill_extra_dacs(codec, cfg->speaker_outs, cfg->speaker_pins,
 				 spec->multiout.extra_out_nid);
 
 	return 0;
@@ -3319,6 +3321,8 @@ static void alc_auto_init_extra_out(stru
 	hda_nid_t pin, dac;
 
 	for (i = 0; i < spec->autocfg.hp_outs; i++) {
+		if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)
+			break;
 		pin = spec->autocfg.hp_pins[i];
 		if (!pin)
 			break;
@@ -3332,6 +3336,8 @@ static void alc_auto_init_extra_out(stru
 		alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
 	}
 	for (i = 0; i < spec->autocfg.speaker_outs; i++) {
+		if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
+			break;
 		pin = spec->autocfg.speaker_pins[i];
 		if (!pin)
 			break;
