Refactored input decoding processing. Updated input task. Not tested.
authorJianzhong Xu <a0869574@ti.com>
Tue, 16 Jan 2018 19:23:44 +0000 (14:23 -0500)
committerJianzhong Xu <a0869574@ti.com>
Tue, 16 Jan 2018 19:23:44 +0000 (14:23 -0500)
pasdk/test_dsp/framework/audioStreamInpDec.c
pasdk/test_dsp/framework/audioStreamInpProc.c
pasdk/test_dsp/framework/audioStreamInpProc.h
pasdk/test_dsp/framework/audioStreamInpProcNewIO.c
pasdk/test_dsp/io/ioConfig.h
pasdk/test_dsp/io/ioData.c
pasdk/test_dsp/io/ioData.h

index 6768e7b09f3579382f83bb106dc4a250981568a5..c3a0388ddbd96daab8544c49b79cf7de821a0973 100644 (file)
@@ -31,117 +31,217 @@ All rights reserved.
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
-#if 0
+
 /*
- *  ======== audioStreamInpProc.c ========
+ *  ======== audioStreamInpDec.c ========
  */
-
-#include <xdc/std.h>
-#include <xdc/cfg/global.h>
-#include <xdc/runtime/Diags.h>
-#include <xdc/runtime/Error.h>
-#include <xdc/runtime/Log.h>
-#include <xdc/runtime/Memory.h>
-#include <xdc/runtime/System.h>
-#include <ti/sysbios/BIOS.h>
-#include <ti/sysbios/hal/Hwi.h>
 #include <ti/sysbios/hal/Cache.h>
-#include <ti/sysbios/knl/Clock.h>
-#include <ti/sysbios/knl/Task.h>
-#include <ti/ipc/Ipc.h>
-#include <ti/ipc/MessageQ.h>
-#include <ti/ipc/MultiProc.h>
-
-#include <sio.h>
-#include <pafsio_ialg.h>
+#include <xdc/runtime/Log.h>
 
-#include "common.h"
-#include "paf_heapMgr.h"
+#include "procsdk_audio_typ.h"
+#include "audioStreamInpProc.h"
+#include "audioStreamProc_common.h"
 #include "aspMsg_common.h"
 #include "aspMsg_master.h"
-#include "aspDecOpCircBuf_master.h"
-#include "audioStreamProc_common.h"
-#include "audioStreamProc_master.h"
-#include "audioStreamInpProc.h"
-#include "mib.h"
+#include "asperr.h"
+#include "common.h"
+#include "as1-f2.h"
 
-//#include "fwkPort.h"
-// FL: debug
-#include "dbgCapAf.h"
-#include "dbgDib.h"
-#include "statusOp_common.h"
+#include "ioConfig.h"    //TODO: remove this header
+#include "ioBuff.h"
+#include "ioPhy.h"
+#include "ioData.h"
 
+enum {
+    INFO1,
+    INFO2,
+    DECODE,
+    QUIT
+};
 
-// -----------------------------------------------------------------------------
-// Debugging Trace Control, local to this file.
-//
-#include "logp.h"
+static Int decDecodeInit(const PAF_ASIT_Params *pP, PAF_ASIT_Config *pAsitCfg,
+                         Int sourceSelect);
+static Int decDecodeInfo(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
+                         PAF_ASIT_Config *pAsitCfg);
+static Int decDecodeData(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
+                         PAF_ASIT_Config *pAsitCfg, Int sourceSelect);
+static Int decDecodeComplete(const PAF_ASIT_Params *pP,
+                             PAF_ASIT_Config *pAsitCfg);
 
-// .............................................................................
+extern Int getFrameLengthSourceSel(const PAF_ASIT_Params *pP, Int8 sourceSelect);
 
-#include <pafsio.h>
-#include "paferr.h"
+extern UInt32 gCbWrtAfErrCnt;
 
-#include <acp_mds.h>
 
-#include <pcm.h>
 
-#include <pce.h>
+Int asipDecodeInit(
+        const PAF_ASIT_Params *pP,
+        PAF_ASIT_Config *pAsitCfg,
+        Int sourceSelect)
+{
+    Int errno;
 
-#include <doberr.h>
+    errno = decDecodeInit(pP, pAsitCfg, sourceSelect);
 
-#include <diberr.h>
+    if(errno) {
+        decDecodeComplete(pP, pAsitCfg);
 
-#include <stdasp.h>
+        return ASIP_ERR_DECODE_INIT;
+    }
 
-#include "as0.h"
-#include "asperr.h"
+    return ASIP_NO_ERR;
+}
 
-#include "audioStreamProc_params.h"
-#include "audioStreamProc_patchs.h"
-#include "audioStreamProc_config.h"
-#include "audioStreamInpProc.h"
 
-#include "ioData.h"
-//#include "../newio/fw/mcasp_cfg.h"
+// -----------------------------------------------------------------------------
+// ASIT Processing Function - Decode Processing
+//
+//   Name:      asipDecodeProcessing
+//   Purpose:
+//   Return:    Error number in standard form (0 on success).
+// -----------------------------------------------------------------------------
+Int asipDecodeProcessing(
+        const PAF_ASIT_Params *pP,
+        const PAF_ASIT_Patchs *pQ,
+        PAF_ASIT_Config *pAsitCfg,
+        Int sourceSelect)
+{
+    PAF_AST_Config *pAstCfg;
+    Int decError, retVal, getVal;                          /* error number */
+    Int zMD;
+    Int8 tempVar8;
 
-#include "ioConfig.h"                //JXTODO: to remove compile-time configurations
+    pAstCfg = pAsitCfg->pAstCfg;     // get pointer to common (shared) configuration
+    zMD = pAstCfg->masterDec;
 
-//#include "dbgBenchmark.h" // PCM high-sampling rate + SRC + CAR benchmarking
+    retVal = ASIP_NO_ERR;
 
+    tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
+                                 GATEMP_INDEX_DEC);
+    if (tempVar8 == PAF_SOURCE_NONE) {
+        TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: sourceSelect == PAF_SOURCE_NONE");
+        pAsitCfg->inpDec.state = QUIT;   // skip processing, quit decoding
+    }
 
-#define DECSIOMAP(X)                                                \
-    pP->pDecSioMap->map[(X) >= pP->pDecSioMap->length ? 0 : (X)]
+    // Process commands (decode)
+    getVal = pP->fxns->decodeCommand(pP, pQ, pAsitCfg);
+    if (getVal) {
+        if (getVal == ASPERR_QUIT) {
+            pAsitCfg->inpDec.state = QUIT;  // skip processing, quit decoding
+            TRACE_VERBOSE0("PAF_ASIT_decodeProcessing. %d: 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--;
 
-enum {
-       INFO1,
-       INFO2,
-       DATA
-};
+            return ASIP_ERR_DECODE_COMMAND;
+        }
+        else {
+            /* ignore */;
+        }
+    }
 
+    retVal = ASIP_NO_ERR;
 
-#ifdef RX_MCASP_USE_MULT_SER
-#define INPUT_STRIDE 8
-#else
-#define INPUT_STRIDE 2
-#endif
+    switch(pAsitCfg->inpDec.state)
+    {
+        case INFO1:
+            decError = decDecodeInfo(pP, pQ, pAsitCfg);
+            if (decError) {
+                //gAsipInfo1_PrimaryErrCnt++;
+                TRACE_TERSE1("INFO1: decError 0x%x after decodeInfo, primary timing", decError);
+                retVal = ASIP_ERR_DECODE_INFO1;
+            }
+            else {
+                // Don't start decode until major access unit is found.
+                Int8 sourceDecode, sampleRate;
 
-extern PAF_AST_InpIO *inpIOtemp;    /* Input I/O */
-extern UInt32 gCapIb_cnt;
+                sourceDecode = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceDecode),
+                                                 GATEMP_INDEX_DEC);
+                sampleRate   = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sampleRate),
+                                                 GATEMP_INDEX_DEC);
+                if ( ( (sourceDecode == PAF_SOURCE_THD)     ||
+                       (sourceDecode == PAF_SOURCE_DXP)     ||
+                       (sourceDecode == PAF_SOURCE_DTSHD) ) &&
+                     ( sampleRate == PAF_SAMPLERATE_UNKNOWN) ) {
+                    //gMajorAuMissed++; // debug
+                    pAsitCfg->inpDec.frame++;
+                    //pAsitCfg->inpDec.state = INFO1;    // stay in this state
+                }
+                else {
+                    decError = pP->fxns->decodeInfo1(pP, pQ, pAsitCfg, pAsitCfg->inpDec.frame, pAsitCfg->inpDec.block);
+                    if(decError) {
+                        retVal = ASIP_ERR_DECODE_INFO1;
+                    }
+                    else {
+                        pAsitCfg->inpDec.state = DECODE;
+                    }
+                }
+            }
+            break;
+
+        case INFO2:
+            decError = decDecodeInfo(pP, pQ, pAsitCfg);
+            if (decError) {
+                //gAsipInfo1_PrimaryErrCnt++;
+                TRACE_TERSE1("INFO2: decError 0x%x after decodeInfo, primary timing", decError);
+                retVal = ASIP_ERR_DECODE_INFO2;
+            }
+            else {
+                pAsitCfg->inpDec.state= DECODE;
+            }
+            break;
+
+        case DECODE:
+            decError = decDecodeData(pP, pQ, pAsitCfg, sourceSelect);
+            if (decError) {
+                //gAsipDecodeErrCnt++;
+                TRACE_TERSE1("PAF_ASIT_decodeProcessing: state: DECODE.  decodeDecode err 0x%04x", decError);
+                retVal = ASIP_ERR_DECODE_DATA;
+            }
+            else {
+                decError = pP->fxns->decodeFinalTest(pP, pQ, pAsitCfg, pAsitCfg->inpDec.frame, pAsitCfg->inpDec.block);
+                if (decError) {
+                    retVal = ASIP_ERR_DECODE_FINAL;
+                }
+                else {
+                    pAsitCfg->inpDec.frame++;
+                    pAsitCfg->inpDec.state = INFO2;
+                }
+            }
+            break;
+
+        case QUIT:
+            //gAsipQuitCnt++;
+            Log_info0("TaskAsip: state=QUIT");
+
+            // Quit:
+            // - 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:
+            break;
+
+    }
+
+    if(retVal != ASIP_NO_ERR) {
+        decDecodeComplete(pP, pAsitCfg);
+    }
+
+    return retVal;
+}  /* asipDecodeProcessing */
 
-// Functions prototypes only referenced in this file
-static Int decDecideFrameLength(Int sourceSelect);
-static Int decDecodeInfo(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
-                          PAF_ASIT_Config *pC, asipDecProc_t *pDec, Int frame, Int block);
-static Int decDecodeData(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
-                            PAF_ASIT_Config *pC, Int sourceSelect, Int frame, Int block);
-//void asipUpdateInpBufConfig(PAF_AST_InpBuf *inpBufConfig, ioDataHandle_t ioDataHandle);
 
 // -----------------------------------------------------------------------------
 // ASIT Decoding Function - Reinitialization of Decode
 //
-//   Name:      PAF_ASIT_decodeInit
+//   Name:      decDecodeInit
 //   Purpose:   Decoding Function for reinitializing the decoding process.
 //   From:      AST Parameter Function -> decodeProcessing
 //   Uses:      See code.
@@ -150,33 +250,42 @@ static Int decDecodeData(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
 //   Trace:     Message Log "trace" in Debug Project Configuration reports:
 //              * State information as per parent.
 //
-Int asipDecodeInit(
-           const PAF_ASIT_Params *pP,
-           PAF_ASIT_Config *pC,
-               asipDecProc_t *pD,
-               Int sourceSelect)
+// -----------------------------------------------------------------------------
+static Int decDecodeInit(
+        const PAF_ASIT_Params *pP,
+        PAF_ASIT_Config *pAsitCfg,
+        Int sourceSelect)
 {
     PAF_AST_Config *pAstCfg;
-    PAF_AST_DecOpCircBufCtl *pCbCtl;    /* Decoder output circular buffer control */
+    PAF_AST_IoInp  *pInp;
+    //PAF_AST_DecOpCircBufCtl *pCbCtl;    /* Decoder output circular buffer control */
     Int as;                             /* Audio Stream Number (1, 2, etc.) */
     Int z;                              /* decode/encode counter */
     Int errno;                          /* error number */
     Int zI, zS;
+    Int argIdx;
     Int8 tempVar8;
+    char decMsgBuf[ASP_MSG_BUF_LEN];
     ioPhyCtl_t ioPhyCtl;
     ioDataCtl_t ioDataCtl;
 
-    pAstCfg = pC->pAstCfg;   // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to AST common (shared) configuration
+    pInp    = pAsitCfg->pIoInp;
+
     as = pAstCfg->as;
     (void)as;  // clear compiler warning in case not used with tracing disabled
 
-    pCbCtl = &pC->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
+    //pCbCtl = &pAsitCfg->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
 
     // reset frameCount
     for (z=DECODE1; z < DECODEN; z++)
     {
-        if (readSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.mode)))  {
-               writeSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.frameCount), 0);
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
+        if (tempVar8)
+        {
+            sharedMemWriteInt(&(pAstCfg->xDec[z].decodeStatus.frameCount),
+                              (Int)0, GATEMP_INDEX_DEC);
         }
     }
 
@@ -186,9 +295,9 @@ Int asipDecodeInit(
         zI = pP->inputsFromDecodes[z];
         zS = pP->streamsFromDecodes[z];
         (void)zS; // clear compiler warning in case not used with tracing disabled
-
-        if (   inpIOtemp[zI].hIoPhy
-            && readSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.mode)))
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
+        if (pInp[zI].hIoPhy && tempVar8)
         {
             Uns gear;
             Int frameLength;
@@ -199,11 +308,31 @@ Int asipDecodeInit(
             Cache_wait();
 
             // FL: send dec activate message to slave
-            asipSendMsgToDecoder(ASP_SLAVE_DEC_ACTIVATE, z, ASP_MASTER_DEC_ACTIVATE_DONE, NULL);
+            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)
+            {
+                TRACE_TERSE0("decodeInit: error in sending DEC_ACTIVATE message ");
+                SW_BREAKPOINT; // temporary
+                return ASIP_ERR_DECODE_MSG; // temporary
+            }
 
             // FL: send dec reset message to slave
-            errno = 0;
-            errno = asipSendMsgToDecoder(ASP_SLAVE_DEC_RESET, z, ASP_MASTER_DEC_RESET_DONE, NULL);
+            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)
+            {
+                TRACE_TERSE0("decodeInit: error in sending DEC_RESET message ");
+                SW_BREAKPOINT; // temporary
+                return ASIP_ERR_DECODE_MSG; // temporary
+            }
+            else
+            {
+                argIdx = 0; // get decErrno
+                errno = *(Int32 *)&decMsgBuf[argIdx];
+            }
 
             // (***) FL: revisit
             // invalidate Dec configuration
@@ -211,32 +340,22 @@ Int asipDecodeInit(
             Cache_wait();
 
             if (errno != 0) {
-                return ASIP_DECODE_ERR_MSG_SEND;
+                return ASIP_ERR_DECODE_MSG;
             }
 
-            gear = readSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.aspGearControl));
+            gear = (Uns)sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.aspGearControl),
+                                          GATEMP_INDEX_DEC);
             tempVar8 = gear < GEARS ? gear : 0;
-            writeSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.aspGearStatus), tempVar8);
+            sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.aspGearStatus),
+                               tempVar8, GATEMP_INDEX_DEC);
 
-            frameLength = decDecideFrameLength(sourceSelect);
+            // Compute decoder frame length based on source selection
+            frameLength = getFrameLengthSourceSel(pP, sourceSelect);
 
             pAstCfg->xDec[z].decodeControl.frameLength = frameLength;
             pAstCfg->xDec[z].decodeInStruct.sampleCount = frameLength;
             pAstCfg->xDec[z].decodeControl.sampleRate = PAF_SAMPLERATE_UNKNOWN;
 
-            // (***) FL: revisit. Count samples for DDP.
-            // Add framework frame length and running sample count to decoder control.
-            //pC->xDec[z].decodeControl.pafFrameLength = FRAMELENGTH;
-            //pC->xDec[z].decodeControl.rdSampleCount = 0;
-
-            // Initialize decoder output circular buffer for selected source
-            //errno = cbInitSourceSel(pCbCtl, z, sourceSelect, frameLength, FRAMELENGTH, 0);
-            if (errno) {
-                SW_BREAKPOINT; // FL: debug
-                return ASIP_DECODE_ERR_INIT_CB;
-            }
-            // FL: debug
-            cbLog(pCbCtl, z, 1, "PAF_ASIT_decodeInit:cbInitSourceSel");
 
 /*
             if (z != zMD) {    // JXTODO: implement similar thing with new I/O
@@ -245,166 +364,35 @@ Int asipDecodeInit(
                 }
             }
 */
-/*
-            //JXTODO: do we need to update input status here again?
-            if (errno = asipUpdateInputStatus(inpIOtemp[0].pRxParams,
-                                                 &pAstCfg->xInp[zI].inpBufStatus,
-                                              &pAstCfg->xInp[zI].inpBufConfig)) {
-                return errno;
-            }
-*/
-        } /* end of if(hIoPhy && decodeStatus.mode) */
-    } /* end of for (z=DECODE1; z < DECODEN; z++) */
-
-    pD->frame = 0;
-    pD->block = 0;
-    pD->state = INFO1;
-    
-    return ASIP_DECODE_NO_ERR;
-}  /* asipDecodeInit */
+            pInp[z].sourceSelect = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.sourceSelect),
+                                                     GATEMP_INDEX_DEC);
 
-// -----------------------------------------------------------------------------
-// ASIT Processing Function - Decode Processing
-//
-//   Name:      asipDecodeProcessing
-//   Purpose:   Audio Stream Input Task Function for processing audio data.
-//   Return:    Error number in standard form (0 on success).
-//
-#if 0
-Int asipDecodeProcessing(
-           const PAF_ASIT_Params *pP,
-           const PAF_ASIT_Patchs *pQ,
-           PAF_ASIT_Config *pC,
-               asipDecProc_t *pD,
-               Int sourceSelect)
-{
-    PAF_AST_Config *pAstCfg;
-    Int errno, retVal;                          /* error number */
-    Int zMD;
+            ioDataCtl.code = IODATA_CTL_SET_PCM_FRAME_LENGTH;
+            ioDataCtl.param.frameLengthPcm = frameLength;
+            errno = ioDataControl(pInp[zI].hIoData, &ioDataCtl);
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
-    zMD = pAstCfg->masterDec;
-
-    retVal = ASIP_DECODE_NO_ERR;
-
-    //!! to add data read from I/O buffer
-    switch(pD->state)
-    {
-        case INFO1:
-            if (errno = decDecodeInfo(pP, pQ, pC, pD, pD->frame, pD->block)) {
-                //gAsipInfo1_PrimaryErrCnt++;
-                TRACE_TERSE1("INFO1: errno 0x%x after decodeInfo, primary timing", errno);
-               retVal = ASIP_DECODE_ERR_INFO1;
-            }
-            else {
-               // Don't start decode until major access unit is found.
-               Int8 sourceDecode, sampleRate;
-               sourceDecode = readSharedMem((Int8 *)&(pAstCfg->xDec[zMD].decodeStatus.sourceDecode));
-               sampleRate   = readSharedMem((Int8 *)&(pAstCfg->xDec[zMD].decodeStatus.sampleRate));
-                if ( ( (sourceDecode == PAF_SOURCE_THD)     ||
-                       (sourceDecode == PAF_SOURCE_DXP)     ||
-                       (sourceDecode == PAF_SOURCE_DTSHD) ) &&
-                     ( sampleRate == PAF_SAMPLERATE_UNKNOWN) ) {
-                       pD->state = INFO1;
-                }
-                else {
-                       pD->state = DATA;
-                }
-            }
-            break;
+            ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
+            ioPhyCtl.params.xferFrameSize = frameLength * (WORD_SIZE_PCM);
+            ioPhyControl(pInp[zI].hIoPhy, &ioPhyCtl);
 
-        case INFO2:
-            if (errno = decDecodeInfo(pP, pQ, pC, pD, pD->frame, pD->block)) {
-                //gAsipInfo1_PrimaryErrCnt++;
-                TRACE_TERSE1("INFO2: errno 0x%x after decodeInfo, primary timing", errno);
-               retVal = ASIP_DECODE_ERR_INFO2;
-            }
-            else {
-                pD->state = DATA;
-            }
-            break;
+            pInp[zI].phyXferSize = ioPhyCtl.params.xferFrameSize;
 
-        case DATA:
-            if (errno = decDecodeData(pP, pQ, pC, sourceSelect, pD->frame, pD->block)) {
-                //gAsipDecodeErrCnt++;
-                TRACE_TERSE1("PAF_ASIT_decodeProcessing: state: DATA.  decodeDecode err 0x%04x", errno);
-               retVal = ASIP_DECODE_ERR_DATA;
-            } 
-            else {
-                if (pP->fxns->decodeFinalTest(pP, pQ, pC, pD->frame, pD->block)) {
-                       retVal = ASIP_DECODE_ERR_FINAL;
-                }
-                else {
-                    pD->state = INFO2;
-                }                
+            //JXTODO: do we need to update input status here again?
+            if (errno = asipUpdateInputStatus(pInp[zI].pRxParams,
+                                              &pAstCfg->xInp[zI].inpBufStatus,
+                                              &pAstCfg->xInp[zI].inpBufConfig)) {
+                return ASIP_ERR_INPUT_CFG;
             }
-            break;
-
-        default:
-               break;
-        
-    }
-
-    return retVal;
-}  /* asipDecodeProcessing */
-#endif
+        } /* end of if(hIoPhy && decodeStatus.mode) */
+    } /* end of for (z=DECODE1; z < DECODEN; z++) */
 
+    pAsitCfg->inpDec.frame = 0;
+    pAsitCfg->inpDec.block = 0;
+    pAsitCfg->inpDec.state = INFO1;
 
-Int asipDecodeProcessing(
-           const PAF_ASIT_Params *pP,
-           const PAF_ASIT_Patchs *pQ,
-           PAF_ASIT_Config *pC,
-               asipDecProc_t *pD,
-               Int sourceSelect)
-{
-    PAF_AST_Config *pAstCfg;
-    Int errno, retVal;                          /* error number */
-    Int zMD;
+    return ASIP_NO_ERR;
+}  /* decDecodeInit */
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
-    zMD = pAstCfg->masterDec;
-    retVal = ASIP_DECODE_NO_ERR;
-
-    //pAstCfg->xInp[0].inpBufStatus.sampleRateStatus = PAF_SAMPLERATE_192000HZ;  //JXTODO: make this correct
-    errno = decDecodeInfo(pP, pQ, pC, pD, pD->frame, pD->block);
-    if (errno != ASIP_DECODE_NO_ERR) {
-        //gAsipInfo1_PrimaryErrCnt++;
-        TRACE_TERSE1("INFO1: errno 0x%x after decodeInfo, primary timing", errno);
-        retVal =  ASIP_DECODE_ERR_INFO;
-    }
-    else {
-       // Don't start decode until major access unit is found.
-       Int8 sourceDecode, sampleRate;
-       sourceDecode = readSharedMem((Int8 *)&(pAstCfg->xDec[zMD].decodeStatus.sourceDecode));
-       sampleRate   = readSharedMem((Int8 *)&(pAstCfg->xDec[zMD].decodeStatus.sampleRate));
-        if ( ( (sourceDecode == PAF_SOURCE_THD)     ||
-               (sourceDecode == PAF_SOURCE_DXP)     ||
-               (sourceDecode == PAF_SOURCE_DTSHD) ) &&
-             ( sampleRate == PAF_SAMPLERATE_UNKNOWN) ) {
-               /* do nothing and return - waiting for major access unit */;
-            retVal =  ASIP_DECODE_NO_ERR;
-        }
-        else {
-               errno = decDecodeData(pP, pQ, pC, sourceSelect, pD->frame, pD->block);
-            if (errno != ASIP_DECODE_NO_ERR) {
-                //gAsipDecodeErrCnt++;
-                TRACE_TERSE1("PAF_ASIT_decodeProcessing: state: DATA.  decodeDecode err 0x%04x", errno);
-               retVal = ASIP_DECODE_ERR_DATA;
-            }
-            else {
-               errno = pP->fxns->decodeFinalTest(pP, pQ, pC, pD->frame, pD->block);
-                if (errno) {
-                       retVal = ASIP_DECODE_ERR_FINAL;
-                }
-                else {
-                    retVal = ASIP_DECODE_NO_ERR;
-                }
-            }
-        }
-    }
-
-    return retVal;
-}  /* asipDecodeProcessing */
 
 // -----------------------------------------------------------------------------
 // ASIT Decoding Function - Info Processing, Common
@@ -423,25 +411,28 @@ Int
 decDecodeInfo(
     const PAF_ASIT_Params *pP,
     const PAF_ASIT_Patchs *pQ,
-    PAF_ASIT_Config *pC,
-       asipDecProc_t *pD,
-    Int frame,
-    Int block
+    PAF_ASIT_Config *pAsitCfg
 )
 {
     PAF_AST_Config *pAstCfg;
+    PAF_AST_IoInp  *pInp;
     Int as;                    /* Audio Stream Number (1, 2, etc.) */
     Int z;                     /* input/decode/stream counter */
     Int errno;                 /* error number */
     Int zD, zI, zS, zX;
     Int zMD;
-    //Int zMI;
+    Int zMS;
+    Int argIdx;
     Int8 tempVar8;
     Int tempVar;
+    char decMsgBuf[ASP_MSG_BUF_LEN];
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg;   // get pointer to common (shared) configuration
+    pInp    = pAsitCfg->pIoInp;
+    as = pAstCfg->as;
     zMD = pAstCfg->masterDec;
-    //zMI = pP->zone.master;
+    zMS = pAstCfg->masterStr;
+    (void)zMS;  (void)as;  // clear compiler warning in case not used with tracing disabled
 
     // Set decode control: sample rate, emphasis
     for (z=INPUT1; z < INPUTN; z++)
@@ -455,7 +446,7 @@ decDecodeInfo(
             }
         }
 
-        if (inpIOtemp[z].hIoPhy) {
+        if (pInp[z].hIoPhy) {
             //determine associated decoder
             if (pAstCfg->xInp[z].inpBufStatus.sampleRateStatus !=
                 pAstCfg->xDec[zD].decodeControl.sampleRate) {
@@ -472,7 +463,8 @@ decDecodeInfo(
                 }
             }
 
-            tempVar8 = readSharedMem((Int8 *)&(pAstCfg->xDec[zD].decodeStatus.sourceDecode));
+            tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zD].decodeStatus.sourceDecode),
+                                         GATEMP_INDEX_DEC);
             pAstCfg->xDec[zD].decodeControl.emphasis =
                 tempVar8 != PAF_SOURCE_PCM
                 ? PAF_IEC_PREEMPHASIS_NO // fix for Mantis ID #119
@@ -499,81 +491,102 @@ decDecodeInfo(
         zS = pP->streamsFromDecodes[z];
         (void)zS; // clear compiler warning in case not used with tracing disabled
 
-        if ( inpIOtemp[zI].hIoPhy &&
-             readSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.mode)))
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
+        if (pInp[zI].hIoPhy  && tempVar8)
         {
-            TRACE_GEN2("PAF_ASIT_decodeInfo: AS%d: processing frame %d -- info", as+zS, frame);
+            TRACE_GEN2("PAF_ASIT_decodeInfo: AS%d: processing frame %d -- info", as+zS, pAsitCfg->inpDec.frame);
 
-            if (errno = asipUpdateInputStatus(inpIOtemp[zI].pRxParams,
+            if (errno = asipUpdateInputStatus(pInp[zI].pRxParams,
                                               &pAstCfg->xInp[zI].inpBufStatus,
-                                                                                         &pAstCfg->xInp[zI].inpBufConfig)) {
+                                              &pAstCfg->xInp[zI].inpBufConfig)) {
                 TRACE_TERSE1("return error errno 0x%x.", errno);
                 return errno;
             }
 
             // debug, capture input buffer
-            capIb(pAstCfg->xInp[zI].pInpBuf);
-            gCapIb_cnt++;
+            //capIb(pAstCfg->xInp[zI].pInpBuf);
+            //gCapIb_cnt++;
 
+#if 1
+            // (***) FL: revisit
             // write back Inp configuration
             Cache_wb(&pAstCfg->xInp[zI], sizeof(PAF_AST_InpBuf), Cache_Type_ALLD, 0);
-            // write back input data //  (***) GJ: don't need this for 1xI2S HDMI/SPDIF. Maybe need this for 4xI2S HDMI.
-            //pIpBufConfig = &gPAF_AST_config.xInp[zI].inpBufConfig;
-            //size = pIpBufConfig->frameLength * pIpBufConfig->sizeofElement;
-            //Cache_wb((Ptr)pIpBufConfig->pntr.pSmInt, size, Cache_Type_ALLD, 0);
             // write back Dec configuration
             Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
             Cache_wait();
+#endif
 
-            errno = asipSendMsgToDecoder(ASP_SLAVE_DEC_INFO, z, ASP_MASTER_DEC_INFO_DONE, NULL);
+            // FL: send info message to slave
+            argIdx = 0; // set decIdx
+            *(Int32 *)&decMsgBuf[argIdx] = z;
+            if(AspMsgSend(ASP_SLAVE_DEC_INFO, ASP_MASTER_DEC_INFO_DONE,
+                          decMsgBuf, decMsgBuf) != ASP_MSG_NO_ERR)
+            {
+                TRACE_TERSE0("decodeInfo: error in sending DEC_INFO message ");
+                SW_BREAKPOINT; // temporary
+                return -1;     // temporary
+            }
+            else
+            {
+                argIdx = 0; // get decErrno
+                errno = *(Int32 *)&decMsgBuf[argIdx];
+            }
 
+#if 1
             // (***) FL: revisit
             // invalidate Dec configuration
             Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
             Cache_wait();
+#endif
 
             if (errno) {
                 TRACE_TERSE1("return error errno 0x%x.", errno);
                 return errno;
             }
 
-            tempVar = readSharedMemInt((Int *)&(pAstCfg->xDec[z].decodeStatus.frameCount));
             // increment decoded frame count
+            tempVar = sharedMemReadInt(&(pAstCfg->xDec[z].decodeStatus.frameCount),
+                                       GATEMP_INDEX_DEC);
             tempVar += 1;
-            writeSharedMemInt((Int *)&(pAstCfg->xDec[z].decodeStatus.frameCount), tempVar);
+            sharedMemWriteInt(&(pAstCfg->xDec[z].decodeStatus.frameCount),
+                              tempVar, GATEMP_INDEX_DEC);
         }
     } // z=DECODE1 to DECODEN
 
     // query IB for latest sourceProgram (needed if we started decoding due to a force mode)
-    if (readSharedMem((Int8 *)&(pAstCfg->xDec[zMD].decodeStatus.mode))) {
-#if 0
-        //JXTODO: implement ioDataControl
-       ioDataCtl_t ioDataCtl;
-       ioDataCtl.code = IODATA_CTL_GET_SOURCEPROGRAM;
-        if (errno = ioDataControl(inpIOtemp->hIoData, &ioDataCtl)) {
-            TRACE_TERSE1("return error ASPERR_AUTO_PROGRAM. errno 0x%x.", errno);
-            return ASPERR_AUTO_PROGRAM;
-        }
-#endif
-        writeSharedMem((Int8 *)&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
-                              (Int8)pD->sourceProgram);
-                              //(Int8)ioDataCtl.param.sourceProgram);
+    tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.mode),
+                                 GATEMP_INDEX_DEC);
+    if (tempVar8)
+    {
+        sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
+                           pInp[zMD].sourceProgram, GATEMP_INDEX_DEC);
     }
 
     // since now decoding update decode status for all enabled decoders
     for (z=DECODE1; z < DECODEN; z++)
     {
-        if (readSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.mode))) {
-               tempVar8 = readSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.sourceProgram));
-            writeSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.sourceDecode), tempVar8);
-            tempVar8 = readSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.sourceSelect));
-            if (tempVar8 == PAF_SOURCE_SNG) {
-                writeSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.sourceDecode), tempVar8);
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
+        if (tempVar8)
+        {
+            tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.sourceProgram),
+                                         GATEMP_INDEX_DEC);
+            sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.sourceDecode),
+                               tempVar8, GATEMP_INDEX_DEC);
+
+            tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.sourceSelect),
+                                         GATEMP_INDEX_DEC);
+            if (tempVar8 == PAF_SOURCE_SNG)
+            {
+                tempVar8 = PAF_SOURCE_SNG;
+                sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.sourceDecode),
+                                   tempVar8, GATEMP_INDEX_DEC);
             }
         }
     }
 
-       return ASIP_DECODE_NO_ERR;
+    return ASIP_NO_ERR;
 } /* decDecodeInfo */
 
 
@@ -590,26 +603,23 @@ decDecodeInfo(
 //   Trace:     Message Log "trace" in Debug Project Configuration reports:
 //              * State information as per parent.
 // -----------------------------------------------------------------------------
-Int
-decDecodeData(
-    const PAF_ASIT_Params *pP,
-    const PAF_ASIT_Patchs *pQ,
-    PAF_ASIT_Config *pC,
-    Int sourceSelect,
-    Int frame,
-    Int block
-)
+static Int decDecodeData(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
+                         PAF_ASIT_Config *pAsitCfg, Int sourceSelect)
 {
     PAF_AST_Config *pAstCfg;
+    PAF_AST_IoInp  *pInp;
     Int as;                     /* Audio Stream Number (1, 2, etc.) */
     Int z;                      /* decode/stream counter */
     Int errno;                  /* error number */
-    //Int ch;
+    Int argIdx;
     Int cbErrno;
     Int frameLength;
-    ioPhyCtl_t ioPhyCtl;
+    char decMsgBuf[ASP_MSG_BUF_LEN];
+    ioPhyCtl_t  ioPhyCtl;
+    ioDataCtl_t ioDataCtl;
 
-    pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
+    pAstCfg = pAsitCfg->pAstCfg; // get pointer to common (shared) configuration
+    pInp    = pAsitCfg->pIoInp;
     as = pAstCfg->as;
     (void)as; // clear compiler warning in case not used with tracing disabled
 
@@ -619,10 +629,9 @@ decDecodeData(
         Int zI = pP->inputsFromDecodes[z];
         Int zS = pP->streamsFromDecodes[z];
         (void)zS; // clear compiler warning in case not used with tracing disabled
-        if ( inpIOtemp[zI].hIoPhy &&
-             readSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.mode)))
+        if ( pInp[zI].hIoPhy && pAstCfg->xDec[z].decodeStatus.mode )
         {
-            TRACE_GEN2("PAF_ASIT_decodeDecode: AS%d: decodeDecode: processing block %d -- decode", as+zS, block);
+            TRACE_GEN2("PAF_ASIT_decodeDecode: AS%d: decodeDecode: processing block %d -- decode", as+zS, pAsitCfg->inpDec.block);
 
             TRACE_VERBOSE3("PAF_ASIT_decodeDecode: AS%d: decodeDecode: decoding from 0x%x (base) 0x%x (ptr)",
                     as+zS,
@@ -637,11 +646,29 @@ decDecodeData(
             Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
             Cache_wait();
 
-            errno = asipSendMsgToDecoder(ASP_SLAVE_DEC_DECODE, z, ASP_MASTER_DEC_DECODE_DONE, &cbErrno);
-            if (cbErrno != 0) {
-                //gCbWrtAfErrCnt++;
-                TRACE_TERSE1("CB write error=%d", cbErrno);
-                //SW_BREAKPOINT; // temporary
+            // FL: send decode message to slave
+            errno  = 0;
+            argIdx = 0; // set decIdx
+            *(Int32 *)&decMsgBuf[argIdx] = z;
+            if(AspMsgSend(ASP_SLAVE_DEC_DECODE, ASP_MASTER_DEC_DECODE_DONE,
+                          decMsgBuf, decMsgBuf) != ASP_MSG_NO_ERR)
+            {
+                TRACE_TERSE0("decodeDecode: error in sending DEC_DECODE message ");
+                SW_BREAKPOINT; // temporary
+                return -1;     // temporary
+            }
+            else
+            {
+                argIdx = 0; // get decErrno
+                errno = *(Int32 *)&decMsgBuf[argIdx];
+                argIdx += sizeof(Int32); // get cbErrno
+                cbErrno = *(Int32 *)&decMsgBuf[argIdx];
+                if (cbErrno != 0)
+                {
+                    gCbWrtAfErrCnt++;
+                    TRACE_TERSE1("CB write error=%d", cbErrno);
+                    //SW_BREAKPOINT; // temporary
+                }
             }
 
             // (***) FL: revisit
@@ -649,106 +676,128 @@ decDecodeData(
             Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
             Cache_wait();
 
-            if (errno) {
+            if (errno)
+            {
                 TRACE_VERBOSE1("PAF_ASIT_decodeDecode: fxns->decode returns 0x%x", errno);
                 return errno;
             }
 
-            frameLength = decDecideFrameLength(sourceSelect);
+#if (CURRENT_TRACE_MASK & TRACE_MASK_DATA)
+            as_traceChannels(pAsitCfg, z);
+#endif
+
+            // Compute decoder frame length based on source selection
+            frameLength = getFrameLengthSourceSel(pP, sourceSelect);
 
-            pAstCfg->xDec[z].decodeControl.frameLength = frameLength;
+            pAstCfg->xDec[z].decodeControl.frameLength  = frameLength;
             pAstCfg->xDec[z].decodeInStruct.sampleCount = frameLength;
 
+            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.
         } // hIoPhy && decodeStatus.mode
         else {
-            TRACE_VERBOSE2("AS%d: PAF_ASIT_decodeDecode: processing block %d -- decode <ignored>", as+zS, block);
+            TRACE_VERBOSE2("AS%d: PAF_ASIT_decodeDecode: processing block %d -- decode <ignored>", as+zS, pAsitCfg->inpDec.block);
         }
     } // z=DECODE1 to DECODEN
 
-       return ASIP_DECODE_NO_ERR;
+    return ASIP_NO_ERR;
+
 } /* decDecodeData */
 
-//JXTODO: what does this frame length have to with IECframeLength[23]
-Int decDecideFrameLength(Int sourceSelect)
+
+Int decDecodeComplete( const PAF_ASIT_Params *pP,
+                       PAF_ASIT_Config *pAsitCfg)
 {
-       Int frameLength;
+    int z, zMD, decError;
+    ALG_Handle alg[DECODEN_MAX];
 
-    if (sourceSelect == PAF_SOURCE_PCM) {
-       frameLength = PAF_SYS_FRAMELENGTH;
-    }
-    else if ((sourceSelect == PAF_SOURCE_DDP) || (sourceSelect == PAF_SOURCE_AC3)) {
-        frameLength = 1536;   //JXTODO: replace 1536 with macro
-    }
-    else if (sourceSelect == PAF_SOURCE_THD) {
-        frameLength = 1536;   //JXTODO: replace 1536 with macro
+    zMD = pAsitCfg->pAstCfg->masterDec;
+
+    for (z=DECODE1; z < DECODEN; z++)
+    {
+        alg[z] = pAsitCfg->pAstCfg->xDec[z].decAlg[PAF_SOURCE_PCM];
     }
-    else {
-        frameLength = 256;   //JXTODO: replace 256 with macro
+    alg[zMD] = NULL; // decAlgMaster; // FL: alg[] init is on slave
+
+    // Call decodeComplete: 2nd argument is NOT used inside the function
+    decError = pP->fxns->decodeComplete(pP, NULL, pAsitCfg, alg,
+                                        pAsitCfg->inpDec.frame, pAsitCfg->inpDec.block);
+
+    if(decError) {
+        return ASIP_ERR_DECODE_COMPLETE;
     }
 
-    return frameLength;
-} /* decDecideFrameLength */
+    return ASIP_NO_ERR;
+}  /* decDecodeComplete */
 
 
-// -----------------------------------------------------------------------------
-// ASIT Decoding Function - Stream-Final Processing
-//
-//   Name:      PAF_ASIT_decodeComplete
-//   Purpose:   Decoding Function for terminating the decoding process.
-//   From:      AST Parameter Function -> decodeProcessing
-//   Uses:      See code.
-//   States:    x
-//   Return:    0.
-//   Trace:     Message Log "trace" in Debug Project Configuration reports:
-//              * State information as per parent.
-//
-Int
-asipDecodeComplete(
-    const PAF_ASIT_Params *pP,
-    const PAF_ASIT_Patchs *pQ,
-    PAF_ASIT_Config *pC,
-    ALG_Handle decAlg[]
-)
+#if 0
+Int asipDecodeProcessing(
+        const PAF_ASIT_Params *pP,
+        const PAF_ASIT_Patchs *pQ,
+        PAF_ASIT_Config *pC,
+        Int sourceSelect)
 {
     PAF_AST_Config *pAstCfg;
-    Int as;                     /* Audio Stream Number (1, 2, etc.) */
-    Int z;                      /* decode/encode counter */
+    Int errno, retVal;                          /* error number */
+    Int zMD;
 
     pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
-    as = pAstCfg->as;
-    (void)as;  // clear compiler warning in case not used with tracing disabled
-
-#ifdef PAF_ASP_FINAL
-    /* This material is currently not utilized */
-#endif /* PAF_ASP_FINAL */
-    for (z=DECODE1; z < DECODEN; z++)
-    {
-#ifdef PAF_ASP_FINAL
-        DEC_Handle dec = (DEC_Handle )decAlg[z];
-#endif /* PAF_ASP_FINAL */
-
-        Int zI = pP->inputsFromDecodes[z];
-        if ( inpIOtemp[zI].hIoPhy &&
-             readSharedMem((Int8 *)&(pAstCfg->xDec[z].decodeStatus.mode)))
-        {
-            TRACE_VERBOSE1("PAF_ASIT_decodeComplete: AS%d: finalizing decode", as+z);
-
-#ifdef PAF_ASP_FINAL
-            if (dec->fxns->final)
-                dec->fxns->final(dec, NULL, &pAstCfg->xDec[z].decodeControl,
-                                 &pAstCfg->xDec[z].decodeStatus);
-#endif /* PAF_ASP_FINAL */
+    zMD = pAstCfg->masterDec;
+    retVal = ASIP_NO_ERR;
 
-            // FL: send dec deactivate message to slave
-            asipSendMsgToDecoder(ASP_SLAVE_DEC_DEACTIVATE, z, ASP_MASTER_DEC_DEACTIVATE_DONE, NULL);
+    //pAstCfg->xInp[0].inpBufStatus.sampleRateStatus = PAF_SAMPLERATE_192000HZ;  //JXTODO: make this correct
+    errno = decDecodeInfo(pP, pQ, pC);
+    if (errno != ASIP_NO_ERR) {
+        //gAsipInfo1_PrimaryErrCnt++;
+        TRACE_TERSE1("INFO1: errno 0x%x after decodeInfo, primary timing", errno);
+        retVal =  ASIP_ERR_DECODE_INFO;
+    }
+    else {
+        // Don't start decode until major access unit is found.
+        Int8 sourceDecode, sampleRate;
+        sourceDecode = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceDecode),
+                                         GATEMP_INDEX_DEC);
+        sampleRate   = sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sampleRate),
+                                         GATEMP_INDEX_DEC);
+        if ( ( (sourceDecode == PAF_SOURCE_THD)     ||
+               (sourceDecode == PAF_SOURCE_DXP)     ||
+               (sourceDecode == PAF_SOURCE_DTSHD) ) &&
+             ( sampleRate == PAF_SAMPLERATE_UNKNOWN) ) {
+            /* do nothing and return - waiting for major access unit */
+            pC->inpDec.frame++;
+            retVal =  ASIP_NO_ERR;
         }
         else {
-            TRACE_VERBOSE1("PAF_ASIT_decodeComplete: AS%d: processing decode <ignored>", as+z);
+            errno = decDecodeData(pP, pQ, pC, sourceSelect);
+            if (errno != ASIP_NO_ERR) {
+                //gAsipDecodeErrCnt++;
+                TRACE_TERSE1("PAF_ASIT_decodeProcessing: state: DECODE.  decodeDecode err 0x%04x", errno);
+                retVal = ASIP_ERR_DECODE_DATA;
+            }
+            else {
+                errno = pP->fxns->decodeFinalTest(pP, pQ, pC, pC->inpDec.frame, pC->inpDec.block);
+                if (errno) {
+                    retVal = ASIP_ERR_DECODE_FINAL;
+                }
+                else {
+                    retVal = ASIP_NO_ERR;
+                }
+            }
         }
     }
-    return 0;
-} //asipDecodeComplete
 
+    return retVal;
+}  /* asipDecodeProcessing */
 #endif
+
 /* Nothing past this line */
index 19c7eba584272a9b79380322e911fb77ce85b8bb..4678ba0c6e61286bfb3abf6c1a3d277ecdb047f9 100644 (file)
@@ -324,7 +324,7 @@ extern UInt32 gAspProfileEnable;
 #define ASIP_FRAMELEN_SS_DTS        ( 512 )         
 
 // Compute decoder frame length based on selected source
-static Int getFrameLengthSourceSel(
+Int getFrameLengthSourceSel(
     const PAF_ASIT_Params *pP, 
     Int8 sourceSelect
 );
@@ -1195,7 +1195,18 @@ PAF_ASIT_initPhaseMalloc(
     TRACE_TERSE3("PAF_ASIT_initPhaseMalloc. (pAstCfg->xDec) %d bytes from space %d at 0x%x.",
         DECODEN * sizeof (*pAstCfg->xDec),
         HEAP_ID_INTERNAL1_SHM, (IArg)pAstCfg->xDec);
-                
+#if 0
+    if (!(pAsitCfg->pInpDec = Memory_calloc(decHeapHandle,
+        DECODEN * sizeof (*pAsitCfg->pInpDec), 4, &eb)))
+    {
+        TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
+        SW_BREAKPOINT;
+        return __LINE__;
+    }
+    TRACE_TERSE3("PAF_ASIT_initPhaseMalloc. (pAsitCfg->pInpDec) %d bytes from space %d at 0x%x.",
+                 DECODEN * sizeof (*pAsitCfg->pInpDec),
+                 HEAP_ID_INTERNAL1_SHM, (IArg)pAsitCfg->pInpDec);
+#endif
     TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: initialization phase - memory allocation complete.", as+zMS);
     return 0;
 } //PAF_ASIT_initPhaseMalloc
@@ -3792,7 +3803,7 @@ void as_traceChannels(PAF_AST_Config *pC, int z)
 #endif
 
 // Compute decoder frame length based on selected source
-static Int getFrameLengthSourceSel(
+Int getFrameLengthSourceSel(
     const PAF_ASIT_Params *pP, 
     Int8 sourceSelect
 )
index 4822d76aca800f7778954c9e4cc0a198cd53e039..ce4825d0302b438f66b211be49bddf9a767fcc7d 100644 (file)
@@ -183,8 +183,21 @@ typedef struct PAF_ASIT_Patchs {
 enum {
     ASIP_NO_ERR,
     ASIP_ERR_AUTO_DETECION,
+    ASIP_ERR_NO_MATCHING_SOURCE,
     ASIP_ERR_SWITCH_TO_PCM,
-    ASIP_ERR_MCASP_CFG
+    ASIP_ERR_D10_CFG,
+    ASIP_ERR_MCASP_CFG,
+    ASIP_ERR_INPUT_CFG,
+    ASIP_ERR_DECODE_INIT,
+    ASIP_ERR_DECODE_COMMAND,
+    ASIP_ERR_DECODE_INFO1,
+    ASIP_ERR_DECODE_INFO2,
+    ASIP_ERR_DECODE_DATA,
+    ASIP_ERR_DECODE_FINAL,
+    ASIP_ERR_DECODE_COMPLETE,
+    ASIP_ERR_DECODE_MSG,
+    ASIP_ERR_DECODE_QUIT,
+    ASIP_ERR_ABORT
 };
 
 // Input I/O structure
@@ -192,9 +205,13 @@ typedef struct PAF_AST_InpIO {
     ioPhyHandle_t        hIoPhy;     /* handle to I/O physical layer */
     ioBuffHandle_t       hIoBuff;    /* handle to I/O buffer management */
     ioDataHandle_t       hIoData;    /* handle to I/O data processing */
+    Ptr                  hMcaspChan;
     const void           *pRxParams; /* pointer to D10 Rx Params */
 
-    Int       syncState;
+    Int sourceSelect;
+    Int sourceProgram;
+
+    Int       preSyncState;
     Int       numPrimeXfers;
     Int       mcaspXferErr;
 /*
@@ -228,17 +245,16 @@ typedef struct asipDecProc_s {
     Int state;
     Int frame;
     Int block;
-    Int sourceSelect;
-    Int sourceProgram;
 } asipDecProc_t;
 
 // Audio Stream Input Task (ASIT) configuration
 typedef struct PAF_ASIT_Config {
-    Task_Handle taskHandle;     // ASIT handle
-    ACP_Handle acp;             // ASIT local ACP handle
-    PAF_ASPM_Config *pAspmCfg;  // ASIT/ASOT shared configuration
-    PAF_AST_Config *pAstCfg;    // ASIT/ASOT/ASDT shared configuration
-    PAF_AST_IoInp  *pIoInp;
+    Task_Handle taskHandle;      // ASIT handle
+    ACP_Handle acp;              // ASIT local ACP handle
+    PAF_ASPM_Config  *pAspmCfg;  // ASIT/ASOT shared configuration
+    PAF_AST_Config   *pAstCfg;   // ASIT/ASOT/ASDT shared configuration
+    PAF_AST_IoInp    *pIoInp;
+    asipDecProc_t    inpDec;
 } PAF_ASIT_Config;
 
 
@@ -545,6 +561,19 @@ static inline Int sharedMemReadInt(volatile XDAS_Int32 *address, Int gateIdx)
 #endif
 }
 
+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,
+        PAF_ASIT_Config *pAsitCfg,
+        Int sourceSelect);
 
 Int rxDecodePcm(PAF_AST_IoInp  *pInp);
 
index f46ffd1b074c6178ed6969d44d416acce986a41e..977fbf17c9913032d783933e091d9baf0aabc7f6 100644 (file)
@@ -42,7 +42,10 @@ All rights reserved.
 #include "procsdk_audio_typ.h"
 #include "audioStreamInpProc.h"
 #include "audioStreamProc_common.h"
+#include "aspMsg_common.h"
+#include "aspMsg_master.h"
 #include "asperr.h"
+#include "common.h"
 
 #include "audk2g.h"
 #include "audk2g_audio.h"
@@ -53,6 +56,7 @@ All rights reserved.
 #include "ioData.h"
 
 
+#define STRIDE_WORST_CASE 32  // 4-byte (32-bit) word, 2 slots, 4 serializers
 
 #define SYNC_PC_MASK         0x1F
 #define SYNC_SUBTYPE_MASK    0x700
@@ -63,6 +67,7 @@ All rights reserved.
 
 #define IEC_HEADER_LENGTH    4
 
+#define INPUT_SWITCH_HANGOVER 8
 
 //table needed until PAF_SOURCE is reordered to match IEC numbering
 const SmUns IECpafSource[23] =
@@ -119,7 +124,9 @@ Int asipUpdateInputStatus(const void *pRxParams, PAF_InpBufStatus *pStatus,
                           PAF_InpBufConfig *pInpBuf);
 
 //Int asipDecideSource(const PAF_ASIT_Params *pP, PAF_AST_Config *pAstCfg, asipDecProc_t *pDec);
-Int asipProcessing(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp);
+Int asipProcessing(const PAF_ASIT_Params *pP,
+                   const PAF_ASIT_Patchs *pQ,
+                   PAF_ASIT_Config *pAsitCfg);
 void asipErrorHandling(PAF_AST_Config *pAstCfg, int asipErrno);
 
 /*
@@ -127,13 +134,15 @@ void asipErrorHandling(PAF_AST_Config *pAstCfg, int asipErrno);
  */
 extern Semaphore_Handle asipSemRx;
 extern PAF_ASIT_Config gPAF_ASIT_config;
+extern const MdUns iecFrameLength[23];
+extern Ptr hMcaspRxChan;
+
 
 enum
 {
     ASIP_SOURCE_DETECTION,
-    ASIP_DECODE_BITSTREAM,
+    ASIP_DECODE,
     ASIP_SWITCH_TO_PCM,
-    ASIP_DECODE_PCM
 };
 
 enum
@@ -142,6 +151,8 @@ enum
     ASIP_INPUT_PROCESSING
 };
 
+
+
 #define ASIP_DEBUG
 
 #ifdef ASIP_DEBUG
@@ -188,7 +199,6 @@ Int inputReadyForProcessing;
     //
     pAsitCfg = &gPAF_ASIT_config;       // initialize pointer to task configuration
     pAstCfg  = pAsitCfg->pAstCfg;       // pointer to AST common (shared) configuration
-    pInp     = pAsitCfg->pIoInp;        // pointer to input I/O components
 
     /* Set Audio Stream Number (1, 2, etc.) */
     as = pAstCfg->as;
@@ -196,10 +206,8 @@ Int inputReadyForProcessing;
     //
     // Determine decoder and stream indices associated with the master input
     //
-    zMI = pP->zone.master;
-
-    pInp[zMI].numPrimeXfers = NUM_PRIME_XFERS;
-    //asipInitDebug(&pInp[zMI]);
+    zMI  = pP->zone.master;
+    pInp = &pAsitCfg->pIoInp[zMI];        // pointer to input I/O components
 
     for (z=STREAM1; z < STREAMN; z++)
     {
@@ -208,130 +216,12 @@ Int inputReadyForProcessing;
 
     TRACE_TERSE0("TaskAsip: Entering Main Loop.");
 
-#if 0
-    // Wait until input device is ready - change this to event based scheduling
-    asipErrno = 0;
-    while (!inputReadyForProcessing)
-    {
-        // Indicate decoder no decoding yet
-        pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_NONE);
-
-        Task_sleep(5);  // 5 system tick, or 5 msec. Should remove this later when implementing event based scheduling.
-
-        inputReadyForProcessing = asipPrepareProcessing(pP, pQ, pAsitCfg, &asipErrno);
-
-        if(asipErrno) {
-            asipErrorHandling(pAstCfg, asipErrno);
-        }
-    }
-
-    // .....................................................................
-    // At this point we have an enabled input and want to decode something.
-    // If no decoder selected then do nothing. Need to reset the sourceProgram, since
-    // when no decoder is selected there are no calls to IB
-    asipErrno = asipIoCompsInit(&pAstCfg->xInp[zMI], &pInp[zMI]);
-    if(asipErrno) {
-        printf("ASIP IO components init error!\n");
-        exit(0);
-    }
-
-    asipProcInit(&pInp[zMI]);
-
-    // start I/O physical layer by priming McASP LLD for input
-    asipIoPhyPrime(&pInp[zMI]);
-
-    //
-    // Main processing loop
-    //
-    asipErrno = 0;
-    for (;;)
-    {
-        // Pending on I/O PHY transfer
-        asipPhyTransferPend();
-
-        // Marks I/O PHY transfer and I/O BUFF write complete
-        asipPhyTransferComplete(&pInp[zMI]);
-
-        // Main function to process input data
-        asipErrno = asipProcessing(pAstCfg, &pInp[zMI]);
-
-        // Start next transfer
-        asipPhyTransferStart(&pInp[zMI]);
-
-        if(asipErrno) {
-            asipErrorHandling(pAstCfg, asipErrno);
-        }
-    }
-#endif
-
-#if 0
     //
     // Main processing loop
     //
     asipLoopCount1 = 0;
     asipLoopCount2 = 0;
     asipErrno = 0;
-    inputReadyForProcessing = FALSE;
-    for (;;)
-    {
-        asipLoopCount1++;
-
-        if(asipErrno) {
-            asipErrorHandling(pAstCfg, asipErrno);
-
-            inputReadyForProcessing = FALSE;
-        }
-
-        // Wait until input device is ready - change this to event based scheduling
-        if(!inputReadyForProcessing) {
-            // Indicate decoder no decoding yet
-            pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_NONE);
-
-            // 5 system tick, or 5 msec. Should remove this later when implementing
-            // event based scheduling.
-            Task_sleep(5);
-
-            inputReadyForProcessing = asipPrepareProcessing(pP, pQ, pAsitCfg, &asipErrno);
-
-            if (inputReadyForProcessing) {
-                // Input is ready for processing, so we initialize the I/O components
-                asipIoCompsInit(&pAstCfg->xInp[zMI], &pInp[zMI]);
-
-                // Initialize ASIP processing
-                asipProcInit(&pInp[zMI]);
-
-                // Start I/O physical layer by priming McASP LLD for input
-                asipIoPhyPrime(&pInp[zMI]);
-            }
-            else {
-                // Input is not ready, so go back to the beginning of the loop
-                continue;
-            }
-        }  /* if(!inputReadyForProcessing) */
-
-        // Pending on I/O PHY transfer
-        asipPhyTransferPend();
-
-        // Marks I/O PHY transfer and I/O BUFF write complete
-        asipPhyTransferComplete(&pInp[zMI]);
-
-        // Main function to process input data
-        asipErrno = asipProcessing(pAstCfg, &pInp[zMI]);
-
-        // Start next transfer
-        asipPhyTransferStart(&pInp[zMI]);
-
-        asipLoopCount2++;
-    }  // for (;;)
-#endif
-
-    //
-    // Main processing loop
-    //
-    asipLoopCount1 = 0;
-    asipLoopCount2 = 0;
-    asipErrno = 0;
-    inputReadyForProcessing = FALSE;
     pInp->asipState = ASIP_INPUT_PREPARATION;
 
     for (;;)
@@ -349,16 +239,15 @@ Int inputReadyForProcessing;
             Task_sleep(5);
 
             inputReadyForProcessing = asipPrepareProcessing(pP, pQ, pAsitCfg, &asipErrno);
-
             if (inputReadyForProcessing) {
                 // Input is ready for processing, so we initialize the I/O components
-                asipIoCompsInit(&pAstCfg->xInp[zMI], &pInp[zMI]);
+                asipIoCompsInit(&pAstCfg->xInp[zMI], pInp);
 
                 // Initialize ASIP processing
-                asipProcInit(&pInp[zMI]);
+                asipProcInit(pInp);
 
                 // Start I/O physical layer by priming McASP LLD for input
-                asipIoPhyPrime(&pInp[zMI]);
+                asipIoPhyPrime(pInp);
 
                 pInp->asipState = ASIP_INPUT_PROCESSING;
             }
@@ -369,13 +258,13 @@ Int inputReadyForProcessing;
             asipPhyTransferPend();
 
             // Marks I/O PHY transfer and I/O BUFF write complete
-            asipPhyTransferComplete(&pInp[zMI]);
+            asipPhyTransferComplete(pInp);
 
             // Main function to process input data
-            asipErrno = asipProcessing(pAstCfg, &pInp[zMI]);
+            asipErrno = asipProcessing(pP, pQ, pAsitCfg);
 
             // Start next transfer
-            asipPhyTransferStart(&pInp[zMI]);
+            asipPhyTransferStart(pInp);
 
             if(asipErrno) {
                 asipErrorHandling(pAstCfg, asipErrno);
@@ -392,10 +281,6 @@ Int inputReadyForProcessing;
 
 }  /* taskAsipFxn */
 
-extern const MdUns iecFrameLength[23];
-extern Ptr hMcaspRxChan;
-#define STRIDE_WORST_CASE 32  // 4-byte (32-bit) word, 2 slots, 4 serializers
-
 
 /*===========================================================================
  * ASIP processing preparation
@@ -512,7 +397,7 @@ int asipIoCompsInit(PAF_AST_InpBuf * pInpBuf, PAF_AST_IoInp * pInpIo)
 
     ioPhyParams.ioBuffHandle    = pInpIo->hIoBuff;
     ioPhyParams.xferFrameSize   = INPUT_FRAME_SIZE_DEF;
-    ioPhyParams.mcaspChanHandle = hMcaspRxChan;
+    ioPhyParams.mcaspChanHandle = pInpIo->hMcaspChan;
     ioPhyParams.ioBuffOp        = IOPHY_IOBUFFOP_WRITE;
     if(ioPhyInit(pInpIo->hIoPhy, &ioPhyParams) != IOPHY_NOERR) {
         return (-1);   // to remove magic number
@@ -531,9 +416,10 @@ int asipIoCompsInit(PAF_AST_InpBuf * pInpBuf, PAF_AST_IoInp * pInpIo)
         return (-1);   // to remove magic number
     }
 
+    pInpIo->numPrimeXfers  = NUM_PRIME_XFERS;
     pInpIo->phyXferSize    = ioPhyParams.xferFrameSize;
     pInpIo->switchHangOver = 0;
-    pInpIo->syncState      = IODATA_SYNC_NONE;
+    pInpIo->preSyncState   = IODATA_SYNC_NONE;
 
     return 0;
 } /* asipIoCompsInit */
@@ -599,11 +485,11 @@ void asipMcaspCallback(void* arg, MCASP_Packet *mcasp_packet)
 /*======================================================================================
  *  This function checks if McASP Rx for input overruns
  *====================================================================================*/
-int asipCheckMcaspRxOverrun(void)
+int asipCheckMcaspRxOverrun(Ptr mcaspChanHandle)
 {
     Mcasp_errCbStatus mcaspErrStat;
 
-    mcaspControlChan(hMcaspRxChan, Mcasp_IOCTL_CHAN_QUERY_ERROR_STATS, &mcaspErrStat);
+    mcaspControlChan(mcaspChanHandle, Mcasp_IOCTL_CHAN_QUERY_ERROR_STATS, &mcaspErrStat);
 
     return (mcaspErrStat.isRcvOvrRunOrTxUndRunErr);
 }
@@ -622,7 +508,7 @@ void asipMcaspRxRestart(void)
  *====================================================================================*/
 void asipPhyTransferStart(PAF_AST_IoInp *pInpIo)
 {
-    if(asipCheckMcaspRxOverrun()) {
+    if(asipCheckMcaspRxOverrun(pInpIo->hMcaspChan)) {
 #ifdef ASIP_DEBUG
         pInpIo->numInputOverrun++;
 #endif
@@ -671,19 +557,23 @@ Int asipSelectDevices(const PAF_ASIT_Patchs *pQ, PAF_AST_IoInp *pInp)
 #endif
         if(status != Audk2g_EOK) {
             Log_info0("audk2g_AudioSelectClkSrc Failed!\n");
+            return ASIP_ERR_D10_CFG;
         }
         audk2g_delay(50000); // Without delay between these 2 calls system aborts.
 
         /* Initialize McASP module */
         status = mcaspAudioConfig(); //defined in newio\fw\mcasp_cfg.c
         if(status != Audk2g_EOK) {
-            TRACE_TERSE0("McASP Configuration Failed!\n");
+            Log_info0("McASP Configuration Failed!\n");
+            return ASIP_ERR_MCASP_CFG;
         }
 
+        pInp->hMcaspChan = hMcaspRxChan;
         d10Initialized = 1;
     }
 
     /////////////// TODO: HW interface selection and initialization //////////////
+    ////// to add what PAF_ASIT_selectDevices() does /////////
 #ifdef IO_HW_INTERFACE
     pInp->pRxParams = pQ->devinp->x[IO_HW_INTERFACE];
 #else
@@ -717,8 +607,9 @@ Int asipUpdateInputStatus(const void *pRxParams, PAF_InpBufStatus *pStatus,
     asipErrno = D10_RxControl(pRxParams,
                           (Uns)PAF_SIO_CONTROL_GET_INPUT_STATUS,
                           (Arg) &inputStatus);
-    if (asipErrno)
+    if (asipErrno) {
         return asipErrno;
+    }
     pStatus->sampleRateData = inputStatus.sampleRateData;
     pStatus->sampleRateMeasured = inputStatus.sampleRateMeasured;
     pStatus->nonaudio = inputStatus.nonaudio;
@@ -775,58 +666,312 @@ Int asipUpdateInputStatus(const void *pRxParams, PAF_InpBufStatus *pStatus,
     return 0;
 }
 
+/*==============================================================================
+ * After SYNC is found, i.e. either bitstream preamble is detected or it times
+ * out to PCM, update input buffer config and I/o components accordingly.
+ ==============================================================================*/
+Int asipUpdateIoComps(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp,
+                      ioDataAutoDetStat_t *autoDetStatus)
+{
+    Int sourceConfig;
+    Int zMD, deliverZeros;
+    int frameLength;
+    PAF_InpBufConfig *pBufConfig;
+    Audk2g_STATUS mcaspStatus;
+    ioPhyCtl_t  ioPhyCtl;
+
+    zMD = pAstCfg->masterDec;
+    pBufConfig = &pAstCfg->xInp[zMD].inpBufConfig;
+
+    // Get the configured source
+    sourceConfig = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
+                                          GATEMP_INDEX_DEC);
+
+    if(autoDetStatus->syncState == IODATA_SYNC_PCM) {
+        // Bitstream preamble is not found and it times out -> assume this is PCM
+        deliverZeros = autoDetStatus->deliverZeros;
+        if (sourceConfig == PAF_SOURCE_PCM || sourceConfig == PAF_SOURCE_DSD1 ||
+            sourceConfig == PAF_SOURCE_DSD2 || sourceConfig == PAF_SOURCE_DSD3) {
+            // set to one -- ensures that PCM decode calls made before data is
+            // available will result in zero output.
+            // (mostly needed for PA15 since, currently, all other frameworks
+            // require a frame of data before the first decode call.
+            deliverZeros = TRUE;  // override deliverZeros returned by ioDataControl
+        }
+
+        // update input buffer config structure
+        pBufConfig->deliverZeros  = deliverZeros;
+        pBufConfig->sizeofElement = WORD_SIZE_PCM;
+        pBufConfig->frameLength   = pBufConfig->lengthofData = INPUT_FRAME_LENGTH;
+
+        // reconfigure McASP LLD to transfer 32-bit unpacked data
+        //mcaspStatus = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_32);
+        //if(mcaspStatus != Audk2g_EOK) {
+        //    return ASIP_ERR_MCASP_CFG;
+        //}
+
+        // Change I/O PHY transfer size to PCM frame size
+        pInp->phyXferSize = (INPUT_FRAME_LENGTH)*(WORD_SIZE_PCM);
+
+        // Adjust I/O BUFF delay and read pointer - to make sure read pointers always point to
+        // PCM data from 1st I2S (out of 4 for HDMI 4xI2S)
+        // Adjust delay and don't mark input buffer as read complete
+        ioBuffAdjustDelay(pInp->hIoBuff, pInp->phyXferSize);
+
+        // Stop swapping data
+        pInp->swapData = FALSE;
+
+    } /* IODATA_SYNC_PCM */
+
+    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;
+
+        // update input buffer config structure
+        pBufConfig->sizeofElement = WORD_SIZE_BITSTREAM;
+        pBufConfig->frameLength   = frameLength;
+        pBufConfig->lengthofData  = frameLength - IEC_HEADER_LENGTH;
+
+/*
+        if (pc == 0x11 && DTSHDSubType == 3 && (PAF_ASP_sampleRateHzTable[pBufConfig->pBufStatus->sampleRateStatus][PAF_SAMPLERATEHZ_STD] <=48000.0))
+            pDevExt->sourceProgram = PAF_SOURCE_DXP;    // LBR is 23
+*/
+
+/*        if (pc == 1)
+            pDevExt->elementSize = 4288;
+        else if (pc == 0x11) {
+            pDevExt->frameLength = (pDevExt->pIECFrameLength[pc] << DTSHDSubType);
+            pDevExt->lengthofData = pDevExt->frameLength;
+        }
+*/
+
+        // Change I/O PHY transfer size to bitstream frame size
+        pInp->phyXferSize = frameLength*WORD_SIZE_BITSTREAM;
+    }
+
+    pBufConfig->stride = INPUT_STRIDE;   // common for PCM and bitstream
+
+    //JXTODO: decide what to do with hRxSio
+    pAstCfg->xInp[zMD].hRxSio = pInp->hIoData; //temporary - does ARM use hRxSio or just check if it is not NULL?
+    pAstCfg->xInp[zMD].pInpBuf = &(pAstCfg->xInp[zMD].inpBufConfig);
+
+    // Update I/O PHY transfer size accordingly
+    ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
+    ioPhyCtl.params.xferFrameSize = pInp->phyXferSize;
+    ioPhyControl(pInp->hIoPhy, &ioPhyCtl);
+
+    return ASIP_NO_ERR;
+} /* asipUpdateIoComps */
+
+void asipUpdateInpBufConfig(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp)
+{
+    PAF_InpBufConfig *pBufConfig;
+    ioDataCtl_t ioDataCtl;
+
+    /* Get information for reading input data */
+    ioDataCtl.code = IODATA_CTL_GET_INPBUFFINFO;
+    ioDataControl(pInp->hIoData, &ioDataCtl);
+
+    if(ioDataCtl.param.dataReadInfo.frameSize != pInp->phyXferSize) {
+        // Fatal error!
+        TRACE_VERBOSE0("TaskAsip: error in updating I/O");
+        SW_BREAKPOINT;
+    }
+
+    pBufConfig = &(pAstCfg->xInp[pAstCfg->masterDec].inpBufConfig);
+
+    //JXTODO: do we need to gate here? - No, since ARM won't read until it receives message
+    //key = GateMP_enter(gateHandle);
+
+    pBufConfig->base.pVoid   = ioDataCtl.param.dataReadInfo.buffBase;
+    pBufConfig->sizeofBuffer = ioDataCtl.param.dataReadInfo.buffSize;
+    pBufConfig->pntr.pSmInt  = ioDataCtl.param.dataReadInfo.startAddress;
+
+    // Leave the gate
+    //GateMP_leave(gateHandle, key);
+}
+
+/*==============================================================================
+ * Decide source after SYNC is found, i.e. either bitstream preamble is detected
+ * or it times out to PCM.
+ ==============================================================================*/
+Int asipDecideSource(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp,
+                     ioDataAutoDetStat_t *autoDetStatus)
+{
+    Int sourceConfig, sourceSelect, sourceProgram;
+    Int zMD;
+    char asipMsgBuf[ASP_MSG_BUF_LEN];
+
+    // Get the configured source
+    zMD = pAstCfg->masterDec;
+    sourceConfig = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect), GATEMP_INDEX_DEC);
+
+    if(autoDetStatus->syncState == IODATA_SYNC_PCM) {
+        if (sourceConfig == PAF_SOURCE_DSD1 || sourceConfig == PAF_SOURCE_DSD2 ||
+            sourceConfig == PAF_SOURCE_DSD3) {
+            sourceProgram = sourceConfig;
+        }
+        else {
+            sourceProgram = PAF_SOURCE_PCM;
+        }
+    }
+
+    if(autoDetStatus->syncState == IODATA_SYNC_BITSTREAM) {
+        uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
+        sourceProgram = IECpafSource[pc];
+    }
+
+    // write the decided source program to memory
+    sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram), sourceProgram, GATEMP_INDEX_DEC);
+
+    // now that we have some input classification, and possibly an outstanding
+    // input frame, we determine whether or not to call decodeProcessing and with
+    // what decAlg.
+    sourceSelect = PAF_SOURCE_NONE;
+
+    switch (sourceConfig)
+    {
+        // If autodetecting, decoding everything, and input is something
+        // (i.e. bitstream or PCM) then decode.
+        case PAF_SOURCE_AUTO:
+            if (sourceProgram >= PAF_SOURCE_PCM)  {
+                sourceSelect = sourceProgram; // use whatever from autodet
+            }
+            break;
+
+        // If autodetecting, decoding only PCM, and input is PCM then decode.
+        case PAF_SOURCE_PCMAUTO:
+            if (sourceProgram == PAF_SOURCE_PCM) {
+                sourceSelect = sourceProgram;  // only expect autodet to give PAF_SOURCE_PCM, otherwise set to NONE
+            }
+            break;
+
+        // If autodetecting, decoding only bitstreams, and input is a bitstream then decode.
+        case PAF_SOURCE_BITSTREAM:
+            if (sourceProgram >= PAF_SOURCE_AC3) {
+                sourceSelect = sourceProgram;
+            }
+            break;
+
+        // If autodetecting, decoding only DTS, and input is DTS then decode.
+        case PAF_SOURCE_DTSALL:
+            switch (sourceProgram)
+            {
+                case PAF_SOURCE_DTS11:
+                case PAF_SOURCE_DTS12:
+                case PAF_SOURCE_DTS13:
+                case PAF_SOURCE_DTS14:
+                case PAF_SOURCE_DTS16:
+                case PAF_SOURCE_DTSHD:
+                    sourceSelect = sourceProgram;
+                    break;
+            }
+            break;
+
+        // All others, e.g., force modes, fall through to here.
+        // If user made specific selection then program must match select.
+        // (NB: this compare relies on ordering of PAF_SOURCE)
+        default:
+            sourceSelect = sourceConfig;
+            if ((sourceSelect >= PAF_SOURCE_PCM) && (sourceSelect <= PAF_SOURCE_N)) {
+                if (sourceProgram != sourceSelect) {
+                    sourceSelect = PAF_SOURCE_NONE;
+                }
+            }
+            break;
+    }
+
+    // if we didn't find any matches then skip
+    if (sourceSelect == PAF_SOURCE_NONE) {
+        TRACE_VERBOSE0("TaskAsip: no matching source type, continue");
+        return ASIP_ERR_NO_MATCHING_SOURCE;
+    }
+
+    // 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) {
+        TRACE_VERBOSE0("TaskAsip: error in sending SOURCE_SELECT message");
+        SW_BREAKPOINT;
+    }
+
+    pInp->sourceSelect  = sourceSelect;
+    pInp->sourceProgram = sourceProgram;
+
+    return ASIP_NO_ERR;
+} /* asipDecideSource */
+
+
+Int asipBypassIoData(PAF_AST_IoInp *pInp)
+{
+    // When switching to PCM, McASP RFMT register will be modified,
+    // which will cause all 0's in one McASP LLD transfer. This will
+    // be detected as loss of SYNC by auto detection. To prevent that,
+    // skip I/O DATA process for hangover period so that this all 0's
+    // frame will not be seen by auto-detection. Also, playing out PCM
+    // needs to be skipped as well, to prevent from playing out garbage
+    // (16-bit packed data).
+    void *buff1, *buff2;
+    size_t size1, size2;
+
+    // Get read pointers (or sub-buffers) of the input buffer
+    if (ioBuffGetReadPtrs(pInp->hIoBuff, pInp->phyXferSize,
+                          &buff1, &size1, &buff2, &size2)
+        == IOBUFF_ERR_UNDERFLOW) {
+        //printf("Input buffer underflows during switch hangover!\n");
+        return ASIP_ERR_SWITCH_TO_PCM;
+    }
+
+    ioBuffReadComplete(pInp->hIoBuff, buff1, size1);
+
+    if(buff2 != NULL) {
+        ioBuffReadComplete(pInp->hIoBuff, buff2, size2);
+    }
+
+    return ASIP_NO_ERR;
+}
 
 /*=============================================================================
  *  Main function of ASIP processing
  *============================================================================*/
-#define INPUT_SWITCH_HANGOVER 8
+Int asipProcessing(const PAF_ASIT_Params *pP,
+                   const PAF_ASIT_Patchs *pQ,
+                   PAF_ASIT_Config *pAsitCfg)
 
-Int asipProcessing(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp)
 {
-    int autoDetstatus, syncState;
+    PAF_AST_Config  *pAstCfg;
+    int ioDataStatus, asipStatus, zMI;
+    ioDataAutoDetStat_t autoDetStatus;
     Audk2g_STATUS mcaspStatus;
-
     ioDataCtl_t ioDataCtl;
     ioPhyCtl_t  ioPhyCtl;
+    PAF_AST_IoInp *pInp;            /* Input I/O components */
 
-    if(pInp->asipProcState == ASIP_SWITCH_TO_PCM) {
-        // When switching to PCM, McASP RFMT register will be modified,
-        // which will cause all 0's in one McASP LLD transfer. This will
-        // be detected as loss of SYNC by auto detection. To prevent that,
-        // skip I/O DATA process for hangover period so that this all 0's
-        // frame will not be seen by auto-detection. Also, playing out PCM
-        // needs to be skipped as well, to prevent from playing out garbage
-        // (16-bit packed data).
-        void *buff1, *buff2;
-        size_t size1, size2;
-
-        // Get read pointers (or sub-buffers) of the input buffer
-        if (ioBuffGetReadPtrs(pInp->hIoBuff, pInp->phyXferSize,
-                              &buff1, &size1, &buff2, &size2)
-            == IOBUFF_ERR_UNDERFLOW) {
-            //printf("Input buffer underflows during switch hangover!\n");
-            return ASIP_ERR_SWITCH_TO_PCM;
-        }
-
-        ioBuffReadComplete(pInp->hIoBuff, buff1, size1);
+    pAstCfg = pAsitCfg->pAstCfg;
+    zMI  = pAstCfg->masterDec;
+    pInp = &pAsitCfg->pIoInp[zMI]; // pointer to input I/O components
 
-        if(buff2 != NULL) {
-            ioBuffReadComplete(pInp->hIoBuff, buff2, size2);
+    if(pInp->asipProcState == ASIP_SWITCH_TO_PCM) {
+        // Bypass I/O data processing due to McASP LLD work around
+        // (refer to comments inside the function)
+        asipStatus = asipBypassIoData(pInp);
+        if(asipStatus != ASIP_NO_ERR) {
+            return asipStatus;
         }
     }
     else {
         // Perform auto-detection when not switching
-        autoDetstatus = ioDataProcess(pInp->hIoData);
-        if(autoDetstatus == IODATA_ERR_IOBUF_UNDERFLOW) {
+        ioDataStatus = ioDataProcess(pInp->hIoData);
+        if(ioDataStatus == IODATA_ERR_IOBUF_UNDERFLOW) {
             // Input buffer underflows - no action is needed
-            //printf("Input buffer underflows.\n");
             pInp->numUnderflow += 1;
 
             // Return since there is no enough data to process
             return ASIP_NO_ERR;
         }
-        else if(autoDetstatus != IODATA_NO_ERR) {
-            // Something run happens: print error log and return
+        else if(ioDataStatus != IODATA_NO_ERR) {
+            // Something is wrong: print error log and return
             //printf("IODATA processing error!\n");
             return ASIP_ERR_AUTO_DETECION;
         }
@@ -835,7 +980,7 @@ Int asipProcessing(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp)
             ioDataCtl.code = IODATA_CTL_GET_AUTODET_STATUS;
             ioDataControl(pInp->hIoData, &ioDataCtl);
 
-            syncState = ioDataCtl.param.autoDetStats.syncState;
+            autoDetStatus = ioDataCtl.param.autoDetStats;
         }
     }
 
@@ -845,55 +990,50 @@ Int asipProcessing(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp)
         // zero out the output buffer
         rxDecodePlayZero(pInp);
 
-        ioDataReadComplete(pInp->hIoData);
-
-        if(syncState == IODATA_SYNC_BITSTREAM || syncState == IODATA_SYNC_PCM) {
-            // Decide input source after SYNC is found, i.e. either
-            // bitstream preamble is detected or it times out to PCM.
-            //sourceSelect = asipDecideSource(pP, pAstCfg, &decProc);
-
-        }
-
-        if(syncState == IODATA_SYNC_BITSTREAM) {
-            // Change I/O PHY transfer size to be the same as the bitstream frame size
-            int frameSize;
-            uint_least16_t pc = ioDataCtl.param.autoDetStats.bitStreamInfo & SYNC_PC_MASK; //0x001F
-            frameSize = iecFrameLength[pc] * WORD_SIZE_BITSTREAM;
+        if(   autoDetStatus.syncState == IODATA_SYNC_BITSTREAM
+           || autoDetStatus.syncState == IODATA_SYNC_PCM) {
+            // Update I/O components and input buffer config
+            asipUpdateIoComps(pAstCfg, pInp, &autoDetStatus);
 
-            ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
-            ioPhyCtl.params.xferFrameSize = frameSize;
-            ioPhyControl(pInp->hIoPhy, &ioPhyCtl);
-            pInp->phyXferSize = ioPhyCtl.params.xferFrameSize;
-
-            pInp->asipProcState = ASIP_DECODE_BITSTREAM;
-            pInp->numFrameReceived = 1;
-        }
-        else if(syncState == IODATA_SYNC_PCM) {
-            // reconfigure McASP LLD to transfer 32-bit unpacked data
-            mcaspStatus = mcaspRecfgWordWidth(hMcaspRxChan, Mcasp_WordLength_32);
-            if(mcaspStatus != Audk2g_EOK) {
-                return ASIP_ERR_MCASP_CFG;
+            // Decide input source and inform decoder
+            asipStatus = asipDecideSource(pAstCfg, pInp, &autoDetStatus);
+            if(asipStatus != ASIP_NO_ERR) {
+                return asipStatus;
+            }
+            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
+                pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_UNKNOWN);
+
+                if(autoDetStatus.syncState == IODATA_SYNC_BITSTREAM) {
+                    // Input is bit stream: go to decoding
+                    pInp->asipProcState = ASIP_DECODE;
+                    pInp->numFrameReceived = 1;
+                }
+                else  {
+                    // Input is PCM: stop swapping data
+                    pInp->swapData = FALSE;
+
+                    // Reconfigure McASP LLD to transfer 32-bit unpacked data
+                    mcaspStatus = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_32);
+                    if(mcaspStatus != Audk2g_EOK) {
+                        return ASIP_ERR_MCASP_CFG;
+                    }
+
+                    // 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;
+                }
             }
 
-            // Change I/O PHY transfer size to PCM frame size
-            ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
-            ioPhyCtl.params.xferFrameSize = INPUT_FRAME_SIZE_PCM;
-            ioPhyControl(pInp->hIoPhy, &ioPhyCtl);
-            pInp->phyXferSize = ioPhyCtl.params.xferFrameSize;
-
-            // Adjust I/O BUFF delay and read pointer - to make sure read pointers always point to
-            // PCM data from 1st I2S (out of 4 for HDMI 4xI2S)
-            // Adjust delay and don't mark input buffer as read complete
-            ioBuffAdjustDelay(pInp->hIoBuff, pInp->phyXferSize);
-
-            // Stop swapping data
-            pInp->swapData = FALSE;
-
-            // Go to transition state to switch to PCM
-            pInp->asipProcState = ASIP_SWITCH_TO_PCM;
-            pInp->switchHangOver = INPUT_SWITCH_HANGOVER;
-
-            pInp->numPcmFrameReceived = 0;
+            pInp->preSyncState = autoDetStatus.syncState;
         }
         else {
             // Source is still unknown - take no action
@@ -901,71 +1041,70 @@ Int asipProcessing(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp)
         }
         break;
 
-    case ASIP_DECODE_BITSTREAM:
-        if (syncState == IODATA_SYNC_NONE) {
-            // Change I/O PHY transfer size to default
-            ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
-            ioPhyCtl.params.xferFrameSize = INPUT_FRAME_SIZE_DEF;
-            ioPhyControl(pInp->hIoPhy, &ioPhyCtl);
-            pInp->phyXferSize  = ioPhyCtl.params.xferFrameSize;
-
-            pInp->numFrameReceived = 0;
-            pInp->asipProcState  = ASIP_SOURCE_DETECTION;
-        }
-        else {
-            pInp->numFrameReceived += 1;
-
-            rxDecodeBitStream(pInp);
-
-            ioDataReadComplete(pInp->hIoData);
-        }
-        break;
-
     case ASIP_SWITCH_TO_PCM:
         // zero out the output buffer
         rxDecodePlayZero(pInp);
 
         pInp->switchHangOver--;
         if(pInp->switchHangOver == 0) {
-            pInp->asipProcState = ASIP_DECODE_PCM;
-            // send message to decoder
+            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;
 
-    case ASIP_DECODE_PCM:
-        if (syncState == IODATA_SYNC_NONE) {
-            // reconfigure McASP LLD to receive 16-bit packed bits
-            mcaspStatus = mcaspRecfgWordWidth(hMcaspRxChan, Mcasp_WordLength_16);
-            if(mcaspStatus != Audk2g_EOK) {
-                return ASIP_ERR_MCASP_CFG;
-            }
-
-            // Change I/O PHY transfer size to default
+    case ASIP_DECODE:
+        if(autoDetStatus.syncState == IODATA_SYNC_NONE) {
+            // SYNC lost: change I/O PHY transfer size to default for auto-detection
             ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
             ioPhyCtl.params.xferFrameSize = INPUT_FRAME_SIZE_DEF;
             ioPhyControl(pInp->hIoPhy, &ioPhyCtl);
             pInp->phyXferSize  = ioPhyCtl.params.xferFrameSize;
 
-            // Start swapping data
-            pInp->swapData = TRUE;
-            pInp->numPcmFrameReceived = 0;
+            if(pInp->preSyncState == IODATA_SYNC_PCM) {
+                // If it was PCM, reconfigure McASP LLD to receive 16-bit packed bits
+                mcaspStatus = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_16);
+                if(mcaspStatus != Audk2g_EOK) {
+                    return ASIP_ERR_MCASP_CFG;
+                }
+
+                // Start swapping data
+                pInp->swapData = TRUE;
+            }
+
+            // Inform decoder to complete decoding previous frame
+            pInp->sourceSelect = PAF_SOURCE_UNKNOWN;
 
-            pInp->asipProcState = ASIP_SOURCE_DETECTION;
+            pInp->numFrameReceived = 0;
+            pInp->asipProcState  = ASIP_SOURCE_DETECTION;
         }
         else {
-            pInp->numPcmFrameReceived += 1;
+            pInp->numFrameReceived += 1;
 
-            rxDecodePcm(pInp);
+            // Communicate input stream information to decoder through input buffer configuration
+            asipUpdateInpBufConfig(pAstCfg, pInp);
+        }
 
-            ioDataReadComplete(pInp->hIoData);
+        asipStatus = asipDecodeProcessing(pP, pQ, pAsitCfg, pInp->sourceSelect);
+        if(asipStatus != ASIP_NO_ERR) {
+            return asipStatus;
         }
 
+        //rxDecodePcm(pInp);     // for PCM loopback testing
         break;
 
     default:
         break;
     }
 
+    if(pInp->asipProcState != ASIP_SWITCH_TO_PCM) {
+        ioDataReadComplete(pInp->hIoData);
+    }
+
     return 0;
 } /* asipProcessing */
 
index 960c4b6a1816b8ec6db76b18102592baa691d1df..3482646b04fe2922cdce7969a839e2aeca3c98ae 100644 (file)
 // Define McASP transfer element size: number of bytes in one word
 #define WORD_SIZE_BITSTREAM     2
 #define WORD_SIZE_PCM           4
+#define NUM_CYCLE_PER_FRAME     128
 
 // Input frame length: number of words to be transfered in 1 transfer of McASP LLD Rx
 // These numbers are according to existing SIO/DEV based I/O.
+#define INPUT_STRIDE            (2*NUM_RX_SERIALIZER)
 #ifdef INPUT_HDMI_4xI2S
-#define INPUT_FRAME_LENGTH      (256*NUM_RX_SERIALIZER)    // 128 stereo/lane
+#define INPUT_FRAME_LENGTH      (NUM_CYCLE_PER_FRAME*INPUT_STRIDE)      // 128 stereo/lane
 #else
-//#define INPUT_FRAME_LENGTH      (128*NUM_RX_SERIALIZER)    // 64 stereo/lane
-#define INPUT_FRAME_LENGTH      (256*NUM_RX_SERIALIZER)    // 128 stereo/lane
+//#define INPUT_FRAME_LENGTH      (64*INPUT_STRIDE)    // 64 stereo/lane
+#define INPUT_FRAME_LENGTH      (NUM_CYCLE_PER_FRAME*INPUT_STRIDE)      // 128 stereo/lane
 #endif
 
 // Input frame size: number of bytes to be transfered in 1 transfer of McASP LLD Rx
@@ -82,7 +84,8 @@
 #define INPUT_FRAME_SIZE_PCM    (INPUT_FRAME_LENGTH * WORD_SIZE_PCM)
 
 // Output frame length: number of words to be transfered in 1 transfer of McASP LLD Tx
-#define OUTPUT_FRAME_LENGTH     (256*NUM_TX_SERIALIZER)    // 128 stereo/lane
+#define OUTPUT_STRIDE           (2*NUM_TX_SERIALIZER)
+#define OUTPUT_FRAME_LENGTH     (NUM_CYCLE_PER_FRAME*OUTPUT_STRIDE)    // 128 stereo/lane
 
 // Output frame size: number of bytes to be transfered in 1 transfer of McASP LLD Tx
 #define OUTPUT_FRAME_SIZE       (OUTPUT_FRAME_LENGTH * WORD_SIZE_PCM)
index dd630c722b068125251b981ac8ff611e8e09726f..cdc44d27a1a4f5c057d701dbe7b2b2f98b386838 100644 (file)
@@ -129,7 +129,7 @@ typedef struct ioDataInst_s {
   uint_least16_t   *IECframeLengths;
   uint_least16_t   frameLengthPCM;
   uint_least16_t   frameLengthDef;
-  uint_least32_t   frameLength;        // frame length: number of elements in a frame
+  //uint_least32_t   frameLength;        // frame length: number of elements in a frame
   uint_least32_t   numElementsRead;    // number of elements to read from input buffer
   uint_least32_t   distToFrameEnd;
   int8_t           elementSize;
@@ -308,12 +308,12 @@ int ioDataControl(ioDataHandle_t ioDataHandle, ioDataCtl_t *ioDataCtl)
   switch (ioDataCtl->code)
   {
 
-    case IODATA_CTL_SET_ELEMENT_SIZE:
-       pIoDataInst->elementSize = ioDataCtl->param.frameInfo.elementSize;
-      break;
+//    case IODATA_CTL_SET_ELEMENT_SIZE:
+//     pIoDataInst->elementSize = ioDataCtl->param.frameInfo.elementSize;
+//      break;
 
-    case IODATA_CTL_SET_FRAME_LENGTH:
-       pIoDataInst->frameLength = ioDataCtl->param.frameInfo.frameLength;
+    case IODATA_CTL_SET_PCM_FRAME_LENGTH:
+       pIoDataInst->frameLengthPCM = ioDataCtl->param.frameLengthPcm;
       break;
 
     case IODATA_CTL_GET_INPBUFFINFO:
index 388a164223264f3a033b4365ae982c79c828d857..bed31c5adbc2ea892a4860b1c70c054c010e7d81 100644 (file)
@@ -39,8 +39,8 @@ typedef struct ioDataReadInfo_s {
 
 // Control commands for ioDataControl
 enum {
-       IODATA_CTL_SET_ELEMENT_SIZE,
-       IODATA_CTL_SET_FRAME_LENGTH,
+       //IODATA_CTL_SET_ELEMENT_SIZE,
+       IODATA_CTL_SET_PCM_FRAME_LENGTH,
        IODATA_CTL_GET_INPBUFFINFO,
     IODATA_CTL_GET_AUTODET_STATUS,
 };
@@ -75,9 +75,9 @@ typedef struct ioDataAutoDetStat_s {
 typedef struct ioDataCtl_s {
   uint_fast16_t code;
   union {
-       ioDataReadInfo_t    dataReadInfo;  // IODATA_CTL_GET_INPBUFFINFO
-       ioDataFrameInfo_t   frameInfo;     // IODATA_CTL_SET_ELEMENT_SIZE or IODATA_CTL_SET_FRAME_LENGTH
-       ioDataAutoDetStat_t autoDetStats;  // IODATA_CTL_GET_AUTODET_STATUS
+       ioDataReadInfo_t    dataReadInfo;   // IODATA_CTL_GET_INPBUFFINFO
+       uint_fast32_t       frameLengthPcm; // IODATA_CTL_SET_PCM_FRAME_LENGTH
+       ioDataAutoDetStat_t autoDetStats;   // IODATA_CTL_GET_AUTODET_STATUS
   } param;      
 } ioDataCtl_t;