PASDK-402:Add writeDECCommandRestart updates
authorFrank Livingston <frank-livingston@ti.com>
Sun, 24 Sep 2017 00:44:14 +0000 (19:44 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Sun, 24 Sep 2017 00:44:14 +0000 (19:44 -0500)
writeDECCommand restart is required for customer.
Updated framework to handle this alpha command.
Implementation from MRB, Kawada-san with guidance from TI.

pasdk/test_dsp/framework/audioStreamInpProc.c
pasdk/test_dsp/framework/audioStreamOutProc.c

index b1917494cbc73ae7776d65756832c6cd299c3c68..990a758abf82a4eae85f414c1eb6874476a14650 100644 (file)
@@ -357,6 +357,9 @@ UInt32 gCapIbReset_cnt          =0;
 UInt32 gCapIb_cnt               =0;
 UInt32 gCbWrtAfErrCnt           =0; // decoder output circular buffer write error count (returned from ARM to DSP)
                                    
 UInt32 gCapIb_cnt               =0;
 UInt32 gCbWrtAfErrCnt           =0; // decoder output circular buffer write error count (returned from ARM to DSP)
                                    
+// For writeDECCommandRestart
+volatile UInt32 gCommandOutputTask_SYNC   =0;
+volatile UInt32 gCommandOutputTask_ACK    =0;
 
 #include "dbgDib.h" // debug
 
 
 #include "dbgDib.h" // debug
 
@@ -658,6 +661,18 @@ Void taskAsipFxn(
         // any error forces idling of input
         if (errno) 
         {
         // any error forces idling of input
         if (errno) 
         {
+            // If gCommandOutputTask_SYNC invoked by writeDECCommandRestart, wait for output task in sync ...
+            if (gCommandOutputTask_SYNC) {
+                TRACE_VERBOSE1("TaskAsip: writeDECCommandRestart issued ... Wait for ack from output task side (errno=%d)", errno);
+                // Wait for ack
+                while (gCommandOutputTask_ACK == 0) {
+                    Task_sleep(1);
+                }
+                TRACE_VERBOSE0("TaskAsip: writeDECCommandRestart issued ... Sync-ed! Startover the process");
+                gCommandOutputTask_ACK = 0;
+                gCommandOutputTask_SYNC = 0;
+            }
+            
             for (z=INPUT1; z < INPUTN; z++)
             {
                 if (pAstCfg->xInp[z].hRxSio)
             for (z=INPUT1; z < INPUTN; z++)
             {
                 if (pAstCfg->xInp[z].hRxSio)
@@ -2396,6 +2411,10 @@ PAF_ASIT_decodeCommand(
                     tempVar8 |= 0x80;
                     sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.command2),
                                        tempVar8, GATEMP_INDEX_DEC);
                     tempVar8 |= 0x80;
                     sharedMemWriteInt8(&(pAstCfg->xDec[z].decodeStatus.command2),
                                        tempVar8, GATEMP_INDEX_DEC);
+                                       
+                    // Invoke command to output task to break the loop
+                    gCommandOutputTask_SYNC = 1;
+                    
                     return (ASPERR_QUIT);
                 default: // command unknown - ignore
                     break;
                     return (ASPERR_QUIT);
                 default: // command unknown - ignore
                     break;
index 6578b3a8d375f4426862e2df803081611685eb55..e45912efc8f25a79aaece85b444368d06d42775f 100644 (file)
@@ -297,6 +297,10 @@ UInt32 gDecOpCbRdAfUnd      =0; // decoder output circular buffer underflow coun
 UInt32 gMaxDecOpCbRdAfUnd   =0; // max (consecutive) decoder output circular buffer underflow count
 UInt32 gMasterCbResetCnt    =0; // master circular buffer reset count
 
 UInt32 gMaxDecOpCbRdAfUnd   =0; // max (consecutive) decoder output circular buffer underflow count
 UInt32 gMasterCbResetCnt    =0; // master circular buffer reset count
 
+// For writeDECCommandRestart
+extern volatile UInt32 gCommandOutputTask_SYNC;
+extern volatile UInt32 gCommandOutputTask_ACK;
+
 // Global debug counters */
 UInt32 gAsopTxSioReclaimCnt         =0;
 UInt32 gAsopInitOutProcCnt          =0;
 // Global debug counters */
 UInt32 gAsopTxSioReclaimCnt         =0;
 UInt32 gAsopInitOutProcCnt          =0;
@@ -449,6 +453,20 @@ Void taskAsopFxn(
         // Check forward (ASIT) error here, TBD
         //
         
         // Check forward (ASIT) error here, TBD
         //
         
+        // Even if we are not in error state, we check if writeDECCommandRestar issued or not
+        if (gCommandOutputTask_SYNC) {
+            TRACE_TERSE0("TaskAsop: ack for writeDECCommandRestart ... Wait for the command deasserted");
+            gCommandOutputTask_ACK = 1;
+            while (gCommandOutputTask_SYNC) {
+                Task_sleep(1);
+            }
+            TRACE_TERSE0("TaskAsop: ack for writeDECCommandRestart ... Sync-ed! Startover the process");
+            procSleep = 1;                  // init sleep flag -- sleep
+            procOutDevSel = 1;              // init device output selection flag -- perform output device selection
+            state = INIT_OUT_PROC_STATE;    // init state -- starover
+            errno = ASOP_DP_FORWARD_ERR;    // Override the error -- for flushing SIO output device
+        }
+        
         // any error forces idling of output
         if (errno) 
         {
         // any error forces idling of output
         if (errno) 
         {
@@ -462,8 +480,8 @@ Void taskAsopFxn(
         
             TRACE_TERSE1("TaskAsop: Trace stopped at loop %d.", loopCount);
             ERRNO_RPRT(TaskAsop, errno);
         
             TRACE_TERSE1("TaskAsop: Trace stopped at loop %d.", loopCount);
             ERRNO_RPRT(TaskAsop, errno);
-        }        
-    
+        }
+        
         if (procSleep == 1)
         {
             TRACE_VERBOSE1("TaskAsop: AS%d: ... sleeping ...", as+zMS);
         if (procSleep == 1)
         {
             TRACE_VERBOSE1("TaskAsop: AS%d: ... sleeping ...", as+zMS);
@@ -1813,7 +1831,13 @@ PAF_ASOT_decodeProcessing(
         // Check forward (ASIT) error here, TBD
         //
         
         // Check forward (ASIT) error here, TBD
         //
         
-        
+        // If writeDECCommandRestart issued, force exit the statemachine
+        if (gCommandOutputTask_SYNC) {
+            TRACE_VERBOSE1("PAF_ASOT_decodeProcessing: writeDECCommandRestart issued in state=0x%x ... exiting core loop", state);
+            errno = ASOP_DP_FORWARD_ERR;
+            break;
+        }
+
         // Check if any change in output SIO, e.g. from Output shortcut.
         // Changes will break FSM and allow Output reconfiguration.
         errno = checkOutSio(pP, pAsotCfg, &outSioUpdate);
         // Check if any change in output SIO, e.g. from Output shortcut.
         // Changes will break FSM and allow Output reconfiguration.
         errno = checkOutSio(pP, pAsotCfg, &outSioUpdate);