]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/commitdiff
PASDK-577:Add "proof of concept" code for McASP LLD to setCheckRateX
authorFrank Livingston <frank-livingston@ti.com>
Wed, 6 Jun 2018 22:21:43 +0000 (17:21 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Wed, 6 Jun 2018 22:21:43 +0000 (17:21 -0500)
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.

pasdk/test_dsp/framework/audioStreamInpProcNewIO.c
pasdk/test_dsp/framework/audioStreamOutDec.c
pasdk/test_dsp/framework/audioStreamOutIo.c
pasdk/test_dsp/framework/audioStreamOutProc.h

index 84d525c83631c5869794344ccac9edb3121db9df..041aaf9c8510dc5f04017b7b56183136822b85c7 100644 (file)
@@ -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;
index 4eb50bf68d7096bdbf951bc22fea5d428813a68f..c3886e54c7fd108173803da59c488e2db7d341ec 100644 (file)
@@ -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(
index 7a5b129509b046950ca8e7f97ff712e15d57321c..a655af2675ac0b7681a8cceeee8678bdd57435fb 100644 (file)
@@ -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;
             }
index f30c85dfb680f4df14b63e6c30d374e0eee07043..9cf06b713f76590e5eed012c6beb169132fdda84 100644 (file)
@@ -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;