Hi All,
We are facing strange issue of loosing audio after ~10 hrs of playback.
Platform:: We have customized platform of SabreSD i.MX 6Q.
Audio Source connected on port-5 of AUDMUX as MASTER using I2S. Port-1 connected SSI-1. Hence, audio received from AudioSource chip -> PORT-5 -> PORT-1 -> SSI-1.
Audio Codec (playback) connected on Port-6 of AUDMUX as SLAVE using I2S. Port-2 connected SSI-2. Hence, audio playback through SSI-2 -> PORT-2 -> PORT-6 -> Audio Codec chip
Existing audio driver for recording path was SSI-1 -> MEMORY. Means one DMA channel setup for DMA_FROM_DEVICE.
We have introduced ASRC in between Recording path (SSI-1 -> ASRC -> MEMORY). So, we have setup two DMA channel; one for SSI-1 -> ASRC i.e. DMA_DEV_TO_DEV & second for ASRC -> MEMORY i.e. DMA_FROM_DEVICE at driver level.
We reference existing playback source code of DMA Channel setup for DMA_DEV_TO_DEV.
Bus width for above channels are DMA_SLAVE_BUSWIDTH_2_BYTES.
Modified clock source of ssi1_clk, ssi2_clk & ssi3_clk to pll4_audio_main_clk in clock.c file.
Now, in our android applicatin we receive recording samples using AudioRecord object & play those sample using AudioTrack. This task done in only one thread at application side.
Result:
After above setup we are able to play recoreded content for approx ~10 hrs. but after that we receive error: "Unvalid SDMA MODE" & audio lost.
As per this log, it seems that DMA channel for DMA_DEV_TO_DEV (SSI-1 -> ASRC) met with an error.We try to read reg value of SDMAARM_EVTERR (Ref pg. no-4871:: 55.20.10 -DMA Request Error Register (SDMAARM_EVTERR) i.MX 6Q RM).
Which suggest that error bit set for above channel; this probably means there is an overflow of data for that channel.
But we could not identify how its possible.
Can anybody help me out to find where we made mistake in setup of DMA channel ? What is the probable reason for above scenario ?
For everybody reference, i am attaching patch here-with.
Please go through it & give comments upon it.
-Ankit.
Original Attachment has been moved to: asrc_V1_for_fsl_community.zip
Hi Ankit. This is interesting. So in 3.0.35 FSL kernel is SDMA_MODE_P2P not supported ? Can please someone from FSL confirm this so that I don't have to spend more time trying to get this working with that kernel. Thanks
Hi Sinan,
Reference source code is for Playback Path. i.e M2P channel (Mem -> ASRC) & P2P channel (ASRC->SSI) setup.
- Here, input clock to ASRC is INCLK_NONE while output clock to ASRC is OUTCLK_ESAI_TX
So, We use this reference source code for Recording Path. We setup P2P channel (SSI1->ASRC) & P2M channel (ASRC->Mem).
- Here, we pass input clock to ASRC is INCLK_SSI1_RX while output clock to ASRC is OUTCLK_SSI3_TX.
-Ankit.
Hi Ankit, thanks for explaining your setup. This is pretty close to what I am trying to put together. I am interested in only capture side : P2P(SPDIF->ASRC) & P2P(ASRC->SSI).
So if I understand correctly you are receiving an invalid sdma mode when you are using P2P into ASRC. Also, you mention a reference code. can you please send that to me, I would like to take a look at. Thanks
Hi Sinan,
I had attached patch on my first post in this discussion.
I am able to capture data through following path:: AudioCapture chip->SSI->ASRC->Memory. i.e. P2P channel (SSI1 -> ASRC) & P2M channel (ASRC->Mem).
- Here, in our case we need to sync Audio Capturing data with playback. So, we gave two clock source to ASRC, which are mentioned above.
But if i do capturing continuously (say for max hours), my capturing stop after ~10 hrs. When it stop capturing i received "Unvalid SDMA Mode" error; which suggest that P2P channel encounter with 'overflow' error & SDMA.
-Ankit.
Hi Lei Ge,
Any comments ??
-Ankit.
Hi Lei Ge,
Today, i had done one experiment. Following steps i had followed.
1. Kept SSI-3 clocking always ON. So, ASRC always receive SSI-3 clock as output clock source.
2. From Android application, i simply created 'AudioRecord' objec & do Audiorecord.read() in while loop.
3. setup the test.
Result:
After ~10 hours, still 'Unvalid SDMA MODE!' error getting & Reg SDMA_H_EVTERR suggest Overflow error in P2P channel.
-Ankit.
Hi,
Can you make sure is there any overflow in ssi rx fifo and asrc input fifo/ asrc output fifo? can you dump the SSI and ASRC fifo status register, to see which fifo first overflow, then cause the other fifo overflow when this issue happen? What's the rate of SSI_RX, ASRC_input rate and ASRC_output rate ? what's the rate of INCLK_SSI1_RX and OUTCLK_SSI3_TX?
Hi Lei Ge,
At present Audio Capture rate is 44100 sampling rate, while playback rate is also 44100 sampling rate.
INCLK_SSI1_RX = 64*fs
OUTCLK_SSI3_TX = 32*fs
where fs=44100.
Following setup for ASRC registers (Clock Divider Registers):
ASRC_ASRCDR1::
1. set value '6' in 'AICPA' bit "Input Clock Prescaler A". So, prescaling ratio would be 64.
2. set value '5' in 'AOCPA' bit "Output Clock Prescaler A". So, prescaling ratio would be 32.
I will try to read FIFO status of ASRC & SSI when issue occurs.
-Ankit.
hi,
codec ----> ssi ---rate1--> asrc ---rate2--> memory
what's the rates of rate1, rate2? all 44100?
Hi Lei Ge,
codec ----> ssi ---44100--> asrc ---44100--> memory
We read FIFO status of SSI & ASRC when Audio lost ("Unvalid SDMA MODE" occurs).
Following registers are read, when interrupt received for above error.
ASRC:-
ASRC_ASRFSTA- value = 0x1f023
Analysis:: Its suggest that INPUT FIFO filled with 35 samples, while OUTPUT FIFO filled with 31 samples.
ASRC_ASRSTR- value = 0x200080
SSI:-
SSIx_SSI_SISR- value = 0x1011
SSIx_SSI_SFCSR- value = 0x460046
Analysis:: Its suggest that currently no samples in RxFIFO-0
-Ankit.
what's the value of ASRC_ASRMCRA? threshold of the asrc input and output fifo?
Hi Lei Ge,
Threshold value of input & output FIFO both equal to '32'.
Register value set to ASRC_ASRMCRA is:- 0x620020
-Ankit.
so, from your register values, there i no fifo overflow? if only capture, not playback and capture at the same time, is this issue still happen?
Hi Lei Ge,
In ASRC's Input FIFO no overflow, while SSI Rx FIFO seems empty when "Unvalid SDMA MODE" interrupt generated.
We have test once, where only Capture test setup with Playback clock (SSI-3) on all the time. Issue also occurred.
-Ankit.
can it be reproduced in FSL's sebresd board?
Hi Lei Ge,
SabreSD board contains one Audio chip wm8962, which support both audio playback & capture. In BSP, no ASRC added as well for wm8962.
-Ankit.
you can add your patch: codec -->ssi --> asrc --> memory to sebresd board to see if sebresd board has the same issue, then we can help debug, or can you take your special board to China to debug with us?
Hi Lei Ge,
I seen the code of imx_wm8962.c [cpu dai] & wm8962.c [codec dai]. In both the case capture & playback wm8962 chip is master.
I will try to do wm8962 -> ssi -> asrc -> memory & will give ssi-3 clocking to asrc.
-Ankit.
is your sebresd board patch ok now for SSI_ASRC capture?
this is my patch:https://community.freescale.com/docs/DOC-100415
it works well in sebresd board, and so far, no 'unvailid SDMA mode' issue happen.
Hi Lei Ge,
Thank you for your patch.
As on Sabresd board, WM8962 chip (acting as MASTER); which support both capture & playback, connected on SSI-2. I will try to setup SSI->ASRC->Mem Capture path; for Sabresd board, using two clock source given to ASRC (i.e config.inclk = INCLK_SSI2_RX, config.outclk = OUTCLK_SSI3_TX).
In your patch only one clock, i.e. OUTCLK_SS2_TX is active while inclk is NONE. Which is not a scenario in our case.
Regarding S24_LE, we have not faced such a issue. May be possible reason would be ASRC not receive 24 bit data in sequence.
-Ankit.
hi, something wrong with my patch and your patch:
mem <--1--- ASRC <-- 2-- SSI <--3-- codec
For capture,
position 1: sample rate and data format should be determined by arecord's command 'arecord -c 2 -r 48000 -f S24_LE'
position 2 and 3: sample rate and data format should be determined by asrc.
Take below as an example:
If an audio codec doesn't support 48000 and S24_LE(only support 44100 and S16_LE), you use 'arecord -c 2 -r 48000 -f S24_LE' to capture
You should modify your position 2 and 3's code to capture 44100 and S16_LE data, then use asrc to convert it to 48000 and S24_LE.
So, position 1's data_width =parmas_format(params); rate = params_rate(params)
position 2 and 3's data_witdth and rate should be set by asrc.