ASoC: Intel: sof_rt5682: add 512FS MCLK clock configuration
Subsystems (3)
PATCH 1/1 ASoC: Intel: sof_rt5682: add 512FS MCLK clock configuration
codec system clock source support 512FS MCLK synchronous directly, so no need to set PLL configuration when MCLK 24.576MHz.
--- sound/soc/intel/boards/sof_rt5682.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
sound/soc/intel/boards/sof_rt5682.c +11 -6
@@ -61,7 +61,6 @@#define SOF_MAX98390_SPEAKER_AMP_PRESENT BIT(24)#define SOF_MAX98390_TWEETER_SPEAKER_PRESENT BIT(25) -/* Default: MCLK on, MCLK 19.2M, SSP0 */ static unsigned long sof_rt5682_quirk =SOF_RT5682_MCLK_EN |SOF_RT5682_SSP_CODEC (0 );
@@ -362,6 +361,9 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,if (sof_rt5682_quirk &SOF_RT5682S_HEADPHONE_CODEC_PRESENT ) { pll_id =RT5682S_PLL2 ; clk_id =RT5682S_SCLK_S_PLL2 ; + +if (pll_in ==24576000 ) + clk_id =RT5682S_SCLK_S_MCLK ; }else { pll_id =RT5682_PLL1 ; clk_id =RT5682_SCLK_S_PLL1 ;
@@ -369,11 +371,14 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, pll_out =params_rate (params) *512 ; -/* Configure pll for codec */ - ret =snd_soc_dai_set_pll (codec_dai, pll_id, pll_source, pll_in, - pll_out); -if (ret <0 ) -dev_err (rtd->dev,"snd_soc_dai_set_pll err = %d\n" , ret); +/* when MCLK is 512FS, no need to set PLL configuration additionally. */ +if (pll_in !=24576000 ) { +/* Configure pll for codec */ + ret =snd_soc_dai_set_pll (codec_dai, pll_id, pll_source, pll_in, + pll_out); +if (ret <0 ) +dev_err (rtd->dev,"snd_soc_dai_set_pll err = %d\n" , ret); + }/* Configure sysclk for codec */ ret = snd_soc_dai_set_sysclk(codec_dai, clk_id,
Signature · 1 line
2.20.1
Quoted 22 lines · Mac Chiang
codec system clock source support 512FS MCLK synchronous directly, so no need to set PLL configuration when MCLK 24.576MHz.
Suggested-by Shuming Fan <[email protected]>Signed-off-by Mac Chiang <[email protected]>--- sound/soc/intel/boards/sof_rt5682.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)sound/soc/intel/boards/sof_rt5682.c +0
-1@@ -61,7 +61,6 @@#define SOF_MAX98390_SPEAKER_AMP_PRESENT BIT(24)#define SOF_MAX98390_TWEETER_SPEAKER_PRESENT BIT(25) -/* Default: MCLK on, MCLK 19.2M, SSP0 */ static unsigned long sof_rt5682_quirk =SOF_RT5682_MCLK_EN |SOF_RT5682_SSP_CODEC (0 );
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, · line 366
Quoted 6 lines
sound/soc/intel/boards/sof_rt5682.c +3
-0@@ -362,6 +361,9 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,if (sof_rt5682_quirk &SOF_RT5682S_HEADPHONE_CODEC_PRESENT ) { pll_id =RT5682S_PLL2 ; clk_id =RT5682S_SCLK_S_PLL2 ; + +if (pll_in ==24576000 ) + clk_id =RT5682S_SCLK_S_MCLK ;
this case only affects the RT5682s case.
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, · line 369
Quoted 3 lines
sound/soc/intel/boards/sof_rt5682.c +0
-0}else { pll_id =RT5682_PLL1 ; clk_id =RT5682_SCLK_S_PLL1 ;
for the RT5682 we keep using the PLL. Is this intentional?
I also wonder if we can avoid the hard-coding. Can we use e.g.
if (pll_in == params_rate(params) * 512)
?
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, · line 375
Quoted 11 lines
sound/soc/intel/boards/sof_rt5682.c +2
-5@@ -369,11 +371,14 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, pll_out =params_rate (params) *512 ; -/* Configure pll for codec */ - ret =snd_soc_dai_set_pll (codec_dai, pll_id, pll_source, pll_in, - pll_out); -if (ret <0 ) -dev_err (rtd->dev,"snd_soc_dai_set_pll err = %d\n" , ret); +/* when MCLK is 512FS, no need to set PLL configuration additionally. */ +if (pll_in !=24576000 ) {
can we use if (pll_in == pll_out) ?
Quoted 10 lines
sound/soc/intel/boards/sof_rt5682.c +6
-0+/* Configure pll for codec */ + ret =snd_soc_dai_set_pll (codec_dai, pll_id, pll_source, pll_in, + pll_out); +if (ret <0 ) +dev_err (rtd->dev,"snd_soc_dai_set_pll err = %d\n" , ret); + }/* Configure sysclk for codec */ ret = snd_soc_dai_set_sysclk(codec_dai, clk_id,
Quoted 11 lines
Review static int sof_rt5682_hw_params(struct
Quoted 1 line
(quoted diff) +0
-0@@ -362,6 +361,9 @@ static int sof_rt5682_hw_params(struct
snd_pcm_substream*substream,Review static int sof_rt5682_hw_params(struct · line 361
Quoted 1 line
(quoted diff) +0
-0if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT){
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, · line 366
Quoted 5 lines
sound/soc/intel/boards/sof_rt5682.c +3
-0pll_id =RT5682S_PLL2 ; clk_id =RT5682S_SCLK_S_PLL2 ; + +if (pll_in ==24576000 ) + clk_id =RT5682S_SCLK_S_MCLK ;this case only affects the RT5682s case.
Thanks Pierre, you are right. Per discussed with Shuming, both 5682vs and 5682vd have to affect.
Quoted 10 lines
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, · line 369
Quoted 4 lines
sound/soc/intel/boards/sof_rt5682.c +0
-0}else { pll_id =RT5682_PLL1 ; clk_id =RT5682_SCLK_S_PLL1 ;for the RT5682 we keep using the PLL. Is this intentional?
I also wonder if we can avoid the hard-coding. Can we use e.g.
if (
pll_in==params_rate(params)* 512)
Agree, no hard-coding.
Quoted 15 lines
?
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct · line 375
Quoted 11 lines
sound/soc/intel/boards/sof_rt5682.c +1
-5@@ -369,11 +371,14 @@ static int sof_rt5682_hw_params(structsnd_pcm_substream *substream, pll_out =params_rate (params) *512 ; -/* Configure pll for codec */ - ret =snd_soc_dai_set_pll (codec_dai, pll_id, pll_source, pll_in, - pll_out); -if (ret <0 ) -dev_err (rtd->dev,"snd_soc_dai_set_pll err = %d\n" , ret); +/* when MCLK is 512FS, no need to set PLL configuration additionally. */
Quoted 3 lines
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, · line 375
Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1
-0+if (pll_in !=24576000 ) {can we use if (
pll_in==pll_out) ?
Agree, will modify as if (!(pll_in == pll_out)) {
Quoted 12 lines
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,
Quoted 6 lines
sound/soc/intel/boards/sof_rt5682.c +5
-0+/* Configure pll for codec */ + ret =snd_soc_dai_set_pll (codec_dai, pll_id, pll_source, pll_in, + pll_out); +if (ret <0 ) + dev_err(rtd->dev, "snd_soc_dai_set_pll err = %d\n",ret);
Quoted 5 lines
sound/soc/intel/boards/sof_rt5682.c +1
-0+ }/* Configure sysclk for codec */ ret = snd_soc_dai_set_sysclk(codec_dai,
clk_id,
Quoted 39 lines
Quoted 11 lines
Review static int sof_rt5682_hw_params(struct
Quoted 1 line
(quoted diff) +0
-0@@ -362,6 +361,9 @@ static int sof_rt5682_hw_params(struct
snd_pcm_substream*substream,Review static int sof_rt5682_hw_params(struct · line 361
Quoted 1 line
(quoted diff) +0
-0if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT){
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, · line 366
Quoted 5 lines
sound/soc/intel/boards/sof_rt5682.c +3
-0pll_id =RT5682S_PLL2 ; clk_id =RT5682S_SCLK_S_PLL2 ; + +if (pll_in ==24576000 ) + clk_id =RT5682S_SCLK_S_MCLK ;this case only affects the RT5682s case.
Thanks Pierre, you are right. Per discussed with Shuming, both 5682vs and 5682vd have to affect.
Quoted 10 lines
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, · line 369
Quoted 4 lines
sound/soc/intel/boards/sof_rt5682.c +0
-0}else { pll_id =RT5682_PLL1 ; clk_id =RT5682_SCLK_S_PLL1 ;for the RT5682 we keep using the PLL. Is this intentional?
I also wonder if we can avoid the hard-coding. Can we use e.g.
if (
pll_in==params_rate(params)* 512)Agree, no hard-coding.
Quoted 15 lines
?
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct · line 375
Quoted 11 lines
sound/soc/intel/boards/sof_rt5682.c +1
-5@@ -369,11 +371,14 @@ static int sof_rt5682_hw_params(structsnd_pcm_substream *substream, pll_out =params_rate (params) *512 ; -/* Configure pll for codec */ - ret =snd_soc_dai_set_pll (codec_dai, pll_id, pll_source, pll_in, - pll_out); -if (ret <0 ) -dev_err (rtd->dev,"snd_soc_dai_set_pll err = %d\n" , ret); +/* when MCLK is 512FS, no need to set PLL configuration additionally. */
Quoted 5 lines
Quoted 3 lines
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, · line 375
Quoted 1 line
sound/soc/intel/boards/sof_rt5682.c +1
-0+if (pll_in !=24576000 ) {can we use if (
pll_in==pll_out) ?Agree, will modify as if (!(pll_in ==
pll_out)) {Quoted 1 line
Maybe something like this?
if (pll_in == pll_out)
clk_id = RT5682S_SCLK_S_MCLK;
else {
/* Configure pll for codec */
ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source, pll_in,
pll_out);
if (ret < 0)
dev_err(rtd->dev, "snd_soc_dai_set_pll err = %d\n", ret);
}Quoted 11 lines
Quoted 11 lines
sound/soc/intel/boards/sof_rt5682.c static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,
Quoted 5 lines
sound/soc/intel/boards/sof_rt5682.c +5
-0+/* Configure pll for codec */ + ret =snd_soc_dai_set_pll (codec_dai, pll_id, pll_source, pll_in, + pll_out); +if (ret <0 ) + dev_err(rtd->dev, "snd_soc_dai_set_pll err = %d\n",ret);
Quoted 5 lines
sound/soc/intel/boards/sof_rt5682.c +1
-0+ }/* Configure sysclk for codec */ ret = snd_soc_dai_set_sysclk(codec_dai,
clk_id,