]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pasdk/test_dsp/framework/audioStreamInpProc.h
Cleaned up code repetitions of messaging and shared memory read/write.
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / audioStreamInpProc.h
2 /*
3 Copyright (c) 2016, 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 } PAF_ASIT_Params;
170 // Audio Stream Input Task (ASIT) patchs
171 typedef struct PAF_ASIT_Patchs {
172     const PAF_SIO_ParamsN * devinp;
173     //const PAF_SIO_ParamsN * devout;
174     //const PAF_ASP_LinkInit * const (*i_decLinkInit);
175     //const PAF_ASP_LinkInit * const (*i_aspLinkInit)[GEARS];
176     //const PAF_ASP_LinkInit * const (*i_encLinkInit);
177 } PAF_ASIT_Patchs;
179 // Audio Stream Input Task (ASIT) configuration
180 typedef struct PAF_ASIT_Config {
181     Task_Handle taskHandle;     // ASIT handle
182     ACP_Handle acp;             // ASIT local ACP handle
183     PAF_ASPM_Config *pAspmCfg;  // ASIT/ASOT shared configuration
184     PAF_AST_Config *pAstCfg;    // ASIT/ASOT/ASDT shared configuration
185 } PAF_ASIT_Config;
188 //   Purpose:   Audio Stream Input Task Function for initialization of data pointers
189 //              by allocation of memory.
190 Int 
191 PAF_ASIT_initPhaseMalloc(
192     const PAF_ASIT_Params *pP, 
193     const PAF_ASIT_Patchs *pQ, 
194     PAF_ASIT_Config *pAsitCfg
195 );
197 //   Purpose:   Audio Stream Input Task Function for initialization of data values
198 //              from parameters.
199 Int
200 PAF_ASIT_initPhaseConfig(
201     const PAF_ASIT_Params *pP, 
202     const PAF_ASIT_Patchs *pQ, 
203     PAF_ASIT_Config *pAsitCfg
204 );
206 //   Purpose:   Audio Stream Input Task Function for initialization of ACP by
207 //              instantiation of the algorithm.
208 Int
209 PAF_ASIT_initPhaseAcpAlg(
210     const PAF_ASIT_Params *pP, 
211     const PAF_ASIT_Patchs *pQ, 
212     PAF_ASIT_Config *pAsitCfg
213 );
215 //   (***) FL: re-visit this, ASIT/ASOT currently consider common memory independently.
216 //             Should simultaneously consider all algs in ASIT/ASOT.
217 //   Purpose:   Audio Stream Input Task Function for allocation of common memory.
218 Int
219 PAF_ASIT_initPhaseCommon(
220     const PAF_ASIT_Params *pP, 
221     const PAF_ASIT_Patchs *pQ, 
222     PAF_ASIT_Config *pAsitCfg
223 );
225 //   Purpose:   Audio Stream Input Task Function for initialization of ASP algorithms.
226 Int
227 PAF_ASIT_initPhaseAspAlg(
228     const PAF_ASIT_Params *pP, 
229     const PAF_ASIT_Patchs *pQ, 
230     PAF_ASIT_Config *pAsitCfg
231 );
233 //   Purpose:   Audio Stream Input Task Function for initialization of data values
234 //              from parameters for Algorithm Keys.
235 Int
236 PAF_ASIT_initPhaseAlgKey(
237     const PAF_ASIT_Params *pP, 
238     const PAF_ASIT_Patchs *pQ, 
239     PAF_ASIT_Config *pAsitCfg
240 );
242 //   Purpose:   Audio Stream Input Task Function for initialization of Decoder Output Circular Buffer.
243 Int
244 PAF_ASIT_initPhaseDecOpCircBuf(
245     const PAF_ASIT_Params *pP, 
246     const PAF_ASIT_Patchs *pQ, 
247     PAF_ASIT_Config *pAsitCfg
248 );
250 //   Purpose:   Audio Stream Input Task Function for initialization of Input Devices.
251 Int
252 PAF_ASIT_initPhaseDevice(
253     const PAF_ASIT_Params *pP, 
254     const PAF_ASIT_Patchs *pQ, 
255     PAF_ASIT_Config *pAsitCfg
256 );
258 #if 0
259 //   Purpose:   Audio Stream Task Function for initialization or reinitiali-
260 //              zation of the Audio Frame(s) by loading of data values of a
261 //              time-varying nature.
262 Int
263 PAF_AST_initFrame1(
264     const PAF_ASIT_Params *pP, 
265     const PAF_ASIT_Patchs *pQ, 
266     PAF_AST_Config *pAsitCfg, 
267     Int z, 
268     Int apply
269 );
270 #endif
272 //   Purpose:   Audio Stream Task Function for processing audio data to
273 //              determine the input type without output.
274 Int
275 PAF_ASIT_autoProcessing(
276     const PAF_ASIT_Params *pP, 
277     const PAF_ASIT_Patchs *pQ, 
278     PAF_ASIT_Config *pAsitCfg, 
279     Int inputTypeSelect, 
280     ALG_Handle pcmAlgMaster);
282 //   Purpose:   Audio Stream Input Task Function for processing audio data.
283 //
284 Int
285 PAF_ASIT_decodeProcessing(
286     const PAF_ASIT_Params *pP, 
287     const PAF_ASIT_Patchs *pQ, 
288     PAF_ASIT_Config *pAsitCfg, 
289     Int sourceSelect
290 );
292 //   Purpose:   Decoding Function for processing Decode Commands.
293 Int
294 PAF_ASIT_decodeCommand(
295     const PAF_ASIT_Params *pP, 
296     const PAF_ASIT_Patchs *pQ, 
297     PAF_ASIT_Config *pAsitCfg
298 );
300 //   Purpose:   Decoding Function for reinitializing the decoding process.
301 Int
302 PAF_ASIT_decodeInit(
303     const PAF_ASIT_Params *pP, 
304     const PAF_ASIT_Patchs *pQ, 
305     PAF_ASIT_Config *pAsitCfg, 
306     Int sourceSelect
307 );
309 //   Purpose:   Decoding Function for processing information in a manner that
310 //              is common for both initial and subsequent frames of input data.
311 Int
312 PAF_ASIT_decodeInfo(
313     const PAF_ASIT_Params *pP, 
314     const PAF_ASIT_Patchs *pQ, 
315     PAF_ASIT_Config *pAsitCfg, 
316     Int frame, 
317     Int block
318 );
320 //   Purpose:   Decoding Function for processing information in a manner that
321 //              is unique to initial frames of input data.
322 Int
323 PAF_ASIT_decodeInfo1(
324     const PAF_ASIT_Params *pP, 
325     const PAF_ASIT_Patchs *pQ, 
326     PAF_ASIT_Config *pAsitCfg, 
327     Int frame, 
328     Int block
329 );
331 //   Purpose:   Decoding Function for processing information in a manner that
332 //              is unique to frames of input data other than the initial one.
333 Int
334 PAF_ASIT_decodeInfo2(
335     const PAF_ASIT_Params *pP, 
336     const PAF_ASIT_Patchs *pQ, 
337     PAF_ASIT_Config *pAsitCfg, 
338     Int frame, 
339     Int block
340 );
342 #if 0
343 //   Purpose:   Decoding Function for processing that occurs subsequent to
344 //              information processing but antecedent to timing processing
345 //              for frames of input data other than the initial one.
346 Int
347 PAF_AST_decodeCont(
348     const PAF_ASIT_Params *pP, 
349     const PAF_ASIT_Patchs *pQ, 
350     PAF_ASIT_Config *pAsitCfg, 
351     ALG_Handle decAlg[], 
352     Int frame, 
353     Int block
354 );
355 #endif
357 //   Purpose:   Decoding Function for processing of input data by the
358 //              Decode Algorithm.
359 Int
360 PAF_ASIT_decodeDecode(
361     const PAF_ASIT_Params *pP, 
362     const PAF_ASIT_Patchs *pQ, 
363     PAF_ASIT_Config *pAsitCfg, 
364     Int sourceSelect, 
365     Int frame, 
366     Int block
367 );
369 //   Purpose:   Decoding Function for determining whether processing of the
370 //              current frame is complete.
371 Int
372 PAF_ASIT_decodeFinalTest(
373     const PAF_ASIT_Params *pP, 
374     const PAF_ASIT_Patchs *pQ, 
375     PAF_ASIT_Config *pAsitCfg, 
376     Int frame, 
377     Int block
378 );
380 //   Purpose:   Decoding Function for terminating the decoding process.
381 Int
382 PAF_ASIT_decodeComplete(
383     const PAF_ASIT_Params *pP, 
384     const PAF_ASIT_Patchs *pQ, 
385     PAF_ASIT_Config *pAsitCfg, 
386     ALG_Handle decAlg[], 
387     Int frame, 
388     Int block
389 );
391 //   Purpose:   Audio Stream Input Task Function for selecting the devices used
392 //              for input.
393 Int
394 PAF_ASIT_selectDevices(
395     const PAF_ASIT_Params *pP, 
396     const PAF_ASIT_Patchs *pQ, 
397     PAF_ASIT_Config *pAsitCfg
398 );
400 //   Purpose:   Audio Stream Input Task Function for selecting the sources used
401 //              for decoding of input to output.
402 Int
403 PAF_ASIT_sourceDecode(
404     const PAF_ASIT_Params *pP, 
405     const PAF_ASIT_Patchs *pQ, 
406     PAF_ASIT_Config *pAsitCfg, 
407     Int x
408 );
410 //   Purpose:   Decoding Function for terminating output.
411 Int
412 PAF_AST_stopOutput(
413     const PAF_ASIT_Params *pP, 
414     const PAF_ASIT_Patchs *pQ, 
415     PAF_ASIT_Config *pAsitCfg
416 );
418 //   Purpose:   Common Function for processing algorithm chains.
419 Int
420 PAF_AST_streamChainFunction(
421     const PAF_ASIT_Params *pP, 
422     const PAF_ASIT_Patchs *pQ, 
423     PAF_ASIT_Config *pAsitCfg, 
424     Int iChainFrameFxns, 
425     Int abortOnError, 
426     Int logArg
427 );
429 //   Purpose:   writing 8-bit integer to shared memeory
430 static inline
431 sharedMemWriteInt8(
432         volatile XDAS_Int8 *address, /* address to write to */
433         Int8 value,                  /* value to write to the adddress */
434         Int gateIdx)                 /* GateMP Index, defined in statusOp_common.h */
436 #ifdef NON_CACHE_STATUS
437         statusOp_write((void *)address, (void *)&value, sizeof(Int8), gateIdx);
438 #else
439         *address = value;
440 #endif
443 //   Purpose:   read 8-bit integer from shared memeory
444 static inline Int8               /* return the value read in the shared memory */
445 sharedMemReadInt8(
446         volatile XDAS_Int8 *address, /* address to read from */
447         Int gateIdx)                 /* GateMP Index, defined in statusOp_common.h */
449 #ifdef NON_CACHE_STATUS
450         Int8 tempVar;
451         statusOp_read((void *)&tempVar, (void *)address, sizeof(Int8), gateIdx);
453         return tempVar;
454 #else
455         return(*address);
456 #endif
459 //   Purpose:   writing 32-bit integer to shared memeory
460 static inline sharedMemWriteInt(volatile XDAS_Int32 *address, Int value, Int gateIdx)
462 #ifdef NON_CACHE_STATUS
463         statusOp_write((void *)address, (void *)&value, sizeof(Int), gateIdx);
464 #else
465         *address = value;
466 #endif
469 //   Purpose:   read 32-bit integer from shared memeory
470 static inline Int sharedMemReadInt(volatile XDAS_Int32 *address, Int gateIdx)
472 #ifdef NON_CACHE_STATUS
473         Int tempVar;
474         statusOp_read((void *)&tempVar, (void *)address, sizeof(Int), gateIdx);
476         return tempVar;
477 #else
478         return(*address);
479 #endif
482 #endif /* _ASIP_H_ */