Skip to content

Commit 8c99a0a

Browse files
Zhu Ningbroonie
authored andcommitted
ASoC: codecs: ES8326: fix the capture noise issue
We get a noise issue during the startup of recording. We update the register setting and dapm widgets to fix this issue. we change callback type of es8326_mute function to mute_stream. ES8326_ADC_MUTE is moved to es8326_mute function so it can be turned on at last and turned off at first. Signed-off-by: Zhu Ning <zhuning0077@gmail.com> Link: https://msgid.link/r/20240120101240.12496-6-zhuning0077@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent a3aa925 commit 8c99a0a

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

sound/soc/codecs/es8326.c

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,6 @@ static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = {
197197
SND_SOC_DAPM_AIF_OUT("I2S OUT", "I2S1 Capture", 0, SND_SOC_NOPM, 0, 0),
198198
SND_SOC_DAPM_AIF_IN("I2S IN", "I2S1 Playback", 0, SND_SOC_NOPM, 0, 0),
199199

200-
/* ADC Digital Mute */
201-
SND_SOC_DAPM_PGA("ADC L1", ES8326_ADC_MUTE, 0, 1, NULL, 0),
202-
SND_SOC_DAPM_PGA("ADC R1", ES8326_ADC_MUTE, 1, 1, NULL, 0),
203-
SND_SOC_DAPM_PGA("ADC L2", ES8326_ADC_MUTE, 2, 1, NULL, 0),
204-
SND_SOC_DAPM_PGA("ADC R2", ES8326_ADC_MUTE, 3, 1, NULL, 0),
205-
206200
/* Analog Power Supply*/
207201
SND_SOC_DAPM_DAC("Right DAC", NULL, ES8326_ANA_PDN, 0, 1),
208202
SND_SOC_DAPM_DAC("Left DAC", NULL, ES8326_ANA_PDN, 1, 1),
@@ -222,15 +216,10 @@ static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = {
222216
};
223217

224218
static const struct snd_soc_dapm_route es8326_dapm_routes[] = {
225-
{"ADC L1", NULL, "MIC1"},
226-
{"ADC R1", NULL, "MIC2"},
227-
{"ADC L2", NULL, "MIC3"},
228-
{"ADC R2", NULL, "MIC4"},
229-
230-
{"ADC L", NULL, "ADC L1"},
231-
{"ADC R", NULL, "ADC R1"},
232-
{"ADC L", NULL, "ADC L2"},
233-
{"ADC R", NULL, "ADC R2"},
219+
{"ADC L", NULL, "MIC1"},
220+
{"ADC R", NULL, "MIC2"},
221+
{"ADC L", NULL, "MIC3"},
222+
{"ADC R", NULL, "MIC4"},
234223

235224
{"I2S OUT", NULL, "ADC L"},
236225
{"I2S OUT", NULL, "ADC R"},
@@ -520,11 +509,16 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction)
520509
unsigned int offset_l, offset_r;
521510

522511
if (mute) {
523-
regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF);
524-
regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE,
525-
ES8326_MUTE_MASK, ES8326_MUTE);
526-
regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF,
527-
0x30, 0x00);
512+
if (direction == SNDRV_PCM_STREAM_PLAYBACK) {
513+
regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF);
514+
regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE,
515+
ES8326_MUTE_MASK, ES8326_MUTE);
516+
regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF,
517+
0x30, 0x00);
518+
} else {
519+
regmap_update_bits(es8326->regmap, ES8326_ADC_MUTE,
520+
0x0F, 0x0F);
521+
}
528522
} else {
529523
if (!es8326->calibrated) {
530524
regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_FORCE_CAL);
@@ -537,16 +531,22 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction)
537531
regmap_write(es8326->regmap, ES8326_HPR_OFFSET_INI, offset_r);
538532
es8326->calibrated = true;
539533
}
540-
regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x01);
541-
usleep_range(1000, 5000);
542-
regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x00);
543-
usleep_range(1000, 5000);
544-
regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x20);
545-
regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x30);
546-
regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1);
547-
regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_ON);
548-
regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE,
549-
ES8326_MUTE_MASK, ~(ES8326_MUTE));
534+
if (direction == SNDRV_PCM_STREAM_PLAYBACK) {
535+
regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x01);
536+
usleep_range(1000, 5000);
537+
regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x00);
538+
usleep_range(1000, 5000);
539+
regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x20);
540+
regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x30);
541+
regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1);
542+
regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_ON);
543+
regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE,
544+
ES8326_MUTE_MASK, ~(ES8326_MUTE));
545+
} else {
546+
msleep(300);
547+
regmap_update_bits(es8326->regmap, ES8326_ADC_MUTE,
548+
0x0F, 0x00);
549+
}
550550
}
551551
return 0;
552552
}
@@ -596,7 +596,7 @@ static const struct snd_soc_dai_ops es8326_ops = {
596596
.set_fmt = es8326_set_dai_fmt,
597597
.set_sysclk = es8326_set_dai_sysclk,
598598
.mute_stream = es8326_mute,
599-
.no_capture_mute = 1,
599+
.no_capture_mute = 0,
600600
};
601601

602602
static struct snd_soc_dai_driver es8326_dai = {
@@ -968,6 +968,7 @@ static int es8326_resume(struct snd_soc_component *component)
968968
regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK,
969969
ES8326_MUTE);
970970

971+
regmap_write(es8326->regmap, ES8326_ADC_MUTE, 0x0f);
971972

972973
es8326->jack_remove_retry = 0;
973974
es8326->hp = 0;

0 commit comments

Comments
 (0)