diff mbox

[04/13] ASoC: dapm: add driver prefix matching for snd_soc_dapm_add_route()

Message ID 87wq2lr8s8.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kuninori Morimoto March 13, 2015, 1:22 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current DAPM will lost correct route settings if some CPU/Codec was using
same stream name, and it will be problem when DPCM case.
For example, stream name of Renesas sound drver / ak4642 / dummy for DPCM
have same name as "Playback", like below

FE CPU   (rsnd):   "DAI0 Playback"
   Codec (dummy):  "Playback"

BE CPU   (dummy):  "Playback"
   Codec (ak4642): "Playback"

Then, "Playback" - "DAI0 Playback" can't match correctly. This patch adds
"driver name" prefix for this case.
We can use "ak4642-hifi Playback" - "DAI0 Playback" here.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-dapm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Lars-Peter Clausen March 14, 2015, 12:19 p.m. UTC | #1
On 03/13/2015 02:22 AM, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> Current DAPM will lost correct route settings if some CPU/Codec was using
> same stream name, and it will be problem when DPCM case.
> For example, stream name of Renesas sound drver / ak4642 / dummy for DPCM
> have same name as "Playback", like below
>
> FE CPU   (rsnd):   "DAI0 Playback"
>     Codec (dummy):  "Playback"
>
> BE CPU   (dummy):  "Playback"
>     Codec (ak4642): "Playback"
>
> Then, "Playback" - "DAI0 Playback" can't match correctly. This patch adds
> "driver name" prefix for this case.
> We can use "ak4642-hifi Playback" - "DAI0 Playback" here.

Hi,

There is already a prefix mechanism to handle this. If you have widgets with 
the same name in different contexts you can use the snd_soc_codec_conf 
struct and set the name_prefix field to assign a unique prefix to each context.

- Lars
Kuninori Morimoto March 16, 2015, 2:44 a.m. UTC | #2
Hi Lars

> > Current DAPM will lost correct route settings if some CPU/Codec was using
> > same stream name, and it will be problem when DPCM case.
> > For example, stream name of Renesas sound drver / ak4642 / dummy for DPCM
> > have same name as "Playback", like below
> >
> > FE CPU   (rsnd):   "DAI0 Playback"
> >     Codec (dummy):  "Playback"
> >
> > BE CPU   (dummy):  "Playback"
> >     Codec (ak4642): "Playback"
> >
> > Then, "Playback" - "DAI0 Playback" can't match correctly. This patch adds
> > "driver name" prefix for this case.
> > We can use "ak4642-hifi Playback" - "DAI0 Playback" here.
> 
> Hi,
> 
> There is already a prefix mechanism to handle this. If you have
> widgets with the same name in different contexts you can use the
> snd_soc_codec_conf struct and set the name_prefix field to assign a
> unique prefix to each context.

Thank you.
I didn't know this, I could use it.
I will send v2 patch

Best regards
---
Kuninori Morimoto
diff mbox

Patch

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index d4b331d..722b922 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2417,10 +2417,12 @@  static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
 {
 	struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w;
 	struct snd_soc_dapm_widget *wtsource = NULL, *wtsink = NULL;
+	struct snd_soc_dai *w_dai;
 	const char *sink;
 	const char *source;
 	char prefixed_sink[80];
 	char prefixed_source[80];
+	char _w_name[80], *w_name;
 	const char *prefix;
 	int ret;
 
@@ -2442,6 +2444,17 @@  static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
 	 * current DAPM context
 	 */
 	list_for_each_entry(w, &dapm->card->widgets, list) {
+		w_dai = w->priv;
+		w_name = NULL;
+		if (w_dai) {
+			snprintf(_w_name, sizeof(_w_name), "%s %s",
+				 w_dai->name, w->name);
+
+			w_name = _w_name;
+		}
+
+		snd_soc_dapm_route_scan(w, dapm, w_name,  &wsource, &wtsource, source);
+		snd_soc_dapm_route_scan(w, dapm, w_name,  &wsink,   &wtsink,   sink);
 		snd_soc_dapm_route_scan(w, dapm, w->name, &wsource, &wtsource, source);
 		snd_soc_dapm_route_scan(w, dapm, w->name, &wsink,   &wtsink,   sink);
 	}