Unverified Commit b5aaf6a5 authored by Brent Lu's avatar Brent Lu Committed by Mark Brown
Browse files

ASoC: Intel: sof-rt5682: setup pll_id only when needed



The variable 'pll_id' is needed only when we use snd_soc_dai_set_pll()
to setup PLL. Move the code segment to improve some readability.

Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarBrent Lu <brent.lu@intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20240426152529.38345-22-pierre-louis.bossart@linux.intel.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 76f33e2f
Loading
Loading
Loading
Loading
+29 −29
Original line number Diff line number Diff line
@@ -320,6 +320,26 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,
		pll_in = params_rate(params) * 50;
	}

	pll_out = params_rate(params) * 512;

	/* when MCLK is 512FS, no need to set PLL configuration additionally. */
	if (pll_in == pll_out) {
		switch (ctx->codec_type) {
		case CODEC_RT5650:
			clk_id = RT5645_SCLK_S_MCLK;
			break;
		case CODEC_RT5682:
			clk_id = RT5682_SCLK_S_MCLK;
			break;
		case CODEC_RT5682S:
			clk_id = RT5682S_SCLK_S_MCLK;
			break;
		default:
			dev_err(rtd->dev, "invalid codec type %d\n",
				ctx->codec_type);
			return -EINVAL;
		}
	} else {
		switch (ctx->codec_type) {
		case CODEC_RT5650:
			pll_id = 0; /* not used in codec driver */
@@ -349,26 +369,6 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,
			return -EINVAL;
		}

	pll_out = params_rate(params) * 512;

	/* when MCLK is 512FS, no need to set PLL configuration additionally. */
	if (pll_in == pll_out) {
		switch (ctx->codec_type) {
		case CODEC_RT5650:
			clk_id = RT5645_SCLK_S_MCLK;
			break;
		case CODEC_RT5682:
			clk_id = RT5682_SCLK_S_MCLK;
			break;
		case CODEC_RT5682S:
			clk_id = RT5682S_SCLK_S_MCLK;
			break;
		default:
			dev_err(rtd->dev, "invalid codec type %d\n",
				ctx->codec_type);
			return -EINVAL;
		}
	} else {
		/* Configure pll for codec */
		ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source, pll_in,
					  pll_out);