Merge remote-tracking branch 'origin/dev_pasdk_govind_pasdk53IpDataDebug' into dev_pa...
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / sap / sap.c
index aff66f8a17eb23e6de178d11c7061de6f4b3a3e5..174e76b143bf391df2fac8bab27199d93f33a2a4 100644 (file)
@@ -104,26 +104,48 @@ void swapHdmi(Ptr, int);
 
 
 #ifdef TEST_MULTICHANNEL
-#define SAP_UNDER_LEN 16
+#define SAP_UNDER_LEN 8
 //#define SAP_UNDER_LEN 1024 // GJ: experiment
 #else
 #define SAP_UNDER_LEN 1024
 #endif
 int sap_UNDER[SAP_UNDER_LEN]; // used for underrun
-int sap_OVER = 0;     // used for overrun
+int sap_OVER_1LANE = 0;     // used for overrun
+int sap_OVER_4LANE[4] = {0,0,0,0};      // used for overrun
 
 #ifdef DEBUG
 void DJDBG_SAP_EDMA_dumpParams(int tag_place)
 {
-       unsigned int *ptrPARAM_BASE = (unsigned int *)0x02704000;
-       unsigned int *ptrPARAM0x18 = (unsigned int *)0x02704300; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[24]
+       //unsigned int *ptrPARAM_BASE = (unsigned int *)0x02704000;
+       //unsigned int *ptrPARAM0x18 = (unsigned int *)0x02704300; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[24]
        unsigned int *ptrPARAM0x19 = (unsigned int *)0x02704320; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[24]
+       unsigned int *ptrPARAM0x41 = (unsigned int *)0x027048A0; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[24]
+       unsigned int *ptrPARAM0x42 = (unsigned int *)0x027048C0; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[24]
+       unsigned int *ptrPARAM0x43 = (unsigned int *)0x027048E0; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[24]
+       unsigned int *ptrPARAM0x44 = (unsigned int *)0x02704910; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[24]
 
-       Log_info5("PARAM0x18a(%d): 0x%x 0x%x 0x%x 0x%x", tag_place, ptrPARAM0x18[0], ptrPARAM0x18[1], ptrPARAM0x18[2], ptrPARAM0x18[3]);
-       Log_info5("PARAM0x18b(%d): 0x%x 0x%x 0x%x 0x%x", tag_place, ptrPARAM0x18[4], ptrPARAM0x18[5], ptrPARAM0x18[6], ptrPARAM0x18[7]);
+       //Log_info5("PARAM0x18a(%d): 0x%x 0x%x 0x%x 0x%x", tag_place, ptrPARAM0x18[0], ptrPARAM0x18[1], ptrPARAM0x18[2], ptrPARAM0x18[3]);
+       //Log_info5("PARAM0x18b(%d): 0x%x 0x%x 0x%x 0x%x", tag_place, ptrPARAM0x18[4], ptrPARAM0x18[5], ptrPARAM0x18[6], ptrPARAM0x18[7]);
 
-       Log_info5("PARAM0x19a(%d): 0x%x 0x%x 0x%x 0x%x", tag_place, ptrPARAM0x19[0], ptrPARAM0x19[1], ptrPARAM0x19[2], ptrPARAM0x19[3]);
-       Log_info5("PARAM0x19b(%d): 0x%x 0x%x 0x%x 0x%x", tag_place, ptrPARAM0x19[4], ptrPARAM0x19[5], ptrPARAM0x19[6], ptrPARAM0x19[7]);
+       Log_info5("PARAM0x19a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x19[0] & 0x200000) >> 21), ((ptrPARAM0x19[0] & 0x100000) >> 20), ((ptrPARAM0x19[0] & 0x3F000) >> 12), ((ptrPARAM0x19[0] & 0x800) >> 11));
+       Log_info5("PARAM0x19b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x19[1], ptrPARAM0x19[2], ptrPARAM0x19[3], ptrPARAM0x19[4]);
+       Log_info4("PARAM0x19b(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x19[5], ptrPARAM0x19[6], ptrPARAM0x19[7]);
+
+       Log_info5("PARAM0x41a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x41[0] & 0x200000) >> 21), ((ptrPARAM0x41[0] & 0x100000) >> 20), ((ptrPARAM0x41[0] & 0x3F000) >> 12), ((ptrPARAM0x41[0] & 0x800) >> 11));
+       Log_info5("PARAM0x41b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x41[1], ptrPARAM0x41[2], ptrPARAM0x41[3], ptrPARAM0x41[4]);
+       Log_info4("PARAM0x41b(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x41[5], ptrPARAM0x41[6], ptrPARAM0x41[7]);
+
+       Log_info5("PARAM0x42a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x42[0] & 0x200000) >> 21), ((ptrPARAM0x42[0] & 0x100000) >> 20), ((ptrPARAM0x42[0] & 0x3F000) >> 12), ((ptrPARAM0x42[0] & 0x800) >> 11));
+       Log_info5("PARAM0x42b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x42[1], ptrPARAM0x42[2], ptrPARAM0x42[3], ptrPARAM0x42[4]);
+       Log_info4("PARAM0x42b(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x42[5], ptrPARAM0x42[6], ptrPARAM0x42[7]);
+
+       Log_info5("PARAM0x43a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x43[0] & 0x200000) >> 21), ((ptrPARAM0x43[0] & 0x100000) >> 20), ((ptrPARAM0x43[0] & 0x3F000) >> 12), ((ptrPARAM0x43[0] & 0x800) >> 11));
+       Log_info5("PARAM0x43b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x43[1], ptrPARAM0x43[2], ptrPARAM0x43[3], ptrPARAM0x43[4]);
+       Log_info4("PARAM0x43b(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x43[5], ptrPARAM0x43[6], ptrPARAM0x43[7]);
+
+       Log_info5("PARAM0x44a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x44[0] & 0x200000) >> 21), ((ptrPARAM0x44[0] & 0x100000) >> 20), ((ptrPARAM0x44[0] & 0x3F000) >> 12), ((ptrPARAM0x44[0] & 0x800) >> 11));
+       Log_info5("PARAM0x44b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x44[1], ptrPARAM0x44[2], ptrPARAM0x44[3], ptrPARAM0x44[4]);
+       Log_info4("PARAM0x44b(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x44[5], ptrPARAM0x44[6], ptrPARAM0x44[7]);
     //Log_info1("TCC0: ERR reg %x", *((unsigned int *)0x02760120)); //DJDBG
 }
 #endif
@@ -602,7 +624,7 @@ Int SAP_start (DEV2_Handle device)
        // will be serviced and generate an interrupt even before the McASP is enabled.
        pDevExt->runState = 1;
        pDevExt->shutDown = 0;
-       //Log_info0 ("SAP_start runState=1 & ENABLE TRANSFERS");
+       Log_info1 ("SAP: %d, SAP_start runState=1 & ENABLE TRANSFERS", __LINE__);
        // enable interrupts and event servicing for this channel
        EDMA3_DRV_enableTransfer (hEdma, pDevExt->activeEdma, EDMA3_DRV_TRIG_MODE_EVENT);
 
@@ -705,8 +727,8 @@ Int SAP_issue (DEV2_Handle device)
     pDevExt->numQueued += 1;
 
     result = SAP_EDMA_setupXfer (device, pParam->hEdmaParam, parentEdma, pDevExt->errorEdma, pFrame);
-    //Log_info4("SAP_issue.%d, EDMA_setupXfer: Target EDMA: 0x%x, Parent Edma: 0x%x Error Edma: 0x%x",
-    //                __LINE__, pParam->hEdma, parentEdma, pDevExt->errorEdma);
+    Log_info4("SAP_issue.%d, EDMA_setupXfer: Target EDMA: 0x%x, Parent Edma: 0x%x Error Edma: 0x%x",
+                    __LINE__, pParam->hEdmaParam, parentEdma, pDevExt->errorEdma);
 
     /*if ((device->mode != DEV2_INPUT) && (gDmaParamsidx <=16))
        {
@@ -792,6 +814,7 @@ Int SAP_reclaim (DEV2_Handle device)
 
     // idle if necessary
         if (pDevExt->errorState == PAF_SIO_ERROR_FATAL) {
+               Log_info1("SAP_reclaim: PAF_SIO_ERROR_FATAL,  Before Idle for device 0x%x  ", device->mode);
             DEV2_idle (device, 1);
             return SIO2_EBADIO;
         }
@@ -807,6 +830,7 @@ Int SAP_reclaim (DEV2_Handle device)
     }
     //Log_info1("SAP_reclaim: After SEM Pend for mode: 0x%x", device->mode);
 
+#if 0
     // return error (owner must idle)
     if (pDevExt->errorState == PAF_SIO_ERROR_FATAL)
     {
@@ -814,6 +838,7 @@ Int SAP_reclaim (DEV2_Handle device)
         //TRACE_TERSE((&TR_MOD, "SAP_reclaim.%d, PAF_SIO_ERROR_FATAL: 0x%x", __LINE__, pDevExt->errorState));
         return PAF_SIO_ERROR_FATAL;
     }
+#endif
 
 #ifdef SAP_CACHE_SUPPORT
     // invalidate CACHE region if input -- use clean since
@@ -842,6 +867,7 @@ Int SAP_reclaim (DEV2_Handle device)
     /*if ((device->mode == DEV2_OUTPUT) && (pFrame->addr == NULL))
        SW_BREAKPOINT; */
 
+    Log_info1("SAP_reclaim: Exiting with SIO2_OK for device 0x%x  ", device->mode);
     //TRACE_VERBOSE((&TR_MOD, "SAP_reclaim.%d, exit SIO2_OK", __LINE__));
     return SIO2_OK;
 } // SAP_reclaim
@@ -1120,6 +1146,7 @@ Int SAP_shutdown (DEV2_Handle device)
     // reset counter
     pDevExt->numQueued = 0;
 
+    //DJDBG_SAP_EDMA_dumpParams(1);
     // make sure active is linked to error
         EDMA3_DRV_linkChannel (hEdma, pDevExt->activeEdma, pDevExt->errorEdma);
 
@@ -1167,8 +1194,6 @@ Void SAP_watchDog (Void)
         return;
     }
 
-    // GJ: Revisit, along with other context protections here.
-    // GJ: Is this architecture ok?
     // protect context
     Task_disable (); // needed since we may call SEM_post
     //oldMask = Hwi_disable ();
@@ -1402,7 +1427,7 @@ Int SAP_EDMA_setupParam (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32
     }
     else {
        //edmaConfig.opt |= EDMA3_DRV_OPT_SAM_SET_MASK (EDMA3_DRV_ADDR_MODE_FIFO); //DJDBG!!!
-       //edmaConfig.opt |= 1;
+       edmaConfig.opt |= 1;
     }
 
     // if regular transfer then enable interrupt with tcc code
@@ -1435,15 +1460,15 @@ Int SAP_EDMA_setupParam (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32
                //if(pDevExt->edmaWordSize == 2)
                //edmaConfig.srcAddr= (unsigned int)edmaConfig.srcAddr+ 2;
             edmaConfig.destBIdx = 0;
-            edmaConfig.destAddr = (unsigned int) &sap_OVER;
+            edmaConfig.destAddr = (unsigned int) &sap_OVER_4LANE;
+            edmaConfig.cCnt = 1;
         }
     }
     else {
         edmaConfig.destBIdx = 0;
+        edmaConfig.srcBIdx  = pDevExt->edmaWordSize;
         edmaConfig.destAddr = (unsigned int) (hPort->xbufAddr);
-
         if (addr) {
-            edmaConfig.srcBIdx  = pDevExt->edmaWordSize;
             edmaConfig.srcCIdx  = pDevExt->edmaWordSize * pDevExt->numSers ;
             edmaConfig.srcAddr  = addr;
             //Edma3_CacheFlush ((unsigned int) addr, (size+3)/4);
@@ -1460,7 +1485,8 @@ Int SAP_EDMA_setupParam (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32
     edmaConfig.srcAddr  = (unsigned int) getGlobalAddr(edmaConfig.srcAddr);
     edmaConfig.destAddr  = (unsigned int) getGlobalAddr(edmaConfig.destAddr);
 
-    //Log_info3("SAP: Inside SAP_EDMA_setupParam with targetEdma = 0x%x linked to childEdma = 0x%x & dest-addr: 0x%x", targetEdma, childEdma, edmaConfig.destAddr);
+    Log_info5("SAP: Inside SAP_EDMA_setupParam with size=0x%x, targetEdma = 0x%x, CCNT = %d with dest-addr: 0x%x and OPT=0x%x", size, targetEdma, edmaConfig.cCnt, edmaConfig.destAddr, edmaConfig.opt);
+    Log_info5("SAP: Inside SAP_EDMA_setupParam with aCnt=0x%x, bCnt = 0x%x, destBIdx = 0x%x destCIdx: 0x%x and bCntReload=0x%x", edmaConfig.aCnt, edmaConfig.bCnt, edmaConfig.destBIdx, edmaConfig.destCIdx, edmaConfig.bCntReload);
 
     EDMA3_DRV_setPaRAM (hEdma, targetEdma, &edmaConfig);