Merge pull request #37 in PASDK/pasdk_sr from pasdk_663_shalini to pasdk1_3_master
authorVeeranna Hanchinal <x0131333@ti.com>
Wed, 14 Nov 2018 14:14:33 +0000 (08:14 -0600)
committerVeeranna Hanchinal <x0131333@ti.com>
Wed, 14 Nov 2018 14:14:33 +0000 (08:14 -0600)
* commit '74f9e4ba5c2100cdea9b461b6bb386ecb9bddc6f':
  PASDK-663: Code changes for new design solving OAR init issue

pasrc/test_dsp/framework/audioStreamOutDec.c
pasrc/test_dsp/framework/audioStreamOutInit.c
pasrc/test_dsp/framework/audioStreamOutIo.c
pasrc/test_dsp/framework/audioStreamOutProc.c
pasrc/test_dsp/framework/audioStreamOutProc.h
pasrc/test_dsp/framework/systemInit.c
pasrc/test_dsp/io/ioBuff.c

index d85185872842bd5774d75cb7b4537cfe1a6ae196..64f4c00f6aef93bb566deaad3012a143a6bc2b7b 100644 (file)
@@ -313,7 +313,7 @@ Int asopDecOutProcInfo2(
     
     // Start output transfer
     // FL, New IO: API for single Output
-    asopPhyTransferStart(&pOut[zO]);
+    //asopPhyTransferStart(&pOut[zO]);
     
     return status;
 }
index 1669557c107be7d98a0150ddd77932fc809aa966..d2bca344c11cd0ded9f2a2b9be0a2ff7db83970b 100644 (file)
@@ -330,7 +330,50 @@ static Int PAF_ASOT_ioCompCreate(
         }
 
         pIoOut[i].hIoPhy = ioPhyHandle;
+               
+#if 1
+#ifdef _TMS320C6X
+    GateMP_Params gateParams;
+    GateMP_Handle gateHandle;
+    
+    GateMP_Params_init(&gateParams);
+    gateParams.localProtect = GateMP_LocalProtect_TASKLET;//GateMP_LocalProtect_THREAD;
+    gateParams.remoteProtect = GateMP_RemoteProtect_SYSTEM;
+    gateParams.name = ASP_STREAM_OUT_GATE_NAME;
+    gateParams.regionId = ASP_STREAM_OUT_GATE_REGION_ID;
+    gateHandle = GateMP_create(&gateParams);
+    if (gateHandle != NULL)
+    {
+        pIoOut[i].gateHandle = gateHandle;
+    }
+    else
+    {
+        pIoOut[i].gateHandle = NULL;
+        return ASP_STREAM_OUT_INV_GATE;
+    }
+
+#elif defined(ARMCOMPILE)
+    GateMP_Handle gateHandle;
+    Int status;
+    
+    do {
+        status = GateMP_open(ASP_STREAM_OUT_GATE_NAME, &gateHandle);
+    } while (status == GateMP_E_NOTFOUND);
+    if (status == GateMP_S_SUCCESS)
+    {
+        pIoOut[i].gateHandle = gateHandle;
+    }
+    else
+    {
+        pIoOut[i].gateHandle = NULL;
+        return ASP_STREAM_OUT_INV_GATE;
+    }
+
+#else
+    #error "Unsupported platform"
 
+#endif  
+#endif
         free(mem_rec);
 
     } // end of for loop
index c132db7f4c7cb489e8de5c3d0c8cbadc9e9a4a91..a4311e986257ac4b0175110b999447212b564a27 100644 (file)
@@ -724,7 +724,7 @@ Void asopIoPhyPrime(
 {
     Int32        count;
 
-    pOut->numPrimeXfers = NUM_PRIME_XFERS;
+    pOut->numPrimeXfers = 2;//NUM_PRIME_XFERS;
 
     for (count = 0; count < pOut->numPrimeXfers; count++)
     {
@@ -741,6 +741,8 @@ Int asopInitOutBufConfig(
     PAF_OutBufConfig *pOutBufCfg;
     ioBuffHandle_t hIoBuff;
     ioBuffInfo_t outBuffInfo;
+       GateMP_Handle gateHandle;
+       IArg key;
     
     pOutBufCfg = &pOutBuf->outBufConfig;
     hIoBuff = pOutIo->hIoBuff;
@@ -749,7 +751,13 @@ Int asopInitOutBufConfig(
     pOutBufCfg->sizeofElement = WORD_SIZE_PCM;
     pOutBufCfg->precision = 24;
     
+    // Get gate handle
+    gateHandle = pOutIo->gateHandle;
+    // Enter gate
+    key = GateMP_enter(gateHandle);
     ioBuffGetInfo(hIoBuff, &outBuffInfo);
+    // Leave the gate
+    GateMP_leave(gateHandle, key);
     pOutBufCfg->base.pLgInt = outBuffInfo.base;
     pOutBufCfg->sizeofBuffer = outBuffInfo.size;
     
@@ -766,9 +774,17 @@ Int asopGetOutBufPtrs(
     void *buff1, *buff2;
     size_t size1, size2;
     Int status;
+    GateMP_Handle gateHandle;
+    IArg key;
 
+    // Get gate handle
+    gateHandle = pOutIo->gateHandle;
+    // Enter gate
+    key = GateMP_enter(gateHandle);
     status = ioBuffGetWritePtrs(pOutIo->hIoBuff, writeSize,
                                 &buff1, &size1, &buff2, &size2);
+    // Leave the gate
+    GateMP_leave(gateHandle, key);
     if (status == IOBUFF_ERR_OVERFLOW)
     {
         pOutIo->errIoBuffOvrCnt++;
@@ -873,6 +889,8 @@ Int asopMarkOutBuffsWriteComplete(
     ioBuffHandle_t hIoBuff;
     void *buff1, *buff2;
     size_t size1, size2;
+       GateMP_Handle gateHandle;
+       IArg key;
     
     // get buffer pointers & sizes from previous IO Buff write allocation
     buff1 = pOutIo->buff1;
@@ -881,9 +899,14 @@ Int asopMarkOutBuffsWriteComplete(
     size2 = pOutIo->size2; // this should always be 0 for Output
     
     hIoBuff = pOutIo->hIoBuff;
-    
-    ioBuffWriteComplete(hIoBuff, buff1, size1);
 
+         // Get gate handle
+    gateHandle = pOutIo->gateHandle;
+    // Enter gate
+    key = GateMP_enter(gateHandle);
+    ioBuffWriteComplete(hIoBuff, buff1, size1);
+    // Leave the gate
+    GateMP_leave(gateHandle, key);
     if (buff2 != NULL) 
     {
         ioBuffWriteComplete(hIoBuff, buff2, size2);
@@ -911,7 +934,7 @@ Void asopPhyTransferStart(
         if(ioPhyXferSubmit(pOut->hIoPhy) == IOPHY_ERR_BUFF_UNDERFLOW) 
         {
             // Output buffer underflows!
-            System_abort("\nOutput buffer underflows!\n");
+            //System_abort("\nOutput buffer underflows!\n");
         }
         else {
             // Output buffer operates normally
index bb462ad7b1fdc99b854dd36e9143b4ecac3a91ad..0bd0f28efa6098ae23058551ff827017db61c00f 100644 (file)
@@ -39,6 +39,7 @@ All rights reserved.
 
 #include <xdc/runtime/Log.h>
 #include <ti/sysbios/BIOS.h>
+#include <ti/sysbios/knl/Swi.h>
 
 #include "aspOutInitSync_master.h"
 #include "aspDecOpCircBuf_master.h"
@@ -324,7 +325,6 @@ UInt32 gReselOutDevState_Evt_invCnt                     = 0; // Re-select Output
 UInt32 gAsotInitSyncResyncState_Cnt                     = 0; // Init-Sync Re-sync (Local error) state execution count
 UInt32 gAsotInvState_Cnt                                = 0; // invalid state count
 
-
 /*
  *  ======== taskAsopFxn ========
  *  Audio Stream Output Processing task function
@@ -371,6 +371,7 @@ Void taskAsopFxn(
     }
 
     pAsotCfg->state = ASOT_STATE_SEL_OUT_DEV;   // init state
+    pAsotCfg->asopPhyTransferStartflag = 0;
     procEvents = TRUE;                          // init proc events flag
     procOutFirstTime = TRUE;                    // init first time process output flag
     asopFrameCount = 0;                         // init frame counter TBD
@@ -394,6 +395,7 @@ Void taskAsopFxn(
             //  Select Output Device state
             //
             case ASOT_STATE_SEL_OUT_DEV:
+                pAsotCfg->asopPhyTransferStartflag = 0;
                 if (events & Evt_Id_AsotWakeTimer)
                 {
                     gSelOutDevState_EvtWakeTimer_cnt++;
@@ -449,6 +451,7 @@ Void taskAsopFxn(
             case ASOT_STATE_RESET_OUT_PROC:
                 if (events & Evt_Id_AsotWakeTimer)
                 {
+                    pAsotCfg->asopPhyTransferStartflag = 0;
                     gResetOutProcState_EvtWakeTimer_cnt++;
                     events &= ~Evt_Id_AsotWakeTimer; // clear event
                     
@@ -830,17 +833,32 @@ Void clkAsotFxn(Void)
     Event_post(gAsotEvtHandle, Evt_Id_AsotWakeTimer);
 }
 
+extern Swi_Handle gAsopSwiHandle;
 void asopMcaspCallback(void* arg, MCASP_Packet *mcasp_packet)
 {
     /* post semaphore */
     if(mcasp_packet->arg == IOPHY_XFER_FINAL) {
         //Semaphore_post(asopSemTx);
-        Event_post(gAsotEvtHandle, Evt_Id_AsotTxMcaspEdma);
+       // Event_post(gAsotEvtHandle, Evt_Id_AsotTxMcaspEdma);
+        Swi_post(gAsopSwiHandle);
     } else {
         ;    // intermediate packet due to buffer wrapping around
     }
 }
 
+// gAsopSwiHandle is been created with the following Swi function
+void asopSwiFunc()
+{
+    PAF_ASOT_Config *pAsotCfg;
+    pAsotCfg = &gPAF_ASOT_config;
+    if(pAsotCfg->asopPhyTransferStartflag == 1)
+    {
+    asopPhyTransferStart(&gPAF_ASOT_config.pIoOut[0]); 
+    }
+    
+    Event_post(gAsotEvtHandle, Evt_Id_AsotTxMcaspEdma);
+}
+
 // Reset audio frame pointers to original values
 static Void resetAfPointers(
     const PAF_ASOT_Params *pP, 
@@ -1337,6 +1355,8 @@ static Int PAF_ASOT_procDecOut(
     status = ASOP_SOK;
     pAstCfg = pAsotCfg->pAstCfg;
 
+    pAsotCfg->asopPhyTransferStartflag = 1;
+
     if (*pFirstTime == TRUE)
     {
         // Initialize Decoder output processing
index 674751f5d3614bf42a17b811b7672e5646efd591..ea803b291dc221cfdbbfc845c21175c527160572 100644 (file)
@@ -67,6 +67,12 @@ All rights reserved.
 #define Evt_Id_AsotRxMsgAsdt    Event_Id_02  // ASOT Rx ASDT message event
 #define Evt_Id_AsotTxMcaspEdma  Event_Id_03  // ASOT Tx McASP EDMA event
 
+#if 1
+#define ASP_STREAM_OUT_GATE_NAME ( "AspStreamOutGate" )  // name of GateMP used StreamOut info protection
+#define ASP_STREAM_OUT_GATE_REGION_ID ( 0 )
+#define ASP_STREAM_OUT_INV_GATE          ( -1 )                      // error: invalid gate handle
+#endif
+
 // ASOT event handle - to put in structure
 extern Event_Handle gAsotEvtHandle;
 
@@ -212,6 +218,7 @@ typedef struct PAF_AST_OutIO {
     
     // debugging counters
     uint32_t num_xfers;
+    GateMP_Handle gateHandle;
 
 } PAF_AST_IoOut;
 
@@ -224,6 +231,7 @@ typedef struct PAF_ASOT_Config {
     PAF_ASPM_Config *pAspmCfg;                  // ASIT/ASOT shared configuration
     PAF_AST_Config  *pAstCfg;                   // ASIT/ASOT/ASDT shared configuration
     PAF_AST_IoOut   *pIoOut;                    // ASOT IO configuration
+    uint32_t        asopPhyTransferStartflag;       // Flag to indicate transfer start in SWI(asopSwiFunc)
 } PAF_ASOT_Config;
 
 // ASOT configuration
index fcd37679aed3c34731ad87f8dfbdb6f658aa15e8..eb6cfbd02a03238f0e55c7eb99e3ba151d3a61c5 100644 (file)
@@ -45,6 +45,8 @@ All rights reserved.
 #include <ti/ipc/SharedRegion.h>
 #include <ti/ipc/Ipc.h>
 #include <ti/sysbios/family/c66/Cache.h>
+#include <ti/sysbios/knl/Swi.h>
+#include <xdc/runtime/Error.h>
 
 #include "params.h"
 #include "pafhjt.h"
@@ -96,6 +98,9 @@ extern PAF_ASOT_Fxns PAF_ASOT_params_fxns;
 //   1: initialized
 Int gTaskInitFlag[NUM_SYS_TASKS];
 
+Swi_Handle gAsopSwiHandle;
+extern void asopSwiFunc();
+
 // PAF Hidden Jump Table (HJT) pointer
 const PAFHJT_t *pafhjt;
 
@@ -258,6 +263,16 @@ Void taskSysInitFxn(Void)
         Task_sleep(SYS_INIT_SLEEP);
     }
 
+    Swi_Params swiParams;
+    Error_Block eb;
+    Error_init(&eb);
+    Swi_Params_init(&swiParams);
+       swiParams.priority = 5;
+    gAsopSwiHandle = Swi_create(asopSwiFunc, &swiParams, &eb);
+    if (gAsopSwiHandle == NULL) {
+     System_abort("Swi create failed");
+    }
+
     Task_setPri(TaskAfp, TASK_AFP_PRI);
     Task_setPri(TaskAip, TASK_AIP_PRI);
     Task_setPri(TaskAsip, TASK_ASIP_PRI);
index fb1906aa395a80f4f3aad0b879677d9deebd580b..79c2ecc97762ee9cc231cd596a7bf13c07d9eee4 100644 (file)
@@ -118,7 +118,8 @@ int ioBuffGetReadPtrs(ioBuffHandle_t handle, size_t mem_size,
   
       if(inst->sync == IOBUff_READ_SYNC) {
         /*If it's read-synchronized, don't return from here, but still return
-        read pointer(s) calculated below.  */
+        read pointer(s) calculated after this.  */
+#if 0        
         /* reset the delay between read and write_complete pointers */
         uint_least32_t delay_adjust = inst->nom_delay;
         if(delay_adjust < mem_size) {
@@ -131,6 +132,22 @@ int ioBuffGetReadPtrs(ioBuffHandle_t handle, size_t mem_size,
           //inst->rw_wrap_around = 1;   // set wrap around flag
         }
          
+#endif
+        /* Make a dummy frame and fill it with 0's */
+        new_read_ptr = (void *)((uint_least32_t)inst->write_complete_ptr - mem_size);
+        if(new_read_ptr < inst->base) {
+          new_read_ptr = (void *)((uint_least32_t)new_read_ptr + inst->size);
+          
+          memset(new_read_ptr, 0, mem_size - ((uint_least32_t)inst->write_complete_ptr - (uint_least32_t)inst->base));
+          memset(inst->base, 0, (uint_least32_t)inst->write_complete_ptr - (uint_least32_t)inst->base);
+        }
+        else {
+          memset(new_read_ptr, 0, mem_size);
+        }
+        
+        /* Set read_ptr for calculating returning read pointer(s) below */
+        inst->read_ptr = new_read_ptr;
+         
         ret_val = IOBUFF_ERR_UNDERFLOW;
       }
       else {