diff mbox series

[05/14] ASoC: SOF: Intel: hda-dai: Pass the CPU dai pointer

Message ID 20230307140435.2808-6-peter.ujfalusi@linux.intel.com
State New
Headers show
Series ASoC: SOF: Intel: hda: Introduce HDA DAI abstraction | expand

Commit Message

Peter Ujfalusi March 7, 2023, 2:04 p.m. UTC
From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

Pass the CPU DAI pointer from the ASoC core to hda_link_dma_hw_params() and
ipc3_hda_dai_trigger(). This will avoid looking up the CPU DAI pointer
multiple times.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
 sound/soc/sof/intel/hda-dai.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c
index d4b98bfe2adf..e448c653cfe1 100644
--- a/sound/soc/sof/intel/hda-dai.c
+++ b/sound/soc/sof/intel/hda-dai.c
@@ -157,10 +157,9 @@  static int hda_link_dma_cleanup(struct snd_pcm_substream *substream,
 }
 
 static int hda_link_dma_hw_params(struct snd_pcm_substream *substream,
-				  struct snd_pcm_hw_params *params)
+				  struct snd_pcm_hw_params *params, struct snd_soc_dai *cpu_dai)
 {
 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
-	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
 	struct hdac_ext_stream *hext_stream;
 	struct hdac_stream *hstream;
@@ -216,18 +215,18 @@  static int hda_link_dma_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
-static int hda_link_dma_prepare(struct snd_pcm_substream *substream)
+static int hda_link_dma_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai)
 {
 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
 	int stream = substream->stream;
 
-	return hda_link_dma_hw_params(substream, &rtd->dpcm[stream].hw_params);
+	return hda_link_dma_hw_params(substream, &rtd->dpcm[stream].hw_params, cpu_dai);
 }
 
-static int hda_link_dma_trigger(struct snd_pcm_substream *substream, int cmd)
+static int hda_link_dma_trigger(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai,
+				int cmd)
 {
 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
-	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
 	struct hdac_ext_stream *hext_stream = snd_soc_dai_get_dma_data(cpu_dai, substream);
 	int ret;
@@ -258,10 +257,9 @@  static int hda_link_dma_trigger(struct snd_pcm_substream *substream, int cmd)
 	return 0;
 }
 
-static int hda_link_dma_hw_free(struct snd_pcm_substream *substream)
+static int hda_link_dma_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai)
 {
 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
-	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
 	struct hdac_ext_stream *hext_stream;
 
@@ -317,7 +315,7 @@  static int hda_dai_hw_params(struct snd_pcm_substream *substream,
 	if (hext_stream && hext_stream->link_prepared)
 		return 0;
 
-	ret = hda_link_dma_hw_params(substream, params);
+	ret = hda_link_dma_hw_params(substream, params, dai);
 	if (ret < 0)
 		return ret;
 
@@ -357,7 +355,7 @@  static int hda_dai_prepare(struct snd_pcm_substream *substream, struct snd_soc_d
 
 	dev_dbg(sdev->dev, "prepare stream dir %d\n", substream->stream);
 
-	ret = hda_link_dma_prepare(substream);
+	ret = hda_link_dma_prepare(substream, dai);
 	if (ret < 0)
 		return ret;
 
@@ -384,7 +382,7 @@  static int ipc3_hda_dai_trigger(struct snd_pcm_substream *substream,
 	dev_dbg(dai->dev, "cmd=%d dai %s direction %d\n", cmd,
 		dai->name, substream->stream);
 
-	ret = hda_link_dma_trigger(substream, cmd);
+	ret = hda_link_dma_trigger(substream, dai, cmd);
 	if (ret < 0)
 		return ret;
 
@@ -512,7 +510,7 @@  static int hda_dai_hw_free(struct snd_pcm_substream *substream,
 {
 	int ret;
 
-	ret = hda_link_dma_hw_free(substream);
+	ret = hda_link_dma_hw_free(substream, dai);
 	if (ret < 0)
 		return ret;