The Mic of es8316 is not work

Hi, I need help, I’m having trouble with the es8316 chip recording function,but the playback function is OK.

tegra_asoc_machine_virt_alt.c (38.0 KB)
tegra_machine_driver_mobile.c (41.2 KB)
tegra_asoc_machine_alt.c (128.8 KB)
es8316.c (37.6 KB)
tegra194-audio-p3668.dtsi (18.3 KB)

1,record command:

arecord -vvv -d 5 -D hw:es8316tegra -f S16_LE -c 2 -t wav >  voice.wav

return error: arecord: pcm_read:2103: read error: Input/output error

Details are as follows:

Hardware PCM card 1 'es8316-tegra' device 0 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 8000
  exact rate   : 8000 (8000/1)
  msbits       : 16
  buffer_size  : 4000
  period_size  : 1000
  period_time  : 125000
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 1000
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 4000
  silence_threshold: 0
  silence_size : 0
  boundary     : 9007199254740992000
  appl_ptr     : 0
  hw_ptr       : 0

arecord: pcm_read:2103: read error: Input/output error

2,We measure that I2S_MCLK has a clock signal, but I2S_SCK and I2S_LRCK have no signal, and ‘voice.wav’ file is only 44 bytes.

3,sudo cat /sys/kernel/debug/tegra_pinctrl_reg | grep dap5

Bank: 0 Reg: 0x02431068 Val: 0x00000444 -> dap5_fs_pu0
Bank: 0 Reg: 0x02431070 Val: 0x00000454 -> dap5_din_pt7
Bank: 0 Reg: 0x02431078 Val: 0x00000404 -> dap5_dout_pt6
Bank: 0 Reg: 0x02431080 Val: 0x00000444 -> dap5_sclk_pt5

4,tegra194-p3668-common.dtsi

--- a/common/tegra194-p3668-common.dtsi
+++ b/common/tegra194-p3668-common.dtsi
@@ -26,6 +26,7 @@
 #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>;
@@ -79,6 +80,56 @@
                };
        };
+
+       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>;
+                       };
+               };        
+        
+       };
+
        external-connection {
                vbus_id_extcon: extcon@1 {
                        compatible = "extcon-gpio-states";
@@ -201,14 +252,18 @@
                };
        };
 
+    clocks-init {
+            /delete-node/ disable;
+    };
+
        mttcan@c310000 {
                status = "okay";
                pll_source = "pllc";
+               clock-names = "can_core", "can_host","can", "pllc";
                clocks = <&bpmp_clks TEGRA194_CLK_CAN1_CORE>,
                        <&bpmp_clks TEGRA194_CLK_CAN1_HOST>,
                        <&bpmp_clks TEGRA194_CLK_CAN1>,
                        <&bpmp_clks TEGRA194_CLK_PLLC>;
-               clock-names = "can_core", "can_host","can", "pllc";
        };
 
        mttcan@c320000 {
@@ -418,22 +473,27 @@
                        };
                };
        };
+
        norco_mcu: i2c@c240000 { 
                mcu: mcu@38 {
                        compatible = "norco,new_mcu";
                        reg = <0x38>;
                };
+               es8316_codec: es8316@10 {
+                       compatible = "everest,es8316";
+                       reg = <0x10>;
+                       status = "okay";
+               };
        };
+

5,This is the previous result, the problem of playing music has been solved

Hi wangxiaozhuang,

Most likely you don’t have capture path set on Tegra side.
Please check with below:

+CTL{name}=“ADMAIF1 Mux”, CTL{value}=“I2S5”

With above, at least arecord error should go away and you should be able to see clocks on the pins. If this works as expected check if there are any ES8316 specific controls (like ADC switches and volume controls) which need to be set for capture to work.

Thanks.

Hi , spujar
Thank you for replying so quickly,according to your modification, I2S_SCK and I2S_LRCK still have no clock, the same error as above when recording

1,The modification of rootfs ‘/usr/share/alsa/init/postinit/00-tegra.conf’ file:

diff --git a/00-tegra.conf b/00-tegra.conf
index e776b0a..bd16c77 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,8 @@ 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"
+CTL{name}="ADMAIF1 Mux", CTL{value}="I2S5"
 
 LABEL="Tegra Common Init"
 CTL{reset}="mixer"
@@ -98,7 +100,8 @@ 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}="ADMAIF1 Mux", CTL{value}="I2S5"
 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 +130,10 @@ 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}="ADMAIF1 Mux", CTL{value}="I2S5"      \
+       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"

2,The modification of driver ‘sound/soc/codecs/es8316.c’ file:

diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
index cc2f465e9fe1..cd459b712fd8 100644
--- a/sound/soc/codecs/es8316.c
+++ b/sound/soc/codecs/es8316.c
@@ -322,10 +322,10 @@ static const struct snd_soc_dapm_widget es8316_dapm_widgets[] = {
                         &es8316_dmic_src_controls),
 
        /* Digital Interface */
-       SND_SOC_DAPM_AIF_OUT("I2S OUT", "I2S1 Capture",  1,
-                            ES8316_SDP_ADCFMT_REG0A, 6, 0),
+       SND_SOC_DAPM_AIF_OUT("I2S OUT", "Capture",  1,
+                            SND_SOC_NOPM, 6, 0),
 
-       SND_SOC_DAPM_AIF_IN("I2S IN", "I2S Playback", 0,
+       SND_SOC_DAPM_AIF_IN("I2S IN", "Playback", 0,
                            SND_SOC_NOPM, 0, 0),
        /*  DACs DATA SRC MUX */

3,dts ‘sources/hardware/nvidia/platform/t19x/jakku/kernel-dts/common/tegra194-audio-p3668.dtsi’:

diff --git a/common/tegra194-audio-p3668.dtsi b/common/tegra194-audio-p3668.dtsi
index 48a3289..0c3dee2 100644
--- a/common/tegra194-audio-p3668.dtsi
+++ b/common/tegra194-audio-p3668.dtsi
@@ -49,20 +49,20 @@
                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",
+            "x Headphone",          "x OUT",
+            "x IN",                 "x MIC1",
+            "x Headphone",          "x OUT",
+                       "x IN",                 "x MIC2",
+                       "x Headphone",          "x OUT",
+                       "x IN",                 "x DMIC",
+                       "x Headphone",          "x OUT",
+                       "x IN",                 "x MIC",
+                       "x Headphone",          "x OUT",
+                       "x IN",                 "x MIC",
+                       "x IN",                 "x DMIC",
+                       "b IN",                 "b MIC1",
+                       "c IN",                 "c MIC2",
+                       "d IN",                 "d DMIC",
                        "d1 Headphone",         "d1 OUT",
                        "d2 Headphone",         "d2 OUT";

4,The configuration information of es8316:

amixer -c es8316tegra > es8316_ctl.txt

es8316_ctl.txt (239.8 KB)

Hi wangxiaozhuang

This seems to be related to DAPM routing issue in the capture path. The changes you have done appear good and you need to find out where exactly the path is broken.

Couple of things you can do:

  1. check if hw_params() callback happens in es8316 codec driver. Add print in es8316_pcm_hw_params() and start arecord to check this.
  2. If [1] does not happen, then it confirms that there is DAPM route issue. You can dump DAPM log as mentioned in the BSP doc and share the log for further analysis.
    https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3271/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/asoc_driver.19.2.html#wwpID0E0ND0HA

Thanks.

Hi spujar
Thanks for the reply. hw_params() callback function not being called. Follow the instructions you provided in [2], get the following result:
for i in find /sys/kernel/debug/tracing/events -name "enable" | grep snd_soc_; do echo 1 > $i; done
cat /sys/kernel/debug/tracing/trace_pipe
arecord -d 5 -D hw:es8316tegra -f S16_LE -c 2 -t wav > test.wav

Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo
         arecord-8463  [000] ....  2054.738809: snd_soc_dapm_start: card=es8316-tegra
         arecord-8463  [000] ....  2054.738995: snd_soc_dapm_walk_done: es8316-tegra: checks 2 power, 2 path, 0 neighbour
         arecord-8463  [000] ....  2054.739004: snd_soc_bias_level_start: card=es8316-tegra val=1
         arecord-8463  [000] ....  2054.739007: snd_soc_bias_level_done: card=es8316-tegra val=1
         arecord-8463  [000] ....  2054.739009: snd_soc_bias_level_start: card=es8316-tegra val=2
         arecord-8463  [000] ....  2054.739010: snd_soc_bias_level_done: card=es8316-tegra val=2
         arecord-8463  [000] ....  2054.739025: snd_soc_dapm_done: card=es8316-tegra
arecord: pcm_read:2103: read error: Input/output error
         arecord-8463  [000] ....  2064.829761: snd_soc_dapm_start: card=es8316-tegra
         arecord-8463  [000] ....  2064.829891: snd_soc_dapm_path: *ADMAIF1 Transmit -> (direct) -> Capture 1
         arecord-8463  [000] ....  2064.829899: snd_soc_dapm_path: *ADMAIF1 Transmit -> (direct) -> ADMAIF1 Transmit-ADMAIF1 CIF Transmit
         arecord-8463  [000] ....  2064.829956: snd_soc_dapm_walk_done: es8316-tegra: checks 2 power, 2 path, 2 neighbour
         arecord-8463  [000] ....  2064.829960: snd_soc_bias_level_start: card=es8316-tegra val=1
         arecord-8463  [000] ....  2064.829962: snd_soc_bias_level_done: card=es8316-tegra val=1
         arecord-8463  [000] ....  2064.829963: snd_soc_bias_level_start: card=es8316-tegra val=2
         arecord-8463  [000] ....  2064.829965: snd_soc_bias_level_done: card=es8316-tegra val=2
         arecord-8463  [000] ....  2064.829980: snd_soc_dapm_done: card=es8316-tegra

for i in find /sys/kernel/debug/tracing/events -name "enable" | grep snd_soc_; do echo 1 > $i; done
cat /sys/kernel/debug/tracing/trace_pipe | grep * &
arecord -d 5 -D hw:es8316tegra -f S16_LE -c 2 -t wav > test.wav

grep: Desktop: Is a directory
grep: Documents: Is a directory
grep: Downloads: Is a directory
grep: mmc0: Is a directory
grep: Music: Is a directory
grep: Pictures: Is a directory
grep: Public: Is a directory
grep: rootfs: Is a directory
grep: ssd: Is a directory
grep: Templates: Is a directory
grep: Videos: Is a directory

Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo
arecord: pcm_read:2103: read error: Input/output error
[1]+  Exit 2                  cat /sys/kernel/debug/tracing/trace_pipe | grep --color=auto *

amixer -c es8316tegra contents > settings.txt
settings.txt (293.1 KB)
dmesg > kernel_log
kernel_log (81.1 KB)
dtc -I fs -O dts /proc/device-tree > dt.log
dt.log (259.5 KB)
cat /sys/kernel/debug/regmap/tegra210-i2s.5/registers > i2s5__reg_dump
i2s5_reg_dump (585 Bytes)

When I play music, the following message is printed:
$ aplay -D hw:es8316tegra music.wav

Playing WAVE 'music.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
           aplay-8784  [001] ....  8137.000798: snd_soc_dapm_start: card=es8316-tegra
           aplay-8784  [001] ....  8137.001070: snd_soc_dapm_widget_power: widget=Playback 1 val=1
           aplay-8784  [001] ....  8137.001088: snd_soc_dapm_widget_power: widget=ADMAIF1 Receive val=1
           aplay-8784  [001] ....  8137.001092: snd_soc_dapm_path: *ADMAIF1 RX <- (direct) <- ADMAIF1 Receive
           aplay-8784  [001] ....  8137.001094: snd_soc_dapm_widget_power: widget=ADMAIF1 RX val=1
           aplay-8784  [001] ....  8137.001098: snd_soc_dapm_path:  I2S5 Mux <- ARAD1 <- ARAD1 RX
           aplay-8784  [001] ....  8137.001100: snd_soc_dapm_path:  I2S5 Mux <- ADX4-4 <- ADX4-4 RX
           aplay-8784  [001] ....  8137.001102: snd_soc_dapm_path:  I2S5 Mux <- ADX4-3 <- ADX4-3 RX
           aplay-8784  [001] ....  8137.001104: snd_soc_dapm_path:  I2S5 Mux <- ADX4-2 <- ADX4-2 RX
           aplay-8784  [001] ....  8137.001111: snd_soc_dapm_path:  I2S5 Mux <- ADX4-1 <- ADX4-1 RX
           aplay-8784  [001] ....  8137.001113: snd_soc_dapm_path:  I2S5 Mux <- AMX4 <- AMX4 RX
           aplay-8784  [001] ....  8137.001115: snd_soc_dapm_path:  I2S5 Mux <- ADX3-4 <- ADX3-4 RX
           aplay-8784  [001] ....  8137.001117: snd_soc_dapm_path:  I2S5 Mux <- ADX3-3 <- ADX3-3 RX
           aplay-8784  [001] ....  8137.001118: snd_soc_dapm_path:  I2S5 Mux <- ADX3-2 <- ADX3-2 RX
           aplay-8784  [001] ....  8137.001119: snd_soc_dapm_path:  I2S5 Mux <- ADX3-1 <- ADX3-1 RX
           aplay-8784  [001] ....  8137.001121: snd_soc_dapm_path:  I2S5 Mux <- AMX3 <- AMX3 RX
           aplay-8784  [001] ....  8137.001122: snd_soc_dapm_path:  I2S5 Mux <- ASRC1-6 <- ASRC1-6 RX
           aplay-8784  [001] ....  8137.001124: snd_soc_dapm_path:  I2S5 Mux <- ASRC1-5 <- ASRC1-5 RX
           aplay-8784  [001] ....  8137.001129: snd_soc_dapm_path:  I2S5 Mux <- ASRC1-4 <- ASRC1-4 RX
           aplay-8784  [001] ....  8137.001131: snd_soc_dapm_path:  I2S5 Mux <- ASRC1-3 <- ASRC1-3 RX
           aplay-8784  [001] ....  8137.001160: snd_soc_dapm_path:  I2S5 Mux <- ASRC1-2 <- ASRC1-2 RX
           aplay-8784  [001] ....  8137.001162: snd_soc_dapm_path:  I2S5 Mux <- ASRC1-1 <- ASRC1-1 RX
           aplay-8784  [001] ....  8137.001163: snd_soc_dapm_path:  I2S5 Mux <- I2S6 <- I2S6 RX
           aplay-8784  [001] ....  8137.001165: snd_soc_dapm_path:  I2S5 Mux <- DMIC4 <- DMIC4 RX
           aplay-8784  [001] ....  8137.001167: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF20 <- ADMAIF20 RX
           aplay-8784  [001] ....  8137.001168: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF19 <- ADMAIF19 RX
           aplay-8784  [001] ....  8137.001170: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF18 <- ADMAIF18 RX
           aplay-8784  [001] ....  8137.001171: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF17 <- ADMAIF17 RX
           aplay-8784  [001] ....  8137.001173: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF16 <- ADMAIF16 RX
           aplay-8784  [001] ....  8137.001174: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF15 <- ADMAIF15 RX
           aplay-8784  [001] ....  8137.001175: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF14 <- ADMAIF14 RX
           aplay-8784  [001] ....  8137.001177: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF13 <- ADMAIF13 RX
           aplay-8784  [001] ....  8137.001178: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF12 <- ADMAIF12 RX
           aplay-8784  [001] ....  8137.001179: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF11 <- ADMAIF11 RX
           aplay-8784  [001] ....  8137.001181: snd_soc_dapm_path:  I2S5 Mux <- ADX2-4 <- ADX2-4 RX
           aplay-8784  [001] ....  8137.001182: snd_soc_dapm_path:  I2S5 Mux <- ADX2-3 <- ADX2-3 RX
           aplay-8784  [001] ....  8137.001185: snd_soc_dapm_path:  I2S5 Mux <- ADX2-2 <- ADX2-2 RX
           aplay-8784  [001] ....  8137.001186: snd_soc_dapm_path:  I2S5 Mux <- ADX2-1 <- ADX2-1 RX
           aplay-8784  [001] ....  8137.001188: snd_soc_dapm_path:  I2S5 Mux <- AMX2 <- AMX2 RX
           aplay-8784  [001] ....  8137.001189: snd_soc_dapm_path:  I2S5 Mux <- ADX1-4 <- ADX1-4 RX
           aplay-8784  [001] ....  8137.001191: snd_soc_dapm_path:  I2S5 Mux <- ADX1-3 <- ADX1-3 RX
           aplay-8784  [001] ....  8137.001192: snd_soc_dapm_path:  I2S5 Mux <- ADX1-2 <- ADX1-2 RX
           aplay-8784  [001] ....  8137.001193: snd_soc_dapm_path:  I2S5 Mux <- ADX1-1 <- ADX1-1 RX
           aplay-8784  [001] ....  8137.001196: snd_soc_dapm_path:  I2S5 Mux <- AMX1 <- AMX1 RX
           aplay-8784  [001] ....  8137.001198: snd_soc_dapm_path:  I2S5 Mux <- DMIC3 <- DMIC3 RX
           aplay-8784  [001] ....  8137.001199: snd_soc_dapm_path:  I2S5 Mux <- DMIC2 <- DMIC2 RX
           aplay-8784  [001] ....  8137.001201: snd_soc_dapm_path:  I2S5 Mux <- DMIC1 <- DMIC1 RX
           aplay-8784  [001] ....  8137.001203: snd_soc_dapm_path:  I2S5 Mux <- IQC2-2 <- IQC2-2 RX
           aplay-8784  [001] ....  8137.001205: snd_soc_dapm_path:  I2S5 Mux <- IQC2-1 <- IQC2-1 RX
           aplay-8784  [001] ....  8137.001206: snd_soc_dapm_path:  I2S5 Mux <- IQC1-2 <- IQC1-2 RX
           aplay-8784  [001] ....  8137.001208: snd_soc_dapm_path:  I2S5 Mux <- IQC1-1 <- IQC1-1 RX
           aplay-8784  [001] ....  8137.001210: snd_soc_dapm_path:  I2S5 Mux <- MVC2 <- MVC2 RX
           aplay-8784  [001] ....  8137.001239: snd_soc_dapm_path:  I2S5 Mux <- MVC1 <- MVC1 RX
           aplay-8784  [001] ....  8137.001241: snd_soc_dapm_path:  I2S5 Mux <- OPE1 <- OPE1 RX
           aplay-8784  [001] ....  8137.001244: snd_soc_dapm_path:  I2S5 Mux <- AFC6 <- AFC6 RX
           aplay-8784  [001] ....  8137.001245: snd_soc_dapm_path:  I2S5 Mux <- AFC5 <- AFC5 RX
           aplay-8784  [001] ....  8137.001247: snd_soc_dapm_path:  I2S5 Mux <- AFC4 <- AFC4 RX
           aplay-8784  [001] ....  8137.001248: snd_soc_dapm_path:  I2S5 Mux <- AFC3 <- AFC3 RX
           aplay-8784  [001] ....  8137.001251: snd_soc_dapm_path:  I2S5 Mux <- AFC2 <- AFC2 RX
           aplay-8784  [001] ....  8137.001252: snd_soc_dapm_path:  I2S5 Mux <- AFC1 <- AFC1 RX
           aplay-8784  [001] ....  8137.001254: snd_soc_dapm_path:  I2S5 Mux <- MIXER1-5 <- MIXER1-5 RX
           aplay-8784  [001] ....  8137.001255: snd_soc_dapm_path:  I2S5 Mux <- MIXER1-4 <- MIXER1-4 RX
           aplay-8784  [001] ....  8137.001257: snd_soc_dapm_path:  I2S5 Mux <- MIXER1-3 <- MIXER1-3 RX
           aplay-8784  [001] ....  8137.001258: snd_soc_dapm_path:  I2S5 Mux <- MIXER1-2 <- MIXER1-2 RX
           aplay-8784  [001] ....  8137.001261: snd_soc_dapm_path:  I2S5 Mux <- MIXER1-1 <- MIXER1-1 RX
           aplay-8784  [001] ....  8137.001263: snd_soc_dapm_path:  I2S5 Mux <- SFC4 <- SFC4 RX
           aplay-8784  [001] ....  8137.001264: snd_soc_dapm_path:  I2S5 Mux <- SFC3 <- SFC3 RX
           aplay-8784  [001] ....  8137.001266: snd_soc_dapm_path:  I2S5 Mux <- SFC2 <- SFC2 RX
           aplay-8784  [001] ....  8137.001269: snd_soc_dapm_path:  I2S5 Mux <- SFC1 <- SFC1 RX
           aplay-8784  [001] ....  8137.001270: snd_soc_dapm_path:  I2S5 Mux <- I2S5 <- I2S5 RX
           aplay-8784  [001] ....  8137.001272: snd_soc_dapm_path:  I2S5 Mux <- I2S4 <- I2S4 RX
           aplay-8784  [001] ....  8137.001273: snd_soc_dapm_path:  I2S5 Mux <- I2S3 <- I2S3 RX
           aplay-8784  [001] ....  8137.001275: snd_soc_dapm_path:  I2S5 Mux <- I2S2 <- I2S2 RX
           aplay-8784  [001] ....  8137.001276: snd_soc_dapm_path:  I2S5 Mux <- I2S1 <- I2S1 RX
           aplay-8784  [001] ....  8137.001277: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF10 <- ADMAIF10 RX
           aplay-8784  [001] ....  8137.001279: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF9 <- ADMAIF9 RX
           aplay-8784  [001] ....  8137.001280: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF8 <- ADMAIF8 RX
           aplay-8784  [001] ....  8137.001282: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF7 <- ADMAIF7 RX
           aplay-8784  [001] ....  8137.001283: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF6 <- ADMAIF6 RX
           aplay-8784  [001] ....  8137.001285: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF5 <- ADMAIF5 RX
           aplay-8784  [001] ....  8137.001286: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF4 <- ADMAIF4 RX
           aplay-8784  [001] ....  8137.001287: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF3 <- ADMAIF3 RX
           aplay-8784  [001] ....  8137.001289: snd_soc_dapm_path:  I2S5 Mux <- ADMAIF2 <- ADMAIF2 RX
           aplay-8784  [001] ....  8137.001290: snd_soc_dapm_path: *I2S5 Mux <- ADMAIF1 <- ADMAIF1 RX
           aplay-8784  [001] ....  8137.001292: snd_soc_dapm_widget_power: widget=I2S5 Mux val=1
           aplay-8784  [001] ....  8137.001296: snd_soc_dapm_path: *I2S5 TX <- (direct) <- I2S5 Mux
           aplay-8784  [001] ....  8137.001297: snd_soc_dapm_widget_power: widget=I2S5 TX val=1
           aplay-8784  [001] ....  8137.001299: snd_soc_dapm_path: *I2S5 Transmit <- (direct) <- I2S5 TX
           aplay-8784  [001] ....  8137.001300: snd_soc_dapm_widget_power: widget=I2S5 Transmit val=1
           aplay-8784  [001] ....  8137.001302: snd_soc_dapm_path: *I2S5 Transmit-I2S5 CIF Receive <- (direct) <- I2S5 Transmit
           aplay-8784  [001] ....  8137.001304: snd_soc_dapm_widget_power: widget=I2S5 Transmit-I2S5 CIF Receive val=1
           aplay-8784  [001] ....  8137.001306: snd_soc_dapm_path: *I2S5 CIF Receive <- (direct) <- I2S5 Transmit-I2S5 CIF Receive
           aplay-8784  [001] ....  8137.001308: snd_soc_dapm_widget_power: widget=I2S5 CIF Receive val=1
           aplay-8784  [001] ....  8137.001310: snd_soc_dapm_path: *I2S5 CIF RX <- (direct) <- I2S5 CIF Receive
           aplay-8784  [001] ....  8137.001312: snd_soc_dapm_widget_power: widget=I2S5 CIF RX val=1
           aplay-8784  [001] ....  8137.001314: snd_soc_dapm_path: *I2S5 DAP TX <- (direct) <- I2S5 CIF RX
           aplay-8784  [001] ....  8137.001316: snd_soc_dapm_widget_power: widget=I2S5 DAP TX val=1
           aplay-8784  [001] ....  8137.001318: snd_soc_dapm_path: *I2S5 DAP Transmit <- (direct) <- I2S5 DAP TX
           aplay-8784  [001] ....  8137.001320: snd_soc_dapm_widget_power: widget=I2S5 DAP Transmit val=1
           aplay-8784  [001] ....  8137.001323: snd_soc_dapm_path: *I2S5 DAP Transmit-x Playback <- (direct) <- I2S5 DAP Transmit
           aplay-8784  [001] ....  8137.001324: snd_soc_dapm_widget_power: widget=I2S5 DAP Transmit-x Playback val=1
           aplay-8784  [001] ....  8137.001327: snd_soc_dapm_path: *x Playback <- (direct) <- I2S5 DAP Transmit-x Playback
           aplay-8784  [001] ....  8137.001329: snd_soc_dapm_widget_power: widget=x Playback val=1
           aplay-8784  [001] ....  8137.001331: snd_soc_dapm_path: *x I2S IN <- (direct) <- x Playback
           aplay-8784  [001] ....  8137.001333: snd_soc_dapm_widget_power: widget=x I2S IN val=1
           aplay-8784  [001] ....  8137.001335: snd_soc_dapm_path:  x DAC SRC Mux <- RDATA TO LDAC, LDATA TO RDAC <- x I2S IN
           aplay-8784  [001] ....  8137.001337: snd_soc_dapm_path:  x DAC SRC Mux <- RDATA TO LDAC, RDATA TO RDAC <- x I2S IN
           aplay-8784  [001] ....  8137.001339: snd_soc_dapm_path:  x DAC SRC Mux <- LDATA TO LDAC, LDATA TO RDAC <- x I2S IN
           aplay-8784  [001] ....  8137.001342: snd_soc_dapm_path: *x DAC SRC Mux <- LDATA TO LDAC, RDATA TO RDAC <- x I2S IN
           aplay-8784  [001] ....  8137.001344: snd_soc_dapm_widget_power: widget=x DAC SRC Mux val=1
           aplay-8784  [001] ....  8137.001346: snd_soc_dapm_path: *x Right DAC <- (direct) <- x DAC SRC Mux
           aplay-8784  [001] ....  8137.001349: snd_soc_dapm_widget_power: widget=x Right DAC val=1
           aplay-8784  [001] ....  8137.001351: snd_soc_dapm_path: *x Left DAC <- (direct) <- x DAC SRC Mux
           aplay-8784  [001] ....  8137.001352: snd_soc_dapm_widget_power: widget=x Left DAC val=1
           aplay-8784  [001] ....  8137.001355: snd_soc_dapm_path: *x Right Hp mixer <- Right DAC Switch <- x Right DAC
           aplay-8784  [001] ....  8137.001357: snd_soc_dapm_path:  x Right Hp mixer <- RLIN Switch <- x Right Hp mux
           aplay-8784  [001] ....  8137.001359: snd_soc_dapm_widget_power: widget=x Right Hp mixer val=1
           aplay-8784  [001] ....  8137.001361: snd_soc_dapm_path: *x Left Hp mixer <- Left DAC Switch <- x Left DAC
           aplay-8784  [001] ....  8137.001388: snd_soc_dapm_path:  x Left Hp mixer <- LLIN Switch <- x Left Hp mux
           aplay-8784  [001] ....  8137.001390: snd_soc_dapm_widget_power: widget=x Left Hp mixer val=1
           aplay-8784  [001] ....  8137.001392: snd_soc_dapm_path: *x HPCP R <- (direct) <- x Right Hp mixer
           aplay-8784  [001] ....  8137.001393: snd_soc_dapm_widget_power: widget=x HPCP R val=1
           aplay-8784  [001] ....  8137.001395: snd_soc_dapm_path: *x HPCP L <- (direct) <- x Left Hp mixer
           aplay-8784  [001] ....  8137.001396: snd_soc_dapm_widget_power: widget=x HPCP L val=1
           aplay-8784  [001] ....  8137.001398: snd_soc_dapm_path: *x HPVOL R <- (direct) <- x HPCP R
           aplay-8784  [001] ....  8137.001399: snd_soc_dapm_widget_power: widget=x HPVOL R val=1
           aplay-8784  [001] ....  8137.001401: snd_soc_dapm_path: *x HPVOL L <- (direct) <- x HPCP L
           aplay-8784  [001] ....  8137.001403: snd_soc_dapm_widget_power: widget=x HPVOL L val=1
           aplay-8784  [001] ....  8137.001405: snd_soc_dapm_path: *x HPOR <- (direct) <- x HPVOL R
           aplay-8784  [001] ....  8137.001406: snd_soc_dapm_widget_power: widget=x HPOR val=1
           aplay-8784  [001] ....  8137.001408: snd_soc_dapm_path: *x HPOL <- (direct) <- x HPVOL L
           aplay-8784  [001] ....  8137.001409: snd_soc_dapm_widget_power: widget=x HPOL val=1
           aplay-8784  [001] ....  8137.001545: snd_soc_dapm_walk_done: es8316-tegra: checks 26 power, 25 path, 106 neighbour
           aplay-8784  [001] ....  8137.001551: snd_soc_bias_level_start: card=es8316-tegra val=1
           aplay-8784  [001] ....  8137.001554: snd_soc_bias_level_done: card=es8316-tegra val=1
           aplay-8784  [001] ....  8137.001556: snd_soc_bias_level_start: card=es8316-tegra val=2
           aplay-8784  [001] ....  8137.001557: snd_soc_bias_level_done: card=es8316-tegra val=2
   kworker/u12:1-8680  [003] ....  8137.001860: snd_soc_bias_level_start: card=es8316-tegra val=1
   kworker/u12:0-8753  [000] ....  8137.001863: snd_soc_bias_level_start: card=es8316-tegra val=1
   kworker/u12:1-8680  [003] ....  8137.001866: snd_soc_bias_level_done: card=es8316-tegra val=1
   kworker/u12:0-8753  [000] ....  8137.001867: snd_soc_bias_level_done: card=es8316-tegra val=1
   kworker/u12:1-8680  [003] ....  8137.001867: snd_soc_bias_level_start: card=es8316-tegra val=2
   kworker/u12:1-8680  [003] ....  8137.001869: snd_soc_bias_level_done: card=es8316-tegra val=2
   kworker/u12:0-8753  [000] ....  8137.001869: snd_soc_bias_level_start: card=es8316-tegra val=2
   kworker/u12:1-8680  [003] ....  8137.001888: snd_soc_bias_level_start: card=es8316-tegra val=1
   kworker/u12:1-8680  [003] ....  8137.001890: snd_soc_bias_level_done: card=es8316-tegra val=1
   kworker/u12:1-8680  [003] ....  8137.001891: snd_soc_bias_level_start: card=es8316-tegra val=2
   kworker/u12:1-8680  [003] ....  8137.001893: snd_soc_bias_level_done: card=es8316-tegra val=2
   kworker/u12:0-8753  [000] ....  8137.001967: snd_soc_bias_level_done: card=es8316-tegra val=2
           aplay-8784  [004] ....  8137.002172: snd_soc_dapm_widget_event_start: widget=I2S5 DAP Transmit-x Playback val=1
           aplay-8784  [005] ....  8137.015346: snd_soc_dapm_widget_event_done: widget=I2S5 DAP Transmit-x Playback val=1
           aplay-8784  [005] ....  8137.015352: snd_soc_dapm_widget_event_start: widget=I2S5 Transmit-I2S5 CIF Receive val=1
           aplay-8784  [005] ....  8137.015357: snd_soc_dapm_widget_event_done: widget=I2S5 Transmit-I2S5 CIF Receive val=1
           aplay-8784  [005] ....  8137.015358: snd_soc_dapm_widget_event_start: widget=I2S5 DAP Transmit-x Playback val=2
           aplay-8784  [005] ....  8137.015360: snd_soc_dapm_widget_event_done: widget=I2S5 DAP Transmit-x Playback val=2
           aplay-8784  [005] ....  8137.015361: snd_soc_dapm_widget_event_start: widget=I2S5 Transmit-I2S5 CIF Receive val=2
           aplay-8784  [005] ....  8137.015363: snd_soc_dapm_widget_event_done: widget=I2S5 Transmit-I2S5 CIF Receive val=2
           aplay-8784  [005] ....  8137.015395: snd_soc_dapm_widget_event_start: widget=I2S5 DAP TX val=1
           aplay-8784  [005] ....  8137.015422: snd_soc_dapm_widget_event_done: widget=I2S5 DAP TX val=1
   kworker/u12:3-8786  [001] ....  8137.033149: snd_soc_bias_level_start: card=es8316-tegra val=3
   kworker/u12:3-8786  [001] ....  8137.033153: snd_soc_bias_level_done: card=es8316-tegra val=3
   kworker/u12:2-8785  [004] ....  8137.033164: snd_soc_bias_level_start: card=es8316-tegra val=3
   kworker/u12:3-8786  [001] ....  8137.033166: snd_soc_bias_level_start: card=es8316-tegra val=3
   kworker/u12:3-8786  [001] ....  8137.033167: snd_soc_bias_level_done: card=es8316-tegra val=3
   kworker/u12:2-8785  [004] ....  8137.033168: snd_soc_bias_level_done: card=es8316-tegra val=3
           aplay-8784  [005] ....  8137.033194: snd_soc_dapm_done: card=es8316-tegra

Hi wangxiaozhuang

The hw_params() observation confirms that you have a DAPM routing issue in the capture path. I reviewed your mixer control dumps, es8316 codec DAPM routes and DT settings. These appear fine and it looks strange to me that you are hitting PCM read errors.

For testing purpose can you add below to codec driver and see if your PCM errors go away?

diff --git a/es8316.c b/es8316.c
index 65c2fb6..6384490 100755
--- a/es8316.c
+++ b/es8316.c
@@ -399,6 +399,8 @@ static const struct snd_soc_dapm_route es8316_dapm_routes[] = {
        {"Differential Mux", "lin1-rin1", "MIC1"},
        {"Differential Mux", "lin2-rin2", "MIC2"},
        {"Line input PGA", NULL, "Differential Mux"},
+       {"Line input PGA", NULL, "MIC1"},
+       {"Line input PGA", NULL, "MIC2"},

        {"Mono ADC", NULL, "Line input PGA"},

Thanks.

Hi spujar

After testing it was found that the PCM error did not go away:

root@tegra-ubuntu:/home/nvidia# Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo
           <...>-7913  [001] ....    52.881078: snd_soc_dapm_start: card=es8316-tegra
           <...>-7913  [001] ....    52.881284: snd_soc_dapm_walk_done: es8316-tegra: checks 2 power, 2 path, 0 neighbour
           <...>-7913  [001] ....    52.881297: snd_soc_bias_level_start: card=es8316-tegra val=1
         arecord-7913  [001] ....    52.881299: snd_soc_bias_level_done: card=es8316-tegra val=1
         arecord-7913  [001] ....    52.881300: snd_soc_bias_level_start: card=es8316-tegra val=2
         arecord-7913  [001] ....    52.881302: snd_soc_bias_level_done: card=es8316-tegra val=2
         arecord-7913  [001] ....    52.881316: snd_soc_dapm_done: card=es8316-tegra
arecord: pcm_read:2103: read error: Input/output error
         arecord-7913  [000] ....    63.069230: snd_soc_dapm_start: card=es8316-tegra
         arecord-7913  [000] ....    63.069363: snd_soc_dapm_path: *ADMAIF1 Transmit -> (direct) -> Capture 1
         arecord-7913  [000] ....    63.069371: snd_soc_dapm_path: *ADMAIF1 Transmit -> (direct) -> ADMAIF1 Transmit-ADMAIF1 CIF Transmit
         arecord-7913  [000] ....    63.069440: snd_soc_dapm_walk_done: es8316-tegra: checks 2 power, 2 path, 2 neighbour
         arecord-7913  [000] ....    63.069445: snd_soc_bias_level_start: card=es8316-tegra val=1
         arecord-7913  [000] ....    63.069447: snd_soc_bias_level_done: card=es8316-tegra val=1
         arecord-7913  [000] ....    63.069449: snd_soc_bias_level_start: card=es8316-tegra val=2
         arecord-7913  [000] ....    63.069450: snd_soc_bias_level_done: card=es8316-tegra val=2
         arecord-7913  [000] ....    63.069464: snd_soc_dapm_done: card=es8316-tegra

[2]+  Exit 1                  arecord -d 5 -D hw:es8316tegra -f S16_LE -c 2 -t wav > test.wav

Below is the diff of es8316:

diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
index cc2f465e9fe1..066a566ab01f 100644
--- a/sound/soc/codecs/es8316.c
+++ b/sound/soc/codecs/es8316.c
@@ -322,10 +322,10 @@ static const struct snd_soc_dapm_widget es8316_dapm_widgets[] = {
                         &es8316_dmic_src_controls),
 
        /* Digital Interface */
-       SND_SOC_DAPM_AIF_OUT("I2S OUT", "I2S1 Capture",  1,
-                            ES8316_SDP_ADCFMT_REG0A, 6, 0),
+       SND_SOC_DAPM_AIF_OUT("I2S OUT", "Capture",  1,
+                            SND_SOC_NOPM, 6, 0),
 
-       SND_SOC_DAPM_AIF_IN("I2S IN", "I2S Playback", 0,
+       SND_SOC_DAPM_AIF_IN("I2S IN", "Playback", 0,
                            SND_SOC_NOPM, 0, 0),
 
        /*  DACs DATA SRC MUX */
@@ -399,6 +399,8 @@ static const struct snd_soc_dapm_route es8316_dapm_routes[] = {
        {"Differential Mux", "lin1-rin1", "MIC1"},
        {"Differential Mux", "lin2-rin2", "MIC2"},
        {"Line input PGA", NULL, "Differential Mux"},
+       {"Line input PGA", NULL, "MIC1"},
+       {"Line input PGA", NULL, "MIC2"},
 
        {"Mono ADC", NULL, "Line input PGA"},
 
@@ -1040,7 +1042,7 @@ static int es8316_probe(struct snd_soc_codec *codec)
        int ret = 0;
        es8316_codec = codec;
        INIT_DELAYED_WORK(&es8316->pcm_pop_work, pcm_pop_work_events);  
-printk("%s %d=========================================\n",__func__,__LINE__);
+printk("%s %dwwwwwww=========================================\n",__func__,__LINE__);
        es8316->mclk = devm_clk_get(codec->dev, "mclk");
        if (PTR_ERR(es8316->mclk) == -EPROBE_DEFER)
                return -EPROBE_DEFER;

dmesg | grep wwwwwww

[    2.338903] es8316_probe 1045wwwwwww=========================================

Thanks.

Hi wangxiaozhuang,

You can do few experiments to isolate the problem:

  1. Can you try arecord with different sample rate 44100 or 48000? You can use “-r” argument and provide the sample rate with arecord application.

  2. Check what is wrong with the codec DAPM routes. Try connecting the codec side widgets directly like below and check if you see hw_params() call:

diff --git a/es8316.c b/es8316.c
index 65c2fb6..47d0c29 100755
--- a/es8316.c
+++ b/es8316.c
@@ -407,6 +407,8 @@ static const struct snd_soc_dapm_route es8316_dapm_routes[] = {
        {"Digital Mic Mux", "dmic data at low level", "DMIC"},

        {"I2S OUT", NULL, "Digital Mic Mux"},
+       {"I2S OUT", NULL, "MIC1"},
+       {"I2S OUT", NULL, "MIC2"},
        /*
         * playback route map
         */
  1. If [1] and [2] still do not work as expected, try I2S5 loopback independently. This will help to isolate if the issue is at Tegra side or codec side. For this you need to remove your DT changes you did for “nvidia,dai-link-5” and try following:
amixer -c es8316tegra cset name="I2S5 Mux" "ADMAIF1"
amixer -c es8316tegra cset name="ADMAIF1 Mux" "I2S5"
amixer -c es8316tegra cset name="I2S5 Loopback" "on"
aplay -Dhw:es8316tegra,0 <file.wav> &
arecord -Dhw:es8316tegra,0 -f S16_LE -c 2 -r 44100 -d 5 cap.wav

It is expected that the record runs clean and it has playback content of duration 5 seconds in the “cap.wav”.

Thanks.

Hi spujar

The Same error.
Below is the diff of es8316:

diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
index cc2f465e9fe1..44c2b6b05f1d 100644
--- a/sound/soc/codecs/es8316.c
+++ b/sound/soc/codecs/es8316.c
@@ -322,10 +322,10 @@ static const struct snd_soc_dapm_widget es8316_dapm_widgets[] = {
                         &es8316_dmic_src_controls),
 
        /* Digital Interface */
-       SND_SOC_DAPM_AIF_OUT("I2S OUT", "I2S1 Capture",  1,
-                            ES8316_SDP_ADCFMT_REG0A, 6, 0),
+       SND_SOC_DAPM_AIF_OUT("I2S OUT", "Capture",  1,
+                            SND_SOC_NOPM, 6, 0),
 
-       SND_SOC_DAPM_AIF_IN("I2S IN", "I2S Playback", 0,
+       SND_SOC_DAPM_AIF_IN("I2S IN", "Playback", 0,
                            SND_SOC_NOPM, 0, 0),
 
        /*  DACs DATA SRC MUX */
@@ -399,6 +399,8 @@ static const struct snd_soc_dapm_route es8316_dapm_routes[] = {
        {"Differential Mux", "lin1-rin1", "MIC1"},
        {"Differential Mux", "lin2-rin2", "MIC2"},
        {"Line input PGA", NULL, "Differential Mux"},
+       {"Line input PGA", NULL, "MIC1"},
+       {"Line input PGA", NULL, "MIC2"},
 
        {"Mono ADC", NULL, "Line input PGA"},
 
@@ -407,6 +409,8 @@ static const struct snd_soc_dapm_route es8316_dapm_routes[] = {
        {"Digital Mic Mux", "dmic data at low level", "DMIC"},
 
        {"I2S OUT", NULL, "Digital Mic Mux"},
+       {"I2S OUT", NULL, "MIC1"},
+       {"I2S OUT", NULL, "MIC2"},
        /*
         * playback route map
         */

amixer -c es8316tegra cset name=“I2S5 Mux” “ADMAIF1”
amixer -c es8316tegra cset name=“ADMAIF1 Mux” “I2S5”
amixer -c es8316tegra cset name=“I2S5 Loopback” “on”
aplay -D hw:es8316tegra,0 music.wav &

Return:

[1] 7976
Playing WAVE 'music.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

dmesg |grep es8316_pcm_hw_params
Return:

[   10.570021] es8316_pcm_hw_params 740=========================================
[   10.744060] es8316_pcm_hw_params 740=========================================
[   54.414334] es8316_pcm_hw_params 740=========================================

arecord -Dhw:es8316tegra,0 -f S16_LE -c 2 -r 44100 -d 5 cap.wav &
Return:

[2] 7979
Recording WAVE 'cap.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

dmesg |grep es8316_pcm_hw_params
Return:

[   10.570021] es8316_pcm_hw_params 740=========================================
[   10.744060] es8316_pcm_hw_params 740=========================================
[   54.414334] es8316_pcm_hw_params 740=========================================

After executing the arecord command, hw_params() doesn’t seem to be called

After a while, the returned:

arecord: pcm_read:2103: read error: Input/output error
[2]+  Exit 1                  arecord -Dhw:es8316tegra,0 -f S16_LE -c 2 -r 44100 -d 5 cap.wav

dmesg > kernel.log
kernel.log (79.0 KB)

Thanks.

While testing this did you remove DT DAI link settings of es8316? This is important check to understand if I2S5 standalone loopback works fine at your end. If this works fine, then it confirms there is an issue with the DAPM route side on codec and DAPM routes are OK on host (Tegra) side.

Hi spujar

The file ‘tegra194-audio-p3668.dtsi’, “nvidia,dai-link-5” only keeps “status = okay”;

diff --git a/common/tegra194-audio-p3668.dtsi b/common/tegra194-audio-p3668.dtsi
index 48a3289..d8bca03 100644
--- a/common/tegra194-audio-p3668.dtsi
+++ b/common/tegra194-audio-p3668.dtsi
@@ -49,20 +49,20 @@
                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",
+            "x Headphone",          "x OUT",
+            "x IN",                 "x MIC1",
+            "x Headphone",          "x OUT",
+                       "x IN",                 "x MIC2",
+                       "x Headphone",          "x OUT",
+                       "x IN",                 "x DMIC",
+                       "x Headphone",          "x OUT",
+                       "x IN",                 "x MIC",
+                       "x Headphone",          "x OUT",
+                       "x IN",                 "x MIC",
+                       "x IN",                 "x DMIC",
+                       "b IN",                 "b MIC1",
+                       "c IN",                 "c MIC2",
+                       "d IN",                 "d DMIC",
                        "d1 Headphone",         "d1 OUT",
                        "d2 Headphone",         "d2 OUT";
 
@@ -77,10 +77,12 @@
                };
 
                hdr40_snd_link_i2s: nvidia,dai-link-5 {
+#if 0
                        name-prefix = "x";
                        link-name = "es8316-playback";
                        codec-dai = <&es8316_codec>;
                        codec-dai-name = "es8316-hifi";
+#endif
                        status = "okay";
                };

amixer -c es8316tegra cset name=“I2S5 Mux” “ADMAIF1”
amixer -c es8316tegra cset name=“ADMAIF1 Mux” “I2S5”
amixer -c es8316tegra cset name=“I2S5 Loopback” “on”

aplay -D hw:es8316tegra,0 music.wav &

Return:

[1] 8170
Playing WAVE 'music.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

arecord -Dhw:es8316tegra,0 -f S16_LE -c 2 -r 44100 -d 5 cap.wav &
Return:

[2] 8171
Recording WAVE 'cap.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

After a while return:

arecord: pcm_read:2103: read error: Input/output error

[1]-  Done            aplay -D hw:es8316tegra,0 music.wav
[2]+  Exit 1          arecord -Dhw:es8316tegra,0 -f S16_LE -c 2 -r 44100 -d 5 cap.wav

“cap.wav” only has a “beep beep” noise for one second.
ls -al cap.wav
-rw-r--r-- 1 root root 44 Oct 13 14:09 cap.wav

dmesg > kernel.log
kernel.log (78.6 KB)

’tegra194-audio-p3668.dtsi‘ changed to this, the same result as above

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

Does this result mean that there is an issue on the host (Tegra) side?
Thanks.

Hi wangxiaozhuang,

I checked internally and it appears that I2S5 loopback is expected to work. You should check on the JP release image without any modifications to the image to double confirm your observation about I2S5 loopback.

Hi spujar

The version I use is JP4.6 and NVIDIA L4T 32.6.1, does this matter? Do I need to switch to the latest version to test? It feels like a lot of work. After changing the version, the testing department has to test from scratch again.

Hi wangxiaozhuang,

What I am saying is to remove all your local modifications related to audio and test once. Because right now the observations are not aligned w.r.t I2S5 loopback. You need not switch to some other release.

Hi spujar

I just rolled back a few changes below and Mic loopback recording worked:

1, sound driver directory: ‘sources/kernel/nvidia/sound’

diff --git a/sound/soc/tegra-alt/Kconfig b/sound/soc/tegra-alt/Kconfig
index 0bffefce8..759dfe97a 100644
--- a/sound/soc/tegra-alt/Kconfig
+++ b/sound/soc/tegra-alt/Kconfig
@@ -176,7 +176,6 @@ 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.
 
@@ -206,7 +205,6 @@ 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 98f592979..b2e8fa27c 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,16 +29,10 @@
 #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)              \
@@ -175,8 +169,6 @@ 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[] = {
@@ -194,7 +186,6 @@ static int tegra_machine_codec_get_rate(struct snd_kcontrol *kcontrol,
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
        struct tegra_machine *machine = snd_soc_card_get_drvdata(card);
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        ucontrol->value.integer.value[0] = machine->rate_via_kcontrol;
 
        return 0;
@@ -218,7 +209,6 @@ static int tegra_machine_codec_get_format(struct snd_kcontrol *kcontrol,
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
        struct tegra_machine *machine = snd_soc_card_get_drvdata(card);
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        ucontrol->value.integer.value[0] = machine->fmt_via_kcontrol;
 
        return 0;
@@ -230,7 +220,6 @@ static int tegra_machine_codec_put_format(struct snd_kcontrol *kcontrol,
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
        struct tegra_machine *machine = snd_soc_card_get_drvdata(card);
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        /* set the format control flag */
        machine->fmt_via_kcontrol = ucontrol->value.integer.value[0];
 
@@ -248,9 +237,9 @@ static int tegra_machine_set_params(struct snd_soc_card *card,
        int idx = 0, err = 0;
        u64 format_k;
 
-       int num_of_dai_links = machine->soc_data->num_ahub_links + machine->num_codec_links;
+       int num_of_dai_links = machine->soc_data->num_ahub_links +
+                              machine->num_codec_links;
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        format_k = (machine->fmt_via_kcontrol == 2) ?
                        (1ULL << SNDRV_PCM_FORMAT_S32_LE) : formats;
 
@@ -308,13 +297,9 @@ static int tegra_machine_dai_init(struct snd_soc_pcm_runtime *runtime,
        int err, sample_size;
        struct snd_soc_pcm_runtime *rtd;
 
-printk("%s %d rate:%d=========================================\n",__func__,__LINE__,rate);
-#if 0
        srate = (machine->rate_via_kcontrol) ?
                        tegra_machine_srate_values[machine->rate_via_kcontrol] :
                        rate;
-#endif
-       srate = rate;
 
        switch (formats) {
        case SNDRV_PCM_FORMAT_S8:
@@ -350,33 +335,13 @@ printk("%s %d rate:%d=========================================\n",__func__,__LIN
 
        aud_mclk = machine->audio_clock.set_aud_mclk_rate;
 
-       printk("pll_a_out0 = %u Hz, aud_mclk = %u Hz, sample rate = %u Hz\n",
+       pr_debug("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===========20211015 %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 =
@@ -446,7 +411,6 @@ static int tegra_machine_pcm_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_card *card = rtd->card;
        int err;
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        err = tegra_machine_dai_init(rtd, params_rate(params),
                                     params_channels(params),
                                     params_format(params));
@@ -463,7 +427,6 @@ static int tegra_machine_pcm_startup(struct snd_pcm_substream *substream)
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct tegra_machine *machine = snd_soc_card_get_drvdata(rtd->card);
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        tegra_alt_asoc_utils_clk_enable(&machine->audio_clock);
 
        return 0;
@@ -474,7 +437,6 @@ static void tegra_machine_pcm_shutdown(struct snd_pcm_substream *substream)
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct tegra_machine *machine = snd_soc_card_get_drvdata(rtd->card);
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        tegra_alt_asoc_utils_clk_disable(&machine->audio_clock);
 }
 
@@ -482,7 +444,6 @@ static int tegra_machine_suspend_pre(struct snd_soc_card *card)
 {
        struct snd_soc_pcm_runtime *rtd;
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        /* DAPM dai link stream work for non pcm links */
        list_for_each_entry(rtd, &card->rtd_list, list) {
                if (rtd->dai_link->params)
@@ -551,7 +512,6 @@ static int tegra_machine_respeaker_init(struct snd_soc_pcm_runtime *rtd)
        struct device *dev = rtd->card->dev;
        int err;
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        /* ac108 codec driver hardcodes the freq as 24000000
         * and source as PLL irrespective of args passed through
         * this callback
@@ -571,7 +531,6 @@ static int tegra_machine_fepi_init(struct snd_soc_pcm_runtime *rtd)
        struct device *dev = rtd->card->dev;
        int err;
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        err = snd_soc_dai_set_sysclk(rtd->codec_dai, SGTL5000_SYSCLK, 12288000,
                                     SND_SOC_CLOCK_IN);
        if (err) {
@@ -582,29 +541,12 @@ printk("%s %d=========================================\n",__func__,__LINE__);
        return 0;
 }
 
-static int tegra_machine_es8316_init(struct snd_soc_pcm_runtime *rtd)  //wxz
-{
-       struct device *dev = rtd->card->dev;
-       int err;
-
-printk("%s %d=========================================\n",__func__,__LINE__);
-       //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;
        struct snd_soc_jack *jack;
        int err;
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        jack = devm_kzalloc(card->dev, sizeof(struct snd_soc_jack), GFP_KERNEL);
        if (!jack)
                return -ENOMEM;
@@ -649,7 +591,6 @@ static int codec_init(struct tegra_machine *machine)
        if (!dai_links || !num_links)
                return -EINVAL;
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        for (i = 0; i < num_links; i++) {
                if (!dai_links[i].name)
                        continue;
@@ -661,8 +602,6 @@ printk("%s %d=========================================\n",__func__,__LINE__);
                        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;
@@ -686,7 +625,6 @@ static void set_dai_ops(struct tegra_machine *machine)
 {
        int i;
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        /* set ADMAIF dai_ops */
        for (i = machine->soc_data->admaif_dai_link_start;
             i <= machine->soc_data->admaif_dai_link_end; i++)
@@ -725,7 +663,6 @@ static int add_dai_links(struct platform_device *pdev)
        struct tegra_machine *machine = snd_soc_card_get_drvdata(card);
        int ret;
 
-printk("%s %d=========================================\n",__func__,__LINE__);
        machine->asoc = devm_kzalloc(&pdev->dev, sizeof(*machine->asoc),
                                     GFP_KERNEL);
        if (!machine->asoc)
@@ -847,8 +784,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) %s %d\n",
-                       ret,__FILE__,__LINE__);
+               dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
+                       ret);
                goto cleanup_asoc;
        }

2, dts file ‘tegra194-audio-p3668.dtsi’

diff --git a/common/tegra194-audio-p3668.dtsi b/common/tegra194-audio-p3668.dtsi
index 48a3289..32ea0bd 100644
--- a/common/tegra194-audio-p3668.dtsi
+++ b/common/tegra194-audio-p3668.dtsi
@@ -36,7 +36,7 @@
        tegra_sound: sound {
                status = "okay";
                compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
-               nvidia,model = "es8316-tegra";
+               nvidia,model = "jetson-xaviernx-ape";
                clocks = <&bpmp_clks TEGRA194_CLK_PLLA>,
                         <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>,
                         <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
@@ -47,11 +47,11 @@
                                         <&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",
+                       "x Headphone",          "x OUT",
+                       "x IN",                 "x Mic",
+                       "y Headphone",          "y OUT",
+                       "y IN",                 "y Mic",
+                       "z Headphone",          "z OUT",
                        "z IN",                 "z Mic",
                        "m Headphone",          "m OUT",
                        "m IN",                 "m Mic",
@@ -66,10 +66,6 @@
                        "d1 Headphone",         "d1 OUT",
                        "d2 Headphone",         "d2 OUT";
 
-
-
-               nvidia,xbar = <&tegra_axbar>;
-
                mclk-fs = <256>;
 
                nvidia,dai-link-1 {
@@ -78,10 +74,6 @@
 
                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";
                };
 
        };

amixer -c jetsonxaviernxa cset name=“I2S1 Mux” “ADMAIF1”
amixer -c jetsonxaviernxa cset name=“ADMAIF1 Mux” “I2S5”
amixer -c jetsonxaviernxa cset name=“I2S5 Loopback” “on”

aplay -Dhw:jetsonxaviernxa,0 music.wav &
arecord -Dhw:jetsonxaviernxa,0 -f S16_LE -c 2 -r 44100 -d 5 cap.wav

‘cap.wav’ file is OK , this file can be played for 5 seconds.

Why does es8316 report an error when recording, please give me a guide.
Thanks.

Above were the routes you added for es8316 codec. But I don’t see the routes for MIC.
In your previous replies the routes were present. Please make sure you have the MIC1 and MIC2 routes enabled.

Can you try with below instead (along with the MIC routes in DT)? I am not sure if this would make any difference, but generally these are the widgets used to for playback or capture paths.

SND_SOC_DAPM_SPK("x OUT", NULL),
SND_SOC_DAPM_MIC("x IN", NULL),

Please note that your standalone I2S5 loopback works. That means there is no issue on Tegra side and you need to fix codec routes. Check with pointers mentioned above, if it still does not work you may want to check with the codec vendor.

Thanks.

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