PASDK-577:Call new McASP LLD control cmd to set Tx bit-clock divider
authorFrank Livingston <frank-livingston@ti.com>
Fri, 15 Jun 2018 15:58:57 +0000 (10:58 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Fri, 15 Jun 2018 15:58:57 +0000 (10:58 -0500)
This is a workaround for the pair-wise channel swap issue with the McASP
LLD control cmd casp_IOCTL_CNTRL_SET_FORMAT_CHAN.

pasdk/test_dsp/framework/audioStreamOutIo.c

index 5fddf93ac84f51d12ad62b6f3aae3b60eb1f910e..c132db7f4c7cb489e8de5c3d0c8cbadc9e9a4a91 100644 (file)
@@ -246,7 +246,7 @@ Int asopSetCheckRateX(
     Int zMS;
     Int zE, zX;
     // "proof of concept" for McASP LLD API
-    Uint32 divider;
+    Uint32 divider, clkXDiv;
     Mcasp_HwSetupData mcaspSetup;
     Int32 status;
 
@@ -323,26 +323,32 @@ Int asopSetCheckRateX(
             //
             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                
+                {
+                    UInt32 regVal;
+
+                    // Experimental code: directly write CLKXDIV -- produces correct output                
+                    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                  
+
+                // Calculate CLKXDIV bit field value
+                clkXDiv = (divider-1) & CSL_MCASP_ACLKXCTL_CLKXDIV_MASK;
 
+#if 0 // use existing McASP LLD API functions -- results in Tx serializer channel swap
                 // get existing McASP HW setup
                 status = mcaspControlChan(pOut->hMcaspChan, Mcasp_IOCTL_CNTRL_GET_FORMAT_CHAN, &mcaspSetup);
                 if (status != MCASP_COMPLETED)
@@ -353,7 +359,7 @@ Int asopSetCheckRateX(
                 
                 // update CLKXDIV based on rateX
                 mcaspSetup.clk.clkSetupClk &= ~CSL_MCASP_ACLKXCTL_CLKXDIV_MASK;
-                mcaspSetup.clk.clkSetupClk |= (divider-1);
+                mcaspSetup.clk.clkSetupClk |= clkXDiv;
                 
                 // update McASP HW setup
                 status = mcaspControlChan(pOut->hMcaspChan, Mcasp_IOCTL_CNTRL_SET_FORMAT_CHAN, &mcaspSetup);
@@ -362,6 +368,17 @@ Int asopSetCheckRateX(
                     Log_info0("asopSetCheckRateX(): McASP set channel format failed!\n");
                     return ASOP_IO_ERR_MCASP_CFG;
                 }
+#endif
+
+#if 1 // use new McASP LLD API function -- produces correct output
+                // update CLKXDIV setup
+                status = mcaspControlChan(pOut->hMcaspChan, Mcasp_IOCTL_CNTRL_SET_FORMAT_CHAN_CLKXDIV, &clkXDiv);
+                if (status != MCASP_COMPLETED)
+                {
+                    Log_info0("asopSetCheckRateX(): McASP set channel format CLKXDIV failed!\n");
+                    return ASOP_IO_ERR_MCASP_CFG;
+                }
+#endif
                 
                 pOut->rateX = rateX; // update saved rateX