Skip to content

Commit 5627503

Browse files
kv2019itiwai
authored andcommitted
ALSA: hda/hdmi: fix failures at PCM open on Intel ICL and later
When HDMI PCM devices are opened in a specific order, with at least one HDMI/DP receiver connected, ALSA PCM open fails to -EBUSY on the connected monitor, on recent Intel platforms (ICL/JSL and newer). While this is not a typical sequence, at least Pulseaudio does this every time when it is started, to discover the available PCMs. The rootcause is an invalid assumption in hdmi_add_pin(), where the total number of converters is assumed to be known at the time the function is called. On older Intel platforms this held true, but after ICL/JSL, the order how pins and converters are in the subnode list as returned by snd_hda_get_sub_nodes(), was changed. As a result, information for some converters was not stored to per_pin->mux_nids. And this means some pins cannot be connected to all converters, and application instead gets -EBUSY instead at open. The assumption that converters are always before pins in the subnode list, is not really a valid one. Fix the problem in hdmi_parse_codec() by introducing separate loops for discovering converters and pins. BugLink: thesofproject#1978 BugLink: thesofproject#2216 BugLink: thesofproject#2217 Reviewed-by: Ranjani Sridharan <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Signed-off-by: Kai Vehmanen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent ad15571 commit 5627503

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

sound/pci/hda/patch_hdmi.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,33 +1804,43 @@ static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid)
18041804

18051805
static int hdmi_parse_codec(struct hda_codec *codec)
18061806
{
1807-
hda_nid_t nid;
1807+
hda_nid_t start_nid;
1808+
unsigned int caps;
18081809
int i, nodes;
18091810

1810-
nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &nid);
1811-
if (!nid || nodes < 0) {
1811+
nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid);
1812+
if (!start_nid || nodes < 0) {
18121813
codec_warn(codec, "HDMI: failed to get afg sub nodes\n");
18131814
return -EINVAL;
18141815
}
18151816

1816-
for (i = 0; i < nodes; i++, nid++) {
1817-
unsigned int caps;
1818-
unsigned int type;
1817+
/*
1818+
* hdmi_add_pin() assumes total amount of converters to
1819+
* be known, so first discover all converters
1820+
*/
1821+
for (i = 0; i < nodes; i++) {
1822+
hda_nid_t nid = start_nid + i;
18191823

18201824
caps = get_wcaps(codec, nid);
1821-
type = get_wcaps_type(caps);
18221825

18231826
if (!(caps & AC_WCAP_DIGITAL))
18241827
continue;
18251828

1826-
switch (type) {
1827-
case AC_WID_AUD_OUT:
1829+
if (get_wcaps_type(caps) == AC_WID_AUD_OUT)
18281830
hdmi_add_cvt(codec, nid);
1829-
break;
1830-
case AC_WID_PIN:
1831+
}
1832+
1833+
/* discover audio pins */
1834+
for (i = 0; i < nodes; i++) {
1835+
hda_nid_t nid = start_nid + i;
1836+
1837+
caps = get_wcaps(codec, nid);
1838+
1839+
if (!(caps & AC_WCAP_DIGITAL))
1840+
continue;
1841+
1842+
if (get_wcaps_type(caps) == AC_WID_PIN)
18311843
hdmi_add_pin(codec, nid);
1832-
break;
1833-
}
18341844
}
18351845

18361846
return 0;

0 commit comments

Comments
 (0)