ALC5640 registered err on Xavier NX

Hi, I’m working on our custom board using two codec ALC5640, and I configured the I2S device tree as instruction like tihs

    i2c@c240000 {
		rt5640_in: rt5640_in@1c {
			status = "okay";
			compatible = "realtek,rt5640";
        	reg = <0x1c>;
		};
    };	

    i2c@31e0000 {
                rt5640_out: rt5640_out@1c {
			status = "okay";
			compatible = "realtek,rt5640";
        	reg = <0x1c>;	
		};
    };	



        /*ALC5640*/
	tegra_sound: sound {
		status = "okay";
		compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
		nvidia,model = "jetson-xaviernx-ape";

		clocks = <&bpmp_clks TEGRA194_CLK_PLLA>,
			 <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>,
			 <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
		clock-names = "pll_a", "pll_a_out0", "extern1";
		assigned-clocks = <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>,
				  <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
		assigned-clock-parents = <&bpmp_clks TEGRA194_CLK_PLLA>,
					 <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>;

		nvidia,num-codec-link = <2>;

		nvidia,audio-routing =
			"x IN2P"     , "x Line In",
			"x IN2N"     , "x Line In",
			"x IN2P"     , "x Int Mic",
			"x IN2N"     , "x Int Mic",
			"y Line Out" , "y LOUTL",
			"y Line Out" , "y LOUTR";

		nvidia,xbar = <&tegra_axbar>;
		mclk-fs = <256>;

		/*audio output*/
		nvidia,dai-link-1 {
			link-name = "rt5640-playback";
			cpu-dai = <&tegra_i2s3>;
			codec-dai = <&rt5640_out>;
			cpu-dai-name = "I2S3";
			codec-dai-name = "rt5640-aif2";
			format = "i2s";
			bclk_ratio = <1>;			
			bitclock-slave;
			frame-slave;
			bitclock-noninversion;
			frame-noninversion;
			bit-format = "s16_le";
			srate = <48000>;
			num-channel = <2>;
			ignore_suspend;
			name-prefix = "y";
			status = "okay";
		};

		/*audio input*/
		nvidia,dai-link-2 {
			link-name = "rt5640-capture";
			cpu-dai = <&tegra_i2s5>;
			codec-dai = <&rt5640_in>;
			cpu-dai-name = "I2S5";
			codec-dai-name = "rt5640-aif2";
			format = "i2s";
			bclk_ratio = <1>;			
			bitclock-slave;
			frame-slave;
			bitclock-noninversion;
			frame-noninversion;
			bit-format = "s16_le";
			srate = <48000>;
			num-channel = <2>;
			ignore_suspend;
			name-prefix = "x";
			status = "okay";
		};
	};

    /*I2S*/
	ahub {
		i2s@2901400 {
			status = "okay";
		};

		i2s@2901200 {
			status = "okay";
		};
	};

But when boot up, there shows these err message

[    2.082428] tegra-asoc: sound: ASoC: CODEC DAI rt5640-aif2 not registered
[    2.082629] tegra-asoc: sound: snd_soc_register_card failed (-517)

The same codecs chip works fine in our nano module and I check the driver is the same in our L4T version R32.7.3.
It seems only one codec-dai registered failed and I don‘t know how this happened
I’ll be really grateful if you give some help!

I test the audio function and find that it can work fine as recording, so I wonder why this err information shows and will it affect our usage?

Hi,

Could you please help with below details:

  • The output of cat /proc/asound/cards.
  • It is observed that RT5640 DAI interface 2 is in use. Is the I2S connected to DAI 2 of the codec or DAI 1?
nvidia@nvidia:~$ cat /proc/asound/cards
 0 [tegrahdaxnx    ]: tegra-hda-xnx - tegra-hda-xnx
                      tegra-hda-xnx at 0x3518000 irq 65
 1 [jetsonxaviernxa]: jetson-xaviernx - jetson-xaviernx-ape
                      jetson-xaviernx-ape

Yes, we have another device to use rt5640 I2S port. For jetson, it used RT5640’s I2S2

The error is EPROBE_DEFER , which does not affect the use case, as the card is registered later once the required DAIs are successfully registered.

Thanks,but I met another question when use application。
In code use snd_pcm_open() to open the device and use it. But it’s so strange that hw:1,0 can not be open by app, it shows

Error opening PCM device: hw:1,0, errno: [Device or resource busy]

But I use arecord cmd to record audio, there is no err

arecord -D hw:1,0 -c 2 -r 48000 -f S16_LE -d 15 out.wav

why it shows the device is busy?

It appears that PCM device 0 (ADMAIF1) is already in use by another application, which is a common scenario and expected behavior. To avoid this error, you can try using a different ADMAIF instance.

If the issue persists, kindly share the mixer control settings you configured before running the route.

I found that it is used by pulseaudio, and I run

pulseaudio --kill

and restart our app, it can use this device as well.

But the device is connected to I2S5 in jetson which is bound with ADMAIF1, if I want to use a different ADMAIF, how can I set it?

I found that these problem is caused by pulseaudio, when I uninstall it, everything works fine

For another ADMAIF use below command,
amixer -c APE cset name="I2S5 Mux" ADMAIF<i> → For playback
amixer -c APE cset name="ADMAIF<i> Mux" I2S5 → For capture

here, <i> is ADMAIF instance from 1 to <N>.

Thanks, I already tried this. The device can be open as well, but when automatic start with boot up, there is no soud heard in our app, if we delay our app start time it can work fine.
Like I said before it’s pulseaudio’s fault. When uninstalled it, there is no problem

Did you try updating the ALSA conf file, there will be some other I2S instance connected to ADMAIF1 instance?

where to check ALSA conf file? I tried some ways to change pulseaudio’s conf file, but didn’t work. So I uninstalled it

Look for conf files here in the target, /usr/share/alsa/init/postinit/. Modify the entries defined under the APE card name of Xavier NX. To know the card name cat /proc/asound/cards.