author | Frank Livingston <frank-livingston@ti.com> | |
Wed, 30 May 2018 21:16:42 +0000 (16:16 -0500) | ||
committer | Frank Livingston <frank-livingston@ti.com> | |
Wed, 30 May 2018 21:16:42 +0000 (16:16 -0500) |
diff --combined pasdk/test_dsp/framework/audioStreamInpProc.h
index 52304c785b5503c869e39d09d3f194293df3d1a0,3bfd7b3c231f634731225797e890c75eb614d517..0d8dbcde7fdff2fbec69b7438b16022ba04bceaf
enum {
ASIT_NO_ERR,
+ ASIT_AUTODET_TIME_OUT,
ASIT_ERR_IOBUFF_INIT,
ASIT_ERR_IODATA_INIT,
- ASIT_ERR_IOPYH_INIT,
+ ASIT_ERR_IOPHY_INIT,
ASIT_ERR_INPDATA_PROC,
ASIT_ERR_INPBUF_UNDERFLOW,
ASIT_ERR_AUTO_DETECION,
bool firstTimeInit;
} PAF_AST_IoInp;
-#define DEC_INPBUF_CONFIG_QUEUE_SIZE 4
+#define DEC_INPBUF_CONFIG_QUEUE_SIZE 8
// Decoder structure
typedef struct asipDecProc_s {
Int state;
diff --combined pasdk/test_dsp/framework/audioStreamInpProcNewIO.c
index b298da7ab77392e04931f62a441df9c0f1bb6ec2,61518a499f85d0e00e1da6e970f70e6149913858..f1d7dc41b699b0f3830cbb1069a512f9050821e5
// Input data is ready - perform source detection.
// New state will be decided inside the function
asitErr = asitSourceDetection(pP, pQ, pAsitCfg);
+
+ if(asitErr == ASIT_AUTODET_TIME_OUT) {
+ // Should restart if new interface is selected.
+ TRACE_VERBOSE0("TaskAsip: auto-detection time out.");
+ }
}
else {
//Error checking & debug
asitErr = asitInputDataProcess(pInp, &autoDetStatus);
if(asitErr != ASIT_NO_ERR) {
// Even though there is error, still need to start next transfer to
- // maintain McASP transfer.
+ // maintain McASP transfer, before returning error.
asitPhyTransferStart(pInp);
return asitErr;
// Mark input data read complete
ioDataReadComplete(pInp->hIoData);
+ if(autoDetStatus.syncTimeOut) {
+ return ASIT_AUTODET_TIME_OUT;
+ }
// Check if bitstream or PCM is detected
- if( autoDetStatus.syncState == IODATA_SYNC_BITSTREAM
+ else if( autoDetStatus.syncState == IODATA_SYNC_BITSTREAM
|| autoDetStatus.syncState == IODATA_SYNC_PCM) {
// Decide input source and inform decoder
asitErr = asitDecideSource(pAstCfg, pInp, &autoDetStatus);
if(autoDetStatus.syncState == IODATA_SYNC_BITSTREAM) {
// Input is bit stream: go to decoding
pInp->asipState = ASIT_DECODE_PROCESSING;
+ TRACE_VERBOSE0("Bit stream detected. Go to decoding. ");
}
else {
// Input is PCM: stop swapping data
// Go to transition state to switch to PCM
pInp->asipState = ASIT_PCM_TRANSITION;
+ TRACE_VERBOSE0("PCM stream detected. Go to PCM transition. ");
}
}
}
+ else {
+ // SYNC search ongoing, no action is needed
+ }
// Start next transfer
asitPhyTransferStart(pInp);
// Inform decoder to complete the decoding of previous frame - is this good?
pInp->sourceSelect = PAF_SOURCE_NONE;
- pInp->numFrameReceived = 0; // for debugging
+ pInp->numFrameReceived = 0; // for debugging
+ pInp->numPcmFrameReceived = 0; // for debugging
TRACE_TERSE0("asitDecodeProcessing: SYNC lost.");
#ifdef DEBUG_SKIP_DECODING
#endif
}
else {
- pInp->numFrameReceived += 1; // for debugging
+ if(autoDetStatus.syncState == IODATA_SYNC_PCM) {
+ pInp->numPcmFrameReceived += 1; // for debugging
+ }
+ else {
+ pInp->numFrameReceived += 1; // for debugging
+ }
// Communicate input stream information to decoder through input
// buffer configuration -- this was moved inside decDecodeFsm
else {
// Inform decoder to complete the decoding of previous frame - is this good?
pInp->sourceSelect = PAF_SOURCE_NONE;
- pInp->numFrameReceived = 0; // for debugging
+ pInp->numFrameReceived = 0; // for debugging
+ pInp->numPcmFrameReceived = 0; // for debugging
TRACE_TERSE1("asitDecodeProcessing: asitInputDataProcess error: %d", asitErr);
#ifdef DEBUG_SKIP_DECODING
ioBuffParams.size = pInpBuf->inpBufConfig.allocation / STRIDE_WORST_CASE
* STRIDE_WORST_CASE;
ioBuffParams.sync = IOBUFF_WRITE_SYNC;
- ioBuffParams.nominalDelay = INPUT_FRAME_SIZE_DEF;
+ ioBuffParams.nominalDelay = pInpIo->phyXferSize;
if (ioBuffInit(pInpIo->hIoBuff, &ioBuffParams) != IOBUFF_NOERR) {
return (ASIT_ERR_IOBUFF_INIT); // to remove magic number
}
ioPhyParams.mcaspChanHandle = pInpIo->hMcaspChan;
ioPhyParams.ioBuffOp = IOPHY_IOBUFFOP_WRITE;
if (ioPhyInit(pInpIo->hIoPhy, &ioPhyParams) != IOPHY_NOERR) {
- return (ASIT_ERR_IOPYH_INIT); // to remove magic number
+ return (ASIT_ERR_IOPHY_INIT); // to remove magic number
}
pInpIo->numPrimeXfers = NUM_PRIME_XFERS;
// pInp->swapData = TRUE;
pInp->pcmSwitchHangOver = INPUT_SWITCH_HANGOVER;
pDec->initDone = FALSE;
- pInp->numFrameReceived = 0;
+ pInp->numFrameReceived = 0; // for debugging
+ pInp->numPcmFrameReceived = 0; // for debugging
}
/*======================================================================================
if(mcasp_packet->arg == IOPHY_XFER_FINAL) {
//Semaphore_post(asipSemRx);
Event_post(gAsitEvtHandle, ASIT_EVTMSK_INPDATA);
+ //Log_info0("asipMcaspCallback: final packet - event posted.\n");
} else {
+ //Log_info0("asipMcaspCallback: intermediate packet.\n");
; // intermediate packet due to buffer wrapping around
}
}
System_abort("\nMcASP for input overruns! %d!\n");
}
else {
+ //TRACE_VERBOSE0("asitPhyTransferStart: submit a transfer");
ioPhyErr = ioPhyXferSubmit(pInpIo->hIoPhy);
//if(ioPhyXferSubmit(pInpIo->hIoPhy)==IOPHY_ERR_BUFF_OVERFLOW) {
if(ioPhyErr!=IOPHY_NOERR){
//
if (pInp->hMcaspChan != NULL) // non-NULL McASP LLD channel handle indicates there's an active interface
{
+ d10Initialized = 0; // indicate no Input selected
+
+ // check McASP LLD control API
+ mcaspControlChan(pInp->hMcaspChan, MCASP_CHAN_RESET, NULL); // Rx reset channel
+ //mcaspControlChan(pInp->hMcaspChan, MCASP_DEVICE_RESET, NULL); // Reset Tx/Rx channel
+
// Delete McASP LLD channel
status = mcaspDeleteChan(pInp->hMcaspChan);
if (status != Aud_EOK)
// Requested device is other than InNone
//
- //if (!d10Initialized)
- //{
- // FL: probably no harm in calling this for every new i/f request.
- // However, it can probably be moved to main() or sys init task.
- // Initialize McASP HW details
- //McaspDevice_init();
+ // Initialize Tx clock mux
+ D10_initClkMux((void *)pD10Params);
- // Initialize Tx clock mux
- D10_initClkMux((void *)pD10Params);
-
- // d10Initialized=1;
- //}
-
- if (!d10Initialized)
- {
- d10Initialized=1; // global flag indicating D10 init completed
- }
-
pReqLldCfg = (mcaspLLDconfig *)pD10Params->sio.pConfig;
if (pReqLldCfg->hMcaspChan == NULL)
{
pReqLldCfg->mcaspChanParams->noOfChannels;
pInp->firstTimeInit = TRUE; // set flag for IO Phy & Buff initialization
+
+ d10Initialized = 1; // indicate Input selected
}
}
else
}
}
- return ASIT_NO_ERR;
+ return ASIP_NO_ERR;
} /* asitSelectDevices */
/*======================================================================================
}
if(autoDetStatus->syncState == IODATA_SYNC_BITSTREAM) {
- uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
+ uint_least16_t pc = autoDetStatus->streamInfo.IEC_PC;
sourceProgram = IECpafSource[pc];
}
}
else {
// For bitstream, I/O frame length is the frame length of the bitstream
- uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
- ioFrameLength = iecFrameLength[pc];
-
-/*
- if( (pc == 0x11) && (DTSHDSubType == 3)
- && (PAF_ASP_sampleRateHzTable[pBufConfig->pBufStatus->sampleRateStatus][PAF_SAMPLERATEHZ_STD] <=48000.0))
- pDevExt->sourceProgram = PAF_SOURCE_DXP; // LBR is 23
-
- if (pc == 1)
- pDevExt->elementSize = 4288;
- else if (pc == 0x11) {
- pDevExt->frameLength = (pDevExt->pIECFrameLength[pc] << DTSHDSubType);
- pDevExt->lengthofData = pDevExt->frameLength;
- }
-*/
-
pBufConfig->sizeofElement = WORD_SIZE_BITSTREAM;
- pBufConfig->frameLength = ioFrameLength;
- pBufConfig->lengthofData = ioFrameLength - IEC_HEADER_LENGTH;
+ pBufConfig->frameLength = autoDetStatus->streamInfo.frameLength;
+ pBufConfig->lengthofData = autoDetStatus->streamInfo.dataLength;
+ ioFrameLength = autoDetStatus->streamInfo.frameLength;
// Change I/O PHY transfer size to bitstream frame size
- pInp->phyXferSize = ioFrameLength*WORD_SIZE_BITSTREAM;
+ pInp->phyXferSize = ioFrameLength*(WORD_SIZE_BITSTREAM);
}
pBufConfig->stride = pInp->stride; // common for PCM and bitstream
TRACE_VERBOSE0("ASIT error handling: input buffer underflows. No actions needed.");
}
+ if(asitErr == ASIT_AUTODET_TIME_OUT) {
+ pAsitCfg->pIoInp[0].asipState = ASIT_RESET;
+ pAsitCfg->pIoInp[0].numAsitRestart++;
+ TRACE_VERBOSE1("ASIT error %d handling finished. Go to state ASIT_RESET.", asitErr);
+ }
+
if(asitErr == ASIT_ERR_DECODE_QUIT) {
TRACE_VERBOSE0("ASIT error handling: DECODE_QUIT - clear INPDATA event.");
#if 0
#endif
pAsitCfg->pIoInp[0].asipState = ASIT_RESET;
pAsitCfg->pIoInp[0].numAsitRestart++;
- TRACE_VERBOSE0("ASIT error handling finished. Go to state ASIT_RESET.");
+ TRACE_VERBOSE1("ASIT error %d handling finished. Go to state ASIT_RESET.", asitErr);
}
if(asitErr == ASIT_ERR_EVENTS) {
pAsitCfg->pIoInp[0].asipState = ASIT_RESET;
pAsitCfg->pIoInp[0].numAsitRestart++;
- TRACE_VERBOSE0("ASIT error handling: events error. Go to state ASIT_RESET.");
+ TRACE_VERBOSE1("ASIT error %d handling: events error. Go to state ASIT_RESET.", asitErr);
}
return;
diff --combined pasdk/test_dsp/io/ioData.c
index bd30f3b0ce2d511f4cee02917796acfc1decda37,4c5c673c71f82f9c30a0fe528568cd1125ff1591..0baa780745d74900fa7c9b7d8492257687985afb
#define IODATA_SYNC_THD 0x16
#define IODATA_MIN_NUM_ZEROS_BEFORE_PA 2
-#define IODATA_PREAMBLE_MAX_LEN 8 // TBD
+#define IODATA_PREAMBLE_MAX_LEN 16 // TBD
#define IODATA_HEADER_LENGTH_IEC 4
#define IODATA_HEADER_CHECK_LENGTH_IEC 2 // For IEC, only look at 2 words to check SYNC.
size_t frameDataSize;
uint8_t deliverZeros;
uint8_t ioBuffUnderFlow;
+ uint8_t syncTimeOut;
void *buff1;
void *buff2;
size_t size1;
pIoDataInst->autoDetState = AUTODET_SYNC_SEARCH_INITIAL;
pIoDataInst->dbgStats.numSyncLost = 0;
pIoDataInst->ioBuffUnderFlow = FALSE;
+ pIoDataInst->syncTimeOut = FALSE;
autoDetReset(pIoDataInst);
case IODATA_CTL_GET_AUTODET_STATUS:
ioDataCtl->param.autoDetStats.syncState = pIoDataInst->autoDet.syncState;
ioDataCtl->param.autoDetStats.deliverZeros = pIoDataInst->deliverZeros;
- ioDataCtl->param.autoDetStats.bitStreamInfo = pIoDataInst->autoDet.bitStreamInfo;
+ ioDataCtl->param.autoDetStats.streamInfo.IEC_PC = pIoDataInst->autoDet.bitStreamInfo & IODATA_SYNC_PC_MASK;
+ ioDataCtl->param.autoDetStats.streamInfo.frameLength = pIoDataInst->autoDet.frameLength;
+ ioDataCtl->param.autoDetStats.streamInfo.dataLength = pIoDataInst->autoDet.frameLength
+ - pIoDataInst->autoDet.headerLength;
+ ioDataCtl->param.autoDetStats.syncTimeOut = pIoDataInst->syncTimeOut;
break;
/*
case IODATA_CTL_GET_STEAM_INFO:
/* Search for SYNC the first time */
autoDetSyncScan(pIoDataInst);
+ pIoDataInst->syncTimeOut = FALSE;
+
if(pIoDataInst->autoDet.syncDetected) {
syncCheckInit(pIoDataInst); // prepare for SYNC checking in subsequent frames
/* Reset if zero-run is long enough */
autoDetReset(pIoDataInst);
pIoDataInst->autoDetState = AUTODET_SYNC_SEARCH_INITIAL;
+ pIoDataInst->syncTimeOut = TRUE;
}
else {
// inform decoder where to read PCM data
/* Check if a full frame has been received and if so, check if SYNC is maintained */
if(pIoDataInst->autoDet.completeFrameRcvd) {
if(pIoDataInst->autoDet.syncDetected) {
+ pIoDataInst->dbgStats.numFramesRcvd += 1;
pIoDataInst->autoDet.syncState = IODATA_SYNC_BITSTREAM;
pIoDataInst->autoDet.completeFrameRcvd = FALSE;
// Store the beginning address of data in current frame (not including the preamble)
pIoDataInst->autoDet.frameDataStartConfirm = pIoDataInst->autoDet.frameDataStartTemp;
- pIoDataInst->dbgStats.numFramesRcvd += 1;
// re-initialize for SYNC check
syncCheckInit(pIoDataInst);
uint_least16_t pc = pIoDataInst->autoDet.bitStreamInfo & IODATA_SYNC_PC_MASK;
pIoDataInst->autoDet.frameLength = pIoDataInst->IECframeLengths[pc];
+
+ if (pc == 1) {
+ pIoDataInst->autoDet.frameLength = 4288;
+ }
+ else if (pc == IODATA_SYNC_SUBTYPE_DTSHD) {
+ int DTSHDSubType = (pIoDataInst->autoDet.bitStreamInfo & IODATA_SYNC_SUBTYPE_MASK)
+ >> IODATA_SYNC_SUBTYPE_SHIFT;
+ pIoDataInst->autoDet.frameLength = pIoDataInst->IECframeLengths[pc] << DTSHDSubType;
+ }
+
pIoDataInst->autoDet.distToFrameEnd = pIoDataInst->autoDet.frameLength
- pIoDataInst->autoDet.numElementsRcvd;
//pDevExt->headerSize = IEC_HEADER_SIZE;
pDet->preambleRef[3] = tail; /* save this word for sync check */
pDet->headerLength = IODATA_HEADER_LENGTH_IEC;
+ if( (pDet->bitStreamInfo & 0x1F) == 0x11) { // DTSHD subtype
+ pDet->headerLength += 6;
+ }
pDet->headerCheckLen = IODATA_HEADER_CHECK_LENGTH_IEC;
scanState = SCANNED_IEC_PD;
diff --combined pasdk/test_dsp/io/ioData.h
index 1c27a4eeb8a89e7a00f7ff4248e128c4d5c1c1ac,087990234f7a3f92581dbe36956927464ffe98c0..c05ed8d56bdcf867ba067e216f81bd298108562d
int8_t elementSize; // size of elements in bytes
} ioDataFrameInfo_t;
+typedef struct streamInfo_s {
+ uint_least16_t IEC_PC;
+ uint_least32_t frameLength;
+ uint_least32_t dataLength;
+} streamInfo_t;
+
// Auto-detection status
typedef struct ioDataAutoDetStat_s {
uint_least16_t syncState; // SYNC state
- uint_least16_t bitStreamInfo; // bit stream information - value of IEC_PC
+ streamInfo_t streamInfo; // bit stream information - value of IEC_PC
uint8_t deliverZeros; // flag to indicate whether zeros should be sent to output
+ uint8_t syncTimeOut;
} ioDataAutoDetStat_t;
// I/O DATA control structure