]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ASoC: SOF: Intel: Set the dai/host get frame/byte counter callbacks
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Thu, 21 Mar 2024 13:08:04 +0000 (15:08 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:38:17 +0000 (16:38 +0200)
commit fd6f6a0632bc891673490bf4a92304172251825c upstream.

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: stable@vger.kernel.org # 6.8
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://msgid.link/r/20240321130814.4412-8-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/soc/sof/intel/hda-common-ops.c
sound/soc/sof/intel/hda-stream.c
sound/soc/sof/intel/hda.h

index dd658ad95ffc9332fae7ec39381cb5a6c1d7768c..a69d63eb37eeab5aa1cedd617bddeca7a82a813f 100644 (file)
@@ -58,6 +58,8 @@ struct snd_sof_dsp_ops sof_hda_common_ops = {
        .pcm_ack        = hda_dsp_pcm_ack,
 
        .get_stream_position = hda_dsp_get_stream_llp,
+       .get_dai_frame_counter = hda_dsp_get_stream_llp,
+       .get_host_byte_counter = hda_dsp_get_stream_ldp,
 
        /* firmware loading */
        .load_firmware = snd_sof_load_firmware_raw,
index 11de9cccaad0d61b08ecb46caab21fd192eabc06..4893d95b8467101fc3fe4148caeac9fd5fb425e2 100644 (file)
@@ -1086,3 +1086,34 @@ u64 hda_dsp_get_stream_llp(struct snd_sof_dev *sdev,
 
        return ((u64)llp_u << 32) | llp_l;
 }
+
+/**
+ * hda_dsp_get_stream_ldp - Retrieve the LDP (Linear DMA Position) of the stream
+ * @sdev: SOF device
+ * @component: ASoC component
+ * @substream: PCM substream
+ *
+ * Returns the raw Linear Link Position value
+ */
+u64 hda_dsp_get_stream_ldp(struct snd_sof_dev *sdev,
+                          struct snd_soc_component *component,
+                          struct snd_pcm_substream *substream)
+{
+       struct hdac_stream *hstream = substream->runtime->private_data;
+       struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream);
+       u32 ldp_l, ldp_u;
+
+       /*
+        * The pphc_addr have been calculated during probe in
+        * hda_dsp_stream_init():
+        * pphc_addr = sdev->bar[HDA_DSP_PP_BAR] +
+        *             SOF_HDA_PPHC_BASE +
+        *             SOF_HDA_PPHC_INTERVAL * stream_index
+        *
+        * Use this pre-calculated address to avoid repeated re-calculation.
+        */
+       ldp_l = readl(hext_stream->pphc_addr + AZX_REG_PPHCLDPL);
+       ldp_u = readl(hext_stream->pphc_addr + AZX_REG_PPHCLDPU);
+
+       return ((u64)ldp_u << 32) | ldp_l;
+}
index b6d599acf15d97875d5ebced06d0285b78214941..efb42117df7936656c5e6f7ca98dd8132d669ca0 100644 (file)
@@ -660,6 +660,9 @@ snd_pcm_uframes_t hda_dsp_stream_get_position(struct hdac_stream *hstream,
 u64 hda_dsp_get_stream_llp(struct snd_sof_dev *sdev,
                           struct snd_soc_component *component,
                           struct snd_pcm_substream *substream);
+u64 hda_dsp_get_stream_ldp(struct snd_sof_dev *sdev,
+                          struct snd_soc_component *component,
+                          struct snd_pcm_substream *substream);
 
 struct hdac_ext_stream *
        hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags);