diff options
-rw-r--r-- | sound/soc/soc-dapm.c | 93 |
1 files changed, 3 insertions, 90 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index bbb2135a0b21..611284194000 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -321,54 +321,6 @@ static int dapm_update_bits(struct snd_soc_dapm_widget *widget) | |||
321 | return change; | 321 | return change; |
322 | } | 322 | } |
323 | 323 | ||
324 | /* ramps the volume up or down to minimise pops before or after a | ||
325 | * DAPM power event */ | ||
326 | static int dapm_set_pga(struct snd_soc_dapm_widget *widget, int power) | ||
327 | { | ||
328 | const struct snd_kcontrol_new *k = widget->kcontrols; | ||
329 | |||
330 | if (widget->muted && !power) | ||
331 | return 0; | ||
332 | if (!widget->muted && power) | ||
333 | return 0; | ||
334 | |||
335 | if (widget->num_kcontrols && k) { | ||
336 | struct soc_mixer_control *mc = | ||
337 | (struct soc_mixer_control *)k->private_value; | ||
338 | unsigned int reg = mc->reg; | ||
339 | unsigned int shift = mc->shift; | ||
340 | int max = mc->max; | ||
341 | unsigned int mask = (1 << fls(max)) - 1; | ||
342 | unsigned int invert = mc->invert; | ||
343 | |||
344 | if (power) { | ||
345 | int i; | ||
346 | /* power up has happended, increase volume to last level */ | ||
347 | if (invert) { | ||
348 | for (i = max; i > widget->saved_value; i--) | ||
349 | snd_soc_update_bits(widget->codec, reg, mask, i); | ||
350 | } else { | ||
351 | for (i = 0; i < widget->saved_value; i++) | ||
352 | snd_soc_update_bits(widget->codec, reg, mask, i); | ||
353 | } | ||
354 | widget->muted = 0; | ||
355 | } else { | ||
356 | /* power down is about to occur, decrease volume to mute */ | ||
357 | int val = snd_soc_read(widget->codec, reg); | ||
358 | int i = widget->saved_value = (val >> shift) & mask; | ||
359 | if (invert) { | ||
360 | for (; i < mask; i++) | ||
361 | snd_soc_update_bits(widget->codec, reg, mask, i); | ||
362 | } else { | ||
363 | for (; i > 0; i--) | ||
364 | snd_soc_update_bits(widget->codec, reg, mask, i); | ||
365 | } | ||
366 | widget->muted = 1; | ||
367 | } | ||
368 | } | ||
369 | return 0; | ||
370 | } | ||
371 | |||
372 | /* create new dapm mixer control */ | 324 | /* create new dapm mixer control */ |
373 | static int dapm_new_mixer(struct snd_soc_codec *codec, | 325 | static int dapm_new_mixer(struct snd_soc_codec *codec, |
374 | struct snd_soc_dapm_widget *w) | 326 | struct snd_soc_dapm_widget *w) |
@@ -463,20 +415,10 @@ err: | |||
463 | static int dapm_new_pga(struct snd_soc_codec *codec, | 415 | static int dapm_new_pga(struct snd_soc_codec *codec, |
464 | struct snd_soc_dapm_widget *w) | 416 | struct snd_soc_dapm_widget *w) |
465 | { | 417 | { |
466 | struct snd_kcontrol *kcontrol; | 418 | if (w->num_kcontrols) |
467 | int ret = 0; | 419 | pr_err("asoc: PGA controls not supported: '%s'\n", w->name); |
468 | |||
469 | if (!w->num_kcontrols) | ||
470 | return -EINVAL; | ||
471 | 420 | ||
472 | kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name); | 421 | return 0; |
473 | ret = snd_ctl_add(codec->card, kcontrol); | ||
474 | if (ret < 0) { | ||
475 | printk(KERN_ERR "asoc: failed to add kcontrol %s\n", w->name); | ||
476 | return ret; | ||
477 | } | ||
478 | |||
479 | return ret; | ||
480 | } | 422 | } |
481 | 423 | ||
482 | /* reset 'walked' bit for each dapm path */ | 424 | /* reset 'walked' bit for each dapm path */ |
@@ -632,16 +574,8 @@ static int dapm_generic_apply_power(struct snd_soc_dapm_widget *w) | |||
632 | return ret; | 574 | return ret; |
633 | } | 575 | } |
634 | 576 | ||
635 | /* Lower PGA volume to reduce pops */ | ||
636 | if (w->id == snd_soc_dapm_pga && !w->power) | ||
637 | dapm_set_pga(w, w->power); | ||
638 | |||
639 | dapm_update_bits(w); | 577 | dapm_update_bits(w); |
640 | 578 | ||
641 | /* Raise PGA volume to reduce pops */ | ||
642 | if (w->id == snd_soc_dapm_pga && w->power) | ||
643 | dapm_set_pga(w, w->power); | ||
644 | |||
645 | /* power up post event */ | 579 | /* power up post event */ |
646 | if (w->power && w->event && | 580 | if (w->power && w->event && |
647 | (w->event_flags & SND_SOC_DAPM_POST_PMU)) { | 581 | (w->event_flags & SND_SOC_DAPM_POST_PMU)) { |
@@ -808,10 +742,6 @@ static void dapm_seq_run_coalesced(struct snd_soc_codec *codec, | |||
808 | pr_err("%s: pre event failed: %d\n", | 742 | pr_err("%s: pre event failed: %d\n", |
809 | w->name, ret); | 743 | w->name, ret); |
810 | } | 744 | } |
811 | |||
812 | /* Lower PGA volume to reduce pops */ | ||
813 | if (w->id == snd_soc_dapm_pga && !w->power) | ||
814 | dapm_set_pga(w, w->power); | ||
815 | } | 745 | } |
816 | 746 | ||
817 | if (reg >= 0) { | 747 | if (reg >= 0) { |
@@ -823,10 +753,6 @@ static void dapm_seq_run_coalesced(struct snd_soc_codec *codec, | |||
823 | } | 753 | } |
824 | 754 | ||
825 | list_for_each_entry(w, pending, power_list) { | 755 | list_for_each_entry(w, pending, power_list) { |
826 | /* Raise PGA volume to reduce pops */ | ||
827 | if (w->id == snd_soc_dapm_pga && w->power) | ||
828 | dapm_set_pga(w, w->power); | ||
829 | |||
830 | /* power up post event */ | 756 | /* power up post event */ |
831 | if (w->power && w->event && | 757 | if (w->power && w->event && |
832 | (w->event_flags & SND_SOC_DAPM_POST_PMU)) { | 758 | (w->event_flags & SND_SOC_DAPM_POST_PMU)) { |
@@ -1596,12 +1522,6 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, | |||
1596 | unsigned int invert = mc->invert; | 1522 | unsigned int invert = mc->invert; |
1597 | unsigned int mask = (1 << fls(max)) - 1; | 1523 | unsigned int mask = (1 << fls(max)) - 1; |
1598 | 1524 | ||
1599 | /* return the saved value if we are powered down */ | ||
1600 | if (widget->id == snd_soc_dapm_pga && !widget->power) { | ||
1601 | ucontrol->value.integer.value[0] = widget->saved_value; | ||
1602 | return 0; | ||
1603 | } | ||
1604 | |||
1605 | ucontrol->value.integer.value[0] = | 1525 | ucontrol->value.integer.value[0] = |
1606 | (snd_soc_read(widget->codec, reg) >> shift) & mask; | 1526 | (snd_soc_read(widget->codec, reg) >> shift) & mask; |
1607 | if (shift != rshift) | 1527 | if (shift != rshift) |
@@ -1661,13 +1581,6 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | |||
1661 | mutex_lock(&widget->codec->mutex); | 1581 | mutex_lock(&widget->codec->mutex); |
1662 | widget->value = val; | 1582 | widget->value = val; |
1663 | 1583 | ||
1664 | /* save volume value if the widget is powered down */ | ||
1665 | if (widget->id == snd_soc_dapm_pga && !widget->power) { | ||
1666 | widget->saved_value = val; | ||
1667 | mutex_unlock(&widget->codec->mutex); | ||
1668 | return 1; | ||
1669 | } | ||
1670 | |||
1671 | if (snd_soc_test_bits(widget->codec, reg, val_mask, val)) { | 1584 | if (snd_soc_test_bits(widget->codec, reg, val_mask, val)) { |
1672 | if (val) | 1585 | if (val) |
1673 | /* new connection */ | 1586 | /* new connection */ |