Hi, I’m working on our custom board using Nano and we used 2 ALC5640 to capture and playback audio individually.
Accroding to
I configured the dts as follows
i2c@7000c000 {
rt5640_in: rt5640_in@1c {
status = "okay";
compatible = "realtek,rt5640";
reg = <0x1c>;
};
};
i2c@7000c400 {
rt5640_out: rt5640_out@1c {
status = "okay";
compatible = "realtek,rt5640";
reg = <0x1c>;
};
};
........
tegra_sound: sound {
status = "okay";
compatible = "nvidia,tegra-audio-t210ref-mobile-rt565x";
nvidia,model = "tegra-snd-t210ref-mobile-rt5640";
clocks = <&tegra_car TEGRA210_CLK_PLL_A>,
<&tegra_car TEGRA210_CLK_PLL_A_OUT0>,
<&tegra_car TEGRA210_CLK_EXTERN1>;
clock-names = "pll_a", "pll_a_out0", "extern1";
assigned-clocks = <&tegra_car TEGRA210_CLK_EXTERN1>,
<&tegra_car TEGRA210_CLK_PLL_A_OUT0>,
<&tegra_car TEGRA210_CLK_PLL_A>;
assigned-clock-parents = <&tegra_car TEGRA210_CLK_PLL_A_OUT0>;
assigned-clock-rates = <12288000>, <49152000>, <368640000>;
nvidia,num-codec-link = <4>;
nvidia,audio-routing =
"x IN2P" , "x Mic",
"x IN2N" , "x Mic",
"y Headphone", "y LOUTL",
"y Headphone", "y LOUTR",
"y Headphone", "y HPOR",
"y Headphone", "y HPOL";
nvidia,xbar = <&tegra_axbar>;
mclk-fs = <256>;
/*audio input*/
hdr40_snd_link_i2s: i2s_dai_link1: nvidia,dai-link-1 {
link-name = "rt5640-capture";
cpu-dai = <&tegra_i2s4>;
codec-dai = <&rt5640_in>;
cpu-dai-name = "I2S4";
codec-dai-name = "rt5640-aif1";
format = "i2s";
bitclock-slave;
frame-slave;
bitclock-noninversion;
frame-noninversion;
bit-format = "s16_le";
srate = <48000>;
num-channel = <2>;
ignore_suspend;
name-prefix = "x";
status = "okay";
};
/*audio output*/
nvidia,dai-link-2 {
link-name = "rt5640-playback";
cpu-dai = <&tegra_i2s3>;
codec-dai = <&rt5640_out>;
cpu-dai-name = "I2S3";
codec-dai-name = "rt5640-aif1";
format = "i2s";
bitclock-slave;
frame-slave;
bitclock-noninversion;
frame-noninversion;
bit-format = "s16_le";
srate = <48000>;
num-channel = <2>;
ignore_suspend;
name-prefix = "y";
status = "okay";
};
};
/*I2S*/
ahub {
i2s@702d1000 {
status = "okay";
};
i2s@702d1300 {
status = "okay";
};
};
And modified the tegra_machine_driver_mobile.c
to regist our two codecs.
After flash our board and boot it, there is no error in codec register and can see two codec.
But when I tried to test the line-out route by
amixer -c tegrasndt210ref cset name='y HP L Playback Switch' on
amixer -c tegrasndt210ref cset name='y HP R Playback Switch' on
amixer -c tegrasndt210ref cset name='y Stereo DAC MIXL DAC L1 Switch' on
amixer -c tegrasndt210ref cset name='y Stereo DAC MIXR DAC R1 Switch' on
amixer -c tegrasndt210ref cset name='y HPO MIX DAC1 Switch' on
aplay -D hw:1,2 story_long.wav
I get these error message
nvidia@nvidia:~$ aplay -D hw:1,2 story_long.wav
Playing WAVE 'story_long.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
underrun!!! (at least 0.333 ms long)
underrun!!! (at least 0.296 ms long)
Recording to the topics above, I tried these and get this information
echo 0 | sudo tee /sys/kernel/debug/tracing/trace
echo 0 | sudo tee /sys/kernel/debug/tracing/events/enable
echo 1 | sudo tee /sys/kernel/debug/tracing/tracing_on
echo 1 | sudo tee /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_path/enable
echo 1 | sudo tee /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_widget_power/enable
aplay ...
sudo cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 2/2 #P:4
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
aplay-10310 [000] .... 396.108511: snd_soc_dapm_path: *ADMAIF3 Receive <- (direct) <- Playback 3
aplay-10310 [000] .... 396.108543: snd_soc_dapm_path: *ADMAIF3 Receive <- (direct) <- ADMAIF3 CIF Receive-ADMAIF3 Receive
I wonder how to fix this problem, beacause I’m really know nothing about codec configuration.
Thanks!!