* [RFC][PATCH] ASoC: Fix sync reg_cache with the hardware in wm8990_resume
@ 2011-10-05 10:16 Axel Lin
2011-10-05 10:21 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Axel Lin @ 2011-10-05 10:16 UTC (permalink / raw)
To: linux-kernel; +Cc: Liam Girdwood, Mark Brown, alsa-devel
Current code has off-by-one bug of checking WM8990_RESET.
Besides, according to wm8990 datasheet (2-wire serial control mode):
A control word consists of 24 bits. The first 8 bits are address bits,
the remaining 16 bits are data bits.
Current code uses 7 bits address bits and 9 bits data bits which is incorrect.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
I'd appreciate if someone can test it.
I'm a little bit confused if this fix is correct, why there is no bug report so far.
If I'm wrong, please kindly let me know.
Thanks,
Axel
sound/soc/codecs/wm8990.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c
index 100aeee..5546f5a 100644
--- a/sound/soc/codecs/wm8990.c
+++ b/sound/soc/codecs/wm8990.c
@@ -1320,16 +1320,17 @@ static int wm8990_suspend(struct snd_soc_codec *codec, pm_message_t state)
static int wm8990_resume(struct snd_soc_codec *codec)
{
int i;
- u8 data[2];
+ u8 data[3];
u16 *cache = codec->reg_cache;
/* Sync reg_cache with the hardware */
for (i = 0; i < ARRAY_SIZE(wm8990_reg); i++) {
- if (i + 1 == WM8990_RESET)
+ if (i == WM8990_RESET)
continue;
- data[0] = ((i + 1) << 1) | ((cache[i] >> 8) & 0x0001);
- data[1] = cache[i] & 0x00ff;
- codec->hw_write(codec->control_data, data, 2);
+ data[0] = i;
+ data[1] = (cache[i] & 0xFF00) >> 8;
+ data[2] = cache[i] & 0x00FF;
+ codec->hw_write(codec->control_data, data, 3);
}
wm8990_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [RFC][PATCH] ASoC: Fix sync reg_cache with the hardware in wm8990_resume
2011-10-05 10:16 [RFC][PATCH] ASoC: Fix sync reg_cache with the hardware in wm8990_resume Axel Lin
@ 2011-10-05 10:21 ` Mark Brown
2011-10-05 10:39 ` Axel Lin
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2011-10-05 10:21 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, alsa-devel
On Wed, Oct 05, 2011 at 06:16:49PM +0800, Axel Lin wrote:
> Current code has off-by-one bug of checking WM8990_RESET.
> Besides, according to wm8990 datasheet (2-wire serial control mode):
> A control word consists of 24 bits. The first 8 bits are address bits,
> the remaining 16 bits are data bits.
> Current code uses 7 bits address bits and 9 bits data bits which is incorrect.
We should just convert drivers like this to snd_soc_cache_sync().
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC][PATCH] ASoC: Fix sync reg_cache with the hardware in wm8990_resume
2011-10-05 10:21 ` Mark Brown
@ 2011-10-05 10:39 ` Axel Lin
0 siblings, 0 replies; 3+ messages in thread
From: Axel Lin @ 2011-10-05 10:39 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, Liam Girdwood, alsa-devel
2011/10/5 Mark Brown <broonie@opensource.wolfsonmicro.com>:
> On Wed, Oct 05, 2011 at 06:16:49PM +0800, Axel Lin wrote:
>> Current code has off-by-one bug of checking WM8990_RESET.
>> Besides, according to wm8990 datasheet (2-wire serial control mode):
>> A control word consists of 24 bits. The first 8 bits are address bits,
>> the remaining 16 bits are data bits.
>> Current code uses 7 bits address bits and 9 bits data bits which is incorrect.
>
> We should just convert drivers like this to snd_soc_cache_sync().
Yes. It would be better convert it to snd_soc_cache_sync().
Just think this patch may be useful for 3.1 or earlier kernel version.
Axel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-05 10:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-05 10:16 [RFC][PATCH] ASoC: Fix sync reg_cache with the hardware in wm8990_resume Axel Lin
2011-10-05 10:21 ` Mark Brown
2011-10-05 10:39 ` Axel Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox