Porting 2 ALC5640 codec to nano

Hi,
I’m working on porting alc5640 codec to nano and the L4T version is R32.7.3.
We have two codec chips, one for line-in reception and one for line-out playback, connected via I2S4 and I2S3 respectively. I referred to the steps in this website
https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3273/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/asoc_driver.19.2.html#wwpID0E0QX0HA
and the content under this topic for porting and modification.

However, there are still the following issues:

  1. Our two codec chips, one for input only and one for output only, are configured correctly in the device tree for audio routing and dai-link.
		nvidia,audio-routing =
			"x Headphone", "x HPOR",
			"x Headphone", "x HPOL",
			"x IN2P"     , "x Mic",
			"x IN2N"     , "x Mic",
			"y Headphone", "y LOUTL",
			"y Headphone", "y LOUTR",
			"y Headphone Jack", "y HPOR",
			"y Headphone Jack", "y HPOL",


		nvidia,xbar = <&tegra_axbar>;
		mclk-fs = <256>;

		/*audio input*/
		hdr40_snd_link_i2s: i2s_dai_link1: nvidia,dai-link-1 {
			link-name = "rt5640-playback";
			cpu-dai = <&tegra_i2s4>;
			codec-dai = <&rt5640_in>;
			cpu-dai-name = "I2S4";
			codec-dai-name = "rt5640-aif1";
			format = "i2s";
			bitclock-slave;
			frame-slave;
			bitclock-noninversion;
			frame-noninversion;
			bit-format = "s16_le";
			srate = <48000>;
			num-channel = <2>;
			ignore_suspend;
			name-prefix = "x";
			status = "okay";
		};

		/*audio output*/
		nvidia,dai-link-2 {
			link-name = "rt5640-playback";
			cpu-dai = <&tegra_i2s3>;
			codec-dai = <&rt5640_out>;
			cpu-dai-name = "I2S3";
			codec-dai-name = "rt5640-aif1";
			format = "i2s";
			bitclock-slave;
			frame-slave;
			bitclock-noninversion;
			frame-noninversion;
			bit-format = "s16_le";
			srate = <48000>;
			num-channel = <2>;
			ignore_suspend;
			name-prefix = "y";
			status = "okay";
		};
  1. The guidance document states that the machine driver needs to be updated to adapt to the codec chips. So, do these two chips share the same adaptation, or do they need to be adapted separately?
    For example, in the example in the post, only one codec is used, so the link-name property is rt5640-playback. If I update the machine driver with this property, can both of my codec chips use the same link-name, or do they need to be separated?
	/*for alc5640*/
	rtd = snd_soc_get_pcm_runtime(card, "rt5640-playback");
	if (rtd) {
		dai_params =
		(struct snd_soc_pcm_stream *)rtd->dai_link->params;

		dai_params->rate_min = srate;
		dai_params->formats = (machine->fmt_via_kcontrol == 2) ?
			(1ULL << SNDRV_PCM_FORMAT_S32_LE) : formats;

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

Sorry for the late response.

Is this still an issue to support? Any result can be shared?

Hi 854053437

  • Since you are interfacing two separate codecs, you would need different DAI link names. Because you would want apply the clock settings to both codecs. Note that snd_soc_dai_set_sysclk() takes the codec DAI argument. You can add link-names like “rt5640-playback” and “rt5640-capture” and add respective settings under it.

  • Please share relevant kernel logs and dumps in case you hit any failure.

Thanks,
Sameer.

ok, thank you for help. I’ll share information if I hit any failure

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.