Bladeren bron

ALSA: hda - Mute unused capture sources for Realtek codecs

When a Realtek codec has a matrix-style capture-source selection, we
need to scan all connections instead of only imux items.  Otherwise some
input might be kept unmuted.  Although the corresponding input must be
dead so there should be no input from it, it's still safer to mute the
route completely.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai 13 jaren geleden
bovenliggende
commit
dccc1810f4
1 gewijzigde bestanden met toevoegingen van 7 en 6 verwijderingen
  1. 7 6
      sound/pci/hda/patch_realtek.c

+ 7 - 6
sound/pci/hda/patch_realtek.c

@@ -284,7 +284,7 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
 	struct alc_spec *spec = codec->spec;
 	struct alc_spec *spec = codec->spec;
 	const struct hda_input_mux *imux;
 	const struct hda_input_mux *imux;
 	unsigned int mux_idx;
 	unsigned int mux_idx;
-	int i, type;
+	int i, type, num_conns;
 	hda_nid_t nid;
 	hda_nid_t nid;
 
 
 	mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
 	mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
@@ -307,16 +307,17 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
 		spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
 		spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
 
 
 	/* no selection? */
 	/* no selection? */
-	if (snd_hda_get_conn_list(codec, nid, NULL) <= 1)
+	num_conns = snd_hda_get_conn_list(codec, nid, NULL);
+	if (num_conns <= 1)
 		return 1;
 		return 1;
 
 
 	type = get_wcaps_type(get_wcaps(codec, nid));
 	type = get_wcaps_type(get_wcaps(codec, nid));
 	if (type == AC_WID_AUD_MIX) {
 	if (type == AC_WID_AUD_MIX) {
 		/* Matrix-mixer style (e.g. ALC882) */
 		/* Matrix-mixer style (e.g. ALC882) */
-		for (i = 0; i < imux->num_items; i++) {
-			unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
-			snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
-						 imux->items[i].index,
+		int active = imux->items[idx].index;
+		for (i = 0; i < num_conns; i++) {
+			unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE;
+			snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i,
 						 HDA_AMP_MUTE, v);
 						 HDA_AMP_MUTE, v);
 		}
 		}
 	} else {
 	} else {