SAI2 using (DMA)

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

SAI2 using (DMA)

2,573 Views
kschauties
Contributor II

I would like to connect a microphone to the SAI 2 on the imx8qm. For this I integrated the microphone in the DTB file.
...
cpu-dai = <&sai2>;
...

As a result, when I create the microphone as a card, I get an error.

fsl-sai 59060000.sai: Missing dma channel for stream: (in the dmaengine_pcm_new function)


This is due to the fact that the SAI2 only has one DMA. (only RX)
1.)Is there any way I can take that into account?

The error no longer occurs if you define an additional DMA in SAI2.
2.) Is this acceptable?
3.) Or will I get the following problem?
4.) Or is there another solution?

sai2: sai@59060000 {
compatible = "fsl,imx8qm-sai";
reg = <0x59060000 0x10000>;
interrupts = <GIC_SPI 318 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&sai2_lpcg 1>,
<&clk_dummy>,
<&sai2_lpcg 0>,
<&clk_dummy>,
<&clk_dummy>;
clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3";
/* dma-names = "rx";
dmas = <&edma0 16 0 1>; */
dma-names = "rx", "tx";
dmas = <&edma0 16 0 1>, <&edma0 17 0 0>;
power-domains = <&pd IMX_SC_R_SAI_2>;
status = "disabled";

11 Replies

2,537 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Using imx8qm-ss-audio.dtsi as a reference, you shouldn't gen any error using just one DMA but, if you fixed that error adding one DMA there is no problem. Please refer to attached code on the next link.

https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm64/boot/dts/freescale/imx8qm-ss-au... 

Best regards.

0 Kudos
Reply

2,528 Views
kschauties
Contributor II

Hi

if i remove my hack i keep getting the error. (sl-sai 59060000.sai: Missing dma channel for stream: (in the dmaengine_pcm_new function))
And the micro (card) is not created!
 
fsl-sai 59060000.sai: Missing dma channel for stream: 0
[ 2.633632] fsl-sai 59060000.sai: ASoC: error at snd_soc_pcm_component_new on 59060000.sai: -22
[ 2.642361] imx-sph0645: ASoC: pcm imx-sph0645 snd-soc-dummy-dai-0 constructor failed for dailink imx-sph0645: -22
[ 2.652816] imx-mic-sph0645 imx-sph0645: ASoC: can't create pcm imx-sph0645 :-22
[ 2.660371] imx-mic-sph0645 imx-sph0645: Failed to register card: -22
0 Kudos
Reply

2,520 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello, 

Could you please share me your entire device tree?

Best regards.

0 Kudos
Reply

2,496 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

All seems to be ok on your device tree but, there is something that is making noise to me, your mux configuration on SAI2 it is configured to use ESAI1 functions I think you should try using 0xCE000040.

Best regards.

0 Kudos
Reply

2,435 Views
kschauties
Contributor II

Hi

the sai2 is only work with "tx" definition !

...

dma-names = "rx", "tx";
dmas = <&edma0 16 0 1>, <&edma0 17 0 0>;

...

and i found in the fsl-sai.txt the sentence

"Two dmas have to be defined, "tx" and "rx".

For me is this a way i can go, i don't used sai3

0 Kudos
Reply

2,351 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

> "Two dmas have to be defined, "tx" and "rx".

It also could be defined with one (tx or rx)

Maybe you have declared on DMA channels tx and rx. Causing an error when you skip tx and working when you include tx on your declaration.

Best regards.

0 Kudos
Reply

2,341 Views
kschauties
Contributor II

Hi

"Maybe you have declared on DMA channels tx and rx"

Where should I have done this?

I only know if I don't set both, it doesn't work.

 

 

0 Kudos
Reply

2,334 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Here is an example of how to configure DMA on iMX8QM. As you can see there are some SAI ports configured with both (tx and rx) or only one. 

Best regards.

0 Kudos
Reply

2,319 Views
kschauties
Contributor II

We can close this point. Thank you

0 Kudos
Reply

2,512 Views
kschauties
Contributor II

Hi

Here is my device tree.

With a hack with the second dma channel for sai i get a card . But i can not change the or set the clock on the sai port!

...

4.858522] random: crng init done
[ 4.874511] ALSA device list:
[ 4.877497] #0: Dummy 1
[ 4.880114] #1: imx-audio-sph0645
[ 4.883608] #2: Sound-Card
[ 4.907909] VFS: Mounted root (nfs filesystem) on device 0:21.
[ 4.914969] devtmpfs: mounted

...

When i start a record i get this error:

arecord -D hw:1,0 -r 48000 -f S32_LE -c 1 -d 5 -t wav -v test2_32_1.
wav
Recording WAVE 'test2_32_1.wav' : [ 92.510820] [imx_sph0645_hw_params]
Signed 32 bit Little Endian, Rate 48000 Hz, Mono
[ 92.517134] channels: 1, sampling rate : 48000, sampling bits : 32
[ 92.527629] bclk : 3072000
[ 92.634864] fsl_sai_set_bclk clk_rate:0 continue
[ 92.639934] fsl-sai 59060000.sai: failed to derive required Rx rate: 3072000
[ 92.647180] fsl-sai 59060000.sai: ASoC: error at snd_soc_dai_hw_params on 59060000.sai: -22
arecord: set_params:1407: Unable to install hw params:
ACCESS: RW_INTERLEAVED
FORMAT: S32_LE
SUBFORMAT: STD
SAMPLE_BITS: 32
FRAME_BITS: 32
CHANNELS: 1
RATE: 48000
PERIOD_TIME: 125000
PERIOD_SIZE: 6000
PERIOD_BYTES: 24000
PERIODS: 4
BUFFER_TIME: 500000
BUFFER_SIZE: 24000
BUFFER_BYTES: 96000
TICK_TIME: 0

0 Kudos
Reply

2,507 Views
kschauties
Contributor II

hi

One point more.

I see by the start following:

(my debug)

[ 3.192721] !!!!!! soc_init_pcm_runtime !!!!!!!!
[ 3.197363] !!!!!! asoc_simple_init_dai !!!!!!!!!
[ 3.202165] !!!!! snd_soc_dai_set_sysclk freq:12000000 !!!!
[ 3.207836] !!!!!! asoc_simple_init_dai !!!!!!!!!
[ 3.212638] !!!!! snd_soc_dai_set_sysclk freq:175000000 !!!!

The sai1 get 12MHz that is ok this is the soundcard and the sai2 get 175MHz  (the micro conected)

Why it can't be neatly divided down. Do you know where the 175 MHz come from?
0 Kudos
Reply