The audio codec es8316 can’t work on I2S0 for Xaiver NX

Hi, Engineers
dmesg.txt (91.3 KB)
es8316.c (38.1 KB)
tegra_machine_driver_mobile.c (24.3 KB)
tegra194-audio-p3668.dtsi (2.1 KB)

The audio chip has been successfully registered in our system, but it can’t work normally. There is no sound when playing music.
Measure I2S_LRCK and I2S_SDO and I2S_SCK with an oscilloscope and there is no signal, Only I2S_MCK has a signal, Here are the pictures



es8316.c and DTS and dmesg links are also placed above.

1. sudo find /sys/kernel/debug/asoc/ -name ‘x Playback’

/sys/kernel/debug/asoc/jetson-xaviernx-ape/codec:es8316.1-0010/dapm/x Playback

2. sudo find /sys/kernel/debug/asoc/ -name ‘x Playback’ | xargs -i cat {};

x Playback: Off  in 0 out 0
 stream Playback inactive
 in  "static" "I2S5 DAP Transmit-x Playback"

3. cat /proc/asound/cards

 0 [tegrahdaxnx    ]: tegra-hda-xnx - tegra-hda-xnx
                      tegra-hda-xnx at 0x3518000 irq 66
 1 [jetsonxaviernxa]: jetson-xaviernx - jetson-xaviernx-ape
                      jetson-xaviernx-ape

4. sudo cat /sys/kernel/debug/asoc/codecs

tegra186-dspk.1
tegra186-dspk.0
tegra186-asrc
tegra186-arad
tegra210-ope.0
tegra210-mvc.1
tegra210-mvc.0
tegra186-afc.5
tegra186-afc.4
tegra186-afc.3
tegra186-afc.2
tegra186-afc.1
tegra186-afc.0
tegra210-sfc.3
tegra210-sfc.2
tegra210-sfc.1
tegra210-sfc.0
tegra210-mixer
tegra210-adx.3
tegra210-adx.2
tegra210-adx.1
tegra210-adx.0
tegra210-amx.3
tegra210-amx.2
tegra210-amx.1
tegra210-amx.0
tegra210-dmic.3
tegra210-dmic.2
tegra210-dmic.1
tegra210-dmic.0
tegra210-i2s.5
tegra210-i2s.4
tegra210-i2s.3
tegra210-i2s.2
tegra210-i2s.1
tegra210-i2s.0
tegra186-admaif
tegra210-axbar
spdif_dit:spdif-dit.13@d
spdif_dit:spdif-dit.12@c
spdif_dit:spdif-dit.11@b
spdif_dit:spdif-dit.10@a
spdif_dit:spdif-dit.9@9
spdif_dit:spdif-dit.8@8
spdif_dit:spdif-dit.7@7
spdif_dit:spdif-dit.6@6
spdif_dit:spdif-dit.5@5
spdif_dit:spdif-dit.4@4
spdif_dit:spdif-dit.3@3
spdif_dit:spdif-dit.2@2
spdif_dit:spdif-dit.1@1
spdif_dit:spdif-dit.0@0
es8316.1-0010
snd-soc-dummy

5. es8316 dts:

	i2c@c240000 { 
		es8316_codec: es8316@10 {
			compatible = "everest,es8316";
			reg = <0x10>;
			status = "okay";
		};
	};

6. I2S pinmux:

	pinmux@2430000 {
		status = "okay";
		pinctrl-names = "default";
		pinctrl-0 = <&hdr40_pinmux>;

		hdr40_pinmux: header-40pin-pinmux {
			pin7 {
				nvidia,pins = HDR40_PIN7;
				nvidia,function = HDR40_CLK;
				nvidia,pull = <TEGRA_PIN_PULL_NONE>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
			};

			pin12 {
				nvidia,pins = HDR40_PIN12;
				nvidia,function = HDR40_I2S;
				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
			};

			pin35 {
				nvidia,pins = HDR40_PIN35;
				nvidia,function = HDR40_I2S;
				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
			};

			pin38 {
				nvidia,pins = HDR40_PIN38;
				nvidia,function = HDR40_I2S;
				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
				nvidia,tristate = <TEGRA_PIN_ENABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
			};

			pin40 {
				nvidia,pins = HDR40_PIN40;
				nvidia,function = HDR40_I2S;
				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
				nvidia,enable-input = <TEGRA_PIN_DISABLE>;
			};
		};        
        
	};

Looking forward to your reply, thank you

Hi:
Now I2S_MCK , I2S_SCK , I2S_LRCK have signals here, But es8316 there was still no sound , some problem with routing

1. es8316 I2C dts is here:

	i2c@3160000 {
		status="okay";
		es8316_codec: es8316@10 {
			compatible = "everest,es8316";
			reg = <0x10>;
            clocks = <&tegra_car TEGRA186_CLK_AUD_MCLK>;
            clock-names = "mclk";
			status = "okay";
		};
	};

2. file sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c diff is here:

--- a/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c
+++ b/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c
@@ -29,10 +29,16 @@
 #include <sound/soc.h>
 #include <dt-bindings/sound/tas2552.h>
 #include "rt5659.h"
+#include "es8316.h"
 #include "sgtl5000.h"
 #include "tegra_asoc_machine_alt.h"
 #include "tegra210_xbar_alt.h"
 
+enum {
+       ES8316_SCLK_S_MCLK = 0,
+       ES8316_SCLK_S_PLL1,
+       ES8316_SCLK_S_RCCLK,
+};
 #define DRV_NAME "tegra-asoc:"
 
 #define PARAMS(sformat, channels)              \
@@ -169,6 +175,8 @@ static const struct snd_soc_dapm_widget tegra_machine_dapm_widgets[] = {
        SND_SOC_DAPM_LINE("y Line Out", NULL),
        SND_SOC_DAPM_LINE("x Line In", NULL),
        SND_SOC_DAPM_LINE("y Line In", NULL),
+       SND_SOC_DAPM_LINE("x IN", NULL),
+       SND_SOC_DAPM_LINE("x OUT",NULL),
 };
 
 static struct snd_soc_pcm_stream tegra_machine_asrc_link_params[] = {
@@ -335,13 +343,33 @@ static int tegra_machine_dai_init(struct snd_soc_pcm_runtime *runtime,
 
        aud_mclk = machine->audio_clock.set_aud_mclk_rate;
 
-       pr_debug("pll_a_out0 = %u Hz, aud_mclk = %u Hz, sample rate = %u Hz\n",
+       printk("pll_a_out0 = %u Hz, aud_mclk = %u Hz, sample rate = %u Hz\n",
                 machine->audio_clock.set_pll_out_rate, aud_mclk, srate);
 
        err = tegra_machine_set_params(card, machine, srate, channels, formats);
        if (err < 0)
                return err;
 
+       rtd = snd_soc_get_pcm_runtime(card, "es8316-playback"); //wxz
+       if (rtd) {
+               printk("%s===========8316=======es8316-playback=========== %d\n",__func__,__LINE__);
+               dai_params =
+               (struct snd_soc_pcm_stream *)rtd->dai_link->params;
+
+               dai_params->formats = (machine->fmt_via_kcontrol == 2) ?
+                       (1ULL << SNDRV_PCM_FORMAT_S32_LE) : formats;
+
+        dai_params->rate_min = srate;
+        //dai_params->channels_min = channels;
+
+               //err = es8316_set_dai_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK,aud_mclk, SND_SOC_CLOCK_IN);
+               err = snd_soc_dai_set_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK, 12288000,SND_SOC_CLOCK_IN);
+               if (err < 0) {
+                       dev_err(card->dev, "codec_dai clock not set\n");
+                       return err;
+               }
+       }
+
        rtd = snd_soc_get_pcm_runtime(card, "rt565x-playback");
        if (rtd) {
                dai_params =
@@ -541,6 +569,21 @@ static int tegra_machine_fepi_init(struct snd_soc_pcm_runtime *rtd)
        return 0;
 }
 
+static int tegra_machine_es8316_init(struct snd_soc_pcm_runtime *rtd)  //wxz
+{
+       struct device *dev = rtd->card->dev;
+       int err;
+
+       //err = es8316_set_dai_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK, 11289600,SND_SOC_CLOCK_IN);
+       err = snd_soc_dai_set_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK, 12288000,SND_SOC_CLOCK_IN);
+       if (err) {
+               dev_err(dev, "failed to set es8316 sysclk!\n");
+               return err;
+       }
+
+       return 0;
+}
+
 static int tegra_machine_rt565x_init(struct snd_soc_pcm_runtime *rtd)
 {
        struct snd_soc_card *card = rtd->card;
@@ -602,6 +645,8 @@ static int codec_init(struct tegra_machine *machine)
                        dai_links[i].init = tegra_machine_fepi_init;
                else if (strstr(dai_links[i].name, "respeaker-4-mic-array"))
                        dai_links[i].init = tegra_machine_respeaker_init;
+               else if (strstr(dai_links[i].name, "es8316-playback"))  //wxz
+                       dai_links[i].init = tegra_machine_es8316_init;
        }
 
        return 0;
@@ -784,8 +829,8 @@ static int tegra_machine_driver_probe(struct platform_device *pdev)
 
        ret = snd_soc_register_card(card);
        if (ret) {
-               dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
-                       ret);
+               dev_err(&pdev->dev, "snd_soc_register_card failed (%d) %s %d\n",
+                       ret,__FILE__,__LINE__);
                goto cleanup_asoc;
        }

3. sound dts tegra186-p3636-0001-a00-audio.dtsi diff is here:

--- a/kernel-dts/common/tegra186-p3636-0001-a00-audio.dtsi
+++ b/kernel-dts/common/tegra186-p3636-0001-a00-audio.dtsi
@@ -42,11 +42,67 @@
 
                mclk-fs = <256>;
 
+               nvidia,audio-routing = 
+                "x HPCP L", 	"x HPVOL L",
+            	"x HPCP R",		"x HPVOL R",
+                "x Headphone", 	"x HPOL",
+            	"x Headphone", 	"x HPOR",
+				"x micbias",            	"x MIC1",
+				"x micbias",            	"x MIC2",
+				"x micbias",            	"x DMIC",
+				"x MIC1",               	"x Differential Mux",
+				"x MIC2",               	"x Differential Mux",
+				"x Differential Mux",   	"x Line input PGA", 
+				"x Line input PGA",     	"x Mono ADC", 
+				"x Mono ADC",           	"x Digital Mic Mux", 
+				"x DMIC",               	"x Digital Mic Mux", 
+				"x DMIC",               	"x Digital Mic Mux", 
+				"x Digital Mic Mux",    	"x I2S OUT",
+				"x I2S IN",             	"x DAC SRC Mux", 
+				"x I2S IN",             	"x DAC SRC Mux", 
+				"x I2S IN",             	"x DAC SRC Mux", 
+				"x I2S IN",             	"x DAC SRC Mux", 
+				"x DAC SRC Mux",        	"x Left DAC", 
+				"x DAC SRC Mux",        	"x Right DAC",
+				"x MIC1",               	"x Left Hp mux", 
+				"x MIC2",               	"x Left Hp mux", 
+				"x Differential Mux",   	"x Left Hp mux", 
+				"x Line input PGA",     	"x Left Hp mux", 
+				"x MIC1",               	"x Right Hp mux", 
+				"x MIC2",               	"x Right Hp mux", 
+				"x Differential Mux",   	"x Right Hp mux", 
+				"x Line input PGA",     	"x Right Hp mux", 
+				"x Left Hp mux",        	"x Left Hp mixer",
+				"x Left DAC",				"x Left Hp mixer",
+				"x Right Hp mux",  			"x Right Hp mixer",  	
+				"x Right DAC",     			"x Right Hp mixer",  	
+				"x Left Hp mixer", 			"x HPCP L",				
+				"x Right Hp mixer",			"x HPCP R";
+
+               nvidia,xbar = <&tegra_axbar>;
+
                /* TODO Avoid rt565x_dai_link definition by modifying common base file
                 * since current base does not have definition of dai link as
                 * rt565x_dai_link,  had to add here
                 */
-               hdr40_snd_link_i2s: rt565x_dai_link: nvidia,dai-link-1 { };
+               hdr40_snd_link_i2s: rt565x_dai_link: nvidia,dai-link-1 {
+                       link-name = "es8316-playback";
+                       cpu-dai = <&tegra_i2s1>;
+                       codec-dai = <&es8316_codec>;
+                       cpu-dai-name = "I2S1";
+                       codec-dai-name = "es8316-hifi";
+                       format = "i2s";
+			bitclock-master;
+			frame-master;
+                       bit-format = "s16_le";
+                       srate = <48000>;
+                       num-channel = <2>;
+                       ignore_suspend;
+                       name-prefix = "x";
+                       status = "okay";                        
+               };
                hdr40_i2c1: i2c@c240000 { };
        };
 };

Look forward to your reply, thanks

Hi @wangxiaozhuang, This is the wrong category for your issue. I am moving this topic from the Triton Inference Server category to Jetson Xavier NX.

Thanks for your reply, I have created a topic here, very eager for support, thank you again

Hi wangxiaozhuang,

Can you please check by updating the correct dtsi file?

Step [3] above points to tegra186-p3636-0001-a00-audio.dtsi. You need to modify tegra194-audio-p3668.dtsi, as you originally posted. Please add the related routing controls and share your observations.

Thanks,
Sameer.

Hi spujar,
We have made three products with the same base plate. NX, TX2 and Nano, they are the same phenomenon, 2S_ MCK , I2S_ SCK , I2S_ LRCK pins have signals but no sound:
1,tegra194-audio-p3668.dtsi for NX

/*
 * T194 p3668 audio common DTSI file.
 *
 * Copyright (c) 2019-2020, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 */

#include <audio/tegra-platforms-audio-dai-links.dtsi>

/ {
	aconnect@2a41000 {
		status = "okay";

		agic-controller@2a41000 {
			status = "okay";
		};

		adsp@2993000 {
			status = "okay";
		};
	};
	i2s@2901400 {
		status = "okay";
	};

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


	hda@3510000 {
		hda,card-name = "tegra-hda-xnx";
		status = "okay";
	};

	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>;


	 	mclk-fs = <256>;

		nvidia,audio-routing = 
		"y Headphone",          "y OUT",
		"y IN",                 "y Mic",
		"n Headphone",          "n OUT",
		"n IN",                 "n Mic";

		nvidia,xbar = <&tegra_axbar>;

		nvidia,dai-link-1 {
			name-prefix = "n";
		};

		hdr40_snd_link_i2s: nvidia,dai-link-5 {
#if 1
			link-name = "es8316-playback";
			cpu-dai = <&tegra_i2s5>;
			codec-dai = <&es8316_codec>;
			cpu-dai-name = "I2S5";
			codec-dai-name = "es8316-hifi";
			format = "i2s";
			bitclock-slave;
			frame-slave;
			bitclock-noninversion;
			frame-noninversion;
			bit-format = "s16_le";
			bclk_ratio = <0>;
			srate = <48000>;
			num-channel = <2>;
			ignore_suspend;
#endif
			name-prefix = "x";
			status = "okay";	
		};

	};
};

2,tegra186-p3636-0001-a00-audio.dtsi for TX2

/*
 * Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * T186 p3636-0001-a00 audio common DTSI file.
 */

#include <audio/tegra-platforms-audio-dai-links.dtsi>

/ {
	i2s@2901000 {
		status = "okay";
		bclk-ratio = <4>;
	};

	hda@3510000 {
		status = "okay";
	};
	tegra_sound: sound {
		status = "okay";
		compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
		nvidia,model = "es8316-tegra";
		clocks = <&tegra_car TEGRA186_CLK_PLLA>,
			 <&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
			 <&tegra_car TEGRA186_CLK_AUD_MCLK>;
		clock-names = "pll_a", "pll_a_out0", "extern1";
		assigned-clocks = <&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
				  <&tegra_car TEGRA186_CLK_AUD_MCLK>;
		assigned-clock-parents = <&tegra_car TEGRA186_CLK_PLLA>,
					 <&tegra_car TEGRA186_CLK_PLL_A_OUT0>;

		resets = <&tegra_car TEGRA186_RESET_AUD_MCLK>;
		reset-names = "extern1_rst";

		mclk-fs = <256>;

		nvidia,audio-routing = 
                "x HPCP L", 	"x HPVOL L",
            	"x HPCP R",		"x HPVOL R",
                "x Headphone", 	"x HPOL",
            	"x Headphone", 	"x HPOR",
				"x micbias",            	"x MIC1",
				"x micbias",            	"x MIC2",
				"x micbias",            	"x DMIC",
				"x MIC1",               	"x Differential Mux",
				"x MIC2",               	"x Differential Mux",
				"x Differential Mux",   	"x Line input PGA", 
				"x Line input PGA",     	"x Mono ADC", 
				"x Mono ADC",           	"x Digital Mic Mux", 
				"x DMIC",               	"x Digital Mic Mux", 
				"x DMIC",               	"x Digital Mic Mux", 
				"x Digital Mic Mux",    	"x I2S OUT",
				"x I2S IN",             	"x DAC SRC Mux", 
				"x I2S IN",             	"x DAC SRC Mux", 
				"x I2S IN",             	"x DAC SRC Mux", 
				"x I2S IN",             	"x DAC SRC Mux", 
				"x DAC SRC Mux",        	"x Left DAC", 
				"x DAC SRC Mux",        	"x Right DAC",
				"x MIC1",               	"x Left Hp mux", 
				"x MIC2",               	"x Left Hp mux", 
				"x Differential Mux",   	"x Left Hp mux", 
				"x Line input PGA",     	"x Left Hp mux", 
				"x MIC1",               	"x Right Hp mux", 
				"x MIC2",               	"x Right Hp mux", 
				"x Differential Mux",   	"x Right Hp mux", 
				"x Line input PGA",     	"x Right Hp mux", 
				"x Left Hp mux",        	"x Left Hp mixer",
				"x Left DAC",				"x Left Hp mixer",
				"x Right Hp mux",  			"x Right Hp mixer",  	
				"x Right DAC",     			"x Right Hp mixer",  	
				"x Left Hp mixer", 			"x HPCP L",				
				"x Right Hp mixer",			"x HPCP R";


		nvidia,xbar = <&tegra_axbar>;

		/* TODO Avoid rt565x_dai_link definition by modifying common base file
		 * since current base does not have definition of dai link as
		 * rt565x_dai_link,  had to add here
		 */

		hdr40_snd_link_i2s: rt565x_dai_link: nvidia,dai-link-1 {
			link-name = "es8316-playback";
			cpu-dai = <&tegra_i2s1>;
			codec-dai = <&es8316_codec>;
			cpu-dai-name = "I2S1";
			codec-dai-name = "es8316-hifi";
			format = "i2s";
			bitclock-master;
			frame-master;
			format = "dsp_a";
			fsync-width = <0>;
			bit-format = "s16_le";
			bclk_ratio = <0>;
			srate = <48000>;
        	num-channel = <2>;
        	ignore_suspend;
			name-prefix = "x";
			status = "okay";			
		};
		hdr40_i2c1: i2c@c240000 { };
	};
};

tegra186-p3636-0001-a00-audio.dtsi (19.8 KB)
tegra194-audio-p3668.dtsi (18.1 KB)

Thanks a lot,
wangxiaozhuang.

Hi wangxiaozhuang,

The issue you are facing may be similar to all the products. To make it simpler you can test on one product to start with and similar fix may help remaining products as well.

Lets consider TX2 for example ( tegra186-p3636-0001-a00-audio.dtsi):

  • I checked the codec datasheet (https://www.alldatasheet.com/datasheet-pdf/pdf/1132837/EVEREST/ES8316.html). The MCLK clock seems to expect 256*fs. Any specific reason why you are using fixed 12.288 MHz clock? Can you please check once by making this a function of sample rate?

  • As per your earlier comment, clocks are fine. What is the configuration you are testing (sample rate, channels or sample size)? Also please double check if you are getting expected clock frequencies.

  • Do you intend to operate codec in master mode? If this is not a strict requirement can you check once with codec slave mode?

  • Do you see any errors when you run playback? Does playback run for expected duration and there is no audio at all? Please share logs in case of errors.

Thanks,
Sameer.

Hi, spujar,

  • I have changed MCLK to 2.8MHz, but it doesn’t work , The default clock is 11.30MHz,when I play music on the command line, it becomes 12.30Mhz
--- a/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c
+++ b/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c
@@ -363,7 +363,7 @@ static int tegra_machine_dai_init(struct snd_soc_pcm_runtime *runtime,
         //dai_params->channels_min = channels;
 
                //err = es8316_set_dai_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK,aud_mclk, SND_SOC_CLOCK_IN);
-               err = snd_soc_dai_set_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK, 12288000,SND_SOC_CLOCK_IN);
+               err = snd_soc_dai_set_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK, 2800000,SND_SOC_CLOCK_IN);
                if (err < 0) {
                        dev_err(card->dev, "codec_dai clock not set\n");
                        return err;
@@ -575,7 +575,7 @@ static int tegra_machine_es8316_init(struct snd_soc_pcm_runtime *rtd)       //wxz
        int err;
 
        //err = es8316_set_dai_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK, 11289600,SND_SOC_CLOCK_IN);
-       err = snd_soc_dai_set_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK, 12288000,SND_SOC_CLOCK_IN);
+       err = snd_soc_dai_set_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK,  2800000,SND_SOC_CLOCK_IN);
        if (err) {
                dev_err(dev, "failed to set es8316 sysclk!\n");
                return err;

  • cmdlineis : speaker-test -D hw:es8316tegra,0 -c 2 -r 48000 -F S16_LE -t sine -f 500
    still no sound .

  • Codec as the master mode ? Can I modify it this way? It’s still 11.30MHz.

--- a/kernel-dts/common/tegra186-p3636-0001-a00-audio.dtsi
+++ b/kernel-dts/common/tegra186-p3636-0001-a00-audio.dtsi
@@ -99,8 +99,8 @@
                        cpu-dai-name = "I2S1";
                        codec-dai-name = "es8316-hifi";
                        format = "i2s";
-                       bitclock-master;
-                       frame-master;
+                       bitclock-slave;
+                       frame-slave;
                        format = "dsp_a";
                        fsync-width = <0>;
                        bit-format = "s16_le";

  • dmesg has no errors .
root@nvidia-desktop:/home/nvidia# dmesg  | grep "asoc"
[    1.728433] tegra-asoc: sound: ADMAIF1 <-> ADMAIF1 mapping ok
[    1.728508] tegra-asoc: sound: ADMAIF2 <-> ADMAIF2 mapping ok
[    1.728582] tegra-asoc: sound: ADMAIF3 <-> ADMAIF3 mapping ok
[    1.728651] tegra-asoc: sound: ADMAIF4 <-> ADMAIF4 mapping ok
[    1.728888] tegra-asoc: sound: ADMAIF5 <-> ADMAIF5 mapping ok
[    1.728962] tegra-asoc: sound: ADMAIF6 <-> ADMAIF6 mapping ok
[    1.729028] tegra-asoc: sound: ADMAIF7 <-> ADMAIF7 mapping ok
[    1.729093] tegra-asoc: sound: ADMAIF8 <-> ADMAIF8 mapping ok
[    1.729163] tegra-asoc: sound: ADMAIF9 <-> ADMAIF9 mapping ok
[    1.729229] tegra-asoc: sound: ADMAIF10 <-> ADMAIF10 mapping ok
[    1.729300] tegra-asoc: sound: ADMAIF11 <-> ADMAIF11 mapping ok
[    1.729366] tegra-asoc: sound: ADMAIF12 <-> ADMAIF12 mapping ok
[    1.729434] tegra-asoc: sound: ADMAIF13 <-> ADMAIF13 mapping ok
[    1.729502] tegra-asoc: sound: ADMAIF14 <-> ADMAIF14 mapping ok
[    1.729571] tegra-asoc: sound: ADMAIF15 <-> ADMAIF15 mapping ok
[    1.729639] tegra-asoc: sound: ADMAIF16 <-> ADMAIF16 mapping ok
[    1.729712] tegra-asoc: sound: ADMAIF17 <-> ADMAIF17 mapping ok
[    1.729779] tegra-asoc: sound: ADMAIF18 <-> ADMAIF18 mapping ok
[    1.729845] tegra-asoc: sound: ADMAIF19 <-> ADMAIF19 mapping ok
[    1.729915] tegra-asoc: sound: ADMAIF20 <-> ADMAIF20 mapping ok

root@nvidia-desktop:/home/nvidia# dmesg  | grep "8316"
[    1.527406] es8316_i2c_probe 1163=========================================
[    1.527409] es8316_i2c_probe 1168=========================================
[    1.527452] es8316_i2c_probe 1182=========================================
[    1.527459] es8316_i2c_probe 1237========================================= ret:0
[    1.606226] es8316_probe 1070=========================================
[    1.606388] es8316_probe 1082=========================================
[    1.612269] es8316_probe 1088=========================================
[    1.721835] es8316_init_regs 967=========================================
[    1.723671] es8316_probe 1115=========================================ret:0
[    1.732722] es8316_set_dai_sysclk===========8316codec================== 586
[    1.820772]   #1: es8316-tegra
[   12.265902] tegra_machine_dai_init===========8316=======es8316-playback=========== 355
[   12.265906] es8316_set_dai_sysclk===========8316codec================== 586
[   12.416972] tegra_machine_dai_init===========8316=======es8316-playback=========== 355
[   12.416975] es8316_set_dai_sysclk===========8316codec================== 586
[   12.545349] tegra_machine_dai_init===========8316=======es8316-playback=========== 355
[   12.545352] es8316_set_dai_sysclk===========8316codec================== 586
[   12.557054] tegra_machine_dai_init===========8316=======es8316-playback=========== 355
[   12.557057] es8316_set_dai_sysclk===========8316codec================== 586
[   12.716711] tegra_machine_dai_init===========8316=======es8316-playback=========== 355
[   12.716714] es8316_set_dai_sysclk===========8316codec================== 586
  • Here are the details of demsg

dmesg.txt (110.9 KB)
es8316.c (38.1 KB)

  • Is there a problem with the routing channel on the platform side? Can you help me configure it with amixer ?

contents.txt (293.2 KB)
scontrols.txt (48.4 KB)
controls.txt (54.2 KB)

root@nvidia-desktop:/home/nvidia# cat /proc/asound/cards
 0 [tegrahda       ]: tegra-hda - tegra-hda
                      tegra-hda at 0x3518000 irq 382
 1 [es8316tegra    ]: es8316-tegra - es8316-tegra
                      es8316-tegra

In addition, we have a seven day holiday on national day. We may not reply to you until after national day

thanks,
wangxiaozhuang.

Why you want to change MCLK to 2.8 MHz?
Generally MCLK = 256 * fs (where fs is sample rate) = 256 * 48000 = 12288000 Hz
The driver sets this rate at runtime. See below:

rtd = snd_soc_get_pcm_runtime(card, "es8316-playback");	//wxz
	if (rtd) {
printk("%s===========8316================== %d\n",__func__,__LINE__);
		dai_params =
		(struct snd_soc_pcm_stream *)rtd->dai_link->params;

		dai_params->formats = (machine->fmt_via_kcontrol == 2) ?
			(1ULL << SNDRV_PCM_FORMAT_S32_LE) : formats;

		err = es8316_set_dai_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK,
					     aud_mclk, SND_SOC_CLOCK_IN);
		if (err < 0) {
			dev_err(card->dev, "codec_dai clock not set\n");
			return err;
		}
	}

Do you need a different frequency? Don’t worry about init, it gets overridden at runtime based on the sample rate you run.

There is nothing like"bitclock-slave" or “frame-slave”. You can just drop the “bitclock-master” and “frame-master” from the DT. But what you did should also make the Tegra I2S master. Don’t worry about the initial clock rates. When you start playback, check if all clocks are as expected.

I checked this dump. It seems to have following controls.

Simple mixer control 'z ADC',0
Simple mixer control 'z ADC Double FS Mode',0
Simple mixer control 'z ADC Soft Ramp',0
Simple mixer control 'z ALC Capture Attack Time',0
Simple mixer control 'z ALC Capture Decay Time',0
Simple mixer control 'z ALC Capture Function',0
Simple mixer control 'z ALC Capture Hold Time',0
Simple mixer control 'z ALC Capture Max PGA',0
Simple mixer control 'z ALC Capture Min PGA',0
Simple mixer control 'z ALC Capture NG',0
Simple mixer control 'z ALC Capture NG Threshold',0
Simple mixer control 'z ALC Capture NG Type',0
Simple mixer control 'z ALC Capture Target',0
Simple mixer control 'z Capture Polarity',0
Simple mixer control 'z DAC',0
Simple mixer control 'z DAC Double Fs Mode',0
Simple mixer control 'z DAC Notch Filter',0
Simple mixer control 'z DAC SRC Mux',0
Simple mixer control 'z DAC Soft Ramp Rate',0
Simple mixer control 'z DAC Stereo Enhancement',0
Simple mixer control 'z DAC Volume Control-LeR',0
Simple mixer control 'z Differential Mux',0
Simple mixer control 'z Digital Mic Mux',0
Simple mixer control 'z Enable DAC Soft Ramp',0
Simple mixer control 'z HP',0
Simple mixer control 'z HPMixer Gain',0
Simple mixer control 'z Input PGA',0
Simple mixer control 'z Left Hp mixer LLIN',0
Simple mixer control 'z Left Hp mixer Left DAC',0
Simple mixer control 'z Left Hp mux',0
Simple mixer control 'z MIC Boost',0
Simple mixer control 'z Playback Polarity',0
Simple mixer control 'z Right Hp mixer RLIN',0
Simple mixer control 'z Right Hp mixer Right DAC',0
Simple mixer control 'z Right Hp mux',0

Above controls are related to your codec es8316? I see “z” as prefix. But the DT you pointed earlier uses “x” prefix for mapping machine and codec widgets. Can you please correct this mapping and then check?

Everything else seem normal. Please confirm the codec side mixer settings are fine, because it is difficult for me to guess what exactly is required for codec mixer controls.

Thanks,
Sameer.

Hi,
Very sorry for the late response, I asked for leave a few days ago.

  • I found a product that also uses es8316, measuring his MCLK is 2.8MHz is due to my measurement position error ,the correct value is 11.4MHz.

  • After I remove “bitclock-master” and “frame-master”, MCLK is still 11.30MHz.

--- a/common/tegra194-audio-p3668.dtsi
+++ b/common/tegra194-audio-p3668.dtsi
@@ -100,10 +100,8 @@
                        cpu-dai-name = "I2S5";
                        codec-dai-name = "es8316-hifi";
                        format = "i2s";
-                       bitclock-master;
-                       frame-master;
-                       //bitclock-noninversion;
-                       //frame-noninversion;
+                       //bitclock-master;
+                       //frame-master;
                        //format = "dsp_a";
                        //fsync-width = <0>;
                        bit-format = "s16_le";

tegra194-audio-p3668.dtsi (19.4 KB)

  • “z” as prefix, the latest configuration is as follows, these widgets are from the es8316.c file :
		nvidia,audio-routing =
                "x HPCP L", 	"x HPVOL L",
				"x HPCP R",		"x HPVOL R",
                "x Headphone", 	"x HPOL",
				"x Headphone", 	"x HPOR",
				"x micbias",            	"x MIC1",
				"x micbias",            	"x MIC2",
				"x micbias",            	"x DMIC",
				"x MIC1",               	"x Differential Mux",
				"x MIC2",               	"x Differential Mux",
				"x Differential Mux",   	"x Line input PGA",
				"x Line input PGA",     	"x Mono ADC", 
				"x Mono ADC",           	"x Digital Mic Mux",
				"x DMIC",               	"x Digital Mic Mux",
				"x DMIC",               	"x Digital Mic Mux",
				"x Digital Mic Mux",    	"x I2S OUT",
				"x I2S IN",             	"x DAC SRC Mux",
				"x I2S IN",             	"x DAC SRC Mux",
				"x I2S IN",             	"x DAC SRC Mux",
				"x I2S IN",             	"x DAC SRC Mux",
				"x DAC SRC Mux",        	"x Left DAC", 
				"x DAC SRC Mux",        	"x Right DAC",
				"x MIC1",               	"x Left Hp mux",
				"x MIC2",               	"x Left Hp mux",
				"x Differential Mux",   	"x Left Hp mux",
				"x Line input PGA",     	"x Left Hp mux",
				"x MIC1",               	"x Right Hp mux",
				"x MIC2",               	"x Right Hp mux",
				"x Differential Mux",   	"x Right Hp mux",
				"x Line input PGA",     	"x Right Hp mux",
				"x Left Hp mux",        	"x Left Hp mixer",
				"x Left DAC",				"x Left Hp mixer",
				"x Right Hp mux",  			"x Right Hp mixer",
				"x Right DAC",     			"x Right Hp mixer",
				"x Left Hp mixer", 			"x HPCP L",
				"x Right Hp mixer",			"x HPCP R";

es8316.c (38.1 KB)
scontrols.txt (48.4 KB)

Thanks,
wangxiaozhuang.

Hi wangxiaozhuang

This file is not readable. Can you please attach the correct file?

You are playing 48kHz/2-channel/16-bit audio stream. The expected MCLK clock is 12.288 MHz. As per your previous update, this clock was correct (~12.3 MHz). Can you confirm this again? Note that you need to probe the clocks after your run the speaker-test.

Thanks,
Sameer.

Hi,

  • So sorry, this is the correct file:
    tegra194-audio-p3668.dtsi (3.4 KB)

  • I reconfirmed that it was 11.3MHz before running “speaker-test” and ~12.3MHz after running “speaker-test”.

Thanks,
wangxiaozhuang

Hi,Sameer
I have a few more questions.

1, Why are there so many sound cards here, can they all work? Can I remove other ADMAIFx and keep only one ADMAIF1? Because es8316 only sees one sound card on other CPUs.
Display after executing “aplay - L” command:

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: tegrahdaxnx [tegra-hda-xnx], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: tegrahdaxnx [tegra-hda-xnx], device 7: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: tegrahdaxnx [tegra-hda-xnx], device 8: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: tegrahdaxnx [tegra-hda-xnx], device 9: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 0: ADMAIF1 CIF ADMAIF1-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 1: ADMAIF2 CIF ADMAIF2-1 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 2: ADMAIF3 CIF ADMAIF3-2 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 3: ADMAIF4 CIF ADMAIF4-3 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 4: ADMAIF5 CIF ADMAIF5-4 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 5: ADMAIF6 CIF ADMAIF6-5 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 6: ADMAIF7 CIF ADMAIF7-6 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 7: ADMAIF8 CIF ADMAIF8-7 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 8: ADMAIF9 CIF ADMAIF9-8 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 9: ADMAIF10 CIF ADMAIF10-9 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 10: ADMAIF11 CIF ADMAIF11-10 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 11: ADMAIF12 CIF ADMAIF12-11 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 12: ADMAIF13 CIF ADMAIF13-12 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 13: ADMAIF14 CIF ADMAIF14-13 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 14: ADMAIF15 CIF ADMAIF15-14 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 15: ADMAIF16 CIF ADMAIF16-15 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 16: ADMAIF17 CIF ADMAIF17-16 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 17: ADMAIF18 CIF ADMAIF18-17 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 18: ADMAIF19 CIF ADMAIF19-18 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 19: ADMAIF20 CIF ADMAIF20-19 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

2, After I modify the following files and run the ”sperker-test“ program, The es8616 driver can enter “es8316_pcm_startup” “es8316_pcm_hw_params” and “es8316_mute” functions, but these functions cannot be called before :

  • The “sources/kernel/nvidia/sound/soc/tegra-alt/utils/tegra_asoc_machine_alt.c” file is modified as follows:
@@ -1120,9 +1120,9 @@ struct snd_soc_dai_link tegra186_xbar_dai_links[TEGRA186_XBAR_DAI_LINKS] = {
                .name = "ADMAIF1 CIF",
                .stream_name = "ADMAIF1 CIF",
                .cpu_dai_name = "ADMAIF1",
-               .codec_dai_name = "ADMAIF1",
+               .codec_dai_name = "es8316-hifi",
                .cpu_name = "tegra186-admaif",
-               .codec_name = "tegra210-axbar",
+               .codec_name = "es8316.1-0010",
                .platform_name = "tegra186-admaif",
                .ignore_pmdown_time = 1,
        },

  • The “tegra194-audio-p3668.dtsi” file is modified as follows:
#include <audio/tegra-platforms-audio-dai-links.dtsi>

/ {
	aconnect@2a41000 {
		status = "okay";

		agic-controller@2a41000 {
			status = "okay";
		};

		adsp@2993000 {
			status = "okay";
		};
	};

	hda@3510000 {
		hda,card-name = "tegra-hda-xnx";
		status = "okay";
	};

	tegra_sound: sound {
		status = "okay";
		compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
		nvidia,model = "es8316-tegra";
		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,audio-routing =
			"x Headphone",          "x OUT";

		nvidia,xbar = <&tegra_axbar>;

		mclk-fs = <256>;

		nvidia,dai-link-1 {
			name-prefix = "n";
		};

		hdr40_snd_link_i2s: nvidia,dai-link-5 {
			name-prefix = "x";
			status = "okay";
		};

	};
};

  • Display after executing “aplay - L” command :
**** List of PLAYBACK Hardware Devices ****
card 0: tegrahdaxnx [tegra-hda-xnx], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: tegrahdaxnx [tegra-hda-xnx], device 7: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: tegrahdaxnx [tegra-hda-xnx], device 8: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: tegrahdaxnx [tegra-hda-xnx], device 9: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 0: ADMAIF1 CIF es8316-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 1: ADMAIF2 CIF ADMAIF2-1 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 2: ADMAIF3 CIF ADMAIF3-2 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 3: ADMAIF4 CIF ADMAIF4-3 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 4: ADMAIF5 CIF ADMAIF5-4 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 5: ADMAIF6 CIF ADMAIF6-5 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 6: ADMAIF7 CIF ADMAIF7-6 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 7: ADMAIF8 CIF ADMAIF8-7 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 8: ADMAIF9 CIF ADMAIF9-8 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 9: ADMAIF10 CIF ADMAIF10-9 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 10: ADMAIF11 CIF ADMAIF11-10 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 11: ADMAIF12 CIF ADMAIF12-11 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 12: ADMAIF13 CIF ADMAIF13-12 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 13: ADMAIF14 CIF ADMAIF14-13 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 14: ADMAIF15 CIF ADMAIF15-14 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 15: ADMAIF16 CIF ADMAIF16-15 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 16: ADMAIF17 CIF ADMAIF17-16 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 17: ADMAIF18 CIF ADMAIF18-17 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 18: ADMAIF19 CIF ADMAIF19-18 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: es8316tegra [es8316-tegra], device 19: ADMAIF20 CIF ADMAIF20-19 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
  • Run the ”sperker-test“ program, MCLK is still 12.3MHz, the audio output pin “I2S_ SDO” has no data. Any suggestions? I look forward to your reply .

  • The following is the modification of es8316. C file, only adding some printing at the beginning of the function:
    es8316.c (38.9 KB)

Here is the dmesg information:

root@nvidia-desktop:/home/nvidia# dmesg  | grep "8316"
[    2.253135] es8316_i2c_probe 1171=========================================
[    2.253139] es8316_i2c_probe 1176=========================================
[    2.253200] es8316_i2c_probe 1190=========================================
[    2.253208] es8316_i2c_probe 1245========================================= ret:0
[    2.330556] es8316_probe 1078=========================================
[    2.330577] es8316_probe 1090=========================================
[    2.336833] es8316_probe 1096=========================================
[    2.460927] es8316_init_regs 975=========================================
[    2.466145] es8316_probe 1123=========================================ret:0
[    2.532793] tegra-asoc: sound: es8316-hifi <-> ADMAIF1 mapping ok
[    3.543863]   #1: es8316-tegra
[   12.192713] es8316_pcm_startup 689=========================================
[   12.204273] es8316_pcm_hw_params 776=========================================
[   12.368143] es8316_pcm_startup 689=========================================
[   12.430300] es8316_pcm_hw_params 776=========================================
[   12.431327] es8316_mute 810=========================================
[   12.694965] es8316_pcm_startup 689=========================================
[   12.696773] es8316_pcm_hw_params 776=========================================
[   12.698310] es8316_mute 810=========================================
[   12.829020] es8316_pcm_startup 689=========================================
[   12.894370] es8316_pcm_hw_params 776=========================================
[   12.895004] es8316_mute 810=========================================
[   13.209240] es8316_pcm_startup 689=========================================
[   13.211053] es8316_pcm_hw_params 776=========================================
[   18.415351] es8316_mute 810=========================================
[ 1803.224945] es8316_pcm_startup 689=========================================
[ 1803.299709] es8316_pcm_hw_params 776=========================================
[ 1803.300736] es8316_mute 810=========================================
[ 1807.306781] es8316_mute 810=========================================
[ 1827.559439] es8316_mute 810=========================================
[ 2275.334851] es8316_pcm_startup 689=========================================
[ 2275.399522] es8316_pcm_hw_params 776=========================================
[ 2275.400437] es8316_mute 810=========================================
[ 2276.775491] es8316_mute 810=========================================

Thanks.
wangxiaozhuang

Hi wangxiaozhuang,

12.3 MHz is expected rate once you start the speaker-test. So from clocking point of view it appears good.

What you see here are the playback or capture HW devices. Multiple devices can be used when there is a requirement of multiple stream playback or capture (For ex: ADMAIF1, ADMAIF2 …). You don’t have to worry about this. Your case may require just one device (ADMAIF1) and you can just use that. You can check following to see number of available sound cards:
cat /proc/asound/cards

Don’t modify this.

This looks incorrect. Can you try with following?

diff --git a/common/tegra194-audio-p3668.dtsi b/common/tegra194-audio-p3668.dtsi
index 32ea0bd..8188165 100644
--- a/common/tegra194-audio-p3668.dtsi
+++ b/common/tegra194-audio-p3668.dtsi
@@ -33,6 +33,14 @@
                status = "okay";
        };

+       i2c@c240000 {
+               es8316_codec: es8316@10 {
+                       compatible = "everest,es8316";
+                       reg = <0x10>;
+                       status = "okay";
+               };
+       };
+
        tegra_sound: sound {
                status = "okay";
                compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
@@ -47,8 +55,8 @@
                                         <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>;

                nvidia,audio-routing =
-                       "x Headphone",          "x OUT",
-                       "x IN",                 "x Mic",
+                       "x Headphone",          "x HPOL",
+                       "x Headphone",          "x HPOR",
                        "y Headphone",          "y OUT",
                        "y IN",                 "y Mic",
                        "z Headphone",          "z OUT",
@@ -74,6 +82,10 @@

                hdr40_snd_link_i2s: nvidia,dai-link-5 {
                        name-prefix = "x";
+
+                       link-name = "es8316-playback";
+                       codec-dai = <&es8316_codec>;
+                       codec-dai-name = "es8316-hifi";
                };

        };

Before you run speaker-test, set up audio path.

amixer -c es8316tegra "I2S5 Mux" "ADMAIF1"
speaker-test -D hw:es8316tegra,0 -c 2 -r 48000 -F S16_LE -t sine -f 500

Also are you checking playback on speaker or headphone? I see es8316 has some switch controls for headphone path. Try turning these switches ON before you start speaker-test.

numid=1143,iface=MIXER,name='x Left Hp mixer LLIN Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=1144,iface=MIXER,name='x Left Hp mixer Left DAC Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=1145,iface=MIXER,name='x Right Hp mixer RLIN Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=1146,iface=MIXER,name='x Right Hp mixer Right DAC Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off

Once you start speaker-test, you should see pcm_startup() and hw_param() calls from your codec driver. Keep those debug prints enabled as you have now.

Thanks,
Sameer.

Hi,Sameer

The “tegra_asoc_machine_alt.c” file has been restored without any modification ,And executed the following commands, except that MCLK has 12.3 MHz clock signal, other pins have no signal :

  • The “tegra194-audio-p3668.dtsi” file is modified as follows:
#include <audio/tegra-platforms-audio-dai-links.dtsi>

/ {
	aconnect@2a41000 {
		status = "okay";

		agic-controller@2a41000 {
			status = "okay";
		};

		adsp@2993000 {
			status = "okay";
		};
	};

	hda@3510000 {
		hda,card-name = "tegra-hda-xnx";
		status = "okay";
	};

	i2c@c240000 { 
		es8316_codec: es8316@10 {
			compatible = "everest,es8316";
			reg = <0x10>;
			status = "okay";
		};
	};

	tegra_sound: sound {
		status = "okay";
		compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
		nvidia,model = "es8316-tegra";
		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,audio-routing =
                        "x Headphone",          "x HPOL",
                        "x Headphone",          "x HPOR",
                        "y Headphone",          "y OUT",
                        "y IN",                 "y Mic",
                        "z Headphone",          "z OUT",
						"z IN",                 "z Mic",
						"m Headphone",          "m OUT",
						"m IN",                 "m Mic",
						"n Headphone",          "n OUT",
						"n IN",                 "n Mic",
						"o Headphone",          "o OUT",
						"o IN",                 "o Mic",
						"a IN",                 "a Mic",
						"b IN",                 "b Mic",
						"c IN",                 "c Mic",
						"d IN",                 "d Mic",
						"d1 Headphone",         "d1 OUT",
						"d2 Headphone",         "d2 OUT";

		nvidia,xbar = <&tegra_axbar>;

		mclk-fs = <256>;

		nvidia,dai-link-1 {
			name-prefix = "n";
		};

		hdr40_snd_link_i2s: nvidia,dai-link-5 {
			name-prefix = "x";
            link-name = "es8316-playback";
            codec-dai = <&es8316_codec>;
            codec-dai-name = "es8316-hifi";
			status = "okay";
		};

	};
};

  • Executed the following commands
amixer -c es8316tegra cset name="I2S5 Mux" "ADMAIF1"
amixer -c es8316tegra cset name="x Left Hp mixer LLIN Switch" 1
amixer -c es8316tegra cset name="x Left Hp mixer Left DAC Switch" 1
amixer -c es8316tegra cset name="x Right Hp mixer RLIN Switch" 1
amixer -c es8316tegra cset name="x Right Hp mixer Right DAC Switch" 1
speaker-test -D hw:es8316tegra,0 -c 2 -r 48000 -F S16_LE -t sine -f 500 music.wav

speaker-test 1.1.3

Playback device is hw:es8316tegra,0
Stream parameters are 48000Hz, S16_LE, 2 channels
Sine wave rate is 500.0000Hz
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 32 to 8192
Period size range from 32 to 4096
Using max buffer size 8192
Periods = 4
was set period_size = 2048
was set buffer_size = 8192
 0 - Front Left
 1 - Front Right
Time per period = 0.112104
 0 - Front Left
 1 - Front Right
Time per period = 0.112295
 0 - Front Left
 1 - Front Right
Time per period = 0.112333
 0 - Front Left
 1 - Front Right
Time per period = 0.112348
 0 - Front Left
 1 - Front Right
Time per period = 0.112328
 0 - Front Left
 1 - Front Right
Time per period = 0.112309
 0 - Front Left
 1 - Front Right
Time per period = 0.112339
 0 - Front Left
......

  • The following is the status in contents:
numid=1143,iface=MIXER,name='x Left Hp mixer LLIN Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=1144,iface=MIXER,name='x Left Hp mixer Left DAC Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=1145,iface=MIXER,name='x Right Hp mixer RLIN Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=1146,iface=MIXER,name='x Right Hp mixer Right DAC Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on

amixer -c es8316tegra scontrols > scontrols.txt
amixer -c es8316tegra controls > controls.txt
amixer -c es8316tegra contents > contents.txt
contents.txt (293.2 KB)
scontrols.txt (48.4 KB)
controls.txt (53.8 KB)

  • Here is the dmesg information, the functions pcm_startup() and hw_param() were not called from my codec driver:
root@nvidia-desktop:/home/nvidia# dmesg  | grep "asoc"
dmesg  | grep "8316"
[    2.686527] tegra-asoc: sound: ADMAIF1 <-> ADMAIF1 mapping ok
[    2.686633] tegra-asoc: sound: ADMAIF2 <-> ADMAIF2 mapping ok
[    2.686734] tegra-asoc: sound: ADMAIF3 <-> ADMAIF3 mapping ok
[    2.686839] tegra-asoc: sound: ADMAIF4 <-> ADMAIF4 mapping ok
[    2.686935] tegra-asoc: sound: ADMAIF5 <-> ADMAIF5 mapping ok
[    2.687064] tegra-asoc: sound: ADMAIF6 <-> ADMAIF6 mapping ok
[    2.687187] tegra-asoc: sound: ADMAIF7 <-> ADMAIF7 mapping ok
[    2.687309] tegra-asoc: sound: ADMAIF8 <-> ADMAIF8 mapping ok
[    2.687412] tegra-asoc: sound: ADMAIF9 <-> ADMAIF9 mapping ok
[    2.687508] tegra-asoc: sound: ADMAIF10 <-> ADMAIF10 mapping ok
[    2.687603] tegra-asoc: sound: ADMAIF11 <-> ADMAIF11 mapping ok
[    2.687692] tegra-asoc: sound: ADMAIF12 <-> ADMAIF12 mapping ok
[    2.687784] tegra-asoc: sound: ADMAIF13 <-> ADMAIF13 mapping ok
[    2.687887] tegra-asoc: sound: ADMAIF14 <-> ADMAIF14 mapping ok
[    2.687984] tegra-asoc: sound: ADMAIF15 <-> ADMAIF15 mapping ok
[    2.688061] tegra-asoc: sound: ADMAIF16 <-> ADMAIF16 mapping ok
[    2.688157] tegra-asoc: sound: ADMAIF17 <-> ADMAIF17 mapping ok
[    2.688232] tegra-asoc: sound: ADMAIF18 <-> ADMAIF18 mapping ok
[    2.688306] tegra-asoc: sound: ADMAIF19 <-> ADMAIF19 mapping ok
[    2.688419] tegra-asoc: sound: ADMAIF20 <-> ADMAIF20 mapping ok
root@nvidia-desktop:/home/nvidia# dmesg  | grep "8316"
[    2.418568] es8316_i2c_probe 1171=========================================
[    2.418572] es8316_i2c_probe 1176=========================================
[    2.418641] es8316_i2c_probe 1190=========================================
[    2.418651] es8316_i2c_probe 1245========================================= ret:0
[    2.550148] es8316_probe 1078=========================================
[    2.550213] es8316_probe 1090=========================================
[    2.556568] es8316_probe 1096=========================================
[    2.676934] es8316_init_regs 975=========================================
[    2.682101] es8316_probe 1123=========================================ret:0
[    2.691096] tegra_machine_es8316_init 590=========================================
[    2.691099] es8316_set_dai_sysclk 562=========================================
[    2.691101] es8316_set_dai_sysclk===========8316codec================== 579
[    2.691104] es8316_set_dai_fmt 603=========================================
[    3.699929]   #1: es8316-tegra
[   12.596084] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[   12.596088] es8316_set_dai_sysclk 562=========================================
[   12.596092] es8316_set_dai_sysclk===========8316codec================== 579
[   12.749777] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[   12.749880] es8316_set_dai_sysclk 562=========================================
[   12.749889] es8316_set_dai_sysclk===========8316codec================== 579
[   12.871621] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[   12.871628] es8316_set_dai_sysclk 562=========================================
[   12.871633] es8316_set_dai_sysclk===========8316codec================== 579
[   12.888984] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[   12.888991] es8316_set_dai_sysclk 562=========================================
[   12.888996] es8316_set_dai_sysclk===========8316codec================== 579
[   13.074740] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[   13.074747] es8316_set_dai_sysclk 562=========================================
[   13.074753] es8316_set_dai_sysclk===========8316codec================== 579
[ 1884.210144] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[ 1884.210150] es8316_set_dai_sysclk 562=========================================
[ 1884.210155] es8316_set_dai_sysclk===========8316codec================== 579
cat /proc/asound/cards 
 0 [tegrahdaxnx    ]: tegra-hda-xnx - tegra-hda-xnx
                      tegra-hda-xnx at 0x3518000 irq 66
 1 [es8316tegra    ]: es8316-tegra - es8316-tegra
                      es8316-tegra

sudo cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 0/0   #P:4
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |

Thanks,
wangxiaozhuang

Hi wangxiaozhuang,

Can you please confirm if you are testing on heapdhone?

**This points to some DAPM routing problem. This needs to be fixed before you proceed.
I had a look at es8316 codec driver. The “I2S IN” widget seems to use “I2S1 Playback” stream which I don’t find in the codec driver. Can you try if below helps?
diff --git a/es8316.c b/es8316.c
index c00931e…7ad827c 100644

--- a/es8316.c
+++ b/es8316.c
@@ -325,7 +325,7 @@ static const struct snd_soc_dapm_widget es8316_dapm_widgets[] = {
        SND_SOC_DAPM_AIF_OUT("I2S OUT", "I2S1 Capture",  1,
                             ES8316_SDP_ADCFMT_REG0A, 6, 0),

-       SND_SOC_DAPM_AIF_IN("I2S IN", "I2S1 Playback", 0,
+       SND_SOC_DAPM_AIF_IN("I2S IN", "Playback", 0,
                            SND_SOC_NOPM, 0, 0),

        /*  DACs DATA SRC MUX */

The DAPM trace logs you captured in previous comment is incomplete. Please enable trace events before you start speaker-test. Dump the trace logs once the speaker-test is done.

Also try with following controls only:

numid=1144,iface=MIXER,name='x Left Hp mixer Left DAC Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=1146,iface=MIXER,name='x Right Hp mixer Right DAC Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on

Thanks.

Hi, Sameer

Thank you very much. Great progress has been made according to your guidance

  1. Both heapdone and speaker are connected to sound output devices.

  2. Run the “speaker-test” and the signals can be detected on “I2S_MCK” “I2S_SCK” “I2S_SDO” and “I2S_LRCK” pins.

amixer -c es8316tegra cset name="I2S5 Mux" "ADMAIF1"
amixer -c es8316tegra cset name="x Left Hp mixer Left DAC Switch" 1
amixer -c es8316tegra cset name="x Right Hp mixer Right DAC Switch" 1

  1. The frequency of "I2S_ SCK” and “I2S_LRCK ” are correct?

I2S_MCK:


I2S_SCK:

I2S_SDO:

I2S_LPCK:

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_widget_power/enable

speaker-test -D hw:es8316tegra,0 -c 2 -r 48000 -F S16_LE -t sine -f 500 

sudo cat /sys/kernel/debug/tracing/trace
  1. Here is the complete trace
sudo cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 26/26   #P:4
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
    speaker-test-8177  [001] ....    97.410536: snd_soc_dapm_widget_power: widget=Playback 1 val=1
    speaker-test-8177  [001] ....    97.410543: snd_soc_dapm_widget_power: widget=ADMAIF1 Receive val=1
    speaker-test-8177  [001] ....    97.410546: snd_soc_dapm_widget_power: widget=ADMAIF1 RX val=1
    speaker-test-8177  [001] ....    97.410552: snd_soc_dapm_widget_power: widget=I2S5 Mux val=1
    speaker-test-8177  [001] ....    97.410554: snd_soc_dapm_widget_power: widget=I2S5 TX val=1
    speaker-test-8177  [001] ....    97.410556: snd_soc_dapm_widget_power: widget=I2S5 Transmit val=1
    speaker-test-8177  [001] ....    97.410558: snd_soc_dapm_widget_power: widget=I2S5 Transmit-I2S5 CIF Receive val=1
    speaker-test-8177  [001] ....    97.410560: snd_soc_dapm_widget_power: widget=I2S5 CIF Receive val=1
    speaker-test-8177  [001] ....    97.410562: snd_soc_dapm_widget_power: widget=I2S5 CIF RX val=1
    speaker-test-8177  [001] ....    97.410564: snd_soc_dapm_widget_power: widget=I2S5 DAP TX val=1
    speaker-test-8177  [001] ....    97.410566: snd_soc_dapm_widget_power: widget=I2S5 DAP Transmit val=1
    speaker-test-8177  [001] ....    97.410568: snd_soc_dapm_widget_power: widget=I2S5 DAP Transmit-x Playback val=1
    speaker-test-8177  [001] ....    97.410569: snd_soc_dapm_widget_power: widget=x Playback val=1
    speaker-test-8177  [001] ....    97.410571: snd_soc_dapm_widget_power: widget=x I2S IN val=1
    speaker-test-8177  [001] ....    97.410573: snd_soc_dapm_widget_power: widget=x DAC SRC Mux val=1
    speaker-test-8177  [001] ....    97.410575: snd_soc_dapm_widget_power: widget=x Right DAC val=1
    speaker-test-8177  [001] ....    97.410577: snd_soc_dapm_widget_power: widget=x Left DAC val=1
    speaker-test-8177  [001] ....    97.410579: snd_soc_dapm_widget_power: widget=x Right Hp mixer val=1
    speaker-test-8177  [001] ....    97.410581: snd_soc_dapm_widget_power: widget=x Left Hp mixer val=1
    speaker-test-8177  [001] ....    97.410583: snd_soc_dapm_widget_power: widget=x HPCP R val=1
    speaker-test-8177  [001] ....    97.410586: snd_soc_dapm_widget_power: widget=x HPCP L val=1
    speaker-test-8177  [001] ....    97.410588: snd_soc_dapm_widget_power: widget=x HPVOL R val=1
    speaker-test-8177  [001] ....    97.410590: snd_soc_dapm_widget_power: widget=x HPVOL L val=1
    speaker-test-8177  [001] ....    97.410592: snd_soc_dapm_widget_power: widget=x HPOR val=1
    speaker-test-8177  [001] ....    97.410594: snd_soc_dapm_widget_power: widget=x HPOL val=1
    speaker-test-8177  [001] ....    97.410596: snd_soc_dapm_widget_power: widget=x Headphone val=1
root@nvidia-desktop:/home/nvidia# 

But there is still no sound from the speakers or headphones, Any suggestions ?

contents.txt (293.2 KB)
scontrols.txt (48.4 KB)
controls.txt (53.8 KB)

I play music with “aplay”, the frequencies of “I2S_MCK” “I2S_SCK” and “I2S_LRCK” are 5.65Mhz, 706KHz and 22KHz respectively. Is that normal ?

aplay -D hw:es8316tegra music.wav 
Playing WAVE 'music.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Stereo

This playback is the same result, and the kernel throws an exception after playing for a while:

aplay -D hw:es8316tegra,0 -r 48000 music.wav
Playing WAVE 'music.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Stereo

[  486.313693] Unable to handle kernel NULL pointer dereference at virtual address 00000628
[  486.313896] Mem abort info:
[  486.313960]   ESR = 0x96000005
[  486.314027]   Exception class = DABT (current EL), IL = 32 bits
[  486.314131]   SET = 0, FnV = 0
[  486.314190]   EA = 0, S1PTW = 0
[  486.314277] Data abort info:
[  486.314335]   ISV = 0, ISS = 0x00000005
[  486.314406]   CM = 0, WnR = 0
[  486.314474] user pgtable: 4k pages, 39-bit VAs, pgd = ffffffc1b7dfb000
[  486.314582] [0000000000000628] *pgd=0000000000000000, *pud=0000000000000000
[  486.314747] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[  486.314849] Modules linked in: fuse xt_conntrack ipt_MASQUERADE nf_nat_masquerade_ipv4 nf_conntrack_netlink nfnetlink xt_addrtype iptable_filter iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack br_netfilter zram 8723bu cfg80211 overlay userspace_alert nvgpu ip_tables x_tables
[  486.316124] CPU: 0 PID: 8098 Comm: aplay Not tainted 4.9.253-tegra #17
[  486.316593] Hardware name: NVIDIA Jetson Xavier NX Developer Kit (DT)
[  486.319431] task: ffffffc19eb6e200 task.stack: ffffffc1b904c000
[  486.324970] PC is at es8316_pcm_shutdown+0x20/0x168
[  486.330199] LR is at snd_soc_dai_link_event+0x27c/0x3d0
[  486.335443] pc : [<ffffff8008d72538>] lr : [<ffffff8008d61ccc>] pstate: 60400045
[  486.342705] sp : ffffffc1b904f890
[  486.345953] x29: ffffffc1b904f890 x28: 00000000ffffffff 
[  486.351456] x27: 00000000ffffffff x26: 0000000000000001 
[  486.356969] x25: ffffff800a1b2aa8 x24: ffffffc1e12b8840 
[  486.362567] x23: 0000000000000004 x22: ffffffc1e26956c0 
[  486.367396] x21: 0000000000000000 x20: ffffffc1da456c00 
[  486.372982] x19: ffffffc1b904f908 x18: 0000000000003524 
[  486.378754] x17: 0000007f8334cd40 x16: ffffff8008274b68 
[  486.384439] x15: 0000000000000345 x14: 000000000000293c 
[  486.390128] x13: 000000000000362b x12: 0000000000000400 
[  486.395817] x11: 000000000000000b x10: 0101010101010101 
[  486.401345] x9 : 0000000000000003 x8 : 7f7f7f7f7f7f7f7f 
[  486.407364] x7 : fefefeff646c606d x6 : 00170401e9e1acf4 
[  486.412630] x5 : 742c616901041700 x4 : 8080808000000000 
[  486.417966] x3 : b34b234b0963a000 x2 : ffffff8008d72518 
[  486.423552] x1 : 0000000000000000 x0 : 0000000000000000 
[  486.428643] 
[  486.430296] Process aplay (pid: 8098, stack limit = 0xffffffc1b904c000)
[  486.436682] Call trace:
[  486.438790] [<ffffff8008d72538>] es8316_pcm_shutdown+0x20/0x168
[  486.444647] [<ffffff8008d61ccc>] snd_soc_dai_link_event+0x27c/0x3d0
[  486.450254] [<ffffff8008d63350>] dapm_seq_check_event.isra.27+0x118/0x2d0
[  486.456722] [<ffffff8008d635e8>] dapm_seq_run_coalesced+0xb0/0x1e0
[  486.462326] [<ffffff8008d638bc>] dapm_seq_run+0x1a4/0x3d0
[  486.467660] [<ffffff8008d64a24>] dapm_power_widgets+0x484/0x9e0
[  486.473259] [<ffffff8008d673dc>] snd_soc_dapm_stream_event+0x9c/0xb8
[  486.479126] [<ffffff8008d6b278>] soc_pcm_close+0x158/0x2a0
[  486.484463] [<ffffff8008d1a64c>] snd_pcm_release_substream.part.17+0x5c/0xb0
[  486.490848] [<ffffff8008d1a7a4>] snd_pcm_release+0xb4/0xd0
[  486.496017] [<ffffff800825dcb8>] __fput+0x90/0x1d0
[  486.500825] [<ffffff800825de70>] ____fput+0x20/0x30
[  486.505643] [<ffffff80080d8dac>] task_work_run+0xbc/0xd8
[  486.511324] [<ffffff800808b334>] do_notify_resume+0xa4/0xb0
[  486.517096] [<ffffff800808379c>] work_pending+0x8/0x10
[  486.522093] ---[ end trace d5e71913c34b44b1 ]---
Segmentation fault
root@nvidia-desktop:/home/nvidia# 
root@nvidia-desktop:/home/nvidia# 

I guess the music “music.wav” is over.

Thanks
wangxiaozhuang

Hi wangxiaozhuang,

It is looking better.

Yes the clock frequencies seem to be correct. This confirms pinmux, driver and DT settings are fine.

You have to enable asoc events related to DAPM path. Please refer to section.

I hope you are getting codec pcm_startup() and hw_param() calls now. Can you please confirm?

I don’t know the stream configuration of music.wav and hence won’t be able to comment on this.
Test with below stream (it is 48000 Hz, 2-channel and 16-bit) and you should see the same clock frequencies with what you were getting for speaker-test run earlier.

Yes the music is probably over and the codec driver crashes when it finishes.

Thanks.

Hi,Sameer
Play your wav file and the clock is correct, but the codec driver is also broken, why ?

aplay -D hw:es8316tegra test.wav 
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
[ 1232.810104] Unable to handle kernel NULL pointer dereference at virtual address 00000628
[ 1232.810276] Mem abort info:
[ 1232.810367]   ESR = 0x96000005
[ 1232.810437]   Exception class = DABT (current EL), IL = 32 bits
[ 1232.810539]   SET = 0, FnV = 0
[ 1232.810597]   EA = 0, S1PTW = 0
[ 1232.810670] Data abort info:
[ 1232.810753]   ISV = 0, ISS = 0x00000005
[ 1232.810824]   CM = 0, WnR = 0
[ 1232.810886] user pgtable: 4k pages, 39-bit VAs, pgd = ffffffc1da320000
[ 1232.810994] [0000000000000628] *pgd=0000000000000000, *pud=0000000000000000
[ 1232.811145] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[ 1232.811246] Modules linked in: fuse xt_conntrack ipt_MASQUERADE nf_nat_masquerade_ipv4 nf_conntrack_netlink nfnetlink xt_addrtype iptable_filter iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack br_netfilter zram userspace_alert overlay 8723bu cfg80211 nvgpu ip_tables x_tables
[ 1232.812530] CPU: 0 PID: 8639 Comm: aplay Not tainted 4.9.253-tegra #18
[ 1232.812997] Hardware name: NVIDIA Jetson Xavier NX Developer Kit (DT)
[ 1232.815579] task: ffffffc1a0376200 task.stack: ffffffc1f62fc000
[ 1232.821366] PC is at es8316_pcm_shutdown+0x20/0x168
[ 1232.826350] LR is at snd_soc_dai_link_event+0x27c/0x3d0
[ 1232.831595] pc : [<ffffff8008d72668>] lr : [<ffffff8008d61ccc>] pstate: 60400045
[ 1232.838854] sp : ffffffc1f62ff890
[ 1232.842094] x29: ffffffc1f62ff890 x28: 00000000ffffffff 
[ 1232.847862] x27: 00000000ffffffff x26: 0000000000000001 
[ 1232.853376] x25: ffffff800a1b2aa8 x24: ffffffc1e10e50c0 
[ 1232.858973] x23: 0000000000000004 x22: ffffffc1e10496c0 
[ 1232.864048] x21: 0000000000000000 x20: ffffffc1a502e400 
[ 1232.869137] x19: ffffffc1f62ff908 x18: 0000000000000de3 
[ 1232.875160] x17: 0000000000004378 x16: 0000000000001a8f 
[ 1232.880848] x15: 0000000000000046 x14: 00000000000041d5 
[ 1232.886535] x13: 000000000000a44f x12: 0000000000000400 
[ 1232.892222] x11: 000000000000000b x10: 0101010101010101 
[ 1232.897999] x9 : 0000000000000003 x8 : 7f7f7f7f7f7f7f7f 
[ 1232.903525] x7 : fefefeff646c606d x6 : 00170401e9e1acf4 
[ 1232.909037] x5 : 742c616901041700 x4 : 8080808000000000 
[ 1232.914624] x3 : b34b234b0963a000 x2 : ffffff8008d72648 
[ 1232.919961] x1 : 0000000000000000 x0 : 0000000000000000 
[ 1232.925297] 
[ 1232.926702] Process aplay (pid: 8639, stack limit = 0xffffffc1f62fc000)
[ 1232.932831] Call trace:
[ 1232.935197] [<ffffff8008d72668>] es8316_pcm_shutdown+0x20/0x168
[ 1232.941054] [<ffffff8008d61ccc>] snd_soc_dai_link_event+0x27c/0x3d0
[ 1232.946918] [<ffffff8008d63350>] dapm_seq_check_event.isra.27+0x118/0x2d0
[ 1232.953047] [<ffffff8008d635e8>] dapm_seq_run_coalesced+0xb0/0x1e0
[ 1232.958992] [<ffffff8008d638bc>] dapm_seq_run+0x1a4/0x3d0
[ 1232.964066] [<ffffff8008d64a24>] dapm_power_widgets+0x484/0x9e0
[ 1232.969411] [<ffffff8008d673dc>] snd_soc_dapm_stream_event+0x9c/0xb8
[ 1232.975792] [<ffffff8008d6b278>] soc_pcm_close+0x158/0x2a0
[ 1232.980869] [<ffffff8008d1a64c>] snd_pcm_release_substream.part.17+0x5c/0xb0
[ 1232.987083] [<ffffff8008d1a7a4>] snd_pcm_release+0xb4/0xd0
[ 1232.992425] [<ffffff800825dcb8>] __fput+0x90/0x1d0
[ 1232.997491] [<ffffff800825de70>] ____fput+0x20/0x30
[ 1233.002306] [<ffffff80080d8dac>] task_work_run+0xbc/0xd8
[ 1233.007732] [<ffffff800808b334>] do_notify_resume+0xa4/0xb0
[ 1233.013504] [<ffffff800808379c>] work_pending+0x8/0x10
[ 1233.018500] ---[ end trace b343e83717dfe884 ]---
Segmentation fault
root@nvidia-desktop:/home/nvidia# 

pcm_startup() and hw_param() functions were called:

root@nvidia-desktop:/home/nvidia#  dmesg  | grep "asoc"
dmesg  | grep "8316"
[    2.619806] tegra-asoc: sound: ADMAIF1 <-> ADMAIF1 mapping ok
[    2.619942] tegra-asoc: sound: ADMAIF2 <-> ADMAIF2 mapping ok
[    2.620060] tegra-asoc: sound: ADMAIF3 <-> ADMAIF3 mapping ok
[    2.620160] tegra-asoc: sound: ADMAIF4 <-> ADMAIF4 mapping ok
[    2.620253] tegra-asoc: sound: ADMAIF5 <-> ADMAIF5 mapping ok
[    2.620351] tegra-asoc: sound: ADMAIF6 <-> ADMAIF6 mapping ok
[    2.620442] tegra-asoc: sound: ADMAIF7 <-> ADMAIF7 mapping ok
[    2.620536] tegra-asoc: sound: ADMAIF8 <-> ADMAIF8 mapping ok
[    2.620635] tegra-asoc: sound: ADMAIF9 <-> ADMAIF9 mapping ok
[    2.620754] tegra-asoc: sound: ADMAIF10 <-> ADMAIF10 mapping ok
[    2.620853] tegra-asoc: sound: ADMAIF11 <-> ADMAIF11 mapping ok
[    2.620944] tegra-asoc: sound: ADMAIF12 <-> ADMAIF12 mapping ok
[    2.621024] tegra-asoc: sound: ADMAIF13 <-> ADMAIF13 mapping ok
[    2.621095] tegra-asoc: sound: ADMAIF14 <-> ADMAIF14 mapping ok
[    2.621165] tegra-asoc: sound: ADMAIF15 <-> ADMAIF15 mapping ok
[    2.621234] tegra-asoc: sound: ADMAIF16 <-> ADMAIF16 mapping ok
[    2.621303] tegra-asoc: sound: ADMAIF17 <-> ADMAIF17 mapping ok
[    2.621373] tegra-asoc: sound: ADMAIF18 <-> ADMAIF18 mapping ok
[    2.621456] tegra-asoc: sound: ADMAIF19 <-> ADMAIF19 mapping ok
[    2.621542] tegra-asoc: sound: ADMAIF20 <-> ADMAIF20 mapping ok
root@nvidia-desktop:/home/nvidia# dmesg  | grep "8316"
[    1.831682] tegra_profiler: auth: init
[    2.348498] es8316_i2c_probe 1171=========================================
[    2.348501] es8316_i2c_probe 1176=========================================
[    2.348546] es8316_i2c_probe 1190=========================================
[    2.348554] es8316_i2c_probe 1245========================================= ret:0
[    2.482946] es8316_probe 1078=========================================1414
[    2.483012] es8316_probe 1090=========================================
[    2.489319] es8316_probe 1096=========================================
[    2.610059] es8316_init_regs 975=========================================
[    2.615278] es8316_probe 1123=========================================ret:0
[    2.623812] tegra_machine_es8316_init 590=========================================
[    2.623816] es8316_set_dai_sysclk 562=========================================
[    2.623818] es8316_set_dai_sysclk===========8316codec================== 579
[    2.623820] es8316_set_dai_fmt 603=========================================
[    3.622346]   #1: es8316-tegra
[   11.251481] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[   11.251486] es8316_set_dai_sysclk 562=========================================
[   11.251489] es8316_set_dai_sysclk===========8316codec================== 579
[   11.410305] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[   11.410310] es8316_set_dai_sysclk 562=========================================
[   11.410313] es8316_set_dai_sysclk===========8316codec================== 579
[   11.535986] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[   11.535991] es8316_set_dai_sysclk 562=========================================
[   11.535994] es8316_set_dai_sysclk===========8316codec================== 579
[   11.552697] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[   11.552702] es8316_set_dai_sysclk 562=========================================
[   11.552705] es8316_set_dai_sysclk===========8316codec================== 579
[   11.716783] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[   11.716789] es8316_set_dai_sysclk 562=========================================
[   11.716792] es8316_set_dai_sysclk===========8316codec================== 579
[  668.418316] RTW: _8051Reset8723: Finish
[ 1202.173769] tegra_machine_dai_init===========8316=======es8316-playback===========20211015 362
[ 1202.173798] es8316_set_dai_sysclk 562=========================================
[ 1202.173803] es8316_set_dai_sysclk===========8316codec================== 579
[ 1202.176603] es8316_pcm_startup 689=========================================
[ 1202.238524] es8316_pcm_hw_params 776=========================================
[ 1202.238966] es8316_mute 810=========================================
[ 1232.704094] es8316_mute 810=========================================
[ 1232.821366] PC is at es8316_pcm_shutdown+0x20/0x168
[ 1232.935197] [<ffffff8008d72668>] es8316_pcm_shutdown+0x20/0x168

Thanks
wangxiaozhuang

You may want to check the codec crash with codec vendor. Also confirm the codec settings with them. I see there is a mute() call from codec. Please make sure that the audio is not really muted. You can also check with increasing playback volume from codec mixer control settings.

From clock, driver and DT setup wise things look good. You are able to get the required clocks and able to get expected driver callbacks. There is data signal on SDO line as well.