Hi Igor,
i debugged into driver as you said but still i am getting master clock around 45Hz but in driver its shows 12.288Mhz.
This is the updated driver code:
static int imx_sph0645_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 *cpu_dai = rtd->cpu_dai;
u32 channels = 2; //ALWAYS 2 CHANNELS params_channels(params);
u32 ratio = 0;
u64 mclk = 12288000;
u32 rate = params_rate(params); //sampling rate
dev_err(cpu_dai->dev, "sampling rate parms_rate output rate : %d \n" , rate);
u32 bclk = rate * channels * 32; //fixed to sampling rate * 64
// ratio = mclk / bclk ;
ratio = 4;
dev_err(cpu_dai->dev, "bclk : %d \n" , bclk);
dev_err(cpu_dai->dev, "ratio : %d \n" , ratio);
int ret = 0;
/* set cpu DAI configuration */
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
if (ret) {
dev_err(cpu_dai->dev, "failed to set dai fmt\n");
return ret;
}
ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 3, 2, 32);
if (ret) {
dev_err(cpu_dai->dev, "failed to set dai tdm slot\n");
return ret;
}
ret = snd_soc_dai_set_sysclk(cpu_dai, 1, mclk, SND_SOC_CLOCK_OUT);
if (ret)
dev_err(cpu_dai->dev, "failed to set cpu sysclk\n");
return ret;
ret = snd_soc_dai_set_bclk_ratio(cpu_dai, ratio);
if (ret)
dev_err(cpu_dai->dev, "failed to set bclk ratio\n");
return ret;
}
This is the debugging ouput:
fsl-sai 2028000.sai: Entered into fsl sai set mclk rate mclk_clk[1] = 12288000Hz:
fsl-sai 2028000.sai: Entered into fsl sai set bclk with freq: 3072000 Hz
fsl-sai 2028000.sai: Entered into fsl sai set bclk mclk_clk[0] = 0Hz:
fsl-sai 2028000.sai: Entered into fsl sai set bclk mclk_clk[1] = 12288000Hz:
fsl-sai 2028000.sai: ratio 4 for freq 3072000Hz based on clock 12288000Hz
fsl-sai 2028000.sai: Entered into fsl sai set bclk id and tx : 0, id = 1:
, savediv :4
Request you to provide your inputs regarding master clock setting.
Regards,
Hitesh