]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pasdk/test_dsp/framework/audioStreamInpProc.h
Added I/O components memory allocation to input and output
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamInpProc.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  *  ======== audioStreamInpProc.h ========
38  */
40 #ifndef _ASIP_H_
41 #define _ASIP_H_
42  
43 #include <xdc/std.h>
44 #include <ti/sysbios/knl/Task.h>
46 #include "audioStreamProc_params.h"
47 #include "audioStreamProc_patchs.h"
48 #include "audioStreamProc_config.h"
49 #include "audioStreamProc_master.h"
50 #include "statusOp_common.h"
51 #include "ioPhy.h"
52 #include "ioBuff.h"
53 #include "ioData.h"
55 // Global debug counter */
56 extern Uint32 gTaskAsipCnt; // debug counter for ASP task
58 struct PAF_ASIT_Params;
59 struct PAF_ASIT_Patchs;
60 struct PAF_ASIT_Config;
62 // Audio Stream Input Task (ASIT) parameters, functions
63 typedef struct PAF_ASIT_Fxns {
64     Int (*initPhase[8]) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
65     //Int (*initFrame0) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
66     //Int (*initFrame1) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
67     Int (*passProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
68     //Int (*passProcessingCopy) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
69     Int (*autoProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, ALG_Handle);
70     Int (*decodeProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);    
71     Int (*decodeCommand) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
72     //Int (*encodeCommand) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
73     Int (*decodeInit) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
74     Int (*decodeInfo) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
75     Int (*decodeInfo1) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
76     Int (*decodeInfo2) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
77     //Int (*decodeCont) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, ALG_Handle *, Int, Int);
78     Int (*decodeDecode) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int, Int);
79     //Int (*decodeStream) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
80     //Int (*decodeEncode) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
81     Int (*decodeFinalTest) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);    
82     Int (*decodeComplete) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, ALG_Handle *, Int, Int);
83     Int (*selectDevices) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
84     Int (*sourceDecode) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);    
85     //Int (*startOutput) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
86     //Int (*stopOutput) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
87     //Int (*setCheckRateX) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
88     //Int (*streamChainFunction) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int, Int);
89     Int (*deviceAllocate) (SIO_Handle *, int, int, int, Ptr);
90     Int (*deviceSelect) (SIO_Handle *, int, int, Ptr);
91     Int (*computeFrameLength) (Int, Int, Int);
92     Int (*updateInputStatus) (SIO_Handle, PAF_InpBufStatus *, PAF_InpBufConfig *);
93     //Int (*copy) (Uns, PAF_InpBufConfig *, Uns, PAF_OutBufConfig *);
95     // For RAM_report
96     Void (*headerPrint)();
97     Int  (*allocPrint)(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p);
98     Void (*commonPrint)(IALG_MemRec common[], PAF_IALG_Config *p);
99     Void (*bufMemPrint)(Int z, Int size, Int heapId, Int bufType);
100     Void (*memStatusPrint)(
101         CString header, 
102         HeapMem_Handle hInternalHeap, 
103         HeapMem_Handle hInternal1Heap, 
104         HeapMem_Handle hExternalHeap, 
105         HeapMem_Handle hInternal1HeapShm, 
106         HeapMem_Handle hExternalHeapShm, 
107         HeapMem_Handle hExternalNoncachedHeapShm);
108 } PAF_ASIT_Fxns;
110 // Audio Stream Input Task (ASIT) parameters
111 typedef struct PAF_ASIT_Params {
112     const PAF_ASIT_Fxns *fxns;
113     struct {
114         SmInt master;
115         SmInt inputs;
116         SmInt input1;
117         SmInt inputN;
118         SmInt decodes;
119         SmInt decode1;
120         SmInt decodeN;
121         SmInt streams;
122         SmInt stream1; /* unused */
123         SmInt streamN; /* unused */
124         SmInt encodes;
125         SmInt encode1;
126         SmInt encodeN;
127         SmInt outputs;
128         SmInt output1;
129         SmInt outputN;
130     } zone;
131     const SmInt *inputsFromDecodes;
132     const SmInt *outputsFromEncodes;
133     struct {
134         int *pHeapIdIntern;             // INT memory heap ID
135         int *pHeapIdExtern;             // EXT memory heap ID
136         int *pHeapIdInpbuf;             // IB buffer heap ID
137         int *pHeapIdOutbuf;             // OB buffer heap ID
138         int *pHeapIdFrmbuf;             // Frame buffer heap ID
139         int *pHeapIdIntern1;            // INT1 memory heap ID
140         int *pHeapIdInt1Shm;            // INT1 SHared Memory heap ID
141         int *pHeapIdExtShm;             // EXT SHared Memory heap ID
142         int *pHeapIdExtNonCachedShm;    // EXT Non-Cached SHared Memory heap ID
143         int clear; 
144     } heap;
145     struct {
146         const IALG_MemSpace *space;
147     } common;
148     const LgInt *z_rx_bufsiz;
149     const LgInt *z_tx_bufsiz;
150     const SmInt *z_numchan;
151     MdInt framelength;
152     const PAF_AudioFunctions *pAudioFrameFunctions;
153     const struct PAF_ASP_ChainFxns *pChainFxns;
154     const PAF_InpBufStatus *pInpBufStatus;
155     const PAF_DecodeStatus * const *z_pDecodeStatus;
156     const PAF_OutBufStatus *pOutBufStatus;
157     const PAF_EncodeStatus * const *z_pEncodeStatus;
158     const PAF_VolumeStatus *pVolumeStatus;
159     const PAF_ASP_AlgKey *pDecAlgKey;
160     const PAF_ASP_AlgKey *pEncAlgKey;
161     const PAF_ASP_SioMap *pDecSioMap;
162     const SmInt *streamsFromDecodes;
163     const SmInt *streamsFromEncodes;
164     const MdInt maxFramelength;
165     const SmInt *streamOrder;
166     const PAF_ASP_LinkInit * const (*i_inpLinkInit);
167     const PAF_ASP_LinkInit * const (*i_outLinkInit);
168     const PAF_ASP_outNumBufMap *  const (*poutNumBufMap);
169     const PAF_MetadataBufStatus *pMetadataBufStatus;
170     const PAF_AudioFrameBufStatus *pAudioFrameBufStatus;
171     const PAF_AST_DecOpCircBufStatus * const *z_pDecOpCircBufStatus;    
172 } PAF_ASIT_Params;
174 // Audio Stream Input Task (ASIT) patchs
175 typedef struct PAF_ASIT_Patchs {
176     const PAF_SIO_ParamsN * devinp;
177     //const PAF_SIO_ParamsN * devout;
178     //const PAF_ASP_LinkInit * const (*i_decLinkInit);
179     //const PAF_ASP_LinkInit * const (*i_aspLinkInit)[GEARS];
180     //const PAF_ASP_LinkInit * const (*i_encLinkInit);
181 } PAF_ASIT_Patchs;
183 // Input I/O structure
184 typedef struct PAF_AST_InpIO {
185     ioPhyHandle_t        hIoPhy;     /* handle to I/O physical layer */
186     ioBuffHandle_t       hIoBuff;    /* handle to I/O buffer management */
187     ioDataHandle_t       hIoData;    /* handle to I/O data processing */
188     const void           *pRxParams; /* pointer to D10 Rx Params */
189     Int                  swapData;
191     Int       syncState;
192     Int       numPrimeXfers;
193     Int       mcaspXferErr;
194 /*
195     void     *mcaspRxBuf1;
196     void     *mcaspRxBuf2;
197     uint32_t  mcaspRxSize1;
198     uint32_t  mcaspRxSize2;
199     Int       mcaspRxtwoXfers;
200 */
201     // debugging counters
202     //uint32_t numXferStart;
203     //uint32_t numXferFinish;
204     //uint32_t numXferInterm;
205     uint32_t numInputOverrun;
206     uint32_t numAsipRestart;
207     uint32_t numAsipDecodeQuit;
209 } PAF_AST_IoInp;
210 // Audio Stream Input Task (ASIT) configuration
211 typedef struct PAF_ASIT_Config {
212     Task_Handle taskHandle;     // ASIT handle
213     ACP_Handle acp;             // ASIT local ACP handle
214     PAF_ASPM_Config *pAspmCfg;  // ASIT/ASOT shared configuration
215     PAF_AST_Config *pAstCfg;    // ASIT/ASOT/ASDT shared configuration
216     PAF_AST_IoInp  *pIoInp;
217 } PAF_ASIT_Config;
220 //   Purpose:   Audio Stream Input Task Function for initialization of data pointers
221 //              by allocation of memory.
222 Int 
223 PAF_ASIT_initPhaseMalloc(
224     const PAF_ASIT_Params *pP, 
225     const PAF_ASIT_Patchs *pQ, 
226     PAF_ASIT_Config *pAsitCfg
227 );
229 //   Purpose:   Audio Stream Input Task Function for initialization of data values
230 //              from parameters.
231 Int
232 PAF_ASIT_initPhaseConfig(
233     const PAF_ASIT_Params *pP, 
234     const PAF_ASIT_Patchs *pQ, 
235     PAF_ASIT_Config *pAsitCfg
236 );
238 //   Purpose:   Audio Stream Input Task Function for initialization of ACP by
239 //              instantiation of the algorithm.
240 Int
241 PAF_ASIT_initPhaseAcpAlg(
242     const PAF_ASIT_Params *pP, 
243     const PAF_ASIT_Patchs *pQ, 
244     PAF_ASIT_Config *pAsitCfg
245 );
247 //   (***) FL: re-visit this, ASIT/ASOT currently consider common memory independently.
248 //             Should simultaneously consider all algs in ASIT/ASOT.
249 //   Purpose:   Audio Stream Input Task Function for allocation of common memory.
250 Int
251 PAF_ASIT_initPhaseCommon(
252     const PAF_ASIT_Params *pP, 
253     const PAF_ASIT_Patchs *pQ, 
254     PAF_ASIT_Config *pAsitCfg
255 );
257 //   Purpose:   Audio Stream Input Task Function for initialization of ASP algorithms.
258 Int
259 PAF_ASIT_initPhaseAspAlg(
260     const PAF_ASIT_Params *pP, 
261     const PAF_ASIT_Patchs *pQ, 
262     PAF_ASIT_Config *pAsitCfg
263 );
265 //   Purpose:   Audio Stream Input Task Function for initialization of data values
266 //              from parameters for Algorithm Keys.
267 Int
268 PAF_ASIT_initPhaseAlgKey(
269     const PAF_ASIT_Params *pP, 
270     const PAF_ASIT_Patchs *pQ, 
271     PAF_ASIT_Config *pAsitCfg
272 );
274 //   Purpose:   Audio Stream Input Task Function for initialization of Decoder Output Circular Buffer.
275 Int
276 PAF_ASIT_initPhaseDecOpCircBuf(
277     const PAF_ASIT_Params *pP, 
278     const PAF_ASIT_Patchs *pQ, 
279     PAF_ASIT_Config *pAsitCfg
280 );
282 //   Purpose:   Audio Stream Input Task Function for initialization of Input Devices.
283 Int
284 PAF_ASIT_initPhaseDevice(
285     const PAF_ASIT_Params *pP, 
286     const PAF_ASIT_Patchs *pQ, 
287     PAF_ASIT_Config *pAsitCfg
288 );
290 //   Purpose:   Audio Stream Input Task Function for initialization of Output Init-Sync.
291 Int
292 PAF_ASIT_initPhaseOutIS(
293     const PAF_ASIT_Params *pP, 
294     const PAF_ASIT_Patchs *pQ, 
295     PAF_ASIT_Config *pAsdtCfg
296 );
299 #if 0
300 //   Purpose:   Audio Stream Task Function for initialization or reinitiali-
301 //              zation of the Audio Frame(s) by loading of data values of a
302 //              time-varying nature.
303 Int
304 PAF_AST_initFrame1(
305     const PAF_ASIT_Params *pP, 
306     const PAF_ASIT_Patchs *pQ, 
307     PAF_AST_Config *pAsitCfg, 
308     Int z, 
309     Int apply
310 );
311 #endif
313 //   Purpose:   Audio Stream Task Function for processing audio data to
314 //              determine the input type without output.
315 Int
316 PAF_ASIT_autoProcessing(
317     const PAF_ASIT_Params *pP, 
318     const PAF_ASIT_Patchs *pQ, 
319     PAF_ASIT_Config *pAsitCfg, 
320     Int inputTypeSelect, 
321     ALG_Handle pcmAlgMaster);
323 //   Purpose:   Audio Stream Input Task Function for processing audio data.
324 //
325 Int
326 PAF_ASIT_decodeProcessing(
327     const PAF_ASIT_Params *pP, 
328     const PAF_ASIT_Patchs *pQ, 
329     PAF_ASIT_Config *pAsitCfg, 
330     Int sourceSelect
331 );
333 //   Purpose:   Decoding Function for processing Decode Commands.
334 Int
335 PAF_ASIT_decodeCommand(
336     const PAF_ASIT_Params *pP, 
337     const PAF_ASIT_Patchs *pQ, 
338     PAF_ASIT_Config *pAsitCfg
339 );
341 //   Purpose:   Decoding Function for reinitializing the decoding process.
342 Int
343 PAF_ASIT_decodeInit(
344     const PAF_ASIT_Params *pP, 
345     const PAF_ASIT_Patchs *pQ, 
346     PAF_ASIT_Config *pAsitCfg, 
347     Int sourceSelect
348 );
350 //   Purpose:   Decoding Function for processing information in a manner that
351 //              is common for both initial and subsequent frames of input data.
352 Int
353 PAF_ASIT_decodeInfo(
354     const PAF_ASIT_Params *pP, 
355     const PAF_ASIT_Patchs *pQ, 
356     PAF_ASIT_Config *pAsitCfg, 
357     Int frame, 
358     Int block
359 );
361 //   Purpose:   Decoding Function for processing information in a manner that
362 //              is unique to initial frames of input data.
363 Int
364 PAF_ASIT_decodeInfo1(
365     const PAF_ASIT_Params *pP, 
366     const PAF_ASIT_Patchs *pQ, 
367     PAF_ASIT_Config *pAsitCfg, 
368     Int frame, 
369     Int block
370 );
372 //   Purpose:   Decoding Function for processing information in a manner that
373 //              is unique to frames of input data other than the initial one.
374 Int
375 PAF_ASIT_decodeInfo2(
376     const PAF_ASIT_Params *pP, 
377     const PAF_ASIT_Patchs *pQ, 
378     PAF_ASIT_Config *pAsitCfg, 
379     Int frame, 
380     Int block
381 );
383 #if 0
384 //   Purpose:   Decoding Function for processing that occurs subsequent to
385 //              information processing but antecedent to timing processing
386 //              for frames of input data other than the initial one.
387 Int
388 PAF_AST_decodeCont(
389     const PAF_ASIT_Params *pP, 
390     const PAF_ASIT_Patchs *pQ, 
391     PAF_ASIT_Config *pAsitCfg, 
392     ALG_Handle decAlg[], 
393     Int frame, 
394     Int block
395 );
396 #endif
398 //   Purpose:   Decoding Function for processing of input data by the
399 //              Decode Algorithm.
400 Int
401 PAF_ASIT_decodeDecode(
402     const PAF_ASIT_Params *pP, 
403     const PAF_ASIT_Patchs *pQ, 
404     PAF_ASIT_Config *pAsitCfg, 
405     Int sourceSelect, 
406     Int frame, 
407     Int block
408 );
410 //   Purpose:   Decoding Function for determining whether processing of the
411 //              current frame is complete.
412 Int
413 PAF_ASIT_decodeFinalTest(
414     const PAF_ASIT_Params *pP, 
415     const PAF_ASIT_Patchs *pQ, 
416     PAF_ASIT_Config *pAsitCfg, 
417     Int frame, 
418     Int block
419 );
421 //   Purpose:   Decoding Function for terminating the decoding process.
422 Int
423 PAF_ASIT_decodeComplete(
424     const PAF_ASIT_Params *pP, 
425     const PAF_ASIT_Patchs *pQ, 
426     PAF_ASIT_Config *pAsitCfg, 
427     ALG_Handle decAlg[], 
428     Int frame, 
429     Int block
430 );
432 //   Purpose:   Audio Stream Input Task Function for selecting the devices used
433 //              for input.
434 Int
435 PAF_ASIT_selectDevices(
436     const PAF_ASIT_Params *pP, 
437     const PAF_ASIT_Patchs *pQ, 
438     PAF_ASIT_Config *pAsitCfg
439 );
441 //   Purpose:   Audio Stream Input Task Function for selecting the sources used
442 //              for decoding of input to output.
443 Int
444 PAF_ASIT_sourceDecode(
445     const PAF_ASIT_Params *pP, 
446     const PAF_ASIT_Patchs *pQ, 
447     PAF_ASIT_Config *pAsitCfg, 
448     Int x
449 );
451 //   Purpose:   Decoding Function for terminating output.
452 Int
453 PAF_AST_stopOutput(
454     const PAF_ASIT_Params *pP, 
455     const PAF_ASIT_Patchs *pQ, 
456     PAF_ASIT_Config *pAsitCfg
457 );
459 //   Purpose:   Common Function for processing algorithm chains.
460 Int
461 PAF_AST_streamChainFunction(
462     const PAF_ASIT_Params *pP, 
463     const PAF_ASIT_Patchs *pQ, 
464     PAF_ASIT_Config *pAsitCfg, 
465     Int iChainFrameFxns, 
466     Int abortOnError, 
467     Int logArg
468 );
470 //   Purpose:   writing 8-bit integer to shared memeory
471 static inline
472 sharedMemWriteInt8(
473         volatile XDAS_Int8 *address, /* address to write to */
474         Int8 value,                  /* value to write to the adddress */
475         Int gateIdx)                 /* GateMP Index, defined in statusOp_common.h */
477 #ifdef NON_CACHE_STATUS
478         statusOp_write((void *)address, (void *)&value, sizeof(Int8), gateIdx);
479 #else
480         *address = value;
481 #endif
484 //   Purpose:   read 8-bit integer from shared memeory
485 static inline Int8               /* return the value read in the shared memory */
486 sharedMemReadInt8(
487         volatile XDAS_Int8 *address, /* address to read from */
488         Int gateIdx)                 /* GateMP Index, defined in statusOp_common.h */
490 #ifdef NON_CACHE_STATUS
491         Int8 tempVar;
492         statusOp_read((void *)&tempVar, (void *)address, sizeof(Int8), gateIdx);
494         return tempVar;
495 #else
496         return(*address);
497 #endif
500 //   Purpose:   writing 32-bit integer to shared memeory
501 static inline sharedMemWriteInt(volatile XDAS_Int32 *address, Int value, Int gateIdx)
503 #ifdef NON_CACHE_STATUS
504         statusOp_write((void *)address, (void *)&value, sizeof(Int), gateIdx);
505 #else
506         *address = value;
507 #endif
510 //   Purpose:   read 32-bit integer from shared memeory
511 static inline Int sharedMemReadInt(volatile XDAS_Int32 *address, Int gateIdx)
513 #ifdef NON_CACHE_STATUS
514         Int tempVar;
515         statusOp_read((void *)&tempVar, (void *)address, sizeof(Int), gateIdx);
517         return tempVar;
518 #else
519         return(*address);
520 #endif
523 #endif /* _ASIP_H_ */