Updated input task and decode processing. Input task can run with
authorJianzhong Xu <a0869574@ti.com>
Fri, 26 Jan 2018 22:40:06 +0000 (17:40 -0500)
committerJianzhong Xu <a0869574@ti.com>
Fri, 26 Jan 2018 22:40:06 +0000 (17:40 -0500)
decode messages going between ARM and DSP.

pasdk/test_dsp/framework/audioStreamInpDec.c
pasdk/test_dsp/framework/audioStreamInpProc.h
pasdk/test_dsp/framework/audioStreamInpProcNewIO.c
pasdk/test_dsp/io/ioConfig.h

index c3a0388ddbd96daab8544c49b79cf7de821a0973..3da417719d40e4faba5164440da8cfb89a931b8e 100644 (file)
@@ -107,15 +107,31 @@ Int asipDecodeProcessing(
         Int sourceSelect)
 {
     PAF_AST_Config *pAstCfg;
+    asipDecProc_t  *pDec;
     Int decError, retVal, getVal;                          /* error number */
     Int zMD;
     Int8 tempVar8;
 
     pAstCfg = pAsitCfg->pAstCfg;     // get pointer to common (shared) configuration
     zMD = pAstCfg->masterDec;
+    pDec = &pAsitCfg->inpDec;
 
     retVal = ASIP_NO_ERR;
 
+    // Initialization for decode processing
+    if(!pDec->initDone) {
+        // Initialize decoder and send message to decoder
+        retVal = decDecodeInit(pP, pAsitCfg, pAsitCfg->pIoInp[zMD].sourceSelect);
+        if(retVal != ASIP_NO_ERR) {
+            decDecodeComplete(pP, pAsitCfg);
+
+            return retVal;
+        }
+
+        pDec->initDone = TRUE;
+    }
+
+    // Check if source has configured to NONE
     tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
                                  GATEMP_INDEX_DEC);
     if (tempVar8 == PAF_SOURCE_NONE) {
@@ -126,26 +142,24 @@ Int asipDecodeProcessing(
     // Process commands (decode)
     getVal = pP->fxns->decodeCommand(pP, pQ, pAsitCfg);
     if (getVal) {
+        retVal = ASIP_ERR_DECODE_COMMAND;
         if (getVal == ASPERR_QUIT) {
-            pAsitCfg->inpDec.state = QUIT;  // skip processing, quit decoding
             TRACE_VERBOSE0("PAF_ASIT_decodeProcessing. %d: state = QUIT");
+
+            // Don't return if ASPERR_QUIT, but skip decode processing and quit
+            pAsitCfg->inpDec.state = QUIT;
         }
         else if (getVal == ASPERR_ABORT) {
             TRACE_VERBOSE0("PAF_ASIT_decodeProcessing. %d: return getVal");
 
-            // PFP end -- outside of PFP for errors, EOS, or Input SIO change
-            //pfpEnd(PFP_ID_ASIT_2, PFP_FINISH_MEAS);
-            //gNumPfpAsit2--;
-
-            return ASIP_ERR_DECODE_COMMAND;
+            // Return here if ASPERR_ABORT
+            return retVal;
         }
         else {
             /* ignore */;
         }
     }
 
-    retVal = ASIP_NO_ERR;
-
     switch(pAsitCfg->inpDec.state)
     {
         case INFO1:
@@ -222,7 +236,6 @@ Int asipDecodeProcessing(
             // - Set error number registers.
             // - Exit state machine to "decode complete" processing.
             TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: state: QUIT");
-            retVal = ASIP_ERR_DECODE_QUIT;
             break;
 
         default:
@@ -350,13 +363,13 @@ static Int decDecodeInit(
                                tempVar8, GATEMP_INDEX_DEC);
 
             // Compute decoder frame length based on source selection
+            // JXU: what does this function do? why does it only return PCM frame length?
             frameLength = getFrameLengthSourceSel(pP, sourceSelect);
 
             pAstCfg->xDec[z].decodeControl.frameLength = frameLength;
             pAstCfg->xDec[z].decodeInStruct.sampleCount = frameLength;
             pAstCfg->xDec[z].decodeControl.sampleRate = PAF_SAMPLERATE_UNKNOWN;
 
-
 /*
             if (z != zMD) {    // JXTODO: implement similar thing with new I/O
                 if (errno = SIO_idle(pAstCfg->xInp[zI].hRxSio)) {
@@ -364,19 +377,14 @@ static Int decDecodeInit(
                 }
             }
 */
+            // JXU: who changes sourceSelect? why not use sourceSelect passed to this function?
             pInp[z].sourceSelect = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.sourceSelect),
                                                      GATEMP_INDEX_DEC);
-
+/*//JXTODO: find out if frameLength needs to be passed to I/O DATA or I/O PHY.
             ioDataCtl.code = IODATA_CTL_SET_PCM_FRAME_LENGTH;
             ioDataCtl.param.frameLengthPcm = frameLength;
-            errno = ioDataControl(pInp[zI].hIoData, &ioDataCtl);
-
-            ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
-            ioPhyCtl.params.xferFrameSize = frameLength * (WORD_SIZE_PCM);
-            ioPhyControl(pInp[zI].hIoPhy, &ioPhyCtl);
-
-            pInp[zI].phyXferSize = ioPhyCtl.params.xferFrameSize;
-
+            ioDataControl(pInp[zI].hIoData, &ioDataCtl);
+*/
             //JXTODO: do we need to update input status here again?
             if (errno = asipUpdateInputStatus(pInp[zI].pRxParams,
                                               &pAstCfg->xInp[zI].inpBufStatus,
@@ -691,18 +699,11 @@ static Int decDecodeData(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
 
             pAstCfg->xDec[z].decodeControl.frameLength  = frameLength;
             pAstCfg->xDec[z].decodeInStruct.sampleCount = frameLength;
-
+/* //JXTODO: find out if frameLength needs to be passed to I/O DATA or I/O PHY.
             ioDataCtl.code = IODATA_CTL_SET_PCM_FRAME_LENGTH;
             ioDataCtl.param.frameLengthPcm = frameLength;
-            errno = ioDataControl(pInp[zI].hIoData, &ioDataCtl);
-
-            ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
-            ioPhyCtl.params.xferFrameSize = frameLength * (WORD_SIZE_PCM);
-            ioPhyControl(pInp[zI].hIoPhy, &ioPhyCtl);
-
-            pInp[zI].phyXferSize = ioPhyCtl.params.xferFrameSize;
-
-            //JXTODO: find out if frameLength needs to be passed to I/O DATA or I/O PHY.
+            ioDataControl(pInp[zI].hIoData, &ioDataCtl);
+*/
         } // hIoPhy && decodeStatus.mode
         else {
             TRACE_VERBOSE2("AS%d: PAF_ASIT_decodeDecode: processing block %d -- decode <ignored>", as+zS, pAsitCfg->inpDec.block);
index ce4825d0302b438f66b211be49bddf9a767fcc7d..2a3cb65b7ba16a1f8b5f1c155cca0afd8754dfa6 100644 (file)
@@ -245,6 +245,8 @@ typedef struct asipDecProc_s {
     Int state;
     Int frame;
     Int block;
+
+    Int initDone;
 } asipDecProc_t;
 
 // Audio Stream Input Task (ASIT) configuration
@@ -563,12 +565,12 @@ static inline Int sharedMemReadInt(volatile XDAS_Int32 *address, Int gateIdx)
 
 Int asipUpdateInputStatus(const void *pRxParams, PAF_InpBufStatus *pStatus,
                           PAF_InpBufConfig *pInpBuf);
-
+/*
 Int asipDecodeInit(
         const PAF_ASIT_Params *pP,
         PAF_ASIT_Config *pAsitCfg,
         Int sourceSelect);
-
+*/
 Int asipDecodeProcessing(
         const PAF_ASIT_Params *pP,
         const PAF_ASIT_Patchs *pQ,
index 977fbf17c9913032d783933e091d9baf0aabc7f6..1ce5608d32efdafd040b152b3849b7e90198dad9 100644 (file)
@@ -114,7 +114,7 @@ extern XDAS_Int32 D10_RxControl(const void *pD10RxParams,
  */
 int asipPrepareProcessing();
 int asipIoCompsInit(PAF_AST_InpBuf * pInpBuf, PAF_AST_IoInp * pInpIo);
-void asipProcInit(PAF_AST_IoInp  *pInp);
+void asipProcInit(PAF_AST_IoInp  *pInp, asipDecProc_t *pDec);
 void asipIoPhyPrime(PAF_AST_IoInp *pInpIo);
 void asipPhyTransferPend(void);
 void asipPhyTransferComplete(PAF_AST_IoInp * pInpIo);
@@ -244,7 +244,7 @@ Int inputReadyForProcessing;
                 asipIoCompsInit(&pAstCfg->xInp[zMI], pInp);
 
                 // Initialize ASIP processing
-                asipProcInit(pInp);
+                asipProcInit(pInp, &pAsitCfg->inpDec);
 
                 // Start I/O physical layer by priming McASP LLD for input
                 asipIoPhyPrime(pInp);
@@ -418,7 +418,7 @@ int asipIoCompsInit(PAF_AST_InpBuf * pInpBuf, PAF_AST_IoInp * pInpIo)
 
     pInpIo->numPrimeXfers  = NUM_PRIME_XFERS;
     pInpIo->phyXferSize    = ioPhyParams.xferFrameSize;
-    pInpIo->switchHangOver = 0;
+    //pInpIo->switchHangOver = 0;
     pInpIo->preSyncState   = IODATA_SYNC_NONE;
 
     return 0;
@@ -427,11 +427,13 @@ int asipIoCompsInit(PAF_AST_InpBuf * pInpBuf, PAF_AST_IoInp * pInpIo)
 /*======================================================================================
  *  This function initializes ASIP processing
  *====================================================================================*/
-void asipProcInit(PAF_AST_IoInp  *pInp)
+void asipProcInit(PAF_AST_IoInp  *pInp, asipDecProc_t *pDec)
 {
     pInp->swapData = SWAP_INPUT_DATA;
     pInp->asipProcState = ASIP_SOURCE_DETECTION;
-    pInp->switchHangOver = 0;
+    //pInp->switchHangOver = 0;
+
+    pDec->initDone = FALSE;
 }
 
 /*======================================================================================
@@ -726,7 +728,7 @@ Int asipUpdateIoComps(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp,
     if(autoDetStatus->syncState == IODATA_SYNC_BITSTREAM) {
         // Change I/O PHY transfer size to be the same as the bitstream frame size
         uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
-        frameLength = iecFrameLength[pc] * WORD_SIZE_BITSTREAM;
+        frameLength = iecFrameLength[pc];
 
         // update input buffer config structure
         pBufConfig->sizeofElement = WORD_SIZE_BITSTREAM;
@@ -888,6 +890,7 @@ Int asipDecideSource(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp,
         return ASIP_ERR_NO_MATCHING_SOURCE;
     }
 
+#ifndef PCM_LOOPBACK_TEST
     // send source select message to slave
     *(Int32 *)&asipMsgBuf[0] = sourceSelect;
     if(AspMsgSend(ASP_SLAVE_DEC_SOURCE_SELECT, ASP_MASTER_DEC_SOURCE_SELECT_DONE,
@@ -895,6 +898,7 @@ Int asipDecideSource(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp,
         TRACE_VERBOSE0("TaskAsip: error in sending SOURCE_SELECT message");
         SW_BREAKPOINT;
     }
+#endif
 
     pInp->sourceSelect  = sourceSelect;
     pInp->sourceProgram = sourceProgram;
@@ -1003,12 +1007,14 @@ Int asipProcessing(const PAF_ASIT_Params *pP,
             else {
                 // set to unknown so that we can ensure, for IOS purposes, that sourceDecode = NONE
                 // iff we are in this top level state machine and specifically not in decodeProcessing
+#ifndef PCM_LOOPBACK_TEST
                 pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_UNKNOWN);
+#endif
 
                 if(autoDetStatus.syncState == IODATA_SYNC_BITSTREAM) {
                     // Input is bit stream: go to decoding
                     pInp->asipProcState = ASIP_DECODE;
-                    pInp->numFrameReceived = 1;
+                    //pInp->numFrameReceived = 1;
                 }
                 else  {
                     // Input is PCM: stop swapping data
@@ -1023,16 +1029,11 @@ Int asipProcessing(const PAF_ASIT_Params *pP,
                     // Go to transition state to switch to PCM
                     pInp->asipProcState = ASIP_SWITCH_TO_PCM;
                     pInp->switchHangOver = INPUT_SWITCH_HANGOVER;
-                    pInp->numPcmFrameReceived = 0;
-                }
-
-                // Initialize decoder
-                asipStatus = asipDecodeInit(pP, pAsitCfg, pInp->sourceSelect);
-                if(asipStatus != ASIP_NO_ERR) {
-                    return asipStatus;
+                    //pInp->numPcmFrameReceived = 0;
                 }
             }
 
+            pInp->numFrameReceived = 0;
             pInp->preSyncState = autoDetStatus.syncState;
         }
         else {
@@ -1048,12 +1049,6 @@ Int asipProcessing(const PAF_ASIT_Params *pP,
         pInp->switchHangOver--;
         if(pInp->switchHangOver == 0) {
             pInp->asipProcState = ASIP_DECODE;
-
-            // Init decoder and send message to decoder
-            //asipStatus = asipDecodeInit(pP, pAsitCfg, pInp->sourceSelect);
-            //if(asipStatus != ASIP_NO_ERR) {
-            //    return asipStatus;
-            //}
         }
         break;
 
@@ -1083,18 +1078,22 @@ Int asipProcessing(const PAF_ASIT_Params *pP,
             pInp->asipProcState  = ASIP_SOURCE_DETECTION;
         }
         else {
-            pInp->numFrameReceived += 1;
+            pInp->numFrameReceived += 1;    // for debugging
 
             // Communicate input stream information to decoder through input buffer configuration
             asipUpdateInpBufConfig(pAstCfg, pInp);
         }
 
+#ifndef PCM_LOOPBACK_TEST
         asipStatus = asipDecodeProcessing(pP, pQ, pAsitCfg, pInp->sourceSelect);
         if(asipStatus != ASIP_NO_ERR) {
             return asipStatus;
         }
-
-        //rxDecodePcm(pInp);     // for PCM loopback testing
+#else
+        if(autoDetStatus.syncState == IODATA_SYNC_PCM) {
+            rxDecodePcm(pInp);     // for PCM loopback testing
+        }
+#endif
         break;
 
     default:
index 3482646b04fe2922cdce7969a839e2aeca3c98ae..ca43abc4f96b05fc42dbdfda4cec0f0f1ecbdf4f 100644 (file)
@@ -4,7 +4,8 @@
 
 //#define PASDK_SIO_DEV         // define this to use the legacy SIO/DEV based I/O driver
 
-//#define IO_LOOPBACK_TEST        // define this to run a loopback test bypassing PASDK processing
+//#define IO_LOOPBACK_TEST        // define this to run a DSP-only standalone loopback test without PASDK framework
+//#define PCM_LOOPBACK_TEST       // define this to run DSP-only PCM loopback test in PASDK framework
 
 #define INPUT_HDMI_4xI2S        // HDMI, 4 Rx serializers
 //#define INPUT_HDMI_STEREO       // HDMI, 1 Rx serializer