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.

Linux/TLV320AIC3100: arecord fails with lower bitrates like 16000hz

Part Number: TLV320AIC3100

Tool/software: Linux

Hi,

I am using the AM335x Custom Board.

I have an issue with arecord functionality.
I am able to record with higher rates, say 44100hz. but when it comes to lower rates it fails.

ie,

"arecord --device=plughw:0,0 --format S16_LE --rate 44100 -c1 --duration=5 test.wav" works fine. I have verified the playback. Other higer bitrates too.

but when it comes to
"arecord --device=plughw:0,0 --format S16_LE --rate 16000 -c1 --duration=5 test.wav", the recording finishes before even 1-second timeout and all I can hear is a noise.

What can be the issue behind recording of lower rates ? I am able to play a sample 16000hz audio. but not record.

_____________________________________________________________________________________________________________
root@azeem-:~# cat /etc/asound.conf
pcm.!default {
type plug
slave {
pcm "hw:0,0"
}
}

ctl.!default {
type hw
card 0
}
___________________________________________________________________________________________________

**** List of PLAYBACK Hardware Devices ****
card 0: PLAYERU [PLAYERU], device 0: Playback tlv320aic31xx-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
root@azeem-:~#
___________________________________________________________________________________________________

  • If i give the record duration more i can see this.

    "overrun!!! (at least 16.177 ms long)
    overrun!!! (at least 39.360 ms long)"
  • Azeem,

    from the Codec side I don't see a reason why this would be the case. The TLV320AIC3100 evm allows for 16khz sample rate without issue.
    Let me look in the AM335x team to help support. Im not familiar enough with this board to be able to comment much on this.

    -Steve wilson
  • Azeem,

    Do you use AM335x TI PSDK Linux? If yes, which version?

    Regards,
    Pavel
  • Yes,

    version : 4.1.18+gitAUTOINC+bbe8cfc1da-r22c

    Regards
    Azeem

  • Azeem,

    This is linux kernel version. I need the version of the PSDK that you are using. The latest version is 5.01

    Regards,
    Pavel
  • Pavel,

    I am sorry i forgot to paste the details.

    ti-processor-sdk-linux-am335x-evm-04.01.00.06

    processor-sdk-linux-02.00.02


    Regards,
    Azeem

  • Hi ,

    Do you have an update on this ?

    Thanks and Regards
    Azeem
  • Azeem,

    I tested 16KHz arecord on the AM335x StarterKit board and it works fine. I also check AM335x McASP user guide and I see that 16KHz is supported sample rate:

    processors.wiki.ti.com/.../AM335x_Audio_Driver's_Guide

    Can you provide me the console output you have with verbose option enabled? Below is what I have:

    root@am335x-evm:~# arecord --device=plughw:0,0 --format S16_LE --rate 16000 -c1 --duration=20 test_16K.wav -v
    Recording WAVE 'test_16K.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
    Plug PCM: Route conversion PCM (sformat=S16_LE)
      Transformation table:
        0 <- 0*0.5 + 1*0.5
    Its setup is:
      stream       : CAPTURE
      access       : RW_INTERLEAVED
      format       : S16_LE
      subformat    : STD
      channels     : 1
      rate         : 16000
      exact rate   : 16000 (16000/1)
      msbits       : 16
      buffer_size  : 8000
      period_size  : 2000
      period_time  : 125000
      tstamp_mode  : NONE
      tstamp_type  : MONOTONIC
      period_step  : 1
      avail_min    : 2000
      period_event : 0
      start_threshold  : 1
      stop_threshold   : 8000
      silence_threshold: 0
      silence_size : 0
      boundary     : 2097152000
    Slave: Hardware PCM card 0 'AM335x-EVMSK' device 0 subdevice 0
    Its setup is:
      stream       : CAPTURE
      access       : MMAP_INTERLEAVED
      format       : S16_LE
      subformat    : STD
      channels     : 2
      rate         : 16000
      exact rate   : 16000 (16000/1)
      msbits       : 16
      buffer_size  : 8000
      period_size  : 2000
      period_time  : 125000
      tstamp_mode  : NONE
      tstamp_type  : MONOTONIC
      period_step  : 1
      avail_min    : 2000
      period_event : 0
      start_threshold  : 1
      stop_threshold   : 8000
      silence_threshold: 0
      silence_size : 0
      boundary     : 2097152000
      appl_ptr     : 0
      hw_ptr       : 0
    root@am335x-evm:~# ls -al test_16K.wav 
    -rw-r--r--    1 root     root        640044 Oct  6 02:14 test_16K.wav
    root@am335x-evm:~# 
    
    

    Can you also provide me your DTS file for review?

    Meanwhile you can check if the below pointers will be in help:

    If there’s an issue:

    - In case of XRUN (under or overrun)

    - ALSA period size must be aligned with the FIFO depth (tx/rx numevt)

    Silicon errata, Advisory 1.0.38 McASP: McASP to EDMA Synchronization Level Event Can Be Lost

    Regards,
    Pavel

  • Hi Pavel,

    Thanks for your faster response. 

    Here is the information you have asked for. Before that with the above "asound.conf" file, i was facing issue with the playback of 16000hz bitrates. So, I have modified the file which is now able to play the 16000hz bitrate but still no fortune on the recording side. I have attached my latest "asound.conf".

    Please see the attached files.

    1. arecord output.

     

    root@azeem-:/download/home/root# arecord --device=plughw:0,0 --format S16_LE --rate 16000 -c1 --duration=20 test_16K.wav -v
    Recording WAVE 'test_16K.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
    Plug PCM: Rate conversion PCM (11025, sformat=S16_LE)
    Converter: libspeex (external)
    Protocol version: 10002
    Its setup is:
      stream       : CAPTURE
      access       : RW_INTERLEAVED
      format       : S16_LE
      subformat    : STD
      channels     : 1
      rate         : 16000
      exact rate   : 16000 (16000/1)
      msbits       : 16
      buffer_size  : 7999
      period_size  : 1999
      period_time  : 124988
      tstamp_mode  : NONE
      tstamp_type  : MONOTONIC
      period_step  : 1
      avail_min    : 1999
      period_event : 0
      start_threshold  : 1
      stop_threshold   : 7999
      silence_threshold: 0
      silence_size : 0
      boundary     : 2096889856
    Slave: Route conversion PCM (sformat=S16_LE)
      Transformation table:
        0 <- 0*0.5 + 1*0.5
    Its setup is:
      stream       : CAPTURE
      access       : MMAP_INTERLEAVED
      format       : S16_LE
      subformat    : STD
      channels     : 1
      rate         : 11025
      exact rate   : 11025 (11025/1)
      msbits       : 16
      buffer_size  : 5512
      period_size  : 1378
      period_time  : 124988
      tstamp_mode  : NONE
      tstamp_type  : MONOTONIC
      period_step  : 1
      avail_min    : 1378
      period_event : 0
      start_threshold  : 1
      stop_threshold   : 5512
      silence_threshold: 0
      silence_size : 0
      boundary     : 1444937728
    Slave: Hardware PCM card 0 'PLAYERU' device 0 subdevice 0
    Its setup is:
      stream       : CAPTURE
      access       : MMAP_INTERLEAVED
      format       : S16_LE
      subformat    : STD
      channels     : 2
      rate         : 11025
      exact rate   : 11025 (11025/1)
      msbits       : 16
      buffer_size  : 5512
      period_size  : 1378
      period_time  : 124988
      tstamp_mode  : NONE
      tstamp_type  : MONOTONIC
      period_step  : 1
      avail_min    : 1378
      period_event : 0
      start_threshold  : 1
      stop_threshold   : 5512
      silence_threshold: 0
      silence_size : 0
      boundary     : 1444937728
      appl_ptr     : 0
      hw_ptr       : 0
    overrun!!! (at least 6.604 ms long)
    Status:
      state       : XRUN
      trigger_time: 416.581207132
      tstamp      : 0.000000
      delay       : 2002
      avail       : 5997
      avail_max   : 7996
    overrun!!! (at least 6.759 ms long)
    Status:
      state       : XRUN
      trigger_time: 416.897735465
      tstamp      : 0.000000
      delay       : 2002
      avail       : 5997
      avail_max   : 7996
    overrun!!! (at least 7.137 ms long)
    Status:
      state       : XRUN
      trigger_time: 417.214377965
      tstamp      : 0.000000
      delay       : 2002
      avail       : 5997
      avail_max   : 7996
    overrun!!! (at least 6.548 ms long)
    Status:
      state       : XRUN
      trigger_time: 417.531381757
      tstamp      : 0.000000
      delay       : 2002
      avail       : 5997
      avail_max   : 7996
    root@azeem-:/download/home/root

    2. dts file trimmed

    ..
    ..
    ..
    ..
    sound1 {
                    compatible = "ti,playeru-audio-revb";
                    ti,model = "PLAYERU";
                    ti,audio-codec = <&tlv320aic3100>;
                    ti,mcasp-controller = <&mcasp1>;
                    ti,codec-clock-rate = <24000000>;
                    ti,audio-routing =
                            "Headphone Jack",       "HPL",
                            "Headphone Jack",       "HPR",
                            "MIC1RP", "Mic Jack",
                            "MIC1RP", "MICBIAS";
            };
    };
    ..
    ..
    playeru_audio_pins: pinmux_playeru_audio_pins {
                    pinctrl-single,pins = <
                            0x10C ( PIN_OUTPUT_PULLDOWN | MUX_MODE4 )  /* gmii1_crs.mcasp1_aclkx */
                            0x110 ( PIN_OUTPUT_PULLDOWN | MUX_MODE4 )  /* gmii1_rxer.mcasp1_fsx */
                            0x128 ( PIN_OUTPUT_PULLDOWN | MUX_MODE3 ) /* gmii1_txd0.mcasp1_axr2 */
                            0x144 ( PIN_INPUT | MUX_MODE4 )           /* rmii1_refclk.mcasp1_axr3 */
                            /* Codec Interrupt and Reset pin */
                            0x150 ( PIN_INPUT | MUX_MODE7 ) /*  spi0_sclk.gpio0[2] */
                            0x154 ( PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* (B18) spi0_d0.gpio0[3] */
                    >;
            };
    ..
    ..
    i2c1_pins_default: pinmux_i2c1_pins_default {
                    pinctrl-single,pins = <
                            0x180 (PIN_INPUT_PULLUP | MUX_MODE3)    /* uart1_txd.i2c1_sda */
                            0x184 (PIN_INPUT_PULLUP | MUX_MODE3)    /* uart1_rxd.i2c1_scl */
                    >;
            };
    ..
    ..
    
    &i2c1 {
            pinctrl-names = "default", "sleep";
            pinctrl-0 = <&i2c1_pins_default>;
            pinctrl-1 = <&i2c1_pins_sleep>;
    
            status = "okay";
            clock-frequency = <100000>;
    
            tlv320aic3100: tlv320aic3100@18 {
                    compatible = "ti,tlv320aic310x";
                    reg = <0x18>;
                    status = "okay";
                    gpio-reset= <&gpio0 3 GPIO_ACTIVE_LOW>;
                    ai31xx-micbias-vg = <0x2>;
                    /* Regulators */
                    HPVDD-supply = <&ldo4_reg>;
                    SPRVDD-supply = <&ldo4_reg>;
                    SPLVDD-supply = <&ldo4_reg>;
                    AVDD-supply = <&ldo4_reg>;
                    IOVDD-supply = <&ldo4_reg>;
                    DVDD-supply = <&ldo4_reg>;
            };
    };
    ..
    ..
    ..
    &mcasp1 {
                    pinctrl-names = "default", "sleep";
                    pinctrl-0 = <&playeru_audio_pins>;
                    pinctrl-1 = <&playeru_audio_pins_sleep>;
    
                    status = "okay";
    
                    op-mode = <0>;          /* MCASP_IIS_MODE */
                    tdm-slots = <2>;
                    /* 4 serializers */
                    serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
                            0 0 1 2
                    >;
                    tx-num-evt = <32>;
                    rx-num-evt = <32>;
    };
    

    3. asound.conf file

    pcm.!default {
            type plug
            slave.pcm "dmixer"
    }
    
    pcm.dmixer  {
            type dmix
            ipc_key 1024
            slave {
                    pcm "hw:0,0"
                    period_time 0
                    period_size 1024
                    buffer_size 4096
                    rate 44100
            }
            bindings {
                    0 0
                    1 1
            }
    }
    
    ctl.dmixer {
            type hw
            card 0
    }

    Thanks and Regards

    Azeem

  • Azeem,

    You stated that you are using ti-processor-sdk-linux-am335x-evm-04.01.00.06. This PSDK version comes with kernel 4.9.41. Can you double check the version of the PSDK you are using? Because kernel 4.1.18 comes with PSDK 2.00.02

    Also in your arecord_veribode.txt file I see that sample rate change from 16000 to 11025, which is not supported by the McASP audio driver. You should measure with scope what frequency exactly you have on the mcasp1_fsx pin during the 16KHz arecord usecase.

    Regards,
    Pavel
  • Pavel,

    Sorry about the confusion again.
    Yes, we are using processor-sdk-linux-02.00.02.


    Thanks and Regards
    Azeem

  • Azeem,

    I check asound.conf file in processor-sdk-linux-02.00.02, and it is empty file. Asoundrc (or asound.conf) is a configuration file that is not technically needed for audio to work in linux, but it is a powerful tool to tailor to the audio needs of a specific system. Routing and sample-rate conversion are examples of properties that can be configured through Asoundrc.
    AM335x EVM and StarterKit audio works fine with an empty asound.conf file. What differences between your board and TI boards need to be hadles in asound.conf file? For more info regarding this file check below pointers:

    processors.wiki.ti.com/.../Sitara_SDK_Linux_Audio_ALSA_User_Space
    www.alsa-project.org/.../Asoundrc


    Also in your DTS file I see below line:

    compatible = "ti,playeru-audio-revb";

    While on AM335x TI boards we have:

    compatible = "ti,da830-evm-audio";

    This "ti,da830-evm-audio" points to linux-kernel/sound/soc/davinci/davinci-evm.c file, where AIC3x (AIC3106) codec is handled. Make sure you have modified your davinci-evm.c for your AIC3100 codec. See also below wiki page:

    processors.wiki.ti.com/.../Sitara_Linux_Audio_Porting_Guide
    processors.wiki.ti.com/.../Sitara_Linux_Audio_DAC_Example


    I would also suggest you to measure frame sync and bit clock pins and verify your have the correct and expected clock frequencies on these pins.

    Regards,
    Pavel
  • If you have no more questions related to the subject of the e2e thread, please close/verify/resolve this thread.

    Regards,
    Pavel