diff options
author | Kuninori Morimoto <morimoto.kuninori@renesas.com> | 2010-03-23 03:27:38 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-03-23 06:59:11 -0400 |
commit | 1ad747ca9b6f97f895e0a6ccd447b158aeaa568d (patch) | |
tree | 482cdcb4003f14fd4f7a6819e6a8a39aafaafe16 | |
parent | 0643ce8f42e763635d8d6cf311730a6e84d4be92 (diff) |
ASoC: ak4642: Add enhanced sampling rate
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>
-rw-r--r-- | sound/soc/codecs/ak4642.c | 68 |
1 files changed, 63 insertions, 5 deletions
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 3452bd752739..de1809dc8d91 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c | |||
@@ -101,6 +101,13 @@ | |||
101 | #define BCKO_MASK (1 << 3) | 101 | #define BCKO_MASK (1 << 3) |
102 | #define BCKO_64 BCKO_MASK | 102 | #define BCKO_64 BCKO_MASK |
103 | 103 | ||
104 | /* MD_CTL2 */ | ||
105 | #define FS0 (1 << 0) | ||
106 | #define FS1 (1 << 1) | ||
107 | #define FS2 (1 << 2) | ||
108 | #define FS3 (1 << 5) | ||
109 | #define FS_MASK (FS0 | FS1 | FS2 | FS3) | ||
110 | |||
104 | struct snd_soc_codec_device soc_codec_dev_ak4642; | 111 | struct snd_soc_codec_device soc_codec_dev_ak4642; |
105 | 112 | ||
106 | /* codec private data */ | 113 | /* codec private data */ |
@@ -196,14 +203,12 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, | |||
196 | * | 203 | * |
197 | * PLL, Master Mode | 204 | * PLL, Master Mode |
198 | * Audio I/F Format :MSB justified (ADC & DAC) | 205 | * Audio I/F Format :MSB justified (ADC & DAC) |
199 | * Sampling Frequency: 44.1kHz | 206 | * Digital Volume: -8dB |
200 | * Digital Volume: −8dB | ||
201 | * Bass Boost Level : Middle | 207 | * Bass Boost Level : Middle |
202 | * | 208 | * |
203 | * This operation came from example code of | 209 | * This operation came from example code of |
204 | * "ASAHI KASEI AK4642" (japanese) manual p97. | 210 | * "ASAHI KASEI AK4642" (japanese) manual p97. |
205 | */ | 211 | */ |
206 | ak4642_write(codec, 0x05, 0x27); | ||
207 | ak4642_write(codec, 0x0f, 0x09); | 212 | ak4642_write(codec, 0x0f, 0x09); |
208 | ak4642_write(codec, 0x0e, 0x19); | 213 | ak4642_write(codec, 0x0e, 0x19); |
209 | ak4642_write(codec, 0x09, 0x91); | 214 | ak4642_write(codec, 0x09, 0x91); |
@@ -219,7 +224,6 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, | |||
219 | * | 224 | * |
220 | * PLL Master Mode | 225 | * PLL Master Mode |
221 | * Audio I/F Format:MSB justified (ADC & DAC) | 226 | * Audio I/F Format:MSB justified (ADC & DAC) |
222 | * Sampling Frequency:44.1kHz | ||
223 | * Pre MIC AMP:+20dB | 227 | * Pre MIC AMP:+20dB |
224 | * MIC Power On | 228 | * MIC Power On |
225 | * ALC setting:Refer to Table 35 | 229 | * ALC setting:Refer to Table 35 |
@@ -228,7 +232,6 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, | |||
228 | * This operation came from example code of | 232 | * This operation came from example code of |
229 | * "ASAHI KASEI AK4642" (japanese) manual p94. | 233 | * "ASAHI KASEI AK4642" (japanese) manual p94. |
230 | */ | 234 | */ |
231 | ak4642_write(codec, 0x05, 0x27); | ||
232 | ak4642_write(codec, 0x02, 0x05); | 235 | ak4642_write(codec, 0x02, 0x05); |
233 | ak4642_write(codec, 0x06, 0x3c); | 236 | ak4642_write(codec, 0x06, 0x3c); |
234 | ak4642_write(codec, 0x08, 0xe1); | 237 | ak4642_write(codec, 0x08, 0xe1); |
@@ -321,11 +324,65 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
321 | return 0; | 324 | return 0; |
322 | } | 325 | } |
323 | 326 | ||
327 | static int ak4642_dai_hw_params(struct snd_pcm_substream *substream, | ||
328 | struct snd_pcm_hw_params *params, | ||
329 | struct snd_soc_dai *dai) | ||
330 | { | ||
331 | struct snd_soc_codec *codec = dai->codec; | ||
332 | u8 rate; | ||
333 | |||
334 | switch (params_rate(params)) { | ||
335 | case 7350: | ||
336 | rate = FS2; | ||
337 | break; | ||
338 | case 8000: | ||
339 | rate = 0; | ||
340 | break; | ||
341 | case 11025: | ||
342 | rate = FS2 | FS0; | ||
343 | break; | ||
344 | case 12000: | ||
345 | rate = FS0; | ||
346 | break; | ||
347 | case 14700: | ||
348 | rate = FS2 | FS1; | ||
349 | break; | ||
350 | case 16000: | ||
351 | rate = FS1; | ||
352 | break; | ||
353 | case 22050: | ||
354 | rate = FS2 | FS1 | FS0; | ||
355 | break; | ||
356 | case 24000: | ||
357 | rate = FS1 | FS0; | ||
358 | break; | ||
359 | case 29400: | ||
360 | rate = FS3 | FS2 | FS1; | ||
361 | break; | ||
362 | case 32000: | ||
363 | rate = FS3 | FS1; | ||
364 | break; | ||
365 | case 44100: | ||
366 | rate = FS3 | FS2 | FS1 | FS0; | ||
367 | break; | ||
368 | case 48000: | ||
369 | rate = FS3 | FS1 | FS0; | ||
370 | break; | ||
371 | default: | ||
372 | return -EINVAL; | ||
373 | break; | ||
374 | } | ||
375 | snd_soc_update_bits(codec, MD_CTL2, FS_MASK, rate); | ||
376 | |||
377 | return 0; | ||
378 | } | ||
379 | |||
324 | static struct snd_soc_dai_ops ak4642_dai_ops = { | 380 | static struct snd_soc_dai_ops ak4642_dai_ops = { |
325 | .startup = ak4642_dai_startup, | 381 | .startup = ak4642_dai_startup, |
326 | .shutdown = ak4642_dai_shutdown, | 382 | .shutdown = ak4642_dai_shutdown, |
327 | .set_sysclk = ak4642_dai_set_sysclk, | 383 | .set_sysclk = ak4642_dai_set_sysclk, |
328 | .set_fmt = ak4642_dai_set_fmt, | 384 | .set_fmt = ak4642_dai_set_fmt, |
385 | .hw_params = ak4642_dai_hw_params, | ||
329 | }; | 386 | }; |
330 | 387 | ||
331 | struct snd_soc_dai ak4642_dai = { | 388 | struct snd_soc_dai ak4642_dai = { |
@@ -343,6 +400,7 @@ struct snd_soc_dai ak4642_dai = { | |||
343 | .rates = SNDRV_PCM_RATE_8000_48000, | 400 | .rates = SNDRV_PCM_RATE_8000_48000, |
344 | .formats = SNDRV_PCM_FMTBIT_S16_LE }, | 401 | .formats = SNDRV_PCM_FMTBIT_S16_LE }, |
345 | .ops = &ak4642_dai_ops, | 402 | .ops = &ak4642_dai_ops, |
403 | .symmetric_rates = 1, | ||
346 | }; | 404 | }; |
347 | EXPORT_SYMBOL_GPL(ak4642_dai); | 405 | EXPORT_SYMBOL_GPL(ak4642_dai); |
348 | 406 | ||