Add support of MAX98091 codec with VIM3L

hi @numbqq

after trying

codec {
    sound-dai = <&dummy_codec &dummy_codec
    &amlogic_codec &max98090>;
};

Getting below kernels logs and sound card not probed!

7.154601@0] defendkey ff630218.defendkey: Reserved memory is not enough!
[    7.168395@0] asoc-aml-card auge_sound: parse dai_link-0 fail
[    7.168704@0] asoc-aml-card auge_sound: aml_card_probe, parse error -517
[    7.175209@0] aml_card_probe error ret:-517
[    7.197691@3] asoc-aml-card auge_sound: parse dai_link-0 fail
[    7.197798@3] asoc-aml-card auge_sound: aml_card_probe, parse error -517
[    7.204580@3] aml_card_probe error ret:-517
[    7.214435@2] asoc-aml-card auge_sound: parse dai_link-0 fail
[    7.214542@2] asoc-aml-card auge_sound: aml_card_probe, parse error -517
[    7.221305@2] aml_card_probe error ret:-517
[    7.226631@2] asoc-aml-card auge_sound: parse dai_link-0 fail
[    7.231214@2] asoc-aml-card auge_sound: aml_card_probe, parse error -517
[    7.237878@2] aml_card_probe error ret:-517
[    7.336959@0] asoc-aml-card auge_sound: parse dai_link-0 fail
[    7.337063@0] asoc-aml-card auge_sound: aml_card_probe, parse error -517
[    7.338919@2] thermal: read gpupp failed
[    7.339126@2] thermal thermal_zone0: binding zone soc_thermal with cdev thermal-cpufreq-0 failed:-22
[    7.339134@2] thermal: read gpupp failed
[    7.339332@2] thermal: read gpupp failed
[    7.364550@0] aml_card_probe error ret:-517
[    7.365735@0] asoc-aml-card auge_sound: parse dai_link-0 fail
[    7.365738@0] asoc-aml-card auge_sound: aml_card_probe, pa�[    7.697682@2] asoc-aml-card auge_sound: parse dai_link-0 fail
[    7.697786@2] asoc-aml-card auge_sound: aml_card_probe, parse error -517
[    7.705134@2] aml_card_probe error ret:-517

Hi @numbqq @Gouwa

can you suggest how can i set 13Mhz on I2S_MCLK0.

@KD_1993 Can you provide the link of MAX98091 codec module so that we can debug on our side.

its same …/sound/soc/codecs/max98090.c

/sound/soc/codecs$ grep MAX98091 *.c
max98090.c:	if (max98090->devtype == MAX98091) {
max98090.c:	if (max98090->devtype == MAX98091) {
max98090.c:		devtype = MAX98091;
max98090.c:		dev_info(component->dev, "MAX98091 REVID=0x%02x\n", ret);
max98090.c:	{ "max98091", MAX98091 },

@numbqq @hyphop

Regardless of what codec is being attached to the vim3l, what i believe is after configuring I2S_MCLK0 pin in ALT0 mode , the pin should generate 12.28 or 13 MHz as per configuration.
But in current scenario even after configuring that MCLK pin(don’t care condition for attached code), it’s not generating desired clock pulse.

The pin is configured in ALT0 function.

The same clock is being set in kernel.
root@Khadas:~# cat /sys/kernel/debug/clk/clk_summary

On DSO, after measuring on MCLK pin, floting/unstable signals

Given the patch https://github.com/khadas/linux/pull/48/commits/de19145edc9c819843d2cdcb7edac81522c2f1ee , As per my knowledge ES8316 codec should also use MCLK, So after applying this patch is it generating stable clock in MCLK pin?

I do not have the ES8316 codec so i will not be able to perform this experiment at my end.

Can you suggest any alternative or debug pointers ?

Appreciate your help.

@numbqq @hyphop

Can you please update??

Hello @KD_1993

Sorry for the late reply, we have reproduced the issue, we need to figure out what’s going wrong and will update you here.

Thanks.

Hello @KD_1993

I have sent patches to fix the I2S MCLK issue of VIM3L, please update your kernel and rebuild to check, it works on my side now.

Releated patches:

1 Like

hi @numbqq

Its work fine.

Thank you!!!

hi @numbqq

After rebooting VIM3L while i use aplay i am getting Input/output error error.

root@Khadas:~# aplay test.wav 
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
aplay: pcm_write:2053: write error: Input/output error

Second time when i aplay i am not getting any error and its playing without error.
their is no any error in kernel log.

root@Khadas:~# aplay test.wav 
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo


can you please provide suggestion?

thanking you in anticipation.

@Frank Please check with VIM3L + EXT board to test ES8316 codec.

dear @numbqq unfortunately i do not have that codec.

Yes, I know that, but we only have ES8316 to test.

@numbqq

So can you please provide suggestion where to debug.

are you getting below error?
aplay: pcm_write:2053: write error: Input/output error

We need to check, will feedback here in the next few days.

Thanks.

1 Like

Hi @numbqq ,

Update from my end while debugging further in this issue,

Observation I found is when first time I play hw_ptr and buf_pos are not updating, afterwards every time while in working condition hw_prt and buf_pos are updating and hence we are hearing audio.

Not working ALSA procfs : hw_ptr value not changed

root@Khadas:~# cat /proc/asound/card0/pcm0p/sub0/status 
state: RUNNING
owner_pid   : 3496
trigger_time: 152.595785417
tstamp      : 0.000000000
delay       : 24000
avail       : 0
avail_max   : 18000
-----
hw_ptr      : 0
appl_ptr    : 24000
root@Khadas:~# 
root@Khadas:~# 

Working ALSA procfs : hw_ptr value changed

root@Khadas:~# cat /proc/asound/card0/pcm0p/sub0/status 
state: RUNNING
owner_pid   : 3506
trigger_time: 170.011932980
tstamp      : 0.000000000
delay       : 20992
avail       : 3008
avail_max   : 18000
-----
hw_ptr      : 147136
appl_ptr    : 168128
root@Khadas:~# 

Not working PCM buffer state: buffer position not changed

root@Khadas:~# cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 22/22   #P:4
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
           aplay-3446  [000] ....   133.288815: hwptr: pcmC0D0p/sub0: POS: pos=0, old=0, base=0, period=6000, buf=24000
 irq/26-ff660000-3447  [001] ....   133.400128: hwptr: pcmC0D0p/sub0: IRQ: pos=0, old=0, base=0, period=6000, buf=24000
 irq/26-ff660000-3447  [001] ....   133.518584: hwptr: pcmC0D0p/sub0: IRQ: pos=0, old=0, base=0, period=6000, buf=24000
 irq/26-ff660000-3447  [001] ....   133.637332: hwptr: pcmC0D0p/sub0: IRQ: pos=0, old=0, base=0, period=6000, buf=24000
 irq/26-ff660000-3447  [001] ....   133.754263: hwptr: pcmC0D0p/sub0: IRQ: pos=0, old=0, base=0, period=6000, buf=24000
 irq/26-ff660000-3447  [001] ....   133.872737: hwptr: pcmC0D0p/sub0: IRQ: pos=0, old=0, base=0, period=6000, buf=24000
 irq/26-ff660000-3447  [001] ....   133.991484: hwptr: pcmC0D0p/sub0: IRQ: pos=0, old=0, base=0, period=6000, buf=24000
 irq/26-ff660000-3447  [001] ....   134.109668: hwptr: pcmC0D0p/sub0: IRQ: pos=0, old=0, base=0, period=6000, buf=24000
 irq/26-ff660000-3447  [001] ....   134.227154: hwptr: pcmC0D0p/sub0: IRQ: pos=0, old=0, base=0, period=6000, buf=24000
period=6000, buf=24000
 irq/26-ff660000-3447  [001] ....   135.527792: hwptr: pcmC0D0p/sub0: IRQ: pos=0, old=0, base=0, period=6000, buf=24000
 irq/26-ff660000-3447  [001] ....   135.645010: hwptr: pcmC0D0p/sub0: IRQ: pos=0, old=0, base=0, period=6000, buf=24000
 irq/26-ff660000-3447  [001] ....   135.763193: hwptr: pcmC0D0p/sub0: IRQ: pos=0, old=0, base=0, period=6000, buf=24000

working PCM buffer state: Buffer position changed

root@Khadas:~# cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 47/47   #P:4
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
           aplay-3572  [002] ....   291.848182: hwptr: pcmC0D0p/sub0: POS: pos=128, old=0, base=0, period=6000, buf=24000
 irq/26-ff660000-3573  [002] ....   291.966122: hwptr: pcmC0D0p/sub0: IRQ: pos=6144, old=128, base=0, period=6000, buf=24000
           aplay-3572  [002] ....   291.966205: hwptr: pcmC0D0p/sub0: POS: pos=6144, old=6144, base=0, period=6000, buf=24000
 irq/26-ff660000-3573  [002] ....   292.084911: hwptr: pcmC0D0p/sub0: IRQ: pos=12160, old=6144, base=0, period=6000, buf=24000
           aplay-3572  [002] ....   292.084981: hwptr: pcmC0D0p/sub0: POS: pos=12160, old=12160, base=0, period=6000, buf=24000
 irq/26-ff660000-3573  [002] ....   292.203330: hwptr: pcmC0D0p/sub0: IRQ: pos=18176, old=12160, base=0, period=6000, buf=24000

Currently I am looking at

sound/soc/amlogic/auge/tdm.c

file for further debug.

Please advice if the track is wrong here.

Thanking you in anticipation.

@KD_1993 I test it with es8316 just now. It can be played normally when running aplay for the first time after booting.

@numbqq

Thanks for working in holidays and trying reproduction of the issue.

Now as it works on your setup, it seems something is missing from max98091.

can you please suggest any debug pointers??

Hello,
I’m having troubles making my ADC (PCM1808) work with my VIM3 (without L), and I’m suspecting that the problem comes from the mclk quality. Do you know if this update would have an impact on VIM3 too?
Best regards