aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/soc-dapm.c110
1 files changed, 60 insertions, 50 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 46485de9e6f8..713d12586705 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -522,6 +522,65 @@ int dapm_reg_event(struct snd_soc_dapm_widget *w,
522} 522}
523EXPORT_SYMBOL_GPL(dapm_reg_event); 523EXPORT_SYMBOL_GPL(dapm_reg_event);
524 524
525/* Standard power change method, used to apply power changes to most
526 * widgets.
527 */
528static int dapm_generic_apply_power(struct snd_soc_dapm_widget *w)
529{
530 int ret;
531
532 /* call any power change event handlers */
533 if (w->event)
534 pr_debug("power %s event for %s flags %x\n",
535 w->power ? "on" : "off",
536 w->name, w->event_flags);
537
538 /* power up pre event */
539 if (w->power && w->event &&
540 (w->event_flags & SND_SOC_DAPM_PRE_PMU)) {
541 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU);
542 if (ret < 0)
543 return ret;
544 }
545
546 /* power down pre event */
547 if (!w->power && w->event &&
548 (w->event_flags & SND_SOC_DAPM_PRE_PMD)) {
549 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD);
550 if (ret < 0)
551 return ret;
552 }
553
554 /* Lower PGA volume to reduce pops */
555 if (w->id == snd_soc_dapm_pga && !w->power)
556 dapm_set_pga(w, w->power);
557
558 dapm_update_bits(w);
559
560 /* Raise PGA volume to reduce pops */
561 if (w->id == snd_soc_dapm_pga && w->power)
562 dapm_set_pga(w, w->power);
563
564 /* power up post event */
565 if (w->power && w->event &&
566 (w->event_flags & SND_SOC_DAPM_POST_PMU)) {
567 ret = w->event(w,
568 NULL, SND_SOC_DAPM_POST_PMU);
569 if (ret < 0)
570 return ret;
571 }
572
573 /* power down post event */
574 if (!w->power && w->event &&
575 (w->event_flags & SND_SOC_DAPM_POST_PMD)) {
576 ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD);
577 if (ret < 0)
578 return ret;
579 }
580
581 return 0;
582}
583
525/* 584/*
526 * Scan a single DAPM widget for a complete audio path and update the 585 * Scan a single DAPM widget for a complete audio path and update the
527 * power status appropriately. 586 * power status appropriately.
@@ -601,56 +660,7 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event,
601 if (!power_change) 660 if (!power_change)
602 return 0; 661 return 0;
603 662
604 /* call any power change event handlers */ 663 return dapm_generic_apply_power(w);
605 if (w->event)
606 pr_debug("power %s event for %s flags %x\n",
607 w->power ? "on" : "off",
608 w->name, w->event_flags);
609
610 /* power up pre event */
611 if (power && w->event &&
612 (w->event_flags & SND_SOC_DAPM_PRE_PMU)) {
613 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU);
614 if (ret < 0)
615 return ret;
616 }
617
618 /* power down pre event */
619 if (!power && w->event &&
620 (w->event_flags & SND_SOC_DAPM_PRE_PMD)) {
621 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD);
622 if (ret < 0)
623 return ret;
624 }
625
626 /* Lower PGA volume to reduce pops */
627 if (w->id == snd_soc_dapm_pga && !power)
628 dapm_set_pga(w, power);
629
630 dapm_update_bits(w);
631
632 /* Raise PGA volume to reduce pops */
633 if (w->id == snd_soc_dapm_pga && power)
634 dapm_set_pga(w, power);
635
636 /* power up post event */
637 if (power && w->event &&
638 (w->event_flags & SND_SOC_DAPM_POST_PMU)) {
639 ret = w->event(w,
640 NULL, SND_SOC_DAPM_POST_PMU);
641 if (ret < 0)
642 return ret;
643 }
644
645 /* power down post event */
646 if (!power && w->event &&
647 (w->event_flags & SND_SOC_DAPM_POST_PMD)) {
648 ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD);
649 if (ret < 0)
650 return ret;
651 }
652
653 return 0;
654} 664}
655 665
656/* 666/*