Skip to contentSkip to conversation

ASoC: Add power down of widget powered up for suspend

PATCH In review Joonyoung Shim 2 participants 3 messages Nov 23, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Add power down of widget powered up for suspend

If the widget was powered up when the device enters to the suspend, it remains on because the power of the widget doesn't change, but we need to power down the widget on suspend.

---
 sound/soc/soc-dapm.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
sound/soc/soc-dapm.c +4 -1
index d2af872..099d3b6 100644
@@ -978,8 +978,11 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
 				continue;
 
 			power = w->power_check(w);
-			if (power)
+			if (power) {
 				sys_power = 1;
+				if (event == SND_SOC_DAPM_STREAM_SUSPEND)
+					power = 0;
+			}
 
 			if (w->power == power)
 				continue;
Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 3 lines · Joonyoung Shim

If the widget was powered up when the device enters to the suspend, it remains on because the power of the widget doesn't change, but we need to power down the widget on suspend.

Hrm, yes - good spot, this got missed in the refactoring to make the bais maintinence less dependant on stream state. However...

Review

Quoted 7 lines
(quoted diff) +4 -1
 			power = w->power_check(w);
-			if (power)
+			if (power) {
 				sys_power = 1;
+				if (event == SND_SOC_DAPM_STREAM_SUSPEND)
+					power = 0;
+			}

We don't want to set sys_power here (since we want to bring the bias down to standby in preparatio for suspend) and we can skip the power check so something like the patch below ought to do the trick. Could you test and let me know, please?

That said, we probably want some more flexibility here for systems which want to suspend with bypass paths active. They'll want to pause streams being directly driven by the CPU but leave any other paths active. That would be a new feature, though.

sound/soc/soc-dapm.c +17 -3
index eaadb4b..0d294ef 100644
@@ -977,9 +977,19 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
 			if (!w->power_check)
 				continue;
 
-			power = w->power_check(w);
-			if (power)
-				sys_power = 1;
+			/* If we're suspending then pull down all the 
+			 * power. */
+			switch (event) {
+			case SND_SOC_DAPM_STREAM_SUSPEND:
+				power = 0;
+				break;
+
+			default:
+				power = w->power_check(w);
+				if (power)
+					sys_power = 1;
+				break;
+			}
 
 			if (w->power == power)
 				continue;
@@ -1003,8 +1013,12 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
 		case SND_SOC_DAPM_STREAM_RESUME:
 			sys_power = 1;
 			break;
+		case SND_SOC_DAPM_STREAM_SUSPEND:
+			sys_power = 0;
+			break;
 		case SND_SOC_DAPM_STREAM_NOP:
 			sys_power = codec->bias_level != SND_SOC_BIAS_STANDBY;
+			break;
 		default:
 			break;
 		}
#2 lore raw
Quoted 8 lines · Mark Brown
Quoted 3 lines · Joonyoung Shim

If the widget was powered up when the device enters to the suspend, it remains on because the power of the widget doesn't change, but we need to power down the widget on suspend.

Hrm, yes - good spot, this got missed in the refactoring to make the bais maintinence less dependant on stream state. However...

Quoted 13 lines

Review

Quoted 7 lines
(quoted diff) +4 -1
 			power = w->power_check(w);
-			if (power)
+			if (power) {
 				sys_power = 1;
+				if (event == SND_SOC_DAPM_STREAM_SUSPEND)
+					power = 0;
+			}

We don't want to set sys_power here (since we want to bring the bias down to standby in preparatio for suspend) and we can skip the power check so something like the patch below ought to do the trick. Could you test and let me know, please?

OK, i missed about sys_power. I tested and below patch solves this issue too. I think your patch is better.

Thanks.

Quoted 5 lines

That said, we probably want some more flexibility here for systems which want to suspend with bypass paths active. They'll want to pause streams being directly driven by the CPU but leave any other paths active. That would be a new feature, though.

Then, is it possible that the bypass path is alive on suspend?

Quoted 41 lines
sound/soc/soc-dapm.c +17 -3
index eaadb4b..0d294ef 100644
@@ -977,9 +977,19 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
 			if (!w->power_check)
 				continue;
 
-			power = w->power_check(w);
-			if (power)
-				sys_power = 1;
+			/* If we're suspending then pull down all the 
+			 * power. */
+			switch (event) {
+			case SND_SOC_DAPM_STREAM_SUSPEND:
+				power = 0;
+				break;
+
+			default:
+				power = w->power_check(w);
+				if (power)
+					sys_power = 1;
+				break;
+			}
 
 			if (w->power == power)
 				continue;
@@ -1003,8 +1013,12 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
 		case SND_SOC_DAPM_STREAM_RESUME:
 			sys_power = 1;
 			break;
+		case SND_SOC_DAPM_STREAM_SUSPEND:
+			sys_power = 0;
+			break;
 		case SND_SOC_DAPM_STREAM_NOP:
 			sys_power = codec->bias_level != SND_SOC_BIAS_STANDBY;
+			break;
 		default:
 			break;
 		}