Skip to content

Commit aaab61d

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: Intel: Read the LLP via the associated Link DMA channel
It is allowed to mix Link and Host DMA channels in a way that their index is different. In this case we would read the LLP from a channel which is not used or used for other operation. Such case can be reproduced on cAVS2.5 or ACE1 platforms with soundwire configuration: playback to SDW would take Host channel 0 (stream_tag 1) and no Link DMA used Second playback to HDMI (HDA) would use Host channel 1 (stream_tag 2) and Link channel 0 (stream_tag 1). In this case reading the LLP from channel 2 is incorrect as that is not the Link channel used for the HDMI playback. To correct this, we should look up the BE and get the channel used on the Link side. Fixes: 67b182b ("ASoC: SOF: Intel: hda: Implement get_stream_position (Linear Link Position)") Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://patch.msgid.link/20251002074719.2084-6-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent a4b8152 commit aaab61d

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

sound/soc/sof/intel/hda-stream.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,10 +1129,35 @@ u64 hda_dsp_get_stream_llp(struct snd_sof_dev *sdev,
11291129
struct snd_soc_component *component,
11301130
struct snd_pcm_substream *substream)
11311131
{
1132-
struct hdac_stream *hstream = substream->runtime->private_data;
1133-
struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream);
1132+
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1133+
struct snd_soc_pcm_runtime *be_rtd = NULL;
1134+
struct hdac_ext_stream *hext_stream;
1135+
struct snd_soc_dai *cpu_dai;
1136+
struct snd_soc_dpcm *dpcm;
11341137
u32 llp_l, llp_u;
11351138

1139+
/*
1140+
* The LLP needs to be read from the Link DMA used for this FE as it is
1141+
* allowed to use any combination of Link and Host channels
1142+
*/
1143+
for_each_dpcm_be(rtd, substream->stream, dpcm) {
1144+
if (dpcm->fe != rtd)
1145+
continue;
1146+
1147+
be_rtd = dpcm->be;
1148+
}
1149+
1150+
if (!be_rtd)
1151+
return 0;
1152+
1153+
cpu_dai = snd_soc_rtd_to_cpu(be_rtd, 0);
1154+
if (!cpu_dai)
1155+
return 0;
1156+
1157+
hext_stream = snd_soc_dai_get_dma_data(cpu_dai, substream);
1158+
if (!hext_stream)
1159+
return 0;
1160+
11361161
/*
11371162
* The pplc_addr have been calculated during probe in
11381163
* hda_dsp_stream_init():

0 commit comments

Comments
 (0)