d8d5469d6de4da87d3b4b4489acbadc3e749c380
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_
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"
51 // Global debug counter */
52 extern Uint32 gTaskAsipCnt; // debug counter for ASP task
54 struct PAF_ASIT_Params;
55 struct PAF_ASIT_Patchs;
56 struct PAF_ASIT_Config;
58 // Audio Stream Input Task (ASIT) parameters, functions
59 typedef struct PAF_ASIT_Fxns {
60 Int (*initPhase[8]) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
61 //Int (*initFrame0) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
62 //Int (*initFrame1) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
63 Int (*passProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
64 //Int (*passProcessingCopy) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
65 Int (*autoProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, ALG_Handle);
66 Int (*decodeProcessing) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
67 Int (*decodeCommand) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
68 //Int (*encodeCommand) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
69 Int (*decodeInit) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
70 Int (*decodeInfo) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
71 Int (*decodeInfo1) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
72 Int (*decodeInfo2) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
73 //Int (*decodeCont) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, ALG_Handle *, Int, Int);
74 Int (*decodeDecode) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int, Int);
75 //Int (*decodeStream) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
76 //Int (*decodeEncode) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int);
77 Int (*decodeFinalTest) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int, Int);
78 Int (*decodeComplete) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, ALG_Handle *, Int, Int);
79 Int (*selectDevices) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *);
80 Int (*sourceDecode) (const struct PAF_ASIT_Params *, const struct PAF_ASIT_Patchs *, struct PAF_ASIT_Config *, Int);
81 //Int (*startOutput) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
82 //Int (*stopOutput) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *);
83 //Int (*setCheckRateX) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int);
84 //Int (*streamChainFunction) (const struct PAF_AST_Params *, const struct PAF_AST_Patchs *, struct PAF_AST_Config *, Int, Int, Int);
85 Int (*deviceAllocate) (SIO_Handle *, int, int, int, Ptr);
86 Int (*deviceSelect) (SIO_Handle *, int, int, Ptr);
87 Int (*computeFrameLength) (Int, Int, Int);
88 Int (*updateInputStatus) (SIO_Handle, PAF_InpBufStatus *, PAF_InpBufConfig *);
89 //Int (*copy) (Uns, PAF_InpBufConfig *, Uns, PAF_OutBufConfig *);
91 // For RAM_report
92 Void (*headerPrint)();
93 Int (*allocPrint)(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p);
94 Void (*commonPrint)(IALG_MemRec common[], PAF_IALG_Config *p);
95 Void (*bufMemPrint)(Int z, Int size, Int heapId, Int bufType);
96 Void (*memStatusPrint)(
97 CString header,
98 HeapMem_Handle hInternalHeap,
99 HeapMem_Handle hInternal1Heap,
100 HeapMem_Handle hExternalHeap,
101 HeapMem_Handle hInternal1HeapShm,
102 HeapMem_Handle hExternalHeapShm,
103 HeapMem_Handle hExternalNoncachedHeapShm);
104 } PAF_ASIT_Fxns;
106 // Audio Stream Input Task (ASIT) parameters
107 typedef struct PAF_ASIT_Params {
108 const PAF_ASIT_Fxns *fxns;
109 struct {
110 SmInt master;
111 SmInt inputs;
112 SmInt input1;
113 SmInt inputN;
114 SmInt decodes;
115 SmInt decode1;
116 SmInt decodeN;
117 SmInt streams;
118 SmInt stream1; /* unused */
119 SmInt streamN; /* unused */
120 SmInt encodes;
121 SmInt encode1;
122 SmInt encodeN;
123 SmInt outputs;
124 SmInt output1;
125 SmInt outputN;
126 } zone;
127 const SmInt *inputsFromDecodes;
128 const SmInt *outputsFromEncodes;
129 struct {
130 int *pHeapIdIntern; // INT memory heap ID
131 int *pHeapIdExtern; // EXT memory heap ID
132 int *pHeapIdInpbuf; // IB buffer heap ID
133 int *pHeapIdOutbuf; // OB buffer heap ID
134 int *pHeapIdFrmbuf; // Frame buffer heap ID
135 int *pHeapIdIntern1; // INT1 memory heap ID
136 int *pHeapIdInt1Shm; // INT1 SHared Memory heap ID
137 int *pHeapIdExtShm; // EXT SHared Memory heap ID
138 int *pHeapIdExtNonCachedShm; // EXT Non-Cached SHared Memory heap ID
139 int clear;
140 } heap;
141 struct {
142 const IALG_MemSpace *space;
143 } common;
144 const LgInt *z_rx_bufsiz;
145 const LgInt *z_tx_bufsiz;
146 const SmInt *z_numchan;
147 MdInt framelength;
148 const PAF_AudioFunctions *pAudioFrameFunctions;
149 const struct PAF_ASP_ChainFxns *pChainFxns;
150 const PAF_InpBufStatus *pInpBufStatus;
151 const PAF_DecodeStatus * const *z_pDecodeStatus;
152 const PAF_OutBufStatus *pOutBufStatus;
153 const PAF_EncodeStatus * const *z_pEncodeStatus;
154 const PAF_VolumeStatus *pVolumeStatus;
155 const PAF_ASP_AlgKey *pDecAlgKey;
156 const PAF_ASP_AlgKey *pEncAlgKey;
157 const PAF_ASP_SioMap *pDecSioMap;
158 const SmInt *streamsFromDecodes;
159 const SmInt *streamsFromEncodes;
160 const MdInt maxFramelength;
161 const SmInt *streamOrder;
162 const PAF_ASP_LinkInit * const (*i_inpLinkInit);
163 const PAF_ASP_LinkInit * const (*i_outLinkInit);
164 const PAF_ASP_outNumBufMap * const (*poutNumBufMap);
165 const PAF_MetadataBufStatus *pMetadataBufStatus;
166 const PAF_AudioFrameBufStatus *pAudioFrameBufStatus;
167 } PAF_ASIT_Params;
169 // Audio Stream Input Task (ASIT) patchs
170 typedef struct PAF_ASIT_Patchs {
171 const PAF_SIO_ParamsN * devinp;
172 //const PAF_SIO_ParamsN * devout;
173 //const PAF_ASP_LinkInit * const (*i_decLinkInit);
174 //const PAF_ASP_LinkInit * const (*i_aspLinkInit)[GEARS];
175 //const PAF_ASP_LinkInit * const (*i_encLinkInit);
176 } PAF_ASIT_Patchs;
178 // Audio Stream Input Task (ASIT) configuration
179 typedef struct PAF_ASIT_Config {
180 Task_Handle taskHandle; // ASIT handle
181 ACP_Handle acp; // ASIT local ACP handle
182 PAF_ASPM_Config *pAspmCfg; // ASIT/ASOT shared configuration
183 PAF_AST_Config *pAstCfg; // ASIT/ASOT/ASDT shared configuration
184 } PAF_ASIT_Config;
187 // Purpose: Audio Stream Input Task Function for initialization of data pointers
188 // by allocation of memory.
189 Int
190 PAF_ASIT_initPhaseMalloc(
191 const PAF_ASIT_Params *pP,
192 const PAF_ASIT_Patchs *pQ,
193 PAF_ASIT_Config *pAsitCfg
194 );
196 // Purpose: Audio Stream Input Task Function for initialization of data values
197 // from parameters.
198 Int
199 PAF_ASIT_initPhaseConfig(
200 const PAF_ASIT_Params *pP,
201 const PAF_ASIT_Patchs *pQ,
202 PAF_ASIT_Config *pAsitCfg
203 );
205 // Purpose: Audio Stream Input Task Function for initialization of ACP by
206 // instantiation of the algorithm.
207 Int
208 PAF_ASIT_initPhaseAcpAlg(
209 const PAF_ASIT_Params *pP,
210 const PAF_ASIT_Patchs *pQ,
211 PAF_ASIT_Config *pAsitCfg
212 );
214 // (***) FL: re-visit this, ASIT/ASOT currently consider common memory independently.
215 // Should simultaneously consider all algs in ASIT/ASOT.
216 // Purpose: Audio Stream Input Task Function for allocation of common memory.
217 Int
218 PAF_ASIT_initPhaseCommon(
219 const PAF_ASIT_Params *pP,
220 const PAF_ASIT_Patchs *pQ,
221 PAF_ASIT_Config *pAsitCfg
222 );
224 // Purpose: Audio Stream Input Task Function for initialization of ASP algorithms.
225 Int
226 PAF_ASIT_initPhaseAspAlg(
227 const PAF_ASIT_Params *pP,
228 const PAF_ASIT_Patchs *pQ,
229 PAF_ASIT_Config *pAsitCfg
230 );
232 // Purpose: Audio Stream Input Task Function for initialization of data values
233 // from parameters for Algorithm Keys.
234 Int
235 PAF_ASIT_initPhaseAlgKey(
236 const PAF_ASIT_Params *pP,
237 const PAF_ASIT_Patchs *pQ,
238 PAF_ASIT_Config *pAsitCfg
239 );
241 // Purpose: Audio Stream Input Task Function for initialization of Decoder Output Circular Buffer.
242 Int
243 PAF_ASIT_initPhaseDecOpCircBuf(
244 const PAF_ASIT_Params *pP,
245 const PAF_ASIT_Patchs *pQ,
246 PAF_ASIT_Config *pAsitCfg
247 );
249 // Purpose: Audio Stream Input Task Function for initialization of Input Devices.
250 Int
251 PAF_ASIT_initPhaseDevice(
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 Output Init-Sync.
258 Int
259 PAF_ASIT_initPhaseOutIS(
260 const PAF_ASIT_Params *pP,
261 const PAF_ASIT_Patchs *pQ,
262 PAF_ASIT_Config *pAsdtCfg
263 );
266 #if 0
267 // Purpose: Audio Stream Task Function for initialization or reinitiali-
268 // zation of the Audio Frame(s) by loading of data values of a
269 // time-varying nature.
270 Int
271 PAF_AST_initFrame1(
272 const PAF_ASIT_Params *pP,
273 const PAF_ASIT_Patchs *pQ,
274 PAF_AST_Config *pAsitCfg,
275 Int z,
276 Int apply
277 );
278 #endif
280 // Purpose: Audio Stream Task Function for processing audio data to
281 // determine the input type without output.
282 Int
283 PAF_ASIT_autoProcessing(
284 const PAF_ASIT_Params *pP,
285 const PAF_ASIT_Patchs *pQ,
286 PAF_ASIT_Config *pAsitCfg,
287 Int inputTypeSelect,
288 ALG_Handle pcmAlgMaster);
290 // Purpose: Audio Stream Input Task Function for processing audio data.
291 //
292 Int
293 PAF_ASIT_decodeProcessing(
294 const PAF_ASIT_Params *pP,
295 const PAF_ASIT_Patchs *pQ,
296 PAF_ASIT_Config *pAsitCfg,
297 Int sourceSelect
298 );
300 // Purpose: Decoding Function for processing Decode Commands.
301 Int
302 PAF_ASIT_decodeCommand(
303 const PAF_ASIT_Params *pP,
304 const PAF_ASIT_Patchs *pQ,
305 PAF_ASIT_Config *pAsitCfg
306 );
308 // Purpose: Decoding Function for reinitializing the decoding process.
309 Int
310 PAF_ASIT_decodeInit(
311 const PAF_ASIT_Params *pP,
312 const PAF_ASIT_Patchs *pQ,
313 PAF_ASIT_Config *pAsitCfg,
314 Int sourceSelect
315 );
317 // Purpose: Decoding Function for processing information in a manner that
318 // is common for both initial and subsequent frames of input data.
319 Int
320 PAF_ASIT_decodeInfo(
321 const PAF_ASIT_Params *pP,
322 const PAF_ASIT_Patchs *pQ,
323 PAF_ASIT_Config *pAsitCfg,
324 Int frame,
325 Int block
326 );
328 // Purpose: Decoding Function for processing information in a manner that
329 // is unique to initial frames of input data.
330 Int
331 PAF_ASIT_decodeInfo1(
332 const PAF_ASIT_Params *pP,
333 const PAF_ASIT_Patchs *pQ,
334 PAF_ASIT_Config *pAsitCfg,
335 Int frame,
336 Int block
337 );
339 // Purpose: Decoding Function for processing information in a manner that
340 // is unique to frames of input data other than the initial one.
341 Int
342 PAF_ASIT_decodeInfo2(
343 const PAF_ASIT_Params *pP,
344 const PAF_ASIT_Patchs *pQ,
345 PAF_ASIT_Config *pAsitCfg,
346 Int frame,
347 Int block
348 );
350 #if 0
351 // Purpose: Decoding Function for processing that occurs subsequent to
352 // information processing but antecedent to timing processing
353 // for frames of input data other than the initial one.
354 Int
355 PAF_AST_decodeCont(
356 const PAF_ASIT_Params *pP,
357 const PAF_ASIT_Patchs *pQ,
358 PAF_ASIT_Config *pAsitCfg,
359 ALG_Handle decAlg[],
360 Int frame,
361 Int block
362 );
363 #endif
365 // Purpose: Decoding Function for processing of input data by the
366 // Decode Algorithm.
367 Int
368 PAF_ASIT_decodeDecode(
369 const PAF_ASIT_Params *pP,
370 const PAF_ASIT_Patchs *pQ,
371 PAF_ASIT_Config *pAsitCfg,
372 Int sourceSelect,
373 Int frame,
374 Int block
375 );
377 // Purpose: Decoding Function for determining whether processing of the
378 // current frame is complete.
379 Int
380 PAF_ASIT_decodeFinalTest(
381 const PAF_ASIT_Params *pP,
382 const PAF_ASIT_Patchs *pQ,
383 PAF_ASIT_Config *pAsitCfg,
384 Int frame,
385 Int block
386 );
388 // Purpose: Decoding Function for terminating the decoding process.
389 Int
390 PAF_ASIT_decodeComplete(
391 const PAF_ASIT_Params *pP,
392 const PAF_ASIT_Patchs *pQ,
393 PAF_ASIT_Config *pAsitCfg,
394 ALG_Handle decAlg[],
395 Int frame,
396 Int block
397 );
399 // Purpose: Audio Stream Input Task Function for selecting the devices used
400 // for input.
401 Int
402 PAF_ASIT_selectDevices(
403 const PAF_ASIT_Params *pP,
404 const PAF_ASIT_Patchs *pQ,
405 PAF_ASIT_Config *pAsitCfg
406 );
408 // Purpose: Audio Stream Input Task Function for selecting the sources used
409 // for decoding of input to output.
410 Int
411 PAF_ASIT_sourceDecode(
412 const PAF_ASIT_Params *pP,
413 const PAF_ASIT_Patchs *pQ,
414 PAF_ASIT_Config *pAsitCfg,
415 Int x
416 );
418 // Purpose: Decoding Function for terminating output.
419 Int
420 PAF_AST_stopOutput(
421 const PAF_ASIT_Params *pP,
422 const PAF_ASIT_Patchs *pQ,
423 PAF_ASIT_Config *pAsitCfg
424 );
426 // Purpose: Common Function for processing algorithm chains.
427 Int
428 PAF_AST_streamChainFunction(
429 const PAF_ASIT_Params *pP,
430 const PAF_ASIT_Patchs *pQ,
431 PAF_ASIT_Config *pAsitCfg,
432 Int iChainFrameFxns,
433 Int abortOnError,
434 Int logArg
435 );
438 #endif /* _ASIP_H_ */