diff options
author | Mark Brown <broonie@linaro.org> | 2013-11-22 06:16:18 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-11-24 08:53:26 -0500 |
commit | 6a0773368619644432fbe46f64ded6aa204baab9 (patch) | |
tree | 22920372876bdeef1ee0a1ce7578a5bf3c058338 | |
parent | 6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff) |
ASoC: wm8991: Use a supply to manage input power
Instead of using a fake register and events to manage input power use a
supply to do the job, saving code and preparing for regmap conversion of
the driver.
Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/codecs/wm8991.c | 53 | ||||
-rw-r--r-- | sound/soc/codecs/wm8991.h | 9 |
2 files changed, 17 insertions, 45 deletions
diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c index 3a39df7a3829..5078fc8e10f7 100644 --- a/sound/soc/codecs/wm8991.c +++ b/sound/soc/codecs/wm8991.c | |||
@@ -374,30 +374,6 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = { | |||
374 | /* | 374 | /* |
375 | * _DAPM_ Controls | 375 | * _DAPM_ Controls |
376 | */ | 376 | */ |
377 | static int inmixer_event(struct snd_soc_dapm_widget *w, | ||
378 | struct snd_kcontrol *kcontrol, int event) | ||
379 | { | ||
380 | u16 reg, fakepower; | ||
381 | |||
382 | reg = snd_soc_read(w->codec, WM8991_POWER_MANAGEMENT_2); | ||
383 | fakepower = snd_soc_read(w->codec, WM8991_INTDRIVBITS); | ||
384 | |||
385 | if (fakepower & ((1 << WM8991_INMIXL_PWR_BIT) | | ||
386 | (1 << WM8991_AINLMUX_PWR_BIT))) | ||
387 | reg |= WM8991_AINL_ENA; | ||
388 | else | ||
389 | reg &= ~WM8991_AINL_ENA; | ||
390 | |||
391 | if (fakepower & ((1 << WM8991_INMIXR_PWR_BIT) | | ||
392 | (1 << WM8991_AINRMUX_PWR_BIT))) | ||
393 | reg |= WM8991_AINR_ENA; | ||
394 | else | ||
395 | reg &= ~WM8991_AINR_ENA; | ||
396 | |||
397 | snd_soc_write(w->codec, WM8991_POWER_MANAGEMENT_2, reg); | ||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static int outmixer_event(struct snd_soc_dapm_widget *w, | 377 | static int outmixer_event(struct snd_soc_dapm_widget *w, |
402 | struct snd_kcontrol *kcontrol, int event) | 378 | struct snd_kcontrol *kcontrol, int event) |
403 | { | 379 | { |
@@ -655,6 +631,11 @@ static const struct snd_soc_dapm_widget wm8991_dapm_widgets[] = { | |||
655 | SND_SOC_DAPM_INPUT("RIN2"), | 631 | SND_SOC_DAPM_INPUT("RIN2"), |
656 | SND_SOC_DAPM_INPUT("Internal ADC Source"), | 632 | SND_SOC_DAPM_INPUT("Internal ADC Source"), |
657 | 633 | ||
634 | SND_SOC_DAPM_SUPPLY("INL", WM8991_POWER_MANAGEMENT_2, | ||
635 | WM8991_AINL_ENA_BIT, 0, NULL, 0), | ||
636 | SND_SOC_DAPM_SUPPLY("INR", WM8991_POWER_MANAGEMENT_2, | ||
637 | WM8991_AINR_ENA_BIT, 0, NULL, 0), | ||
638 | |||
658 | /* DACs */ | 639 | /* DACs */ |
659 | SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8991_POWER_MANAGEMENT_2, | 640 | SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8991_POWER_MANAGEMENT_2, |
660 | WM8991_ADCL_ENA_BIT, 0), | 641 | WM8991_ADCL_ENA_BIT, 0), |
@@ -676,26 +657,22 @@ static const struct snd_soc_dapm_widget wm8991_dapm_widgets[] = { | |||
676 | ARRAY_SIZE(wm8991_dapm_rin34_pga_controls)), | 657 | ARRAY_SIZE(wm8991_dapm_rin34_pga_controls)), |
677 | 658 | ||
678 | /* INMIXL */ | 659 | /* INMIXL */ |
679 | SND_SOC_DAPM_MIXER_E("INMIXL", WM8991_INTDRIVBITS, WM8991_INMIXL_PWR_BIT, 0, | 660 | SND_SOC_DAPM_MIXER("INMIXL", SND_SOC_NOPM, 0, 0, |
680 | &wm8991_dapm_inmixl_controls[0], | 661 | &wm8991_dapm_inmixl_controls[0], |
681 | ARRAY_SIZE(wm8991_dapm_inmixl_controls), | 662 | ARRAY_SIZE(wm8991_dapm_inmixl_controls)), |
682 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
683 | 663 | ||
684 | /* AINLMUX */ | 664 | /* AINLMUX */ |
685 | SND_SOC_DAPM_MUX_E("AINLMUX", WM8991_INTDRIVBITS, WM8991_AINLMUX_PWR_BIT, 0, | 665 | SND_SOC_DAPM_MUX("AINLMUX", SND_SOC_NOPM, 0, 0, |
686 | &wm8991_dapm_ainlmux_controls, inmixer_event, | 666 | &wm8991_dapm_ainlmux_controls), |
687 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
688 | 667 | ||
689 | /* INMIXR */ | 668 | /* INMIXR */ |
690 | SND_SOC_DAPM_MIXER_E("INMIXR", WM8991_INTDRIVBITS, WM8991_INMIXR_PWR_BIT, 0, | 669 | SND_SOC_DAPM_MIXER("INMIXR", SND_SOC_NOPM, 0, 0, |
691 | &wm8991_dapm_inmixr_controls[0], | 670 | &wm8991_dapm_inmixr_controls[0], |
692 | ARRAY_SIZE(wm8991_dapm_inmixr_controls), | 671 | ARRAY_SIZE(wm8991_dapm_inmixr_controls)), |
693 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
694 | 672 | ||
695 | /* AINRMUX */ | 673 | /* AINRMUX */ |
696 | SND_SOC_DAPM_MUX_E("AINRMUX", WM8991_INTDRIVBITS, WM8991_AINRMUX_PWR_BIT, 0, | 674 | SND_SOC_DAPM_MUX("AINRMUX", SND_SOC_NOPM, 0, 0, |
697 | &wm8991_dapm_ainrmux_controls, inmixer_event, | 675 | &wm8991_dapm_ainrmux_controls), |
698 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
699 | 676 | ||
700 | /* Output Side */ | 677 | /* Output Side */ |
701 | /* DACs */ | 678 | /* DACs */ |
@@ -797,6 +774,10 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
797 | {"Right ADC", NULL, "Internal ADC Source"}, | 774 | {"Right ADC", NULL, "Internal ADC Source"}, |
798 | 775 | ||
799 | /* Input Side */ | 776 | /* Input Side */ |
777 | {"INMIXL", NULL, "INL"}, | ||
778 | {"AINLMUX", NULL, "INL"}, | ||
779 | {"INMIXR", NULL, "INR"}, | ||
780 | {"AINRMUX", NULL, "INR"}, | ||
800 | /* LIN12 PGA */ | 781 | /* LIN12 PGA */ |
801 | {"LIN12 PGA", "LIN1 Switch", "LIN1"}, | 782 | {"LIN12 PGA", "LIN1 Switch", "LIN1"}, |
802 | {"LIN12 PGA", "LIN2 Switch", "LIN2"}, | 783 | {"LIN12 PGA", "LIN2 Switch", "LIN2"}, |
diff --git a/sound/soc/codecs/wm8991.h b/sound/soc/codecs/wm8991.h index 07707d8d7e20..08ed383303c0 100644 --- a/sound/soc/codecs/wm8991.h +++ b/sound/soc/codecs/wm8991.h | |||
@@ -76,7 +76,6 @@ | |||
76 | #define WM8991_PLL1 0x3C | 76 | #define WM8991_PLL1 0x3C |
77 | #define WM8991_PLL2 0x3D | 77 | #define WM8991_PLL2 0x3D |
78 | #define WM8991_PLL3 0x3E | 78 | #define WM8991_PLL3 0x3E |
79 | #define WM8991_INTDRIVBITS 0x3F | ||
80 | 79 | ||
81 | #define WM8991_REGISTER_COUNT 60 | 80 | #define WM8991_REGISTER_COUNT 60 |
82 | #define WM8991_MAX_REGISTER 0x3F | 81 | #define WM8991_MAX_REGISTER 0x3F |
@@ -807,14 +806,6 @@ | |||
807 | */ | 806 | */ |
808 | #define WM8991_PLLK2_MASK 0x00FF /* PLLK2 - [7:0] */ | 807 | #define WM8991_PLLK2_MASK 0x00FF /* PLLK2 - [7:0] */ |
809 | 808 | ||
810 | /* | ||
811 | * R63 (0x3F) - Internal Driver Bits | ||
812 | */ | ||
813 | #define WM8991_INMIXL_PWR_BIT 0 | ||
814 | #define WM8991_AINLMUX_PWR_BIT 1 | ||
815 | #define WM8991_INMIXR_PWR_BIT 2 | ||
816 | #define WM8991_AINRMUX_PWR_BIT 3 | ||
817 | |||
818 | #define WM8991_MCLK_DIV 0 | 809 | #define WM8991_MCLK_DIV 0 |
819 | #define WM8991_DACCLK_DIV 1 | 810 | #define WM8991_DACCLK_DIV 1 |
820 | #define WM8991_ADCCLK_DIV 2 | 811 | #define WM8991_ADCCLK_DIV 2 |