aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>2022-04-21 15:31:56 -0500
committerMark Brown <broonie@kernel.org>2022-04-25 13:58:32 +0100
commit81622503229943363858cd7ae1330f49b131dfbc (patch)
tree76106a833444cd85ee5a7aafac0d1d04a5ca6cea
parentd1c73a213b462058e91654b5d1d493b3003375cd (diff)
ASOC: SOF: Intel: hda-dai: add hda_dai_hw_free_ipc() helper
We do the same thing from different places, let's use a helper. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220421203201.1550328-10-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/sof/intel/hda-dai.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c
index 20eb4097ce75..0521cb755a8a 100644
--- a/sound/soc/sof/intel/hda-dai.c
+++ b/sound/soc/sof/intel/hda-dai.c
@@ -382,6 +382,16 @@ static int ipc3_hda_dai_prepare(struct snd_pcm_substream *substream,
return hda_dai_hw_params_update(substream, &rtd->dpcm[stream].hw_params, dai);
}
+static int hda_dai_hw_free_ipc(int stream, /* direction */
+ struct snd_soc_dai *dai)
+{
+ struct snd_soc_dapm_widget *w;
+
+ w = snd_soc_dai_get_widget(dai, stream);
+
+ /* free the link DMA channel in the FW and the DAI widget */
+ return hda_dai_widget_update(w, DMA_CHAN_INVALID, false);
+}
static int ipc3_hda_dai_trigger(struct snd_pcm_substream *substream,
int cmd, struct snd_soc_dai *dai)
@@ -402,7 +412,7 @@ static int ipc3_hda_dai_trigger(struct snd_pcm_substream *substream,
/*
* free DAI widget during stop/suspend to keep widget use_count's balanced.
*/
- ret = hda_dai_widget_update(w, DMA_CHAN_INVALID, false);
+ ret = hda_dai_hw_free_ipc(substream->stream, dai);
if (ret < 0)
return ret;
@@ -422,21 +432,13 @@ static int ipc3_hda_dai_trigger(struct snd_pcm_substream *substream,
static int hda_dai_hw_free(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
- struct snd_soc_dapm_widget *w;
int ret;
ret = hda_link_dma_hw_free(substream);
if (ret < 0)
return ret;
- w = snd_soc_dai_get_widget(dai, substream->stream);
-
- /* free the link DMA channel in the FW and the DAI widget */
- ret = hda_dai_widget_update(w, DMA_CHAN_INVALID, false);
- if (ret < 0)
- return ret;
-
- return 0;
+ return hda_dai_hw_free_ipc(substream->stream, dai);
}
static const struct snd_soc_dai_ops ipc3_hda_dai_ops = {