OSDN Git Service

ASoC: SOF: Intel: hda: send DAI_CONFIG IPC during pause
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Thu, 25 Nov 2021 10:15:20 +0000 (12:15 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 26 Nov 2021 13:24:26 +0000 (13:24 +0000)
For HDA DAI's the DMA must be paused after the RUN bit is cleared by the
host. So, send the DAI_CONFIG IPC with just the SOF_DAI_CONFIG_FLAGS_PAUSE
flag set to indicate this to the firmware.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211125101520.291581-11-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda-dai.c

index bce5366..8c1d7dd 100644 (file)
@@ -287,6 +287,36 @@ static int hda_link_pcm_prepare(struct snd_pcm_substream *substream,
                                  dai);
 }
 
+static int hda_link_dai_config_pause_push_ipc(struct snd_soc_dapm_widget *w)
+{
+       struct snd_sof_widget *swidget = w->dobj.private;
+       struct snd_soc_component *component = swidget->scomp;
+       struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
+       struct sof_ipc_dai_config *config;
+       struct snd_sof_dai *sof_dai;
+       struct sof_ipc_reply reply;
+       int ret;
+
+       sof_dai = swidget->private;
+
+       if (!sof_dai || !sof_dai->dai_config) {
+               dev_err(sdev->dev, "No config for DAI %s\n", w->name);
+               return -EINVAL;
+       }
+
+       config = &sof_dai->dai_config[sof_dai->current_config];
+
+       /* set PAUSE command flag */
+       config->flags = FIELD_PREP(SOF_DAI_CONFIG_FLAGS_CMD_MASK, SOF_DAI_CONFIG_FLAGS_PAUSE);
+
+       ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, config->hdr.size,
+                                &reply, sizeof(reply));
+       if (ret < 0)
+               dev_err(sdev->dev, "DAI config for %s failed during pause push\n", w->name);
+
+       return ret;
+}
+
 static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
                                int cmd, struct snd_soc_dai *dai)
 {
@@ -312,6 +342,9 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
        hda_stream = hstream_to_sof_hda_stream(link_dev);
 
        dev_dbg(dai->dev, "In %s cmd=%d\n", __func__, cmd);
+
+       w = snd_soc_dai_get_widget(dai, substream->stream);
+
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_RESUME:
                /* set up hw_params */
@@ -331,11 +364,6 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
        case SNDRV_PCM_TRIGGER_STOP:
                snd_hdac_ext_link_stream_clear(link_dev);
 
-               if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-                       w = dai->playback_widget;
-               else
-                       w = dai->capture_widget;
-
                /*
                 * free DAI widget during stop/suspend to keep widget use_count's balanced.
                 */
@@ -352,6 +380,10 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
                break;
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
                snd_hdac_ext_link_stream_clear(link_dev);
+
+               ret = hda_link_dai_config_pause_push_ipc(w);
+               if (ret < 0)
+                       return ret;
                break;
        default:
                return -EINVAL;