Solved! Go to Solution.
Hi @JorgeCas san and community!
I've come to a good workaround, so I'll share it with you.
&sai1 {
~~~
//fsl,sai-multi-lane; do not set!!
fsl,dataline = <8 0xFF 0xFF>;
fsl,sai-asynchronous;
~~~
};
Also, the data output when using alsalib(snd_pcm_writei) is as follows.
TXD0 = CH1/CH9
TXD1 = CH2/CH10
TXD2 = CH3/CH11
TXD3 = CH4/CH12
TXD4 = CH5/CH13
TXD5 = CH6/CH14
TXD6 = CH7/CH15
TXD7 = CH8/CH16
If necessary, you may want to swap it yourself or use channel mapping.
About "fsl,sai-multi-lane":
When "fsl,sai-multi-lane" is enabled, fsl_sai_hw_params() disables SAI's FIFO Combine Mode. If FCOMB is disabled, each register (TDR[0~7]/RDR[0~7]) must be accessed to read or write data. However, at least in If-5.15-y, the driver seems to only access TDR[0]/RDR[0].
Best Regards,
KASHIWAGI Takashi
@JorgeCas san
Thank you for reply!
Thank you for the helpful information. Also, could you please answer Q1, Q2, Q3, and Q4?
> I suggest you take a look on next thread.
As mentioned in this thread, when I enabled FCOMB as follows, data was now output to TXD0~7 via snd_pcm_writei(alsalib).
if (__sw_hweight8(dl_cfg[dl_cfg_idx].mask[tx]) <= 1 || sai->is_multi_lane)regmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx, ofs),FSL_SAI_CR4_FCOMB_MASK, 0);elseregmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx, ofs),FSL_SAI_CR4_FCOMB_MASK, FSL_SAI_CR4_FCOMB_SOFT);+if(sai->is_multi_lane)+{+ regmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx, ofs), FSL_SAI_CR4_FCOMB_MASK, FSL_SAI_CR4_FCOMB_SOFT);+}
The order of the data was as follows.
TXD0 - CH1, CH9
TXD1 - CH2, CH10
TXD2 - CH3, CH11
TXD3 - CH4, CH12
TXD4 - CH5, CH13
TXD5 - CH6, CH14
TXD6 - CH7, CH15
TXD7 - CH8, CH16
By the way, is this the correct way to handle FCOMB when fsl,sai-multi-lane is enabled?.
Are the problems pointed out in "Configuring-SAI-for-I2S-multi-line-with-linux" had not fixed?
* sbouthillier san says (in "Configuring-SAI-for-I2S-multi-line-with-linux"):
* 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 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?
> ALSAhas a asound.conf file, and it has some ways to split and/or join audio cards.
Thank you for the information about aredord/aplay!
For now, our application calls alsalib's snd_pcm_writei/readi directly. I will refer to it later if I need it.
Best Regards,
KASHIWAGI Takashi
Hello,
Q1.
Please refer to fsl-sai.txt.
Q2.
On our EVK reference designs there is no working examples of this type of applications using "fsl, sai-multi-lane" and "fsl, dataline".
Q3.
It should be the total number of WORDs.
Q4.
I suggest you take a look on SAI Transmit Configuration 4 Register (TCR4) and SAI Receive Configuration 4 Register (RCR4) of reference manual and the next link.
Best regards.
Hi @JorgeCas san
Hi @JorgeCas san and community!
I've come to a good workaround, so I'll share it with you.
&sai1 {
~~~
//fsl,sai-multi-lane; do not set!!
fsl,dataline = <8 0xFF 0xFF>;
fsl,sai-asynchronous;
~~~
};
Also, the data output when using alsalib(snd_pcm_writei) is as follows.
TXD0 = CH1/CH9
TXD1 = CH2/CH10
TXD2 = CH3/CH11
TXD3 = CH4/CH12
TXD4 = CH5/CH13
TXD5 = CH6/CH14
TXD6 = CH7/CH15
TXD7 = CH8/CH16
If necessary, you may want to swap it yourself or use channel mapping.
About "fsl,sai-multi-lane":
When "fsl,sai-multi-lane" is enabled, fsl_sai_hw_params() disables SAI's FIFO Combine Mode. If FCOMB is disabled, each register (TDR[0~7]/RDR[0~7]) must be accessed to read or write data. However, at least in If-5.15-y, the driver seems to only access TDR[0]/RDR[0].
Best Regards,
KASHIWAGI Takashi
Hi Takashi Kashiwagi san,
as far I am developing audio application on our custom iMX(MP board, I am facing with multi-lane SAI peripheral problmems.
I found interesting this post and I ask to you what is the SoundCard driver ("simple-audio-card", "imx-audio-card", ... ) that have you used and how you have descriobed the links between the "cpu" side and the "codec" side (if any).
Thanks in advance
Best Regads
Stefano Gigli
Great! Thank you for the feedback.
Best regards.
Hello, I hope you are doing well.
I suggest you take a look on next thread.
Also, I was researching internally, and it seems that it is possible to use ALSA to control all playback. It is one of possible ways (maybe easiest way to do it).
ALSAhas a asound.conf file, and it has some ways to split and/or join audio cards.
In ALSA, customer can define its card and codec in kernel (dts and all config files). Then create a asound.conf in /etc.
In asound.conf, create a audio card and then, using an ALSA virtual device for each output (stereo or mono) via "dshare" propriety. So, ALSA is reponsable to produce all data that will be send through SAI (via driver), but all sequence of sound or empties slots will be dealed by ALSA in user space, so you don need to include this sequence of channels and its control on driver.
For dshare, customer can check for examples at:
Alsa Opensrc Org - Independent ALSA and linux audio support site
With asound.conf, customer can check if devices are ok, using:
aplay -L
To play independently different sources, customer can use:
aplay -Dplug:name_of_dshare_card name_of_file
In order to play more than one file, use a sequence of parallel execution aplay xxx & aplay xxx & (...). For example if in config file it was defined outputs, you can use:
aplay -Dplug:output1 audio1.wav & aplay -Dplug:output2 audio2.wav & aplay -Dplug:output3 audio3.wav
It will play 3 different audio files in three different virtual devices that can be at same SAI.
Best regards.