]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_dsp/framework/audioStreamInpDec.c
PASDK-538:Update DSP ASP master messaging to use SyncEvents
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamInpDec.c
index cc48d809c1e8f7b61042b22f8e5ee4d5da1a98e7..fe2bb19b3474b7500be2444e5a237218b392a7c9 100644 (file)
@@ -83,8 +83,10 @@ static Int decDecodeFinalTest(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *
                               PAF_ASIT_Config *pAsitCfg);
 Int decCheckMajorAu(PAF_AST_Config *pAstCfg);
 
+#if 0
 Int AspMsgSnd(UInt32 sndCmd, char *sndMsgBuf);
 Int AspMsgAck(UInt32 ackCmd, char *ackMsgBuf);
+#endif
 
 extern UInt32 gCbWrtAfErrCnt;
 
@@ -167,13 +169,15 @@ Int decDecodeFsm(
         case DEC_STATE_INFO_ACK_DECODE_SND:
             //if(decMsg != DEC_MSGMSK_INFOACK) {
                 // only DEC_MSGMSK_INFOACK is expected in this state
-            if((decMsg&DEC_MSGMSK_INFOACK) != DEC_MSGMSK_INFOACK) {
-                // During debugging, it is possible that INPDATA and INFOACK
-                // come at the same time (e.g. due to breaking point).
-                decErr = DEC_ERR_WRONG_MSG;
-            }
-            else {
-                decMsg &= ~DEC_MSGMSK_INFOACK;  // clear the bit mask
+            //if((decMsg&DEC_MSGMSK_INFOACK) != DEC_MSGMSK_INFOACK) {
+            //    // During debugging, it is possible that INPDATA and INFOACK
+            //    // come at the same time (e.g. due to breaking point).
+            //    decErr = DEC_ERR_WRONG_MSG;
+            //}
+            //else {
+                
+            if (decMsg & DEC_MSGMSK_RXACK) {
+                decMsg &= ~DEC_MSGMSK_RXACK;  // clear the bit mask
 
                 // Process the INFO acknowledgment from decoder
                 decErr = decInfoAck(pP, pQ, pAsitCfg);
@@ -206,14 +210,22 @@ Int decDecodeFsm(
                     }
                 }
             }
+            
+            if (decMsg != 0) {
+                decErr = DEC_ERR_WRONG_MSG;
+            }            
         break;
 
         case DEC_STATE_DECODE_ACK:
             // Two different messages may be received: DECACK (decode acknowledgment)
             // or INPDATA (input data ready).
-            if(decMsg & DEC_MSGMSK_DECACK) {
-                decMsg &= ~DEC_MSGMSK_DECACK;
-
+            //if(decMsg & DEC_MSGMSK_DECACK) {
+            //    decMsg &= ~DEC_MSGMSK_DECACK;
+            
+            if (decMsg & DEC_MSGMSK_RXACK)
+            {
+                decMsg &= ~DEC_MSGMSK_RXACK;  // clear the bit mask
+                
                 // Process DECODE ACK from decoder
                 decErr = decDecodeAck(pP, pQ, pAsitCfg);
                 if(decErr == DEC_NO_ERR) {
@@ -239,7 +251,8 @@ Int decDecodeFsm(
                     }
                 }
             }
-            else if(decMsg & DEC_MSGMSK_INPDATA) {
+            
+            if (decMsg & DEC_MSGMSK_INPDATA) {
                 // If we're here, it means decode acknowledgment from decoder
                 // is delayed, i.e., a new frame of input data is ready before
                 // current frame decoding is finished.
@@ -250,7 +263,8 @@ Int decDecodeFsm(
 
                 TRACE_VERBOSE0("decDecodeFsm: receiving INPDATA in DEC_STATE_DECODE_ACK");
             }
-            else {
+            
+            if (decMsg != 0) {
                 decErr = DEC_ERR_WRONG_MSG;
             }
         break;
@@ -371,6 +385,7 @@ static Int decodeInit(
 {
     PAF_AST_Config *pAstCfg;
     PAF_AST_IoInp  *pInp;
+    AspMsgMaster_Handle hAspMsgMaster;  // ASIT message master handle
     //PAF_AST_DecOpCircBufCtl *pCbCtl;    /* Decoder output circular buffer control */
     Int as;                             /* Audio Stream Number (1, 2, etc.) */
     Int z;                              /* decode/encode counter */
@@ -379,9 +394,11 @@ static Int decodeInit(
     Int argIdx;
     Int8 tempVar8;
     char decMsgBuf[ASP_MSG_BUF_LEN];
+    Int status;
 
-    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
-    pInp    = pAsitCfg->pIoInp;
+    pAstCfg = pAsitCfg->pAstCfg;                // get pointer to AST common (shared) configuration
+    pInp    = pAsitCfg->pIoInp;                 // get pointer to IO configuration
+    hAspMsgMaster = pAsitCfg->hAspMsgMaster;    // get message master handle
 
     as = pAstCfg->as;
     (void)as;  // clear compiler warning in case not used with tracing disabled
@@ -420,19 +437,33 @@ static Int decodeInit(
             // send dec activate message to slave
             argIdx = 0; // set decIdx (zone index)
             *(Int32 *)&decMsgBuf[argIdx] = z;
-            if(AspMsgSend(ASP_SLAVE_DEC_ACTIVATE, ASP_MASTER_DEC_ACTIVATE_DONE,
-                          decMsgBuf, NULL) != ASP_MSG_NO_ERR)
+            status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_ACTIVATE, decMsgBuf);
+            if (status != ASP_MSG_NO_ERR)
             {
                 TRACE_TERSE0("decodeInit: error in sending DEC_ACTIVATE message ");
                 SW_BREAKPOINT; // temporary
                 return ASIP_ERR_DECODE_MSG; // temporary
             }
+            status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_ACTIVATE_DONE, NULL, TRUE);
+            if (status != ASP_MSG_NO_ERR)
+            {
+                TRACE_TERSE0("decodeInit: error in receiving DEC_ACTIVATE_DONE ack message ");
+                SW_BREAKPOINT; // temporary
+                return ASIP_ERR_DECODE_MSG; // temporary
+            }
 
             // send dec reset message to slave
             argIdx = 0; // set decIdx
             *(Int32 *)&decMsgBuf[argIdx] = z;
-            if(AspMsgSend(ASP_SLAVE_DEC_RESET, ASP_MASTER_DEC_RESET_DONE,
-                          decMsgBuf, decMsgBuf) != ASP_MSG_NO_ERR)
+            status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_RESET, decMsgBuf);
+            if (status != ASP_MSG_NO_ERR)
+            {
+                TRACE_TERSE0("decodeInit: error in sending DEC_RESET message ");
+                SW_BREAKPOINT; // temporary
+                return ASIP_ERR_DECODE_MSG; // temporary
+            }
+            status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_RESET_DONE, decMsgBuf, TRUE);
+            if (status != ASP_MSG_NO_ERR)
             {
                 TRACE_TERSE0("decodeInit: error in sending DEC_RESET message ");
                 SW_BREAKPOINT; // temporary
@@ -500,13 +531,16 @@ Int decDecodeComplete( const PAF_ASIT_Params *pP,
                        PAF_ASIT_Config *pAsitCfg)
 {
     PAF_AST_Config *pAstCfg;
+    AspMsgMaster_Handle hAspMsgMaster;  // ASIT message master handle
     Int as;                     /* Audio Stream Number (1, 2, etc.) */
     Int z;                      /* decode/encode counter */
     Int argIdx;
     Int8 tempVar8;
     char decMsgBuf[ASP_MSG_BUF_LEN];
+    Int status;
 
-    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg;                // get pointer to AST common (shared) configuration
+    hAspMsgMaster = pAsitCfg->hAspMsgMaster;    // get message master handle
     as = pAstCfg->as;
     (void)as;  // clear compiler warning in case not used with tracing disabled
 
@@ -518,11 +552,18 @@ Int decDecodeComplete( const PAF_ASIT_Params *pP,
         {
             TRACE_VERBOSE1("decDecodeComplete: AS%d: finalizing decode", as+z);
 
-            // FL: send dec deactivate message to slave
+            // send dec deactivate message to slave
             argIdx = 0; // set decIdx
             *(Int32 *)&decMsgBuf[argIdx] = z;
-            if(AspMsgSend(ASP_SLAVE_DEC_DEACTIVATE, ASP_MASTER_DEC_DEACTIVATE_DONE,
-                          decMsgBuf, NULL) != ASP_MSG_NO_ERR)
+            status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_DEACTIVATE, decMsgBuf);
+            if (status != ASP_MSG_NO_ERR)
+            {
+                TRACE_TERSE0("decodeComplete: error in sending DEC_DEACTIVATE message.");
+                SW_BREAKPOINT;
+                return DEC_ERR_COMPLETE_MSG;
+            }
+            status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_DEACTIVATE_DONE, NULL, TRUE);
+            if (status != ASP_MSG_NO_ERR)
             {
                 TRACE_TERSE0("decodeComplete: error in sending DEC_DEACTIVATE message.");
                 SW_BREAKPOINT;
@@ -625,6 +666,7 @@ Int decInfoSnd(
 {
     PAF_AST_Config *pAstCfg;
     PAF_AST_IoInp  *pInp;
+    AspMsgMaster_Handle hAspMsgMaster;  // ASIT message master handle
     Int as;                    /* Audio Stream Number (1, 2, etc.) */
     Int z;                     /* input/decode/stream counter */
     Int errno;                 /* error number */
@@ -632,9 +674,11 @@ Int decInfoSnd(
     Int argIdx;
     Int8 tempVar8;
     char decMsgBuf[ASP_MSG_BUF_LEN];
+    Int status;
 
-    pAstCfg = pAsitCfg->pAstCfg;   // get pointer to common (shared) configuration
-    pInp    = pAsitCfg->pIoInp;
+    pAstCfg = pAsitCfg->pAstCfg;                // get pointer to common (shared) configuration
+    pInp    = pAsitCfg->pIoInp;                 // get pointer to IO configuration
+    hAspMsgMaster = pAsitCfg->hAspMsgMaster;    // get message master handle
     as = pAstCfg->as;
 
     // Set decode control: sample rate, emphasis
@@ -714,7 +758,8 @@ Int decInfoSnd(
             // send info message to slave
             argIdx = 0; // set decIdx
             *(Int32 *)&decMsgBuf[argIdx] = z;
-            if(AspMsgSnd(ASP_SLAVE_DEC_INFO, decMsgBuf) != ASP_MSG_NO_ERR)
+            status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_INFO, decMsgBuf);
+            if (status != ASP_MSG_NO_ERR)
             {
                 TRACE_TERSE0("decodeInfo: error in sending DEC_INFO message ");
                 SW_BREAKPOINT; // temporary
@@ -735,7 +780,7 @@ Int decInfoSnd(
     } // z=DECODE1 to DECODEN
 
 //////////////////////////////////////////////////////////////////////////////
-    asitPostInfoEvent();
+    //asitPostInfoEvent(); // simulation
 //////////////////////////////////////////////////////////////////////////////
 
     return ASIP_NO_ERR;
@@ -750,6 +795,7 @@ Int decInfoAck(
 {
     PAF_AST_Config *pAstCfg;
     PAF_AST_IoInp  *pInp;
+    AspMsgMaster_Handle hAspMsgMaster;
     Int as;                    /* Audio Stream Number (1, 2, etc.) */
     Int z;                     /* input/decode/stream counter */
     Int errno;                 /* error number */
@@ -760,9 +806,11 @@ Int decInfoAck(
     Int8 tempVar8;
     Int tempVar;
     char decMsgBuf[ASP_MSG_BUF_LEN];
+    Int status;
 
-    pAstCfg = pAsitCfg->pAstCfg;   // get pointer to common (shared) configuration
-    pInp    = pAsitCfg->pIoInp;
+    pAstCfg = pAsitCfg->pAstCfg;                // get pointer to common (shared) configuration
+    pInp    = pAsitCfg->pIoInp;                 // get pointer to IO configuration
+    hAspMsgMaster = pAsitCfg->hAspMsgMaster;    // get message master handle
     as = pAstCfg->as;
     zMD = pAstCfg->masterDec;
     zMS = pAstCfg->masterStr;
@@ -779,15 +827,17 @@ Int decInfoAck(
                                      GATEMP_INDEX_DEC);
         if (pInp[zI].hIoPhy  && tempVar8)
         {
-            // FL: acknowledge info message from slave
-            argIdx = 0; // set decIdx
-            *(Int32 *)&decMsgBuf[argIdx] = z;
-            if(AspMsgAck(ASP_MASTER_DEC_INFO_DONE,
-                         decMsgBuf) != ASP_MSG_NO_ERR)
+            // acknowledge info message from slave
+            errno  = 0;
+            //argIdx = 0; // set decIdx
+            //*(Int32 *)&decMsgBuf[argIdx] = z;
+            status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_INFO_DONE, decMsgBuf, FALSE);
+            if (status != ASP_MSG_NO_ERR)
             {
-                TRACE_TERSE0("decodeInfo: error in receiving DEC_INFO message ");
+                TRACE_TERSE0("decodeInfo: error in receiving DEC_INFO_DONE ack message ");
                 SW_BREAKPOINT; // temporary
-                return -1;     // temporary
+                errno = -1;    // temporary error return value
+                return errno;     // temporary
             }
             else
             {
@@ -854,14 +904,17 @@ static Int decDecodeSnd(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
 {
     PAF_AST_Config *pAstCfg;
     PAF_AST_IoInp  *pInp;
+    AspMsgMaster_Handle hAspMsgMaster;  // ASIT message master handle
     Int as;                     /* Audio Stream Number (1, 2, etc.) */
     Int z;                      /* decode/stream counter */
     Int argIdx;
     Int cbErrno, errno;
     char decMsgBuf[ASP_MSG_BUF_LEN];
+    Int status;
 
-    pAstCfg = pAsitCfg->pAstCfg; // get pointer to common (shared) configuration
-    pInp    = pAsitCfg->pIoInp;
+    pAstCfg = pAsitCfg->pAstCfg;                // get pointer to common (shared) configuration
+    pInp    = pAsitCfg->pIoInp;                 // get pointer to IO configuration
+    hAspMsgMaster = pAsitCfg->hAspMsgMaster;    // get message master handle
     as = pAstCfg->as;
     (void)as; // clear compiler warning in case not used with tracing disabled
 
@@ -893,7 +946,8 @@ static Int decDecodeSnd(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
             errno  = 0;
             argIdx = 0; // set decIdx
             *(Int32 *)&decMsgBuf[argIdx] = z;
-            if(AspMsgSnd(ASP_SLAVE_DEC_DECODE, decMsgBuf) != ASP_MSG_NO_ERR)
+            status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_DECODE, decMsgBuf);
+            if (status != ASP_MSG_NO_ERR)
             {
                 TRACE_TERSE0("decodeDecode: error in sending DEC_DECODE message ");
                 SW_BREAKPOINT; // temporary
@@ -925,7 +979,7 @@ static Int decDecodeSnd(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
     } // z=DECODE1 to DECODEN
 
 //////////////////////////////////////////////////////////////////////////////
-    asitPostDecEvent();
+    //asitPostDecEvent(); // simulation
 //////////////////////////////////////////////////////////////////////////////
 
     return ASIP_NO_ERR;
@@ -937,15 +991,18 @@ static Int decDecodeAck(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
 {
     PAF_AST_Config *pAstCfg;
     PAF_AST_IoInp  *pInp;
+    AspMsgMaster_Handle hAspMsgMaster;  // ASIT message master handle
     Int as;                     /* Audio Stream Number (1, 2, etc.) */
     Int z;                      /* decode/stream counter */
     Int errno;                  /* error number */
     Int argIdx;
     Int cbErrno;
     char decMsgBuf[ASP_MSG_BUF_LEN];
+    Int status;
 
-    pAstCfg = pAsitCfg->pAstCfg; // get pointer to common (shared) configuration
-    pInp    = pAsitCfg->pIoInp;
+    pAstCfg = pAsitCfg->pAstCfg;                // get pointer to common (shared) configuration
+    pInp    = pAsitCfg->pIoInp;                 // get pointer to IO configuration
+    hAspMsgMaster = pAsitCfg->hAspMsgMaster;    // get message master handle
     as = pAstCfg->as;
     (void)as; // clear compiler warning in case not used with tracing disabled
 
@@ -957,16 +1014,17 @@ static Int decDecodeAck(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
         (void)zS; // clear compiler warning in case not used with tracing disabled
         if ( pInp[zI].hIoPhy && pAstCfg->xDec[z].decodeStatus.mode )
         {
-            // FL: send decode message to slave
+            // receive decode ack message from slave
             errno  = 0;
-            argIdx = 0; // set decIdx
-            *(Int32 *)&decMsgBuf[argIdx] = z;
-            errno = AspMsgAck(ASP_MASTER_DEC_DECODE_DONE, decMsgBuf);
-            if(errno != ASP_MSG_NO_ERR)
+            //argIdx = 0; // set decIdx
+            //*(Int32 *)&decMsgBuf[argIdx] = z;
+            status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_DECODE_DONE, decMsgBuf, FALSE);
+            if (status != ASP_MSG_NO_ERR)
             {
-                TRACE_TERSE0("decodeDecode: error in sending DEC_DECODE message ");
+                TRACE_TERSE0("decodeDecode: error in receiving DEC_DECODE_DONE ack message ");
                 SW_BREAKPOINT; // temporary
-                return -1;     // temporary
+                errno = -1; // temporary error return value
+                return errno;
             }
             else
             {
@@ -1004,7 +1062,7 @@ static Int decDecodeAck(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
 } /* decDecodeAck */
 
 
-
+#if 0
 /************************************************************************************
  * ASP message sending function. Refer to aspMsg_master.h for detailed description.
 ************************************************************************************/
@@ -1103,6 +1161,7 @@ Int AspMsgAck(UInt32 ackCmd, char *ackMsgBuf)
     // may be error in returned (acknowledgement) message.
     return (ASP_MSG_NO_ERR);
 } /* AspMsgAck */
+#endif
 
 
 #if 0