aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorKuninori Morimoto <morimoto.kuninori@renesas.com>2010-02-28 20:10:43 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-03-09 10:21:16 -0500
commit3a9d620278981f367a77a8888c0d59a70473b056 (patch)
tree91f51b54774ccf4599fdbb889d3b32f91703974c /sound/soc
parent692247196dd845eef02f26bf2959719b82e935c6 (diff)
ASoC: da7210: Add 8/12/16/24/32/48/96 kHz rate support
Signed-off-by: Phil Edworthy <Phil.Edworthy@renesas.com> Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/da7210.c67
1 files changed, 48 insertions, 19 deletions
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c
index cf2975a7294a..3bd867de597b 100644
--- a/sound/soc/codecs/da7210.c
+++ b/sound/soc/codecs/da7210.c
@@ -74,15 +74,14 @@
74/* INMIX_R bit fields */ 74/* INMIX_R bit fields */
75#define DA7210_IN_R_EN (1 << 7) 75#define DA7210_IN_R_EN (1 << 7)
76 76
77/* ADC_HPF bit fields */
78#define DA7210_ADC_VOICE_EN (1 << 7)
79
80/* ADC bit fields */ 77/* ADC bit fields */
81#define DA7210_ADC_L_EN (1 << 3) 78#define DA7210_ADC_L_EN (1 << 3)
82#define DA7210_ADC_R_EN (1 << 7) 79#define DA7210_ADC_R_EN (1 << 7)
83 80
84/* DAC_HPF fields */ 81/* DAC/ADC HPF fields */
85#define DA7210_DAC_VOICE_EN (1 << 7) 82#define DA7210_VOICE_F0_MASK (0x7 << 4)
83#define DA7210_VOICE_F0_25 (1 << 4)
84#define DA7210_VOICE_EN (1 << 7)
86 85
87/* DAC_SEL bit fields */ 86/* DAC_SEL bit fields */
88#define DA7210_DAC_L_SRC_DAI_L (4 << 0) 87#define DA7210_DAC_L_SRC_DAI_L (4 << 0)
@@ -123,7 +122,15 @@
123#define DA7210_PLL_BYP (1 << 6) 122#define DA7210_PLL_BYP (1 << 6)
124 123
125/* PLL bit fields */ 124/* PLL bit fields */
126#define DA7210_PLL_FS_48000 (11 << 0) 125#define DA7210_PLL_FS_MASK (0xF << 0)
126#define DA7210_PLL_FS_8000 (0x1 << 0)
127#define DA7210_PLL_FS_12000 (0x3 << 0)
128#define DA7210_PLL_FS_16000 (0x5 << 0)
129#define DA7210_PLL_FS_24000 (0x7 << 0)
130#define DA7210_PLL_FS_32000 (0x9 << 0)
131#define DA7210_PLL_FS_48000 (0xB << 0)
132#define DA7210_PLL_FS_96000 (0xF << 0)
133
127 134
128#define DA7210_VERSION "0.0.1" 135#define DA7210_VERSION "0.0.1"
129 136
@@ -241,7 +248,8 @@ static int da7210_hw_params(struct snd_pcm_substream *substream,
241 struct snd_soc_device *socdev = rtd->socdev; 248 struct snd_soc_device *socdev = rtd->socdev;
242 struct snd_soc_codec *codec = socdev->card->codec; 249 struct snd_soc_codec *codec = socdev->card->codec;
243 u32 dai_cfg1; 250 u32 dai_cfg1;
244 u32 reg, mask; 251 u32 hpf_reg, hpf_mask, hpf_value;
252 u32 fs;
245 253
246 /* set DAI source to Left and Right ADC */ 254 /* set DAI source to Left and Right ADC */
247 da7210_write(codec, DA7210_DAI_SRC_SEL, 255 da7210_write(codec, DA7210_DAI_SRC_SEL,
@@ -265,25 +273,46 @@ static int da7210_hw_params(struct snd_pcm_substream *substream,
265 273
266 da7210_write(codec, DA7210_DAI_CFG1, dai_cfg1); 274 da7210_write(codec, DA7210_DAI_CFG1, dai_cfg1);
267 275
268 /* FIXME 276 hpf_reg = (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) ?
269 * 277 DA7210_DAC_HPF : DA7210_ADC_HPF;
270 * It support 48K only now 278
271 */
272 switch (params_rate(params)) { 279 switch (params_rate(params)) {
280 case 8000:
281 fs = DA7210_PLL_FS_8000;
282 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN;
283 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN;
284 break;
285 case 12000:
286 fs = DA7210_PLL_FS_12000;
287 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN;
288 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN;
289 break;
290 case 16000:
291 fs = DA7210_PLL_FS_16000;
292 hpf_mask = DA7210_VOICE_F0_MASK | DA7210_VOICE_EN;
293 hpf_value = DA7210_VOICE_F0_25 | DA7210_VOICE_EN;
294 break;
295 case 32000:
296 fs = DA7210_PLL_FS_32000;
297 hpf_mask = DA7210_VOICE_EN;
298 hpf_value = 0;
299 break;
273 case 48000: 300 case 48000:
274 if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { 301 fs = DA7210_PLL_FS_48000;
275 reg = DA7210_DAC_HPF; 302 hpf_mask = DA7210_VOICE_EN;
276 mask = DA7210_DAC_VOICE_EN; 303 hpf_value = 0;
277 } else { 304 break;
278 reg = DA7210_ADC_HPF; 305 case 96000:
279 mask = DA7210_ADC_VOICE_EN; 306 fs = DA7210_PLL_FS_96000;
280 } 307 hpf_mask = DA7210_VOICE_EN;
308 hpf_value = 0;
281 break; 309 break;
282 default: 310 default:
283 return -EINVAL; 311 return -EINVAL;
284 } 312 }
285 313
286 snd_soc_update_bits(codec, reg, mask, 0); 314 snd_soc_update_bits(codec, hpf_reg, hpf_mask, hpf_value);
315 snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_FS_MASK, fs);
287 316
288 return 0; 317 return 0;
289} 318}