iMX8MM stuck with audio codec MAX9867

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

iMX8MM stuck with audio codec MAX9867

跳至解决方案
2,079 次查看
dpog
Contributor V

I'm trying to integrate a MAX9867 audio codec in our custom imx8m mini board, but I'm stuck when trying to test the audio output with ALSA speaker-test:

root@evalboard:~# speaker-test

speaker-test 1.2.6

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
[ 18.948357] max9867 1-0018: ASoC: error at snd_soc_dai_hw_params on max9867-aif1: -22
[ 18.960141] 30050000.sai-max9867-aif1: ASoC: error at __soc_pcm_hw_params on 30050000.sai-max9867-aif1: -22
ALSA lib ../../../alsa-lib-1.2.6.1/src/pcm/pcm_direct.c:1284:(snd1_pcm_direct_initialize_slave) unable to install hw params
ALSA lib ../../../alsa-lib-1.2.6.1/src/pcm/pcm_dmix.c:1044:(snd_pcm_dmix_open) unable to initialize slave
Playback open error: -22,Invalid argument
root@evalboard:~#

 

my device tree looks as follows, I'm not quite sure what to do with the fsl,dataline, so it's commented out:

sound_card: sound-card {
    compatible = "simple-audio-card";
    simple-audio-card,name = "max9867";
    simple-audio-card,format = "i2s";
    simple-audio-card,frame-master = <&dailink_master>;
    simple-audio-card,bitclock-master = <&dailink_master>;

    dailink_master: simple-audio-card,codec {
        clocks = <&clk IMX8MM_CLK_SAI5_ROOT>;
        sound-dai = <&audio_codec>;
    };

    simple-audio-card,cpu {
        sound-dai = <&sai5>;
    };
};
 
&i2c2 {
    clock-frequency = <400000>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_i2c2>;
    status = "okay";

    audio_codec: audio_codec@18 {
        #sound-dai-cells = <0>;
        compatible = "maxim,max9867";
        clocks = <&clk IMX8MM_CLK_SAI5_ROOT>;
        reg = <0x18>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_sai5_mclk>;
        status = "okay";
    };
};

&sai5 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_sai5>;

    // fsl,dataline = <1 0xff 0xff 2 0xff 0x11>;
};
 
pinctrl_sai5: sai5grp {
    fsl,pins = <
        MX8MM_IOMUXC_SAI3_RXD_SAI5_RX_DATA0     0x1f
        MX8MM_IOMUXC_SAI5_RXD3_SAI5_TX_DATA0    0x30
        MX8MM_IOMUXC_SAI2_RXC_SAI5_TX_BCLK      0x1f
        MX8MM_IOMUXC_SAI5_RXD1_SAI5_TX_SYNC     0x1f
    >;
};

pinctrl_sai5_mclk: sai5mclkgrp {
    fsl,pins = <
        MX8MM_IOMUXC_SAI2_MCLK_SAI5_MCLK        0x1f
    >;
};
 
Am I missing some dt configurations or are wrong ones set?
标签 (1)
0 项奖励
回复
1 解答
1,833 次查看
dpog
Contributor V
Sorry for my delayed reply, I lost track of this thread. The issue was resolved by changing the hardware, apparently there was an error in the design that switched two clock signals. We wired them correctly and got the output from the speakers.

在原帖中查看解决方案

0 项奖励
回复
8 回复数
1,963 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

We do not have an specific device tree configuration to the MAX9867 codec, did you check with vendor for a device tree example?

We have a device tree from the EVK board and also the simple-card.yaml that you could use as a reference for your design.

Best regards.

0 项奖励
回复
1,935 次查看
dpog
Contributor V
I used the example given in the kernel docs. The codec seems to be working, when I change some settings in alsamixer I hear clicking noises on the speakers.

So I'm guessing the problem might be the SAI, do I need to configure it to use I2S? Or is it done by the simple-card format?

Best regards
0 项奖励
回复
1,927 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

The device tree has the necessary configuration to use the corresponding driver and be correctly detected and used on the OS.

Are you able to see the sent data to the codec when you hear the noises from the speaker?

Best regards.

0 项奖励
回复
1,834 次查看
dpog
Contributor V
Sorry for my delayed reply, I lost track of this thread. The issue was resolved by changing the hardware, apparently there was an error in the design that switched two clock signals. We wired them correctly and got the output from the speakers.
0 项奖励
回复
2,037 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

Hello, I hope you are doing well.

I suggest you take a look at Chapter 16 Porting Audio Codecs i.MX Porting Guide.

Best regards.

0 项奖励
回复
2,025 次查看
dpog
Contributor V
Hi, I did take a look, but it was of no help. For the max9867 i cannot use the imx-wm8962.c, so I took the simple-audio-card as it is done in the imx8mm-evk.dtsi. I also checked the drivers, they all load as expected, the error happens at runtime, most likely when executing ioctl(4, SNDRV_PCM_IOCTL_HW_PARAMS, 0xfff......) : EINVAL

Best regards
0 项奖励
回复
2,016 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

If you are using a different codec, it is needed to adapt the driver architecture accordingly. The exact adaptation depends on the codec chosen. Please try to check the codec-specific software from the codec vendor.

Best regards.

 

0 项奖励
回复
1,994 次查看
dpog
Contributor V
The hw_params problem were resolved by adding
assigned-clocks = <&clk IMX8MM_CLK_SAI5>;
assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
assigned-clock-rates = <24576000>;
to the sai5 node.

But still there is no output. Do I need to configure the SAI to work in I2S-Mode? Have not found anything related, so I'm just guessing right now
0 项奖励
回复