* [PATCH 1/2] ASoC: wm9081: Fix setting soft VMID ramp enable with VMID 2*240k
@ 2011-10-17 4:34 Axel Lin
2011-10-17 4:36 ` [PATCH 2/2] ASoC: wm9081: Use snd_soc_update_bits for read-modify-write Axel Lin
2011-10-17 23:22 ` [PATCH 1/2] ASoC: wm9081: Fix setting soft VMID ramp enable with VMID 2*240k Mark Brown
0 siblings, 2 replies; 7+ messages in thread
From: Axel Lin @ 2011-10-17 4:34 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, Dimitris Papastamos, Liam Girdwood, alsa-devel
According to the datasheet:
BIT 2:1
VMID_SEL[1:0] VMID Divider Enable and Select
00 = VMID disabled
01 = 2x40k Omh divider
10 = 2x240k Omh divider
11 = 2x5k Omh divider
To set VMID 2*240k, we should OR reg with 0x04 instead of 0x40.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
sound/soc/codecs/wm9081.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c
index b2d3448..66092ef 100644
--- a/sound/soc/codecs/wm9081.c
+++ b/sound/soc/codecs/wm9081.c
@@ -819,7 +819,7 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec,
/* VMID 2*240k */
reg = snd_soc_read(codec, WM9081_BIAS_CONTROL_1);
reg &= ~WM9081_VMID_SEL_MASK;
- reg |= 0x40;
+ reg |= 0x04;
snd_soc_write(codec, WM9081_VMID_CONTROL, reg);
/* Standby bias current on */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/2] ASoC: wm9081: Use snd_soc_update_bits for read-modify-write 2011-10-17 4:34 [PATCH 1/2] ASoC: wm9081: Fix setting soft VMID ramp enable with VMID 2*240k Axel Lin @ 2011-10-17 4:36 ` Axel Lin 2011-10-17 23:25 ` Mark Brown 2011-10-17 23:22 ` [PATCH 1/2] ASoC: wm9081: Fix setting soft VMID ramp enable with VMID 2*240k Mark Brown 1 sibling, 1 reply; 7+ messages in thread From: Axel Lin @ 2011-10-17 4:36 UTC (permalink / raw) To: linux-kernel; +Cc: Mark Brown, Dimitris Papastamos, Liam Girdwood, alsa-devel Use snd_soc_update_bits for read-modify-write register access instead of open-coding it using snd_soc_read and snd_soc_write Signed-off-by: Axel Lin <axel.lin@gmail.com> --- sound/soc/codecs/wm9081.c | 81 +++++++++++++++++++-------------------------- 1 files changed, 34 insertions(+), 47 deletions(-) diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index 66092ef..f4fc03b 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c @@ -766,84 +766,72 @@ static const struct snd_soc_dapm_route wm9081_audio_paths[] = { static int wm9081_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { - u16 reg; - switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: /* VMID=2*40k */ - reg = snd_soc_read(codec, WM9081_VMID_CONTROL); - reg &= ~WM9081_VMID_SEL_MASK; - reg |= 0x2; - snd_soc_write(codec, WM9081_VMID_CONTROL, reg); + snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + WM9081_VMID_SEL_MASK, 0x2); /* Normal bias current */ - reg = snd_soc_read(codec, WM9081_BIAS_CONTROL_1); - reg &= ~WM9081_STBY_BIAS_ENA; - snd_soc_write(codec, WM9081_BIAS_CONTROL_1, reg); + snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + WM9081_STBY_BIAS_ENA, 0); break; case SND_SOC_BIAS_STANDBY: /* Initial cold start */ if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { /* Disable LINEOUT discharge */ - reg = snd_soc_read(codec, WM9081_ANTI_POP_CONTROL); - reg &= ~WM9081_LINEOUT_DISCH; - snd_soc_write(codec, WM9081_ANTI_POP_CONTROL, reg); + snd_soc_update_bits(codec, WM9081_ANTI_POP_CONTROL, + WM9081_LINEOUT_DISCH, 0); /* Select startup bias source */ - reg = snd_soc_read(codec, WM9081_BIAS_CONTROL_1); - reg |= WM9081_BIAS_SRC | WM9081_BIAS_ENA; - snd_soc_write(codec, WM9081_BIAS_CONTROL_1, reg); + snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + WM9081_BIAS_SRC | WM9081_BIAS_ENA, + WM9081_BIAS_SRC | WM9081_BIAS_ENA); /* VMID 2*4k; Soft VMID ramp enable */ - reg = snd_soc_read(codec, WM9081_VMID_CONTROL); - reg |= WM9081_VMID_RAMP | 0x6; - snd_soc_write(codec, WM9081_VMID_CONTROL, reg); - + snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + WM9081_VMID_RAMP | 0x6, + WM9081_VMID_RAMP | 0x6); mdelay(100); /* Normal bias enable & soft start off */ - reg |= WM9081_BIAS_ENA; - reg &= ~WM9081_VMID_RAMP; - snd_soc_write(codec, WM9081_VMID_CONTROL, reg); + snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + WM9081_VMID_RAMP | WM9081_BIAS_ENA, + WM9081_BIAS_ENA); /* Standard bias source */ - reg = snd_soc_read(codec, WM9081_BIAS_CONTROL_1); - reg &= ~WM9081_BIAS_SRC; - snd_soc_write(codec, WM9081_BIAS_CONTROL_1, reg); + snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + WM9081_BIAS_SRC, 0); } /* VMID 2*240k */ - reg = snd_soc_read(codec, WM9081_BIAS_CONTROL_1); - reg &= ~WM9081_VMID_SEL_MASK; - reg |= 0x04; - snd_soc_write(codec, WM9081_VMID_CONTROL, reg); + snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + WM9081_VMID_SEL_MASK, 0x04); /* Standby bias current on */ - reg = snd_soc_read(codec, WM9081_BIAS_CONTROL_1); - reg |= WM9081_STBY_BIAS_ENA; - snd_soc_write(codec, WM9081_BIAS_CONTROL_1, reg); + snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + WM9081_STBY_BIAS_ENA, + WM9081_STBY_BIAS_ENA); break; case SND_SOC_BIAS_OFF: /* Startup bias source */ - reg = snd_soc_read(codec, WM9081_BIAS_CONTROL_1); - reg |= WM9081_BIAS_SRC; - snd_soc_write(codec, WM9081_BIAS_CONTROL_1, reg); + snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + WM9081_BIAS_SRC, WM9081_BIAS_SRC); /* Disable VMID and biases with soft ramping */ - reg = snd_soc_read(codec, WM9081_VMID_CONTROL); - reg &= ~(WM9081_VMID_SEL_MASK | WM9081_BIAS_ENA); - reg |= WM9081_VMID_RAMP; - snd_soc_write(codec, WM9081_VMID_CONTROL, reg); + snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + WM9081_VMID_RAMP | WM9081_VMID_SEL_MASK | + WM9081_BIAS_ENA, WM9081_VMID_RAMP); /* Actively discharge LINEOUT */ - reg = snd_soc_read(codec, WM9081_ANTI_POP_CONTROL); - reg |= WM9081_LINEOUT_DISCH; - snd_soc_write(codec, WM9081_ANTI_POP_CONTROL, reg); + snd_soc_update_bits(codec, WM9081_ANTI_POP_CONTROL, + WM9081_LINEOUT_DISCH, + WM9081_LINEOUT_DISCH); break; } @@ -1242,11 +1230,10 @@ static int wm9081_probe(struct snd_soc_codec *codec) wm9081_set_bias_level(codec, SND_SOC_BIAS_STANDBY); /* Enable zero cross by default */ - reg = snd_soc_read(codec, WM9081_ANALOGUE_LINEOUT); - snd_soc_write(codec, WM9081_ANALOGUE_LINEOUT, reg | WM9081_LINEOUTZC); - reg = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_PGA); - snd_soc_write(codec, WM9081_ANALOGUE_SPEAKER_PGA, - reg | WM9081_SPKPGAZC); + snd_soc_update_bits(codec, WM9081_ANALOGUE_LINEOUT, + WM9081_LINEOUTZC, WM9081_LINEOUTZC); + snd_soc_update_bits(codec, WM9081_ANALOGUE_SPEAKER_PGA, + WM9081_SPKPGAZC, WM9081_SPKPGAZC); snd_soc_add_controls(codec, wm9081_snd_controls, ARRAY_SIZE(wm9081_snd_controls)); -- 1.7.4.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] ASoC: wm9081: Use snd_soc_update_bits for read-modify-write 2011-10-17 4:36 ` [PATCH 2/2] ASoC: wm9081: Use snd_soc_update_bits for read-modify-write Axel Lin @ 2011-10-17 23:25 ` Mark Brown 2011-10-18 1:43 ` Axel Lin 0 siblings, 1 reply; 7+ messages in thread From: Mark Brown @ 2011-10-17 23:25 UTC (permalink / raw) To: Axel Lin; +Cc: linux-kernel, Dimitris Papastamos, Liam Girdwood, alsa-devel On Mon, Oct 17, 2011 at 12:36:52PM +0800, Axel Lin wrote: > Use snd_soc_update_bits for read-modify-write register access instead of > open-coding it using snd_soc_read and snd_soc_write Something in here is breaking audio through the WM9081 on Speyside. I can't immediately spot anything wrong but the behaviour is quite obvious in the system. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] ASoC: wm9081: Use snd_soc_update_bits for read-modify-write 2011-10-17 23:25 ` Mark Brown @ 2011-10-18 1:43 ` Axel Lin 0 siblings, 0 replies; 7+ messages in thread From: Axel Lin @ 2011-10-18 1:43 UTC (permalink / raw) To: Mark Brown; +Cc: linux-kernel, Dimitris Papastamos, Liam Girdwood, alsa-devel 2011/10/18 Mark Brown <broonie@opensource.wolfsonmicro.com>: > On Mon, Oct 17, 2011 at 12:36:52PM +0800, Axel Lin wrote: >> Use snd_soc_update_bits for read-modify-write register access instead of >> open-coding it using snd_soc_read and snd_soc_write > > Something in here is breaking audio through the WM9081 on Speyside. I > can't immediately spot anything wrong but the behaviour is quite obvious > in the system. > hi Mark, Thanks for testing. I think the suspect part is here: /* VMID 2*4k; Soft VMID ramp enable */ - reg = snd_soc_read(codec, WM9081_VMID_CONTROL); - reg |= WM9081_VMID_RAMP | 0x6; - snd_soc_write(codec, WM9081_VMID_CONTROL, reg); - + snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + WM9081_VMID_RAMP | 0x6, + WM9081_VMID_RAMP | 0x6); mdelay(100); /* Normal bias enable & soft start off */ - reg |= WM9081_BIAS_ENA; - reg &= ~WM9081_VMID_RAMP; - snd_soc_write(codec, WM9081_VMID_CONTROL, reg); + snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + WM9081_VMID_RAMP | WM9081_BIAS_ENA, + WM9081_BIAS_ENA); Original code does not change VMID_SEL[1:0] bits in the second write for Normal bias enable & soft start off. Maybe I should not convert it to snd_soc_update_bits for this case. Regards, Axel ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] ASoC: wm9081: Fix setting soft VMID ramp enable with VMID 2*240k 2011-10-17 4:34 [PATCH 1/2] ASoC: wm9081: Fix setting soft VMID ramp enable with VMID 2*240k Axel Lin 2011-10-17 4:36 ` [PATCH 2/2] ASoC: wm9081: Use snd_soc_update_bits for read-modify-write Axel Lin @ 2011-10-17 23:22 ` Mark Brown 2011-10-20 1:50 ` Axel Lin 1 sibling, 1 reply; 7+ messages in thread From: Mark Brown @ 2011-10-17 23:22 UTC (permalink / raw) To: Axel Lin; +Cc: linux-kernel, Dimitris Papastamos, Liam Girdwood, alsa-devel On Mon, Oct 17, 2011 at 12:34:31PM +0800, Axel Lin wrote: > According to the datasheet: > BIT 2:1 Applied, thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] ASoC: wm9081: Fix setting soft VMID ramp enable with VMID 2*240k 2011-10-17 23:22 ` [PATCH 1/2] ASoC: wm9081: Fix setting soft VMID ramp enable with VMID 2*240k Mark Brown @ 2011-10-20 1:50 ` Axel Lin 2011-10-20 12:37 ` Mark Brown 0 siblings, 1 reply; 7+ messages in thread From: Axel Lin @ 2011-10-20 1:50 UTC (permalink / raw) To: Mark Brown; +Cc: linux-kernel, Dimitris Papastamos, Liam Girdwood, alsa-devel 2011/10/18 Mark Brown <broonie@opensource.wolfsonmicro.com>: > On Mon, Oct 17, 2011 at 12:34:31PM +0800, Axel Lin wrote: >> According to the datasheet: >> BIT 2:1 > > Applied, thanks. Hi Mark, Seems this patch is not yet applied. It is still not in asoc tree. Thanks, Axel ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] ASoC: wm9081: Fix setting soft VMID ramp enable with VMID 2*240k 2011-10-20 1:50 ` Axel Lin @ 2011-10-20 12:37 ` Mark Brown 0 siblings, 0 replies; 7+ messages in thread From: Mark Brown @ 2011-10-20 12:37 UTC (permalink / raw) To: Axel Lin; +Cc: linux-kernel, Dimitris Papastamos, Liam Girdwood, alsa-devel On Thu, Oct 20, 2011 at 09:50:46AM +0800, Axel Lin wrote: > Seems this patch is not yet applied. > It is still not in asoc tree. If you want to do stuff like this resend patches, I can't apply nag mails. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-10-20 12:37 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-10-17 4:34 [PATCH 1/2] ASoC: wm9081: Fix setting soft VMID ramp enable with VMID 2*240k Axel Lin 2011-10-17 4:36 ` [PATCH 2/2] ASoC: wm9081: Use snd_soc_update_bits for read-modify-write Axel Lin 2011-10-17 23:25 ` Mark Brown 2011-10-18 1:43 ` Axel Lin 2011-10-17 23:22 ` [PATCH 1/2] ASoC: wm9081: Fix setting soft VMID ramp enable with VMID 2*240k Mark Brown 2011-10-20 1:50 ` Axel Lin 2011-10-20 12:37 ` Mark Brown
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).