This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TLV320AIC3104: Clock related issue

Part Number: TLV320AIC3104

Tool/software:

Hello Team, 

We are integrating TLV320aic3104 audio codec to our processor. We are facing this error 

01-01 12:14:56.427 4157 4157 E aic3x_hw_params(): unable to setup PLL
01-01 12:14:56.427 4157 4157 E tlv320aic3x 29-0018: ASoC: error at snd_soc_dai_hw_params on tlv320aic3x-hifi: -22

and I see that sysclk value is 0. and also I see that .set_sysclk     = aic3x_set_dai_sysclk,  This function is not called. At which stage this function will be called? 

And we want the value of the register 102 as 0xA2. And i see this register is modified in the above function only. Could you pls confirm this?

Also If i want to use bclk and not mclk is there any specific changes we need to do in DTS? 

Thanks & Regards,

Kokila K

  • Hi,

    I will get back to you on Tuesday about this, sorry about the delay. 

  • Hi Kokila,

    Hi again. I believe it will be called at runtime, and if not, it would be when you set the clock in your DTS file. Can you provide your DTS and let's see where we need to define the MCLK/BCLK rate. I would think it is in the <clocks> section.

    https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/devicetree/bindings/sound/ti,tlv320aic3x.yaml

    Best,
    Mir

  • Hi Mir,

    This is my DTS entry for the TLV. and for the clocks param what is the expected value we need to give?

    tlv320aic320: tlv320aic320@18 {
                    compatible = "ti,tlv320aic3104";
                    reg = <0x18>;
                    #sound-dai-cells = <0>;
    
                    ai3x-micbias-vg = <3>;
                    //reset-gpios = <&io_expander 11 GPIO_ACTIVE_LOW>;
                    AVDD-supply = <&codec_3v3_reg>;
                    IOVDD-supply = <&codec_3v3_reg>;
                    DRVDD-supply = <&codec_1v8_reg>;
                    DVDD-supply = <&codec_1v8_reg>;
            };

  • Hi,

    I found this old e2e talking about the same problem:  https://e2e.ti.com/support/audio-group/audio/f/audio-forum/702805/rtos-tlv320aic3105-tlv320aic3105-codec-showing-system-clock-sysclk-as-0 

    They suggest adding in the line aic3x->sysclk = <value> in the driver itself... but according to other forum posts, it may be expecting your SoC to change the MCLK rate. You can check out this forum for some suggestions for the DTS or changing the driver to a hard coded MCLK:

    https://community.nxp.com/t5/i-MX-Processors/i-MX8QXP-SAI-MCLK-frequency/m-p/1097084#M160628

    https://www.programmersought.com/article/40346906740/

    Sorry I am not more help, I am not a Linux DTS expert.

    Best,
    Mir

  • Hello Mir,

    Now my PLL error is solved, and Iam able to capture, but after capturing when i try to check the wav file, there is no valid data.

    exynosauto9_easdk_android_vm:/ # i2cdump -y -f 29 0x18
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
    00: 00 00 00 91 10 0c dc 0a 00 00 00 01 00 00 00 20    ...?????...?...
    10: 20 ff ff 04 78 78 04 78 78 06 00 fe 00 00 fe 00     ???xx?xx?.?..?.
    20: 00 00 00 00 cc 00 00 00 40 00 00 af af 00 2f af    ....?...@..??./?
    30: 00 00 00 0c 00 2f af 00 00 00 0c 00 00 00 00 2f    ...?./?...?..../
    40: af 0c 00 00 00 00 2f af 0c 00 00 00 00 00 00 00    ??..../??.......
    50: 00 2f af 00 00 00 08 00 00 00 00 2f af 08 00 00    ./?...?..../??..
    60: 00 00 00 00 00 00 a2 00 00 00 00 00 00 00 00 00    ......?.........
    70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    80: 00 00 00 91 10 0c dc 0a 00 00 00 01 00 00 00 20    ...?????...?...
    90: 20 ff ff 04 78 78 04 78 78 06 00 fe 00 00 fe 00     ???xx?xx?.?..?.
    a0: 00 00 00 00 cc 00 00 00 40 00 00 af af 00 2f af    ....?...@..??./?
    b0: 00 00 00 0c 00 2f af 00 00 00 0c 00 00 00 00 2f    ...?./?...?..../
    c0: af 0c 00 00 00 00 2f af 0c 00 00 00 00 00 00 00    ??..../??.......
    d0: 00 2f af 00 00 00 08 00 00 00 00 2f af 08 00 00    ./?...?..../??..
    e0: 00 00 00 00 00 00 a2 00 00 00 00 00 00 00 00 00    ......?.........
    f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    exynosauto9_easdk_android_vm:/ #
    
    

    Also, Let me know for routing of the audio, should we set any value for mixer?

    Please find the logs while try to capture the audio.

    exynosauto9_easdk_android_vm:/ # tinycap /mnt/test.wav -d 16 -c 2 -r 48000 -b 16
    Capturing sample: 2 ch, 48000 hz, 16 bit
    Captured 417792 frames
    exynosauto9_easdk_android_vm:/ #

  • Hi,

    Can you share what you changed to fix your PLL/clocks? Just for future reference. 

    And yes, you need to add dapm_routes to the DTS file. You can find the options by searching "snd_soc_dapm_route" in the driver aic3x.c file: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/sound/soc/codecs/tlv320aic3x.c And the codec pin names are in the yaml help file for the driver: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/devicetree/bindings/sound/ti,tlv320aic3x.yaml

    There are common values in the "intercon" section but the AIC3104 has its own few options as well. It depends which pins you are trying to use. 

    Best,
    Mir

  • Hi Mir,

    For PLL issue, I tried to set the sysclk from the master, This automatically calls the set_sysclk function, which resolves PLL error.

     ret = snd_soc_dai_set_sysclk(codec_dai, 2, 24080000, SND_SOC_CLOCK_OUT);
            if (ret) {
                dev_err(card->dev, "failed to set tlv320aic31xx sysclk!\n");
                return ret;
            }


    Now, Pls help me with the Mixer settings, what are the value we need to set for the Mic capture.?

  • I tried to capture the audio, The files is captured there is no valid audio data, I think iam missing some of the mixer routing. Please help me with the Mixer configuration

  • Hi Kokila,

    You will want to include some routing in your dts file, like this:

             simple-audio-card,widgets =
                    "Microphone", "Microphone Jack",
                    "Microphone", "Internal Microphone",
                    "Headphone", "Headphone Jack",
                    "Line", "Line Out",
                    "Speaker", "Internal Speaker";
                simple-audio-card,routing =
                    "Line Out", "HPLCOM",
                    "Line Out", "HPRCOM",
                    "Headphone Jack", "HPLOUT",
                    "Headphone Jack", "HPROUT",
                    "Microphone Jack", "MIC2L",
                    "Internal Microphone", "MIC1L",
                    "Internal Speaker", "LLOUT",
                    "Internal Speaker", "RLOUT";

    -Mir

  • Hello Mir, 

    Now we are able to Playback the audio, When we try to capture the audio is not getting captured. getting the junk data on the file.

    These are the default value of the mixer's controls, Can you please comment on it? What are teh value we need to set to get the audio recorded properly?

    522	ENUM	1	Left Line1L Mux                          single-ended
    523	ENUM	1	Left Line1R Mux                          single-ended
    524	ENUM	1	Right Line1L Mux                         single-ended
    525	ENUM	1	Right Line1R Mux                         single-ended
    526	BOOL	1	Left PGA Mixer Line1L Switch             On
    527	BOOL	1	Left PGA Mixer Line1R Switch             Off
    528	BOOL	1	Left PGA Mixer Mic2L Switch              Off
    529	BOOL	1	Left PGA Mixer Mic2R Switch              Off
    530	BOOL	1	Right PGA Mixer Line1R Switch            On
    531	BOOL	1	Right PGA Mixer Line1L Switch            Off
    532	BOOL	1	Right PGA Mixer Mic2L Switch             Off
    533	BOOL	1	Right PGA Mixer Mic2R Switch             Off

    Also, This is the Path Iam trying to Capture the audio via MIC.

    What exactly the value we need to set for MICBIAS? Also Please find the I2cdump of the TLV Codec

    exynosauto9_easdk_android_vm:/ # i2cdump -y -f 29 0x18
    
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
    
    00: 00 00 00 91 10 00 00 0a 00 00 00 41 00 00 00 20    ...??..?...A... 
    
    10: 20 00 00 04 78 78 04 78 78 06 00 fe 00 00 fe 00     ..?xx?xx?.?..?.
    
    20: 00 00 00 00 44 00 00 00 40 00 00 af af 00 2f af    ....D...@..??./?
    
    30: 00 00 00 0c 00 2f af 00 00 00 0c 00 00 00 00 2f    ...?./?...?..../
    
    40: af 0c 00 00 00 00 2f af 0c 00 00 00 00 00 00 00    ??..../??.......
    
    50: 00 2f af 00 00 00 08 00 00 00 00 2f af 08 00 00    ./?...?..../??..
    
    60: 00 00 00 00 00 00 a2 00 00 00 00 00 00 00 00 00    ......?.........
    
    70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    
    80: 00 00 00 91 10 00 00 0a 00 00 00 01 00 00 00 20    ...??..?...?... 
    
    90: 20 00 00 04 78 78 04 78 78 06 00 fe 00 00 fe 00     ..?xx?xx?.?..?.
    
    a0: 00 00 00 00 44 00 00 00 40 00 00 af af 00 2f af    ....D...@..??./?
    
    b0: 00 00 00 0c 00 2f af 00 00 00 0c 00 00 00 00 2f    ...?./?...?..../
    
    c0: af 0c 00 00 00 00 2f af 0c 00 00 00 00 00 00 00    ??..../??.......
    
    d0: 00 2f af 00 00 00 08 00 00 00 00 2f af 08 00 00    ./?...?..../??..
    
    e0: 00 00 00 00 00 00 a2 00 00 00 00 00 00 00 00 00    ......?.........
    
    f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    
     

  • Hi,

    Give me a day to read through this, sorry about the delay. The junk data looks like it is offset differently for each channel, this leads me to believe that either your mic bias is incorrect or it is set to AC or DC coupled when you do not intend, something like this. 

    -Mir

  • Can you share your schematic? I see that in register 25, 0x19, micbias is powered down during your recording. Also, there is an overflow flag in register 11 (0x0b) that says the right ADC has overflowed, and we see that your right channel on the Audacity screenshot is close to +1. So, I think that your bias on the microphone signals may be incorrect. We expect analog input signals to be between 0 and AVDD, and micbias may be somewhere between 1.8 and 2.5V. So, if the signals are not externally biased, then there will be an issue since your micbias is not enabled (and so the signal is not properly AC-coupled). Can you also measure the voltage coming out of the microphone to check that range and verify that you have analog signal coming out as you expect?

    Best,
    Mir

  • Hi Mir, 

    As you pointed out, we found an issue in Mic power supply and its resolved. after that I have tried capturing the Audio, still the audio is not recorded. The new waveform looks like this now.

    Also, this is how i2cdump looks now, that ADC overflow is not happening.

    exynosauto9_easdk_android_vm:/ # i2cdump -y -f 29 0x18
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
    00: 00 00 00 91 10 0c dc 0a 00 00 00 01 00 00 00 20    ...?????...?...
    10: 20 ff ff 04 78 78 04 78 78 06 00 fe 00 00 fe 00     ???xx?xx?.?..?.
    20: 00 00 00 00 cc 00 00 00 40 00 00 af af 00 2f af    ....?...@..??./?
    30: 00 00 00 0c 00 2f af 00 00 00 0c 00 00 00 00 2f    ...?./?...?..../
    40: af 0c 00 00 00 00 2f af 0c 00 00 00 00 00 00 00    ??..../??.......
    50: 00 2f af 00 00 00 08 00 00 00 00 2f af 08 00 00    ./?...?..../??..
    60: 00 00 00 00 00 00 a2 00 00 00 00 00 00 00 00 00    ......?.........
    70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    80: 00 00 00 91 10 0c dc 0a 00 00 00 01 00 00 00 20    ...?????...?...
    90: 20 ff ff 04 78 78 04 78 78 06 00 fe 00 00 fe 00     ???xx?xx?.?..?.
    a0: 00 00 00 00 cc 00 00 00 40 00 00 af af 00 2f af    ....?...@..??./?
    b0: 00 00 00 0c 00 2f af 00 00 00 0c 00 00 00 00 2f    ...?./?...?..../
    c0: af 0c 00 00 00 00 2f af 0c 00 00 00 00 00 00 00    ??..../??.......
    d0: 00 2f af 00 00 00 08 00 00 00 00 2f af 08 00 00    ./?...?..../??..
    e0: 00 00 00 00 00 00 a2 00 00 00 00 00 00 00 00 00    ......?.........
    f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

    Can you help us here?  Did I miss any register setting with respect to Capture via Mic?

    Thanks,

    Kokila

  • Hi,

    Can you share your schematic? This will help me understand what you intend to do. I see that there is not an overflow anymore, but micbias is still powered down. I also noticed that your J.D is different than it was in the previous screenshot, what clocks are you providing and what clocks do you expect out of the chip? Or are you providing all clocks? Here are my notes on the input registers:

    03 91 #pll enabled, p=q=1
    04 10 #j=4
    05 0c #d msb = 1100 
    06 dc #d lsb = 1101 11 -> 823 ??
    07 0a #48k
    0b 01 #no overflows
    0f 20 #ladc pga is not muted, gain=32db
    10 20 #radc pga not muted, gain=32db
    11 ff #mic2l and mic2r not connected to ladc 
    12 ff #mic2l and mic2r not connected to radc
    13 04 #mic1lp single ended, connected to ladc pga, 0db, ladc powered up
    15 78 #line1r not connected to ladc
    16 04 #mic1rp single ended, connected to radc pga, 0db, radc powered up
    18 78 #mic1lp not connected to radc
    19 06 #micbias powered DOWN -> ??

    Best,
    Mir

  • Hi Mir, 

    Please find the Schematic.

    Audio codec schematic.pdf

    Thanks 

    Kokila K

  • Hi,

    I think there is a chance that the audio you are getting is expected, can you try to increase the PGA gain? I am not sure about the swing of your microphone, but I notice in the schematic that you have ~10dB reduction in the mic signal from the op amp filter circuit. So, there is a chance that the voltage making it to the ADC is just low - if you can change the gain of that op amp you should see some improvement in the signal's swing. To remove the DC offset in your audio signal, you can select a preset ADC high pass filter in page 0 register 12 (0x0c).

    Best,
    Mir