diff options
author | Ashish Chavan <ashish.chavan@kpitcummins.com> | 2011-10-21 08:46:08 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-10-22 05:34:22 -0400 |
commit | 6950c60dc1a0981a6a99bece52437965be8e1be0 (patch) | |
tree | c281e53f16bf5d21b8a59aeab1f524e24b2548a9 /sound/soc/codecs/da7210.c | |
parent | 064a4bcee4114e519ce22d56d2eb8e9dfa653804 (diff) |
ASoC: da7210: Add support for DAPM
This patch adds support for DAPM covering all inputs and outputs
as well as ADC and DAC.
Signed-off-by: Ashish Chavan <ashish.chavan@kpitcummins.com>
Signed-off-by: David Dajun Chen <dchen@diasemi.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/da7210.c')
-rw-r--r-- | sound/soc/codecs/da7210.c | 145 |
1 files changed, 121 insertions, 24 deletions
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index e9ee6a4faa26..7a4b952a05eb 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c | |||
@@ -29,6 +29,8 @@ | |||
29 | #define DA7210_CONTROL 0x01 | 29 | #define DA7210_CONTROL 0x01 |
30 | #define DA7210_STATUS 0x02 | 30 | #define DA7210_STATUS 0x02 |
31 | #define DA7210_STARTUP1 0x03 | 31 | #define DA7210_STARTUP1 0x03 |
32 | #define DA7210_STARTUP2 0x04 | ||
33 | #define DA7210_STARTUP3 0x05 | ||
32 | #define DA7210_MIC_L 0x07 | 34 | #define DA7210_MIC_L 0x07 |
33 | #define DA7210_MIC_R 0x08 | 35 | #define DA7210_MIC_R 0x08 |
34 | #define DA7210_AUX1_L 0x09 | 36 | #define DA7210_AUX1_L 0x09 |
@@ -372,6 +374,120 @@ static const struct snd_kcontrol_new da7210_snd_controls[] = { | |||
372 | 0, snd_soc_get_volsw, da7210_put_noise_sup_sw), | 374 | 0, snd_soc_get_volsw, da7210_put_noise_sup_sw), |
373 | }; | 375 | }; |
374 | 376 | ||
377 | /* | ||
378 | * DAPM Controls | ||
379 | * | ||
380 | * Current DAPM implementation covers almost all codec components e.g. IOs, | ||
381 | * mixers, PGAs,ADC and DAC. | ||
382 | */ | ||
383 | /* In Mixer Left */ | ||
384 | static const struct snd_kcontrol_new da7210_dapm_inmixl_controls[] = { | ||
385 | SOC_DAPM_SINGLE("Mic Left Switch", DA7210_INMIX_L, 0, 1, 0), | ||
386 | SOC_DAPM_SINGLE("Mic Right Switch", DA7210_INMIX_L, 1, 1, 0), | ||
387 | }; | ||
388 | |||
389 | /* In Mixer Right */ | ||
390 | static const struct snd_kcontrol_new da7210_dapm_inmixr_controls[] = { | ||
391 | SOC_DAPM_SINGLE("Mic Right Switch", DA7210_INMIX_R, 0, 1, 0), | ||
392 | SOC_DAPM_SINGLE("Mic Left Switch", DA7210_INMIX_R, 1, 1, 0), | ||
393 | }; | ||
394 | |||
395 | /* Out Mixer Left */ | ||
396 | static const struct snd_kcontrol_new da7210_dapm_outmixl_controls[] = { | ||
397 | SOC_DAPM_SINGLE("DAC Left Switch", DA7210_OUTMIX_L, 4, 1, 0), | ||
398 | }; | ||
399 | |||
400 | /* Out Mixer Right */ | ||
401 | static const struct snd_kcontrol_new da7210_dapm_outmixr_controls[] = { | ||
402 | SOC_DAPM_SINGLE("DAC Right Switch", DA7210_OUTMIX_R, 4, 1, 0), | ||
403 | }; | ||
404 | |||
405 | /* DAPM widgets */ | ||
406 | static const struct snd_soc_dapm_widget da7210_dapm_widgets[] = { | ||
407 | /* Input Side */ | ||
408 | /* Input Lines */ | ||
409 | SND_SOC_DAPM_INPUT("MICL"), | ||
410 | SND_SOC_DAPM_INPUT("MICR"), | ||
411 | |||
412 | /* Input PGAs */ | ||
413 | SND_SOC_DAPM_PGA("Mic Left", DA7210_STARTUP3, 0, 1, NULL, 0), | ||
414 | SND_SOC_DAPM_PGA("Mic Right", DA7210_STARTUP3, 1, 1, NULL, 0), | ||
415 | |||
416 | SND_SOC_DAPM_PGA("INPGA Left", DA7210_INMIX_L, 7, 0, NULL, 0), | ||
417 | SND_SOC_DAPM_PGA("INPGA Right", DA7210_INMIX_R, 7, 0, NULL, 0), | ||
418 | |||
419 | /* Input Mixers */ | ||
420 | SND_SOC_DAPM_MIXER("In Mixer Left", SND_SOC_NOPM, 0, 0, | ||
421 | &da7210_dapm_inmixl_controls[0], | ||
422 | ARRAY_SIZE(da7210_dapm_inmixl_controls)), | ||
423 | |||
424 | SND_SOC_DAPM_MIXER("In Mixer Right", SND_SOC_NOPM, 0, 0, | ||
425 | &da7210_dapm_inmixr_controls[0], | ||
426 | ARRAY_SIZE(da7210_dapm_inmixr_controls)), | ||
427 | |||
428 | /* ADCs */ | ||
429 | SND_SOC_DAPM_ADC("ADC Left", "Capture", DA7210_STARTUP3, 5, 1), | ||
430 | SND_SOC_DAPM_ADC("ADC Right", "Capture", DA7210_STARTUP3, 6, 1), | ||
431 | |||
432 | /* Output Side */ | ||
433 | /* DACs */ | ||
434 | SND_SOC_DAPM_DAC("DAC Left", "Playback", DA7210_STARTUP2, 5, 1), | ||
435 | SND_SOC_DAPM_DAC("DAC Right", "Playback", DA7210_STARTUP2, 6, 1), | ||
436 | |||
437 | /* Output Mixers */ | ||
438 | SND_SOC_DAPM_MIXER("Out Mixer Left", SND_SOC_NOPM, 0, 0, | ||
439 | &da7210_dapm_outmixl_controls[0], | ||
440 | ARRAY_SIZE(da7210_dapm_outmixl_controls)), | ||
441 | |||
442 | SND_SOC_DAPM_MIXER("Out Mixer Right", SND_SOC_NOPM, 0, 0, | ||
443 | &da7210_dapm_outmixr_controls[0], | ||
444 | ARRAY_SIZE(da7210_dapm_outmixr_controls)), | ||
445 | |||
446 | /* Output PGAs */ | ||
447 | SND_SOC_DAPM_PGA("OUTPGA Left Enable", DA7210_OUTMIX_L, 7, 0, NULL, 0), | ||
448 | SND_SOC_DAPM_PGA("OUTPGA Right Enable", DA7210_OUTMIX_R, 7, 0, NULL, 0), | ||
449 | |||
450 | SND_SOC_DAPM_PGA("Headphone Left", DA7210_STARTUP2, 3, 1, NULL, 0), | ||
451 | SND_SOC_DAPM_PGA("Headphone Right", DA7210_STARTUP2, 4, 1, NULL, 0), | ||
452 | |||
453 | /* Output Lines */ | ||
454 | SND_SOC_DAPM_OUTPUT("HPL"), | ||
455 | SND_SOC_DAPM_OUTPUT("HPR"), | ||
456 | }; | ||
457 | |||
458 | /* DAPM audio route definition */ | ||
459 | static const struct snd_soc_dapm_route da7210_audio_map[] = { | ||
460 | /* Dest Connecting Widget source */ | ||
461 | /* Input path */ | ||
462 | {"Mic Left", NULL, "MICL"}, | ||
463 | {"Mic Right", NULL, "MICR"}, | ||
464 | |||
465 | {"In Mixer Left", "Mic Left Switch", "Mic Left"}, | ||
466 | {"In Mixer Left", "Mic Right Switch", "Mic Right"}, | ||
467 | |||
468 | {"In Mixer Right", "Mic Right Switch", "Mic Right"}, | ||
469 | {"In Mixer Right", "Mic Left Switch", "Mic Left"}, | ||
470 | |||
471 | {"INPGA Left", NULL, "In Mixer Left"}, | ||
472 | {"ADC Left", NULL, "INPGA Left"}, | ||
473 | |||
474 | {"INPGA Right", NULL, "In Mixer Right"}, | ||
475 | {"ADC Right", NULL, "INPGA Right"}, | ||
476 | |||
477 | /* Output path */ | ||
478 | {"Out Mixer Left", "DAC Left Switch", "DAC Left"}, | ||
479 | {"Out Mixer Right", "DAC Right Switch", "DAC Right"}, | ||
480 | |||
481 | {"OUTPGA Left Enable", NULL, "Out Mixer Left"}, | ||
482 | {"OUTPGA Right Enable", NULL, "Out Mixer Right"}, | ||
483 | |||
484 | {"Headphone Left", NULL, "OUTPGA Left Enable"}, | ||
485 | {"HPL", NULL, "Headphone Left"}, | ||
486 | |||
487 | {"Headphone Right", NULL, "OUTPGA Right Enable"}, | ||
488 | {"HPR", NULL, "Headphone Right"}, | ||
489 | }; | ||
490 | |||
375 | /* Codec private data */ | 491 | /* Codec private data */ |
376 | struct da7210_priv { | 492 | struct da7210_priv { |
377 | enum snd_soc_control_type control_type; | 493 | enum snd_soc_control_type control_type; |
@@ -411,29 +527,6 @@ static int da7210_volatile_register(struct snd_soc_codec *codec, | |||
411 | return 0; | 527 | return 0; |
412 | } | 528 | } |
413 | } | 529 | } |
414 | static int da7210_startup(struct snd_pcm_substream *substream, | ||
415 | struct snd_soc_dai *dai) | ||
416 | { | ||
417 | int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; | ||
418 | struct snd_soc_codec *codec = dai->codec; | ||
419 | |||
420 | if (is_play) { | ||
421 | /* Enable Out */ | ||
422 | snd_soc_update_bits(codec, DA7210_OUTMIX_L, 0x1F, 0x10); | ||
423 | snd_soc_update_bits(codec, DA7210_OUTMIX_R, 0x1F, 0x10); | ||
424 | |||
425 | } else { | ||
426 | /* Volume 7 */ | ||
427 | snd_soc_update_bits(codec, DA7210_MIC_L, 0x7, 0x7); | ||
428 | snd_soc_update_bits(codec, DA7210_MIC_R, 0x7, 0x7); | ||
429 | |||
430 | /* Enable Mic */ | ||
431 | snd_soc_update_bits(codec, DA7210_INMIX_L, 0x1F, 0x1); | ||
432 | snd_soc_update_bits(codec, DA7210_INMIX_R, 0x1F, 0x1); | ||
433 | } | ||
434 | |||
435 | return 0; | ||
436 | } | ||
437 | 530 | ||
438 | /* | 531 | /* |
439 | * Set PCM DAI word length. | 532 | * Set PCM DAI word length. |
@@ -603,7 +696,6 @@ static int da7210_mute(struct snd_soc_dai *dai, int mute) | |||
603 | 696 | ||
604 | /* DAI operations */ | 697 | /* DAI operations */ |
605 | static struct snd_soc_dai_ops da7210_dai_ops = { | 698 | static struct snd_soc_dai_ops da7210_dai_ops = { |
606 | .startup = da7210_startup, | ||
607 | .hw_params = da7210_hw_params, | 699 | .hw_params = da7210_hw_params, |
608 | .set_fmt = da7210_set_dai_fmt, | 700 | .set_fmt = da7210_set_dai_fmt, |
609 | .digital_mute = da7210_mute, | 701 | .digital_mute = da7210_mute, |
@@ -742,6 +834,11 @@ static struct snd_soc_codec_driver soc_codec_dev_da7210 = { | |||
742 | 834 | ||
743 | .controls = da7210_snd_controls, | 835 | .controls = da7210_snd_controls, |
744 | .num_controls = ARRAY_SIZE(da7210_snd_controls), | 836 | .num_controls = ARRAY_SIZE(da7210_snd_controls), |
837 | |||
838 | .dapm_widgets = da7210_dapm_widgets, | ||
839 | .num_dapm_widgets = ARRAY_SIZE(da7210_dapm_widgets), | ||
840 | .dapm_routes = da7210_audio_map, | ||
841 | .num_dapm_routes = ARRAY_SIZE(da7210_audio_map), | ||
745 | }; | 842 | }; |
746 | 843 | ||
747 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 844 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |