bef354372e8709f46fb24a7c581206e5fea00a94
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.c ========
38 */
40 #include <xdc/std.h>
41 #include <xdc/cfg/global.h>
42 #include <xdc/runtime/Diags.h>
43 #include <xdc/runtime/Error.h>
44 #include <xdc/runtime/Log.h>
45 #include <xdc/runtime/Memory.h>
46 #include <xdc/runtime/System.h>
47 #include <ti/sysbios/BIOS.h>
48 #include <ti/sysbios/hal/Hwi.h>
49 #include <ti/sysbios/hal/Cache.h>
50 #include <ti/sysbios/knl/Clock.h>
51 #include <ti/sysbios/knl/Task.h>
52 #include <ti/ipc/Ipc.h>
53 #include <ti/ipc/MessageQ.h>
54 #include <ti/ipc/MultiProc.h>
56 #include <sio.h>
57 #include <pafsio_ialg.h>
59 #include "common.h"
60 #include "paf_heapMgr.h"
61 #include "aspMsg_common.h"
62 #include "aspMsg_master.h"
63 #include "aspDecOpCircBuf_master.h"
64 #include "audioStreamProc_common.h"
65 #include "audioStreamProc_master.h"
66 #include "audioStreamInpProc.h"
68 // FL: porting
69 #include "fwkSim.h"
70 //#include "fwkPort.h"
71 // FL: debug
72 #include "dbgCapAf.h"
74 #include "statusOp_common.h"
77 // -----------------------------------------------------------------------------
78 // Debugging Trace Control, local to this file.
79 //
80 #include "logp.h"
82 #define TRACE_ARC(a)
84 // allows you to set a different trace module in pa.cfg
85 #define TR_MOD trace
87 // Allow a developer to selectively enable tracing.
88 #define CURRENT_TRACE_MASK 0x21
90 #define TRACE_MASK_TERSE 0x01 // only flag errors and show init
91 #define TRACE_MASK_GENERAL 0x02 // half dozen lines per frame
92 #define TRACE_MASK_VERBOSE 0x04 // trace full operation
93 #define TRACE_MASK_DATA 0x08 // Show data
94 #define TRACE_MASK_TIME 0x10 // Timing related traces
95 #define TRACE_MASK_MSG 0x20 // Message related traces
97 #if !(CURRENT_TRACE_MASK & TRACE_MASK_TERSE)
98 #undef TRACE_TERSE0
99 #undef TRACE_TERSE1
100 #undef TRACE_TERSE2
101 #undef TRACE_TERSE3
102 #undef TRACE_TERSE4
103 #define TRACE_TERSE0(a)
104 #define TRACE_TERSE1(a,b)
105 #define TRACE_TERSE2(a,b,c)
106 #define TRACE_TERSE3(a,b,c,d)
107 #define TRACE_TERSE4(a,b,c,d,e)
108 #endif
110 #if !(CURRENT_TRACE_MASK & TRACE_MASK_GENERAL)
111 #undef TRACE_GEN0
112 #undef TRACE_GEN1
113 #undef TRACE_GEN2
114 #undef TRACE_GEN3
115 #undef TRACE_GEN4
116 #define TRACE_GEN0(a)
117 #define TRACE_GEN1(a,b)
118 #define TRACE_GEN2(a,b,c)
119 #define TRACE_GEN3(a,b,c,d)
120 #define TRACE_GEN4(a,b,c,d,e)
121 #endif
123 #if (CURRENT_TRACE_MASK & TRACE_MASK_VERBOSE)
124 // consolidate list of processing strings, indexed by PAF_SOURCE
125 static char *procName[] =
126 {
127 "", //PAF_SOURCE_UNKNOWN
128 "", //PAF_SOURCE_NONE
129 "AS%d: Pass processing ...", //PAF_SOURCE_PASS
130 "AS%d: SNG processing ...", //PAF_SOURCE_SNG
131 "AS%d: Auto processing ...", //PAF_SOURCE_AUTO
132 "AS%d: Auto processing ...", //PAF_SOURCE_BITSTREAM
133 "AS%d: DTS processing ...", //PAF_SOURCE_DTSALL
134 "AS%d: PCM processing ...", //PAF_SOURCE_PCMAUTO
135 "AS%d: PCM processing ...", //PAF_SOURCE_PCM
136 "AS%d: PCN processing ...", //PAF_SOURCE_PC8
137 "AS%d: AC3 processing ...", //PAF_SOURCE_AC3
138 "AS%d: DTS processing ...", //PAF_SOURCE_DTS
139 "AS%d: AAC processing ...", //PAF_SOURCE_AAC
140 "AS%d: MPG processing ...", //PAF_SOURCE_MPEG
141 "AS%d: DTS processing ...", //PAF_SOURCE_DTS12
142 "AS%d: DTS processing ...", //PAF_SOURCE_DTS13
143 "AS%d: DTS processing ...", //PAF_SOURCE_DTS14
144 "AS%d: DTS processing ...", //PAF_SOURCE_DTS16
145 "AS%d: WMP processing ...", //PAF_SOURCE_WMA9PRO
146 "AS%d: MP3 processing ...", //PAF_SOURCE_MP3
147 "AS%d: DSD processing ...", //PAF_SOURCE_DSD1
148 "AS%d: DSD processing ...", //PAF_SOURCE_DSD2
149 "AS%d: DSD processing ...", //PAF_SOURCE_DSD3
150 "AS%d: DDP processing ...", //PAF_SOURCE_DDP
151 "AS%d: DTSHD processing ...", //PAF_SOURCE_DTSHD
152 "AS%d: THD processing ...", //PAF_SOURCE_THD
153 "AS%d: DXP processing ...", //PAF_SOURCE_DXP
154 "AS%d: WMA processing ...", //PAF_SOURCE_WMA
155 };
157 #else
158 #undef TRACE_VERBOSE0
159 #undef TRACE_VERBOSE1
160 #undef TRACE_VERBOSE2
161 #undef TRACE_VERBOSE3
162 #undef TRACE_VERBOSE4
163 #define TRACE_VERBOSE0(a)
164 #define TRACE_VERBOSE1(a,b)
165 #define TRACE_VERBOSE2(a,b,c)
166 #define TRACE_VERBOSE3(a,b,c,d)
167 #define TRACE_VERBOSE4(a,b,c,d,e)
168 #endif
170 #if (CURRENT_TRACE_MASK & TRACE_MASK_DATA)
171 #define TRACE_DATA(a) LOG_printf a
172 #else
173 #define TRACE_DATA(a)
174 #endif
176 #if (CURRENT_TRACE_MASK & TRACE_MASK_TIME)
177 #define TRACE_TIME(a) LOG_printf a
178 #define TIME_MOD trace // this could be different
179 static Int dtime()
180 {
181 static Int old_time = 0;
182 Int time = TSK_time();
183 Int delta_time = time - old_time;
184 old_time = time;
185 return( delta_time);
186 }
188 static char *stateName[11] =
189 {
190 "INIT",
191 "INFO1",
192 "AGAIN",
193 "INFO2",
194 "CONT",
195 "TIME",
196 "DECODE",
197 "STREAM",
198 "ENCODE",
199 "FINAL",
200 "QUIT"
201 };
203 #else
204 #define TRACE_TIME(a)
205 #endif
207 #if !(CURRENT_TRACE_MASK & TRACE_MASK_MSG)
208 #undef TRACE_MSG0
209 #undef TRACE_MSG1
210 #undef TRACE_MSG2
211 #undef TRACE_MSG3
212 #undef TRACE_MSG4
213 #define TRACE_MSG0(a)
214 #define TRACE_MSG1(a,b)
215 #define TRACE_MSG2(a,b,c)
216 #define TRACE_MSG3(a,b,c,d)
217 #define TRACE_MSG4(a,b,c,d,e)
218 #endif
221 // .............................................................................
223 #include <pafsio.h>
224 #include "paferr.h"
226 #include <acp_mds.h>
228 #include <pcm.h>
230 #include <pce.h>
232 #include <doberr.h>
234 #include <diberr.h>
236 #include <stdasp.h>
238 #include "as0.h"
239 #include "asperr.h"
241 #include "audioStreamProc_params.h"
242 #include "audioStreamProc_patchs.h"
243 #include "audioStreamProc_config.h"
244 #include "audioStreamInpProc.h"
246 //
247 // Audio Stream Definitions
248 //
250 // minimum audio frame "length" in samples (must be multiple of PA_MODULO)
251 #define MINFRAMELENGTH 24
252 #define PA_MODULO 8 // also defined independently in ARC2 code, and may be hard coded other places.
255 //
256 // Decoder Definitions
257 //
258 //#define decLinkInit pQ->i_decLinkInit
260 //
261 // Audio Stream Processing Definitions
262 //
263 //#define aspLinkInit pQ->i_aspLinkInit
265 //
266 // Encoder Definitions
267 //
268 #define encLinkInit pQ->i_encLinkInit
270 //
271 // Input, Output Definitions
272 //
273 #define inpLinkInit pP->i_inpLinkInit
274 //#define outLinkInit pP->i_outLinkInit
276 /* ---------------------------------------------------------------- */
277 /* Parameter macro definitions end here. */
278 /* ---------------------------------------------------------------- */
280 //
281 // Standardized Definitions
282 //
284 //#define DEC_Handle PCM_Handle /* works for all: SNG, PCM, AC3, DTS, AAC */
285 //#define ENC_Handle PCE_Handle /* works for all: PCE */
287 #define __TASK_NAME__ "TaskAsip"
289 LINNO_DEFN(TaskAsip); /* Line number macros */
290 ERRNO_DEFN(TaskAsip); /* Error number macros */
292 // ASIT configuration
293 #pragma DATA_SECTION(gPAF_ASIT_config, ".globalSectionPafAsitConfig")
294 PAF_ASIT_Config gPAF_ASIT_config = {
295 NULL, // acp
296 &gPAF_ASPM_config, // pAspmCfg, shared ASIT/ASOT configuration
297 &gPAF_AST_config // pAstCfg, shared ASIT/ASOT/ASDT configuration
298 };
300 // Global debug counters */
301 UInt32 gTaskAsipCnt=0; // debug
302 UInt32 gAsipInitCnt =0;
303 UInt32 gAsipInfo1Cnt =0;
304 UInt32 gAsipInfo2Cnt =0;
305 UInt32 gAsipDecodeCnt =0;
306 UInt32 gAsipDecodeErrCnt =0;
307 UInt32 gAsipFinalCnt =0;
308 UInt32 gAsipQuitCnt =0;
309 UInt32 gIbReset_cnt =0;
310 UInt32 gcapIb_cnt =0;
311 UInt32 gAsipInfo2_PrimaryErrCnt =0;
312 UInt32 gAsipInfo2_ErrCnt =0;
314 #include "dbgDib.h"
316 extern struct {
317 Int size;
318 IALG_Status *pStatus[512];
319 } IACP_STD_BETA_TABLE;
322 /*
323 * ======== taskAsipFxn ========
324 * Audio Stream Input Processing task function
325 */
326 Void taskAsipFxn(
327 // Int betaPrimeValue, // FL: revisit
328 const PAF_ASIT_Params *pP,
329 const PAF_ASIT_Patchs *pQ
330 )
331 {
332 PAF_ASIT_Config *pC; /* Local configuration pointer */
333 PAF_AST_Config *pAstCfg; /* Common (shared) configuration pointer */
334 Int as; /* Audio Stream Number (1, 2, etc.) */
335 Int z; /* input/encode/stream/decode/output counter */
336 Int i; /* phase */
337 Int errno; /* error number */
338 Int zMD, zMI, zMS, zX;
339 Int loopCount = 0; // used to stop trace to see startup behavior.
340 UInt32 curTime;
341 Int size;
342 // Messaging
343 ASP_Msg *pAspMsg;
344 Int status;
345 #ifdef NON_CACHE_STATUS
346 Int8 tempVar8;
347 #endif
349 Log_info0("Enter taskAsipFxn()");
351 #ifdef SIMULATE_SIO
352 /* Start simulation */
353 simStart();
354 #endif // SIMULATE_SIO
356 //
357 // Audio Framework Parameters & Patch (*pP, *pQ)
358 //
359 if (!pP)
360 {
361 TRACE_TERSE0("TaskAsip: No Parameters defined. Exiting.");
362 LINNO_RPRT(TaskAsip, -1);
363 return;
364 }
366 if (!pQ)
367 {
368 TRACE_TERSE0("TaskAsip: No Patchs defined. Exiting.");
369 LINNO_RPRT(TaskAsip, -1);
370 return;
371 }
373 //
374 // Audio Framework Configuration (*pC):
375 //
376 pC = &gPAF_ASIT_config;
377 pAstCfg = pC->pAstCfg;
379 /* Set Audio Stream Number (1, 2, etc.) */
380 as = gBetaPrimeValue + 1;
381 pAstCfg->as = as;
382 TRACE_TERSE1("TaskAsip: Started with AS%d.", as);
384 //
385 // Initialize message log trace and line number reporting
386 //
387 for (z=STREAM1; z < STREAMN; z++)
388 {
389 TRACE_TERSE1("TaskAsip: AS%d: initiated", as+z);
390 }
391 LINNO_RPRT(TaskAsip, -1);
393 //
394 // Determine decoder and stream indices associated with the master input
395 //
396 zMI = pP->zone.master;
397 pAstCfg->masterDec = zMI;
398 pAstCfg->masterStr = zMI;
399 for (zX = DECODE1; zX < DECODEN; zX++)
400 {
401 if (pP->inputsFromDecodes[zX] == zMI)
402 {
403 pAstCfg->masterDec = zX;
404 pAstCfg->masterStr = pP->streamsFromDecodes[zX];
405 break;
406 }
407 }
408 zMD = pAstCfg->masterDec;
409 zMS = pAstCfg->masterStr;
411 // Initialize as per parametrized phases:
412 //
413 // In standard form these are:
414 // - Malloc: Memory Allocation
415 // - Config: Configuration Initialization
416 // - AcpAlg: ACP Algorithm Initialization and Local Attachment
417 // - Common: Common Memory Initialization
418 // - AlgKey: Dec/Enc chain to Array Initialization
419 // - Device: I/O Device Initialization
420 // - DecOpCircBuf: Decoder Output Circular Buffer
421 // - Unused: (available)
422 //
423 LINNO_RPRT(TaskAsip, -2);
424 for (i=0; i < lengthof(pP->fxns->initPhase); i++)
425 {
426 Int linno;
427 if (pP->fxns->initPhase[i])
428 {
429 if (linno = pP->fxns->initPhase[i](pP, pQ, pC))
430 {
431 LINNO_RPRT(TaskAsip, linno);
432 return;
433 }
434 }
435 else
436 {
437 TRACE_TERSE1("TaskAsip: AS%d: initialization phase - null", as+zMS);
438 }
439 TRACE_TERSE2("TaskAsip: AS%d: initialization phase - %d completed", as+zMS, i);
440 LINNO_RPRT(TaskAsip, -i-3);
441 }
443 //
444 // End of Initialization -- display memory usage report.
445 //
446 if (pP->fxns->memStatusPrint)
447 {
448 pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, HEAP_INTERNAL1_SHM);
449 }
451 // (***) FL: revisit
452 // write back AST shared configuration
453 Cache_wb(pAstCfg, sizeof(PAF_AST_Config), Cache_Type_ALLD, 0);
454 // FL: no need to share this pointer, can be local
455 //Cache_wb(&pC, sizeof(PAF_AST_Config *), Cache_Type_ALLD, 0);
456 Cache_wait();
458 // (***) FL: revisit
459 // write back Dec configuration
460 Cache_wb(&pAstCfg->xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
461 Cache_wait();
463 // (***) FL: revisit
464 // write back entire beta table
465 Cache_wb((Ptr)(&IACP_STD_BETA_TABLE.pStatus[0]), 512*sizeof(IALG_Status *), Cache_Type_ALLD, 0);
466 Cache_wait();
468 // FL: send start initialization message to slave
469 pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize); /* allocate message */
470 MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg); /* set the return address in the message header */
471 pAspMsg->cmd = ASP_SLAVE_START; /* fill in message payload */
472 pAspMsg->procId = hAspMsgMaster->masterProcId;
473 pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
474 pAspMsg->expectResp = TRUE;
475 TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
476 status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg); /* send message */
477 if (status != MessageQ_S_SUCCESS)
478 {
479 SW_BREAKPOINT;
480 }
481 // wait for initialization complete message from slave
482 do {
483 //status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
484 status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, 0); // FL: no other thread is allowed to run until Slave finished startup
485 } while ((status != MessageQ_S_SUCCESS) || (pAspMsg->cmd != ASP_MASTER_START_DONE));
486 if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) ||
487 (pAspMsg->cmd != ASP_MASTER_START_DONE) ||
488 (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
489 {
490 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
491 SW_BREAKPOINT;
492 }
493 hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
494 TRACE_MSG3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
495 status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
496 if (status != MessageQ_S_SUCCESS)
497 {
498 SW_BREAKPOINT;
499 }
501 // (***) FL: revisit
502 // invalidate Status structure addresses for Beta Units initialized on Slave
503 Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
504 Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
505 Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
506 Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
507 Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
508 Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
509 Cache_inv((Ptr)(&IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), sizeof(IALG_Status *), Cache_Type_ALLD, 0);
510 Cache_wait();
511 if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]) Log_info0("ERROR: beta unit for Dec==NULL");
512 if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]) Log_info0("ERROR: beta unit for Dec==NULL");
513 if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]) Log_info0("ERROR: beta unit for Dec==NULL");
514 if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]) Log_info0("ERROR: beta unit for Dec==NULL");
515 if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]) Log_info0("ERROR: beta unit for Dec==NULL");
516 if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]) Log_info0("ERROR: beta unit for Dec==NULL");
517 if (!IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]) Log_info0("ERROR: beta unit for Dec==NULL");
519 // (***) FL: revisit
520 // invalidate Status structures for Beta Units initialized on Slave
521 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), sizeof(Int), Cache_Type_ALLD, 0);
522 size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
523 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
524 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), sizeof(Int), Cache_Type_ALLD, 0);
525 size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
526 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
527 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), sizeof(Int), Cache_Type_ALLD, 0);
528 size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]->size;
529 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM2]), size, Cache_Type_ALLD, 0);
530 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), sizeof(Int), Cache_Type_ALLD, 0);
531 size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]->size;
532 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
533 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), sizeof(Int), Cache_Type_ALLD, 0);
534 size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]->size;
535 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP2]), size, Cache_Type_ALLD, 0);
536 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), sizeof(Int), Cache_Type_ALLD, 0);
537 size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]->size;
538 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD]), size, Cache_Type_ALLD, 0);
539 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), sizeof(Int), Cache_Type_ALLD, 0);
540 size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]->size;
541 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), size, Cache_Type_ALLD, 0);
542 Cache_wait();
544 #ifdef NON_CACHE_STATUS
545 // Get the shared status structure GateMP handles. Initialized at slave.
546 if (statusOp_Init(GATEMP_INDEX_DEC) == STATUSOP_INIT_FAIL)
547 {
548 Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_DEC);
549 }
550 if (statusOp_Init(GATEMP_INDEX_DDP) == STATUSOP_INIT_FAIL)
551 {
552 Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_DDP);
553 }
554 if (statusOp_Init(GATEMP_INDEX_PCM) == STATUSOP_INIT_FAIL)
555 {
556 Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_PCM);
557 }
558 if (statusOp_Init(GATEMP_INDEX_THD) == STATUSOP_INIT_FAIL)
559 {
560 Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_THD);
561 }
562 #endif
564 // (***) FL: revisit
565 // invalidate Dec configuration
566 Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
567 Cache_wait();
569 //
570 // Main processing loop
571 //
572 for (z=STREAM1; z < STREAMN; z++)
573 {
574 TRACE_VERBOSE1("TaskAsip: AS%d: running", as+z);
575 }
577 TRACE_TERSE0("TaskAsip: Entering Main Loop.");
579 errno = 0;
580 for (;;)
581 {
582 Int sourceSelect;
583 XDAS_Int8 sourceProgram;
585 loopCount++;
587 #if 0 // enable and tune to see startup behavior.
588 // this is an alternative to fixed/circular setting in pa.cfg.
589 // If you are searching for a memory allocation failure, disable on first round.
590 // All allocation has already happened.
591 // This is the outer loop. This loop count goes up when the stream resets.
592 // If the stream is running without problems, this does not increment.
593 // If the stream is repeatedly resetting, this loop count will go up rapidly.
594 if (loopCount > 10) // see traces for a few of the passes through the main loop.
595 {
596 TRACE_TERSE1("TaskAsip: Trace stopped at loop %d.", loopCount);
597 LOG_disable(&TR_MOD); // stop tracing
598 }
599 #endif
601 TRACE_GEN2("TaskAsip (begin Main loop %d) (errno 0x%x)", loopCount, errno);
602 TRACE_TIME((&TIME_MOD, "as1_f2... + %d = %d (begin Main loop)", dtime(), TSK_time()));
604 // since not decoding indicate such
605 pP->fxns->sourceDecode(pP, pQ, pC, PAF_SOURCE_NONE);
607 // any error forces idling of input
608 if (errno)
609 {
610 for (z=INPUT1; z < INPUTN; z++)
611 {
612 if (pAstCfg->xInp[z].hRxSio)
613 {
614 SIO_idle(pAstCfg->xInp[z].hRxSio);
615 }
616 }
618 TRACE_TERSE1("TaskAsip: Trace stopped at loop %d.", loopCount);
619 ERRNO_RPRT(TaskAsip, errno);
620 }
622 // Execute a TSK_sleep to ensure that any non-blocking code paths are broken
623 // up to allow lower priority tasks to run. This may seem odd to be at the top
624 // of the state machine but provides for a cleaner flow even though the very
625 // first time we enter we do a sleep which is non-intuitive.
626 TRACE_VERBOSE1("TaskAsip: AS%d: ... sleeping ...", as+zMS);
627 TRACE_TIME((&TIME_MOD, "as1-f2... + %d = %d (begin SLEEP)", dtime(), TSK_time()));
628 Task_sleep(1);
630 TRACE_GEN1("TaskAsip: AS%d: Input device selection ...", as+zMS);
631 if (errno = pP->fxns->selectDevices(pP, pQ, pC))
632 {
633 TRACE_TERSE2("TaskAsip: selectDevices returned errno = 0x%04x at line %d. AS%d", errno, as+zMS);
634 continue;
635 }
637 // if no master input selected then we don't know what may be at the input
638 // so set to unknown and skip any remaining processing
639 if (!pAstCfg->xInp[zMI].hRxSio)
640 {
641 #ifdef NON_CACHE_STATUS
642 tempVar8 = PAF_SOURCE_UNKNOWN;
643 statusOp_write(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
644 &tempVar8,
645 sizeof(tempVar8),
646 GATEMP_INDEX_DEC);
647 #else
648 pAstCfg->xDec[zMD].decodeStatus.sourceProgram = PAF_SOURCE_UNKNOWN;
649 #endif
650 TRACE_VERBOSE1("TaskAsip: AS%d: No input selected...", as+zMS);
651 continue;
652 }
654 // if here then we have a valid input so query its status
655 if (errno = pP->fxns->updateInputStatus(pAstCfg->xInp[zMI].hRxSio, &pAstCfg->xInp[zMI].inpBufStatus, &pAstCfg->xInp[zMI].inpBufConfig))
656 {
657 TRACE_VERBOSE1("TaskAsip: continue as updateInputStatus returns 0x%x", errno);
658 continue;
659 }
661 #ifdef NON_CACHE_STATUS
662 statusOp_read(&tempVar8,
663 &(pAstCfg->xDec[zMD].decodeStatus.mode),
664 sizeof(tempVar8),
665 GATEMP_INDEX_DEC);
666 // If master decoder is not enabled, or the input is unlocked, then do nothing
667 if (!tempVar8 || !pAstCfg->xInp[zMI].inpBufStatus.lock)
668 {
669 TRACE_VERBOSE0("TaskAsip: Not locked, continue");
670 continue;
671 }
672 #else
673 // If master decoder is not enabled, or the input is unlocked, then do nothing
674 if (!pAstCfg->xDec[zMD].decodeStatus.mode || !pAstCfg->xInp[zMI].inpBufStatus.lock)
675 {
676 TRACE_VERBOSE0("TaskAsip: Not locked, continue");
677 continue;
678 }
679 #endif
681 #ifdef NON_CACHE_STATUS
682 statusOp_read(&tempVar8,
683 &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
684 sizeof(tempVar8),
685 GATEMP_INDEX_DEC);
686 // If no source selected then do nothing
687 if (tempVar8 == PAF_SOURCE_NONE)
688 {
689 tempVar8 = PAF_SOURCE_NONE;
690 statusOp_write(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
691 &tempVar8,
692 sizeof(tempVar8),
693 GATEMP_INDEX_DEC);
694 TRACE_VERBOSE1("TaskAsip: AS%d: no source selected, continue", as+zMS);
695 continue;
696 }
697 #else
698 // If no source selected then do nothing
699 if (pAstCfg->xDec[zMD].decodeStatus.sourceSelect == PAF_SOURCE_NONE)
700 {
701 pAstCfg->xDec[zMD].decodeStatus.sourceProgram = PAF_SOURCE_NONE;
702 TRACE_VERBOSE1("TaskAsip: AS%d: no source selected, continue", as+zMS);
703 continue;
704 }
705 #endif
707 #ifdef NON_CACHE_STATUS
708 statusOp_read(&tempVar8,
709 &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
710 sizeof(tempVar8),
711 GATEMP_INDEX_DEC);
712 // If we want pass processing then proceed directly
713 if (tempVar8 == PAF_SOURCE_PASS)
714 {
715 TRACE_VERBOSE1("TaskAsip: AS%d: Pass processing ...", as+zMS);
717 tempVar8 = PAF_SOURCE_PASS;
718 statusOp_write(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
719 &tempVar8,
720 sizeof(tempVar8),
721 GATEMP_INDEX_DEC);
722 #else
723 // If we want pass processing then proceed directly
724 if (pAstCfg->xDec[zMD].decodeStatus.sourceSelect == PAF_SOURCE_PASS)
725 {
726 TRACE_VERBOSE1("TaskAsip: AS%d: Pass processing ...", as+zMS);
727 pAstCfg->xDec[zMD].decodeStatus.sourceProgram = PAF_SOURCE_PASS;
728 #endif
729 pP->fxns->sourceDecode(pP, pQ, pC, PAF_SOURCE_PASS);
730 if (pP->fxns->passProcessing)
731 {
732 errno = pP->fxns->passProcessing(pP, pQ, pC, NULL);
733 }
734 else
735 {
736 TRACE_TERSE2("TaskAsip: AS%d: Pass Processing not supported, errno 0x%x", as+zMS, ASPERR_PASS);
737 errno = ASPERR_PASS;
738 }
739 TRACE_VERBOSE0("TaskAsip: continue");
740 continue;
741 }
743 #ifdef NON_CACHE_STATUS
744 statusOp_read(&tempVar8,
745 &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
746 sizeof(tempVar8),
747 GATEMP_INDEX_DEC);
748 // .....................................................................
749 // At this point we have an enabled input and want to decode something.
750 // If no decoder selected then do nothing. Need to reset the sourceProgram, since
751 // when no decoder is selected there are no calls to IB
752 //if (errno = pP->fxns->autoProcessing(pP, pQ, pC, pC->xDec[zMD].decodeStatus.sourceSelect, pC->xDec[zMD].decAlg[PAF_SOURCE_PCM]))
753 if (errno = pP->fxns->autoProcessing(pP, pQ, pC, tempVar8, NULL)) // (***) FL: re-visit this, hard-coded to use PCM framelength inside function
754 {
755 TRACE_VERBOSE1("TaskAsip: autoProcessing returns 0x%x, continue", errno);
756 continue;
757 }
758 #else
759 // .....................................................................
760 // At this point we have an enabled input and want to decode something.
761 // If no decoder selected then do nothing. Need to reset the sourceProgram, since
762 // when no decoder is selected there are no calls to IB
763 //if (errno = pP->fxns->autoProcessing(pP, pQ, pC, pC->xDec[zMD].decodeStatus.sourceSelect, pC->xDec[zMD].decAlg[PAF_SOURCE_PCM]))
764 if (errno = pP->fxns->autoProcessing(pP, pQ, pC, pAstCfg->xDec[zMD].decodeStatus.sourceSelect, NULL)) // (***) FL: re-visit this, hard-coded to use PCM framelength inside function
765 {
766 TRACE_VERBOSE1("TaskAsip: autoProcessing returns 0x%x, continue", errno);
767 continue;
768 }
769 #endif
771 // query for input type
772 if (errno = SIO_ctrl(pAstCfg->xInp[zMI].hRxSio, PAF_SIO_CONTROL_GET_SOURCEPROGRAM, (Arg )&sourceProgram))
773 {
774 TRACE_TERSE2("TaskAsip: SIO_ctrl returns 0x%x, then 0x%x, continue", errno, ASPERR_AUTO_PROGRAM);
775 errno = ASPERR_AUTO_PROGRAM;
776 continue;
777 }
778 #ifdef NON_CACHE_STATUS
779 statusOp_write(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
780 &(sourceProgram),
781 sizeof(sourceProgram),
782 GATEMP_INDEX_DEC);
783 #else
784 pAstCfg->xDec[zMD].decodeStatus.sourceProgram = sourceProgram;
785 #endif
787 // if input is unclassifiable then do nothing
788 if (sourceProgram == PAF_SOURCE_UNKNOWN)
789 {
790 TRACE_VERBOSE0("TaskAsip: Source program unknown. continue");
791 continue;
792 }
794 // now that we have some input classification, and possibly an outstanding
795 // input frame, we determine whether or not to call decodeProcessing and with
796 // what decAlg.
797 sourceSelect = PAF_SOURCE_NONE;
798 #ifdef NON_CACHE_STATUS
799 statusOp_read(&tempVar8,
800 &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
801 sizeof(tempVar8),
802 GATEMP_INDEX_DEC);
803 switch (tempVar8)
804 {
805 #else
806 switch (pAstCfg->xDec[zMD].decodeStatus.sourceSelect)
807 {
808 #endif
809 // If autodetecting, decoding everything, and input is something
810 // (i.e. bitstream or PCM) then decode.
811 case PAF_SOURCE_AUTO:
812 if (sourceProgram >= PAF_SOURCE_PCM)
813 {
814 sourceSelect = sourceProgram;
815 }
816 break;
818 // If autodetecting, decoding only PCM, and input is PCM then decode.
819 case PAF_SOURCE_PCMAUTO:
820 if (sourceProgram == PAF_SOURCE_PCM)
821 {
822 sourceSelect = sourceProgram;
823 }
824 break;
826 // If autodetecting, decoding only bitstreams, and input is a bitstream then decode.
827 case PAF_SOURCE_BITSTREAM:
828 if (sourceProgram >= PAF_SOURCE_AC3)
829 {
830 sourceSelect = sourceProgram;
831 }
832 break;
834 // If autodetecting, decoding only DTS, and input is DTS then decode.
835 case PAF_SOURCE_DTSALL:
836 switch (sourceProgram)
837 {
838 case PAF_SOURCE_DTS11:
839 case PAF_SOURCE_DTS12:
840 case PAF_SOURCE_DTS13:
841 case PAF_SOURCE_DTS14:
842 case PAF_SOURCE_DTS16:
843 case PAF_SOURCE_DTSHD:
844 sourceSelect = sourceProgram;
845 break;
846 }
847 break;
849 // All others, e.g., force modes, fall through to here.
850 // If user made specific selection then program must match select.
851 // (NB: this compare relies on ordering of PAF_SOURCE)
852 default:
853 #ifdef NON_CACHE_STATUS
854 sourceSelect = 0; // due to size difference
855 statusOp_read(&sourceSelect,
856 &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
857 sizeof(Int8),
858 GATEMP_INDEX_DEC);
859 #else
860 sourceSelect = pAstCfg->xDec[zMD].decodeStatus.sourceSelect;
861 #endif
862 if ((sourceSelect >= PAF_SOURCE_PCM) && (sourceSelect <= PAF_SOURCE_N))
863 {
864 if (sourceProgram != sourceSelect)
865 {
866 sourceSelect = PAF_SOURCE_NONE;
867 }
868 }
869 break;
870 }
872 // if we didn't find any matches then skip
873 if (sourceSelect == PAF_SOURCE_NONE)
874 {
875 TRACE_VERBOSE0("TaskAsip: no matching source type, continue");
876 continue;
877 }
879 // FL: debug, reset IB capture buffer
880 //capIbReset();
881 //Log_info0("capIbReset()");
883 // FL: send source select message to slave
884 pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize); /* allocate message */
885 MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg); /* set the return address in the message header */
886 pAspMsg->cmd = ASP_SLAVE_DEC_SOURCE_SELECT; /* fill in message payload */
887 pAspMsg->procId = hAspMsgMaster->masterProcId;
888 pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
889 pAspMsg->expectResp = TRUE;
890 *(Int32 *)&pAspMsg->buf[0] = sourceSelect;
891 TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
892 TRACE_MSG1("sourceSelect=%d", pAspMsg->buf[0]);
893 status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg); /* send message */
894 if (status != MessageQ_S_SUCCESS)
895 {
896 SW_BREAKPOINT;
897 }
898 // wait for source select complete message from slave
899 //do {
900 // status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
901 //} while (status != MessageQ_S_SUCCESS);
902 status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
903 if (status != MessageQ_S_SUCCESS)
904 {
905 TRACE_TERSE0("MessageQ_get() failure.");
906 SW_BREAKPOINT; // temporary
907 }
908 if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) ||
909 (pAspMsg->cmd != ASP_MASTER_DEC_SOURCE_SELECT_DONE) ||
910 (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
911 {
912 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
913 SW_BREAKPOINT;
914 }
915 hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
916 TRACE_MSG3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
917 status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
918 if (status != MessageQ_S_SUCCESS)
919 {
920 SW_BREAKPOINT;
921 }
923 // set to unknown so that we can ensure, for IOS purposes, that sourceDecode = NONE
924 // iff we are in this top level state machine and specifically not in decodeProcessing
925 pP->fxns->sourceDecode(pP, pQ, pC, PAF_SOURCE_UNKNOWN);
927 TRACE_VERBOSE1(procName[sourceProgram], as+zMS);
929 TRACE_VERBOSE0("TaskAsip: calling decodeProcessing.");
930 errno = pP->fxns->decodeProcessing(pP, pQ, pC, sourceSelect);
931 if (errno)
932 {
933 TRACE_TERSE1("TaskAsip: decodeProcessing returns 0x%x, continue", errno);
934 }
935 else
936 {
937 TRACE_VERBOSE0("TaskAsip: decodeProcessing complete with no error.");
938 }
940 // FL: send dec exit message to slave
941 pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize); /* allocate message */
942 MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg); /* set the return address in the message header */
943 pAspMsg->cmd = ASP_SLAVE_DEC_EXIT; /* fill in message payload */
944 pAspMsg->procId = hAspMsgMaster->masterProcId;
945 pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
946 pAspMsg->expectResp = TRUE;
947 TRACE_MSG2("Tx ASP message: procId=%d, cmd=%d.", pAspMsg->procId, pAspMsg->cmd);
948 status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg); /* send message */
949 if (status != MessageQ_S_SUCCESS)
950 {
951 SW_BREAKPOINT;
952 }
953 // wait for dec exit complete message from slave
954 //do {
955 // status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
956 //} while ((status < 0) || (pAspMsg->cmd != ASP_MASTER_DEC_EXIT_DONE));
957 status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
958 if (status != MessageQ_S_SUCCESS)
959 {
960 TRACE_TERSE0("MessageQ_get() failure.");
961 SW_BREAKPOINT; // temporary
962 }
963 if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) ||
964 (pAspMsg->cmd != ASP_MASTER_DEC_EXIT_DONE) ||
965 (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
966 {
967 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
968 SW_BREAKPOINT;
969 }
970 hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
971 TRACE_MSG3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
972 // free the message
973 status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
974 if (status != MessageQ_S_SUCCESS)
975 {
976 SW_BREAKPOINT;
977 }
978 } // End of main processing loop for (;;)
980 Log_info0("Exit taskAsipFxn()");
981 }
983 // -----------------------------------------------------------------------------
984 // ASIT Initialization Function - Memory Allocation
985 //
986 // Name: PAF_ASIT_initPhaseMalloc
987 // Purpose: Audio Stream Input Task Function for initialization of data pointers
988 // by allocation of memory.
989 // From: audioStream1Task or equivalent
990 // Uses: See code.
991 // States: x
992 // Return: 0 on success.
993 // Source code line number on MEM_calloc failure.
994 // Trace: Message Log "trace" in Debug Project Configuration reports:
995 // * State information as per parent.
996 // * Memory allocation errors.
997 //
998 Int
999 PAF_ASIT_initPhaseMalloc(
1000 const PAF_ASIT_Params *pP,
1001 const PAF_ASIT_Patchs *pQ,
1002 PAF_ASIT_Config *pC
1003 )
1004 {
1005 PAF_AST_Config *pAstCfg;
1006 Int as; /* Audio Stream Number (1, 2, etc.) */
1007 Int zMS;
1008 Error_Block eb;
1010 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
1011 as = pAstCfg->as;
1012 zMS = pAstCfg->masterStr;
1014 TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: initialization phase - memory allocation", as+zMS);
1016 // Initialize error block
1017 Error_init(&eb);
1019 /* Input memory */
1020 if (!(pAstCfg->xInp = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM,
1021 INPUTN * sizeof (*pAstCfg->xInp), 4, &eb)))
1022 {
1023 TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
1024 SW_BREAKPOINT;
1025 return __LINE__;
1026 }
1027 TRACE_TERSE3("PAF_ASIT_initPhaseMalloc. (pC->xInp) %d bytes from space %d at 0x%x.",
1028 INPUTN * sizeof (*pAstCfg->xInp),
1029 HEAP_ID_INTERNAL1_SHM, (IArg)pAstCfg->xInp);
1031 #ifdef NON_CACHE_STATUS
1032 /* Decode memory */
1033 if (!(pAstCfg->xDec = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_NONCACHED_SHM,
1034 DECODEN * sizeof (*pAstCfg->xDec), 4, &eb)))
1035 {
1036 TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
1037 SW_BREAKPOINT;
1038 return __LINE__;
1039 }
1040 #else
1041 /* Decode memory */
1042 if (!(pAstCfg->xDec = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM,
1043 DECODEN * sizeof (*pAstCfg->xDec), 4, &eb)))
1044 {
1045 TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: Memory_calloc failed", as+zMS);
1046 SW_BREAKPOINT;
1047 return __LINE__;
1048 }
1049 #endif
1050 TRACE_TERSE3("PAF_ASIT_initPhaseMalloc. (pC->xDec) %d bytes from space %d at 0x%x.",
1051 DECODEN * sizeof (*pAstCfg->xDec),
1052 HEAP_ID_INTERNAL1_SHM, (IArg)pAstCfg->xDec);
1054 TRACE_TERSE1("PAF_ASIT_initPhaseMalloc: AS%d: initialization phase - memory allocation complete.", as+zMS);
1055 return 0;
1056 } //PAF_ASIT_initPhaseMalloc
1058 // -----------------------------------------------------------------------------
1059 // ASIT Initialization Function - Memory Initialization from Configuration
1060 //
1061 // Name: PAF_ASIT_initPhaseConfig
1062 // Purpose: Audio Stream Task Function for initialization of data values
1063 // from parameters.
1064 // From: audioStream1Task or equivalent
1065 // Uses: See code.
1066 // States: x
1067 // Return: 0 on success.
1068 // Other as per initFrame0 and initFrame1.
1069 // Trace: Message Log "trace" in Debug Project Configuration reports:
1070 // * State information as per parent.
1071 //
1072 Int
1073 PAF_ASIT_initPhaseConfig(
1074 const PAF_ASIT_Params *pP,
1075 const PAF_ASIT_Patchs *pQ,
1076 PAF_ASIT_Config *pC
1077 )
1078 {
1079 PAF_AST_Config *pAstCfg;
1080 Int as; /* Audio Stream Number (1, 2, etc.) */
1081 Int z; /* input/encode/stream/decode/output counter */
1082 Int zMS;
1084 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
1085 as = pAstCfg->as;
1086 zMS = pAstCfg->masterStr;
1088 TRACE_TERSE1("PAF_ASIT_initPhaseConfig: AS%d: initialization phase - configuration", as+zMS);
1090 //
1091 // Unspecified elements have been initialized to zero during alloc
1092 //
1094 for (z=INPUT1; z < INPUTN; z++)
1095 {
1096 pAstCfg->xInp[z].inpBufStatus = *pP->pInpBufStatus;
1097 pAstCfg->xInp[z].inpBufConfig.pBufStatus = &pAstCfg->xInp[z].inpBufStatus;
1098 }
1100 for (z=DECODE1; z < DECODEN; z++)
1101 {
1102 Int zI = pP->inputsFromDecodes[z];
1103 pAstCfg->xDec[z].decodeControl.size = sizeof(pAstCfg->xDec[z].decodeControl);
1104 pAstCfg->xDec[z].decodeControl.pInpBufConfig = (const PAF_InpBufConfig *)&pAstCfg->xInp[zI].inpBufConfig;
1105 //pC->xDec[z].decodeStatus = *pP->z_pDecodeStatus[z]; // FL: slave
1106 }
1108 TRACE_TERSE1("PAF_ASIT_initPhaseConfig: AS%d: initialization phase - configuration complete.", as+zMS);
1109 return 0;
1110 } //PAF_ASIT_initPhaseConfig
1112 // -----------------------------------------------------------------------------
1113 // ASIT Initialization Function - ACP Algorithm Instantiation
1114 //
1115 // Name: PAF_ASIT_initPhaseAcpAlg
1116 // Purpose: Audio Stream Input Task Function for initialization of ACP by
1117 // instantiation of the algorithm.
1118 // From: audioStream1Task or equivalent
1119 // Uses: See code.
1120 // States: x
1121 // Return: 0 on success.
1122 // Source code line number on ACP Algorithm creation failure.
1123 // Trace: Message Log "trace" in Debug Project Configuration reports:
1124 // * State information as per parent.
1125 // * Memory allocation errors.
1126 //
1127 Int
1128 PAF_ASIT_initPhaseAcpAlg(
1129 const PAF_ASIT_Params *pP,
1130 const PAF_ASIT_Patchs *pQ,
1131 PAF_ASIT_Config *pC
1132 )
1133 {
1134 PAF_AST_Config *pAstCfg;
1135 Int as; /* Audio Stream Number (1, 2, etc.) */
1136 Int z; /* input/encode/stream/decode/output counter */
1137 Int betaPrimeOffset;
1138 ACP_Handle acp;
1139 Int zMS;
1140 Int zS, zX;
1142 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
1143 as = pAstCfg->as;
1144 zMS = pAstCfg->masterStr;
1146 TRACE_TERSE1("PAF_ASIT_initPhaseAcpAlg: AS%d: initialization phase - ACP Algorithm", as+zMS);
1148 ACP_MDS_init();
1150 if (!(acp = (ACP_Handle)ACP_MDS_create(NULL)))
1151 {
1152 TRACE_TERSE1("PAF_ASIT_initPhaseAcpAlg: AS%d: ACP algorithm instance creation failed", as+zMS);
1153 return __LINE__;
1154 }
1155 pC->acp = acp;
1157 ((ALG_Handle)acp)->fxns->algControl((ALG_Handle) acp,
1158 ACP_GETBETAPRIMEOFFSET, (IALG_Status *)&betaPrimeOffset);
1160 for (z=INPUT1; z < INPUTN; z++)
1161 {
1162 zS = z;
1163 for (zX = DECODE1; zX < DECODEN; zX++)
1164 {
1165 if (pP->inputsFromDecodes[zX] == z)
1166 {
1167 zS = pP->streamsFromDecodes[zX];
1168 break;
1169 }
1170 }
1171 acp->fxns->attach(acp, ACP_SERIES_STD,
1172 STD_BETA_IB + betaPrimeOffset * (as-1+zS),
1173 (IALG_Status *)&pAstCfg->xInp[z].inpBufStatus);
1174 /* Ignore errors, not reported. */
1175 }
1177 TRACE_TERSE1("PAF_ASIT_initPhaseAcpAlg: AS%d: initialization phase - ACP Algorithm complete.", as+zMS);
1179 return 0;
1180 } //PAF_ASIT_initPhaseAcpAlg
1182 // -----------------------------------------------------------------------------
1183 // ASIT Initialization Function - Common Memory
1184 //
1185 // Name: PAF_ASIT_initPhaseCommon
1186 // Purpose: Audio Stream Input Task Function for allocation of common memory.
1187 // From: audioStream1Task or equivalent
1188 // Uses: See code.
1189 // States: x
1190 // Return: 0 on success.
1191 // Source code line number on PAF_ALG_alloc failure.
1192 // Source code line number on PAF_ALG_mallocMemory failure.
1193 // Source code line number on Decode Chain initialization failure.
1194 // Source code line number on ASP Chain initialization failure.
1195 // Source code line number on Encode Chain initialization failure.
1196 // Trace: Message Log "trace" in Debug Project Configuration reports:
1197 // * State information as per parent.
1198 // * Memory allocation errors.
1199 //
1200 Int
1201 PAF_ASIT_initPhaseCommon(
1202 const PAF_ASIT_Params *pP,
1203 const PAF_ASIT_Patchs *pQ,
1204 PAF_ASIT_Config *pC
1205 )
1206 {
1207 PAF_AST_Config *pAstCfg;
1208 Int as; /* Audio Stream Number (1, 2, etc.) */
1209 Int z; /* stream counter */
1210 ACP_Handle acp;
1211 PAF_IALG_Config pafAlgConfig;
1212 IALG_MemRec common[3][PAF_IALG_COMMON_MEMN+1];
1214 acp = pC->acp;
1215 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
1216 as = pAstCfg->as;
1218 TRACE_TERSE0("PAF_ASIT_initPhaseCommon: initialization phase - Common Memory");
1220 //
1221 // Determine memory needs and instantiate algorithms across audio streams
1222 //
1223 TRACE_TERSE0("PAF_ASIT_initPhaseCommon: calling PAF_ALG_setup.");
1224 PAF_ALG_setup(&pafAlgConfig,
1225 HEAP_ID_INTERNAL, HEAP_INTERNAL,
1226 HEAP_ID_INTERNAL1, HEAP_INTERNAL1,
1227 HEAP_ID_EXTERNAL, HEAP_EXTERNAL,
1228 HEAP_ID_INTERNAL1_SHM, HEAP_INTERNAL1_SHM,
1229 HEAP_ID_EXTERNAL_SHM, HEAP_EXTERNAL_SHM,
1230 HEAP_ID_EXTERNAL_NONCACHED_SHM, HEAP_EXTERNAL_NONCACHED_SHM,
1231 HEAP_CLEAR);
1233 if (pP->fxns->headerPrint)
1234 {
1235 pP->fxns->headerPrint();
1236 }
1238 for (z = STREAM1; z < STREAMN; z++)
1239 {
1240 TRACE_TERSE1("PAF_ASIT_initPhaseCommon: AS%d: initialization phase - Common Memory", as+z);
1242 //
1243 // Determine common memory for:
1244 // (1) Logical Input drivers
1245 //
1246 // Decode Algorithms common memory determined in ASP Slave.
1247 //
1248 PAF_ALG_init(common[z], lengthof(common[z]), COMMONSPACE);
1250 //
1251 // Determine common memory needs of Logical Input driver
1252 //
1254 // really need to loop over all inputs for this stream using the tables
1255 // inputsFromDecodes and streamsFromDecodes. But these don't exist for this
1256 // patch, and not needed for FS11, since there is only one input.
1257 if (INPUT1 <= z && z < INPUTN)
1258 {
1259 TRACE_TERSE2("PAF_ASIT_initPhaseCommon: AS%d: alloc inpLinkInit common[%d]", as+z, z);
1260 if (PAF_ALG_ALLOC(inpLinkInit[z-INPUT1], common[z]))
1261 {
1262 TRACE_TERSE1("PAF_ASIT_initPhaseCommon: AS%d: PAF_ALG_alloc failed", as+z);
1263 TRACE_TERSE2("failed to alloc %d bytes from space %d", common[z]->size, (IArg)common[z]->space);
1264 SW_BREAKPOINT;
1265 return __LINE__;
1266 }
1267 TRACE_TERSE3("alloced %d bytes from space %d at 0x%x", common[z]->size, common[z]->space, (IArg)common[z]->base);
1268 if (pP->fxns->allocPrint)
1269 {
1270 pP->fxns->allocPrint((const PAF_ALG_AllocInit *)(inpLinkInit[z-INPUT1]), sizeof (*(inpLinkInit[z-INPUT1])), &pafAlgConfig);
1271 }
1272 }
1273 }
1274 {
1275 // Changes made to share scratch between zones
1276 // Assume maximum 3 zones and scratch common memory is at offset 0;
1277 int max=0;
1278 for (z=STREAM1; z<STREAMN; z++)
1279 {
1280 if (max < common[z][0].size)
1281 {
1282 max = common[z][0].size;
1283 }
1284 }
1285 common[STREAM1][0].size=max;
1286 for (z=STREAM1+1; z<STREAMN; z++)
1287 {
1288 common[z][0].size = 0;
1289 }
1290 }
1292 //
1293 // Allocate common memory for:
1294 // (1) Logical Input drivers
1295 //
1296 for (z = STREAM1; z < STREAMN; z++)
1297 {
1298 TRACE_TERSE0("PAF_ASIT_initPhaseCommon: calling PAF_ALG_mallocMemory for common space.");
1299 if (PAF_ALG_mallocMemory(common[z], &pafAlgConfig))
1300 {
1301 TRACE_TERSE1("PAF_ASIT_initPhaseCommon: AS%d: PAF_ALG_mallocMemory failed", as+z);
1302 TRACE_TERSE3("AS%d: z: %d. Size 0x%x", as+z, z, common[z][0].size);
1303 SW_BREAKPOINT;
1304 return __LINE__;
1305 }
1306 TRACE_TERSE3("alloced %d bytes from space %d at 0x%x", common[z]->size, common[z]->space, (IArg)common[z]->base);
1307 // share zone0 scratch with all zones
1308 common[z][0].base = common[0][0].base;
1309 if (pP->fxns->commonPrint)
1310 {
1311 pP->fxns->commonPrint(common[z], &pafAlgConfig);
1312 }
1314 //
1315 // Allocate non-common memories for Logical IO drivers
1316 // Since these structures are used at run-time we allocate from external memory
1317 if (INPUT1 <= z && z < INPUTN)
1318 {
1319 PAF_ASP_Chain *chain;
1320 TRACE_TERSE2("PAF_ASIT_initPhaseCommon: AS%d: non-common input chain init for %d",
1321 as+z, z);
1322 chain = PAF_ASP_chainInit(&pAstCfg->xInp[z].inpChainData, pP->pChainFxns,
1323 HEAP_EXTERNAL, as+z, acp, &trace,
1324 inpLinkInit[z-INPUT1], NULL, common[z], &pafAlgConfig);
1325 if (!chain)
1326 {
1327 TRACE_TERSE1("PAF_ASIT_initPhaseCommon: AS%d: Input chain initialization failed", as+z);
1328 return __LINE__;
1329 }
1330 }
1331 }
1332 TRACE_TERSE1("PAF_ASIT_initPhaseCommon: AS%d: Returning complete.", as+z);
1334 return 0;
1335 } //PAF_ASIT_initPhaseCommon
1337 // (***) FL: candidate for removal
1338 // -----------------------------------------------------------------------------
1339 // ASIT Initialization Function - Algorithm Keys
1340 //
1341 // Name: PAF_ASIT_initPhaseAlgKey
1342 // Purpose: Audio Stream Input Task Function for initialization of data values
1343 // from parameters for Algorithm Keys.
1344 // From: audioStream1Task or equivalent
1345 // Uses: See code.
1346 // States: x
1347 // Return: 0.
1348 // Trace: Message Log "trace" in Debug Project Configuration reports:
1349 // * State information as per parent.
1350 //
1351 // .............................................................................
1352 Int
1353 PAF_ASIT_initPhaseAlgKey(
1354 const PAF_ASIT_Params *pP,
1355 const PAF_ASIT_Patchs *pQ,
1356 PAF_ASIT_Config *pC
1357 )
1358 {
1359 PAF_AST_Config *pAstCfg;
1360 Int as; /* Audio Stream Number (1, 2, etc.) */
1363 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
1364 as = pAstCfg->as;
1365 (void)as; // clear compiler warning in case not used with tracing disabled
1367 TRACE_VERBOSE1("PAF_ASIT_initPhaseAlgKey: AS%d: initialization phase - Algorithm Keys", as);
1369 #if 0 // FL: slave
1370 for (z=DECODE1; z < DECODEN; z++)
1371 {
1372 for (s=0; s < pP->pDecAlgKey->length; s++)
1373 {
1374 if ((pP->pDecAlgKey->code[s].full != 0) &&
1375 (that = PAF_ASP_chainFind (&pC->xDec[z].decChainData, pP->pDecAlgKey->code[s])))
1376 {
1377 pC->xDec[z].decAlg[s] = (ALG_Handle )that->alg;
1378 /* Cast in interface, for now --Kurt */
1379 }
1380 else
1381 {
1382 pC->xDec[z].decAlg[s] = NULL;
1383 }
1384 }
1385 }
1386 #endif
1388 return 0;
1389 } //PAF_ASIT_initPhaseAlgKey
1391 // -----------------------------------------------------------------------------
1392 // ASIT Initialization Function - I/O Devices
1393 //
1394 // Name: PAF_ASIT_initPhaseDevice
1395 // Purpose: Audio Stream Input Task Function for initialization of I/O Devices.
1396 // From: audioStream1Task or equivalent
1397 // Uses: See code.
1398 // States: x
1399 // Return: 0 on success.
1400 // Source code line number on device allocation failure.
1401 // Trace: Message Log "trace" in Debug Project Configuration reports:
1402 // * State information as per parent.
1403 // * Memory allocation errors.
1404 //
1405 Int
1406 PAF_ASIT_initPhaseDevice(
1407 const PAF_ASIT_Params *pP,
1408 const PAF_ASIT_Patchs *pQ,
1409 PAF_ASIT_Config *pC
1410 )
1411 {
1412 PAF_AST_Config *pAstCfg;
1413 Int as; /* Audio Stream Number (1, 2, etc.) */
1414 Int z; /* input/output counter */
1415 PAF_SIO_IALG_Obj *pObj;
1416 PAF_SIO_IALG_Config *pAlgConfig;
1417 PAF_IALG_Config pafAlgConfig;
1420 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
1421 as = pAstCfg->as;
1422 (void)as; // clear compiler warning in case not used with tracing disabled
1424 TRACE_TERSE1("PAF_ASIT_initPhaseDevice: AS%d: initialization phase - I/O Devices", as);
1426 if (pP->fxns->bufMemPrint)
1427 {
1428 PAF_ALG_setup (&pafAlgConfig,
1429 HEAP_ID_INTERNAL, HEAP_INTERNAL,
1430 HEAP_ID_INTERNAL1, HEAP_INTERNAL1,
1431 HEAP_ID_EXTERNAL, HEAP_EXTERNAL,
1432 HEAP_ID_INTERNAL1_SHM, HEAP_INTERNAL1_SHM,
1433 HEAP_ID_EXTERNAL_SHM, HEAP_EXTERNAL_SHM,
1434 HEAP_ID_EXTERNAL_NONCACHED_SHM, HEAP_EXTERNAL_NONCACHED_SHM,
1435 HEAP_CLEAR);
1436 TRACE_TERSE2("PAF_ASIT_initPhaseDevice: AS%d: calling PAF_ALG_setup with clear at %d.", as, HEAP_CLEAR);
1437 }
1439 for (z=INPUT1; z < INPUTN; z++)
1440 {
1441 PAF_InpBufConfig *pConfig = &pAstCfg->xInp[z].inpBufConfig;
1443 pObj = (PAF_SIO_IALG_Obj *)pAstCfg->xInp[z].inpChainData.head->alg;
1444 pAlgConfig = &pObj->config;
1446 pAstCfg->xInp[z].hRxSio = NULL;
1448 pConfig->base.pVoid = pAlgConfig->pMemRec[0].base;
1449 pConfig->pntr.pVoid = pAlgConfig->pMemRec[0].base;
1450 pConfig->head.pVoid = pAlgConfig->pMemRec[0].base;
1451 pConfig->futureHead.pVoid = pAlgConfig->pMemRec[0].base;
1452 pConfig->allocation = pAlgConfig->pMemRec[0].size;
1453 pConfig->sizeofElement = 2;
1454 pConfig->precision = 16;
1456 if (pP->fxns->bufMemPrint)
1457 {
1458 pP->fxns->bufMemPrint(z, pAlgConfig->pMemRec[0].size, PAF_ALG_memSpaceToHeapId(&pafAlgConfig,pAlgConfig->pMemRec[0].space), 0);
1459 }
1460 }
1462 TRACE_TERSE1("PAF_ASIT_initPhaseDevice: AS%d: initialization phase - I/O Devices complete.", as);
1464 return 0;
1465 } //PAF_ASIT_initPhaseDevice
1467 // -----------------------------------------------------------------------------
1468 // ASIT Initialization Function - Decoder Output Circular Buffer
1469 //
1470 // Name: PAF_ASIT_initPhaseDecOpCircBuf
1471 // Purpose: Audio Stream Input Task Function for initialization of Decoder Output Circular Buffer.
1472 // From: audioStream1Task or equivalent
1473 // Uses: See code.
1474 // States: x
1475 // Return: 0 on success.
1476 // Source code line number on device allocation failure.
1477 // Trace: Message Log "trace" in Debug Project Configuration reports:
1478 // * State information as per parent.
1479 // * Memory allocation errors.
1480 //
1481 Int
1482 PAF_ASIT_initPhaseDecOpCircBuf(
1483 const PAF_ASIT_Params *pP,
1484 const PAF_ASIT_Patchs *pQ,
1485 PAF_ASIT_Config *pC
1486 )
1487 {
1488 PAF_AST_Config *pAstCfg;
1489 PAF_AST_DecOpCircBuf *pCb; /* Decoder output circular buffer */
1490 Int as; /* Audio Stream Number (1, 2, etc.) */
1491 Int zMS;
1492 Int z; /* decode counter */
1493 Int errno; /* error number */
1494 Error_Block eb;
1495 Int i;
1497 // FL: (***)revisit
1498 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
1499 as = pAstCfg->as;
1500 zMS = pAstCfg->masterStr;
1502 /* Decode output circular buffer memory */
1503 if (!(pAstCfg->xDecOpCb = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM,
1504 DECODEN * sizeof (*pAstCfg->xDecOpCb), 4, &eb)))
1505 {
1506 TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
1507 SW_BREAKPOINT;
1508 return __LINE__;
1509 }
1511 TRACE_TERSE3("PAF_ASIT_initPhaseDecOpCircBuf. (pC->xDecOpCb) %d bytes from space %d at 0x%x.",
1512 DECODEN * sizeof (*pAstCfg->xDecOpCb),
1513 HEAP_ID_INTERNAL1_SHM, (IArg)pAstCfg->xDecOpCb);
1515 for (z=DECODE1; z < DECODEN; z++)
1516 {
1517 pCb = &pAstCfg->xDecOpCb[z];
1519 // allocate audio frame circular buffer
1520 if (!(pCb->afCb = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, ASP_DECOP_CB_MAX_NUM_AF * sizeof(PAF_AudioFrame), 4, &eb)))
1521 {
1522 TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
1523 SW_BREAKPOINT;
1524 }
1525 // allocate audio frame PCM sample pointer array
1526 for (i = 0; i<ASP_DECOP_CB_MAX_NUM_AF; i++)
1527 {
1528 if (!(pCb->afCb[i].data.sample = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT * sizeof(PAF_AudioData *), 4, &eb)))
1529 {
1530 TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
1531 SW_BREAKPOINT;
1532 }
1533 if (!(pCb->afCb[i].data.samsiz = Memory_calloc((IHeap_Handle)HEAP_INTERNAL1_SHM, ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT * sizeof(PAF_AudioSize), 4, &eb)))
1534 {
1535 TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
1536 SW_BREAKPOINT;
1537 }
1538 }
1539 // allocate PCM sample buffer
1540 if (!(pCb->pcmBuf = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_SHM, ASP_DECOP_CB_PCM_BUF_SZ * sizeof(PAF_AudioData), 4, &eb)))
1541 {
1542 TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
1543 SW_BREAKPOINT;
1544 }
1545 pCb->pcmBufEnd = pCb->pcmBuf + ASP_DECOP_CB_PCM_BUF_SZ;
1546 // allocate Metadata buffers //QIN
1547 if (!(pCb->metaBuf = Memory_calloc((IHeap_Handle)HEAP_EXTERNAL_SHM, ASP_DECOP_CB_MAX_NUM_AF * PAF_MAX_PRIVATE_MD_SZ * PAF_MAX_NUM_PRIVATE_MD * sizeof(Int8), 4, &eb)))
1548 {
1549 TRACE_TERSE1("PAF_ASIT_initPhaseDecOpCircBuf: AS%d: Memory_calloc failed", as+zMS);
1550 SW_BREAKPOINT;
1551 }
1552 pCb->metaBufEnd = pCb->metaBuf + (ASP_DECOP_CB_MAX_NUM_AF * PAF_MAX_PRIVATE_MD_SZ * PAF_MAX_NUM_PRIVATE_MD);
1553 // (***) FL: revisit, here PCM is hard-coded for 256 sample dec op frame length
1554 // Initialize decoder output circular buffer for PCM
1555 errno = cbInit(pCb);
1556 if (errno)
1557 {
1558 SW_BREAKPOINT; // FL: debug
1559 return errno;
1560 }
1561 }
1563 return 0;
1564 } //PAF_ASIT_initPhaseDecOpCircBuf
1567 #if 0
1568 // -----------------------------------------------------------------------------
1569 // AST Processing Function - Pass-Through Processing
1570 //
1571 // Name: PAF_AST_passProcessing
1572 // Purpose: Audio Stream Task Function for processing audio data as a
1573 // pass-through from the input driver to the output driver
1574 // for development and testing.
1575 // From: audioStream1Task or equivalent
1576 // Uses: See code.
1577 // States: x
1578 // Return: Error number in standard form (0 on success).
1579 // Trace: Message Log "trace" in Debug Project Configuration reports:
1580 // * State information on initialization.
1581 // * State information on processing.
1582 //
1584 #pragma CODE_SECTION(PAF_AST_passProcessing,".text:_PAF_AST_passProcessing")
1585 /* Pass Processing is often omitted from builds to save memory, */
1586 /* and CODE_SECTION/clink constructs facilitate this omission. */
1588 Int
1589 PAF_AST_passProcessing(const PAF_AST_Params *pP, const PAF_AST_Patchs *pQ, PAF_AST_Config *pC, Int hack)
1590 {
1591 Int z; /* input/output counter */
1592 Int errno = 0; /* error number */
1593 Int getVal;
1594 Int rxNumChan, txNumChan;
1595 Int first;
1596 Int zMD = pC->masterDec;
1597 Int zMI = pP->zone.master;
1600 #ifndef __TI_EABI__
1601 asm (" .clink"); /* See comment above regarding CODE_SECTION/clink. */
1602 #endif
1604 TRACE_VERBOSE0("PAF_AST_passProcessing: initializing");
1606 //
1607 // Determine that receive/transmit channels are compatible
1608 //
1610 // Can handle handle only master input
1611 for (z=INPUT1; z < INPUTN; z++) {
1612 if (z != zMI && pC->xInp[z].hRxSio)
1613 return (ASPERR_PASS + 0x01);
1614 }
1616 /* Number of receive/transmit channels */
1618 if (! pC->xInp[zMI].hRxSio)
1619 return (ASPERR_PASS + 0x11);
1620 if (SIO_ctrl (pC->xInp[zMI].hRxSio, PAF_SIO_CONTROL_GET_NUMCHANNELS, (Arg) &rxNumChan))
1621 return (ASPERR_PASS + 0x12);
1622 if (rxNumChan > NUM_TX_CHAN(zMI))
1623 return (ASPERR_PASS + 0x13);
1625 for (z=OUTPUT1; z < OUTPUTN; z++) {
1626 if (! pC->xOut[zMI].hTxSio)
1627 return (ASPERR_PASS + 0x10*(z+2) + 0x01);
1628 if (SIO_ctrl (pC->xOut[z].hTxSio, PAF_SIO_CONTROL_GET_NUMCHANNELS, (Arg) &txNumChan))
1629 return (ASPERR_PASS + 0x10*(z+2) + 0x02);
1630 if (txNumChan > NUM_TX_CHAN(zMI))
1631 return (ASPERR_PASS + 0x10*(z+2) + 0x03);
1632 }
1634 //
1635 // Set up receive/transmit
1636 //
1638 SIO_idle (pC->xInp[zMI].hRxSio);
1639 for (z=OUTPUT1; z < OUTPUTN; z++) {
1640 if(SIO_idle (pC->xOut[z].hTxSio))
1641 return ASPERR_IDLE;
1642 }
1644 if (SIO_ctrl (pC->xInp[zMI].hRxSio, PAF_SIO_CONTROL_SET_SOURCESELECT, PAF_SOURCE_PCM))
1645 return (ASPERR_PASS + 0x14);
1647 if (SIO_ctrl (pC->xInp[zMI].hRxSio, PAF_SIO_CONTROL_SET_PCMFRAMELENGTH, FRAMELENGTH))
1648 return (ASPERR_PASS + 0x15);
1650 for (z=OUTPUT1; z < OUTPUTN; z++)
1651 pC->xOut[z].outBufConfig.lengthofFrame = FRAMELENGTH;
1653 if (SIO_issue (pC->xInp[zMI].hRxSio, &pC->xInp[zMI].inpBufConfig, sizeof (pC->xInp[zMI].inpBufConfig), PAF_SIO_REQUEST_SYNC))
1654 return ASPERR_PASS + 0x16;
1656 if (SIO_reclaim (pC->xInp[zMI].hRxSio, (Ptr)&pC->xInp[zMI].pInpBuf, NULL) != sizeof (PAF_InpBufConfig))
1657 return ASPERR_PASS + 0x17;
1659 //
1660 // Receive and transmit the data in single-frame buffers
1661 //
1663 first = 1;
1664 while (pC->xDec[zMD].decodeStatus.sourceSelect == PAF_SOURCE_PASS) {
1665 PAF_OutBufConfig *pOutBuf;
1666 PAF_InpBufConfig *pInpBuf;
1668 if (first) {
1669 first = 0;
1671 TRACE_VERBOSE0("PAF_AST_passProcessing: starting output");
1673 for (z=OUTPUT1; z < OUTPUTN; z++) {
1674 getVal = SIO_issue (pC->xOut[z].hTxSio, &pC->xOut[z].outBufConfig, sizeof(pC->xOut[z].outBufConfig), 0);
1675 if (getVal > 0) {
1676 errno = ASPERR_ISSUE;
1677 break;
1678 }
1679 else if (getVal < 0) {
1680 errno = -getVal;
1681 break;
1682 }
1684 if (getVal = SIO_ctrl (pC->xOut[z].hTxSio, PAF_SIO_CONTROL_UNMUTE, 0))
1685 return (getVal & 0xff) | ASPERR_MUTE;
1686 }
1687 if (errno)
1688 break;
1690 }
1692 getVal = SIO_issue (pC->xInp[zMI].hRxSio, &pC->xInp[zMI].inpBufConfig, sizeof (pC->xInp[zMI].inpBufConfig), PAF_SIO_REQUEST_NEWFRAME);
1693 if (getVal > 0) {
1694 errno = ASPERR_ISSUE;
1695 break;
1696 }
1698 TRACE_VERBOSE1("PAF_AST_passProcessing: awaiting frame -- input size %d", rxNumChan * FRAMELENGTH);
1700 getVal = SIO_reclaim (pC->xInp[zMI].hRxSio, (Ptr) &pInpBuf, NULL);
1701 if (getVal < 0) {
1702 errno = -getVal;
1703 break;
1704 }
1706 for (z=OUTPUT1; z < OUTPUTN; z++) {
1707 getVal = SIO_reclaim (pC->xOut[z].hTxSio, (Ptr) &pOutBuf, NULL);
1708 if (getVal < 0) {
1709 errno = -getVal;
1710 break;
1711 }
1712 }
1713 if( errno )
1714 break;
1716 TRACE_VERBOSE0("PAF_AST_passProcessing: copying frame");
1718 if (errno = pP->fxns->passProcessingCopy (pP, pQ, pC))
1719 break;
1721 for (z=OUTPUT1; z < OUTPUTN; z++) {
1722 getVal = SIO_issue (pC->xOut[z].hTxSio, &pC->xOut[z].outBufConfig, sizeof(pC->xOut[z].outBufConfig), 0);
1723 if (getVal > 0) {
1724 errno = ASPERR_ISSUE;
1725 break;
1726 }
1727 else if (getVal < 0) {
1728 errno = -getVal;
1729 break;
1730 }
1731 }
1732 if( errno )
1733 break;
1734 }
1736 //
1737 // Close down receive/transmit
1738 //
1740 TRACE_TERSE0("PAF_AST_passProcessing: finalizing"));
1742 for (z=OUTPUT1; z < OUTPUTN; z++) {
1743 if (getVal = SIO_ctrl (pC->xOut[z].hTxSio, PAF_SIO_CONTROL_MUTE, 0)) {
1744 if (! errno)
1745 errno = (getVal & 0xff) | ASPERR_MUTE;
1746 /* convert to sensical errno */
1747 }
1748 }
1750 SIO_idle (pC->xInp[zMI].hRxSio);
1751 for (z=OUTPUT1; z < OUTPUTN; z++)
1752 SIO_idle (pC->xOut[z].hTxSio);
1754 return errno;
1756 } //PAF_AST_passProcessing
1757 #endif // #if 0
1759 #if 0
1760 // -----------------------------------------------------------------------------
1761 // AST Processing Function Helper - Pass-Through Processing Patch Point
1762 //
1763 // Name: PAF_AST_passProcessingCopy
1764 // Purpose: Pass-Through Processing Function for copying audio data
1765 // from the input buffer to the output buffer.
1766 // From: AST Parameter Function -> passProcessing
1767 // Uses: See code.
1768 // States: x
1769 // Return: Error number in standard form (0 on success).
1770 // Trace: Message Log "trace" in Debug Project Configuration reports:
1771 // x
1772 //
1774 #pragma CODE_SECTION(PAF_AST_passProcessingCopy,".text:_PAF_AST_passProcessingCopy")
1775 /* Pass Processing is often omitted from builds to save memory, */
1776 /* and CODE_SECTION/clink constructs facilitate this omission. */
1778 Int
1779 PAF_AST_passProcessingCopy (const PAF_AST_Params *pP, const PAF_AST_Patchs *pQ, PAF_AST_Config *pC)
1780 {
1781 Int z; /* output counter */
1782 Int errno; /* error number */
1783 Int i;
1784 Int rxNumChan, txNumChan;
1785 Int zMI = pP->zone.master;
1788 asm (" .clink"); /* See comment above regarding CODE_SECTION/clink. */
1790 // Copy data from input channels to output channels one of two ways:
1792 if (SIO_ctrl (pC->xInp[zMI].hRxSio, PAF_SIO_CONTROL_GET_NUMCHANNELS, (Arg) &rxNumChan))
1793 return (ASPERR_PASS + 0x12);
1795 for (z=OUTPUT1; z < OUTPUTN; z++) {
1796 if (SIO_ctrl (pC->xOut[z].hTxSio, PAF_SIO_CONTROL_GET_NUMCHANNELS, (Arg) &txNumChan))
1797 return (ASPERR_PASS + 0x22);
1799 if( txNumChan <= rxNumChan ) {
1801 // Copy one to one, ignoring later rx channels as needed.
1803 for( i=0; i < txNumChan; i++ ) {
1804 errno = pP->fxns->copy( i, &pC->xInp[zMI].inpBufConfig, i, &pC->xOut[z].outBufConfig );
1805 if( errno )
1806 return errno;
1807 }
1808 }
1809 else {
1811 // Copy one to many, repeating earlier rx channels as needed.
1813 Int from, to;
1815 from = 0;
1816 to = 0;
1817 while( to < txNumChan ) {
1818 errno = pP->fxns->copy( from, &pC->xInp[zMI].inpBufConfig, to, &pC->xOut[z].outBufConfig );
1819 if( errno )
1820 return errno;
1822 from++;
1823 to++;
1824 if( from == rxNumChan )
1825 from = 0;
1826 }
1827 }
1828 }
1830 return 0;
1831 } //PAF_AST_passProcessingCopy
1832 #endif // #if 0
1834 // -----------------------------------------------------------------------------
1835 // ASIT Processing Function - Auto Processing
1836 //
1837 // Name: PAF_ASIT_autoProcessing
1838 // Purpose: Audio Stream Input Task Function for processing audio data to
1839 // determine the input type without output.
1840 // From: audioStream1Task or equivalent
1841 // Uses: See code.
1842 // States: x
1843 // Return: Error number in standard or SIO form (0 on success).
1844 // Trace: Message Log "trace" in Debug Project Configuration reports:
1845 // * State information on initialization.
1846 //
1848 #define DECSIOMAP(X) \
1849 pP->pDecSioMap->map[(X) >= pP->pDecSioMap->length ? 0 : (X)]
1851 Int
1852 PAF_ASIT_autoProcessing(
1853 const PAF_ASIT_Params *pP,
1854 const PAF_ASIT_Patchs *pQ,
1855 PAF_ASIT_Config *pC,
1856 Int inputTypeSelect,
1857 ALG_Handle pcmAlgMaster
1858 )
1859 {
1860 PAF_AST_Config *pAstCfg;
1861 Int as; /* Audio Stream Number (1, 2, etc.) */
1862 Int errno = 0; /* error number */
1863 Int nbytes;
1864 Int frameLength;
1865 Int zMD;
1866 Int zMI;
1867 Int zMS;
1869 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
1870 as = pAstCfg->as;
1871 zMD = pAstCfg->masterDec;
1872 zMS = pAstCfg->masterStr;
1873 zMI = pP->zone.master;
1875 TRACE_VERBOSE1("PAF_ASIT_autoProcessing: AS%d: PAF_AST_autoProcessing", as+zMS);
1877 if (errno = SIO_ctrl(pAstCfg->xInp[zMI].hRxSio,
1878 PAF_SIO_CONTROL_SET_SOURCESELECT,
1879 DECSIOMAP(pAstCfg->xDec[zMD].decodeStatus.sourceSelect)))
1880 {
1881 TRACE_VERBOSE2("PAF_ASIT_autoProcessing: AS%d: source select returns 0x%x", as+zMS, errno);
1882 return errno;
1883 }
1884 //frameLength = pP->fxns->computeFrameLength (pcmAlgMaster, FRAMELENGTH,
1885 // pC->xDec[zMD].decodeStatus.bufferRatio);
1886 frameLength = FRAMELENGTH; // FL: fix PCM frameLength for alpha release.
1888 if (errno = SIO_ctrl(pAstCfg->xInp[zMI].hRxSio,
1889 PAF_SIO_CONTROL_SET_PCMFRAMELENGTH, frameLength))
1890 {
1891 TRACE_VERBOSE2("PAF_ASIT_autoProcessing: SET_PCMFRAMELENGTH returns 0x%x, returning ASPERR_AUTO_LENGTH, 0x%x",
1892 errno, ASPERR_AUTO_LENGTH);
1893 return ASPERR_AUTO_LENGTH;
1894 }
1896 if (errno = SIO_issue(pAstCfg->xInp[zMI].hRxSio,
1897 &pAstCfg->xInp[zMI].inpBufConfig, sizeof(pAstCfg->xInp[zMI].inpBufConfig),
1898 PAF_SIO_REQUEST_SYNC))
1899 {
1900 TRACE_VERBOSE2("PAF_ASIT_autoProcessing: REQUEST_SYNC returns 0x%x, returning ASPERR_ISSUE, 0x%x",
1901 errno, ASPERR_ISSUE);
1902 return ASPERR_ISSUE;
1903 }
1905 TRACE_VERBOSE1("PAF_ASIT_autoProcessing: AS%d: awaiting sync", as+zMS);
1907 // all of the sync scan work is done in this call. If the error returned
1908 // is DIBERR_SYNC then that just means we didn't find a sync, not a real I/O
1909 // error so we mask it off.
1910 nbytes = SIO_reclaim(pAstCfg->xInp[zMI].hRxSio, (Ptr)&pAstCfg->xInp[zMI].pInpBuf, NULL);
1911 if (nbytes == -DIBERR_SYNC)
1912 {
1913 TRACE_TERSE2("PAF_ASIT_autoProcessing: AS%d: SIO_reclaim returned 0x%x, ignoring", as+zMS, nbytes);
1914 return 0;
1915 }
1916 if (nbytes != sizeof(PAF_InpBufConfig))
1917 {
1918 TRACE_TERSE3("PAF_ASIT_autoProcessing. SIO_reclaim returned %d, not %d, returning ASPERR_RECLAIM (0x%x)",
1919 nbytes, sizeof(PAF_InpBufConfig), ASPERR_RECLAIM);
1920 return ASPERR_RECLAIM;
1921 }
1922 if (errno)
1923 {
1924 TRACE_TERSE2("PAF_ASIT_autoProcessing: AS%d: returning errno 0x%x", as+zMS, errno);
1925 }
1926 return errno;
1927 } //PAF_ASIT_autoProcessing
1929 UInt32 gProbe1Err=0;
1930 UInt32 gProbe2Err=0;
1931 UInt32 gMajorAuMissed=0;
1933 // -----------------------------------------------------------------------------
1934 // ASIT Processing Function - Decode Processing
1935 //
1936 // Name: PAF_ASIT_decodeProcessing
1937 // Purpose: Audio Stream Input Task Function for processing audio data.
1938 // From: audioStream1Task or equivalent
1939 // Uses: See code.
1940 // States: x
1941 // Return: Error number in standard form (0 on success).
1942 // Trace: Message Log "trace" in Debug Project Configuration reports:
1943 // * State information on initialization (via children).
1944 // * State information on processing (via children).
1945 // * Decode warnings.
1946 //
1947 // When "writeDECModeContinuous" is used for zMI input/decode:
1948 // PAF_AST_decodeProcessing() loop may be (is designed to be) exited:
1949 // (a) if "writeDECCommandRestart" is used
1950 // (or "writeDECCommandAbort", but this performs no cleanup whatsoever, and so its use is discouraged)
1951 // (b) if "writeDECSourceSelectNone" is used
1952 // [ the latter events lead to QUIT state, simply for exiting (errme = errno = ASPERR_QUIT)
1953 // (c) if an error occurs in
1954 // INIT
1955 // CONT ("subsequent block state", which "Establish[es] secondary timing")
1956 // -> PAF_AST_decodeCont(): "Await slave inputs"
1957 // STREAM (errno |= PAF_COMPONENT_ASP)
1958 // ENCODE (errno |= PAF_COMPONENT_ENCODE)
1959 // [ the latter errors lead to "switch_break:"
1960 // -> PAF_AST_decodeComplete(), which always returns 0 (no error) ]
1961 //
1962 // [ Notably, in FINAL ("frame-finalization state")
1963 // -> PAF_AST_decodeFinalTest() is *not* called,
1964 // and so any other (asynchronous) changes in pC->xDec[zMD].decodeStatus.sourceSelect are ignored. ]
1965 // [ For completeness, note also: "default" state, internal check (errme = errno = ASPERR_UNKNOWNSTATE) ]
1966 //
1967 // States in which error can't occur:
1968 // AGAIN ("subsequent initial state")
1969 //
1970 // States in which (some) errors must be handled:
1971 // INFO1 ("first frame state")
1972 // -> PAF_AST_decodeInfo(): pass on ASPERR_INFO_RATECHANGE, ASPERR_INFO_PROGRAM ("bad" internal error)
1973 // -> *DONE* must "catch" ASPERR_RECLAIM from SIO_reclaim (pC->xInp[zMI].hRxSio) -- note zMI only **
1974 // ?*? but what about ASPERR_RESYNC from same call ?*?
1975 // -> *for now, at least, pass on error from pP->fxns->updateInputStatus ()*
1976 // -> *DONE* must "catch" error from (zMI) dec->fxns->info() **
1977 // -> PAF_AST_decodeInfo1(): pass on any errors which occur here:
1978 // - pP->fxns->streamChainFunction (... PAF_ASP_CHAINFRAMEFXNS_RESET)
1979 // - enc->fxns->info()
1980 // - pP->fxns->setCheckRateX()
1981 // - pP->fxns->startOutput()
1982 // - "Start slave inputs if necessary"
1983 // INFO2 ("subsequent frame state")
1984 // -> PAF_AST_decodeInfo(): (see above)
1985 // -> PAF_AST_decodeInfo2(): pass on any errors which occur here:
1986 // - pP->fxns->setCheckRateX()
1987 // TIME ("timing state")
1988 // -> PAF_AST_decodeTime(): "Special timing consideations for AC-3"
1989 // -> performs SIO_issue (... PAF_SIO_REQUEST_FULLFRAME) & SIO_reclaim() *for zMI only*
1990 // -> now, DIB_issue [PAF_SIO_REQUEST_FULLFRAME] would only return SYS_EINVAL for "bad" internal error
1991 // (*OK* don't try to recover from this*)
1992 // -> much more likely would be SIO_reclaim() error (ASPERR_RECLAIM)
1993 // -> *DONE* must "catch" (just) ASPERR_RECLAIM error -- note zMI only,
1994 // possibly in PAF_AST_decodeProcessing() itself **
1995 // DECODE ("decode state")
1996 // -> PAF_AST_decodeDecode(): pass on error from
1997 // - PAF_SIO_CONTROL_GET_NUM_REMAINING ("bad" internal error)
1998 // - dec->fxns->reset()
1999 // - PAF_SIO_CONTROL_SET_PCMFRAMELENGTH
2000 // -> *DONE* must catch error from (zMI) dec->fxns->decode()
2001 // -> *?* must catch ASPERR_ISSUE from (zMI) SIO_issue()
2002 Int
2003 PAF_ASIT_decodeProcessing(
2004 const PAF_ASIT_Params *pP,
2005 const PAF_ASIT_Patchs *pQ,
2006 PAF_ASIT_Config *pC,
2007 Int sourceSelect
2008 )
2009 {
2010 PAF_AST_Config *pAstCfg;
2011 //Int as = pC->as; /* Audio Stream Number (1, 2, etc.) */
2012 Int z; /* decode counter */
2013 Int errno; /* error number */
2014 Int getVal;
2015 enum { INIT, INFO1, INFO2, DECODE, FINAL, QUIT } state;
2016 ALG_Handle alg[DECODEN_MAX];
2017 Int zMD;
2018 Int zMS;
2019 Int size;
2020 //PAF_InpBufConfig *pIpBufConfig;
2021 Int frame; // decoder input frame count
2022 Int block; // (***) FL: formerly -- decoder output block count / input frame
2023 #ifdef NON_CACHE_STATUS
2024 Int8 tempVar8, temp2Var8;
2025 #endif
2027 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
2028 zMD = pAstCfg->masterDec;
2029 zMS = pAstCfg->masterStr;
2031 for (z=DECODE1; z < DECODEN; z++)
2032 {
2033 alg[z] = pAstCfg->xDec[z].decAlg[PAF_SOURCE_PCM];
2034 }
2035 alg[zMD] = NULL; // decAlgMaster; // FL: alg[] init is on slave
2037 //
2038 // Receive and process the data in single-frame buffers
2039 //
2041 state = INIT;
2042 errno = 0; /* error number */
2044 #ifdef NON_CACHE_STATUS
2045 statusOp_read(&tempVar8,
2046 &(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
2047 sizeof(tempVar8),
2048 GATEMP_INDEX_DEC);
2049 TRACE_TERSE1("PAF_ASIT_decodeProcessing: sourceSelect is %d", tempVar8);
2051 for (;;)
2052 {
2053 if (tempVar8 == PAF_SOURCE_NONE)
2054 {
2055 #else
2056 TRACE_TERSE1("PAF_ASIT_decodeProcessing: sourceSelect is %d", pAstCfg->xDec[zMD].decodeStatus.sourceSelect);
2058 for (;;)
2059 {
2060 if (pAstCfg->xDec[zMD].decodeStatus.sourceSelect == PAF_SOURCE_NONE)
2061 {
2062 #endif
2063 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: sourceSelect == PAF_SOURCE_NONE");
2064 state = QUIT;
2065 }
2067 // Process commands (decode)
2068 if (getVal = pP->fxns->decodeCommand(pP, pQ, pC))
2069 {
2070 if (state != INIT) // no need to restart/abort if not yet started
2071 {
2072 if (getVal == ASPERR_QUIT)
2073 {
2074 state = QUIT;
2075 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing. %d: state = QUIT");
2076 }
2077 else if (getVal == ASPERR_ABORT)
2078 {
2079 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing. %d: return getVal");
2080 return getVal;
2081 }
2082 else
2083 {
2084 /* ignore */;
2085 }
2086 }
2087 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: state == INIT");
2088 }
2090 TRACE_TIME((&TIME_MOD, "... + %d = %d ->", dtime(), TSK_time()));
2091 TRACE_TIME((&TIME_MOD, " state = %s", stateName[state]));
2093 // Process state (decode)
2094 switch (state)
2095 {
2096 case INIT: // initial state
2097 gAsipInitCnt++;
2098 Log_info0("TaskAsip: state=INIT");
2100 // (***) FL: revisit
2101 #if 1 // status for shared beta units can change (e.g. at-boot or alpha)
2102 // write back Status structures for shared Beta Units
2103 //size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
2104 //Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
2105 /*size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
2106 Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
2107 size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]->size;
2108 Cache_wb((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
2109 Cache_wait();*/
2110 #endif
2111 #if 0
2112 ////size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
2113 ////Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
2114 //size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
2115 //Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
2116 //size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]->size;
2117 //Cache_wbInv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
2118 //Cache_wait();
2119 #endif
2121 if (errno = pP->fxns->decodeInit(pP, pQ, pC, sourceSelect))
2122 {
2123 TRACE_VERBOSE1("PAF_ASIT_decodeProcessing: INIT, errno 0x%x. break after decodeInit", errno);
2124 break;
2125 }
2127 #if 1
2128 // (***) FL: revisit
2129 // invalidate Status structures for shared Beta Units
2130 //size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]->size;
2131 //Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DECODE]), size, Cache_Type_ALLD, 0);
2132 /* size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]->size;
2133 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_PCM]), size, Cache_Type_ALLD, 0);
2134 size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]->size;
2135 Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DDP]), size, Cache_Type_ALLD, 0);
2136 Cache_wait();*/
2137 #endif
2139 frame = 0;
2140 block = 0;
2142 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: state: INIT->INFO1");
2143 state = INFO1;
2144 continue;
2146 case INFO1: // first frame state
2147 gAsipInfo1Cnt++;
2148 Log_info0("TaskAsip: state=INFO1");
2150 #if 0
2151 //// (***) FL: revisit
2152 //// write back Inp configuration
2153 //Cache_wb(&gPAF_AST_config.xInp[0], INPUTN*sizeof(PAF_AST_InpBuf), Cache_Type_ALLD, 0);
2154 //// write back input data
2155 //pIpBufConfig = &gPAF_AST_config.xInp[0].inpBufConfig;
2156 //size = pIpBufConfig->frameLength * pIpBufConfig->sizeofElement;
2157 //Cache_wb(pIpBufConfig->pntr.pLgInt, size, Cache_Type_ALLD, 0);
2158 //// write back Dec configuration
2159 //Cache_wb(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
2160 //Cache_wait();
2161 #endif
2163 // Establish primary timing
2164 if (errno = pP->fxns->decodeInfo(pP, pQ, pC, frame, block))
2165 {
2166 gProbe1Err++;
2167 TRACE_TERSE1("INFO1: errno 0x%x after decodeInfo, primary timing", errno);
2168 break;
2169 }
2171 #if 0
2172 //// (***) FL: revisit
2173 //// invalidate Dec configuration
2174 //Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
2175 //Cache_wait();
2176 #endif
2179 #ifdef NON_CACHE_STATUS
2180 statusOp_read(&tempVar8,
2181 &(pAstCfg->xDec[zMD].decodeStatus.sourceDecode),
2182 sizeof(tempVar8),
2183 GATEMP_INDEX_DEC);
2184 statusOp_read(&temp2Var8,
2185 &(pAstCfg->xDec[zMD].decodeStatus.sampleRate),
2186 sizeof(tempVar8),
2187 GATEMP_INDEX_DEC);
2188 // Don't start decode until major access unit is found.
2189 if (((tempVar8 == PAF_SOURCE_THD) ||
2190 (tempVar8 == PAF_SOURCE_DXP) ||
2191 (tempVar8 == PAF_SOURCE_DTSHD)) &&
2192 (temp2Var8 == PAF_SAMPLERATE_UNKNOWN))
2193 #else
2194 // Don't start decode until major access unit is found.
2195 if (((pAstCfg->xDec[zMD].decodeStatus.sourceDecode == PAF_SOURCE_THD) ||
2196 (pAstCfg->xDec[zMD].decodeStatus.sourceDecode == PAF_SOURCE_DXP) ||
2197 (pAstCfg->xDec[zMD].decodeStatus.sourceDecode == PAF_SOURCE_DTSHD)) &&
2198 (pAstCfg->xDec[zMD].decodeStatus.sampleRate == PAF_SAMPLERATE_UNKNOWN))
2199 #endif
2200 {
2201 Int z;
2202 for (z=DECODE1; z < DECODEN; z++)
2203 {
2204 Int zI = pP->inputsFromDecodes[z];
2205 #ifdef NON_CACHE_STATUS
2206 statusOp_read(&tempVar8,
2207 &(pAstCfg->xDec[z].decodeStatus.mode),
2208 sizeof(tempVar8),
2209 GATEMP_INDEX_DEC);
2210 if (pAstCfg->xInp[zI].hRxSio && tempVar8)
2211 {
2212 #else
2213 if (pAstCfg->xInp[zI].hRxSio && pAstCfg->xDec[z].decodeStatus.mode)
2214 {
2215 #endif
2216 TRACE_VERBOSE0("TaskAsip: PAF_ASIT_decodeProcessing: INFO1, SIO_issue");
2217 if (SIO_issue(pAstCfg->xInp[zI].hRxSio, &pAstCfg->xInp[zI].inpBufConfig,
2218 sizeof(pAstCfg->xInp[zI].inpBufConfig), PAF_SIO_REQUEST_NEWFRAME))
2219 {
2220 gProbe2Err++;
2221 TRACE_TERSE0("PAF_ASIT_decodeProcessing. %d: INFO1, return (ASPERR_ISSUE)");
2222 return (ASPERR_ISSUE);
2223 }
2224 }
2225 }
2226 TRACE_VERBOSE1("PAF_ASIT_decodeProcessing: INFO1: frame %d, not major access unit", frame);
2227 gMajorAuMissed++; // debug
2228 frame++;
2229 state = INFO1;
2230 continue;
2231 }
2232 TRACE_VERBOSE1("PAF_ASIT_decodeProcessing: INFO1: frame %d, major access unit found", frame);
2234 // Establish secondary timing
2235 if (errno = pP->fxns->decodeInfo1(pP, pQ, pC, frame, block))
2236 {
2237 TRACE_VERBOSE1("PAF_ASIT_decodeProcessing: INFO1, errno 0x%x. break after decodeInfo1", errno);
2238 break;
2239 }
2241 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: state: INFO1->DECODE");
2242 state = DECODE;
2243 continue;
2245 case INFO2: // subsequent frame state
2246 gAsipInfo2Cnt++;
2247 Log_info0("TaskAsip: state=INFO2");
2249 #if 0
2250 //// (***) FL: revisit
2251 //// write back Inp configuration
2252 //Cache_wb(&gPAF_AST_config.xInp[0], INPUTN*sizeof(PAF_AST_InpBuf), Cache_Type_ALLD, 0);
2253 //// write back input data
2254 //pIpBufConfig = &gPAF_AST_config.xInp[0].inpBufConfig;
2255 //size = pIpBufConfig->frameLength * pIpBufConfig->sizeofElement;
2256 //Cache_wb(pIpBufConfig->pntr.pLgInt, size, Cache_Type_ALLD, 0);
2257 //// write back Dec configuration
2258 //Cache_wb(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
2259 //Cache_wait();
2260 #endif
2262 // Establish primary timing
2263 if (errno = pP->fxns->decodeInfo(pP, pQ, pC, frame, block))
2264 {
2265 TRACE_TERSE1("PAF_ASIT_decodeProcessing: INFO2 break on decodeInfo. errno 0x%x", errno);
2266 gAsipInfo2_PrimaryErrCnt++;
2267 break;
2268 }
2270 #if 0
2271 //// (***) FL: revisit
2272 //// invalidate Dec configuration
2273 //Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
2274 //Cache_wait();
2275 #endif
2277 if (errno = pP->fxns->decodeInfo2(pP, pQ, pC, frame, block))
2278 {
2279 TRACE_TERSE1("PAF_ASIT_decodeProcessing. %d: INFO2 break on decodeInfo2. errno 0x%x", errno);
2280 gAsipInfo2_ErrCnt++;
2281 break;
2282 }
2284 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: state: INFO2->DECODE");
2285 state = DECODE;
2286 continue;
2288 case DECODE: // decode state
2289 gAsipDecodeCnt++;
2290 Log_info0("TaskAsip: state=DECODE");
2292 #if 0
2293 //// (***) FL: revisit
2294 //// write back Dec configuration
2295 //Cache_wb(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
2296 //Cache_wait();
2297 #endif
2299 if (errno = pP->fxns->decodeDecode(pP, pQ, pC, sourceSelect, frame, block))
2300 {
2301 gAsipDecodeErrCnt++;
2302 TRACE_TERSE1("PAF_ASIT_decodeProcessing: state: DECODE. decodeDecode err 0x%04x", errno);
2303 break;
2304 }
2306 #if 0
2307 //// (***) FL: revisit
2308 //// invalidate Dec configuration
2309 //Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
2310 //Cache_wait();
2311 #endif
2313 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: state: DECODE->FINAL");
2314 state = FINAL;
2315 continue;
2317 case FINAL: // frame-finalization state
2318 gAsipFinalCnt++;
2319 Log_info0("TaskAsip: state=FINAL");
2321 // Check for final frame, and if indicated:
2322 // - Exit state machine to "complete" processing.
2323 if (pP->fxns->decodeFinalTest(pP, pQ, pC, frame, block))
2324 {
2325 break;
2326 }
2328 frame++;
2329 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: state: FINAL->AGAIN");
2330 state = INFO2;
2331 continue;
2333 case QUIT: // exit state
2334 gAsipQuitCnt++;
2335 Log_info0("TaskAsip: state=QUIT");
2337 // Quit:
2338 // - Set error number registers.
2339 // - Exit state machine to "decode complete" processing.
2340 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: state: QUIT");
2341 errno = ASPERR_QUIT;
2342 break;
2344 default: // unknown state
2346 // Unknown:
2347 // - Set error number registers.
2348 // - Exit state machine to "decode complete" processing.
2350 TRACE_TERSE1("PAF_ASIT_decodeProcessing: state: unknown, 0x%x", state);
2351 errno = ASPERR_UNKNOWNSTATE;
2352 break;
2354 } // End of switch (state).
2356 TRACE_VERBOSE0("PAF_ASIT_decodeProcessing: Calling decode complete");
2357 if (pP->fxns->decodeComplete(pP, pQ, pC, alg, frame, block))
2358 {
2359 /* ignored? */;
2360 }
2362 TRACE_TIME((&TIME_MOD, "as1-f2: ... + %d = ?? (final? %d)", dtime(), state == FINAL));
2364 return errno;
2365 } // End of for (;;) to Receive, process, and transmit the data.
2366 } //PAF_ASIT_decodeProcessing
2368 // -----------------------------------------------------------------------------
2369 // ASIT Decoding Function - Decode Command Processing
2370 //
2371 // Name: PAF_ASIT_decodeCommand
2372 // Purpose: Decoding Function for processing Decode Commands.
2373 // From: AST Parameter Function -> decodeProcessing
2374 // Uses: See code.
2375 // States: x
2376 // Return: Error number in standard form (0 on success).
2377 // Trace: Message Log "trace" in Debug Project Configuration reports:
2378 // * Command execution.
2379 //
2381 Int
2382 PAF_ASIT_decodeCommand(
2383 const PAF_ASIT_Params *pP,
2384 const PAF_ASIT_Patchs *pQ,
2385 PAF_ASIT_Config *pC
2386 )
2387 {
2388 PAF_AST_Config *pAstCfg;
2389 Int as; /* Audio Stream Number (1, 2, etc.) */
2390 Int z; /* decode counter */
2391 Int zS;
2392 #ifdef NON_CACHE_STATUS
2393 Int8 tempVar8;
2394 #endif
2396 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
2397 as = pAstCfg->as;
2399 for (z=DECODE1; z < DECODEN; z++)
2400 {
2401 zS = pP->streamsFromDecodes[z];
2402 #ifdef NON_CACHE_STATUS
2403 statusOp_read(&tempVar8,
2404 &(pAstCfg->xDec[z].decodeStatus.command2),
2405 sizeof(tempVar8),
2406 GATEMP_INDEX_DEC);
2407 if (!(tempVar8 & 0x80))
2408 {
2409 switch (tempVar8)
2410 {
2411 case 0: // command none - process
2412 tempVar8 |= 0x80;
2413 statusOp_write(&(pAstCfg->xDec[z].decodeStatus.command2),
2414 &tempVar8,
2415 sizeof(tempVar8),
2416 GATEMP_INDEX_DEC);
2417 break;
2418 case 1: // command abort - leave now
2419 TRACE_TERSE2("AS%d: PAF_ASIT_decodeCommand: decode command abort (0x%02x)", as+zS, 1);
2420 tempVar8 |= 0x80;
2421 statusOp_write(&(pAstCfg->xDec[z].decodeStatus.command2),
2422 &tempVar8,
2423 sizeof(tempVar8),
2424 GATEMP_INDEX_DEC);
2425 return (ASPERR_ABORT);
2426 case 2: // command restart - leave later
2427 TRACE_TERSE2("AS%d: PAF_ASIT_decodeCommand: decode command quit (0x%02x)", as+zS, 2);
2428 tempVar8 |= 0x80;
2429 statusOp_write(&(pAstCfg->xDec[z].decodeStatus.command2),
2430 &tempVar8,
2431 sizeof(tempVar8),
2432 GATEMP_INDEX_DEC);
2433 return (ASPERR_QUIT);
2434 default: // command unknown - ignore
2435 break;
2436 }
2437 }
2438 #else
2439 if (!(pAstCfg->xDec[z].decodeStatus.command2 & 0x80))
2440 {
2441 switch (pAstCfg->xDec[z].decodeStatus.command2)
2442 {
2443 case 0: // command none - process
2444 pAstCfg->xDec[z].decodeStatus.command2 |= 0x80;
2445 break;
2446 case 1: // command abort - leave now
2447 TRACE_TERSE2("AS%d: PAF_ASIT_decodeCommand: decode command abort (0x%02x)", as+zS, 1);
2448 pAstCfg->xDec[z].decodeStatus.command2 |= 0x80;
2449 return (ASPERR_ABORT);
2450 case 2: // command restart - leave later
2451 TRACE_TERSE2("AS%d: PAF_ASIT_decodeCommand: decode command quit (0x%02x)", as+zS, 2);
2452 pAstCfg->xDec[z].decodeStatus.command2 |= 0x80;
2453 return (ASPERR_QUIT);
2454 default: // command unknown - ignore
2455 break;
2456 }
2457 }
2458 #endif
2459 }
2461 return 0;
2462 } //PAF_ASIT_decodeCommand
2464 // -----------------------------------------------------------------------------
2465 // ASIT Decoding Function - Reinitialization of Decode
2466 //
2467 // Name: PAF_ASIT_decodeInit
2468 // Purpose: Decoding Function for reinitializing the decoding process.
2469 // From: AST Parameter Function -> decodeProcessing
2470 // Uses: See code.
2471 // States: x
2472 // Return: Error number in standard or SIO form (0 on success).
2473 // Trace: Message Log "trace" in Debug Project Configuration reports:
2474 // * State information as per parent.
2475 //
2476 Int
2477 PAF_ASIT_decodeInit(
2478 const PAF_ASIT_Params *pP,
2479 const PAF_ASIT_Patchs *pQ,
2480 PAF_ASIT_Config *pC,
2481 Int sourceSelect
2482 )
2483 {
2484 PAF_AST_Config *pAstCfg;
2485 PAF_AST_DecOpCircBufCtl *pCbCtl; /* Decoder output circular buffer control */
2486 Int as; /* Audio Stream Number (1, 2, etc.) */
2487 Int z; /* decode/encode counter */
2488 Int errno; /* error number */
2489 Int zI, zS;
2490 Int zMD;
2491 Int zMI;
2492 ASP_Msg* pAspMsg; /* Messaging */
2493 Int argIdx;
2494 Int decErrno;
2495 Int status;
2496 #ifdef NON_CACHE_STATUS
2497 Int8 tempVar8;
2498 #endif
2500 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
2501 as = pAstCfg->as;
2502 zMD = pAstCfg->masterDec;
2503 zMI = pP->zone.master;
2504 (void)as; // clear compiler warning in case not used with tracing disabled
2506 pCbCtl = &pC->pAspmCfg->decOpCircBufCtl; // get pointer to circular buffer control
2508 #ifdef NON_CACHE_STATUS
2509 // reset frameCount
2510 for (z=DECODE1; z < DECODEN; z++)
2511 {
2512 statusOp_read(&tempVar8,
2513 &(pAstCfg->xDec[z].decodeStatus.mode),
2514 sizeof(tempVar8),
2515 GATEMP_INDEX_DEC);
2516 if (tempVar8)
2517 {
2518 tempVar8 = 0;
2519 statusOp_write(&(pAstCfg->xDec[z].decodeStatus.frameCount),
2520 &tempVar8,
2521 sizeof(tempVar8),
2522 GATEMP_INDEX_DEC);
2523 }
2524 }
2526 for (z=DECODE1; z < DECODEN; z++)
2527 {
2528 zI = pP->inputsFromDecodes[z];
2529 zS = pP->streamsFromDecodes[z];
2530 (void)zS; // clear compiler warning in case not used with tracing disabled
2531 statusOp_read(&tempVar8,
2532 &(pAstCfg->xDec[z].decodeStatus.mode),
2533 sizeof(tempVar8),
2534 GATEMP_INDEX_DEC);
2535 if (pAstCfg->xInp[zI].hRxSio && tempVar8)
2536 {
2537 #else
2538 // reset frameCount
2539 for (z=DECODE1; z < DECODEN; z++)
2540 {
2541 if (pAstCfg->xDec[z].decodeStatus.mode)
2542 {
2543 pAstCfg->xDec[z].decodeStatus.frameCount = 0;
2544 }
2545 }
2547 for (z=DECODE1; z < DECODEN; z++)
2548 {
2549 zI = pP->inputsFromDecodes[z];
2550 zS = pP->streamsFromDecodes[z];
2551 (void)zS; // clear compiler warning in case not used with tracing disabled
2552 if (pAstCfg->xInp[zI].hRxSio && pAstCfg->xDec[z].decodeStatus.mode)
2553 {
2554 #endif
2555 Uns gear;
2556 Int frameLength;
2557 TRACE_VERBOSE1("AS%d: PAF_ASIT_decodeInit: initializing decode", as+zS);
2559 // write back Dec configuration
2560 Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
2561 Cache_wait();
2563 // FL: send dec activate message to slave
2564 pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize); /* allocate message */
2565 if (pAspMsg == NULL)
2566 {
2567 TRACE_TERSE0("MessageQ_alloc() failure.");
2568 SW_BREAKPOINT; // temporary
2569 return -1; // temporary
2570 }
2571 MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg); /* set the return address in the message header */
2572 pAspMsg->cmd = ASP_SLAVE_DEC_ACTIVATE; /* fill in message payload */
2573 pAspMsg->procId = hAspMsgMaster->masterProcId;
2574 pAspMsg->expectResp = TRUE;
2575 pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
2576 argIdx = 0; // set decIdx (zone index)
2577 *(Int32 *)&pAspMsg->buf[argIdx] = z;
2578 TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
2579 TRACE_MSG1("decIdx=%d", pAspMsg->buf[0]);
2580 status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg); /* send message */
2581 if (status != MessageQ_S_SUCCESS)
2582 {
2583 SW_BREAKPOINT;
2584 }
2585 // wait for dec activate complete message from slave
2586 status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
2587 if (status != MessageQ_S_SUCCESS)
2588 {
2589 TRACE_TERSE0("MessageQ_get() failure.");
2590 SW_BREAKPOINT; // temporary
2591 return -1; // temporary
2592 }
2593 if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) ||
2594 (pAspMsg->cmd != ASP_MASTER_DEC_ACTIVATE_DONE) ||
2595 (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
2596 {
2597 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
2598 SW_BREAKPOINT; // temporary
2599 return -1; // temporary
2600 }
2601 hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
2602 TRACE_MSG3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
2603 // free the message
2604 status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
2605 if (status != MessageQ_S_SUCCESS)
2606 {
2607 SW_BREAKPOINT;
2608 }
2610 #if 0 // FL: decoder activate call, slave
2611 if (decAlg[z]->fxns->algActivate)
2612 decAlg[z]->fxns->algActivate (decAlg[z]);
2613 #endif
2615 // FL: send dec reset message to slave
2616 pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize); /* allocate message */
2617 if (pAspMsg == NULL)
2618 {
2619 TRACE_TERSE0("MessageQ_alloc() failure.");
2620 SW_BREAKPOINT; // temporary
2621 return -1; // temporary
2622 }
2623 MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg); /* set the return address in the message header */
2624 pAspMsg->cmd = ASP_SLAVE_DEC_RESET; /* fill in message payload */
2625 pAspMsg->procId = hAspMsgMaster->masterProcId;
2626 pAspMsg->expectResp = TRUE;
2627 pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
2628 argIdx = 0; // set decIdx
2629 *(Int32 *)&pAspMsg->buf[argIdx] = z;
2630 TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
2631 TRACE_MSG1("decIdx=%d", pAspMsg->buf[0]);
2632 // wait for dec reset complete message from slave
2633 status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg); /* send message */
2634 if (status != MessageQ_S_SUCCESS)
2635 {
2636 SW_BREAKPOINT;
2637 }
2638 status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
2639 if (status != MessageQ_S_SUCCESS)
2640 {
2641 TRACE_TERSE0("MessageQ_get() failure.");
2642 SW_BREAKPOINT; // temporary
2643 return -1; // temporary
2644 }
2645 if ((pAspMsg->procId == hAspMsgMaster->slaveProcId) &&
2646 (pAspMsg->cmd == ASP_MASTER_DEC_RESET_DONE) &&
2647 (pAspMsg->messageId == (hAspMsgMaster->messageId | ((UInt32)1<<31))))
2648 {
2649 hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
2650 TRACE_MSG3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
2651 TRACE_MSG1("decErrno=%d", pAspMsg->buf[0]);
2653 argIdx = 0; // get decErrno
2654 decErrno = *(Int32 *)&pAspMsg->buf[argIdx];
2655 if (decErrno != 0)
2656 {
2657 return decErrno;
2658 }
2659 }
2660 else
2661 {
2662 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
2663 SW_BREAKPOINT; // temporary
2664 return -1; // temporary
2665 }
2666 // free the message
2667 status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
2668 if (status != MessageQ_S_SUCCESS)
2669 {
2670 SW_BREAKPOINT;
2671 }
2673 // (***) FL: revisit
2674 // invalidate Dec configuration
2675 Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
2676 Cache_wait();
2678 #if 0 // FL: decoder reset call, slave
2679 if (dec->fxns->reset
2680 && (errno = dec->fxns->reset (dec, NULL,
2681 &pC->xDec[z].decodeControl, &pC->xDec[z].decodeStatus)))
2682 return errno;
2683 #endif
2685 #ifdef NON_CACHE_STATUS
2686 gear = 0; // due to size difference
2687 statusOp_read(&gear,
2688 &(pAstCfg->xDec[z].decodeStatus.aspGearControl),
2689 sizeof(Int8),
2690 GATEMP_INDEX_DEC);
2691 tempVar8 = gear < GEARS ? gear : 0;
2692 statusOp_write(&(pAstCfg->xDec[z].decodeStatus.aspGearStatus),
2693 &tempVar8,
2694 sizeof(tempVar8),
2695 GATEMP_INDEX_DEC);
2696 #else
2697 gear = pAstCfg->xDec[z].decodeStatus.aspGearControl;
2698 pAstCfg->xDec[z].decodeStatus.aspGearStatus = gear < GEARS ? gear : 0;
2699 #endif
2701 #if 0 // FL: change handle to decIdx (zone index)
2702 frameLength = pP->fxns->computeFrameLength(decAlg[z],
2703 FRAMELENGTH,
2704 pC->xDec[z].decodeStatus.bufferRatio);
2705 #endif
2706 #if 0 // (***) FL: revisit. Bypass computeFrameLength().
2707 frameLength = pP->fxns->computeFrameLength(z,
2708 FRAMELENGTH,
2709 pC->xDec[z].decodeStatus.bufferRatio);
2710 #else
2711 if (sourceSelect == PAF_SOURCE_PCM)
2712 {
2713 frameLength = 256;
2714 }
2715 else if ((sourceSelect == PAF_SOURCE_DDP) || (sourceSelect == PAF_SOURCE_AC3))
2716 {
2717 frameLength = 1536;
2718 }
2719 else if (sourceSelect == PAF_SOURCE_THD)
2720 {
2721 frameLength = 1536; //QIN FIX ME
2722 }
2723 else
2724 {
2725 frameLength = 256;
2726 }
2727 #endif
2729 pAstCfg->xDec[z].decodeControl.frameLength = frameLength;
2730 pAstCfg->xDec[z].decodeInStruct.sampleCount = frameLength;
2731 pAstCfg->xDec[z].decodeControl.sampleRate = PAF_SAMPLERATE_UNKNOWN;
2733 // (***) FL: revisit. Count samples for DDP.
2734 // Add framework frame length and running sample count to decoder control.
2735 //pC->xDec[z].decodeControl.pafFrameLength = FRAMELENGTH;
2736 //pC->xDec[z].decodeControl.rdSampleCount = 0;
2738 // Initialize decoder output circular buffer for selected source
2739 errno = cbInitSourceSel(pCbCtl, z, sourceSelect, frameLength, FRAMELENGTH, 0);
2740 if (errno)
2741 {
2742 SW_BREAKPOINT; // FL: debug
2743 return errno;
2744 }
2745 // FL: debug
2746 cbLog(pCbCtl, z, 1, "PAF_ASIT_decodeInit:cbInitSourceSel");
2748 if (z != zMD)
2749 {
2750 if (errno = SIO_idle(pAstCfg->xInp[zI].hRxSio))
2751 {
2752 return errno;
2753 }
2754 }
2756 #ifdef NON_CACHE_STATUS
2757 statusOp_read(&tempVar8,
2758 &(pAstCfg->xDec[z].decodeStatus.sourceSelect),
2759 sizeof(Int8),
2760 GATEMP_INDEX_DEC);
2761 if (errno = SIO_ctrl(pAstCfg->xInp[zI].hRxSio, PAF_SIO_CONTROL_SET_SOURCESELECT,
2762 DECSIOMAP(tempVar8)))
2763 {
2764 return errno;
2765 }
2766 #else
2767 if (errno = SIO_ctrl(pAstCfg->xInp[zI].hRxSio, PAF_SIO_CONTROL_SET_SOURCESELECT,
2768 DECSIOMAP(pAstCfg->xDec[z].decodeStatus.sourceSelect)))
2769 {
2770 return errno;
2771 }
2772 #endif
2773 if (errno = SIO_ctrl(pAstCfg->xInp[zI].hRxSio, PAF_SIO_CONTROL_SET_PCMFRAMELENGTH,
2774 frameLength))
2775 {
2776 return errno;
2777 }
2778 if (errno = pP->fxns->updateInputStatus(pAstCfg->xInp[zI].hRxSio, &pAstCfg->xInp[zI].inpBufStatus,
2779 &pAstCfg->xInp[zI].inpBufConfig))
2780 {
2781 return errno;
2782 }
2783 }
2784 }
2786 if (pAstCfg->xInp[zMI].hRxSio)
2787 {
2788 errno = SIO_issue(pAstCfg->xInp[zMI].hRxSio, &pAstCfg->xInp[zMI].inpBufConfig,
2789 sizeof(pAstCfg->xInp[zMI].inpBufConfig), PAF_SIO_REQUEST_NEWFRAME);
2790 if (errno)
2791 {
2792 return errno;
2793 }
2794 }
2796 return 0;
2797 } //PAF_AST_decodeInit
2799 // -----------------------------------------------------------------------------
2800 // ASIT Decoding Function - Info Processing, Common
2801 //
2802 // Name: PAF_ASIT_decodeInfo
2803 // Purpose: Decoding Function for processing information in a manner that
2804 // is common for both initial and subsequent frames of input data.
2805 // From: AST Parameter Function -> decodeProcessing
2806 // Uses: See code.
2807 // States: x
2808 // Return: Error number in standard form (0 on success).
2809 // Trace: Message Log "trace" in Debug Project Configuration reports:
2810 // * State information as per parent.
2811 //
2812 Int
2813 PAF_ASIT_decodeInfo(
2814 const PAF_ASIT_Params *pP,
2815 const PAF_ASIT_Patchs *pQ,
2816 PAF_ASIT_Config *pC,
2817 Int frame,
2818 Int block
2819 )
2820 {
2821 PAF_AST_Config *pAstCfg;
2822 Int as; /* Audio Stream Number (1, 2, etc.) */
2823 Int z; /* input/decode/stream counter */
2824 Int errno; /* error number */
2825 Int sioErr; /* error number, SIO */
2826 Int zD, zI, zS, zX;
2827 Int zMD;
2828 Int zMI;
2829 Int zMS;
2830 UInt32 curTime;
2831 ASP_Msg *pAspMsg; /* Messaging */
2832 Int argIdx;
2833 Int status;
2834 #ifdef NON_CACHE_STATUS
2835 Int8 tempVar8;
2836 Int tempVar;
2837 #endif
2838 // FL: revisit
2839 //Int size;
2840 //PAF_InpBufConfig *pIpBufConfig;
2842 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
2843 as = pAstCfg->as;
2844 zMD = pAstCfg->masterDec;
2845 zMS = pAstCfg->masterStr;
2846 zMI = pP->zone.master;
2847 (void)zMS; (void)as; // clear compiler warning in case not used with tracing disabled
2849 // Set decode control: sample rate, emphasis
2850 for (z=INPUT1; z < INPUTN; z++)
2851 {
2852 zD = z;
2853 for (zX = DECODE1; zX < DECODEN; zX++)
2854 {
2855 if (pP->inputsFromDecodes[zX] == z)
2856 {
2857 zD = zX;
2858 break;
2859 }
2860 }
2862 if (pAstCfg->xInp[z].hRxSio)
2863 {
2864 //determine associated decoder
2865 if (pAstCfg->xInp[z].inpBufStatus.sampleRateStatus !=
2866 pAstCfg->xDec[zD].decodeControl.sampleRate)
2867 {
2868 if (pAstCfg->xDec[zD].decodeControl.sampleRate == PAF_SAMPLERATE_UNKNOWN)
2869 {
2870 pAstCfg->xDec[zD].decodeControl.sampleRate =
2871 pAstCfg->xInp[z].inpBufStatus.sampleRateStatus;
2872 }
2873 else
2874 {
2875 TRACE_TERSE1("AS%d: return error ASPERR_INFO_RATECHANGE", as+pAstCfg->masterStr);
2876 TRACE_TERSE2("inpBufStatus.sampleRateStatus: 0x%x, decodeControl.sampleRate: 0x%x",
2877 pAstCfg->xInp[z].inpBufStatus.sampleRateStatus,
2878 pAstCfg->xDec[zD].decodeControl.sampleRate);
2879 // return (ASPERR_INFO_RATECHANGE);
2880 }
2881 }
2882 #ifdef NON_CACHE_STATUS
2883 statusOp_read(&tempVar8,
2884 &(pAstCfg->xDec[zD].decodeStatus.sourceDecode),
2885 sizeof(Int8),
2886 GATEMP_INDEX_DEC);
2887 pAstCfg->xDec[zD].decodeControl.emphasis =
2888 tempVar8 != PAF_SOURCE_PCM
2889 ? PAF_IEC_PREEMPHASIS_NO // fix for Mantis ID #119
2890 : pAstCfg->xInp[z].inpBufStatus.emphasisStatus;
2891 #else
2892 pAstCfg->xDec[zD].decodeControl.emphasis =
2893 pAstCfg->xDec[zD].decodeStatus.sourceDecode != PAF_SOURCE_PCM
2894 ? PAF_IEC_PREEMPHASIS_NO // fix for Mantis ID #119
2895 : pAstCfg->xInp[z].inpBufStatus.emphasisStatus;
2896 #endif
2897 }
2898 else
2899 {
2900 pAstCfg->xDec[zD].decodeControl.sampleRate = PAF_SAMPLERATE_UNKNOWN;
2901 pAstCfg->xDec[zD].decodeControl.emphasis = PAF_IEC_PREEMPHASIS_UNKNOWN;
2902 }
2903 }
2905 // Wait for info input
2906 TRACE_VERBOSE2("PAF_ASIT_decodeInfo: AS%d: awaiting frame %d -- sync+info+data", as+zMS, frame);
2907 if (pAstCfg->xInp[zMI].hRxSio)
2908 {
2909 TRACE_VERBOSE0("PAF_ASIT_decodeInfo: call SIO_reclaim to get input buffer.");
2910 sioErr = SIO_reclaim(pAstCfg->xInp[zMI].hRxSio, (Ptr)&pAstCfg->xInp[zMI].pInpBuf, NULL);
2911 if (sioErr != sizeof(pAstCfg->xInp[zMI].inpBufConfig))
2912 {
2913 TRACE_TERSE1("SIO_reclaim on input returned error ASPERR_RECLAIM. sioErr: 0x%x", sioErr);
2914 return ASPERR_RECLAIM;
2915 }
2917 // FL: debug, capture input buffer
2918 //capIb(pAstCfg->xInp[zMI].pInpBuf);
2920 //
2921 // Simulate Rx SIO_reclaim() pend
2922 //
2923 //Semaphore_pend(semaphoreRxAudio, BIOS_WAIT_FOREVER);
2924 gTaskAsipCnt++;
2925 curTime = Clock_getTicks();
2926 //System_printf("System time in TaskAsipFxn Rx audio = %lu\n", (ULong)curTime);
2927 //Log_info1("System time in TaskAsipFxn Rx audio = %u", curTime);
2928 //Log_info1("decodeInfo():Rx SIO reclaim(), system time = %u", curTime);
2929 } //pC->xInp[zMI].hRxSio
2931 // Decode info
2932 for (z=DECODE1; z < DECODEN; z++)
2933 {
2934 zI = pP->inputsFromDecodes[z];
2935 zS = pP->streamsFromDecodes[z];
2936 (void)zS; // clear compiler warning in case not used with tracing disabled
2937 #ifdef NON_CACHE_STATUS
2938 statusOp_read(&tempVar8,
2939 &(pAstCfg->xDec[z].decodeStatus.mode),
2940 sizeof(Int8),
2941 GATEMP_INDEX_DEC);
2942 if (pAstCfg->xInp[zI].hRxSio && tempVar8)
2943 {
2944 #else
2945 if (pAstCfg->xInp[zI].hRxSio && pAstCfg->xDec[z].decodeStatus.mode)
2946 {
2947 #endif
2948 TRACE_GEN2("PAF_ASIT_decodeInfo: AS%d: processing frame %d -- info", as+zS, frame);
2950 if (errno = pP->fxns->updateInputStatus(pAstCfg->xInp[zI].hRxSio,
2951 &pAstCfg->xInp[zI].inpBufStatus, &pAstCfg->xInp[zI].inpBufConfig))
2952 {
2953 TRACE_TERSE1("return error errno 0x%x.", errno);
2954 return errno;
2955 }
2957 #if 1
2958 // (***) FL: revisit
2959 // write back Inp configuration
2960 Cache_wb(&pAstCfg->xInp[zI], sizeof(PAF_AST_InpBuf), Cache_Type_ALLD, 0);
2961 // write back input data // (***) GJ: don't need this for 1xI2S HDMI/SPDIF. Maybe need this for 4xI2S HDMI.
2962 //pIpBufConfig = &gPAF_AST_config.xInp[zI].inpBufConfig;
2963 //size = pIpBufConfig->frameLength * pIpBufConfig->sizeofElement;
2964 //Cache_wb((Ptr)pIpBufConfig->pntr.pSmInt, size, Cache_Type_ALLD, 0);
2965 // write back Dec configuration
2966 Cache_wb(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
2967 Cache_wait();
2968 #endif
2970 // FL: send info message to slave
2971 pAspMsg = (ASP_Msg *)MessageQ_alloc(hAspMsgMaster->heapId, hAspMsgMaster->msgSize); /* allocate message */
2972 if (pAspMsg == NULL)
2973 {
2974 TRACE_TERSE0("MessageQ_alloc() failure.");
2975 SW_BREAKPOINT; // temporary
2976 return -1; // temporary
2977 }
2978 MessageQ_setReplyQueue(hAspMsgMaster->masterQue, (MessageQ_Msg)pAspMsg); /* set the return address in the message header */
2979 pAspMsg->cmd = ASP_SLAVE_DEC_INFO; /* fill in message payload */
2980 pAspMsg->procId = hAspMsgMaster->masterProcId;
2981 pAspMsg->expectResp = TRUE;
2982 pAspMsg->messageId = hAspMsgMaster->messageId & ~(1<<31);
2983 argIdx = 0; // set decIdx
2984 *(Int32 *)&pAspMsg->buf[argIdx] = z;
2985 TRACE_MSG3("Tx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
2986 TRACE_MSG1("decIdx=%d", pAspMsg->buf[0]);
2987 status = MessageQ_put(hAspMsgMaster->slaveQue, (MessageQ_Msg)pAspMsg); /* send message to slave */
2988 if (status != MessageQ_S_SUCCESS)
2989 {
2990 SW_BREAKPOINT;
2991 }
2992 // wait for dec info complete message from slave -- temporary
2993 status = MessageQ_get(hAspMsgMaster->masterQue, (MessageQ_Msg *)&pAspMsg, MessageQ_FOREVER);
2994 if (status != MessageQ_S_SUCCESS)
2995 {
2996 TRACE_TERSE0("MessageQ_get() failure.");
2997 SW_BREAKPOINT;
2998 return -1; // temporary
2999 }
3000 if ((pAspMsg->procId != hAspMsgMaster->slaveProcId) ||
3001 (pAspMsg->cmd != ASP_MASTER_DEC_INFO_DONE) ||
3002 (pAspMsg->messageId != (hAspMsgMaster->messageId | ((UInt32)1<<31))))
3003 {
3004 TRACE_TERSE3("ERROR: Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
3005 SW_BREAKPOINT; // temporary
3006 }
3007 hAspMsgMaster->messageId = (hAspMsgMaster->messageId + 1) & ~(1<<31);
3008 TRACE_MSG3("Rx ASP message: procId=%d, cmd=%d, messageId=0x%04x", pAspMsg->procId, pAspMsg->cmd, pAspMsg->messageId);
3009 // free the message
3010 status = MessageQ_free((MessageQ_Msg)pAspMsg); /* free the message */
3011 if (status != MessageQ_S_SUCCESS)
3012 {
3013 SW_BREAKPOINT;
3014 }
3016 #if 1
3017 // (***) FL: revisit
3018 // invalidate Dec configuration
3019 Cache_inv(&pAstCfg->xDec[z], sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
3020 Cache_wait();
3021 #endif
3023 #if 0 // FL: decoder info call, slave
3024 if (dec->fxns->info
3025 && (errno = dec->fxns->info (dec, NULL,
3026 &pC->xDec[z].decodeControl, &pC->xDec[z].decodeStatus)))
3027 #endif
3028 if (errno)
3029 {
3030 TRACE_TERSE1("return error errno 0x%x.", errno);
3031 return errno;
3032 }
3033 #ifdef NON_CACHE_STATUS
3034 statusOp_read(&tempVar,
3035 &(pAstCfg->xDec[z].decodeStatus.frameCount),
3036 sizeof(Int),
3037 GATEMP_INDEX_DEC);
3038 // increment decoded frame count
3039 tempVar += 1;
3040 statusOp_write(&(pAstCfg->xDec[z].decodeStatus.frameCount),
3041 &tempVar,
3042 sizeof(Int),
3043 GATEMP_INDEX_DEC);
3044 #else
3045 // increment decoded frame count
3046 pAstCfg->xDec[z].decodeStatus.frameCount += 1;
3047 #endif
3048 }
3049 } // z=DECODE1 to DECODEN
3051 #ifdef NON_CACHE_STATUS
3052 statusOp_read(&tempVar8,
3053 &(pAstCfg->xDec[zMD].decodeStatus.mode),
3054 sizeof(Int8),
3055 GATEMP_INDEX_DEC);
3056 // query IB for latest sourceProgram (needed if we started decoding due to a force mode)
3057 if (tempVar8)
3058 {
3059 XDAS_Int8 sourceProgram;
3060 if (errno = SIO_ctrl(pAstCfg->xInp[zMI].hRxSio, PAF_SIO_CONTROL_GET_SOURCEPROGRAM,
3061 (Arg)&sourceProgram))
3062 {
3063 TRACE_TERSE1("return error ASPERR_AUTO_PROGRAM. errno 0x%x.", errno);
3064 return ASPERR_AUTO_PROGRAM;
3065 }
3066 statusOp_write(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
3067 &(sourceProgram),
3068 sizeof(Int8),
3069 GATEMP_INDEX_DEC);
3070 }
3072 // since now decoding update decode status for all enabled decoders
3073 for (z=DECODE1; z < DECODEN; z++)
3074 {
3075 statusOp_read(&tempVar8,
3076 &(pAstCfg->xDec[z].decodeStatus.mode),
3077 sizeof(Int8),
3078 GATEMP_INDEX_DEC);
3079 if (tempVar8)
3080 {
3081 statusOp_read(&tempVar8,
3082 &(pAstCfg->xDec[z].decodeStatus.sourceProgram),
3083 sizeof(Int8),
3084 GATEMP_INDEX_DEC);
3085 statusOp_write(&(pAstCfg->xDec[z].decodeStatus.sourceDecode),
3086 &tempVar8,
3087 sizeof(Int8),
3088 GATEMP_INDEX_DEC);
3089 statusOp_read(&tempVar8,
3090 &(pAstCfg->xDec[z].decodeStatus.sourceSelect),
3091 sizeof(Int8),
3092 GATEMP_INDEX_DEC);
3093 if (tempVar8 == PAF_SOURCE_SNG)
3094 {
3095 tempVar8 = PAF_SOURCE_SNG;
3096 statusOp_write(&(pAstCfg->xDec[z].decodeStatus.sourceDecode),
3097 &tempVar8,
3098 sizeof(Int8),
3099 GATEMP_INDEX_DEC);
3100 }
3101 }
3102 }
3103 #else
3104 // query IB for latest sourceProgram (needed if we started decoding due to a force mode)
3105 if (pAstCfg->xDec[zMD].decodeStatus.mode)
3106 {
3107 XDAS_Int8 sourceProgram;
3108 if (errno = SIO_ctrl(pAstCfg->xInp[zMI].hRxSio, PAF_SIO_CONTROL_GET_SOURCEPROGRAM,
3109 (Arg)&sourceProgram))
3110 {
3111 TRACE_TERSE1("return error ASPERR_AUTO_PROGRAM. errno 0x%x.", errno);
3112 return ASPERR_AUTO_PROGRAM;
3113 }
3114 pAstCfg->xDec[zMD].decodeStatus.sourceProgram = sourceProgram;
3115 }
3117 // since now decoding update decode status for all enabled decoders
3118 for (z=DECODE1; z < DECODEN; z++)
3119 {
3120 if (pAstCfg->xDec[z].decodeStatus.mode)
3121 {
3122 pAstCfg->xDec[z].decodeStatus.sourceDecode = pAstCfg->xDec[z].decodeStatus.sourceProgram;
3123 if (pAstCfg->xDec[z].decodeStatus.sourceSelect == PAF_SOURCE_SNG)
3124 {
3125 pAstCfg->xDec[z].decodeStatus.sourceDecode = PAF_SOURCE_SNG;
3126 }
3127 }
3128 }
3129 #endif
3131 #if 0 // FL: ASDT (slave)
3132 // TODO: move this to start of this function so that it doesn't affect IO timing
3133 // Initialize audio frame(s)
3134 // Re-initialize audio frame if there is an associated decode and
3135 // that decode doesn't have a valid input or is turned off
3136 for (z=STREAM1; z < STREAMN; z++)
3137 {
3138 Int reset = 0;
3139 for (zX = DECODE1; zX < DECODEN; zX++)
3140 {
3141 if (pP->streamsFromDecodes[zX] == z)
3142 {
3143 zI = pP->inputsFromDecodes[zX];
3144 if (!pC->xDec[zX].decodeStatus.mode || !pC->xInp[zI].hRxSio)
3145 {
3146 reset = 1;
3147 }
3148 }
3149 }
3150 if (reset)
3151 {
3152 TRACE_VERBOSE2("PAF_ASIT_decodeInfo: AS%d: initializing block %d -- info", as+z, frame);
3153 pP->fxns->initFrame1 (pP, pQ, pC, z, 0);
3154 }
3155 else
3156 {
3157 TRACE_VERBOSE2("PAF_ASIT_decodeInfo: AS%d: initializing block %d -- info <ignored>", as+z, frame);
3158 }
3159 }
3160 #endif
3162 return 0;
3163 } //PAF_ASIT_decodeInfo
3165 // -----------------------------------------------------------------------------
3166 // ASIT Decoding Function - Info Processing, Initial
3167 //
3168 // Name: PAF_ASIT_decodeInfo1
3169 // Purpose: Decoding Function for processing information in a manner that
3170 // is unique to initial frames of input data.
3171 // From: AST Parameter Function -> decodeProcessing
3172 // Uses: See code.
3173 // States: x
3174 // Return: Error number in standard or SIO form (0 on success).
3175 // Trace: Message Log "trace" in Debug Project Configuration reports:
3176 // * State information as per parent.
3177 //
3178 Int
3179 PAF_ASIT_decodeInfo1(
3180 const PAF_ASIT_Params *pP,
3181 const PAF_ASIT_Patchs *pQ,
3182 PAF_ASIT_Config *pC,
3183 Int frame,
3184 Int block
3185 )
3186 {
3187 return 0;
3188 } //PAF_ASIT_decodeInfo1
3190 // -----------------------------------------------------------------------------
3191 // AST Decoding Function - Info Processing, Subsequent
3192 //
3193 // Name: PAF_AST_decodeInfo2
3194 // Purpose: Decoding Function for processing information in a manner that
3195 // is unique to frames of input data other than the initial one.
3196 // From: AST Parameter Function -> decodeProcessing
3197 // Uses: See code.
3198 // States: x
3199 // Return: Error number in standard form (0 on success).
3200 // Trace: None.
3201 //
3202 Int
3203 PAF_ASIT_decodeInfo2(
3204 const PAF_ASIT_Params *pP,
3205 const PAF_ASIT_Patchs *pQ,
3206 PAF_ASIT_Config *pC,
3207 Int frame,
3208 Int block
3209 )
3210 {
3211 return 0;
3212 } //PAF_ASIT_decodeInfo2
3214 // -----------------------------------------------------------------------------
3215 // AST Decoding Function - Continuation Processing
3216 //
3217 // Name: PAF_AST_decodeCont
3218 // Purpose: Decoding Function for processing that occurs subsequent to
3219 // information processing but antecedent to timing processing
3220 // for frames of input data other than the initial one.
3221 // From: AST Parameter Function -> decodeProcessing
3222 // Uses: See code.
3223 // States: x
3224 // Return: Error number in standard form (0 on success).
3225 // Trace: Message Log "trace" in Debug Project Configuration reports:
3226 // * State information as per parent.
3227 //
3229 Int
3230 PAF_AST_decodeCont(
3231 const PAF_ASIT_Params *pP,
3232 const PAF_ASIT_Patchs *pQ,
3233 PAF_ASIT_Config *pC,
3234 ALG_Handle decAlg[],
3235 Int frame,
3236 Int block
3237 )
3238 {
3239 PAF_AST_Config *pAstCfg;
3240 Int as; /* Audio Stream Number (1, 2, etc.) */
3241 Int z; /* decode counter */
3242 Int zI, zS;
3243 Int zMD;
3244 #ifdef NON_CACHE_STATUS
3245 Int8 tempVar8;
3246 #endif
3249 pAstCfg = pC->pAstCfg; // get pointer to common (shared) configuration
3250 as = pAstCfg->as;
3251 zMD = pAstCfg->masterDec;
3252 (void)as; // clear compiler warning in case not used with tracing disabled
3254 // Await slave inputs
3255 for (z=DECODE1; z < DECODEN; z++)
3256 {
3257 zI = pP->inputsFromDecodes[z];
3258 zS = pP->streamsFromDecodes[z];
3259 (void)zS;
3260 #ifdef NON_CACHE_STATUS
3261 statusOp_read(&tempVar8,
3262 &(pAstCfg->xDec[z].decodeStatus.mode),
3263 sizeof(Int8),
3264 GATEMP_INDEX_DEC);
3265 if (z == zMD
3266 || ! pAstCfg->xInp[zI].hRxSio
3267 || ! tempVar8)
3268 continue;
3269 #else
3270 if (z == zMD
3271 || ! pAstCfg->xInp[zI].hRxSio
3272 || ! pAstCfg->xDec[z].decodeStatus.mode)
3273 continue;
3274 #endif
3275 TRACE_VERBOSE2("PAF_AST_decodeCont: AS%d: awaiting frame %d -- data", as+zS, frame);
3276 if (SIO_reclaim(pAstCfg->xInp[zI].hRxSio, (Ptr)&pAstCfg->xInp[zI].pInpBuf, NULL)
3277 != sizeof (pAstCfg->xInp[zI].inpBufConfig))
3278 return (ASPERR_RECLAIM);
3279 }
3281 return 0;
3282 } //PAF_AST_decodeCont
3284 // -----------------------------------------------------------------------------
3285 // ASIT Decoding Function - Decode Processing
3286 //
3287 // Name: PAF_ASIT_decodeDecode
3288 // Purpose: Decoding Function for processing of input data by the
3289 // Decode Algorithm.
3290 // From: AST Parameter Function -> decodeProcessing
3291 // Uses: See code.
3292 // States: x
3293 // Return: Error number in standard form (0 on success).
3294 // Trace: Message Log "trace" in Debug Project Configuration reports:
3295 // * State information as per parent.
3296 //
3297 Int
3298 PAF_ASIT_decodeDecode(
3299 const PAF_ASIT_Params *pP,
3300 const PAF_ASIT_Patchs *pQ,