]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/commitdiff
PASDK-516:Add updates for PCE
authorFrank Livingston <frank-livingston@ti.com>
Thu, 15 Feb 2018 23:38:20 +0000 (17:38 -0600)
committerFrank Livingston <frank-livingston@ti.com>
Thu, 15 Feb 2018 23:38:20 +0000 (17:38 -0600)
Add updates for proper OB configuration for PCM encoder.

pasdk/test_dsp/framework/audioStreamInpProcNewIO.c
pasdk/test_dsp/framework/audioStreamOutDec.c
pasdk/test_dsp/framework/audioStreamOutDec.h
pasdk/test_dsp/framework/audioStreamOutIo.c
pasdk/test_dsp/framework/audioStreamOutIo.h
pasdk/test_dsp/framework/audioStreamOutProc.c
pasdk/test_dsp/framework/audioStreamOutProc.h
pasdk/test_dsp/framework/systemInit.c

index d35fd6e18ae5979dcbfac0c2d2faa9f5f81a24d6..3afb532b2621401c4e757f293791bfe528f29b3e 100644 (file)
@@ -160,6 +160,9 @@ enum
 int asipLoopCount1, asipLoopCount2;
 Int asipErrno;
 Int inputReadyForProcessing;
+
+// FL: debug
+#include "evmc66x_gpio_dbg.h"
 #endif
 
 /*
@@ -266,6 +269,18 @@ Int inputReadyForProcessing;
             // Pending on I/O PHY transfer
             asipPhyTransferPend();
 
+#if 1 // (***) FL: shows timing of Input (Rx McASP EDMA) after decoding has started (autodet complete)
+            // (***) debug // B5
+            {
+                static Uint8 toggleState = 0;
+                if (toggleState == 0)
+                    GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99);
+                else
+                    GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
+                toggleState = ~(toggleState);
+            }
+#endif            
+            
             // Marks I/O PHY transfer and I/O BUFF write complete
             asipPhyTransferComplete(pInp);
 
index 5da02bdc32bfc01f7671c34384af739f8fdc4f67..cbab851de909de9f6ab7f1015d584a56538eef6d 100644 (file)
@@ -56,6 +56,7 @@ All rights reserved.
 
 // debug
 #include "evmc66x_gpio_dbg.h"
+#include "dbgCapAf.h"
 PAF_AST_DecOpCircBufStats gCbStats; // circular buffer stats
 
 // debug
@@ -86,6 +87,7 @@ Int asopDecOutProcReset(
 )
 {
     PAF_AST_Config *pAstCfg;    // ASIT/ASOT/ASDT shared configuration
+    PAF_AST_IoOut *pOut;        // ASOT IO configuration
     Int as;                     // Audio Stream Number (1, 2, etc.) */
     Int zO, zS;
     Int z;                      // encode counter
@@ -94,13 +96,14 @@ Int asopDecOutProcReset(
     
     status = ASOP_DOP_SOK;
     pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
+    pOut = pAsotCfg->pIoOut; // get pointer to ASOT IO configuration
     as = pAstCfg->as;
 
     for (z=ENCODE1; z < ENCODEN; z++) 
     {
         zO = pP->outputsFromEncodes[z];
         zS = pP->streamsFromEncodes[z];
-        if (pAstCfg->xOut[zO].hTxSio && pAstCfg->xEnc[z].encodeStatus.mode) 
+        if (pOut[zO].hIoPhy && pAstCfg->xEnc[z].encodeStatus.mode) 
         {
             Int select = pAstCfg->xEnc[z].encodeStatus.select;
             ALG_Handle encAlg = pAstCfg->xEnc[z].encAlg[select];
@@ -138,12 +141,12 @@ Int asopDecOutProcInfo1(
     Int frame 
 )
 {
-    PAF_AST_Config *pAstCfg;
-    PAF_AST_IoOut  *pOut;
-    Int zO, zS;
-    Int z;                              // decode/encode counter
-    Int errno;                          // error number
-    Int status;                         // status code
+    PAF_AST_Config *pAstCfg;    // ASIT/ASOT/ASDT shared configuration
+    PAF_AST_IoOut *pOut;        // ASOT IO configuration
+    Int zO, zS; 
+    Int z;                      // decode/encode counter
+    Int errno;                  // error number
+    Int status;                 // status code
     
     status = ASOP_DOP_SOK;
     pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
@@ -227,13 +230,14 @@ Int asopDecOutProcInfo1(
         }
     }
     
-    //// I/O physical layer prime operation required by McASP LLD
-    ////  FL, New IO: API for single Output
-    //asopIoPhyPrime(&pAsotCfg->pIoOut[zO]);
-    
-    //// Start output transfer
-    //// FL, New IO: API for single Output
-    //asopPhyTransferStart(&pOut[zO]);
+    // Initialize Output buffer configuration
+    errno = asopInitOutBufConfig(&pAstCfg->xOut[zO], &pOut[zO]);
+    if (errno)
+    {
+        TRACE_TERSE1("asopDecOutProcInfo1: asopInitOutBufConfig returns errno 0x%x ", errno);
+        status = ASOP_DOP_ERR_INFO1_STARTOUTPUT;
+        return status;
+    }
     
     return status;
 } //asopDecOutProcInfo1
@@ -246,12 +250,12 @@ Int asopDecOutProcInfo2(
     Int frame 
 )
 {
-    PAF_AST_Config *pAstCfg;
-    PAF_AST_IoOut  *pOut;
+    PAF_AST_Config *pAstCfg;    // ASIT/ASOT/ASDT shared configuration
+    PAF_AST_IoOut  *pOut;       // ASIO IO configuration
     Int zO, zS;
-    Int z;                              // decode/encode counter
-    Int errno;                          // error number
-    Int status;                         // status code
+    Int z;                      // decode/encode counter
+    Int errno;                  // error number
+    Int status;                 // status code
     
     status = ASOP_DOP_SOK;
     pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
@@ -457,6 +461,13 @@ Int asopDecOutProcStream(
         return status;
     }
 
+#if 0 // debug, capture audio frame
+    if (capAfWrite(pAfRd, PAF_LEFT) != CAP_AF_SOK)
+    {
+        Log_info0("asopDecOutProcStream:capAfWrite() error");
+    }
+#endif
+    
     return status;
 } //asopDecodeStream
 
@@ -480,8 +491,8 @@ Int asopDecOutProcEncode(
     Int frame 
 )
 {
-    PAF_AST_Config *pAstCfg;
-    PAF_AST_IoOut  *pOut;
+    PAF_AST_Config *pAstCfg;    // ASIT/ASOT/ASDT shared configuration
+    PAF_AST_IoOut  *pOut;       // ASIO IO configuration
     Int as;                     // Audio Stream Number (1, 2, etc.)
     Int zX, zE, zS;
     Int z;                      // encode/output counter
@@ -518,14 +529,14 @@ Int asopDecOutProcEncode(
             TRACE_GEN2("asopDecodeEncode: AS%d: processing frame %d -- idle", as+zS, frame);
 
 #if 0 // FL, New IO: add similar thing to be figured out
+            // Update framework Phy transfer size
+            pOut[z].phyXferSize = pAstCfg->xOut[z].outBufConfig.lengthofFrame * OUTPUT_STRIDE * WORD_SIZE_PCM;
+            // Update IO Phy transfer size            
             ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
-            ioPhyCtl.params.xferFrameSize = pAstCfg->xOut[z].outBufConfig.lengthofFrame
-                                               * ASOP_OUTBUF_STRIDE * ASOP_NUM_BYTES_PCM_SAMPLE;
+            ioPhyCtl.params.xferFrameSize = pOut[z].phyXferSize;
             ioPhyControl(pOut[z].hIoPhy, &ioPhyCtl);
-            // Update framework transfer size to IO Phy transfer size
-            pOut[z].phyXferSize = ioPhyCtl.params.xferFrameSize;
-            // Update IO Buff delay to match IO Phy transfer size
-            ioBuffAdjustDelay(pOut[z].hIoBuff, ioPhyCtl.params.xferFrameSize * (NUM_PRIME_XFERS+1));
+            // Update IO Buff delay to match Phy transfer size
+            ioBuffAdjustDelay(pOut[z].hIoBuff, pOut[z].phyXferSize * (NUM_PRIME_XFERS+1));
 
             errno = SIO_reclaim(pAstCfg->xOut[z].hTxSio,(Ptr *) &pAstCfg->xOut[z].pOutBuf, NULL);
             if (errno < 0)
@@ -558,6 +569,15 @@ Int asopDecOutProcEncode(
     // Encode data
     for (z=ENCODE1; z < ENCODEN; z++) 
     {
+#if 0 // debug, capture audio frame
+        PAF_AudioFrame *pAfRd;
+        pAfRd = pAstCfg->xEnc[z].encodeInStruct.pAudioFrame;
+        if (capAfWrite(pAfRd, PAF_LEFT) != CAP_AF_SOK)
+        {
+            Log_info0("asopDecOutProcEncode:capAfWrite() error");
+        }
+#endif
+        
         Int zS = pP->streamsFromEncodes[z];
         (void)zS; // clear compiler warning in case not used with tracing disabled
         if (pAstCfg->xEnc[z].encodeStatus.mode) 
@@ -660,16 +680,6 @@ Int asopDecOutProcEncode(
             TRACE_GEN2("PAF_ASOT_decodeEncode: AS%d: processing frame %d -- output <ignored>", as+zS, frame);
         }
 #endif
-        if (pOut[z].hIoPhy)
-        {
-            TRACE_GEN2("asopDecOutProcEncode: AS%d: processing frame %d -- output", as+zS, frame);
-            errno = asopWriteOpBuffers(&pAstCfg->xOut[z].outBufConfig, &pOut[z]);
-            if (errno)
-            {
-                status = ASOP_DOP_ERR_ENCODE_WRTOPBUFS;
-                return status;
-            }
-        }
     }
 
     return status;
@@ -728,8 +738,8 @@ Int asopDecOutProcComplete(
     Int frame
 )
 {
-    PAF_AST_Config *pAstCfg;
-    PAF_AST_IoOut  *pOut;
+    PAF_AST_Config *pAstCfg;            // ASIT/ASOT/ASDT shared configuration
+    PAF_AST_IoOut  *pOut;               // ASIO IO configuration
     PAF_AST_DecOpCircBufCtl *pCbCtl;    // Decoder output circular buffer control
     Int as;                             // Audio Stream Number (1, 2, etc.)
     Int z;                              // decode/encode counter
index 192aa0c2eb23f530377ebb6057529d114ce13374..cf4a2bc9e5b64cc2f18c3c9717cb40558baaa9c4 100644 (file)
@@ -51,19 +51,20 @@ All rights reserved.
 #define ASOP_DOP_ERR_INFO1_ENCINFO          (  -3 ) // error - info1, enc info
 #define ASOP_DOP_ERR_INFO1_SETRATEX         (  -4 ) // error - info1, set rate X
 #define ASOP_DOP_ERR_INFO1_STARTOUTPUT      (  -5 ) // error - info1, start output
-#define ASOP_DOP_ERR_INFO2_SETRATEX         (  -6 ) // error - info2, set rate X
-#define ASOP_DOP_ERR_INIT_CBINITREAD        (  -7 ) // error - init, CB init read
-#define ASOP_DOP_ERR_INIT_CBREADSTART       (  -8 ) // error - init, CB read start
-#define ASOP_DOP_ERR_STREAM_CBREAD          (  -9 ) // error - stream, CB read
-#define ASOP_DOP_ERR_STREAM_CBREADUNDTHR    ( -10 ) // error - stream, CB read underflow threshold reached
-#define ASOP_DOP_ERR_STREAM_ASPCHAINAPPLY   ( -11 ) // error - stream, ASP chain apply
-#define ASOP_DOP_ERR_ENCODE_ENCSELECT       ( -12 ) // error - encode, encoder (re-)select
-#define ASOP_DOP_ERR_ENCODE_ENC             ( -13 ) // error - encode, encoder 
-#define ASOP_DOP_ERR_ENCODE_WRTOPBUFS       ( -14 ) // error - encode, write output buffers 
-#define ASOP_DOP_ERR_FINALTEST_CBCHKDRAIN   ( -15 ) // error - final test, CB check drained
-#define ASOP_DOP_ERR_FINALTEST_CBDRAINED    ( -16 ) // error - final test, CB drained
-#define ASOP_DOP_ERR_COMPLETE_CBREADSTOP    ( -17 ) // error - complete, CB read stop
-#define ASOP_DOP_ERR_COMPLETE_STOPOUTPUT    ( -18 ) // error - complete, stop output
+#define ASOP_DOP_ERR_INFO1_INITOUTBUFCFG    (  -6 ) // error - info1, init out buf config
+#define ASOP_DOP_ERR_INFO2_SETRATEX         (  -7 ) // error - info2, set rate X
+#define ASOP_DOP_ERR_INIT_CBINITREAD        (  -8 ) // error - init, CB init read
+#define ASOP_DOP_ERR_INIT_CBREADSTART       (  -9 ) // error - init, CB read start
+#define ASOP_DOP_ERR_STREAM_CBREAD          ( -10 ) // error - stream, CB read
+#define ASOP_DOP_ERR_STREAM_CBREADUNDTHR    ( -11 ) // error - stream, CB read underflow threshold reached
+#define ASOP_DOP_ERR_STREAM_ASPCHAINAPPLY   ( -12 ) // error - stream, ASP chain apply
+#define ASOP_DOP_ERR_ENCODE_ENCSELECT       ( -13 ) // error - encode, encoder (re-)select
+#define ASOP_DOP_ERR_ENCODE_ENC             ( -14 ) // error - encode, encoder 
+#define ASOP_DOP_ERR_ENCODE_WRTOPBUFS       ( -15 ) // error - encode, write output buffers 
+#define ASOP_DOP_ERR_FINALTEST_CBCHKDRAIN   ( -16 ) // error - final test, CB check drained
+#define ASOP_DOP_ERR_FINALTEST_CBDRAINED    ( -17 ) // error - final test, CB drained
+#define ASOP_DOP_ERR_COMPLETE_CBREADSTOP    ( -18 ) // error - complete, CB read stop
+#define ASOP_DOP_ERR_COMPLETE_STOPOUTPUT    ( -19 ) // error - complete, stop output
 
 
 //   Purpose:   ASOT Function for Output reset
index e0ad21d00140d1b872e0659f2aefdae6a6fc11ca..7c715ba59613a2a55338fb81459825d0e80cc0f3 100644 (file)
@@ -64,6 +64,71 @@ extern Ptr hMcaspTxChan;
 extern Int d10Initialized;
 
 
+// FL, New IO: this function is currently a stub
+// FL, New IO: need to McASP/EDMA configuration using SAP configuration from Output shortcut
+// Select Output devices
+Int asopSelectDevices(PAF_AST_IoOut *pOut)
+{
+    if((pOut->hIoBuff == NULL) || (pOut->hIoPhy == NULL) || (!d10Initialized)) {
+        return -1;
+    }
+
+    pOut->hMcaspChan = hMcaspTxChan;
+
+    return 0;
+}
+
+// Check if Output device SIO selection changed
+Int checkOutDevSioSelUpdate(
+    const PAF_ASOT_Params *pP, 
+    PAF_ASOT_Config *pAsotCfg,
+    Int z, 
+    Bool *pOutDevSelUpdate
+)
+{
+    PAF_AST_Config *pAstCfg;
+    
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
+
+    if ((z < OUTPUT1) || (z >= OUTPUTN))
+    {
+        *pOutDevSelUpdate = FALSE;
+        return -1;
+    }
+    
+    *pOutDevSelUpdate = (Bool)(pAstCfg->xOut[z].outBufStatus.sioSelect >= 0);
+
+    return 0;
+}
+
+// Check if any Output device SIO selection changed
+Int checkAnyOutDevSioSelUpdate(
+    const PAF_ASOT_Params *pP, 
+    PAF_ASOT_Config *pAsotCfg,
+    Bool *pOutDevSelUpdate
+)
+{
+    PAF_AST_Config *pAstCfg;
+    Int outDevSelUpdate;
+    Int z;
+    
+    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
+
+    outDevSelUpdate = FALSE;
+    for (z=OUTPUT1; z < OUTPUTN; z++) 
+    {
+        if (pAstCfg->xOut[z].outBufStatus.sioSelect >= 0)
+        {
+            outDevSelUpdate = TRUE;
+            break;
+        }
+    }
+    
+    *pOutDevSelUpdate = outDevSelUpdate;
+
+    return 0;
+}
+
 // -----------------------------------------------------------------------------
 // ASOT Decoding Function Helper - SIO Driver Change
 //
@@ -249,17 +314,17 @@ Int asopStartOutput(
             pAstCfg->xOut[z].outBufConfig.lengthofFrame =
                 pAstCfg->xEnc[zE].encodeInStruct.pAudioFrame->sampleCount;
 
-#if 1 // FL New IO: add similar thing to be figured out
+#if 1 // FL, New IO: add similar thing to be figured out
+            // Update framework Phy transfer size
+            pOut[z].phyXferSize = pAstCfg->xOut[z].outBufConfig.lengthofFrame * OUTPUT_STRIDE * WORD_SIZE_PCM;
+            // Update IO Phy transfer size            
             ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
-            ioPhyCtl.params.xferFrameSize = pAstCfg->xOut[z].outBufConfig.lengthofFrame
-                                               * OUTPUT_STRIDE * WORD_SIZE_PCM;
+            ioPhyCtl.params.xferFrameSize = pOut[z].phyXferSize;
             ioPhyControl(pOut[z].hIoPhy, &ioPhyCtl);
-            // Update framework transfer size to IO Phy transfer size
-            pOut[z].phyXferSize = ioPhyCtl.params.xferFrameSize;
-            // Update IO Buff delay to match IO Phy transfer size
-            ioBuffAdjustDelay(pOut[z].hIoBuff, ioPhyCtl.params.xferFrameSize * (NUM_PRIME_XFERS+1));
+            // Update IO Buff delay to match Phy transfer size
+            ioBuffAdjustDelay(pOut[z].hIoBuff, pOut[z].phyXferSize * (NUM_PRIME_XFERS+1));
 #endif            
-                
+
             if (pAstCfg->xOut[z].outBufStatus.markerMode == PAF_OB_MARKER_ENABLED)
             {
                 pObj = (PAF_SIO_IALG_Obj *) pAstCfg->xOut[z].outChainData.head->alg;
@@ -438,20 +503,6 @@ Int asopStopOutput(
     return errno;
 } //asopStopOutput
 
-// FL, New IO: this function is currently a stub
-// FL, New IO: need to McASP/EDMA configuration using SAP configuration from Output shortcut
-// Select Output devices
-Int asopSelectDevices(PAF_AST_IoOut *pOut)
-{
-    if((pOut->hIoBuff == NULL) || (pOut->hIoPhy == NULL) || (!d10Initialized)) {
-        return -1;
-    }
-
-    pOut->hMcaspChan = hMcaspTxChan;
-
-    return 0;
-}
-
 /*===========================================================================
  * Initialize I/O components for output processing
 ============================================================================*/
@@ -483,10 +534,23 @@ Int asopIoCompsInit(
     }
 
     pOutIo->phyXferSize = ioPhyParams.xferFrameSize;
+    
+    pOutIo->ioBuffNumOvr = 0; // initialize number of IO buff overflows
+    pOutIo->ioBuffNumUnd = 0; // initialize number of IO buff underflows
 
     return 0;
 } /* asopIoCompsInit */
 
+/*======================================================================================
+ *  This function checks whether the I/O physical layer has been initialized
+ *====================================================================================*/
+Bool asopIoPhyCheckInit(Void)
+{
+    if (!d10Initialized)
+        return FALSE;
+    else 
+        return TRUE;
+}
 
 /*======================================================================================
  *  I/O physical layer prime operation required by McASP LLD
@@ -505,132 +569,141 @@ Void asopIoPhyPrime(
     }
 } /* asipIoPhyPrime */
 
-
-/*======================================================================================
- *  This function checks whether the I/O physical layer has been initialized
- *====================================================================================*/
-Bool asopIoPhyCheckInit(Void)
-{
-    if (!d10Initialized)
-        return FALSE;
-    else 
-        return TRUE;
-}
-
-/*======================================================================================
- *  This function starts an I/O PHY transfer for output
- *====================================================================================*/
-Void asopPhyTransferStart(
-    PAF_AST_IoOut *pOut
+// Initialize Output buffer configuration
+Int asopInitOutBufConfig(
+    PAF_AST_OutBuf *pOutBuf, 
+    PAF_AST_IoOut *pOutIo
 )
 {
-    if(mcaspCheckOverUnderRun(pOut->hMcaspChan)) 
-    {
-        mcaspTxReset();
-        mcaspTxCreate();
-        pOut->hMcaspChan = hMcaspTxChan;
-    }
-    else 
-    {
-        if(ioPhyXferSubmit(pOut->hIoPhy) == IOPHY_ERR_BUFF_UNDERFLOW) 
-        {
-            // Output buffer underflows!
-            System_abort("\nOutput buffer underflows!\n");
-        }
-        else {
-            // Output buffer operates normally
-            ;
-        }
-    }
+    PAF_OutBufConfig *pOutBufCfg;
+    ioBuffHandle_t hIoBuff;
+    ioBuffInfo_t outBuffInfo;
+    
+    pOutBufCfg = &pOutBuf->outBufConfig;
+    hIoBuff = pOutIo->hIoBuff;
+    
+    pOutBufCfg->stride = OUTPUT_STRIDE;
+    pOutBufCfg->sizeofElement = WORD_SIZE_PCM;
+    pOutBufCfg->precision = 24;
+    
+    ioBuffGetInfo(hIoBuff, &outBuffInfo);
+       pOutBufCfg->base.pLgInt = outBuffInfo.base;
+       pOutBufCfg->sizeofBuffer = outBuffInfo.size;
+    
+       pOutBuf->pOutBuf = &(pOutBuf->outBufConfig);    
+    
+    return 0;
 }
 
-// Write output buffers with encoded data
-Int asopWriteOpBuffers(
-    PAF_OutBufConfig *pOpBufCfg, 
-    PAF_AST_IoOut *pOut
+// Update Output buffer configuration.
+// This is needed for proper operation of PCM encoder.
+Int asopUpdateOutBufConfig(
+    PAF_AST_OutBuf *pOutBuf, 
+    PAF_AST_IoOut *pOutIo
 )
 {
-    PAF_UnionPointer pntr;
+    PAF_OutBufConfig *pOutBufCfg;
+    ioBuffHandle_t hIoBuff;
+    ioBuffInfo_t outBuffInfo;
     void *buff1, *buff2;
-    size_t size1, size2;
-    int status;
+    size_t size1, size2, total_write_size;
+    Int status;
+
+    pOutBufCfg = &pOutBuf->outBufConfig;
+    hIoBuff = pOutIo->hIoBuff;
 
-    pntr = pOpBufCfg->pntr; // get output buffer pointer
+    // FL, New IO: original code can change these values in every DOB issue
+    //  Need to determine if this is required or not.
+    pOutBufCfg->stride = OUTPUT_STRIDE;
+    pOutBufCfg->sizeofElement = WORD_SIZE_PCM;
+    pOutBufCfg->precision = 24;
     
-    status = ioBuffGetWritePtrs(pOut->hIoBuff, pOut->phyXferSize,
+    //JXTODO: to replace hard coded write size
+    // Get write pointers of output memory pool
+       total_write_size = pOutBufCfg->lengthofFrame * pOutBufCfg->stride * pOutBufCfg->sizeofElement;
+    status = ioBuffGetWritePtrs(hIoBuff, total_write_size,
         &buff1, &size1, &buff2, &size2);
     if (status == IOBUFF_ERR_OVERFLOW) 
     {
-        /* skip processing since output buffer overflows */
-        return IOBUFF_ERR_OVERFLOW;   // to use a different error code
-    }
+        pOutIo->ioBuffNumOvr++;
+        //System_printf ("asopUpdateOutBufConfig: output buff overflow\n"); // debug
 
-    // Copy data to output buffer to be transmitted by McASP
-    memcpy(buff1, &pntr.pSmInt[0], size1);
-    Cache_wbInv(buff1, size1, Cache_Type_ALL,TRUE);
-
-    ioBuffWriteComplete(pOut->hIoBuff, buff1, size1);
-
-    if (buff2 != NULL) 
+        // skip processing since output buffer overflows        
+        return -1;
+    }
+    else if (status == IOBUFF_ERR_UNDERFLOW) 
     {
-      memcpy(buff2, &pntr.pSmInt[size1], size2);
-      Cache_wbInv(buff2, size2, Cache_Type_ALL,TRUE);
-
-      ioBuffWriteComplete(pOut->hIoBuff, buff2, size2);
+        pOutIo->ioBuffNumUnd++;
+        //System_printf ("asopUpdateOutBufConfig: output buff underflow\n"); // debug
+        
+        // already underflows and remain in underflow
     }
 
+    // Update Output buffer pointer for Encoder
+       pOutBufCfg->pntr.pLgInt = buff1;
+    
+    // save buffer pointers & sizes for later write complete
+    pOutIo->buff1 = buff1;
+    pOutIo->size1 = size1;
+    pOutIo->buff2 = buff2; // this should always be NULL for Output
+    pOutIo->size2 = size2; // this should always be 0 for Output
+    
     return 0;
 }
 
-// Check if Output device SIO selection changed
-Int checkOutDevSioSelUpdate(
-    const PAF_ASOT_Params *pP, 
-    PAF_ASOT_Config *pAsotCfg,
-    Int z, 
-    Bool *pOutDevSelUpdate
+// Mark Output buffers write complete
+Int asopMarkOutBuffsWriteComplete(
+    PAF_AST_OutBuf *pOutBuf, 
+    PAF_AST_IoOut *pOutIo
 )
 {
-    PAF_AST_Config *pAstCfg;
+    ioBuffHandle_t hIoBuff;
+    void *buff1, *buff2;
+    size_t size1, size2;
     
-    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
+    // get buffer pointers & sizes from previous IO Buff write allocation
+    buff1 = pOutIo->buff1;
+    size1 = pOutIo->size1;
+    buff2 = pOutIo->buff2; // this should always be NULL for Output
+    size2 = pOutIo->size2; // this should always be 0 for Output
+    
+    hIoBuff = pOutIo->hIoBuff;
+    
+    ioBuffWriteComplete(hIoBuff, buff1, size1);
 
-    if ((z < OUTPUT1) || (z >= OUTPUTN))
+    if (buff2 != NULL) 
     {
-        *pOutDevSelUpdate = FALSE;
-        return -1;
+        ioBuffWriteComplete(hIoBuff, buff2, size2);
     }
     
-    *pOutDevSelUpdate = (Bool)(pAstCfg->xOut[z].outBufStatus.sioSelect >= 0);
-
     return 0;
 }
 
-// Check if any Output device SIO selection changed
-Int checkAnyOutDevSioSelUpdate(
-    const PAF_ASOT_Params *pP, 
-    PAF_ASOT_Config *pAsotCfg,
-    Bool *pOutDevSelUpdate
+/*======================================================================================
+ *  This function starts an I/O PHY transfer for output
+ *====================================================================================*/
+Void asopPhyTransferStart(
+    PAF_AST_IoOut *pOut
 )
 {
-    PAF_AST_Config *pAstCfg;
-    Int outDevSelUpdate;
-    Int z;
-    
-    pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
-
-    outDevSelUpdate = FALSE;
-    for (z=OUTPUT1; z < OUTPUTN; z++) 
+    if(mcaspCheckOverUnderRun(pOut->hMcaspChan)) 
     {
-        if (pAstCfg->xOut[z].outBufStatus.sioSelect >= 0)
+        mcaspTxReset();
+        mcaspTxCreate();
+        pOut->hMcaspChan = hMcaspTxChan;
+    }
+    else 
+    {
+        if(ioPhyXferSubmit(pOut->hIoPhy) == IOPHY_ERR_BUFF_UNDERFLOW) 
         {
-            outDevSelUpdate = TRUE;
-            break;
+            // Output buffer underflows!
+            System_abort("\nOutput buffer underflows!\n");
+        }
+        else {
+            // Output buffer operates normally
+            ;
         }
     }
-    
-    *pOutDevSelUpdate = outDevSelUpdate;
-
-    return 0;
 }
 
 /* nothing past this point */
index 7459de4d98eae5c120e2fa0318cead891d1264f8..7e33e96cd3f5cbe2626e640085efa0d51dc3e1d2 100644 (file)
@@ -45,6 +45,26 @@ All rights reserved.
 #include "audioStreamOutProc.h"
 
 
+// Select Output devices
+Int asopSelectDevices(
+    PAF_AST_IoOut *pOut
+);
+
+// Check if Output device SIO selection changed
+Int checkOutDevSioSelUpdate(
+    const PAF_ASOT_Params *pP, 
+    PAF_ASOT_Config *pAsotCfg,
+    Int z, 
+    Bool *pOutDevSelUpdate
+);
+
+// Check if any Output device SIO selection changed
+Int checkAnyOutDevSioSelUpdate(
+    const PAF_ASOT_Params *pP, 
+    PAF_ASOT_Config *pAsotCfg,
+    Bool *pOutDevSelUpdate
+);
+
 // Re-initiate Output
 Int asopSetCheckRateX(
     const PAF_ASOT_Params *pP, 
@@ -66,11 +86,6 @@ Int asopStopOutput(
     PAF_ASOT_Config *pAsotCfg
 );
 
-// Select Output devices
-Int asopSelectDevices(
-    PAF_AST_IoOut *pOut
-);
-
 // Initialize I/O components for output processing
 Int asopIoCompsInit(
     PAF_AST_OutBuf *pOutBuf, 
@@ -85,30 +100,27 @@ Void asopIoPhyPrime(
     PAF_AST_IoOut *pOut
 );
 
-// This function starts an I/O PHY transfer for output 
-Void asopPhyTransferStart(
-    PAF_AST_IoOut *pOut
+// Initialize Output buffer configuration
+Int asopInitOutBufConfig(
+    PAF_AST_OutBuf *pOutBuf, 
+    PAF_AST_IoOut *pOutIo
 );
 
-// Write output buffers with encoded data
-Int asopWriteOpBuffers(
-    PAF_OutBufConfig *pOpBufCfg
-    PAF_AST_IoOut *pOut
+// Update Output buffer configuration
+Int asopUpdateOutBufConfig(
+    PAF_AST_OutBuf *pOutBuf
+    PAF_AST_IoOut *pOutIo
 );
 
-// Check if Output device SIO selection changed
-Int checkOutDevSioSelUpdate(
-    const PAF_ASOT_Params *pP, 
-    PAF_ASOT_Config *pAsotCfg,
-    Int z, 
-    Bool *pOutDevSelUpdate
+// Mark Output buffers write complete
+Int asopMarkOutBuffsWriteComplete(
+    PAF_AST_OutBuf *pOutBuf, 
+    PAF_AST_IoOut *pOutIo
 );
 
-// Check if any Output device SIO selection changed
-Int checkAnyOutDevSioSelUpdate(
-    const PAF_ASOT_Params *pP, 
-    PAF_ASOT_Config *pAsotCfg,
-    Bool *pOutDevSelUpdate
+// This function starts an I/O PHY transfer for output 
+Void asopPhyTransferStart(
+    PAF_AST_IoOut *pOut
 );
 
 
index b3b4319996b455e72be6ee5b876f23b07f3a2d73..a4e9327dfd12af59a5d1c02298a944c9a6fcce64 100644 (file)
@@ -52,7 +52,7 @@ All rights reserved.
 //Int32 gNumPfpAsot1=0; // debug
 
 // debug
-//#include "evmc66x_gpio_dbg.h"
+#include "evmc66x_gpio_dbg.h"
 
 //#include "ioConfig.h"
 
@@ -622,7 +622,19 @@ Void taskAsopFxn(
                 {
                     gProcDecOutState_EvtTxMcaspEdma_cnt++;
                     events &= ~Evt_Id_AsotTxMcaspEdma; // clear event
-
+                    
+#if 1 // (***) FL: shows timing of Output (Tx McASP EDMA)
+                    // (***) debug // B8
+                    {
+                        static Uint8 toggleState = 0;
+                        if (toggleState == 0)
+                            GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106);
+                        else
+                            GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
+                        toggleState = ~(toggleState);
+                    }
+#endif                                 
+                    
                     // Process Output
                     status = PAF_ASOT_procDecOut(pP, pQ, pAsotCfg, &procOutFirstTime, asopFrameCount);
                     if (status < 0)
@@ -937,10 +949,6 @@ static Int PAF_ASOT_selectDevices(
                 *pOutDevSel = FALSE;
                 return status;
             }
-                
-            //// I/O physical layer prime operation required by McASP LLD
-            ////  FL, New IO: API for single Output
-            //asopIoPhyPrime(&pAsotCfg->pIoOut[zO]);
         }
 
         pAstCfg->xOut[zO].outBufStatus.sioSelect = device | 0x80;
@@ -1207,12 +1215,13 @@ static Int PAF_ASOT_initSyncDecDecode1(
             }
         }
 
-        // FL, New IO: assumption here is Output frame size (output frame size)
-        //             & McASP Tx clock dividers are set correctly (stream)
-        //             before IO prime, i.e. IO prime is not set to default
+        // FL, New IO: assumption here is Tx McASP clock dividers &
+        //  Output frame size are set correctly before IO prime, 
+        //  i.e. IO prime is not using defaults
         
+        // FL, New IO: API for single Output
+
         // I/O physical layer prime operation required by McASP LLD
-        //  FL, New IO: API for single Output
         asopIoPhyPrime(&pAsotCfg->pIoOut[zO]);        
         
         return ASOP_SOK;
@@ -1312,12 +1321,30 @@ static Int PAF_ASOT_procDecOut(
 
     if (status == ASOP_SOK)
     {
-        // Execute encode
-        errno = asopDecOutProcEncode(pP, pQ, pAsotCfg, frame);
-        if (errno < 0)
+        // Update Output buffer configuration
+        errno = asopUpdateOutBufConfig(&pAstCfg->xOut[zO], &pAsotCfg->pIoOut[zO]);
+        if (errno)
         {
             status = errno;
         }
+        else
+        {
+            // Execute encode
+            errno = asopDecOutProcEncode(pP, pQ, pAsotCfg, frame);
+            if (errno < 0)
+            {
+                status = errno;
+            }
+            else
+            {
+                // Mark Output buffers write complete
+                errno = asopMarkOutBuffsWriteComplete(&pAstCfg->xOut[zO], &pAsotCfg->pIoOut[zO]);
+                if (errno)
+                {
+                    status = errno;
+                }
+            }
+        }
     }
 
     if (status == ASOP_SOK)
index e8f78cfa2824207749b8d67a531c00e4209e4601..c3ba449de5ca79810c266995ab39b1766b60d534 100644 (file)
@@ -196,6 +196,14 @@ typedef struct PAF_AST_OutIO {
 
     uint32_t  mcaspXferErr;
 
+    void  *buff1;   // pointer to 1st buffer in output memory pool
+    void  *buff2;   // pointer to 2nd buffer in output memory pool in case of buffer wrap
+    size_t size1;   // size of 1st buffer in output memory pool
+    size_t size2;   // size of 2nd buffer in output memory pool
+    
+    uint32_t ioBuffNumUnd;
+    uint32_t ioBuffNumOvr;
+    
     // debugging counters
     uint32_t num_xfers;
 
index 5b3f7d03493c7ef8af761bec47ce7f81f1212914..9dfc363e4fbfe5bbca0a309e079b00616048b6ea 100644 (file)
@@ -215,7 +215,7 @@ Void taskSysInitFxn(Void)
     PAF_ASOT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
 #endif
 
-#if 0 // debug
+#if 1 // debug
     // Any of these can be used on ARM, but DSP must configure the GPIO since pinMuxSetMode() is only available on DSP
     audk2g_pinMuxSetMode(101,AUDK2G_PADCONFIG_MUX_MODE_QUATERNARY); // PAD101 to QUATERNARY, GPIO (B5 on AudioDaughterCard J12)
     GPIOSetDirection(GPIO_PORT_0, GPIO_PIN_99, GPIO_OUT); // GPIO0,pin99 output