<?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>i.MX ProcessorsのトピックRe: IMX8MP - AD1939 audio codec capture issue</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/IMX8MP-AD1939-audio-codec-capture-issue/m-p/1543954#M196862</link>
    <description>&lt;P&gt;Answering myself in case somebody needs a hint on a similar issue.&lt;/P&gt;&lt;P&gt;The problem was I had clocked the SAI peripheral at the same rate my bit clock is. I have 8 32-bit slots at 48 kHz, so my bit clock is 12.288 MHz and in my device tree I had&amp;nbsp;assigned-clock-rates = &amp;lt;12288000&amp;gt;&lt;/P&gt;&lt;P&gt;Running out of ideas I tried to reduce the slot count to 4 (bit clock 6.144 MHz) and all went fine. So I tried to revert to 8 slots and increase assigned-clock-rates to twice the bit clock. Now I can playback and capture w/o any issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Oct 2022 09:13:54 GMT</pubDate>
    <dc:creator>Airbus_A320</dc:creator>
    <dc:date>2022-10-26T09:13:54Z</dc:date>
    <item>
      <title>IMX8MP - AD1939 audio codec capture issue</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/IMX8MP-AD1939-audio-codec-capture-issue/m-p/1542668#M196768</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm having some trouble with an AD1939 codec. I need my application to work in TDM mode (8 playback streams on a single lane and 4 capture streams on a single lane) and the CPU to be the clock master. I managed to get the codec recognized by the kernel and it playbacks OK. I'm having a hard time getting the capture streams configured.&lt;/P&gt;&lt;P&gt;Here is a snippet of my device tree:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/ {
	sound-ad193x {
		compatible = "simple-audio-card";
		simple-audio-card,name = "ad193x-audio";
		simple-audio-card,format = "dsp_a";
		simple-audio-card,frame-master = &amp;lt;&amp;amp;cpudai&amp;gt;;
		simple-audio-card,bitclock-master = &amp;lt;&amp;amp;cpudai&amp;gt;;
		simple-audio-card,mclk-fs = &amp;lt;256&amp;gt;;

		cpudai: simple-audio-card,cpu {
			sound-dai = &amp;lt;&amp;amp;sai2&amp;gt;;
			dai-tdm-slot-num = &amp;lt;8&amp;gt;;
			dai-tdm-slot-width = &amp;lt;32&amp;gt;;
		};

		codecdai:simple-audio-card,codec {
			sound-dai = &amp;lt;&amp;amp;codec_audio_analog&amp;gt;;
		};
	};
};

&amp;amp;ecspi2 {
	codec_audio_analog: ad1939_spi@0 {
		compatible = "ad1939";
		reg = &amp;lt;0&amp;gt;;
		spi-max-frequency = &amp;lt;1000000&amp;gt;;
		#sound-dai-cells = &amp;lt;0&amp;gt;;
		status = "okay";
	};
};

&amp;amp;sai2 {
	#sound-dai-cells = &amp;lt;0&amp;gt;;
	pinctrl-names = "default";
	pinctrl-0 = &amp;lt;&amp;amp;pinctrl_sai2&amp;gt;;
	assigned-clocks = &amp;lt;&amp;amp;clk IMX8MP_CLK_SAI2&amp;gt;;
	assigned-clock-parents = &amp;lt;&amp;amp;clk IMX8MP_AUDIO_PLL1_OUT&amp;gt;;
	assigned-clock-rates = &amp;lt;12288000&amp;gt;;
	clocks = &amp;lt;&amp;amp;audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI2_IPG&amp;gt;, &amp;lt;&amp;amp;clk IMX8MP_CLK_DUMMY&amp;gt;,
		 &amp;lt;&amp;amp;audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI2_MCLK1&amp;gt;, &amp;lt;&amp;amp;clk IMX8MP_CLK_DUMMY&amp;gt;,
		 &amp;lt;&amp;amp;clk IMX8MP_CLK_DUMMY&amp;gt;;
	clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3";
	fsl,dataline = &amp;lt;0 0x1 0x1&amp;gt;;
	fsl,sai-mclk-direction-output;
	status = "okay";
};

&amp;amp;iomuxc {
	pinctrl_sai2: sai2grp {
		fsl,pins = &amp;lt;
            MX8MP_IOMUXC_SAI2_TXC__AUDIOMIX_SAI2_TX_BCLK 	0x000000D6
            MX8MP_IOMUXC_SAI2_TXD0__AUDIOMIX_SAI2_TX_DATA00	0x00000196
            MX8MP_IOMUXC_SAI2_TXFS__AUDIOMIX_SAI2_TX_SYNC	0x000000D6
			MX8MP_IOMUXC_SAI2_RXD0__AUDIOMIX_SAI2_RX_DATA00 0x000000D6
		&amp;gt;;
	};
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The configuration sent by the codec driver over the SPI bus looks fine to me. Here is a screenshot of the signals I get:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20221024-0003.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/197859i8639BC9BE51D580B/image-size/large?v=v2&amp;amp;px=999" role="button" title="20221024-0003.png" alt="20221024-0003.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I try to record I get just noise. Reproducing the wave file through my logic analyzer looks like the whole 8-slot frame gets "compressed" into 4 frames (muting first channel one and then channel two while recording I see during playback that the most significant bit of channel one got zeroed first then the least significant ones). Another symptom is that if I lunch arecord with a duration flag it records for exactly twice the time!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;~# time arecord -fs16 -r48000 -c4 /dev/null --duration 2
Recording WAVE '/dev/null' : Signed 16 bit Little Endian, Rate 48000 Hz, Channels 4

real	0m4.136s
user	0m0.056s
sys	0m0.024s&lt;/LI-CODE&gt;&lt;P&gt;My theory is the bit clock inside the receiver got somehow halved...&lt;BR /&gt;Peeking at the sai registers during the recording I see MSEL in RCR2 is 00, I was expecting it to be 01 as in TCR2.&lt;/P&gt;&lt;P&gt;If I configure the codec to be the clock master all works as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody please help me?&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 11:09:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/IMX8MP-AD1939-audio-codec-capture-issue/m-p/1542668#M196768</guid>
      <dc:creator>Airbus_A320</dc:creator>
      <dc:date>2022-10-24T11:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: IMX8MP - AD1939 audio codec capture issue</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/IMX8MP-AD1939-audio-codec-capture-issue/m-p/1543954#M196862</link>
      <description>&lt;P&gt;Answering myself in case somebody needs a hint on a similar issue.&lt;/P&gt;&lt;P&gt;The problem was I had clocked the SAI peripheral at the same rate my bit clock is. I have 8 32-bit slots at 48 kHz, so my bit clock is 12.288 MHz and in my device tree I had&amp;nbsp;assigned-clock-rates = &amp;lt;12288000&amp;gt;&lt;/P&gt;&lt;P&gt;Running out of ideas I tried to reduce the slot count to 4 (bit clock 6.144 MHz) and all went fine. So I tried to revert to 8 slots and increase assigned-clock-rates to twice the bit clock. Now I can playback and capture w/o any issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 09:13:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/IMX8MP-AD1939-audio-codec-capture-issue/m-p/1543954#M196862</guid>
      <dc:creator>Airbus_A320</dc:creator>
      <dc:date>2022-10-26T09:13:54Z</dc:date>
    </item>
  </channel>
</rss>

