Skip to content

Commit fd6f6a0

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: Intel: Set the dai/host get frame/byte counter callbacks
Add implementation for reading the LDP (Linear DMA Position) to be used as get_host_byte_counter(). The LDP is counting the number of bytes moved between the DSP and host memory. Set the get_dai_frame_counter to hda_dsp_get_stream_llp, which is counting the frames on the link side of the DSP. Cc: [email protected] # 6.8 Signed-off-by: Peter Ujfalusi <[email protected]> Reviewed-by: Kai Vehmanen <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ce2faa9 commit fd6f6a0

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

sound/soc/sof/intel/hda-common-ops.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ struct snd_sof_dsp_ops sof_hda_common_ops = {
5858
.pcm_ack = hda_dsp_pcm_ack,
5959

6060
.get_stream_position = hda_dsp_get_stream_llp,
61+
.get_dai_frame_counter = hda_dsp_get_stream_llp,
62+
.get_host_byte_counter = hda_dsp_get_stream_ldp,
6163

6264
/* firmware loading */
6365
.load_firmware = snd_sof_load_firmware_raw,

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,3 +1095,34 @@ u64 hda_dsp_get_stream_llp(struct snd_sof_dev *sdev,
10951095

10961096
return ((u64)llp_u << 32) | llp_l;
10971097
}
1098+
1099+
/**
1100+
* hda_dsp_get_stream_ldp - Retrieve the LDP (Linear DMA Position) of the stream
1101+
* @sdev: SOF device
1102+
* @component: ASoC component
1103+
* @substream: PCM substream
1104+
*
1105+
* Returns the raw Linear Link Position value
1106+
*/
1107+
u64 hda_dsp_get_stream_ldp(struct snd_sof_dev *sdev,
1108+
struct snd_soc_component *component,
1109+
struct snd_pcm_substream *substream)
1110+
{
1111+
struct hdac_stream *hstream = substream->runtime->private_data;
1112+
struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream);
1113+
u32 ldp_l, ldp_u;
1114+
1115+
/*
1116+
* The pphc_addr have been calculated during probe in
1117+
* hda_dsp_stream_init():
1118+
* pphc_addr = sdev->bar[HDA_DSP_PP_BAR] +
1119+
* SOF_HDA_PPHC_BASE +
1120+
* SOF_HDA_PPHC_INTERVAL * stream_index
1121+
*
1122+
* Use this pre-calculated address to avoid repeated re-calculation.
1123+
*/
1124+
ldp_l = readl(hext_stream->pphc_addr + AZX_REG_PPHCLDPL);
1125+
ldp_u = readl(hext_stream->pphc_addr + AZX_REG_PPHCLDPU);
1126+
1127+
return ((u64)ldp_u << 32) | ldp_l;
1128+
}

sound/soc/sof/intel/hda.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,9 @@ snd_pcm_uframes_t hda_dsp_stream_get_position(struct hdac_stream *hstream,
665665
u64 hda_dsp_get_stream_llp(struct snd_sof_dev *sdev,
666666
struct snd_soc_component *component,
667667
struct snd_pcm_substream *substream);
668+
u64 hda_dsp_get_stream_ldp(struct snd_sof_dev *sdev,
669+
struct snd_soc_component *component,
670+
struct snd_pcm_substream *substream);
668671

669672
struct hdac_ext_stream *
670673
hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags);

0 commit comments

Comments
 (0)