Audio LOST after ~10 hrs on i.MX 6Q

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

Audio LOST after ~10 hrs on i.MX 6Q

7,284 Views
_at
Contributor III

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

Tags (3)
0 Kudos
68 Replies

900 Views
_at
Contributor III

Hi Lei Ge,

In our case, at all position data format is same S16_LE  &sample rate is 44100.

We are using two clock as source to ASRC (i.e config.inclk = INCLK_SSI1_RX, config.outclk =  OUTCLK_SSI3_TX).

-Ankit.

0 Kudos

900 Views
_at
Contributor III

Hi Lei Ge,

I am able to reproduce this issue "Audio LOST after ~10 hrs on i.MX 6Q"  on SABRE-SD board.

I will give you patch of ASRC which uses two real time clock source(i.e config.inclk = INCLK_SSI1_RX, config.outclk =  OUTCLK_SSI3_TX)  & tinyalsa test to reproduce this issue.

-Ankit.

0 Kudos

900 Views
_at
Contributor III

Hi Lei Ge,

I am able to reproduce the issue "Audio LOST after ~10 hrs on i.MX 6Q"  on SABRE-SD board.

I am using Android source code of: IMX6_JB43_110_ANDROID_SOURCE_BSP provided by Freescale for SABRE-SD board.

I have used your patch attached here:: https://community.freescale.com/docs/DOC-100415    Followed all patch which mentioned in you link.


Here i am attaching patch (Audio_lost_using_ASRC_two_realtime_clock_P2P_channel_SABRESD.zip, include all patch mentioned in your link) which include modification i have done apart from your above patch to use two real time clock for ASRC:

  1. arch/arm/mach-mx6/board-mx6q_sabresd.c
    • Added SSI-3.
    • This SSI-3 is used for clocking to ASRC ;as a playback clock.
  2. arch/arm/mach-mx6/clock.c
    • Change clock source of all SSI ( ssi-1, ssi-2, ssi-3) to pll4_audio_main_clk.
    • Modify clock rate of PLL4 to 180633600 [which is calculated (44100 * 512 * 8) = 180633600].
    • This change used to get bitclock of (32*fs).
  3. drivers/dma/imx-sdma.c
    • Added log to get FIFO status of ASRC & SSI-2 when 'Unvalid SDMA mode' interrupt occurs.
  4. drivers/mxc/asrc/mxc_asrc.c
    • Added API to get FIFO status of ASRC. 
  5. sound/soc/imx/imx-ssi.c
    • Added API imx_dummy_ssi_on_or_off().
    • This API will simply enable/disable SSI-3 clock & set its DIV2 & PSR  to get (32*fs) bit clock.
    • Added API ssi_fifo_status(), use to get FIFO status of SSI-2.
    • I took reference of ssi-2 & ssi-3 in global variables.
  6. sound/soc/imx/imx-wm8962.c
    • Enable SSI-3 clocking by calling above api imx_dummy_ssi_on_or_off() when ASRC going to configure.
    • Disable SSI-3 clocking by calling above api imx_dummy_ssi_on_or_off()() when ASRC going to release.

Use 'tinycap' utility to capture only raw PCM data from console (provided in /system/bin).

As this utility 'tinycap' fwrite raw data in file, i have simply disabled fwrite code in 'tinycap' utility source code & created new 'tinycap' utility;which is attached here. Which simply do 'pcm_read() in while loop.

So, now ASRC uses two differenct real time clock source ( one is WM8962;send clock on SSI-2 & another is SSI-3) as input (i.e config.inclk = INCLK_SSI2_TX, config.outclk =  OUTCLK_SSI3_TX). Based upon that it will do Sample rate conversion. (here in our case simply do a sync two clock as both clock are at 32*fs, where fs=44100).

ASRC configured as (32*fs); where fs=44100.

Use following command :: tinycap record_asrc.wav -D 0 -d 1 -c 2 -r 44100 -b 16

You can use your 'arecord' utility as well to reproduce this issue. (disable fwrite code in 'arecord' utility as well, because it will mess up stoarge on external storage).

Please provide us comment upon this.

-Ankit.

0 Kudos

900 Views
_at
Contributor III

This is the log i received on SABRE-SD board after ~10 hrs.

///////////////////  start ////////////

root@sabresd_6dq:/extsd/ATP/tinyalsa_test # tinycap record_asrc.wav -D 0 -d 1 -c 2 -r 44100 -b 16

PCM OPEN with 16 bit

ssi3 B4: clock is 22579200 after = 22579200 REQUIRED:22579200

SSI3 ENABLED

  ###ASRC RECORD: P2P dma channel ID:0 CONFIGURED! ASRC RX ReqID:41, SSI RX ReqID: 17

  ###ASRC RECORD: P2M dma channel ID:1 CONFIGURED! ASRC TX ReqID:20

Capturing sample: 2 ch, 44100 hz, 16 bit

imx_hifi_trigger

####SRxF:1, Aif:35, Aof:32, SF:461046, Serr:5011, AF:20023, Aerr:200080

####SDMA_H_EVTERR: 2, ch:1, id:0

Unvalid SDMA MODE!

imx_hifi_trigger

SSI3 DISABLED

##ASRC CAPTURE snd_imx_pcm_hw_free

/////////////////   end //////////////

0 Kudos

900 Views
_at
Contributor III

Hi LeiGe,

Any comment for this issue?

-Ankit.

0 Kudos

900 Views
_at
Contributor III

Hi LeiGe,

Sorry for late reply... But this issue is still not resolved.

I applied above patch & didn't swap gReg0 & gReg1. But issue still occurs.

-Ankit.

0 Kudos

900 Views
saurabh206
Senior Contributor III

Hi,

Lei Ge

Thanks for this patch we will apply this patch and provide you update.

Thanks

Saurabh/Ankit

0 Kudos

900 Views
leige-b42127
Senior Contributor II

can you try the attached patch, this patch is used to slove a ssi p2p issue, you don't need to swap gReg0 and gReg1 if you use this patch.

0 Kudos

900 Views
fabio_estevam
NXP Employee
NXP Employee

Ankit,

Could you try 3.10.17 GA kernel?

0 Kudos

900 Views
leige-b42127
Senior Contributor II

check on going

0 Kudos

900 Views
_at
Contributor III

Hi Lei Ge,

Any comments upon above reply ??

-Ankit.

0 Kudos

900 Views
_at
Contributor III

Hi Lei Ge,

I have apply your patch mentioned here (patch-1 & patch-2) -> https://community.freescale.com/docs/DOC-100658

This patch is *not* uses two different real time clock source to ASRC. This patch is simply doing Sample rate conversion for what ASRC configured for.

We want to use ASRC to do sample rate conversion using two different real time clock source. [i.e on sabre-sd one codec (wm8962) sending audio data & clocking to SSI-2 (capture path), while other codec (here not connected but assume it connected) playing audio data & clocking using SSI-3 (i.e).

Here i am attaching patch:

patch-ssi3:: only_ssi3.patch

This only_ssi3.patch is based on above mentioned patch(patch-1 & patch-2). Explanation of this patch & change files is mentioned in my above reply.

Even after applied your patch + little modification for ASRC, "Unvalid SDMA MODE!" error occurs after ~10 hrs & audio stop capture because of P2P channel was off by SDMA.

We want to sync & sample rate conversion of two different clock source using ASRC.

The incoming audio data to this chip (imx6q) may be received from various sources at different sampling rates (capture codec). The outgoing audio data of this chip may have different sampling rates and it can also be associated with output clocks that are asynchronous to the input clocks. [Chapter 15 Asynchronous Sample Rate Converter (ASRC)].

Please review our patch & give comment upon this.

-Ankit.

0 Kudos

900 Views
leige-b42127
Senior Contributor II

hi
https://community.freescale.com/docs/DOC-100415 this patch is wrong.

https://community.freescale.com/docs/DOC-100658 this patch is right for SSI_ASRC_2P capture.

  memory <-- ASRC_Output FIFO | ASRC_Input FIFO <-- SSI_RX FIFO <-- Audio Codec 

                                             |           |

    ASRC Out clk ASRCK1 <---|           |--->   ASRC In clk None

                                             |           |

    ASRC OutPut width            |           |       ASRC InPut width and data format

    is set by arecord            <---|           |--->   is set by ASRC P2P parameter

    parameter                          |           |

                                            |           |

    support 44100/48000          |           |       support 44100/48000

    and S24_LE/S16_LE     <---|           |--->   and S24_LE/S16_LE


   You can use:

    arecord -Dhw:0,1 -c 2 -f S16_LE/S24_LE -r 44100/48000 XXX.wav

    aplay XXX.wav

    to test this patch.

900 Views
leige-b42127
Senior Contributor II


i use ssi slave mode and

179         config.inclk = INCLK_NONE;

180         config.outclk = OUTCLK_SSI2_TX;

0 Kudos

900 Views
_at
Contributor III

Hi Lei Ge,

You had setup SSI->ASRC->Mem for non-realtime streaming audio (where the input sampling rate clocks avoided by setting ideal-ratio values into ASRC interface registers)

We need to setup realtime streaming audio (where both input and output clocks need to be available and activated).

In our case, both clocks are given to ASRC (config.inclk = INCLK_SSI1_RX  , config.outclk =  OUTCLK_SSI3_TX).

-Ankit.

0 Kudos

900 Views
leige-b42127
Senior Contributor II

hi, when i use S24_LE, the voice captured is much bigger in one channel than the other, do you have such issue?

static const struct asrc_p2p_params ssi_p2p = {

       .p2p_rate = 44100,

       .p2p_width = ASRC_WIDTH_24_BIT,

};

0 Kudos

900 Views
leige-b42127
Senior Contributor II

i am now adding and testing SSI ASRC P2P for capture in our sebresd board now , for about half day now, so far, no such 'unvalid sdma mode' issue found.

0 Kudos

900 Views
leige-b42127
Senior Contributor II


I am now adding SSI ASRC P2P for capture in our sebresd board too, i will test if this issue happens in our board.

0 Kudos

900 Views
leige-b42127
Senior Contributor II

i use  this command for test under linux:
arecord -Dhw:0,1 -c 2 -f S16_LE -r 44100 | aplay

0 Kudos

901 Views
leige-b42127
Senior Contributor II

hi, what format do you use, S16_LE or S24_LE?

0 Kudos

901 Views
_at
Contributor III

Hi Lei Ge,

We use S16_LE

-Ankit.

0 Kudos