]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_dsp/framework/audioStreamInpProc.c
Build #38: remove GPIO debug
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamInpProc.c
index 937b61ca2c732b34b9a85628f99173b5f320609e..bf595044718a60f6a722487abb1ccd78f2b7b70b 100644 (file)
@@ -298,20 +298,25 @@ PAF_ASIT_Config gPAF_ASIT_config = {
 };
 
 // Global debug counters */
-UInt32 gTaskAsipCnt=0; // debug
-UInt32 gAsipInitCnt     =0;
-UInt32 gAsipInfo1Cnt    =0;
-UInt32 gAsipInfo2Cnt    =0;
-UInt32 gAsipDecodeCnt   =0;
-UInt32 gAsipDecodeErrCnt   =0;
-UInt32 gAsipFinalCnt    =0;
-UInt32 gAsipQuitCnt     =0;
-UInt32 gIbReset_cnt    =0;
-UInt32 gcapIb_cnt              =0;
+UInt32 gTaskAsipCnt             =0;
+UInt32 gAsipInitCnt             =0;
+UInt32 gAsipInfo1Cnt            =0;
+UInt32 gAsipInfo2Cnt            =0;
+UInt32 gAsipDecodeCnt           =0;
+UInt32 gAsipDecodeErrCnt        =0;
+UInt32 gAsipFinalCnt            =0;
+UInt32 gAsipQuitCnt             =0;
+UInt32 gAsipInfo1_PrimaryErrCnt =0;
+UInt32 gAsipInfo1_ErrCnt        =0;
 UInt32 gAsipInfo2_PrimaryErrCnt =0;
-UInt32 gAsipInfo2_ErrCnt               =0;
+UInt32 gAsipInfo2_ErrCnt        =0;
+UInt32 gCapIbReset_cnt          =0;
+UInt32 gCapIb_cnt               =0;
+// debug
+UInt32 gCbWrtAfErrCnt           =0; // decoder output circular buffer write error count (returned from ARM to DSP)
+                                   
 
-#include "dbgDib.h"
+#include "dbgDib.h" // debug
 
 extern struct {
     Int size;
@@ -319,7 +324,6 @@ extern struct {
 } IACP_STD_BETA_TABLE;
 
 // FL: debug
-#include "evmc66x_pinmux.h"
 #include "evmc66x_gpio_dbg.h"
 
 /*
@@ -348,6 +352,7 @@ Void taskAsipFxn(
 #ifdef NON_CACHE_STATUS
     Int8 tempVar8;
 #endif
+    Task_Handle taskHandle;
 
     Log_info0("Enter taskAsipFxn()");
     
@@ -384,6 +389,8 @@ Void taskAsipFxn(
     pAstCfg->as = as;    
     TRACE_TERSE1("TaskAsip: Started with AS%d.", as);
 
+    taskHandle = Task_self();
+    
     //
     // Initialize message log trace and line number reporting
     //
@@ -881,7 +888,7 @@ Void taskAsipFxn(
 
         // FL: debug, reset IB capture buffer
         capIbReset();
-        gIbReset_cnt++;
+        gCapIbReset_cnt++;
         Log_info0("capIbReset()");
 
         // FL: send source select message to slave
@@ -930,6 +937,9 @@ Void taskAsipFxn(
         
         TRACE_VERBOSE1(procName[sourceProgram], as+zMS);
 
+        // Reduce priority level since autodetection complete
+        Task_setPri(taskHandle, Task_getPri(taskHandle)-1);
+        
         TRACE_VERBOSE0("TaskAsip: calling decodeProcessing.");
         errno = pP->fxns->decodeProcessing(pP, pQ, pC, sourceSelect);
         if (errno) 
@@ -941,6 +951,9 @@ Void taskAsipFxn(
             TRACE_VERBOSE0("TaskAsip: decodeProcessing complete with no error.");
         }        
 
+        // Increase priority level since decoding complete
+        Task_setPri(taskHandle, Task_getPri(taskHandle)+1);
+
         // FL: send dec exit message to slave
         pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize); /* allocate message */
         MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg);            /* set the return address in the message header */
@@ -1914,8 +1927,20 @@ PAF_ASIT_autoProcessing(
     nbytes = SIO_reclaim(pAstCfg->xInp[zMI].hRxSio, (Ptr)&pAstCfg->xInp[zMI].pInpBuf, NULL);
     if (nbytes == -DIBERR_SYNC)
     {
+#if 0 // (***) FL: shows timing of autosync restart
+        // (***) debug // B5
+        {
+            static Uint8 toggleState = 0;
+            if (toggleState == 0)
+                GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99);
+            else
+                GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
+            toggleState = ~(toggleState);
+        }
+#endif        
+        
         TRACE_TERSE2("PAF_ASIT_autoProcessing: AS%d: SIO_reclaim returned 0x%x, ignoring", as+zMS, nbytes);
-        return 0;
+        return nbytes;
     }
     if (nbytes != sizeof(PAF_InpBufConfig))
     {
@@ -2054,6 +2079,10 @@ PAF_ASIT_decodeProcessing(
 
     for (;;) 
     {
+        statusOp_read(&tempVar8,
+                      &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
+                    sizeof(tempVar8),
+                    GATEMP_INDEX_DEC);
         if (tempVar8 == PAF_SOURCE_NONE)
         {
 #else
@@ -2101,18 +2130,21 @@ PAF_ASIT_decodeProcessing(
                 gAsipInitCnt++;
                 Log_info0("TaskAsip: state=INIT");
 
-                // (***) FL: revisit
-#if 1 // status for shared beta units can change (e.g. at-boot or alpha)
+#if 0 // Not necessary since decoder status is in uncached memory
+                // status for shared beta units can change (e.g. at-boot or alpha)
+                
                 // 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;
+                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_DDP]->size;
                 Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
-                Cache_wait();*/
+                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();
 #endif
-#if 0
+#if 0 // Not necessary since decoder status is in uncached memory
                 ////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;
@@ -2128,16 +2160,21 @@ PAF_ASIT_decodeProcessing(
                     break;
                 }
                 
-#if 1
-                // (***) FL: revisit
+                //
+                // Not necessary since decoder status is in uncached memory
+                //
+               
+#if 0 // Not necessary since decoder status is in uncached memory
                 // 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);
-                Cache_wait();*/
+                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();
 #endif
                 
                 frame = 0;
@@ -2167,7 +2204,7 @@ PAF_ASIT_decodeProcessing(
                 // Establish primary timing
                 if (errno = pP->fxns->decodeInfo(pP, pQ, pC, frame, block))
                 {
-                    gProbe1Err++;
+                    gAsipInfo1_PrimaryErrCnt++;
                     TRACE_TERSE1("INFO1: errno 0x%x after decodeInfo, primary timing", errno);
                     break;
                 }
@@ -2180,7 +2217,6 @@ PAF_ASIT_decodeProcessing(
 #endif                
 
 
-#if 0 // (***) FL: debug
 #ifdef NON_CACHE_STATUS
                 statusOp_read(&tempVar8,
                               &(pAstCfg->xDec[zMD].decodeStatus.sourceDecode),
@@ -2234,13 +2270,13 @@ PAF_ASIT_decodeProcessing(
                     state = INFO1;
                     continue;
                 }
-#endif // (***) FL: debug         
                 TRACE_VERBOSE1("PAF_ASIT_decodeProcessing: INFO1: frame %d, major access unit found", frame);
 
                 // Establish secondary timing
                 if (errno = pP->fxns->decodeInfo1(pP, pQ, pC, frame, block))
                 {
                     TRACE_VERBOSE1("PAF_ASIT_decodeProcessing: INFO1, errno 0x%x.  break after decodeInfo1", errno);
+                    gAsipInfo1_ErrCnt++;
                     break;
                 }
 
@@ -2497,7 +2533,6 @@ PAF_ASIT_decodeInit(
     Int zMI;
     ASP_Msg* pAspMsg;                   /* Messaging */
     Int argIdx;
-    Int decErrno;
     Int status;
 #ifdef NON_CACHE_STATUS
     Int8 tempVar8;
@@ -2562,7 +2597,6 @@ PAF_ASIT_decodeInit(
             Int frameLength;
             TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: initializing decode", as+zS);
 
-#if 0 // (***) FL: debug
             // write back Dec configuration
             Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
             Cache_wait();
@@ -2658,14 +2692,13 @@ PAF_ASIT_decodeInit(
                 TRACE_MSG1("decErrno=%d", pAspMsg->buf[0]);
 
                 argIdx = 0; // get decErrno
-                decErrno = *(Int32 *)&pAspMsg->buf[argIdx];
-                if (decErrno != 0)
-                {
-                    return decErrno;
-                }
+                errno = *(Int32 *)&pAspMsg->buf[argIdx];
             }
             else
             {
+                //
+                // Invalid message received
+                //
                 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
                 SW_BREAKPOINT; // temporary
                 return -1; // temporary
@@ -2676,12 +2709,11 @@ PAF_ASIT_decodeInit(
             {
                 SW_BREAKPOINT;
             }
-
+            
             // (***) FL: revisit
             // invalidate Dec configuration
             Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
             Cache_wait();
-#endif // (***) FL: debug
             
 #if 0 // FL: decoder reset call, slave
             if (dec->fxns->reset
@@ -2689,6 +2721,10 @@ PAF_ASIT_decodeInit(
                                               &pC->xDec[z].decodeControl, &pC->xDec[z].decodeStatus)))
                 return errno;
 #endif
+            if (errno != 0)
+            {
+                return errno;
+            }
             
 #ifdef NON_CACHE_STATUS
             gear = 0;  // due to size difference
@@ -2844,8 +2880,8 @@ PAF_ASIT_decodeInfo(
     Int tempVar;
 #endif
     // FL: revisit
-    Int size;
-    PAF_InpBufConfig *pIpBufConfig;
+    //Int size;
+    //PAF_InpBufConfig *pIpBufConfig;
 
     pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
     as = pAstCfg->as;
@@ -2924,8 +2960,10 @@ PAF_ASIT_decodeInfo(
         
         // FL: debug, capture input buffer
         capIb(pAstCfg->xInp[zMI].pInpBuf);
-        gcapIb_cnt++;
+        gCapIb_cnt++;
         
+#if 0 // (***) FL: shows timing of Input Rx SIO reclaim after decoding has started (autodet complete)
+        // (***) debug // B5
         {
             static Uint8 toggleState = 0;
             if (toggleState == 0)
@@ -2934,7 +2972,8 @@ PAF_ASIT_decodeInfo(
                 GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
             toggleState = ~(toggleState);
         }
-        
+#endif
+
         //
         // Simulate Rx SIO_reclaim() pend
         //
@@ -2972,7 +3011,6 @@ PAF_ASIT_decodeInfo(
                 return errno;
             }
 
-#if 0 // (***) FL: debug
 #if 1
             // (***) FL: revisit
             // write back Inp configuration
@@ -3016,15 +3054,26 @@ PAF_ASIT_decodeInfo(
                 SW_BREAKPOINT;
                 return -1; // temporary
             }
-            if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) || 
-                (pAspMsg->cmd != ASP_MASTER_DEC_INFO_DONE) || 
-                (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
+            if ((pAspMsg->procId == hAspMsgMaster->slaveProcId) &&
+                (pAspMsg->cmd == ASP_MASTER_DEC_INFO_DONE) && 
+                (pAspMsg->messageId == (hAspMsgMaster->messageId | ((UInt32)1<<31))))
+            {
+                hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
+                TRACE_TERSE3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
+                TRACE_MSG1("decErrno=%d", pAspMsg->buf[0]);
+                
+                argIdx = 0; // get decErrno
+                errno = *(Int32 *)&pAspMsg->buf[argIdx];
+            }
+            else
             {
+                //
+                // Invalid message received
+                //
                 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
                 SW_BREAKPOINT; // temporary
-            }           
-            hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
-            TRACE_MSG3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
+                return -1; // temporary
+            }
             // free the message
             status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
             if (status != MessageQ_S_SUCCESS)
@@ -3038,7 +3087,6 @@ PAF_ASIT_decodeInfo(
             Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
             Cache_wait();                            
 #endif            
-#endif // (***) FL: debug
             
 #if 0 // FL: decoder info call, slave
             if (dec->fxns->info
@@ -3050,6 +3098,7 @@ PAF_ASIT_decodeInfo(
                 TRACE_TERSE1("return error errno 0x%x.", errno);
                 return errno;
             }
+
 #ifdef NON_CACHE_STATUS
             statusOp_read(&tempVar,
                           &(pAstCfg->xDec[z].decodeStatus.frameCount),
@@ -3368,7 +3417,6 @@ PAF_ASIT_decodeDecode(
             // FL: debug, capture input buffer
             //capIbPcm(pAstCfg->xInp[z].pInpBuf);
             
-#if 0 // (***) FL: debug
             // (***) FL: revisit
             // write back Dec configuration
             Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
@@ -3411,18 +3459,22 @@ PAF_ASIT_decodeDecode(
                 hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
                 TRACE_MSG3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
                 
-                argIdx = 0;
+                argIdx = 0; // get decErrno
                 errno = *(Int32 *)&pAspMsg->buf[argIdx];
-                argIdx += sizeof(Int32);
+                argIdx += sizeof(Int32); // get cbErrno
                 cbErrno = *(Int32 *)&pAspMsg->buf[argIdx];
                 if (cbErrno != 0)
                 {
+                    gCbWrtAfErrCnt++;
                     TRACE_TERSE1("CB write error=%d", cbErrno);
-                    SW_BREAKPOINT; // temporary
+                    //SW_BREAKPOINT; // temporary
                 }
             }
             else
             {
+                //
+                // Invalid message received
+                //
                 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
                 SW_BREAKPOINT; // temporary
             }
@@ -3437,8 +3489,7 @@ PAF_ASIT_decodeDecode(
             // invalidate Dec configuration
             Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
             Cache_wait();
-#endif // (***) FL: debug
-           errno = 0;
+
 #if 0 // FL: decoder decode call, slave
             if (dec->fxns->decode
                 && (errno = dec->fxns->decode (dec, NULL,