diff --git a/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c b/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c
index b613653c9934b3c5e9262f9082a9de13d479766b..8ee9140bea4869cf32c0e24a64cd496e22145728 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"
extern const MdUns iecFrameLength[23];
extern Ptr hMcaspRxChan;
-#define ASIT_EVTMSK_NONE 0x0
-#define ASIT_EVTMSK_INPDATA 0x1
-#define ASIT_EVTMSK_INFOACK 0x2
-#define ASIT_EVTMSK_DECACK 0x4
-
+// temp for simulation
+//#define ASIT_ALL_EVENTS ( ASIT_EVTMSK_INPDATA \
+// + ASIT_EVTMSK_INFOACK \
+// + ASIT_EVTMSK_DECACK )
#define ASIT_ALL_EVENTS ( ASIT_EVTMSK_INPDATA \
- + ASIT_EVTMSK_INFOACK \
- + ASIT_EVTMSK_DECACK )
+ + ASIT_EVTMSK_RXACK )
+// temp for simulation
+//#define ASIT_DEC_EVENTS ( ASIT_EVTMSK_INPDATA \
+// + ASIT_EVTMSK_INFOACK \
+// + ASIT_EVTMSK_DECACK )
#define ASIT_DEC_EVENTS ( ASIT_EVTMSK_INPDATA \
- + ASIT_EVTMSK_INFOACK \
- + ASIT_EVTMSK_DECACK )
+ + ASIT_EVTMSK_RXACK )
#define ASIP_DEBUG
Int asipErrno;
Int inputReadyForProcessing;
-// FL: debug
+// debug
#include "evmc66x_gpio_dbg.h"
#endif
-Event_Handle asitEvent;
-Int eventsOn;
+Event_Handle gAsitEvtHandle; // ASIT event handle
+Int eventsOn; // flag indicating whether to process events
+
+SyncEvent_Handle gAsitSyncEvtHandle; // ASIT Sync event handle
/*
* ======== taskAsipFxn ========
Int asitErr;
UInt events;
// Int eventsOn;
- Error_Block eb;
+// Error_Block eb;
Log_info0("Enter taskAsipFxn()");
taskAsipFxnInit(pP, pQ); // initialization of input task
- Error_init(&eb); // initialize error block
-
- asitEvent = Event_create(NULL, &eb);
- if (asitEvent == NULL) {
- System_abort("Event create failed");
- }
//
// Audio Stream Input Task Configuration (*pAsitCfg):
//
asipLoopCount1++;
if(eventsOn) {
- events = Event_pend(asitEvent, ASIT_EVTMSK_NONE, ASIT_ALL_EVENTS,
+ events = Event_pend(gAsitEvtHandle, ASIT_EVTMSK_NONE, ASIT_ALL_EVENTS,
BIOS_WAIT_FOREVER);
}
switch (pInp->asipState)
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);
PAF_ASIT_Config *pAsitCfg)
{
PAF_AST_Config *pAstCfg;
- PAF_AST_IoInp *pInp; /* I/O components for input */
+ PAF_AST_IoInp *pInp; // I/O components for input
Int zMD, mcaspErr, asitErr;
ioDataAutoDetStat_t autoDetStatus;
- pAstCfg = pAsitCfg->pAstCfg; // pointer to AST common (shared) configuration
+ pAstCfg = pAsitCfg->pAstCfg; // pointer to AST common (shared) configuration
zMD = pAstCfg->masterDec;
- pInp = &pAsitCfg->pIoInp[zMD]; // pointer to input I/O components
+ pInp = &pAsitCfg->pIoInp[zMD]; // pointer to input I/O components
// Marks I/O PHY transfer and I/O BUFF write complete
asitPhyTransferComplete(pInp);
// 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;
}
{
Int asitErr, decErr;
PAF_AST_IoInp *pInp; // I/O components for input
+ AspMsgMaster_Handle hAspMsgMaster; // ASIT message master handle
asipDecProc_t *pDec;
ioDataAutoDetStat_t autoDetStatus;
Int zMD;
UInt decMsg;
+ Int status;
- zMD = pAsitCfg->pAstCfg->masterDec; // pointer to AST common (shared) configuration
- pInp = &pAsitCfg->pIoInp[zMD]; // pointer to input I/O components
+ zMD = pAsitCfg->pAstCfg->masterDec; // pointer to AST common (shared) configuration
+ pInp = &pAsitCfg->pIoInp[zMD]; // pointer to input I/O components
+ hAspMsgMaster = pAsitCfg->hAspMsgMaster; // get ASIT message master handle
pDec = &pAsitCfg->inpDec;
// Initialization for decode processing when this function is called the first time
TRACE_VERBOSE0("TaskAsip: send DEC_EXIT message to slave decoder.");
// Send dec exit message to slave decoder
- if( AspMsgSend(ASP_SLAVE_DEC_EXIT, ASP_MASTER_DEC_EXIT_DONE, NULL, NULL)
- != ASP_MSG_NO_ERR) {
+ status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_EXIT, NULL);
+ if (status != ASP_MSG_NO_ERR)
+ {
+ TRACE_VERBOSE0("TaskAsip: error in sending DEC_EXIT message");
+ SW_BREAKPOINT;
+ }
+ status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_EXIT_DONE, NULL, TRUE);
+ if (status != ASP_MSG_NO_ERR)
+ {
TRACE_VERBOSE0("TaskAsip: error in sending DEC_EXIT message");
SW_BREAKPOINT;
}
{
UInt decMsg = 0;
- if(asitEvents & ASIT_EVTMSK_INPDATA) {
+ if (asitEvents & ASIT_EVTMSK_INPDATA) {
+ // Input data event
decMsg |= DEC_MSGMSK_INPDATA;
}
- if(asitEvents & ASIT_EVTMSK_INFOACK) {
- decMsg |= DEC_MSGMSK_INFOACK;
- }
+ // temp, simulation
+ //if(asitEvents & ASIT_EVTMSK_INFOACK) {
+ // decMsg |= DEC_MSGMSK_INFOACK;
+ //}
- if(asitEvents & ASIT_EVTMSK_DECACK) {
- decMsg |= DEC_MSGMSK_DECACK;
- }
+ // temp, simulation
+ //if(asitEvents & ASIT_EVTMSK_DECACK) {
+ // decMsg |= DEC_MSGMSK_DECACK;
+ //}
+ if (asitEvents & ASIT_EVTMSK_RXACK)
+ {
+ // Receive acknowledge message event
+ decMsg |= DEC_MSGMSK_RXACK;
+ }
+
return decMsg;
} /* asitEventsToDecMsg */
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.");
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
/* post semaphore */
if(mcasp_packet->arg == IOPHY_XFER_FINAL) {
//Semaphore_post(asipSemRx);
- Event_post(asitEvent, ASIT_EVTMSK_INPDATA);
+ Event_post(gAsitEvtHandle, ASIT_EVTMSK_INPDATA);
} else {
; // intermediate packet due to buffer wrapping around
}
}
Int d10Initialized = 0;
-//extern Audk2g_STATUS mcaspAudioConfig(void);
+//extern Aud_STATUS mcaspAudioConfig(void);
extern void McaspDevice_init(void);
/*======================================================================================
*====================================================================================*/
Int asitSelectDevices(const PAF_ASIT_Patchs *pQ, PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp)
{
- Audk2g_STATUS status;
+ Aud_STATUS status;
mcaspLLDconfig *lldCfg;
Ptr mcaspChanHandle;
- Int zMD, device;
+ Int zMD, interface;
zMD = pAstCfg->masterDec;
- device = pAstCfg->xInp[zMD].inpBufStatus.sioSelect; // obtain SIO select for input
+ interface = pAstCfg->xInp[zMD].inpBufStatus.sioSelect; // obtain SIO select for input
- if (device <= 0) {
+ if (interface <= 0) {
pInp->pRxParams = NULL;
return ASIT_NO_ERR;
@@ -1088,7 +1124,7 @@ Int asitSelectDevices(const PAF_ASIT_Patchs *pQ, PAF_AST_Config *pAstCfg, PAF_AS
// Initialize D10
if(!d10Initialized) {
- void * pD10Params = (void *)pQ->devinp->x[device];
+ void * pD10Params = (void *)pQ->devinp->x[interface];
/* Initialize McASP HW details */
McaspDevice_init();
@@ -1098,18 +1134,38 @@ Int asitSelectDevices(const PAF_ASIT_Patchs *pQ, PAF_AST_Config *pAstCfg, PAF_AS
d10Initialized = 1;
}
- if(pInp->hMcaspChan == NULL) {
- /* Create an McASP LLD channel */
- lldCfg = (mcaspLLDconfig *)pQ->devinp->x[device]->sio.pConfig;
+ /* Get the McASP LLD channel for this interface. Create one if not yet created. */
+ lldCfg = (mcaspLLDconfig *)pQ->devinp->x[interface]->sio.pConfig;
+ if(lldCfg->hMcaspChan == NULL) {
+ mcaspChanHandle = NULL;
status = mcasplldChanCreate(lldCfg, &mcaspChanHandle);
- if(status != Audk2g_EOK) {
+ if(status != Aud_EOK) {
Log_info0("McASP channel creation failed!\n");
return ASIT_ERR_MCASP_CFG;
}
- pInp->hMcaspChan = mcaspChanHandle;
+ lldCfg->hMcaspChan = mcaspChanHandle;
+ }
+ else {
+ /* Configure McASP to receive 16/32-bit data according to default configuration */
+ status = mcaspRecfgWordWidth(pInp->hMcaspChan, lldCfg->mcaspChanParams->wordWidth);
+ if(status != Aud_EOK) {
+ return ASIT_ERR_MCASP_CFG;
+ }
+ }
+
+ pInp->pRxParams = pQ->devinp->x[interface];
+ pInp->hMcaspChan = lldCfg->hMcaspChan;
+ pInp->stride = lldCfg->mcaspChanParams->noOfSerRequested * 2; // 2 for stereo
- pInp->pRxParams = pQ->devinp->x[device];
+ /* Set flag to swap HDMI data if it is 4xI2S and word length is 16 */
+ if( (lldCfg->mcaspChanParams->wordWidth == Mcasp_WordLength_16)
+ &&(lldCfg->mcaspChanParams->noOfSerRequested == 4)
+ ) {
+ pInp->swapData = TRUE;
+ }
+ else {
+ pInp->swapData = FALSE;
}
return ASIT_NO_ERR;
* Decide source after SYNC is found, i.e. either bitstream preamble is detected
* or it times out to PCM.
==============================================================================*/
-Int asitDecideSource(PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp,
+Int asitDecideSource(PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp,
ioDataAutoDetStat_t *autoDetStatus)
{
Int sourceConfig, sourceSelect, sourceProgram;
Int zMD;
char asipMsgBuf[ASP_MSG_BUF_LEN];
+ Int status;
// Get the configured source
zMD = pAstCfg->masterDec;
#ifndef DEBUG_SKIP_DECODING
// send source select message to slave
*(Int32 *)&asipMsgBuf[0] = sourceSelect;
- if(AspMsgSend(ASP_SLAVE_DEC_SOURCE_SELECT, ASP_MASTER_DEC_SOURCE_SELECT_DONE,
- asipMsgBuf, NULL) != ASP_MSG_NO_ERR) {
+ status = AspMsgSnd(gPAF_ASIT_config.hAspMsgMaster, ASP_SLAVE_DEC_SOURCE_SELECT, asipMsgBuf);
+ if (status != ASP_MSG_NO_ERR)
+ {
TRACE_VERBOSE0("TaskAsip: error in sending SOURCE_SELECT message");
SW_BREAKPOINT;
}
+ status = AspMsgRcvAck(gPAF_ASIT_config.hAspMsgMaster, ASP_MASTER_DEC_SOURCE_SELECT_DONE, NULL, TRUE);
+ if (status != ASP_MSG_NO_ERR)
+ {
+ TRACE_VERBOSE0("TaskAsip: error in receiving SOURCE_SELECT ack message");
+ SW_BREAKPOINT;
+ }
#endif
pInp->sourceSelect = sourceSelect;
// 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;
void asitErrorHandling(PAF_ASIT_Config *pAsitCfg, Int asitErr)
{
- UInt events;
+ //UInt events;
if(asitErr == ASIT_ERR_INPBUF_UNDERFLOW) {
TRACE_VERBOSE0("ASIT error handling: input buffer underflows. No actions needed.");
//////////////////////////////////////////////////////////////////////////////
void asitPostInfoEvent()
{
- Event_post(asitEvent, ASIT_EVTMSK_INFOACK);
+ Event_post(gAsitEvtHandle, ASIT_EVTMSK_INFOACK);
}
void asitPostDecEvent()
{
- Event_post(asitEvent, ASIT_EVTMSK_DECACK);
+ Event_post(gAsitEvtHandle, ASIT_EVTMSK_DECACK);
}
//////////////////////////////////////////////////////////////////////////////