From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: kai.vehmanen@linux.intel.com, yung-chuan.liao@linux.intel.com,
lgirdwood@gmail.com, pierre-louis.bossart@linux.intel.com,
ranjani.sridharan@linux.intel.com, daniel.baluta@nxp.com
Subject: [PATCH 06/10] ASoC: SOF: Add a helper for freeing PCM stream
Date: Thu, 25 Nov 2021 12:15:16 +0200 [thread overview]
Message-ID: <20211125101520.291581-7-kai.vehmanen@linux.intel.com> (raw)
In-Reply-To: <20211125101520.291581-1-kai.vehmanen@linux.intel.com>
From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add a helper function to free PCM in the FW, stop the DMA and free the
widget list. These actions are performed both during PCM trigger STOP
and when a paused stream is freed during system suspend.
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>
---
sound/soc/sof/pcm.c | 11 ++---------
sound/soc/sof/sof-audio.c | 40 +++++++++++++++++++++++++--------------
sound/soc/sof/sof-audio.h | 2 ++
3 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
index 1d0d90551e8f..3aa708b1ac26 100644
--- a/sound/soc/sof/pcm.c
+++ b/sound/soc/sof/pcm.c
@@ -466,17 +466,10 @@ static int sof_pcm_trigger(struct snd_soc_component *component,
/* free PCM if reset_hw_params is set and the STOP IPC is successful */
if (!ret && reset_hw_params) {
- ret = sof_pcm_dsp_pcm_free(substream, sdev, spcm);
+ ret = sof_pcm_stream_free(sdev, substream, spcm, substream->stream,
+ free_widget_list);
if (ret < 0)
return ret;
-
- ret = snd_sof_pcm_platform_hw_free(sdev, substream);
- if (ret < 0)
- return ret;
-
- /* free widget list only for SUSPEND trigger */
- if (free_widget_list)
- ret = sof_widget_list_free(sdev, spcm, substream->stream);
}
return ret;
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index d81071b39825..a275f7b7c812 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -728,6 +728,31 @@ int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify)
return 0;
}
+int sof_pcm_stream_free(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
+ struct snd_sof_pcm *spcm, int dir, bool free_widget_list)
+{
+ int ret;
+
+ /* Send PCM_FREE IPC to reset pipeline */
+ ret = sof_pcm_dsp_pcm_free(substream, sdev, spcm);
+ if (ret < 0)
+ return ret;
+
+ /* stop the DMA */
+ ret = snd_sof_pcm_platform_hw_free(sdev, substream);
+ if (ret < 0)
+ return ret;
+
+ /* free widget list */
+ if (free_widget_list) {
+ ret = sof_widget_list_free(sdev, spcm, dir);
+ if (ret < 0)
+ dev_err(sdev->dev, "failed to free widgets during suspend\n");
+ }
+
+ return ret;
+}
+
/*
* Free the PCM, its associated widgets and set the prepared flag to false for all PCMs that
* did not get suspended(ex: paused streams) so the widgets can be set up again during resume.
@@ -751,22 +776,9 @@ static int sof_tear_down_left_over_pipelines(struct snd_sof_dev *sdev)
continue;
if (spcm->stream[dir].list) {
- /* Free PCM in the DSP */
- ret = sof_pcm_dsp_pcm_free(substream, sdev, spcm);
- if (ret < 0)
- return ret;
-
- /* stop DMA */
- ret = snd_sof_pcm_platform_hw_free(sdev, substream);
+ ret = sof_pcm_stream_free(sdev, substream, spcm, dir, true);
if (ret < 0)
return ret;
-
- /* free the DAPM widget list */
- ret = sof_widget_list_free(sdev, spcm, dir);
- if (ret < 0) {
- dev_err(sdev->dev, "failed to free widgets during suspend\n");
- return ret;
- }
}
}
diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h
index 1c4f59d34717..e419e7082c28 100644
--- a/sound/soc/sof/sof-audio.h
+++ b/sound/soc/sof/sof-audio.h
@@ -267,4 +267,6 @@ int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, in
int sof_widget_list_free(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int dir);
int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream, struct snd_sof_dev *sdev,
struct snd_sof_pcm *spcm);
+int sof_pcm_stream_free(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
+ struct snd_sof_pcm *spcm, int dir, bool free_widget_list);
#endif
--
2.33.0
next prev parent reply other threads:[~2021-11-25 10:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 10:15 [PATCH 00/10] ASoC: SOF: Fixes for Intel HD-Audio DMA stopping Kai Vehmanen
2021-11-25 10:15 ` [PATCH 01/10] ASoC: SOF: Intel: hda: clear stream before freeing the DAI widget Kai Vehmanen
2021-11-25 10:15 ` [PATCH 02/10] ASoC: SOF: Intel: hda: Add a helper function for stream reset Kai Vehmanen
2021-11-25 10:15 ` [PATCH 03/10] ASoC: SOF: Intel: hda: reset stream before coupling host and link DMA's Kai Vehmanen
2021-11-25 10:15 ` [PATCH 04/10] ASoC: SOF: pcm: invoke platform hw_free for STOP/SUSPEND triggers Kai Vehmanen
2021-11-25 10:15 ` [PATCH 05/10] ASoC: SOF: call platform hw_free for paused streams during suspend Kai Vehmanen
2021-11-25 10:15 ` Kai Vehmanen [this message]
2021-11-25 10:15 ` [PATCH 07/10] ASoC: SOF: pcm: move the check for prepared flag Kai Vehmanen
2021-11-25 10:15 ` [PATCH 08/10] ASoC: SOF: align the hw_free sequence with stop Kai Vehmanen
2021-11-25 10:15 ` [PATCH 09/10] ASoC: SOF: IPC: dai: Expand DAI_CONFIG IPC flags Kai Vehmanen
2021-11-25 10:15 ` [PATCH 10/10] ASoC: SOF: Intel: hda: send DAI_CONFIG IPC during pause Kai Vehmanen
2021-11-27 1:29 ` [PATCH 00/10] ASoC: SOF: Fixes for Intel HD-Audio DMA stopping Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211125101520.291581-7-kai.vehmanen@linux.intel.com \
--to=kai.vehmanen@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=lgirdwood@gmail.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).