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 * ======== audioStreamInpProcNewIo.c ========
38 */
39 #include <xdc/runtime/Log.h>
40 #include <ti/sysbios/BIOS.h>
41 #include <xdc/runtime/Error.h>
42 #include <ti/sysbios/knl/Event.h>
44 #include "procsdk_audio_typ.h"
45 #include "audioStreamInpProc.h"
46 #include "audioStreamProc_common.h"
47 #include "aspMsg_common.h"
48 #include "aspMsg_master.h"
49 #include "asperr.h"
50 #include "common.h"
52 #include "aud.h"
53 #include "aud_audio.h"
54 #include "mcasp_cfg.h"
55 #include "ioConfig.h" //TODO: remove this header
56 #include "ioBuff.h"
57 #include "ioPhy.h"
58 #include "ioData.h"
61 #define STRIDE_WORST_CASE 32 // 4-byte (32-bit) word, 2 slots, 4 serializers
63 //#define DEBUG_SKIP_DECODING
65 #define SYNC_PC_MASK 0x1F
66 #define SYNC_SUBTYPE_MASK 0x700
67 #define SYNC_SUBTYPE_SHIFT 8
68 #define SYNC_SUBTYPE_DTSHD 0x11
69 #define SYNC_DDP 0x15
70 #define SYNC_THD 0x16
72 #define IEC_HEADER_LENGTH 4
74 #define INPUT_SWITCH_HANGOVER 8
76 //table needed until PAF_SOURCE is reordered to match IEC numbering
77 const SmUns IECpafSource[23] =
78 {
79 PAF_SOURCE_UNKNOWN, // 0: IEC NULL Type
80 PAF_SOURCE_AC3, // 1: Comments on 1-15 match IEC 61937 part 2.
81 PAF_SOURCE_UNKNOWN, // 2: IEC reserved
82 PAF_SOURCE_UNKNOWN, // 3: IEC pause
83 PAF_SOURCE_UNKNOWN, // 4: MPEG 1 layer 1
84 PAF_SOURCE_MP3, // 5: MPEG layer 2 or 3
85 PAF_SOURCE_UNKNOWN, // 6: MPEG 2 data with extension
86 PAF_SOURCE_AAC, // 7: MPEG-2 AAC ADTS
87 PAF_SOURCE_UNKNOWN, // 8: MPEG 2 layer 1 low sampling frequency
88 PAF_SOURCE_UNKNOWN, // 9: MPEG 2 layer 2 or 3 low sampling frequency
89 PAF_SOURCE_UNKNOWN, // 10: reserved
90 PAF_SOURCE_DTS, // 11: DTS type 1 (11 bit: 512 sample repeat period)
91 PAF_SOURCE_DTS12, // 12: DTS type 2 (12 bit: 1024 sample repeat period)
92 PAF_SOURCE_DTS13, // 13: DTS type 3 (13 bit: 2048 sample repeat period)
93 PAF_SOURCE_DTS14, // 14: ATRAC
94 PAF_SOURCE_UNKNOWN, // 15: ATRAC 2/3
95 PAF_SOURCE_THD, // 16
96 PAF_SOURCE_DTSHD, // 17
97 PAF_SOURCE_WMA9PRO, // 18
98 PAF_SOURCE_UNKNOWN, // 19
99 PAF_SOURCE_UNKNOWN, // 20
100 PAF_SOURCE_DDP, // 21
101 PAF_SOURCE_THD, // 22
102 };
104 /*
105 * Functions defined in other files and to be put into proper header files
106 */
107 extern Void taskAsipFxnInit(const PAF_ASIT_Params *pP,const PAF_ASIT_Patchs *pQ);
110 // avoid including sap_d10.h, which would cause symbol redefinition
111 // warning (MCASP_PFUNC_XXX)
112 //extern XDAS_Int32 D10_init(void * pD10Params);
113 extern XDAS_Int32 D10_initClkMux(void *pD10Params);
114 extern XDAS_Int32 D10_RxControl(const void *pD10RxParams,
115 XDAS_Int32 code, XDAS_Int32 arg);
117 /*
118 * Functions only used in this file
119 */
120 int asitPrepareProcessing();
121 int asitIoCompsInit(PAF_AST_InpBuf * pInpBuf, PAF_AST_IoInp * pInpIo);
122 void asitProcInit(PAF_AST_IoInp *pInp, asipDecProc_t *pDec);
123 void asitIoPhyPrime(PAF_AST_IoInp *pInpIo);
124 void asitPhyTransferComplete(PAF_AST_IoInp * pInpIo);
125 void asitPhyTransferStart(PAF_AST_IoInp *pInpIo);
126 Int asitRecfgPhyXfer(PAF_AST_IoInp *pInp, size_t xferSize);
128 // Select Input devices
129 Int asitSelectDevices(
130 const PAF_ASIT_Patchs *pQ,
131 PAF_AST_Config *pAstCfg,
132 PAF_AST_IoInp *pInp
133 );
135 Int asitUpdateInputStatus(const void *pRxParams, PAF_InpBufStatus *pStatus,
136 PAF_InpBufConfig *pInpBuf);
138 Int asitSourceDetection(const PAF_ASIT_Params *pP,
139 const PAF_ASIT_Patchs *pQ,
140 PAF_ASIT_Config *pAsitCfg);
142 Int asitDecideSource(PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp,
143 ioDataAutoDetStat_t *autoDetStatus);
144 Int asitUpdateIoComps(const PAF_ASIT_Params *pP, PAF_AST_Config *pAstCfg,
145 PAF_AST_IoInp *pInp, ioDataAutoDetStat_t *autoDetStatus);
146 Int asitBypassIoData(PAF_AST_IoInp *pInp);
147 Int asitPcmTransition(PAF_ASIT_Config *pAsitCfg);
149 void asitUpdateInpBufConfig(PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp);
150 Int asitInputDataProcess(PAF_AST_IoInp *pInp, ioDataAutoDetStat_t *pAutoDetStats);
152 UInt asitEventsToDecMsg(UInt asitEvents);
153 void asitErrorHandling(PAF_ASIT_Config *pAsitCfg, Int asitErr);
154 Int asitEvtErrCheck(UInt actualEvents, UInt expectedEvents);
156 void asitPostInfoEvent();
157 void asitPostDecEvent();
159 /*
160 * variables/structures to be put into proper global structures
161 */
162 extern PAF_ASIT_Config gPAF_ASIT_config;
163 extern const MdUns iecFrameLength[23];
164 extern Ptr hMcaspRxChan;
166 // temp for simulation
167 //#define ASIT_ALL_EVENTS ( ASIT_EVTMSK_INPDATA \
168 // + ASIT_EVTMSK_INFOACK \
169 // + ASIT_EVTMSK_DECACK )
170 #define ASIT_ALL_EVENTS ( ASIT_EVTMSK_INPDATA \
171 + ASIT_EVTMSK_RXACK )
173 // temp for simulation
174 //#define ASIT_DEC_EVENTS ( ASIT_EVTMSK_INPDATA \
175 // + ASIT_EVTMSK_INFOACK \
176 // + ASIT_EVTMSK_DECACK )
177 #define ASIT_DEC_EVENTS ( ASIT_EVTMSK_INPDATA \
178 + ASIT_EVTMSK_RXACK )
180 #define ASIP_DEBUG
182 #ifdef ASIP_DEBUG
183 /* define the following as global variables for easy debugging */
184 int asipLoopCount1, asipLoopCount2;
185 Int asipErrno;
186 Int inputReadyForProcessing;
188 // debug
189 #include "evmc66x_gpio_dbg.h"
190 #endif
192 Event_Handle gAsitEvtHandle; // ASIT event handle
193 Int eventsOn; // flag indicating whether to process events
195 SyncEvent_Handle gAsitSyncEvtHandle; // ASIT Sync event handle
197 /*
198 * ======== taskAsipFxn ========
199 * Audio Stream Input Processing task function
200 */
201 #ifndef PASDK_SIO_DEV
202 #ifndef IO_LOOPBACK_TEST
203 Void taskAsipFxn( // ASIP task function for new I/O
204 #else
205 Void taskAsipFxn_NewIO_Not_Used( // not used for loopback test
206 #endif
207 #else
208 Void taskAsipFxn_NewIO_Not_USED( // not used for SIO/DEV based I/O
209 #endif
210 const PAF_ASIT_Params *pP,
211 const PAF_ASIT_Patchs *pQ)
212 {
213 PAF_ASIT_Config *pAsitCfg; /* ASIT configuration pointer */
214 PAF_AST_Config *pAstCfg; /* AST Common (shared) configuration pointer */
215 PAF_AST_IoInp *pInp; /* Input I/O components */
216 Int as; /* Audio Stream Number (1, 2, etc.) */
217 Int z; /* input/encode/stream/decode/output counter */
218 Int zMI;
219 #ifndef ASIP_DEBUG
220 int asipLoopCount1, asipLoopCount2;
221 Int asipErrno;
222 Int inputReadyForProcessing;
223 #endif
224 Int asitErr;
225 UInt events;
226 // Int eventsOn;
227 // Error_Block eb;
229 Log_info0("Enter taskAsipFxn()");
231 taskAsipFxnInit(pP, pQ); // initialization of input task
233 //
234 // Audio Stream Input Task Configuration (*pAsitCfg):
235 //
236 pAsitCfg = &gPAF_ASIT_config; // initialize pointer to task configuration
237 pAstCfg = pAsitCfg->pAstCfg; // pointer to AST common (shared) configuration
239 /* Set Audio Stream Number (1, 2, etc.) */
240 as = pAstCfg->as;
242 //
243 // Determine decoder and stream indices associated with the master input
244 //
245 zMI = pP->zone.master;
246 pInp = &pAsitCfg->pIoInp[zMI]; // pointer to input I/O components
248 for (z=STREAM1; z < STREAMN; z++)
249 {
250 TRACE_VERBOSE1("TaskAsip: AS%d: running", as+z);
251 }
253 Log_info0("TaskAsip: Entering Main Loop.");
255 //
256 // Main processing loop
257 //
258 asipLoopCount1 = 0;
259 asipLoopCount2 = 0;
260 asitErr = ASIT_NO_ERR;
262 // The events_on flag will be removed if the RESTART state is changed to
263 // event-based scheduling instead of polling
264 eventsOn = FALSE;
266 for (;;)
267 {
268 asipLoopCount1++;
270 if(eventsOn) {
271 events = Event_pend(gAsitEvtHandle, ASIT_EVTMSK_NONE, ASIT_ALL_EVENTS,
272 BIOS_WAIT_FOREVER);
273 }
274 switch (pInp->asipState)
275 {
276 case ASIT_RESET: // No events pending in this state
277 // Indicate decoder no decoding yet
278 pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_NONE);
280 // 5 system tick, or 5 msec. Should remove this later when implementing
281 // event based scheduling.
282 Task_sleep(5);
284 inputReadyForProcessing = asitPrepareProcessing(pP, pQ, pAsitCfg, &asipErrno);
285 if (inputReadyForProcessing) {
286 TRACE_VERBOSE0("TaskAsip: Input is ready. Initialize I/O components.");
287 // Input is ready for processing, so we initialize the I/O components.
288 // Note that the I/O components init. and I/O PHY prime are performed only
289 // at the first time. This should be changed later - init. and prime
290 // should be done whenever input interface has changed.
291 asitErr = asitIoCompsInit(&pAstCfg->xInp[zMI], pInp);
293 // Initialize ASIT processing
294 asitProcInit(pInp, &pAsitCfg->inpDec);
295 pInp->asipState = ASIT_SOURCE_DETECTION;
296 eventsOn = TRUE; // turn on events pending
297 TRACE_VERBOSE0("TaskAsip: turn on events and go to source detection.");
298 }
299 break;
301 case ASIT_SOURCE_DETECTION:
302 // Source unknown - to detect & identify source
303 if(events == ASIT_EVTMSK_INPDATA) {
304 // Only this event is expected. If any other event, it's error.
305 // Input data is ready - perform source detection.
306 // New state will be decided inside the function
307 asitErr = asitSourceDetection(pP, pQ, pAsitCfg);
308 }
309 else {
310 //Error checking & debug
311 asitErr = asitEvtErrCheck(events, ASIT_EVTMSK_INPDATA);
312 }
314 break;
316 case ASIT_PCM_TRANSITION:
317 // Source is PCM - transition to PCM decoding
318 if(events == ASIT_EVTMSK_INPDATA) {
319 // Only this event is expected. If any other event, it's error.
320 // Input data is ready - transition to PCM decoding
321 // New state will be decided inside the function
322 asitErr = asitPcmTransition(pAsitCfg);
323 }
324 else {
325 //Error checking & debug
326 asitErr = asitEvtErrCheck(events, ASIT_EVTMSK_INPDATA);
327 }
328 break;
330 case ASIT_DECODE_PROCESSING:
331 if(events & ASIT_DEC_EVENTS) {
333 #if 1 // debug
334 if (events & ASIT_EVTMSK_INPDATA)
335 {
336 // shows timing of Input (Rx McASP EDMA)
337 // ADC B5
338 {
339 static Uint8 toggleState = 0;
340 if (toggleState == 0)
341 GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99);
342 else
343 GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
344 toggleState = ~(toggleState);
345 }
346 }
347 #endif
349 // Decode processing for either PCM or bitstream
350 // New state will be decided inside the function
351 asitErr = asitDecodeProcessing(pP, pQ, pAsitCfg, events);
352 }
353 else {
354 //Error checking & debug
355 asitErr = asitEvtErrCheck(events, ASIT_DEC_EVENTS);
356 }
357 break;
359 default:
360 break;
361 }
363 if(asitErr) {
364 asitErrorHandling(pAsitCfg, asitErr);
366 if(pInp->asipState == ASIT_RESET) {
367 eventsOn = FALSE;
368 }
370 asitErr = ASIT_NO_ERR;
371 }
373 } // for (;;)
375 } /* taskAsipFxn */
378 /*===========================================================================
379 * ASIT Processing Preparation
380 * Output:
381 * - return TRUE (input is ready) or FALSE (input is not ready)
382 * - *asipErrno Error number
383 ============================================================================*/
384 Int asitPrepareProcessing(const PAF_ASIT_Params *pP,
385 const PAF_ASIT_Patchs *pQ,
386 PAF_ASIT_Config *pC,
387 Int *asipErrno)
388 {
389 Int as, zMS, zMI, zMD;
390 Int sourceConfig, mode;
391 PAF_AST_Config *pAstCfg;
392 PAF_AST_IoInp *pInp; /* I/O components for input */
394 pAstCfg = pC->pAstCfg; // pointer to AST common (shared) configuration
395 as = pAstCfg->as;
396 zMI = pP->zone.master;
397 zMD = pAstCfg->masterDec;
398 zMS = pAstCfg->masterStr;
399 pInp = pC->pIoInp; // pointer to input I/O components
401 *asipErrno = 0;
403 // Select source and initialize physical layer / HW interface
404 *asipErrno = asitSelectDevices(pQ, pAstCfg, pInp);
405 if (*asipErrno) {
406 TRACE_TERSE2("asitSelectDevices returned asipErrno = 0x%04x at line %d. AS%d",
407 *asipErrno, as+zMS);
408 return FALSE; // Input is not ready for processing due to error
409 }
411 // If no master input selected then we don't know what may be at the input,
412 // so set to unknown and skip any remaining processing
413 if (!pInp[zMI].pRxParams) {
414 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
415 (Int8)PAF_SOURCE_UNKNOWN, GATEMP_INDEX_DEC);
417 TRACE_VERBOSE1("TaskAsip: AS%d: No input selected...", as+zMS);
418 return FALSE; // No error, but input is not ready for processing
419 }
421 // If here then we have a valid input so query its status
422 *asipErrno = asitUpdateInputStatus(pInp[zMI].pRxParams,
423 &pAstCfg->xInp[zMI].inpBufStatus,
424 &pAstCfg->xInp[zMI].inpBufConfig);
425 if(*asipErrno) {
426 TRACE_VERBOSE1("TaskAsip: updateInputStatus returns 0x%x", *asipErrno);
427 return FALSE; // Input is not ready for processing due to error
428 }
430 // If master decoder is not enabled, or the input is unlocked, then do nothing
431 mode = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.mode),
432 GATEMP_INDEX_DEC);
433 if (!mode || !pAstCfg->xInp[zMI].inpBufStatus.lock)
434 {
435 TRACE_VERBOSE0("TaskAsip: Not locked, continue");
436 return FALSE; // No error, but input is not ready for processing
437 }
439 // Check selected source: sourceSelect is set by another task, AIP or AFP
440 sourceConfig = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
441 GATEMP_INDEX_DEC);
442 // If no source selected then do nothing
443 if(sourceConfig == PAF_SOURCE_NONE) {
444 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
445 (Int8)PAF_SOURCE_NONE, GATEMP_INDEX_DEC);
446 TRACE_VERBOSE1("TaskAsip: AS%d: no source selected, continue", as+zMS);
447 return FALSE; // No error, but input is not ready for processing
448 }
450 // If we want pass processing then proceed directly
451 if (sourceConfig == PAF_SOURCE_PASS)
452 {
453 TRACE_VERBOSE1("TaskAsip: AS%d: Pass processing ...", as+zMS);
454 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
455 (Int8)PAF_SOURCE_PASS, GATEMP_INDEX_DEC);
457 pP->fxns->sourceDecode(pP, pQ, pC, PAF_SOURCE_PASS);
458 if (pP->fxns->passProcessing) {
459 *asipErrno = pP->fxns->passProcessing(pP, pQ, pC, NULL);
460 }
461 else {
462 TRACE_TERSE2("TaskAsip: AS%d: Pass Processing not supported, asipErrno 0x%x",
463 as+zMS, ASPERR_PASS);
464 *asipErrno = ASPERR_PASS;
465 }
467 TRACE_VERBOSE0("TaskAsip: continue");
468 return FALSE; // Error or not, input is not ready for processing
469 }
471 // No error and input processing is ready
472 return TRUE;
473 } /* asitPrepareProcessing */
476 /*===========================================================================
477 * ASIT Source Detection:
478 * ASIT processing for input source identification:
479 * - mark I/O PHY transfer completion
480 * - run auto-detection via I/O DATA in asitInputDataProcess
481 * - mark I/O DATA read completion
482 * - check auto-detection status and take corresponding actions if either
483 * PCM or bitstream is identified:
484 * - decide input source
485 * - update I/O components
486 * - reconfigure McASP LLD if it is PCM
487 * - start next I/O PHY transfer
488 ============================================================================*/
489 Int asitSourceDetection(const PAF_ASIT_Params *pP,
490 const PAF_ASIT_Patchs *pQ,
491 PAF_ASIT_Config *pAsitCfg)
492 {
493 PAF_AST_Config *pAstCfg;
494 PAF_AST_IoInp *pInp; // I/O components for input
495 Int zMD, mcaspErr, asitErr;
496 ioDataAutoDetStat_t autoDetStatus;
498 pAstCfg = pAsitCfg->pAstCfg; // pointer to AST common (shared) configuration
499 zMD = pAstCfg->masterDec;
500 pInp = &pAsitCfg->pIoInp[zMD]; // pointer to input I/O components
502 // Marks I/O PHY transfer and I/O BUFF write complete
503 asitPhyTransferComplete(pInp);
505 // Process input data - either searching SYNC for PCM or checking SYNC for bitstream
506 asitErr = asitInputDataProcess(pInp, &autoDetStatus);
507 if(asitErr != ASIT_NO_ERR) {
508 // Even though there is error, still need to start next transfer to
509 // maintain McASP transfer.
510 asitPhyTransferStart(pInp);
512 return asitErr;
513 }
515 // Mark input data read complete
516 ioDataReadComplete(pInp->hIoData);
518 // Check if bitstream or PCM is detected
519 if( autoDetStatus.syncState == IODATA_SYNC_BITSTREAM
520 || autoDetStatus.syncState == IODATA_SYNC_PCM) {
521 // Decide input source and inform decoder
522 asitErr = asitDecideSource(pAstCfg, pInp, &autoDetStatus);
523 if(asitErr != ASIT_NO_ERR) {
524 return asitErr;
525 }
526 else {
527 // Update I/O components and input buffer config
528 asitUpdateIoComps(pP, pAstCfg, pInp, &autoDetStatus);
530 // set to unknown so that we can ensure, for IOS purposes, that
531 // sourceDecode = NONE iff we are in this top level state machine
532 // and specifically not in decodeProcessing
533 #ifndef DEBUG_SKIP_DECODING
534 pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_UNKNOWN);
535 #endif
537 if(autoDetStatus.syncState == IODATA_SYNC_BITSTREAM) {
538 // Input is bit stream: go to decoding
539 pInp->asipState = ASIT_DECODE_PROCESSING;
540 }
541 else {
542 // Input is PCM: stop swapping data
543 pInp->swapData = FALSE;
545 // Reconfigure McASP LLD to transfer 32-bit unpacked data
546 mcaspErr = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_32);
547 if(mcaspErr != Aud_EOK) {
548 return ASIT_ERR_MCASP_CFG;
549 }
551 // Adjust I/O BUFF delay and read pointer - to make sure read pointers
552 // always point to PCM data from 1st I2S (out of 4 for HDMI 4xI2S)
553 ioBuffAdjustDelay(pInp->hIoBuff, pInp->phyXferSize);
555 // Go to transition state to switch to PCM
556 pInp->asipState = ASIT_PCM_TRANSITION;
557 }
558 }
559 }
561 // Start next transfer
562 asitPhyTransferStart(pInp);
564 return (ASIT_NO_ERR);
565 } /* asitSourceDetection */
568 /*===========================================================================
569 //
570 // which will cause all 0's in one McASP LLD transfer. This will
571 // be detected as loss of SYNC by auto detection. To prevent that,
572 // skip I/O DATA process for hangover period so that this all 0's
573 // frame will not be seen by auto-detection. Also, playing out PCM
574 // needs to be skipped as well, to prevent from playing out garbage
575 // (16-bit packed data).
576 *
577 * ASIT Transition to PCM decoding.
578 * When PCM is detected, McASP LLD will be reconfigured to transmit 32-bit
579 * words, which will modify the RFMT register. This will cause all 0's in
580 * one McASP LLD transfer, which would be detected as loss of SYNC by auto
581 * detection (performed by I/O DATA). To prevent that, skip I/O DATA process
582 * for hangover period so that this all-0's frame will not be seen by the
583 * auto-detection.
584 *
585 * In addition, playing out PCM should be skipped as well to prevent from
586 * playing out the 16-bit packed data that's still in the input buffer.
587 *
588 * This function does the following:
589 * - mark I/O PHY transfer completion
590 * - bypass I/O DATA
591 * - start next I/O PHY transfer
592 ============================================================================*/
593 Int asitPcmTransition(PAF_ASIT_Config *pAsitCfg)
594 {
595 Int asitErr;
596 PAF_AST_IoInp *pInp; // I/O components for input
597 Int zMD;
599 zMD = pAsitCfg->pAstCfg->masterDec; // pointer to AST common (shared) configuration
600 pInp = &pAsitCfg->pIoInp[zMD]; // pointer to input I/O components
602 // Marks I/O PHY transfer and I/O BUFF write complete
603 asitPhyTransferComplete(pInp);
605 // Bypass I/O data processing due to McASP LLD work around
606 // (refer to comments inside the function)
607 asitErr = asitBypassIoData(pInp);
609 pInp->pcmSwitchHangOver--;
610 if(pInp->pcmSwitchHangOver == 0) {
611 pInp->asipState = ASIT_DECODE_PROCESSING;
612 }
613 else {
614 ; // stay in this state
615 }
617 // Start next transfer
618 asitPhyTransferStart(pInp);
620 return asitErr;
622 } /* asitPcmTransition */
624 /*============================================================================
625 * ASIT Bypass I/O DATA Processing
626 * This function bypasses the I/O DATA processing. It maintains the read
627 * operation of I/O BUFF by directly calling I/O BUFF APIs. When I/O DATA
628 * is not bypassed, I/O BUFF read operation is invoked by I/O DATA.
629 *
630 ============================================================================*/
631 Int asitBypassIoData(PAF_AST_IoInp *pInp)
632 {
633 void *buff1, *buff2;
634 size_t size1, size2;
636 // Get read pointers (or sub-buffers) of the input buffer
637 if (ioBuffGetReadPtrs(pInp->hIoBuff, pInp->phyXferSize,
638 &buff1, &size1, &buff2, &size2)
639 == IOBUFF_ERR_UNDERFLOW) {
640 pInp->numUnderflow += 1;
642 // Return since there is no enough data to process
643 return ASIT_ERR_INPBUF_UNDERFLOW;
644 }
646 ioBuffReadComplete(pInp->hIoBuff, buff1, size1);
648 if(buff2 != NULL) {
649 ioBuffReadComplete(pInp->hIoBuff, buff2, size2);
650 }
652 return ASIT_NO_ERR;
653 } /* asitBypassIoData */
656 /*============================================================================
657 * ASIT Decode Processing
658 * This function performs the decode processing and does the following based
659 * on the ASIT events:
660 * - initialize the decode processing if it is the first time
661 * - if there is ASIT INPUT DATA event (ASIT_EVTMSK_INPDATA):
662 * - mark I/O PHY transfer completion
663 * - run auto-detection via I/O DATA in asitInputDataProcess
664 * - check auto-detection status and take corresponding actions if SYNC
665 * is lost.
666 * - start next I/O PHY transfer
667 * - map ASIT events to decoding messages
668 * - invoke decDecodeFsm() and pass the mapped decoding messages
669 * - if there is ASIT DECODE ACK event (ASIT_EVTMSK_DECACK)
670 * - mark I/O DATA read completion
671 * - error handling
672 ============================================================================*/
673 Int asitDecodeProcessing(const PAF_ASIT_Params *pP,
674 const PAF_ASIT_Patchs *pQ,
675 PAF_ASIT_Config *pAsitCfg,
676 UInt asitEvents)
677 {
678 Int asitErr, decErr;
679 PAF_AST_IoInp *pInp; // I/O components for input
680 AspMsgMaster_Handle hAspMsgMaster; // ASIT message master handle
681 asipDecProc_t *pDec;
682 ioDataAutoDetStat_t autoDetStatus;
683 Int zMD;
684 UInt decMsg;
685 Int status;
687 zMD = pAsitCfg->pAstCfg->masterDec; // pointer to AST common (shared) configuration
688 pInp = &pAsitCfg->pIoInp[zMD]; // pointer to input I/O components
689 hAspMsgMaster = pAsitCfg->hAspMsgMaster; // get ASIT message master handle
690 pDec = &pAsitCfg->inpDec;
692 // Initialization for decode processing when this function is called the first time
693 #ifndef DEBUG_SKIP_DECODING
694 if(!pDec->initDone) {
695 // Initialize decoder
696 decDecodeInit(pP, pAsitCfg, pInp->sourceSelect);
698 pDec->initDone = TRUE;
699 }
700 #endif
702 // Process input data if this is a data ready message
703 if(asitEvents & ASIT_EVTMSK_INPDATA) {
704 TRACE_TERSE0("asitDecodeProcessing: process input data.");
706 // Marks I/O PHY transfer and I/O BUFF write complete
707 asitPhyTransferComplete(pInp);
709 // Process input data - either search SYNC for PCM or check SYNC for bitstream
710 asitErr = asitInputDataProcess(pInp, &autoDetStatus);
712 if(asitErr == ASIT_NO_ERR) {
713 ioDataReadComplete(pInp->hIoData);
715 // Check if SYNC is maintained or lost (stream stops or format changes)
716 if(autoDetStatus.syncState == IODATA_SYNC_NONE) {
717 // SYNC lost: change I/O PHY transfer size to default for auto-detection
718 //asitErr = asitRecfgPhyXfer(pInp, INPUT_FRAME_SIZE_DEF);
719 //if(asitErr != ASIT_NO_ERR) {
720 // return asitErr;
721 //}
723 // Inform decoder to complete the decoding of previous frame - is this good?
724 pInp->sourceSelect = PAF_SOURCE_NONE;
725 pInp->numFrameReceived = 0; // for debugging
726 TRACE_TERSE0("asitDecodeProcessing: SYNC lost.");
728 #ifdef DEBUG_SKIP_DECODING
729 asitErr = ASIT_ERR_DECODE_QUIT;
730 #endif
731 }
732 else {
733 pInp->numFrameReceived += 1; // for debugging
735 // Communicate input stream information to decoder through input
736 // buffer configuration -- this was moved inside decDecodeFsm
737 //asitUpdateInpBufConfig(pAsitCfg->pAstCfg, pInp);
739 // Start next transfer
740 asitPhyTransferStart(pInp);
741 }
743 // Start next transfer
744 //asitPhyTransferStart(pInp);
746 #ifdef DEBUG_SKIP_DECODING
747 return asitErr;
748 #endif
749 }
750 else if(asitErr == ASIT_ERR_INPBUF_UNDERFLOW) {
751 TRACE_TERSE0("asitDecodeProcessing: Input buffer underflows.");
753 // When input buffer underflows, it is not an error but decoding needs
754 // to be skipped as there is not enough data in the buffer.
755 asitPhyTransferStart(pInp);
757 return asitErr;
758 }
759 else {
760 // Inform decoder to complete the decoding of previous frame - is this good?
761 pInp->sourceSelect = PAF_SOURCE_NONE;
762 pInp->numFrameReceived = 0; // for debugging
763 TRACE_TERSE1("asitDecodeProcessing: asitInputDataProcess error: %d", asitErr);
765 #ifdef DEBUG_SKIP_DECODING
766 return ASIT_ERR_DECODE_QUIT;
767 #endif
768 }
769 } /* ASIT_EVTMSK_INPDATA */
770 #ifdef DEBUG_SKIP_DECODING
771 else {
772 TRACE_TERSE0("asitDecodeProcessing: events error.");
773 return ASIT_ERR_EVENTS;
774 }
775 #endif
777 #ifndef DEBUG_SKIP_DECODING
778 // Map ASIT events to decode messages
779 decMsg = asitEventsToDecMsg(asitEvents);
781 // Pass messages (corresponding to events) to decode FSM
782 decErr = decDecodeFsm(pP, pQ, pAsitCfg, pInp->sourceSelect, decMsg);
784 // Mark I/O DATA read complete if decoder indicates decoding is done.
785 if((asitEvents & ASIT_EVTMSK_DECACK)) { // DECACK -> decoding done
786 //ioDataReadComplete(pInp->hIoData);
787 }
789 if(decErr != DEC_NO_ERR) {
790 TRACE_VERBOSE0("TaskAsip: send DEC_EXIT message to slave decoder.");
792 // Send dec exit message to slave decoder
793 status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_EXIT, NULL);
794 if (status != ASP_MSG_NO_ERR)
795 {
796 TRACE_VERBOSE0("TaskAsip: error in sending DEC_EXIT message");
797 SW_BREAKPOINT;
798 }
799 status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_EXIT_DONE, NULL, TRUE);
800 if (status != ASP_MSG_NO_ERR)
801 {
802 TRACE_VERBOSE0("TaskAsip: error in sending DEC_EXIT message");
803 SW_BREAKPOINT;
804 }
806 return ASIT_ERR_DECODE_QUIT; // This is not necessarily an error
807 }
808 else {
809 return ASIT_NO_ERR;
810 }
811 #endif
812 } /* asitDecodeProcessing */
815 /*============================================================================
816 * ASIT Input Data Processing:
817 * - invoke ioDataProcess() to inspect input data for
818 * - initial auto-detection, or
819 * - background scanning for PCM data, or
820 * - SYNC check for bitstream
821 * - return auto-detection status (SYNC detected, SYNC loss, etc)
822 ============================================================================*/
823 Int asitInputDataProcess(PAF_AST_IoInp *pInp, ioDataAutoDetStat_t *pAutoDetStats)
824 {
825 Int ioDataErr, retVal;
826 ioDataCtl_t ioDataCtl;
828 // Perform auto-detection inside I/O DATA component
829 ioDataErr = ioDataProcess(pInp->hIoData);
831 if(ioDataErr == IODATA_NO_ERR) {
832 // Normal operation - check auto-detection status
833 ioDataCtl.code = IODATA_CTL_GET_AUTODET_STATUS;
834 ioDataControl(pInp->hIoData, &ioDataCtl);
836 *pAutoDetStats = ioDataCtl.param.autoDetStats;
838 retVal = ASIT_NO_ERR;
839 }
840 else if(ioDataErr == IODATA_ERR_IOBUF_UNDERFLOW) {
841 // Input buffer underflows - there is no enough data to process.
842 // This is not error and no action is needed.
843 pInp->numUnderflow += 1; // debug
845 retVal = ASIT_ERR_INPBUF_UNDERFLOW;
846 }
847 else {
848 // Something is wrong: print error log and return
849 //printf("IODATA processing error!\n");
850 retVal = ASIT_ERR_INPDATA_PROC;
851 }
853 return retVal;
854 } /* asitInputDataProcess */
856 /*============================================================================
857 * Mapping ASIT Events to Decoding Messages
858 ============================================================================*/
859 UInt asitEventsToDecMsg(UInt asitEvents)
860 {
861 UInt decMsg = 0;
863 if (asitEvents & ASIT_EVTMSK_INPDATA) {
864 // Input data event
865 decMsg |= DEC_MSGMSK_INPDATA;
866 }
868 // temp, simulation
869 //if(asitEvents & ASIT_EVTMSK_INFOACK) {
870 // decMsg |= DEC_MSGMSK_INFOACK;
871 //}
873 // temp, simulation
874 //if(asitEvents & ASIT_EVTMSK_DECACK) {
875 // decMsg |= DEC_MSGMSK_DECACK;
876 //}
878 if (asitEvents & ASIT_EVTMSK_RXACK)
879 {
880 // Receive acknowledge message event
881 decMsg |= DEC_MSGMSK_RXACK;
882 }
884 return decMsg;
885 } /* asitEventsToDecMsg */
887 /*===========================================================================
888 * Initialize I/O components for input processing
889 ============================================================================*/
890 int asitIoCompsInit(PAF_AST_InpBuf * pInpBuf, PAF_AST_IoInp * pInpIo)
891 {
892 ioBuffParams_t ioBuffParams;
893 ioPhyParams_t ioPhyParams;
894 ioDataParam_t ioDataCfg;
895 ioPhyCtl_t ioPhyCtl;
897 if (pInpIo->hMcaspChan != NULL)
898 {
899 //pInpIo->phyXferSize = INPUT_FRAME_SIZE_DEF;
900 pInpIo->phyXferSize = pInpIo->stride * NUM_CYCLE_PER_FRAME_DEF * WORD_SIZE_BITSTREAM;
902 if (pInpIo->firstTimeInit) {
903 TRACE_VERBOSE0("Initialize I/O BUFF and I/O PHY.");
904 ioBuffParams.base = pInpBuf->inpBufConfig.base.pVoid;
905 ioBuffParams.size = pInpBuf->inpBufConfig.allocation / STRIDE_WORST_CASE
906 * STRIDE_WORST_CASE;
907 ioBuffParams.sync = IOBUFF_WRITE_SYNC;
908 ioBuffParams.nominalDelay = INPUT_FRAME_SIZE_DEF;
909 if (ioBuffInit(pInpIo->hIoBuff, &ioBuffParams) != IOBUFF_NOERR) {
910 return (ASIT_ERR_IOBUFF_INIT); // to remove magic number
911 }
913 ioPhyParams.ioBuffHandle = pInpIo->hIoBuff;
914 ioPhyParams.xferFrameSize = pInpIo->phyXferSize;
915 ioPhyParams.mcaspChanHandle = pInpIo->hMcaspChan;
916 ioPhyParams.ioBuffOp = IOPHY_IOBUFFOP_WRITE;
917 if (ioPhyInit(pInpIo->hIoPhy, &ioPhyParams) != IOPHY_NOERR) {
918 return (ASIT_ERR_IOPYH_INIT); // to remove magic number
919 }
921 pInpIo->numPrimeXfers = NUM_PRIME_XFERS;
922 }
924 /* Reinitialize I/O DATA every time when ASIT restarts */
925 TRACE_VERBOSE0("Initialize I/O DATA.");
926 ioDataCfg.ioBuffHandle = pInpIo->hIoBuff;
927 ioDataCfg.unknownSourceTimeOut = pInpBuf->inpBufConfig.pBufStatus->unknownTimeout;
928 ioDataCfg.frameLengthsIEC = (uint_least16_t *)&iecFrameLength[0];
929 ioDataCfg.frameLengthPCM = pInpIo->stride * NUM_CYCLE_PER_FRAME_DEF;
930 ioDataCfg.frameLengthDef = pInpIo->stride * NUM_CYCLE_PER_FRAME_DEF;
931 ioDataCfg.ibMode = pInpBuf->inpBufConfig.pBufStatus->mode;
932 ioDataCfg.zeroRunRestart = pInpBuf->inpBufConfig.pBufStatus->zeroRunRestart;
933 ioDataCfg.zeroRunTrigger = pInpBuf->inpBufConfig.pBufStatus->zeroRunTrigger;
935 if (ioDataInit(pInpIo->hIoData, &ioDataCfg) != IODATA_NO_ERR) {
936 return (ASIT_ERR_IODATA_INIT); // to remove magic number
937 }
939 if (pInpIo->firstTimeInit) {
940 /* Initialize I/O BUFF and I/O PHY only when input interface changes. */
941 TRACE_VERBOSE0("Prime I/O PHY.");
943 // Start I/O physical layer by priming McASP LLD for input
944 asitIoPhyPrime(pInpIo);
946 pInpIo->firstTimeInit = FALSE;
947 }
948 else {
949 // Reconfigure I/O PHY transfer size
950 ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
951 ioPhyCtl.params.xferFrameSize = pInpIo->phyXferSize;
952 ioPhyControl(pInpIo->hIoPhy, &ioPhyCtl);
953 #if 0
954 // If previous stream before reset was PCM, reconfigure McASP LLD to receive 16-bit packed bits
955 if (!pInpIo->swapData) {
956 Int mcaspErr;
957 mcaspErr = mcaspRecfgWordWidth(pInpIo->hMcaspChan, Mcasp_WordLength_16);
958 if(mcaspErr != Aud_EOK) {
959 return ASIT_ERR_MCASP_CFG;
960 }
962 // Start swapping data
963 pInpIo->swapData = TRUE;
964 TRACE_VERBOSE0("Reconfigure McASP word length and start swapping data.");
965 }
966 #endif
967 // Start PHY transfer
968 TRACE_VERBOSE0("Start I/O PHY transfer.");
969 asitPhyTransferStart(pInpIo);
970 }
971 }
973 return 0;
974 } /* asitIoCompsInit */
976 /*======================================================================================
977 * This function initializes ASIT processing
978 *====================================================================================*/
979 void asitProcInit(PAF_AST_IoInp *pInp, asipDecProc_t *pDec)
980 {
981 // pInp->swapData = TRUE;
982 pInp->pcmSwitchHangOver = INPUT_SWITCH_HANGOVER;
983 pDec->initDone = FALSE;
984 pInp->numFrameReceived = 0;
985 }
987 /*======================================================================================
988 * I/O physical layer prime operation required by McASP LLD
989 *====================================================================================*/
990 void asitIoPhyPrime(PAF_AST_IoInp *pInp)
991 {
992 Int32 count;
994 for(count = 0; count < pInp->numPrimeXfers; count++)
995 {
996 ioPhyXferSubmit(pInp->hIoPhy);
997 #ifdef ASIP_DEBUG
998 //pInp->numXferStart++;
999 #endif
1000 }
1001 } /* asitIoPhyPrime */
1004 /*======================================================================================
1005 * This function marks the I/O PHY transfer as complete
1006 *====================================================================================*/
1007 void asitPhyTransferComplete(PAF_AST_IoInp * pInpIo)
1008 {
1009 // Mark underlining I/O BUFF write complete and swap data if needed
1010 ioPhyXferComplete(pInpIo->hIoPhy, pInpIo->swapData);
1011 } /* asitPhyTransferComplete */
1013 #if 0
1014 Int asitRecfgPhyXfer(PAF_AST_IoInp *pInp, size_t xferSize)
1015 {
1016 ioPhyCtl_t ioPhyCtl;
1017 Int mcaspErr;
1019 ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
1020 ioPhyCtl.params.xferFrameSize = xferSize;
1021 ioPhyControl(pInp->hIoPhy, &ioPhyCtl);
1023 pInp->phyXferSize = ioPhyCtl.params.xferFrameSize;
1025 if(!pInp->swapData) {
1026 // If it was PCM, reconfigure McASP LLD to receive 16-bit packed bits
1027 mcaspErr = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_16);
1028 if(mcaspErr != Aud_EOK) {
1029 return ASIT_ERR_MCASP_CFG;
1030 }
1032 // Start swapping data
1033 pInp->swapData = TRUE;
1034 }
1036 return ASIT_NO_ERR;
1038 } /* asitRecfgPhyXfer */
1039 #endif
1041 /*======================================================================================
1042 * McASP LLD call back function
1043 *====================================================================================*/
1044 void asipMcaspCallback(void* arg, MCASP_Packet *mcasp_packet)
1045 {
1046 /* post semaphore */
1047 if(mcasp_packet->arg == IOPHY_XFER_FINAL) {
1048 //Semaphore_post(asipSemRx);
1049 Event_post(gAsitEvtHandle, ASIT_EVTMSK_INPDATA);
1050 } else {
1051 ; // intermediate packet due to buffer wrapping around
1052 }
1053 }
1055 /*======================================================================================
1056 * This function checks if McASP Rx for input overruns
1057 *====================================================================================*/
1058 int asipCheckMcaspRxOverrun(Ptr mcaspChanHandle)
1059 {
1060 Mcasp_errCbStatus mcaspErrStat;
1062 mcaspControlChan(mcaspChanHandle, Mcasp_IOCTL_CHAN_QUERY_ERROR_STATS, &mcaspErrStat);
1064 return (mcaspErrStat.isRcvOvrRunOrTxUndRunErr);
1065 }
1067 #if 0
1068 /*======================================================================================
1069 * This function restarts McASP LLD channel for input
1070 *====================================================================================*/
1071 void asipMcaspRxRestart(PAF_AST_IoInp *pInpIo)
1072 {
1073 mcaspRxReset();
1074 mcaspRxCreate();
1075 }
1076 #endif
1078 /*======================================================================================
1079 * This function starts an I/O PHY transfer
1080 *====================================================================================*/
1081 void asitPhyTransferStart(PAF_AST_IoInp *pInpIo)
1082 {
1083 Int ioPhyErr;
1085 if(asipCheckMcaspRxOverrun(pInpIo->hMcaspChan)) {
1086 #ifdef ASIP_DEBUG
1087 pInpIo->numInputOverrun++;
1088 #endif
1089 //asipMcaspRxRestart(pInpIo);
1090 System_abort("\nMcASP for input overruns! %d!\n");
1091 }
1092 else {
1093 ioPhyErr = ioPhyXferSubmit(pInpIo->hIoPhy);
1094 //if(ioPhyXferSubmit(pInpIo->hIoPhy)==IOPHY_ERR_BUFF_OVERFLOW) {
1095 if(ioPhyErr!=IOPHY_NOERR){
1096 printf("\n I/O PHY ioPhyXferSubmit fails with error %d!\n", ioPhyErr);
1097 // Input buffer overflows!
1098 //printf("\nInput buffer overflows!\n");
1099 exit(0);
1100 }
1101 else {
1102 // Input buffer operates normally
1103 ;
1104 }
1105 #ifdef ASIP_DEBUG
1106 //pInpIo->numXferStart++;
1107 #endif
1108 }
1109 }
1111 Int d10Initialized = 0;
1112 //extern Aud_STATUS mcaspAudioConfig(void);
1113 //extern void McaspDevice_init(void);
1115 /*======================================================================================
1116 * This function initializes HW interface and selects the right device for input
1117 *====================================================================================*/
1118 Int asitSelectDevices(
1119 const PAF_ASIT_Patchs *pQ,
1120 PAF_AST_Config *pAstCfg,
1121 PAF_AST_IoInp *pInp
1122 )
1123 {
1124 Aud_STATUS status;
1125 const PAF_SIO_Params *pInPrms;
1126 mcaspLLDconfig *pLldCfg;
1127 mcaspLLDconfig *pReqLldCfg;
1128 Ptr mcaspChanHandle;
1129 Int zMD;
1130 Int interface;
1131 const PAF_SIO_Params *pD10Params;
1133 zMD = pAstCfg->masterDec;
1135 interface = pAstCfg->xInp[zMD].inpBufStatus.sioSelect; // obtain SIO select for input
1137 if (interface >= 0)
1138 {
1139 // Positive value for interface: new Input SIO update request has been received via alpha command.
1140 // Negative value for interface: no new Input SIO update request has been received,
1141 // previous requests have been processed.
1143 // check for valid index into device array
1144 if (interface >= pQ->devinp->n) // DEVINP_N
1145 {
1146 interface = 0; // treat as device InNone
1147 }
1149 //
1150 // Deactivate currently active interface
1151 //
1152 if (pInp->hMcaspChan != NULL) // non-NULL McASP LLD channel handle indicates there's an active interface
1153 {
1154 // Delete McASP LLD channel
1155 status = mcaspDeleteChan(pInp->hMcaspChan);
1156 if (status != Aud_EOK)
1157 {
1158 Log_info0("asitSelectDevices(): McASP channel deletion failed!\n");
1159 return ASIP_ERR_MCASP_CFG;
1160 }
1162 pInp->hMcaspChan = NULL; // reset active McASP LLD handle
1163 if (pInp->pRxParams != NULL) // sanity check, pInp->pRxParams should be non NULL if pInp->hMcaspChan is non NULL
1164 {
1165 pInPrms = (const PAF_SIO_Params *)pInp->pRxParams;
1166 pLldCfg = (mcaspLLDconfig *)pInPrms->sio.pConfig; // get pointer to active McASP LLD configuration
1167 pLldCfg->hMcaspChan = NULL; // reset McASP LLD handle for active McASP LLD configuration
1168 pInp->pRxParams = NULL; // reset pointer to active D10 parameters
1169 }
1170 else
1171 {
1172 // This is a programming error
1173 SW_BREAKPOINT; // debug
1174 }
1175 }
1177 //
1178 // Activate requested interface
1179 //
1180 pD10Params = (const PAF_SIO_Params *)pQ->devinp->x[interface]; // get D10 parameters for selected interface
1181 if (pD10Params != NULL)
1182 {
1183 //
1184 // Requested device is other than InNone
1185 //
1187 if (!d10Initialized)
1188 {
1189 // FL: probably no harm in calling this for every new i/f request.
1190 // However, it can probably be moved to main() or sys init task.
1191 // Initialize McASP HW details
1192 //McaspDevice_init();
1194 // Initialize Tx clock mux
1195 //D10_init((void *)pD10Params);
1196 D10_initClkMux((void *)pD10Params);
1198 d10Initialized=1;
1199 }
1201 //if (!d10Initialized)
1202 //{
1203 // d10Initialized=1; // global flag indicating D10 init completed
1204 //}
1206 pReqLldCfg = (mcaspLLDconfig *)pD10Params->sio.pConfig;
1207 if (pReqLldCfg->hMcaspChan == NULL)
1208 {
1209 // Create McASP LLD channel
1210 mcaspChanHandle = NULL;
1211 status = mcasplldChanCreate(pReqLldCfg, &mcaspChanHandle);
1212 if (status != Aud_EOK)
1213 {
1214 Log_info0("asitSelectDevices(): McASP channel creation failed!\n");
1215 return ASIP_ERR_MCASP_CFG;
1216 }
1218 pReqLldCfg->hMcaspChan = mcaspChanHandle; // set McASP LLD handle for requested McASP LLD configuration
1219 pInp->pRxParams = (const void *)pD10Params; // set pointer to active D10 parameters
1220 pInp->hMcaspChan = pReqLldCfg->hMcaspChan; // set active McASP LLD handle
1222 // configure stride according to selected McASP LLD configuration
1223 pInp->stride = pReqLldCfg->mcaspChanParams->noOfSerRequested *
1224 pReqLldCfg->mcaspChanParams->noOfChannels;
1226 pInp->firstTimeInit = TRUE; // set flag for IO Phy & Buff initialization
1227 }
1228 }
1229 else
1230 {
1231 //
1232 // Requested device is InNone
1233 //
1234 pInp->hMcaspChan = NULL; // reset active McASP LLD handle
1235 pInp->pRxParams = NULL; // reset pointer to active D10 parameters
1236 }
1238 // indicate SIO update request processed
1239 pAstCfg->xInp[zMD].inpBufStatus.sioSelect = interface | 0x80;
1240 }
1242 if (pInp->hMcaspChan != NULL) // non NULL indicates there's an active interface
1243 {
1244 if (pInp->pRxParams != NULL) // sanity check, this should be non NULL if pInp->hMcaspChan is non NULL
1245 {
1246 pInPrms = (const PAF_SIO_Params *)pInp->pRxParams;
1247 pLldCfg = (mcaspLLDconfig *)pInPrms->sio.pConfig; // get currently active McASP LLD configuration
1248 if (pLldCfg != NULL) // sanity check, this should be non NULL if pInp->hMcaspChan is non NULL
1249 {
1250 // Configure McASP to receive 16/32-bit data according to default configuration
1251 mcaspRecfgWordWidth(pInp->hMcaspChan, pLldCfg->mcaspChanParams->wordWidth);
1253 // Set flag to swap HDMI data if it is 4xI2S and word length is 16
1254 if ((pLldCfg->mcaspChanParams->wordWidth == Mcasp_WordLength_16) &&
1255 (pLldCfg->mcaspChanParams->noOfSerRequested == 4))
1256 {
1257 pInp->swapData = TRUE;
1258 }
1259 else
1260 {
1261 pInp->swapData = FALSE;
1262 }
1263 }
1264 else
1265 {
1266 // This is a programming error
1267 SW_BREAKPOINT; // debug
1268 }
1270 }
1271 else
1272 {
1273 // This is a programming error
1274 SW_BREAKPOINT; // debug
1275 }
1276 }
1278 return ASIT_NO_ERR;
1279 } /* asitSelectDevices */
1281 /*======================================================================================
1282 * This function updates input status
1283 *====================================================================================*/
1284 Int asitUpdateInputStatus(const void *pRxParams, PAF_InpBufStatus *pStatus,
1285 PAF_InpBufConfig *pInpBuf)
1286 {
1287 Int asipErrno;
1289 PAF_SIO_InputStatus inputStatus;
1291 // initialize all values to unknown so that device specific
1292 // driver layer need only fill in those entries that it is aware of.
1293 // This allows extensibility of the structure without requiring users
1294 // to re-code.
1295 inputStatus.lock = 0;
1296 inputStatus.sampleRateData = PAF_SAMPLERATE_UNKNOWN;
1297 inputStatus.sampleRateMeasured = PAF_SAMPLERATE_UNKNOWN;
1298 inputStatus.nonaudio = PAF_IEC_AUDIOMODE_UNKNOWN;
1299 inputStatus.emphasis = PAF_IEC_PREEMPHASIS_UNKNOWN;
1301 //more configuration is needed to abstract out D10
1302 asipErrno = D10_RxControl(pRxParams,
1303 (Uns)PAF_SIO_CONTROL_GET_INPUT_STATUS,
1304 (Arg) &inputStatus);
1305 if (asipErrno) {
1306 return asipErrno;
1307 }
1308 pStatus->sampleRateData = inputStatus.sampleRateData;
1309 pStatus->sampleRateMeasured = inputStatus.sampleRateMeasured;
1310 pStatus->nonaudio = inputStatus.nonaudio;
1311 pStatus->emphasisData = inputStatus.emphasis;
1313 // if MSB of override clear then use as reported lock
1314 // if = 0x80 then use default [0x81]
1315 // if = 0x81 then use measured (from device)
1316 // others not defined or implemented
1317 if ((pStatus->lockOverride & (XDAS_Int8)0x80) == 0)
1318 pStatus->lock = pStatus->lockOverride;
1319 else if (pStatus->lockOverride == (XDAS_Int8)0x80)
1320 pStatus->lock = inputStatus.lock;
1321 else if (pStatus->lockOverride == (XDAS_Int8)0x81)
1322 pStatus->lock = inputStatus.lock;
1324 // if MSB of override clear then use it as sample rate for system,
1325 // if = 0x80 then use default [0x82]
1326 // if = 0x81 then use data
1327 // if = 0x82 then use measured
1328 // others not defined or implemented
1329 if ((pStatus->sampleRateOverride & (XDAS_Int8)0x80) == 0)
1330 pStatus->sampleRateStatus = pStatus->sampleRateOverride;
1331 else if (pStatus->sampleRateOverride == (XDAS_Int8)0x80)
1332 pStatus->sampleRateStatus = pStatus->sampleRateMeasured;
1333 else if (pStatus->sampleRateOverride == (XDAS_Int8)0x81)
1334 pStatus->sampleRateStatus = pStatus->sampleRateData;
1335 else if (pStatus->sampleRateOverride == (XDAS_Int8)0x82)
1336 pStatus->sampleRateStatus = pStatus->sampleRateMeasured;
1338 // Update emphasis status:
1339 if ((pStatus->emphasisOverride & (XDAS_Int8)0x80) == 0) {
1340 if (pStatus->emphasisData == PAF_IEC_PREEMPHASIS_YES)
1341 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_YES;
1342 else
1343 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_NO;
1344 }
1345 else if (pStatus->emphasisOverride ==
1346 (XDAS_Int8 )(0x80+PAF_IEC_PREEMPHASIS_YES))
1347 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_YES;
1348 else /* IBEmphasisOverrideNo or other */
1349 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_NO;
1351 // Update precision control
1352 pInpBuf->precision = pStatus->precisionInput =
1353 pStatus->precisionOverride < 0
1354 ? pStatus->precisionDefault
1355 : pStatus->precisionOverride > 0
1356 ? pStatus->precisionOverride
1357 : pStatus->precisionDetect > 0
1358 ? pStatus->precisionDetect
1359 : pStatus->precisionDefault;
1361 return 0;
1362 }
1365 /*==============================================================================
1366 * This function updates input buffer config based on frame information provided
1367 * by I/O DATA.
1368 ==============================================================================*/
1369 void asitUpdateInpBufConfig(PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp)
1370 {
1371 PAF_InpBufConfig *pBufConfig;
1372 ioDataCtl_t ioDataCtl;
1374 /* Get information for reading input data */
1375 ioDataCtl.code = IODATA_CTL_GET_INPBUFFINFO;
1376 ioDataControl(pInp->hIoData, &ioDataCtl);
1378 if(ioDataCtl.param.dataReadInfo.frameSize != pInp->phyXferSize) {
1379 // Fatal error!
1380 TRACE_VERBOSE0("TaskAsip: error in updating I/O");
1381 SW_BREAKPOINT;
1382 }
1384 pBufConfig = &(pAstCfg->xInp[pAstCfg->masterDec].inpBufConfig);
1386 //JXTODO: do we need to gate here?
1387 //key = GateMP_enter(gateHandle);
1389 pBufConfig->base.pVoid = ioDataCtl.param.dataReadInfo.buffBase;
1390 pBufConfig->sizeofBuffer = ioDataCtl.param.dataReadInfo.buffSize;
1391 pBufConfig->pntr.pSmInt = ioDataCtl.param.dataReadInfo.startAddress;
1393 // Leave the gate
1394 //GateMP_leave(gateHandle, key);
1396 TRACE_TERSE2("Frame start address: 0x%x., preamble: 0x%x",
1397 (UInt)ioDataCtl.param.dataReadInfo.startAddress,
1398 *(UInt *)ioDataCtl.param.dataReadInfo.startAddress);
1399 }
1401 /*==============================================================================
1402 * Decide source after SYNC is found, i.e. either bitstream preamble is detected
1403 * or it times out to PCM.
1404 ==============================================================================*/
1405 Int asitDecideSource(PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp,
1406 ioDataAutoDetStat_t *autoDetStatus)
1407 {
1408 Int sourceConfig, sourceSelect, sourceProgram;
1409 Int zMD;
1410 char asipMsgBuf[ASP_MSG_BUF_LEN];
1411 Int status;
1413 // Get the configured source
1414 zMD = pAstCfg->masterDec;
1415 sourceConfig = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
1416 GATEMP_INDEX_DEC);
1418 if(autoDetStatus->syncState == IODATA_SYNC_PCM) {
1419 if (sourceConfig == PAF_SOURCE_DSD1 || sourceConfig == PAF_SOURCE_DSD2 ||
1420 sourceConfig == PAF_SOURCE_DSD3) {
1421 sourceProgram = sourceConfig;
1422 }
1423 else {
1424 sourceProgram = PAF_SOURCE_PCM;
1425 }
1426 }
1428 if(autoDetStatus->syncState == IODATA_SYNC_BITSTREAM) {
1429 uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
1430 sourceProgram = IECpafSource[pc];
1431 }
1433 // write the decided source program to memory
1434 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram), sourceProgram,
1435 GATEMP_INDEX_DEC);
1437 // now that we have some input classification, and possibly an outstanding
1438 // input frame, we determine whether or not to call decodeProcessing and with
1439 // what decAlg.
1440 sourceSelect = PAF_SOURCE_NONE;
1442 switch (sourceConfig)
1443 {
1444 // If autodetecting, decoding everything, and input is something
1445 // (i.e. bitstream or PCM) then decode.
1446 case PAF_SOURCE_AUTO:
1447 if (sourceProgram >= PAF_SOURCE_PCM) {
1448 sourceSelect = sourceProgram; // use whatever from autodet
1449 }
1450 break;
1452 // If autodetecting, decoding only PCM, and input is PCM then decode.
1453 case PAF_SOURCE_PCMAUTO:
1454 if (sourceProgram == PAF_SOURCE_PCM) {
1455 // only expect autodet to give PAF_SOURCE_PCM, otherwise set to NONE
1456 sourceSelect = sourceProgram;
1457 }
1458 break;
1460 // If autodetecting, decoding only bitstreams, and input is a bitstream then decode.
1461 case PAF_SOURCE_BITSTREAM:
1462 if (sourceProgram >= PAF_SOURCE_AC3) {
1463 sourceSelect = sourceProgram;
1464 }
1465 break;
1467 // If autodetecting, decoding only DTS, and input is DTS then decode.
1468 case PAF_SOURCE_DTSALL:
1469 switch (sourceProgram)
1470 {
1471 case PAF_SOURCE_DTS11:
1472 case PAF_SOURCE_DTS12:
1473 case PAF_SOURCE_DTS13:
1474 case PAF_SOURCE_DTS14:
1475 case PAF_SOURCE_DTS16:
1476 case PAF_SOURCE_DTSHD:
1477 sourceSelect = sourceProgram;
1478 break;
1479 }
1480 break;
1482 // All others, e.g., force modes, fall through to here.
1483 // If user made specific selection then program must match select.
1484 // (NB: this compare relies on ordering of PAF_SOURCE)
1485 default:
1486 sourceSelect = sourceConfig;
1487 if ((sourceSelect >= PAF_SOURCE_PCM) && (sourceSelect <= PAF_SOURCE_N)) {
1488 if (sourceProgram != sourceSelect) {
1489 sourceSelect = PAF_SOURCE_NONE;
1490 }
1491 }
1492 break;
1493 }
1495 // if we didn't find any matches then skip
1496 if (sourceSelect == PAF_SOURCE_NONE) {
1497 TRACE_VERBOSE0("TaskAsip: no matching source type, continue");
1498 return ASIT_ERR_NO_MATCHING_SOURCE;
1499 }
1501 #ifndef DEBUG_SKIP_DECODING
1502 // send source select message to slave
1503 *(Int32 *)&asipMsgBuf[0] = sourceSelect;
1504 status = AspMsgSnd(gPAF_ASIT_config.hAspMsgMaster, ASP_SLAVE_DEC_SOURCE_SELECT, asipMsgBuf);
1505 if (status != ASP_MSG_NO_ERR)
1506 {
1507 TRACE_VERBOSE0("TaskAsip: error in sending SOURCE_SELECT message");
1508 SW_BREAKPOINT;
1509 }
1510 status = AspMsgRcvAck(gPAF_ASIT_config.hAspMsgMaster, ASP_MASTER_DEC_SOURCE_SELECT_DONE, NULL, TRUE);
1511 if (status != ASP_MSG_NO_ERR)
1512 {
1513 TRACE_VERBOSE0("TaskAsip: error in receiving SOURCE_SELECT ack message");
1514 SW_BREAKPOINT;
1515 }
1516 #endif
1518 pInp->sourceSelect = sourceSelect;
1519 pInp->sourceProgram = sourceProgram;
1521 return ASIT_NO_ERR;
1522 } /* asitDecideSource */
1524 /*==============================================================================
1525 * After SYNC is found, i.e. either bitstream preamble is detected or it times
1526 * out to PCM, update input buffer config and I/o components accordingly.
1527 ==============================================================================*/
1528 Int asitUpdateIoComps(const PAF_ASIT_Params *pP, PAF_AST_Config *pAstCfg,
1529 PAF_AST_IoInp *pInp, ioDataAutoDetStat_t *autoDetStatus)
1530 {
1531 Int sourceConfig;
1532 Int zMD, deliverZeros;
1533 int ioFrameLength, decFrameLength;
1534 PAF_InpBufConfig *pBufConfig;
1535 ioPhyCtl_t ioPhyCtl;
1536 ioDataCtl_t ioDataCtl;
1538 zMD = pAstCfg->masterDec;
1539 pBufConfig = &pAstCfg->xInp[zMD].inpBufConfig;
1541 // Compute decoder frame length based on source selection
1542 decFrameLength = getFrameLengthSourceSel(pP, pInp->sourceSelect);
1544 pAstCfg->xDec[zMD].decodeControl.frameLength = decFrameLength;
1545 pAstCfg->xDec[zMD].decodeInStruct.sampleCount = decFrameLength;
1546 pAstCfg->xDec[zMD].decodeControl.sampleRate = PAF_SAMPLERATE_UNKNOWN;
1548 // Decide frame length for I/O DATA and I/O PHY
1549 if(autoDetStatus->syncState == IODATA_SYNC_PCM) {
1550 // For PCM, I/O frame length is decode frame length multiplied by stride
1551 ioFrameLength = decFrameLength * pInp->stride;
1553 pBufConfig->sizeofElement = WORD_SIZE_PCM;
1554 pBufConfig->frameLength = pBufConfig->lengthofData = ioFrameLength;
1556 // Configure I/O DATA PCM frame length
1557 ioDataCtl.code = IODATA_CTL_SET_PCM_FRAME_LENGTH;
1558 ioDataCtl.param.frameLengthPcm = ioFrameLength;
1559 ioDataControl(pInp->hIoData, &ioDataCtl);
1561 // Change I/O PHY transfer size to PCM frame size
1562 pInp->phyXferSize = ioFrameLength*(WORD_SIZE_PCM);
1564 // Adjust I/O BUFF delay and read pointer - to make sure read pointers always point to
1565 // PCM data from 1st I2S (out of 4 for HDMI 4xI2S)
1566 // Adjust delay and don't mark input buffer as read complete
1567 //ioBuffAdjustDelay(pInp->hIoBuff, pInp->phyXferSize);
1569 // Stop swapping data
1570 //pInp->swapData = FALSE;
1571 }
1572 else {
1573 // For bitstream, I/O frame length is the frame length of the bitstream
1574 uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
1575 ioFrameLength = iecFrameLength[pc];
1577 /*
1578 if( (pc == 0x11) && (DTSHDSubType == 3)
1579 && (PAF_ASP_sampleRateHzTable[pBufConfig->pBufStatus->sampleRateStatus][PAF_SAMPLERATEHZ_STD] <=48000.0))
1580 pDevExt->sourceProgram = PAF_SOURCE_DXP; // LBR is 23
1582 if (pc == 1)
1583 pDevExt->elementSize = 4288;
1584 else if (pc == 0x11) {
1585 pDevExt->frameLength = (pDevExt->pIECFrameLength[pc] << DTSHDSubType);
1586 pDevExt->lengthofData = pDevExt->frameLength;
1587 }
1588 */
1590 pBufConfig->sizeofElement = WORD_SIZE_BITSTREAM;
1591 pBufConfig->frameLength = ioFrameLength;
1592 pBufConfig->lengthofData = ioFrameLength - IEC_HEADER_LENGTH;
1594 // Change I/O PHY transfer size to bitstream frame size
1595 pInp->phyXferSize = ioFrameLength*WORD_SIZE_BITSTREAM;
1596 }
1598 pBufConfig->stride = pInp->stride; // common for PCM and bitstream
1600 // Configure I/O PHY transfer size
1601 ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
1602 ioPhyCtl.params.xferFrameSize = pInp->phyXferSize;
1603 ioPhyControl(pInp->hIoPhy, &ioPhyCtl);
1605 // Decide if zeros should be delivered based on the configured source
1606 sourceConfig = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
1607 GATEMP_INDEX_DEC);
1609 if(autoDetStatus->syncState == IODATA_SYNC_PCM) {
1610 // Bitstream preamble is not found and it times out -> assume this is PCM
1611 deliverZeros = autoDetStatus->deliverZeros;
1612 if (sourceConfig == PAF_SOURCE_PCM || sourceConfig == PAF_SOURCE_DSD1 ||
1613 sourceConfig == PAF_SOURCE_DSD2 || sourceConfig == PAF_SOURCE_DSD3) {
1614 // set to one -- ensures that PCM decode calls made before data is
1615 // available will result in zero output.
1616 // (mostly needed for PA15 since, currently, all other frameworks
1617 // require a frame of data before the first decode call.
1618 deliverZeros = TRUE; // override deliverZeros returned by ioDataControl
1619 }
1621 // update input buffer config structure
1622 pBufConfig->deliverZeros = deliverZeros;
1623 }
1625 //JXTODO: decide what to do with hRxSio
1626 //temporary - does ARM use hRxSio or just check if it is not NULL?
1627 pAstCfg->xInp[zMD].hRxSio = pInp->hIoData;
1628 pAstCfg->xInp[zMD].pInpBuf = &(pAstCfg->xInp[zMD].inpBufConfig);
1630 return ASIT_NO_ERR;
1631 } /* asitUpdateIoComps */
1633 #if 0
1634 #ifndef IO_LOOPBACK_TEST
1635 #if OUTPUT_FRAME_LENGTH == INPUT_FRAME_LENGTH
1636 U8 pcmbuf[OUTPUT_FRAME_SIZE];
1637 #else
1638 #error Input frame length is not equal to output frame length!
1639 #endif
1641 Int rxDecodePcm(PAF_AST_IoInp *pInp)
1642 {
1643 ioDataCtl_t ioDataCtl;
1644 void *buffBase;
1645 void *dataStartAddress;
1646 size_t buffSize, frameSize, size1, size2;
1648 /* Get information for reading input data */
1649 ioDataCtl.code = IODATA_CTL_GET_INPBUFFINFO;
1650 ioDataControl(pInp->hIoData, &ioDataCtl);
1652 buffBase = ioDataCtl.param.dataReadInfo.buffBase;
1653 buffSize = ioDataCtl.param.dataReadInfo.buffSize;
1654 dataStartAddress = ioDataCtl.param.dataReadInfo.startAddress;
1655 frameSize = ioDataCtl.param.dataReadInfo.frameSize;
1657 // Copy PCM data to output buffer
1658 if(((size_t)dataStartAddress+frameSize) <= ((size_t)buffBase+buffSize)) {
1659 // Input buffer doesn't wrap around
1660 Cache_inv(dataStartAddress, frameSize, Cache_Type_ALL, TRUE);
1661 memcpy((void *)&pcmbuf[0], dataStartAddress, frameSize);
1662 }
1663 else {
1664 // Input buffer wraps around
1665 size1 = (size_t)buffBase + buffSize - (size_t)dataStartAddress;
1666 size2 = frameSize - size1;
1667 Cache_inv(dataStartAddress, size1, Cache_Type_ALL, TRUE);
1668 memcpy((void *)&pcmbuf[0], dataStartAddress, size1);
1670 Cache_inv(buffBase, size2, Cache_Type_ALL, TRUE);
1671 memcpy((void *)&pcmbuf[size1], buffBase, size2);
1672 }
1675 return ASIT_NO_ERR;
1676 }
1679 Int rxDecodePlayZero(PAF_AST_IoInp *pInp)
1680 {
1681 return ASIT_NO_ERR;
1682 }
1683 #endif
1685 #endif
1687 Int asitEvtErrCheck(UInt actualEvents, UInt expectedEvents)
1688 {
1689 TRACE_VERBOSE2("ASIT events error: actual events are: %d, expected events are: %d.",
1690 actualEvents, expectedEvents);
1692 return ASIT_ERR_EVENTS;
1693 }
1695 void asitErrorHandling(PAF_ASIT_Config *pAsitCfg, Int asitErr)
1696 {
1697 //UInt events;
1699 if(asitErr == ASIT_ERR_INPBUF_UNDERFLOW) {
1700 TRACE_VERBOSE0("ASIT error handling: input buffer underflows. No actions needed.");
1701 }
1703 if(asitErr == ASIT_ERR_DECODE_QUIT) {
1704 TRACE_VERBOSE0("ASIT error handling: DECODE_QUIT - clear INPDATA event.");
1705 #if 0
1706 // Pend on INPTDATA event that should have been posted before decoding quits.
1707 events = Event_pend(asitEvent, ASIT_EVTMSK_NONE, ASIT_EVTMSK_INPDATA,
1708 BIOS_WAIT_FOREVER);
1710 // Marks I/O PHY transfer and I/O BUFF write complete
1711 asitPhyTransferComplete(&pAsitCfg->pIoInp[0]);
1713 // Keep I/O BUFF read pointers going
1714 asitBypassIoData(&pAsitCfg->pIoInp[0]);
1715 #endif
1716 pAsitCfg->pIoInp[0].asipState = ASIT_RESET;
1717 pAsitCfg->pIoInp[0].numAsitRestart++;
1718 TRACE_VERBOSE0("ASIT error handling finished. Go to state ASIT_RESET.");
1719 }
1721 if(asitErr == ASIT_ERR_EVENTS) {
1722 pAsitCfg->pIoInp[0].asipState = ASIT_RESET;
1723 pAsitCfg->pIoInp[0].numAsitRestart++;
1724 TRACE_VERBOSE0("ASIT error handling: events error. Go to state ASIT_RESET.");
1725 }
1727 return;
1728 } /* asitErrorHandling */
1731 //////////////////////////////////////////////////////////////////////////////
1732 void asitPostInfoEvent()
1733 {
1734 Event_post(gAsitEvtHandle, ASIT_EVTMSK_INFOACK);
1735 }
1737 void asitPostDecEvent()
1738 {
1739 Event_post(gAsitEvtHandle, ASIT_EVTMSK_DECACK);
1740 }
1741 //////////////////////////////////////////////////////////////////////////////
1743 /* Nothing past this line */