diff options
author | Mark Brown <broonie@linaro.org> | 2013-08-31 08:17:08 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-09-16 19:41:39 -0400 |
commit | 37c83edf9afd3d7b39ace9113a166c03b7a2820f (patch) | |
tree | 99354e4d337f750240fb75c2b163c7bea293f758 | |
parent | 272b98c6455f00884f0350f775c5342358ebb73f (diff) |
ASoC: wm8400: Use supplies to manage input power
Rather than using a fake register to manage input power create some supply
widgets and use those.
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | sound/soc/codecs/wm8400.c | 73 |
1 files changed, 18 insertions, 55 deletions
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index d2a092850283..95c33d169952 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c | |||
@@ -32,13 +32,6 @@ | |||
32 | 32 | ||
33 | #include "wm8400.h" | 33 | #include "wm8400.h" |
34 | 34 | ||
35 | /* Fake register for internal state */ | ||
36 | #define WM8400_INTDRIVBITS (WM8400_REGISTER_COUNT + 1) | ||
37 | #define WM8400_INMIXL_PWR 0 | ||
38 | #define WM8400_AINLMUX_PWR 1 | ||
39 | #define WM8400_INMIXR_PWR 2 | ||
40 | #define WM8400_AINRMUX_PWR 3 | ||
41 | |||
42 | static struct regulator_bulk_data power[] = { | 35 | static struct regulator_bulk_data power[] = { |
43 | { | 36 | { |
44 | .supply = "I2S1VDD", | 37 | .supply = "I2S1VDD", |
@@ -79,10 +72,7 @@ static inline unsigned int wm8400_read(struct snd_soc_codec *codec, | |||
79 | { | 72 | { |
80 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | 73 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); |
81 | 74 | ||
82 | if (reg == WM8400_INTDRIVBITS) | 75 | return wm8400_reg_read(wm8400->wm8400, reg); |
83 | return wm8400->fake_register; | ||
84 | else | ||
85 | return wm8400_reg_read(wm8400->wm8400, reg); | ||
86 | } | 76 | } |
87 | 77 | ||
88 | /* | 78 | /* |
@@ -93,11 +83,7 @@ static int wm8400_write(struct snd_soc_codec *codec, unsigned int reg, | |||
93 | { | 83 | { |
94 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | 84 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); |
95 | 85 | ||
96 | if (reg == WM8400_INTDRIVBITS) { | 86 | return wm8400_set_bits(wm8400->wm8400, reg, 0xffff, value); |
97 | wm8400->fake_register = value; | ||
98 | return 0; | ||
99 | } else | ||
100 | return wm8400_set_bits(wm8400->wm8400, reg, 0xffff, value); | ||
101 | } | 87 | } |
102 | 88 | ||
103 | static void wm8400_codec_reset(struct snd_soc_codec *codec) | 89 | static void wm8400_codec_reset(struct snd_soc_codec *codec) |
@@ -352,32 +338,6 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, | |||
352 | * _DAPM_ Controls | 338 | * _DAPM_ Controls |
353 | */ | 339 | */ |
354 | 340 | ||
355 | static int inmixer_event (struct snd_soc_dapm_widget *w, | ||
356 | struct snd_kcontrol *kcontrol, int event) | ||
357 | { | ||
358 | u16 reg, fakepower; | ||
359 | |||
360 | reg = snd_soc_read(w->codec, WM8400_POWER_MANAGEMENT_2); | ||
361 | fakepower = snd_soc_read(w->codec, WM8400_INTDRIVBITS); | ||
362 | |||
363 | if (fakepower & ((1 << WM8400_INMIXL_PWR) | | ||
364 | (1 << WM8400_AINLMUX_PWR))) { | ||
365 | reg |= WM8400_AINL_ENA; | ||
366 | } else { | ||
367 | reg &= ~WM8400_AINL_ENA; | ||
368 | } | ||
369 | |||
370 | if (fakepower & ((1 << WM8400_INMIXR_PWR) | | ||
371 | (1 << WM8400_AINRMUX_PWR))) { | ||
372 | reg |= WM8400_AINR_ENA; | ||
373 | } else { | ||
374 | reg &= ~WM8400_AINR_ENA; | ||
375 | } | ||
376 | snd_soc_write(w->codec, WM8400_POWER_MANAGEMENT_2, reg); | ||
377 | |||
378 | return 0; | ||
379 | } | ||
380 | |||
381 | static int outmixer_event (struct snd_soc_dapm_widget *w, | 341 | static int outmixer_event (struct snd_soc_dapm_widget *w, |
382 | struct snd_kcontrol * kcontrol, int event) | 342 | struct snd_kcontrol * kcontrol, int event) |
383 | { | 343 | { |
@@ -658,27 +618,26 @@ SND_SOC_DAPM_MIXER("RIN34 PGA", WM8400_POWER_MANAGEMENT_2, | |||
658 | 0, &wm8400_dapm_rin34_pga_controls[0], | 618 | 0, &wm8400_dapm_rin34_pga_controls[0], |
659 | ARRAY_SIZE(wm8400_dapm_rin34_pga_controls)), | 619 | ARRAY_SIZE(wm8400_dapm_rin34_pga_controls)), |
660 | 620 | ||
621 | SND_SOC_DAPM_SUPPLY("INL", WM8400_POWER_MANAGEMENT_2, WM8400_AINL_ENA_SHIFT, | ||
622 | 0, NULL, 0), | ||
623 | SND_SOC_DAPM_SUPPLY("INR", WM8400_POWER_MANAGEMENT_2, WM8400_AINR_ENA_SHIFT, | ||
624 | 0, NULL, 0), | ||
625 | |||
661 | /* INMIXL */ | 626 | /* INMIXL */ |
662 | SND_SOC_DAPM_MIXER_E("INMIXL", WM8400_INTDRIVBITS, WM8400_INMIXL_PWR, 0, | 627 | SND_SOC_DAPM_MIXER("INMIXL", SND_SOC_NOPM, 0, 0, |
663 | &wm8400_dapm_inmixl_controls[0], | 628 | &wm8400_dapm_inmixl_controls[0], |
664 | ARRAY_SIZE(wm8400_dapm_inmixl_controls), | 629 | ARRAY_SIZE(wm8400_dapm_inmixl_controls)), |
665 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
666 | 630 | ||
667 | /* AINLMUX */ | 631 | /* AINLMUX */ |
668 | SND_SOC_DAPM_MUX_E("AILNMUX", WM8400_INTDRIVBITS, WM8400_AINLMUX_PWR, 0, | 632 | SND_SOC_DAPM_MUX("AILNMUX", SND_SOC_NOPM, 0, 0, &wm8400_dapm_ainlmux_controls), |
669 | &wm8400_dapm_ainlmux_controls, inmixer_event, | ||
670 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
671 | 633 | ||
672 | /* INMIXR */ | 634 | /* INMIXR */ |
673 | SND_SOC_DAPM_MIXER_E("INMIXR", WM8400_INTDRIVBITS, WM8400_INMIXR_PWR, 0, | 635 | SND_SOC_DAPM_MIXER("INMIXR", SND_SOC_NOPM, 0, 0, |
674 | &wm8400_dapm_inmixr_controls[0], | 636 | &wm8400_dapm_inmixr_controls[0], |
675 | ARRAY_SIZE(wm8400_dapm_inmixr_controls), | 637 | ARRAY_SIZE(wm8400_dapm_inmixr_controls)), |
676 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
677 | 638 | ||
678 | /* AINRMUX */ | 639 | /* AINRMUX */ |
679 | SND_SOC_DAPM_MUX_E("AIRNMUX", WM8400_INTDRIVBITS, WM8400_AINRMUX_PWR, 0, | 640 | SND_SOC_DAPM_MUX("AIRNMUX", SND_SOC_NOPM, 0, 0, &wm8400_dapm_ainrmux_controls), |
680 | &wm8400_dapm_ainrmux_controls, inmixer_event, | ||
681 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
682 | 641 | ||
683 | /* Output Side */ | 642 | /* Output Side */ |
684 | /* DACs */ | 643 | /* DACs */ |
@@ -789,11 +748,13 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = { | |||
789 | {"LIN34 PGA", "LIN3 Switch", "LIN3"}, | 748 | {"LIN34 PGA", "LIN3 Switch", "LIN3"}, |
790 | {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"}, | 749 | {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"}, |
791 | /* INMIXL */ | 750 | /* INMIXL */ |
751 | {"INMIXL", NULL, "INL"}, | ||
792 | {"INMIXL", "Record Left Volume", "LOMIX"}, | 752 | {"INMIXL", "Record Left Volume", "LOMIX"}, |
793 | {"INMIXL", "LIN2 Volume", "LIN2"}, | 753 | {"INMIXL", "LIN2 Volume", "LIN2"}, |
794 | {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"}, | 754 | {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"}, |
795 | {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"}, | 755 | {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"}, |
796 | /* AILNMUX */ | 756 | /* AILNMUX */ |
757 | {"AILNMUX", NULL, "INL"}, | ||
797 | {"AILNMUX", "INMIXL Mix", "INMIXL"}, | 758 | {"AILNMUX", "INMIXL Mix", "INMIXL"}, |
798 | {"AILNMUX", "DIFFINL Mix", "LIN12 PGA"}, | 759 | {"AILNMUX", "DIFFINL Mix", "LIN12 PGA"}, |
799 | {"AILNMUX", "DIFFINL Mix", "LIN34 PGA"}, | 760 | {"AILNMUX", "DIFFINL Mix", "LIN34 PGA"}, |
@@ -808,12 +769,14 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = { | |||
808 | /* RIN34 PGA */ | 769 | /* RIN34 PGA */ |
809 | {"RIN34 PGA", "RIN3 Switch", "RIN3"}, | 770 | {"RIN34 PGA", "RIN3 Switch", "RIN3"}, |
810 | {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"}, | 771 | {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"}, |
811 | /* INMIXL */ | 772 | /* INMIXR */ |
773 | {"INMIXR", NULL, "INR"}, | ||
812 | {"INMIXR", "Record Right Volume", "ROMIX"}, | 774 | {"INMIXR", "Record Right Volume", "ROMIX"}, |
813 | {"INMIXR", "RIN2 Volume", "RIN2"}, | 775 | {"INMIXR", "RIN2 Volume", "RIN2"}, |
814 | {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"}, | 776 | {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"}, |
815 | {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"}, | 777 | {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"}, |
816 | /* AIRNMUX */ | 778 | /* AIRNMUX */ |
779 | {"AIRNMUX", NULL, "INR"}, | ||
817 | {"AIRNMUX", "INMIXR Mix", "INMIXR"}, | 780 | {"AIRNMUX", "INMIXR Mix", "INMIXR"}, |
818 | {"AIRNMUX", "DIFFINR Mix", "RIN12 PGA"}, | 781 | {"AIRNMUX", "DIFFINR Mix", "RIN12 PGA"}, |
819 | {"AIRNMUX", "DIFFINR Mix", "RIN34 PGA"}, | 782 | {"AIRNMUX", "DIFFINR Mix", "RIN34 PGA"}, |