diff options
Diffstat (limited to 'sound/soc/codecs/twl4030.c')
-rw-r--r-- | sound/soc/codecs/twl4030.c | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 1e3884d6b3fb..dfc51bb425da 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -46,13 +46,7 @@ | |||
46 | /* TWL4030 PMBR1 Register GPIO6 mux bits */ | 46 | /* TWL4030 PMBR1 Register GPIO6 mux bits */ |
47 | #define TWL4030_GPIO6_PWM0_MUTE(value) ((value & 0x03) << 2) | 47 | #define TWL4030_GPIO6_PWM0_MUTE(value) ((value & 0x03) << 2) |
48 | 48 | ||
49 | /* Shadow register used by the audio driver */ | 49 | #define TWL4030_CACHEREGNUM (TWL4030_REG_MISC_SET_2 + 1) |
50 | #define TWL4030_REG_SW_SHADOW 0x4A | ||
51 | #define TWL4030_CACHEREGNUM (TWL4030_REG_SW_SHADOW + 1) | ||
52 | |||
53 | /* TWL4030_REG_SW_SHADOW (0x4A) Fields */ | ||
54 | #define TWL4030_HFL_EN 0x01 | ||
55 | #define TWL4030_HFR_EN 0x02 | ||
56 | 50 | ||
57 | /* | 51 | /* |
58 | * twl4030 register cache & default register settings | 52 | * twl4030 register cache & default register settings |
@@ -132,7 +126,6 @@ static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = { | |||
132 | 0x00, /* REG_VIBRA_PWM_SET (0x47) */ | 126 | 0x00, /* REG_VIBRA_PWM_SET (0x47) */ |
133 | 0x00, /* REG_ANAMIC_GAIN (0x48) */ | 127 | 0x00, /* REG_ANAMIC_GAIN (0x48) */ |
134 | 0x00, /* REG_MISC_SET_2 (0x49) */ | 128 | 0x00, /* REG_MISC_SET_2 (0x49) */ |
135 | 0x00, /* REG_SW_SHADOW (0x4A) - Shadow, non HW register */ | ||
136 | }; | 129 | }; |
137 | 130 | ||
138 | /* codec private data */ | 131 | /* codec private data */ |
@@ -198,42 +191,41 @@ static int twl4030_write(struct snd_soc_codec *codec, | |||
198 | int write_to_reg = 0; | 191 | int write_to_reg = 0; |
199 | 192 | ||
200 | twl4030_write_reg_cache(codec, reg, value); | 193 | twl4030_write_reg_cache(codec, reg, value); |
201 | if (likely(reg < TWL4030_REG_SW_SHADOW)) { | 194 | /* Decide if the given register can be written */ |
202 | /* Decide if the given register can be written */ | 195 | switch (reg) { |
203 | switch (reg) { | 196 | case TWL4030_REG_EAR_CTL: |
204 | case TWL4030_REG_EAR_CTL: | 197 | if (twl4030->earpiece_enabled) |
205 | if (twl4030->earpiece_enabled) | ||
206 | write_to_reg = 1; | ||
207 | break; | ||
208 | case TWL4030_REG_PREDL_CTL: | ||
209 | if (twl4030->predrivel_enabled) | ||
210 | write_to_reg = 1; | ||
211 | break; | ||
212 | case TWL4030_REG_PREDR_CTL: | ||
213 | if (twl4030->predriver_enabled) | ||
214 | write_to_reg = 1; | ||
215 | break; | ||
216 | case TWL4030_REG_PRECKL_CTL: | ||
217 | if (twl4030->carkitl_enabled) | ||
218 | write_to_reg = 1; | ||
219 | break; | ||
220 | case TWL4030_REG_PRECKR_CTL: | ||
221 | if (twl4030->carkitr_enabled) | ||
222 | write_to_reg = 1; | ||
223 | break; | ||
224 | case TWL4030_REG_HS_GAIN_SET: | ||
225 | if (twl4030->hsl_enabled || twl4030->hsr_enabled) | ||
226 | write_to_reg = 1; | ||
227 | break; | ||
228 | default: | ||
229 | /* All other register can be written */ | ||
230 | write_to_reg = 1; | 198 | write_to_reg = 1; |
231 | break; | 199 | break; |
232 | } | 200 | case TWL4030_REG_PREDL_CTL: |
233 | if (write_to_reg) | 201 | if (twl4030->predrivel_enabled) |
234 | return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, | 202 | write_to_reg = 1; |
235 | value, reg); | 203 | break; |
204 | case TWL4030_REG_PREDR_CTL: | ||
205 | if (twl4030->predriver_enabled) | ||
206 | write_to_reg = 1; | ||
207 | break; | ||
208 | case TWL4030_REG_PRECKL_CTL: | ||
209 | if (twl4030->carkitl_enabled) | ||
210 | write_to_reg = 1; | ||
211 | break; | ||
212 | case TWL4030_REG_PRECKR_CTL: | ||
213 | if (twl4030->carkitr_enabled) | ||
214 | write_to_reg = 1; | ||
215 | break; | ||
216 | case TWL4030_REG_HS_GAIN_SET: | ||
217 | if (twl4030->hsl_enabled || twl4030->hsr_enabled) | ||
218 | write_to_reg = 1; | ||
219 | break; | ||
220 | default: | ||
221 | /* All other register can be written */ | ||
222 | write_to_reg = 1; | ||
223 | break; | ||
236 | } | 224 | } |
225 | if (write_to_reg) | ||
226 | return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, | ||
227 | value, reg); | ||
228 | |||
237 | return 0; | 229 | return 0; |
238 | } | 230 | } |
239 | 231 | ||
@@ -532,7 +524,7 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreel_enum); | |||
532 | 524 | ||
533 | /* Handsfree Left virtual mute */ | 525 | /* Handsfree Left virtual mute */ |
534 | static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control = | 526 | static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control = |
535 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 0, 1, 0); | 527 | SOC_DAPM_SINGLE_VIRT("Switch", 1); |
536 | 528 | ||
537 | /* Handsfree Right */ | 529 | /* Handsfree Right */ |
538 | static const char *twl4030_handsfreer_texts[] = | 530 | static const char *twl4030_handsfreer_texts[] = |
@@ -548,7 +540,7 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); | |||
548 | 540 | ||
549 | /* Handsfree Right virtual mute */ | 541 | /* Handsfree Right virtual mute */ |
550 | static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control = | 542 | static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control = |
551 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 1, 1, 0); | 543 | SOC_DAPM_SINGLE_VIRT("Switch", 1); |
552 | 544 | ||
553 | /* Vibra */ | 545 | /* Vibra */ |
554 | /* Vibra audio path selection */ | 546 | /* Vibra audio path selection */ |