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_
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 #if 0
258 // Purpose: Audio Stream Task Function for initialization or reinitiali-
259 // zation of the Audio Frame(s) by loading of data values of a
260 // time-varying nature.
261 Int
262 PAF_AST_initFrame1(
263 const PAF_ASIT_Params *pP,
264 const PAF_ASIT_Patchs *pQ,
265 PAF_AST_Config *pAsitCfg,
266 Int z,
267 Int apply
268 );
269 #endif
271 // Purpose: Audio Stream Task Function for processing audio data to
272 // determine the input type without output.
273 Int
274 PAF_ASIT_autoProcessing(
275 const PAF_ASIT_Params *pP,
276 const PAF_ASIT_Patchs *pQ,
277 PAF_ASIT_Config *pAsitCfg,
278 Int inputTypeSelect,
279 ALG_Handle pcmAlgMaster);
281 // Purpose: Audio Stream Input Task Function for processing audio data.
282 //
283 Int
284 PAF_ASIT_decodeProcessing(
285 const PAF_ASIT_Params *pP,
286 const PAF_ASIT_Patchs *pQ,
287 PAF_ASIT_Config *pAsitCfg,
288 Int sourceSelect
289 );
291 // Purpose: Decoding Function for processing Decode Commands.
292 Int
293 PAF_ASIT_decodeCommand(
294 const PAF_ASIT_Params *pP,
295 const PAF_ASIT_Patchs *pQ,
296 PAF_ASIT_Config *pAsitCfg
297 );
299 // Purpose: Decoding Function for reinitializing the decoding process.
300 Int
301 PAF_ASIT_decodeInit(
302 const PAF_ASIT_Params *pP,
303 const PAF_ASIT_Patchs *pQ,
304 PAF_ASIT_Config *pAsitCfg,
305 Int sourceSelect
306 );
308 // Purpose: Decoding Function for processing information in a manner that
309 // is common for both initial and subsequent frames of input data.
310 Int
311 PAF_ASIT_decodeInfo(
312 const PAF_ASIT_Params *pP,
313 const PAF_ASIT_Patchs *pQ,
314 PAF_ASIT_Config *pAsitCfg,
315 Int frame,
316 Int block
317 );
319 // Purpose: Decoding Function for processing information in a manner that
320 // is unique to initial frames of input data.
321 Int
322 PAF_ASIT_decodeInfo1(
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 frames of input data other than the initial one.
332 Int
333 PAF_ASIT_decodeInfo2(
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 #if 0
342 // Purpose: Decoding Function for processing that occurs subsequent to
343 // information processing but antecedent to timing processing
344 // for frames of input data other than the initial one.
345 Int
346 PAF_AST_decodeCont(
347 const PAF_ASIT_Params *pP,
348 const PAF_ASIT_Patchs *pQ,
349 PAF_ASIT_Config *pAsitCfg,
350 ALG_Handle decAlg[],
351 Int frame,
352 Int block
353 );
354 #endif
356 // Purpose: Decoding Function for processing of input data by the
357 // Decode Algorithm.
358 Int
359 PAF_ASIT_decodeDecode(
360 const PAF_ASIT_Params *pP,
361 const PAF_ASIT_Patchs *pQ,
362 PAF_ASIT_Config *pAsitCfg,
363 Int sourceSelect,
364 Int frame,
365 Int block
366 );
368 // Purpose: Decoding Function for determining whether processing of the
369 // current frame is complete.
370 Int
371 PAF_ASIT_decodeFinalTest(
372 const PAF_ASIT_Params *pP,
373 const PAF_ASIT_Patchs *pQ,
374 PAF_ASIT_Config *pAsitCfg,
375 Int frame,
376 Int block
377 );
379 // Purpose: Decoding Function for terminating the decoding process.
380 Int
381 PAF_ASIT_decodeComplete(
382 const PAF_ASIT_Params *pP,
383 const PAF_ASIT_Patchs *pQ,
384 PAF_ASIT_Config *pAsitCfg,
385 ALG_Handle decAlg[],
386 Int frame,
387 Int block
388 );
390 // Purpose: Audio Stream Input Task Function for selecting the devices used
391 // for input.
392 Int
393 PAF_ASIT_selectDevices(
394 const PAF_ASIT_Params *pP,
395 const PAF_ASIT_Patchs *pQ,
396 PAF_ASIT_Config *pAsitCfg
397 );
399 // Purpose: Audio Stream Input Task Function for selecting the sources used
400 // for decoding of input to output.
401 Int
402 PAF_ASIT_sourceDecode(
403 const PAF_ASIT_Params *pP,
404 const PAF_ASIT_Patchs *pQ,
405 PAF_ASIT_Config *pAsitCfg,
406 Int x
407 );
409 // Purpose: Decoding Function for terminating output.
410 Int
411 PAF_AST_stopOutput(
412 const PAF_ASIT_Params *pP,
413 const PAF_ASIT_Patchs *pQ,
414 PAF_ASIT_Config *pAsitCfg
415 );
417 // Purpose: Common Function for processing algorithm chains.
418 Int
419 PAF_AST_streamChainFunction(
420 const PAF_ASIT_Params *pP,
421 const PAF_ASIT_Patchs *pQ,
422 PAF_ASIT_Config *pAsitCfg,
423 Int iChainFrameFxns,
424 Int abortOnError,
425 Int logArg
426 );
429 #endif /* _ASIP_H_ */