Skip to contentSkip to conversation

ASoC: dapm: Mark widgets as dirty when a route is added

PATCH In review Mark Brown 2 participants 4 messages Jul 5, 2012 – Jul 6, 2012

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/3 ASoC: dapm: Mark widgets as dirty when a route is added

If we add a new route at runtime then we'll need to recheck the connections to the affected widgets.

---
 sound/soc/soc-dapm.c |    4 ++++
 1 file changed, 4 insertions(+)
sound/soc/soc-dapm.c +4 -0
index ed1860c..beac5e6 100644
@@ -2250,6 +2250,10 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
 		path->connect = 0;
 		return 0;
 	}
+
+	dapm_mark_dirty(wsource, "Route added");
+	dapm_mark_dirty(wsink, "Route added");
+
 	return 0;
 
 err:
Signature · 1 line
1.7.10
author
#1 lore raw

PATCH 2/3 ASoC: dapm: Allow routes to be deleted at runtime

Since we're now relying on DAPM for things like enabling clocks when we reparent the clocks for widgets we need to either use conditional routes (which are expensive) or remove routes at runtime. Add a route removal API to support this use case.

Currently only unconditional routes are supported.

---
 include/sound/soc-dapm.h |    2 ++
 sound/soc/soc-dapm.c     |   77 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)
include/sound/soc-dapm.h +2 -0
index 05559e5..abe373d 100644
@@ -374,6 +374,8 @@ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm);
 void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm);
 int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
 			    const struct snd_soc_dapm_route *route, int num);
+int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm,
+			    const struct snd_soc_dapm_route *route, int num);
 int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm,
 			     const struct snd_soc_dapm_route *route, int num);
 
sound/soc/soc-dapm.c +77 -0

89 lines not on this page · raw message

Signature · 1 line
1.7.10
author
#2 lore raw

PATCH 3/3 ASoC: arizona: Change DAPM routes for AIF clocks when we change them

In reply to Mark Brown
---
 sound/soc/codecs/arizona.c |   32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
sound/soc/codecs/arizona.c +29 -3
index d0bcca9..901b53e 100644
@@ -588,12 +588,25 @@ static int arizona_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static const char *arizona_dai_clk_str(int clk_id)
+{
+	switch (clk_id) {
+	case ARIZONA_CLK_SYSCLK:
+		return "SYSCLK";
+	case ARIZONA_CLK_ASYNCCLK:
+		return "ASYNCCLK";
+	default:
+		return "Unknown clock";
+	}
+}
+
 static int arizona_dai_set_sysclk(struct snd_soc_dai *dai,
 				  int clk_id, unsigned int freq, int dir)
 {
 	struct snd_soc_codec *codec = dai->codec;
 	struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
 	struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1];
+	struct snd_soc_dapm_route routes[2];
 
 	switch (clk_id) {
 	case ARIZONA_CLK_SYSCLK:
@@ -603,15 +616,28 @@ static int arizona_dai_set_sysclk(struct snd_soc_dai *dai,
 		return -EINVAL;
 	}
 
-	if (clk_id != dai_priv->clk && dai->active) {
+	if (clk_id == dai_priv->clk)
+		return 0;
+
+	if (dai->active) {
 		dev_err(codec->dev, "Can't change clock on active DAI %d\n",
 			dai->id);
 		return -EBUSY;
 	}
 
-	dai_priv->clk = clk_id;
+	memset(&routes, 0, sizeof(routes));
+	routes[0].sink = dai->driver->capture.stream_name;
+	routes[1].sink = dai->driver->playback.stream_name;
 
-	return 0;
+	routes[0].source = arizona_dai_clk_str(dai_priv->clk);
+	routes[1].source = arizona_dai_clk_str(dai_priv->clk);
+	snd_soc_dapm_del_routes(&codec->dapm, routes, ARRAY_SIZE(routes));
+
+	routes[0].source = arizona_dai_clk_str(clk_id);
+	routes[1].source = arizona_dai_clk_str(clk_id);
+	snd_soc_dapm_add_routes(&codec->dapm, routes, ARRAY_SIZE(routes));
+
+	return snd_soc_dapm_sync(&codec->dapm);
 }
 
 const struct snd_soc_dai_ops arizona_dai_ops = {
Signature · 1 line
1.7.10
Acked-by on v1 1/3
#3 lore raw
In reply to Mark Brown
Quoted 13 lines · Mark Brown

If we add a new route at runtime then we'll need to recheck the connections to the affected widgets.

---
 sound/soc/soc-dapm.c |    4 ++++
 1 file changed, 4 insertions(+)
sound/soc/soc-dapm.c +0 -0
index ed1860c..beac5e6 100644

sound/soc/soc-dapm.c static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, · line 2259

Quoted 10 lines
sound/soc/soc-dapm.c +4 -0
@@ -2250,6 +2250,10 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
 		path->connect = 0;
 		return 0;
 	}
+
+	dapm_mark_dirty(wsource, "Route added");
+	dapm_mark_dirty(wsink, "Route added");
+
 	return 0;
 
 err:

All