summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4f497f1)
raw | patch | inline | side by side (parent: 4f497f1)
author | Jianzhong Xu <a0869574@ti.com> | |
Wed, 13 Jun 2018 19:16:30 +0000 (15:16 -0400) | ||
committer | Jianzhong Xu <a0869574@ti.com> | |
Wed, 13 Jun 2018 19:16:30 +0000 (15:16 -0400) |
dev_pasdk_frank_pasdk577RunTimeAudioIoCfg.
diff --git a/pasdk/test_dsp/application/itopo/evmk2g/sap_d10.c b/pasdk/test_dsp/application/itopo/evmk2g/sap_d10.c
index d4f1564a42394ce24c2028823c1b3d7b7f8cebab..1ce8ed56294d31fa4ed1e2a5b5a16a4e273108f7 100644 (file)
// flag to facilitate one time initialization of DA10x Audio hardware
// 0 ==> not initialized, 1 ==> initialized
static char initDone = 0;
+static char initHDMIDone = 0;
// input status
static PAF_SIO_InputStatus primaryStatus =
else
Log_info0("Audio DIR Init Passed!\n");
-#if 1
+#if 0 // Configuring HDMI if available
/* Setup HSR41 for HDMI input operation */
//status = platformAudioSelectClkSrc(AUDIO_CLK_SRC_I2S);
/* Initialize the HDMI Card */
} //initD10
+
+Aud_STATUS D10_initHDMI(void)
+{
+ Aud_STATUS status = Aud_EOK;
+
+ if(!initHDMIDone)
+ {
+ /* Setup HSR41 for HDMI input operation */
+ //status = platformAudioSelectClkSrc(AUDIO_CLK_SRC_I2S);
+ /* Initialize the HDMI Card */
+ while(HDMIGpioGetState());
+ status = audioHDMIConfig();
+ if(status != Aud_EOK)
+ {
+ Log_info0("Audio HDMI Init Failed!\n");
+ return status;
+ }
+ else
+ {
+ Log_info0("Audio HDMI Init Passed!\n");
+ }
+
+ initHDMIDone = 1;
+ }
+
+ return status;
+}
+
// -----------------------------------------------------------------------------
// The McASP TX section is *only* used as a master clock mux.
// Mux functionality is achieved by selecting either external high
diff --git a/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c b/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c
index e5b962961cbc7912e2cada5dff78f42ac2c6a84f..d332c088c7547a412c26954677ed15ac889039f0 100644 (file)
#include "ioPhy.h"
#include "ioData.h"
+#include <pa_i13_evmk2g_io_a.h>
#define STRIDE_WORST_CASE 32 // 4-byte (32-bit) word, 2 slots, 4 serializers
@@ -113,6 +114,7 @@ extern Void taskAsipFxnInit(const PAF_ASIT_Params *pP,const PAF_ASIT_Patchs *pQ)
extern XDAS_Int32 D10_initClkMux(void *pD10Params);
extern XDAS_Int32 D10_RxControl(const void *pD10RxParams,
XDAS_Int32 code, XDAS_Int32 arg);
+extern Aud_STATUS D10_initHDMI(void);
/*
* Functions only used in this file
}
}
+// Indicates whether Input has been selected
Int d10Initialized = 0;
//extern Aud_STATUS mcaspAudioConfig(void);
//extern void McaspDevice_init(void);
PAF_AST_IoInp *pInp
)
{
- Aud_STATUS status;
+ Int32 status;
+ Aud_STATUS audStatus;
const PAF_SIO_Params *pInPrms;
mcaspLLDconfig *pLldCfg;
mcaspLLDconfig *pReqLldCfg;
Int zMD;
Int interface;
const PAF_SIO_Params *pD10Params;
+ UInt postedEvents;
zMD = pAstCfg->masterDec;
{
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
+ // Reset channel
+ status = mcaspControlChan(pInp->hMcaspChan, MCASP_CHAN_RESET, NULL); // Rx reset channel
+ //status = mcaspControlChan(pInp->hMcaspChan, MCASP_DEVICE_RESET, NULL); // Reset Tx/Rx channel
+ if (status != MCASP_COMPLETED)
+ {
+ Log_info0("asitSelectDevices(): McASP channel reset failed!\n");
+ return ASIP_ERR_MCASP_CFG;
+ }
// Delete McASP LLD channel
status = mcaspDeleteChan(pInp->hMcaspChan);
- if (status != Aud_EOK)
+ if (status != MCASP_COMPLETED)
{
Log_info0("asitSelectDevices(): McASP channel deletion failed!\n");
return ASIP_ERR_MCASP_CFG;
}
+ // Clear (drop) already posted Input data events
+ postedEvents = Event_getPostedEvents(gAsitEvtHandle);
+ while ((postedEvents & ASIT_EVTMSK_INPDATA) != 0)
+ {
+ Event_pend(gAsitEvtHandle, ASIT_EVTMSK_NONE, ASIT_EVTMSK_INPDATA, 0);
+ postedEvents = Event_getPostedEvents(gAsitEvtHandle);
+ }
+
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
{
//
// Requested device is other than InNone
//
+ if((interface == DEVINP_HDMI) || (interface == DEVINP_HDMI_STEREO))
+ {
+ D10_initHDMI();
+ }
// Initialize Tx clock mux
D10_initClkMux((void *)pD10Params);
{
// Create McASP LLD channel
mcaspChanHandle = NULL;
- status = mcasplldChanCreate(pReqLldCfg, &mcaspChanHandle);
- if (status != Aud_EOK)
+ audStatus = mcasplldChanCreate(pReqLldCfg, &mcaspChanHandle);
+ if (audStatus != Aud_EOK)
{
Log_info0("asitSelectDevices(): McASP channel creation failed!\n");
return ASIP_ERR_MCASP_CFG;
diff --git a/pasdk/test_dsp/framework/audioStreamOutDec.c b/pasdk/test_dsp/framework/audioStreamOutDec.c
index 4eb50bf68d7096bdbf951bc22fea5d428813a68f..89075d9779ea59be676239045283a146139f1b6f 100644 (file)
//
// Reset ASP chain
//
- TRACE_VERBOSE0("asopDecOutProcInfo1: calling streamChainFunction.");
+ TRACE_VERBOSE0("asopDecOutProcDec1: calling streamChainFunction.");
errno = streamChainFunction(pP, pQ, pAsotCfg, PAF_ASP_CHAINFRAMEFXNS_RESET, 1, frame); // SRC reset is called inside;
if (errno)
{
- TRACE_TERSE1("asopDecOutProcInfo1: streamChainFunction returns errno 0x%x ", errno);
+ TRACE_TERSE1("asopDecOutProcDec1: streamChainFunction returns errno 0x%x ", errno);
status = ASOP_DOP_ERR_DEC1_ASPCHAINRESET;
return status;
}
//
// Encode Info
//
- TRACE_VERBOSE0("asopDecOutProcInfo1: calling enc->info.");
+ TRACE_VERBOSE0("asopDecOutProcDec1: calling enc->info.");
for (z=ENCODE1; z < ENCODEN; z++)
{
Int zO = pP->outputsFromEncodes[z];
&pAstCfg->xEnc[z].encodeStatus);
if (errno)
{
- TRACE_TERSE1("asopDecOutProcInfo1: info returns errno 0x%x ", errno);
+ TRACE_TERSE1("asopDecOutProcDec1: enc info returns errno 0x%x ", errno);
status = ASOP_DOP_ERR_DEC1_ENCINFO;
return status;
}
errno = asopSetCheckRateX(pP, pQ, pAsotCfg, 0);
if (errno)
{
- TRACE_TERSE1("asopDecOutProcInfo1: info returns errno 0x%x ", errno);
- status = ASOP_DOP_ERR_DEC1_SETRATEX;
- return status;
+ if (errno != ASOP_IO_ERR_RATE_CHANGE)
+ {
+ TRACE_TERSE1("asopDecOutProcDec1: asopSetCheckRateX returns errno 0x%x", errno);
+ status = ASOP_DOP_ERR_DEC1_SETRATEX;
+ return status;
+ }
+ else
+ {
+ TRACE_TERSE1("asopDecOutProcDec1: asopSetCheckRateX returns errno 0x%x, ignoring", errno);
+ }
}
// FL, New IO: API for multiple Outputs
errno = asopStartOutput(pP, pQ, pAsotCfg);
if (errno)
{
- TRACE_TERSE1("asopDecOutProcInfo1: asopStartOutput returns errno 0x%x ", errno);
+ TRACE_TERSE1("asopDecOutProcDec1: asopStartOutput returns errno 0x%x ", errno);
status = ASOP_DOP_ERR_DEC1_STARTOUTPUT;
return status;
}
#endif
return status;
-} //asopDecOutProcInfo1
+} //asopDecOutProcDec1
// Purpose: Re-initiate Output
Int asopDecOutProcInfo2(
errno = asopSetCheckRateX(pP, pQ, pAsotCfg, 0);
if (errno)
{
+ //
+ // Note Rate change is NOT ignored here
+ //
+
TRACE_TERSE1("asopDecOutProcInfo2: info returns errno 0x%x ", errno);
status = ASOP_DOP_ERR_INFO2_SETRATEX;
return status;
diff --git a/pasdk/test_dsp/framework/audioStreamOutIo.c b/pasdk/test_dsp/framework/audioStreamOutIo.c
index 9562fed315c93cb63067ceb924c3a1dca2053584..a5796b35b7d94857aedd89b95c0f1066510273bd 100644 (file)
{
mcaspLLDconfig *pReqLldCfg;
Ptr mcaspChanHandle;
- Aud_STATUS status;
+ Int32 status;
+ Aud_STATUS audStatus;
+ UInt postedEvents;
if ((pOut->hIoBuff == NULL) || (pOut->hIoPhy == NULL) || (!d10Initialized))
{
// Deactivate currently active Output device
if (pOut->hMcaspChan != NULL)
{
+ // Reset channel
+ status = mcaspControlChan(pOut->hMcaspChan, MCASP_CHAN_RESET, NULL);
+ if (status != MCASP_COMPLETED)
+ {
+ Log_info0("asopSelectDevices(): McASP channel reset failed!\n");
+ return ASOP_IO_ERR_MCASP_CFG;
+ }
- // check McASP LLD control API
- mcaspControlChan(pOut->hMcaspChan, MCASP_CHAN_RESET, NULL);
// Delete McASP LLD channel
status = mcaspDeleteChan(pOut->hMcaspChan);
- if (status != Aud_EOK)
+ if (status != MCASP_COMPLETED)
{
Log_info0("asopSelectDevices(): McASP channel deletion failed!\n");
return ASOP_IO_ERR_MCASP_CFG;
}
+ // Clear (drop) already posted Output data events
+ postedEvents = Event_getPostedEvents(gAsotEvtHandle);
+ while ((postedEvents & Evt_Id_AsotTxMcaspEdma) != 0)
+ {
+ Event_pend(gAsotEvtHandle, Event_Id_NONE, Evt_Id_AsotTxMcaspEdma, 0);
+ postedEvents = Event_getPostedEvents(gAsotEvtHandle);
+ }
+
pOut->hMcaspChan = NULL; // reset active McASP LLD handle
pOut->pLldCfg->hMcaspChan = NULL; // reset McASP LLD handle for active McASP LLD configuration
pOut->pLldCfg = NULL; // reset pointer to active McASP LLD configuration
{
// Create McASP LLD channel
mcaspChanHandle = NULL;
- status = mcasplldChanCreate(pReqLldCfg, &mcaspChanHandle);
- if (status != Aud_EOK) {
+ audStatus = mcasplldChanCreate(pReqLldCfg, &mcaspChanHandle);
+ if (audStatus != Aud_EOK)
+ {
Log_info0("asopSelectDevices(): McASP channel creation failed!\n");
return ASOP_IO_ERR_MCASP_CFG;
}
// configure stride according to selected McASP LLD configuration
pOut->stride = pReqLldCfg->mcaspChanParams->noOfSerRequested *
pReqLldCfg->mcaspChanParams->noOfChannels;
+ // initialize rateX
+ pOut->rateX = 1.; // rateX==1.0 for CLKXDIV==1
+ }
+ else
+ {
+ return ASOP_IO_ERR_INV_STATE;
}
}
else
Int zMI;
Int zMS;
Int zE, zX;
+ // "proof of concept" for McASP LLD API
+ Uint32 divider;
+ Mcasp_HwSetupData mcaspSetup;
+ Int32 status;
pAstCfg = pAsotCfg->pAstCfg; // get pointer to AST common (shared) configuration
pOut = pAsotCfg->pIoOut; // get pointer to ASOT IO configuration
return ((getVal & 0xff) | ASPERR_RATE_CHECK);
}
#endif // FL, New IO
- // FL: ugly little experiment
- //*(volatile UInt32 *)0x23400B0 |= 7;
+
+ //
+ // "Proof on concept" code for McASP LLD API to change bit clock divider.
+ //
+ if (pOut->rateX != rateX)
+ {
+ //UInt32 regVal;
+
+ // Initialize divider value.
+ // This works for AHCLKX input from HDMI & sample rate = 44.1,48,88.2,96,192 kHz.
+ divider = 2;
+
+ // Update divider based on calculated rateX
+ divider /= rateX;
+
+#if 0 // debug
+ // Experimental code: directly write CLKXDIV
+ regVal = *(volatile UInt32 *)0x23400B0; // read MCASP_ACLKXCTL
+ regVal &= ~0x1F; // mask off CLKXDIV bits
+ //regVal |= 7; // set CLKXDIV for 48 kHz
+ //regVal |= 3; // set CLKXDIV for 96 kHz
+ //regVal |= 1; // set CLKXDIV for 192 kHz
+ regVal |= (divider-1); // set CLKXDIV
+ *(volatile UInt32 *)0x23400B0 = regVal; // write MCASP_ACLKXCTL
+#endif
+
+ // get existing McASP HW setup
+ status = mcaspControlChan(pOut->hMcaspChan, Mcasp_IOCTL_CNTRL_GET_FORMAT_CHAN, &mcaspSetup);
+ if (status != MCASP_COMPLETED)
+ {
+ Log_info0("asopSetCheckRateX(): McASP get channel format failed!\n");
+ return ASOP_IO_ERR_MCASP_CFG;
+ }
+
+ // update CLKXDIV based on rateX
+ mcaspSetup.clk.clkSetupClk &= ~CSL_MCASP_ACLKXCTL_CLKXDIV_MASK;
+ mcaspSetup.clk.clkSetupClk |= (divider-1);
+
+ // update McASP HW setup
+ status = mcaspControlChan(pOut->hMcaspChan, Mcasp_IOCTL_CNTRL_SET_FORMAT_CHAN, &mcaspSetup);
+ if (status != MCASP_COMPLETED)
+ {
+ Log_info0("asopSetCheckRateX(): McASP set channel format failed!\n");
+ return ASOP_IO_ERR_MCASP_CFG;
+ }
+
+ pOut->rateX = rateX; // update saved rateX
+
+ return ASOP_IO_ERR_RATE_CHANGE;
+ }
}
}
diff --git a/pasdk/test_dsp/framework/audioStreamOutIo.h b/pasdk/test_dsp/framework/audioStreamOutIo.h
index cfd00dfe72874a508a7f476b617c2c0adf399edc..4d85fea6381d82a693b30245c494fe380a2eff6a 100644 (file)
#define ASOP_IO_SOK ( 0 ) // ok
#define ASOP_IO_ERR_INV_PARAMS ( -1 ) // error, invalid parameters
#define ASOP_IO_ERR_IO_UNINIT ( -2 ) // error, IO uninitialized
-#define ASOP_IO_ERR_MCASP_CFG ( -3 ) // error, McASP configuration
-#define ASOP_IO_ERR_IOBUFF_INIT ( -4 ) // error, IO Buff initialization
-#define ASOP_IO_ERR_IOPHY_INIT ( -5 ) // error, IO Phy initialization
-#define ASOP_IO_ERR_OUTBUF_OVERFLOW ( -6 ) // error, Output buffer overflow
+#define ASOP_IO_ERR_INV_STATE ( -3 ) // error, IO invalid state
+#define ASOP_IO_ERR_MCASP_CFG ( -4 ) // error, McASP configuration
+#define ASOP_IO_ERR_IOBUFF_INIT ( -5 ) // error, IO Buff initialization
+#define ASOP_IO_ERR_IOPHY_INIT ( -6 ) // error, IO Phy initialization
+#define ASOP_IO_ERR_OUTBUF_OVERFLOW ( -7 ) // error, Output buffer overflow
+#define ASOP_IO_ERR_RATE_CHANGE ( -8 ) // error, rateX change
// Select Output devices
diff --git a/pasdk/test_dsp/framework/audioStreamOutProc.h b/pasdk/test_dsp/framework/audioStreamOutProc.h
index f30c85dfb680f4df14b63e6c30d374e0eee07043..53a29c3329e2996772f8511616c88052f83f8bb8 100644 (file)
uint32_t ioBuffBuf2AllocCnt; // Output buffer2 allocation (split buffer on buffer wrap) count
uint32_t errIoBuffOvrCnt; // Output IO overflow count
uint32_t errIoBuffUndCnt; // Output IO underflow count
+ float rateX; // Input/Output clock ratio
// debugging counters
uint32_t num_xfers;