diff options
author | Joonyoung Shim <jy0922.shim@samsung.com> | 2009-07-23 04:33:17 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-07-23 06:08:30 -0400 |
commit | a7569afa8b79ca9272b0d7544335bc05b5b721d6 (patch) | |
tree | fdc41caf35e146da60c65714826932737d9db5e6 /sound/soc/codecs/max9877.c | |
parent | 459dc35233c88d9eb7c5d0e6c086122751e64750 (diff) |
ASoC: MAX9877: fix write operation for register
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>
Diffstat (limited to 'sound/soc/codecs/max9877.c')
-rw-r--r-- | 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 a1f1119e1b7a..9e7e964a5fa3 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 }; | |||
25 | 25 | ||
26 | static void max9877_write_regs(void) | 26 | static void max9877_write_regs(void) |
27 | { | 27 | { |
28 | if (i2c_master_send(i2c, max9877_regs, 5) != 5) | 28 | unsigned int i; |
29 | u8 data[6]; | ||
30 | |||
31 | data[0] = MAX9877_INPUT_MODE; | ||
32 | for (i = 0; i < ARRAY_SIZE(max9877_regs); i++) | ||
33 | data[i + 1] = max9877_regs[i]; | ||
34 | |||
35 | if (i2c_master_send(i2c, data, 6) != 6) | ||
29 | dev_err(&i2c->dev, "i2c write failed\n"); | 36 | dev_err(&i2c->dev, "i2c write failed\n"); |
30 | } | 37 | } |
31 | 38 | ||
@@ -135,12 +142,12 @@ static int max9877_set_out_mode(struct snd_kcontrol *kcontrol, | |||
135 | { | 142 | { |
136 | u8 value = ucontrol->value.integer.value[0]; | 143 | u8 value = ucontrol->value.integer.value[0]; |
137 | 144 | ||
138 | if (value) | 145 | value += 1; |
139 | value += 1; | ||
140 | 146 | ||
141 | if ((max9877_regs[MAX9877_OUTPUT_MODE] & MAX9877_OUTMODE_MASK) == value) | 147 | if ((max9877_regs[MAX9877_OUTPUT_MODE] & MAX9877_OUTMODE_MASK) == value) |
142 | return 0; | 148 | return 0; |
143 | 149 | ||
150 | max9877_regs[MAX9877_OUTPUT_MODE] &= ~MAX9877_OUTMODE_MASK; | ||
144 | max9877_regs[MAX9877_OUTPUT_MODE] |= value; | 151 | max9877_regs[MAX9877_OUTPUT_MODE] |= value; |
145 | max9877_write_regs(); | 152 | max9877_write_regs(); |
146 | return 1; | 153 | return 1; |
@@ -166,6 +173,7 @@ static int max9877_set_osc_mode(struct snd_kcontrol *kcontrol, | |||
166 | if ((max9877_regs[MAX9877_OUTPUT_MODE] & MAX9877_OSC_MASK) == value) | 173 | if ((max9877_regs[MAX9877_OUTPUT_MODE] & MAX9877_OSC_MASK) == value) |
167 | return 0; | 174 | return 0; |
168 | 175 | ||
176 | max9877_regs[MAX9877_OUTPUT_MODE] &= ~MAX9877_OSC_MASK; | ||
169 | max9877_regs[MAX9877_OUTPUT_MODE] |= value; | 177 | max9877_regs[MAX9877_OUTPUT_MODE] |= value; |
170 | max9877_write_regs(); | 178 | max9877_write_regs(); |
171 | return 1; | 179 | return 1; |