The audio codec es8316 can’t work on I2S1 for TX2, but 2S_ MCK , I2S_ SCK , I2S_ LRCK pins have signals

Hi,
I have some problem with this audio codec, the es8316 has been successfully registered and the sound card has appeared, but there is no sound. The following are my modifications based on r32.6.1:

es8316.c (38.1 KB)

1. codec:

--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -68,6 +68,7 @@ config SND_SOC_ALL_CODECS
        select SND_SOC_DA732X if I2C
        select SND_SOC_DA9055 if I2C
        select SND_SOC_DMIC
+       select SND_SOC_ES8316 if I2C
        select SND_SOC_ES8328_SPI if SPI_MASTER
        select SND_SOC_ES8328_I2C if I2C
        select SND_SOC_GTM601
@@ -513,6 +514,10 @@ config SND_SOC_DA9055
 config SND_SOC_DMIC
        tristate
 
+config SND_SOC_ES8316
+    tristate "Everest Semi ES8316 CODEC"
+    depends on I2C
+
 config SND_SOC_HDMI_CODEC
        tristate
        select SND_PCM_ELD
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 426b39afdd73..158f8e5b8934 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -61,6 +61,7 @@ snd-soc-da7219-objs := da7219.o da7219-aad.o
 snd-soc-da732x-objs := da732x.o
 snd-soc-da9055-objs := da9055.o
 snd-soc-dmic-objs := dmic.o
+snd-soc-es8316-objs := es8316.o
 snd-soc-es8328-objs := es8328.o
 snd-soc-es8328-i2c-objs := es8328-i2c.o
 snd-soc-es8328-spi-objs := es8328-spi.o
@@ -286,6 +287,7 @@ obj-$(CONFIG_SND_SOC_DA7219)        += snd-soc-da7219.o
 obj-$(CONFIG_SND_SOC_DA732X)   += snd-soc-da732x.o
 obj-$(CONFIG_SND_SOC_DA9055)   += snd-soc-da9055.o
 obj-$(CONFIG_SND_SOC_DMIC)     += snd-soc-dmic.o
+obj-y                     	+= snd-soc-es8316.o
 obj-$(CONFIG_SND_SOC_ES8328)   += snd-soc-es8328.o
 obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
 obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c


2. machine:

--- a/sound/soc/tegra-alt/Kconfig
+++ b/sound/soc/tegra-alt/Kconfig
@@ -176,6 +176,7 @@ config SND_SOC_TEGRA_T186REF_ALT
        select SND_SOC_TEGRA_ASOC_HWDEP_ALT
        select SND_SOC_SPDIF
        select SND_SOC_COMPRESS
+       select SND_SOC_ES8316
        help
          Say Y or M here.
 
@@ -205,6 +206,7 @@ config SND_SOC_TEGRA210_AUDIO_ALT
        select SND_SOC_RT5640
        select SND_SOC_RT5659
        select SND_SOC_SGTL5000
+       select SND_SOC_ES8316
        help
          Say Y or M here if you want to enable support for ASoC machine driver on
          Tegra210 and successor platforms like Tegra186, Tegra194.
diff --git a/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c b/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c
index b2e8fa27c..4d3760c95 100644
--- 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;
        }



3. dts:
--- a/kernel-dts/common/tegra186-p3636-0001-a00-audio.dtsi
+++ b/kernel-dts/common/tegra186-p3636-0001-a00-audio.dtsi
@@ -21,14 +21,18 @@
 #include <audio/tegra-platforms-audio-dai-links.dtsi>
 
 / {
-       hda@3510000 {
+       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 = "tegra-snd-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>;
@@ -37,16 +41,58 @@
                                  <&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 Headphone",          "x HPOL",
+               "x Headphone",          "x HPOR",
+               "x Headphone",          "x OUT",
+               "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";
+
+               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;
+                       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 { };
        };
 };
diff --git a/kernel-dts/common/tegra186-p3636-0001-common.dtsi b/kernel-dts/common/tegra186-p3636-0001-common.dtsi
index 27009d8..77b753b 100644
--- a/kernel-dts/common/tegra186-p3636-0001-common.dtsi
+++ b/kernel-dts/common/tegra186-p3636-0001-common.dtsi
@@ -36,6 +36,7 @@
 #include "tegra186-p3636-0001-a00-comms.dtsi"
 #include <dt-bindings/pinctrl/pinctrl-tegra.h>
 #include <dt-bindings/gpio/tegra186-gpio.h>
+#include <dt-common/jetson/tegra186-p3509-0000-p3636-0001.h>
 
 #define EXTCON_NONE            0
 #define EXTCON_USB             1
@@ -64,6 +65,7 @@
        };
 
        serial@c280000 {
+               compatible = "nvidia,tegra186-hsuart";
                status = "disabled";
        };
 
@@ -78,19 +80,78 @@
                status="okay";
        };
 
+       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>;
+                       };
+               };        
+        
+       };
+
+    clocks {
+            es8316_mclk: es8316_mclk {
+                    compatible = "fixed-clock";
+                    #clock-cells = <0>;
+                    clock-frequency = <12288000>;
+                    clock-output-names = "es8316-mclk";
+                    status = "okay";
+            };
+    };
+
        norco_mcu: i2c@3160000 {
                status="okay";
                mcu: mcu@38 {
                        compatible = "norco,new_mcu";
                        reg = <0x38>;
                };
                es8316_codec: es8316@10 {
                        compatible = "everest,es8316";
                        reg = <0x10>;
+            clocks = <&tegra_car TEGRA186_CLK_AUD_MCLK>;
+            clock-names = "mclk";
                        status = "okay";
                };
        };

*Here is the information of codec:

root@nvidia-desktop:~# 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


root@nvidia-desktop:~# 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

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

speaker-test -D hw:es8316tegra,0 -c 2 -r 48000 -F S16_LE -t sine -f 500
Use this command to play music without sound , What should I do? We look forward to your help. Thank you very much

Hi wangxiaozhuang,

Sorry for the late response, is this still an issue to support?

Thanks

Hi wangxiaozhuang,

This issue is already being discussed on The audio codec es8316 can’t work on I2S0 for Xaiver NX. Please redirect your queries to older thread as you have been doing already and let us know if this can be closed.

Later, if you see any specific issue with respect to TX2, it can be filed seperately.

Thanks

Hi ,atalambedu
Sorry for the late response, The problem has not been solved, I asked for leave a few days ago. OK, I’ll continue to reply here . The audio codec es8316 can’t work on I2S0 for Xaiver NX It’s the same kind of problem. If it’s solved, I’ll share the solution here .

Issue seems resolved, see The audio codec es8316 can’t work on I2S0 for Xaiver NX - #23 by wangxiaozhuang

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