summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cb73a8f)
raw | patch | inline | side by side (parent: cb73a8f)
author | Frank Livingston <frank-livingston@ti.com> | |
Fri, 30 Jun 2017 21:06:33 +0000 (16:06 -0500) | ||
committer | Frank Livingston <frank-livingston@ti.com> | |
Fri, 30 Jun 2017 21:06:33 +0000 (16:06 -0500) |
1) Remove CB drain indicator from cbReadAf().
2) Add check CB drain function.
3) Add # CBs to CB control.
4) Move ARM/DSP code w/ common API to common source file (cbCtlInit()).
2) Add check CB drain function.
3) Add # CBs to CB control.
4) Move ARM/DSP code w/ common API to common source file (cbCtlInit()).
index 193e04fc926dad70b151ac9bebcb2136dba97aa3..15cf1342e3c3996cf7dd652595c2e28fefed17d5 100644 (file)
#include "aspDecOpCircBuf_common.h"
+// Initialize circular buffer control
+Int cbCtlInit(
+ PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
+ Int8 numDecOpCb, // number of circular buffers
+ PAF_AST_DecOpCircBuf **pXDecOpCb // address of decoder output circular buffer base pointer
+)
+{
+#ifdef _TMS320C6X
+ GateMP_Params gateParams;
+ GateMP_Handle gateHandle;
+
+ GateMP_Params_init(&gateParams);
+ gateParams.localProtect = GateMP_LocalProtect_THREAD;
+ gateParams.remoteProtect = GateMP_RemoteProtect_SYSTEM;
+ gateParams.name = ASP_DECODE_CB_GATE_NAME;
+ gateParams.regionId = ASP_DECODE_CB_GATE_REGION_ID;
+ gateHandle = GateMP_create(&gateParams);
+ if (gateHandle != NULL)
+ {
+ pCbCtl->gateHandle = gateHandle;
+ }
+ else
+ {
+ pCbCtl->gateHandle = NULL;
+ return ASP_DECOP_CB_CTL_INIT_INV_GATE;
+ }
+
+ pCbCtl->numDecOpCb = numDecOpCb; // init number of circular buffers
+ pCbCtl->pXDecOpCb = pXDecOpCb; // init base address of circular buffers
+
+ return ASP_DECOP_CB_SOK;
+
+#elif defined(ARMCOMPILE)
+ GateMP_Handle gateHandle;
+ Int status;
+
+ do {
+ status = GateMP_open(ASP_DECODE_CB_GATE_NAME, &gateHandle);
+ } while (status == GateMP_E_NOTFOUND);
+ if (status == GateMP_S_SUCCESS)
+ {
+ pCbCtl->gateHandle = gateHandle;
+ }
+ else
+ {
+ pCbCtl->gateHandle = NULL;
+ return ASP_DECOP_CB_CTL_INIT_INV_GATE;
+ }
+
+ pCbCtl->numDecOpCb = numDecOpCb; // init number of circular buffers
+ pCbCtl->pXDecOpCb = pXDecOpCb; // init base address of circular buffers
+
+ return ASP_DECOP_CB_SOK;
+
+#else
+ #error "Unsupported platform"
+
+#endif
+}
+
// Reset circular buffer
Int cbReset(
PAF_AST_DecOpCircBufCtl *pCbCtl,
index a5fb33d660f7f520dc300212ed6b8346fd3fb78c..bdaa50ef975fdefb4370cb82569de44612904e47 100644 (file)
typedef struct PAF_AST_DecOpCircBufCtl
{
GateMP_Handle gateHandle; // circular buffer gate handle
+ Int8 numDecOpCb; // number of circular buffers
PAF_AST_DecOpCircBuf **pXDecOpCb; // address of decoder output circular buffer base pointer
} PAF_AST_DecOpCircBufCtl;
// Initialize circular buffer control
Int cbCtlInit(
PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
+ Int8 numDecOpCb, // number of circular buffers
PAF_AST_DecOpCircBuf **pXDecOpCb // address of decoder output circular buffer base pointer
);
diff --git a/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c b/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c
index 36fdccc4ee65594472eab6e6dc5feab13221dc6d..806f1dbf57c7f2bf5d6445a8c69fdcd5350df188 100644 (file)
#include "evmc66x_gpio_dbg.h" // Debug
+#if 0
// Initialize circular buffer control
Int cbCtlInit(
PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
}
else
{
- pCbCtl->gateHandle = NULL;
+ pCbCtl->gateHandle = NULL;
return ASP_DECOP_CB_CTL_INIT_INV_GATE;
}
- pCbCtl->pXDecOpCb = pXDecOpCb;
+ pCbCtl->numCb = numCb; // init number of circular buffers
+ pCbCtl->pXDecOpCb = pXDecOpCb; // init base address of circular buffers
return ASP_DECOP_CB_SOK;
-
}
+#endif
//Int8 gCbWriteStartCnt=0; // debug
diff --git a/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c b/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c
index d40165830109863a82893321c12b0f2f727d6383..040b8ace19a8612887b5e18aef6ca1a663a9282b 100644 (file)
PAF_AudioFrame *pAfRd // audio frame into which to read
);
+#if 0
// Initialize circular buffer control
Int cbCtlInit(
PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
+ Int8 numCb, // number of circular buffers
PAF_AST_DecOpCircBuf **pXDecOpCb // address of decoder output circular buffer base pointer
)
{
return ASP_DECOP_CB_CTL_INIT_INV_GATE;
}
- pCbCtl->pXDecOpCb = pXDecOpCb;
-
- return ASP_DECOP_CB_SOK;
+ pCbCtl->numCb = numCb; // init number of circular buffers
+ pCbCtl->pXDecOpCb = pXDecOpCb; // init base address of circular buffers
+ return ASP_DECOP_CB_SOK;
}
+#endif
// Initialize circular buffer
Int cbInit(
Int cbReadAf(
PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
Int8 cbIdx, // decoder output circular buffer index
- PAF_AudioFrame *pAfRd, // audio frame into which to read
- Int8 *pCbDrained // pointer to boolean, indicates if circular buffer drained: FALSE - not drained, TRUE - drained
+ PAF_AudioFrame *pAfRd // audio frame into which to read
)
{
IArg key;
Int16 j;
Int8 numMetadata = 0;
- *pCbDrained = 0; // initialize drained indicator
-
// Get gate handle
gateHandle = pCbCtl->gateHandle;
// Enter gate
if (pCb->numAfCb <= 0)
{
pCb->drainFlag = 0;
- *pCbDrained = 1; // update drained indicator
}
}
pAfRd->bsMetadata_offset = 0; /* offset into audio frame for change in bsMetadata_type field */
}
+// Check circular buffer drain state
+Int cbCheckDrainState(
+ PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
+ Int8 cbIdx, // decoder output circular buffer index, or indicator combined drain state desired
+ Int8 *pDrainedFlag // output drain state indicator (combined or for selected circular buffer)
+)
+{
+ IArg key;
+ GateMP_Handle gateHandle;
+ PAF_AST_DecOpCircBuf *pCb;
+ Int8 drainedFlag;
+ Int8 i;
+
+ // Get gate handle
+ gateHandle = pCbCtl->gateHandle;
+ // Enter gate
+ key = GateMP_enter(gateHandle);
+
+ if (cbIdx != ASP_DECOP_CHECK_DRAINSTATE_ALL)
+ {
+ //
+ // Check drain state for selected circular buffer
+ //
+
+ // Get circular buffer base pointer
+ pCb = &((*pCbCtl->pXDecOpCb)[cbIdx]);
+
+ // Invalidate circular buffer configuration
+ Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+ Cache_wait();
+
+ drainedFlag = !pCb->writerActiveFlag && !pCb->drainFlag;
+ }
+ else
+ {
+ //
+ // Check combined drain state for all circular buffers.
+ // Combined drain state is logical AND of drain state for all circular buffers.
+ //
+
+ drainedFlag = 1; // init combined drained flag to TRUE
+ for (i = 0; i < pCbCtl->numDecOpCb; i++)
+ {
+ // Get circular buffer base pointer
+ pCb = &((*pCbCtl->pXDecOpCb)[i]);
+
+ // Invalidate circular buffer configuration
+ Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+ Cache_wait();
+
+ // Update combined drain state
+ drainedFlag = drainedFlag && (!pCb->writerActiveFlag && !pCb->drainFlag);
+ }
+ }
+
+ *pDrainedFlag = drainedFlag;
+
+ // Leave the gate
+ GateMP_leave(gateHandle, key);
+
+ return ASP_DECOP_CB_SOK;
+}
diff --git a/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h b/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h
index 81104a5cda131e3958450319df99460b8405ad66..e2c39025d91f9a45df27144314d161c7f812224f 100644 (file)
#define ASP_DECOP_CB_READ_UNDERFLOW ( ASP_DECOP_CB_ERR_START-2 ) // error: read underflow
#define ASP_DECOP_CB_READ_INVSTATE ( ASP_DECOP_CB_ERR_START-3 ) // error: circular buffer invalid state on read
+#define ASP_DECOP_CHECK_DRAINSTATE_ALL ( -1 ) // check circular buffer combined drain state
+
// Initialize circular buffer
Int cbInit(
Int cbReadAf(
PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
Int8 cbIdx, // decoder output circular buffer index
- PAF_AudioFrame *pAfRd, // audio frame into which to read
- Int8 *pCbDrained // pointer to boolean, indicates if circular buffer drained: FALSE - not drained, TRUE - drained
+ PAF_AudioFrame *pAfRd // audio frame into which to read
);
+// Check circular buffer drain state
+Int cbCheckDrainState(
+ PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
+ Int8 cbIdx, // decoder output circular buffer index, or indicator combined drain state desired
+ Int8 *pDrainedFlag // output drain state indicator (combined or for selected circular buffer)
+);
+
+
#endif /* _ASP_DECOP_CB_MASTER_H_ */