TLV320AIC32x4 evaluation board with TX2

Hi Igal,

Sorry I have been out of the office. With regard to comment #238, as I mentioned in comment #237, this should be able when the audio path itself is enabled and so you should not need to enable this explicitly.

I still do not know why you are trying to enable this manually, because if you have capture working then this means it must be enabled, right? You should see that if you trace the DAPM power events.

Regards,
Jon

Jon, hi,

I was thinking the same that somehow eventually these registers will be set:

SND_SOC_DAPM_ADC("Left ADC", "Capture", AIC32X4_ADCSETUP, 7, 0),
SND_SOC_DAPM_ADC("Right ADC", "Capture", AIC32X4_ADCSETUP, 6, 0),

that is, bits 6 and 7 in register AIC32X4_ADCSETUP will be set by the ALSA framework internally.
But they were not set and I had to add code setting these bits in the CODEC driver, otherwise encoding does not get any data once I start the arecord.

Regards, Igal.

Igal,

Thanks for the explanation, now it is clear what you are doing, I was not aware that you had made such a change.

I assume that you did not make such a change for playback, and if so what I would do, is trace the DAPM power events (as we have done previously) for both playback and then capture and compare the two. I believe that the paths are quite similar but with some obvious differences (with DACs vs ADCs) but hopefully it will help you track down whatever you are missing in the audio path that enables the ADC.

Regards,
Jon

Are you tuned out now? I now consider the TLV320AIC3109 chip should be similar to yours

hi,igal.kroyter.
I also want to use TLV320AIC32x4 on tx2, hardware wiring and JetPack version is the same as yours.Now debug for one month,bud no result.I follow yours steps and uploaded files, no sound is heard when aplay,and aic32x4_hw_params is not invoked.
Can you share with your latest modified files and amixer parameter settings?

hi,

I have summarized all that I’ve learnt during the above 243 messages thanks to jonathanh.
It took me quite a while to arrange the sources again and make sure that they actually are working for.
Anyone can use these modification hoping that NVidia will find the time to embed these modifications or others to support future uses who intend to use audio CODECs like the TLV320AIC32x4.

Assumptions:

  1. A remote PC was installed with Jetpack 3 (https://www.youtube.com/watch?v=D7lkth34rgM)
  2. The target Jetson TX2 is programmed with L4T 28.2.1 (by above Jetpack)
  3. the target Jetson TX2 is programmed with Kernel sources(https://www.jetsonhacks.com/2017/03/25/build-kernel-and-modules-nvidia-jetson-tx2/)

Procedure

  1. Apply the following :
    • Replace tegra186-quill-common.dtsi with /usr/src/hardware/nvidia/platform/t18x/common/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi
    • Replace tlv320aic32x4.c with /usr/src/kernel/kernel-4.4/sound/soc/codecs/tlv320aic32x4.c
    • Replace tegra_asoc_utils_alt.c with /usr/src/kernel/kernel-4.4/sound/soc/tegra-alt/tegra_asoc_utils_alt.c
    • Replace Kconfig with /usr/src/kernel/kernel-4.4/sound/soc/codecs/Kconfig
    • Replace tegra18_defconfig with /usr/src/kernel/kernel-4.4/arch/arm64/configs/tegra18_defconfig
    • Replace tegra_t186ref_mobile_rt565x.c with /usr/src/kernel/t18x/sound/soc/tegra-alt/tegra_t186ref_mobile_rt565x.c
    • Replace Kconfig.t18x with /usr/src/kernel/t18x/sound/soc/tegra-alt/Kconfig.t18x

    Pay attention to the exact files’ path.
    Please do consider compare the attached files with the original files just to make sure that you are comfortable with these changes. Again these changes and the reasons are extensively depicted within this post (again a big thanks to jonathanh).


  2. Do not forget to remove the .txt extension
    I have also added a batch file which has to be positioned in a local directory with the source files (attached) and activate from with a terminal which pointing to the same directory.
  3. Enter the kernel configuration so one is able to select the tlv320aic32x4 driver from kernel (GUI) configuration.
    cd /usr/src/kernel/kernel-4.4
    sudo make xconfig
    

    Verify that the driver TLV320AIC32x4 driver is selected. CTRL+F to find the driver, one can see that the driver is selected, I do not know but I could not deselect it, maybe some other changes have to be applied to the configuration files.

  4. Compile the kernel, so all added files will take affect
    cd /home/nvidia/buildjetsontx2kernel
    sudo ./makeKernel.sh
    sudo ./copyImage.sh
    
  5. Compile Device Tree with the modified tegra186-quill-common.dtsi file
    cd /usr/src/kernel/kernel-4.4
    sudo make dtbs
    

    TX2: copy the file /usr/src/kernel/kernel-4.4/arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb to a remote station for programming the Device Tree file.
    TX2i: copy the file /usr/src/kernel/kernel-4.4/arch/arm64/boot/dts/tegra186-quill-p3489-1000-a00-00-ucm1.dtb to a remote station for programming the Device Tree file.
    If someone wants to verify that the changes in tegra186-quill-common.dtsi were applied to the dtb file then de-compile the file (TX2: /usr/src/kernel/kernel-4.4/arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb or TX2i: /usr/src/kernel/kernel-4.4/arch/arm64/boot/dts/tegra186-quill-p3489-1000-a00-00-ucm1.dtb[/b]) and look for the changes:
    TX2:

    /usr/bin/dtc -I dtb -O dts -o tegra186-quill-p3310-1000-c03-00-base.dts tegra186-quill-p3310-1000-c03-00-base.dtb
    

    TX2i:

    /usr/bin/dtc -I dtb -O dts -o tegra186-quill-p3489-1000-a00-00-ucm1.dts tegra186-quill-p3489-1000-a00-00-ucm1.dtb
    
  6. Program the Device Tree file from a Remote Machine (this way the Jetson will get to knwo that there is an I2C driver for the TLV320AIC32x4 and the sound configuration with all DAIs Replace new dtb file with TX2:JetPack/3.1/64_TX2/Linux_for_Tegra_64_tx2/kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb or TX2i:JetPack/3.1/64_TX2/Linux_for_Tegra_64_tx2/kernel/dtb/tegra186-quill-p3489-1000-a00-00-ucm1.dtb(please verify that the Jetpack was extracted to the above directory if not then modify the directory above.)
    sudo ./flash.sh -r -k kernel-dtb jetson-tx2 mmcblk0p1
    
  7. Reboot
  8. Watch the terminal via the RS232 and verify that there are no errors - I had none. It is time to connect the evaluation board of the TLV320AIC32x4 with the Jetson TX2 evaluation board. I have attached a connection table. DO NOT FORGET TO CONNECT A GND CABLE BETWEEN THE BOARDS - I used dedicated pins on connectors P22 on the TLV320AIC32x4 and J21 on the Jetson. Do not connect the MCLK - I experienced noises during playback.

    Connect analog input via Input jack (not headphones) and output to speakers.

    Activate the

    ./Record.sh
    

    script to record a file on the eMMC and then the

    ./Play.sh
    

    script to playback the recently recorded file.

    Igal

    tegra_asoc_utils_alt.c (14.9 KB)
    tegra_t186ref_mobile_rt565x.c (33.2 KB)
    tlv320aic32x4.c (27.9 KB)
    CopyAudioFiles.sh.txt (681 Bytes)
    Kconfig.t18x.txt (4.43 KB)
    Kconfig.txt (19.2 KB)
    tegra18_defconfig.txt (15.2 KB)
    tegra186-quill-common.dtsi.txt (35.9 KB)
    Play.sh.txt (1.68 KB)
    Record.sh.txt (1.7 KB)
    Tegra40pinconnection.jpg

Hi everybody!
igal.kroyter and jonathanh, thank you for big work!

Is there anybody who tested this config from igal.kroyter?
I’ve made all like igal said. And everything is Ok except that I hear no sound)

And now I’m in process of finding the problem.

If anybody test it, please give a feedback.
Thank you!

Ilya, hi,

Please try to get into System Settings->Sound and there you are supposed to see at the lower portion of the Window under Output tab in the “Play sound through” two options: HDMI and Analog Output.

Once you run in the terminal the configuration Play.sh you may press the “Test Sound” Button and in the new window try an audio output test.

Regards.

Hi igal!

I’m using custom board with Jetson-TX2 (and TLV onboard) and yocto image based on linux-tegra layer.
And I have no GUI unfortunately.
I’ve tested your patch on 2 versions of poky: pyro (JetPack 28.1) and thud (28.2.1).
On both configurations I have all lines going to TLV working: bclkw, wclk and dout.
But when I use Play.sh with some file I hear only short “puff” sound on start playing and in the end. Sounds like power on and power off of home sound system. Speakers are connected to LOUT-L and LOUT-R (22 and 23 pin).

So no sound of actual file.

Also when I start Record.sh I see all the clocks but no DOUT from TLV.

TLV is accessible through i2c and I have no errors in kernel log (as it seems).
TLV is connected through I2S0 (i2s1 in dtb like you do).

Any help would be appreciated!
Here is part of kernel log:

[    4.052798] tegra210_adsp_audio_platform_probe: platform probe started
[    4.053667] tegra210-adsp adsp_audio: Default param-type to BYTE for mp3-dec1
[    4.054180] tegra210-adsp adsp_audio: Default param-type to BYTE for spkprot
[    4.054613] tegra210-adsp adsp_audio: Default param-type to BYTE for src
[    4.054983] tegra210-adsp adsp_audio: Default param-type to BYTE for aac-dec1
[    4.055400] tegra210-adsp adsp_audio: Default param-type to BYTE for aec
[    4.055405] tegra210-adsp adsp_audio: adma channel page address dt entry not found
[    4.055408] tegra210-adsp adsp_audio: using adma channel page 0
[    4.058728] tegra210_adsp_audio_platform_probe probe successfull.
[    4.058729] input: tegra-hda HDMI/DP,pcm=3 as /devices/3510000.hda/sound/card0/input0
[    4.058932] input: tegra-hda HDMI/DP,pcm=7 as /devices/3510000.hda/sound/card0/input1
[    4.066924] OPE platform probe
[    4.067014] OPE platform probe successful
[    4.169322] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF1 <-> ADMAIF1 mapping ok
[    4.169425] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF2 <-> ADMAIF2 mapping ok
[    4.169505] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF3 <-> ADMAIF3 mapping ok
[    4.169585] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF4 <-> ADMAIF4 mapping ok
[    4.169666] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF5 <-> ADMAIF5 mapping ok
[    4.169744] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF6 <-> ADMAIF6 mapping ok
[    4.169821] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF7 <-> ADMAIF7 mapping ok
[    4.169902] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF8 <-> ADMAIF8 mapping ok
[    4.169990] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF9 <-> ADMAIF9 mapping ok
[    4.170069] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF10 <-> ADMAIF10 mapping ok
[    4.170165] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF11 <-> ADMAIF11 mapping ok
[    4.170244] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF12 <-> ADMAIF12 mapping ok
[    4.170325] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF13 <-> ADMAIF13 mapping ok
[    4.170401] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF14 <-> ADMAIF14 mapping ok
[    4.170508] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF15 <-> ADMAIF15 mapping ok
[    4.170593] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF16 <-> ADMAIF16 mapping ok
[    4.170673] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF17 <-> ADMAIF17 mapping ok
[    4.170752] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF18 <-> ADMAIF18 mapping ok
[    4.170834] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF19 <-> ADMAIF19 mapping ok
[    4.170911] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF20 <-> ADMAIF20 mapping ok
[    4.174228] tegra-snd-t186ref-mobile-rt565x sound: ADSP-FE1 <-> ADSP PCM1 mapping ok
[    4.174317] tegra-snd-t186ref-mobile-rt565x sound: ADSP-FE2 <-> ADSP PCM2 mapping ok
[    4.174341] compress asoc: ADSP-FE3 <-> ADSP COMPR1 mapping ok
[    4.174363] compress asoc: ADSP-FE4 <-> ADSP COMPR2 mapping ok
[    4.215928] input: tegra-snd-t186ref-mobile-rt565x Headphone Jack as /devices/sound/sound/card1/input2
[    4.216054] input: tegra-snd-t186ref-mobile-rt565x Headphone Jack as /devices/sound/sound/card1/input3
[    4.216717] tegra-snd-t186ref-mobile-rt565x sound: codec-dai "tlv320aic32x4-hifi" registered

Ilia, hi,

Please verify that you are using the correct audio file with the correct frequency audio ( I think it is supposed to be 44,100 Hz).
Could you upload your file so I’ll try it too.

Could you try to play a sinus file and verify on scope that the device output the signal you are expecting?

Regards.

Igal, Hi!

Test file is in attachement.
I’ve also tested it on another system, it plays OK.

aplay NavigationAccuracyRestored.wav 
Playing WAVE 'NavigationAccuracyRestored.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

I’ve tested with generated sinus file (also in attachement) - same result.

Did you try to test system with internal Beep generator of TVL?
I’m going to test with it. It seems that only need is to set correct routes in TVL to LOUT.

audiocheck.net_sin_1000Hz_-3dBFS_3s.wav (258 KB)
NavigationAccuracyRestored.wav (300 KB)

Igal, hi!

On DEV board for TLV320AIC3204 there is SW2 switch which controls LDO enable, AVDD and DVDD.
Could you please check which position is it set on your dev-board?
The picture is in attachement.

hi, Igal!

I’ve solved the problem.

static int aic32x4_probe(struct snd_soc_codec *codec) 
{
.........
// Enable Master Analog Power Control
//snd_soc_write(codec, AIC32X4_LDOCTL, 0x00); // 0x08 - disables audio
snd_soc_write(codec, AIC32X4_LDOCTL, 0x01); // 0x08 - disables audio
.........
}

As I use LDO in circuit I need to enable AVDD from LDO.
Actually it should be set up in DTB file because driver support this setting. But I didn’t figured it out how to set it in DTB.

By the way… Did you try to set alsa configs so that no need to run Play.sh, just “aplay filename” ?

If somebody use custom device-tree file over whole jetson’s DT, here is the path that overwrites tegra186-quill-common.dtsi. So you do not need to edit tegra186-quill-common.dtsi itself.

// Sound settings
    i2c@c240000 {
            status="okay";
            aic32x4: tlv320aic32x4.1-0018@18 {
    			compatible = "ti,tlv320aic32x4";
    			status = "okay";
    			reg = <0x18>;
    			clocks = <&tegra_car TEGRA186_CLK_AUD_MCLK>;
    			clock-names = "mclk";
    		};
    };

    sound {
        nvidia,audio-routing =
			"z IN1_R",			"z IN",
			"z IN1_L",			"z IN",
			"z OUT",			"z LOR",
			"z OUT",			"z LOL";

        nvidia,dai-link-1 {
			cpu-dai = <&tegra_i2s2>;
			cpu-dai-name = "I2S2";
        };
        nvidia,dai-link-3 { status = "disabled";};
        nvidia,dai-link-4 { status = "disabled";};
        nvidia,dai-link-5 { status = "disabled";};
        nvidia,dai-link-6 { status = "disabled";};
        nvidia,dai-link-7 { status = "disabled";};
        nvidia,dai-link-8 { status = "disabled";};
        nvidia,dai-link-9 { status = "disabled";};
        nvidia,dai-link-10 { status = "disabled";};
        nvidia,dai-link-11 { status = "disabled";};
        nvidia,dai-link-12 { status = "disabled";};
        nvidia,dai-link-13 { status = "disabled";};
        nvidia,dai-link-2 {
            link-name = "ti-capture";
            cpu-dai = <&tegra_i2s1>;
            codec-dai = <&aic32x4>;
            cpu-dai-name = "I2S1";
            codec-dai-name = "tlv320aic32x4-hifi";
         	tx-mask = <0xFF>;
          	rx-mask = <0xFF>;
            format = "i2s";
            bitclock-slave;
            frame-slave;
            bitclock-noninversion;
            frame-noninversion;
            bit-format = "s16_le";
            bclk_ratio = <1>;
            srate = <44100>;
            num-channel = <2>;
            ignore_suspend;
            name-prefix = "z";
            status = "okay";
        };

    };

Hi, Igal!
Did you try to set alsa configs so that no need to run Play.sh, just “aplay filename” ?

Ilya, hi,

sorry for no answering, I have played your files, and I saw that you successfully provide a much elegant solution for the modifying the device tree file.

I was trying to do it but I recall that somewhere I read that it is not applicable. Pleased to update if you find a solution.

BTW our custom board has no LDOs for the matter.

Hi, Igal!

I’m using yocto poky and there I just add my top-level *.dts file based on tegra186-quill-p3310-1000-c03-00-base.dts and change path to this file in configuration.

I’t more easy to create patches because patch for dtb will contain only this file and no other dts and dtsi files would be modified.

If I remember correctly, in JetPack, this file is used for Jetso-TX2 dev-doard:

64_TX2/Linux_for_Tegra_tx2/sources/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dts

So you could change this file to meet your dts changes.

Hi, Igal!
Hope you found info about DTS file helpfull.

I have a question. Maybe someone could help me.

root@jetson-tx2:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: tegrahda [tegra-hda], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: tegrahda [tegra-hda], device 7: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 0: ADMAIF1 CIF ADMAIF1-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 1: ADMAIF2 CIF ADMAIF2-1 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 2: ADMAIF3 CIF ADMAIF3-2 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 3: ADMAIF4 CIF ADMAIF4-3 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 4: ADMAIF5 CIF ADMAIF5-4 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 5: ADMAIF6 CIF ADMAIF6-5 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 6: ADMAIF7 CIF ADMAIF7-6 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt186ref [tegra-snd-t186ref-mobile-rt565x], device 7: ADMAIF8 CIF ADMAIF8-7 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
.......

gives 2 devices.
New one (tegrasndt186ref) is a “card 1”.
And I could use this info to change /etc/asound.conf to make this card default.

But, is there a way just to delete tegra-hda card completely from device-tree?
Maybe in that case tegrasndt186ref would be default right from the box?

Thanks everyone for help!

Hi, Igal!

Thank you so much for your guide! But I have a question to ask.
I’m using L4T 32.1, Jetpack 4.2.1. How should I change your files and configurations to avoid fatal system crashes?

Hi Michael,

I wish I could help you but I’m not there yet, I’m still with 28.2.

I tried to look into it but there are too many changes between the kernels. Sorry.