<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Sync SAI RX to TX? in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1563737#M198299</link>
    <description>&lt;P&gt;Hello Moose:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;tas5808m.c&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;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 = &amp;amp;tas5805m_dai_ops,
};&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take for instance a codec device from same manufacturer.&amp;nbsp; This device exposes both a playback and a capture stream:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;tlv320aic3x.c&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;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 = &amp;amp;aic3x_dai_ops,
	.symmetric_rate = 1,
};&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;---&lt;/P&gt;
&lt;P&gt;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&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code bellow is an example of how the move to fsl-asoc-card could be done:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;fsl-asoc-card.c&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;/*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*/
};&lt;/LI-CODE&gt;&lt;LI-CODE lang="c"&gt;/*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-&amp;gt;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-&amp;gt;card_type = CARD_TAS5805M; /*name defined in the enum above*/
}&lt;/LI-CODE&gt;&lt;LI-CODE lang="c"&gt;/*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*/
	{}
};&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a basic entry for the sound card on the dts using fsl-asoc-card:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;	sound-tas5805m {
		audio-cpu = &amp;lt;&amp;amp;sai2&amp;gt;;
		audio-codec = &amp;lt;&amp;amp;tas5805m&amp;gt;;
		audio-routing =
			"External Speaker", "OUT",
			"IN", "Audio Monitoring";
		compatible = "fsl,imx-audio-tas5805m";
		model = "tas5805m-audio";
	};&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if you run into any issue.&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
    <pubDate>Fri, 02 Dec 2022 22:06:24 GMT</pubDate>
    <dc:creator>Luis_Valdez</dc:creator>
    <dc:date>2022-12-02T22:06:24Z</dc:date>
    <item>
      <title>How to Sync SAI RX to TX?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1563062#M198260</link>
      <description>&lt;P&gt;&lt;SPAN&gt;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&amp;nbsp; (TX bit clock and frame sync). However, the SAI binding documentation (fsl-sai.txt) lists only &lt;/SPAN&gt;&lt;STRONG&gt;sai-synchronous-rx&lt;/STRONG&gt;&lt;SPAN&gt; property which syncs TX to RX. How can we define our SAI module in our devicetree so the RX channel is synced to TX?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 23:03:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1563062#M198260</guid>
      <dc:creator>moose</dc:creator>
      <dc:date>2022-12-01T23:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sync SAI RX to TX?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1563070#M198261</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;Would it be possible for you to attach the .DTS file being used to configure the device soundcard?&amp;nbsp;&lt;/P&gt;&lt;P&gt;This would allow me to see how the dai-links are being described and i could provide better feedback for this issue.&lt;/P&gt;&lt;P&gt;Looking forward for your reply&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 23:30:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1563070#M198261</guid>
      <dc:creator>Luis_Valdez</dc:creator>
      <dc:date>2022-12-01T23:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sync SAI RX to TX?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1563737#M198299</link>
      <description>&lt;P&gt;Hello Moose:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;tas5808m.c&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;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 = &amp;amp;tas5805m_dai_ops,
};&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take for instance a codec device from same manufacturer.&amp;nbsp; This device exposes both a playback and a capture stream:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;tlv320aic3x.c&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;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 = &amp;amp;aic3x_dai_ops,
	.symmetric_rate = 1,
};&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;---&lt;/P&gt;
&lt;P&gt;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&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code bellow is an example of how the move to fsl-asoc-card could be done:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;fsl-asoc-card.c&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;/*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*/
};&lt;/LI-CODE&gt;&lt;LI-CODE lang="c"&gt;/*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-&amp;gt;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-&amp;gt;card_type = CARD_TAS5805M; /*name defined in the enum above*/
}&lt;/LI-CODE&gt;&lt;LI-CODE lang="c"&gt;/*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*/
	{}
};&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a basic entry for the sound card on the dts using fsl-asoc-card:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;	sound-tas5805m {
		audio-cpu = &amp;lt;&amp;amp;sai2&amp;gt;;
		audio-codec = &amp;lt;&amp;amp;tas5805m&amp;gt;;
		audio-routing =
			"External Speaker", "OUT",
			"IN", "Audio Monitoring";
		compatible = "fsl,imx-audio-tas5805m";
		model = "tas5805m-audio";
	};&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if you run into any issue.&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2022 22:06:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1563737#M198299</guid>
      <dc:creator>Luis_Valdez</dc:creator>
      <dc:date>2022-12-02T22:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sync SAI RX to TX?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1564654#M198362</link>
      <description>&lt;P&gt;Hello Moose&lt;/P&gt;
&lt;P&gt;Regarding the SAI property needed to sync Rx with Tx,&amp;nbsp; as per &lt;STRONG&gt;fsl_sai.c&lt;/STRONG&gt; code block on lines 1425 down to 1428, it actually is &lt;STRONG&gt;fsl,sai-synchronous-rx&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;	if (of_find_property(np, "fsl,sai-synchronous-rx", NULL)) {
		/* Sync Rx with Tx */
		sai-&amp;gt;synchronous[RX] = false;
		sai-&amp;gt;synchronous[TX] = true;
	} else if (of_find_property(np, "fsl,sai-asynchronous", NULL)) {
		/* Discard all settings for asynchronous mode */
		sai-&amp;gt;synchronous[RX] = false;
		sai-&amp;gt;synchronous[TX] = false;
		sai-&amp;gt;cpu_dai_drv.symmetric_rate = 0;
		sai-&amp;gt;cpu_dai_drv.symmetric_channels = 0;
		sai-&amp;gt;cpu_dai_drv.symmetric_sample_bits = 0;
	}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Leaving sai without any of the above properties will end up syncing Tx to Rx by default.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 21:07:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1564654#M198362</guid>
      <dc:creator>Luis_Valdez</dc:creator>
      <dc:date>2022-12-05T21:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sync SAI RX to TX?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1564673#M198363</link>
      <description>&lt;P&gt;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"&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 21:57:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1564673#M198363</guid>
      <dc:creator>moose</dc:creator>
      <dc:date>2022-12-05T21:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sync SAI RX to TX?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1564679#M198364</link>
      <description>&lt;P&gt;For future reference, here is the summary of what these device tree properties do to the fsl-sai configuration:&lt;/P&gt;
&lt;P&gt;* Adding no synchronization properties results in the default configuration which is Rx synchronized with Tx&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Adding&amp;nbsp;&lt;STRONG&gt;fsl,sai-synchronous-rx&amp;nbsp;&lt;/STRONG&gt;results with Tx being synchronized with Rx&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Adding &lt;STRONG&gt;fsl,sai-asynchronous&lt;/STRONG&gt; clears synchronization bits for both Tx and Rx, thus operating on their timing.&lt;/P&gt;
&lt;P&gt;* Adding both&amp;nbsp;&lt;STRONG&gt;fsl,sai-synchronous-rx&amp;nbsp;&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;fsl,sai-asynchronous&lt;/STRONG&gt; ends up in an error as they are mutually exclusive&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 17:02:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-Sync-SAI-RX-to-TX/m-p/1564679#M198364</guid>
      <dc:creator>Luis_Valdez</dc:creator>
      <dc:date>2022-12-06T17:02:17Z</dc:date>
    </item>
  </channel>
</rss>

