Configuring SAI for I2S multi-line with linux

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Configuring SAI for I2S multi-line with linux

2,572件の閲覧回数
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

ラベル(3)
0 件の賞賛
返信
4 返答(返信)

2,545件の閲覧回数
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 件の賞賛
返信

2,534件の閲覧回数
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 件の賞賛
返信

2,508件の閲覧回数
sbouthillier
Contributor II

I finally found a way to do it!

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

Thanks

0 件の賞賛
返信

1,395件の閲覧回数
iicsanjeev01
Contributor I

Hi

What configuration you did in Alsa to remap the channels? 

Your input will help.

 

Thanks

Sanjeev

0 件の賞賛
返信