summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 23e7a45)
raw | patch | inline | side by side (parent: 23e7a45)
author | Jianzhong Xu <a0869574@ti.com> | |
Thu, 26 Apr 2018 22:00:44 +0000 (18:00 -0400) | ||
committer | Jianzhong Xu <a0869574@ti.com> | |
Thu, 26 Apr 2018 22:00:44 +0000 (18:00 -0400) |
diff --git a/pasdk/test_dsp/framework/audioStreamInpDec.c b/pasdk/test_dsp/framework/audioStreamInpDec.c
index e98dceb6d8190a67fd270cc486c4eb183052f26e..d62af3bda84d845fd722790d9ac77cd6fb12a2c0 100644 (file)
DEC_STATE_INFO_SND,
DEC_STATE_INFO_ACK_DECODE_SND,
DEC_STATE_DECODE_ACK,
+ DEC_STATE_INFO,
+ DEC_STATE_DECODE,
DEC_STATE_QUIT
};
+enum {
+ DEC_MSG_INFO,
+ DEC_MSG_DECODE
+};
+
static Int decodeInit(const PAF_ASIT_Params *pP, PAF_ASIT_Config *pAsitCfg,
Int sourceSelect);
PAF_ASIT_Config *pAsitCfg);
static Int decDecodeFinalTest(const PAF_ASIT_Params *pP, const PAF_ASIT_Patchs *pQ,
PAF_ASIT_Config *pAsitCfg);
+static void decGetStreamInfo(PAF_AST_IoInp *pInp, asipDecProc_t *pDec);
+static void decUpdateInpBufConfig(PAF_AST_Config *pAstCfg, asipDecProc_t *pDec);
+static Int decIbConfigQueNotEmpty(asipDecProc_t *pDec);
+
Int decCheckMajorAu(PAF_AST_Config *pAstCfg);
extern UInt32 gCbWrtAfErrCnt;
; // No error
}
+ 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.");
+ }
+
// It is possible to go through the FSM multiple times:
// - Multiple messages may be received, INPDATA and DECACK. In this case,
- // the FSM will process DECACK in state DEC_STATE_DECODE_ACK and then
+ // the FSM will process DECACK in state DEC_STATE_DECODE_ACK and then
// INPDATA in state DEC_STATE_INFO_SND.
- // - DECACK is received after INPDATA. In this case, after DECACK is
- // processed, we will spoof decMsg with INPDATA so that FSM will run
+ // - DECACK is received after INPDATA. In this case, after DECACK is
+ // processed, we will spoof decMsg with INPDATA so that FSM will run
// again and process INPDATA in DEC_STATE_INFO_SND.
do {
switch(pDec->state)
decMsg &= ~DEC_MSGMSK_INPDATA; // clear bit mask
// Prepare and send INFO to decoder
+ decUpdateInpBufConfig(pAsitCfg->pAstCfg, pDec);
+
decErr = decInfoSnd(pP, pQ, pAsitCfg);
if(decErr == DEC_NO_ERR) {
pDec->state = DEC_STATE_INFO_ACK_DECODE_SND;
// decErr = DEC_ERR_WRONG_MSG;
//}
//else {
-
+
if (decMsg & DEC_MSGMSK_RXACK) {
decMsg &= ~DEC_MSGMSK_RXACK; // clear the bit mask
// Don't start decode until major access unit is found.
if(!pDec->majorAuFound) {
// Do we want to still check major AU after it is found?
- // In old code, it was not checked again after it was found.
- pDec->majorAuFound = decCheckMajorAu(pAsitCfg->pAstCfg);
+ // In old code, it was not checked again after it was found.
+ pDec->majorAuFound = decCheckMajorAu(pAsitCfg->pAstCfg);
}
-
+
if(pDec->majorAuFound) {
// Major access unit is found. Send message to decoder to decode now.
decErr = decDecodeSnd(pP, pQ, pAsitCfg);
if(decErr == DEC_NO_ERR) {
pDec->state = DEC_STATE_DECODE_ACK;
- // Initialize decodeAckDelayed to FALSE - normally
- // DECODE ACK comes after INPDATA.
- pDec->decodeAckDelayed = FALSE;
-
- TRACE_VERBOSE0("decDecodeFsm: DEC_STATE_INFO_ACK_DECODE_SND done and going to DEC_STATE_DECODE_ACK.");
+ TRACE_VERBOSE0("decDecodeFsm: DEC_STATE_INFO_ACK_DECODE_SND done and major AU found. Going to DEC_STATE_DECODE_ACK.");
}
}
else {
// No major access unit - go back to INFO.
pDec->frame++;
pDec->state = DEC_STATE_INFO_SND;
- TRACE_VERBOSE0("decDecodeFsm: DEC_STATE_INFO_ACK_DECODE_SND done and going to DEC_STATE_INFO_SND.");
+ TRACE_VERBOSE0("decDecodeFsm: DEC_STATE_INFO_ACK_DECODE_SND done and no major AU. Going to DEC_STATE_INFO_SND.");
}
}
}
-
- if (decMsg != 0) {
+ else if (decMsg & DEC_MSGMSK_INPDATA) {
+ // Ignore INPDATA message since IB info is already queued
+ decMsg &= ~DEC_MSGMSK_INPDATA;
+ }
+ else {
decErr = DEC_ERR_WRONG_MSG;
- }
+ }
break;
case DEC_STATE_DECODE_ACK:
// Two different messages may be received: DECACK (decode acknowledgment)
// or INPDATA (input data ready).
- //if(decMsg & DEC_MSGMSK_DECACK) {
- // decMsg &= ~DEC_MSGMSK_DECACK;
-
if (decMsg & DEC_MSGMSK_RXACK)
{
decMsg &= ~DEC_MSGMSK_RXACK; // clear the bit mask
-
+
// Process DECODE ACK from decoder
decErr = decDecodeAck(pP, pQ, pAsitCfg);
if(decErr == DEC_NO_ERR) {
pDec->state = DEC_STATE_INFO_SND;
TRACE_VERBOSE0("decDecodeFsm: DEC_STATE_DECODE_ACK done and going to DEC_STATE_INFO_SND.");
- // Check if DECACK comes late (after INPDATA)
- if(pDec->decodeAckDelayed) {
- pDec->decodeAckDelayed = FALSE;
-
+ // Check if IB config queue is empty or not
+ if(decIbConfigQueNotEmpty(pDec)) {
// Need to prepare and send INFO to decoder immediately.
// Because INPUT_DATA message is already received,
- // we're just spoofing the message with INPDATA to
- // run the FSM one more time.
+ // we're just spoofing the message with INPDATA to
+ // run the FSM one more time.
decMsg |= DEC_MSGMSK_INPDATA;
- TRACE_VERBOSE0("decDecodeFsm: Info was delayed.");
+ TRACE_VERBOSE0("decDecodeFsm: DECODE_ACK was late and INFO_SND was delayed.");
}
}
}
}
- // If both INPDATA and RXACK are received, INPDATA message will be
- // processed in next iteration, in state DEC_STATE_INFO_SND.
else if (decMsg & DEC_MSGMSK_INPDATA) {
- // If we're here, it means decode acknowledgment from decoder
- // is delayed, i.e., a new frame of input data is ready before
- // current frame decoding is finished.
+ // Ignore INPDATA message since IB info is already queued
decMsg &= ~DEC_MSGMSK_INPDATA;
-
- // Do nothing but set a flag to postpone action.
- pDec->decodeAckDelayed = TRUE;
-
- TRACE_VERBOSE0("decDecodeFsm: receiving INPDATA in DEC_STATE_DECODE_ACK");
}
else {
decErr = DEC_ERR_WRONG_MSG;
} /* switch */
// Loop through the FSM one more time if:
- // - there are more real or spoofed messages to process,
+ // - there are more real or spoofed messages to process,
// - and there is no error.
if((decMsg==0) || (decErr!=DEC_NO_ERR)) {
decDone = TRUE;
return decErr;
} /* decDecodeFsm */
+void decGetStreamInfo(PAF_AST_IoInp *pInp, asipDecProc_t *pDec)
+{
+ PAF_InpBufConfig *pBufConfig;
+ ioDataCtl_t ioDataCtl;
+
+ /* Get information for reading input data */
+ ioDataCtl.code = IODATA_CTL_GET_INPBUFFINFO;
+ ioDataControl(pInp->hIoData, &ioDataCtl);
+
+ if(ioDataCtl.param.dataReadInfo.frameSize != pInp->phyXferSize) {
+ // Fatal error!
+ TRACE_VERBOSE0("TaskAsip: error in updating I/O");
+ SW_BREAKPOINT;
+ }
+
+ pBufConfig = &(pDec->inpBufConfigQueue[pDec->wridx]);
+
+ pBufConfig->base.pVoid = ioDataCtl.param.dataReadInfo.buffBase;
+ pBufConfig->sizeofBuffer = ioDataCtl.param.dataReadInfo.buffSize;
+ pBufConfig->pntr.pSmInt = ioDataCtl.param.dataReadInfo.startAddress;
+
+ TRACE_TERSE2("Frame start address: 0x%x., preamble: 0x%x",
+ (UInt)ioDataCtl.param.dataReadInfo.startAddress,
+ *(UInt *)ioDataCtl.param.dataReadInfo.startAddress);
+
+ pDec->wridx++;
+ if(pDec->wridx == DEC_INPBUF_CONFIG_QUEUE_SIZE) {
+ pDec->wridx = 0;
+ }
+}
+
+void decUpdateInpBufConfig(PAF_AST_Config *pAstCfg, asipDecProc_t *pDec)
+{
+ PAF_InpBufConfig *pBufConfig = &(pAstCfg->xInp[pAstCfg->masterDec].inpBufConfig);
+
+ pBufConfig->base.pVoid = pDec->inpBufConfigQueue[pDec->rdidx].base.pVoid;
+ pBufConfig->sizeofBuffer = pDec->inpBufConfigQueue[pDec->rdidx].sizeofBuffer;
+ pBufConfig->pntr.pSmInt = pDec->inpBufConfigQueue[pDec->rdidx].pntr.pSmInt;
+
+ pDec->rdidx++;
+ if(pDec->rdidx == DEC_INPBUF_CONFIG_QUEUE_SIZE) {
+ pDec->rdidx = 0;
+ }
+}
+
+Int decIbConfigQueNotEmpty(asipDecProc_t *pDec)
+{
+ if(pDec->rdidx != pDec->wridx) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
Int decErrorCheck(const PAF_ASIT_Params *pP,
const PAF_ASIT_Patchs *pQ,
pAsitCfg->inpDec.frame = 0;
pAsitCfg->inpDec.block = 0;
pAsitCfg->inpDec.state = DEC_STATE_INFO_SND;
+ //pAsitCfg->inpDec.state = DEC_STATE_INFO;
+ pAsitCfg->inpDec.rdidx = 0;
+ pAsitCfg->inpDec.wridx = 0;
return ASIP_NO_ERR;
} /* decDecodeInit */
diff --git a/pasdk/test_dsp/framework/audioStreamInpProc.h b/pasdk/test_dsp/framework/audioStreamInpProc.h
index 1a6e373fd1d0713fba53a23a8eec861a09eaeab2..85aec193c491aa739aac81b06eeebf41c81b9771 100644 (file)
bool firstTimeInit;
} PAF_AST_IoInp;
+#define DEC_INPBUF_CONFIG_QUEUE_SIZE 4
// Decoder structure
typedef struct asipDecProc_s {
Int state;
Int majorAuFound;
Int initDone;
Int decodeAckDelayed;
+
+ PAF_InpBufConfig inpBufConfigQueue[DEC_INPBUF_CONFIG_QUEUE_SIZE];
+ Int rdidx;
+ Int wridx;
} asipDecProc_t;
// Audio Stream Input Task (ASIT) configuration
diff --git a/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c b/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c
index 6a88397e5b092e3396db46b6844256e237af0c72..15cdb70b46e96ea2b06b23b67922816f77217e1c 100644 (file)
pInp->numFrameReceived += 1; // for debugging
// Communicate input stream information to decoder through input
- // buffer configuration
- asitUpdateInpBufConfig(pAsitCfg->pAstCfg, pInp);
+ // buffer configuration -- this was moved inside decDecodeFsm
+ //asitUpdateInpBufConfig(pAsitCfg->pAstCfg, pInp);
// Start next transfer
asitPhyTransferStart(pInp);