]> rtime.felk.cvut.cz Git - lisovros/linux_canprio.git/commitdiff
ASoC: TWL4030: Add configurable delay after digimic enable
authorPeter Ujfalusi <peter.ujfalusi@nokia.com>
Tue, 20 Jul 2010 12:49:09 +0000 (15:49 +0300)
committerLiam Girdwood <lrg@slimlogic.co.uk>
Wed, 21 Jul 2010 10:57:58 +0000 (11:57 +0100)
When digital microphones are connected to twl, delay is
needed after enabling the digimic interface of the codec.
Add new parameter for the setup data, which can be used
to pass the apropriate delay in ms after the digimic
interface has been enabled.

Without certain delay (in certain HW configuration) the
beggining of the recorded sample contains a glitch, which
is generated by the digital microphones.

Delaying the micbias1, 2 (which is the bias for the digimic0
or 1) does not help, since the glitch is coming after
switching the digimic interface.

Reversing the micbias and digimic enable order does not
work either (in that case the wait need to be added after
the micbias enabled).

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
sound/soc/codecs/twl4030.c
sound/soc/codecs/twl4030.h

index 6fd6d0b1055504507cc15141a744e2fdb4c3afbd..bd557c2bcb8c0b74c8569f35fa494915716ac8d6 100644 (file)
@@ -143,6 +143,9 @@ struct twl4030_priv {
        u8 earpiece_enabled;
        u8 predrivel_enabled, predriver_enabled;
        u8 carkitl_enabled, carkitr_enabled;
+
+       /* Delay needed after enabling the digimic interface */
+       unsigned int digimic_delay;
 };
 
 /*
@@ -312,6 +315,8 @@ static void twl4030_init_chip(struct platform_device *pdev)
        if (!setup)
                return;
 
+       twl4030->digimic_delay = setup->digimic_delay;
+
        /* Configuration for headset ramp delay from setup data */
        if (setup->sysclk != twl4030->sysclk)
                dev_warn(codec->dev,
@@ -855,6 +860,16 @@ static int headsetrpga_event(struct snd_soc_dapm_widget *w,
        return 0;
 }
 
+static int digimic_event(struct snd_soc_dapm_widget *w,
+               struct snd_kcontrol *kcontrol, int event)
+{
+       struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec);
+
+       if (twl4030->digimic_delay)
+               mdelay(twl4030->digimic_delay);
+       return 0;
+}
+
 /*
  * Some of the gain controls in TWL (mostly those which are associated with
  * the outputs) are implemented in an interesting way:
@@ -1439,10 +1454,12 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
        SND_SOC_DAPM_PGA("ADC Physical Right",
                TWL4030_REG_AVADC_CTL, 1, 0, NULL, 0),
 
-       SND_SOC_DAPM_PGA("Digimic0 Enable",
-               TWL4030_REG_ADCMICSEL, 1, 0, NULL, 0),
-       SND_SOC_DAPM_PGA("Digimic1 Enable",
-               TWL4030_REG_ADCMICSEL, 3, 0, NULL, 0),
+       SND_SOC_DAPM_PGA_E("Digimic0 Enable",
+               TWL4030_REG_ADCMICSEL, 1, 0, NULL, 0,
+               digimic_event, SND_SOC_DAPM_POST_PMU),
+       SND_SOC_DAPM_PGA_E("Digimic1 Enable",
+               TWL4030_REG_ADCMICSEL, 3, 0, NULL, 0,
+               digimic_event, SND_SOC_DAPM_POST_PMU),
 
        SND_SOC_DAPM_MICBIAS("Mic Bias 1", TWL4030_REG_MICBIAS_CTL, 0, 0),
        SND_SOC_DAPM_MICBIAS("Mic Bias 2", TWL4030_REG_MICBIAS_CTL, 1, 0),
index 788e3d12509906379773caab25873b598853ff16..6c57430f6e2440c2e94e8c6cd8ae5ecd16fbbc5b 100644 (file)
@@ -41,6 +41,7 @@ extern struct snd_soc_codec_device soc_codec_dev_twl4030;
 
 struct twl4030_setup_data {
        unsigned int ramp_delay_value;
+       unsigned int digimic_delay; /* in ms */
        unsigned int sysclk;
        unsigned int offset_cncl_path;
        unsigned int check_defaults:1;