Ti TLV320AIC3101 cannot capture and play sound

Hello everybody,
I designed a board used aic31 and I2S0.I used a driver (not alsa structure) test the hardware is ok.Then I want to use the alsa structure code tlv320aic3x.c in kenerl.I changed the tegra186-quill-common.dtsi as follows
nvidia,audio-routing =
“z LINE2L”, “z IN”,
“z LINE2R”, “z IN”,
“z HPLOUT”, “z OUT”,
“z HPROUT”, “z OUT”
/* “x Headphone”, “x OUT”,
“x IN”, “x Mic”,
“y Headphone”, “y OUT”,
“y IN”, “y Mic”,
“z IN”, “z OUT”,
“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 = "rt565x-playback";
		cpu-dai = <&tegra_i2s1>;
		codec-dai = <&spdif_dit0>;
		cpu-dai-name = "I2S1";
		codec-dai-name = "dit-hifi";
		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";
	};

I chaned the tegra_t186ref_mobile_rt565x.c as follws
SND_SOC_DAPM_LINE( “z IN”, NULL),
SND_SOC_DAPM_LINE( “z OUT”, NULL),SND_SOC_DAPM_LINE( “z IN”, NULL),
SND_SOC_DAPM_LINE( “z OUT”, NULL),
idx = tegra_machine_get_codec_dai_link_idx_t18x(“ti-capture”);
/* 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);*/
		err = snd_soc_dai_set_sysclk(card->rtd[idx].codec_dai, 0, 12000000, SND_SOC_CLOCK_IN);
		if (err < 0) {
			dev_err(card->dev, "codec_dai clock not set clk_out_rate-%d\n", clk_out_rate);
			return err;
		}
	}
}

I think the changes is ok.The boot log as follows
[09:14:16][ 2.827688] ****AIC31------aic3x_add_widgets
[09:14:16][ 2.832613] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF1 <-> ADMAIF1 mapping ok
[09:14:16][ 2.832681] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF2 <-> ADMAIF2 mapping ok
[09:14:16][ 2.832785] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF3 <-> ADMAIF3 mapping ok
[09:14:16][ 2.832848] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF4 <-> ADMAIF4 mapping ok
[09:14:16][ 2.832918] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF5 <-> ADMAIF5 mapping ok
[09:14:16][ 2.832989] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF6 <-> ADMAIF6 mapping ok
[09:14:16][ 2.833059] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF7 <-> ADMAIF7 mapping ok
[09:14:16][ 2.833152] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF8 <-> ADMAIF8 mapping ok
[09:14:16][ 2.833223] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF9 <-> ADMAIF9 mapping ok
[09:14:16][ 2.833293] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF10 <-> ADMAIF10 mapping ok
[09:14:16][ 2.833361] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF11 <-> ADMAIF11 mapping ok
[09:14:16][ 2.833442] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF12 <-> ADMAIF12 mapping ok
[09:14:16][ 2.833517] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF13 <-> ADMAIF13 mapping ok
[09:14:16][ 2.833588] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF14 <-> ADMAIF14 mapping ok
[09:14:16][ 2.833655] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF15 <-> ADMAIF15 mapping ok
[09:14:16][ 2.833728] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF16 <-> ADMAIF16 mapping ok
[09:14:16][ 2.833815] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF17 <-> ADMAIF17 mapping ok
[09:14:16][ 2.833881] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF18 <-> ADMAIF18 mapping ok
[09:14:16][ 2.833950] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF19 <-> ADMAIF19 mapping ok
[09:14:16][ 2.834020] tegra-snd-t186ref-mobile-rt565x sound: ADMAIF20 <-> ADMAIF20 mapping ok
[09:14:16][ 2.837117] tegra-snd-t186ref-mobile-rt565x sound: ADSP-FE1 <-> ADSP PCM1 mapping ok
[09:14:16][ 2.837206] tegra-snd-t186ref-mobile-rt565x sound: ADSP-FE2 <-> ADSP PCM2 mapping ok
[09:14:16][ 2.837232] compress asoc: ADSP-FE3 <-> ADSP COMPR1 mapping ok
[09:14:16][ 2.837253] compress asoc: ADSP-FE4 <-> ADSP COMPR2 mapping ok
[09:14:16][ 2.840883] mmc1: queuing unknown CIS tuple 0x80 (5 bytes)
[09:14:16][ 2.877680] input: tegra-snd-t186ref-mobile-rt565x Headphone Jack as /devices/sound/sound/card1/input2
[09:14:16][ 2.878450] ****codec-dai “tlv320aic3x-hifi” registered

I enter the following command,it cannot capture sound,but no error reported.I don’t know how to eliminate the problem,thank you!
amixer -c tegrasndt186ref sset ‘ADMAIF1 Mux’ ‘I2S1’
amixer -c tegrasndt186ref sset ‘I2S1 Mux’ ‘ADMAIF1’
amixer -c tegrasndt186ref cset name=‘z Left PGA Mixer Line2L Switch’ 1
amixer -c tegrasndt186ref cset name=‘z Right PGA Mixer Line2R Switch’ 1
amixer -c tegrasndt186ref cset name=‘z Left HP Mixer Line2L Bypass Switch’ 1
amixer -c tegrasndt186ref cset name=‘z Right HP Mixer Line2L Bypass Switch’ 1
gst-launch-1.0 -v alsasrc ! “audio/x-raw,format=S16LE,layout=(string)interleaved,rate=(int)44100,channels=(int)2” ! queue ! audioconvert ! autoaudiosink

tegra186-quill-common.dtsi.txt (35.9 KB)
tegra_t186ref_mobile_rt565x.c (33.1 KB)

Hello everybody,
Today I find the SCLK and LRCLK is no clock.Before I changed these files the clock is ok.I am confused.

Hello!

So there are a few things you need to look at here …

  1. MCLK
    In the above you are telling the codec that the MCLK is 12MHz. Is this MCLK provided by an external oscillator or Tegra? If it is provided by the Tegra ‘aud_mclk’ then this clock needs to be configured to operate at 12MHz. If it is an external oscillator connected to the codec, then there is no more to be done here.

  2. Device-tree configuration
    The above device-tree snippet has (although it is unclear if this commented out) …

rt565x_dai_link: nvidia,dai-link-1 {
        link-name = "rt565x-playback";
        cpu-dai = <&tegra_i2s1>;
        codec-dai = <&spdif_dit0>;
        cpu-dai-name = "I2S1";
        codec-dai-name = "dit-hifi";
        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";
};

There are a couple items here …

i). The ‘codec_dai’ and ‘codec_dai_name’ need to be updated to reference the codec you are using. For example see …

https://devtalk.nvidia.com/default/topic/1036828/jetson-tx2/sound-card-transplantation/post/5268266/#5268266

ii). In device-tree you are configuring the codec as the SCLK/LRCK slave. If the codec is being provided a 12MHz external clock, then this implies that you are using the codec’s internal PLL to generate the audio clocks. In this case, the codec should be the SCLK/LRCK master and not slave you should update the device-tree to have the following for the appropriate dai-link …

bitclock-master;
        frame-master;

iii). Have you updated the ‘nvidia,audio-routing’? If not you need to update. For example …
https://devtalk.nvidia.com/default/topic/1036828/jetson-tx2/sound-card-transplantation/post/5268809/#5268809

3). Codec configuration
The final thing that trips people up is configuring the codec. For a similar TI codec we did the following to get the line-out working …
https://devtalk.nvidia.com/default/topic/1036828/jetson-tx2/sound-card-transplantation/post/5269448/#5269448

Hope this helps.
Jon

Hi jonathanh,
Thank you.I read the link,my problem is different.When I change file to #1, SCLK and LRCLK is no clock.Now I have changed all files back.I plan to not use another way.I write a driver just to configure register not use ALSA,it seems easier to me.