From: "Agrawal, Akshu" <Akshu.Agrawal@amd.com> To: unlisted-recipients:; (no To-header on input) Cc: "Agrawal, Akshu" <Akshu.Agrawal@amd.com>, "djkurtz@chromium.org" <djkurtz@chromium.org>, "Deucher, Alexander" <Alexander.Deucher@amd.com>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, "Mukunda, Vijendar" <Vijendar.Mukunda@amd.com>, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>, Wei Yongjun <weiyongjun1@huawei.com>, "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." <alsa-devel@alsa-project.org>, open list <linux-kernel@vger.kernel.org> Subject: [PATCH] ASoC: AMD: Add delay before starting to capture Date: Thu, 3 Jan 2019 10:18:13 +0000 [thread overview] Message-ID: <1546510559-17798-1-git-send-email-akshu.agrawal@amd.com> (raw) On capture through dmic we observe a glitch at the start of record. This is because we start capturing even before dmic is ready to send out data. The glitch seen last for ~20msec. Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> --- sound/soc/amd/acp-da7219-max98357a.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c index a5daad9..72b1cf4 100644 --- a/sound/soc/amd/acp-da7219-max98357a.c +++ b/sound/soc/amd/acp-da7219-max98357a.c @@ -44,6 +44,8 @@ #define CZ_PLAT_CLK 48000000 #define DUAL_CHANNEL 2 +#define ADAU7002_DELAY_MS 20 + static struct snd_soc_jack cz_jack; static struct clk *da7219_dai_clk; @@ -213,6 +215,7 @@ static int cz_dmic0_startup(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_card *card = rtd->card; struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); + int ret; /* * On this platform for PCM device we support stereo @@ -225,7 +228,17 @@ static int cz_dmic0_startup(struct snd_pcm_substream *substream) &constraints_rates); machine->cap_i2s_instance = I2S_BT_INSTANCE; - return da7219_clk_enable(substream); + ret = da7219_clk_enable(substream); + if (ret) + return ret; + /* + * On some platforms, it takes ~20 msec for PDM DMICs and ADAU7002 + * to settle and start producing proper audio data. + */ + msleep(ADAU7002_DELAY_MS); + /* Delay in frames for 48Khz, 16bit, 2 channel */ + runtime->delay = ADAU7002_DELAY_MS * 48; + return 0; } static int cz_dmic1_startup(struct snd_pcm_substream *substream) @@ -234,6 +247,7 @@ static int cz_dmic1_startup(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_card *card = rtd->card; struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); + int ret; /* * On this platform for PCM device we support stereo @@ -247,7 +261,17 @@ static int cz_dmic1_startup(struct snd_pcm_substream *substream) machine->cap_i2s_instance = I2S_SP_INSTANCE; machine->capture_channel = CAP_CHANNEL0; - return da7219_clk_enable(substream); + ret = da7219_clk_enable(substream); + if (ret) + return ret; + /* + * On some platforms, it takes ~20 msec for PDM DMICs and ADAU7002 + * to settle and start producing proper audio data. + */ + msleep(ADAU7002_DELAY_MS); + /* Delay in frames for 48Khz, 16bit, 2 channel */ + runtime->delay = ADAU7002_DELAY_MS * 48; + return 0; } static void cz_dmic_shutdown(struct snd_pcm_substream *substream) -- 1.9.1
WARNING: multiple messages have this Message-ID (diff)
From: "Agrawal, Akshu" <Akshu.Agrawal@amd.com> Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." <alsa-devel@alsa-project.org>, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>, open list <linux-kernel@vger.kernel.org>, Takashi Iwai <tiwai@suse.com>, Liam Girdwood <lgirdwood@gmail.com>, "djkurtz@chromium.org" <djkurtz@chromium.org>, Mark Brown <broonie@kernel.org>, Wei Yongjun <weiyongjun1@huawei.com>, "Mukunda, Vijendar" <Vijendar.Mukunda@amd.com>, "Deucher, Alexander" <Alexander.Deucher@amd.com>, "Agrawal, Akshu" <Akshu.Agrawal@amd.com> Subject: [PATCH] ASoC: AMD: Add delay before starting to capture Date: Thu, 3 Jan 2019 10:18:13 +0000 [thread overview] Message-ID: <1546510559-17798-1-git-send-email-akshu.agrawal@amd.com> (raw) On capture through dmic we observe a glitch at the start of record. This is because we start capturing even before dmic is ready to send out data. The glitch seen last for ~20msec. Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> --- sound/soc/amd/acp-da7219-max98357a.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c index a5daad9..72b1cf4 100644 --- a/sound/soc/amd/acp-da7219-max98357a.c +++ b/sound/soc/amd/acp-da7219-max98357a.c @@ -44,6 +44,8 @@ #define CZ_PLAT_CLK 48000000 #define DUAL_CHANNEL 2 +#define ADAU7002_DELAY_MS 20 + static struct snd_soc_jack cz_jack; static struct clk *da7219_dai_clk; @@ -213,6 +215,7 @@ static int cz_dmic0_startup(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_card *card = rtd->card; struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); + int ret; /* * On this platform for PCM device we support stereo @@ -225,7 +228,17 @@ static int cz_dmic0_startup(struct snd_pcm_substream *substream) &constraints_rates); machine->cap_i2s_instance = I2S_BT_INSTANCE; - return da7219_clk_enable(substream); + ret = da7219_clk_enable(substream); + if (ret) + return ret; + /* + * On some platforms, it takes ~20 msec for PDM DMICs and ADAU7002 + * to settle and start producing proper audio data. + */ + msleep(ADAU7002_DELAY_MS); + /* Delay in frames for 48Khz, 16bit, 2 channel */ + runtime->delay = ADAU7002_DELAY_MS * 48; + return 0; } static int cz_dmic1_startup(struct snd_pcm_substream *substream) @@ -234,6 +247,7 @@ static int cz_dmic1_startup(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_card *card = rtd->card; struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); + int ret; /* * On this platform for PCM device we support stereo @@ -247,7 +261,17 @@ static int cz_dmic1_startup(struct snd_pcm_substream *substream) machine->cap_i2s_instance = I2S_SP_INSTANCE; machine->capture_channel = CAP_CHANNEL0; - return da7219_clk_enable(substream); + ret = da7219_clk_enable(substream); + if (ret) + return ret; + /* + * On some platforms, it takes ~20 msec for PDM DMICs and ADAU7002 + * to settle and start producing proper audio data. + */ + msleep(ADAU7002_DELAY_MS); + /* Delay in frames for 48Khz, 16bit, 2 channel */ + runtime->delay = ADAU7002_DELAY_MS * 48; + return 0; } static void cz_dmic_shutdown(struct snd_pcm_substream *substream) -- 1.9.1
next reply other threads:[~2019-01-03 10:18 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-01-03 10:18 Agrawal, Akshu [this message] 2019-01-03 10:18 ` [PATCH] ASoC: AMD: Add delay before starting to capture Agrawal, Akshu 2019-01-04 12:27 ` Mark Brown 2019-01-04 12:27 ` Mark Brown 2019-01-07 6:00 ` Agrawal, Akshu 2019-01-07 6:00 ` Agrawal, Akshu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1546510559-17798-1-git-send-email-akshu.agrawal@amd.com \ --to=akshu.agrawal@amd.com \ --cc=Alexander.Deucher@amd.com \ --cc=Vijendar.Mukunda@amd.com \ --cc=alsa-devel@alsa-project.org \ --cc=broonie@kernel.org \ --cc=djkurtz@chromium.org \ --cc=kuninori.morimoto.gx@renesas.com \ --cc=lgirdwood@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=perex@perex.cz \ --cc=tiwai@suse.com \ --cc=weiyongjun1@huawei.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.