* ASoC: MAX9877: fix write operation for register
@ 2009-07-23 8:33 Joonyoung Shim
2009-07-23 10:09 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Joonyoung Shim @ 2009-07-23 8:33 UTC (permalink / raw)
To: alsa-devel; +Cc: kyungmin.park, broonie
The MAX9877 needs an address of start register when we write values to
registers through i2c_master_send(), but the code for this was missed in
max9877_write_regs().
If the value of control is 0 in the max9877_set_out_mode(), the value is
not increased to 1, but actually the value to write to the register
should be 1.
And the register bits for out_mode and osc_mode should be cleared before
writing.
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
---
sound/soc/codecs/max9877.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/max9877.c b/sound/soc/codecs/max9877.c
index a1f1119..9e7e964 100644
--- a/sound/soc/codecs/max9877.c
+++ b/sound/soc/codecs/max9877.c
@@ -25,7 +25,14 @@ static u8 max9877_regs[5] = { 0x40, 0x00, 0x00, 0x00, 0x49 };
static void max9877_write_regs(void)
{
- if (i2c_master_send(i2c, max9877_regs, 5) != 5)
+ unsigned int i;
+ u8 data[6];
+
+ data[0] = MAX9877_INPUT_MODE;
+ for (i = 0; i < ARRAY_SIZE(max9877_regs); i++)
+ data[i + 1] = max9877_regs[i];
+
+ if (i2c_master_send(i2c, data, 6) != 6)
dev_err(&i2c->dev, "i2c write failed\n");
}
@@ -135,12 +142,12 @@ static int max9877_set_out_mode(struct snd_kcontrol *kcontrol,
{
u8 value = ucontrol->value.integer.value[0];
- if (value)
- value += 1;
+ value += 1;
if ((max9877_regs[MAX9877_OUTPUT_MODE] & MAX9877_OUTMODE_MASK) == value)
return 0;
+ max9877_regs[MAX9877_OUTPUT_MODE] &= ~MAX9877_OUTMODE_MASK;
max9877_regs[MAX9877_OUTPUT_MODE] |= value;
max9877_write_regs();
return 1;
@@ -166,6 +173,7 @@ static int max9877_set_osc_mode(struct snd_kcontrol *kcontrol,
if ((max9877_regs[MAX9877_OUTPUT_MODE] & MAX9877_OSC_MASK) == value)
return 0;
+ max9877_regs[MAX9877_OUTPUT_MODE] &= ~MAX9877_OSC_MASK;
max9877_regs[MAX9877_OUTPUT_MODE] |= value;
max9877_write_regs();
return 1;
--
1.6.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: ASoC: MAX9877: fix write operation for register
2009-07-23 8:33 ASoC: MAX9877: fix write operation for register Joonyoung Shim
@ 2009-07-23 10:09 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2009-07-23 10:09 UTC (permalink / raw)
To: Joonyoung Shim; +Cc: alsa-devel, kyungmin.park
On Thu, Jul 23, 2009 at 05:33:17PM +0900, Joonyoung Shim wrote:
> The MAX9877 needs an address of start register when we write values to
> registers through i2c_master_send(), but the code for this was missed in
> max9877_write_regs().
> If the value of control is 0 in the max9877_set_out_mode(), the value is
> not increased to 1, but actually the value to write to the register
> should be 1.
> And the register bits for out_mode and osc_mode should be cleared before
> writing.
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-07-23 10:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-23 8:33 ASoC: MAX9877: fix write operation for register Joonyoung Shim
2009-07-23 10:09 ` Mark Brown
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.