Skip to contentSkip to conversation

ASoC: Indentation fix for null loop operation

PATCH In review Mark Brown 2 participants 7 messages Jun 6, 2011

Subsystems (5)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/6 ASoC: Indentation fix for null loop operation

More with the legibility.

---
 sound/soc/soc-dapm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/soc-dapm.c +1 -1
index 6be6546..988cdff 100644
@@ -209,7 +209,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
 		int val, item, bitmask;
 
 		for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
-		;
+			;
 		val = snd_soc_read(w->codec, e->reg);
 		item = (val >> e->shift_l) & (bitmask - 1);
 
Signature · 1 line
1.7.5.3
author
#1 lore raw

PATCH 2/6 ASoC: Remove trace for DAPM bias level logging

It's redundant now thanks to the use of the generic trace infrastructure.

---
 sound/soc/soc-dapm.c |   18 ------------------
 1 files changed, 0 insertions(+), 18 deletions(-)
sound/soc/soc-dapm.c +0 -18
index 988cdff..4452b57 100644
@@ -139,24 +139,6 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm,
 	struct snd_soc_card *card = dapm->card;
 	int ret = 0;
 
-	switch (level) {
-	case SND_SOC_BIAS_ON:
-		dev_dbg(dapm->dev, "Setting full bias\n");
-		break;
-	case SND_SOC_BIAS_PREPARE:
-		dev_dbg(dapm->dev, "Setting bias prepare\n");
-		break;
-	case SND_SOC_BIAS_STANDBY:
-		dev_dbg(dapm->dev, "Setting standby bias\n");
-		break;
-	case SND_SOC_BIAS_OFF:
-		dev_dbg(dapm->dev, "Setting bias off\n");
-		break;
-	default:
-		dev_err(dapm->dev, "Setting invalid bias %d\n", level);
-		return -EINVAL;
-	}
-
 	trace_snd_soc_bias_level_start(card, level);
 
 	if (card && card->set_bias_level)
Signature · 1 line
1.7.5.3
author
#2 lore raw

PATCH 3/6 ASoC: Simplify logic in snd_soc_dapm_set_bias_level()

In reply to Mark Brown

No functional changes but much less indentation.

---
 sound/soc/soc-dapm.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)
sound/soc/soc-dapm.c +12 -10
index 4452b57..d989dd7 100644
@@ -143,17 +143,19 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm,
 
 	if (card && card->set_bias_level)
 		ret = card->set_bias_level(card, level);
-	if (ret == 0) {
-		if (dapm->codec && dapm->codec->driver->set_bias_level)
-			ret = dapm->codec->driver->set_bias_level(dapm->codec, level);
-		else
-			dapm->bias_level = level;
-	}
-	if (ret == 0) {
-		if (card && card->set_bias_level_post)
-			ret = card->set_bias_level_post(card, level);
-	}
+	if (ret != 0)
+		goto out;
+
+	if (dapm->codec && dapm->codec->driver->set_bias_level)
+		ret = dapm->codec->driver->set_bias_level(dapm->codec, level);
+	else
+		dapm->bias_level = level;
+	if (ret != 0)
+		goto out;
 
+	if (card && card->set_bias_level_post)
+		ret = card->set_bias_level_post(card, level);
+out:
 	trace_snd_soc_bias_level_done(card, level);
 
 	return ret;
Signature · 1 line
1.7.5.3
author
#3 lore raw

PATCH 4/6 ASoC: Add context parameter to card DAPM callbacks

In reply to Mark Brown

The card callback will get called for each DAPM context in the card so it can be useful for it to know which device is currently undergoing a transition.

---
 include/sound/soc.h              |    2 ++
 sound/soc/atmel/sam9g20_wm8731.c |    1 +
 sound/soc/omap/ams-delta.c       |    3 ++-
 sound/soc/samsung/speyside.c     |    4 ++++
 sound/soc/soc-dapm.c             |    4 ++--
 5 files changed, 11 insertions(+), 3 deletions(-)
include/sound/soc.h +2 -0
index 0f29700..f55efc1 100644
@@ -726,8 +726,10 @@ struct snd_soc_card {
 
 	/* callbacks */
 	int (*set_bias_level)(struct snd_soc_card *,
+			      struct snd_soc_dapm_context *dapm,
 			      enum snd_soc_bias_level level);
 	int (*set_bias_level_post)(struct snd_soc_card *,
+				   struct snd_soc_dapm_context *dapm,
 				   enum snd_soc_bias_level level);
 
 	long pmdown_time;
sound/soc/atmel/sam9g20_wm8731.c +1 -0
index 95572d2..bad3aa1 100644
@@ -92,6 +92,7 @@ static struct snd_soc_ops at91sam9g20ek_ops = {
 };
 
 static int at91sam9g20ek_set_bias_level(struct snd_soc_card *card,
+					struct snd_soc_dapm_context *dapm,
 					enum snd_soc_bias_level level)
 {
 	static int mclk_on;
sound/soc/omap/ams-delta.c +2 -1
index 462cbcb..b40095a 100644
@@ -427,7 +427,8 @@ static struct snd_soc_ops ams_delta_ops = {
 
 /* Board specific codec bias level control */
 static int ams_delta_set_bias_level(struct snd_soc_card *card,
-					enum snd_soc_bias_level level)
+				    struct snd_soc_dapm_context *dapm,
+				    enum snd_soc_bias_level level)
 {
 	struct snd_soc_codec *codec = card->rtd->codec;
 
sound/soc/samsung/speyside.c +4 -0
index 93078b1..99fb033 100644
@@ -20,11 +20,15 @@
 #define WM8915_HPSEL_GPIO 214
 
 static int speyside_set_bias_level(struct snd_soc_card *card,
+				   struct snd_soc_dapm_context *dapm,
 				   enum snd_soc_bias_level level)
 {
 	struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
 	int ret;
 
+	if (dapm->dev != codec_dai->dev)
+		return 0;
+
 	switch (level) {
 	case SND_SOC_BIAS_STANDBY:
 		ret = snd_soc_dai_set_sysclk(codec_dai, WM8915_SYSCLK_MCLK2,
sound/soc/soc-dapm.c +2 -2
index d989dd7..1682834 100644
@@ -142,7 +142,7 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm,
 	trace_snd_soc_bias_level_start(card, level);
 
 	if (card && card->set_bias_level)
-		ret = card->set_bias_level(card, level);
+		ret = card->set_bias_level(card, dapm, level);
 	if (ret != 0)
 		goto out;
 
@@ -154,7 +154,7 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm,
 		goto out;
 
 	if (card && card->set_bias_level_post)
-		ret = card->set_bias_level_post(card, level);
+		ret = card->set_bias_level_post(card, dapm, level);
 out:
 	trace_snd_soc_bias_level_done(card, level);
 
Signature · 1 line
1.7.5.3
author
#4 lore raw

PATCH 5/6 ASoC: Only provide a default bias level update for CODEC contexts

In reply to Mark Brown

This allows the card driver to use the bias level variable more easily in multi component systems.

---
 sound/soc/soc-dapm.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
sound/soc/soc-dapm.c +7 -4
index 1682834..34106bc 100644
@@ -146,10 +146,13 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm,
 	if (ret != 0)
 		goto out;
 
-	if (dapm->codec && dapm->codec->driver->set_bias_level)
-		ret = dapm->codec->driver->set_bias_level(dapm->codec, level);
-	else
-		dapm->bias_level = level;
+	if (dapm->codec) {
+		if (dapm->codec->driver->set_bias_level)
+			ret = dapm->codec->driver->set_bias_level(dapm->codec,
+								  level);
+		else
+			dapm->bias_level = level;
+	}
 	if (ret != 0)
 		goto out;
 
Signature · 1 line
1.7.5.3
author
#5 lore raw

PATCH 6/6 ASoC: Manage Speyside system clocking only in bias management

In reply to Mark Brown

Now that the CODEC driver supports it defer configuration of the system clock until bias management which is a much more idiomatic place to do system power control and makes things a lot more happy when we're using both interfaces.

---
 sound/soc/samsung/speyside.c |   50 +++++++++++++++++++++++++++++++++--------
 1 files changed, 40 insertions(+), 10 deletions(-)
sound/soc/samsung/speyside.c +40 -10
index 99fb033..2515dba 100644
@@ -42,11 +42,51 @@ static int speyside_set_bias_level(struct snd_soc_card *card,
 			pr_err("Failed to stop FLL\n");
 			return ret;
 		}
+		break;
+
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static int speyside_set_bias_level_post(struct snd_soc_card *card,
+					struct snd_soc_dapm_context *dapm,
+					enum snd_soc_bias_level level)
+{
+	struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+	int ret;
+
+	if (dapm->dev != codec_dai->dev)
+		return 0;
+
+	switch (level) {
+	case SND_SOC_BIAS_PREPARE:
+		if (card->dapm.bias_level == SND_SOC_BIAS_STANDBY) {
+			ret = snd_soc_dai_set_pll(codec_dai, 0,
+						  WM8915_FLL_MCLK2,
+						  32768, 48000 * 256);
+			if (ret < 0) {
+				pr_err("Failed to start FLL\n");
+				return ret;
+			}
+
+			ret = snd_soc_dai_set_sysclk(codec_dai,
+						     WM8915_SYSCLK_FLL,
+						     48000 * 256,
+						     SND_SOC_CLOCK_IN);
+			if (ret < 0)
+				return ret;
+		}
+		break;
 
 	default:
 		break;
 	}
 
+	card->dapm.bias_level = level;
+
 	return 0;
 }
 
@@ -70,16 +110,6 @@ static int speyside_hw_params(struct snd_pcm_substream *substream,
 	if (ret < 0)
 		return ret;
 
-	ret = snd_soc_dai_set_pll(codec_dai, 0, WM8915_FLL_MCLK2,
-				  32768, 256 * 48000);
-	if (ret < 0)
-		return ret;
-
-	ret = snd_soc_dai_set_sysclk(codec_dai, WM8915_SYSCLK_FLL,
-				     256 * 48000, SND_SOC_CLOCK_IN);
-	if (ret < 0)
-		return ret;
-
 	return 0;
 }
 
Signature · 1 line
1.7.5.3
Acked-by on v1 1/6
#6 lore raw
In reply to Mark Brown
Quoted 12 lines · Mark Brown

More with the legibility.

---
 sound/soc/soc-dapm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/soc-dapm.c +0 -0
index 6be6546..988cdff 100644

sound/soc/soc-dapm.c static void dapm_set_path_status(struct snd_soc_dapm_widget *w, · line 215

Quoted 8 lines
sound/soc/soc-dapm.c +1 -1
@@ -209,7 +209,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
 		int val, item, bitmask;
 
 		for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
-		;
+			;
 		val = snd_soc_read(w->codec, e->reg);
 		item = (val >> e->shift_l) & (bitmask - 1);
 

All