aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorAshish Chavan <ashish.chavan@kpitcummins.com>2011-10-15 05:20:06 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-10-17 17:43:33 -0400
commit4ced2b96f3d8b5944611e4e93b59b69ad440e10e (patch)
tree3c29132407fea5563d48324c53c579c857778537 /sound/soc
parent0ee6e9e721fc85e093e20e7a9ca848cfa71f80a9 (diff)
ASoC: da7210: Add support for High pass and Voice filters for ADC and DAC
This patch add controls for setting cut-off for high pass and voice filters of ADC and DAC. There are also switches to enable/disable these filters. Also removed hard coded, fixed values of these parameters used by previous version of driver. Signed-off-by: Ashish Chavan <ashish.chavan@kpitcummins.com> Signed-off-by: David Dajun Chen <dchen@diasemi.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/da7210.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c
index 7dc1259010be..fa0d5125e70b 100644
--- a/sound/soc/codecs/da7210.c
+++ b/sound/soc/codecs/da7210.c
@@ -167,6 +167,28 @@ static const unsigned int hp_out_tlv[] = {
167static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0); 167static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0);
168static const DECLARE_TLV_DB_SCALE(adc_eq_master_gain_tlv, -1800, 600, 1); 168static const DECLARE_TLV_DB_SCALE(adc_eq_master_gain_tlv, -1800, 600, 1);
169 169
170/* ADC and DAC high pass filter f0 value */
171static const char const *da7210_hpf_cutoff_txt[] = {
172 "Fs/8192*pi", "Fs/4096*pi", "Fs/2048*pi", "Fs/1024*pi"
173};
174
175static const struct soc_enum da7210_dac_hpf_cutoff =
176 SOC_ENUM_SINGLE(DA7210_DAC_HPF, 0, 4, da7210_hpf_cutoff_txt);
177
178static const struct soc_enum da7210_adc_hpf_cutoff =
179 SOC_ENUM_SINGLE(DA7210_ADC_HPF, 0, 4, da7210_hpf_cutoff_txt);
180
181/* ADC and DAC voice (8kHz) high pass cutoff value */
182static const char const *da7210_vf_cutoff_txt[] = {
183 "2.5Hz", "25Hz", "50Hz", "100Hz", "150Hz", "200Hz", "300Hz", "400Hz"
184};
185
186static const struct soc_enum da7210_dac_vf_cutoff =
187 SOC_ENUM_SINGLE(DA7210_DAC_HPF, 4, 8, da7210_vf_cutoff_txt);
188
189static const struct soc_enum da7210_adc_vf_cutoff =
190 SOC_ENUM_SINGLE(DA7210_ADC_HPF, 4, 8, da7210_vf_cutoff_txt);
191
170static const struct snd_kcontrol_new da7210_snd_controls[] = { 192static const struct snd_kcontrol_new da7210_snd_controls[] = {
171 193
172 SOC_DOUBLE_R_TLV("HeadPhone Playback Volume", 194 SOC_DOUBLE_R_TLV("HeadPhone Playback Volume",
@@ -200,6 +222,16 @@ static const struct snd_kcontrol_new da7210_snd_controls[] = {
200 eq_gain_tlv), 222 eq_gain_tlv),
201 SOC_SINGLE_TLV("ADC EQ5 Volume", DA7210_ADC_EQ5, 0, 0xf, 1, 223 SOC_SINGLE_TLV("ADC EQ5 Volume", DA7210_ADC_EQ5, 0, 0xf, 1,
202 eq_gain_tlv), 224 eq_gain_tlv),
225
226 SOC_SINGLE("DAC HPF Switch", DA7210_DAC_HPF, 3, 1, 0),
227 SOC_ENUM("DAC HPF Cutoff", da7210_dac_hpf_cutoff),
228 SOC_SINGLE("DAC Voice Mode Switch", DA7210_DAC_HPF, 7, 1, 0),
229 SOC_ENUM("DAC Voice Cutoff", da7210_dac_vf_cutoff),
230
231 SOC_SINGLE("ADC HPF Switch", DA7210_ADC_HPF, 3, 1, 0),
232 SOC_ENUM("ADC HPF Cutoff", da7210_adc_hpf_cutoff),
233 SOC_SINGLE("ADC Voice Mode Switch", DA7210_ADC_HPF, 7, 1, 0),
234 SOC_ENUM("ADC Voice Cutoff", da7210_adc_vf_cutoff),
203}; 235};
204 236
205/* Codec private data */ 237/* Codec private data */
@@ -275,7 +307,6 @@ static int da7210_hw_params(struct snd_pcm_substream *substream,
275 struct snd_soc_pcm_runtime *rtd = substream->private_data; 307 struct snd_soc_pcm_runtime *rtd = substream->private_data;
276 struct snd_soc_codec *codec = rtd->codec; 308 struct snd_soc_codec *codec = rtd->codec;
277 u32 dai_cfg1; 309 u32 dai_cfg1;
278 u32 hpf_reg, hpf_mask, hpf_value;
279 u32 fs, bypass; 310 u32 fs, bypass;
280 311
281 /* set DAI source to Left and Right ADC */ 312 /* set DAI source to Left and Right ADC */
@@ -306,68 +337,45 @@ static int da7210_hw_params(struct snd_pcm_substream *substream,
306 337
307 snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1); 338 snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1);
308 339
309 hpf_reg = (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) ?
310 DA7210_DAC_HPF : DA7210_ADC_HPF;
311
312 switch (params_rate(params)) { 340 switch (params_rate(params)) {
313 case 8000: 341 case 8000:
314 fs = DA7210_PLL_FS_8000; 342 fs = DA7210_PLL_FS_8000;
315 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN;
316 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN;
317 bypass = DA7210_PLL_BYP; 343 bypass = DA7210_PLL_BYP;
318 break; 344 break;
319 case 11025: 345 case 11025:
320 fs = DA7210_PLL_FS_11025; 346 fs = DA7210_PLL_FS_11025;
321 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN;
322 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN;
323 bypass = 0; 347 bypass = 0;
324 break; 348 break;
325 case 12000: 349 case 12000:
326 fs = DA7210_PLL_FS_12000; 350 fs = DA7210_PLL_FS_12000;
327 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN;
328 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN;
329 bypass = DA7210_PLL_BYP; 351 bypass = DA7210_PLL_BYP;
330 break; 352 break;
331 case 16000: 353 case 16000:
332 fs = DA7210_PLL_FS_16000; 354 fs = DA7210_PLL_FS_16000;
333 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN;
334 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN;
335 bypass = DA7210_PLL_BYP; 355 bypass = DA7210_PLL_BYP;
336 break; 356 break;
337 case 22050: 357 case 22050:
338 fs = DA7210_PLL_FS_22050; 358 fs = DA7210_PLL_FS_22050;
339 hpf_mask = DA7210_VOICE_EN;
340 hpf_value = 0;
341 bypass = 0; 359 bypass = 0;
342 break; 360 break;
343 case 32000: 361 case 32000:
344 fs = DA7210_PLL_FS_32000; 362 fs = DA7210_PLL_FS_32000;
345 hpf_mask = DA7210_VOICE_EN;
346 hpf_value = 0;
347 bypass = DA7210_PLL_BYP; 363 bypass = DA7210_PLL_BYP;
348 break; 364 break;
349 case 44100: 365 case 44100:
350 fs = DA7210_PLL_FS_44100; 366 fs = DA7210_PLL_FS_44100;
351 hpf_mask = DA7210_VOICE_EN;
352 hpf_value = 0;
353 bypass = 0; 367 bypass = 0;
354 break; 368 break;
355 case 48000: 369 case 48000:
356 fs = DA7210_PLL_FS_48000; 370 fs = DA7210_PLL_FS_48000;
357 hpf_mask = DA7210_VOICE_EN;
358 hpf_value = 0;
359 bypass = DA7210_PLL_BYP; 371 bypass = DA7210_PLL_BYP;
360 break; 372 break;
361 case 88200: 373 case 88200:
362 fs = DA7210_PLL_FS_88200; 374 fs = DA7210_PLL_FS_88200;
363 hpf_mask = DA7210_VOICE_EN;
364 hpf_value = 0;
365 bypass = 0; 375 bypass = 0;
366 break; 376 break;
367 case 96000: 377 case 96000:
368 fs = DA7210_PLL_FS_96000; 378 fs = DA7210_PLL_FS_96000;
369 hpf_mask = DA7210_VOICE_EN;
370 hpf_value = 0;
371 bypass = DA7210_PLL_BYP; 379 bypass = DA7210_PLL_BYP;
372 break; 380 break;
373 default: 381 default:
@@ -377,7 +385,6 @@ static int da7210_hw_params(struct snd_pcm_substream *substream,
377 /* Disable active mode */ 385 /* Disable active mode */
378 snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); 386 snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, 0);
379 387
380 snd_soc_update_bits(codec, hpf_reg, hpf_mask, hpf_value);
381 snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_FS_MASK, fs); 388 snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_FS_MASK, fs);
382 snd_soc_update_bits(codec, DA7210_PLL_DIV3, DA7210_PLL_BYP, bypass); 389 snd_soc_update_bits(codec, DA7210_PLL_DIV3, DA7210_PLL_BYP, bypass);
383 390