Audio codec es8316 driver

Hello, I’m debugging the audio driver, I configured the I2S0 feature in PINMUX ,I2S SCLK, I2S LRCK have no signal by instrument measurement, Where is the wrong configuration?
tegra194-p3668-all-p3509-0000.dts (248.7 KB)
tegra194-audio-p3668.dtsi (4.1 KB)
tegra19x-jetson_xavier_nx_module-pinmux.dtsi (54.4 KB)
tegra19x-jetson_xavier_nx_module-gpio-default.dtsi (1.8 KB)

What’s the JetPack version you’re using?

versions: 32.5.1 JetPack 4.5.1

  • I2S has no signal output, is that related to Codec configuration?

Please refer to Audio Setup and Development — Jetson Linux
Developer Guide 34.1 documentation (nvidia.com)

Now the audio output is normal, but it cannot be recorded. Can you check the reason?
tegra194-audio-p3668.dtsi (4.7 KB)
es8316.c (37.6 KB)
tegra_machine_driver_mobile.c (24.9 KB)

1 Like

Hi chao.zhang,

I see that the pinmux settings are incomplete for certain mode of operation. Instead of using dts changes for setting pinmux, use original pinmux/gpio dtsi (i.e do not modify them) and use jetson-io tool to configure pinmux with commands below (More details at link)

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

After setting pinmux, one can check that the setting has reflected using below command

sudo /opt/nvidia/jetson-io/config-by-function.py -l enabled

The o/p should be as shown below which indicates i2s5 and aud_mclk are enabled on 40 pin header

Header 1 [default]: Jetson 40pin Header
  Enabled functions (pins):
   1. aud_mclk (7)
   2. i2s5 (12,35,38,40)
Header 2: Jetson Nano CSI Connector
  No functions are enabled.
Header 3: Jetson M.2 Key E Slot
  Enabled functions (pins):
   1. i2s3 (8,10,12,14)

Further, are you using jetson i2s in bit clock master or slave mode?

Thanks

Thanks for your reply. the following information is printed:
Screenshot from 2022-07-15 13-49-42
Screenshot from 2022-07-15 14-08-53

jetson i2s in bit clock is master mode.Codec is slave mode.

There are also the following, I see the, I2S5 Dailink is on for Play and off for Capture.

Hi chao.zhang,

Since playback is working fine, the codec and card registration are succesful. I suspect that DAPM path during capture may not be complete. Therefore the capture fails to start. In order to see the path trace, you could use commands below

#First enable DAPM trace events in a different terminal shell
for i in `find /sys/kernel/debug/tracing/events -name "enable" | grep snd_soc_`; do echo 1 > $i; done
#Then start the usecase as background process and issue  below command to check the trace
 cat /sys/kernel/debug/tracing/trace_pipe | grep *

Suggest to add below routes (in case you are using non DMIC path) in nvidia,audio_routing property of sound node before capturing trace

"x MIC1"      "x Mic",
"x MIC2"      "x Mic",

You may need to set some codec-specific mixer controls to enable capture. You can get these settings from the codec vendor or from the codec data sheet.

In addition, ensure to set below mixer settings in addition to codec specific settings

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

Check if this helps and share the DAPM trace captured and mixer settings (amixer -c 1 contents)

Thanks

Thanks for your reply.

  1. I added “X MIC2” and “x Mic” to the DTS file.
  2. Execute command line:amixer -c 1 cset name=“ADMAIF1 Mux” I2S5.
  3. Also when I execute the command: amixer -c 1 cset name = “I2S5 codec master mode” “cbs-cfs”,the command is invalid .
    Screenshot from 2022-07-18 10-21-42

The result is still not recorded.
When I record the command: arecord -d hw:1,0 -r 48000 -f S16_LE test.wav , Executing sudo cat/sys/kernel/debug/tracing/trace, The routing information is in the following file.Thanks.

trace.txt (204.3 KB)
contents.txt (303.7 KB)
controls.txt (55.0 KB)
tegra194-audio-p3668.dtsi (3.2 KB)
dmesg.txt (76.9 KB)

Hi chao.zhang,

The command failed because of the additional spaces.Retry with below command

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

I got to check the mixer settings and below seems suspicious. Contact codec vendor to get enable sequence (mixer settings) for capture via MIC1 or MIC2 which ever you are using.

numid=953,iface=MIXER,name='x ALC Capture NG Type'
  ; type=ENUMERATED,access=rw------,values=1,items=2
  ; Item #0 'Constant PGA Gain'
  ; Item #1 'Mute ADC Output'
  : values=1

Further from trace, it seems that path from MIC1 is complete but not from MIC2. Have you connected your mic to LIN1 and RIN1 or LIN2 and RIN2. Can you provide detail on your connection.

I suppose you are not connecting dmic. Please confirm

Thanks

Hi,Thanks.
I set ‘x ALC Capture NG Type’ to 0, The recording file still has no sound output.

Here are the Settings for the Mixer Settings:

static const struct snd_soc_dapm_route es8316_dapm_routes[] = {
	/*
	 * record route map
	 */
	{"MIC1", NULL, "micbias"},
	{"MIC2", NULL, "micbias"},
	{"DMIC", NULL, "micbias"},

	{"Differential Mux", "lin1-rin1", "MIC1"},
	{"Differential Mux", "lin2-rin2", "MIC2"},
	{"Line input PGA", NULL, "Differential Mux"},

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

	{"Digital Mic Mux", "dmic disable", "Mono ADC"},
	{"Digital Mic Mux", "dmic data at high level", "DMIC"},
	{"Digital Mic Mux", "dmic data at low level", "DMIC"},

My MIC is connected to LIN1.RIN1, LIN2 and RIN2 are connected to GND
2022-07-18_150326

Hi chao.zhang,

Do you mean arecord runs but the recorded file has silence? or arecord does not proceed and gives out pcm read error? or the recorded file is generated with header alone?

Thanks

Yes, I can use commands to record audio files or play the recorded audio files, but no sound is heard.No error reported.
I recorded with the command:arecord -D hw:1,0 -r 44100 -f S16_LE test.wav
Play command:aplay -D hw:1,0 test.wav

Hi chao.zhang,

Could you run below command and attach test.wav

arecord -D hw:1,0 -r 48000 -f S16_LE -d 10 test.wav

Thanks

OK,
The recording command:

amixer -c 1 cset name="ADMAIF1 Mux" I2S5
arecord -D hw:1,0 -r 48000 -f S16_LE -d 10 test.wav

Play Audio Commands:

amixer -c es8316tegra cset name="I2S5 Mux" "ADMAIF1"
amixer -c es8316tegra cset name="x Left DAC Switch" 1
amixer -c es8316tegra cset name="x Right DAC Switch" 1
aplay -D hw:1,0 test.wav

2022-07-18_160534

Hi chao.zhang,

So I see that arecord runs but captures zeroes or silence. I have two suggestions

  1. Probe the LIN1 to check if non-zero data is being sent from mic to LIN1

  2. If LIN1 is receiving non-zero data, probe Jetson I2S DIN<->Codec I2S OUT line to see if the non-zero data is getting propogated to Jetson

If you are

  1. seeing zero data on LIN1, issue is with input from mic
  2. seeing non zero on LIN1 but zero on codec I2S DOUT. This implies issue on codec side. contact codec vendor to get the codec settings and DAPM routes used reviewed.

Thanks

Thanks for your suggestions.
LIN1 pins are non-zero data when recording audio,but the Codec I2S OUT pin is zero data,
I2S0_SCLK AUD_MCLK I2S0_LRCK Signal is normal.

Hi chao.zhang,

Since the codec circuit is muting the data, suggest to take this further with codec vendor as I mentioned in previous posts.

Thanks

OK,Thank you for your support.

Hello. Now I see another problem.
I could play the audio file, but I noticed that the first time I ran it, the device or resource was busy. Second run, no hint. Any suggestions?

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

n@n-desktop:~/Desktop$ aplay -D hw:1,0 a.wav
aplay: main:788: audio open error: Device or resource busy

If I switch to another channel, I don’t have Device or resource busy.

  amixer -c jetsonxaviernxa cset name="I2S5 Mux" "ADMAIF2"
  amixer -c jetsonxaviernxa cset name="x Left DAC Switch" 1
  amixer -c jetsonxaviernxa cset name="x Right DAC Switch" 1

 n@n-desktop:~/Desktop$ aplay -D hw:1,1 test.wav
Playing WAVE 'a.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo