AnsweredAssumed Answered

imx8mm sai3 and adau1761 driver

Question asked by tan yd on Jun 4, 2020
Latest reply on Jun 15, 2020 by tan yd

在调试adau1761时,驱动正常加载上去,但gplay a.wav时,总是报
[   43.439222] fsl-sai 30030000.sai: failed to derive required Rx rate: 2822400
[   43.446285] fsl-sai 30030000.sai: ASoC: can't set 30030000.sai hw params: -22
错误 提示,跟进源码中,发现在函数:

static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq)
{
    struct fsl_sai *sai = snd_soc_dai_get_drvdata(dai);
    unsigned char offset = sai->soc->reg_offset;
    unsigned long clk_rate;
    unsigned int reg = 0;
    u32 ratio, savesub = freq, saveratio = 0, savediv = 0;
    u32 id;
    int ret = 0;

 

    /* Don't apply to slave mode */
    if (sai->slave_mode[tx])
        return 0;

 

    fsl_sai_check_ver(dai);
    for (id = 0; id < FSL_SAI_MCLK_MAX; id++)
    {
        clk_rate = clk_get_rate(sai->mclk_clk[id]);

 

        if (!clk_rate)continue;

 

        ratio = clk_rate / freq;
        ret = clk_rate - ratio * freq;
printk("fsl_sai_set_bclk ret:%d \n",ret);//1996800

 

        /*
         * Drop the source that can not be
         * divided into the required rate.
         */
        if (ret != 0 && clk_rate / ret < 1000) //
            continue;

 

printk("fsl_sai_set_bclk line:%d \n",__LINE__);
        if ((ratio % 2 == 0 && ratio >= 2 && ratio <= 512) ||(ratio == 1 && sai->verid.id >= FSL_SAI_VERID_0301))
        {
printk("fsl_sai_set_bclk line:%d \n",__LINE__);
            if (ret < savesub) {
printk("fsl_sai_set_bclk line:%d \n",__LINE__);
                saveratio = ratio;
                sai->mclk_id[tx] = id;
                savesub = ret;
            }
printk("fsl_sai_set_bclk line:%d ret %d\n",__LINE__,ret);
            if (ret == 0)
                break;
        }
    }

 

    if (saveratio == 0) {
        printk("ratio %d sai->verid.id %d\n",ratio,sai->verid.id);//8 0
        dev_err(dai->dev, "failed to derive required %cx rate: %d\n",tx ? 'T' : 'R', freq);
        return -EINVAL;
    }

 

        if (ret != 0 && clk_rate / ret < 1000) //
            continue;


,这个判断条件值引用的sai3的配置

&sai3 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_sai3>;
    assigned-clocks = <&clk IMX8MM_CLK_SAI3_SRC>,
            <&clk IMX8MM_CLK_SAI3_DIV>;
    assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
    assigned-clock-rates = <0>, <49152000>;
    status = "okay";
};

按这些条件计算,根本不会大于1000,配成最大值 得到的结果也只有:41.967213。
所以,这个是sai3配置是否有错?这个问题要如何解决?

我的需求是sai配成master模式,收发时钟都要提供,adau1761工作在slave模式下。

Outcomes