]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_dsp/sap/sap.c
PASDK-218: Fixed a bug involving insufficient num of spare EDMA params used by the...
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / sap / sap.c
index 065dacc30a1e15ed7592b34d62e88623e4832759..862494d54ed62c3132f2892fd8b94f73d6c96f4c 100644 (file)
@@ -66,6 +66,7 @@ All rights reserved.
 #include <ti/csl/cslr_device.h>
 
 #define EDMA_HINV NULL
+#define EDMA_NUM_PARAMS 6
 
 #include "sap_mcasp.h"
 #include <pafsio.h>
@@ -102,20 +103,26 @@ 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)
+void 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 *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]
+       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 *ptrPARAM0x48 = (unsigned int *)0x02704910; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[24]
+       unsigned int *ptrPARAM0x45 = (unsigned int *)0x027048A0; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[69]
+       unsigned int *ptrPARAM0x46 = (unsigned int *)0x027048C0; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[70]
+       unsigned int *ptrPARAM0x47 = (unsigned int *)0x027048E0; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[71]
+       unsigned int *ptrPARAM0x48 = (unsigned int *)0x02704900; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[72]
+       unsigned int *ptrPARAM0x49 = (unsigned int *)0x02704920; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[73]
+       unsigned int *ptrPARAM0x4A = (unsigned int *)0x02704940; // ((*((EDMA3_CCRL_Regs *) 0x02700000)).PARAMENTRY)[74]
 
        //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): 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("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]);
 
@@ -131,10 +138,39 @@ void DJDBG_SAP_EDMA_dumpParams(int tag_place)
        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
+       Log_info5("PARAM0x48a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x48[0] & 0x200000) >> 21), ((ptrPARAM0x48[0] & 0x100000) >> 20), ((ptrPARAM0x48[0] & 0x3F000) >> 12), ((ptrPARAM0x48[0] & 0x800) >> 11));
+       Log_info5("PARAM0x48b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x48[1], ptrPARAM0x48[2], ptrPARAM0x48[3], ptrPARAM0x48[4]);
+       Log_info4("PARAM0x48b(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x48[5], ptrPARAM0x48[6], ptrPARAM0x48[7]);*/
+
+       Log_info5("PARAM0x18a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x18[0] & 0x200000) >> 21), ((ptrPARAM0x18[0] & 0x100000) >> 20), ((ptrPARAM0x18[0] & 0x3F000) >> 12), ((ptrPARAM0x18[0] & 0x800) >> 11));
+       Log_info5("PARAM0x18b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x18[1], ptrPARAM0x18[2], ptrPARAM0x18[3], ptrPARAM0x18[4]);
+       Log_info4("PARAM0x18c(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x18[5], ptrPARAM0x18[6], ptrPARAM0x18[7]);
+
+       Log_info5("PARAM0x45a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x45[0] & 0x200000) >> 21), ((ptrPARAM0x45[0] & 0x100000) >> 20), ((ptrPARAM0x45[0] & 0x3F000) >> 12), ((ptrPARAM0x45[0] & 0x800) >> 11));
+       Log_info5("PARAM0x45b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x45[1], ptrPARAM0x45[2], ptrPARAM0x45[3], ptrPARAM0x45[4]);
+       Log_info4("PARAM0x45c(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x45[5], ptrPARAM0x45[6], ptrPARAM0x45[7]);
+
+       Log_info5("PARAM0x46a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x46[0] & 0x200000) >> 21), ((ptrPARAM0x46[0] & 0x100000) >> 20), ((ptrPARAM0x46[0] & 0x3F000) >> 12), ((ptrPARAM0x46[0] & 0x800) >> 11));
+       Log_info5("PARAM0x46b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x46[1], ptrPARAM0x46[2], ptrPARAM0x46[3], ptrPARAM0x46[4]);
+       Log_info4("PARAM0x46c(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x46[5], ptrPARAM0x46[6], ptrPARAM0x46[7]);
+
+       Log_info5("PARAM0x47a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x47[0] & 0x200000) >> 21), ((ptrPARAM0x47[0] & 0x100000) >> 20), ((ptrPARAM0x47[0] & 0x3F000) >> 12), ((ptrPARAM0x47[0] & 0x800) >> 11));
+       Log_info5("PARAM0x47b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x47[1], ptrPARAM0x47[2], ptrPARAM0x47[3], ptrPARAM0x47[4]);
+       Log_info4("PARAM0x47c(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x47[5], ptrPARAM0x47[6], ptrPARAM0x47[7]);
+
+       Log_info5("PARAM0x48a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x48[0] & 0x200000) >> 21), ((ptrPARAM0x48[0] & 0x100000) >> 20), ((ptrPARAM0x48[0] & 0x3F000) >> 12), ((ptrPARAM0x48[0] & 0x800) >> 11));
+       Log_info5("PARAM0x48b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x48[1], ptrPARAM0x48[2], ptrPARAM0x48[3], ptrPARAM0x48[4]);
+       Log_info4("PARAM0x48c(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x48[5], ptrPARAM0x48[6], ptrPARAM0x48[7]);
+
+       Log_info5("PARAM0x49a(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x49[0] & 0x200000) >> 21), ((ptrPARAM0x49[0] & 0x100000) >> 20), ((ptrPARAM0x49[0] & 0x3F000) >> 12), ((ptrPARAM0x49[0] & 0x800) >> 11));
+       Log_info5("PARAM0x49b(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x49[1], ptrPARAM0x49[2], ptrPARAM0x49[3], ptrPARAM0x49[4]);
+       Log_info4("PARAM0x49c(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x49[5], ptrPARAM0x49[6], ptrPARAM0x49[7]);
+
+       Log_info5("PARAM0x4Aa(%d): ITCINTEN: 0x%02x, TCINTEN: 0x%02x, TCC: 0x%02x, TCCMODE: %d", tag_place, ((ptrPARAM0x4A[0] & 0x200000) >> 21), ((ptrPARAM0x4A[0] & 0x100000) >> 20), ((ptrPARAM0x4A[0] & 0x3F000) >> 12), ((ptrPARAM0x4A[0] & 0x800) >> 11));
+       Log_info5("PARAM0x4Ab(%d): SRC: 0x%08x, A_B_CNT: 0x%08x, DST: 0x%08x,  SRC_DST_BIDX: 0x%08x", tag_place, ptrPARAM0x4A[1], ptrPARAM0x4A[2], ptrPARAM0x4A[3], ptrPARAM0x4A[4]);
+       Log_info4("PARAM0x4Ac(%d): LINK_BCNTRLD: 0x%08x, SRC_DST_CIDX: 0x%08x, CCNT: 0x%08x", tag_place, ptrPARAM0x4A[5], ptrPARAM0x4A[6], ptrPARAM0x4A[7]);
+
+       Log_info1("TCC0: ERR reg %x", *((unsigned int *)0x02760120)); //DJDBG
 }
 #endif
 // .............................................................................
@@ -231,11 +267,17 @@ Void SAP_init (Void)
 
 // -----------------------------------------------------------------------------
 
+int gSapInput_ControlOpen = 0;
+int gSapOutput_ControlOpen = 0;
+
+int gSapInput_ControlClose = 0;
+int gSapOutput_ControlClose = 0;
+
 Int SAP_ctrl (DEV2_Handle device, Uns code, Arg arg)
 {
     SAP_DeviceExtension *pDevExt = (SAP_DeviceExtension *)device->object;
     const SAP_Params *pParams;
-    Int result = SIO2_OK;
+    Int i, result = SIO2_OK;
     EDMA3_DRV_Handle   hEdma;
     //TRACE_GEN((&TR_MOD, "SAP_ctrl.%d (0x%x) code = 0x%x", __LINE__, device, code));
 
@@ -262,6 +304,11 @@ Int SAP_ctrl (DEV2_Handle device, Uns code, Arg arg)
             if (!( pParams = (const SAP_Params *) arg ))
                 return SIO2_OK;
 
+            if(device->mode == DEV2_OUTPUT)
+               gSapOutput_ControlOpen++;
+            else
+               gSapInput_ControlOpen++;
+
             if (result = SAP_FTABLE_config (device, pParams))
                 return result;
 
@@ -285,10 +332,29 @@ Int SAP_ctrl (DEV2_Handle device, Uns code, Arg arg)
                                hEdma = hEdma0;
                        else if (pParams->sio.moduleNum == 1 || pParams->sio.moduleNum == 2)
                                hEdma = hEdma1;
+
             if (pDevExt->activeEdma != EDMA_HINV) {
                                EDMA3_DRV_freeChannel (hEdma, pDevExt->activeEdma);
-                            pDevExt->activeEdma = EDMA_HINV;
-                        }
+                               pDevExt->activeEdma = EDMA_HINV;
+                       }
+
+            if(device->mode == DEV2_INPUT)
+               gSapInput_ControlClose++;
+            else
+               gSapOutput_ControlClose++;
+
+            for (i=0; i < pDevExt->numEdmaParams; i++) {
+               if (pDevExt->edmaParams[i].hEdmaParam != EDMA_HINV)
+               {
+                       EDMA3_DRV_freeChannel (hEdma, pDevExt->edmaParams[i].hEdmaParam);
+                       pDevExt->edmaParams[i].hEdmaParam = EDMA_HINV;
+               }
+            }
+
+            if (pDevExt->errorEdma != EDMA_HINV) {
+                               EDMA3_DRV_freeChannel (hEdma, pDevExt->errorEdma);
+                               pDevExt->errorEdma = EDMA_HINV;
+                       }
 
             if (!(pParams = pDevExt->pParams))
                 return SIO2_OK;
@@ -545,6 +611,7 @@ Int SAP_idle (DEV2_Handle device, Bool flush)
 
     // signal stopped
     pDevExt->runState = 0;
+    Log_info0("SAP_idle: runState = 0");
 
     // reset errorState
     pDevExt->errorState = PAF_SIO_ERROR_NONE;
@@ -566,15 +633,8 @@ Int SAP_start (DEV2_Handle device)
     int result;
     EDMA3_DRV_Handle hEdma;
 
-    //TRACE_GEN((&TR_MOD, "SAP_start.%d (0x%x)", __LINE__, device));
+    Log_info2("SAP_start.%d (0x%x)", __LINE__, device);
 
-    // signal we have started
-    //    we change the state here since we have already moved a frame from the 
-    //    todevice queue to the xferQue. If an error occurs during one of the 
-    //    following resets/enables then we need to have runState !=0 in order
-    //    for SAP_idle to properly cleanup. Moreover, the following resets/enables
-    //    do not (and are now required not to) depend on runState being 0.
-    //pDevExt->runState = 1;
     // Assume todevice queue is not empty -- how else could we be here?
     pFrame = (DEV2_Frame *) Queue_get (device->todevice);
 
@@ -599,20 +659,22 @@ Int SAP_start (DEV2_Handle device)
     }
 
     // enable DMA processing
-
+    if (device->mode == DEV2_OUTPUT)
+       Log_info3("SAP_start.%d, pDevExt->activeEdma 0x%x (pDevExt->errorEdma = 0x%x)",
+                           __LINE__, pDevExt->activeEdma, pDevExt->errorEdma);
     // config active xfer for this buffer
     result = SAP_EDMA_setupXfer(device, pDevExt->activeEdma, EDMA_HINV, pDevExt->errorEdma, pFrame);
 
-    //Log_info3("SAP_start.%d, pDevExt->activeEdma 0x%x (pDevExt->errorEdma = 0x%x)",
-      //              __LINE__, pDevExt->activeEdma, pDevExt->errorEdma);
+
        // signal we have started -- this must come before last enable to prevent a race
        // condition where the initial EDMA transfer is very small (e.g. due to startClocks)
        // and completes before any further instructions in this thread are executed.
        // This comes before the EDMA enable since, if the # of samples is 1, then the EDMA
        // will be serviced and generate an interrupt even before the McASP is enabled.
-       pDevExt->runState = 1;
-       pDevExt->shutDown = 0;
-       Log_info1 ("SAP: %d, SAP_start runState=1 & ENABLE TRANSFERS", __LINE__);
+    pDevExt->runState = 1;
+    pDevExt->shutDown = 0;
+    if (device->mode == DEV2_OUTPUT)
+       Log_info2 ("SAP: %d, SAP_start runState=1 & ENABLE TRANSFERS for activeEdma = 0x%x", __LINE__, pDevExt->activeEdma);
        // enable interrupts and event servicing for this channel
        EDMA3_DRV_enableTransfer (hEdma, pDevExt->activeEdma, EDMA3_DRV_TRIG_MODE_EVENT);
 
@@ -640,7 +702,8 @@ Int SAP_issue (DEV2_Handle device)
     SAP_EDMA_Param *pParam;
     XDAS_UInt32 parentEdma;
 
-    //TRACE_GEN((&TR_MOD, "SAP_issue.%d (0x%x)", __LINE__, device));
+    if (device->mode == DEV2_OUTPUT)
+       Log_info1("SAP_issue for output device with pDevExt->errorState = 0x%x", pDevExt->errorState);
 
     if ((device->mode == DEV2_OUTPUT) && (pDevExt->errorState >= PAF_SIO_ERROR_ERRBUF_XFER))
     {
@@ -686,6 +749,9 @@ Int SAP_issue (DEV2_Handle device)
            parentEdma = ((SAP_EDMA_Param *) tail->misc)->hEdmaParam;
        }
 
+       //if (device->mode == DEV2_OUTPUT)
+          Log_info2("SAP_issue: Determined Parent = 0x%x for device = 0x%x", parentEdma, device->mode );
+
     // get frame and parameter table to use; ints off => non-atomic OK
     //     dont need to check for empty queues since were here then todevice
     //     must have a frame placed there by the SIO_issue layer.
@@ -698,7 +764,7 @@ Int SAP_issue (DEV2_Handle device)
     pParam = (SAP_EDMA_Param *) Queue_dequeue (Queue_handle(&pDevExt->paramQue));
 
     if (pParam->hEdmaParam == NULL)
-       Log_info0("SAP_issue: hEdma value is NULL");
+       Log_info1("SAP_issue: hEdma value is NULL for device = 0x%x", device->mode);
     // set misc argument to pParam so get enqueue later
     pFrame->misc = (Arg) pParam;
 
@@ -715,8 +781,12 @@ 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->hEdmaParam, parentEdma, pDevExt->errorEdma);
+    if (device->mode == DEV2_OUTPUT)
+    {
+       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))
        {
@@ -730,6 +800,9 @@ Int SAP_issue (DEV2_Handle device)
 
         pDevExt->shutDown = 0;
 
+        //if (device->mode == DEV2_OUTPUT)
+                       //SAP_EDMA_dumpParams(1);
+
     // special case enables when not yet started
     if (pDevExt->runState == 0) {
        gSAPSpecialCase++;
@@ -792,11 +865,12 @@ Int SAP_reclaim (DEV2_Handle device)
 #endif
 
     //TRACE_GEN((&TR_MOD, "SAP_reclaim.%d (0x%x)", __LINE__, device));
-
+    if (device->mode == DEV2_OUTPUT)
+               Log_info2("SAP_reclaim for output device with pDevExt->errorState = 0x%x & runState: 0x%x", pDevExt->errorState, pDevExt->runState);
     // must be running and  error free 
     if ((!pDevExt->runState) || (pDevExt->errorState))
     {
-        //TRACE_GEN((&TR_MOD, "SAP_reclaim.%d, not runState: 0x%x", __LINE__, pDevExt->errorState));
+        Log_info3("SAP_reclaim.%d, not runState: 0x%x, mode = 0x%x", __LINE__, pDevExt->errorState, device->mode);
         return SIO2_EBADIO;
     }
 
@@ -807,7 +881,7 @@ Int SAP_reclaim (DEV2_Handle device)
             return SIO2_EBADIO;
         }
 
-       // Log_info0("SAP_reclaim: Before SEM Pend");
+       Log_info1("SAP_reclaim: Before SEM Pend for mode: 0x%x", device->mode);
 
     // wait for ISR to signal block completion
     //TRACE_VERBOSE((&TR_MOD, "SAP_reclaim.%d wait for ISR to signal block completion", __LINE__));
@@ -816,14 +890,14 @@ Int SAP_reclaim (DEV2_Handle device)
        Log_info0("SAP_reclaim, SYS_ETIMEOUT");
         return SIO2_ETIMEOUT;
     }
-    //Log_info1("SAP_reclaim: After SEM Pend for mode: 0x%x", device->mode);
+    Log_info1("SAP_reclaim: After SEM Pend for mode: 0x%x", device->mode);
 
-#if 0
+#if 1
     // return error (owner must idle)
     if (pDevExt->errorState == PAF_SIO_ERROR_FATAL)
     {
        DEV2_idle (device, 1);
-        //TRACE_TERSE((&TR_MOD, "SAP_reclaim.%d, PAF_SIO_ERROR_FATAL: 0x%x", __LINE__, pDevExt->errorState));
+        Log_info2("SAP_reclaim.%d, PAF_SIO_ERROR_FATAL: 0x%x", __LINE__, pDevExt->errorState);
         return PAF_SIO_ERROR_FATAL;
     }
 #endif
@@ -900,7 +974,8 @@ Int SAP_open (DEV2_Handle device, String name)
     pDevExt->firstTCC = 0;
     pDevExt->optLevel = 0;
     pDevExt->numParamSetup = 0;
-    pDevExt->numEdmaParams = 4;
+    pDevExt->numEdmaParams = EDMA_NUM_PARAMS;          // We need more than 4 spare params to handle the immediate transition from Unknown
+                                                                                               // to a Known program. Cheap resource to spend.
 
     // use dev match to fetch function table pointer for SAP
     DEV2_match(SAP_NAME, &entry);
@@ -988,7 +1063,7 @@ Int SAP_config (DEV2_Handle device, const SAP_Params *pParams)
        }
        else
        {
-               Que_num = 1;
+               Que_num = 0;
                pDevExt->activeEdma = CSL_EDMACC_0_McASP_0_XEVT;
        }
     }
@@ -1003,7 +1078,7 @@ Int SAP_config (DEV2_Handle device, const SAP_Params *pParams)
                }
                else
                {
-                       Que_num = 1;
+                       Que_num = 0;
                        pDevExt->activeEdma = CSL_EDMACC_1_McASP_1_XEVT;
                }
     }
@@ -1018,7 +1093,7 @@ Int SAP_config (DEV2_Handle device, const SAP_Params *pParams)
                }
                else
                {
-                       Que_num = 1;
+                       Que_num = 0;
                        pDevExt->activeEdma = CSL_EDMACC_1_McASP_2_XEVT;
                }
     }
@@ -1136,7 +1211,7 @@ Int SAP_shutdown (DEV2_Handle device)
 
     //DJDBG_SAP_EDMA_dumpParams(1);
     // make sure active is linked to error
-        EDMA3_DRV_linkChannel (hEdma, pDevExt->activeEdma, pDevExt->errorEdma);
+    EDMA3_DRV_linkChannel (hEdma, pDevExt->activeEdma, pDevExt->errorEdma);
 
     // think this is better (from SIO_idle for standard model )
     // refill frame list -- so user needn't call reclaim, which may cause Rx underrun.
@@ -1187,12 +1262,12 @@ Void SAP_watchDog (Void)
     //oldMask = Hwi_disable ();
 
 
-    //TRACE_VERBOSE((&TR_MOD, "%s.%d: devices loop, numDevices = %d", __FUNCTION__, __LINE__, dapDrv.numDevices));
+    //Log_info3("%s.%d: devices loop, numDevices = %d", __FUNCTION__, __LINE__, sapDrv.numDevices);
 
     for (i=0; i < sapDrv.numDevices; i++) {
         device  = sapDrv.device[i];
 
-        //TRACE_VERBOSE((&TR_MOD, "%s.%d, devices loop start, device = 0x%x", __FUNCTION__, __LINE__, device));
+        //Log_info3("%s.%d, devices loop start, device = 0x%x", __FUNCTION__, __LINE__, device);
 
         pDevExt = (SAP_DeviceExtension *) device->object;
 
@@ -1213,7 +1288,11 @@ Void SAP_watchDog (Void)
             if(device->mode == DEV2_INPUT)
                gSapWatchDogIn++;
             else
-                gSapWatchDogOut++;
+            {
+               //if (gSapWatchDogOut == 0)
+                       //SAP_EDMA_dumpParams(1);
+               gSapWatchDogOut++;
+            }
 
             //TRACE_TERSE((&TR_MOD, "SAP_watchDog.%d, PAF_SIO_ERROR_FATAL: 0x%x", __LINE__, pDevExt->errorState));
            /* if(gSapWatchDogThrottle == 0) //DJDBG
@@ -1291,7 +1370,10 @@ void SAP_isrCallback (Uint32 tcc, EDMA3_RM_TccStatus status, Ptr context)
             pDevExt->numQueued -= 1;
             //gIsrCnt++;
             if (device->mode == 1)
+               {
                gIsrOutputCnt++;
+               //Log_info1("SAP isrCallback for 0x%x", pDevExt->activeEdma);
+               }
             else
                gIsrInputCnt++;
             // place frame onto user queue and signal user thread
@@ -1366,9 +1448,14 @@ Int SAP_EDMA_setupXfer (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32
     }
     SAP_DMA_FTABLE_setupParam (device, targetEdma, childEdma, (XDAS_UInt32) pFrame->addr, pFrame->size);
 
+    if (device->mode == DEV2_OUTPUT)
+       Log_info4("SAP: Inside SAP_EDMA_setupXfer with childEdma=0x%x & targetEdma = 0x%x; pFrame->addr = 0x%x, pFrame->size=0x%x", childEdma, targetEdma, pFrame->addr, pFrame->size);
+
     if (parentEdma != EDMA_HINV)
         EDMA3_DRV_linkChannel (hEdma, parentEdma, targetEdma);
 
+    if (device->mode == DEV2_OUTPUT)
+               Log_info3("SAP: Inside SAP_EDMA_setupXfer linked targetEdma = 0x%x with parentEdma=0x%x on Edma=0x%x", targetEdma, parentEdma, hEdma);
 
     Hwi_restore (key); //DJDBG
 
@@ -1464,7 +1551,7 @@ Int SAP_EDMA_setupParam (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32
         else {
             edmaConfig.srcBIdx  = 0;
             edmaConfig.srcAddr  = (unsigned int) &sap_UNDER[0];
-#if 1
+#if 0
             //edmaConfig.cCnt = (SAP_UNDER_LEN * sizeof(int))/(edmaConfig.aCnt * edmaConfig.bCnt); //DJDBG
             edmaConfig.cCnt = SAP_UNDER_LEN; //DJDBG, if underrun have frame of silence
 #endif
@@ -1473,14 +1560,16 @@ 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_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);
 
     // link child xfer
     if (childEdma != EDMA_HINV)
         EDMA3_DRV_linkChannel (hEdma, targetEdma, childEdma);
 
+    if (device->mode == DEV2_OUTPUT) {
+        Log_info5("SAP: Inside SAP_EDMA_setupParam: 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: aCnt=0x%x, bCnt = 0x%x; linked targetEdma = 0x%x with childEdma=0x%x on Edma=0x%x", edmaConfig.aCnt, edmaConfig.bCnt, targetEdma, childEdma, hEdma );
+        }
+
     return SIO2_OK;
 } //SAP_setupParam