diff --git a/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c b/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c
index 7e4b482f81b7115a738d56b69dc9b0e69b5a2700..4e6b92cd39af8504329d44bab98f1dae4743c862 100644 (file)
#include "asperr.h"
#include "common.h"
-#include "audk2g.h"
-#include "audk2g_audio.h"
+#include "aud.h"
+#include "aud_audio.h"
#include "mcasp_cfg.h"
#include "ioConfig.h" //TODO: remove this header
#include "ioBuff.h"
void asitPhyTransferComplete(PAF_AST_IoInp * pInpIo);
void asitPhyTransferStart(PAF_AST_IoInp *pInpIo);
Int asitRecfgPhyXfer(PAF_AST_IoInp *pInp, size_t xferSize);
-Int asitSelectDevices(const PAF_ASIT_Patchs *pQ, PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp);
+
+// Select Input devices
+Int asitSelectDevices(
+ const PAF_ASIT_Patchs *pQ,
+ PAF_AST_Config *pAstCfg,
+ PAF_AST_IoInp *pInp
+);
+
Int asitUpdateInputStatus(const void *pRxParams, PAF_InpBufStatus *pStatus,
PAF_InpBufConfig *pInpBuf);
case ASIT_DECODE_PROCESSING:
if(events & ASIT_DEC_EVENTS) {
+
+#if 1 // debug
+ if (events & ASIT_EVTMSK_INPDATA)
+ {
+ // shows timing of Input (Rx McASP EDMA)
+ // ADC B5
+ {
+ static Uint8 toggleState = 0;
+ if (toggleState == 0)
+ GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99);
+ else
+ GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
+ toggleState = ~(toggleState);
+ }
+ }
+#endif
+
// Decode processing for either PCM or bitstream
// New state will be decided inside the function
asitErr = asitDecodeProcessing(pP, pQ, pAsitCfg, events);
// Reconfigure McASP LLD to transfer 32-bit unpacked data
mcaspErr = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_32);
- if(mcaspErr != Audk2g_EOK) {
+ if(mcaspErr != Aud_EOK) {
return ASIT_ERR_MCASP_CFG;
}
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);
ioDataParam_t ioDataCfg;
ioPhyCtl_t ioPhyCtl;
- pInpIo->phyXferSize = INPUT_FRAME_SIZE_DEF;
+ //pInpIo->phyXferSize = INPUT_FRAME_SIZE_DEF;
+ pInpIo->phyXferSize = pInpIo->stride * NUM_CYCLE_PER_FRAME_DEF * WORD_SIZE_BITSTREAM;
if(pInpIo->firstTimeInit) {
TRACE_VERBOSE0("Initialize I/O BUFF and I/O PHY.");
ioDataCfg.ioBuffHandle = pInpIo->hIoBuff;
ioDataCfg.unknownSourceTimeOut = pInpBuf->inpBufConfig.pBufStatus->unknownTimeout;
ioDataCfg.frameLengthsIEC = (uint_least16_t *)&iecFrameLength[0];
- ioDataCfg.frameLengthPCM = INPUT_FRAME_SIZE_PCM / WORD_SIZE_PCM;
- ioDataCfg.frameLengthDef = INPUT_FRAME_SIZE_DEF / WORD_SIZE_BITSTREAM;
+ ioDataCfg.frameLengthPCM = pInpIo->stride * NUM_CYCLE_PER_FRAME_DEF;
+ ioDataCfg.frameLengthDef = pInpIo->stride * NUM_CYCLE_PER_FRAME_DEF;
ioDataCfg.ibMode = pInpBuf->inpBufConfig.pBufStatus->mode;
ioDataCfg.zeroRunRestart = pInpBuf->inpBufConfig.pBufStatus->zeroRunRestart;
ioDataCfg.zeroRunTrigger = pInpBuf->inpBufConfig.pBufStatus->zeroRunTrigger;
ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
ioPhyCtl.params.xferFrameSize = pInpIo->phyXferSize;
ioPhyControl(pInpIo->hIoPhy, &ioPhyCtl);
-
+#if 0
// If previous stream before reset was PCM, reconfigure McASP LLD to receive 16-bit packed bits
if(!pInpIo->swapData) {
Int mcaspErr;
mcaspErr = mcaspRecfgWordWidth(pInpIo->hMcaspChan, Mcasp_WordLength_16);
- if(mcaspErr != Audk2g_EOK) {
+ if(mcaspErr != Aud_EOK) {
return ASIT_ERR_MCASP_CFG;
}
pInpIo->swapData = TRUE;
TRACE_VERBOSE0("Reconfigure McASP word length and start swapping data.");
}
-
+#endif
// Start PHY transfer
TRACE_VERBOSE0("Start I/O PHY transfer.");
asitPhyTransferStart(pInpIo);
*====================================================================================*/
void asitProcInit(PAF_AST_IoInp *pInp, asipDecProc_t *pDec)
{
- pInp->swapData = TRUE;
+// pInp->swapData = TRUE;
pInp->pcmSwitchHangOver = INPUT_SWITCH_HANGOVER;
pDec->initDone = FALSE;
pInp->numFrameReceived = 0;
ioPhyXferComplete(pInpIo->hIoPhy, pInpIo->swapData);
} /* asitPhyTransferComplete */
+#if 0
Int asitRecfgPhyXfer(PAF_AST_IoInp *pInp, size_t xferSize)
{
ioPhyCtl_t ioPhyCtl;
if(!pInp->swapData) {
// If it was PCM, reconfigure McASP LLD to receive 16-bit packed bits
mcaspErr = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_16);
- if(mcaspErr != Audk2g_EOK) {
+ if(mcaspErr != Aud_EOK) {
return ASIT_ERR_MCASP_CFG;
}
return ASIT_NO_ERR;
} /* asitRecfgPhyXfer */
+#endif
/*======================================================================================
* McASP LLD call back function
}
Int d10Initialized = 0;
-//extern Audk2g_STATUS mcaspAudioConfig(void);
+//extern Aud_STATUS mcaspAudioConfig(void);
extern void McaspDevice_init(void);
/*======================================================================================
* This function initializes HW interface and selects the right device for input
*====================================================================================*/
-Int asitSelectDevices(const PAF_ASIT_Patchs *pQ, PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp)
+Int asitSelectDevices(
+ const PAF_ASIT_Patchs *pQ,
+ PAF_AST_Config *pAstCfg,
+ PAF_AST_IoInp *pInp
+)
{
- Audk2g_STATUS status;
- mcaspLLDconfig *lldCfg;
+ Aud_STATUS status;
+ const PAF_SIO_Params *pInPrms;
+ mcaspLLDconfig *pLldCfg;
+ mcaspLLDconfig *pReqLldCfg;
Ptr mcaspChanHandle;
- Int zMD, device;
+ Int zMD;
+ Int interface;
+ const PAF_SIO_Params *pD10Params;
zMD = pAstCfg->masterDec;
+
+ interface = pAstCfg->xInp[zMD].inpBufStatus.sioSelect; // obtain SIO select for input
+
+ if (interface >= 0)
+ {
+ // Positive value for interface: new Input SIO update request has been received via alpha command.
+ // Negative value for interface: no new Input SIO update request has been received,
+ // previous requests have been processed.
+
+ // check for valid index into device array
+ if (interface >= pQ->devinp->n) // DEVINP_N
+ {
+ interface = 0; // treat as device InNone
+ }
+
+ //
+ // Deactivate currently active interface
+ //
+ if (pInp->hMcaspChan != NULL) // non-NULL McASP LLD channel handle indicates there's an active interface
+ {
+ // Delete McASP LLD channel
+ status = mcaspDeleteChan(pInp->hMcaspChan);
+ if (status != Aud_EOK)
+ {
+ Log_info0("asitSelectDevices(): McASP channel deletion failed!\n");
+ return ASIP_ERR_MCASP_CFG;
+ }
+
+ pInp->hMcaspChan = NULL; // reset active McASP LLD handle
+ if (pInp->pRxParams != NULL) // sanity check, pInp->pRxParams should be non NULL if pInp->hMcaspChan is non NULL
+ {
+ pInPrms = (const PAF_SIO_Params *)pInp->pRxParams;
+ pLldCfg = (mcaspLLDconfig *)pInPrms->sio.pConfig; // get pointer to active McASP LLD configuration
+ pLldCfg->hMcaspChan = NULL; // reset McASP LLD handle for active McASP LLD configuration
+ pInp->pRxParams = NULL; // reset pointer to active D10 parameters
+ }
+ else
+ {
+ // This is a programming error
+ SW_BREAKPOINT; // debug
+ }
+ }
- device = pAstCfg->xInp[zMD].inpBufStatus.sioSelect; // obtain SIO select for input
-
- if (device <= 0) {
- pInp->pRxParams = NULL;
-
- return ASIT_NO_ERR;
+ //
+ // Activate requested interface
+ //
+ pD10Params = (const PAF_SIO_Params *)pQ->devinp->x[interface]; // get D10 parameters for selected interface
+ if (pD10Params != NULL)
+ {
+ //
+ // 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 Rx hardware
+ D10_init((void *)pD10Params);
+
+ d10Initialized=1;
+ }
+
+ //if (!d10Initialized)
+ //{
+ // d10Initialized=1; // global flag indicating D10 init completed
+ //}
+
+ pReqLldCfg = (mcaspLLDconfig *)pD10Params->sio.pConfig;
+ if (pReqLldCfg->hMcaspChan == NULL)
+ {
+ // Create McASP LLD channel
+ mcaspChanHandle = NULL;
+ status = mcasplldChanCreate(pReqLldCfg, &mcaspChanHandle);
+ if (status != Aud_EOK)
+ {
+ Log_info0("asitSelectDevices(): McASP channel creation failed!\n");
+ return ASIP_ERR_MCASP_CFG;
+ }
+
+ pReqLldCfg->hMcaspChan = mcaspChanHandle; // set McASP LLD handle for requested McASP LLD configuration
+ pInp->pRxParams = (const void *)pD10Params; // set pointer to active D10 parameters
+ pInp->hMcaspChan = pReqLldCfg->hMcaspChan; // set active McASP LLD handle
+
+ // configure stride according to selected McASP LLD configuration
+ pInp->stride = pReqLldCfg->mcaspChanParams->noOfSerRequested *
+ pReqLldCfg->mcaspChanParams->noOfChannels;
+ }
+ }
+ else
+ {
+ //
+ // Requested device is InNone
+ //
+ pInp->hMcaspChan = NULL; // reset active McASP LLD handle
+ pInp->pRxParams = NULL; // reset pointer to active D10 parameters
+ }
+
+ // indicate SIO update request processed
+ pAstCfg->xInp[zMD].inpBufStatus.sioSelect = interface | 0x80;
}
- // Initialize D10
- if(!d10Initialized) {
- void * pD10Params = (void *)pQ->devinp->x[device];
-
- /* Initialize McASP HW details */
- McaspDevice_init();
-
- D10_init(pD10Params);
-
- d10Initialized = 1;
- }
+ if (pInp->hMcaspChan != NULL) // non NULL indicates there's an active interface
+ {
+ if (pInp->pRxParams != NULL) // sanity check, this should be non NULL if pInp->hMcaspChan is non NULL
+ {
+ pInPrms = (const PAF_SIO_Params *)pInp->pRxParams;
+ pLldCfg = (mcaspLLDconfig *)pInPrms->sio.pConfig; // get currently active McASP LLD configuration
+ if (pLldCfg != NULL) // sanity check, this should be non NULL if pInp->hMcaspChan is non NULL
+ {
+ // Configure McASP to receive 16/32-bit data according to default configuration
+ mcaspRecfgWordWidth(pInp->hMcaspChan, pLldCfg->mcaspChanParams->wordWidth);
+
+ // Set flag to swap HDMI data if it is 4xI2S and word length is 16
+ if ((pLldCfg->mcaspChanParams->wordWidth == Mcasp_WordLength_16) &&
+ (pLldCfg->mcaspChanParams->noOfSerRequested == 4))
+ {
+ pInp->swapData = TRUE;
+ }
+ else
+ {
+ pInp->swapData = FALSE;
+ }
+ }
+ else
+ {
+ // This is a programming error
+ SW_BREAKPOINT; // debug
+ }
- if(pInp->hMcaspChan == NULL) {
- /* Create an McASP LLD channel */
- lldCfg = (mcaspLLDconfig *)pQ->devinp->x[device]->sio.pConfig;
- status = mcasplldChanCreate(lldCfg, &mcaspChanHandle);
- if(status != Audk2g_EOK) {
- Log_info0("McASP channel creation failed!\n");
- return ASIT_ERR_MCASP_CFG;
}
-
- pInp->hMcaspChan = mcaspChanHandle;
-
- pInp->pRxParams = pQ->devinp->x[device];
+ else
+ {
+ // This is a programming error
+ SW_BREAKPOINT; // debug
+ }
}
-
+
return ASIT_NO_ERR;
} /* asitSelectDevices */
// Decide frame length for I/O DATA and I/O PHY
if(autoDetStatus->syncState == IODATA_SYNC_PCM) {
// For PCM, I/O frame length is decode frame length multiplied by stride
- ioFrameLength = decFrameLength * INPUT_STRIDE;
+ ioFrameLength = decFrameLength * pInp->stride;
pBufConfig->sizeofElement = WORD_SIZE_PCM;
pBufConfig->frameLength = pBufConfig->lengthofData = ioFrameLength;
pInp->phyXferSize = ioFrameLength*WORD_SIZE_BITSTREAM;
}
- pBufConfig->stride = INPUT_STRIDE; // common for PCM and bitstream
+ pBufConfig->stride = pInp->stride; // common for PCM and bitstream
// Configure I/O PHY transfer size
ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
return ASIT_NO_ERR;
} /* asitUpdateIoComps */
-
+#if 0
#ifndef IO_LOOPBACK_TEST
#if OUTPUT_FRAME_LENGTH == INPUT_FRAME_LENGTH
U8 pcmbuf[OUTPUT_FRAME_SIZE];
}
#endif
+#endif
+
Int asitEvtErrCheck(UInt actualEvents, UInt expectedEvents)
{
TRACE_VERBOSE2("ASIT events error: actual events are: %d, expected events are: %d.",