Skip to content

Commit

Permalink
ASoC: MAX9877: fix write operation for register
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Joonyoung Shim authored and Mark Brown committed Jul 23, 2009
1 parent 459dc35 commit a7569af
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions sound/soc/codecs/max9877.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit a7569af

Please sign in to comment.