ASoC: Intel: Skylake: Reset DSP Pipelines in prepare
authorPardha Saradhi K <pardha.saradhi.kesapragada@intel.com>
Mon, 2 Apr 2018 06:45:48 +0000 (12:15 +0530)
committerMark Brown <broonie@kernel.org>
Tue, 17 Apr 2018 10:35:28 +0000 (11:35 +0100)
An application can choose to call .prepare function
any number of times. In such scenarios, there is a
need to reset the DSP pipeline.

Signed-off-by: Pardha Saradhi K <pardha.saradhi.kesapragada@intel.com>
Signed-off-by: Divya Prakash <divya1.prakash@intel.com>
Signed-off-by: Sriram Periyasamy <sriramx.periyasamy@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/skylake/skl-pcm.c

index fe25515..afa86b9 100644 (file)
@@ -268,15 +268,31 @@ static int skl_pcm_prepare(struct snd_pcm_substream *substream,
 {
        struct skl *skl = get_skl_ctx(dai->dev);
        struct skl_module_cfg *mconfig;
+       int ret;
 
        dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
 
        mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
 
-       /* In case of XRUN recovery, reset the FW pipe to clean state */
-       if (mconfig && (substream->runtime->status->state ==
-                                       SNDRV_PCM_STATE_XRUN))
-               skl_reset_pipe(skl->skl_sst, mconfig->pipe);
+       /*
+        * In case of XRUN recovery or in the case when the application
+        * calls prepare another time, reset the FW pipe to clean state
+        */
+       if (mconfig &&
+               (substream->runtime->status->state == SNDRV_PCM_STATE_XRUN ||
+                mconfig->pipe->state == SKL_PIPE_CREATED ||
+                mconfig->pipe->state == SKL_PIPE_PAUSED)) {
+
+               ret = skl_reset_pipe(skl->skl_sst, mconfig->pipe);
+
+               if (ret < 0)
+                       return ret;
+
+               ret = skl_pcm_host_dma_prepare(dai->dev,
+                                       mconfig->pipe->p_params);
+               if (ret < 0)
+                       return ret;
+       }
 
        return 0;
 }