How to use TLV320AIC32X4 Audio card in i.MX8QM?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use TLV320AIC32X4 Audio card in i.MX8QM?

2,521 Views
xie_ht2000
Contributor I

Hi:

    we are using TI TLV320AIC32X4 audio card in our i.MX8QM custom board, cpu DAI connected with audio codec by I2S interface,using SOC's sai1 interface, so the dts is as below:

sound-tlv320 {     
        compatible = "simple-audio-card";
        status = "okay";
        simple-audio-card,name = "tlv320-audio";
        simple-audio-card,format = "i2s";
        simple-audio-card,bitclock-inversion;
        simple-audio-card,frame-master = <&cpu_dai>;
        simple-audio-card,bitclock-master = <&cpu_dai>;
        /*simple-audio-card,mclk-fs = <512>;*/

        simple-audio-card,widgets =
        "Microphone", "Mic Jack",
        "Line", "Line In",
        "Line", "Line Out",
        "Speaker", "Speaker",
        "Headphone", "Headphone Jack";      

        simple-audio-card,routing =     
        "IN1_L", "Line In",
        "IN1_R", "Line In",        
        "Line Out", "LOL",
        "Line Out", "LOR",
        "Headphone Jack", "HPL",
        "Headphone Jack", "HPR";

        simple-audio-card,hp-det-gpio = <&lsio_gpio0 31 GPIO_ACTIVE_HIGH>;
        simple-audio-card,mic-det-gpio = <&lsio_gpio0 31 GPIO_ACTIVE_HIGH>;

        cpu_dai: simple-audio-card,cpu
        {
            sound-dai = <&sai1>;
            /*system-clock-direction-out;*/
            dai-tdm-slot-num = <2>;
            dai-tdm-slot-width = <16>;
        };

        codec_dai: simple-audio-card,codec {
                sound-dai = <&codec_tlv320>;                
                clocks = <&mclkout0_lpcg 0>;
        };
    };

then,configed the kernel to support SIMPLE_CARD,after booting the system,using aplay -L command,can found the tlv320audio sound card.
but when I play a sample audio wav file,there is no sound in my headphone, and I also measured several CODEC's pin signal using an oscilloscope,
MCLK:12.3MHZ
BCLK:1.024MHZ
FSCLK:32KHZ,sample rate
DIN:datas are on this signal

here is a play log:

root@imx8qmmek:~# aplay -D sysdefault:CARD=tlv320audio -f dat 1.wav
[ 2805.407069] fsl_sai_startup 988
[ 2805.410233] fsl_sai_startup 1004
[ 2805.415108] asoc_simple_startup 202
[ 2805.418620] asoc_simple_startup 208
[ 2805.423216] asoc_simple_startup 214
Warning: format is changed to U8[ 2805.428976] soc_pcm_hw_params 878

Playing WAVE '1.wav' : Unsigned 8 bit, Rate 32000 Hz, Stereo
[ 2805.433229] asoc_simple_hw_params 270,num 0
[ 2805.442957] codec_dai name tlv320aic32x4-hifi,cpu_dai name 59050000.sai
[ 2805.449598] mclk_fs 0
[ 2805.451871] asoc_simple_hw_params 277,is_codec_slave,fmt 0x4001
[ 2805.457825] fsl_sai_set_dai_fmt 465,fmt is 0x4001
[ 2805.462559] fsl_sai_set_dai_fmt 485
[ 2805.466077] aic32x4_set_dai_fmt 588,fmt 0x4001
[ 2805.473157] aic32x4_set_dai_fmt 636
[ 2805.476683] fsl_sai_set_dai_sysclk 297,freq is 0, dir 1
[ 2805.481948] fsl_sai_set_dai_sysclk 304
[ 2805.485728] fsl_sai_set_dai_sysclk 325
[ 2805.489483] fsl_sai_set_dai_sysclk_tr 215,clk_id 0,freq 0, dir 0
[ 2805.495525] fsl_sai_set_dai_sysclk 334
[ 2805.499291] fsl_sai_set_dai_sysclk_tr 215,clk_id 0,freq 0, dir 1
[ 2805.505327] fsl_sai_set_dai_sysclk 341
[ 2805.509100] snd_soc_dai_hw_params 276
[ 2805.512786] flags 0
[ 2805.514901] rmask 0
[ 2805.517000] cmask 1048327
[ 2805.519642] info 2949395
[ 2805.522196] msbits 16
[ 2805.524472] rate_num 32000
[ 2805.527202] rate_den 1
[ 2805.529578] fifo_size 0
[ 2805.532024] aic32x4_hw_params 796,bclk 1024000
[ 2805.540281] aic32x4_hw_params 832,lrclk 32000
[ 2805.546301] aic32x4_hw_params 847
[ 2805.549629] soc_pcm_hw_params 941
[ 2805.552940] snd_soc_dai_hw_params 276
[ 2805.556629] fsl_sai_hw_params 654
[ 2805.559966] fsl_sai_hw_params 689,rate 32000,bitclk_ratio 0,slots 2,slot_width 16,bclk 1024000
[ 2805.568608] fsl_sai_hw_params 705
[ 2805.571944] fsl_sai_set_bclk 554,tx 1,freq 1024000
[ 2805.576765] fsl_sai_set_bclk 558,id 0, clk_rate 0
[ 2805.581496] fsl_sai_set_bclk 558,id 1, clk_rate 49152000
[ 2805.586840] fsl_sai_set_bclk 566,ratio 48,ret 0
[ 2805.591406] fsl-sai 59050000.sai: ratio 48 for freq 1024000Hz based on clock 49152000Hz
[ 2805.599444] fsl-sai 59050000.sai: best fit: clock id=1, ratio=48, deviation=0
[ 2805.606597] fsl_sai_hw_params 710,bclk is 1024000
[ 2805.611379] fsl_sai_hw_params 819
[ 2805.614716] soc_pcm_hw_params 952
[ 2805.618057] soc_pcm_hw_params 968
[ 2805.623088] aic32x4_mute 862,mute 0
[ 2806.253212] aic32x4_mute 862,mute 1
[ 2806.256856] asoc_simple_shutdown 229
[ 2806.260484] asoc_simple_shutdown 235

Linux kernel version:Linux imx8qmmek 5.4.47

is there anythine wrong in my dts? or is the simple sound card driver can support TLV320AIC sound card? Are their patches available for TLV320AIC for kernel 5.4.47?
Any advice would be greatly appreciated!

Thanks,

Haitao

0 Kudos
3 Replies

972 Views
bit
Contributor I

Is the problem solved? I am looking for help.

0 Kudos

2,496 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi,

 See examples of single audio card, from Documentation / devicetree / bindings / sound / simple-card.txt

sound {
compatible = "simple-audio-card";
simple-audio-card,name = "VF610-Tower-Sound-Card";
simple-audio-card,format = "left_j";
simple-audio-card,widgets =
"Microphone", "Microphone Jack",
"Headphone", "Headphone Jack",
"Speaker", "External Speaker";
simple-audio-card,routing =
"MIC_IN", "Microphone Jack",
"Headphone Jack", "HP_OUT",
"External Speaker", "LINE_OUT";

 

you lost MIC routing in 'simple-audio-card,routing = ', so please check it and use real widget of your codec driver!

 

Have a nice day!

B.R,

Weidong

0 Kudos

2,512 Views
xie_ht2000
Contributor I

now we can play sound,but arecoard is not working,it seems that capture widget is not found,so the codec's bias level is not change,any one know how to fix the record issue?

 

thank!

0 Kudos