ASoC: SOF: pcm: add .ack callback support
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Fri, 19 Nov 2021 23:08:51 +0000 (17:08 -0600)
committerMark Brown <broonie@kernel.org>
Wed, 24 Nov 2021 12:57:19 +0000 (12:57 +0000)
Add the indirections required at the core level for platform-specific
operations on ack.

Note that on errors in the .ack the ALSA core will restore the
previous appl_ptr.

Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211119230852.206310-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/ops.h
sound/soc/sof/pcm.c
sound/soc/sof/sof-priv.h

index a0648a13e3ebd77358d481445ff1b4381259031b..0226a53148c92ab4e6df8643942c254792d3da3f 100644 (file)
@@ -487,6 +487,16 @@ snd_sof_pcm_platform_pointer(struct snd_sof_dev *sdev,
        return 0;
 }
 
+/* pcm ack */
+static inline int snd_sof_pcm_platform_ack(struct snd_sof_dev *sdev,
+                                          struct snd_pcm_substream *substream)
+{
+       if (sof_ops(sdev) && sof_ops(sdev)->pcm_ack)
+               return sof_ops(sdev)->pcm_ack(sdev, substream);
+
+       return 0;
+}
+
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_PROBES)
 static inline int
 snd_sof_probe_compr_assign(struct snd_sof_dev *sdev,
index 31dd79b794f15657b6755659b3494ded957192c2..98aa5a6579e3eda73b4bf74156936c025e81ca8c 100644 (file)
@@ -917,6 +917,14 @@ static void sof_pcm_remove(struct snd_soc_component *component)
        snd_soc_tplg_component_remove(component);
 }
 
+static int sof_pcm_ack(struct snd_soc_component *component,
+                      struct snd_pcm_substream *substream)
+{
+       struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
+
+       return snd_sof_pcm_platform_ack(sdev, substream);
+}
+
 void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
 {
        struct snd_soc_component_driver *pd = &sdev->plat_drv;
@@ -935,6 +943,7 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
        pd->hw_free = sof_pcm_hw_free;
        pd->trigger = sof_pcm_trigger;
        pd->pointer = sof_pcm_pointer;
+       pd->ack = sof_pcm_ack;
 
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_PROBES)
        pd->compress_ops = &sof_probe_compressed_ops;
index a9c5197617f16f9c5eea52db72910f0ca44ace3c..16caf5c74035dbacc075ff36f9a40895f188e285 100644 (file)
@@ -207,6 +207,9 @@ struct snd_sof_dsp_ops {
        snd_pcm_uframes_t (*pcm_pointer)(struct snd_sof_dev *sdev,
                                         struct snd_pcm_substream *substream); /* optional */
 
+       /* pcm ack */
+       int (*pcm_ack)(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream); /* optional */
+
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_PROBES)
        /* Except for probe_pointer, all probe ops are mandatory */
        int (*probe_assign)(struct snd_sof_dev *sdev,