ASoC: SOF: pcm: add pending_stop state variable
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Tue, 2 Apr 2024 15:18:26 +0000 (10:18 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 2 Apr 2024 16:14:56 +0000 (17:14 +0100)
Add a state variable to keep track of delayed stops, in case
pcm_ops->platform_stop_during_hw_free is set.

This patch should be iso-functionality, possibly removing no-op
cases. The main purpose of this new state variable is to prepare a
follow-up patch to reset all PCM and DMAs in case of stop/prepare xrun
sequences.

Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://msgid.link/r/20240402151828.175002-16-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/pcm.c
sound/soc/sof/sof-audio.c
sound/soc/sof/sof-audio.h

index 7b732f31f97405cfb950df93243bd65b2c52249a..2e8782dddc807234922a90b31962a3e96a28f578 100644 (file)
@@ -276,6 +276,8 @@ static int sof_pcm_trigger(struct snd_soc_component *component,
        dev_dbg(component->dev, "pcm: trigger stream %d dir %d cmd %d\n",
                spcm->pcm.pcm_id, substream->stream, cmd);
 
+       spcm->pending_stop[substream->stream] = false;
+
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
                ipc_first = true;
@@ -345,6 +347,15 @@ static int sof_pcm_trigger(struct snd_soc_component *component,
                /* invoke platform trigger to stop DMA even if pcm_ops isn't set or if it failed */
                if (!pcm_ops || !pcm_ops->platform_stop_during_hw_free)
                        snd_sof_pcm_platform_trigger(sdev, substream, cmd);
+
+               /*
+                * set the pending_stop flag to indicate that pipeline stop has been delayed.
+                * This will be used later to stop the pipelines during prepare when recovering
+                * from xruns.
+                */
+               if (pcm_ops && pcm_ops->platform_stop_during_hw_free &&
+                   cmd == SNDRV_PCM_TRIGGER_STOP)
+                       spcm->pending_stop[substream->stream] = true;
                break;
        default:
                break;
index b5ca2861edbd5d82abf1364c5bb3c1e1d28500e0..32fef64ef10ddb1ec93aa510c48692d90c8a655a 100644 (file)
@@ -852,6 +852,7 @@ int sof_pcm_stream_free(struct snd_sof_dev *sdev, struct snd_pcm_substream *subs
                }
 
                spcm->prepared[substream->stream] = false;
+               spcm->pending_stop[substream->stream] = false;
        }
 
        /* reset the DMA */
index fd664d5586f0d579236ab6a56ce336fa50214dbb..80a5bd69ef1c79b7071d9fba08100a7ac6a4f13b 100644 (file)
@@ -342,6 +342,7 @@ struct snd_sof_pcm {
        struct list_head list;  /* list in sdev pcm list */
        struct snd_pcm_hw_params params[2];
        bool prepared[2]; /* PCM_PARAMS set successfully */
+       bool pending_stop[2]; /* only used if (!pcm_ops->platform_stop_during_hw_free) */
 };
 
 struct snd_sof_led_control {