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