Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions sound/pci/hda/patch_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ static int hinfo_to_pcm_index(struct hda_codec *codec,
if (get_pcm_rec(spec, pcm_idx)->stream == hinfo)
return pcm_idx;

codec_warn(codec, "HDMI: hinfo %p not registered\n", hinfo);
codec_warn(codec, "HDMI: hinfo %p not tied to a PCM\n", hinfo);
return -EINVAL;
}

Expand All @@ -277,7 +277,8 @@ static int hinfo_to_pin_index(struct hda_codec *codec,
return pin_idx;
}

codec_dbg(codec, "HDMI: hinfo %p not registered\n", hinfo);
codec_dbg(codec, "HDMI: hinfo %p (pcm %u) not registered\n", hinfo,
hinfo_to_pcm_index(codec, hinfo));
return -EINVAL;
}

Expand Down Expand Up @@ -952,6 +953,26 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
return 0;
}

static int hdmi_choose_cvt_nopin(struct hda_codec *codec,
int pcm_idx, int *cvt_id)
{
struct hdmi_spec *spec = codec->spec;
struct hdmi_spec_per_cvt *per_cvt;

if (pcm_idx >= spec->num_cvts)
return -EINVAL;

per_cvt = get_cvt(spec, pcm_idx);

if (per_cvt->assigned)
return -EBUSY;

if (cvt_id)
*cvt_id = pcm_idx;

return 0;
}

/* Try to find an available converter
* If pin_idx is less then zero, just try to find an available converter.
* Otherwise, try to find an available converter and get the cvt mux index
Expand Down Expand Up @@ -1162,7 +1183,9 @@ static int hdmi_pcm_open_no_pin(struct hda_pcm_stream *hinfo,
if (pcm_idx < 0)
return -EINVAL;

err = hdmi_choose_cvt(codec, -1, &cvt_idx);
err = hdmi_choose_cvt_nopin(codec, pcm_idx, &cvt_idx);
if (err)
err = hdmi_choose_cvt(codec, -1, &cvt_idx);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit message nit-pick:
Fix the problem by prioritizing the converter with the same index as PCM

This isn't really prioritizing, you first try with the nopin version then fallback to the existing solution.

if (err)
return err;

Expand Down
7 changes: 1 addition & 6 deletions sound/soc/codecs/hdac_hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ static int hdac_hda_dai_open(struct snd_pcm_substream *substream,
struct hdac_hda_priv *hda_pvt;
struct hda_pcm_stream *hda_stream;
struct hda_pcm *pcm;
int ret;

hda_pvt = snd_soc_component_get_drvdata(component);
pcm = snd_soc_find_pcm_from_dai(hda_pvt, dai);
Expand All @@ -300,11 +299,7 @@ static int hdac_hda_dai_open(struct snd_pcm_substream *substream,

hda_stream = &pcm->stream[substream->stream];

ret = hda_stream->ops.open(hda_stream, &hda_pvt->codec, substream);
if (ret < 0)
snd_hda_codec_pcm_put(pcm);

return ret;
return hda_stream->ops.open(hda_stream, &hda_pvt->codec, substream);
}

static void hdac_hda_dai_close(struct snd_pcm_substream *substream,
Expand Down