]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_arm/framework/audioStreamDecodeProc.c
Build #38: remove GPIO debug
[processor-sdk/performance-audio-sr.git] / pasdk / test_arm / framework / audioStreamDecodeProc.c
index 197af1dba413bc58b2d49605e887bda5d6afc699..12c4e8b6902badc2a36011662f9458661ed2d025 100644 (file)
@@ -61,6 +61,9 @@ All rights reserved.
 #include "audioStreamProc_common.h"
 #include "audioStreamDecodeProc.h"
 
+#include "statusOp_common.h"
+
+
 // FL: debug
 //#include "fwkSim.h"
 #include "dbgCapAf.h"
@@ -98,9 +101,11 @@ PAF_AudioData  *gDecAudioFrameChannelPointers[PAF_MAXNUMCHAN_AF];
 PAF_AudioSize  gDecAudioFrameChannelSizes[PAF_MAXNUMCHAN_AF];
 PAF_AudioData  *gDecOrigAudioFrameChannelPointers[PAF_MAXNUMCHAN_AF];
 
-// Underflow threshold before returning error to Top-Level FSM
+// Overflow threshold before circular buffer reset and return error to Top-Level FSM
 #define DEC_OP_CB_WRTAF_OVR_THR  ( 20 ) // FL: arbitrary setting
-UInt32 gDecOpCbWrtAfOvr  =0; // decoder output circular buffer overflow count
+UInt32 gCbWrtAfErrCnt           =0; // decoder output circular buffer write error count, not including overflows
+UInt32 gDecOpCbWrtAfOvr         =0; // decoder output circular buffer overflow count
+UInt32 gMaxDecOpCbWrtAfOvr      =0; // max (consecutive) decoder output circular buffer overflow count
 
 // Global debug counters */
 UInt32 gSlaveStartErrCnt        =0;
@@ -116,6 +121,10 @@ UInt32 gSlaveDecDecodeCnt       =0;
 UInt32 gSlaveDecDeactivateCnt   =0;
 
 
+// FL: (***) debug
+#include "evmc66x_gpio_dbg.h"
+
+
 /*
  *  ======== taskAsdpFxn ========
  *  Audio Stream Decode Processing task function
@@ -155,6 +164,7 @@ Void taskAsdpFxn(
     Int status;
     Int zI;
     Int bufEnd, wrapSize, currentBufSize, chunkSize;
+    Int8 temp8;
 
     
     Log_info0("Enter taskAsdpFxn()");
@@ -271,6 +281,28 @@ Void taskAsdpFxn(
         pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, HEAP_INTERNAL1_SHM);
     }
     
+#ifdef NON_CACHE_STATUS
+    //
+    // init Status structure Gate
+    //
+    if (statusOp_Init(GATEMP_INDEX_DEC) == STATUSOP_INIT_FAIL)
+    {
+        TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_DEC);
+    }
+    if (statusOp_Init(GATEMP_INDEX_DDP) == STATUSOP_INIT_FAIL)
+    {
+        TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_DDP);
+    }
+    if (statusOp_Init(GATEMP_INDEX_PCM) == STATUSOP_INIT_FAIL)
+    {
+        TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_PCM);
+    }
+    if (statusOp_Init(GATEMP_INDEX_THD) == STATUSOP_INIT_FAIL)
+    {
+        TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_THD);
+    }
+#endif
+
     // (***) FL: revisit
     // write back Status structure addresses for Beta Units initialized on Slave
     Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
@@ -284,26 +316,22 @@ Void taskAsdpFxn(
     
     // (***) FL: revisit
     // write back Status structures for Beta Units initialized on Slave
-    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
-    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
+   /* size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
+    Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
     size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
-    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
+    Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
     size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]->size;
-    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), size, Cache_Type_ALLD, 0);
+    Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), size, Cache_Type_ALLD, 0);
     size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]->size;
-    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
+    Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
     size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]->size;
-    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), size, Cache_Type_ALLD, 0);
-    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]->size;
-    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), size, Cache_Type_ALLD, 0);
-    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]->size;
-    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), size, Cache_Type_ALLD, 0);
+    Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), size, Cache_Type_ALLD, 0);
     Cache_wait();
 
     // (***) FL: revisit
     // write back Dec configuration
-    Cache_wb(&pAstCfg->xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
-    Cache_wait();
+    Cache_wbInv(&pAstCfg->xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+    Cache_wait();*/
     
     // Send initialization complete message to master
     queId = MessageQ_getReplyQueue(pAspMsg);
@@ -445,13 +473,11 @@ Void taskAsdpFxn(
                     // invalidate Status structures for shared Beta Units
                     //size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
                     //Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
-                    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
+                    /*size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
                     Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
                     size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]->size;
                     Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
-                    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]->size;
-                    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), size, Cache_Type_ALLD, 0);
-                    Cache_wait();
+                    Cache_wait();*/
                     
                     argIdx = 0; // get decIdx
                     z = *(Int32 *)&pAspMsg->buf[argIdx];
@@ -473,6 +499,9 @@ Void taskAsdpFxn(
                     {
                         SW_BREAKPOINT;
                     }
+                    gCbWrtAfErrCnt=0;       // reset write circular buffer error count
+                    gDecOpCbWrtAfOvr=0;     // reset decoder output circular buffer overflow count
+                    gMaxDecOpCbWrtAfOvr=0;  // reset max decoder output circular buffer overflow count
                     // FL: debug, log circular buffer control variables
                     cbLog(pCbCtl, z, 1, "cbWriteStart");
                     // Reset audio frame
@@ -516,13 +545,11 @@ Void taskAsdpFxn(
                     // write back Status structures for shared Beta Units
                     //size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
                     //Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
-                    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
-                    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
+                   /* size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
+                    Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
                     size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]->size;
-                    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
-                    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]->size;
-                    Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), size, Cache_Type_ALLD, 0);
-                    Cache_wait();
+                    Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
+                    Cache_wait();*/
                     
                     // send dec reset complete message to master
                     queId = MessageQ_getReplyQueue(pAspMsg);
@@ -550,7 +577,7 @@ Void taskAsdpFxn(
                     TRACE_TERSE2("slaveCmd=%d,decIdx=%d", slaveCmd, z);
                     // Get input associated w/ decoder
                     zI = pP->inputsFromDecodes[z];
-                    
+
                     // (***) FL: revisit
                     // invalidate Inp configuration
                     Cache_inv(&pAstCfg->xInp[zI], sizeof(PAF_AST_InpBuf), Cache_Type_ALLD, 0);
@@ -560,7 +587,7 @@ Void taskAsdpFxn(
                     size = pIpBufConfig->frameLength * pIpBufConfig->sizeofElement;
                     if (sourceSelect == PAF_SOURCE_PCM)
                     {
-                       size *= pIpBufConfig->stride;
+                        size *= pIpBufConfig->stride;
                     }
 
                     bufEnd = (Int) pIpBufConfig->base.pVoid + pIpBufConfig->sizeofBuffer;
@@ -605,12 +632,25 @@ Void taskAsdpFxn(
                     Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
                     Cache_wait();            
                     
-                    // Re-initialize audio frame if decoder is disabled or 
-                    // doesn't have a valid input 
+#ifdef NON_CACHE_STATUS
+                    statusOp_read(&(temp8),
+                                  &(pAstCfg->xDec[z].decodeStatus.mode),
+                                  sizeof(Int8),
+                                  GATEMP_INDEX_DEC);
+                    // Re-initialize audio frame if decoder is disabled or
+                    // doesn't have a valid input
+                    if (!temp8 || !pAstCfg->xInp[zI].hRxSio)
+                    {
+                        pP->fxns->initFrame1(pP, pQ, pC, z, 0);
+                    }
+#else
+                    // Re-initialize audio frame if decoder is disabled or
+                    // doesn't have a valid input
                     if (!pAstCfg->xDec[z].decodeStatus.mode || !pAstCfg->xInp[zI].hRxSio)
                     {
                         pP->fxns->initFrame1(pP, pQ, pC, z, 0);
                     }
+#endif
 
                     // send dec info complete message to master
                     queId = MessageQ_getReplyQueue(pAspMsg);
@@ -660,7 +700,7 @@ Void taskAsdpFxn(
                         errno = dec->fxns->decode(dec, NULL, &pAstCfg->xDec[z].decodeInStruct, &pAstCfg->xDec[z].decodeOutStruct);
                         if (errno < 0)
                         {
-                            SW_BREAKPOINT;
+                            //SW_BREAKPOINT;
                         }
                         TRACE_TERSE0("Dec:decode done");
                         
@@ -679,28 +719,53 @@ Void taskAsdpFxn(
                         //}                        
 
                         cbErrno = cbWriteAf(pCbCtl, z, pAfWrt);
-                        if (cbErrno < 0)
+                        if ((cbErrno < 0) && (cbErrno != ASP_DECOP_CB_WRITE_OVERFLOW))
                         {
+                            gCbWrtAfErrCnt++;
                             //SW_BREAKPOINT; // FL: debug
-                            
-                            if (cbErrno == ASP_DECOP_CB_WRITE_OVERFLOW)
+                        }
+                        
+                        // Handle overflows
+                        if (cbErrno == ASP_DECOP_CB_WRITE_OVERFLOW)
+                        {
+                            gDecOpCbWrtAfOvr++; // increment circular buffer overflow count
+                            if (gDecOpCbWrtAfOvr >= DEC_OP_CB_WRTAF_OVR_THR)
                             {
+                                gMaxDecOpCbWrtAfOvr = DEC_OP_CB_WRTAF_OVR_THR; // update max overflow count
+                                gDecOpCbWrtAfOvr = 0; // reset overflow count
+                                
                                 // Reset circular buffer
                                 cbReset(pCbCtl, z);
-                                // Update overflow count, return if above threshold
-                                gDecOpCbWrtAfOvr++;
-                                if (gDecOpCbWrtAfOvr < DEC_OP_CB_WRTAF_OVR_THR)
-                                {
-                                    cbErrno = 0;
-                                }
-                                else 
-                                {
-                                    gDecOpCbWrtAfOvr = 0;
-                                }
                             }
                         }
+                        else if ((cbErrno == ASP_DECOP_CB_SOK) && (gDecOpCbWrtAfOvr > 0))
+                        {
+                            // No overflow detected.
+                            // update max overflow count,
+                            // reset overflow count
+                            
+                            if (gDecOpCbWrtAfOvr > gMaxDecOpCbWrtAfOvr)
+                            {
+                                gMaxDecOpCbWrtAfOvr = gDecOpCbWrtAfOvr;
+                            }
+                            gDecOpCbWrtAfOvr = 0; // reset circular buffer overflow count
+                            
+                            cbErrno = 0; // don't return error condition
+                        }
                         TRACE_TERSE0("Dec:cbWriteAf() complete");
                         
+#if 0 // (***) FL: shows timing of CB write
+                        // (***) debug // B9
+                        {
+                            static Uint8 toggleState = 0;
+                            if (toggleState == 0)
+                                GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_107);
+                            else
+                                GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_107);
+                            toggleState = ~(toggleState);
+                        }
+#endif        
+                        
                         // FL: debug, log circular buffer control variables
                         cbLog(pCbCtl, z, 1, "cbWriteAf");
                     }
@@ -709,13 +774,25 @@ Void taskAsdpFxn(
                     Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
                     Cache_wait();
                     
+#ifdef NON_CACHE_STATUS
+                    statusOp_read(&(temp8),
+                                  &(pAstCfg->xDec[z].decodeStatus.mode),
+                                  sizeof(Int8),
+                                  GATEMP_INDEX_DEC);
                     // Re-initialize audio frame if decoder is disabled or 
                     // doesn't have a valid input 
+                    if (!temp8 || !pAstCfg->xInp[zI].hRxSio)
+                    {
+                        pP->fxns->initFrame1(pP, pQ, pC, z, 0);
+                    }
+#else
+                    // Re-initialize audio frame if decoder is disabled or
+                    // doesn't have a valid input
                     if (!pAstCfg->xDec[z].decodeStatus.mode || !pAstCfg->xInp[zI].hRxSio)
                     {
                         pP->fxns->initFrame1(pP, pQ, pC, z, 0);
                     }
-
+#endif
                     // send dec info complete message to master
                     queId = MessageQ_getReplyQueue(pAspMsg);
                     pAspMsg->procId = hAspMsgSlave->slaveProcId;
@@ -996,11 +1073,12 @@ PAF_ASDT_initPhaseCommon(
 
     TRACE_TERSE0("PAF_ASDT_initPhaseCommon: calling PAF_ALG_setup.");
     PAF_ALG_setup(&pafAlgConfig, 
-        HEAP_ID_INTERNAL,       HEAP_INTERNAL, 
-        HEAP_ID_INTERNAL1,      HEAP_INTERNAL1, 
-        HEAP_ID_EXTERNAL,       HEAP_EXTERNAL, 
-        HEAP_ID_INTERNAL1_SHM,  HEAP_INTERNAL1_SHM, 
-        HEAP_ID_EXTERNAL_SHM,   HEAP_EXTERNAL_SHM, 
+        HEAP_ID_INTERNAL,               HEAP_INTERNAL, 
+        HEAP_ID_INTERNAL1,              HEAP_INTERNAL1, 
+        HEAP_ID_EXTERNAL,               HEAP_EXTERNAL, 
+        HEAP_ID_INTERNAL1_SHM,          HEAP_INTERNAL1_SHM, 
+        HEAP_ID_EXTERNAL_SHM,           HEAP_EXTERNAL_SHM, 
+        HEAP_ID_EXTERNAL_NONCACHED_SHM, HEAP_EXTERNAL_NONCACHED_SHM,
         HEAP_CLEAR);
 
     if (pP->fxns->headerPrint)
@@ -1240,7 +1318,7 @@ PAF_ASDT_initFrame0(
     //maxFrameLength += PA_MODULO - maxFrameLength % PA_MODULO; // compute maximum framelength (needed for ARC support)
     //aLen = numchan[z] * maxFrameLength;
     aLen = numchan[z] * maxFrameLength + (maxFrameLength - FRAMELENGTH); /* Qin - need additional memory for starting offset
-                                                                                     See line 1307 */
+                                                                                     See line 1301 */
 
     //
     // Initialize audio frame elements directly