aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Thomson <Adam.Thomson.Opensource@diasemi.com>2018-08-09 05:48:50 -0400
committerMark Brown <broonie@kernel.org>2018-08-09 05:50:14 -0400
commit17c81d2f5a59929c73a2a19fd49fe0b068fda76f (patch)
tree42a72072724fdff4078625498d3e7933b2448aff
parent605391d0f4bfdff2f2c6c5477ce0ccf776d8d5c0 (diff)
ASoC: da7219: Add delays to capture path to remove DC offset noise
On some platforms it has been noted that a pop noise can be witnessed when capturing audio, mainly for first time after a headset jack has been inserted. This is due to a DC offset in the Mic PGA and so to avoid this delays are required when powering up the capture path. This commit rectifies the problem by adding delays post Mic PGA and post Mixin PGA. The post Mic PGA delay is determined based on Mic Bias voltage, and is only applied the first time after a headset jack is inserted. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/da7219-aad.c5
-rw-r--r--sound/soc/codecs/da7219.c44
-rw-r--r--sound/soc/codecs/da7219.h8
3 files changed, 49 insertions, 8 deletions
diff --git a/sound/soc/codecs/da7219-aad.c b/sound/soc/codecs/da7219-aad.c
index a49ab751a036..2c7d5088e6f2 100644
--- a/sound/soc/codecs/da7219-aad.c
+++ b/sound/soc/codecs/da7219-aad.c
@@ -59,6 +59,7 @@ static void da7219_aad_btn_det_work(struct work_struct *work)
59 container_of(work, struct da7219_aad_priv, btn_det_work); 59 container_of(work, struct da7219_aad_priv, btn_det_work);
60 struct snd_soc_component *component = da7219_aad->component; 60 struct snd_soc_component *component = da7219_aad->component;
61 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); 61 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
62 struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
62 u8 statusa, micbias_ctrl; 63 u8 statusa, micbias_ctrl;
63 bool micbias_up = false; 64 bool micbias_up = false;
64 int retries = 0; 65 int retries = 0;
@@ -86,6 +87,8 @@ static void da7219_aad_btn_det_work(struct work_struct *work)
86 if (retries >= DA7219_AAD_MICBIAS_CHK_RETRIES) 87 if (retries >= DA7219_AAD_MICBIAS_CHK_RETRIES)
87 dev_warn(component->dev, "Mic bias status check timed out"); 88 dev_warn(component->dev, "Mic bias status check timed out");
88 89
90 da7219->micbias_on_event = true;
91
89 /* 92 /*
90 * Mic bias pulse required to enable mic, must be done before enabling 93 * Mic bias pulse required to enable mic, must be done before enabling
91 * button detection to prevent erroneous button readings. 94 * button detection to prevent erroneous button readings.
@@ -439,6 +442,8 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data)
439 snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, 442 snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1,
440 DA7219_BUTTON_CONFIG_MASK, 0); 443 DA7219_BUTTON_CONFIG_MASK, 0);
441 444
445 da7219->micbias_on_event = false;
446
442 /* Disable mic bias */ 447 /* Disable mic bias */
443 snd_soc_dapm_disable_pin(dapm, "Mic Bias"); 448 snd_soc_dapm_disable_pin(dapm, "Mic Bias");
444 snd_soc_dapm_sync(dapm); 449 snd_soc_dapm_sync(dapm);
diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c
index c0144f2f8174..e46e9f4bc994 100644
--- a/sound/soc/codecs/da7219.c
+++ b/sound/soc/codecs/da7219.c
@@ -768,6 +768,30 @@ static const struct snd_kcontrol_new da7219_st_out_filtr_mix_controls[] = {
768 * DAPM Events 768 * DAPM Events
769 */ 769 */
770 770
771static int da7219_mic_pga_event(struct snd_soc_dapm_widget *w,
772 struct snd_kcontrol *kcontrol, int event)
773{
774 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
775 struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
776
777 switch (event) {
778 case SND_SOC_DAPM_POST_PMU:
779 if (da7219->micbias_on_event) {
780 /*
781 * Delay only for first capture after bias enabled to
782 * avoid possible DC offset related noise.
783 */
784 da7219->micbias_on_event = false;
785 msleep(da7219->mic_pga_delay);
786 }
787 break;
788 default:
789 break;
790 }
791
792 return 0;
793}
794
771static int da7219_dai_event(struct snd_soc_dapm_widget *w, 795static int da7219_dai_event(struct snd_soc_dapm_widget *w,
772 struct snd_kcontrol *kcontrol, int event) 796 struct snd_kcontrol *kcontrol, int event)
773{ 797{
@@ -937,12 +961,12 @@ static const struct snd_soc_dapm_widget da7219_dapm_widgets[] = {
937 SND_SOC_DAPM_INPUT("MIC"), 961 SND_SOC_DAPM_INPUT("MIC"),
938 962
939 /* Input PGAs */ 963 /* Input PGAs */
940 SND_SOC_DAPM_PGA("Mic PGA", DA7219_MIC_1_CTRL, 964 SND_SOC_DAPM_PGA_E("Mic PGA", DA7219_MIC_1_CTRL,
941 DA7219_MIC_1_AMP_EN_SHIFT, DA7219_NO_INVERT, 965 DA7219_MIC_1_AMP_EN_SHIFT, DA7219_NO_INVERT,
942 NULL, 0), 966 NULL, 0, da7219_mic_pga_event, SND_SOC_DAPM_POST_PMU),
943 SND_SOC_DAPM_PGA("Mixin PGA", DA7219_MIXIN_L_CTRL, 967 SND_SOC_DAPM_PGA_E("Mixin PGA", DA7219_MIXIN_L_CTRL,
944 DA7219_MIXIN_L_AMP_EN_SHIFT, DA7219_NO_INVERT, 968 DA7219_MIXIN_L_AMP_EN_SHIFT, DA7219_NO_INVERT,
945 NULL, 0), 969 NULL, 0, da7219_settling_event, SND_SOC_DAPM_POST_PMU),
946 970
947 /* Input Filters */ 971 /* Input Filters */
948 SND_SOC_DAPM_ADC("ADC", NULL, DA7219_ADC_L_CTRL, DA7219_ADC_L_EN_SHIFT, 972 SND_SOC_DAPM_ADC("ADC", NULL, DA7219_ADC_L_CTRL, DA7219_ADC_L_EN_SHIFT,
@@ -1847,6 +1871,14 @@ static void da7219_handle_pdata(struct snd_soc_component *component)
1847 1871
1848 snd_soc_component_write(component, DA7219_MICBIAS_CTRL, micbias_lvl); 1872 snd_soc_component_write(component, DA7219_MICBIAS_CTRL, micbias_lvl);
1849 1873
1874 /*
1875 * Calculate delay required to compensate for DC offset in
1876 * Mic PGA, based on Mic Bias voltage.
1877 */
1878 da7219->mic_pga_delay = DA7219_MIC_PGA_BASE_DELAY +
1879 (pdata->micbias_lvl *
1880 DA7219_MIC_PGA_OFFSET_DELAY);
1881
1850 /* Mic */ 1882 /* Mic */
1851 switch (pdata->mic_amp_in_sel) { 1883 switch (pdata->mic_amp_in_sel) {
1852 case DA7219_MIC_AMP_IN_SEL_DIFF: 1884 case DA7219_MIC_AMP_IN_SEL_DIFF:
diff --git a/sound/soc/codecs/da7219.h b/sound/soc/codecs/da7219.h
index 1b00023e33cd..3a006862f0e7 100644
--- a/sound/soc/codecs/da7219.h
+++ b/sound/soc/codecs/da7219.h
@@ -781,8 +781,10 @@
781#define DA7219_SYS_STAT_CHECK_DELAY 50 781#define DA7219_SYS_STAT_CHECK_DELAY 50
782 782
783/* Power up/down Delays */ 783/* Power up/down Delays */
784#define DA7219_SETTLING_DELAY 40 784#define DA7219_SETTLING_DELAY 40
785#define DA7219_MIN_GAIN_DELAY 30 785#define DA7219_MIN_GAIN_DELAY 30
786#define DA7219_MIC_PGA_BASE_DELAY 100
787#define DA7219_MIC_PGA_OFFSET_DELAY 40
786 788
787enum da7219_clk_src { 789enum da7219_clk_src {
788 DA7219_CLKSRC_MCLK = 0, 790 DA7219_CLKSRC_MCLK = 0,
@@ -828,6 +830,8 @@ struct da7219_priv {
828 830
829 bool master; 831 bool master;
830 bool alc_en; 832 bool alc_en;
833 bool micbias_on_event;
834 unsigned int mic_pga_delay;
831 u8 gain_ramp_ctrl; 835 u8 gain_ramp_ctrl;
832}; 836};
833 837