All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: codec: wm8960: complete discharge on BIAS OFF->STANDBY
@ 2022-02-08 12:17 Viorel Suman (OSS)
  2022-02-14 14:55 ` Mark Brown
  2022-02-15 10:55   ` Charles Keepax
  0 siblings, 2 replies; 4+ messages in thread
From: Viorel Suman (OSS) @ 2022-02-08 12:17 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Shengjiu Wang, Charles Keepax, Daniel Baluta, Viorel Suman,
	patches, alsa-devel, linux-kernel

From: Viorel Suman <viorel.suman@nxp.com>

On BIAS STANDBY->OFF transition the current implementation sleeps
600ms on suspend in order to discharge the chip. The suspend is
propagated from "snd_soc_suspend" call for all audio cards in a
serial fashion, thus in case of boards like i.MX8DXL EVK which has
3 distinct WM8960 codecs the total cumulated sleep on suspend is 1.8
seconds.

On the other hand the BIAS OFF->STANDBY transition happens
asynchronously with regard to "snd_soc_resume" - the call is
propagated from "soc_resume_deferred" which is just scheduled
from "snd_soc_resume", each card having its own work scheduled to
execute "soc_resume_deferred" call.

The patch performs discharge completion on BIAS OFF->STANDBY transition
so that the cumulated effect on suspend described above is avoided
and discharge is completed in paralel in case of multiple WM8960
codecs on the board.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
---
 sound/soc/codecs/wm8960.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index 75de6a81465df..b7a2246184e08 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -45,6 +45,8 @@
 #define WM8960_DISOP     0x40
 #define WM8960_DRES_MASK 0x30
 
+#define WM8960_DSCH_TOUT	600 /* discharge timeout, ms */
+
 static bool is_pll_freq_available(unsigned int source, unsigned int target);
 static int wm8960_set_pll(struct snd_soc_component *component,
 		unsigned int freq_in, unsigned int freq_out);
@@ -133,6 +135,7 @@ struct wm8960_priv {
 	int freq_in;
 	bool is_stream_in_use[2];
 	struct wm8960_data pdata;
+	ktime_t dsch_start;
 };
 
 #define wm8960_reset(c)	regmap_write(c, WM8960_RESET, 0)
@@ -898,6 +901,7 @@ static int wm8960_set_bias_level_out3(struct snd_soc_component *component,
 	struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
 	u16 pm2 = snd_soc_component_read(component, WM8960_POWER2);
 	int ret;
+	ktime_t tout;
 
 	switch (level) {
 	case SND_SOC_BIAS_ON:
@@ -944,6 +948,11 @@ static int wm8960_set_bias_level_out3(struct snd_soc_component *component,
 
 	case SND_SOC_BIAS_STANDBY:
 		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
+			/* ensure discharge is complete */
+			tout = WM8960_DSCH_TOUT - ktime_ms_delta(ktime_get(), wm8960->dsch_start);
+			if (tout > 0)
+				msleep(tout);
+
 			regcache_sync(wm8960->regmap);
 
 			/* Enable anti-pop features */
@@ -973,9 +982,9 @@ static int wm8960_set_bias_level_out3(struct snd_soc_component *component,
 			     WM8960_POBCTRL | WM8960_SOFT_ST |
 			     WM8960_BUFDCOPEN | WM8960_BUFIOEN);
 
-		/* Disable VMID and VREF, let them discharge */
+		/* Disable VMID and VREF, mark discharge */
 		snd_soc_component_write(component, WM8960_POWER1, 0);
-		msleep(600);
+		wm8960->dsch_start = ktime_get();
 		break;
 	}
 
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: codec: wm8960: complete discharge on BIAS OFF->STANDBY
  2022-02-08 12:17 [PATCH] ASoC: codec: wm8960: complete discharge on BIAS OFF->STANDBY Viorel Suman (OSS)
@ 2022-02-14 14:55 ` Mark Brown
  2022-02-15 10:55   ` Charles Keepax
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2022-02-14 14:55 UTC (permalink / raw)
  To: Liam Girdwood, linux-kernel, Jaroslav Kysela, Daniel Baluta,
	Shengjiu Wang, Charles Keepax, alsa-devel, Takashi Iwai,
	Viorel Suman, patches, Viorel Suman (OSS)

On Tue, 8 Feb 2022 14:17:27 +0200, Viorel Suman (OSS) wrote:
> From: Viorel Suman <viorel.suman@nxp.com>
> 
> On BIAS STANDBY->OFF transition the current implementation sleeps
> 600ms on suspend in order to discharge the chip. The suspend is
> propagated from "snd_soc_suspend" call for all audio cards in a
> serial fashion, thus in case of boards like i.MX8DXL EVK which has
> 3 distinct WM8960 codecs the total cumulated sleep on suspend is 1.8
> seconds.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: codec: wm8960: complete discharge on BIAS OFF->STANDBY
      commit: 3c7a4c24bd0ac2dfeb4f3f9053a2207cad90c7dd

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: codec: wm8960: complete discharge on BIAS OFF->STANDBY
  2022-02-08 12:17 [PATCH] ASoC: codec: wm8960: complete discharge on BIAS OFF->STANDBY Viorel Suman (OSS)
@ 2022-02-15 10:55   ` Charles Keepax
  2022-02-15 10:55   ` Charles Keepax
  1 sibling, 0 replies; 4+ messages in thread
From: Charles Keepax @ 2022-02-15 10:55 UTC (permalink / raw)
  To: Viorel Suman (OSS)
  Cc: Shengjiu Wang, alsa-devel, patches, Takashi Iwai, Liam Girdwood,
	Mark Brown, Viorel Suman, Daniel Baluta, linux-kernel

On Tue, Feb 08, 2022 at 02:17:27PM +0200, Viorel Suman (OSS) wrote:
> From: Viorel Suman <viorel.suman@nxp.com>
> 
> On BIAS STANDBY->OFF transition the current implementation sleeps
> 600ms on suspend in order to discharge the chip. The suspend is
> propagated from "snd_soc_suspend" call for all audio cards in a
> serial fashion, thus in case of boards like i.MX8DXL EVK which has
> 3 distinct WM8960 codecs the total cumulated sleep on suspend is 1.8
> seconds.
> 
> On the other hand the BIAS OFF->STANDBY transition happens
> asynchronously with regard to "snd_soc_resume" - the call is
> propagated from "soc_resume_deferred" which is just scheduled
> from "snd_soc_resume", each card having its own work scheduled to
> execute "soc_resume_deferred" call.
> 
> The patch performs discharge completion on BIAS OFF->STANDBY transition
> so that the cumulated effect on suspend described above is avoided
> and discharge is completed in paralel in case of multiple WM8960
> codecs on the board.
> 
> Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
> ---

Apologies Mark not sure how I missed this one, a bit late now,
but the change looks good to me.

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: codec: wm8960: complete discharge on BIAS OFF->STANDBY
@ 2022-02-15 10:55   ` Charles Keepax
  0 siblings, 0 replies; 4+ messages in thread
From: Charles Keepax @ 2022-02-15 10:55 UTC (permalink / raw)
  To: Viorel Suman (OSS)
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Shengjiu Wang, Daniel Baluta, Viorel Suman, patches, alsa-devel,
	linux-kernel

On Tue, Feb 08, 2022 at 02:17:27PM +0200, Viorel Suman (OSS) wrote:
> From: Viorel Suman <viorel.suman@nxp.com>
> 
> On BIAS STANDBY->OFF transition the current implementation sleeps
> 600ms on suspend in order to discharge the chip. The suspend is
> propagated from "snd_soc_suspend" call for all audio cards in a
> serial fashion, thus in case of boards like i.MX8DXL EVK which has
> 3 distinct WM8960 codecs the total cumulated sleep on suspend is 1.8
> seconds.
> 
> On the other hand the BIAS OFF->STANDBY transition happens
> asynchronously with regard to "snd_soc_resume" - the call is
> propagated from "soc_resume_deferred" which is just scheduled
> from "snd_soc_resume", each card having its own work scheduled to
> execute "soc_resume_deferred" call.
> 
> The patch performs discharge completion on BIAS OFF->STANDBY transition
> so that the cumulated effect on suspend described above is avoided
> and discharge is completed in paralel in case of multiple WM8960
> codecs on the board.
> 
> Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
> ---

Apologies Mark not sure how I missed this one, a bit late now,
but the change looks good to me.

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-15 10:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08 12:17 [PATCH] ASoC: codec: wm8960: complete discharge on BIAS OFF->STANDBY Viorel Suman (OSS)
2022-02-14 14:55 ` Mark Brown
2022-02-15 10:55 ` Charles Keepax
2022-02-15 10:55   ` Charles Keepax

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.