diff mbox

[3/3] ASoC: Add Multi CPU DAI support in DAPM

Message ID 1520334030-8018-4-git-send-email-shreyas.nc@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shreyas NC March 6, 2018, 11 a.m. UTC
Extend the multi CPU support in DAPM functions to check for
valid widgets and connected widgets.

Signed-off-by: Shreyas NC <shreyas.nc@intel.com>
---
 sound/soc/soc-dapm.c | 71 ++++++++++++++++++++++++++++++++++------------------
 1 file changed, 46 insertions(+), 25 deletions(-)

Comments

Charles Keepax March 9, 2018, 4:31 p.m. UTC | #1
On Tue, Mar 06, 2018 at 04:30:30PM +0530, Shreyas NC wrote:
> Extend the multi CPU support in DAPM functions to check for
> valid widgets and connected widgets.
> 
> Signed-off-by: Shreyas NC <shreyas.nc@intel.com>
> ---
>  sound/soc/soc-dapm.c | 71 ++++++++++++++++++++++++++++++++++------------------
>  1 file changed, 46 insertions(+), 25 deletions(-)
> 
> diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> index 2f34590..6c7b0f4 100644
> --- a/sound/soc/soc-dapm.c
> +++ b/sound/soc/soc-dapm.c
> @@ -4066,38 +4066,57 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
>  	return 0;
>  }
>  
> -static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
> -					  struct snd_soc_pcm_runtime *rtd)
> +static void dapm_check_dai_valid_widget(struct snd_soc_card *card,
> +					struct snd_soc_pcm_runtime *rtd,
> +					struct snd_soc_dai *codec_dai,
> +					struct snd_soc_dai *cpu_dai)

Not sure about the name here dapm_check_dai_valid_widget doesn't
sound like it should be adding paths, otherwise I think this one
looks ok.

Thanks,
Charles
Shreyas NC March 12, 2018, 5:37 a.m. UTC | #2
On Fri, Mar 09, 2018 at 10:01:24PM +0530, Charles Keepax wrote:
> On Tue, Mar 06, 2018 at 04:30:30PM +0530, Shreyas NC wrote:
> > Extend the multi CPU support in DAPM functions to check for
> > valid widgets and connected widgets.
> > 
> > Signed-off-by: Shreyas NC <shreyas.nc@intel.com>
> > ---
> >  sound/soc/soc-dapm.c | 71 ++++++++++++++++++++++++++++++++++------------------
> >  1 file changed, 46 insertions(+), 25 deletions(-)
> > 
> > diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> > index 2f34590..6c7b0f4 100644
> > --- a/sound/soc/soc-dapm.c
> > +++ b/sound/soc/soc-dapm.c
> > @@ -4066,38 +4066,57 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
> >  	return 0;
> >  }
> >  
> > -static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
> > -					  struct snd_soc_pcm_runtime *rtd)
> > +static void dapm_check_dai_valid_widget(struct snd_soc_card *card,
> > +					struct snd_soc_pcm_runtime *rtd,
> > +					struct snd_soc_dai *codec_dai,
> > +					struct snd_soc_dai *cpu_dai)
> 
> Not sure about the name here dapm_check_dai_valid_widget doesn't
> sound like it should be adding paths, otherwise I think this one
> looks ok.
> 

Ok, does dapm_add_valid_widget() sound better?

--Shreyas
Charles Keepax March 12, 2018, 9:21 a.m. UTC | #3
On Mon, Mar 12, 2018 at 11:07:52AM +0530, Shreyas NC wrote:
> On Fri, Mar 09, 2018 at 10:01:24PM +0530, Charles Keepax wrote:
> > On Tue, Mar 06, 2018 at 04:30:30PM +0530, Shreyas NC wrote:
> > > -static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
> > > -					  struct snd_soc_pcm_runtime *rtd)
> > > +static void dapm_check_dai_valid_widget(struct snd_soc_card *card,
> > > +					struct snd_soc_pcm_runtime *rtd,
> > > +					struct snd_soc_dai *codec_dai,
> > > +					struct snd_soc_dai *cpu_dai)
> > 
> > Not sure about the name here dapm_check_dai_valid_widget doesn't
> > sound like it should be adding paths, otherwise I think this one
> > looks ok.
> > 
> 
> Ok, does dapm_add_valid_widget() sound better?

Yeah that seems like a better name to me.

Thanks,
Charles
diff mbox

Patch

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 2f34590..6c7b0f4 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -4066,38 +4066,57 @@  int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
 	return 0;
 }
 
-static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
-					  struct snd_soc_pcm_runtime *rtd)
+static void dapm_check_dai_valid_widget(struct snd_soc_card *card,
+					struct snd_soc_pcm_runtime *rtd,
+					struct snd_soc_dai *codec_dai,
+					struct snd_soc_dai *cpu_dai)
 {
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dapm_widget *sink, *source;
-	int i;
 
-	for (i = 0; i < rtd->num_codecs; i++) {
-		struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
+	/* connect BE DAI playback if widgets are valid */
+	if (codec_dai->playback_widget && cpu_dai->playback_widget) {
+		source = cpu_dai->playback_widget;
+		sink = codec_dai->playback_widget;
+		dev_err(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
+				cpu_dai->component->name,
+				source->name,
+				codec_dai->component->name,
+				sink->name);
+
+		snd_soc_dapm_add_path(&card->dapm, source, sink,
+				NULL, NULL);
+	}
 
-		/* connect BE DAI playback if widgets are valid */
-		if (codec_dai->playback_widget && cpu_dai->playback_widget) {
-			source = cpu_dai->playback_widget;
-			sink = codec_dai->playback_widget;
-			dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
-				cpu_dai->component->name, source->name,
-				codec_dai->component->name, sink->name);
+	/* connect BE DAI capture if widgets are valid */
+	if (codec_dai->capture_widget && cpu_dai->capture_widget) {
+		source = codec_dai->capture_widget;
+		sink = cpu_dai->capture_widget;
+		dev_err(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
+				codec_dai->component->name,
+				source->name,
+				cpu_dai->component->name,
+				sink->name);
 
-			snd_soc_dapm_add_path(&card->dapm, source, sink,
+		snd_soc_dapm_add_path(&card->dapm, source, sink,
 				NULL, NULL);
-		}
+	}
+
+}
 
-		/* connect BE DAI capture if widgets are valid */
-		if (codec_dai->capture_widget && cpu_dai->capture_widget) {
-			source = codec_dai->capture_widget;
-			sink = cpu_dai->capture_widget;
-			dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
-				codec_dai->component->name, source->name,
-				cpu_dai->component->name, sink->name);
+static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
+					  struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_dai *cpu_dai;
+	int i, j;
 
-			snd_soc_dapm_add_path(&card->dapm, source, sink,
-				NULL, NULL);
+	for (i = 0; i < rtd->num_codecs; i++) {
+		struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
+
+		for (j = 0; j < rtd->num_cpu_dai; j++) {
+			cpu_dai = rtd->cpu_dais[j];
+
+			dapm_check_dai_valid_widget(card, rtd,
+						codec_dai, cpu_dai);
 		}
 	}
 }
@@ -4164,7 +4183,9 @@  static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
 {
 	int i;
 
-	soc_dapm_dai_stream_event(rtd->cpu_dai, stream, event);
+	for (i = 0; i < rtd->num_cpu_dai; i++)
+		soc_dapm_dai_stream_event(rtd->cpu_dais[i], stream, event);
+
 	for (i = 0; i < rtd->num_codecs; i++)
 		soc_dapm_dai_stream_event(rtd->codec_dais[i], stream, event);