audio codec 5640 in tx2

Hi NVpeople

I wanna use I2S0 and I2C_GP0 to connect alc5640 audio codec.
i followed this topic and Document
https://devtalk.nvidia.com/default/topic/1031303/jetson-tx2/audio-codec-rt5631-on-tx2

  1. in tegra186-quill-common-p3310-1000-a00.dtsi //reset codec
gpio@2200000 {
		wifi_over_pcie {
			gpio-hog;
			gpios = <TEGRA_MAIN_GPIO(R, 4) 0>;
			output-low;
			label = "wifi-over-pcie";
			status = "disabled";
		};
		pcie0_lane2_mux {
			gpio-hog;
			gpios = <TEGRA_MAIN_GPIO(R, 3) 0>;
			output-low;
			label = "pcie-lane2-mux";
			status = "disabled";
		};
		e3325_sdio_rst {
			gpio-hog;
			gpios = <TEGRA_MAIN_GPIO(B, 6) 0>;
			output-high;
			label = "e3325-sdio-rst";
			status = "disabled";
		};
		e3325_lane0_mux {
			gpio-hog;
			gpios = <TEGRA_MAIN_GPIO(B, 4) 0>;
			output-low;
			label = "e3325-lane0-mux";
			status = "disabled";
		};
		aud_rst {
			gpio-hog;
			gpios = <TEGRA_MAIN_GPIO(J, 6) 0>;
			output-high;
			label = "audio reset";
			status = "okay";
        };
	};
  1. modify sound structure. in tegra186-quill-common.dtsi
i2c@c240000 {
		clock-frequency = <400000>;
		rt5640_codec: rt5640@1c {
            compatible = "realtek,rt5640";
            reg = <0x1c>;
            gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(J , 5) GPIO_ACTIVE_HIGH>;
			realtek,jd-src = <1>; /* RT5659_JD3 */
			realtek,ldo1-en-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(J, 6) GPIO_ACTIVE_HIGH>;
        };
	};


tegra_sound: sound {
		compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
		nvidia,model = "tegra-snd-t186ref-mobile-rt565x";
		nvidia,num-codec-link = <11>;
		nvidia,num-clk = <8>;
		nvidia,ldo-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(J, 6) GPIO_ACTIVE_HIGH>;   //reset
		nvidia,hp-det-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(J, 5) GPIO_ACTIVE_HIGH>;
		nvidia,clk-rates = < 270950400	/* PLLA_x11025_RATE */
				     11289600	/* AUD_MCLK_x11025_RATE */
				     45158400	/* PLLA_OUT0_x11025_RATE */
				     45158400	/* AHUB_x11025_RATE */
				     245760000  /* PLLA_x8000_RATE */
				     12288000	/* AUD_MCLK_x8000_RATE */
				     49152000	/* PLLA_OUT0_x8000_RATE */
				     49152000 >;/* AHUB_x8000_RATE */
		clocks = <&tegra_car TEGRA186_CLK_PLLP_OUT0>,
			<&tegra_car TEGRA186_CLK_PLLA>,
			<&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
			<&tegra_car TEGRA186_CLK_AHUB>,
			<&tegra_car TEGRA186_CLK_CLK_M>,
			<&tegra_car TEGRA186_CLK_AUD_MCLK>;
		clock-names = "pll_p_out1", "pll_a", "pll_a_out0", "ahub",
				"clk_m", "extern1";
		resets = <&tegra_car TEGRA186_RESET_AUD_MCLK>;
		reset-names = "extern1_rst";

		status = "okay";
		nvidia,audio-routing =
			"x Headphone",          "x Left DAC",
			"x Headphone",          "x Right DAC",
			"x IN",                 "x Left ADC",
			"x IN",                 "x Right ADC",
			"y Headphone",		"y OUT",
			"y IN",			"y Mic",
			"z Headphone",		"z OUT",
			"z IN",			"z Mic",
			"m Headphone",		"m OUT",
			"m IN",			"m Mic",
			"n Headphone",		"n OUT",
			"n IN",			"n Mic",
			"o Headphone",		"o OUT",
			"o IN",			"o Mic",
			"a IN",			"a Mic",
			"b IN",			"b Mic",
			"c IN",			"c Mic",
			"d IN",			"d Mic",
			"e Headphone",		"e OUT",
			"e IN",			"e Mic",
			"d1 Headphone",		"d1 OUT",
			"d2 Headphone",		"d2 OUT";

		nvidia,xbar = <&tegra_axbar>;

		rt565x_dai_link: nvidia,dai-link-1 {
			link-name = "rt5640-playback";
			cpu-dai = <&tegra_i2s1>;
			codec-dai = <&rt5640_codec>;
			cpu-dai-name = "I2S1";
			codec-dai-name = "rt5640-aif1";
			format = "i2s";
			bitclock-slave;
			frame-slave;
			bitclock-noninversion;
			frame-noninversion;
			bit-format = "s16_le";
			bclk_ratio = <0>;
			srate = <48000>;
			num-channel = <2>;
			ignore_suspend;
			name-prefix = "x";
			status = "okay";
		};

and i followed
https://devtalk.nvidia.com/default/topic/1031303/jetson-tx2/audio-codec-rt5631-on-tx2/post/5247188/#5247188
step 2 modify tegra_t186ref_mobile_rt565x.c

static int tegra_t186ref_dai_init(struct snd_soc_pcm_runtime *rtd,
					int rate,
					int channels,
					u64 formats,
					bool is_playback)
{
	struct snd_soc_card *card = rtd->card;
	struct tegra_t186ref *machine = snd_soc_card_get_drvdata(card);
	struct snd_soc_pcm_stream *dai_params;
	unsigned int idx, clk_out_rate;
	int err, codec_rate, clk_rate;

	codec_rate = tegra_t186ref_srate_values[machine->rate_via_kcontrol];
	clk_rate = (machine->rate_via_kcontrol) ? codec_rate : rate;

	err = tegra_alt_asoc_utils_set_rate(&machine->audio_clock, clk_rate,
						0, 0);
	if (err < 0) {
		dev_err(card->dev, "Can't configure clocks\n");
		return err;
	}

	clk_out_rate = machine->audio_clock.clk_out_rate;

	pr_debug("pll_a_out0 = %d Hz, aud_mclk = %d Hz, codec rate = %d Hz\n",
		machine->audio_clock.set_mclk, clk_out_rate, clk_rate);

	tegra_t186ref_set_params(card, machine, rate, channels, formats);

	idx = tegra_machine_get_codec_dai_link_idx_t18x("rt5640-playback");  
	/* check if idx has valid number */
	if (idx != -EINVAL) {
		dai_params =
		(struct snd_soc_pcm_stream *)card->rtd[idx].dai_link->params;
	/*
		dai_params->rate_min = clk_rate;
		dai_params->formats = (machine->fmt_via_kcontrol == 2) ?
                                (1ULL << SNDRV_PCM_FORMAT_S32_LE) : formats;

		if (!machine->is_codec_dummy) {
			err = snd_soc_dai_set_sysclk(card->rtd[idx].codec_dai,
			RT5659_SCLK_S_MCLK, clk_out_rate, SND_SOC_CLOCK_IN);
			if (err < 0) {
				dev_err(card->dev, "codec_dai clock not set\n");
				return err;
			}
		}
	*/
		dai_params->rate_min = clk_rate;
		dai_params->formats = formats;
		err = snd_soc_dai_set_pll(card->rtd[idx].codec_dai, 0, 0, 0, 0);
		if (err < 0) 
		{
			dev_err(card->dev, "failed to set codec clock to %d\n",clk_out_rate);
			return err;		
		}
			
	}

	/* set clk rate for i2s3 dai link*/
	idx = tegra_machine_get_codec_dai_link_idx_t18x("spdif-dit-2");
	if (idx != -EINVAL) {
		dai_params =
		(struct snd_soc_pcm_stream *)card->rtd[idx].dai_link->params;

		dai_params->rate_min = clk_rate;
	}


static void dai_link_setup(struct platform_device *pdev)
{
	struct snd_soc_card *card = platform_get_drvdata(pdev);
	struct tegra_t186ref *machine = snd_soc_card_get_drvdata(card);
	struct snd_soc_codec_conf *tegra_machine_codec_conf = NULL;
	struct snd_soc_codec_conf *tegra_t186ref_codec_conf = NULL;
	struct snd_soc_dai_link *tegra_machine_dai_links = NULL;
	struct snd_soc_dai_link *tegra_t186ref_codec_links = NULL;
	int i;
	printk("test!!test[%s][%d]\n",__func__,__LINE__);
	/* set new codec links and conf */
	tegra_t186ref_codec_links = tegra_machine_new_codec_links(pdev,
		tegra_t186ref_codec_links,
		&machine->num_codec_links);
	if (!tegra_t186ref_codec_links)
		goto err_alloc_dai_link;

	/* set codec init */
	for (i = 0; i < machine->num_codec_links; i++) {
		if (tegra_t186ref_codec_links[i].name) {
			if (strstr(tegra_t186ref_codec_links[i].name,
				"rt565x-playback"))
				tegra_t186ref_codec_links[i].init = tegra_t186ref_init;
			else if (strstr(tegra_t186ref_codec_links[i].name,
				"rt5640-playback"))
				tegra_t186ref_codec_links[i].init = tegra_t186ref_init;
			else if (strstr(tegra_t186ref_codec_links[i].name,
				"dspk-playback-r"))
				tegra_t186ref_codec_links[i].init = tegra_t186ref_dspk_init;
			else if (strstr(tegra_t186ref_codec_links[i].name,
				"dspk-playback-l"))
				tegra_t186ref_codec_links[i].init = tegra_t186ref_dspk_init;
		}
	}

the console message

[    4.570046] cpuidle: Initializing cpuidle driver init for Denver cluster
[    4.570166] cpuidle: Initializing cpuidle driver init for A57 cluster
[    4.571230] tachometer tegra-tachometer: Tachometer driver tegra-tachometer registered
[    4.571234] Tachometer driver initialized with pulse_per_rev: 2 and win_len: 2
[    4.573238] test[rt5640_i2c_probe][2429]
[    4.582052] tegradc 15210000.nvdisplay: blank - powerdown
[    4.582632] test[rt5640_i2c_probe][2501]
[    4.584185] tegra210_adsp_audio_platform_probe: platform probe started
[    4.584788] tegra210-adsp adsp_audio: Default param-type to BYTE for mp3-dec1
[    4.585062] tegra210-adsp adsp_audio: Default param-type to BYTE for spkprot
[    4.585419] tegra210-adsp adsp_audio: Default param-type to BYTE for src
[    4.585729] tegra210-adsp adsp_audio: Default param-type to BYTE for aac-dec1
[    4.586075] tegra210-adsp adsp_audio: Default param-type to BYTE for aec
[    4.586079] tegra210-adsp adsp_audio: adma channel page address dt entry not found
[    4.586080] tegra210-adsp adsp_audio: using adma channel page 0
[    4.587229] tegra210_adsp_audio_platform_probe probe successfull.
[    4.587230] input: tegra-hda HDMI/DP,pcm=3 as /devices/3510000.hda/sound/card0/input0
[    4.587404] input: tegra-hda HDMI/DP,pcm=7 as /devices/3510000.hda/sound/card0/input1
[    4.596029] OPE platform probe
[    4.596096] OPE platform probe successful
[    4.627181] test!!test[tegra_t186ref_driver_probe][1038]
[    4.627231] test!!test[dai_link_setup][932]
[    4.672954] random: nonblocking pool is initialized
[    4.676717] test[rt5640_probe][2027]
[    4.681238] test[rt5640_probe][2072]
[    4.686523] PD DISP2 index4 DOWN
[    4.686627] PD DISP1 index3 DOWN
[    4.686719] PD DISP0 index2 DOWN
[    4.695356] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF1 <-> ADMAIF1 mapping ok
[    4.695451] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF2 <-> ADMAIF2 mapping ok
[    4.695539] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF3 <-> ADMAIF3 mapping ok
[    4.695631] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF4 <-> ADMAIF4 mapping ok
[    4.695727] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF5 <-> ADMAIF5 mapping ok
[    4.695821] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF6 <-> ADMAIF6 mapping ok
[    4.695910] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF7 <-> ADMAIF7 mapping ok
[    4.695998] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF8 <-> ADMAIF8 mapping ok
[    4.696095] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF9 <-> ADMAIF9 mapping ok
[    4.696209] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF10 <-> ADMAIF10 mapping ok
[    4.696301] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF11 <-> ADMAIF11 mapping ok
[    4.696391] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF12 <-> ADMAIF12 mapping ok
[    4.696482] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF13 <-> ADMAIF13 mapping ok
[    4.696569] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF14 <-> ADMAIF14 mapping ok
[    4.696661] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF15 <-> ADMAIF15 mapping ok
[    4.696761] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF16 <-> ADMAIF16 mapping ok
[    4.696859] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF17 <-> ADMAIF17 mapping ok
[    4.696949] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF18 <-> ADMAIF18 mapping ok
[    4.697045] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF19 <-> ADMAIF19 mapping ok
[    4.697137] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF20 <-> ADMAIF20 mapping ok
[    4.701339] tegra-snd-t186ref-mobile-rt565x sound: ADSP-FE1 <-> ADSP PCM1 mapping ok
[    4.701437] tegra-snd-t186ref-mobile-rt565x sound: ADSP-FE2 <-> ADSP PCM2 mapping ok
[    4.701465] compress asoc: ADSP-FE3 <-> ADSP COMPR1 mapping ok
[    4.701492] compress asoc: ADSP-FE4 <-> ADSP COMPR2 mapping ok
[    4.708922] tegradc 15210000.nvdisplay: unblank
[    4.708937] PD DISP0 index2 UP
[    4.709986] PD DISP1 index3 UP
[    4.710086] PD DISP2 index4 UP
[    4.711718] Parent Clock set for DC plld2
[    4.713337] tegradc 15210000.nvdisplay: hdmi: pclk:297000K, set prod-setting:prod_c_300M
[    4.716581] tegra-snd-t186ref-mobile-rt565x sound: ASoC: no source widget found for x Left DAC
[    4.716586] tegra-snd-t186ref-mobile-rt565x sound: ASoC: Failed to add route x Left DAC -> direct -> x Headphone
[    4.716616] tegra-snd-t186ref-mobile-rt565x sound: ASoC: no source widget found for x Right DAC
[    4.716619] tegra-snd-t186ref-mobile-rt565x sound: ASoC: Failed to add route x Right DAC -> direct -> x Headphone
[    4.716681] tegra-snd-t186ref-mobile-rt565x sound: ASoC: no source widget found for x Left ADC
[    4.716684] tegra-snd-t186ref-mobile-rt565x sound: ASoC: Failed to add route x Left ADC -> direct -> x IN
[    4.716752] tegra-snd-t186ref-mobile-rt565x sound: ASoC: no source widget found for x Right ADC
[    4.716754] tegra-snd-t186ref-mobile-rt565x sound: ASoC: Failed to add route x Right ADC -> direct -> x IN
[    4.717234] tegra-snd-t186ref-mobile-rt565x sound: ASoC: no source widget found for d1 OUT
[    4.717237] tegra-snd-t186ref-mobile-rt565x sound: ASoC: Failed to add route d1 OUT -> direct -> d1 Headphone
[    4.717267] tegra-snd-t186ref-mobile-rt565x sound: ASoC: no source widget found for d2 OUT
[    4.717270] tegra-snd-t186ref-mobile-rt565x sound: ASoC: Failed to add route d2 OUT -> direct -> d2 Headphone
[    4.746133] input: tegra-snd-t186ref-mobile-rt565x Headphone Jack as /devices/sound/sound/card1/input2
[    4.746843] tegra-snd-t186ref-mobile-rt565x sound: codec link not defined - codec not part of sound card
[    4.746846] test!!test[tegra_t186ref_driver_probe][1146]
[    4.747420] GACT probability NOT on
[    4.747430] Mirror/redirect action on
[    4.747441] u32 classifier
[    4.747442]     Actions configured
[    4.747469] nf_conntrack version 0.5.0 (65536 buckets, 262144 max)
[    4.748190] IPVS: Registered protocols ()
[    4.748216] IPVS: Connection hash table configured (size=4096, memory=64Kbytes)
[    4.748287] IPVS: Creating netns size=1424 id=0
[    4.748316] IPVS: ipvs loaded.
[    4.748321] IPVS: [rr] scheduler registered.
[    4.748398] ipip: IPv4 over IPv4 tunneling driver
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$ sudo i2cdetect -y -r 1
[sudo] password for nvidia:
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$ find /sys/devices/*.i2c/ -name name -exec cat {} \; | grep 5640
rt5640
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$

i can’t hear voice form headphone.
audio routing is correct or need to modify??

and how the check rt5640 codec configuration?

Hello!

To begin with, can you tell me how you have connected the codec to the Jetson TX2? I would like to know what signals are connected. I understand you are using I2S0 and I2C_GP0, but what other signals are connected?

I see that the kernel is detecting the codec which is good, but audio will not work because there are errors that need to be resolved …

[    4.716581] tegra-snd-t186ref-mobile-rt565x sound: ASoC: no source widget found for x Left DAC
[    4.716586] tegra-snd-t186ref-mobile-rt565x sound: ASoC: Failed to add route x Left DAC -> direct -> x Headphone
[    4.716616] tegra-snd-t186ref-mobile-rt565x sound: ASoC: no source widget found for x Right DAC
[    4.716619] tegra-snd-t186ref-mobile-rt565x sound: ASoC: Failed to add route x Right DAC -> direct -> x Headphone
[    4.716681] tegra-snd-t186ref-mobile-rt565x sound: ASoC: no source widget found for x Left ADC
[    4.716684] tegra-snd-t186ref-mobile-rt565x sound: ASoC: Failed to add route x Left ADC -> direct -> x IN
[    4.716752] tegra-snd-t186ref-mobile-rt565x sound: ASoC: no source widget found for x Right ADC
[    4.716754] tegra-snd-t186ref-mobile-rt565x sound: ASoC: Failed to add route x Right ADC -> direct -> x IN

The rt5631 is different from the rt5640 and if you look at the drivers you will see for the rt5640 the ‘Left/Right DAC’ and ‘Left/Right ADC’ widgets do not exist. So we need to update the ‘nvidia,audio-routing’ with the correct widget names. However, before we do that, let’s make sure the clocking is correct.

Regards,
Jon

Hi jonathanh

thanks for your reply.

SOM ----------- rt5640
AUDIO_MCLK MCLK
GPIO20_AUD_INT GPIO1_IRQ
GPIO19_AUD_RST LDO1_EN

rt5640 --------------interface
LOUTR/LOUTL headset
LINEIN_L/LINEIN_R microphone

If I miss any signal description please tell me.

Hi,

If you are using the aud_mclk to drive the codec mclk, then you do not need to configure the codec pll and you can just do something like …

idx = tegra_machine_get_codec_dai_link_idx_t18x("rt5640-playback");  
	/* check if idx has valid number */
	if (idx != -EINVAL) {
		dai_params =
		(struct snd_soc_pcm_stream *)card->rtd[idx].dai_link->params;

		dai_params->rate_min = clk_rate;
		dai_params->formats = formats;

		err = snd_soc_dai_set_sysclk(card->rtd[idx].codec_dai,
			RT5640_SCLK_S_MCLK, clk_out_rate, SND_SOC_CLOCK_IN);
		if (err < 0) {
			dev_err(card->dev, "codec_dai clock not set\n");
			return err;
		}
	}

With regard to the audio routing can you try …

nvidia,audio-routing =
			"x Headphone",          "x Speaker L Playback",
			"x Headphone",          "x Speaker R Playback",
			"x IN2P",               "x Mic",
			"x IN2N",               "x Mic",

Once this is done, then you need to map I2S1 to one of the ADMAIF interfaces for capture and playback. For example, to map I2S1 to ADMAIF1 for capture and playback you …

$ amixer -c tegrasndt186ref cset name=“ADMAIF1 Mux” “I2S1”
$ amixer -c tegrasndt186ref cset name=“I2S1 Mux” “ADMAIF1”

Then there are most likely some mixer controls that you need to set for the codec (see rt5640_snd_controls in the rt5640 driver). You can configure these using the ‘amixer’ tool similar to the above to set these. Each codec is a bit different here and so it is best to look for an example for how to set the mixer controls.

Finally, once the codec is configured, then you should be able to play a file by …

$ aplay -D hw:tegrasndt186ref,0

Regards
Jon

Hi jonathanh

i followed your step to modify.

static int tegra_t186ref_dai_init(struct snd_soc_pcm_runtime *rtd,
					int rate,
					int channels,
					u64 formats,
					bool is_playback)
{
	struct snd_soc_card *card = rtd->card;
	struct tegra_t186ref *machine = snd_soc_card_get_drvdata(card);
	struct snd_soc_pcm_stream *dai_params;
	unsigned int idx, clk_out_rate;
	int err, codec_rate, clk_rate;

	codec_rate = tegra_t186ref_srate_values[machine->rate_via_kcontrol];
	clk_rate = (machine->rate_via_kcontrol) ? codec_rate : rate;

	err = tegra_alt_asoc_utils_set_rate(&machine->audio_clock, clk_rate,
						0, 0);
	if (err < 0) {
		dev_err(card->dev, "Can't configure clocks\n");
		return err;
	}

	clk_out_rate = machine->audio_clock.clk_out_rate;

	pr_debug("pll_a_out0 = %d Hz, aud_mclk = %d Hz, codec rate = %d Hz\n",
		machine->audio_clock.set_mclk, clk_out_rate, clk_rate);

	tegra_t186ref_set_params(card, machine, rate, channels, formats);

	idx = tegra_machine_get_codec_dai_link_idx_t18x("rt5640-playback");  
	/* check if idx has valid number */
	if (idx != -EINVAL) {
		dai_params =
		(struct snd_soc_pcm_stream *)card->rtd[idx].dai_link->params;
	/*
		dai_params->rate_min = clk_rate;
		dai_params->formats = (machine->fmt_via_kcontrol == 2) ?
                                (1ULL << SNDRV_PCM_FORMAT_S32_LE) : formats;

		if (!machine->is_codec_dummy) {
			err = snd_soc_dai_set_sysclk(card->rtd[idx].codec_dai,
			RT5659_SCLK_S_MCLK, clk_out_rate, SND_SOC_CLOCK_IN);
			if (err < 0) {
				dev_err(card->dev, "codec_dai clock not set\n");
				return err;
			}
		}
	*/
		dai_params->rate_min = clk_rate;
		dai_params->formats = formats;
		err = snd_soc_dai_set_sysclk(card->rtd[idx].codec_dai,
			RT5640_SCLK_S_MCLK, clk_out_rate, SND_SOC_CLOCK_IN);
		if (err < 0) 
		{
			dev_err(card->dev, "failed to set codec clock to %d\n",clk_out_rate);
			return err;		
		}
			
	}
	printk("test!!test[%s][%d]\n",__func__,__LINE__);
	/* set clk rate for i2s3 dai link*/
	idx = tegra_machine_get_codec_dai_link_idx_t18x("spdif-dit-2");
	if (idx != -EINVAL) {
		dai_params =
		(struct snd_soc_pcm_stream *)card->rtd[idx].dai_link->params;
i2c@c240000 {
		clock-frequency = <400000>;
		rt5640_codec: rt5640@1c {
            compatible = "realtek,rt5640";
            reg = <0x1c>;
            gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(J , 5) GPIO_ACTIVE_HIGH>;
			realtek,jd-src = <1>; /* RT5659_JD3 */
			realtek,ldo1-en-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(J, 6) GPIO_ACTIVE_HIGH>;
        };
	};
	
	tegra_sound: sound {
		compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
		nvidia,model = "tegra-snd-t186ref-mobile-rt565x";
		nvidia,num-codec-link = <11>;
		nvidia,num-clk = <8>;
		nvidia,ldo-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(J, 6) GPIO_ACTIVE_HIGH>;   //reset
		nvidia,hp-det-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(J, 5) GPIO_ACTIVE_HIGH>;
		nvidia,clk-rates = < 270950400	/* PLLA_x11025_RATE */
				     11289600	/* AUD_MCLK_x11025_RATE */
				     45158400	/* PLLA_OUT0_x11025_RATE */
				     45158400	/* AHUB_x11025_RATE */
				     245760000  /* PLLA_x8000_RATE */
				     12288000	/* AUD_MCLK_x8000_RATE */
				     49152000	/* PLLA_OUT0_x8000_RATE */
				     49152000 >;/* AHUB_x8000_RATE */
		clocks = <&tegra_car TEGRA186_CLK_PLLP_OUT0>,
			<&tegra_car TEGRA186_CLK_PLLA>,
			<&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
			<&tegra_car TEGRA186_CLK_AHUB>,
			<&tegra_car TEGRA186_CLK_CLK_M>,
			<&tegra_car TEGRA186_CLK_AUD_MCLK>;
		clock-names = "pll_p_out1", "pll_a", "pll_a_out0", "ahub",
				"clk_m", "extern1";
		resets = <&tegra_car TEGRA186_RESET_AUD_MCLK>;
		reset-names = "extern1_rst";

		status = "okay";
		nvidia,audio-routing =
			"x Headphone",          "x Speaker L Playback",
			"x Headphone",          "x Speaker R Playback",
			"x IN2P",               "x Mic",
			"x IN2N",               "x Mic",
			"y Headphone",		"y OUT",
			"y IN",			"y Mic",
			"z Headphone",		"z OUT",
			"z IN",			"z Mic",
			"m Headphone",		"m OUT",
			"m IN",			"m Mic",
			"n Headphone",		"n OUT",
			"n IN",			"n Mic",
			"o Headphone",		"o OUT",
			"o IN",			"o Mic",
			"a IN",			"a Mic",
			"b IN",			"b Mic",
			"c IN",			"c Mic",
			"d IN",			"d Mic",
			"e Headphone",		"e OUT",
			"e IN",			"e Mic",
			"d1 Headphone",		"d1 OUT",
			"d2 Headphone",		"d2 OUT";

		nvidia,xbar = <&tegra_axbar>;

		rt565x_dai_link: nvidia,dai-link-1 {
			link-name = "rt5640-playback";
			cpu-dai = <&tegra_i2s1>;
			codec-dai = <&rt5640_codec>;
			cpu-dai-name = "I2S1";
			codec-dai-name = "rt5640-aif1";
			format = "i2s";
			bitclock-slave;
			frame-slave;
			bitclock-noninversion;
			frame-noninversion;
			bit-format = "s16_le";
			bclk_ratio = <0>;
			srate = <48000>;
			num-channel = <2>;
			ignore_suspend;
			name-prefix = "x";
			status = "okay";
		};

after i set the
$ amixer -c tegrasndt186ref cset name=“ADMAIF1 Mux” “I2S1”
$ amixer -c tegrasndt186ref cset name=“I2S1 Mux” “ADMAIF1”

and aplay -D hw:tegrasndt186ref,0 test.wav

when I played one .wav file (about 3mins) it will be terminated after 5 seconds.

nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$ amixer -c tegrasndt186ref cset name="I2S1 Mux" "ADMAIF1"
numid=685,iface=MIXER,name='I2S1 Mux'
  ; type=ENUMERATED,access=rw------,values=1,items=83
  ; Item #0 'None'
  ; Item #1 'ADMAIF1'
  ; Item #2 'ADMAIF2'
  ; Item #3 'ADMAIF3'
  ; Item #4 'ADMAIF4'
  ; Item #5 'ADMAIF5'
  ; Item #6 'ADMAIF6'
  ; Item #7 'ADMAIF7'
  ; Item #8 'ADMAIF8'
  ; Item #9 'ADMAIF9'
  ; Item #10 'ADMAIF10'
  ; Item #11 'ADMAIF11'
  ; Item #12 'ADMAIF12'
  ; Item #13 'ADMAIF13'
  ; Item #14 'ADMAIF14'
  ; Item #15 'ADMAIF15'
  ; Item #16 'ADMAIF16'
  ; Item #17 'I2S1'
  ; Item #18 'I2S2'
  ; Item #19 'I2S3'
  ; Item #20 'I2S4'
  ; Item #21 'I2S5'
  ; Item #22 'I2S6'
  ; Item #23 'SFC1'
  ; Item #24 'SFC2'
  ; Item #25 'SFC3'
  ; Item #26 'SFC4'
  ; Item #27 'MIXER1-1'
  ; Item #28 'MIXER1-2'
  ; Item #29 'MIXER1-3'
  ; Item #30 'MIXER1-4'
  ; Item #31 'MIXER1-5'
  ; Item #32 'AMX1'
  ; Item #33 'AMX2'
  ; Item #34 'AMX3'
  ; Item #35 'AMX4'
  ; Item #36 'ARAD1'
  ; Item #37 'SPDIF1-1'
  ; Item #38 'SPDIF1-2'
  ; Item #39 'AFC1'
  ; Item #40 'AFC2'
  ; Item #41 'AFC3'
  ; Item #42 'AFC4'
  ; Item #43 'AFC5'
  ; Item #44 'AFC6'
  ; Item #45 'OPE1'
  ; Item #46 'SPKPROT1'
  ; Item #47 'MVC1'
  ; Item #48 'MVC2'
  ; Item #49 'IQC1-1'
  ; Item #50 'IQC1-2'
  ; Item #51 'IQC2-1'
  ; Item #52 'IQC2-2'
  ; Item #53 'DMIC1'
  ; Item #54 'DMIC2'
  ; Item #55 'DMIC3'
  ; Item #56 'DMIC4'
  ; Item #57 'ADX1-1'
  ; Item #58 'ADX1-2'
  ; Item #59 'ADX1-3'
  ; Item #60 'ADX1-4'
  ; Item #61 'ADX2-1'
  ; Item #62 'ADX2-2'
  ; Item #63 'ADX2-3'
  ; Item #64 'ADX2-4'
  ; Item #65 'ADX3-1'
  ; Item #66 'ADX3-2'
  ; Item #67 'ADX3-3'
  ; Item #68 'ADX3-4'
  ; Item #69 'ADX4-1'
  ; Item #70 'ADX4-2'
  ; Item #71 'ADX4-3'
  ; Item #72 'ADX4-4'
  ; Item #73 'ADMAIF17'
  ; Item #74 'ADMAIF18'
  ; Item #75 'ADMAIF19'
  ; Item #76 'ADMAIF20'
  ; Item #77 'ASRC1-1'
  ; Item #78 'ASRC1-2'
  ; Item #79 'ASRC1-3'
  ; Item #80 'ASRC1-4'
  ; Item #81 'ASRC1-5'
  ; Item #82 'ASRC1-6'
  : values=1
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$ amixer -c tegrasNdt186ef cset name="ADMAIF1 Mux" "I2S1"
numid=675,iface=MIXER,name='ADMAIF1 Mux'
  ; type=ENUMERATED,access=rw------,values=1,items=83
  ; Item #0 'None'
  ; Item #1 'ADMAIF1'
  ; Item #2 'ADMAIF2'
  ; Item #3 'ADMAIF3'
  ; Item #4 'ADMAIF4'
  ; Item #5 'ADMAIF5'
  ; Item #6 'ADMAIF6'
  ; Item #7 'ADMAIF7'
  ; Item #8 'ADMAIF8'
  ; Item #9 'ADMAIF9'
  ; Item #10 'ADMAIF10'
  ; Item #11 'ADMAIF11'
  ; Item #12 'ADMAIF12'
  ; Item #13 'ADMAIF13'
  ; Item #14 'ADMAIF14'
  ; Item #15 'ADMAIF15'
  ; Item #16 'ADMAIF16'
  ; Item #17 'I2S1'
  ; Item #18 'I2S2'
  ; Item #19 'I2S3'
  ; Item #20 'I2S4'
  ; Item #21 'I2S5'
  ; Item #22 'I2S6'
  ; Item #23 'SFC1'
  ; Item #24 'SFC2'
  ; Item #25 'SFC3'
  ; Item #26 'SFC4'
  ; Item #27 'MIXER1-1'
  ; Item #28 'MIXER1-2'
  ; Item #29 'MIXER1-3'
  ; Item #30 'MIXER1-4'
  ; Item #31 'MIXER1-5'
  ; Item #32 'AMX1'
  ; Item #33 'AMX2'
  ; Item #34 'AMX3'
  ; Item #35 'AMX4'
  ; Item #36 'ARAD1'
  ; Item #37 'SPDIF1-1'
  ; Item #38 'SPDIF1-2'
  ; Item #39 'AFC1'
  ; Item #40 'AFC2'
  ; Item #41 'AFC3'
  ; Item #42 'AFC4'
  ; Item #43 'AFC5'
  ; Item #44 'AFC6'
  ; Item #45 'OPE1'
  ; Item #46 'SPKPROT1'
  ; Item #47 'MVC1'
  ; Item #48 'MVC2'
  ; Item #49 'IQC1-1'
  ; Item #50 'IQC1-2'
  ; Item #51 'IQC2-1'
  ; Item #52 'IQC2-2'
  ; Item #53 'DMIC1'
  ; Item #54 'DMIC2'
  ; Item #55 'DMIC3'
  ; Item #56 'DMIC4'
  ; Item #57 'ADX1-1'
  ; Item #58 'ADX1-2'
  ; Item #59 'ADX1-3'
  ; Item #60 'ADX1-4'
  ; Item #61 'ADX2-1'
  ; Item #62 'ADX2-2'
  ; Item #63 'ADX2-3'
  ; Item #64 'ADX2-4'
  ; Item #65 'ADX3-1'
  ; Item #66 'ADX3-2'
  ; Item #67 'ADX3-3'
  ; Item #68 'ADX3-4'
  ; Item #69 'ADX4-1'
  ; Item #70 'ADX4-2'
  ; Item #71 'ADX4-3'
  ; Item #72 'ADX4-4'
  ; Item #73 'ADMAIF17'
  ; Item #74 'ADMAIF18'
  ; Item #75 'ADMAIF19'
  ; Item #76 'ADMAIF20'
  ; Item #77 'ASRC1-1'
  ; Item #78 'ASRC1-2'
  ; Item #79 'ASRC1-3'
  ; Item #80 'ASRC1-4'
  ; Item #81 'ASRC1-5'
  ; Item #82 'ASRC1-6'
  : values=17
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$ aplay -Dhw:tegrasndt186ref,0 test.wav
Playing WAVE 'test.wav' : Signed 1[ 1387.614333] test!!test[tegra_t186ref_dai_init][328]
6 bit Little Endian, Rate 44100 Hz, Stereo
nvidia@tegra-ubuntu:~$

Hello!

This is a common problem where audio terminates in a few seconds despite that the audio clip is actually minutes in length. However, this indicates that the audio path is not configured correctly. Per comment #4, I mentioned that …

“Then there are most likely some mixer controls that you need to set for the codec (see rt5640_snd_controls in the rt5640 driver). You can configure these using the ‘amixer’ tool similar to the above to set these. Each codec is a bit different here and so it is best to look for an example for how to set the mixer controls.”

You need to now check that the codec is configured correctly as there maybe some mixer controls for the codec that need to be configured. This part can be a bit more difficult as it varies from codec to codec. However, fortunately it appears that the rt5640 was used on the Google Nexus 7 and there are some configuration files for it that show how to configure the codec. See …

https://www.apt-browse.org/browse/ubuntu/trusty/main/all/libasound2-data/1.0.27.2-3ubuntu7/file/usr/share/alsa/ucm/tegra-rt5640

Please note that the Nexus 7 appears to be using the Headphone outputs and not the LineOut. However, it should be a good pointer.

Regards,
Jon

Hi jonathanh

how do i know how many audio routing need to set?

Any method to check audio path and check routing map?

could i followed this suggestion
https://devtalk.nvidia.com/default/topic/985516/jetson-tx1/acl5639-audio-codec-on-tx1/post/5049189/#5049189

Hi Elma,

This is where you need to review the codec documentation along with the driver and understand how it needs to be configured.

One suggestion is to trace the dapm widget power events to see if the I2S is even turning on …

https://devtalk.nvidia.com/default/topic/1027508/jetson-tx2/tlv320aic32x4-evaluation-board-with-tx2/post/5244828/#5244828

I also created a script which you can run and dump various debug information to help track down where the problem might be …

https://devtalk.nvidia.com/default/topic/1027508/jetson-tx2/tlv320aic32x4-evaluation-board-with-tx2/post/5244039/#5244039

Regards,
Jon

Hi jonathanh

i see the tlv320aic32x4 this topic.
Audio routing is interest but is difficult.

i use the setting and debug
$ amixer -c tegrasndt186ref cset name=“ADMAIF1 Mux” “I2S1”
$ amixer -c tegrasndt186ref cset name=“I2S1 Mux” “ADMAIF1”

sudo ls -l /sys/kernel/debug/asoc/tegra-snd-t186ref-mobile-rt565x/dapm/
[sudo] password for nvidia:
total 0
-r--r--r-- 1 root root 0 Jan  1  1970 a Capture-DMIC1 DMIC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF10 CIF Receive-ADMAIF10 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF10 FIFO Receive-ADSP-ADMAIF10 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF10 Transmit-ADMAIF10 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF11 CIF Receive-ADMAIF11 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF11 FIFO Receive-ADSP-ADMAIF11 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF11 Transmit-ADMAIF11 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF12 CIF Receive-ADMAIF12 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF12 FIFO Receive-ADSP-ADMAIF12 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF12 Transmit-ADMAIF12 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF13 CIF Receive-ADMAIF13 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF13 FIFO Receive-ADSP-ADMAIF13 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF13 Transmit-ADMAIF13 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF14 CIF Receive-ADMAIF14 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF14 FIFO Receive-ADSP-ADMAIF14 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF14 Transmit-ADMAIF14 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF15 CIF Receive-ADMAIF15 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF15 FIFO Receive-ADSP-ADMAIF15 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF15 Transmit-ADMAIF15 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF16 CIF Receive-ADMAIF16 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF16 FIFO Receive-ADSP-ADMAIF16 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF16 Transmit-ADMAIF16 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF17 CIF Receive-ADMAIF17 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF17 FIFO Receive-ADSP-ADMAIF17 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF17 Transmit-ADMAIF17 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF18 CIF Receive-ADMAIF18 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF18 FIFO Receive-ADSP-ADMAIF18 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF18 Transmit-ADMAIF18 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF19 CIF Receive-ADMAIF19 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF19 FIFO Receive-ADSP-ADMAIF19 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF19 Transmit-ADMAIF19 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF1 CIF Receive-ADMAIF1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF1 FIFO Receive-ADSP-ADMAIF1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF1 Transmit-ADMAIF1 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF20 CIF Receive-ADMAIF20 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF20 FIFO Receive-ADSP-ADMAIF20 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF20 Transmit-ADMAIF20 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF2 CIF Receive-ADMAIF2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF2 FIFO Receive-ADSP-ADMAIF2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF2 Transmit-ADMAIF2 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF3 CIF Receive-ADMAIF3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF3 FIFO Receive-ADSP-ADMAIF3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF3 Transmit-ADMAIF3 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF4 CIF Receive-ADMAIF4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF4 FIFO Receive-ADSP-ADMAIF4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF4 Transmit-ADMAIF4 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF5 CIF Receive-ADMAIF5 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF5 FIFO Receive-ADSP-ADMAIF5 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF5 Transmit-ADMAIF5 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF6 CIF Receive-ADMAIF6 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF6 FIFO Receive-ADSP-ADMAIF6 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF6 Transmit-ADMAIF6 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF7 CIF Receive-ADMAIF7 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF7 FIFO Receive-ADSP-ADMAIF7 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF7 Transmit-ADMAIF7 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF8 CIF Receive-ADMAIF8 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF8 FIFO Receive-ADSP-ADMAIF8 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF8 Transmit-ADMAIF8 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF9 CIF Receive-ADMAIF9 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF9 FIFO Receive-ADSP-ADMAIF9 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADMAIF9 Transmit-ADMAIF9 CIF Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF10 Transmit-ADMAIF10 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF11 Transmit-ADMAIF11 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF12 Transmit-ADMAIF12 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF13 Transmit-ADMAIF13 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF14 Transmit-ADMAIF14 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF15 Transmit-ADMAIF15 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF16 Transmit-ADMAIF16 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF17 Transmit-ADMAIF17 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF18 Transmit-ADMAIF18 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF19 Transmit-ADMAIF19 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF1 Transmit-ADMAIF1 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF20 Transmit-ADMAIF20 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF2 Transmit-ADMAIF2 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF3 Transmit-ADMAIF3 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF4 Transmit-ADMAIF4 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF5 Transmit-ADMAIF5 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF6 Transmit-ADMAIF6 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF7 Transmit-ADMAIF7 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF8 Transmit-ADMAIF8 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADSP-ADMAIF9 Transmit-ADMAIF9 FIFO Transmit
-r--r--r-- 1 root root 0 Jan  1  1970 ADX1 OUT1 Transmit-ADX1-1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX1 OUT2 Transmit-ADX1-2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX1 OUT3 Transmit-ADX1-3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX1 OUT4 Transmit-ADX1-4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX1 Transmit-ADX1 IN Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX2 OUT1 Transmit-ADX2-1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX2 OUT2 Transmit-ADX2-2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX2 OUT3 Transmit-ADX2-3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX2 OUT4 Transmit-ADX2-4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX2 Transmit-ADX2 IN Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX3 OUT1 Transmit-ADX3-1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX3 OUT2 Transmit-ADX3-2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX3 OUT3 Transmit-ADX3-3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX3 OUT4 Transmit-ADX3-4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX3 Transmit-ADX3 IN Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX4 OUT1 Transmit-ADX4-1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX4 OUT2 Transmit-ADX4-2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX4 OUT3 Transmit-ADX4-3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX4 OUT4 Transmit-ADX4-4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ADX4 Transmit-ADX4 IN Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC1 AFC Transmit-AFC1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC1 Transmit-AFC1 AFC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC2 AFC Transmit-AFC2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC2 Transmit-AFC2 AFC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC3 AFC Transmit-AFC3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC3 Transmit-AFC3 AFC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC4 AFC Transmit-AFC4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC4 Transmit-AFC4 AFC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC5 AFC Transmit-AFC5 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC5 Transmit-AFC5 AFC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC6 AFC Transmit-AFC6 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AFC6 Transmit-AFC6 AFC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 a Mic
-r--r--r-- 1 root root 0 Jan  1  1970 AMX1-1 Transmit-AMX1 IN1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX1-2 Transmit-AMX1 IN2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX1-3 Transmit-AMX1 IN3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX1-4 Transmit-AMX1 IN4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX1 OUT Transmit-AMX1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX2-1 Transmit-AMX2 IN1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX2-2 Transmit-AMX2 IN2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX2-3 Transmit-AMX2 IN3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX2-4 Transmit-AMX2 IN4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX2 OUT Transmit-AMX2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX3-1 Transmit-AMX3 IN1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX3-2 Transmit-AMX3 IN2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX3-3 Transmit-AMX3 IN3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX3-4 Transmit-AMX3 IN4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX3 OUT Transmit-AMX3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX4-1 Transmit-AMX4 IN1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX4-2 Transmit-AMX4 IN2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX4-3 Transmit-AMX4 IN3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX4-4 Transmit-AMX4 IN4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 AMX4 OUT Transmit-AMX4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1-1 Transmit-ASRC1 RX1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1-2 Transmit-ASRC1 RX2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1-3 Transmit-ASRC1 RX3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1-4 Transmit-ASRC1 RX4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1-5 Transmit-ASRC1 RX5 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1-6 Transmit-ASRC1 RX6 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1-7 Transmit-ASRC1 RX7 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1 TX1 Transmit-ASRC1-1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1 TX2 Transmit-ASRC1-2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1 TX3 Transmit-ASRC1-3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1 TX4 Transmit-ASRC1-4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1 TX5 Transmit-ASRC1-5 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 ASRC1 TX6 Transmit-ASRC1-6 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 b Capture-DMIC2 DMIC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 bias_level
-r--r--r-- 1 root root 0 Jan  1  1970 b Mic
-r--r--r-- 1 root root 0 Jan  1  1970 c Capture-DMIC3 DMIC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 c Mic
-r--r--r-- 1 root root 0 Jan  1  1970 d1 Headphone
-r--r--r-- 1 root root 0 Jan  1  1970 d2 Headphone
-r--r--r-- 1 root root 0 Jan  1  1970 d Capture-DMIC4 DMIC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 d Mic
-r--r--r-- 1 root root 0 Jan  1  1970 DMIC1 DMIC Transmit-DMIC1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 DMIC2 DMIC Transmit-DMIC2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 DMIC3 DMIC Transmit-DMIC3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 DMIC4 DMIC Transmit-DMIC4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 e Capture-SPDIF DAP Receive
-r--r--r-- 1 root root 0 Jan  1  1970 e Headphone
-r--r--r-- 1 root root 0 Jan  1  1970 e Mic
-r--r--r-- 1 root root 0 Jan  1  1970 I2S1 CIF Transmit-I2S1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 I2S1 DAP Transmit-x AIF1 Playback
-r--r--r-- 1 root root 0 Jan  1  1970 I2S1 Transmit-I2S1 CIF Receive
-r--r--r-- 1 root root 0 Jan  1  1970 I2S2 CIF Transmit-I2S2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 I2S2 DAP Transmit-y Playback
-r--r--r-- 1 root root 0 Jan  1  1970 I2S2 Transmit-I2S2 CIF Receive
-r--r--r-- 1 root root 0 Jan  1  1970 I2S3 CIF Transmit-I2S3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 I2S3 DAP Transmit-z Playback
-r--r--r-- 1 root root 0 Jan  1  1970 I2S3 Transmit-I2S3 CIF Receive
-r--r--r-- 1 root root 0 Jan  1  1970 I2S4 CIF Transmit-I2S4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 I2S4 DAP Transmit-m Playback
-r--r--r-- 1 root root 0 Jan  1  1970 I2S4 Transmit-I2S4 CIF Receive
-r--r--r-- 1 root root 0 Jan  1  1970 I2S5 CIF Transmit-I2S5 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 I2S5 DAP Transmit-n Playback
-r--r--r-- 1 root root 0 Jan  1  1970 I2S5 Transmit-I2S5 CIF Receive
-r--r--r-- 1 root root 0 Jan  1  1970 I2S6 CIF Transmit-I2S6 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 I2S6 DAP Transmit-o Playback
-r--r--r-- 1 root root 0 Jan  1  1970 I2S6 Transmit-I2S6 CIF Receive
-r--r--r-- 1 root root 0 Jan  1  1970 Int Mic
-r--r--r-- 1 root root 0 Jan  1  1970 m Capture-I2S4 DAP Receive
-r--r--r-- 1 root root 0 Jan  1  1970 m Headphone
-r--r--r-- 1 root root 0 Jan  1  1970 MIXER1-10 Transmit-RX10 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MIXER1-1 Transmit-RX1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MIXER1-2 Transmit-RX2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MIXER1-3 Transmit-RX3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MIXER1-4 Transmit-RX4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MIXER1-5 Transmit-RX5 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MIXER1-6 Transmit-RX6 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MIXER1-7 Transmit-RX7 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MIXER1-8 Transmit-RX8 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MIXER1-9 Transmit-RX9 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 m Mic
-r--r--r-- 1 root root 0 Jan  1  1970 MVC1 MVC Transmit-MVC1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MVC1 Transmit-MVC1 MVC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MVC2 MVC Transmit-MVC2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 MVC2 Transmit-MVC2 MVC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 n Capture-I2S5 DAP Receive
-r--r--r-- 1 root root 0 Jan  1  1970 n Headphone
-r--r--r-- 1 root root 0 Jan  1  1970 n Mic
-r--r--r-- 1 root root 0 Jan  1  1970 o Capture-I2S6 DAP Receive
-r--r--r-- 1 root root 0 Jan  1  1970 o Headphone
-r--r--r-- 1 root root 0 Jan  1  1970 o Mic
-r--r--r-- 1 root root 0 Jan  1  1970 OPE1 OPE Transmit-OPE1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 OPE1 Transmit-OPE1 OPE Receive
-r--r--r-- 1 root root 0 Jan  1  1970 SFC1 SFC Transmit-SFC1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 SFC1 Transmit-SFC1 SFC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 SFC2 SFC Transmit-SFC2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 SFC2 Transmit-SFC2 SFC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 SFC3 SFC Transmit-SFC3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 SFC3 Transmit-SFC3 SFC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 SFC4 SFC Transmit-SFC4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 SFC4 Transmit-SFC4 SFC Receive
-r--r--r-- 1 root root 0 Jan  1  1970 SPDIF1-1 Transmit-SPDIF CIF Receive
-r--r--r-- 1 root root 0 Jan  1  1970 SPDIF CIF Transmit-SPDIF1-1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 SPDIF DAP Transmit-e Playback
-r--r--r-- 1 root root 0 Jan  1  1970 TX1 Transmit-MIXER1-1 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 TX2 Transmit-MIXER1-2 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 TX3 Transmit-MIXER1-3 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 TX4 Transmit-MIXER1-4 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 TX5 Transmit-MIXER1-5 Receive
-r--r--r-- 1 root root 0 Jan  1  1970 x AIF1 Capture-I2S1 DAP Receive
-r--r--r-- 1 root root 0 Jan  1  1970 x Headphone
-r--r--r-- 1 root root 0 Jan  1  1970 x Headphone Jack
-r--r--r-- 1 root root 0 Jan  1  1970 x Int Mic
-r--r--r-- 1 root root 0 Jan  1  1970 x Int Spk
-r--r--r-- 1 root root 0 Jan  1  1970 x Mic
-r--r--r-- 1 root root 0 Jan  1  1970 x Mic Jack
-r--r--r-- 1 root root 0 Jan  1  1970 y Capture-I2S2 DAP Receive
-r--r--r-- 1 root root 0 Jan  1  1970 y Headphone
-r--r--r-- 1 root root 0 Jan  1  1970 y Mic
-r--r--r-- 1 root root 0 Jan  1  1970 z Capture-I2S3 DAP Receive
-r--r--r-- 1 root root 0 Jan  1  1970 z Headphone
-r--r--r-- 1 root root 0 Jan  1  1970 z Mic
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$ cat /etc/lixer_settings
#!/bin/bash

# Reset controls
amixer cset -c tegrasndt186ref name="ADMAIF1 Mux" 'I2S1'
amixer cset -c tegrasndt186ref name="x Int Spk Switch" 0
amixer cset -c tegrasndt186ref name="x Int Mic Switch" 0
amixer cset -c tegrasndt186ref name="x Headphone Jack Switch" 0
amixer cset -c tegrasndt186ref name="x Mic Jack Switch" 0
amixer cset -c tegrasndt186ref name="x Stereo DAC MIXR DAC L1 Switch" 0
amixer cset -c tegrasndt186ref name="x Stereo DAC MIXR DAC R1 Switch" 0
amixer cset -c tegrasndt186ref name="x Stereo DAC MIXL DAC L1 Switch" 0
amixer cset -c tegrasndt186ref name="x Stereo DAC MIXL DAC R1 Switch" 0
amixer cset -c tegrasndt186ref name="x HPO R Playback Switch" 0
amixer cset -c tegrasndt186ref name="x HPO L Playback Switch" 0
amixer cset -c tegrasndt186ref name="x HP Playback Volume" 31
amixer cset -c tegrasndt186ref name="x Speaker Playback Volume" 32

amixer cset -c tegrasndt186ref name="x RECMIX1L BST1 Switch" 0
amixer cset -c tegrasndt186ref name="x RECMIX1R BST1 Switch" 0
amixer cset -c tegrasndt186ref name="x Stereo1 ADC Source" 0
amixer cset -c tegrasndt186ref name="x Stereo1 ADC1 Source" 0
amixer cset -c tegrasndt186ref name="x Stereo1 ADC MIXL ADC1 Switch" 0
amixer cset -c tegrasndt186ref name="x Stereo1 ADC MIXR ADC1 Switch" 0
amixer cset -c tegrasndt186ref name="x TDM Data Mux" 'AD1:AD2:DAC:NUL'

# To get audio working on headset using following mixer controls
amixer cset -c tegrasndt186ref name="I2S1 Mux" 'ADMAIF1'
amixer cset -c tegrasndt186ref name="x HPO R Playback Switch" 1
amixer cset -c tegrasndt186ref name="x HPO L Playback Switch" 1
amixer cset -c tegrasndt186ref name="x Headphone Jack Switch" 1
amixer cset -c tegrasndt186ref name="x Stereo DAC MIXR DAC R1 Switch" 1
amixer cset -c tegrasndt186ref name="x Stereo DAC MIXL DAC L1 Switch" 1
amixer cset -c tegrasndt186ref name="x Headphone Playback Volume" 31
amixer cset -c tegrasndt186ref name="x DAC1 Playback Volume" 175
amixer cset -c tegrasndt186ref name="x DAC1 Playback Switch" 1
amixer cset -c tegrasndt186ref name="x DAC1 MIXR DAC1 Switch" 1
amixer cset -c tegrasndt186ref name="x DAC1 MIXL DAC1 Switch" 1

# To capture audio using headset mic, use following controls
amixer cset -c tegrasndt186ref name="ADMAIF1 Mux" "I2S1"
amixer cset -c tegrasndt186ref name="x RECMIX1L BST1 Switch" 1
amixer cset -c tegrasndt186ref name="x RECMIX1R BST1 Switch" 1
amixer cset -c tegrasndt186ref name="x Stereo1 ADC Source" "ADC1"
amixer cset -c tegrasndt186ref name="x Stereo1 ADC1 Source" "ADC"
amixer cset -c tegrasndt186ref name="x Stereo1 ADC MIXL ADC1 Switch" 1
amixer cset -c tegrasndt186ref name="x Stereo1 ADC MIXR ADC1 Switch" 1
amixer cset -c tegrasndt186ref name="x TDM Data Mux" "AD1:AD2:DAC:NUL"
amixer cset -c tegrasndt186ref name="x IN1 Boost Volume" 43
amixer cset -c tegrasndt186ref name="x Mic Jack Switch" 1
nvidia@tegra-ubuntu:~$
echo 0 > /sys/kernel/debug/tracing/trace
echo 0 > /sys/kernel/debug/tracing/events/enable

echo 1 > /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_path/enable
echo 1 > /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_start/enable
echo 1 > /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_walk_done/enable
echo 1 > /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_widget_power/enable

root@tegra-ubuntu:~#
root@tegra-ubuntu:aplay -D hw:1,0 /home/nvidia/test.wav
Playing WAVE '/home/nvidia/test.wav' : S[  312.113520] test!!test[tegra_t186ref_dai_init][328]
igned 16 bit Little Endian, Rate 44100 Hz, Stereo
root@tegra-ubuntu:~#
root@tegra-ubuntu:~#
root@tegra-ubuntu:~# cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 6/6   #P:4
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
           aplay-2656  [000] ...1   312.122171: snd_soc_dapm_start: card=tegra-snd-t186ref-mobile-rt565x
           aplay-2656  [000] ...1   312.122443: snd_soc_dapm_walk_done: tegra-snd-t186ref-mobile-rt565x: checks 2 power, 2 path, 0 neighbour
           aplay-2656  [004] ...1   319.468701: snd_soc_dapm_start: card=tegra-snd-t186ref-mobile-rt565x
           aplay-2656  [004] ...1   319.468902: snd_soc_dapm_path: *ADMAIF1 Receive <- (direct) <- Playback 1
           aplay-2656  [004] ...1   319.468907: snd_soc_dapm_path: *ADMAIF1 Receive <- (direct) <- ADMAIF1 CIF Receive-ADMAIF1 Receive
           aplay-2656  [004] ...1   319.469117: snd_soc_dapm_walk_done: tegra-snd-t186ref-mobile-rt565x: checks 2 power, 2 path, 2 neighbour
root@tegra-ubuntu:~#

and i run your tegra-audio-debug.sh script
https://drive.google.com/file/d/1w2fISQ5rJqblW7-lW-WQBASXZugpde8r/view?usp=sharing

do you have any suggestion?

RHi Elma,

Looking at this some more, because you are using the line out and not speaker, the routing I stated in comment #4 is incorrect and should be …

nvidia,audio-routing =
			"x Headphone",          "x LOUTL",
			"x Headphone",          "x LOUTR",
			"x IN2P",               "x Mic",
			"x IN2N",               "x Mic",

Then can you trying enabling the following …

amixer -c tegrasndt186ref cset name="x LOUT MIX DAC L1 Switch" 1
amixer -c tegrasndt186ref cset name="x LOUT MIX DAC R1 Switch" 1
amixer -c tegrasndt186ref cset name="x LOUT MIX OUTVOL L Switch" 1
amixer -c tegrasndt186ref cset name="x LOUT MIX OUTVOL R Switch" 1
amixer -c tegrasndt186ref cset name="x Stereo DAC MIXL DAC L1 Switch" 1
amixer -c tegrasndt186ref cset name="x Stereo DAC MIXR DAC R1 Switch" 1
amixer -c tegrasndt186ref cset name="x DAC MIXL INF1 Switch" 1
amixer -c tegrasndt186ref cset name="x DAC MIXR INF1 Switch" 1

I assume that you are using I2S1 interface on the codec as it appears that there are two I2S interfaces.

Regards,
Jon

Hi jonathanh

thanks for your setting.

i can hear the music from headset jack.
but the voice have some noise.
how to improve it ?

how to arecord the voice?
when i use arecord command and after 10 minutes console message will show
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$ arecord -D hw:1,0 -r 48000 -f S32_LE -c 2 -d 10 cap.wav
Recording WAVE ‘cap.wav’ : Signed 32 bit Little Endian, Rate 48000 Hz, Stereo
arecord: pcm_read:2032: read error: Input/output error
nvidia@tegra-ubuntu:~$

how to fix it??

Hi jonathanh

the noise is clock issue??

i modify the tegra_t186ref_dai_init function, but music still have noise.

Hi Elma,

With regard to noise, this could be one of several things, for example, clocking, power, etc.

From a Tegra perspective, you should verify that the mclk frequency and I2S frame format aligns with what the codec requires. If it does, then the I2S should be fine and you should focus on the codec side to investigate what the problem might be. To do that you may need to work with the codec vendor.

Regards,
Jon

Hi jonathanh

thanks your reply.

the noise issue i will check datasheet and connect the vendor.

how about “arecord -D hw:1,0 -r 48000 -f S32_LE -c 2 -d 10 cap.wav” issue

how to fix it?
is this a routing path issue or HW issue?

Hi jonathanh

when i play the music i can see the J21 Pin40(Dout) have Signal
but if i set “how about “arecord -D hw:1,0 -r 48000 -f S32_LE -c 2 -d 10 cap.wav” issue”

i can’t see the Signal from J21 Pin38(Din) , and the console will show
Recording WAVE ‘cap.wav’ : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
arecord: pcm_read:2032: read error: Input/output error

how did i debug it??

could you give some suggestion??

Hi Elma,

In comment #10, I referenced the IN2 inputs, however, I wanted to check if you are using the IN1 or IN2 inputs?

If it is IN2, then you you try setting …

amixer -c tegrasndt186ref cset name="x RECMIXR BST2 Switch" 1
amixer -c tegrasndt186ref cset name="x RECMIXL BST2 Switch" 1
amixer -c tegrasndt186ref cset name="Stereo ADC MIXR ADC1 Switch" 1
amixer -c tegrasndt186ref cset name="Stereo ADC MIXL ADC1 Switch" 1

Regards,
Jon

Hi jonathanh

i am so sorry for missing your problem.

i use IN1 to be microphone in.

in comment #10 maybe i need to modify

nvidia,audio-routing =
			"x Headphone",          "x LOUTL",
			"x Headphone",          "x LOUTR",
-			"x IN2P",               "x Mic",
-			"x IN2N",               "x Mic",
+			"x IN1P",               "x Mic",
+			"x IN1N",               "x Mic",

and how to set the amixer command?

one more question, i can’t get “Stereo ADC MIXR ADC1 Switch” “Stereo ADC MIXL ADC1 Switch” element

nvidia@tegra-ubuntu:~$ amixer -c tegrasndt186ref cset name="Stereo ADC MIXL ADC1 Switch" 1
amixer: Cannot find the given element from control hw:1

nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$ amixer -c tegrasndt186ref cget name="Stereo ADC MIXR ADC1 Switch"
amixer: Cannot find the given element from control hw:1

nvidia@tegra-ubuntu:~$

if you need any information or message please tell me.

Hi Elma,

Sorry, looks like I missed the ‘x’ prefix on those. If you are using IN1 can you try …

amixer -c tegrasndt186ref cset name="x RECMIXR BST1 Switch" 1
amixer -c tegrasndt186ref cset name="x RECMIXL BST1 Switch" 1
amixer -c tegrasndt186ref cset name="x Stereo ADC MIXR ADC1 Switch" 1
amixer -c tegrasndt186ref cset name="x Stereo ADC MIXL ADC1 Switch" 1

Regards,
Jon

Hi Jon

thanks for your reply.

i use your command to test microphone, it’s still no signal from pin 38.
but the arecord will be terminated immediately and have error message.

nvidia@tegra-ubuntu:~$
nvidia@tegra-ubuntu:~$ arecord -D hw:1,0 -r 4800 -f S32_LE -c 2 -d 10 cap.wav
Recording WAVE 'cap.wav' : Signed 32 bit Little Endian, Rate 48000 Hz, Stereo
[  235.566909] test!!test[tegra_t186ref_dai_init][354]
[  235.588237] test[rt5640_hw_params][1727]
[  235.592246] rt5640 1-001c: ASoC: can't set rt5640-aif1 hw params: -22
[  235.598719] tegra-snd-t186ref-mobile-rt565x sound: ASoC: PRE_PMU: x AIF1 Capture-I2S1 DAP Receive event failed: -22
nvidia@tegra-ubuntu:~$

the attached file is console log and debug log.

5640-log.txt (71.7 KB)
tegra-audio-debug0530.txt (737 KB)

Hi Elma,

The above error is caused because the codec does not support 32-bit sample sizes. Please try 16-bit.

Jon