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.

TLV320AIC3110: Click sound on tlv320aic3110

Part Number: TLV320AIC3110


Hello, I'm trying to integrate a tlv320aic3110 into an stm32mp135 board. So far, I've been able to make it recognize the chip as a sound card:

~# aplay -l

**** List of PLAYBACK Hardware Devices ****

card 0: MySound [MySound], device 0: 44004000.audio-controller-tlv320aic31xx-hifi tlv320aic31xx-hifi [44004000.audio-controller-tlv320aic31xx-hifi tlv320aic31xx-hifi]

  Subdevices: 1/1

  Subdevice #0: subdevice #0

I have written this for the device tree:

sound0: sound@0 {
    compatible = "simple-audio-card";
    simple-audio-card,name = "MySound";
    simple-audio-card,widgets =
        "Microphone", "Microphone Jack",
        "Headphone", "Headphone Jack",
        "Speaker", "Speaker";
    simple-audio-card,routing =
        "MIC1LP", "Microphone Jack",
        "MIC1RP", "Microphone Jack",
        "MIC1LP", "MICBIAS",
        "MIC1RP", "MICBIAS",
        "Headphone Jack", "HPL",
        "Headphone Jack", "HPR",
        "Speaker", "SPL",
        "Speaker", "SPR";
    simple-audio-card,format = "i2s";
    simple-audio-card,bitclock-master = <&sound0_master>;
    simple-audio-card,frame-master = <&sound0_master>;
    simple-audio-card,bitclock-inversion;

    simple-audio-card,cpu {
        sound-dai = <&i2s1>;
        system-clock-frequency = <12000000>;
    };

    sound0_master: simple-audio-card,codec {
        sound-dai = <&codec>;
        system-clock-frequency = <12000000>;
    };
};

...

&pinctrl {
	codec_pins_a: codec_pins_a {
		pins1 {
			pinmux = <STM32_PINMUX('F', 8, GPIO)>;	/* AUDIO_PWR_EN1 */
			bias-pull-up;
		};

		pins2 {
			pinmux = <STM32_PINMUX('F', 6, GPIO)>;	/* RESET */
			bias-disable;
		};

		pins3 {
			pinmux = <STM32_PINMUX('A', 3, AF5)>,	/* I2S1_SDO */
					 <STM32_PINMUX('A', 6, AF5)>,	/* I2S1_SDI */
					 <STM32_PINMUX('B', 1, AF5)>,	/* I2S1_BITCLK / I2S1_CK */
					 <STM32_PINMUX('B', 0, AF5)>,	/* I2S1_WORDCLK / I2S1_MCK */
					 <STM32_PINMUX('D',  9, AF13)>,	/* CLK1_A / LCD_CLK */
					 <STM32_PINMUX('B', 10, GPIO)>;	/* K81_AUD_MUTE */
		};
    };
};

&i2s1 {
	// pinctrl-names = "default";
	// pinctrl-0 = <&i2s1_pins>;
	status = "okay";
	#clock-cells = <0>;
	clock-names = "pclk", "i2sclk", "x8k", "x11k";
	clocks = <&rcc SPI5>,
			 <&rcc SPI1_K>,
			 <&rcc SAI1_K>,
			 <&rcc SAI2_K>;
};

&i2c1 {
    codec: codec@18 {
        compatible = "ti,tlv320aic3110";
        reg = <0x18>;
        // pinctrl-names = "default";
        pinctrl-0 = <&codec_pins_a>;
        #sound-dai-cells = <0>;
        status = "okay";

        system-clock-frequency = <100000>;

        ai31xx-micbias-vg = <MICBIAS_2_0V>;

        reset-gpios = <&gpiof 6 GPIO_ACTIVE_LOW>;

        /* Regulators */
        HPVDD-supply = <&scmi_v3v3_sw>;
        SPRVDD-supply = <&scmi_vdd_usb>;
        SPLVDD-supply = <&scmi_vdd_usb>;
        AVDD-supply = <&scmi_v3v3_sw>;
        IOVDD-supply = <&scmi_v3v3_sw>;
        DVDD-supply = <&scmi_v1v8_periph>;
    };
};

After modifying the parameters shown in amixer/alsamixer, I've finally been able to hear something, but it's just a short "click" sound after I try playing a wav file or the speaker-test command. Both commands stay "blocked", by the way. If I run them on my computer, the play the sound and then close themselves, in the board they stay in execution until I stop them manually.

Here is also my amixer output:

Simple mixer control 'Speaker Analog',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 127
  Mono:
  Front Left: Playback 127 [100%] [0.00dB]
  Front Right: Playback 127 [100%] [0.00dB]
Simple mixer control 'Speaker Driver',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 3
  Mono:
  Front Left: Playback 3 [100%] [24.00dB] [on]
  Front Right: Playback 3 [100%] [24.00dB] [on]
Simple mixer control 'Speaker Left',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Speaker Right',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Mic PGA',0
  Capabilities: cvolume cvolume-joined
  Capture channels: Mono
  Limits: Capture 0 - 119
  Mono: Capture 119 [100%] [59.50dB]
Simple mixer control 'ADC',0
  Capabilities: cvolume cvolume-joined cswitch cswitch-joined
  Capture channels: Mono
  Limits: Capture 0 - 64
  Mono: Capture 64 [100%] [12.00dB] [on]
Simple mixer control 'ADC Fine',0
  Capabilities: cvolume cvolume-joined
  Capture channels: Mono
  Limits: Capture 0 - 4
  Mono: Capture 4 [100%] [0.40dB]
Simple mixer control 'DAC',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 175
  Mono:
  Front Left: Playback 175 [100%] [24.00dB]
  Front Right: Playback 175 [100%] [24.00dB]
Simple mixer control 'DAC Left Input',0
  Capabilities: enum
  Items: 'Off' 'Left Data' 'Right Data' 'Mono'
  Item0: 'Mono'
Simple mixer control 'DAC Right Input',0
  Capabilities: enum
  Items: 'Off' 'Right Data' 'Left Data' 'Mono'
  Item0: 'Mono'
Simple mixer control 'HP Analog',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 127
  Mono:
  Front Left: Playback 127 [100%] [0.00dB]
  Front Right: Playback 127 [100%] [0.00dB]
Simple mixer control 'HP Driver',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 9
  Mono:
  Front Left: Playback 9 [100%] [9.00dB] [on]
  Front Right: Playback 9 [100%] [9.00dB] [on]
Simple mixer control 'HP Left',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'HP Output Driver Power-On time',0
  Capabilities: enum
  Items: '0us' '15.3us' '153us' '1.53ms' '15.3ms' '76.2ms' '153ms' '304ms' '610ms' '1.22s' '3.04s' '6.1s'
  Item0: '6.1s'
Simple mixer control 'HP Output Driver Ramp-up step',0
  Capabilities: enum
  Items: '0ms' '0.98ms' '1.95ms' '3.9ms'
  Item0: '3.9ms'
Simple mixer control 'HP Right',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'MIC1LM M-Terminal',0
  Capabilities: enum
  Items: 'Off' 'FFR 10 Ohm' 'FFR 20 Ohm' 'FFR 40 Ohm'
  Item0: 'FFR 10 Ohm'
Simple mixer control 'MIC1LM P-Terminal',0
  Capabilities: enum
  Items: 'Off' 'FFR 10 Ohm' 'FFR 20 Ohm' 'FFR 40 Ohm'
  Item0: 'FFR 10 Ohm'
Simple mixer control 'MIC1LP P-Terminal',0
  Capabilities: enum
  Items: 'Off' 'FFR 10 Ohm' 'FFR 20 Ohm' 'FFR 40 Ohm'
  Item0: 'FFR 10 Ohm'
Simple mixer control 'MIC1RP P-Terminal',0
  Capabilities: enum
  Items: 'Off' 'FFR 10 Ohm' 'FFR 20 Ohm' 'FFR 40 Ohm'
  Item0: 'FFR 10 Ohm'
Simple mixer control 'Output Left From Left DAC',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Output Left From MIC1LP',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Output Left From MIC1RP',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Output Right From MIC1RP',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Output Right From Right DAC',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Volume Soft Stepping',0
  Capabilities: enum
  Items: 'fast' 'slow' 'disabled'
  Item0: 'fast'

And my i2cdump output:

~# i2cdump -f -y 0 0x18
No size specified (using byte-data access)
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 00 00 01 56 03 91 07 14 90 00 00 90 82 00 80 80    ..?V?????..??.??
10: 08 00 90 82 80 80 04 00 00 00 01 0c 00 08 88 00    ?.?????...??.??.
20: 00 00 00 00 80 33 11 00 00 00 00 00 00 00 00 00    ....?3?.........
30: 00 00 00 02 32 12 03 02 02 11 10 00 01 04 00 3c    ...?2??????.??.<
40: 0c 30 30 00 6f 38 00 00 00 00 00 ee 10 d8 7e e3    ?00.o8.....???~?
50: 00 00 00 28 00 00 00 00 7f 00 00 00 00 00 00 00    ...(....?.......
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
70: 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00    .....T..........
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
e0: 00 00 00 00 00 00 00 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    ................

Could you check if I maybe have done something incorrectly, please? Let me know if you need more information

Thank you

  • Hi,

    Our audio experts are out of office for the holiday and will return the week of 11/28. Please be patient as responses are delayed.

    Thanks,

  • From the i2cdump, both DAC and ADC are powered down.

    See comment in the attached i2cdump. 

    ~# i2cdump -f -y 0 0x18
    No size specified (using byte-data access)
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    comment
    00: 00 00 01 56 03 91 07 14 90 00 00 90 82 00 80 80    PLL_CLKIN=MCLK, CODEC_CLKIN=PLL_CLK, PLL enabled withP=R=1, J=7, D=5264, NDAC powered with value=16, MDAC powered with value=2, DOSR=128
    10: 08 00 90 82 80 80 04 00 00 00 01 0c 00 08 88 00    NADC powered with value=16, MADC powered with value=2, AOSR=128, master mode I2S, 16 bit depth, BCLK inverted, 
    20: 00 00 00 00 80 33 11 00 00 00 00 00 00 00 00 00    
    30: 00 00 00 02 32 12 03 02 02 11 10 00 01 04 00 3c    Left and right DAC powered down
    40: 0c 30 30 00 6f 38 00 00 00 00 00 ee 10 d8 7e e3    Left and right DAC volume muted, 
    50: 00 00 00 28 00 00 00 00 7f 00 00 00 00 00 00 00    ADC powered down
    60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    70: 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00    .....T..........
    80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    e0: 00 00 00 00 00 00 00 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    ................

    Is the MCLK 12MHz?

    You can download the PLL calculator from this site.

    https://www.ti.com/product/TLV320AIC3110

    I have entered your current settings in the cell, if 44.1KHz is the sampling rate change NDAC and NADC to 8 as shown and change register 0x1D to 0x00 instead of 0x08.

    This is only configuring the digital side, the codec will provide the 44.1KHz WCLK and 1.4112MHz for the BCLK

    Please check your register settings again to ensure you configure the right path.

  • Hello,

    Do you know how can I modify the register 0x1D from 0x08 to 0x00. Is that done in the device tree? I have tried using the command i2cset -f -y 0 0x18 0x1d 0x00, but after a restart of the board, the value goes back to the previous state.

    Also, using amixer, I have enabled DAC and ADC, but apparently that's not enough. Could you also explain a bit how can I enable these two options?

    Thank you.

  • I'm not a Linux expert, so I will refer that to Shenghao to provide guidance.

  • Have you tried "aplay xxx.wav" instead of speaker-test command? Can you share your wav file with me?

  • Hi

    I think audio route can enable the DAC or ADC automatically during playback or recording.

    Can you tell me what comands you used during playback or recording? During playback, kindly use a long audio clip, and capture the I2S clk with scope. Also share the I2S clk waveform with me?

  • Hello,

    Sorry for the wait, my colleagues and I were trying some things to get the waveform correctly.

    Our MCLK is 10MHz, not 12 MHz. I forgot to respond to that.

    We are trying to play this wav file:

    /cfs-file/__key/communityserver-discussions-components-files/6/CantinaBand3.wav

    Here are the waveforms:

    MCLK (yellow) DIN (Pink)

    WCLK (yellow) BCLK (pink)

    WCLK (yellow) DIN (pink)

    ~# aplay /mnt/usb/CantinaBand3.wav &
    ~# Playing WAVE '/mnt/usb/CantinaBand3.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono
    
    ~#
    ~# i2cdump -f -y 0 0x18
    No size specified (using byte-data access)
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
    00: 00 00 01 56 03 91 08 12 40 00 00 8f 82 00 80 80    ..?V????@..??.??
    10: 08 00 85 86 80 80 04 00 00 00 01 0c 00 0c 88 00    ?.?????...??.??.
    20: 00 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00    ....?...........
    30: 00 00 00 02 32 12 03 02 02 11 10 00 01 04 00 14    ...?2??????.??.?
    40: 00 d8 d8 00 6f 38 00 00 00 00 00 ee 10 d8 7e e3    .??.o8.....???~?
    50: 00 00 80 00 00 00 00 00 7f 00 00 00 00 00 00 00    ..?.....?.......
    60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    70: 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00    .....?..........
    80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    e0: 00 00 00 00 00 00 00 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    ................

    Let me know if you need anything else.

  • Your i2cdump shows both DAC (register 63 (0x3F)) and ADC are powered down.

    Have you tried enabling the DAC?

  • Kindly get the I2c and I2s sequence with scope. I wonder whether i2s clk is earlier than code work? In theory, i2s must be earlier than code on.

  • Hello,

    I enabled DAC and ADC using amixer. Wouldn't that be enough? If not, how can I enable them? Is that done in the Device Tree or somewhere else?

    Simple mixer control 'ADC',0
      Capabilities: cvolume cvolume-joined cswitch cswitch-joined
      Capture channels: Mono
      Limits: Capture 0 - 64
      Mono: Capture 24 [38%] [-8.00dB] [on]
    Simple mixer control 'ADC Fine',0
      Capabilities: cvolume cvolume-joined
      Capture channels: Mono
      Limits: Capture 0 - 4
      Mono: Capture 4 [100%] [0.40dB]
    Simple mixer control 'DAC',0
      Capabilities: pvolume
      Playback channels: Front Left - Front Right
      Limits: Playback 0 - 175
      Mono:
      Front Left: Playback 175 [100%] [24.00dB]
      Front Right: Playback 175 [100%] [24.00dB]
    Simple mixer control 'DAC Left Input',0
      Capabilities: enum
      Items: 'Off' 'Left Data' 'Right Data' 'Mono'
      Item0: 'Left Data'
    Simple mixer control 'DAC Right Input',0
      Capabilities: enum
      Items: 'Off' 'Right Data' 'Left Data' 'Mono'
      Item0: 'Right Data'

  • Hi ,

    What do you mean by that? Could you clarify what you mean about "code work"?

    Thank you.

  • Hi,

    According to the wav file you shared, its properties are as following,

    would you be so kind use a 16-bit 48kHz or 44.1kHz, stereo, wav file. And test it again?

    One more thing. according to your wavform, I can't find the freq of the bck. What I can find is the freq of WS clk is 22.05.

    Another thing I want to check from you is whether aic3110 is set as a master codec?

    General
    Complete name : C:\Users\haodi\Desktop\CantinaBand3.wav
    Format : Wave
    File size : 129 KiB
    Duration : 3 s 0 ms
    Overall bit rate mode : Constant
    Overall bit rate : 353 kb/s

    Audio
    Format : PCM
    Format settings, Endianness : Little
    Format settings, Sign : Signed
    Codec ID : 1
    Duration : 3 s 0 ms
    Bit rate mode : Constant
    Bit rate : 352.8 kb/s
    Channel(s) : 1 channel
    Sampling rate : 22.05 kHz
    Bit depth : 16 bits
    Stream size : 129 KiB (100%)

  • Hello ,

    How can I check if the aic3110 is set as master codec?

    About the frequency of the BCK, isn't that the same as the one shown in the second image I sent?

    WCLK (yellow) BCLK (pink)

    About testing again, I have converted the original wav file to 48 KHz stereo and I'm getting this error:

    ~# aplay 48ECantinaBand3.wav 
    Playing WAVE '48ECantinaBand3.wav' : Signed 16 bi[  166.185832] tlv320aic31xx-codec 0-0018: aic31xx_setup_pll: Sample rate (48000) and format not supported
    [  166.195482] tlv320aic31xx-codec 0-0018: ASoC: error at snd_soc_dai_hw_params on tlv320aic31xx-hifi: -22
    [  166.204394]  44004000.audio-controller-tlv320aic31xx-hifi: ASoC: soc_pcm_hw_params() failed (-22)
    t Little Endian, Rate 48000 Hz, Stereo
    aplay: set_params:1416: Unable to install hw params:
    ACCESS:  RW_INTERLEAVED
    FORMAT:  S16_LE
    SUBFORMAT:  STD
    SAMPLE_BITS: 16
    FRAME_BITS: 32
    CHANNELS: 2
    RATE: 48000
    PERIOD_TIME: (42666 42667)
    PERIOD_SIZE: 2048
    PERIOD_BYTES: 8192
    PERIODS: 4
    BUFFER_TIME: (170666 170667)
    BUFFER_SIZE: 8192
    BUFFER_BYTES: 32768
    TICK_TIME: 0

    This is the file:

    /cfs-file/__key/communityserver-discussions-components-files/6/48ECantinaBand3.wav

  • WS clk is still wrong, this time you use 48k-samplerate wavfile, so the freq of WS must be 48kHz.

    Tell me where you get the code?

    Can you check what's wrong with the code related with the following log

    [ 166.195482] tlv320aic31xx-codec 0-0018: ASoC: error at snd_soc_dai_hw_params on tlv320aic31xx-hifi: -22
    [ 166.204394] 44004000.audio-controller-tlv320aic31xx-hifi: ASoC: soc_pcm_hw_params() failed (-22).

    As to how to check whether the aic3110 is set as master codec or slave, I wonder what the requirement for tlv320aic3110 in your project is? According to your dts setting, you have set it as master mode. that means both the bit clk and ws clk must be generated by the tlv320aic3110.