Forráskód Böngészése

ALSA: hda - force different capture controls if amp caps differ

Otherwise setting the capture volume for amps will be weird and
inconsistent (it will try to set values outside the range of the
second amp based on capabilities of the first amp).

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
David Henningsson 12 éve
szülő
commit
99a5592d6a
1 módosított fájl, 21 hozzáadás és 3 törlés
  1. 21 3
      sound/pci/hda/hda_generic.c

+ 21 - 3
sound/pci/hda/hda_generic.c

@@ -484,6 +484,15 @@ static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid,
 	return false;
 	return false;
 }
 }
 
 
+static bool same_amp_caps(struct hda_codec *codec, hda_nid_t nid1,
+			  hda_nid_t nid2, int dir)
+{
+	if (!(get_wcaps(codec, nid1) & (1 << (dir + 1))))
+		return !(get_wcaps(codec, nid2) & (1 << (dir + 1)));
+	return (query_amp_caps(codec, nid1, dir) ==
+		query_amp_caps(codec, nid2, dir));
+}
+
 #define nid_has_mute(codec, nid, dir) \
 #define nid_has_mute(codec, nid, dir) \
 	check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
 	check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
 #define nid_has_volume(codec, nid, dir) \
 #define nid_has_volume(codec, nid, dir) \
@@ -2768,6 +2777,7 @@ static int create_capture_mixers(struct hda_codec *codec)
 
 
 	for (n = 0; n < nums; n++) {
 	for (n = 0; n < nums; n++) {
 		bool multi = false;
 		bool multi = false;
+		bool multi_cap_vol = spec->multi_cap_vol;
 		bool inv_dmic = false;
 		bool inv_dmic = false;
 		int vol, sw;
 		int vol, sw;
 
 
@@ -2780,12 +2790,20 @@ static int create_capture_mixers(struct hda_codec *codec)
 			parse_capvol_in_path(codec, path);
 			parse_capvol_in_path(codec, path);
 			if (!vol)
 			if (!vol)
 				vol = path->ctls[NID_PATH_VOL_CTL];
 				vol = path->ctls[NID_PATH_VOL_CTL];
-			else if (vol != path->ctls[NID_PATH_VOL_CTL])
+			else if (vol != path->ctls[NID_PATH_VOL_CTL]) {
 				multi = true;
 				multi = true;
+				if (!same_amp_caps(codec, vol,
+				    path->ctls[NID_PATH_VOL_CTL], HDA_INPUT))
+					multi_cap_vol = true;
+			}
 			if (!sw)
 			if (!sw)
 				sw = path->ctls[NID_PATH_MUTE_CTL];
 				sw = path->ctls[NID_PATH_MUTE_CTL];
-			else if (sw != path->ctls[NID_PATH_MUTE_CTL])
+			else if (sw != path->ctls[NID_PATH_MUTE_CTL]) {
 				multi = true;
 				multi = true;
+				if (!same_amp_caps(codec, sw,
+				    path->ctls[NID_PATH_MUTE_CTL], HDA_INPUT))
+					multi_cap_vol = true;
+			}
 			if (is_inv_dmic_pin(codec, spec->imux_pins[i]))
 			if (is_inv_dmic_pin(codec, spec->imux_pins[i]))
 				inv_dmic = true;
 				inv_dmic = true;
 		}
 		}
@@ -2793,7 +2811,7 @@ static int create_capture_mixers(struct hda_codec *codec)
 		if (!multi)
 		if (!multi)
 			err = create_single_cap_vol_ctl(codec, n, vol, sw,
 			err = create_single_cap_vol_ctl(codec, n, vol, sw,
 							inv_dmic);
 							inv_dmic);
-		else if (!spec->multi_cap_vol)
+		else if (!multi_cap_vol)
 			err = create_bind_cap_vol_ctl(codec, n, vol, sw);
 			err = create_bind_cap_vol_ctl(codec, n, vol, sw);
 		else
 		else
 			err = create_multi_cap_vol_ctl(codec);
 			err = create_multi_cap_vol_ctl(codec);