Skip to content

Commit

Permalink
ASoC: nau8821: Add delay control for ADC
Browse files Browse the repository at this point in the history
Change the original fixed delay to the assignment from the property.
It will make it more flexible to different platforms to avoid pop
noise at the beginning of recording.

Signed-off-by: Seven Lee <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
LeeWeiTse-seven authored and broonie committed Apr 21, 2024
1 parent 467d252 commit b37fdd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions sound/soc/codecs/nau8821.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ static int nau8821_left_adc_event(struct snd_soc_dapm_widget *w,

switch (event) {
case SND_SOC_DAPM_POST_PMU:
msleep(125);
msleep(nau8821->adc_delay);
regmap_update_bits(nau8821->regmap, NAU8821_R01_ENA_CTRL,
NAU8821_EN_ADCL, NAU8821_EN_ADCL);
break;
Expand All @@ -535,7 +535,7 @@ static int nau8821_right_adc_event(struct snd_soc_dapm_widget *w,

switch (event) {
case SND_SOC_DAPM_POST_PMU:
msleep(125);
msleep(nau8821->adc_delay);
regmap_update_bits(nau8821->regmap, NAU8821_R01_ENA_CTRL,
NAU8821_EN_ADCR, NAU8821_EN_ADCR);
break;
Expand Down Expand Up @@ -1697,6 +1697,7 @@ static void nau8821_print_device_properties(struct nau8821 *nau8821)
dev_dbg(dev, "dmic-clk-threshold: %d\n",
nau8821->dmic_clk_threshold);
dev_dbg(dev, "key_enable: %d\n", nau8821->key_enable);
dev_dbg(dev, "adc-delay-ms: %d\n", nau8821->adc_delay);
}

static int nau8821_read_device_properties(struct device *dev,
Expand Down Expand Up @@ -1742,6 +1743,12 @@ static int nau8821_read_device_properties(struct device *dev,
&nau8821->dmic_slew_rate);
if (ret)
nau8821->dmic_slew_rate = 0;
ret = device_property_read_u32(dev, "nuvoton,adc-delay-ms",
&nau8821->adc_delay);
if (ret)
nau8821->adc_delay = 125;
if (nau8821->adc_delay < 125 || nau8821->adc_delay > 500)
dev_warn(dev, "Please set the suitable delay time!\n");

return 0;
}
Expand Down
1 change: 1 addition & 0 deletions sound/soc/codecs/nau8821.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ struct nau8821 {
int dmic_clk_threshold;
int dmic_slew_rate;
int key_enable;
int adc_delay;
};

int nau8821_enable_jack_detect(struct snd_soc_component *component,
Expand Down

0 comments on commit b37fdd4

Please sign in to comment.