iMX8MM SAI I2S with dummy codec

cancel
Showing results for 
Search instead for 
Did you mean: 

iMX8MM SAI I2S with dummy codec

1,733 Views
jonver
Contributor II

Hi,

I trying to make the imx8mm board output audio via I2S. The chip that decodes the audio is CS4344, which has no config so no I2C is present.

I made the following changes to the dts file:


    sound {
        compatible = "simple-audio-card";
        simple-audio-card,name = "CS4344";
        simple-audio-card,format = "i2s";
        simple-audio-card,widgets =
            "Line""Line Out";
        simple-audio-card,routing =
            "Line Out""LLOUT",
            "Line Out""RLOUT";
        simple-audio-card,cpu {
            sound-dai = <&sai5>;
        };
        simple-audio-card,codec {
         sound-dai = <&codec1>;
        };
    };

    codec1codec1 {
         compatible = "linux,snd-soc-dummy";
         #sound-dai-cells = <0>;
         status = "okay";
     };
        pinctrl_sai5sai5grp {
            fsl,pins = <
                MX8MM_IOMUXC_SAI2_MCLK_SAI5_MCLK        0xd6
                MX8MM_IOMUXC_SAI1_TXFS_SAI5_TX_SYNC     0xd6
                MX8MM_IOMUXC_SAI5_RXD2_SAI5_TX_BCLK     0xd6
                MX8MM_IOMUXC_SAI1_TXD1_SAI5_TX_DATA1    0xd6
                MX8MM_IOMUXC_SAI1_TXD3_SAI5_TX_DATA3    0xd6
            >;
        };
&sai5 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_sai5>;
    assigned-clocks = <&clk IMX8MM_CLK_SAI5_SRC>,
            <&clk IMX8MM_CLK_SAI5_DIV>;
    assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
    assigned-clock-rates = <0>, <1536000>;
    #sound-dai-cells = <0>;
    status = "okay";
};

The CONFIG_SND_SIMPLE_CARD option is enabled when compiling the kernel.

I see no sound card in my boot logs or with the following commands `dmesg | grep sai` or `cat /proc/asound/cards`. 

Any ideas? Thanks.

Tags (2)
0 Kudos
10 Replies

684 Views
maxipenna
Contributor III

@igorpadykov why are you linking a solution where an i2c codec is used and binded into the dts? The user asked a question about interfacing a codec that is NOT managed on i2c. So your solution isn't applicable...I've just tried the approach provided by @jonver and I confirm it's not working altought I think it's very likely to be correct...

 

 

0 Kudos

681 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Massimo

 

one can try to remove i2c codes, if they are not used.

 

Best regards
igor

0 Kudos

677 Views
maxipenna
Contributor III

Sorry but have you tried to do that and confirm it's working or not? If I open simple-card.txt in a more or less recent kernel I see

Required dai-link subnodes:

- cpu : CPU sub-node
- codec : CODEC sub-node

You have to define a codec subnode since on dts you're describing a "link" between your i2s interface and what's outside. Without this quirk alsa won't work. That's why they introduced the dummy codec module inside kernel. The problem is that this module is not working properly on imx8mm. I'm using 5.4.97 linux-fslc-imx and the following dts config on an imx8mm processor.

/dts-v1/;
/plugin/;

#include "imx8mm-pinfunc.h"
#include <dt-bindings/clock/imx8mm-clock.h>

/ {
	compatible = "fsl,imx8mm-evk", "fsl,imx8mm";

	fragment@0 {
		target = <&iomuxc>;
		__overlay__ {
			imx8mm {
				pinctrl_sai3: sai3grp {
					fsl,pins = <
						MX8MM_IOMUXC_SAI3_TXFS_SAI3_TX_SYNC     0xd6
						MX8MM_IOMUXC_SAI3_TXC_SAI3_TX_BCLK      0xd6
						MX8MM_IOMUXC_SAI3_TXD_SAI3_TX_DATA0     0xd6
						MX8MM_IOMUXC_SAI3_RXD_SAI3_RX_DATA0     0xd6
					>;
				};
			};
		};
	};

	fragment@1 {
		target = <&sai3>;
		__overlay__ {
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_sai3>;
			assigned-clocks = <&clk IMX8MM_CLK_SAI3>;
			assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
			assigned-clock-rates = <24576000>;
			status = "okay";
		};
	};

	fragment@2 {
		target-path = "/";
		__overlay__ {
			sound-i2s {
				compatible = "simple-audio-card";
				simple-audio-card,name = "i2s-audio";
				simple-audio-card,format = "left_j";
				simple-audio-card,bitclock-master = <&dailink0_master>;
				simple-audio-card,frame-master = <&dailink0_master>;
				simple-audio-card,widgets =
					"Microphone", "Microphone Jack",
					"Headphone", "Headphone Jack",
					"Speaker", "External Speaker";
				simple-audio-card,routing =
					"MIC_IN", "Microphone Jack",
					"Headphone Jack", "HP_OUT",
					"External Speaker", "LINE_OUT";

				dailink0_master: simple-audio-card,cpu {
					sound-dai = <&sai3>;
					dai-tdm-slot-num = <2>;
					dai-tdm-slot-width = <32>;
				};

				simple-audio-card,codec {
					sound-dai = <&codecdummy1>;
					clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;
				};
			};
		};
	};

	fragment@3 {
		target-path = "/";
		__overlay__ {
			codecdummy1: codec1 {
				#sound-dai-cells = <0>;
				compatible = "linux,snd-soc-dummy";
				status = "okay";
			};
		};
	};
};

 

0 Kudos

568 Views
amalle
Contributor II

Hi @maxipenna ,

I seams to have end up in the same rabbit hole as you.

An I2S microphone on an IMX8MM without the need of a codec. The dummy codec looks like the obvious solution here...

Did you found a solution ?

Regards

0 Kudos

471 Views
maxipenna
Contributor III

Hello, I've found the solution by looking around for other stuff like always

 

https://community.nxp.com/t5/i-MX-Processors/iMX8MM-SAI-I2S-with-dummy-codec/m-p/1275118/highlight/t...

0 Kudos

665 Views
igorpadykov
NXP TechSupport
NXP TechSupport
0 Kudos

654 Views
maxipenna
Contributor III

Hello @igorpadykov, your link contains another example that uses a real codec on i2c. So it's out of topic since we don't have a codec on i2c bus.

0 Kudos

647 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi maxipenna

 

in general one can find many simple-audio-card examples, one more below

https://bootlin.com/blog/eight-channels-audio-on-i-mx7-with-pcm3168/

Regarding your specific case, unfortunately nxp does not "officially" support solution

(verified set of software configurations described in official documents:

i.MX Linux Release Notes , i.MX Linux Reference Manual​ )  without real codec, sorry.

For that reason may be recommended to proceed for further help using

https://contact.nxp.com/new-prof-svcs-sw-tech

 

Best regards
igor

0 Kudos

474 Views
maxipenna
Contributor III

@igorpadykov it seems what you said was not true. Don't know the meaning of "nxp does not "officially" support solution without real codec" either.  I was able to achieve required functionality by using bt-sco driver instead of snd-soc-dummy.

__overlay__ {
                        codecdummy1: codec1 {
                                #sound-dai-cells = <0>;
-                               compatible = "linux,snd-soc-dummy";
+                               compatible = "linux,bt-sco";
                                status = "okay";
                        };
                };

and by adding the corresponding module CONFIG_SND_SOC_BT_SCO=m to my kernel config.

 

Cheers,

1,242 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Jonathan

one can check solution provided on

SAI on i.MX8M Mini 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos