[alsa-devel] [asoc-dev][RFC/PATCH 0/3] Add digital mic support to TLV320AIC3X and N810
Hi
These patches are built on top of my recent generic register modifier widget patches:
http://mailman.alsa-project.org/pipermail/alsa-devel/2008-June/008778.html
Basically AIC3x will capture data either from its ADC converter or from external digital mic. Therefore I named this input selection in n810.c as "Input Select" == "ADC" | "Digital Mic".
Those two serial data interface control register bits have also other functions and they can be set before aic3x_set_dai_fmt is called.
Signed-off-by: Jarkko Nikula jarkko.nikula@nokia.com --- sound/soc/codecs/tlv320aic3x.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 0c7452f..29dc0ec 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -809,8 +809,10 @@ static int aic3x_set_dai_fmt(struct snd_soc_codec_dai *codec_dai, { struct snd_soc_codec *codec = codec_dai->codec; struct aic3x_priv *aic3x = codec->private_data; - u8 iface_areg = 0; - u8 iface_breg = 0; + u8 iface_areg, iface_breg; + + iface_areg = aic3x_read_reg_cache(codec, AIC3X_ASD_INTF_CTRLA) & 0x3f; + iface_breg = aic3x_read_reg_cache(codec, AIC3X_ASD_INTF_CTRLB) & 0x3f;
/* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
AIC33 and AIC34 codecs in TLV320AIC3x family support digital microphone input. When enabled, the codec ADC takes bitstream input to low-pass filter from GPIO2 instead of its own delta-sigma modulator while providing oversampling clock through GPIO1.
Signed-off-by: Jarkko Nikula jarkko.nikula@nokia.com --- sound/soc/codecs/tlv320aic3x.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 29dc0ec..4f0bf26 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -455,6 +455,27 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { SND_SOC_DAPM_MUX("Right Line2R Mux", SND_SOC_NOPM, 0, 0, &aic3x_right_line2_mux_controls),
+ /* + * Not a real mic bias widget but similar function. This is for dynamic + * control of GPIO1 digital mic modulator clock output function when + * using digital mic. + */ + SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "GPIO1 dmic modclk", + AIC3X_GPIO1_REG, 4, 0xf, + AIC3X_GPIO1_FUNC_DIGITAL_MIC_MODCLK, + AIC3X_GPIO1_FUNC_DISABLED), + + /* + * Also similar function like mic bias. Selects digital mic with + * configurable oversampling rate instead of ADC converter. + */ + SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 128", + AIC3X_ASD_INTF_CTRLA, 0, 3, 1, 0), + SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 64", + AIC3X_ASD_INTF_CTRLA, 0, 3, 2, 0), + SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 32", + AIC3X_ASD_INTF_CTRLA, 0, 3, 3, 0), + /* Mic Bias */ SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "Mic Bias 2V", MICBIAS_CTRL, 6, 3, 1, 0), @@ -570,6 +591,7 @@ static const struct snd_soc_dapm_route intercon[] = { {"Left PGA Mixer", "Mic3L Switch", "MIC3L"},
{"Left ADC", NULL, "Left PGA Mixer"}, + {"Left ADC", NULL, "GPIO1 dmic modclk"},
/* Right Input */ {"Right Line1R Mux", "single-ended", "LINE1R"}, @@ -583,6 +605,7 @@ static const struct snd_soc_dapm_route intercon[] = { {"Right PGA Mixer", "Mic3R Switch", "MIC3R"},
{"Right ADC", NULL, "Right PGA Mixer"}, + {"Right ADC", NULL, "GPIO1 dmic modclk"},
/* Left PGA Bypass */ {"Left PGA Bypass Mixer", "Line Switch", "Left PGA Mixer"}, @@ -643,6 +666,14 @@ static const struct snd_soc_dapm_route intercon[] = { {"Right Line Out", NULL, "Right Line2 Bypass Mixer"}, {"Mono Out", NULL, "Right Line2 Bypass Mixer"}, {"Right HP Out", NULL, "Right Line2 Bypass Mixer"}, + + /* + * Logical path between digital mic enable and GPIO1 modulator clock + * output function + */ + {"GPIO1 dmic modclk", NULL, "DMic Rate 128"}, + {"GPIO1 dmic modclk", NULL, "DMic Rate 64"}, + {"GPIO1 dmic modclk", NULL, "DMic Rate 32"}, };
static int aic3x_add_widgets(struct snd_soc_codec *codec)
Signed-off-by: Jarkko Nikula jarkko.nikula@nokia.com --- sound/soc/omap/n810.c | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index c168a64..767b39f 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -46,11 +46,13 @@ static struct clk *func96m_clk;
static int n810_spk_func; static int n810_jack_func; +static int n810_dmic_func;
static void n810_ext_control(struct snd_soc_codec *codec) { snd_soc_dapm_set_endpoint(codec, "Ext Spk", n810_spk_func); snd_soc_dapm_set_endpoint(codec, "Headphone Jack", n810_jack_func); + snd_soc_dapm_set_endpoint(codec, "DMic", n810_dmic_func);
snd_soc_dapm_sync_endpoints(codec); } @@ -150,6 +152,28 @@ static int n810_set_jack(struct snd_kcontrol *kcontrol, return 1; }
+static int n810_get_input(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = n810_dmic_func; + + return 0; +} + +static int n810_set_input(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + + if (n810_dmic_func == ucontrol->value.integer.value[0]) + return 0; + + n810_dmic_func = ucontrol->value.integer.value[0]; + n810_ext_control(codec); + + return 1; +} + static int n810_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { @@ -175,6 +199,7 @@ static int n810_jack_event(struct snd_soc_dapm_widget *w, static const struct snd_soc_dapm_widget aic33_dapm_widgets[] = { SND_SOC_DAPM_SPK("Ext Spk", n810_spk_event), SND_SOC_DAPM_HP("Headphone Jack", n810_jack_event), + SND_SOC_DAPM_MIC("DMic", NULL), };
static const struct snd_soc_dapm_route audio_map[] = { @@ -183,13 +208,18 @@ static const struct snd_soc_dapm_route audio_map[] = {
{"Ext Spk", NULL, "LLOUT"}, {"Ext Spk", NULL, "RLOUT"}, + + {"DMic Rate 64", NULL, "Mic Bias 2V"}, + {"Mic Bias 2V", NULL, "DMic"}, };
static const char *spk_function[] = {"Off", "On"}; static const char *jack_function[] = {"Off", "Headphone"}; +static const char *input_function[] = {"ADC", "Digital Mic"}; static const struct soc_enum n810_enum[] = { SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(jack_function), jack_function), + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(input_function), input_function), };
static const struct snd_kcontrol_new aic33_n810_controls[] = { @@ -197,6 +227,8 @@ static const struct snd_kcontrol_new aic33_n810_controls[] = { n810_get_spk, n810_set_spk), SOC_ENUM_EXT("Jack Function", n810_enum[1], n810_get_jack, n810_set_jack), + SOC_ENUM_EXT("Input Select", n810_enum[2], + n810_get_input, n810_set_input), };
static int n810_aic33_init(struct snd_soc_codec *codec) @@ -248,6 +280,8 @@ static struct snd_soc_machine snd_soc_machine_n810 = { /* Audio private data */ static struct aic3x_setup_data n810_aic33_setup = { .i2c_address = 0x18, + .gpio_func[0] = AIC3X_GPIO1_FUNC_DISABLED, + .gpio_func[1] = AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT, };
/* Audio subsystem */
On Wed, 2008-06-25 at 14:58 +0300, Jarkko Nikula wrote:
Signed-off-by: Jarkko Nikula jarkko.nikula@nokia.com
sound/soc/omap/n810.c | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-)
All 3 look fine. Thanks.
Signed-off-by: Liam Girdwood lg@opensource.wolfsonmicro.com
participants (2)
-
Jarkko Nikula
-
Liam Girdwood