Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f25dcf6 authored by David Henningsson's avatar David Henningsson Committed by Takashi Iwai
Browse files

ALSA: hda - Don't add unnecessary indices on HDMI and SPDIF



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

[slight code refactoring by tiwai]

Signed-off-by: default avatarDavid Henningsson <david.henningsson@canonical.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 8e8db7f1
Loading
Loading
Loading
Loading
+16 −10
Original line number Original line Diff line number Diff line
@@ -583,6 +583,9 @@ static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid,
	return 1;
	return 1;
}
}


#define is_hdmi_cfg(conf) \
	(get_defcfg_location(conf) == AC_JACK_LOC_HDMI)

/**
/**
 * snd_hda_get_pin_label - Get a label for the given I/O pin
 * snd_hda_get_pin_label - Get a label for the given I/O pin
 *
 *
@@ -603,6 +606,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);
	unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
	const char *name = NULL;
	const char *name = NULL;
	int i;
	int i;
	bool hdmi;


	if (indexp)
	if (indexp)
		*indexp = 0;
		*indexp = 0;
@@ -621,15 +625,17 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
					   label, maxlen, indexp);
					   label, maxlen, indexp);
	case AC_JACK_SPDIF_OUT:
	case AC_JACK_SPDIF_OUT:
	case AC_JACK_DIG_OTHER_OUT:
	case AC_JACK_DIG_OTHER_OUT:
		if (get_defcfg_location(def_conf) == AC_JACK_LOC_HDMI)
		hdmi = is_hdmi_cfg(def_conf);
			name = "HDMI";
		name = hdmi ? "HDMI" : "SPDIF";
		else
		if (cfg && indexp)
			name = "SPDIF";
			for (i = 0; i < cfg->dig_outs; i++) {
		if (cfg && indexp) {
				hda_nid_t pin = cfg->dig_out_pins[i];
			i = find_idx_in_nid_list(nid, cfg->dig_out_pins,
				unsigned int c;
						 cfg->dig_outs);
				if (pin == nid)
			if (i >= 0)
					break;
				*indexp = i;
				c = snd_hda_codec_get_pincfg(codec, pin);
				if (hdmi == is_hdmi_cfg(c))
					(*indexp)++;
			}
			}
		break;
		break;
	default:
	default: