We use i.MX6 for audio processing, do ASRC to fixed S/PDIF input in 48kHz.
Without any process, i.MX6 direct pass 48kHz S/PDIF to output.
The latency between playback(to i.MX6) and recording(from i.MX6) will increase.


Environment
- PC software
- [Audacity]
- play and record
- i.MX6
- $ alsaloop -P sysdefault:CARD=imxspdif -C sysdefault:CARD=imxspdif -r 48000 -t 8192 -vvvv -f S16_LE
- the argument [-t] won't change result
- Latency between PC and Focusrite is 5ms and it is very stable
- PC => Focusrite spdif out => Focusrite spdif in => PC
Logs and observation
- alsaloop log, please refer to the attachment
- expected clock rate = 227328000
- actual clock rate = 227368421
- set sample rate to 48008Hz for 48000Hz playback
- many underruns for playback
- many times do resync
- Audio Precision, measure spdif out for Focusrite and i.MX6
- Focusrite sample rate 47999.9 Hz (diff < 0.1)
- i.MX6 sample rate 48003.5 Hz (diff > 3.5)

- Latency increase until XRUN occur

Source code and Setting
- Linux imx6qsabresd 4.9.88-PgFx+
- imx6qdl.dtsi:
spdif: spdif@02004000 {
compatible = "fsl,imx35-spdif";
reg = <0x02004000 0x4000>;
interrupts = <0 52 IRQ_TYPE_LEVEL_HIGH>;
dmas = <&sdma 14 18 0>,
<&sdma 15 18 0>;
dma-names = "rx", "tx";
clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>,
<&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_ASRC>,
<&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_ESAI_EXTAL>,
<&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_MLB>, // <&clks IMX6QDL_CLK_DUMMY>, same result
<&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>;
clock-names = "core", "rxtx0",
"rxtx1", "rxtx2",
"rxtx3", "rxtx4",
"rxtx5", "rxtx6",
"rxtx7", "dma";
status = "okay";
};
Question
- Why does the latency increase ( until underrun occurs ) ?
- Why actual CPU clock differ than expected clock ?
- How to bypass i.MX6, directly pass spdif-IN to spdif-OUT ?
Thanks,
William