Generic DAPM register modifier widget
Subsystems (4)
cover Generic DAPM register modifier widget
Hi
At least tlv320aic3x codec has several use cases where multiple register bits are needed to change when widget power state changes and where these are not worth/safe to expose into user space. Like mic bias voltage.
Currently there is one use case for this multiple bit change in tlv320aic3x:
SND_SOC_DAPM_MICBIAS("Mic Bias AVDD", MICBIAS_CTRL, 6, 0), SND_SOC_DAPM_MICBIAS("Mic Bias AVDD", MICBIAS_CTRL, 7, 0),
There are two problems with that:
1. Two widgets having the same name and thus snd_soc_dapm_add_route will add only first one them into audio path
2. Even then bits aren't modified at once and thus some fault bit configuration might be present while power state is changing.
So I came with this idea of generic register modifiers widget and event handler for it.
Signature · 1 line
Jarkko
PATCH 1/2 ASoC: Add support for generic DAPM register modifier widget
This generic register modifier widget is for updating multiple codec register bits at once when the widget changes its power state.
--- include/sound/soc-dapm.h | 14 ++++++++++++++ sound/soc/soc-dapm.c | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-)
include/sound/soc-dapm.h +14 -0
@@ -130,6 +130,13 @@ { .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \ .shift = wshift, .invert = winvert} +/* generic register modifier widget */ +#define SND_SOC_DAPM_REG (wid, wname, wreg, wshift, wmask, won_val, woff_val) \ +{ .id = wid, .name = wname, .kcontrols = NULL, .num_kcontrols = 0, \ + .reg = -((wreg) + 1), .shift = wshift, .mask = wmask, \ + .on_val = won_val, .off_val = woff_val, .event = dapm_reg_event, \ + .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD} +/* dapm kcontrol types */ #define SOC_DAPM_SINGLE (xname, reg, shift, max, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
@@ -227,6 +234,10 @@ int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,/* dapm sys fs - used by the core */ int snd_soc_dapm_sys_add (struct device *dev); +/* event handler for register modifier widget - used by the soc-dapm */ +int dapm_reg_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event); +/* dapm audio endpoint control */ int snd_soc_dapm_set_endpoint (struct snd_soc_codec *codec,char *pin,int status);
@@ -298,6 +309,9 @@ struct snd_soc_dapm_widget {unsigned char shift;/* bits to shift */ unsigned int saved_value;/* widget saved value */ unsigned int value;/* widget current value */ +unsigned int mask;/* non-shifted mask */ +unsigned int on_val;/* on state value */ +unsigned int off_val;/* off state value */ unsigned char power:1; /* block power status */ unsigned char invert:1; /* invert the power bit */ unsigned char active:1; /* active stream on DAC, ADC's */
sound/soc/soc-dapm.c +19 -0
@@ -443,6 +443,25 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget) }/* +* Handler for generic register modifier widget. +*/ +int dapm_reg_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event) +{ +unsigned int val; + +if (SND_SOC_DAPM_EVENT_ON (event)) + val = w->on_val; +else + val = w->off_val; + +snd_soc_update_bits (w->codec, -(w->reg +1 ), + w->mask << w->shift, val << w->shift); + +return 0 ; +} + +/* * Scan each dapm widget for complete audio path. * A complete path is a route that has valid endpoints i.e.:- *
Signature · 1 line
1.5.5.4
Re: [asoc-dev][RFC/PATCH 1/2] ASoC: Add support for generic DAPM register modifier widget
Quoted 4 lines · Jarkko Nikula
This generic register modifier widget is for updating multiple codec register bits at once when the widget changes its power state.
Signed-off-by Jarkko Nikula <[email protected]>
PATCH 2/2 ASoC: TLV320AIC3X: Use register modifier widget for mic bias
In reply to Jarkko Nikula--- sound/soc/codecs/tlv320aic3x.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
sound/soc/codecs/tlv320aic3x.c +6 -4
@@ -456,10 +456,12 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { &aic3x_right_line2_mux_controls),/* Mic Bias */ -SND_SOC_DAPM_MICBIAS ("Mic Bias 2V" ,MICBIAS_CTRL ,6 ,0 ), -SND_SOC_DAPM_MICBIAS ("Mic Bias 2.5V" ,MICBIAS_CTRL ,7 ,0 ), -SND_SOC_DAPM_MICBIAS ("Mic Bias AVDD" ,MICBIAS_CTRL ,6 ,0 ), -SND_SOC_DAPM_MICBIAS ("Mic Bias AVDD" ,MICBIAS_CTRL ,7 ,0 ), +SND_SOC_DAPM_REG (snd_soc_dapm_micbias,"Mic Bias 2V" , +MICBIAS_CTRL ,6 ,3 ,1 ,0 ), +SND_SOC_DAPM_REG (snd_soc_dapm_micbias,"Mic Bias 2.5V" , +MICBIAS_CTRL ,6 ,3 ,2 ,0 ), +SND_SOC_DAPM_REG (snd_soc_dapm_micbias,"Mic Bias AVDD" , +MICBIAS_CTRL ,6 ,3 ,3 ,0 ),/* Left PGA to Left Output bypass */ SND_SOC_DAPM_MIXER("Left PGA Bypass Mixer", SND_SOC_NOPM, 0, 0,
Signature · 1 line
1.5.5.4
Re: [asoc-dev][RFC/PATCH 2/2] ASoC: TLV320AIC3X: Use register modifier widget for mic bias
Quoted 1 line · Jarkko Nikula
Signed-off-by Jarkko Nikula <[email protected]>
Quoted 14 lines · Jarkko Nikula
Hi
At least tlv320aic3x codec has several use cases where multiple register bits are needed to change when widget power state changes and where these are not worth/safe to expose into user space. Like mic bias voltage.
Currently there is one use case for this multiple bit change in tlv320aic3x:
SND_SOC_DAPM_MICBIAS("Mic Bias AVDD", MICBIAS_CTRL, 6, 0),SND_SOC_DAPM_MICBIAS("Mic Bias AVDD", MICBIAS_CTRL, 7, 0),There are two problems with that:
Quoted 8 lines
1. Two widgets having the same name and thus
snd_soc_dapm_add_routewill add only first one them into audio path
2. Even then bits aren't modified at once and thus some fault bit configuration might be present while power state is changing.So I came with this idea of generic register modifiers widget and event handler for it.
Any chance you could also add a little text toDocs/sound/alsa/soc/dapm.txt for this.
Thanks
Liam
Quoted 7 lines · On Wed, 25 Jun 2008 13:01:20 +0100 "ext Liam Girdwood"…
Quoted 3 lines
So I came with this idea of generic register modifiers widget and event handler for it.
Any chance you could also add a little text to
Docs/sound/alsa/soc/dapm.txtfor this.
Documentation? That's difficult and actually forgot it completely :-)
But is it documented already? "There are convience macros defined in soc-dapm.h that can be used to quickly build a list of widgets of the codecs and machines DAPM widgets."
Jarkko
Quoted 7 lines · Jarkko Nikula
Quoted 4 lines · On Wed, 25 Jun 2008 13:01:20 +0100 "ext Liam Girdwood"…
Quoted 3 lines
So I came with this idea of generic register modifiers widget and event handler for it.
Quoted 9 lines
Quoted 3 lines
Any chance you could also add a little text to
Docs/sound/alsa/soc/dapm.txtfor this.Documentation? That's difficult and actually forgot it completely :-)
But is it documented already? "There are convience macros defined in
soc-dapm.hthat can be used to quickly build a list of widgets of the codecs and machines DAPM widgets."
Sorry, just to clarify, I was meaning 1 line in section 2 of dapm.txt (the widget type table). Just a little description next to the others.
Thanks
Liam
Quoted 5 lines · On Wed, 25 Jun 2008 16:40:33 +0100 "ext Liam Girdwood"…
Quoted 5 lines
Quoted 3 lines
Any chance you could also add a little text to
Docs/sound/alsa/soc/dapm.txtfor this.Documentation? That's difficult and actually forgot it completely :-)
Quoted 8 lines
Quoted 4 lines
But is it documented already? "There are convience macros defined in
soc-dapm.hthat can be used to quickly build a list of widgets of the codecs and machines DAPM widgets."Sorry, just to clarify, I was meaning 1 line in section 2 of dapm.txt (the widget type table). Just a little description next to the others.
A diff like below looks bit confusing since the patch itself doesn't add anything new into enum snd_soc_dapm_type. What would you think?
Jarkko
Documentation/sound/alsa/soc/dapm.txt +1 -0
@@ -64,6 +64,7 @@ Audio DAPM widgets fall into a number of types:- o Speaker - Speaker o Pre - Special PRE widget (exec before all others) o Post - Special POST widget (exec after all others) + o Generic - Generic register modifier widget which can have any type above (Widgets are defined in include/sound/soc-dapm.h)