From a7b7a96ea5a972e60b321f0901fcaf255dd097ae Mon Sep 17 00:00:00 2001 From: Frank Livingston Date: Wed, 6 Jun 2018 17:21:43 -0500 Subject: [PATCH 1/1] PASDK-577:Add "proof of concept" code for McASP LLD to setCheckRateX Add "proof of concept" code to asopSetCheckRateX() for setting Tx McASP CLKXDIV using McASP LLD. The "proof of concept" code only works for HDMI input & output sampling rates 44.1,48,88.2,96 & 192 kHz. Additional integration work needs to be done for asopSetCheckRateX() full functionality. See sap_d10.c:manageOutput() for details of required functionality. --- .../framework/audioStreamInpProcNewIO.c | 20 ++++--- pasdk/test_dsp/framework/audioStreamOutDec.c | 14 ++--- pasdk/test_dsp/framework/audioStreamOutIo.c | 52 ++++++++++++++++--- pasdk/test_dsp/framework/audioStreamOutProc.h | 2 + 4 files changed, 66 insertions(+), 22 deletions(-) diff --git a/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c b/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c index 84d525c8..041aaf9c 100644 --- a/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c +++ b/pasdk/test_dsp/framework/audioStreamInpProcNewIO.c @@ -1134,7 +1134,8 @@ Int asitSelectDevices( PAF_AST_IoInp *pInp ) { - Aud_STATUS status; + Int32 status; + Aud_STATUS audStatus; const PAF_SIO_Params *pInPrms; mcaspLLDconfig *pLldCfg; mcaspLLDconfig *pReqLldCfg; @@ -1167,13 +1168,18 @@ Int asitSelectDevices( { 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; @@ -1220,8 +1226,8 @@ Int asitSelectDevices( { // 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 4eb50bf6..c3886e54 100644 --- a/pasdk/test_dsp/framework/audioStreamOutDec.c +++ b/pasdk/test_dsp/framework/audioStreamOutDec.c @@ -168,11 +168,11 @@ Int asopDecOutProcDec1( // // 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; } @@ -180,7 +180,7 @@ Int asopDecOutProcDec1( // // 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]; @@ -197,7 +197,7 @@ Int asopDecOutProcDec1( &pAstCfg->xEnc[z].encodeStatus); if (errno) { - TRACE_TERSE1("asopDecOutProcInfo1: info returns errno 0x%x ", errno); + TRACE_TERSE1("asopDecOutProcDec1: info returns errno 0x%x ", errno); status = ASOP_DOP_ERR_DEC1_ENCINFO; return status; } @@ -215,7 +215,7 @@ Int asopDecOutProcDec1( errno = asopSetCheckRateX(pP, pQ, pAsotCfg, 0); if (errno) { - TRACE_TERSE1("asopDecOutProcInfo1: info returns errno 0x%x ", errno); + TRACE_TERSE1("asopDecOutProcDec1: info returns errno 0x%x ", errno); status = ASOP_DOP_ERR_DEC1_SETRATEX; return status; } @@ -225,7 +225,7 @@ Int asopDecOutProcDec1( 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; } @@ -255,7 +255,7 @@ Int asopDecOutProcDec1( #endif return status; -} //asopDecOutProcInfo1 +} //asopDecOutProcDec1 // Purpose: Re-initiate Output Int asopDecOutProcInfo2( diff --git a/pasdk/test_dsp/framework/audioStreamOutIo.c b/pasdk/test_dsp/framework/audioStreamOutIo.c index 7a5b1295..a655af26 100644 --- a/pasdk/test_dsp/framework/audioStreamOutIo.c +++ b/pasdk/test_dsp/framework/audioStreamOutIo.c @@ -72,7 +72,8 @@ Int asopSelectDevices( { mcaspLLDconfig *pReqLldCfg; Ptr mcaspChanHandle; - Aud_STATUS status; + Int32 status; + Aud_STATUS audStatus; UInt postedEvents; if ((pOut->hIoBuff == NULL) || (pOut->hIoPhy == NULL) || (!d10Initialized)) @@ -83,11 +84,17 @@ Int asopSelectDevices( // Deactivate currently active Output device if (pOut->hMcaspChan != NULL) { - // check McASP LLD control API - mcaspControlChan(pOut->hMcaspChan, MCASP_CHAN_RESET, 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; + } + // 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; @@ -118,8 +125,9 @@ Int asopSelectDevices( { // 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; } @@ -236,6 +244,10 @@ Int asopSetCheckRateX( 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 @@ -319,14 +331,38 @@ Int asopSetCheckRateX( // Update divider based on calculated rateX divider /= rateX; +#if 0 // debug // Experimental code: directly write CLKXDIV - regVal = *(volatile UInt32 *)0x23400B0; + 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; + *(volatile UInt32 *)0x23400B0 = regVal; // write MCASP_ACLKXCTL +#endif + +#if 1 + // 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; + } +#endif pOut->rateX = rateX; } diff --git a/pasdk/test_dsp/framework/audioStreamOutProc.h b/pasdk/test_dsp/framework/audioStreamOutProc.h index f30c85df..9cf06b71 100644 --- a/pasdk/test_dsp/framework/audioStreamOutProc.h +++ b/pasdk/test_dsp/framework/audioStreamOutProc.h @@ -208,6 +208,8 @@ typedef struct PAF_AST_OutIO { 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; -- 2.39.2