PASDK 571: DTSX input and output working preliminarily:
authorJianzhong Xu <a0869574@ti.com>
Fri, 25 May 2018 20:36:13 +0000 (16:36 -0400)
committerJianzhong Xu <a0869574@ti.com>
Fri, 25 May 2018 20:47:39 +0000 (16:47 -0400)
1. I/O DATA added DTSHD specific handling
2. ASIT decoder init split into two parts in order not to wait for slave decoder reset too long
3. ASIT decoder FSM change corresponding to #2.
4. ASOT added reset of audio frame data pointers.

pasdk/test_dsp/framework/audioStreamInpDec.c
pasdk/test_dsp/framework/audioStreamInpProc.h
pasdk/test_dsp/framework/audioStreamInpProcNewIO.c
pasdk/test_dsp/framework/audioStreamOutProc.c
pasdk/test_dsp/io/ioData.c
pasdk/test_dsp/io/ioData.h

index 43dd8e725f68ce0730b129e455786de0e34ea49f..3e9d1f06fa187c346e268d5c17952955745e02a2 100644 (file)
@@ -57,6 +57,7 @@ extern void asitPostInfoEvent();    // TODO: remove
 extern void asitPostDecEvent();     // TODO: remove
 
 enum {
+    DEC_STATE_INIT_ACK,
     DEC_STATE_INFO_SND,
     DEC_STATE_INFO_ACK_DECODE_SND,
     DEC_STATE_DECODE_ACK,
@@ -72,6 +73,14 @@ enum {
 
 static Int decodeInit(const PAF_ASIT_Params *pP, PAF_ASIT_Config *pAsitCfg,
                       Int sourceSelect);
+static Int decodeInitSnd(
+        const PAF_ASIT_Params *pP,
+        PAF_ASIT_Config *pAsitCfg,
+        Int sourceSelect);
+static Int decodeInitAck(
+        const PAF_ASIT_Params *pP,
+        PAF_ASIT_Config *pAsitCfg,
+        Int sourceSelect);
 
 static Int decDecodeComplete(const PAF_ASIT_Params *pP,
                              PAF_ASIT_Config *pAsitCfg);
@@ -129,7 +138,8 @@ Int decDecodeInit(
 {
     Int errno;
 
-    errno = decodeInit(pP, pAsitCfg, sourceSelect);
+//    errno = decodeInit(pP, pAsitCfg, sourceSelect);
+    errno = decodeInitSnd(pP, pAsitCfg, sourceSelect);
 
     if(errno) {
         decDecodeComplete(pP, pAsitCfg);
@@ -169,7 +179,8 @@ Int decDecodeFsm(
         ; // No error
     }
 
-    if (decMsg & DEC_MSGMSK_INPDATA) {
+    //if ( (decMsg & DEC_MSGMSK_INPDATA) && (pDec->state != DEC_STATE_INIT_ACK)) {
+    if ( (decMsg & DEC_MSGMSK_INPDATA) ) {
         // put IB read information to the queue
         decGetStreamInfo(&pAsitCfg->pIoInp[pAsitCfg->pAstCfg->masterDec], pDec);
         TRACE_VERBOSE0("decDecodeFsm: INPUT DATA event. Put IB info into queue.");
@@ -185,6 +196,29 @@ Int decDecodeFsm(
     do {
         switch(pDec->state)
         {
+        case DEC_STATE_INIT_ACK:
+            // Ignore any input data event in this state
+            if(decMsg & DEC_MSGMSK_INPDATA) {
+                decMsg &= ~DEC_MSGMSK_INPDATA;   // clear bit mask
+            }
+
+            if (decMsg & DEC_MSGMSK_RXACK) {
+                int errno;
+                errno = decodeInitAck(pP, pAsitCfg, sourceSelect);
+
+                if(errno) {
+                    decDecodeComplete(pP, pAsitCfg);
+
+                    return ASIP_ERR_DECODE_INIT;
+                }
+
+                pDec->state = DEC_STATE_INFO_SND;
+                TRACE_VERBOSE0("decDecodeFsm: DEC_STATE_INIT_ACK done.");
+
+                decMsg &= ~DEC_MSGMSK_RXACK;  // clear the bit mask
+            }
+            break;
+
         case DEC_STATE_INFO_SND:
             if(decMsg != DEC_MSGMSK_INPDATA) {
                 // Only DEC_MSGMSK_INPDATA is expected in this state
@@ -445,7 +479,7 @@ Int decCheckMajorAu(PAF_AST_Config *pAstCfg)
 // -----------------------------------------------------------------------------
 // ASIT Decoding Function - Reinitialization of Decode
 //
-//   Name:      decDecodeInit
+//   Name:      decodeInit
 //   Purpose:   Decoding Function for reinitializing the decoding process.
 //   From:      AST Parameter Function -> decodeProcessing
 //   Uses:      See code.
@@ -466,7 +500,7 @@ static Int decodeInit(
     //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 errno = 0;                      /* error number */
     Int zI, zS;
     Int argIdx;
     Int8 tempVar8;
@@ -512,6 +546,7 @@ static Int decodeInit(
             Cache_wait();
 
             // send dec activate message to slave
+            TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: sending dec activate message to slave", as+zS);
             argIdx = 0; // set decIdx (zone index)
             *(Int32 *)&decMsgBuf[argIdx] = z;
             status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_ACTIVATE, decMsgBuf);
@@ -521,6 +556,8 @@ static Int decodeInit(
                 SW_BREAKPOINT; // temporary
                 return ASIP_ERR_DECODE_MSG; // temporary
             }
+
+            TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: waiting slave to finish dec activate", as+zS);
             status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_ACTIVATE_DONE, NULL, TRUE);
             if (status != ASP_MSG_NO_ERR)
             {
@@ -528,6 +565,7 @@ static Int decodeInit(
                 SW_BREAKPOINT; // temporary
                 return ASIP_ERR_DECODE_MSG; // temporary
             }
+            TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: slave finished dec activate", as+zS);
 
             // send dec reset message to slave
             argIdx = 0; // set decIdx
@@ -539,6 +577,8 @@ static Int decodeInit(
                 SW_BREAKPOINT; // temporary
                 return ASIP_ERR_DECODE_MSG; // temporary
             }
+
+            TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: waiting slave to finish dec reset", as+zS);
             status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_RESET_DONE, decMsgBuf, TRUE);
             if (status != ASP_MSG_NO_ERR)
             {
@@ -551,6 +591,7 @@ static Int decodeInit(
                 argIdx = 0; // get decErrno
                 errno = *(Int32 *)&decMsgBuf[argIdx];
             }
+            TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: slave finished dec reset", as+zS);
 
             // invalidate Dec configuration
             Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
@@ -603,7 +644,197 @@ static Int decodeInit(
     pAsitCfg->inpDec.wridx = 0;
 
     return ASIP_NO_ERR;
-}  /* decDecodeInit */
+}  /* decodeInit */
+
+
+// -----------------------------------------------------------------------------
+// ASIT Decoding Function - Reinitialization of Decode
+//
+//   Name:      decDecodeInit
+//   Purpose:   Decoding Function for reinitializing the decoding process.
+//   From:      AST Parameter Function -> decodeProcessing
+//   Uses:      See code.
+//   States:    x
+//   Return:    Error number in standard or SIO form (0 on success).
+//   Trace:     Message Log "trace" in Debug Project Configuration reports:
+//              * State information as per parent.
+//
+// -----------------------------------------------------------------------------
+static Int decodeInitSnd(
+        const PAF_ASIT_Params *pP,
+        PAF_ASIT_Config *pAsitCfg,
+        Int sourceSelect)
+{
+    PAF_AST_Config *pAstCfg;
+    PAF_AST_IoInp  *pInp;
+    AspMsgMaster_Handle hAspMsgMaster;  // ASIT message master handle
+    //PAF_AST_DecOpCircBufCtl *pCbCtl;    /* Decoder output circular buffer control */
+    Int as;                             /* Audio Stream Number (1, 2, etc.) */
+    Int z;                              /* decode/encode counter */
+    Int errno;                          /* error number */
+    Int zI, zS;
+    Int argIdx;
+    Int8 tempVar8;
+    char decMsgBuf[ASP_MSG_BUF_LEN];
+    Int status;
+
+    pAstCfg = pAsitCfg->pAstCfg;                // get pointer to AST common (shared) configuration
+    pInp    = pAsitCfg->pIoInp;                 // get pointer to IO configuration
+    hAspMsgMaster = pAsitCfg->hAspMsgMaster;    // get message master handle
+
+    as = pAstCfg->as;
+    (void)as;  // clear compiler warning in case not used with tracing disabled
+
+    //pCbCtl = &pAsitCfg->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
+
+    // reset frameCount
+    for (z=DECODE1; z < DECODEN; z++)
+    {
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
+        if (tempVar8)
+        {
+            sharedMemWriteInt(&(pAstCfg->xDec[z].decodeStatus.frameCount),
+                              (Int)0, GATEMP_INDEX_DEC);
+        }
+    }
+
+    // loop through all supported inputs
+    for (z=DECODE1; z < DECODEN; z++)
+    {
+        zI = pP->inputsFromDecodes[z];
+        zS = pP->streamsFromDecodes[z];
+        (void)zS; // clear compiler warning in case not used with tracing disabled
+        tempVar8 = sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.mode),
+                                     GATEMP_INDEX_DEC);
+        if (pInp[zI].hIoPhy && tempVar8)
+        {
+            TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: initializing decode", as+zS);
+
+            // write back Dec configuration
+            Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+            Cache_wait();
+
+            // send dec activate message to slave
+            TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: sending dec activate message to slave", as+zS);
+            argIdx = 0; // set decIdx (zone index)
+            *(Int32 *)&decMsgBuf[argIdx] = z;
+            status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_ACTIVATE, decMsgBuf);
+            if (status != ASP_MSG_NO_ERR)
+            {
+                TRACE_TERSE0("decodeInit: error in sending DEC_ACTIVATE message ");
+                SW_BREAKPOINT; // temporary
+                return ASIP_ERR_DECODE_MSG; // temporary
+            }
+
+            TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: waiting slave to finish dec activate", as+zS);
+            status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_ACTIVATE_DONE, NULL, TRUE);
+            if (status != ASP_MSG_NO_ERR)
+            {
+                TRACE_TERSE0("decodeInit: error in receiving DEC_ACTIVATE_DONE ack message ");
+                SW_BREAKPOINT; // temporary
+                return ASIP_ERR_DECODE_MSG; // temporary
+            }
+            TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: slave finished dec activate", as+zS);
+
+            // send dec reset message to slave
+            argIdx = 0; // set decIdx
+            *(Int32 *)&decMsgBuf[argIdx] = z;
+            status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_RESET, decMsgBuf);
+            if (status != ASP_MSG_NO_ERR)
+            {
+                TRACE_TERSE0("decodeInit: error in sending DEC_RESET message ");
+                SW_BREAKPOINT; // temporary
+                return ASIP_ERR_DECODE_MSG; // temporary
+            }
+
+            TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: waiting slave to finish dec reset", as+zS);
+        } /* end of if(hIoPhy && decodeStatus.mode) */
+    } /* end of for (z=DECODE1; z < DECODEN; z++) */
+
+    pAsitCfg->inpDec.state = DEC_STATE_INIT_ACK;
+
+    return ASIP_NO_ERR;
+}  /* decDecodeInitSnd */
+
+
+static Int decodeInitAck(
+        const PAF_ASIT_Params *pP,
+        PAF_ASIT_Config *pAsitCfg,
+        Int sourceSelect)
+{
+    PAF_AST_Config *pAstCfg;
+    PAF_AST_IoInp  *pInp;
+    AspMsgMaster_Handle hAspMsgMaster;  // ASIT message master handle
+    Int as;                             /* Audio Stream Number (1, 2, etc.) */
+    Int z;                              /* decode/encode counter */
+    Int errno;                          /* error number */
+    Int zI, zS;
+    Int8 tempVar8;
+    char decMsgBuf[ASP_MSG_BUF_LEN];
+
+    pAstCfg = pAsitCfg->pAstCfg;                // get pointer to AST common (shared) configuration
+    pInp    = pAsitCfg->pIoInp;                 // get pointer to IO configuration
+
+    as = pAstCfg->as;
+    (void)as;  // clear compiler warning in case not used with tracing disabled
+
+
+    // loop through all supported inputs
+    for (z=DECODE1; z < DECODEN; z++)
+    {
+        Uns gear;
+        int status;
+        zI = pP->inputsFromDecodes[z];
+        zS = pP->streamsFromDecodes[z];
+        (void)zS; // clear compiler warning in case not used with tracing disabled
+
+        hAspMsgMaster = pAsitCfg->hAspMsgMaster;    // get message master handle
+        status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_RESET_DONE, decMsgBuf, FALSE);
+        if (status != ASP_MSG_NO_ERR)
+        {
+            TRACE_TERSE0("decodeInit: error in sending DEC_RESET message ");
+            SW_BREAKPOINT; // temporary
+            return ASIP_ERR_DECODE_MSG; // temporary
+        }
+        else
+        {
+            errno = *(Int32 *)&decMsgBuf[0];
+            if (errno != 0) {
+                return ASIP_ERR_DECODE_MSG;
+            }
+        }
+        TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: slave finished dec reset", as+zS);
+
+        // invalidate Dec configuration
+        Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
+        Cache_wait();
+
+        if (errno != 0) {
+            return ASIP_ERR_DECODE_MSG;
+        }
+
+        gear = (Uns)sharedMemReadInt8(&(pAstCfg->xDec[z].decodeStatus.aspGearControl),
+                                      GATEMP_INDEX_DEC);
+        tempVar8 = gear < GEARS ? gear : 0;
+        sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.aspGearStatus),
+                           tempVar8, GATEMP_INDEX_DEC);
+
+        //JXTODO: do we need to update input status here again?
+        if (errno = asitUpdateInputStatus(pInp[zI].pRxParams,
+                                          &pAstCfg->xInp[zI].inpBufStatus,
+                                          &pAstCfg->xInp[zI].inpBufConfig)) {
+            return ASIP_ERR_INPUT_CFG;
+        }
+    } /* end of for (z=DECODE1; z < DECODEN; z++) */
+
+    pAsitCfg->inpDec.frame = 0;
+    pAsitCfg->inpDec.block = 0;
+    pAsitCfg->inpDec.rdidx = 0;
+    pAsitCfg->inpDec.wridx = 0;
+
+    return ASIP_NO_ERR;
+}  /* decDecodeInitAck */
 
 Int decDecodeComplete( const PAF_ASIT_Params *pP,
                        PAF_ASIT_Config *pAsitCfg)
index 4f9ca0dea5830bb29ab43714b6a3b4b682ced21d..52304c785b5503c869e39d09d3f194293df3d1a0 100644 (file)
@@ -294,7 +294,7 @@ typedef struct PAF_AST_InpIO {
     bool           firstTimeInit;
 } PAF_AST_IoInp;
 
-#define DEC_INPBUF_CONFIG_QUEUE_SIZE 4
+#define DEC_INPBUF_CONFIG_QUEUE_SIZE 8
 // Decoder structure
 typedef struct asipDecProc_s {
     Int state;
index e07c9f1a725a1098216562a7e8b3c383d409ff64..b298da7ab77392e04931f62a441df9c0f1bb6ec2 100644 (file)
@@ -506,7 +506,7 @@ Int asitSourceDetection(const PAF_ASIT_Params *pP,
     asitErr = asitInputDataProcess(pInp, &autoDetStatus);
     if(asitErr != ASIT_NO_ERR) {
         // Even though there is error, still need to start next transfer to
-        // maintain McASP transfer.
+        // maintain McASP transfer, before returning error.
         asitPhyTransferStart(pInp);
 
         return asitErr;
@@ -537,6 +537,7 @@ Int asitSourceDetection(const PAF_ASIT_Params *pP,
             if(autoDetStatus.syncState == IODATA_SYNC_BITSTREAM) {
                 // Input is bit stream: go to decoding
                 pInp->asipState = ASIT_DECODE_PROCESSING;
+                TRACE_VERBOSE0("Bit stream detected. Go to decoding. ");
             }
             else  {
                 // Input is PCM: stop swapping data
@@ -554,6 +555,7 @@ Int asitSourceDetection(const PAF_ASIT_Params *pP,
 
                 // Go to transition state to switch to PCM
                 pInp->asipState = ASIT_PCM_TRANSITION;
+                TRACE_VERBOSE0("PCM stream detected. Go to PCM transition. ");
             }
         }
     }
@@ -722,7 +724,8 @@ Int asitDecodeProcessing(const PAF_ASIT_Params *pP,
 
                 // Inform decoder to complete the decoding of previous frame - is this good?
                 pInp->sourceSelect = PAF_SOURCE_NONE;
-                pInp->numFrameReceived = 0;    // for debugging
+                pInp->numFrameReceived    = 0;    // for debugging
+                pInp->numPcmFrameReceived = 0;    // for debugging
                 TRACE_TERSE0("asitDecodeProcessing: SYNC lost.");
 
 #ifdef DEBUG_SKIP_DECODING
@@ -730,7 +733,12 @@ Int asitDecodeProcessing(const PAF_ASIT_Params *pP,
 #endif
             }
             else {
-                pInp->numFrameReceived += 1;    // for debugging
+                if(autoDetStatus.syncState == IODATA_SYNC_PCM) {
+                    pInp->numPcmFrameReceived += 1;  // for debugging
+                }
+                else {
+                    pInp->numFrameReceived += 1;     // for debugging
+                }
 
                 // Communicate input stream information to decoder through input
                 // buffer configuration -- this was moved inside decDecodeFsm
@@ -759,7 +767,8 @@ Int asitDecodeProcessing(const PAF_ASIT_Params *pP,
         else {
             // Inform decoder to complete the decoding of previous frame - is this good?
             pInp->sourceSelect = PAF_SOURCE_NONE;
-            pInp->numFrameReceived = 0;    // for debugging
+            pInp->numFrameReceived    = 0;    // for debugging
+            pInp->numPcmFrameReceived = 0;    // for debugging
             TRACE_TERSE1("asitDecodeProcessing: asitInputDataProcess error: %d", asitErr);
 
 #ifdef DEBUG_SKIP_DECODING
@@ -905,7 +914,7 @@ int asitIoCompsInit(PAF_AST_InpBuf * pInpBuf, PAF_AST_IoInp * pInpIo)
             ioBuffParams.size         = pInpBuf->inpBufConfig.allocation / STRIDE_WORST_CASE
                                                                          * STRIDE_WORST_CASE;
             ioBuffParams.sync         = IOBUFF_WRITE_SYNC;
-            ioBuffParams.nominalDelay = INPUT_FRAME_SIZE_DEF;
+            ioBuffParams.nominalDelay = pInpIo->phyXferSize;
             if (ioBuffInit(pInpIo->hIoBuff, &ioBuffParams) != IOBUFF_NOERR) {
                 return (ASIT_ERR_IOBUFF_INIT);   // to remove magic number
             }
@@ -981,7 +990,8 @@ void asitProcInit(PAF_AST_IoInp  *pInp, asipDecProc_t *pDec)
 //    pInp->swapData = TRUE;
     pInp->pcmSwitchHangOver = INPUT_SWITCH_HANGOVER;
     pDec->initDone = FALSE;
-    pInp->numFrameReceived = 0;
+    pInp->numFrameReceived    = 0;    // for debugging
+    pInp->numPcmFrameReceived = 0;    // for debugging
 }
 
 /*======================================================================================
@@ -1047,7 +1057,9 @@ void asipMcaspCallback(void* arg, MCASP_Packet *mcasp_packet)
     if(mcasp_packet->arg == IOPHY_XFER_FINAL) {
         //Semaphore_post(asipSemRx);
         Event_post(gAsitEvtHandle, ASIT_EVTMSK_INPDATA);
+        //Log_info0("asipMcaspCallback: final packet - event posted.\n");
     } else {
+        //Log_info0("asipMcaspCallback: intermediate packet.\n");
         ;    // intermediate packet due to buffer wrapping around
     }
 }
@@ -1090,6 +1102,7 @@ void asitPhyTransferStart(PAF_AST_IoInp *pInpIo)
         System_abort("\nMcASP for input overruns! %d!\n");
     }
     else {
+        //TRACE_VERBOSE0("asitPhyTransferStart: submit a transfer");
         ioPhyErr = ioPhyXferSubmit(pInpIo->hIoPhy);
         //if(ioPhyXferSubmit(pInpIo->hIoPhy)==IOPHY_ERR_BUFF_OVERFLOW) {
         if(ioPhyErr!=IOPHY_NOERR){
@@ -1425,7 +1438,7 @@ Int asitDecideSource(PAF_AST_Config *pAstCfg, PAF_AST_IoInp  *pInp,
     }
 
     if(autoDetStatus->syncState == IODATA_SYNC_BITSTREAM) {
-        uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
+        uint_least16_t pc = autoDetStatus->streamInfo.IEC_PC;
         sourceProgram = IECpafSource[pc];
     }
 
@@ -1570,28 +1583,13 @@ Int asitUpdateIoComps(const PAF_ASIT_Params *pP, PAF_AST_Config *pAstCfg,
     }
     else {
         // For bitstream, I/O frame length is the frame length of the bitstream
-        uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
-        ioFrameLength = iecFrameLength[pc];
-
-/*
-        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;
-        }
-*/
-
         pBufConfig->sizeofElement = WORD_SIZE_BITSTREAM;
-        pBufConfig->frameLength   = ioFrameLength;
-        pBufConfig->lengthofData  = ioFrameLength - IEC_HEADER_LENGTH;
+        pBufConfig->frameLength   = autoDetStatus->streamInfo.frameLength;
+        pBufConfig->lengthofData  = autoDetStatus->streamInfo.dataLength;
+        ioFrameLength = autoDetStatus->streamInfo.frameLength;
 
         // Change I/O PHY transfer size to bitstream frame size
-        pInp->phyXferSize = ioFrameLength*WORD_SIZE_BITSTREAM;
+        pInp->phyXferSize = ioFrameLength*(WORD_SIZE_BITSTREAM);
     }
 
     pBufConfig->stride = pInp->stride;   // common for PCM and bitstream
index d25f1e476b42a766ae0aef7f2f2160f15b1c626f..bb462ad7b1fdc99b854dd36e9143b4ecac3a91ad 100644 (file)
@@ -1431,6 +1431,9 @@ static Int PAF_ASOT_procDecOut(
         asopMarkOutBuffsWriteComplete(&pAstCfg->xOut[zO], &pAsotCfg->pIoOut[zO]);
     }
 
+    // Audio frame pointers need to be reset because DTS PARMA modifies them!!
+    resetAfPointers(pP, pAstCfg->xStr);
+
     if (status == ASOP_SOK)
     {
         // Execute Info2
index 1db06be89256b916a3ec3cb68e5ccfa79f45e1a4..bd30f3b0ce2d511f4cee02917796acfc1decda37 100644 (file)
@@ -29,7 +29,7 @@
 #define IODATA_SYNC_THD             0x16
 
 #define IODATA_MIN_NUM_ZEROS_BEFORE_PA   2
-#define IODATA_PREAMBLE_MAX_LEN          8          // TBD
+#define IODATA_PREAMBLE_MAX_LEN          16 // TBD
 #define IODATA_HEADER_LENGTH_IEC         4
 #define IODATA_HEADER_CHECK_LENGTH_IEC   2  // For IEC, only look at 2 words to check SYNC.
 
@@ -327,7 +327,10 @@ int ioDataControl(ioDataHandle_t ioDataHandle, ioDataCtl_t *ioDataCtl)
     case IODATA_CTL_GET_AUTODET_STATUS:
       ioDataCtl->param.autoDetStats.syncState     = pIoDataInst->autoDet.syncState;
       ioDataCtl->param.autoDetStats.deliverZeros  = pIoDataInst->deliverZeros;
-      ioDataCtl->param.autoDetStats.bitStreamInfo = pIoDataInst->autoDet.bitStreamInfo;
+      ioDataCtl->param.autoDetStats.streamInfo.IEC_PC = pIoDataInst->autoDet.bitStreamInfo & IODATA_SYNC_PC_MASK;
+      ioDataCtl->param.autoDetStats.streamInfo.frameLength = pIoDataInst->autoDet.frameLength;
+      ioDataCtl->param.autoDetStats.streamInfo.dataLength  =  pIoDataInst->autoDet.frameLength
+                                                            - pIoDataInst->autoDet.headerLength;
       break;
 /*
     case IODATA_CTL_GET_STEAM_INFO:
@@ -440,6 +443,7 @@ void autoDetection(ioDataInst_t * pIoDataInst)
          /* Check if a full frame has been received and if so, check if SYNC is maintained */
       if(pIoDataInst->autoDet.completeFrameRcvd) {
                if(pIoDataInst->autoDet.syncDetected) {
+          pIoDataInst->dbgStats.numFramesRcvd += 1;
                  pIoDataInst->autoDet.syncState = IODATA_SYNC_BITSTREAM;
          pIoDataInst->autoDet.completeFrameRcvd = FALSE;
 
@@ -452,7 +456,6 @@ void autoDetection(ioDataInst_t * pIoDataInst)
 
          // Store the beginning address of data in current frame (not including the preamble)
          pIoDataInst->autoDet.frameDataStartConfirm = pIoDataInst->autoDet.frameDataStartTemp;
-         pIoDataInst->dbgStats.numFramesRcvd += 1;
 
          // re-initialize for SYNC check
                  syncCheckInit(pIoDataInst);
@@ -523,6 +526,16 @@ void syncCheckInit(ioDataInst_t * pIoDataInst)
        uint_least16_t pc = pIoDataInst->autoDet.bitStreamInfo & IODATA_SYNC_PC_MASK;
 
        pIoDataInst->autoDet.frameLength    = pIoDataInst->IECframeLengths[pc];
+
+    if (pc == 1) {
+        pIoDataInst->autoDet.frameLength = 4288;
+    }
+    else if (pc == IODATA_SYNC_SUBTYPE_DTSHD) {
+        int DTSHDSubType = (pIoDataInst->autoDet.bitStreamInfo & IODATA_SYNC_SUBTYPE_MASK)
+                           >> IODATA_SYNC_SUBTYPE_SHIFT;
+        pIoDataInst->autoDet.frameLength = pIoDataInst->IECframeLengths[pc] << DTSHDSubType;
+    }
+
        pIoDataInst->autoDet.distToFrameEnd = pIoDataInst->autoDet.frameLength
                                                      - pIoDataInst->autoDet.numElementsRcvd;
 
@@ -716,6 +729,9 @@ void syncScan(void *buff, size_t size, int8_t elementSize, autoDet_t *pDet)
                 //pDevExt->headerSize = IEC_HEADER_SIZE;
                 pDet->preambleRef[3]  = tail; /* save this word for sync check */
                pDet->headerLength    = IODATA_HEADER_LENGTH_IEC;
+                if( (pDet->bitStreamInfo & 0x1F) == 0x11) { // DTSHD subtype
+                    pDet->headerLength += 6;
+                }
                pDet->headerCheckLen  = IODATA_HEADER_CHECK_LENGTH_IEC;
                 scanState = SCANNED_IEC_PD;
 
index bed31c5adbc2ea892a4860b1c70c054c010e7d81..1c27a4eeb8a89e7a00f7ff4248e128c4d5c1c1ac 100644 (file)
@@ -64,10 +64,16 @@ typedef struct ioDataFrameInfo_s {
   int8_t        elementSize;       // size of elements in bytes
 } ioDataFrameInfo_t;
 
+typedef struct streamInfo_s {
+    uint_least16_t IEC_PC;
+    uint_least32_t frameLength;
+    uint_least32_t dataLength;
+} streamInfo_t;
+
 // Auto-detection status
 typedef struct ioDataAutoDetStat_s {
   uint_least16_t   syncState;      // SYNC state
-  uint_least16_t   bitStreamInfo;  // bit stream information - value of IEC_PC
+  streamInfo_t     streamInfo;  // bit stream information - value of IEC_PC
   uint8_t          deliverZeros;   // flag to indicate whether zeros should be sent to output
 } ioDataAutoDetStat_t;