]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pasdk/test_dsp/framework/audioStreamOutProc.h
PASDK-538:Update DSP ASP master messaging to use SyncEvents
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamOutProc.h
2 /*
3 Copyright (c) 2017, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without 
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 /*
37  *  ======== audioStreamOutProc.h ========
38  */
40 #ifndef _ASOP_H_
41 #define _ASOP_H_
42  
43 #include <xdc/std.h>
44 #include <ti/sysbios/knl/Event.h>
45 #include <ti/sysbios/knl/Task.h>
47 #include "ioPhy.h"
48 #include "ioBuff.h"
50 #include "audioStreamProc_params.h"
51 #include "audioStreamProc_patchs.h"
52 #include "audioStreamProc_config.h"
53 #include "audioStreamProc_master.h"
55 #define TRACE_TIME(a)
57 /* !!!!!!!!! Revisit !!!!!!!!!!!!!!
58  * Purpose : Temporary ASOT frame length sizes.
59  *                       Deprecate PAF_SYS_FRAMELENGTH in phases.*/
60 #define PAF_ASOT_FRAMELENGTH            256
61 #define PAF_ASOT_MAX_FRAMELENGTH        1024
63 // ASOT event IDs
64 #define Evt_Id_AsotWakeTimer    Event_Id_00  // ASOT Wake Timer event
65 #define Evt_Id_AsotRxMsgAsit    Event_Id_01  // ASOT Rx ASIT message event
66 #define Evt_Id_AsotRxMsgAsdt    Event_Id_02  // ASOT Rx ASDT message event
67 #define Evt_Id_AsotTxMcaspEdma  Event_Id_03  // ASOT Tx McASP EDMA event
69 // ASOT event handle - to put in structure
70 extern Event_Handle gAsotEvtHandle;
72 struct PAF_ASOT_Params;
73 struct PAF_ASOT_Patchs;
74 struct PAF_ASOT_Config;
76 // Audio Stream Output Task (ASOT) parameters, functions
77 typedef struct PAF_ASOT_Fxns {
78     Int (*initPhase[8]) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
79     Int (*initFrame0) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
80     Int (*initFrame1) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);    
81     Int (*decodeProcessing) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);    
82     Int (*encodeCommand) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
83     Int (*decodeInit) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
84     Int (*decodeInfo1) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
85     Int (*decodeInfo2) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
86     Int (*decodeStream) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
87     Int (*decodeEncode) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
88     Int (*decodeFinalTest) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);    
89     Int (*decodeComplete) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
90     Int (*selectDevices) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Bool *);
91     Int (*startOutput) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
92     Int (*stopOutput) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
93     Int (*setCheckRateX) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
94     Int (*streamChainFunction) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int, Int);
95     Int (*deviceAllocate) (SIO_Handle *, int, int, int, Ptr);
96     Int (*deviceSelect) (SIO_Handle *, int, int, Ptr);
98     // For RAM_report
99     Void (*headerPrint)();
100     Int  (*allocPrint)(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p);
101     Void (*commonPrint)(IALG_MemRec common[], PAF_IALG_Config *p);
102     Void (*bufMemPrint)(Int z, Int size, Int heapId, Int bufType);
103     Void (*memStatusPrint)(
104         CString header, 
105         HeapMem_Handle hInternalHeap, 
106         HeapMem_Handle hInternal1Heap, 
107         HeapMem_Handle hExternalHeap, 
108         HeapMem_Handle hInternal1HeapShm, 
109         HeapMem_Handle hExternalHeapShm, 
110         HeapMem_Handle hExternalNoncachedHeapShm);
111 } PAF_ASOT_Fxns;
113 // Audio Stream Output Task (ASOT) parameters
114 typedef struct PAF_ASOT_Params {
115     const PAF_ASOT_Fxns *fxns;
116     struct {
117         SmInt master;
118         SmInt inputs;
119         SmInt input1;
120         SmInt inputN;
121         SmInt decodes;
122         SmInt decode1;
123         SmInt decodeN;
124         SmInt streams;
125         SmInt stream1; /* unused */
126         SmInt streamN; /* unused */
127         SmInt encodes;
128         SmInt encode1;
129         SmInt encodeN;
130         SmInt outputs;
131         SmInt output1;
132         SmInt outputN;
133     } zone;
134     const SmInt *inputsFromDecodes;
135     const SmInt *outputsFromEncodes;
136     struct {
137         int *pHeapIdIntern;             // INT memory heap ID
138         int *pHeapIdExtern;             // EXT memory heap ID
139         int *pHeapIdInpbuf;             // IB buffer heap ID
140         int *pHeapIdOutbuf;             // OB buffer heap ID
141         int *pHeapIdFrmbuf;             // Frame buffer heap ID
142         int *pHeapIdIntern1;            // INT1 memory heap ID
143         int *pHeapIdInt1Shm;            // INT1 SHared Memory heap ID
144         int *pHeapIdExtShm;             // EXT SHared Memory heap ID
145         int *pHeapIdExtNonCachedShm;    // EXT Non-Cached SHared Memory heap ID
146         int clear; 
147     } heap;
148     struct {
149         const IALG_MemSpace *space;
150     } common;
151     const LgInt *z_rx_bufsiz;
152     const LgInt *z_tx_bufsiz;
153     const SmInt *z_numchan;
154     MdInt framelength;
155     const PAF_AudioFunctions *pAudioFrameFunctions;
156     const struct PAF_ASP_ChainFxns *pChainFxns;
157     const PAF_InpBufStatus *pInpBufStatus;
158     const PAF_DecodeStatus * const *z_pDecodeStatus;
159     const PAF_OutBufStatus *pOutBufStatus;
160     const PAF_EncodeStatus * const *z_pEncodeStatus;
161     const PAF_VolumeStatus *pVolumeStatus;
162     const PAF_ASP_AlgKey *pDecAlgKey;
163     const PAF_ASP_AlgKey *pEncAlgKey;
164     const PAF_ASP_SioMap *pDecSioMap;
165     const SmInt *streamsFromDecodes;
166     const SmInt *streamsFromEncodes;
167     const MdInt maxFramelength;
168     const SmInt *streamOrder;
169     const PAF_ASP_LinkInit * const (*i_inpLinkInit);
170     const PAF_ASP_LinkInit * const (*i_outLinkInit);
171     const PAF_ASP_outNumBufMap *  const (*poutNumBufMap);
172     const PAF_MetadataBufStatus *pMetadataBufStatus;
173     const PAF_AudioFrameBufStatus *pAudioFrameBufStatus;
174 } PAF_ASOT_Params;
176 // Audio Stream Output Task (ASOT) patchs
177 typedef struct PAF_ASOT_Patchs {
178     const PAF_SIO_ParamsN * devout;
179     const PAF_ASP_LinkInit * const (*i_aspLinkInit)[GEARS];
180     const PAF_ASP_LinkInit * const (*i_encLinkInit);
181 } PAF_ASOT_Patchs;
183 typedef struct PAF_AST_OutIO {
184     ioPhyHandle_t        hIoPhy;     /* handle to I/O physical layer */
185     ioBuffHandle_t       hIoBuff;    /* handle to I/O buffer management */
186     Ptr                  hMcaspChan; /* handle to McASP LLD channel for output */
187     uint32_t             phyXferSize;
189     void     *mcaspTxBuf1;
190     void     *mcaspTxBuf2;
191     uint32_t  mcaspTxSize1;
192     uint32_t  mcaspTxSize2;
193     int       mcaspTxtwoXfers;
195     int       numPrimeXfers;
197     uint32_t  mcaspXferErr;
199     void  *buff1;   // pointer to 1st buffer in output memory pool
200     void  *buff2;   // pointer to 2nd buffer in output memory pool in case of buffer wrap
201     size_t size1;   // size of 1st buffer in output memory pool
202     size_t size2;   // size of 2nd buffer in output memory pool
203     
204     uint32_t ioBuffBuf2AllocCnt;
205     uint32_t errIoBuffOvrCnt;
206     uint32_t errIoBuffUndCnt;
207     
208     // debugging counters
209     uint32_t num_xfers;
211 } PAF_AST_IoOut;
213 // Audio Stream Input Task (ASOT) configuration
214 typedef struct PAF_ASOT_Config {
215     Task_Handle     taskHandle;                 // ASOT task handle
216     uint_least16_t  state;                      // ASOT state
217     ACP_Handle      acp;                        // ASOT ACP handle
218     Int8            cbDrainedFlag[DECODEN_MAX]; // CB drained flags
219     PAF_ASPM_Config *pAspmCfg;                  // ASIT/ASOT shared configuration
220     PAF_AST_Config  *pAstCfg;                   // ASIT/ASOT/ASDT shared configuration
221     PAF_AST_IoOut   *pIoOut;                    // ASOT IO configuration
222 } PAF_ASOT_Config;
224 // ASOT configuration
225 extern PAF_ASOT_Config gPAF_ASOT_config;
227 #endif /* _ASOP_H_ */