How to execute the driver code of uda1334

I connected the uda1334 module to the orin nx module according to the connection in this article Only Right output works in Adafruit I2S UDA1334A Breakout Board. After plugging in the headphones, there is sound output.

step:

1.pinmux config
2.playback
amixer -c APE cset name="I2S2 Mux" ADMAIF2
aplay -D hw:APE,1 <in_wav>

I noticed that the decoder has a mute function, and there is a corresponding driver in the kernel driver (location: kernel-5.10/sound/soc/codecs/uda1334.c), but I didn’t actually use the uda1334 driver in this way. So I made the following changes to try to use my uda1334 driver.

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index bab95b241..813b78f15 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -994,6 +994,7 @@ CONFIG_SND_SOC_ES7134=m
 CONFIG_SND_SOC_MAX98927=m
 CONFIG_SND_SOC_PCM3168A_I2C=m
 CONFIG_SND_SOC_RT5640=m
+CONFIG_SND_SOC_UDA1334=m
 CONFIG_SND_SOC_SPDIF=m
 CONFIG_SND_SOC_TAS571X=m
 CONFIG_SND_SIMPLE_CARD=m
diff --git a/nvidia/platform/t23x/p3768/kernel-dts/cvb/tegra234-p3767-common-audio.dtsi b/nvidia/platform/t23x/p3768/kernel-dts/cvb/tegra234-p3767-common-audio.dtsi
index 7d79edd..e43dd38 100644
--- a/nvidia/platform/t23x/p3768/kernel-dts/cvb/tegra234-p3767-common-audio.dtsi
+++ b/nvidia/platform/t23x/p3768/kernel-dts/cvb/tegra234-p3767-common-audio.dtsi
@@ -181,6 +181,12 @@
                assigned-clocks = <&bpmp_clks TEGRA234_CLK_AUD_MCLK>;
                assigned-clock-parents = <&bpmp_clks TEGRA234_CLK_PLLA_OUT0>;
        };
+
+       uda1334: audio-codec {
+               compatible = "nxp,uda1334";
+               nxp,mute-gpios = <&tegra_main_gpio TEGRA234_MAIN_GPIO(H, 0) GPIO_ACTIVE_LOW>;
+               nxp,deemph-gpios = <&tegra_main_gpio TEGRA234_MAIN_GPIO(Q, 6) GPIO_ACTIVE_LOW>;
+       };
 };
 
 hdr40_snd_link_i2s: &i2s2_to_codec { };

After completing the above configuration, I used aplay to play, and there was sound, but the code in uda1334.c was still not executed. When I executed aplay to play on other platforms, the uda1334_startup function should be executed, but it was not executed here (the startup member in snd_soc_dai_ops). I want to know how I can set the decoder driver to be executed?

Hello,

It appears that you are only adding the codec node but not hooking it into the DAI link for I2S2, nor adding the codec in the I2C node. Kindly refer to an example codec integration @ Audio Setup and Development — NVIDIA Jetson Linux Developer Guide 1 documentation.

Depending on whether you are using JP5 or JP6, your DT location would be either hardware/nvidia/platform/t23x/p3768/kernel-dts/cvb/tegra234-p3767-common-audio.dtsi or hardware/nvidia/t23x/nv-public/nv-platform/tegra234-p3768-0000.dtsi. You may also refer another example codec integration @ hardware/nvidia/tegra/nv-public/overlay/jetson-audio-fe-pi.dtsi.

Thanks.

I am using jetpack5.1.2. Uda1334 does not have an i2c interface. It converts i2s to analog audio signals. Now it only generates i2s waveforms. What should I do to make the driver executed? I have read the documentation, but it is not very clear.
What I can think of is to modify i2s2_to_codec, but it doesn’t seem to make the driver work.

hdr40_snd_link_i2s: &i2s2_to_codec { 
	bitclock-master;
    frame-master;
	format = "i2s";
	cpu {
        sound-dai = <&tegra_i2s2 0>;
    };

};

This chip do not have i2c interface, so there is no codec node here.

Can you please try this kind override:

&i2s2_to_codec {
	codec {
		sound-dai = <&uda1334 0>;
	};
};

There may not be any I2C interface, but in case you want the driver to be called, it may be necessary to hook into the link.

I have tried this method, but uda1334 is not an iic device and cannot be bound in a similar way. Have you verified the application of uda1334 on orin nx?