ASoC: dapm: Delay w->power update until the changes are written
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 29 Jul 2013 15:14:03 +0000 (17:14 +0200)
committerMark Brown <broonie@linaro.org>
Mon, 29 Jul 2013 17:41:00 +0000 (18:41 +0100)
Wait with updating the widgets power field until the changes are actually
written to the hardware in dapm_seq_run_coalesced(). This will allow us to query
the current hardware state between calling dapm_power_one_widget() and actually
writing the new power state to hardware.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
sound/soc/soc-dapm.c

index b811a27bf21a67cfdb6e825381a1f41524c0005a..9abb3b21f1fd35a7f59bbbcbb9f10c8112e29f05 100644 (file)
@@ -293,6 +293,7 @@ static void dapm_reset(struct snd_soc_card *card)
        memset(&card->dapm_stats, 0, sizeof(card->dapm_stats));
 
        list_for_each_entry(w, &card->widgets, list) {
+               w->new_power = w->power;
                w->power_checked = false;
                w->inputs = -1;
                w->outputs = -1;
@@ -1340,7 +1341,7 @@ static void dapm_seq_check_event(struct snd_soc_card *card,
                return;
        }
 
-       if (w->power != power)
+       if (w->new_power != power)
                return;
 
        if (w->event && (w->event_flags & event)) {
@@ -1369,6 +1370,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card,
 
        list_for_each_entry(w, pending, power_list) {
                BUG_ON(reg != w->reg);
+               w->power = w->new_power;
 
                mask |= w->mask << w->shift;
                if (w->power)
@@ -1676,8 +1678,6 @@ static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power,
                dapm_seq_insert(w, up_list, true);
        else
                dapm_seq_insert(w, down_list, false);
-
-       w->power = power;
 }
 
 static void dapm_power_one_widget(struct snd_soc_dapm_widget *w,
@@ -1752,7 +1752,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
                        break;
                }
 
-               if (w->power) {
+               if (w->new_power) {
                        d = w->dapm;
 
                        /* Supplies and micbiases only bring the