iMX93: SAI round-trip latency can 'randomly' change by 1 sample The round-trip latency of the SAI in synchronous mode should always be the same (deterministic) when opening a capture & playback ALSA stream on a hardware sound card. That is: if you have an audio codec (ADC+DAC) and you use it for capture and playback, the latency seen from input to output should always be the same, given the ALSA settings (buffer sizes, periods, etc.) do not change. What I am actually seeing is that the latency can vary by 1 sample. This variation is some lower percentage of the time, e.g. 20%. 2 in 10 runs result in a delay 1 sample less than the other 8 runs. This was tested by running DUT Delay measurement on an Audio Precision: Further Info: Codec is TAC5211 running @ 192kHz, connected to SAI3. Codec provides clocks to TXC and TXFS (it is the master). Capture and playback are linked (snd_pcm_link). Running @48kHz: 1 sample offset appears 3/10 times. So, lowering the sample rate does not lower the changes of the 1 sample difference appearing. I suspect some sort of timing related/race condition between the TX and RX, at a very low level (fsl_sai.c, or DMA). 1 sample different might seem like not a big deal, but it does matter when you need to maintain a fixed phase relationship between what you are generating (DAC) with the signal present at the input (ADC). Re: iMX93: SAI round-trip latency can 'randomly' change by 1 sample I have tried 22 different attempts at modifying `fsl_sai.c` to try to get RX and TX to sync. So far I have not been able to get anything that works 100% of the time. There are some changes that reduce the % of time the 1 sample offset appears. This is all on the same board. Each time the audio device is opened, there is a chance the round-trip latency is 1 sample different. Re: iMX93: SAI round-trip latency can 'randomly' change by 1 sample Hello,
SAI synchronous mode guarantees a shared BCLK/frame-sync relationship, but synchronous mode does not prove sample accurate startup alignment.
That requires synchronized start support and compliance with the processor and SAI enable/reset sequence.
You can refer to this link in section Streams Syncronization:
https://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html
i.MX93 provides shared BCLK/frame-sync SAI operation, but there is not documented that it guarantees deterministic sample aligned startup latency
As you mention, this could be caused in a low level preventing simultaneous FIFO start and modification may be needed.
Does this issue occur on the same boards, or does it occur randomly across all boards?
Best regards.
View full article