]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_dsp/framework/audioStreamInpProc.c
PASDK-401:Add No-IP builds
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamInpProc.c
index 1d509a4bfdb19e6278b1dec80bd094ad3f8fa37f..ace2a1dc98405a10cddb490c22ea6adf663454ad 100644 (file)
@@ -89,7 +89,7 @@ Int32 gNumPfpAsit2=0;
 #define TR_MOD  trace
 
 // Allow a developer to selectively enable tracing.
-#define CURRENT_TRACE_MASK      0x21
+#define CURRENT_TRACE_MASK      0x27
 
 #define TRACE_MASK_TERSE        0x01   // only flag errors and show init
 #define TRACE_MASK_GENERAL      0x02   // half dozen lines per frame
@@ -317,7 +317,9 @@ extern UInt32 gAspProfileEnable;
 // FL: (***) hard-coded
 #define ASIP_FRAMELEN_SS_DDP_AC3    ( 1536 )
 // FL: (***) hard-coded
-#define ASIP_FRAMELEN_SS_THD        ( 1536 )        //QIN FIX ME
+#define ASIP_FRAMELEN_SS_THD        ( 1536 )        
+
+#define ASIP_FRAMELEN_SS_DTS        ( 512 )         
 
 // Compute decoder frame length based on selected source
 static Int getFrameLengthSourceSel(
@@ -338,7 +340,7 @@ PAF_ASIT_Config gPAF_ASIT_config = {
 };
 
 // Global debug counters */
-UInt32 gTaskAsipCnt             =0;
+UInt32 gAsipRxSioReclaimCnt     =0;
 UInt32 gAsipInitCnt             =0;
 UInt32 gAsipInfo1Cnt            =0;
 UInt32 gAsipInfo2Cnt            =0;
@@ -350,11 +352,14 @@ UInt32 gAsipInfo1_PrimaryErrCnt =0;
 UInt32 gAsipInfo1_ErrCnt        =0;
 UInt32 gAsipInfo2_PrimaryErrCnt =0;
 UInt32 gAsipInfo2_ErrCnt        =0;
+// debug
 UInt32 gCapIbReset_cnt          =0;
 UInt32 gCapIb_cnt               =0;
-// debug
 UInt32 gCbWrtAfErrCnt           =0; // decoder output circular buffer write error count (returned from ARM to DSP)
                                    
+// For writeDECCommandRestart
+volatile UInt32 gCommandOutputTask_SYNC   =0;
+volatile UInt32 gCommandOutputTask_ACK    =0;
 
 #include "dbgDib.h" // debug
 
@@ -384,7 +389,6 @@ Void taskAsipFxn(
     Int errno;                      /* error number */
     Int zMD, zMI, zMS, zX;
     Int loopCount = 0;  // used to stop trace to see startup behavior.        
-    UInt32 curTime;
     Int size;
     // Messaging
     ASP_Msg *pAspMsg;              
@@ -460,7 +464,7 @@ Void taskAsipFxn(
     //      - AlgKey: Dec/Enc chain to Array Initialization
     //      - Device: I/O Device Initialization
     //      - DecOpCircBuf: Decoder Output Circular Buffer
-    //      - Unused: (available)
+    //      - OutIS: Output Init-Sync
     //
     LINNO_RPRT(TaskAsip, -2);
     for (i=0; i < lengthof(pP->fxns->initPhase); i++)
@@ -550,14 +554,20 @@ Void taskAsipFxn(
     Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
+    Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
     Cache_wait();
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]) Log_info0("ERROR: beta unit for Dec==NULL");
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]) Log_info0("ERROR: beta unit for Dec==NULL");
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]) Log_info0("ERROR: beta unit for Dec==NULL");
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]) Log_info0("ERROR: beta unit for Dec==NULL");
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]) Log_info0("ERROR: beta unit for Dec==NULL");
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]) Log_info0("ERROR: beta unit for Dec==NULL");
-    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]) Log_info0("ERROR: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC]) Log_info0("WARNING: beta unit for Dec==NULL");
+    if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]) Log_info0("WARNING: beta unit for Dec==NULL");
     
     // (***) FL: revisit
     // invalidate Status structures for Beta Units initialized on Slave
@@ -582,6 +592,14 @@ Void taskAsipFxn(
     Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), sizeof(Int), Cache_Type_ALLD, 0);
     size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]->size;
     Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), size, Cache_Type_ALLD, 0);
+    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]->size;
+    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]), size, Cache_Type_ALLD, 0);
+    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC]), sizeof(Int), Cache_Type_ALLD, 0);
+    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC]->size;
+    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC]), size, Cache_Type_ALLD, 0);
+    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]), sizeof(Int), Cache_Type_ALLD, 0);
+    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]->size;
+    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_AAC2]), size, Cache_Type_ALLD, 0);
     Cache_wait();
     
 #ifdef NON_CACHE_STATUS
@@ -602,8 +620,11 @@ Void taskAsipFxn(
     {
         Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_THD);
     }
+    if (statusOp_Init(GATEMP_INDEX_DTS) == STATUSOP_INIT_FAIL)
+    {
+        Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_DTS);
+    }
 #endif
-
     // (***) FL: revisit
     // invalidate Dec configuration
     Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
@@ -650,6 +671,18 @@ Void taskAsipFxn(
         // any error forces idling of input
         if (errno) 
         {
+            // If gCommandOutputTask_SYNC invoked by writeDECCommandRestart, wait for output task in sync ...
+            if (gCommandOutputTask_SYNC) {
+                TRACE_VERBOSE1("TaskAsip: writeDECCommandRestart issued ... Wait for ack from output task side (errno=%d)", errno);
+                // Wait for ack
+                while (gCommandOutputTask_ACK == 0) {
+                    Task_sleep(1);
+                }
+                TRACE_VERBOSE0("TaskAsip: writeDECCommandRestart issued ... Sync-ed! Startover the process");
+                gCommandOutputTask_ACK = 0;
+                gCommandOutputTask_SYNC = 0;
+            }
+            
             for (z=INPUT1; z < INPUTN; z++)
             {
                 if (pAstCfg->xInp[z].hRxSio)
@@ -850,12 +883,13 @@ Void taskAsipFxn(
             continue;
         }
 
-        // FL: debug, reset IB capture buffer
+#if 0 // debug, reset IB capture buffer
         capIbReset();
         gCapIbReset_cnt++;
         Log_info0("capIbReset()");
+#endif
 
-        // FL: send source select message to slave
+        // send source select message to slave
         *(Int32 *)&asipMsgBuf[0] = sourceSelect;
         if(AspMsgSend(ASP_SLAVE_DEC_SOURCE_SELECT, ASP_MASTER_DEC_SOURCE_SELECT_DONE,
                       asipMsgBuf, NULL) != ASP_MSG_NO_ERR)
@@ -2067,16 +2101,14 @@ PAF_ASIT_decodeProcessing(
     enum { INIT, INFO1, INFO2, DECODE, FINAL, QUIT } state;
     ALG_Handle alg[DECODEN_MAX];
     Int zMD;
-    Int zMS;
-    Int size;
-    //PAF_InpBufConfig *pIpBufConfig;
+    //Int zMS;
     Int frame; // decoder input frame count
     Int block; // (***) FL: formerly  -- decoder output block count / input frame
     Int8 tempVar8, temp2Var8;
     
     pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     zMD = pAstCfg->masterDec;
-    zMS = pAstCfg->masterStr;
+    //zMS = pAstCfg->masterStr;
         
     for (z=DECODE1; z < DECODEN; z++)
     {
@@ -2389,6 +2421,10 @@ PAF_ASIT_decodeCommand(
                     tempVar8 |= 0x80;
                     sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.command2),
                                        tempVar8, GATEMP_INDEX_DEC);
+                                       
+                    // Invoke command to output task to break the loop
+                    gCommandOutputTask_SYNC = 1;
+                    
                     return (ASPERR_QUIT);
                 default: // command unknown - ignore
                     break;
@@ -2625,7 +2661,6 @@ PAF_ASIT_decodeInfo(
     Int zMD;
     Int zMI;
     Int zMS;
-    UInt32 curTime;
     Int argIdx;
     Int8 tempVar8;
     Int tempVar;
@@ -2633,6 +2668,8 @@ PAF_ASIT_decodeInfo(
     // FL: revisit
     //Int size;
     //PAF_InpBufConfig *pIpBufConfig;
+    // debug
+    //UInt32 curTime;
 
     pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
     as = pAstCfg->as;
@@ -2711,9 +2748,10 @@ PAF_ASIT_decodeInfo(
             return ASPERR_RECLAIM;
         }
         
-        //// FL: debug, capture input buffer
-        //capIb(pAstCfg->xInp[zMI].pInpBuf);
-        //gCapIb_cnt++;
+#if 0 // debug, capture input buffer
+        capIb(pAstCfg->xInp[zMI].pInpBuf);
+        gCapIb_cnt++;
+#endif
         
 #if 0 // (***) FL: shows timing of Input Rx SIO reclaim after decoding has started (autodet complete)
         // (***) debug // B5
@@ -2731,11 +2769,12 @@ PAF_ASIT_decodeInfo(
         // Simulate Rx SIO_reclaim() pend
         //
         //Semaphore_pend(semaphoreRxAudio, BIOS_WAIT_FOREVER); 
-        gTaskAsipCnt++;
-        curTime = Clock_getTicks();
+        //curTime = Clock_getTicks();
         //System_printf("System time in TaskAsipFxn Rx audio = %lu\n", (ULong)curTime);        
         //Log_info1("System time in TaskAsipFxn Rx audio = %u", curTime);
         //Log_info1("decodeInfo():Rx SIO reclaim(), system time = %u", curTime);
+        
+        gAsipRxSioReclaimCnt++;
     } //pAstCfg->xInp[zMI].hRxSio
 
     // Decode info
@@ -3057,8 +3096,9 @@ PAF_ASIT_decodeDecode(
                     (IArg)pAstCfg->xInp[z].pInpBuf->base.pVoid,
                     (IArg)pAstCfg->xInp[z].pInpBuf->head.pVoid);
 
-            // FL: debug, capture input buffer
-            //capIbPcm(pAstCfg->xInp[z].pInpBuf);
+#if 0 // debug, capture input buffer
+            capIbPcm(pAstCfg->xInp[z].pInpBuf);
+#endif
             
             // (***) FL: revisit
             // write back Dec configuration
@@ -3299,7 +3339,6 @@ PAF_ASIT_decodeComplete(
     Int as;                     /* Audio Stream Number (1, 2, etc.) */
     Int z;                      /* decode/encode counter */
     Int argIdx;
-    Int errno;                  /* error number */
     Int8 tempVar8;
     char decMsgBuf[ASP_MSG_BUF_LEN];
     
@@ -3574,6 +3613,9 @@ static Int getFrameLengthSourceSel(
         case PAF_SOURCE_PCM:
             frameLength = FRAMELENGTH;
             break;
+        case PAF_SOURCE_AAC:
+            frameLength = 1024;
+            break;
         case PAF_SOURCE_AC3: 
         case PAF_SOURCE_DDP: 
             frameLength = ASIP_FRAMELEN_SS_DDP_AC3;
@@ -3581,6 +3623,15 @@ static Int getFrameLengthSourceSel(
         case PAF_SOURCE_THD:
             frameLength = ASIP_FRAMELEN_SS_THD;
             break;
+        case PAF_SOURCE_DTS:
+        case PAF_SOURCE_DTSHD:
+        case PAF_SOURCE_DTS12:
+        case PAF_SOURCE_DTS13:
+        case PAF_SOURCE_DTS14:
+        case PAF_SOURCE_DTS16:
+        case PAF_SOURCE_DTSALL:
+            frameLength = ASIP_FRAMELEN_SS_DTS;
+            break;
         default:
             frameLength = ASIP_FRAMELEN_SS_DEFAULT;
             break;