* [RESEND] ASoC: amd: acp: Add setbias level for rt5682s codec in machine driver
@ 2022-09-29 7:08 Venkata Prasad Potturu
2022-09-29 10:29 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Venkata Prasad Potturu @ 2022-09-29 7:08 UTC (permalink / raw)
To: broonie, alsa-devel
Cc: vsujithkumar.reddy, Vijendar.Mukunda, Basavaraj.Hiregoudar,
Sunil-kumar.Dommati, ssabakar, Venkata Prasad Potturu,
Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Ajit Kumar Pandey,
V sujith kumar Reddy, Akihiko Odaki, ye xingchen, Jia-Ju Bai,
open list
From: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
Add set_bais_level function for rt5682s codec to enable bclk and lrclk
before codec widgets power on and disable bclk and lrclk after widgets
power down, to avoid pop noise
Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
---
sound/soc/amd/acp/acp-mach-common.c | 62 ++++++++++++++++++++++++++---
1 file changed, 56 insertions(+), 6 deletions(-)
diff --git a/sound/soc/amd/acp/acp-mach-common.c b/sound/soc/amd/acp/acp-mach-common.c
index 4c69cb6e3400..a78cf29387a7 100644
--- a/sound/soc/amd/acp/acp-mach-common.c
+++ b/sound/soc/amd/acp/acp-mach-common.c
@@ -167,11 +167,14 @@ static int acp_card_hs_startup(struct snd_pcm_substream *substream)
&constraints_channels);
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
&constraints_rates);
- if (!drvdata->soc_mclk) {
- ret = acp_clk_enable(drvdata);
- if (ret < 0) {
- dev_err(rtd->card->dev, "Failed to enable HS clk: %d\n", ret);
- return ret;
+
+ if (strcmp(codec_dai->name, "rt5682s-aif1") && strcmp(codec_dai->name, "rt5682s-aif2")) {
+ if (!drvdata->soc_mclk) {
+ ret = acp_clk_enable(drvdata);
+ if (ret < 0) {
+ dev_err(rtd->card->dev, "Failed to enable HS clk: %d\n", ret);
+ return ret;
+ }
}
}
@@ -280,7 +283,6 @@ static int acp_card_rt5682s_init(struct snd_soc_pcm_runtime *rtd)
static const struct snd_soc_ops acp_card_rt5682s_ops = {
.startup = acp_card_hs_startup,
- .shutdown = acp_card_shutdown,
};
static const unsigned int dmic_channels[] = {
@@ -570,6 +572,52 @@ SND_SOC_DAILINK_DEF(sof_dmic,
SND_SOC_DAILINK_DEF(pdm_dmic,
DAILINK_COMP_ARRAY(COMP_CPU("acp-pdm-dmic")));
+static int acp_rtk_set_bias_level(struct snd_soc_card *card,
+ struct snd_soc_dapm_context *dapm,
+ enum snd_soc_bias_level level)
+{
+ struct snd_soc_component *component = dapm->component;
+ struct acp_card_drvdata *drvdata = card->drvdata;
+ int ret = 0;
+
+ if (!component)
+ return 0;
+
+ if (strncmp(component->name, "i2c-RTL5682", 11) &&
+ strncmp(component->name, "i2c-10EC1019", 12))
+ return 0;
+
+ /*
+ * For Realtek's codec and amplifier components,
+ * the lrck and bclk must be enabled brfore their all dapms be powered on,
+ * and must be disabled after their all dapms be powered down
+ * to avoid any pop.
+ */
+ switch (level) {
+ case SND_SOC_BIAS_STANDBY:
+ if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) {
+ clk_set_rate(drvdata->wclk, 48000);
+ clk_set_rate(drvdata->bclk, 48000 * 64);
+
+ /* Increase bclk's enable_count */
+ ret = clk_prepare_enable(drvdata->bclk);
+ if (ret < 0)
+ dev_err(component->dev, "Failed to enable bclk %d\n", ret);
+ } else {
+ /*
+ * Decrease bclk's enable_count.
+ * While the enable_count is 0, the bclk would be closed.
+ */
+ clk_disable_unprepare(drvdata->bclk);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
int acp_sofdsp_dai_links_create(struct snd_soc_card *card)
{
struct snd_soc_dai_link *links;
@@ -730,6 +778,7 @@ int acp_sofdsp_dai_links_create(struct snd_soc_card *card)
card->dai_link = links;
card->num_links = num_links;
+ card->set_bias_level = acp_rtk_set_bias_level;
return 0;
}
@@ -907,6 +956,7 @@ int acp_legacy_dai_links_create(struct snd_soc_card *card)
card->dai_link = links;
card->num_links = num_links;
+ card->set_bias_level = acp_rtk_set_bias_level;
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RESEND] ASoC: amd: acp: Add setbias level for rt5682s codec in machine driver
2022-09-29 7:08 [RESEND] ASoC: amd: acp: Add setbias level for rt5682s codec in machine driver Venkata Prasad Potturu
@ 2022-09-29 10:29 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-09-29 10:29 UTC (permalink / raw)
To: Venkata Prasad Potturu
Cc: alsa-devel, vsujithkumar.reddy, Vijendar.Mukunda,
Basavaraj.Hiregoudar, Sunil-kumar.Dommati, ssabakar,
Venkata Prasad Potturu, Liam Girdwood, Jaroslav Kysela,
Takashi Iwai, Ajit Kumar Pandey, Akihiko Odaki, ye xingchen,
Jia-Ju Bai, open list
[-- Attachment #1: Type: text/plain, Size: 371 bytes --]
On Thu, Sep 29, 2022 at 12:38:22PM +0530, Venkata Prasad Potturu wrote:
> From: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
>
> Add set_bais_level function for rt5682s codec to enable bclk and lrclk
> before codec widgets power on and disable bclk and lrclk after widgets
> power down, to avoid pop noise
Please allow a reasonable time for review...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RESEND] ASoC: amd: acp: Add setbias level for rt5682s codec in machine driver
@ 2022-09-29 10:29 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-09-29 10:29 UTC (permalink / raw)
To: Venkata Prasad Potturu
Cc: alsa-devel, Sunil-kumar.Dommati, ssabakar, Ajit Kumar Pandey,
Venkata Prasad Potturu, ye xingchen, Basavaraj.Hiregoudar,
Takashi Iwai, Liam Girdwood, Jia-Ju Bai, Akihiko Odaki,
Vijendar.Mukunda, vsujithkumar.reddy, open list
[-- Attachment #1: Type: text/plain, Size: 371 bytes --]
On Thu, Sep 29, 2022 at 12:38:22PM +0530, Venkata Prasad Potturu wrote:
> From: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
>
> Add set_bais_level function for rt5682s codec to enable bclk and lrclk
> before codec widgets power on and disable bclk and lrclk after widgets
> power down, to avoid pop noise
Please allow a reasonable time for review...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-29 10:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29 7:08 [RESEND] ASoC: amd: acp: Add setbias level for rt5682s codec in machine driver Venkata Prasad Potturu
2022-09-29 10:29 ` Mark Brown
2022-09-29 10:29 ` Mark Brown
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.