[alsa-devel] [PATCH 3/3] ALSA: hda - Don't add unnecessary indices on HDMI and SPDIF

David Henningsson david.henningsson at canonical.com
Fri Jan 18 15:43:03 CET 2013


If there's one each of HDMI and SPDIF, we should not add an index
on the one that comes second.

Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
 sound/pci/hda/hda_auto_parser.c |   22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c
index a4810c7..dcb6575 100644
--- a/sound/pci/hda/hda_auto_parser.c
+++ b/sound/pci/hda/hda_auto_parser.c
@@ -603,6 +603,7 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
 	unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
 	const char *name = NULL;
 	int i;
+	bool hdmi;
 
 	if (indexp)
 		*indexp = 0;
@@ -621,16 +622,17 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
 					   label, maxlen, indexp);
 	case AC_JACK_SPDIF_OUT:
 	case AC_JACK_DIG_OTHER_OUT:
-		if (get_defcfg_location(def_conf) == AC_JACK_LOC_HDMI)
-			name = "HDMI";
-		else
-			name = "SPDIF";
-		if (cfg && indexp) {
-			i = find_idx_in_nid_list(nid, cfg->dig_out_pins,
-						 cfg->dig_outs);
-			if (i >= 0)
-				*indexp = i;
-		}
+		hdmi = get_defcfg_location(def_conf) == AC_JACK_LOC_HDMI;
+		name = hdmi ? "HDMI" : "SPDIF";
+		if (cfg && indexp)
+			for (i = 0; i < cfg->dig_outs; i++) {
+				unsigned int c;
+				if (cfg->dig_out_pins[i] == nid)
+					break;
+				c = snd_hda_codec_get_pincfg(codec, cfg->dig_out_pins[i]);
+				if (hdmi == (get_defcfg_location(c) == AC_JACK_LOC_HDMI))
+					(*indexp)++;
+			}
 		break;
 	default:
 		if (cfg) {
-- 
1.7.9.5



More information about the Alsa-devel mailing list