aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-07-27 17:11:53 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-27 17:11:53 -0400
commiteb703027ac4ed563823e4d7824f68afed637d89a (patch)
treede35552440e7d2c7b74d0020c6a3cc1a8ed8b060 /sound/soc/soc-dapm.c
parent429e90893c9ad2c266d541c94d6ca69a34a7701d (diff)
parent837b41b5de356aa67abb2cadb5eef3efc7776f91 (diff)
Merge ../linux-2.6
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c105
1 files changed, 49 insertions, 56 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 2c87061c2a6b..820347c9ae4b 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -523,24 +523,6 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
523 continue; 523 continue;
524 } 524 }
525 525
526 /* programmable gain/attenuation */
527 if (w->id == snd_soc_dapm_pga) {
528 int on;
529 in = is_connected_input_ep(w);
530 dapm_clear_walk(w->codec);
531 out = is_connected_output_ep(w);
532 dapm_clear_walk(w->codec);
533 w->power = on = (out != 0 && in != 0) ? 1 : 0;
534
535 if (!on)
536 dapm_set_pga(w, on); /* lower volume to reduce pops */
537 dapm_update_bits(w);
538 if (on)
539 dapm_set_pga(w, on); /* restore volume from zero */
540
541 continue;
542 }
543
544 /* pre and post event widgets */ 526 /* pre and post event widgets */
545 if (w->id == snd_soc_dapm_pre) { 527 if (w->id == snd_soc_dapm_pre) {
546 if (!w->event) 528 if (!w->event)
@@ -586,45 +568,56 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
586 power_change = (w->power == power) ? 0: 1; 568 power_change = (w->power == power) ? 0: 1;
587 w->power = power; 569 w->power = power;
588 570
571 if (!power_change)
572 continue;
573
589 /* call any power change event handlers */ 574 /* call any power change event handlers */
590 if (power_change) { 575 if (w->event)
591 if (w->event) { 576 pr_debug("power %s event for %s flags %x\n",
592 pr_debug("power %s event for %s flags %x\n", 577 w->power ? "on" : "off",
593 w->power ? "on" : "off", w->name, w->event_flags); 578 w->name, w->event_flags);
594 if (power) { 579
595 /* power up event */ 580 /* power up pre event */
596 if (w->event_flags & SND_SOC_DAPM_PRE_PMU) { 581 if (power && w->event &&
597 ret = w->event(w, 582 (w->event_flags & SND_SOC_DAPM_PRE_PMU)) {
598 NULL, SND_SOC_DAPM_PRE_PMU); 583 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU);
599 if (ret < 0) 584 if (ret < 0)
600 return ret; 585 return ret;
601 } 586 }
602 dapm_update_bits(w); 587
603 if (w->event_flags & SND_SOC_DAPM_POST_PMU){ 588 /* power down pre event */
604 ret = w->event(w, 589 if (!power && w->event &&
605 NULL, SND_SOC_DAPM_POST_PMU); 590 (w->event_flags & SND_SOC_DAPM_PRE_PMD)) {
606 if (ret < 0) 591 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD);
607 return ret; 592 if (ret < 0)
608 } 593 return ret;
609 } else { 594 }
610 /* power down event */ 595
611 if (w->event_flags & SND_SOC_DAPM_PRE_PMD) { 596 /* Lower PGA volume to reduce pops */
612 ret = w->event(w, 597 if (w->id == snd_soc_dapm_pga && !power)
613 NULL, SND_SOC_DAPM_PRE_PMD); 598 dapm_set_pga(w, power);
614 if (ret < 0) 599
615 return ret; 600 dapm_update_bits(w);
616 } 601
617 dapm_update_bits(w); 602 /* Raise PGA volume to reduce pops */
618 if (w->event_flags & SND_SOC_DAPM_POST_PMD) { 603 if (w->id == snd_soc_dapm_pga && power)
619 ret = w->event(w, 604 dapm_set_pga(w, power);
620 NULL, SND_SOC_DAPM_POST_PMD); 605
621 if (ret < 0) 606 /* power up post event */
622 return ret; 607 if (power && w->event &&
623 } 608 (w->event_flags & SND_SOC_DAPM_POST_PMU)) {
624 } 609 ret = w->event(w,
625 } else 610 NULL, SND_SOC_DAPM_POST_PMU);
626 /* no event handler */ 611 if (ret < 0)
627 dapm_update_bits(w); 612 return ret;
613 }
614
615 /* power down post event */
616 if (!power && w->event &&
617 (w->event_flags & SND_SOC_DAPM_POST_PMD)) {
618 ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD);
619 if (ret < 0)
620 return ret;
628 } 621 }
629 } 622 }
630 } 623 }