diff mbox series

[6/6] ASoC: amd: Added hw_params support for ALC1015

Message ID 20200727145840.25142-6-Vishnuvardhanrao.Ravulapati@amd.com (mailing list archive)
State New, archived
Headers show
Series [1/6] ASoC: amd: Renaming snd-soc-card structure and fields. | expand

Commit Message

RAVULAPATI, VISHNU VARDHAN RAO July 27, 2020, 2:58 p.m. UTC
Adding rt1015 hw_params which set Bit-clock ratio PLL and appropriate
sys clk specific with RTK1015.

Signed-off-by: Ravulapati Vishnu vardhan rao <Vishnuvardhanrao.Ravulapati@amd.com>
---
 sound/soc/amd/acp3x-rt5682-max9836.c | 39 ++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

Comments

kernel test robot July 27, 2020, 7:56 p.m. UTC | #1
Hi Ravulapati,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on next-20200727]
[cannot apply to v5.8-rc7]
[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/Ravulapati-Vishnu-vardhan-rao/ASoC-amd-Renaming-snd-soc-card-structure-and-fields/20200727-230352
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-14) 9.3.0
reproduce (this is a W=1 build):
        # 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
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   sound/soc/amd/acp3x-rt5682-max9836.c: In function 'acp3x_1015_hw_params':
>> sound/soc/amd/acp3x-rt5682-max9836.c:140:17: error: 'struct snd_soc_pcm_runtime' has no member named 'codec_dais'
     140 |   if (strcmp(rtd->codec_dais[i]->name, "rt1015-aif"))
         |                 ^~
   sound/soc/amd/acp3x-rt5682-max9836.c:142:18: error: 'struct snd_soc_pcm_runtime' has no member named 'codec_dais'
     142 |   codec_dai = rtd->codec_dais[i];
         |                  ^~
   sound/soc/amd/acp3x-rt5682-max9836.c: At top level:
   sound/soc/amd/acp3x-rt5682-max9836.c:433:7: warning: no previous prototype for 'soc_is_rltk_max' [-Wmissing-prototypes]
     433 | void *soc_is_rltk_max(struct device *dev)
         |       ^~~~~~~~~~~~~~~

vim +140 sound/soc/amd/acp3x-rt5682-max9836.c

   128	
   129	static int acp3x_1015_hw_params(struct snd_pcm_substream *substream,
   130						struct snd_pcm_hw_params *params)
   131	{
   132		struct snd_soc_pcm_runtime *rtd = substream->private_data;
   133		struct snd_soc_dai *codec_dai;
   134		int srate, i, ret;
   135	
   136		ret = 0;
   137		srate = params_rate(params);
   138	
   139		for (i = 0; i < rtd->num_codecs; i++) {
 > 140			if (strcmp(rtd->codec_dais[i]->name, "rt1015-aif"))
   141				continue;
   142			codec_dai = rtd->codec_dais[i];
   143	
   144			ret = snd_soc_dai_set_bclk_ratio(codec_dai, 64);
   145			if (ret < 0) {
   146				dev_err(codec_dai->dev,
   147					"codec_dai bclk ratio not set\n");
   148				return ret;
   149			}
   150			ret = snd_soc_dai_set_pll(codec_dai, 0, RT1015_PLL_S_BCLK,
   151							64 * srate, 256 * srate);
   152			if (ret < 0) {
   153				dev_err(codec_dai->dev, "codec_dai PLL not set\n");
   154				return ret;
   155			}
   156			ret = snd_soc_dai_set_sysclk(codec_dai, RT1015_SCLK_S_PLL,
   157						256 * srate, SND_SOC_CLOCK_IN);
   158			if (ret < 0) {
   159				dev_err(codec_dai->dev,
   160						"codec_dai sys clock not set\n");
   161				return ret;
   162			}
   163		}
   164		return ret;
   165	}
   166	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Kuninori Morimoto July 27, 2020, 11:40 p.m. UTC | #2
Hi Ravulapati

> +static int acp3x_1015_hw_params(struct snd_pcm_substream *substream,
> +					struct snd_pcm_hw_params *params)
> +{
> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> +	struct snd_soc_dai *codec_dai;
> +	int srate, i, ret;
> +
> +	ret = 0;
> +	srate = params_rate(params);
> +
> +	for (i = 0; i < rtd->num_codecs; i++) {

You can use for_each_rtd_codec_dais() here

> +		if (strcmp(rtd->codec_dais[i]->name, "rt1015-aif"))
> +			continue;
> +		codec_dai = rtd->codec_dais[i];
> +
> +		ret = snd_soc_dai_set_bclk_ratio(codec_dai, 64);
> +		if (ret < 0) {
> +			dev_err(codec_dai->dev,
> +				"codec_dai bclk ratio not set\n");
> +			return ret;
> +		}
> +		ret = snd_soc_dai_set_pll(codec_dai, 0, RT1015_PLL_S_BCLK,
> +						64 * srate, 256 * srate);
> +		if (ret < 0) {
> +			dev_err(codec_dai->dev, "codec_dai PLL not set\n");
> +			return ret;
> +		}
> +		ret = snd_soc_dai_set_sysclk(codec_dai, RT1015_SCLK_S_PLL,
> +					256 * srate, SND_SOC_CLOCK_IN);
> +		if (ret < 0) {
> +			dev_err(codec_dai->dev,
> +					"codec_dai sys clock not set\n");
> +			return ret;
> +		}

You don't need to use dev_err() for snd_soc_dai_xxx().
Current snd_soc_dai_xxx() will indicate error message in such case.

Thank you for your help !!

Best regards
---
Kuninori Morimoto
diff mbox series

Patch

diff --git a/sound/soc/amd/acp3x-rt5682-max9836.c b/sound/soc/amd/acp3x-rt5682-max9836.c
index 607205cb3a98..bf635ae928ae 100644
--- a/sound/soc/amd/acp3x-rt5682-max9836.c
+++ b/sound/soc/amd/acp3x-rt5682-max9836.c
@@ -126,6 +126,44 @@  static int rt5682_clk_enable(struct snd_pcm_substream *substream)
 	return ret;
 }
 
+static int acp3x_1015_hw_params(struct snd_pcm_substream *substream,
+					struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai;
+	int srate, i, ret;
+
+	ret = 0;
+	srate = params_rate(params);
+
+	for (i = 0; i < rtd->num_codecs; i++) {
+		if (strcmp(rtd->codec_dais[i]->name, "rt1015-aif"))
+			continue;
+		codec_dai = rtd->codec_dais[i];
+
+		ret = snd_soc_dai_set_bclk_ratio(codec_dai, 64);
+		if (ret < 0) {
+			dev_err(codec_dai->dev,
+				"codec_dai bclk ratio not set\n");
+			return ret;
+		}
+		ret = snd_soc_dai_set_pll(codec_dai, 0, RT1015_PLL_S_BCLK,
+						64 * srate, 256 * srate);
+		if (ret < 0) {
+			dev_err(codec_dai->dev, "codec_dai PLL not set\n");
+			return ret;
+		}
+		ret = snd_soc_dai_set_sysclk(codec_dai, RT1015_SCLK_S_PLL,
+					256 * srate, SND_SOC_CLOCK_IN);
+		if (ret < 0) {
+			dev_err(codec_dai->dev,
+					"codec_dai sys clock not set\n");
+			return ret;
+		}
+	}
+	return ret;
+}
+
 static void rt5682_clk_disable(void)
 {
 	clk_disable_unprepare(rt5682_dai_wclk);
@@ -231,6 +269,7 @@  static const struct snd_soc_ops acp3x_5682_ops = {
 static const struct snd_soc_ops acp3x_max_play_ops = {
 	.startup = acp3x_max_startup,
 	.shutdown = rt5682_shutdown,
+	.hw_params = acp3x_1015_hw_params,
 };
 
 static const struct snd_soc_ops acp3x_ec_cap0_ops = {