Audio codec es8316 cannot work on I2S0 and I2C2 for Xaiver NX

es8316 connect to I2S0 and I2C2 interfaces , and using GPIO09 for AUD_MCLK.
I do my change refer to the following link, but is not helpful.
The audio codec es8316 can’t work on I2S0 for Xaiver NX:

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.
tegra194-p3668-all-p3509-0000.dts (254.7 KB)
dmesg.log (73.6 KB)
es8316.c (38.1 KB)

We look forward to your help. Thank you very much!

Meanwhile, here are my change code:
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("xiaoz 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,20 @@ 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 = snd_soc_dai_set_sysclk(rtd->codec_dai, ES8316_SCLK_S_MCLK, 12288000,SND_SOC_CLOCK_IN);
+       if (err) {
+               dev_info(dev, "xiaoz 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 +644,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"))
+                       dai_links[i].init = tegra_machine_es8316_init;
        }
 
        return 0;
@@ -784,8 +828,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_info(&pdev->dev, "xiaoz %s snd_soc_register_card failed (%d)\n",
+                       __FILE__,ret);

tegra194-audio-p3668.dtsi

 
+       //tegra_i2s5
+       i2s@2901400 {
+               status = "okay";
+       };
+
+       i2s@2901100 {
+               status = "okay";
+       };
+
+       i2c@3160000 {
+               status="okay";
+               es8316_codec: es8316@10 {
+                       compatible = "everest,es8316";
+                       reg = <0x10>;
+                       status = "okay";
+               };
+       };
+
        hda@3510000 {
                hda,card-name = "tegra-hda-xnx";
                status = "okay";
@@ -36,7 +54,7 @@
        tegra_sound: sound {
                status = "okay";
                compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
-               nvidia,model = "jetson-xaviernx-ape";
+               nvidia,model = "es8316-tegra";
                clocks = <&bpmp_clks TEGRA194_CLK_PLLA>,
                         <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>,
                         <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
@@ -68,12 +86,27 @@
 
                mclk-fs = <256>;
 
+               nvidia,xbar = <&tegra_axbar>;
+
                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";
+                       format = "i2s";
+                       bit-format = "s16_le";
+                       cpu-dai-name = "I2S5";  
+                       //bitclock-master;
+                       //frame-master;
+                       //bclk_ratio = <0>;
+                       //srate = <48000>;
+                       //num-channel = <2>;
+                       status = "okay";
                };
 
        };

tegra194-p3668-common.dtsi

 #include <t19x-common-platforms/tegra194-no-pll-aon-clock.dtsi>
 #include "tegra194-p3668-pcie-plugin-manager.dtsi"
 #include "tegra194-plugin-manager-p3668.dtsi"
+#include <dt-common/jetson/tegra194-p3668-all-p3509-0000.h>
 
 / {
        nvidia,fastboot-usb-vid = <0x0955>;
@@ -582,6 +583,57 @@
        soctherm-oc-event {
                status = "okay";
        };
+
+       //add by xiaoz Audio 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>;
+                       };
+               };        
+        
+       };
+
 };

And this is my debug info:

image


However, there is no sound when playing music.
I dont know what to do next, can anybody help me?Thank you very much!

Hi,can someone help me check this problem?

Hi,

I am looking into this. I will provide you suggestions shortly.

Meanwhile you could check Audio Setup and Development — Jetson Linux<br/>Developer Guide 34.1 documentation for exploring by self.

Thanks

thank you, look forward to your reply!

Hi,

for aud mclk i.e pin 7 of hdr40 seems to be incorrectly configured. Above shoudl be TEGRA_PIN_DISABLE. Could you just use Jetson-IO tool and no manual DT modifications for pinmux part. Guide for using same is here. Jetson-IO tool can be used via command line as well through below command for your usecase.

sudo /opt/nvidia/jetson-io/config-by-function.py -o dtbo i2s5 aud_mclk

Suggest to use Jetson I2S in master mode. Below commands can be used to set up same

amixer -c 1 cset name="I2S5 codec master mode" "cbs-cfs"

Use below if not done already

amixer -c 1 cset name="I2S5 Mux" ADMAIF1

From, earlier post, below codec mixer settings are needed in addition. Hope you have taken care of these. Otherwise, please share amixer settings as an attachment (amixer -c 1 scontents)

amixer -c 1 cset name="x Left DAC Switch" 1
amixer -c 1 cset name="x Right DAC Switch" 1

Is there any error log during playback failure on screen or in dmesg or are you failing to see clocks at SCLK, BCLK lines?

If the clocks are working fine, share dapm path trace. Steps for getting trace can be found at link

Thanks

Hi, atalambedu,
thank you very much for reply,

I have disabled DT configration, and use Jetson-IO:

but the problem has not improved:
I2S_LRCK and I2S_SDO and I2S_SCK no signal and aud_mclk is normal.

this is my test mothod

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

no error log in the dmesg, and I dont see clocks at SCLK, BCLK lines.
Should I doubt the direction of hardware?

Hi,

Pinmux seems to be fine. and as per your initial screen shots, the codec and card resgistration seem to be fine. Please share the mixer settings (amixer -c 1 contents) and DAPM trace path as emntioned in earlier comment.

Thanks

here are my infor:

root@tegra-ubuntu:~# cat /sys/kernel/debug/tracing/trace_pipe | grep *
    speaker-test-11444 [000] ....  2807.961003: snd_soc_dapm_start: card=es8316-tegra
    speaker-test-11444 [000] ....  2807.961580: snd_soc_dapm_walk_done: es8316-tegra: checks 2 power, 2 path, 0 neighbour
    speaker-test-11444 [000] ....  2807.961607: snd_soc_bias_level_start: card=es8316-tegra val=1
    speaker-test-11444 [000] ....  2807.961609: snd_soc_bias_level_done: card=es8316-tegra val=1
    speaker-test-11444 [000] ....  2807.961610: snd_soc_bias_level_start: card=es8316-tegra val=2
    speaker-test-11444 [000] ....  2807.961611: snd_soc_bias_level_done: card=es8316-tegra val=2
    speaker-test-11444 [000] ....  2807.961623: snd_soc_dapm_done: card=es8316-tegra
    speaker-test-11444 [000] ....  2812.111960: snd_soc_dapm_start: card=es8316-tegra
    speaker-test-11444 [000] ....  2812.112121: snd_soc_dapm_walk_done: es8316-tegra: checks 2 power, 2 path, 2 neighbour
    speaker-test-11444 [000] ....  2812.112127: snd_soc_bias_level_start: card=es8316-tegra val=1
    speaker-test-11444 [000] ....  2812.112133: snd_soc_bias_level_done: card=es8316-tegra val=1
    speaker-test-11444 [000] ....  2812.112135: snd_soc_bias_level_start: card=es8316-tegra val=2
    speaker-test-11444 [000] ....  2812.112138: snd_soc_bias_level_done: card=es8316-tegra val=2
    speaker-test-11444 [000] ....  2812.112153: snd_soc_dapm_done: card=es8316-tegra

amixer -c 1 scontrols
contents.txt (293.2 KB)

amixer -c 1 controls
controls.txt (53.8 KB)

amixer -c 1 scontrols
scontrols.txt (48.4 KB)

Hi Xzz,

I am not seeing “Left DAC Switch” and “Right DAC Switch” controls in your amixer setting dump.

You may have to use below settings instead

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

Also, the DAPM trace path looks incomplete. This needs to be fixed. Following suggestion from reference post seems to have been not taken

--- 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 */

Please share the DAPM trace after doing these changes

Thanks

Hi, atalambedu,
Really thank you for support.
Now es8316 can playback music normal.
And how can I fix the command ?
I found this commit The audio codec es8316 can’t work on I2S0 for Xaiver NX:

Hi,

You are welcome. Glad to hear that playback is working.

Did both of the steps put together in my earlier comment helped resolve the issue?

By fixing command, do you mean how to automate the mixer setup? I think the deatils are available here

Did you give a try

Thanks

Hi, atalambedu

Actually yes.

I have do this change,but it looks not effective after I reboot the system:

diff --git a/00-tegra.conf b/00-tegra.conf
index e776b0a..fb2ecf8 100644
--- a/00-tegra.conf
+++ b/00-tegra.conf
@@ -13,7 +13,7 @@
 
 CARDINFO{driver}=="tegra-snd-t210r", GOTO="Tegra210 Init"
 CARDINFO{driver}=="tegra-snd-t186r", GOTO="Tegra186 Init"
-CARDINFO{driver}=="tegra-snd-t19x-", GOTO="Tegra186 Init"
+CARDINFO{driver}=="es8316-tegra", GOTO="Tegra186 Init"
 CARDINFO{driver}=="jetson-xaviernx", GOTO="Tegra186 Init"
 RESULT="false", EXIT="return"
 
@@ -65,6 +65,7 @@ CTL{name}="Numerator3 Mux", CTL{value}="None"
 CTL{name}="Numerator4 Mux", CTL{value}="None"
 CTL{name}="Numerator5 Mux", CTL{value}="None"
 CTL{name}="Numerator6 Mux", CTL{value}="None"
+CTL{name}="I2S5 Mux", CTL{value}="ADMAIF1"
 
 LABEL="Tegra Common Init"
 CTL{reset}="mixer"
@@ -98,7 +99,7 @@ CTL{name}="I2S1 Mux", CTL{value}="None"
 CTL{name}="I2S2 Mux", CTL{value}="None"
 CTL{name}="I2S3 Mux", CTL{value}="None"
 CTL{name}="I2S4 Mux", CTL{value}="None"
-CTL{name}="I2S5 Mux", CTL{value}="None"
+CTL{name}="I2S5 Mux", CTL{value}="ADMAIF1"
 CTL{name}="MIXER1-1 Mux", CTL{value}="None"
 CTL{name}="MIXER1-2 Mux", CTL{value}="None"
 CTL{name}="MIXER1-3 Mux", CTL{value}="None"
@@ -127,11 +128,9 @@ CARDINFO{driver}=="tegra-snd-t210r",                       \
        CTL{name}="I2S4 Loopback", CTL{do_search}=="1", \
        CTL{name}="ADMAIF1 Mux", CTL{value}="I2S4"      \
        CTL{name}="I2S4 Mux", CTL{value}="ADMAIF1"
-CARDINFO{driver}=="tegra-snd-t210r",                   \
-       CTL{name}="I2S1 Loopback", CTL{do_search}=="1", \
-       CTL{name}="I2S4 Loopback", CTL{do_search}=="1", \
-       CTL{name}="ADMAIF1 Mux", CTL{value}="I2S1"      \
-       CTL{name}="I2S1 Mux", CTL{value}="ADMAIF1"
+CARDINFO{driver}=="es8316-tegra",                      \
+       CTL{name}="x Letf DAC Switch", CTL{do_search}=="1",     \
+       CTL{name}="x Right DAC Switch", CTL{do_search}=="1"
 CARDINFO{driver}=="tegra-snd-t186r",                   \
        CTL{name}="ADMAIF1 Mux", CTL{value}="I2S1"      \
        CTL{name}="I2S1 Mux", CTL{value}="ADMAIF1"

Hi, you should have used below instead

CARDINFO{driver}=="es8316-tegra",                      \
       CTL{name}="x Left Hp mixer Left DAC Switch", CTL{do_search}=="1",     \
       CTL{name}="x Right Hp mixer Right DAC Switch", CTL{do_search}=="1"

One more thing, as you replacing “tegra-snd-t19x-” with "es8316-tegra"you should replace same entry below and
not tegra-snd-t210r-. Please note

-CARDINFO{driver}=="tegra-snd-t210r",                   \
-       CTL{name}="I2S1 Loopback", CTL{do_search}=="1", \
-       CTL{name}="I2S4 Loopback", CTL{do_search}=="1", \
-       CTL{name}="ADMAIF1 Mux", CTL{value}="I2S1"      \
-       CTL{name}="I2S1 Mux", CTL{value}="ADMAIF1"
+CARDINFO{driver}=="es8316-tegra",                      \
+       CTL{name}="x Letf DAC Switch", CTL{do_search}=="1",     \
+       CTL{name}="x Right DAC Switch", CTL{do_search}=="1"

Thanks

Hi, atalambedu
Thank u for support!
Heartfelt thanks!

Happy to! If no other queries, kindly mark the comment that helped resolve the issue (for forum users’ benefit)

Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.