ASoC: amd: add support for rt5682 codec in machine driver
Subsystems (3)
Vijendar Mukunda
maintainerPATCH v3 1/1 ASoC: amd: add support for rt5682 codec in machine driver
Add support for RT5682 codec in machine driver.
---v2->v3: updated SPDX licensev1->v2: updated kconfig, spdx license, removed unnecessary initialization and updated comment
sound/soc/amd/Kconfig | 5 +- sound/soc/amd/acp-da7219-max98357a.c | 380 +++++++++++++++++++++++++++++++---- 2 files changed, 343 insertions(+), 42 deletions(-)
sound/soc/amd/Kconfig +3 -2
@@ -5,14 +5,15 @@ config SND_SOC_AMD_ACP This option enables ACP DMA support on AMD platform. config SND_SOC_AMD_CZ_DA7219MX98357_MACH - tristate "AMD CZ support for DA7219 and MAX9835" + tristate "AMD CZ support for DA7219, RT5682 and MAX9835" select SND_SOC_DA7219 + select SND_SOC_RT5682_I2C select SND_SOC_MAX98357A select SND_SOC_ADAU7002 select REGULATOR depends on SND_SOC_AMD_ACP && I2C && GPIOLIB help - This option enables machine driver for DA7219 and MAX9835. + This option enables machine driver for DA7219, RT5682 and MAX9835. config SND_SOC_AMD_CZ_RT5645_MACH tristate "AMD CZ support for RT5645"
sound/soc/amd/acp-da7219-max98357a.c +340 -40
464 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 11 lines
sound/soc/amd/acp-da7219-max98357a.c +10
-0+static int rt5682_clk_enable (struct snd_pcm_substream *substream) +{ +int ret; +struct snd_soc_pcm_runtime *rtd =asoc_substream_to_rtd (substream); + +/* +* Set wclk to 48000 because the rate constraint of this driver is +* 48000. ADAU7002 spec: "The ADAU7002 requires a BCLK rate that is +* minimum of 64x the LRCLK sample rate." RT5682 is the only clk +* source so for all codecs we have to limit bclk to 64X lrclk.
sound/soc/amd/acp-da7219-max98357a.c static void da7219_clk_disable(void) · line 192
Quoted 10 lines
sound/soc/amd/acp-da7219-max98357a.c +10
-0+*/ +clk_set_rate (rt5682_dai_wclk,48000 ); +clk_set_rate (rt5682_dai_bclk,48000 *64 ); + ret =clk_prepare_enable (rt5682_dai_bclk); +if (ret <0 ) { +dev_err (rtd->dev,"can't enable master clock %d\n" , ret); +return ret; + } +return ret; +}
Out of curiosity, is there a reason why you use clk_prepare_enable() for the bclk but not for the wclk?
Mukunda,Vijendar
maintainerQuoted 15 lines · Pierre-Louis Bossart
Quoted 15 lines
sound/soc/amd/acp-da7219-max98357a.c +14
-0+static int rt5682_clk_enable (struct snd_pcm_substream *substream) +{ + int ret; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + + /* + * Set wclk to 48000 because the rate constraint of this driver is + * 48000. ADAU7002 spec: "The ADAU7002 requires a BCLK rate that is + * minimum of 64x the LRCLK sample rate." RT5682 is the only clk + * source so for all codecs we have to limit bclk to 64X lrclk. + */ + clk_set_rate(rt5682_dai_wclk, 48000); + clk_set_rate(rt5682_dai_bclk, 48000 * 64); + ret = clk_prepare_enable(rt5682_dai_bclk);
Quoted 8 lines
Quoted 6 lines
+ if (ret < 0) {
+dev_err(rtd->dev, "can't enable master clock %d\n", ret); + return ret;
+ }
+ return ret;
+}Out of curiosity, is there a reason why you use
clk_prepare_enable()for the bclk but not for the wclk?These changes were shared by codec vendor as an initial patch.
We should use clk_prepare_enable() for wclk not for bclk. We will update and share the new patch.
Quoted 26 lines · Mukunda,Vijendar
Quoted 15 lines · Pierre-Louis Bossart
Quoted 15 lines
sound/soc/amd/acp-da7219-max98357a.c +14
-0+static int rt5682_clk_enable (struct snd_pcm_substream *substream) +{ + int ret; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + + /* + * Set wclk to 48000 because the rate constraint of this driver is + * 48000. ADAU7002 spec: "The ADAU7002 requires a BCLK rate that is + * minimum of 64x the LRCLK sample rate." RT5682 is the only clk + * source so for all codecs we have to limit bclk to 64X lrclk. + */ + clk_set_rate(rt5682_dai_wclk, 48000); + clk_set_rate(rt5682_dai_bclk, 48000 * 64); + ret = clk_prepare_enable(rt5682_dai_bclk);Quoted 8 lines
Quoted 6 lines
+ if (ret < 0) {
+dev_err(rtd->dev, "can't enable master clock %d\n", ret); + return ret;
+ }
+ return ret;
+}Out of curiosity, is there a reason why you use
clk_prepare_enable()for the bclk but not for the wclk?These changes were shared by codec vendor as an initial patch.
Quoted 2 lines
We should use
clk_prepare_enable()for wclk not for bclk. We will update and share the new patch.
Well the question remains: if you have two clocks and only enable one, why do you need to get two clocks.
Also this patch was modeled after the da7219 case, where the same open applies.
Quoted 32 lines · Mukunda,Vijendar
Quoted 31 lines · Pierre-Louis Bossart
Quoted 28 lines
Quoted 14 lines
sound/soc/amd/acp-da7219-max98357a.c +13
-0+static int rt5682_clk_enable (struct snd_pcm_substream *substream) { + int ret; + struct snd_soc_pcm_runtime *rtd = +asoc_substream_to_rtd (substream); + + /* +* Set wclk to 48000 because the rate constraint of this driver +is +* 48000. ADAU7002 spec: "The ADAU7002 requires a BCLK rate +that is +* minimum of 64x the LRCLK sample rate." RT5682 is the only +clk +* source so for all codecs we have to limit bclk to 64X lrclk. sound/soc/amd/acp-da7219-max98357a.c static void da7219_clk_disable(void) · line 192
Quoted 10 lines
sound/soc/amd/acp-da7219-max98357a.c +10
-0+*/ + clk_set_rate(rt5682_dai_wclk, 48000); + clk_set_rate(rt5682_dai_bclk, 48000 * 64); + ret = clk_prepare_enable(rt5682_dai_bclk); + if (ret < 0) { + dev_err(rtd->dev, "can't enable master clock %d\n", ret); + return ret; + } + return ret; +}Out of curiosity, is there a reason why you use
clk_prepare_enable()for the bclk but not for the wclk?These changes were shared by codec vendor as an initial patch.
Quoted 8 lines
Quoted 2 lines
We should use
clk_prepare_enable()for wclk not for bclk. We will update and share the new patch.Well the question remains: if you have two clocks and only enable one, why do you need to get two clocks.
Also this patch was modeled after the da7219 case, where the same open applies.
The RT5682 could set the wclk and bclk separately.
The bclk could set the different ratios (32/64/128/256).
However, only the wclk of DAI clock has the .prepare callback function to enable the related power. The next patch should update the clk_prepare_enable() for wclk.
Quoted 1 line
------Please consider the environment before printing this e-mail.
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Vijendar,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on asoc/for-next]
[also build test ERROR on v5.12-rc3 next-20210315]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Vijendar-Mukunda/ASoC-amd-add-support-for-rt5682-codec-in-machine-driver/20210315-234723 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next config: x86_64-allyesconfig (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/3ce3631a5e78f3564d42ce966b97b5496dec7db6 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Vijendar-Mukunda/ASoC-amd-add-support-for-rt5682-codec-in-machine-driver/20210315-234723 git checkout 3ce3631a5e78f3564d42ce966b97b5496dec7db6 # save the attached .config to linux build tree make W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
ld: sound/soc/amd/acp3x-rt5682-max9836.o: in function `soc_is_rltk_max':
>> acp3x-rt5682-max9836.c:(.text+0x840): multiple definition of `soc_is_rltk_max'; sound/soc/amd/acp-da7219-max98357a.o:acp-da7219-max98357a.c:(.text+0xd00): first defined here
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org