diff options
author | Axel Lin <axel.lin@gmail.com> | 2011-10-05 23:00:19 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-10-06 15:02:55 -0400 |
commit | 416a0ce5f2338799f02fb41f6c56a6e490e4e8f0 (patch) | |
tree | e1675fa2d79b17789322e162a3eb4c815d5d1ccf /sound/soc/codecs/wm8990.c | |
parent | a92f1394a184191d904872e0d3b8ef0c158e5021 (diff) |
ASoC: wm8990: Convert to snd_soc_cache_sync for sync reg_cache with the hardware
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8990.c')
-rw-r--r-- | sound/soc/codecs/wm8990.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index 100aeee5ba96..48e9dd9975a2 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c | |||
@@ -36,6 +36,17 @@ struct wm8990_priv { | |||
36 | unsigned int pcmclk; | 36 | unsigned int pcmclk; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | static int wm8990_volatile_register(struct snd_soc_codec *codec, | ||
40 | unsigned int reg) | ||
41 | { | ||
42 | switch (reg) { | ||
43 | case WM8990_RESET: | ||
44 | return 1; | ||
45 | default: | ||
46 | return 0; | ||
47 | } | ||
48 | } | ||
49 | |||
39 | /* | 50 | /* |
40 | * wm8990 register cache. Note that register 0 is not included in the | 51 | * wm8990 register cache. Note that register 0 is not included in the |
41 | * cache. | 52 | * cache. |
@@ -1156,6 +1167,7 @@ static int wm8990_mute(struct snd_soc_dai *dai, int mute) | |||
1156 | static int wm8990_set_bias_level(struct snd_soc_codec *codec, | 1167 | static int wm8990_set_bias_level(struct snd_soc_codec *codec, |
1157 | enum snd_soc_bias_level level) | 1168 | enum snd_soc_bias_level level) |
1158 | { | 1169 | { |
1170 | int ret; | ||
1159 | u16 val; | 1171 | u16 val; |
1160 | 1172 | ||
1161 | switch (level) { | 1173 | switch (level) { |
@@ -1171,6 +1183,12 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec, | |||
1171 | 1183 | ||
1172 | case SND_SOC_BIAS_STANDBY: | 1184 | case SND_SOC_BIAS_STANDBY: |
1173 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { | 1185 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
1186 | ret = snd_soc_cache_sync(codec); | ||
1187 | if (ret < 0) { | ||
1188 | dev_err(codec->dev, "Failed to sync cache: %d\n", ret); | ||
1189 | return ret; | ||
1190 | } | ||
1191 | |||
1174 | /* Enable all output discharge bits */ | 1192 | /* Enable all output discharge bits */ |
1175 | snd_soc_write(codec, WM8990_ANTIPOP1, WM8990_DIS_LLINE | | 1193 | snd_soc_write(codec, WM8990_ANTIPOP1, WM8990_DIS_LLINE | |
1176 | WM8990_DIS_RLINE | WM8990_DIS_OUT3 | | 1194 | WM8990_DIS_RLINE | WM8990_DIS_OUT3 | |
@@ -1319,19 +1337,6 @@ static int wm8990_suspend(struct snd_soc_codec *codec, pm_message_t state) | |||
1319 | 1337 | ||
1320 | static int wm8990_resume(struct snd_soc_codec *codec) | 1338 | static int wm8990_resume(struct snd_soc_codec *codec) |
1321 | { | 1339 | { |
1322 | int i; | ||
1323 | u8 data[2]; | ||
1324 | u16 *cache = codec->reg_cache; | ||
1325 | |||
1326 | /* Sync reg_cache with the hardware */ | ||
1327 | for (i = 0; i < ARRAY_SIZE(wm8990_reg); i++) { | ||
1328 | if (i + 1 == WM8990_RESET) | ||
1329 | continue; | ||
1330 | data[0] = ((i + 1) << 1) | ((cache[i] >> 8) & 0x0001); | ||
1331 | data[1] = cache[i] & 0x00ff; | ||
1332 | codec->hw_write(codec->control_data, data, 2); | ||
1333 | } | ||
1334 | |||
1335 | wm8990_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1340 | wm8990_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
1336 | return 0; | 1341 | return 0; |
1337 | } | 1342 | } |
@@ -1392,6 +1397,7 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8990 = { | |||
1392 | .reg_cache_size = ARRAY_SIZE(wm8990_reg), | 1397 | .reg_cache_size = ARRAY_SIZE(wm8990_reg), |
1393 | .reg_word_size = sizeof(u16), | 1398 | .reg_word_size = sizeof(u16), |
1394 | .reg_cache_default = wm8990_reg, | 1399 | .reg_cache_default = wm8990_reg, |
1400 | .volatile_register = wm8990_volatile_register, | ||
1395 | }; | 1401 | }; |
1396 | 1402 | ||
1397 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1403 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |