IMX6Q output audio is too fast to play music normally

In a scheme, MCU is used to control TEF6638 chip to output audio, and SOC side only outputs audio signal (I2S format).

According to the hardware scheme, the SOC side only needs to provide I2S audio signal, and the clock can only be provided through the SOC side. Therefore, after confirming the I2S pin configuration, the audio clock direction should be modified first
Modify the IMX audmux config function in imx-tef6635.c

static int imx_audmux_config(int slave, int master)
	unsigned int ptcr, pdcr;
	slave = slave - 1;
	master = master - 1;
	/* SSI1 MASTERED BY PORT 3 ,mx6 sipply pcm clock. */
    pdcr = MXC_AUDMUX_V2_PDCR_RXDSEL(master);
    mxc_audmux_v2_configure_port(slave, ptcr, pdcr);
    ptcr =MXC_AUDMUX_V2_PTCR_SYN    |
      		MXC_AUDMUX_V2_PTCR_TFSEL(slave) |
    pdcr = MXC_AUDMUX_V2_PDCR_RXDSEL(slave);
    mxc_audmux_v2_configure_port(master, ptcr, pdcr);
	return 0;

ALSA music playing too fast
In the development stage, it is found that I2S can output signals, but it can't play normally due to the speed is too fast, reaching about 20M. So step by step check the configuration.
1. Compare the clock settings of your own device and other devices. It is found that there is no corresponding clock configuration process during initialization
2. Add mx6 sabresd tef6638 init function to tef6638 data structure
3. Modify IMX? HW? Params in imx-tef6638 and add correct snd? SOC? Dai? Set? Sysclk

//Set the clock frequency of this SSI
snd_soc_dai_set_tdm_slot //Set TDM, if not set, LRCK signal does not
switch (channels) {
	case 2:
		snd_soc_dai_set_tdm_slot(cpu_dai, 0xfffffffc, 0xfffffffc, 2, 32);
	case 1:
		snd_soc_dai_set_tdm_slot(cpu_dai, 0xfffffffe, 0xfffffffe, 2, 32);
		return -EINVAL;
//Set I2S format on CPU side
snd_soc_dai_set_fmt//Set DAI format
ret = snd_soc_dai_set_fmt(cpu_dai, dai_format);
//Setting I2S clock and frequency division coefficient
//The function parameter is: Dai: Dai div? ID: Dai specific clock dividerid div: new clock divisor
snd_soc_dai_set_clkdiv(cpu_dai, IMX_SSI_TX_DIV_PM, 4);
//Setting I2S clock reference
//Clock output by soc, clk is SSP system clock, frequency is clk
clk = sample_rate*64*4;
After setting, the clock signal required for playing audio can be output normally.

Posted by numerical25 on Sun, 10 Nov 2019 09:44:53 -0800