]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/commitdiff
* Fixes towards PASDK-53 include --- PART II (BIOS6 Queue API usage CleanUp:
authorGovind Jeyaram <govind.j@ti.com>
Tue, 17 Jan 2017 21:14:51 +0000 (13:14 -0800)
committerFrank Livingston <frank-livingston@ti.com>
Fri, 27 Jan 2017 23:18:10 +0000 (17:18 -0600)
1. (sap.c) - Add debug counters; reduce underrun frame-length (impacts outputStartClocks); remove unnecessary Edma3_CacheFlush call.
Remove context-protection around swapHdmi, experimentally - to unblock UART intr mainly.
Remove TEST_MULTICHANNEL from the file-level.
2. (mib.c, mob.c) Fix Queue API usage, to remove compiler warnings about unsavoury typecasting.
3. (audioStreamInpProc.c) minor cleanup for removing compiler warnings.

pasdk/test_dsp/framework/audioStreamInpProc.c
pasdk/test_dsp/mib/mib.c
pasdk/test_dsp/mob/mob.c
pasdk/test_dsp/sap/sap.c

index 937b61ca2c732b34b9a85628f99173b5f320609e..000c4b10616b41a8f0e254199517a82bf0703431 100644 (file)
@@ -2844,8 +2844,8 @@ PAF_ASIT_decodeInfo(
     Int tempVar;
 #endif
     // FL: revisit
-    Int size;
-    PAF_InpBufConfig *pIpBufConfig;
+    //Int size;
+    //PAF_InpBufConfig *pIpBufConfig;
 
     pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
     as = pAstCfg->as;
index ebb5d688d303c2479918abbc0000888f0d8a3fb0..43327b34661badfbe9151895e6ede5ccd29617e3 100644 (file)
@@ -66,6 +66,7 @@ typedef xdc_UShort MdUns;
 typedef xdc_Char SmInt;
 typedef xdc_UChar SmUns;
 
+#define SW_BREAKPOINT       asm( " SWBP 0" );
 
 extern const ti_sysbios_heaps_HeapMem_Handle heapMemDdr3;
 #define HEAPMALLOC (IHeap_Handle)heapMemDdr3
@@ -353,10 +354,11 @@ Int DIB_issue (DEV2_Handle device)
     if (!pBufConfig || !pBufConfig->pBufStatus)
         return SIO2_EINVAL;
 
-    Queue_put (device->fromdevice, srcFrame);
+    Queue_put (device->fromdevice, (Queue_Elem *)srcFrame);
 
+//GJ: PAF_SIO_REQUEST_AUTO, Not Supported, yet.
     if (srcFrame->arg == PAF_SIO_REQUEST_AUTO) {
-
+#if 0
         // if not yet running, prime input buffer
         if (pDevExt->syncState == SYNC_NONE) {
 
@@ -387,6 +389,7 @@ Int DIB_issue (DEV2_Handle device)
         status = DIB_FTABLE_issueChild (device, &pDevExt->bufConfig, pDevExt->autoRequestSize, 0);
         if (status)
             return status;
+#endif
     }
     else if (srcFrame->arg == PAF_SIO_REQUEST_NEWFRAME) {
 
@@ -439,7 +442,8 @@ Int DIB_reclaim (DEV2_Handle device)
     // .........................................................................
 
     if (dstFrame->arg == PAF_SIO_REQUEST_AUTO) {
-
+//GJ: PAF_SIO_REQUEST_AUTO - not supported, yet.
+#if 0
         Log_info0("DIB: At case = PAF_SIO_REQUEST_AUTO"); // GJ Debug
 
         // verify set up by prior DIB_issue()
@@ -500,6 +504,8 @@ Int DIB_reclaim (DEV2_Handle device)
             if (status)
                 return status;
         }
+
+#endif
     } //dstFrame->arg == PAF_SIO_REQUEST_AUTO
 
     // .........................................................................
@@ -795,7 +801,7 @@ Int DIB_idle (DEV2_Handle device, Bool flush)
         Queue_enqueue (device->fromdevice, Queue_dequeue (device->todevice));
 
     while (!Queue_empty (device->fromdevice))
-        Queue_enqueue (&((SIO2_Handle) device)->framelist, Queue_dequeue (device->fromdevice));
+        Queue_enqueue (Queue_handle(&((SIO2_Handle) device)->framelist), Queue_dequeue (device->fromdevice));
 
     status = DIB_FTABLE_reset (device, NULL);
     if (status)
@@ -865,7 +871,7 @@ Int DIB_open (DEV2_Handle device, String name)
         frame = DEV2_mkframe (0, 0, 0);
         if (!frame)
             return SYS_EALLOC;
-        Queue_put (&((SIO2_Handle)pChild)->framelist, frame);
+        Queue_put (Queue_handle(&((SIO2_Handle)pChild)->framelist), (Queue_Elem *) frame);
     }
 
     // open underlying device
@@ -1049,7 +1055,7 @@ Int DIB_getSync (DEV2_Handle device, PAF_InpBufConfig *pBufConfig )
     // syncScan makes this assumption in order to perform an efficient scan.
     {
         int sizeofStride = pBufConfig->sizeofElement*pBufConfig->stride*pDevExt->pcmFrameLength;
-        pBufConfig->sizeofBuffer = pBufConfig->allocation/sizeofStride*sizeofStride;
+        pBufConfig->sizeofBuffer = (pBufConfig->allocation)/sizeofStride*sizeofStride;
     }
 
     if (pDevExt->sourceSelect == PAF_SOURCE_DSD1 || pDevExt->sourceSelect == PAF_SOURCE_DSD2 ||
@@ -1111,11 +1117,13 @@ Int DIB_issueChild (DEV2_Handle device, PAF_InpBufConfig  *pBufConfig, int size,
     // the buffer is a multiple of 8 and so, by using this single statement, we
     // ensure all requests are a mulitple 8 even if they need to be split across
     // the buffer wrap point.
-    if (pBufConfig->stride == 8)
-        size = (size + 7) & ~0x7;
+    
+    /* GJ: The below is dMAX specific & unnecessary now w/ EDMA*/
+    //if (pBufConfig->stride == 8)
+        //size = (size + 7) & ~0x7;
 
     // convert to bytes
-    size = (size * pBufConfig->sizeofElement); //To Do: +2 GJ : Temporary, to get past initial hiccup.  // GJ Debug
+    size *= pBufConfig->sizeofElement;
     //size *= 4;
 
     // if request crosses circular buffer boundary then split into two requests
@@ -1140,14 +1148,14 @@ Int DIB_issueChild (DEV2_Handle device, PAF_InpBufConfig  *pBufConfig, int size,
 
     for (i=0; i < 2; i++) {
         if (sizes[i]) {
-            dstFrame = Queue_get (&((SIO2_Handle) pChild)->framelist);
+            dstFrame = Queue_get (Queue_handle(&((SIO2_Handle) pChild)->framelist));
             if (dstFrame == (DEV2_Frame *)&((SIO2_Handle) pChild)->framelist)
                 return DIBERR_UNSPECIFIED;
             dstFrame->arg = (Arg) pBufConfig;
 
             dstFrame->addr = pBufConfig->futureHead.pVoid;
             dstFrame->size = sizes[i];
-            Queue_put (pChild->todevice, dstFrame);
+            Queue_put (pChild->todevice, (Queue_Elem *)dstFrame);
             status = DEV2_issue (pChild);
             if (status)
                 return DIBERR_UNSPECIFIED;
@@ -1190,7 +1198,7 @@ Int DIB_reclaimChild (DEV2_Handle device, PAF_InpBufConfig *pBufConfig)
     srcFrame = Queue_get (pChild->fromdevice);
     //Log_info2("DIB_reclaimChild.%d calling Queue_put(), srcFrame = 0x%x", __LINE__, srcFrame); // GJ Debug
     //TRACE((&TR_MOD, "DIB_reclaimChild.%d calling Queue_put(), srcFrame = 0x%x\n", __LINE__, srcFrame));
-    Queue_put (&((SIO2_Handle) pChild)->framelist, srcFrame);
+    Queue_put (Queue_handle(&((SIO2_Handle) pChild)->framelist), (Queue_Elem *)srcFrame);
 
     // Only for non-fill requests do we update ptrs
     if (srcFrame->addr != NULL) {
@@ -1342,7 +1350,7 @@ Int DIB_reset (DEV2_Handle device, PAF_InpBufConfig *pBufConfig)
 
         // compute and use *effective buffer size*
         sizeofStride = pBufConfig->sizeofElement*pBufConfig->stride;
-        pBufConfig->sizeofBuffer = pBufConfig->allocation/sizeofStride*sizeofStride;
+        pBufConfig->sizeofBuffer = (pBufConfig->allocation)/sizeofStride*sizeofStride; //GJ: Debug - Account for EDMA padding
 
         //hack -- save status context for use in close
         pDevExt->pInpBufStatus = pBufConfig->pBufStatus;
@@ -1426,7 +1434,7 @@ Int DIB_syncScan (DEV2_Handle device, PAF_InpBufConfig *pBufConfig, XDAS_UInt32
     scanState = pDevExt->scanState;
     pSync     = pDevExt->pSync.pMdInt;
 
-    Log_info3("DIB: Entered DIB_syncScan with zeroCount = %d & scanState = %d, pSync = 0x%x", zeroCount, scanState, pSync); // GJ Debug
+    Log_info4("DIB: Entered DIB_syncScan with zeroCount = %d & scanState = %d, stride = %d, pSync = 0x%x", zeroCount, scanState, stride, pSync); // GJ Debug
 
     // scan until out of available data or a sync found
     for (i=0; i < numLeft; i++) {
index aa1eca1e8bd50a440c94aa7c0b79198ce746f6a1..184a23d61dc77239f607f4dca992159baba5739d 100644 (file)
@@ -168,6 +168,14 @@ Int DOB_close (DEV2_Handle device)
     return (SIO2_EBADIO);
 } // DOB_close
 
+// GJ Debug Counters
+Uint32 gMobStart_Idle=0;
+Uint32 gMobIdle_ClocksElse=0;
+Uint32 gMobIdle_ClocksIf=0;
+Uint32 gMobOutRateX_Cnt=0;
+Uint32 gMobStart_Open=0;
+Uint32 gMobStart_Clocks=0;
+Uint32 gMobRateXChanged=0;
 // -----------------------------------------------------------------------------
 
 Int DOB_ctrl (DEV2_Handle  device, Uns code, Arg arg)
@@ -191,6 +199,7 @@ Int DOB_ctrl (DEV2_Handle  device, Uns code, Arg arg)
                     return status;
 
                 status = DOB_FTABLE_startClocks (device);
+                gMobStart_Idle++;
             }
             break;
 
@@ -198,6 +207,7 @@ Int DOB_ctrl (DEV2_Handle  device, Uns code, Arg arg)
             //TODO: check that we are idle?
             pDevExt->rateX = 1.;            
             status = DEV2_ctrl (pChild, code, arg);
+            gMobStart_Open++;
             if (status)
                 return status;
             break;
@@ -207,8 +217,11 @@ Int DOB_ctrl (DEV2_Handle  device, Uns code, Arg arg)
             float rateX = *(float *)arg;
             int errno = SYS_OK;
 
+            gMobOutRateX_Cnt++;
+
             if (pDevExt->rateX != rateX) {
-                status = DEV2_idle (device,0);
+               status = DEV2_idle (device,0);
+               gMobRateXChanged++;
                 if (status)
                     return status;
                 errno = DOBERR_RATECHANGE;
@@ -234,6 +247,7 @@ Int DOB_ctrl (DEV2_Handle  device, Uns code, Arg arg)
             if (arg) {
                 // flush data (and keep clocks)
                 DOB_FTABLE_shutdown (device);
+                gMobIdle_ClocksIf++;
                 status = DEV2_ctrl (pChild, PAF_SIO_CONTROL_IDLE_WITH_CLOCKS, arg);
                 if (!status)
                     pDevExt->state = DOB_STATE_CLOCKING;
@@ -242,6 +256,7 @@ Int DOB_ctrl (DEV2_Handle  device, Uns code, Arg arg)
                 // truncate data (stops clocks)
                 DEV2_idle (device, 0);
                 status = DEV2_ctrl (pChild, code, arg);
+                gMobIdle_ClocksElse++;
             }
             break;
 
@@ -301,7 +316,7 @@ Int DOB_idle (DEV2_Handle device, Bool flush)
     return status;
 } // DOB_idle
 
-static Queue_Handle dobFrameQue;
+static Queue_Struct dobFrameQue;
 
 // -----------------------------------------------------------------------------
 // This function is called before main and hence no devices yet running.
@@ -315,9 +330,10 @@ Void DOB_init (Void)
 
        Error_init(&eb);
 
-    dobFrameQue = Queue_create (NULL, &eb);
-    if (!dobFrameQue) {
-        Log_info1 ("DOB_init failed after Queue_create:", SYS_EALLOC);
+    //dobFrameQue = Queue_create (NULL, &eb);
+       Queue_construct (&dobFrameQue, NULL);
+    if (Queue_handle(&dobFrameQue) == NULL) {
+        Log_info1 ("DOB_init failed after Queue_construct:", SYS_EALLOC);
         return;
     }
 
@@ -344,7 +360,7 @@ Int DOB_issue (DEV2_Handle device)
     if (!pParentFrame->addr)
         return SIO2_EINVAL;
     pBufConfig = (PAF_OutBufConfig *) pParentFrame->addr;
-    Queue_put (device->fromdevice, pParentFrame);
+    Queue_put (device->fromdevice, (Queue_Elem *)pParentFrame);
 
     Log_info0("Still In MOB Issue - 1");
 
@@ -391,7 +407,7 @@ Int DOB_issue (DEV2_Handle device)
         // will be <= this size. Effectively each DEV2_Frame is assigned a unique
         // segment of the buffer. This simplifies bookeeping and limits passing
         // side information between issue and reclaim.
-        pChildFrame = Queue_head (&((SIO2_Handle)pChild)->framelist);
+        pChildFrame = Queue_head (Queue_handle(&((SIO2_Handle)pChild)->framelist));
         for (i=0; i < pDevExt->maxNumBuf; i++) {
             pChildFrame->arg = (Arg) ((int) pBufConfig->pntr.pVoid + i*pBufConfig->sizeofBuffer/pDevExt->maxNumBuf);
             pChildFrame = Queue_next ((Queue_Elem *) pChildFrame);
@@ -416,7 +432,7 @@ Int DOB_issue (DEV2_Handle device)
         return DOB_FTABLE_issueIEC (device, pBufConfig);
 
     for (i=0; i < numXfers; i++) {
-        pChildFrame = Queue_get (&((SIO2_Handle)pChild)->framelist);
+        pChildFrame = Queue_get (Queue_handle(&((SIO2_Handle)pChild)->framelist));
         if (pChildFrame == (DEV2_Frame *)&((SIO2_Handle)pChild)->framelist)
             return SIO2_EBADIO;
 
@@ -428,7 +444,7 @@ Int DOB_issue (DEV2_Handle device)
             pChildFrame->addr = (Ptr) pChildFrame->arg; 
         pChildFrame->size = xferSize;
 
-        Queue_put (pChild->todevice, pChildFrame);
+        Queue_put (pChild->todevice, (Queue_Elem *)pChildFrame);
         status = DEV2_issue(pChild);
         if (status != SYS_OK)
             return status;
@@ -471,7 +487,7 @@ Int DOB_issueIEC (DEV2_Handle device, PAF_OutBufConfig  *pBufConfig)
        numBytes = pBufConfig->head.pSmInt - pBufConfig->pntr.pSmInt;
 
 
-        pChildFrame = Queue_get (&((SIO2_Handle)pChild)->framelist);
+        pChildFrame = Queue_get (Queue_handle(&((SIO2_Handle)pChild)->framelist));
         if (pChildFrame == (DEV2_Frame *)&((SIO2_Handle)pChild)->framelist)
             return SIO2_EBADIO;
 
@@ -512,7 +528,7 @@ Int DOB_issueIEC (DEV2_Handle device, PAF_OutBufConfig  *pBufConfig)
             pChildFrame->addr = NULL; // send zero data
         }
 
-        Queue_put (pChild->todevice, pChildFrame);
+        Queue_put (pChild->todevice, (Queue_Elem *)pChildFrame);
         status = DEV2_issue(pChild);
         if (status != SYS_OK)
             return status;
@@ -521,14 +537,14 @@ Int DOB_issueIEC (DEV2_Handle device, PAF_OutBufConfig  *pBufConfig)
     else {
         // when kick-started send nbufs of zeroes
         for (i=0; i < pChild->nbufs; i++) {
-            pChildFrame = Queue_get (&((SIO2_Handle)pChild)->framelist);
+            pChildFrame = Queue_get (Queue_handle(&((SIO2_Handle)pChild)->framelist));
             if (pChildFrame == (DEV2_Frame *)&((SIO2_Handle)pChild)->framelist)
                 return SIO2_EBADIO;
 
             pChildFrame->size = xferSize;
             pChildFrame->addr = NULL; // send zero data
 
-            Queue_put (pChild->todevice, pChildFrame);
+            Queue_put (pChild->todevice, (Queue_Elem *)pChildFrame);
             status = DEV2_issue(pChild);
             if (status != SYS_OK)
                 return status;
@@ -641,7 +657,7 @@ Int DOB_reclaim (DEV2_Handle device)
         return DOBERR_NOTRUNNING;
 
     // if no available frames then wait for one to free o/w pull one from queue
-    if (Queue_empty (&((SIO2_Handle)pChild)->framelist)) {
+    if (Queue_empty (Queue_handle(&((SIO2_Handle)pChild)->framelist))) {
         status = DEV2_reclaim (pChild);
         if (status != SYS_OK)
             return status;
@@ -649,11 +665,11 @@ Int DOB_reclaim (DEV2_Handle device)
 
         // place frame at end of queue to be used later by issue
         // since queue was empty this will place it on the head of the queue
-        Queue_put (&((SIO2_Handle)pChild)->framelist, pChildFrame);
+        Queue_put (Queue_handle(&((SIO2_Handle)pChild)->framelist), (Queue_Elem *)pChildFrame);
     }
     else
         // since queue is not empty then get head of queue which will be the next one used by issue
-        pChildFrame = Queue_head (&((SIO2_Handle)pChild)->framelist);
+        pChildFrame = Queue_head (Queue_handle(&((SIO2_Handle)pChild)->framelist));
 
     // if in IEC mode then don't update ptrs (this is done by issueIEC),
     // otherwise we assume encoder is PCE and we need these updates
@@ -700,7 +716,7 @@ Int DOB_shutdown (DEV2_Handle device)
         Queue_enqueue (device->fromdevice, Queue_dequeue(device->todevice));
 
     while (!Queue_empty(device->fromdevice))
-        Queue_enqueue(&((SIO2_Handle) device)->framelist, Queue_dequeue(device->fromdevice));
+        Queue_enqueue(Queue_handle(&((SIO2_Handle) device)->framelist), Queue_dequeue(device->fromdevice));
 
     return SYS_OK;
 } // DOB_shutdown
@@ -728,7 +744,7 @@ Int DOB_startClocks (DEV2_Handle device)
     //xferSize = numChan * wordSize * 1;
     xferSize = numChan * wordSize * 4; // GJ: Experiment with longer startup transfers
 
-    pChildFrame = Queue_get (&((SIO2_Handle)pChild)->framelist);
+    pChildFrame = Queue_get (Queue_handle(&((SIO2_Handle)pChild)->framelist));
     if (pChildFrame == (DEV2_Frame *)&((SIO2_Handle)pChild)->framelist)
         return SIO2_EBADIO;
 
@@ -736,7 +752,7 @@ Int DOB_startClocks (DEV2_Handle device)
     pChildFrame->arg = NULL;
     pChildFrame->size = xferSize;
 
-    Queue_put (pChild->todevice, pChildFrame);
+    Queue_put (pChild->todevice, (Queue_Elem *)pChildFrame);
     status = DEV2_issue (pChild);
     if (status != SYS_OK)
         return status;
@@ -752,6 +768,9 @@ Int DOB_startClocks (DEV2_Handle device)
 
     pDevExt->state = DOB_STATE_CLOCKING;
 
+    gMobStart_Clocks++;
+    Log_info0("Leaving DOB_startClocks with DOB_STATE_CLOCKING");
+
     return status;
 } // DOB_startClocks
 
@@ -761,7 +780,7 @@ Int DOB_reallocFrames (DEV2_Handle device)
 {
     DOB_DeviceExtension   *pDevExt   = (DOB_DeviceExtension *)device->object;
     DEV2_Handle             pChild    = (DEV2_Handle)&pDevExt->child;
-    Queue_Handle            pChildQue = &((SIO2_Handle)pChild)->framelist;
+    Queue_Handle            pChildQue = Queue_handle(&((SIO2_Handle)pChild)->framelist);
     DEV2_Frame             *pFrame;
     Int                    i;
 
@@ -769,17 +788,17 @@ Int DOB_reallocFrames (DEV2_Handle device)
     // first pull off any frames from the child frame queue and place in holder
     while (!Queue_empty (pChildQue)) {
        pFrame = (DEV2_Frame *) Queue_get (pChildQue);
-       Queue_put (dobFrameQue, (Queue_Elem *) pFrame);
+       Queue_put (Queue_handle(&dobFrameQue), (Queue_Elem *) pFrame);
     }
 
     // next pull frames from holder and place onto child queue. If there aren't
     // enough in the holder then allocate from memory. We only support
     // ISSUERECLAIM mode so size = 0
     for (i=0; i < pDevExt->maxNumBuf; i++) {
-        if (Queue_empty (dobFrameQue))
+        if (Queue_empty (Queue_handle(&dobFrameQue)))
             pFrame = DEV2_mkframe (0, 0, 0); 
         else
-            pFrame = (DEV2_Frame *) Queue_get (dobFrameQue);
+            pFrame = (DEV2_Frame *) Queue_get (Queue_handle(&dobFrameQue));
 
         if (!pFrame)
             return SYS_EALLOC;            
index 6797dcc6273e67061ba4fce6226608af439dbe08..f98c6fe24725685558458ef1042e3102dad9ecfc 100644 (file)
@@ -100,17 +100,19 @@ typedef xdc_Short MdInt;
 
 void swapHdmi(Ptr, int);
 
-#define TEST_MULTICHANNEL
+//#define TEST_MULTICHANNEL
 
 
 #ifdef TEST_MULTICHANNEL
-#define SAP_UNDER_LEN 4
+#define SAP_UNDER_LEN 16
 //#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
+
+#ifdef DEBUG
 void DJDBG_SAP_EDMA_dumpParams(int tag_place)
 {
        unsigned int *ptrPARAM_BASE = (unsigned int *)0x02704000;
@@ -124,6 +126,7 @@ void DJDBG_SAP_EDMA_dumpParams(int tag_place)
        Log_info5("PARAM0x19b(%d): 0x%x 0x%x 0x%x 0x%x", tag_place, ptrPARAM0x19[4], ptrPARAM0x19[5], ptrPARAM0x19[6], ptrPARAM0x19[7]);
     //Log_info1("TCC0: ERR reg %x", *((unsigned int *)0x02760120)); //DJDBG
 }
+#endif
 // .............................................................................
 // notes:
 //  . add control function to PORT table
@@ -153,7 +156,7 @@ Int  SAP_reclaim(DEV2_Handle);
 Int  SAP_shutdown(DEV2_Handle);
 Int  SAP_start(DEV2_Handle);
 Int  SAP_config(DEV2_Handle device, const SAP_Params *pParams);
-Int  SAP_EDMA_setupParam (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32 childEdma, unsigned int addr, unsigned int size);
+Int  SAP_EDMA_setupParam (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32 childEdma, XDAS_UInt32 addr, XDAS_UInt32 size);
 Int  SAP_EDMA_setupXfer (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32 parentEdma, XDAS_UInt32 childEdma, DEV2_Frame *pFrame);
 
 // .............................................................................
@@ -616,7 +619,7 @@ Int SAP_start (DEV2_Handle device)
 } // SAP_start
 
 int gDmaParamsarray[17][3];
-int gDmaParamsidx=0;
+int gDmaParamsidx=0, gSAPSpecialCase=0;
 // -----------------------------------------------------------------------------
 
 Int SAP_issue (DEV2_Handle device)
@@ -684,8 +687,6 @@ Int SAP_issue (DEV2_Handle device)
     pFrame = Queue_dequeue (device->todevice);
     pParam = (SAP_EDMA_Param *) Queue_dequeue (Queue_handle(&pDevExt->paramQue));
 
-   /* if (pFrame->addr == NULL)
-               SW_BREAKPOINT; */
     if (pParam->hEdmaParam == NULL)
        Log_info0("SAP_issue: hEdma value is NULL");
     // set misc argument to pParam so get enqueue later
@@ -721,10 +722,11 @@ Int SAP_issue (DEV2_Handle device)
 
     // special case enables when not yet started
     if (pDevExt->runState == 0) {
+       gSAPSpecialCase++;
         result = SAP_FTABLE_start (device);
         if (result) {
             //SAP_DMA_FTABLE_unlock (device);
-                 Hwi_enable ();
+                 Hwi_restore (key);
             return result;
         }
     }
@@ -767,16 +769,7 @@ void swapHdmi(Ptr Input, int size)
 
        }
 
-       Log_info3("SAP: Exiting swapHdmi with Frame->Addr: 0x%x, p1->addr: 0x%x, p2->addr: 0x%x ", (MdInt *)Input, p1, p2);
-
-       /**p2++ = 0xF872;
-       *p2++ = 0x4E1F;
-       *p2++ = 0x0016;
-       *p2++ = 0xEFF0;
-       *p2++ = 0x079E;
-       *p2++ = 0x0003;
-       *p2++ = 0x8401;
-       *p2++ = 0x0101; */
+       Log_info3("SAP: Exiting swapHdmi with Frame->Addr: 0x%x, p1->addr: 0x%x, p2->addr: 0x%x ", (xdc_IArg)Input, p1, p2);
 
        return;
 }
@@ -784,7 +777,6 @@ void swapHdmi(Ptr Input, int size)
 Int SAP_reclaim (DEV2_Handle device)
 {
     SAP_DeviceExtension *pDevExt = (SAP_DeviceExtension *)(device->object);
-    Int result, i, oldMask;
 #ifdef SAP_CACHE_SUPPORT
     DEV2_Frame *pFrame;
 #endif
@@ -835,18 +827,11 @@ Int SAP_reclaim (DEV2_Handle device)
         {
             Cache_inv (pFrame->addr, pFrame->size, Cache_Type_ALL, 0);
             Cache_wait();
-               //note: size here is in # of bytes, so incrementing by 4X32b words ( or 8X16b)
-                       //for(i=0; i<(pFrame->size)/(4*4); i+=16)
-                       //{
-                // Hwi_disable commented since it used to affect other interrupts
-                // max HWI disable duration ~1ms observed
-                   //oldMask = Hwi_disable ();
-                               swapHdmi(pFrame->addr, pFrame->size);
-                               //Hwi_restore(oldMask);
-
-                       Cache_wb (pFrame->addr, pFrame->size, Cache_Type_ALL, 0);
-                       Cache_wait();
-                       //}
+
+            // max HWI disable duration ~1ms observed
+            //unsigned int key = Hwi_disable ();                                       // GJ: Revisit, along with other context protections here.
+            swapHdmi(pFrame->addr, pFrame->size);
+            //Hwi_restore(key);
         }
     }
 
@@ -1091,7 +1076,7 @@ Int SAP_shutdown (DEV2_Handle device)
     SAP_DeviceExtension *pDevExt = (SAP_DeviceExtension *)(device->object);
     SIO2_Handle stream = (SIO2_Handle) device;
     DEV2_Frame *pFrame;
-    Int result,i;
+    Int i;
     EDMA3_DRV_Handle hEdma;
     //TRACE_GEN((&TR_MOD, "SAP_shutdown.%d (0x%x)", __LINE__, device));
 
@@ -1159,6 +1144,11 @@ Int SAP_shutdown (DEV2_Handle device)
 
 // -----------------------------------------------------------------------------
 int gSapWatchDogThrottle = 0; //DJDBG
+int gSapWatchDogIn =0;
+int gSapWatchDogOut = 0;
+int gSapWatchDogInSemPost = 0;
+int gSapWatchDogOutSemPost = 0;
+
 Void SAP_watchDog (Void)
 {
     DEV2_Handle device;
@@ -1174,12 +1164,14 @@ Void SAP_watchDog (Void)
         return;
     }
 
+
     // protect context
     Task_disable (); // needed since we may call SEM_post
     // Hwi_disable commented since it used to affect other interrupts
     // max HWI disable duration ~4ms observed
     //oldMask = Hwi_disable ();
 
+
     //TRACE_VERBOSE((&TR_MOD, "%s.%d: devices loop, numDevices = %d", __FUNCTION__, __LINE__, dapDrv.numDevices));
 
     for (i=0; i < sapDrv.numDevices; i++) {
@@ -1203,6 +1195,11 @@ Void SAP_watchDog (Void)
             // set errorState which will force owner thread
             //   to clean up via SIO_idle()
             pDevExt->errorState = PAF_SIO_ERROR_FATAL;
+            if(device->mode == DEV2_INPUT)
+               gSapWatchDogIn++;
+            else
+                gSapWatchDogOut++;
+
             //TRACE_TERSE((&TR_MOD, "SAP_watchDog.%d, PAF_SIO_ERROR_FATAL: 0x%x", __LINE__, pDevExt->errorState));
            /* if(gSapWatchDogThrottle == 0) //DJDBG
             {
@@ -1212,10 +1209,17 @@ Void SAP_watchDog (Void)
             if(gSapWatchDogThrottle > 10) gSapWatchDogThrottle = 0; */
             // if outstanding pend then post to free owner thead
             if (!Semaphore_pend(pDevExt->sync, 0))
-                Semaphore_post (pDevExt->sync);
+            {
+               if(device->mode == DEV2_INPUT)
+                       gSapWatchDogInSemPost++;
+               else
+                       gSapWatchDogOutSemPost++;
+               Semaphore_post (pDevExt->sync);
+            }
         }
     }
 
+
     // renable interrupts and task manager.
     // If we posted to the semaphore then the TSK_enable call will lead to
     // an immediate task switch to the associated audio thread.
@@ -1241,8 +1245,8 @@ void SAP_isrCallback (Uint32 tcc, EDMA3_RM_TccStatus status, Ptr context)
 
     device = (DEV2_Handle) context;
     pDevExt = (SAP_DeviceExtension *)(device->object);
-    if (pDevExt->pParams == NULL)
-        return SIO2_EINVAL;
+    //if (pDevExt->pParams == NULL)
+        //return SIO2_EINVAL;
 
     if (pDevExt->pParams->sio.moduleNum == 0)
        hEdma = hEdma0;
@@ -1272,12 +1276,13 @@ void SAP_isrCallback (Uint32 tcc, EDMA3_RM_TccStatus status, Ptr context)
             pDevExt->numQueued -= 1;
             //gIsrCnt++;
             if (device->mode == 1)
-               gisrOutput++;
-
+               gIsrOutputCnt++;
+            else
+               gIsrInputCnt++;
             // place frame onto user queue and signal user thread
             Queue_enqueue (device->fromdevice, (Ptr) pFrame);
 
-            Log_info2("Before SEM_post for device: 0x%x gIsrOutput: %d", device->mode, gisrOutput);
+            //Log_info2("Before SEM_post for device: 0x%x gIsrOutput: %d", device->mode, gisrOutput);
             // signal user thread
             Semaphore_post (pDevExt->sync);
 #if 0
@@ -1344,7 +1349,7 @@ Int SAP_EDMA_setupXfer (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32
     {
         Log_info0("pFrame has NULL address?");
     }
-    SAP_DMA_FTABLE_setupParam (device, targetEdma, childEdma, pFrame->addr, pFrame->size);
+    SAP_DMA_FTABLE_setupParam (device, targetEdma, childEdma, (XDAS_UInt32) pFrame->addr, pFrame->size);
 
     if (parentEdma != EDMA_HINV)
         EDMA3_DRV_linkChannel (hEdma, parentEdma, targetEdma);
@@ -1358,7 +1363,7 @@ Int SAP_EDMA_setupXfer (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32
 // -----------------------------------------------------------------------------
 // Configure EDMA3 parameter entry
 
-Int SAP_EDMA_setupParam (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32 childEdma, unsigned int addr, unsigned int size)
+Int SAP_EDMA_setupParam (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32 childEdma, XDAS_UInt32 addr, XDAS_UInt32 size)
 {
     SAP_DeviceExtension *pDevExt = (SAP_DeviceExtension *)device->object;
     EDMA3_DRV_Handle           hEdma;
@@ -1372,7 +1377,7 @@ Int SAP_EDMA_setupParam (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32
        else if (pDevExt->pParams->sio.moduleNum == 1 || pDevExt->pParams->sio.moduleNum == 2)
                hEdma = hEdma1;
     MCASP_Handle hPort = sapMcaspDrv.hPort[pDevExt->pParams->sio.moduleNum];
-    volatile Uint32 *base = (volatile Uint32 *)(hPort->baseAddr);
+   // volatile Uint32 *base = (volatile Uint32 *)(hPort->baseAddr);
 
    //Log_info3("%s.%d: Entered SAP_EDMA_setupParam for Target: 0x%x.\n", (xdc_IArg)__FUNCTION__, __LINE__, targetEdma);
 
@@ -1422,7 +1427,7 @@ Int SAP_EDMA_setupParam (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32
             edmaConfig.destAddr = addr;
             edmaConfig.destCIdx  = pDevExt->edmaWordSize * pDevExt->numSers ;
             if(pDevExt->edmaWordSize == 2)
-               edmaConfig.cCnt= (size)/((edmaConfig.aCnt * edmaConfig.bCnt)/2);        // GJ: Account for additional 2-bytes.
+               edmaConfig.cCnt= (size)/((edmaConfig.aCnt * edmaConfig.bCnt)/2);
         }
         else {
                //if(pDevExt->edmaWordSize == 2)
@@ -1439,14 +1444,14 @@ Int SAP_EDMA_setupParam (DEV2_Handle device, XDAS_UInt32 targetEdma, XDAS_UInt32
             edmaConfig.srcBIdx  = pDevExt->edmaWordSize;
             edmaConfig.srcCIdx  = pDevExt->edmaWordSize * pDevExt->numSers ;
             edmaConfig.srcAddr  = addr;
-            Edma3_CacheFlush ((unsigned int) addr, (size+3)/4);
+            //Edma3_CacheFlush ((unsigned int) addr, (size+3)/4);
         }
         else {
             edmaConfig.srcBIdx  = 0;
             edmaConfig.srcAddr  = (unsigned int) &sap_UNDER[0];
 #if 1
             //edmaConfig.cCnt = (SAP_UNDER_LEN * sizeof(int))/(edmaConfig.aCnt * edmaConfig.bCnt); //DJDBG
-            edmaConfig.cCnt = 512; //DJDBG, if underrun have frame of silence
+            edmaConfig.cCnt = SAP_UNDER_LEN; //DJDBG, if underrun have frame of silence
 #endif
         }
     }