aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8753.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/wm8753.c')
-rw-r--r--sound/soc/codecs/wm8753.c183
1 files changed, 90 insertions, 93 deletions
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index fb41826c4c4c..8604809f0c36 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -55,25 +55,6 @@
55#define AUDIO_NAME "wm8753" 55#define AUDIO_NAME "wm8753"
56#define WM8753_VERSION "0.16" 56#define WM8753_VERSION "0.16"
57 57
58/*
59 * Debug
60 */
61
62#define WM8753_DEBUG 0
63
64#ifdef WM8753_DEBUG
65#define dbg(format, arg...) \
66 printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg)
67#else
68#define dbg(format, arg...) do {} while (0)
69#endif
70#define err(format, arg...) \
71 printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)
72#define info(format, arg...) \
73 printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
74#define warn(format, arg...) \
75 printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)
76
77static int caps_charge = 2000; 58static int caps_charge = 2000;
78module_param(caps_charge, int, 0); 59module_param(caps_charge, int, 0);
79MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)"); 60MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)");
@@ -260,28 +241,50 @@ static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
260 return 1; 241 return 1;
261} 242}
262 243
263static const DECLARE_TLV_DB_LINEAR(rec_mix_tlv, -1500, 600); 244static const DECLARE_TLV_DB_SCALE(rec_mix_tlv, -1500, 300, 0);
245static const DECLARE_TLV_DB_SCALE(mic_preamp_tlv, 1200, 600, 0);
246static const DECLARE_TLV_DB_SCALE(adc_tlv, -9750, 50, 1);
247static const DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 1);
248static const unsigned int out_tlv[] = {
249 TLV_DB_RANGE_HEAD(2),
250 /* 0000000 - 0101111 = "Analogue mute" */
251 0, 48, TLV_DB_SCALE_ITEM(-25500, 0, 0),
252 48, 127, TLV_DB_SCALE_ITEM(-7300, 100, 0),
253};
254static const DECLARE_TLV_DB_SCALE(mix_tlv, -1500, 300, 0);
255static const DECLARE_TLV_DB_SCALE(voice_mix_tlv, -1200, 300, 0);
256static const DECLARE_TLV_DB_SCALE(pga_tlv, -1725, 75, 0);
264 257
265static const struct snd_kcontrol_new wm8753_snd_controls[] = { 258static const struct snd_kcontrol_new wm8753_snd_controls[] = {
266SOC_DOUBLE_R("PCM Volume", WM8753_LDAC, WM8753_RDAC, 0, 255, 0), 259SOC_DOUBLE_R_TLV("PCM Volume", WM8753_LDAC, WM8753_RDAC, 0, 255, 0, dac_tlv),
267 260
268SOC_DOUBLE_R("ADC Capture Volume", WM8753_LADC, WM8753_RADC, 0, 255, 0), 261SOC_DOUBLE_R_TLV("ADC Capture Volume", WM8753_LADC, WM8753_RADC, 0, 255, 0,
269 262 adc_tlv),
270SOC_DOUBLE_R("Headphone Playback Volume", WM8753_LOUT1V, WM8753_ROUT1V, 0, 127, 0), 263
271SOC_DOUBLE_R("Speaker Playback Volume", WM8753_LOUT2V, WM8753_ROUT2V, 0, 127, 0), 264SOC_DOUBLE_R_TLV("Headphone Playback Volume", WM8753_LOUT1V, WM8753_ROUT1V,
272 265 0, 127, 0, out_tlv),
273SOC_SINGLE("Mono Playback Volume", WM8753_MOUTV, 0, 127, 0), 266SOC_DOUBLE_R_TLV("Speaker Playback Volume", WM8753_LOUT2V, WM8753_ROUT2V, 0,
274 267 127, 0, out_tlv),
275SOC_DOUBLE_R("Bypass Playback Volume", WM8753_LOUTM1, WM8753_ROUTM1, 4, 7, 1), 268
276SOC_DOUBLE_R("Sidetone Playback Volume", WM8753_LOUTM2, WM8753_ROUTM2, 4, 7, 1), 269SOC_SINGLE_TLV("Mono Playback Volume", WM8753_MOUTV, 0, 127, 0, out_tlv),
277SOC_DOUBLE_R("Voice Playback Volume", WM8753_LOUTM2, WM8753_ROUTM2, 0, 7, 1), 270
278 271SOC_DOUBLE_R_TLV("Bypass Playback Volume", WM8753_LOUTM1, WM8753_ROUTM1, 4, 7,
279SOC_DOUBLE_R("Headphone Playback ZC Switch", WM8753_LOUT1V, WM8753_ROUT1V, 7, 1, 0), 272 1, mix_tlv),
280SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8753_LOUT2V, WM8753_ROUT2V, 7, 1, 0), 273SOC_DOUBLE_R_TLV("Sidetone Playback Volume", WM8753_LOUTM2, WM8753_ROUTM2, 4,
281 274 7, 1, mix_tlv),
282SOC_SINGLE("Mono Bypass Playback Volume", WM8753_MOUTM1, 4, 7, 1), 275SOC_DOUBLE_R_TLV("Voice Playback Volume", WM8753_LOUTM2, WM8753_ROUTM2, 0, 7,
283SOC_SINGLE("Mono Sidetone Playback Volume", WM8753_MOUTM2, 4, 7, 1), 276 1, voice_mix_tlv),
284SOC_SINGLE("Mono Voice Playback Volume", WM8753_MOUTM2, 0, 7, 1), 277
278SOC_DOUBLE_R("Headphone Playback ZC Switch", WM8753_LOUT1V, WM8753_ROUT1V, 7,
279 1, 0),
280SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8753_LOUT2V, WM8753_ROUT2V, 7,
281 1, 0),
282
283SOC_SINGLE_TLV("Mono Bypass Playback Volume", WM8753_MOUTM1, 4, 7, 1, mix_tlv),
284SOC_SINGLE_TLV("Mono Sidetone Playback Volume", WM8753_MOUTM2, 4, 7, 1,
285 mix_tlv),
286SOC_SINGLE_TLV("Mono Voice Playback Volume", WM8753_MOUTM2, 0, 7, 1,
287 voice_mix_tlv),
285SOC_SINGLE("Mono Playback ZC Switch", WM8753_MOUTV, 7, 1, 0), 288SOC_SINGLE("Mono Playback ZC Switch", WM8753_MOUTV, 7, 1, 0),
286 289
287SOC_ENUM("Bass Boost", wm8753_enum[0]), 290SOC_ENUM("Bass Boost", wm8753_enum[0]),
@@ -291,10 +294,13 @@ SOC_SINGLE("Bass Volume", WM8753_BASS, 0, 15, 1),
291SOC_SINGLE("Treble Volume", WM8753_TREBLE, 0, 15, 1), 294SOC_SINGLE("Treble Volume", WM8753_TREBLE, 0, 15, 1),
292SOC_ENUM("Treble Cut-off", wm8753_enum[2]), 295SOC_ENUM("Treble Cut-off", wm8753_enum[2]),
293 296
294SOC_DOUBLE_TLV("Sidetone Capture Volume", WM8753_RECMIX1, 0, 4, 7, 1, rec_mix_tlv), 297SOC_DOUBLE_TLV("Sidetone Capture Volume", WM8753_RECMIX1, 0, 4, 7, 1,
295SOC_SINGLE_TLV("Voice Sidetone Capture Volume", WM8753_RECMIX2, 0, 7, 1, rec_mix_tlv), 298 rec_mix_tlv),
299SOC_SINGLE_TLV("Voice Sidetone Capture Volume", WM8753_RECMIX2, 0, 7, 1,
300 rec_mix_tlv),
296 301
297SOC_DOUBLE_R("Capture Volume", WM8753_LINVOL, WM8753_RINVOL, 0, 63, 0), 302SOC_DOUBLE_R_TLV("Capture Volume", WM8753_LINVOL, WM8753_RINVOL, 0, 63, 0,
303 pga_tlv),
298SOC_DOUBLE_R("Capture ZC Switch", WM8753_LINVOL, WM8753_RINVOL, 6, 1, 0), 304SOC_DOUBLE_R("Capture ZC Switch", WM8753_LINVOL, WM8753_RINVOL, 6, 1, 0),
299SOC_DOUBLE_R("Capture Switch", WM8753_LINVOL, WM8753_RINVOL, 7, 1, 1), 305SOC_DOUBLE_R("Capture Switch", WM8753_LINVOL, WM8753_RINVOL, 7, 1, 1),
300 306
@@ -326,8 +332,8 @@ SOC_ENUM("De-emphasis", wm8753_enum[8]),
326SOC_ENUM("Playback Mono Mix", wm8753_enum[9]), 332SOC_ENUM("Playback Mono Mix", wm8753_enum[9]),
327SOC_ENUM("Playback Phase", wm8753_enum[10]), 333SOC_ENUM("Playback Phase", wm8753_enum[10]),
328 334
329SOC_SINGLE("Mic2 Capture Volume", WM8753_INCTL1, 7, 3, 0), 335SOC_SINGLE_TLV("Mic2 Capture Volume", WM8753_INCTL1, 7, 3, 0, mic_preamp_tlv),
330SOC_SINGLE("Mic1 Capture Volume", WM8753_INCTL1, 5, 3, 0), 336SOC_SINGLE_TLV("Mic1 Capture Volume", WM8753_INCTL1, 5, 3, 0, mic_preamp_tlv),
331 337
332SOC_ENUM_EXT("DAI Mode", wm8753_enum[26], wm8753_get_dai, wm8753_set_dai), 338SOC_ENUM_EXT("DAI Mode", wm8753_enum[26], wm8753_get_dai, wm8753_set_dai),
333 339
@@ -523,7 +529,7 @@ SND_SOC_DAPM_INPUT("MIC2"),
523SND_SOC_DAPM_VMID("VREF"), 529SND_SOC_DAPM_VMID("VREF"),
524}; 530};
525 531
526static const char *audio_map[][3] = { 532static const struct snd_soc_dapm_route audio_map[] = {
527 /* left mixer */ 533 /* left mixer */
528 {"Left Mixer", "Left Playback Switch", "Left DAC"}, 534 {"Left Mixer", "Left Playback Switch", "Left DAC"},
529 {"Left Mixer", "Voice Playback Switch", "Voice DAC"}, 535 {"Left Mixer", "Voice Playback Switch", "Voice DAC"},
@@ -674,23 +680,14 @@ static const char *audio_map[][3] = {
674 680
675 /* ACOP */ 681 /* ACOP */
676 {"ACOP", NULL, "ALC Mixer"}, 682 {"ACOP", NULL, "ALC Mixer"},
677
678 /* terminator */
679 {NULL, NULL, NULL},
680}; 683};
681 684
682static int wm8753_add_widgets(struct snd_soc_codec *codec) 685static int wm8753_add_widgets(struct snd_soc_codec *codec)
683{ 686{
684 int i; 687 snd_soc_dapm_new_controls(codec, wm8753_dapm_widgets,
688 ARRAY_SIZE(wm8753_dapm_widgets));
685 689
686 for (i = 0; i < ARRAY_SIZE(wm8753_dapm_widgets); i++) 690 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
687 snd_soc_dapm_new_control(codec, &wm8753_dapm_widgets[i]);
688
689 /* set up the WM8753 audio map */
690 for (i = 0; audio_map[i][0] != NULL; i++) {
691 snd_soc_dapm_connect_input(codec, audio_map[i][0],
692 audio_map[i][1], audio_map[i][2]);
693 }
694 691
695 snd_soc_dapm_new_widgets(codec); 692 snd_soc_dapm_new_widgets(codec);
696 return 0; 693 return 0;
@@ -743,7 +740,7 @@ static void pll_factors(struct _pll_div *pll_div, unsigned int target,
743 pll_div->k = K; 740 pll_div->k = K;
744} 741}
745 742
746static int wm8753_set_dai_pll(struct snd_soc_codec_dai *codec_dai, 743static int wm8753_set_dai_pll(struct snd_soc_dai *codec_dai,
747 int pll_id, unsigned int freq_in, unsigned int freq_out) 744 int pll_id, unsigned int freq_in, unsigned int freq_out)
748{ 745{
749 u16 reg, enable; 746 u16 reg, enable;
@@ -866,7 +863,7 @@ static int get_coeff(int mclk, int rate)
866/* 863/*
867 * Clock after PLL and dividers 864 * Clock after PLL and dividers
868 */ 865 */
869static int wm8753_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai, 866static int wm8753_set_dai_sysclk(struct snd_soc_dai *codec_dai,
870 int clk_id, unsigned int freq, int dir) 867 int clk_id, unsigned int freq, int dir)
871{ 868{
872 struct snd_soc_codec *codec = codec_dai->codec; 869 struct snd_soc_codec *codec = codec_dai->codec;
@@ -893,7 +890,7 @@ static int wm8753_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai,
893/* 890/*
894 * Set's ADC and Voice DAC format. 891 * Set's ADC and Voice DAC format.
895 */ 892 */
896static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_codec_dai *codec_dai, 893static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_dai *codec_dai,
897 unsigned int fmt) 894 unsigned int fmt)
898{ 895{
899 struct snd_soc_codec *codec = codec_dai->codec; 896 struct snd_soc_codec *codec = codec_dai->codec;
@@ -963,7 +960,7 @@ static int wm8753_pcm_hw_params(struct snd_pcm_substream *substream,
963/* 960/*
964 * Set's PCM dai fmt and BCLK. 961 * Set's PCM dai fmt and BCLK.
965 */ 962 */
966static int wm8753_pcm_set_dai_fmt(struct snd_soc_codec_dai *codec_dai, 963static int wm8753_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai,
967 unsigned int fmt) 964 unsigned int fmt)
968{ 965{
969 struct snd_soc_codec *codec = codec_dai->codec; 966 struct snd_soc_codec *codec = codec_dai->codec;
@@ -1029,7 +1026,7 @@ static int wm8753_pcm_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1029 return 0; 1026 return 0;
1030} 1027}
1031 1028
1032static int wm8753_set_dai_clkdiv(struct snd_soc_codec_dai *codec_dai, 1029static int wm8753_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
1033 int div_id, int div) 1030 int div_id, int div)
1034{ 1031{
1035 struct snd_soc_codec *codec = codec_dai->codec; 1032 struct snd_soc_codec *codec = codec_dai->codec;
@@ -1057,7 +1054,7 @@ static int wm8753_set_dai_clkdiv(struct snd_soc_codec_dai *codec_dai,
1057/* 1054/*
1058 * Set's HiFi DAC format. 1055 * Set's HiFi DAC format.
1059 */ 1056 */
1060static int wm8753_hdac_set_dai_fmt(struct snd_soc_codec_dai *codec_dai, 1057static int wm8753_hdac_set_dai_fmt(struct snd_soc_dai *codec_dai,
1061 unsigned int fmt) 1058 unsigned int fmt)
1062{ 1059{
1063 struct snd_soc_codec *codec = codec_dai->codec; 1060 struct snd_soc_codec *codec = codec_dai->codec;
@@ -1090,7 +1087,7 @@ static int wm8753_hdac_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1090/* 1087/*
1091 * Set's I2S DAI format. 1088 * Set's I2S DAI format.
1092 */ 1089 */
1093static int wm8753_i2s_set_dai_fmt(struct snd_soc_codec_dai *codec_dai, 1090static int wm8753_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai,
1094 unsigned int fmt) 1091 unsigned int fmt)
1095{ 1092{
1096 struct snd_soc_codec *codec = codec_dai->codec; 1093 struct snd_soc_codec *codec = codec_dai->codec;
@@ -1198,7 +1195,7 @@ static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream,
1198 return 0; 1195 return 0;
1199} 1196}
1200 1197
1201static int wm8753_mode1v_set_dai_fmt(struct snd_soc_codec_dai *codec_dai, 1198static int wm8753_mode1v_set_dai_fmt(struct snd_soc_dai *codec_dai,
1202 unsigned int fmt) 1199 unsigned int fmt)
1203{ 1200{
1204 struct snd_soc_codec *codec = codec_dai->codec; 1201 struct snd_soc_codec *codec = codec_dai->codec;
@@ -1213,7 +1210,7 @@ static int wm8753_mode1v_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1213 return wm8753_pcm_set_dai_fmt(codec_dai, fmt); 1210 return wm8753_pcm_set_dai_fmt(codec_dai, fmt);
1214} 1211}
1215 1212
1216static int wm8753_mode1h_set_dai_fmt(struct snd_soc_codec_dai *codec_dai, 1213static int wm8753_mode1h_set_dai_fmt(struct snd_soc_dai *codec_dai,
1217 unsigned int fmt) 1214 unsigned int fmt)
1218{ 1215{
1219 if (wm8753_hdac_set_dai_fmt(codec_dai, fmt) < 0) 1216 if (wm8753_hdac_set_dai_fmt(codec_dai, fmt) < 0)
@@ -1221,7 +1218,7 @@ static int wm8753_mode1h_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1221 return wm8753_i2s_set_dai_fmt(codec_dai, fmt); 1218 return wm8753_i2s_set_dai_fmt(codec_dai, fmt);
1222} 1219}
1223 1220
1224static int wm8753_mode2_set_dai_fmt(struct snd_soc_codec_dai *codec_dai, 1221static int wm8753_mode2_set_dai_fmt(struct snd_soc_dai *codec_dai,
1225 unsigned int fmt) 1222 unsigned int fmt)
1226{ 1223{
1227 struct snd_soc_codec *codec = codec_dai->codec; 1224 struct snd_soc_codec *codec = codec_dai->codec;
@@ -1236,7 +1233,7 @@ static int wm8753_mode2_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1236 return wm8753_i2s_set_dai_fmt(codec_dai, fmt); 1233 return wm8753_i2s_set_dai_fmt(codec_dai, fmt);
1237} 1234}
1238 1235
1239static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_codec_dai *codec_dai, 1236static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_dai *codec_dai,
1240 unsigned int fmt) 1237 unsigned int fmt)
1241{ 1238{
1242 struct snd_soc_codec *codec = codec_dai->codec; 1239 struct snd_soc_codec *codec = codec_dai->codec;
@@ -1253,7 +1250,7 @@ static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1253 return wm8753_i2s_set_dai_fmt(codec_dai, fmt); 1250 return wm8753_i2s_set_dai_fmt(codec_dai, fmt);
1254} 1251}
1255 1252
1256static int wm8753_mute(struct snd_soc_codec_dai *dai, int mute) 1253static int wm8753_mute(struct snd_soc_dai *dai, int mute)
1257{ 1254{
1258 struct snd_soc_codec *codec = dai->codec; 1255 struct snd_soc_codec *codec = dai->codec;
1259 u16 mute_reg = wm8753_read_reg_cache(codec, WM8753_DAC) & 0xfff7; 1256 u16 mute_reg = wm8753_read_reg_cache(codec, WM8753_DAC) & 0xfff7;
@@ -1274,29 +1271,29 @@ static int wm8753_mute(struct snd_soc_codec_dai *dai, int mute)
1274 return 0; 1271 return 0;
1275} 1272}
1276 1273
1277static int wm8753_dapm_event(struct snd_soc_codec *codec, int event) 1274static int wm8753_set_bias_level(struct snd_soc_codec *codec,
1275 enum snd_soc_bias_level level)
1278{ 1276{
1279 u16 pwr_reg = wm8753_read_reg_cache(codec, WM8753_PWR1) & 0xfe3e; 1277 u16 pwr_reg = wm8753_read_reg_cache(codec, WM8753_PWR1) & 0xfe3e;
1280 1278
1281 switch (event) { 1279 switch (level) {
1282 case SNDRV_CTL_POWER_D0: /* full On */ 1280 case SND_SOC_BIAS_ON:
1283 /* set vmid to 50k and unmute dac */ 1281 /* set vmid to 50k and unmute dac */
1284 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x00c0); 1282 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x00c0);
1285 break; 1283 break;
1286 case SNDRV_CTL_POWER_D1: /* partial On */ 1284 case SND_SOC_BIAS_PREPARE:
1287 case SNDRV_CTL_POWER_D2: /* partial On */
1288 /* set vmid to 5k for quick power up */ 1285 /* set vmid to 5k for quick power up */
1289 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x01c1); 1286 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x01c1);
1290 break; 1287 break;
1291 case SNDRV_CTL_POWER_D3hot: /* Off, with power */ 1288 case SND_SOC_BIAS_STANDBY:
1292 /* mute dac and set vmid to 500k, enable VREF */ 1289 /* mute dac and set vmid to 500k, enable VREF */
1293 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x0141); 1290 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x0141);
1294 break; 1291 break;
1295 case SNDRV_CTL_POWER_D3cold: /* Off, without power */ 1292 case SND_SOC_BIAS_OFF:
1296 wm8753_write(codec, WM8753_PWR1, 0x0001); 1293 wm8753_write(codec, WM8753_PWR1, 0x0001);
1297 break; 1294 break;
1298 } 1295 }
1299 codec->dapm_state = event; 1296 codec->bias_level = level;
1300 return 0; 1297 return 0;
1301} 1298}
1302 1299
@@ -1319,7 +1316,7 @@ static int wm8753_dapm_event(struct snd_soc_codec *codec, int event)
1319 * 3. Voice disabled - HIFI over HIFI 1316 * 3. Voice disabled - HIFI over HIFI
1320 * 4. Voice disabled - HIFI over HIFI, uses voice DAI LRC for capture 1317 * 4. Voice disabled - HIFI over HIFI, uses voice DAI LRC for capture
1321 */ 1318 */
1322static const struct snd_soc_codec_dai wm8753_all_dai[] = { 1319static const struct snd_soc_dai wm8753_all_dai[] = {
1323/* DAI HiFi mode 1 */ 1320/* DAI HiFi mode 1 */
1324{ .name = "WM8753 HiFi", 1321{ .name = "WM8753 HiFi",
1325 .id = 1, 1322 .id = 1,
@@ -1459,7 +1456,7 @@ static const struct snd_soc_codec_dai wm8753_all_dai[] = {
1459}, 1456},
1460}; 1457};
1461 1458
1462struct snd_soc_codec_dai wm8753_dai[2]; 1459struct snd_soc_dai wm8753_dai[2];
1463EXPORT_SYMBOL_GPL(wm8753_dai); 1460EXPORT_SYMBOL_GPL(wm8753_dai);
1464 1461
1465static void wm8753_set_dai_mode(struct snd_soc_codec *codec, unsigned int mode) 1462static void wm8753_set_dai_mode(struct snd_soc_codec *codec, unsigned int mode)
@@ -1500,7 +1497,7 @@ static void wm8753_work(struct work_struct *work)
1500{ 1497{
1501 struct snd_soc_codec *codec = 1498 struct snd_soc_codec *codec =
1502 container_of(work, struct snd_soc_codec, delayed_work.work); 1499 container_of(work, struct snd_soc_codec, delayed_work.work);
1503 wm8753_dapm_event(codec, codec->dapm_state); 1500 wm8753_set_bias_level(codec, codec->bias_level);
1504} 1501}
1505 1502
1506static int wm8753_suspend(struct platform_device *pdev, pm_message_t state) 1503static int wm8753_suspend(struct platform_device *pdev, pm_message_t state)
@@ -1512,7 +1509,7 @@ static int wm8753_suspend(struct platform_device *pdev, pm_message_t state)
1512 if (!codec->card) 1509 if (!codec->card)
1513 return 0; 1510 return 0;
1514 1511
1515 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D3cold); 1512 wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF);
1516 return 0; 1513 return 0;
1517} 1514}
1518 1515
@@ -1537,12 +1534,12 @@ static int wm8753_resume(struct platform_device *pdev)
1537 codec->hw_write(codec->control_data, data, 2); 1534 codec->hw_write(codec->control_data, data, 2);
1538 } 1535 }
1539 1536
1540 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D3hot); 1537 wm8753_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1541 1538
1542 /* charge wm8753 caps */ 1539 /* charge wm8753 caps */
1543 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) { 1540 if (codec->suspend_bias_level == SND_SOC_BIAS_ON) {
1544 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D2); 1541 wm8753_set_bias_level(codec, SND_SOC_BIAS_PREPARE);
1545 codec->dapm_state = SNDRV_CTL_POWER_D0; 1542 codec->bias_level = SND_SOC_BIAS_ON;
1546 schedule_delayed_work(&codec->delayed_work, 1543 schedule_delayed_work(&codec->delayed_work,
1547 msecs_to_jiffies(caps_charge)); 1544 msecs_to_jiffies(caps_charge));
1548 } 1545 }
@@ -1563,10 +1560,10 @@ static int wm8753_init(struct snd_soc_device *socdev)
1563 codec->owner = THIS_MODULE; 1560 codec->owner = THIS_MODULE;
1564 codec->read = wm8753_read_reg_cache; 1561 codec->read = wm8753_read_reg_cache;
1565 codec->write = wm8753_write; 1562 codec->write = wm8753_write;
1566 codec->dapm_event = wm8753_dapm_event; 1563 codec->set_bias_level = wm8753_set_bias_level;
1567 codec->dai = wm8753_dai; 1564 codec->dai = wm8753_dai;
1568 codec->num_dai = 2; 1565 codec->num_dai = 2;
1569 codec->reg_cache_size = sizeof(wm8753_reg); 1566 codec->reg_cache_size = ARRAY_SIZE(wm8753_reg);
1570 codec->reg_cache = kmemdup(wm8753_reg, sizeof(wm8753_reg), GFP_KERNEL); 1567 codec->reg_cache = kmemdup(wm8753_reg, sizeof(wm8753_reg), GFP_KERNEL);
1571 1568
1572 if (codec->reg_cache == NULL) 1569 if (codec->reg_cache == NULL)
@@ -1584,8 +1581,8 @@ static int wm8753_init(struct snd_soc_device *socdev)
1584 } 1581 }
1585 1582
1586 /* charge output caps */ 1583 /* charge output caps */
1587 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D2); 1584 wm8753_set_bias_level(codec, SND_SOC_BIAS_PREPARE);
1588 codec->dapm_state = SNDRV_CTL_POWER_D3hot; 1585 codec->bias_level = SND_SOC_BIAS_STANDBY;
1589 schedule_delayed_work(&codec->delayed_work, 1586 schedule_delayed_work(&codec->delayed_work,
1590 msecs_to_jiffies(caps_charge)); 1587 msecs_to_jiffies(caps_charge));
1591 1588
@@ -1673,13 +1670,13 @@ static int wm8753_codec_probe(struct i2c_adapter *adap, int addr, int kind)
1673 1670
1674 ret = i2c_attach_client(i2c); 1671 ret = i2c_attach_client(i2c);
1675 if (ret < 0) { 1672 if (ret < 0) {
1676 err("failed to attach codec at addr %x\n", addr); 1673 pr_err("failed to attach codec at addr %x\n", addr);
1677 goto err; 1674 goto err;
1678 } 1675 }
1679 1676
1680 ret = wm8753_init(socdev); 1677 ret = wm8753_init(socdev);
1681 if (ret < 0) { 1678 if (ret < 0) {
1682 err("failed to initialise WM8753\n"); 1679 pr_err("failed to initialise WM8753\n");
1683 goto err; 1680 goto err;
1684 } 1681 }
1685 1682
@@ -1731,7 +1728,7 @@ static int wm8753_probe(struct platform_device *pdev)
1731 struct wm8753_priv *wm8753; 1728 struct wm8753_priv *wm8753;
1732 int ret = 0; 1729 int ret = 0;
1733 1730
1734 info("WM8753 Audio Codec %s", WM8753_VERSION); 1731 pr_info("WM8753 Audio Codec %s", WM8753_VERSION);
1735 1732
1736 setup = socdev->codec_data; 1733 setup = socdev->codec_data;
1737 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); 1734 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
@@ -1792,7 +1789,7 @@ static int wm8753_remove(struct platform_device *pdev)
1792 struct snd_soc_codec *codec = socdev->codec; 1789 struct snd_soc_codec *codec = socdev->codec;
1793 1790
1794 if (codec->control_data) 1791 if (codec->control_data)
1795 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D3cold); 1792 wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF);
1796 run_delayed_work(&codec->delayed_work); 1793 run_delayed_work(&codec->delayed_work);
1797 snd_soc_free_pcms(socdev); 1794 snd_soc_free_pcms(socdev);
1798 snd_soc_dapm_free(socdev); 1795 snd_soc_dapm_free(socdev);