* [asoc-dev][RFC/PATCH 1/2] ASoC: Add support for generic DAPM register modifier widget
2008-06-25 11:42 [asoc-dev][RFC/PATCH 0/2] Generic DAPM register modifier widget Jarkko Nikula
@ 2008-06-25 11:42 ` Jarkko Nikula
2008-06-25 11:59 ` Liam Girdwood
2008-06-25 11:42 ` [asoc-dev][RFC/PATCH 2/2] ASoC: TLV320AIC3X: Use register modifier widget for mic bias Jarkko Nikula
2008-06-25 12:01 ` [asoc-dev][RFC/PATCH 0/2] Generic DAPM register modifier widget Liam Girdwood
2 siblings, 1 reply; 9+ messages in thread
From: Jarkko Nikula @ 2008-06-25 11:42 UTC (permalink / raw)
To: alsa-devel; +Cc: 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 <jarkko.nikula@nokia.com>
---
include/sound/soc-dapm.h | 14 ++++++++++++++
sound/soc/soc-dapm.c | 19 +++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index f8223fa..b284953 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -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 */
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 728f3ac..2536382 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -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.:-
*
--
1.5.5.4
^ permalink raw reply related [flat|nested] 9+ messages in thread* [asoc-dev][RFC/PATCH 2/2] ASoC: TLV320AIC3X: Use register modifier widget for mic bias
2008-06-25 11:42 [asoc-dev][RFC/PATCH 0/2] Generic DAPM register modifier widget Jarkko Nikula
2008-06-25 11:42 ` [asoc-dev][RFC/PATCH 1/2] ASoC: Add support for generic " Jarkko Nikula
@ 2008-06-25 11:42 ` Jarkko Nikula
2008-06-25 12:00 ` Liam Girdwood
2008-06-25 12:01 ` [asoc-dev][RFC/PATCH 0/2] Generic DAPM register modifier widget Liam Girdwood
2 siblings, 1 reply; 9+ messages in thread
From: Jarkko Nikula @ 2008-06-25 11:42 UTC (permalink / raw)
To: alsa-devel; +Cc: Jarkko Nikula
Signed-off-by: Jarkko Nikula <jarkko.nikula@nokia.com>
---
sound/soc/codecs/tlv320aic3x.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 528c26a..0c7452f 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -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,
--
1.5.5.4
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [asoc-dev][RFC/PATCH 0/2] Generic DAPM register modifier widget
2008-06-25 11:42 [asoc-dev][RFC/PATCH 0/2] Generic DAPM register modifier widget Jarkko Nikula
2008-06-25 11:42 ` [asoc-dev][RFC/PATCH 1/2] ASoC: Add support for generic " Jarkko Nikula
2008-06-25 11:42 ` [asoc-dev][RFC/PATCH 2/2] ASoC: TLV320AIC3X: Use register modifier widget for mic bias Jarkko Nikula
@ 2008-06-25 12:01 ` Liam Girdwood
2008-06-25 12:15 ` Jarkko Nikula
2 siblings, 1 reply; 9+ messages in thread
From: Liam Girdwood @ 2008-06-25 12:01 UTC (permalink / raw)
To: Jarkko Nikula; +Cc: alsa-devel
On Wed, 2008-06-25 at 14:42 +0300, Jarkko Nikula wrote:
> 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.
>
Any chance you could also add a little text to
Docs/sound/alsa/soc/dapm.txt for this.
Thanks
Liam
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [asoc-dev][RFC/PATCH 0/2] Generic DAPM register modifier widget
2008-06-25 12:01 ` [asoc-dev][RFC/PATCH 0/2] Generic DAPM register modifier widget Liam Girdwood
@ 2008-06-25 12:15 ` Jarkko Nikula
2008-06-25 15:40 ` Liam Girdwood
0 siblings, 1 reply; 9+ messages in thread
From: Jarkko Nikula @ 2008-06-25 12:15 UTC (permalink / raw)
To: ext Liam Girdwood; +Cc: alsa-devel
On Wed, 25 Jun 2008 13:01:20 +0100
"ext Liam Girdwood" <lg@opensource.wolfsonmicro.com> wrote:
> > 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.txt for 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [asoc-dev][RFC/PATCH 0/2] Generic DAPM register modifier widget
2008-06-25 12:15 ` Jarkko Nikula
@ 2008-06-25 15:40 ` Liam Girdwood
2008-06-26 10:11 ` Jarkko Nikula
0 siblings, 1 reply; 9+ messages in thread
From: Liam Girdwood @ 2008-06-25 15:40 UTC (permalink / raw)
To: Jarkko Nikula; +Cc: alsa-devel
On Wed, 2008-06-25 at 15:15 +0300, Jarkko Nikula wrote:
> On Wed, 25 Jun 2008 13:01:20 +0100
> "ext Liam Girdwood" <lg@opensource.wolfsonmicro.com> wrote:
>
> > > 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.txt for 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."
>
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [asoc-dev][RFC/PATCH 0/2] Generic DAPM register modifier widget
2008-06-25 15:40 ` Liam Girdwood
@ 2008-06-26 10:11 ` Jarkko Nikula
0 siblings, 0 replies; 9+ messages in thread
From: Jarkko Nikula @ 2008-06-26 10:11 UTC (permalink / raw)
To: ext Liam Girdwood; +Cc: alsa-devel
On Wed, 25 Jun 2008 16:40:33 +0100
"ext Liam Girdwood" <lg@opensource.wolfsonmicro.com> wrote:
> > > Any chance you could also add a little text to
> > > Docs/sound/alsa/soc/dapm.txt for 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."
> >
>
> 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
diff --git a/Documentation/sound/alsa/soc/dapm.txt b/Documentation/sound/alsa/soc/dapm.txt
index c784a18..d621b50 100644
--- a/Documentation/sound/alsa/soc/dapm.txt
+++ b/Documentation/sound/alsa/soc/dapm.txt
@@ -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)
^ permalink raw reply related [flat|nested] 9+ messages in thread