84d525c83631c5869794344ccac9edb3121db9df
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);
309 if(asitErr == ASIT_AUTODET_TIME_OUT) {
310 // Should restart if new interface is selected.
311 TRACE_VERBOSE0("TaskAsip: auto-detection time out.");
312 }
313 }
314 else {
315 //Error checking & debug
316 asitErr = asitEvtErrCheck(events, ASIT_EVTMSK_INPDATA);
317 }
319 break;
321 case ASIT_PCM_TRANSITION:
322 // Source is PCM - transition to PCM decoding
323 if(events == ASIT_EVTMSK_INPDATA) {
324 // Only this event is expected. If any other event, it's error.
325 // Input data is ready - transition to PCM decoding
326 // New state will be decided inside the function
327 asitErr = asitPcmTransition(pAsitCfg);
328 }
329 else {
330 //Error checking & debug
331 asitErr = asitEvtErrCheck(events, ASIT_EVTMSK_INPDATA);
332 }
333 break;
335 case ASIT_DECODE_PROCESSING:
336 if(events & ASIT_DEC_EVENTS) {
338 #if 1 // debug
339 if (events & ASIT_EVTMSK_INPDATA)
340 {
341 // shows timing of Input (Rx McASP EDMA)
342 // ADC B5
343 {
344 static Uint8 toggleState = 0;
345 if (toggleState == 0)
346 GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99);
347 else
348 GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
349 toggleState = ~(toggleState);
350 }
351 }
352 #endif
354 // Decode processing for either PCM or bitstream
355 // New state will be decided inside the function
356 asitErr = asitDecodeProcessing(pP, pQ, pAsitCfg, events);
357 }
358 else {
359 //Error checking & debug
360 asitErr = asitEvtErrCheck(events, ASIT_DEC_EVENTS);
361 }
362 break;
364 default:
365 break;
366 }
368 if(asitErr) {
369 asitErrorHandling(pAsitCfg, asitErr);
371 if(pInp->asipState == ASIT_RESET) {
372 eventsOn = FALSE;
373 }
375 asitErr = ASIT_NO_ERR;
376 }
378 } // for (;;)
380 } /* taskAsipFxn */
383 /*===========================================================================
384 * ASIT Processing Preparation
385 * Output:
386 * - return TRUE (input is ready) or FALSE (input is not ready)
387 * - *asipErrno Error number
388 ============================================================================*/
389 Int asitPrepareProcessing(const PAF_ASIT_Params *pP,
390 const PAF_ASIT_Patchs *pQ,
391 PAF_ASIT_Config *pC,
392 Int *asipErrno)
393 {
394 Int as, zMS, zMI, zMD;
395 Int sourceConfig, mode;
396 PAF_AST_Config *pAstCfg;
397 PAF_AST_IoInp *pInp; /* I/O components for input */
399 pAstCfg = pC->pAstCfg; // pointer to AST common (shared) configuration
400 as = pAstCfg->as;
401 zMI = pP->zone.master;
402 zMD = pAstCfg->masterDec;
403 zMS = pAstCfg->masterStr;
404 pInp = pC->pIoInp; // pointer to input I/O components
406 *asipErrno = 0;
408 // Select source and initialize physical layer / HW interface
409 *asipErrno = asitSelectDevices(pQ, pAstCfg, pInp);
410 if (*asipErrno) {
411 TRACE_TERSE2("asitSelectDevices returned asipErrno = 0x%04x at line %d. AS%d",
412 *asipErrno, as+zMS);
413 return FALSE; // Input is not ready for processing due to error
414 }
416 // If no master input selected then we don't know what may be at the input,
417 // so set to unknown and skip any remaining processing
418 if (!pInp[zMI].pRxParams) {
419 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
420 (Int8)PAF_SOURCE_UNKNOWN, GATEMP_INDEX_DEC);
422 TRACE_VERBOSE1("TaskAsip: AS%d: No input selected...", as+zMS);
423 return FALSE; // No error, but input is not ready for processing
424 }
426 // If here then we have a valid input so query its status
427 *asipErrno = asitUpdateInputStatus(pInp[zMI].pRxParams,
428 &pAstCfg->xInp[zMI].inpBufStatus,
429 &pAstCfg->xInp[zMI].inpBufConfig);
430 if(*asipErrno) {
431 TRACE_VERBOSE1("TaskAsip: updateInputStatus returns 0x%x", *asipErrno);
432 return FALSE; // Input is not ready for processing due to error
433 }
435 // If master decoder is not enabled, or the input is unlocked, then do nothing
436 mode = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.mode),
437 GATEMP_INDEX_DEC);
438 if (!mode || !pAstCfg->xInp[zMI].inpBufStatus.lock)
439 {
440 TRACE_VERBOSE0("TaskAsip: Not locked, continue");
441 return FALSE; // No error, but input is not ready for processing
442 }
444 // Check selected source: sourceSelect is set by another task, AIP or AFP
445 sourceConfig = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
446 GATEMP_INDEX_DEC);
447 // If no source selected then do nothing
448 if(sourceConfig == PAF_SOURCE_NONE) {
449 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
450 (Int8)PAF_SOURCE_NONE, GATEMP_INDEX_DEC);
451 TRACE_VERBOSE1("TaskAsip: AS%d: no source selected, continue", as+zMS);
452 return FALSE; // No error, but input is not ready for processing
453 }
455 // If we want pass processing then proceed directly
456 if (sourceConfig == PAF_SOURCE_PASS)
457 {
458 TRACE_VERBOSE1("TaskAsip: AS%d: Pass processing ...", as+zMS);
459 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
460 (Int8)PAF_SOURCE_PASS, GATEMP_INDEX_DEC);
462 pP->fxns->sourceDecode(pP, pQ, pC, PAF_SOURCE_PASS);
463 if (pP->fxns->passProcessing) {
464 *asipErrno = pP->fxns->passProcessing(pP, pQ, pC, NULL);
465 }
466 else {
467 TRACE_TERSE2("TaskAsip: AS%d: Pass Processing not supported, asipErrno 0x%x",
468 as+zMS, ASPERR_PASS);
469 *asipErrno = ASPERR_PASS;
470 }
472 TRACE_VERBOSE0("TaskAsip: continue");
473 return FALSE; // Error or not, input is not ready for processing
474 }
476 // No error and input processing is ready
477 return TRUE;
478 } /* asitPrepareProcessing */
481 /*===========================================================================
482 * ASIT Source Detection:
483 * ASIT processing for input source identification:
484 * - mark I/O PHY transfer completion
485 * - run auto-detection via I/O DATA in asitInputDataProcess
486 * - mark I/O DATA read completion
487 * - check auto-detection status and take corresponding actions if either
488 * PCM or bitstream is identified:
489 * - decide input source
490 * - update I/O components
491 * - reconfigure McASP LLD if it is PCM
492 * - start next I/O PHY transfer
493 ============================================================================*/
494 Int asitSourceDetection(const PAF_ASIT_Params *pP,
495 const PAF_ASIT_Patchs *pQ,
496 PAF_ASIT_Config *pAsitCfg)
497 {
498 PAF_AST_Config *pAstCfg;
499 PAF_AST_IoInp *pInp; // I/O components for input
500 Int zMD, mcaspErr, asitErr;
501 ioDataAutoDetStat_t autoDetStatus;
503 pAstCfg = pAsitCfg->pAstCfg; // pointer to AST common (shared) configuration
504 zMD = pAstCfg->masterDec;
505 pInp = &pAsitCfg->pIoInp[zMD]; // pointer to input I/O components
507 // Marks I/O PHY transfer and I/O BUFF write complete
508 asitPhyTransferComplete(pInp);
510 // Process input data - either searching SYNC for PCM or checking SYNC for bitstream
511 asitErr = asitInputDataProcess(pInp, &autoDetStatus);
512 if(asitErr != ASIT_NO_ERR) {
513 // Even though there is error, still need to start next transfer to
514 // maintain McASP transfer.
515 asitPhyTransferStart(pInp);
517 return asitErr;
518 }
520 // Mark input data read complete
521 ioDataReadComplete(pInp->hIoData);
523 if(autoDetStatus.syncTimeOut) {
524 return ASIT_AUTODET_TIME_OUT;
525 }
526 // Check if bitstream or PCM is detected
527 else if( autoDetStatus.syncState == IODATA_SYNC_BITSTREAM
528 || autoDetStatus.syncState == IODATA_SYNC_PCM) {
529 // Decide input source and inform decoder
530 asitErr = asitDecideSource(pAstCfg, pInp, &autoDetStatus);
531 if(asitErr != ASIT_NO_ERR) {
532 return asitErr;
533 }
534 else {
535 // Update I/O components and input buffer config
536 asitUpdateIoComps(pP, pAstCfg, pInp, &autoDetStatus);
538 // set to unknown so that we can ensure, for IOS purposes, that
539 // sourceDecode = NONE iff we are in this top level state machine
540 // and specifically not in decodeProcessing
541 #ifndef DEBUG_SKIP_DECODING
542 pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_UNKNOWN);
543 #endif
545 if(autoDetStatus.syncState == IODATA_SYNC_BITSTREAM) {
546 // Input is bit stream: go to decoding
547 pInp->asipState = ASIT_DECODE_PROCESSING;
548 }
549 else {
550 // Input is PCM: stop swapping data
551 pInp->swapData = FALSE;
553 // Reconfigure McASP LLD to transfer 32-bit unpacked data
554 mcaspErr = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_32);
555 if(mcaspErr != Aud_EOK) {
556 return ASIT_ERR_MCASP_CFG;
557 }
559 // Adjust I/O BUFF delay and read pointer - to make sure read pointers
560 // always point to PCM data from 1st I2S (out of 4 for HDMI 4xI2S)
561 ioBuffAdjustDelay(pInp->hIoBuff, pInp->phyXferSize);
563 // Go to transition state to switch to PCM
564 pInp->asipState = ASIT_PCM_TRANSITION;
565 }
566 }
567 }
568 else {
569 // SYNC search ongoing, no action is needed
570 }
572 // Start next transfer
573 asitPhyTransferStart(pInp);
575 return (ASIT_NO_ERR);
576 } /* asitSourceDetection */
579 /*===========================================================================
580 //
581 // which will cause all 0's in one McASP LLD transfer. This will
582 // be detected as loss of SYNC by auto detection. To prevent that,
583 // skip I/O DATA process for hangover period so that this all 0's
584 // frame will not be seen by auto-detection. Also, playing out PCM
585 // needs to be skipped as well, to prevent from playing out garbage
586 // (16-bit packed data).
587 *
588 * ASIT Transition to PCM decoding.
589 * When PCM is detected, McASP LLD will be reconfigured to transmit 32-bit
590 * words, which will modify the RFMT register. This will cause all 0's in
591 * one McASP LLD transfer, which would be detected as loss of SYNC by auto
592 * detection (performed by I/O DATA). To prevent that, skip I/O DATA process
593 * for hangover period so that this all-0's frame will not be seen by the
594 * auto-detection.
595 *
596 * In addition, playing out PCM should be skipped as well to prevent from
597 * playing out the 16-bit packed data that's still in the input buffer.
598 *
599 * This function does the following:
600 * - mark I/O PHY transfer completion
601 * - bypass I/O DATA
602 * - start next I/O PHY transfer
603 ============================================================================*/
604 Int asitPcmTransition(PAF_ASIT_Config *pAsitCfg)
605 {
606 Int asitErr;
607 PAF_AST_IoInp *pInp; // I/O components for input
608 Int zMD;
610 zMD = pAsitCfg->pAstCfg->masterDec; // pointer to AST common (shared) configuration
611 pInp = &pAsitCfg->pIoInp[zMD]; // pointer to input I/O components
613 // Marks I/O PHY transfer and I/O BUFF write complete
614 asitPhyTransferComplete(pInp);
616 // Bypass I/O data processing due to McASP LLD work around
617 // (refer to comments inside the function)
618 asitErr = asitBypassIoData(pInp);
620 pInp->pcmSwitchHangOver--;
621 if(pInp->pcmSwitchHangOver == 0) {
622 pInp->asipState = ASIT_DECODE_PROCESSING;
623 }
624 else {
625 ; // stay in this state
626 }
628 // Start next transfer
629 asitPhyTransferStart(pInp);
631 return asitErr;
633 } /* asitPcmTransition */
635 /*============================================================================
636 * ASIT Bypass I/O DATA Processing
637 * This function bypasses the I/O DATA processing. It maintains the read
638 * operation of I/O BUFF by directly calling I/O BUFF APIs. When I/O DATA
639 * is not bypassed, I/O BUFF read operation is invoked by I/O DATA.
640 *
641 ============================================================================*/
642 Int asitBypassIoData(PAF_AST_IoInp *pInp)
643 {
644 void *buff1, *buff2;
645 size_t size1, size2;
647 // Get read pointers (or sub-buffers) of the input buffer
648 if (ioBuffGetReadPtrs(pInp->hIoBuff, pInp->phyXferSize,
649 &buff1, &size1, &buff2, &size2)
650 == IOBUFF_ERR_UNDERFLOW) {
651 pInp->numUnderflow += 1;
653 // Return since there is no enough data to process
654 return ASIT_ERR_INPBUF_UNDERFLOW;
655 }
657 ioBuffReadComplete(pInp->hIoBuff, buff1, size1);
659 if(buff2 != NULL) {
660 ioBuffReadComplete(pInp->hIoBuff, buff2, size2);
661 }
663 return ASIT_NO_ERR;
664 } /* asitBypassIoData */
667 /*============================================================================
668 * ASIT Decode Processing
669 * This function performs the decode processing and does the following based
670 * on the ASIT events:
671 * - initialize the decode processing if it is the first time
672 * - if there is ASIT INPUT DATA event (ASIT_EVTMSK_INPDATA):
673 * - mark I/O PHY transfer completion
674 * - run auto-detection via I/O DATA in asitInputDataProcess
675 * - check auto-detection status and take corresponding actions if SYNC
676 * is lost.
677 * - start next I/O PHY transfer
678 * - map ASIT events to decoding messages
679 * - invoke decDecodeFsm() and pass the mapped decoding messages
680 * - if there is ASIT DECODE ACK event (ASIT_EVTMSK_DECACK)
681 * - mark I/O DATA read completion
682 * - error handling
683 ============================================================================*/
684 Int asitDecodeProcessing(const PAF_ASIT_Params *pP,
685 const PAF_ASIT_Patchs *pQ,
686 PAF_ASIT_Config *pAsitCfg,
687 UInt asitEvents)
688 {
689 Int asitErr, decErr;
690 PAF_AST_IoInp *pInp; // I/O components for input
691 AspMsgMaster_Handle hAspMsgMaster; // ASIT message master handle
692 asipDecProc_t *pDec;
693 ioDataAutoDetStat_t autoDetStatus;
694 Int zMD;
695 UInt decMsg;
696 Int status;
698 zMD = pAsitCfg->pAstCfg->masterDec; // pointer to AST common (shared) configuration
699 pInp = &pAsitCfg->pIoInp[zMD]; // pointer to input I/O components
700 hAspMsgMaster = pAsitCfg->hAspMsgMaster; // get ASIT message master handle
701 pDec = &pAsitCfg->inpDec;
703 // Initialization for decode processing when this function is called the first time
704 #ifndef DEBUG_SKIP_DECODING
705 if(!pDec->initDone) {
706 // Initialize decoder
707 decDecodeInit(pP, pAsitCfg, pInp->sourceSelect);
709 pDec->initDone = TRUE;
710 }
711 #endif
713 // Process input data if this is a data ready message
714 if(asitEvents & ASIT_EVTMSK_INPDATA) {
715 TRACE_TERSE0("asitDecodeProcessing: process input data.");
717 // Marks I/O PHY transfer and I/O BUFF write complete
718 asitPhyTransferComplete(pInp);
720 // Process input data - either search SYNC for PCM or check SYNC for bitstream
721 asitErr = asitInputDataProcess(pInp, &autoDetStatus);
723 if(asitErr == ASIT_NO_ERR) {
724 ioDataReadComplete(pInp->hIoData);
726 // Check if SYNC is maintained or lost (stream stops or format changes)
727 if(autoDetStatus.syncState == IODATA_SYNC_NONE) {
728 // SYNC lost: change I/O PHY transfer size to default for auto-detection
729 //asitErr = asitRecfgPhyXfer(pInp, INPUT_FRAME_SIZE_DEF);
730 //if(asitErr != ASIT_NO_ERR) {
731 // return asitErr;
732 //}
734 // Inform decoder to complete the decoding of previous frame - is this good?
735 pInp->sourceSelect = PAF_SOURCE_NONE;
736 pInp->numFrameReceived = 0; // for debugging
737 TRACE_TERSE0("asitDecodeProcessing: SYNC lost.");
739 #ifdef DEBUG_SKIP_DECODING
740 asitErr = ASIT_ERR_DECODE_QUIT;
741 #endif
742 }
743 else {
744 pInp->numFrameReceived += 1; // for debugging
746 // Communicate input stream information to decoder through input
747 // buffer configuration -- this was moved inside decDecodeFsm
748 //asitUpdateInpBufConfig(pAsitCfg->pAstCfg, pInp);
750 // Start next transfer
751 asitPhyTransferStart(pInp);
752 }
754 // Start next transfer
755 //asitPhyTransferStart(pInp);
757 #ifdef DEBUG_SKIP_DECODING
758 return asitErr;
759 #endif
760 }
761 else if(asitErr == ASIT_ERR_INPBUF_UNDERFLOW) {
762 TRACE_TERSE0("asitDecodeProcessing: Input buffer underflows.");
764 // When input buffer underflows, it is not an error but decoding needs
765 // to be skipped as there is not enough data in the buffer.
766 asitPhyTransferStart(pInp);
768 return asitErr;
769 }
770 else {
771 // Inform decoder to complete the decoding of previous frame - is this good?
772 pInp->sourceSelect = PAF_SOURCE_NONE;
773 pInp->numFrameReceived = 0; // for debugging
774 TRACE_TERSE1("asitDecodeProcessing: asitInputDataProcess error: %d", asitErr);
776 #ifdef DEBUG_SKIP_DECODING
777 return ASIT_ERR_DECODE_QUIT;
778 #endif
779 }
780 } /* ASIT_EVTMSK_INPDATA */
781 #ifdef DEBUG_SKIP_DECODING
782 else {
783 TRACE_TERSE0("asitDecodeProcessing: events error.");
784 return ASIT_ERR_EVENTS;
785 }
786 #endif
788 #ifndef DEBUG_SKIP_DECODING
789 // Map ASIT events to decode messages
790 decMsg = asitEventsToDecMsg(asitEvents);
792 // Pass messages (corresponding to events) to decode FSM
793 decErr = decDecodeFsm(pP, pQ, pAsitCfg, pInp->sourceSelect, decMsg);
795 // Mark I/O DATA read complete if decoder indicates decoding is done.
796 if((asitEvents & ASIT_EVTMSK_DECACK)) { // DECACK -> decoding done
797 //ioDataReadComplete(pInp->hIoData);
798 }
800 if(decErr != DEC_NO_ERR) {
801 TRACE_VERBOSE0("TaskAsip: send DEC_EXIT message to slave decoder.");
803 // Send dec exit message to slave decoder
804 status = AspMsgSnd(hAspMsgMaster, ASP_SLAVE_DEC_EXIT, NULL);
805 if (status != ASP_MSG_NO_ERR)
806 {
807 TRACE_VERBOSE0("TaskAsip: error in sending DEC_EXIT message");
808 SW_BREAKPOINT;
809 }
810 status = AspMsgRcvAck(hAspMsgMaster, ASP_MASTER_DEC_EXIT_DONE, NULL, TRUE);
811 if (status != ASP_MSG_NO_ERR)
812 {
813 TRACE_VERBOSE0("TaskAsip: error in sending DEC_EXIT message");
814 SW_BREAKPOINT;
815 }
817 return ASIT_ERR_DECODE_QUIT; // This is not necessarily an error
818 }
819 else {
820 return ASIT_NO_ERR;
821 }
822 #endif
823 } /* asitDecodeProcessing */
826 /*============================================================================
827 * ASIT Input Data Processing:
828 * - invoke ioDataProcess() to inspect input data for
829 * - initial auto-detection, or
830 * - background scanning for PCM data, or
831 * - SYNC check for bitstream
832 * - return auto-detection status (SYNC detected, SYNC loss, etc)
833 ============================================================================*/
834 Int asitInputDataProcess(PAF_AST_IoInp *pInp, ioDataAutoDetStat_t *pAutoDetStats)
835 {
836 Int ioDataErr, retVal;
837 ioDataCtl_t ioDataCtl;
839 // Perform auto-detection inside I/O DATA component
840 ioDataErr = ioDataProcess(pInp->hIoData);
842 if(ioDataErr == IODATA_NO_ERR) {
843 // Normal operation - check auto-detection status
844 ioDataCtl.code = IODATA_CTL_GET_AUTODET_STATUS;
845 ioDataControl(pInp->hIoData, &ioDataCtl);
847 *pAutoDetStats = ioDataCtl.param.autoDetStats;
849 retVal = ASIT_NO_ERR;
850 }
851 else if(ioDataErr == IODATA_ERR_IOBUF_UNDERFLOW) {
852 // Input buffer underflows - there is no enough data to process.
853 // This is not error and no action is needed.
854 pInp->numUnderflow += 1; // debug
856 retVal = ASIT_ERR_INPBUF_UNDERFLOW;
857 }
858 else {
859 // Something is wrong: print error log and return
860 //printf("IODATA processing error!\n");
861 retVal = ASIT_ERR_INPDATA_PROC;
862 }
864 return retVal;
865 } /* asitInputDataProcess */
867 /*============================================================================
868 * Mapping ASIT Events to Decoding Messages
869 ============================================================================*/
870 UInt asitEventsToDecMsg(UInt asitEvents)
871 {
872 UInt decMsg = 0;
874 if (asitEvents & ASIT_EVTMSK_INPDATA) {
875 // Input data event
876 decMsg |= DEC_MSGMSK_INPDATA;
877 }
879 // temp, simulation
880 //if(asitEvents & ASIT_EVTMSK_INFOACK) {
881 // decMsg |= DEC_MSGMSK_INFOACK;
882 //}
884 // temp, simulation
885 //if(asitEvents & ASIT_EVTMSK_DECACK) {
886 // decMsg |= DEC_MSGMSK_DECACK;
887 //}
889 if (asitEvents & ASIT_EVTMSK_RXACK)
890 {
891 // Receive acknowledge message event
892 decMsg |= DEC_MSGMSK_RXACK;
893 }
895 return decMsg;
896 } /* asitEventsToDecMsg */
898 /*===========================================================================
899 * Initialize I/O components for input processing
900 ============================================================================*/
901 int asitIoCompsInit(PAF_AST_InpBuf * pInpBuf, PAF_AST_IoInp * pInpIo)
902 {
903 ioBuffParams_t ioBuffParams;
904 ioPhyParams_t ioPhyParams;
905 ioDataParam_t ioDataCfg;
906 ioPhyCtl_t ioPhyCtl;
908 if (pInpIo->hMcaspChan != NULL)
909 {
910 //pInpIo->phyXferSize = INPUT_FRAME_SIZE_DEF;
911 pInpIo->phyXferSize = pInpIo->stride * NUM_CYCLE_PER_FRAME_DEF * WORD_SIZE_BITSTREAM;
913 if (pInpIo->firstTimeInit) {
914 TRACE_VERBOSE0("Initialize I/O BUFF and I/O PHY.");
915 ioBuffParams.base = pInpBuf->inpBufConfig.base.pVoid;
916 ioBuffParams.size = pInpBuf->inpBufConfig.allocation / STRIDE_WORST_CASE
917 * STRIDE_WORST_CASE;
918 ioBuffParams.sync = IOBUFF_WRITE_SYNC;
919 ioBuffParams.nominalDelay = INPUT_FRAME_SIZE_DEF;
920 if (ioBuffInit(pInpIo->hIoBuff, &ioBuffParams) != IOBUFF_NOERR) {
921 return (ASIT_ERR_IOBUFF_INIT); // to remove magic number
922 }
924 ioPhyParams.ioBuffHandle = pInpIo->hIoBuff;
925 ioPhyParams.xferFrameSize = pInpIo->phyXferSize;
926 ioPhyParams.mcaspChanHandle = pInpIo->hMcaspChan;
927 ioPhyParams.ioBuffOp = IOPHY_IOBUFFOP_WRITE;
928 if (ioPhyInit(pInpIo->hIoPhy, &ioPhyParams) != IOPHY_NOERR) {
929 return (ASIT_ERR_IOPHY_INIT); // to remove magic number
930 }
932 pInpIo->numPrimeXfers = NUM_PRIME_XFERS;
933 }
935 /* Reinitialize I/O DATA every time when ASIT restarts */
936 TRACE_VERBOSE0("Initialize I/O DATA.");
937 ioDataCfg.ioBuffHandle = pInpIo->hIoBuff;
938 ioDataCfg.unknownSourceTimeOut = pInpBuf->inpBufConfig.pBufStatus->unknownTimeout;
939 ioDataCfg.frameLengthsIEC = (uint_least16_t *)&iecFrameLength[0];
940 ioDataCfg.frameLengthPCM = pInpIo->stride * NUM_CYCLE_PER_FRAME_DEF;
941 ioDataCfg.frameLengthDef = pInpIo->stride * NUM_CYCLE_PER_FRAME_DEF;
942 ioDataCfg.ibMode = pInpBuf->inpBufConfig.pBufStatus->mode;
943 ioDataCfg.zeroRunRestart = pInpBuf->inpBufConfig.pBufStatus->zeroRunRestart;
944 ioDataCfg.zeroRunTrigger = pInpBuf->inpBufConfig.pBufStatus->zeroRunTrigger;
946 if (ioDataInit(pInpIo->hIoData, &ioDataCfg) != IODATA_NO_ERR) {
947 return (ASIT_ERR_IODATA_INIT); // to remove magic number
948 }
950 if (pInpIo->firstTimeInit) {
951 /* Initialize I/O BUFF and I/O PHY only when input interface changes. */
952 TRACE_VERBOSE0("Prime I/O PHY.");
954 // Start I/O physical layer by priming McASP LLD for input
955 asitIoPhyPrime(pInpIo);
957 pInpIo->firstTimeInit = FALSE;
958 }
959 else {
960 // Reconfigure I/O PHY transfer size
961 ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
962 ioPhyCtl.params.xferFrameSize = pInpIo->phyXferSize;
963 ioPhyControl(pInpIo->hIoPhy, &ioPhyCtl);
964 #if 0
965 // If previous stream before reset was PCM, reconfigure McASP LLD to receive 16-bit packed bits
966 if (!pInpIo->swapData) {
967 Int mcaspErr;
968 mcaspErr = mcaspRecfgWordWidth(pInpIo->hMcaspChan, Mcasp_WordLength_16);
969 if(mcaspErr != Aud_EOK) {
970 return ASIT_ERR_MCASP_CFG;
971 }
973 // Start swapping data
974 pInpIo->swapData = TRUE;
975 TRACE_VERBOSE0("Reconfigure McASP word length and start swapping data.");
976 }
977 #endif
978 // Start PHY transfer
979 TRACE_VERBOSE0("Start I/O PHY transfer.");
980 asitPhyTransferStart(pInpIo);
981 }
982 }
984 return 0;
985 } /* asitIoCompsInit */
987 /*======================================================================================
988 * This function initializes ASIT processing
989 *====================================================================================*/
990 void asitProcInit(PAF_AST_IoInp *pInp, asipDecProc_t *pDec)
991 {
992 // pInp->swapData = TRUE;
993 pInp->pcmSwitchHangOver = INPUT_SWITCH_HANGOVER;
994 pDec->initDone = FALSE;
995 pInp->numFrameReceived = 0;
996 }
998 /*======================================================================================
999 * I/O physical layer prime operation required by McASP LLD
1000 *====================================================================================*/
1001 void asitIoPhyPrime(PAF_AST_IoInp *pInp)
1002 {
1003 Int32 count;
1005 for(count = 0; count < pInp->numPrimeXfers; count++)
1006 {
1007 ioPhyXferSubmit(pInp->hIoPhy);
1008 #ifdef ASIP_DEBUG
1009 //pInp->numXferStart++;
1010 #endif
1011 }
1012 } /* asitIoPhyPrime */
1015 /*======================================================================================
1016 * This function marks the I/O PHY transfer as complete
1017 *====================================================================================*/
1018 void asitPhyTransferComplete(PAF_AST_IoInp * pInpIo)
1019 {
1020 // Mark underlining I/O BUFF write complete and swap data if needed
1021 ioPhyXferComplete(pInpIo->hIoPhy, pInpIo->swapData);
1022 } /* asitPhyTransferComplete */
1024 #if 0
1025 Int asitRecfgPhyXfer(PAF_AST_IoInp *pInp, size_t xferSize)
1026 {
1027 ioPhyCtl_t ioPhyCtl;
1028 Int mcaspErr;
1030 ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
1031 ioPhyCtl.params.xferFrameSize = xferSize;
1032 ioPhyControl(pInp->hIoPhy, &ioPhyCtl);
1034 pInp->phyXferSize = ioPhyCtl.params.xferFrameSize;
1036 if(!pInp->swapData) {
1037 // If it was PCM, reconfigure McASP LLD to receive 16-bit packed bits
1038 mcaspErr = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_16);
1039 if(mcaspErr != Aud_EOK) {
1040 return ASIT_ERR_MCASP_CFG;
1041 }
1043 // Start swapping data
1044 pInp->swapData = TRUE;
1045 }
1047 return ASIT_NO_ERR;
1049 } /* asitRecfgPhyXfer */
1050 #endif
1052 /*======================================================================================
1053 * McASP LLD call back function
1054 *====================================================================================*/
1055 void asipMcaspCallback(void* arg, MCASP_Packet *mcasp_packet)
1056 {
1057 /* post semaphore */
1058 if(mcasp_packet->arg == IOPHY_XFER_FINAL) {
1059 //Semaphore_post(asipSemRx);
1060 Event_post(gAsitEvtHandle, ASIT_EVTMSK_INPDATA);
1061 } else {
1062 ; // intermediate packet due to buffer wrapping around
1063 }
1064 }
1066 /*======================================================================================
1067 * This function checks if McASP Rx for input overruns
1068 *====================================================================================*/
1069 int asipCheckMcaspRxOverrun(Ptr mcaspChanHandle)
1070 {
1071 Mcasp_errCbStatus mcaspErrStat;
1073 mcaspControlChan(mcaspChanHandle, Mcasp_IOCTL_CHAN_QUERY_ERROR_STATS, &mcaspErrStat);
1075 return (mcaspErrStat.isRcvOvrRunOrTxUndRunErr);
1076 }
1078 #if 0
1079 /*======================================================================================
1080 * This function restarts McASP LLD channel for input
1081 *====================================================================================*/
1082 void asipMcaspRxRestart(PAF_AST_IoInp *pInpIo)
1083 {
1084 mcaspRxReset();
1085 mcaspRxCreate();
1086 }
1087 #endif
1089 /*======================================================================================
1090 * This function starts an I/O PHY transfer
1091 *====================================================================================*/
1092 void asitPhyTransferStart(PAF_AST_IoInp *pInpIo)
1093 {
1094 Int ioPhyErr;
1096 if(asipCheckMcaspRxOverrun(pInpIo->hMcaspChan)) {
1097 #ifdef ASIP_DEBUG
1098 pInpIo->numInputOverrun++;
1099 #endif
1100 //asipMcaspRxRestart(pInpIo);
1101 System_abort("\nMcASP for input overruns! %d!\n");
1102 }
1103 else {
1104 ioPhyErr = ioPhyXferSubmit(pInpIo->hIoPhy);
1105 //if(ioPhyXferSubmit(pInpIo->hIoPhy)==IOPHY_ERR_BUFF_OVERFLOW) {
1106 if(ioPhyErr!=IOPHY_NOERR){
1107 printf("\n I/O PHY ioPhyXferSubmit fails with error %d!\n", ioPhyErr);
1108 // Input buffer overflows!
1109 //printf("\nInput buffer overflows!\n");
1110 exit(0);
1111 }
1112 else {
1113 // Input buffer operates normally
1114 ;
1115 }
1116 #ifdef ASIP_DEBUG
1117 //pInpIo->numXferStart++;
1118 #endif
1119 }
1120 }
1122 // Indicates whether Input has been selected
1123 Int d10Initialized = 0;
1125 //extern Aud_STATUS mcaspAudioConfig(void);
1126 //extern void McaspDevice_init(void);
1128 /*======================================================================================
1129 * This function initializes HW interface and selects the right device for input
1130 *====================================================================================*/
1131 Int asitSelectDevices(
1132 const PAF_ASIT_Patchs *pQ,
1133 PAF_AST_Config *pAstCfg,
1134 PAF_AST_IoInp *pInp
1135 )
1136 {
1137 Aud_STATUS status;
1138 const PAF_SIO_Params *pInPrms;
1139 mcaspLLDconfig *pLldCfg;
1140 mcaspLLDconfig *pReqLldCfg;
1141 Ptr mcaspChanHandle;
1142 Int zMD;
1143 Int interface;
1144 const PAF_SIO_Params *pD10Params;
1145 UInt postedEvents;
1147 zMD = pAstCfg->masterDec;
1149 interface = pAstCfg->xInp[zMD].inpBufStatus.sioSelect; // obtain SIO select for input
1151 if (interface >= 0)
1152 {
1153 // Positive value for interface: new Input SIO update request has been received via alpha command.
1154 // Negative value for interface: no new Input SIO update request has been received,
1155 // previous requests have been processed.
1157 // check for valid index into device array
1158 if (interface >= pQ->devinp->n) // DEVINP_N
1159 {
1160 interface = 0; // treat as device InNone
1161 }
1163 //
1164 // Deactivate currently active interface
1165 //
1166 if (pInp->hMcaspChan != NULL) // non-NULL McASP LLD channel handle indicates there's an active interface
1167 {
1168 d10Initialized = 0; // indicate no Input selected
1170 // check McASP LLD control API
1171 mcaspControlChan(pInp->hMcaspChan, MCASP_CHAN_RESET, NULL); // Rx reset channel
1172 //mcaspControlChan(pInp->hMcaspChan, MCASP_DEVICE_RESET, NULL); // Reset Tx/Rx channel
1174 // Delete McASP LLD channel
1175 status = mcaspDeleteChan(pInp->hMcaspChan);
1176 if (status != Aud_EOK)
1177 {
1178 Log_info0("asitSelectDevices(): McASP channel deletion failed!\n");
1179 return ASIP_ERR_MCASP_CFG;
1180 }
1182 // Clear (drop) already posted Input data events
1183 postedEvents = Event_getPostedEvents(gAsitEvtHandle);
1184 while ((postedEvents & ASIT_EVTMSK_INPDATA) != 0)
1185 {
1186 Event_pend(gAsitEvtHandle, ASIT_EVTMSK_NONE, ASIT_EVTMSK_INPDATA, 0);
1187 postedEvents = Event_getPostedEvents(gAsitEvtHandle);
1188 }
1190 pInp->hMcaspChan = NULL; // reset active McASP LLD handle
1191 if (pInp->pRxParams != NULL) // sanity check, pInp->pRxParams should be non NULL if pInp->hMcaspChan is non NULL
1192 {
1193 pInPrms = (const PAF_SIO_Params *)pInp->pRxParams;
1194 pLldCfg = (mcaspLLDconfig *)pInPrms->sio.pConfig; // get pointer to active McASP LLD configuration
1195 pLldCfg->hMcaspChan = NULL; // reset McASP LLD handle for active McASP LLD configuration
1196 pInp->pRxParams = NULL; // reset pointer to active D10 parameters
1197 }
1198 else
1199 {
1200 // This is a programming error
1201 SW_BREAKPOINT; // debug
1202 }
1203 }
1205 //
1206 // Activate requested interface
1207 //
1208 pD10Params = (const PAF_SIO_Params *)pQ->devinp->x[interface]; // get D10 parameters for selected interface
1209 if (pD10Params != NULL)
1210 {
1211 //
1212 // Requested device is other than InNone
1213 //
1215 // Initialize Tx clock mux
1216 D10_initClkMux((void *)pD10Params);
1218 pReqLldCfg = (mcaspLLDconfig *)pD10Params->sio.pConfig;
1219 if (pReqLldCfg->hMcaspChan == NULL)
1220 {
1221 // Create McASP LLD channel
1222 mcaspChanHandle = NULL;
1223 status = mcasplldChanCreate(pReqLldCfg, &mcaspChanHandle);
1224 if (status != Aud_EOK)
1225 {
1226 Log_info0("asitSelectDevices(): McASP channel creation failed!\n");
1227 return ASIP_ERR_MCASP_CFG;
1228 }
1230 pReqLldCfg->hMcaspChan = mcaspChanHandle; // set McASP LLD handle for requested McASP LLD configuration
1231 pInp->pRxParams = (const void *)pD10Params; // set pointer to active D10 parameters
1232 pInp->hMcaspChan = pReqLldCfg->hMcaspChan; // set active McASP LLD handle
1234 // configure stride according to selected McASP LLD configuration
1235 pInp->stride = pReqLldCfg->mcaspChanParams->noOfSerRequested *
1236 pReqLldCfg->mcaspChanParams->noOfChannels;
1238 pInp->firstTimeInit = TRUE; // set flag for IO Phy & Buff initialization
1240 d10Initialized = 1; // indicate Input selected
1241 }
1242 }
1243 else
1244 {
1245 //
1246 // Requested device is InNone
1247 //
1248 pInp->hMcaspChan = NULL; // reset active McASP LLD handle
1249 pInp->pRxParams = NULL; // reset pointer to active D10 parameters
1250 }
1252 // indicate SIO update request processed
1253 pAstCfg->xInp[zMD].inpBufStatus.sioSelect = interface | 0x80;
1254 }
1256 if (pInp->hMcaspChan != NULL) // non NULL indicates there's an active interface
1257 {
1258 if (pInp->pRxParams != NULL) // sanity check, this should be non NULL if pInp->hMcaspChan is non NULL
1259 {
1260 pInPrms = (const PAF_SIO_Params *)pInp->pRxParams;
1261 pLldCfg = (mcaspLLDconfig *)pInPrms->sio.pConfig; // get currently active McASP LLD configuration
1262 if (pLldCfg != NULL) // sanity check, this should be non NULL if pInp->hMcaspChan is non NULL
1263 {
1264 // Configure McASP to receive 16/32-bit data according to default configuration
1265 mcaspRecfgWordWidth(pInp->hMcaspChan, pLldCfg->mcaspChanParams->wordWidth);
1267 // Set flag to swap HDMI data if it is 4xI2S and word length is 16
1268 if ((pLldCfg->mcaspChanParams->wordWidth == Mcasp_WordLength_16) &&
1269 (pLldCfg->mcaspChanParams->noOfSerRequested == 4))
1270 {
1271 pInp->swapData = TRUE;
1272 }
1273 else
1274 {
1275 pInp->swapData = FALSE;
1276 }
1277 }
1278 else
1279 {
1280 // This is a programming error
1281 SW_BREAKPOINT; // debug
1282 }
1284 }
1285 else
1286 {
1287 // This is a programming error
1288 SW_BREAKPOINT; // debug
1289 }
1290 }
1292 return ASIP_NO_ERR;
1293 } /* asitSelectDevices */
1295 /*======================================================================================
1296 * This function updates input status
1297 *====================================================================================*/
1298 Int asitUpdateInputStatus(const void *pRxParams, PAF_InpBufStatus *pStatus,
1299 PAF_InpBufConfig *pInpBuf)
1300 {
1301 Int asipErrno;
1303 PAF_SIO_InputStatus inputStatus;
1305 // initialize all values to unknown so that device specific
1306 // driver layer need only fill in those entries that it is aware of.
1307 // This allows extensibility of the structure without requiring users
1308 // to re-code.
1309 inputStatus.lock = 0;
1310 inputStatus.sampleRateData = PAF_SAMPLERATE_UNKNOWN;
1311 inputStatus.sampleRateMeasured = PAF_SAMPLERATE_UNKNOWN;
1312 inputStatus.nonaudio = PAF_IEC_AUDIOMODE_UNKNOWN;
1313 inputStatus.emphasis = PAF_IEC_PREEMPHASIS_UNKNOWN;
1315 //more configuration is needed to abstract out D10
1316 asipErrno = D10_RxControl(pRxParams,
1317 (Uns)PAF_SIO_CONTROL_GET_INPUT_STATUS,
1318 (Arg) &inputStatus);
1319 if (asipErrno) {
1320 return asipErrno;
1321 }
1322 pStatus->sampleRateData = inputStatus.sampleRateData;
1323 pStatus->sampleRateMeasured = inputStatus.sampleRateMeasured;
1324 pStatus->nonaudio = inputStatus.nonaudio;
1325 pStatus->emphasisData = inputStatus.emphasis;
1327 // if MSB of override clear then use as reported lock
1328 // if = 0x80 then use default [0x81]
1329 // if = 0x81 then use measured (from device)
1330 // others not defined or implemented
1331 if ((pStatus->lockOverride & (XDAS_Int8)0x80) == 0)
1332 pStatus->lock = pStatus->lockOverride;
1333 else if (pStatus->lockOverride == (XDAS_Int8)0x80)
1334 pStatus->lock = inputStatus.lock;
1335 else if (pStatus->lockOverride == (XDAS_Int8)0x81)
1336 pStatus->lock = inputStatus.lock;
1338 // if MSB of override clear then use it as sample rate for system,
1339 // if = 0x80 then use default [0x82]
1340 // if = 0x81 then use data
1341 // if = 0x82 then use measured
1342 // others not defined or implemented
1343 if ((pStatus->sampleRateOverride & (XDAS_Int8)0x80) == 0)
1344 pStatus->sampleRateStatus = pStatus->sampleRateOverride;
1345 else if (pStatus->sampleRateOverride == (XDAS_Int8)0x80)
1346 pStatus->sampleRateStatus = pStatus->sampleRateMeasured;
1347 else if (pStatus->sampleRateOverride == (XDAS_Int8)0x81)
1348 pStatus->sampleRateStatus = pStatus->sampleRateData;
1349 else if (pStatus->sampleRateOverride == (XDAS_Int8)0x82)
1350 pStatus->sampleRateStatus = pStatus->sampleRateMeasured;
1352 // Update emphasis status:
1353 if ((pStatus->emphasisOverride & (XDAS_Int8)0x80) == 0) {
1354 if (pStatus->emphasisData == PAF_IEC_PREEMPHASIS_YES)
1355 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_YES;
1356 else
1357 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_NO;
1358 }
1359 else if (pStatus->emphasisOverride ==
1360 (XDAS_Int8 )(0x80+PAF_IEC_PREEMPHASIS_YES))
1361 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_YES;
1362 else /* IBEmphasisOverrideNo or other */
1363 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_NO;
1365 // Update precision control
1366 pInpBuf->precision = pStatus->precisionInput =
1367 pStatus->precisionOverride < 0
1368 ? pStatus->precisionDefault
1369 : pStatus->precisionOverride > 0
1370 ? pStatus->precisionOverride
1371 : pStatus->precisionDetect > 0
1372 ? pStatus->precisionDetect
1373 : pStatus->precisionDefault;
1375 return 0;
1376 }
1379 /*==============================================================================
1380 * This function updates input buffer config based on frame information provided
1381 * by I/O DATA.
1382 ==============================================================================*/
1383 void asitUpdateInpBufConfig(PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp)
1384 {
1385 PAF_InpBufConfig *pBufConfig;
1386 ioDataCtl_t ioDataCtl;
1388 /* Get information for reading input data */
1389 ioDataCtl.code = IODATA_CTL_GET_INPBUFFINFO;
1390 ioDataControl(pInp->hIoData, &ioDataCtl);
1392 if(ioDataCtl.param.dataReadInfo.frameSize != pInp->phyXferSize) {
1393 // Fatal error!
1394 TRACE_VERBOSE0("TaskAsip: error in updating I/O");
1395 SW_BREAKPOINT;
1396 }
1398 pBufConfig = &(pAstCfg->xInp[pAstCfg->masterDec].inpBufConfig);
1400 //JXTODO: do we need to gate here?
1401 //key = GateMP_enter(gateHandle);
1403 pBufConfig->base.pVoid = ioDataCtl.param.dataReadInfo.buffBase;
1404 pBufConfig->sizeofBuffer = ioDataCtl.param.dataReadInfo.buffSize;
1405 pBufConfig->pntr.pSmInt = ioDataCtl.param.dataReadInfo.startAddress;
1407 // Leave the gate
1408 //GateMP_leave(gateHandle, key);
1410 TRACE_TERSE2("Frame start address: 0x%x., preamble: 0x%x",
1411 (UInt)ioDataCtl.param.dataReadInfo.startAddress,
1412 *(UInt *)ioDataCtl.param.dataReadInfo.startAddress);
1413 }
1415 /*==============================================================================
1416 * Decide source after SYNC is found, i.e. either bitstream preamble is detected
1417 * or it times out to PCM.
1418 ==============================================================================*/
1419 Int asitDecideSource(PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp,
1420 ioDataAutoDetStat_t *autoDetStatus)
1421 {
1422 Int sourceConfig, sourceSelect, sourceProgram;
1423 Int zMD;
1424 char asipMsgBuf[ASP_MSG_BUF_LEN];
1425 Int status;
1427 // Get the configured source
1428 zMD = pAstCfg->masterDec;
1429 sourceConfig = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
1430 GATEMP_INDEX_DEC);
1432 if(autoDetStatus->syncState == IODATA_SYNC_PCM) {
1433 if (sourceConfig == PAF_SOURCE_DSD1 || sourceConfig == PAF_SOURCE_DSD2 ||
1434 sourceConfig == PAF_SOURCE_DSD3) {
1435 sourceProgram = sourceConfig;
1436 }
1437 else {
1438 sourceProgram = PAF_SOURCE_PCM;
1439 }
1440 }
1442 if(autoDetStatus->syncState == IODATA_SYNC_BITSTREAM) {
1443 uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
1444 sourceProgram = IECpafSource[pc];
1445 }
1447 // write the decided source program to memory
1448 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram), sourceProgram,
1449 GATEMP_INDEX_DEC);
1451 // now that we have some input classification, and possibly an outstanding
1452 // input frame, we determine whether or not to call decodeProcessing and with
1453 // what decAlg.
1454 sourceSelect = PAF_SOURCE_NONE;
1456 switch (sourceConfig)
1457 {
1458 // If autodetecting, decoding everything, and input is something
1459 // (i.e. bitstream or PCM) then decode.
1460 case PAF_SOURCE_AUTO:
1461 if (sourceProgram >= PAF_SOURCE_PCM) {
1462 sourceSelect = sourceProgram; // use whatever from autodet
1463 }
1464 break;
1466 // If autodetecting, decoding only PCM, and input is PCM then decode.
1467 case PAF_SOURCE_PCMAUTO:
1468 if (sourceProgram == PAF_SOURCE_PCM) {
1469 // only expect autodet to give PAF_SOURCE_PCM, otherwise set to NONE
1470 sourceSelect = sourceProgram;
1471 }
1472 break;
1474 // If autodetecting, decoding only bitstreams, and input is a bitstream then decode.
1475 case PAF_SOURCE_BITSTREAM:
1476 if (sourceProgram >= PAF_SOURCE_AC3) {
1477 sourceSelect = sourceProgram;
1478 }
1479 break;
1481 // If autodetecting, decoding only DTS, and input is DTS then decode.
1482 case PAF_SOURCE_DTSALL:
1483 switch (sourceProgram)
1484 {
1485 case PAF_SOURCE_DTS11:
1486 case PAF_SOURCE_DTS12:
1487 case PAF_SOURCE_DTS13:
1488 case PAF_SOURCE_DTS14:
1489 case PAF_SOURCE_DTS16:
1490 case PAF_SOURCE_DTSHD:
1491 sourceSelect = sourceProgram;
1492 break;
1493 }
1494 break;
1496 // All others, e.g., force modes, fall through to here.
1497 // If user made specific selection then program must match select.
1498 // (NB: this compare relies on ordering of PAF_SOURCE)
1499 default:
1500 sourceSelect = sourceConfig;
1501 if ((sourceSelect >= PAF_SOURCE_PCM) && (sourceSelect <= PAF_SOURCE_N)) {
1502 if (sourceProgram != sourceSelect) {
1503 sourceSelect = PAF_SOURCE_NONE;
1504 }
1505 }
1506 break;
1507 }
1509 // if we didn't find any matches then skip
1510 if (sourceSelect == PAF_SOURCE_NONE) {
1511 TRACE_VERBOSE0("TaskAsip: no matching source type, continue");
1512 return ASIT_ERR_NO_MATCHING_SOURCE;
1513 }
1515 #ifndef DEBUG_SKIP_DECODING
1516 // send source select message to slave
1517 *(Int32 *)&asipMsgBuf[0] = sourceSelect;
1518 status = AspMsgSnd(gPAF_ASIT_config.hAspMsgMaster, ASP_SLAVE_DEC_SOURCE_SELECT, asipMsgBuf);
1519 if (status != ASP_MSG_NO_ERR)
1520 {
1521 TRACE_VERBOSE0("TaskAsip: error in sending SOURCE_SELECT message");
1522 SW_BREAKPOINT;
1523 }
1524 status = AspMsgRcvAck(gPAF_ASIT_config.hAspMsgMaster, ASP_MASTER_DEC_SOURCE_SELECT_DONE, NULL, TRUE);
1525 if (status != ASP_MSG_NO_ERR)
1526 {
1527 TRACE_VERBOSE0("TaskAsip: error in receiving SOURCE_SELECT ack message");
1528 SW_BREAKPOINT;
1529 }
1530 #endif
1532 pInp->sourceSelect = sourceSelect;
1533 pInp->sourceProgram = sourceProgram;
1535 return ASIT_NO_ERR;
1536 } /* asitDecideSource */
1538 /*==============================================================================
1539 * After SYNC is found, i.e. either bitstream preamble is detected or it times
1540 * out to PCM, update input buffer config and I/o components accordingly.
1541 ==============================================================================*/
1542 Int asitUpdateIoComps(const PAF_ASIT_Params *pP, PAF_AST_Config *pAstCfg,
1543 PAF_AST_IoInp *pInp, ioDataAutoDetStat_t *autoDetStatus)
1544 {
1545 Int sourceConfig;
1546 Int zMD, deliverZeros;
1547 int ioFrameLength, decFrameLength;
1548 PAF_InpBufConfig *pBufConfig;
1549 ioPhyCtl_t ioPhyCtl;
1550 ioDataCtl_t ioDataCtl;
1552 zMD = pAstCfg->masterDec;
1553 pBufConfig = &pAstCfg->xInp[zMD].inpBufConfig;
1555 // Compute decoder frame length based on source selection
1556 decFrameLength = getFrameLengthSourceSel(pP, pInp->sourceSelect);
1558 pAstCfg->xDec[zMD].decodeControl.frameLength = decFrameLength;
1559 pAstCfg->xDec[zMD].decodeInStruct.sampleCount = decFrameLength;
1560 pAstCfg->xDec[zMD].decodeControl.sampleRate = PAF_SAMPLERATE_UNKNOWN;
1562 // Decide frame length for I/O DATA and I/O PHY
1563 if(autoDetStatus->syncState == IODATA_SYNC_PCM) {
1564 // For PCM, I/O frame length is decode frame length multiplied by stride
1565 ioFrameLength = decFrameLength * pInp->stride;
1567 pBufConfig->sizeofElement = WORD_SIZE_PCM;
1568 pBufConfig->frameLength = pBufConfig->lengthofData = ioFrameLength;
1570 // Configure I/O DATA PCM frame length
1571 ioDataCtl.code = IODATA_CTL_SET_PCM_FRAME_LENGTH;
1572 ioDataCtl.param.frameLengthPcm = ioFrameLength;
1573 ioDataControl(pInp->hIoData, &ioDataCtl);
1575 // Change I/O PHY transfer size to PCM frame size
1576 pInp->phyXferSize = ioFrameLength*(WORD_SIZE_PCM);
1578 // Adjust I/O BUFF delay and read pointer - to make sure read pointers always point to
1579 // PCM data from 1st I2S (out of 4 for HDMI 4xI2S)
1580 // Adjust delay and don't mark input buffer as read complete
1581 //ioBuffAdjustDelay(pInp->hIoBuff, pInp->phyXferSize);
1583 // Stop swapping data
1584 //pInp->swapData = FALSE;
1585 }
1586 else {
1587 // For bitstream, I/O frame length is the frame length of the bitstream
1588 uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
1589 ioFrameLength = iecFrameLength[pc];
1591 /*
1592 if( (pc == 0x11) && (DTSHDSubType == 3)
1593 && (PAF_ASP_sampleRateHzTable[pBufConfig->pBufStatus->sampleRateStatus][PAF_SAMPLERATEHZ_STD] <=48000.0))
1594 pDevExt->sourceProgram = PAF_SOURCE_DXP; // LBR is 23
1596 if (pc == 1)
1597 pDevExt->elementSize = 4288;
1598 else if (pc == 0x11) {
1599 pDevExt->frameLength = (pDevExt->pIECFrameLength[pc] << DTSHDSubType);
1600 pDevExt->lengthofData = pDevExt->frameLength;
1601 }
1602 */
1604 pBufConfig->sizeofElement = WORD_SIZE_BITSTREAM;
1605 pBufConfig->frameLength = ioFrameLength;
1606 pBufConfig->lengthofData = ioFrameLength - IEC_HEADER_LENGTH;
1608 // Change I/O PHY transfer size to bitstream frame size
1609 pInp->phyXferSize = ioFrameLength*WORD_SIZE_BITSTREAM;
1610 }
1612 pBufConfig->stride = pInp->stride; // common for PCM and bitstream
1614 // Configure I/O PHY transfer size
1615 ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
1616 ioPhyCtl.params.xferFrameSize = pInp->phyXferSize;
1617 ioPhyControl(pInp->hIoPhy, &ioPhyCtl);
1619 // Decide if zeros should be delivered based on the configured source
1620 sourceConfig = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
1621 GATEMP_INDEX_DEC);
1623 if(autoDetStatus->syncState == IODATA_SYNC_PCM) {
1624 // Bitstream preamble is not found and it times out -> assume this is PCM
1625 deliverZeros = autoDetStatus->deliverZeros;
1626 if (sourceConfig == PAF_SOURCE_PCM || sourceConfig == PAF_SOURCE_DSD1 ||
1627 sourceConfig == PAF_SOURCE_DSD2 || sourceConfig == PAF_SOURCE_DSD3) {
1628 // set to one -- ensures that PCM decode calls made before data is
1629 // available will result in zero output.
1630 // (mostly needed for PA15 since, currently, all other frameworks
1631 // require a frame of data before the first decode call.
1632 deliverZeros = TRUE; // override deliverZeros returned by ioDataControl
1633 }
1635 // update input buffer config structure
1636 pBufConfig->deliverZeros = deliverZeros;
1637 }
1639 //JXTODO: decide what to do with hRxSio
1640 //temporary - does ARM use hRxSio or just check if it is not NULL?
1641 pAstCfg->xInp[zMD].hRxSio = pInp->hIoData;
1642 pAstCfg->xInp[zMD].pInpBuf = &(pAstCfg->xInp[zMD].inpBufConfig);
1644 return ASIT_NO_ERR;
1645 } /* asitUpdateIoComps */
1647 #if 0
1648 #ifndef IO_LOOPBACK_TEST
1649 #if OUTPUT_FRAME_LENGTH == INPUT_FRAME_LENGTH
1650 U8 pcmbuf[OUTPUT_FRAME_SIZE];
1651 #else
1652 #error Input frame length is not equal to output frame length!
1653 #endif
1655 Int rxDecodePcm(PAF_AST_IoInp *pInp)
1656 {
1657 ioDataCtl_t ioDataCtl;
1658 void *buffBase;
1659 void *dataStartAddress;
1660 size_t buffSize, frameSize, size1, size2;
1662 /* Get information for reading input data */
1663 ioDataCtl.code = IODATA_CTL_GET_INPBUFFINFO;
1664 ioDataControl(pInp->hIoData, &ioDataCtl);
1666 buffBase = ioDataCtl.param.dataReadInfo.buffBase;
1667 buffSize = ioDataCtl.param.dataReadInfo.buffSize;
1668 dataStartAddress = ioDataCtl.param.dataReadInfo.startAddress;
1669 frameSize = ioDataCtl.param.dataReadInfo.frameSize;
1671 // Copy PCM data to output buffer
1672 if(((size_t)dataStartAddress+frameSize) <= ((size_t)buffBase+buffSize)) {
1673 // Input buffer doesn't wrap around
1674 Cache_inv(dataStartAddress, frameSize, Cache_Type_ALL, TRUE);
1675 memcpy((void *)&pcmbuf[0], dataStartAddress, frameSize);
1676 }
1677 else {
1678 // Input buffer wraps around
1679 size1 = (size_t)buffBase + buffSize - (size_t)dataStartAddress;
1680 size2 = frameSize - size1;
1681 Cache_inv(dataStartAddress, size1, Cache_Type_ALL, TRUE);
1682 memcpy((void *)&pcmbuf[0], dataStartAddress, size1);
1684 Cache_inv(buffBase, size2, Cache_Type_ALL, TRUE);
1685 memcpy((void *)&pcmbuf[size1], buffBase, size2);
1686 }
1689 return ASIT_NO_ERR;
1690 }
1693 Int rxDecodePlayZero(PAF_AST_IoInp *pInp)
1694 {
1695 return ASIT_NO_ERR;
1696 }
1697 #endif
1699 #endif
1701 Int asitEvtErrCheck(UInt actualEvents, UInt expectedEvents)
1702 {
1703 TRACE_VERBOSE2("ASIT events error: actual events are: %d, expected events are: %d.",
1704 actualEvents, expectedEvents);
1706 return ASIT_ERR_EVENTS;
1707 }
1709 void asitErrorHandling(PAF_ASIT_Config *pAsitCfg, Int asitErr)
1710 {
1711 //UInt events;
1713 if(asitErr == ASIT_ERR_INPBUF_UNDERFLOW) {
1714 TRACE_VERBOSE0("ASIT error handling: input buffer underflows. No actions needed.");
1715 }
1717 if(asitErr == ASIT_AUTODET_TIME_OUT) {
1718 pAsitCfg->pIoInp[0].asipState = ASIT_RESET;
1719 pAsitCfg->pIoInp[0].numAsitRestart++;
1720 TRACE_VERBOSE1("ASIT error %d handling finished. Go to state ASIT_RESET.", asitErr);
1721 }
1723 if(asitErr == ASIT_ERR_DECODE_QUIT) {
1724 TRACE_VERBOSE0("ASIT error handling: DECODE_QUIT - clear INPDATA event.");
1725 #if 0
1726 // Pend on INPTDATA event that should have been posted before decoding quits.
1727 events = Event_pend(asitEvent, ASIT_EVTMSK_NONE, ASIT_EVTMSK_INPDATA,
1728 BIOS_WAIT_FOREVER);
1730 // Marks I/O PHY transfer and I/O BUFF write complete
1731 asitPhyTransferComplete(&pAsitCfg->pIoInp[0]);
1733 // Keep I/O BUFF read pointers going
1734 asitBypassIoData(&pAsitCfg->pIoInp[0]);
1735 #endif
1736 pAsitCfg->pIoInp[0].asipState = ASIT_RESET;
1737 pAsitCfg->pIoInp[0].numAsitRestart++;
1738 TRACE_VERBOSE1("ASIT error %d handling finished. Go to state ASIT_RESET.", asitErr);
1739 }
1741 if(asitErr == ASIT_ERR_EVENTS) {
1742 pAsitCfg->pIoInp[0].asipState = ASIT_RESET;
1743 pAsitCfg->pIoInp[0].numAsitRestart++;
1744 TRACE_VERBOSE1("ASIT error %d handling: events error. Go to state ASIT_RESET.", asitErr);
1745 }
1747 return;
1748 } /* asitErrorHandling */
1751 //////////////////////////////////////////////////////////////////////////////
1752 void asitPostInfoEvent()
1753 {
1754 Event_post(gAsitEvtHandle, ASIT_EVTMSK_INFOACK);
1755 }
1757 void asitPostDecEvent()
1758 {
1759 Event_post(gAsitEvtHandle, ASIT_EVTMSK_DECACK);
1760 }
1761 //////////////////////////////////////////////////////////////////////////////
1763 /* Nothing past this line */