aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-11-03 23:51:49 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-11-11 09:54:15 -0500
commit68f89ad8c233a88b10404c5fd8a1109d12999962 (patch)
treee3dc10bbfc888c1bab9b3695f0476c1463e776fd /sound/soc/soc-dapm.c
parent00fb0d98add90480f60db2d1701ef2bb68a73797 (diff)
ASoC: Factor out boiler plate for DAPM event generation
Make the DAPM sequence execution look a bit nicer by factoring out the code to invoke an event into a single function since it's all the same pretty much. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 450307ccaf68..5a5db3f58f0f 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -726,13 +726,55 @@ static void dapm_seq_insert(struct snd_soc_dapm_widget *new_widget,
726 list_add_tail(&new_widget->power_list, list); 726 list_add_tail(&new_widget->power_list, list);
727} 727}
728 728
729static void dapm_seq_check_event(struct snd_soc_dapm_context *dapm,
730 struct snd_soc_dapm_widget *w, int event)
731{
732 struct snd_soc_card *card = dapm->card;
733 const char *ev_name;
734 int power, ret;
735
736 switch (event) {
737 case SND_SOC_DAPM_PRE_PMU:
738 ev_name = "PRE_PMU";
739 power = 1;
740 break;
741 case SND_SOC_DAPM_POST_PMU:
742 ev_name = "POST_PMU";
743 power = 1;
744 break;
745 case SND_SOC_DAPM_PRE_PMD:
746 ev_name = "PRE_PMD";
747 power = 0;
748 break;
749 case SND_SOC_DAPM_POST_PMD:
750 ev_name = "POST_PMD";
751 power = 0;
752 break;
753 default:
754 BUG();
755 return;
756 }
757
758 if (w->power != power)
759 return;
760
761 if (w->event && (w->event_flags & event)) {
762 pop_dbg(dapm->dev, card->pop_time, "pop test : %s %s\n",
763 w->name, ev_name);
764 ret = w->event(w, NULL, event);
765 if (ret < 0)
766 pr_err("%s: %s event failed: %d\n",
767 ev_name, w->name, ret);
768 }
769}
770
729/* Apply the coalesced changes from a DAPM sequence */ 771/* Apply the coalesced changes from a DAPM sequence */
730static void dapm_seq_run_coalesced(struct snd_soc_dapm_context *dapm, 772static void dapm_seq_run_coalesced(struct snd_soc_dapm_context *dapm,
731 struct list_head *pending) 773 struct list_head *pending)
732{ 774{
733 struct snd_soc_dapm_widget *w;
734 struct snd_soc_card *card = dapm->card; 775 struct snd_soc_card *card = dapm->card;
735 int reg, power, ret; 776 struct snd_soc_dapm_widget *w;
777 int reg, power;
736 unsigned int value = 0; 778 unsigned int value = 0;
737 unsigned int mask = 0; 779 unsigned int mask = 0;
738 unsigned int cur_mask; 780 unsigned int cur_mask;
@@ -757,29 +799,9 @@ static void dapm_seq_run_coalesced(struct snd_soc_dapm_context *dapm,
757 "pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n", 799 "pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n",
758 w->name, reg, value, mask); 800 w->name, reg, value, mask);
759 801
760 /* power up pre event */ 802 /* Check for events */
761 if (w->power && w->event && 803 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_PRE_PMU);
762 (w->event_flags & SND_SOC_DAPM_PRE_PMU)) { 804 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_PRE_PMD);
763 pop_dbg(dapm->dev, card->pop_time,
764 "pop test : %s PRE_PMU\n", w->name);
765 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU);
766 if (ret < 0)
767 dev_err(dapm->dev,
768 "%s: pre event failed: %d\n",
769 w->name, ret);
770 }
771
772 /* power down pre event */
773 if (!w->power && w->event &&
774 (w->event_flags & SND_SOC_DAPM_PRE_PMD)) {
775 pop_dbg(dapm->dev, card->pop_time,
776 "pop test : %s PRE_PMD\n", w->name);
777 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD);
778 if (ret < 0)
779 dev_err(dapm->dev,
780 "%s: pre event failed: %d\n",
781 w->name, ret);
782 }
783 } 805 }
784 806
785 if (reg >= 0) { 807 if (reg >= 0) {
@@ -791,30 +813,8 @@ static void dapm_seq_run_coalesced(struct snd_soc_dapm_context *dapm,
791 } 813 }
792 814
793 list_for_each_entry(w, pending, power_list) { 815 list_for_each_entry(w, pending, power_list) {
794 /* power up post event */ 816 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_POST_PMU);
795 if (w->power && w->event && 817 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_POST_PMD);
796 (w->event_flags & SND_SOC_DAPM_POST_PMU)) {
797 pop_dbg(dapm->dev, card->pop_time,
798 "pop test : %s POST_PMU\n", w->name);
799 ret = w->event(w,
800 NULL, SND_SOC_DAPM_POST_PMU);
801 if (ret < 0)
802 dev_err(dapm->dev,
803 "%s: post event failed: %d\n",
804 w->name, ret);
805 }
806
807 /* power down post event */
808 if (!w->power && w->event &&
809 (w->event_flags & SND_SOC_DAPM_POST_PMD)) {
810 pop_dbg(dapm->dev, card->pop_time,
811 "pop test : %s POST_PMD\n", w->name);
812 ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD);
813 if (ret < 0)
814 dev_err(dapm->dev,
815 "%s: post event failed: %d\n",
816 w->name, ret);
817 }
818 } 818 }
819} 819}
820 820