]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_dsp/framework/audioStreamOutProc.h
Merge remote-tracking branch 'origin/dev_pasdk_frank_pasdk577RunTimeAudioIoCfg' into...
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamOutProc.h
index 5cb7a14421e40cd94e1fcf6f15ab0d75b9770c31..96e0433b16837da3830973d51bd6a7cc9cef321b 100644 (file)
@@ -41,23 +41,34 @@ All rights reserved.
 #define _ASOP_H_
  
 #include <xdc/std.h>
+#include <ti/sysbios/knl/Event.h>
 #include <ti/sysbios/knl/Task.h>
 
+#include "mcasp_cfg.h"
+#include "ioPhy.h"
+#include "ioBuff.h"
+
 #include "audioStreamProc_params.h"
 #include "audioStreamProc_patchs.h"
 #include "audioStreamProc_config.h"
 #include "audioStreamProc_master.h"
-#include "ioPhy.h"
-#include "ioBuff.h"
+
+#define TRACE_TIME(a)
 
 /* !!!!!!!!! Revisit !!!!!!!!!!!!!!
- * Purpose : Temporary ASOT FL sizes.
+ * Purpose : Temporary ASOT frame length sizes.
  *                      Deprecate PAF_SYS_FRAMELENGTH in phases.*/
 #define PAF_ASOT_FRAMELENGTH           256
 #define PAF_ASOT_MAX_FRAMELENGTH       1024
 
-// Global debug counter */
-extern Uint32 gTaskAsopCnt; // debug counter for ASOP task
+// ASOT event IDs
+#define Evt_Id_AsotWakeTimer    Event_Id_00  // ASOT Wake Timer event
+#define Evt_Id_AsotRxMsgAsit    Event_Id_01  // ASOT Rx ASIT message event
+#define Evt_Id_AsotRxMsgAsdt    Event_Id_02  // ASOT Rx ASDT message event
+#define Evt_Id_AsotTxMcaspEdma  Event_Id_03  // ASOT Tx McASP EDMA event
+
+// ASOT event handle - to put in structure
+extern Event_Handle gAsotEvtHandle;
 
 struct PAF_ASOT_Params;
 struct PAF_ASOT_Patchs;
@@ -67,43 +78,23 @@ struct PAF_ASOT_Config;
 typedef struct PAF_ASOT_Fxns {
     Int (*initPhase[8]) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
     Int (*initFrame0) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
-    Int (*initFrame1) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);
-    //Int (*passProcessing) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
-    //Int (*passProcessingCopy) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
-    //Int (*autoProcessing) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, ALG_Handle);
-    
-    //Int (*decodeProcessing) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);    
+    Int (*initFrame1) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);    
     Int (*decodeProcessing) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);    
-    
-    //Int (*decodeCommand) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
     Int (*encodeCommand) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
-    
-    //Int (*decodeInit) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
     Int (*decodeInit) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
-    
-    //Int (*decodeInfo) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
-    Int (*decodeInfo1) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);
-    Int (*decodeInfo2) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);
-    //Int (*decodeCont) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, ALG_Handle *, Int, Int);
-    //Int (*decodeDecode) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int, Int);
-    Int (*decodeStream) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);
-    Int (*decodeEncode) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);
-
-    //Int (*decodeFinalTest) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);    
-    Int (*decodeFinalTest) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);    
-
-    Int (*decodeComplete) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, ALG_Handle *, Int, Int);
-    Int (*selectDevices) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
-    //Int (*sourceDecode) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
+    Int (*decodeInfo1) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
+    Int (*decodeInfo2) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
+    Int (*decodeStream) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
+    Int (*decodeEncode) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
+    Int (*decodeFinalTest) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);    
+    Int (*decodeComplete) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
+    Int (*selectDevices) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Bool *);
     Int (*startOutput) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
     Int (*stopOutput) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
     Int (*setCheckRateX) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
     Int (*streamChainFunction) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int, Int);
     Int (*deviceAllocate) (SIO_Handle *, int, int, int, Ptr);
     Int (*deviceSelect) (SIO_Handle *, int, int, Ptr);
-    //Int (*computeFrameLength) (Int, Int, Int);
-    //Int (*updateInputStatus) (SIO_Handle, PAF_InpBufStatus *, PAF_InpBufConfig *);
-    //Int (*copy) (Uns, PAF_InpBufConfig *, Uns, PAF_OutBufConfig *);
 
     // For RAM_report
     Void (*headerPrint)();
@@ -185,16 +176,19 @@ typedef struct PAF_ASOT_Params {
 
 // Audio Stream Output Task (ASOT) patchs
 typedef struct PAF_ASOT_Patchs {
-    //const PAF_SIO_ParamsN * devinp;
     const PAF_SIO_ParamsN * devout;
-    //const PAF_ASP_LinkInit * const (*i_decLinkInit);
     const PAF_ASP_LinkInit * const (*i_aspLinkInit)[GEARS];
     const PAF_ASP_LinkInit * const (*i_encLinkInit);
 } PAF_ASOT_Patchs;
 
 typedef struct PAF_AST_OutIO {
-    ioPhyHandle_t        hIoPhy;     /* handle to I/O physical layer */
-    ioBuffHandle_t       hIoBuff;    /* handle to I/O buffer management */
+    ioPhyHandle_t        hIoPhy;        // handle to I/O physical layer
+    ioBuffHandle_t       hIoBuff;       // handle to I/O buffer management
+    Ptr                  hMcaspChan;    // handle to McASP LLD channel for output
+    mcaspLLDconfig       *pLldCfg;      // pointer to McASP LLD configuration
+    
+    uint32_t             phyXferSize;
+    uint32_t             stride;
 
     void     *mcaspTxBuf1;
     void     *mcaspTxBuf2;
@@ -206,6 +200,16 @@ 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 ioBuffBuf2AllocCnt;        // Output buffer2 allocation (split buffer on buffer wrap) count
+    uint32_t errIoBuffOvrCnt;           // Output IO overflow count
+    uint32_t errIoBuffUndCnt;           // Output IO underflow count
+    float    rateX;                     // Input/Output clock ratio
+    
     // debugging counters
     uint32_t num_xfers;
 
@@ -213,245 +217,16 @@ typedef struct PAF_AST_OutIO {
 
 // Audio Stream Input Task (ASOT) configuration
 typedef struct PAF_ASOT_Config {
-    Task_Handle taskHandle;             // ASOT handle
-    ACP_Handle acp;                     // ASOT local ACP handle
-    Int8 cbDrainedFlag[DECODEN_MAX];    // CB drained flags
-    PAF_ASPM_Config *pAspmCfg;          // ASIT/ASOT shared configuration
-    PAF_AST_Config *pAstCfg;            // ASIT/ASOT/ASDT shared configuration
-    PAF_AST_IoOut  *pIoOut;
+    Task_Handle     taskHandle;                 // ASOT task handle
+    uint_least16_t  state;                      // ASOT state
+    ACP_Handle      acp;                        // ASOT ACP handle
+    Int8            cbDrainedFlag[DECODEN_MAX]; // CB drained flags
+    PAF_ASPM_Config *pAspmCfg;                  // ASIT/ASOT shared configuration
+    PAF_AST_Config  *pAstCfg;                   // ASIT/ASOT/ASDT shared configuration
+    PAF_AST_IoOut   *pIoOut;                    // ASOT IO configuration
 } PAF_ASOT_Config;
 
-
-//   Purpose:   Audio Stream Outpu Task Function for initialization of data pointers
-//              by allocation of memory.
-Int 
-PAF_ASOT_initPhaseMalloc(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-    
-//   Purpose:   Audio Stream Output Task Function for initialization of data values
-//              from parameters.
-Int
-PAF_ASOT_initPhaseConfig(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-
-//   Purpose:   Audio Stream Output Task Function for initialization of ACP by
-//              instantiation of the algorithm.
-Int
-PAF_ASOT_initPhaseAcpAlg(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-
-//   (***) FL: ASIT/ASOT currently consider common memory independently.
-//             Should simultaneously consider all algs in ASIT/ASOT.
-//   Purpose:   Audio Stream Output Task Function for allocation of common memory.
-Int
-PAF_ASOT_initPhaseCommon(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-
-//   Purpose:   Audio Stream Output Task Function for initialization of ASP algorithms.
-Int
-PAF_ASOT_initPhaseAspAlg(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-
-//   Purpose:   Audio Stream Output Task Function for initialization of data values
-//              from parameters for Algorithm Keys.
-Int
-PAF_ASOT_initPhaseAlgKey(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-
-//   Purpose:   Audio Stream Output Task Function for initialization of Input Devices.
-Int
-PAF_ASOT_initPhaseDevice(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-
-//   Purpose:   Audio Stream Output Task Function for initialization of the Audio
-//              Frame(s) by memory allocation and loading of data pointers
-//              and values.
-Int
-PAF_ASOT_initFrame0(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg, 
-    Int z
-);
-
-//   Purpose:   Audio Stream Task Function for initialization or reinitiali-
-//              zation of the Audio Frame(s) by loading of data values of a
-//              time-varying nature.
-Int
-PAF_ASOT_initFrame1(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg, 
-    Int z, 
-    Int apply
-);
-
-//   Purpose:   Audio Stream Output Task Function for selecting the devices used
-//              for output.
-Int
-PAF_ASOT_selectDevices(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-
-//   Purpose:   Audio Stream Output Task Function for processing audio data.
-//
-Int
-PAF_ASOT_decodeProcessing(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg 
-);
-
-//   Purpose:   Decoding Function for processing Encode Commands.
-Int
-PAF_ASOT_encodeCommand(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-
-//   Purpose:   Decoding Function for reinitializing the decoding process.
-Int
-PAF_ASOT_decodeInit(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-
-//   Purpose:   Decoding Function for processing information in a manner that
-//              is unique to initial frames of input data.
-Int
-PAF_ASOT_decodeInfo(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg, 
-    Int frame, 
-    Int block
-);
-
-//   Purpose:   Decoding Function for processing information in a manner that
-//              is unique to initial frames of input data.
-Int
-PAF_ASOT_decodeInfo1(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg, 
-    Int frame, 
-    Int block
-);
-
-//   Purpose:   Decoding Function for processing information in a manner that
-//              is unique to frames of input data other than the initial one.
-Int
-PAF_ASOT_decodeInfo2(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg, 
-    Int frame, 
-    Int block
-);
-
-//   Purpose:   Decoding Function for processing of audio frame data by the
-//              ASP Algorithms.
-Int
-PAF_ASOT_decodeStream(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg, 
-    Int frame, 
-    Int block
-);
-
-//   Purpose:   Decoding Function for processing of audio frame data by the
-//              Encode Algorithm.
-Int
-PAF_ASOT_decodeEncode(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg, 
-    Int frame, 
-    Int block
-);
-
-//   Purpose:   Decoding Function for terminating the decoding process.
-Int
-PAF_ASOT_decodeComplete(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg, 
-    ALG_Handle decAlg[], 
-    Int frame, 
-    Int block
-);
-
-//   Purpose:   Decoding Function for initiating output.
-Int
-PAF_ASOT_startOutput(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-
-//   Purpose:   Decoding Function for terminating output.
-Int
-PAF_ASOT_stopOutput(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg
-);
-
-//   Purpose:   Decoding Function for re-initiating output.
-Int
-PAF_ASOT_setCheckRateX(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg, 
-    Int check
-);
-
-//   Purpose:   Common Function for processing algorithm chains.
-Int
-PAF_ASOT_streamChainFunction(
-    const PAF_ASOT_Params *pP, 
-    const PAF_ASOT_Patchs *pQ, 
-    PAF_ASOT_Config *pAsotCfg, 
-    Int iChainFrameFxns, 
-    Int abortOnError, 
-    Int logArg
-);
-
-//   Purpose:   Decoding Function for determining whether processing of the
-//              current stream is complete.
-Int
-PAF_ASOT_decodeFinalTest(
-    const struct PAF_ASOT_Params *pP, 
-    const struct PAF_ASOT_Patchs *pQ, 
-    struct PAF_ASOT_Config *pAsotCfg, 
-    Int frame, 
-    Int block
-);
+// ASOT configuration
+extern PAF_ASOT_Config gPAF_ASOT_config;
 
 #endif /* _ASOP_H_ */