summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2009-04-20 17:56:13 +0100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-04-20 18:09:48 +0100
commitb75576d76d4be50196773f36709cb7a4f5ac2ab7 (patch)
tree10c8c2cafda5bde450a073f8c6bc84a5e798ea80
parent6ea31b9f0a0307e16656af27fcda3160e2a64a1b (diff)
downloadtalos-op-linux-b75576d76d4be50196773f36709cb7a4f5ac2ab7.tar.gz
talos-op-linux-b75576d76d4be50196773f36709cb7a4f5ac2ab7.zip
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>
-rw-r--r--include/sound/soc-dapm.h2
-rw-r--r--sound/soc/soc-dapm.c27
2 files changed, 15 insertions, 14 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index fcc929da0339..839a97b63269 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -367,6 +367,8 @@ struct snd_soc_dapm_widget {
unsigned char suspend:1; /* was active before suspend */
unsigned char pmdown:1; /* waiting for timeout */
+ int (*power_check)(struct snd_soc_dapm_widget *w);
+
/* external events */
unsigned short event_flags; /* flags to specify event types */
int (*event)(struct snd_soc_dapm_widget*, struct snd_kcontrol *, int);
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,
{
int power, ret;
- /* Work out the new power state */
switch (w->id) {
- case snd_soc_dapm_vmid:
- /* No action required */
- return 0;
-
- case snd_soc_dapm_adc:
- power = dapm_adc_check_power(w);
- break;
-
- case snd_soc_dapm_dac:
- power = dapm_dac_check_power(w);
- break;
-
case snd_soc_dapm_pre:
if (!w->event)
return 0;
@@ -680,10 +667,13 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event,
return 0;
default:
- power = dapm_generic_check_power(w);
break;
}
+ if (!w->power_check)
+ return 0;
+
+ power = w->power_check(w);
if (w->power == power)
return 0;
w->power = power;
@@ -1147,15 +1137,22 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
case snd_soc_dapm_switch:
case snd_soc_dapm_mixer:
case snd_soc_dapm_mixer_named_ctl:
+ w->power_check = dapm_generic_check_power;
dapm_new_mixer(codec, w);
break;
case snd_soc_dapm_mux:
case snd_soc_dapm_value_mux:
+ w->power_check = dapm_generic_check_power;
dapm_new_mux(codec, w);
break;
case snd_soc_dapm_adc:
+ w->power_check = dapm_adc_check_power;
+ break;
case snd_soc_dapm_dac:
+ w->power_check = dapm_dac_check_power;
+ break;
case snd_soc_dapm_pga:
+ w->power_check = dapm_generic_check_power;
dapm_new_pga(codec, w);
break;
case snd_soc_dapm_input:
@@ -1165,6 +1162,8 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
case snd_soc_dapm_hp:
case snd_soc_dapm_mic:
case snd_soc_dapm_line:
+ w->power_check = dapm_generic_check_power;
+ break;
case snd_soc_dapm_vmid:
case snd_soc_dapm_pre:
case snd_soc_dapm_post:
OpenPOWER on IntegriCloud