The audio codec ES8388 does not work on Jetson nano

hi ,mkumard, i cannot contact Codec vendor , but i find some one do es8388 on rk3588 borad,
the dts shows:

es8388_sound: es8388-sound {
status = “okay”;
compatible = “rockchip,multicodecs-card”;
rockchip,card-name = “rockchip,es8388”;
hp-det-gpio = <&gpio1 RK_PD5 GPIO_ACTIVE_LOW>;
io-channels = <&saradc 3>;
io-channel-names = “adc-detect”;
keyup-threshold-microvolt = <1800000>;
poll-interval = <100>;
spk-con-gpio = <&gpio1 RK_PD3 GPIO_ACTIVE_HIGH>;
hp-con-gpio = <&gpio1 RK_PD2 GPIO_ACTIVE_HIGH>;
rockchip,format = “i2s”;
rockchip,mclk-fs = <256>;
rockchip,cpu = <&i2s0_8ch>;
rockchip,codec = <&es8388>;
rockchip,audio-routing =
“Headphone”, “LOUT1”,
“Headphone”, “ROUT1”,
“Speaker”, “LOUT2”,
“Speaker”, “ROUT2”,
“Headphone”, “Headphone Power”,
“Headphone”, “Headphone Power”,
“Speaker”, “Speaker Power”,
“Speaker”, “Speaker Power”,
“LINPUT1”, “Main Mic”,
“LINPUT2”, “Main Mic”,
“RINPUT1”, “Headset Mic”,
“RINPUT2”, “Headset Mic”;
pinctrl-names = “default”;
pinctrl-0 = <&hp_det>;
play-pause-key {
label = “playpause”;
linux,code = <KEY_PLAYPAUSE>;
press-threshold-microvolt = <2000>;
};
does it have help?

Hi,
We are inline with above setting, though many of this entries are not required in our driver.

“Headphone”, “LOUT1”,
“Headphone”, “ROUT1”,

Little indepth review of driver noticed

/*
{ “Capture”, “LAMP”, “LINPUT1” },
{ “Capture”, “RAMP”, “LINPUT2” },

{ "LOUT1", NULL, "Playback" },
{ "ROUT1", NULL, "Playback" },
*/

Can I know, is this code was already disabled in the driver?. This could be the reason behind dapm not closing. Can you try enabling this piece of code?.

yes, they give me the codec source that those code were disabled, let me try tomorrow morning, and i found that if i play the music by ubuntu system default application, it play very fast, i mean the test.wav has 30 second duration ,but it played in 1 second then finish.

Sure, the behavior on ubuntu system expected as DAPM path not completed. We need to fix DAPM path issue to get proper audio playback data.

Also if above mentioned change not helping. Try with below suggestion on es8388_dapm_widgets struct.

Replace below lines
SND_SOC_DAPM_DAC(“Right DAC”, “Right Playback”, ES8388_DACPOWER, 6, 1),
SND_SOC_DAPM_DAC(“Left DAC”, “Left Playback”, ES8388_DACPOWER, 7, 1),
with
SND_SOC_DAPM_DAC(Right DAC, Playback, ES8388_DACPOWER, 6, 1),
SND_SOC_DAPM_DAC(Left DAC, Playback, ES8388_DACPOWER, 7, 1),

I have enable these code
/*
{ “Capture”, “LAMP”, “LINPUT1” },
{ “Capture”, “RAMP”, “LINPUT2” },

{ “LOUT1”, NULL, “Playback” },
{ “ROUT1”, NULL, “Playback” },
*/

but when i try to aplay test.wav, it always say it busy

biao@biao-desktop:~/Developer$ aplay -D hw:tegrasndt210ref test.wav
aplay: main:788: audio open error: Device or resource busy
biao@biao-desktop:~/Developer$ aplay -D hw:tegrasndt210ref test.wav
aplay: main:788: audio open error: Device or resource busy
biao@biao-desktop:~/Developer$ aplay -D hw:tegrasndt210ref test.wav
aplay: main:788: audio open error: Device or resource busy
biao@biao-desktop:~/Developer$ aplay -D hw:tegrasndt210ref test.wav
aplay: main:788: audio open error: Device or resource busy
biao@biao-desktop:~/Developer$ aplay -D hw:tegrasndt210ref test.wav
aplay: main:788: audio open error: Device or resource busy
biao@biao-desktop:~/Developer$ aplay -D hw:tegrasndt210ref test.wav
aplay: main:788: audio open error: Device or resource busy
biao@biao-desktop:~/Developer$ aplay -D hw:tegrasndt210ref test.wav
aplay: main:788: audio open error: Device or resource busy

but i paly it on ubuntu system , the duration becomes normal, but no sound.

and trace log shows nothing.

~/Developer$ sudo cat /sys/kernel/debug/tracing/trace

tracer: nop

entries-in-buffer/entries-written: 0/0 #P:4

_-----=> irqs-off

/ _----=> need-resched

| / _—=> hardirq/softirq

|| / _–=> preempt-depth

||| / delay

TASK-PID CPU# |||| TIMESTAMP FUNCTION

| | | |||| | |

if I Replace below lines

SND_SOC_DAPM_DAC(“Right DAC”, “Right Playback”, ES8388_DACPOWER, 6, 1),
SND_SOC_DAPM_DAC(“Left DAC”, “Left Playback”, ES8388_DACPOWER, 7, 1),
with
SND_SOC_DAPM_DAC(“Right DAC”, “Playback”, ES8388_DACPOWER, 6, 1),
SND_SOC_DAPM_DAC(“Left DAC”, “Playback”, ES8388_DACPOWER, 7, 1),

It still always show the device or resouce busy.

Hi,
If it shows device or resource busy then it means some process has opened the pcm device, mostly by ubuntu as same issue not seen with playing on it. can you check with “cat /proc/asound/card1/pcm0p/sub0/hw_params”

If audio player on ubuntu plays exactly for the audio file duration then DAPM completed and data started to flow. No audio could be some other issue. you can verify this by having prints in hw_params function in codec to confirm this.

if i enable those code ,the device or resource busy,hw_params shows

~/Developer$ cat /proc/asound/card1/pcm0p/sub0/hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 1
rate: 44100 (44100/1)
period_size: 2204
buffer_size: 4408

and if i disable those code, i can aplay the test.wav, but played very fast , then i got this logs

biao@biao-desktop:~/Developer$ aplay -D hw:tegrasndt210ref test.wav
Playing WAVE ‘test.wav’ : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
biao@biao-desktop:~/Developer$ cat /proc/asound/card1/pcm0p/sub0/hw_params
closed

Hi
I believe we need to get some help from codec vendor on the driver on DAPM path closing. Can you try contacting them on this. Please check if this driver works fine and required DAPM path configs.

hi, mkumard, sorry for reply late, could you help me to check the MCLK, SCLK and LRCK. at beginning , i set it as salve mode, now i change it as master mode ,

bitclock-master;
frame-master;

then I mesure this clock,


the blue one is SCLK and yellow one is MCLK in first picture,

in second picture, the blue one is LRCK,
The reason why i change it as master mode ,because the SCLK and LRCK seems not correct in slave mode.
Thanks.

btw, the mclk should be 12288000,

biao@biao-desktop:~/Developer$ dmesg | grep Enter
[ 1.612346] Entering es8388_set_dai_sysclk
[ 1.612348] Entering 12288000
[ 10.077438] Entering es8388_set_dai_sysclk
[ 10.077440] Entering 12288000
[ 10.223747] Entering es8388_set_dai_sysclk
[ 10.223750] Entering 12288000
[ 10.354024] Entering es8388_set_dai_sysclk
[ 10.354026] Entering 12288000
[ 10.482492] Entering es8388_set_dai_sysclk
[ 10.482494] Entering 12288000
[ 10.483550] Entering es8388_set_dai_sysclk
[ 10.483552] Entering 12288000
[ 10.485221] Entering es8388_set_dai_sysclk
[ 10.485223] Entering 12288000
[ 10.607651] Entering es8388_set_dai_sysclk
[ 10.607653] Entering 12288000
[ 10.608648] Entering es8388_set_dai_sysclk
[ 10.608650] Entering 12288000
[ 10.623649] Entering es8388_set_dai_sysclk
[ 10.623651] Entering 12288000
[ 10.769815] Entering es8388_set_dai_sysclk
[ 10.769817] Entering 12288000

ES8388 DS.pdf (760.1 KB)
ES8388 user Guide.pdf (6.0 MB)

the PAE of Codec vonder share those two files, in first file,shows the pin config,

PIN NAME I/O DESCRIPTION
1 MCLK I Master clock
2 DVDD Supply Digital core supply
3 PVDD Supply Digital IO supply
4 DGND Supply Digital ground (return path for both DVDD and PVDD)
5 SCLK I/O Audio data bit clock
6 DSDIN I DAC audio data
7 LRCK I/O Audio data left and right clock
8 ASDOUT O ADC audio data
9 NC 10 VREF O Decoupling capacitor
11 ROUT1 O Right output 1 (line or speaker/headphone)
12 LOUT1 O Left output 1 (line or speaker/headphone)
13 HPGND Supply Ground for analog output drivers (LOUT1/2, ROUT1/2)
14 ROUT2 O Right output 2 (line or speaker/headphone)
15 LOUT2 O Left output 2 (line or speaker/headphone)
16 HPVDD Supply Supply for analog output drivers (LOUT1/2, ROUT1/2)
17 AVDD Supply Analog supply
18 AGND Supply Analog ground
19 ADCVREF O Decoupling capacitor
20 VMID O Decoupling capacitor
21 RIN2 AI Right channel input 2
22 LIN2 I Left channel input 2
23 RIN1 I Right channel input 1
24 LIN1 I Left channel input 1
25 NC 26 CE I Control select or device address selection
27 CDATA I/O Control data input or output
28 CCLK I Control clock input

it seems only have LOUT1,ROUT1,LOUT2,ROUT2 as output.

Hi,
I see the clocks are very close to the required rate though MCLK is bit on higher side 12.315MHz.

What is the behavior seen with this clock?.

just follow the step of this linkhttps://forums.developer.nvidia.com/t/the-audio-codec-es8316-can-t-work-on-i2s0-for-xaiver-nx/189088/17
to check if there has anything wrong with hardware.

Hi,
I would like to understand, whether the DAPM issue seen earlier was resolved now?. Also what is the current status of the audio playback on codec speaker?.

the DAPM issue not resolve. I found that the kernel have audio codec ES8328, the DAPM is similar with ES8388. do you have any example about ES8328

Hi,
Don’t have any example for ES8328. There is one for ES8316 which got resolved The audio codec es8316 can’t work on I2S0 for Xaiver NX - #23 by wangxiaozhuang

I believe we should concentrate on the DAPM issue as unless it’s resolved we can’t expect audio to be working. valid clock and data comes after this.

yes, but the DAPM of ES8316 are different with ES8388, i have no idea to fix it.

es8388.c (30.1 KB)

Try with this driver. Set all the mixer controls as done earlier like “Right Playback Switch”, “Left Playback Switch” etc…

Enable the dapm tracing and provide log if issue still exists.