PASDK-277: Added capture for CB R/W operations.
authorChitresh Gupta <chitresh.g@pathpartnertech.com>
Mon, 29 May 2017 15:10:43 +0000 (20:40 +0530)
committerChitresh Gupta <chitresh.g@pathpartnertech.com>
Mon, 29 May 2017 15:10:43 +0000 (20:40 +0530)
pasdk/common/aspDecOpCircBuf_common.h
pasdk/test_arm/framework/aspDecOpCircBuf_slave.c
pasdk/test_dsp/framework/aspDecOpCircBuf_master.c
pasdk/test_dsp/framework/audioStreamInpProc.c

index e78111684fc9be9115c9cf863f8b39d30ed9dd6e..85ab8a73a5e4f0ad67c121b5f0ede61fa427d576 100644 (file)
@@ -40,6 +40,16 @@ All rights reserved.
 #include <ti/ipc/GateMP.h>
 #include "paftyp.h"
 #include "pafdec.h"
+
+//#define CB_RW_OP_CAP_PP
+
+#ifdef CB_RW_OP_CAP_PP
+#define CB_OP_NONE        0
+#define CB_OP_W           1     // ARM write
+#define CB_OP_R           2     // DSP read
+#define CB_OP_COUNT_MAX   10000
+#endif
+
 #define ASP_DECOP_CB_SOK                    ( 0 )       // ok
 #define ASP_DECOP_CB_CTL_INIT_INV_GATE      ( ASP_DECOP_CB_SOK-1 )  // error: invalid gate handle
 #define ASP_DECOP_CB_ERR_START              ( ASP_DECOP_CB_CTL_INIT_INV_GATE )
@@ -101,6 +111,14 @@ typedef struct PAF_AST_DecOpCircBuf
     Int8 maxAFChanNum;      // maximum number of audio data channels in audio frame
     Int16 maxAFSampCount;   // maximum number of sample counts in audio frame
     PAF_AudioFrame lastAf;  // used to store the last valid read out audio frame info to generate mute frame
+    #ifdef CB_RW_OP_CAP_PP
+    UInt32 *cb_samples_op;  // should be in shared memory, preferred NON cache
+    UInt8 *cb_op_owner;     // should be in shared memory, preferred NON cache
+    UInt8 *cb_afRdIdx;      // should be in shared memory, preferred NON cache
+    UInt8 *cb_afWrtIdx;     // should be in shared memory, preferred NON cache
+    UInt8 *cb_numAfCb;      // should be in shared memory, preferred NON cache
+    UInt32 cb_opCnt;        // range (0 - CB_OP_COUNT_MAX)
+    #endif
 } PAF_AST_DecOpCircBuf;
 
 // Decoder output circular buffer control
index 50b2d861d04d4aecaf53d169985e421bea9728f3..f07e65d5db010974a1559ec78db67d4e5a04f852 100644 (file)
@@ -314,6 +314,22 @@ Int cbWriteAf(
             }
         }
 
+        #ifdef CB_RW_OP_CAP_PP
+        if (pCb->cb_opCnt < CB_OP_COUNT_MAX)
+        {
+            if ((pCb->cb_samples_op != NULL) && (pCb->cb_op_owner != NULL))
+            {
+                // log sample count
+                pCb->cb_samples_op[pCb->cb_opCnt] = pAfWrt->sampleCount;
+                pCb->cb_op_owner[pCb->cb_opCnt] = CB_OP_W;
+                // log idxs
+                pCb->cb_afRdIdx[pCb->cb_opCnt] = pCb->afRdIdx;
+                pCb->cb_afWrtIdx[pCb->cb_opCnt] = pCb->afWrtIdx;
+                pCb->cb_numAfCb[pCb->cb_opCnt] = pCb->numAfCb; // numAfCb might not be pointing to this instance
+                pCb->cb_opCnt++;
+            }
+        }
+        #endif
 
         // prepare metadata buffer pointers according to the metadata and buffer sizes
         for (i=0; i < pAfWrt->numPrivateMetadata; i++)
index bc546a9b957f1291a5ad36a79e37cc3794a0d386..f726fc3b076e57e69c932ba4811c5d9dd27b86fd 100644 (file)
@@ -47,6 +47,16 @@ All rights reserved.
 
 #include "dbgBenchmark.h" // PCM high-sampling rate + SRC + CAR benchmarking
 
+#ifdef CB_RW_OP_CAP_PP
+// Global variables
+Uint32 *gCB_samples_op = NULL;
+Uint8 *gCB_op_owner = NULL;
+Uint32 *gCB_opCnt = 0;
+Uint8 *gCB_afRdIdx = NULL;
+Uint8 *gCB_afWrtIdx = NULL;
+Uint8 *gCB_numAfCb = NULL;
+#endif
+
 #define DEF_SOURCE_SEL          ( PAF_SOURCE_PCM ) // default source select
 #define DEF_DEC_OP_FRAME_LEN    ( PAF_SYS_FRAMELENGTH )   // ( 256 )     // default decoder output frame length
 #define DEF_STR_FRAME_LEN       ( PAF_SYS_FRAMELENGTH )     // default stream frame length
@@ -189,6 +199,16 @@ Int cbInit(
     pCb->errUndCnt = 0;
     pCb->errOvrCnt = 0;
     
+    #ifdef CB_RW_OP_CAP_PP
+    // Get address in global variables
+    gCB_samples_op = pCb->cb_samples_op;
+    gCB_op_owner = pCb->cb_op_owner;
+    gCB_opCnt = &pCb->cb_opCnt;
+    gCB_afRdIdx = pCb->cb_afRdIdx;
+    gCB_afWrtIdx = pCb->cb_afWrtIdx;
+    gCB_numAfCb = pCb->cb_numAfCb;
+    #endif
+
     cbInitLastAfInfo(&pCb->lastAf);
 
     // (***) FL: revisit
@@ -589,6 +609,23 @@ Int cbReadAf(
             cbReadMuteWithLastAfInfo(pCb, pAfRd);
             //SW_BREAKPOINT; // FL: debug
             
+            #ifdef CB_RW_OP_CAP_PP
+            if (pCb->cb_opCnt < CB_OP_COUNT_MAX)
+            {
+                if ((pCb->cb_samples_op != NULL) && (pCb->cb_op_owner != NULL))
+                {
+                    // log sample count
+                    pCb->cb_samples_op[pCb->cb_opCnt] = 0;  // due to underflow
+                    pCb->cb_op_owner[pCb->cb_opCnt] = CB_OP_R;
+                    // log idxs
+                    pCb->cb_afRdIdx[pCb->cb_opCnt] = pCb->afRdIdx;
+                    pCb->cb_afWrtIdx[pCb->cb_opCnt] = pCb->afWrtIdx;
+                    pCb->cb_numAfCb[pCb->cb_opCnt] = pCb->numAfCb; // numAfCb might not be pointing to this instance
+                    pCb->cb_opCnt++;
+                }
+            }
+            #endif
+
             // Write back circular buffer configuration.
             Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
             Cache_wait();    
@@ -651,6 +688,23 @@ Int cbReadAf(
         pAfRd->numPrivateMetadata  = pAfCb->numPrivateMetadata;     /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
         pAfRd->bsMetadata_offset   = pAfCb->bsMetadata_offset;      /* offset into audio frame for change in bsMetadata_type field */
         
+        #ifdef CB_RW_OP_CAP_PP
+        if (pCb->cb_opCnt < CB_OP_COUNT_MAX)
+        {
+            if ((pCb->cb_samples_op != NULL) && (pCb->cb_op_owner != NULL))
+            {
+                // log sample count
+                pCb->cb_samples_op[pCb->cb_opCnt] = pAfRd->sampleCount;
+                pCb->cb_op_owner[pCb->cb_opCnt] = CB_OP_R;
+                // log idxs
+                pCb->cb_afRdIdx[pCb->cb_opCnt] = pCb->afRdIdx;
+                pCb->cb_afWrtIdx[pCb->cb_opCnt] = pCb->afWrtIdx;
+                pCb->cb_numAfCb[pCb->cb_opCnt] = pCb->numAfCb; // numAfCb might not be pointing to this instance
+                pCb->cb_opCnt++;
+            }
+        }
+        #endif
+
         // update Last Cb info as per actual stream
         pCb->lastAf.sampleCount = pCb->strFrameLen;
         pCb->lastAf.sampleRate = pAfCb->sampleRate;
index 64c0d07f063580ce96d47c89fac1f7773082aa50..967318046953b7f2c2a1c9676fa48eba510b60ba 100644 (file)
@@ -1595,6 +1595,45 @@ PAF_ASIT_initPhaseDecOpCircBuf(
             SW_BREAKPOINT;
         }
         pCb->metaBufEnd = pCb->metaBuf + (ASP_DECOP_CB_MAX_NUM_AF * PAF_MAX_PRIVATE_MD_SZ * PAF_MAX_NUM_PRIVATE_MD);
+
+
+        #ifdef CB_RW_OP_CAP_PP
+        // allocate debug buffer
+        if (!(pCb->cb_samples_op = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM, CB_OP_COUNT_MAX * sizeof(UInt32), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+
+        // allocate debug buffer
+        if (!(pCb->cb_op_owner = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM, CB_OP_COUNT_MAX * sizeof(UInt8), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+
+        // allocate debug buffer
+        if (!(pCb->cb_afRdIdx = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM, CB_OP_COUNT_MAX * sizeof(UInt8), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+
+        // allocate debug buffer
+        if (!(pCb->cb_afWrtIdx = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM, CB_OP_COUNT_MAX * sizeof(UInt8), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+
+        // allocate debug buffer
+        if (!(pCb->cb_numAfCb = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM, CB_OP_COUNT_MAX * sizeof(UInt8), 4, &eb)))
+        {
+            TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
+            SW_BREAKPOINT;
+        }
+        #endif
+
         // (***) FL: revisit, here PCM is hard-coded for 256 sample dec op frame length        
         // Initialize decoder output circular buffer for PCM
         errno = cbInit(pCb);