diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-04-20 12:56:13 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-04-20 13:09:48 -0400 |
commit | b75576d76d4be50196773f36709cb7a4f5ac2ab7 (patch) | |
tree | 10c8c2cafda5bde450a073f8c6bc84a5e798ea80 /sound | |
parent | 6ea31b9f0a0307e16656af27fcda3160e2a64a1b (diff) |
ASoC: Make the DAPM power check an operation on the widget
Rather than having switch statements at point of use make the DAPM
power check a member of the widget structure and set it when we
instantiate the widget.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/soc-dapm.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 22522e2d83a4..d3d17354e76c 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -631,20 +631,7 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event, | |||
631 | { | 631 | { |
632 | int power, ret; | 632 | int power, ret; |
633 | 633 | ||
634 | /* Work out the new power state */ | ||
635 | switch (w->id) { | 634 | switch (w->id) { |
636 | case snd_soc_dapm_vmid: | ||
637 | /* No action required */ | ||
638 | return 0; | ||
639 | |||
640 | case snd_soc_dapm_adc: | ||
641 | power = dapm_adc_check_power(w); | ||
642 | break; | ||
643 | |||
644 | case snd_soc_dapm_dac: | ||
645 | power = dapm_dac_check_power(w); | ||
646 | break; | ||
647 | |||
648 | case snd_soc_dapm_pre: | 635 | case snd_soc_dapm_pre: |
649 | if (!w->event) | 636 | if (!w->event) |
650 | return 0; | 637 | return 0; |
@@ -680,10 +667,13 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event, | |||
680 | return 0; | 667 | return 0; |
681 | 668 | ||
682 | default: | 669 | default: |
683 | power = dapm_generic_check_power(w); | ||
684 | break; | 670 | break; |
685 | } | 671 | } |
686 | 672 | ||
673 | if (!w->power_check) | ||
674 | return 0; | ||
675 | |||
676 | power = w->power_check(w); | ||
687 | if (w->power == power) | 677 | if (w->power == power) |
688 | return 0; | 678 | return 0; |
689 | w->power = power; | 679 | w->power = power; |
@@ -1147,15 +1137,22 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec) | |||
1147 | case snd_soc_dapm_switch: | 1137 | case snd_soc_dapm_switch: |
1148 | case snd_soc_dapm_mixer: | 1138 | case snd_soc_dapm_mixer: |
1149 | case snd_soc_dapm_mixer_named_ctl: | 1139 | case snd_soc_dapm_mixer_named_ctl: |
1140 | w->power_check = dapm_generic_check_power; | ||
1150 | dapm_new_mixer(codec, w); | 1141 | dapm_new_mixer(codec, w); |
1151 | break; | 1142 | break; |
1152 | case snd_soc_dapm_mux: | 1143 | case snd_soc_dapm_mux: |
1153 | case snd_soc_dapm_value_mux: | 1144 | case snd_soc_dapm_value_mux: |
1145 | w->power_check = dapm_generic_check_power; | ||
1154 | dapm_new_mux(codec, w); | 1146 | dapm_new_mux(codec, w); |
1155 | break; | 1147 | break; |
1156 | case snd_soc_dapm_adc: | 1148 | case snd_soc_dapm_adc: |
1149 | w->power_check = dapm_adc_check_power; | ||
1150 | break; | ||
1157 | case snd_soc_dapm_dac: | 1151 | case snd_soc_dapm_dac: |
1152 | w->power_check = dapm_dac_check_power; | ||
1153 | break; | ||
1158 | case snd_soc_dapm_pga: | 1154 | case snd_soc_dapm_pga: |
1155 | w->power_check = dapm_generic_check_power; | ||
1159 | dapm_new_pga(codec, w); | 1156 | dapm_new_pga(codec, w); |
1160 | break; | 1157 | break; |
1161 | case snd_soc_dapm_input: | 1158 | case snd_soc_dapm_input: |
@@ -1165,6 +1162,8 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec) | |||
1165 | case snd_soc_dapm_hp: | 1162 | case snd_soc_dapm_hp: |
1166 | case snd_soc_dapm_mic: | 1163 | case snd_soc_dapm_mic: |
1167 | case snd_soc_dapm_line: | 1164 | case snd_soc_dapm_line: |
1165 | w->power_check = dapm_generic_check_power; | ||
1166 | break; | ||
1168 | case snd_soc_dapm_vmid: | 1167 | case snd_soc_dapm_vmid: |
1169 | case snd_soc_dapm_pre: | 1168 | case snd_soc_dapm_pre: |
1170 | case snd_soc_dapm_post: | 1169 | case snd_soc_dapm_post: |