diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-04-20 11:56:59 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-04-20 13:09:33 -0400 |
commit | cd0f2d4736ae8efabc60e54ecc8f677d0eddce02 (patch) | |
tree | 4f285d995cbb8422edb4b436f3732acfbec49ce7 /sound/soc/soc-dapm.c | |
parent | 9b5b0c01598f9782690b09ce6c49f4ba116dde44 (diff) |
ASoC: Factor out generic widget power checks
This will form a basis for further power check refactoring: the overall
goal of these changes is to allow us to check power separately to
applying it, allowing improvements in the power sequencing algorithms.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r-- | sound/soc/soc-dapm.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index a6d73379ab32..28e6e324ccfb 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -581,6 +581,19 @@ static int dapm_generic_apply_power(struct snd_soc_dapm_widget *w) | |||
581 | return 0; | 581 | return 0; |
582 | } | 582 | } |
583 | 583 | ||
584 | /* Generic check to see if a widget should be powered. | ||
585 | */ | ||
586 | static int dapm_generic_check_power(struct snd_soc_dapm_widget *w) | ||
587 | { | ||
588 | int in, out; | ||
589 | |||
590 | in = is_connected_input_ep(w); | ||
591 | dapm_clear_walk(w->codec); | ||
592 | out = is_connected_output_ep(w); | ||
593 | dapm_clear_walk(w->codec); | ||
594 | return out != 0 && in != 0; | ||
595 | } | ||
596 | |||
584 | /* | 597 | /* |
585 | * Scan a single DAPM widget for a complete audio path and update the | 598 | * Scan a single DAPM widget for a complete audio path and update the |
586 | * power status appropriately. | 599 | * power status appropriately. |
@@ -653,11 +666,7 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event, | |||
653 | } | 666 | } |
654 | 667 | ||
655 | /* all other widgets */ | 668 | /* all other widgets */ |
656 | in = is_connected_input_ep(w); | 669 | power = dapm_generic_check_power(w); |
657 | dapm_clear_walk(w->codec); | ||
658 | out = is_connected_output_ep(w); | ||
659 | dapm_clear_walk(w->codec); | ||
660 | power = (out != 0 && in != 0) ? 1 : 0; | ||
661 | power_change = (w->power == power) ? 0 : 1; | 670 | power_change = (w->power == power) ? 0 : 1; |
662 | w->power = power; | 671 | w->power = power; |
663 | 672 | ||