Skip to contentSkip to conversation

ASoC: Remove unused DAPM_DOUBLE control types

PATCH In review Mark Brown 3 participants 10 messages Dec 14, 2010 – Dec 17, 2010

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/2 ASoC: Remove unused DAPM_DOUBLE control types

There are no users of these and it's not clear what they would do given the mono flow modelling which DAPM does. If need arises we can add them again.

---

May as well do this anyway, regardless of the fate of patch 2/2 but patch 2/2 will remove the implementation of stereo controls so depends on this one.

 include/sound/soc-dapm.h |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)
include/sound/soc-dapm.h +0 -16
index 2f76a51..aef975f 100644
@@ -227,13 +227,6 @@
 	.info = snd_soc_info_volsw, \
 	.get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
 	.private_value =  SOC_SINGLE_VALUE(reg, shift, max, invert) }
-#define SOC_DAPM_DOUBLE(xname, reg, shift_left, shift_right, max, invert, \
-	power) \
-{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
-	.info = snd_soc_info_volsw, \
- 	.get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
- 	.private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\
-		((max) << 16) | ((invert) << 24) }
 #define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
 	.info = snd_soc_info_volsw, \
@@ -241,15 +234,6 @@
 	.tlv.p = (tlv_array), \
 	.get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
 	.private_value =  SOC_SINGLE_VALUE(reg, shift, max, invert) }
-#define SOC_DAPM_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, \
-	power, tlv_array) \
-{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
-	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
-	.tlv.p = (tlv_array), \
-	.info = snd_soc_info_volsw, \
-	.get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
-	.private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\
-		((max) << 16) | ((invert) << 24) }
 #define SOC_DAPM_ENUM(xname, xenum) \
 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
 	.info = snd_soc_info_enum_double, \
Signature · 1 line
1.7.1
author
#1 lore raw

PATCH 2/2 ASoC: Do DAPM control updates in the middle of DAPM sequences

Attempt to minimise audible effects from mixer and mux updates by implementing the actual register changes between powering down widgets that have become unused and powering up widgets that are newly used.

This means that we're making the change with the minimum set of widgets powered, that the input path is connected when we're powering up widgets (so things like DC offset correction can run with their signal active) and that we bring things down to cold before switching away. Since hardware tends to be designed for the power on/off case more than for dynamic reconfiguration this should minimise pops and clicks during reconfiguration while active.

---

Peter, I think this will address your widget reordering issue - I'd appreciate it if you could test and let me know if it helps. If this works it avoids the need for the the widget to know anything about the particular algorithm implemented by DAPM which seems more robust to me.

Sorry about how long it took to get this done.

 include/sound/soc-dapm.h |   10 ++++
 sound/soc/soc-dapm.c     |  130 +++++++++++++++++++++++++--------------------
 2 files changed, 82 insertions(+), 58 deletions(-)
include/sound/soc-dapm.h +10 -0
index aef975f..1490c72 100644
@@ -460,6 +460,14 @@ struct snd_soc_dapm_widget {
 	struct list_head power_list;
 };
 
+struct snd_soc_dapm_update {
+	struct snd_soc_dapm_widget *widget;
+	struct snd_kcontrol *kcontrol;
+	int reg;
+	int mask;
+	int val;
+};
+
 /* DAPM context */
 struct snd_soc_dapm_context {
 	struct list_head widgets;
@@ -469,6 +477,8 @@ struct snd_soc_dapm_context {
 	struct delayed_work delayed_work;
 	unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */
 
+	struct snd_soc_dapm_update *update;
+
 	struct device *dev; /* from parent - for debug */
 	struct snd_soc_codec *codec; /* parent codec */
 	struct snd_soc_card *card; /* parent card */
sound/soc/soc-dapm.c +72 -58

205 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 2/2] ASoC: Do DAPM control updates in the middle of DAPM sequences

Quoted 13 lines · On Tuesday 14 December 2010 19:53:22 ext Mark Brown wrote:

Attempt to minimise audible effects from mixer and mux updates by implementing the actual register changes between powering down widgets that have become unused and powering up widgets that are newly used.

This means that we're making the change with the minimum set of widgets powered, that the input path is connected when we're powering up widgets (so things like DC offset correction can run with their signal active) and that we bring things down to cold before switching away. Since hardware tends to be designed for the power on/off case more than for dynamic reconfiguration this should minimise pops and clicks during reconfiguration while active.

Quoted 8 lines

---

Peter, I think this will address your widget reordering issue - I'd appreciate it if you could test and let me know if it helps. If this works it avoids the need for the the widget to know anything about the particular algorithm implemented by DAPM which seems more robust to me.

Sorry about how long it took to get this done.

I'll try to give this one a try soon, sorry for the delay, but I got sidetracked...

Signature · 1 line
Péter
#3 lore raw

Re: [PATCH 2/2] ASoC: Do DAPM control updates in the middle of DAPM sequences

In reply to Mark Brown

sound/soc/soc-dapm.c int snd_soc_dapm_put_volsw(struct snd_kcontrol · line 1678

Quoted 13 lines · On Tuesday 14 December 2010 19:53:22 ext Mark Brown wrote:
sound/soc/soc-dapm.c +2 -4
@@ -1634,13 +1671,12 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol
 *kcontrol, (struct soc_mixer_control *)kcontrol->private_value; unsigned
 int reg = mc->reg;
        unsigned int shift = mc->shift;
-       unsigned int rshift = mc->rshift;
        int max = mc->max;
        unsigned int mask = (1 << fls(max)) - 1;
        unsigned int invert = mc->invert;
-       unsigned int val, val2, val_mask;
-       int connect;
-       int ret;
+       unsigned int val, val_mask;
+       int connect, change;

You do not need the change variable, since

Quoted 12 lines
sound/soc/soc-dapm.c +1 -4
+       struct snd_soc_dapm_update update;
 
        val = (ucontrol->value.integer.value[0] & mask);
 
@@ -1648,18 +1684,12 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol
 *kcontrol, val = max - val;
        val_mask = mask << shift;
        val = val << shift;
-       if (shift != rshift) {
-               val2 = (ucontrol->value.integer.value[1] & mask);
-               if (invert)
-                       val2 = max - val2;

sound/soc/soc-dapm.c int snd_soc_dapm_put_volsw(struct snd_kcontrol · line 1692

Quoted 10 lines
sound/soc/soc-dapm.c +2 -4
-               val_mask |= mask << rshift;
-               val |= val2 << rshift;
-       }
 
        mutex_lock(&widget->codec->mutex);
        widget->value = val;
 
-       if (snd_soc_test_bits(widget->codec, reg, val_mask, val)) {
+       change = snd_soc_test_bits(widget->codec, reg, val_mask, val);
+       if (change) {

it is used only here, so you could just keep the old if () way.

Quoted 41 lines
sound/soc/soc-dapm.c +9 -14
                if (val)
                        /* new connection */
                        connect = invert ? 0:1;
@@ -1667,28 +1697,20 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol
 *kcontrol, /* old connection must be powered down */
                        connect = invert ? 1:0;
 
+               update.kcontrol = kcontrol;
+               update.widget = widget;
+               update.reg = reg;
+               update.mask = mask;
+               update.val = val;
+               widget->dapm->update = &update;
+
                dapm_mixer_update_power(widget, kcontrol, connect);
+
+               widget->dapm->update = NULL;
        }
 
-       if (widget->event) {
-               if (widget->event_flags & SND_SOC_DAPM_PRE_REG) {
-                       ret = widget->event(widget, kcontrol,
-                                               SND_SOC_DAPM_PRE_REG);
-                       if (ret < 0) {
-                               ret = 1;
-                               goto out;
-                       }
-               }
-               ret = snd_soc_update_bits(widget->codec, reg, val_mask,
 val); -               if (widget->event_flags & SND_SOC_DAPM_POST_REG)
-                       ret = widget->event(widget, kcontrol,
-                                               SND_SOC_DAPM_POST_REG);
-       } else
-               ret = snd_soc_update_bits(widget->codec, reg, val_mask,

val); -

sound/soc/soc-dapm.c +1 -2
-out:
        mutex_unlock(&widget->codec->mutex);
-       return ret;
+       return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);
Signature · 1 line
Péter
#4 lore raw

Re: [PATCH 2/2] ASoC: Do DAPM control updates in the middle of DAPM sequences

In reply to Mark Brown
Quoted 13 lines · On Tuesday 14 December 2010 19:53:22 ext Mark Brown wrote:

Attempt to minimise audible effects from mixer and mux updates by implementing the actual register changes between powering down widgets that have become unused and powering up widgets that are newly used.

This means that we're making the change with the minimum set of widgets powered, that the input path is connected when we're powering up widgets (so things like DC offset correction can run with their signal active) and that we bring things down to cold before switching away. Since hardware tends to be designed for the power on/off case more than for dynamic reconfiguration this should minimise pops and clicks during reconfiguration while active.

Quoted 8 lines

---

Peter, I think this will address your widget reordering issue - I'd appreciate it if you could test and let me know if it helps. If this works it avoids the need for the the widget to know anything about the particular algorithm implemented by DAPM which seems more robust to me.

Sorry about how long it took to get this done.

Well, it is good, and bad.
It behaves mostly OK, but there's a strange side effect:
I noticed a pop on playback stream start on the twl4030 codec.
I'll look into it, but I do not see how this patch can affect the stream start.. Could you hold this patch for some time, so I can look at this?

Thanks,
Péter

author
#5 lore raw

Re: [PATCH 2/2] ASoC: Do DAPM control updates in the middle of DAPM sequences

Quoted 3 lines · Peter Ujfalusi

It behaves mostly OK, but there's a strange side effect:
I noticed a pop on playback stream start on the twl4030 codec.
I'll look into it, but I do not see how this patch can affect the stream start..

Indeed, it should result in an extra comparison in the middle of the DAPM sequence which oughtn't to have any effect here. Is it possible that some of the other updates that have been going in recently such as the cross-device changes introduced this, or is it definitely just this one patch?

Quoted 1 line

Could you hold this patch for some time, so I can look at this?

Sure.

Acked-by Tested-by
#6 lore raw

Re: [PATCH 2/2] ASoC: Do DAPM control updates in the middle of DAPM sequences

Quoted 11 lines · On Thursday 16 December 2010 15:55:05 ext Mark Brown wrote:
Quoted 4 lines · Peter Ujfalusi

It behaves mostly OK, but there's a strange side effect:
I noticed a pop on playback stream start on the twl4030 codec. I'll look into it, but I do not see how this patch can affect the stream start..

Indeed, it should result in an extra comparison in the middle of the DAPM sequence which oughtn't to have any effect here. Is it possible that some of the other updates that have been going in recently such as the cross-device changes introduced this, or is it definitely just this one patch?

Found the reason..
The pop is there without this patch, it is coming from the output amp power up. In normal use case, it is filtered by the external amp, but I use non convetional setup at the moment, and that is the reason for the pop. I need to take a look at this at some time :(

Quoted 3 lines
Quoted 1 line

Could you hold this patch for some time, so I can look at this?

Sure.

Thanks,
You can pick either of my:

author
#7 lore raw

Re: [PATCH 2/2] ASoC: Do DAPM control updates in the middle of DAPM sequences

Quoted 3 lines · Peter Ujfalusi

In normal use case, it is filtered by the external amp, but I use non convetional setup at the moment, and that is the reason for the pop. I need to take a look at this at some time :(

Ah, well. At least the mux issue should be fixed now.

Quoted 4 lines

You can pick either of my:

Why choose? :)

author
#9 lore raw
Quoted 10 lines · Liam Girdwood
Quoted 5 lines · Mark Brown

There are no users of these and it's not clear what they would do given the mono flow modelling which DAPM does. If need arises we can add them again.

All

I've pushed the first patch out now but I'll wait for Peter's testing before doing anything with the second one.