]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/commitdiff
PASDK-577:Dynamic Output device selection
authorFrank Livingston <frank-livingston@ti.com>
Wed, 9 May 2018 01:41:25 +0000 (20:41 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Wed, 9 May 2018 01:41:25 +0000 (20:41 -0500)
Update Output device selection to allow dynamic selection over alpha
commands (Output shortcuts)

pasdk/test_dsp/framework/audioStreamOutIo.c
pasdk/test_dsp/framework/audioStreamOutIo.h
pasdk/test_dsp/framework/audioStreamOutProc.c
pasdk/test_dsp/framework/audioStreamOutProc.h

index 7ba0c8b914696dac21d0b59c1bf4935929fa4cf7..0827ee0fcaf64924e6c353ebe0574cc745a44f40 100644 (file)
@@ -65,28 +65,64 @@ extern Int d10Initialized;
 
 
 // Select Output devices
-Int asopSelectDevices(void *pConfig, PAF_AST_IoOut *pOut)
+Int asopSelectDevices(
+    const PAF_SIO_Params *pOutCfg, 
+    PAF_AST_IoOut *pOut
+)
 {
-    mcaspLLDconfig *lldCfg;
+    mcaspLLDconfig *pReqLldCfg;
     Ptr mcaspChanHandle;
     Aud_STATUS status;
-    
+
     if ((pOut->hIoBuff == NULL) || (pOut->hIoPhy == NULL) || (!d10Initialized)) {
         return ASOP_IO_ERR_IO_UNINIT;
     }
 
-    lldCfg = (mcaspLLDconfig *)pConfig;
-    if (lldCfg->hMcaspChan == NULL) {
-        mcaspChanHandle = NULL;
-        status = mcasplldChanCreate(lldCfg, &mcaspChanHandle);
-        if (status != Aud_EOK) {
-            Log_info0("asopSelectDevices(): McASP channel creation failed!\n");
+    // Deactivate currently active Output device
+    if (pOut->hMcaspChan != NULL)
+    {
+        status = mcaspDeleteChan(pOut->hMcaspChan);
+        if (status != Aud_EOK)
+        {
             return ASOP_IO_ERR_MCASP_CFG;
         }
+        
+        pOut->hMcaspChan = NULL;
+        pOut->pLldCfg->hMcaspChan = NULL;
+        pOut->pLldCfg = NULL;
+    }
 
-        lldCfg->hMcaspChan = mcaspChanHandle;
-        pOut->hMcaspChan = lldCfg->hMcaspChan;
-        pOut->stride = lldCfg->mcaspChanParams->noOfSerRequested * lldCfg->mcaspChanParams->noOfChannels;
+    // Activate requested device
+    if (pOutCfg != NULL)
+    {
+        //
+        // Device other than OutNone selected
+        //
+        
+        pReqLldCfg = (mcaspLLDconfig *)pOutCfg->sio.pConfig;
+        if (pReqLldCfg->hMcaspChan == NULL) 
+        {
+            mcaspChanHandle = NULL;
+            status = mcasplldChanCreate(pReqLldCfg, &mcaspChanHandle);
+            if (status != Aud_EOK) {
+                Log_info0("asopSelectDevices(): McASP channel creation failed!\n");
+                return ASOP_IO_ERR_MCASP_CFG;
+            }
+
+            pReqLldCfg->hMcaspChan = mcaspChanHandle;
+            pOut->pLldCfg = pReqLldCfg;
+            pOut->hMcaspChan = pReqLldCfg->hMcaspChan;
+            pOut->stride = pReqLldCfg->mcaspChanParams->noOfSerRequested * pReqLldCfg->mcaspChanParams->noOfChannels;
+        }
+    }
+    else
+    {
+        //
+        // OutNone device selected
+        //
+        
+        pOut->hMcaspChan = NULL;
+        pOut->pLldCfg = NULL;
     }
 
     return ASOP_IO_SOK;
@@ -528,34 +564,37 @@ Int asopIoCompsInit(
     PAF_AST_IoOut *pOutIo
 )
 {
-    // Initialize I/O BUFF and I/O PHY components for output task
-    ioBuffParams_t ioBuffParams;
-    ioPhyParams_t  ioPhyParams;
-
-    ioBuffParams.base         = pOutBuf->outBufConfig.base.pVoid;
-    ioBuffParams.size         = pOutBuf->outBufConfig.allocation/STRIDE_WORST_CASE*STRIDE_WORST_CASE;
-    ioBuffParams.sync         = IOBUff_READ_SYNC;
-    ioBuffParams.nominalDelay = NUM_CYCLE_PER_OUTPUT_FRAME_DEF * pOutIo->stride * WORD_SIZE_PCM * (NUM_PRIME_XFERS+1);
-    if(ioBuffInit(pOutIo->hIoBuff, &ioBuffParams) != IOBUFF_NOERR) 
+    if (pOutIo->hMcaspChan != NULL)
     {
-        return ASOP_IO_ERR_IOBUFF_INIT;   // to remove magic number
-    }
+        // Initialize I/O BUFF and I/O PHY components for output task
+        ioBuffParams_t ioBuffParams;
+        ioPhyParams_t  ioPhyParams;
+
+        ioBuffParams.base         = pOutBuf->outBufConfig.base.pVoid;
+        ioBuffParams.size         = pOutBuf->outBufConfig.allocation/STRIDE_WORST_CASE*STRIDE_WORST_CASE;
+        ioBuffParams.sync         = IOBUff_READ_SYNC;
+        ioBuffParams.nominalDelay = NUM_CYCLE_PER_OUTPUT_FRAME_DEF * pOutIo->stride * WORD_SIZE_PCM * (NUM_PRIME_XFERS+1);
+        if(ioBuffInit(pOutIo->hIoBuff, &ioBuffParams) != IOBUFF_NOERR) 
+        {
+            return ASOP_IO_ERR_IOBUFF_INIT;   // to remove magic number
+        }
 
-    ioPhyParams.ioBuffHandle    = pOutIo->hIoBuff;
-    ioPhyParams.xferFrameSize   = NUM_CYCLE_PER_FRAME_DEF * pOutIo->stride * WORD_SIZE_PCM;
-    ioPhyParams.mcaspChanHandle = pOutIo->hMcaspChan;
-    ioPhyParams.ioBuffOp        = IOPHY_IOBUFFOP_READ;
-    if(ioPhyInit(pOutIo->hIoPhy, &ioPhyParams) != IOPHY_NOERR) 
-    {
-        return ASOP_IO_ERR_IOPHY_INIT;   // to remove magic number
-    }
+        ioPhyParams.ioBuffHandle    = pOutIo->hIoBuff;
+        ioPhyParams.xferFrameSize   = NUM_CYCLE_PER_FRAME_DEF * pOutIo->stride * WORD_SIZE_PCM;
+        ioPhyParams.mcaspChanHandle = pOutIo->hMcaspChan;
+        ioPhyParams.ioBuffOp        = IOPHY_IOBUFFOP_READ;
+        if(ioPhyInit(pOutIo->hIoPhy, &ioPhyParams) != IOPHY_NOERR) 
+        {
+            return ASOP_IO_ERR_IOPHY_INIT;   // to remove magic number
+        }
 
-    pOutIo->phyXferSize = ioPhyParams.xferFrameSize;
+        pOutIo->phyXferSize = ioPhyParams.xferFrameSize;
+        
+        pOutIo->ioBuffBuf2AllocCnt = 0; // initialize buffer2 alloc count (indicates Output buffer wrap)
+        pOutIo->errIoBuffOvrCnt = 0; // initialize IO buff overflow count
+        pOutIo->errIoBuffUndCnt = 0; // initialize IO buff underflow count
+    }
     
-    pOutIo->ioBuffBuf2AllocCnt = 0; // initialize buffer2 alloc count (indicates Output buffer wrap)
-    pOutIo->errIoBuffOvrCnt = 0; // initialize IO buff overflow count
-    pOutIo->errIoBuffUndCnt = 0; // initialize IO buff underflow count
-
     return ASOP_IO_SOK;
 } /* asopIoCompsInit */
 
index 2245474ab1fb471c6b85ab8453624a86f7d375b5..df1afe1325cdba9a3168c96b64bc402baa1b53b6 100644 (file)
@@ -56,7 +56,7 @@ All rights reserved.
 
 // Select Output devices
 Int asopSelectDevices(
-    void *pConfig,
+    const PAF_SIO_Params *pOutCfg, 
     PAF_AST_IoOut *pOut
 );
 
index f3818abe10f2094d85543a8885180713f457c804..740440cc43d6875206f01087fc5b89fab509db87 100644 (file)
@@ -940,29 +940,24 @@ static Int PAF_ASOT_selectDevices(
             device = 0; // treat as device None
         }
         
-        if (device > 0)
+        // Select Output Devices
+        //  FL, New IO: API for single Output
+        status = asopSelectDevices(pQ->devout->x[device], &pAsotCfg->pIoOut[zO]);
+        if (status < 0)
         {
-            // Select Output Devices
-            //  FL, New IO: Placeholder function, this will be reorganized moving forward.
-            //  FL, New IO: API for single Output.
-            //  FL, New IO: Doesn't (re-)configure Output driver.
-            status = asopSelectDevices(pQ->devout->x[device]->sio.pConfig, &pAsotCfg->pIoOut[zO]);
-            if (status < 0)
-            {
-                pAstCfg->xOut[zO].outBufStatus.sioSelect = 0x80;
-                *pOutDevSel = FALSE;
-                return status;
-            }
+            pAstCfg->xOut[zO].outBufStatus.sioSelect = 0x80;
+            *pOutDevSel = FALSE;
+            return status;
+        }
             
-            // Reset IO Buff & IO Phy
-            //  FL, New IO: API for single Output
-            status = asopIoCompsInit(&pAstCfg->xOut[zO], &pAsotCfg->pIoOut[zO]);
-            if (status < 0)
-            {
-                pAstCfg->xOut[zO].outBufStatus.sioSelect = 0x80;
-                *pOutDevSel = FALSE;
-                return status;
-            }
+        // Reset IO Buff & IO Phy
+        //  FL, New IO: API for single Output
+        status = asopIoCompsInit(&pAstCfg->xOut[zO], &pAsotCfg->pIoOut[zO]);
+        if (status < 0)
+        {
+            pAstCfg->xOut[zO].outBufStatus.sioSelect = 0x80;
+            *pOutDevSel = FALSE;
+            return status;
         }
 
         pAstCfg->xOut[zO].outBufStatus.sioSelect = device | 0x80;
index 88d5483b60ab7f819292f3cc1c9d7e75f66abbd3..5aff6c71094aa204cb25f3adf29eb8b8af580f53 100644 (file)
@@ -44,6 +44,7 @@ All rights reserved.
 #include <ti/sysbios/knl/Event.h>
 #include <ti/sysbios/knl/Task.h>
 
+#include "mcasp_cfg.h"
 #include "ioPhy.h"
 #include "ioBuff.h"
 
@@ -184,6 +185,7 @@ typedef struct PAF_AST_OutIO {
     ioPhyHandle_t        hIoPhy;     /* handle to I/O physical layer */
     ioBuffHandle_t       hIoBuff;    /* handle to I/O buffer management */
     Ptr                  hMcaspChan; /* handle to McASP LLD channel for output */
+    mcaspLLDconfig       *pLldCfg;   /* pointer to McASP LLD configuration */
     uint32_t             phyXferSize;
     uint32_t             stride;