Configuring SAI for I2S multi-line with linux

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Configuring SAI for I2S multi-line with linux

1,811 Views
sbouthillier
Contributor II

Hello,

On a custom board, I have an iMX8mm running Linux and I'm using SAI1 to send I2S audio to an external codec. Because the codec supports 8 channels, the I2S bus uses 4 data lines (TXD0..TXD3).

The SAI driver is configured with 8 channels, a frame sync width of 32 bits, 2 words per frame and a word size of 32 bits. The driver is enabling the correct number of transmit channels (TCE) based on the number of channels and frame size, but it looks like only the FIFO of TXD0 is serviced by the DMA. 

I can manually enable the FIFO combine mode (FCOMB) but in this mode, when I use the tool speaker-test to playback 8 audio channels on SAI1, the data form channels are not correctly distributed through the 4 data lines. i.e. ch0 and ch4 are on TXD0, ch1 and ch5 are on TXD1, ch2 and ch6 on TXD2...

What I would like to have is ch0 and ch1 on TXD0, ch2 and ch3 on TXD1 and so on.

How do I configure the DMA to correctly distribute the data over the FIFOs?

 

Thanks

0 Kudos
4 Replies

1,784 Views
jimmychan
NXP TechSupport
NXP TechSupport

Could you tell me which version of BSP are you using?

You may need to modify the code under fsl_sai_hw_params() in fsl_sai.c. But we don't recommend to modify the driver source code. It is better that you may modify the driver source code of your audio codec side.

https://source.codeaurora.org/external/imx/linux-imx/tree/sound/soc/fsl/fsl_sai.c?h=rel_imx_5.4.47_2...

0 Kudos

1,773 Views
sbouthillier
Contributor II

Thanks Jimmychan for your answer.

I'm using version 4.14.98_2.0.0_ga-stable from github.com/TechNexion/linux-tn-imx.git.
The code you pointed out to me is similar to what I am using. 

I see in fsl_sai.c that there is some parameters (undocummented) that can be configured in the devicetree, fsl,sai-multi-lane and fsl,dataline.
In fsl_sai_hw_params(), when fsl,sai-multi-lane is set in the devicetree, the FIFO combine mode is disabled and the DMA seems to be configured differently.
What are these parameters for exactly?

In my case, the number of channels is set to 8 and the number of slots is set to 2. fsl_sai_hw_params() correctly determines the number of pins (8/2 = 4) and correctly configures the channel mask in TCR3_TCE.
The FIFO combine mode is also enabled on FIFO writes (by software).

Like I said in my first post, I'm using speaker-test to playback 8 channels, but with the FIFO combine mode enabled, the audio samples from the different channels are distributed like illustrated bellow:

Channels distribution 1.png

I would like to find a way to have the audio samples distributed like:

Channels distribution 2.png

Thanks

 

 

0 Kudos

1,747 Views
sbouthillier
Contributor II

I finally found a way to do it!

I'm using an ALSA configuration to remap the channels.

Thanks

0 Kudos

634 Views
iicsanjeev01
Contributor I

Hi

What configuration you did in Alsa to remap the channels? 

Your input will help.

 

Thanks

Sanjeev

0 Kudos