]> www.infradead.org Git - users/hch/dma-mapping.git/commitdiff
ASoC: SOF: add delay function support in sof framework
authorRander Wang <rander.wang@intel.com>
Thu, 2 Feb 2023 13:29:51 +0000 (15:29 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 3 Feb 2023 12:03:52 +0000 (12:03 +0000)
Sof framework will call specific delay function for
different IPC version.

Signed-off-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230202132954.26773-7-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/pcm.c
sound/soc/sof/sof-audio.h

index 34d40c5c629a2bd0a804d5e4a74c24f84577baa1..445acb5c3a21bb3a744e73e66ab55cd546a0dc48 100644 (file)
@@ -646,6 +646,18 @@ static int sof_pcm_ack(struct snd_soc_component *component,
        return snd_sof_pcm_platform_ack(sdev, substream);
 }
 
+static snd_pcm_sframes_t sof_pcm_delay(struct snd_soc_component *component,
+                                      struct snd_pcm_substream *substream)
+{
+       struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
+       const struct sof_ipc_pcm_ops *pcm_ops = sof_ipc_get_ops(sdev, pcm);
+
+       if (pcm_ops && pcm_ops->delay)
+               return pcm_ops->delay(component, substream);
+
+       return 0;
+}
+
 void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
 {
        struct snd_soc_component_driver *pd = &sdev->plat_drv;
@@ -670,6 +682,7 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
        pd->trigger = sof_pcm_trigger;
        pd->pointer = sof_pcm_pointer;
        pd->ack = sof_pcm_ack;
+       pd->delay = sof_pcm_delay;
 
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS)
        pd->compress_ops = &sof_compressed_ops;
index 334b715b17c8a0c5381e273626bfdb5fb0858be8..d3104941e83ec8d4e45a7bbfe1f10e68b1cf140b 100644 (file)
@@ -102,6 +102,7 @@ struct snd_sof_dai_config_data {
  *            additional memory in the SOF PCM stream structure
  * @pcm_free: Function pointer for PCM free that can be used for freeing any
  *            additional memory in the SOF PCM stream structure
+ * @delay: Function pointer for pcm delay calculation
  */
 struct sof_ipc_pcm_ops {
        int (*hw_params)(struct snd_soc_component *component, struct snd_pcm_substream *substream,
@@ -113,6 +114,8 @@ struct sof_ipc_pcm_ops {
        int (*dai_link_fixup)(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params);
        int (*pcm_setup)(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm);
        void (*pcm_free)(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm);
+       snd_pcm_sframes_t (*delay)(struct snd_soc_component *component,
+                                  struct snd_pcm_substream *substream);
 };
 
 /**