How to Sync SAI RX to TX?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to Sync SAI RX to TX?

跳至解决方案
1,806 次查看
moose
Contributor IV

Hello, according to IMX8MNRM (section 13.10.3.1.2 in Rev 1), we could configure SAI RX channel to be synchronous to the TX channel  (TX bit clock and frame sync). However, the SAI binding documentation (fsl-sai.txt) lists only sai-synchronous-rx property which syncs TX to RX. How can we define our SAI module in our devicetree so the RX channel is synced to TX?

标记 (2)
0 项奖励
回复
1 解答
1,763 次查看
Luis_Valdez
NXP Employee
NXP Employee

Hello Moose

Regarding the SAI property needed to sync Rx with Tx,  as per fsl_sai.c code block on lines 1425 down to 1428, it actually is fsl,sai-synchronous-rx

 

	if (of_find_property(np, "fsl,sai-synchronous-rx", NULL)) {
		/* Sync Rx with Tx */
		sai->synchronous[RX] = false;
		sai->synchronous[TX] = true;
	} else if (of_find_property(np, "fsl,sai-asynchronous", NULL)) {
		/* Discard all settings for asynchronous mode */
		sai->synchronous[RX] = false;
		sai->synchronous[TX] = false;
		sai->cpu_dai_drv.symmetric_rate = 0;
		sai->cpu_dai_drv.symmetric_channels = 0;
		sai->cpu_dai_drv.symmetric_sample_bits = 0;
	}

 

Leaving sai without any of the above properties will end up syncing Tx to Rx by default.

 

Would it be possible to get a dmesg log concerning the tas5805m? i would like to see if the kernel outputs any message concerning an error or failure to initialize part of the codec.

 

Regards

在原帖中查看解决方案

5 回复数
1,764 次查看
Luis_Valdez
NXP Employee
NXP Employee

Hello Moose

Regarding the SAI property needed to sync Rx with Tx,  as per fsl_sai.c code block on lines 1425 down to 1428, it actually is fsl,sai-synchronous-rx

 

	if (of_find_property(np, "fsl,sai-synchronous-rx", NULL)) {
		/* Sync Rx with Tx */
		sai->synchronous[RX] = false;
		sai->synchronous[TX] = true;
	} else if (of_find_property(np, "fsl,sai-asynchronous", NULL)) {
		/* Discard all settings for asynchronous mode */
		sai->synchronous[RX] = false;
		sai->synchronous[TX] = false;
		sai->cpu_dai_drv.symmetric_rate = 0;
		sai->cpu_dai_drv.symmetric_channels = 0;
		sai->cpu_dai_drv.symmetric_sample_bits = 0;
	}

 

Leaving sai without any of the above properties will end up syncing Tx to Rx by default.

 

Would it be possible to get a dmesg log concerning the tas5805m? i would like to see if the kernel outputs any message concerning an error or failure to initialize part of the codec.

 

Regards

1,758 次查看
moose
Contributor IV

Thank you. So to sync RX to TX do nothing. To sync TX to RX add "fsl,sai-synchronous-rx" property to the node definition and to configure RX and TX as independent, add "fsl,sai-asynchronous"

0 项奖励
回复
1,754 次查看
Luis_Valdez
NXP Employee
NXP Employee

For future reference, here is the summary of what these device tree properties do to the fsl-sai configuration:

* Adding no synchronization properties results in the default configuration which is Rx synchronized with Tx 

* Adding fsl,sai-synchronous-rx results with Tx being synchronized with Rx 

*Adding fsl,sai-asynchronous clears synchronization bits for both Tx and Rx, thus operating on their timing.

* Adding both fsl,sai-synchronous-rx  and fsl,sai-asynchronous ends up in an error as they are mutually exclusive

 

 

1,778 次查看
Luis_Valdez
NXP Employee
NXP Employee

Hello Moose: 

I was looking into the source file for the tas5805 and found that this device lacks a capture stream, which is essential for record operations:

tas5808m.c

 

 

static struct snd_soc_dai_driver tas5805m_dai = {
	.name		= "tas5805m-amplifier",
	.playback	= {
		.stream_name	= "Playback",
		.channels_min	= 2,
		.channels_max	= 2,
		.rates		= SNDRV_PCM_RATE_48000,
		.formats	= SNDRV_PCM_FMTBIT_S32_LE,
	},
	.ops = &tas5805m_dai_ops,
};

 

 

Take for instance a codec device from same manufacturer.  This device exposes both a playback and a capture stream:

tlv320aic3x.c

 

 

static struct snd_soc_dai_driver aic3x_dai = {
	.name = "tlv320aic3x-hifi",
	.playback = {
		.stream_name = "Playback",
		.channels_min = 2,
		.channels_max = 2,
		.rates = AIC3X_RATES,
		.formats = AIC3X_FORMATS,},
	.capture = {
		.stream_name = "Capture",
		.channels_min = 2,
		.channels_max = 2,
		.rates = AIC3X_RATES,
		.formats = AIC3X_FORMATS,},
	.ops = &aic3x_dai_ops,
	.symmetric_rate = 1,
};

 

 

This would be a reason as to why the device isn't shown when listing devices with arecord as it does not have a valid capture stream. 

---

Nevertheless, there is one last thing that we could try, and that is, to move your current sound card implementation from the generic simple-card.c (which is playback based only and does not support capture) to fsl-asoc-card.c 

The code bellow is an example of how the move to fsl-asoc-card could be done:

fsl-asoc-card.c 

 

 

/*Add the card to fsl_asoc_card_type enum found in line 39*/

enum fsl_asoc_card_type {
	CARD_CS42888 = 1,
	CARD_WM8960,
	CARD_WM8962,
	CARD_SGTL5000,
	CARD_AC97,
	CARD_CS427X,
	CARD_TLV320AIC32X4,
	CARD_MQS,
	CARD_WM8524,
	CARD_SI476X,
	CARD_WM8958,
        CARD_TAS5805M,  /*new card*/
};
/*Add an -else if- to the conditional block on line 773 containing card data*/

else if (of_device_is_compatible(np, "fsl,imx-audio-tas5805m")) {
		codec_dai_name = "tas5805m";
		priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; /*This will depend on the configuration of the DTS whether the codec is Bit and Frame master*/
		priv->card_type = CARD_TAS5805M; /*name defined in the enum above*/
}
/*Line 1156: add a -compatible- member to the fsl_asoc_card_dt_ids array. It must be the same name we defined in the else if case above*/

static const struct of_device_id fsl_asoc_card_dt_ids[] = {
	{ .compatible = "fsl,imx-audio-ac97", },
	{ .compatible = "fsl,imx-audio-cs42888", },
	{ .compatible = "fsl,imx-audio-cs427x", },
	{ .compatible = "fsl,imx-audio-tlv320aic32x4", },
	{ .compatible = "fsl,imx-audio-sgtl5000", },
	{ .compatible = "fsl,imx-audio-wm8962", },
	{ .compatible = "fsl,imx-audio-wm8960", },
	{ .compatible = "fsl,imx-audio-mqs", },
	{ .compatible = "fsl,imx-audio-wm8524", },
	{ .compatible = "fsl,imx-audio-si476x", },
	{ .compatible = "fsl,imx-audio-wm8958", },
        { .compatible = "fsl,imx-audio-tas5805m", }, /*user card*/
	{}
};

 

 

This is a basic entry for the sound card on the dts using fsl-asoc-card:

	sound-tas5805m {
		audio-cpu = <&sai2>;
		audio-codec = <&tas5805m>;
		audio-routing =
			"External Speaker", "OUT",
			"IN", "Audio Monitoring";
		compatible = "fsl,imx-audio-tas5805m";
		model = "tas5805m-audio";
	};

 

Let me know if you run into any issue.

Regards

0 项奖励
回复
1,791 次查看
Luis_Valdez
NXP Employee
NXP Employee

Hello:

Would it be possible for you to attach the .DTS file being used to configure the device soundcard? 

This would allow me to see how the dai-links are being described and i could provide better feedback for this issue.

Looking forward for your reply

Regards

0 项奖励
回复