977fbf17c9913032d783933e091d9baf0aabc7f6
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>
42 #include "procsdk_audio_typ.h"
43 #include "audioStreamInpProc.h"
44 #include "audioStreamProc_common.h"
45 #include "aspMsg_common.h"
46 #include "aspMsg_master.h"
47 #include "asperr.h"
48 #include "common.h"
50 #include "audk2g.h"
51 #include "audk2g_audio.h"
52 #include "mcasp_cfg.h"
53 #include "ioConfig.h" //TODO: remove this header
54 #include "ioBuff.h"
55 #include "ioPhy.h"
56 #include "ioData.h"
59 #define STRIDE_WORST_CASE 32 // 4-byte (32-bit) word, 2 slots, 4 serializers
61 #define SYNC_PC_MASK 0x1F
62 #define SYNC_SUBTYPE_MASK 0x700
63 #define SYNC_SUBTYPE_SHIFT 8
64 #define SYNC_SUBTYPE_DTSHD 0x11
65 #define SYNC_DDP 0x15
66 #define SYNC_THD 0x16
68 #define IEC_HEADER_LENGTH 4
70 #define INPUT_SWITCH_HANGOVER 8
72 //table needed until PAF_SOURCE is reordered to match IEC numbering
73 const SmUns IECpafSource[23] =
74 {
75 PAF_SOURCE_UNKNOWN, // 0: IEC NULL Type
76 PAF_SOURCE_AC3, // 1: Comments on 1-15 match IEC 61937 part 2.
77 PAF_SOURCE_UNKNOWN, // 2: IEC reserved
78 PAF_SOURCE_UNKNOWN, // 3: IEC pause
79 PAF_SOURCE_UNKNOWN, // 4: MPEG 1 layer 1
80 PAF_SOURCE_MP3, // 5: MPEG layer 2 or 3
81 PAF_SOURCE_UNKNOWN, // 6: MPEG 2 data with extension
82 PAF_SOURCE_AAC, // 7: MPEG-2 AAC ADTS
83 PAF_SOURCE_UNKNOWN, // 8: MPEG 2 layer 1 low sampling frequency
84 PAF_SOURCE_UNKNOWN, // 9: MPEG 2 layer 2 or 3 low sampling frequency
85 PAF_SOURCE_UNKNOWN, // 10: reserved
86 PAF_SOURCE_DTS, // 11: DTS type 1 (11 bit: 512 sample repeat period)
87 PAF_SOURCE_DTS12, // 12: DTS type 2 (12 bit: 1024 sample repeat period)
88 PAF_SOURCE_DTS13, // 13: DTS type 3 (13 bit: 2048 sample repeat period)
89 PAF_SOURCE_DTS14, // 14: ATRAC
90 PAF_SOURCE_UNKNOWN, // 15: ATRAC 2/3
91 PAF_SOURCE_THD, // 16
92 PAF_SOURCE_DTSHD, // 17
93 PAF_SOURCE_WMA9PRO, // 18
94 PAF_SOURCE_UNKNOWN, // 19
95 PAF_SOURCE_UNKNOWN, // 20
96 PAF_SOURCE_DDP, // 21
97 PAF_SOURCE_THD, // 22
98 };
100 /*
101 * Functions defined in other files and to be put into proper header files
102 */
103 extern Void taskAsipFxnInit(const PAF_ASIT_Params *pP,const PAF_ASIT_Patchs *pQ);
106 // avoid including sap_d10.h, which would cause symbol redefinition
107 // warning (MCASP_PFUNC_XXX)
108 extern XDAS_Int32 D10_init();
109 extern XDAS_Int32 D10_RxControl(const void *pD10RxParams,
110 XDAS_Int32 code, XDAS_Int32 arg);
112 /*
113 * Functions only used in this file
114 */
115 int asipPrepareProcessing();
116 int asipIoCompsInit(PAF_AST_InpBuf * pInpBuf, PAF_AST_IoInp * pInpIo);
117 void asipProcInit(PAF_AST_IoInp *pInp);
118 void asipIoPhyPrime(PAF_AST_IoInp *pInpIo);
119 void asipPhyTransferPend(void);
120 void asipPhyTransferComplete(PAF_AST_IoInp * pInpIo);
121 void asipPhyTransferStart(PAF_AST_IoInp *pInpIo);
122 Int asipSelectDevices(const PAF_ASIT_Patchs *pQ, PAF_AST_IoInp *pInp);
123 Int asipUpdateInputStatus(const void *pRxParams, PAF_InpBufStatus *pStatus,
124 PAF_InpBufConfig *pInpBuf);
126 //Int asipDecideSource(const PAF_ASIT_Params *pP, PAF_AST_Config *pAstCfg, asipDecProc_t *pDec);
127 Int asipProcessing(const PAF_ASIT_Params *pP,
128 const PAF_ASIT_Patchs *pQ,
129 PAF_ASIT_Config *pAsitCfg);
130 void asipErrorHandling(PAF_AST_Config *pAstCfg, int asipErrno);
132 /*
133 * variables/structures to be put into proper global structures
134 */
135 extern Semaphore_Handle asipSemRx;
136 extern PAF_ASIT_Config gPAF_ASIT_config;
137 extern const MdUns iecFrameLength[23];
138 extern Ptr hMcaspRxChan;
141 enum
142 {
143 ASIP_SOURCE_DETECTION,
144 ASIP_DECODE,
145 ASIP_SWITCH_TO_PCM,
146 };
148 enum
149 {
150 ASIP_INPUT_PREPARATION,
151 ASIP_INPUT_PROCESSING
152 };
156 #define ASIP_DEBUG
158 #ifdef ASIP_DEBUG
159 /* define the following as global variables for easy debugging */
160 int asipLoopCount1, asipLoopCount2;
161 Int asipErrno;
162 Int inputReadyForProcessing;
163 #endif
165 /*
166 * ======== taskAsipFxn ========
167 * Audio Stream Input Processing task function
168 */
169 #ifndef PASDK_SIO_DEV
170 #ifndef IO_LOOPBACK_TEST
171 Void taskAsipFxn( // ASIP task function for new I/O
172 #else
173 Void taskAsipFxn_NewIO_Not_Used( // not used for loopback test
174 #endif
175 #else
176 Void taskAsipFxn_NewIO_Not_USED( // not used for SIO/DEV based I/O
177 #endif
178 const PAF_ASIT_Params *pP,
179 const PAF_ASIT_Patchs *pQ)
180 {
181 PAF_ASIT_Config *pAsitCfg; /* ASIT configuration pointer */
182 PAF_AST_Config *pAstCfg; /* AST Common (shared) configuration pointer */
183 PAF_AST_IoInp *pInp; /* Input I/O components */
184 Int as; /* Audio Stream Number (1, 2, etc.) */
185 Int z; /* input/encode/stream/decode/output counter */
186 Int zMI;
187 #ifndef ASIP_DEBUG
188 int asipLoopCount1, asipLoopCount2;
189 Int asipErrno;
190 Int inputReadyForProcessing;
191 #endif
193 Log_info0("Enter taskAsipFxn()");
195 taskAsipFxnInit(pP, pQ); // initialization of input task
197 //
198 // Audio Stream Input Task Configuration (*pAsitCfg):
199 //
200 pAsitCfg = &gPAF_ASIT_config; // initialize pointer to task configuration
201 pAstCfg = pAsitCfg->pAstCfg; // pointer to AST common (shared) configuration
203 /* Set Audio Stream Number (1, 2, etc.) */
204 as = pAstCfg->as;
206 //
207 // Determine decoder and stream indices associated with the master input
208 //
209 zMI = pP->zone.master;
210 pInp = &pAsitCfg->pIoInp[zMI]; // pointer to input I/O components
212 for (z=STREAM1; z < STREAMN; z++)
213 {
214 TRACE_VERBOSE1("TaskAsip: AS%d: running", as+z);
215 }
217 TRACE_TERSE0("TaskAsip: Entering Main Loop.");
219 //
220 // Main processing loop
221 //
222 asipLoopCount1 = 0;
223 asipLoopCount2 = 0;
224 asipErrno = 0;
225 pInp->asipState = ASIP_INPUT_PREPARATION;
227 for (;;)
228 {
229 asipLoopCount1++;
231 switch (pInp->asipState)
232 {
233 case ASIP_INPUT_PREPARATION:
234 // Indicate decoder no decoding yet
235 pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_NONE);
237 // 5 system tick, or 5 msec. Should remove this later when implementing
238 // event based scheduling.
239 Task_sleep(5);
241 inputReadyForProcessing = asipPrepareProcessing(pP, pQ, pAsitCfg, &asipErrno);
242 if (inputReadyForProcessing) {
243 // Input is ready for processing, so we initialize the I/O components
244 asipIoCompsInit(&pAstCfg->xInp[zMI], pInp);
246 // Initialize ASIP processing
247 asipProcInit(pInp);
249 // Start I/O physical layer by priming McASP LLD for input
250 asipIoPhyPrime(pInp);
252 pInp->asipState = ASIP_INPUT_PROCESSING;
253 }
254 break;
256 case ASIP_INPUT_PROCESSING:
257 // Pending on I/O PHY transfer
258 asipPhyTransferPend();
260 // Marks I/O PHY transfer and I/O BUFF write complete
261 asipPhyTransferComplete(pInp);
263 // Main function to process input data
264 asipErrno = asipProcessing(pP, pQ, pAsitCfg);
266 // Start next transfer
267 asipPhyTransferStart(pInp);
269 if(asipErrno) {
270 asipErrorHandling(pAstCfg, asipErrno);
272 pInp->asipState = ASIP_INPUT_PREPARATION;
273 }
275 break;
277 default:
278 break;
279 }
280 } // for (;;)
282 } /* taskAsipFxn */
285 /*===========================================================================
286 * ASIP processing preparation
287 * Output:
288 * - return TRUE (input is ready) or FALSE (input is not ready)
289 * - *asipErrno Error number
290 ============================================================================*/
291 Int asipPrepareProcessing(const PAF_ASIT_Params *pP,
292 const PAF_ASIT_Patchs *pQ,
293 PAF_ASIT_Config *pC,
294 Int *asipErrno)
295 {
296 Int as, zMS, zMI, zMD;
297 Int sourceConfig, mode;
298 PAF_AST_Config *pAstCfg;
299 PAF_AST_IoInp *pInp; /* I/O components for input */
301 pAstCfg = pC->pAstCfg; // pointer to AST common (shared) configuration
302 as = pAstCfg->as;
303 zMI = pP->zone.master;
304 zMD = pAstCfg->masterDec;
305 zMS = pAstCfg->masterStr;
306 pInp = pC->pIoInp; // pointer to input I/O components
308 *asipErrno = 0;
310 // Select source and initialize physical layer / HW interface
311 *asipErrno = asipSelectDevices(pQ, pInp);
312 if (*asipErrno) {
313 TRACE_TERSE2("TaskAsip: selectDevices returned asipErrno = 0x%04x at line %d. AS%d", *asipErrno, as+zMS);
314 return FALSE; // Input is not ready for processing due to error
315 }
317 // If no master input selected then we don't know what may be at the input,
318 // so set to unknown and skip any remaining processing
319 if (!pInp[zMI].pRxParams) {
320 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
321 (Int8)PAF_SOURCE_UNKNOWN, GATEMP_INDEX_DEC);
323 TRACE_VERBOSE1("TaskAsip: AS%d: No input selected...", as+zMS);
324 return FALSE; // No error, but input is not ready for processing
325 }
327 // If here then we have a valid input so query its status
328 *asipErrno = asipUpdateInputStatus(pInp[zMI].pRxParams,
329 &pAstCfg->xInp[zMI].inpBufStatus,
330 &pAstCfg->xInp[zMI].inpBufConfig);
331 if(*asipErrno) {
332 TRACE_VERBOSE1("TaskAsip: updateInputStatus returns 0x%x", *asipErrno);
333 return FALSE; // Input is not ready for processing due to error
334 }
336 // If master decoder is not enabled, or the input is unlocked, then do nothing
337 mode = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.mode),
338 GATEMP_INDEX_DEC);
339 if (!mode || !pAstCfg->xInp[zMI].inpBufStatus.lock)
340 {
341 TRACE_VERBOSE0("TaskAsip: Not locked, continue");
342 return FALSE; // No error, but input is not ready for processing
343 }
345 // Check selected source: sourceSelect is set by another task, AIP or AFP
346 sourceConfig = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
347 GATEMP_INDEX_DEC);
348 // If no source selected then do nothing
349 if(sourceConfig == PAF_SOURCE_NONE) {
350 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
351 (Int8)PAF_SOURCE_NONE, GATEMP_INDEX_DEC);
352 TRACE_VERBOSE1("TaskAsip: AS%d: no source selected, continue", as+zMS);
353 return FALSE; // No error, but input is not ready for processing
354 }
356 // If we want pass processing then proceed directly
357 if (sourceConfig == PAF_SOURCE_PASS)
358 {
359 TRACE_VERBOSE1("TaskAsip: AS%d: Pass processing ...", as+zMS);
360 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram),
361 (Int8)PAF_SOURCE_PASS, GATEMP_INDEX_DEC);
363 pP->fxns->sourceDecode(pP, pQ, pC, PAF_SOURCE_PASS);
364 if (pP->fxns->passProcessing) {
365 *asipErrno = pP->fxns->passProcessing(pP, pQ, pC, NULL);
366 }
367 else {
368 TRACE_TERSE2("TaskAsip: AS%d: Pass Processing not supported, asipErrno 0x%x", as+zMS, ASPERR_PASS);
369 *asipErrno = ASPERR_PASS;
370 }
372 TRACE_VERBOSE0("TaskAsip: continue");
373 return FALSE; // Error or not, input is not ready for processing
374 }
376 // No error and input processing is ready
377 return TRUE;
378 } /* asipPrepareProcessing */
380 /*===========================================================================
381 * Initialize I/O components for input processing
382 ============================================================================*/
383 int asipIoCompsInit(PAF_AST_InpBuf * pInpBuf, PAF_AST_IoInp * pInpIo)
384 {
385 // Initialize I/O BUFF and I/O PHY components for input task
386 ioBuffParams_t ioBuffParams;
387 ioPhyParams_t ioPhyParams;
388 ioDataParam_t ioDataCfg;
390 ioBuffParams.base = pInpBuf->inpBufConfig.base.pVoid;
391 ioBuffParams.size = pInpBuf->inpBufConfig.allocation/STRIDE_WORST_CASE*STRIDE_WORST_CASE;
392 ioBuffParams.sync = IOBUFF_WRITE_SYNC;
393 ioBuffParams.nominalDelay = INPUT_FRAME_SIZE_DEF;
394 if(ioBuffInit(pInpIo->hIoBuff, &ioBuffParams) != IOBUFF_NOERR) {
395 return (-1); // to remove magic number
396 }
398 ioPhyParams.ioBuffHandle = pInpIo->hIoBuff;
399 ioPhyParams.xferFrameSize = INPUT_FRAME_SIZE_DEF;
400 ioPhyParams.mcaspChanHandle = pInpIo->hMcaspChan;
401 ioPhyParams.ioBuffOp = IOPHY_IOBUFFOP_WRITE;
402 if(ioPhyInit(pInpIo->hIoPhy, &ioPhyParams) != IOPHY_NOERR) {
403 return (-1); // to remove magic number
404 }
406 ioDataCfg.ioBuffHandle = pInpIo->hIoBuff;
407 ioDataCfg.unknownSourceTimeOut = pInpBuf->inpBufConfig.pBufStatus->unknownTimeout;
408 ioDataCfg.frameLengthsIEC = (uint_least16_t *)&iecFrameLength[0];
409 ioDataCfg.frameLengthPCM = INPUT_FRAME_SIZE_PCM / WORD_SIZE_PCM;
410 ioDataCfg.frameLengthDef = INPUT_FRAME_SIZE_DEF / WORD_SIZE_BITSTREAM;
411 ioDataCfg.ibMode = pInpBuf->inpBufConfig.pBufStatus->mode;
412 ioDataCfg.zeroRunRestart = pInpBuf->inpBufConfig.pBufStatus->zeroRunRestart;
413 ioDataCfg.zeroRunTrigger = pInpBuf->inpBufConfig.pBufStatus->zeroRunTrigger;
415 if(ioDataInit(pInpIo->hIoData, &ioDataCfg) != IODATA_NO_ERR) {
416 return (-1); // to remove magic number
417 }
419 pInpIo->numPrimeXfers = NUM_PRIME_XFERS;
420 pInpIo->phyXferSize = ioPhyParams.xferFrameSize;
421 pInpIo->switchHangOver = 0;
422 pInpIo->preSyncState = IODATA_SYNC_NONE;
424 return 0;
425 } /* asipIoCompsInit */
427 /*======================================================================================
428 * This function initializes ASIP processing
429 *====================================================================================*/
430 void asipProcInit(PAF_AST_IoInp *pInp)
431 {
432 pInp->swapData = SWAP_INPUT_DATA;
433 pInp->asipProcState = ASIP_SOURCE_DETECTION;
434 pInp->switchHangOver = 0;
435 }
437 /*======================================================================================
438 * I/O physical layer prime operation required by McASP LLD
439 *====================================================================================*/
440 void asipIoPhyPrime(PAF_AST_IoInp *pInp)
441 {
442 Int32 count;
444 for(count = 0; count < pInp->numPrimeXfers; count++)
445 {
446 ioPhyXferSubmit(pInp->hIoPhy);
447 #ifdef ASIP_DEBUG
448 //pInp->numXferStart++;
449 #endif
450 }
451 } /* asipIoPhyPrime */
453 /*======================================================================================
454 * This function pends on I/O PHY transfer for the input task
455 *====================================================================================*/
456 void asipPhyTransferPend()
457 {
458 // asipSemRx needs to be placed into some data structure
459 Semaphore_pend(asipSemRx, BIOS_WAIT_FOREVER);
460 } /* asipPhyTransferPend */
462 /*======================================================================================
463 * This function marks the I/O PHY transfer as complete
464 *====================================================================================*/
465 void asipPhyTransferComplete(PAF_AST_IoInp * pInpIo)
466 {
467 // Mark underlining I/O BUFF write complete and swap data if needed
468 ioPhyXferComplete(pInpIo->hIoPhy, pInpIo->swapData);
469 } /* asipPhyTransferComplete */
472 /*======================================================================================
473 * McASP LLD call back function
474 *====================================================================================*/
475 void asipMcaspCallback(void* arg, MCASP_Packet *mcasp_packet)
476 {
477 /* post semaphore */
478 if(mcasp_packet->arg == IOPHY_XFER_FINAL) {
479 Semaphore_post(asipSemRx);
480 } else {
481 ; // intermediate packet due to buffer wrapping around
482 }
483 }
485 /*======================================================================================
486 * This function checks if McASP Rx for input overruns
487 *====================================================================================*/
488 int asipCheckMcaspRxOverrun(Ptr mcaspChanHandle)
489 {
490 Mcasp_errCbStatus mcaspErrStat;
492 mcaspControlChan(mcaspChanHandle, Mcasp_IOCTL_CHAN_QUERY_ERROR_STATS, &mcaspErrStat);
494 return (mcaspErrStat.isRcvOvrRunOrTxUndRunErr);
495 }
497 /*======================================================================================
498 * This function restarts McASP LLD channel for input
499 *====================================================================================*/
500 void asipMcaspRxRestart(void)
501 {
502 mcaspRxReset();
503 mcaspRxCreate();
504 }
506 /*======================================================================================
507 * This function starts an I/O PHY transfer
508 *====================================================================================*/
509 void asipPhyTransferStart(PAF_AST_IoInp *pInpIo)
510 {
511 if(asipCheckMcaspRxOverrun(pInpIo->hMcaspChan)) {
512 #ifdef ASIP_DEBUG
513 pInpIo->numInputOverrun++;
514 #endif
515 asipMcaspRxRestart();
516 }
517 else {
518 if(ioPhyXferSubmit(pInpIo->hIoPhy)==IOPHY_ERR_BUFF_OVERFLOW) {
519 // Input buffer overflows!
520 printf("\nInput buffer overflows!\n");
521 exit(0);
522 }
523 else {
524 // Input buffer operates normally
525 ;
526 }
527 #ifdef ASIP_DEBUG
528 //pInpIo->numXferStart++;
529 #endif
530 }
531 }
533 Int d10Initialized = 0;
534 //extern Audk2g_STATUS mcaspAudioConfig(void);
535 extern void McaspDevice_init(void);
537 /*======================================================================================
538 * This function initializes HW interface and selects the right device for input
539 *====================================================================================*/
540 Int asipSelectDevices(const PAF_ASIT_Patchs *pQ, PAF_AST_IoInp *pInp)
541 {
542 Audk2g_STATUS status;
544 //more configuration is needed to abstract out D10
545 if(!d10Initialized) {
546 /* Initialize McASP HW details */
547 McaspDevice_init();
549 D10_init();
551 #ifdef INPUT_SPDIF
552 // Input is DIR
553 status = audk2g_AudioSelectClkSrc(AUDK2G_AUDIO_CLK_SRC_DIR);
554 #else
555 // Input is HDMI
556 status = audk2g_AudioSelectClkSrc(AUDK2G_AUDIO_CLK_SRC_I2S);
557 #endif
558 if(status != Audk2g_EOK) {
559 Log_info0("audk2g_AudioSelectClkSrc Failed!\n");
560 return ASIP_ERR_D10_CFG;
561 }
562 audk2g_delay(50000); // Without delay between these 2 calls system aborts.
564 /* Initialize McASP module */
565 status = mcaspAudioConfig(); //defined in newio\fw\mcasp_cfg.c
566 if(status != Audk2g_EOK) {
567 Log_info0("McASP Configuration Failed!\n");
568 return ASIP_ERR_MCASP_CFG;
569 }
571 pInp->hMcaspChan = hMcaspRxChan;
572 d10Initialized = 1;
573 }
575 /////////////// TODO: HW interface selection and initialization //////////////
576 ////// to add what PAF_ASIT_selectDevices() does /////////
577 #ifdef IO_HW_INTERFACE
578 pInp->pRxParams = pQ->devinp->x[IO_HW_INTERFACE];
579 #else
580 pInp->pRxParams = NULL;
581 #endif
583 return 0;
584 } /* asipSelectDevices */
586 /*======================================================================================
587 * This function updates input status
588 *====================================================================================*/
589 Int asipUpdateInputStatus(const void *pRxParams, PAF_InpBufStatus *pStatus,
590 PAF_InpBufConfig *pInpBuf)
591 {
592 Int asipErrno;
594 PAF_SIO_InputStatus inputStatus;
596 // initialize all values to unknown so that device specific
597 // driver layer need only fill in those entries that it is aware of.
598 // This allows extensibility of the structure without requiring users
599 // to re-code.
600 inputStatus.lock = 0;
601 inputStatus.sampleRateData = PAF_SAMPLERATE_UNKNOWN;
602 inputStatus.sampleRateMeasured = PAF_SAMPLERATE_UNKNOWN;
603 inputStatus.nonaudio = PAF_IEC_AUDIOMODE_UNKNOWN;
604 inputStatus.emphasis = PAF_IEC_PREEMPHASIS_UNKNOWN;
606 //more configuration is needed to abstract out D10
607 asipErrno = D10_RxControl(pRxParams,
608 (Uns)PAF_SIO_CONTROL_GET_INPUT_STATUS,
609 (Arg) &inputStatus);
610 if (asipErrno) {
611 return asipErrno;
612 }
613 pStatus->sampleRateData = inputStatus.sampleRateData;
614 pStatus->sampleRateMeasured = inputStatus.sampleRateMeasured;
615 pStatus->nonaudio = inputStatus.nonaudio;
616 pStatus->emphasisData = inputStatus.emphasis;
618 // if MSB of override clear then use as reported lock
619 // if = 0x80 then use default [0x81]
620 // if = 0x81 then use measured (from device)
621 // others not defined or implemented
622 if ((pStatus->lockOverride & (XDAS_Int8)0x80) == 0)
623 pStatus->lock = pStatus->lockOverride;
624 else if (pStatus->lockOverride == (XDAS_Int8)0x80)
625 pStatus->lock = inputStatus.lock;
626 else if (pStatus->lockOverride == (XDAS_Int8)0x81)
627 pStatus->lock = inputStatus.lock;
629 // if MSB of override clear then use it as sample rate for system,
630 // if = 0x80 then use default [0x82]
631 // if = 0x81 then use data
632 // if = 0x82 then use measured
633 // others not defined or implemented
634 if ((pStatus->sampleRateOverride & (XDAS_Int8)0x80) == 0)
635 pStatus->sampleRateStatus = pStatus->sampleRateOverride;
636 else if (pStatus->sampleRateOverride == (XDAS_Int8)0x80)
637 pStatus->sampleRateStatus = pStatus->sampleRateMeasured;
638 else if (pStatus->sampleRateOverride == (XDAS_Int8)0x81)
639 pStatus->sampleRateStatus = pStatus->sampleRateData;
640 else if (pStatus->sampleRateOverride == (XDAS_Int8)0x82)
641 pStatus->sampleRateStatus = pStatus->sampleRateMeasured;
643 // Update emphasis status:
644 if ((pStatus->emphasisOverride & (XDAS_Int8)0x80) == 0) {
645 if (pStatus->emphasisData == PAF_IEC_PREEMPHASIS_YES)
646 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_YES;
647 else
648 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_NO;
649 }
650 else if (pStatus->emphasisOverride ==
651 (XDAS_Int8 )(0x80+PAF_IEC_PREEMPHASIS_YES))
652 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_YES;
653 else /* IBEmphasisOverrideNo or other */
654 pStatus->emphasisStatus = PAF_IEC_PREEMPHASIS_NO;
656 // Update precision control
657 pInpBuf->precision = pStatus->precisionInput =
658 pStatus->precisionOverride < 0
659 ? pStatus->precisionDefault
660 : pStatus->precisionOverride > 0
661 ? pStatus->precisionOverride
662 : pStatus->precisionDetect > 0
663 ? pStatus->precisionDetect
664 : pStatus->precisionDefault;
666 return 0;
667 }
669 /*==============================================================================
670 * After SYNC is found, i.e. either bitstream preamble is detected or it times
671 * out to PCM, update input buffer config and I/o components accordingly.
672 ==============================================================================*/
673 Int asipUpdateIoComps(PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp,
674 ioDataAutoDetStat_t *autoDetStatus)
675 {
676 Int sourceConfig;
677 Int zMD, deliverZeros;
678 int frameLength;
679 PAF_InpBufConfig *pBufConfig;
680 Audk2g_STATUS mcaspStatus;
681 ioPhyCtl_t ioPhyCtl;
683 zMD = pAstCfg->masterDec;
684 pBufConfig = &pAstCfg->xInp[zMD].inpBufConfig;
686 // Get the configured source
687 sourceConfig = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect),
688 GATEMP_INDEX_DEC);
690 if(autoDetStatus->syncState == IODATA_SYNC_PCM) {
691 // Bitstream preamble is not found and it times out -> assume this is PCM
692 deliverZeros = autoDetStatus->deliverZeros;
693 if (sourceConfig == PAF_SOURCE_PCM || sourceConfig == PAF_SOURCE_DSD1 ||
694 sourceConfig == PAF_SOURCE_DSD2 || sourceConfig == PAF_SOURCE_DSD3) {
695 // set to one -- ensures that PCM decode calls made before data is
696 // available will result in zero output.
697 // (mostly needed for PA15 since, currently, all other frameworks
698 // require a frame of data before the first decode call.
699 deliverZeros = TRUE; // override deliverZeros returned by ioDataControl
700 }
702 // update input buffer config structure
703 pBufConfig->deliverZeros = deliverZeros;
704 pBufConfig->sizeofElement = WORD_SIZE_PCM;
705 pBufConfig->frameLength = pBufConfig->lengthofData = INPUT_FRAME_LENGTH;
707 // reconfigure McASP LLD to transfer 32-bit unpacked data
708 //mcaspStatus = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_32);
709 //if(mcaspStatus != Audk2g_EOK) {
710 // return ASIP_ERR_MCASP_CFG;
711 //}
713 // Change I/O PHY transfer size to PCM frame size
714 pInp->phyXferSize = (INPUT_FRAME_LENGTH)*(WORD_SIZE_PCM);
716 // Adjust I/O BUFF delay and read pointer - to make sure read pointers always point to
717 // PCM data from 1st I2S (out of 4 for HDMI 4xI2S)
718 // Adjust delay and don't mark input buffer as read complete
719 ioBuffAdjustDelay(pInp->hIoBuff, pInp->phyXferSize);
721 // Stop swapping data
722 pInp->swapData = FALSE;
724 } /* IODATA_SYNC_PCM */
726 if(autoDetStatus->syncState == IODATA_SYNC_BITSTREAM) {
727 // Change I/O PHY transfer size to be the same as the bitstream frame size
728 uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
729 frameLength = iecFrameLength[pc] * WORD_SIZE_BITSTREAM;
731 // update input buffer config structure
732 pBufConfig->sizeofElement = WORD_SIZE_BITSTREAM;
733 pBufConfig->frameLength = frameLength;
734 pBufConfig->lengthofData = frameLength - IEC_HEADER_LENGTH;
736 /*
737 if (pc == 0x11 && DTSHDSubType == 3 && (PAF_ASP_sampleRateHzTable[pBufConfig->pBufStatus->sampleRateStatus][PAF_SAMPLERATEHZ_STD] <=48000.0))
738 pDevExt->sourceProgram = PAF_SOURCE_DXP; // LBR is 23
739 */
741 /* if (pc == 1)
742 pDevExt->elementSize = 4288;
743 else if (pc == 0x11) {
744 pDevExt->frameLength = (pDevExt->pIECFrameLength[pc] << DTSHDSubType);
745 pDevExt->lengthofData = pDevExt->frameLength;
746 }
747 */
749 // Change I/O PHY transfer size to bitstream frame size
750 pInp->phyXferSize = frameLength*WORD_SIZE_BITSTREAM;
751 }
753 pBufConfig->stride = INPUT_STRIDE; // common for PCM and bitstream
755 //JXTODO: decide what to do with hRxSio
756 pAstCfg->xInp[zMD].hRxSio = pInp->hIoData; //temporary - does ARM use hRxSio or just check if it is not NULL?
757 pAstCfg->xInp[zMD].pInpBuf = &(pAstCfg->xInp[zMD].inpBufConfig);
759 // Update I/O PHY transfer size accordingly
760 ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
761 ioPhyCtl.params.xferFrameSize = pInp->phyXferSize;
762 ioPhyControl(pInp->hIoPhy, &ioPhyCtl);
764 return ASIP_NO_ERR;
765 } /* asipUpdateIoComps */
767 void asipUpdateInpBufConfig(PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp)
768 {
769 PAF_InpBufConfig *pBufConfig;
770 ioDataCtl_t ioDataCtl;
772 /* Get information for reading input data */
773 ioDataCtl.code = IODATA_CTL_GET_INPBUFFINFO;
774 ioDataControl(pInp->hIoData, &ioDataCtl);
776 if(ioDataCtl.param.dataReadInfo.frameSize != pInp->phyXferSize) {
777 // Fatal error!
778 TRACE_VERBOSE0("TaskAsip: error in updating I/O");
779 SW_BREAKPOINT;
780 }
782 pBufConfig = &(pAstCfg->xInp[pAstCfg->masterDec].inpBufConfig);
784 //JXTODO: do we need to gate here? - No, since ARM won't read until it receives message
785 //key = GateMP_enter(gateHandle);
787 pBufConfig->base.pVoid = ioDataCtl.param.dataReadInfo.buffBase;
788 pBufConfig->sizeofBuffer = ioDataCtl.param.dataReadInfo.buffSize;
789 pBufConfig->pntr.pSmInt = ioDataCtl.param.dataReadInfo.startAddress;
791 // Leave the gate
792 //GateMP_leave(gateHandle, key);
793 }
795 /*==============================================================================
796 * Decide source after SYNC is found, i.e. either bitstream preamble is detected
797 * or it times out to PCM.
798 ==============================================================================*/
799 Int asipDecideSource(PAF_AST_Config *pAstCfg, PAF_AST_IoInp *pInp,
800 ioDataAutoDetStat_t *autoDetStatus)
801 {
802 Int sourceConfig, sourceSelect, sourceProgram;
803 Int zMD;
804 char asipMsgBuf[ASP_MSG_BUF_LEN];
806 // Get the configured source
807 zMD = pAstCfg->masterDec;
808 sourceConfig = (Int)sharedMemReadInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceSelect), GATEMP_INDEX_DEC);
810 if(autoDetStatus->syncState == IODATA_SYNC_PCM) {
811 if (sourceConfig == PAF_SOURCE_DSD1 || sourceConfig == PAF_SOURCE_DSD2 ||
812 sourceConfig == PAF_SOURCE_DSD3) {
813 sourceProgram = sourceConfig;
814 }
815 else {
816 sourceProgram = PAF_SOURCE_PCM;
817 }
818 }
820 if(autoDetStatus->syncState == IODATA_SYNC_BITSTREAM) {
821 uint_least16_t pc = autoDetStatus->bitStreamInfo & SYNC_PC_MASK; //0x001F
822 sourceProgram = IECpafSource[pc];
823 }
825 // write the decided source program to memory
826 sharedMemWriteInt8(&(pAstCfg->xDec[zMD].decodeStatus.sourceProgram), sourceProgram, GATEMP_INDEX_DEC);
828 // now that we have some input classification, and possibly an outstanding
829 // input frame, we determine whether or not to call decodeProcessing and with
830 // what decAlg.
831 sourceSelect = PAF_SOURCE_NONE;
833 switch (sourceConfig)
834 {
835 // If autodetecting, decoding everything, and input is something
836 // (i.e. bitstream or PCM) then decode.
837 case PAF_SOURCE_AUTO:
838 if (sourceProgram >= PAF_SOURCE_PCM) {
839 sourceSelect = sourceProgram; // use whatever from autodet
840 }
841 break;
843 // If autodetecting, decoding only PCM, and input is PCM then decode.
844 case PAF_SOURCE_PCMAUTO:
845 if (sourceProgram == PAF_SOURCE_PCM) {
846 sourceSelect = sourceProgram; // only expect autodet to give PAF_SOURCE_PCM, otherwise set to NONE
847 }
848 break;
850 // If autodetecting, decoding only bitstreams, and input is a bitstream then decode.
851 case PAF_SOURCE_BITSTREAM:
852 if (sourceProgram >= PAF_SOURCE_AC3) {
853 sourceSelect = sourceProgram;
854 }
855 break;
857 // If autodetecting, decoding only DTS, and input is DTS then decode.
858 case PAF_SOURCE_DTSALL:
859 switch (sourceProgram)
860 {
861 case PAF_SOURCE_DTS11:
862 case PAF_SOURCE_DTS12:
863 case PAF_SOURCE_DTS13:
864 case PAF_SOURCE_DTS14:
865 case PAF_SOURCE_DTS16:
866 case PAF_SOURCE_DTSHD:
867 sourceSelect = sourceProgram;
868 break;
869 }
870 break;
872 // All others, e.g., force modes, fall through to here.
873 // If user made specific selection then program must match select.
874 // (NB: this compare relies on ordering of PAF_SOURCE)
875 default:
876 sourceSelect = sourceConfig;
877 if ((sourceSelect >= PAF_SOURCE_PCM) && (sourceSelect <= PAF_SOURCE_N)) {
878 if (sourceProgram != sourceSelect) {
879 sourceSelect = PAF_SOURCE_NONE;
880 }
881 }
882 break;
883 }
885 // if we didn't find any matches then skip
886 if (sourceSelect == PAF_SOURCE_NONE) {
887 TRACE_VERBOSE0("TaskAsip: no matching source type, continue");
888 return ASIP_ERR_NO_MATCHING_SOURCE;
889 }
891 // send source select message to slave
892 *(Int32 *)&asipMsgBuf[0] = sourceSelect;
893 if(AspMsgSend(ASP_SLAVE_DEC_SOURCE_SELECT, ASP_MASTER_DEC_SOURCE_SELECT_DONE,
894 asipMsgBuf, NULL) != ASP_MSG_NO_ERR) {
895 TRACE_VERBOSE0("TaskAsip: error in sending SOURCE_SELECT message");
896 SW_BREAKPOINT;
897 }
899 pInp->sourceSelect = sourceSelect;
900 pInp->sourceProgram = sourceProgram;
902 return ASIP_NO_ERR;
903 } /* asipDecideSource */
906 Int asipBypassIoData(PAF_AST_IoInp *pInp)
907 {
908 // When switching to PCM, McASP RFMT register will be modified,
909 // which will cause all 0's in one McASP LLD transfer. This will
910 // be detected as loss of SYNC by auto detection. To prevent that,
911 // skip I/O DATA process for hangover period so that this all 0's
912 // frame will not be seen by auto-detection. Also, playing out PCM
913 // needs to be skipped as well, to prevent from playing out garbage
914 // (16-bit packed data).
915 void *buff1, *buff2;
916 size_t size1, size2;
918 // Get read pointers (or sub-buffers) of the input buffer
919 if (ioBuffGetReadPtrs(pInp->hIoBuff, pInp->phyXferSize,
920 &buff1, &size1, &buff2, &size2)
921 == IOBUFF_ERR_UNDERFLOW) {
922 //printf("Input buffer underflows during switch hangover!\n");
923 return ASIP_ERR_SWITCH_TO_PCM;
924 }
926 ioBuffReadComplete(pInp->hIoBuff, buff1, size1);
928 if(buff2 != NULL) {
929 ioBuffReadComplete(pInp->hIoBuff, buff2, size2);
930 }
932 return ASIP_NO_ERR;
933 }
935 /*=============================================================================
936 * Main function of ASIP processing
937 *============================================================================*/
938 Int asipProcessing(const PAF_ASIT_Params *pP,
939 const PAF_ASIT_Patchs *pQ,
940 PAF_ASIT_Config *pAsitCfg)
942 {
943 PAF_AST_Config *pAstCfg;
944 int ioDataStatus, asipStatus, zMI;
945 ioDataAutoDetStat_t autoDetStatus;
946 Audk2g_STATUS mcaspStatus;
947 ioDataCtl_t ioDataCtl;
948 ioPhyCtl_t ioPhyCtl;
949 PAF_AST_IoInp *pInp; /* Input I/O components */
951 pAstCfg = pAsitCfg->pAstCfg;
952 zMI = pAstCfg->masterDec;
953 pInp = &pAsitCfg->pIoInp[zMI]; // pointer to input I/O components
955 if(pInp->asipProcState == ASIP_SWITCH_TO_PCM) {
956 // Bypass I/O data processing due to McASP LLD work around
957 // (refer to comments inside the function)
958 asipStatus = asipBypassIoData(pInp);
959 if(asipStatus != ASIP_NO_ERR) {
960 return asipStatus;
961 }
962 }
963 else {
964 // Perform auto-detection when not switching
965 ioDataStatus = ioDataProcess(pInp->hIoData);
966 if(ioDataStatus == IODATA_ERR_IOBUF_UNDERFLOW) {
967 // Input buffer underflows - no action is needed
968 pInp->numUnderflow += 1;
970 // Return since there is no enough data to process
971 return ASIP_NO_ERR;
972 }
973 else if(ioDataStatus != IODATA_NO_ERR) {
974 // Something is wrong: print error log and return
975 //printf("IODATA processing error!\n");
976 return ASIP_ERR_AUTO_DETECION;
977 }
978 else {
979 // Normal operation - check auto-detection status
980 ioDataCtl.code = IODATA_CTL_GET_AUTODET_STATUS;
981 ioDataControl(pInp->hIoData, &ioDataCtl);
983 autoDetStatus = ioDataCtl.param.autoDetStats;
984 }
985 }
987 switch(pInp->asipProcState)
988 {
989 case ASIP_SOURCE_DETECTION:
990 // zero out the output buffer
991 rxDecodePlayZero(pInp);
993 if( autoDetStatus.syncState == IODATA_SYNC_BITSTREAM
994 || autoDetStatus.syncState == IODATA_SYNC_PCM) {
995 // Update I/O components and input buffer config
996 asipUpdateIoComps(pAstCfg, pInp, &autoDetStatus);
998 // Decide input source and inform decoder
999 asipStatus = asipDecideSource(pAstCfg, pInp, &autoDetStatus);
1000 if(asipStatus != ASIP_NO_ERR) {
1001 return asipStatus;
1002 }
1003 else {
1004 // set to unknown so that we can ensure, for IOS purposes, that sourceDecode = NONE
1005 // iff we are in this top level state machine and specifically not in decodeProcessing
1006 pP->fxns->sourceDecode(pP, pQ, pAsitCfg, PAF_SOURCE_UNKNOWN);
1008 if(autoDetStatus.syncState == IODATA_SYNC_BITSTREAM) {
1009 // Input is bit stream: go to decoding
1010 pInp->asipProcState = ASIP_DECODE;
1011 pInp->numFrameReceived = 1;
1012 }
1013 else {
1014 // Input is PCM: stop swapping data
1015 pInp->swapData = FALSE;
1017 // Reconfigure McASP LLD to transfer 32-bit unpacked data
1018 mcaspStatus = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_32);
1019 if(mcaspStatus != Audk2g_EOK) {
1020 return ASIP_ERR_MCASP_CFG;
1021 }
1023 // Go to transition state to switch to PCM
1024 pInp->asipProcState = ASIP_SWITCH_TO_PCM;
1025 pInp->switchHangOver = INPUT_SWITCH_HANGOVER;
1026 pInp->numPcmFrameReceived = 0;
1027 }
1029 // Initialize decoder
1030 asipStatus = asipDecodeInit(pP, pAsitCfg, pInp->sourceSelect);
1031 if(asipStatus != ASIP_NO_ERR) {
1032 return asipStatus;
1033 }
1034 }
1036 pInp->preSyncState = autoDetStatus.syncState;
1037 }
1038 else {
1039 // Source is still unknown - take no action
1040 ;
1041 }
1042 break;
1044 case ASIP_SWITCH_TO_PCM:
1045 // zero out the output buffer
1046 rxDecodePlayZero(pInp);
1048 pInp->switchHangOver--;
1049 if(pInp->switchHangOver == 0) {
1050 pInp->asipProcState = ASIP_DECODE;
1052 // Init decoder and send message to decoder
1053 //asipStatus = asipDecodeInit(pP, pAsitCfg, pInp->sourceSelect);
1054 //if(asipStatus != ASIP_NO_ERR) {
1055 // return asipStatus;
1056 //}
1057 }
1058 break;
1060 case ASIP_DECODE:
1061 if(autoDetStatus.syncState == IODATA_SYNC_NONE) {
1062 // SYNC lost: change I/O PHY transfer size to default for auto-detection
1063 ioPhyCtl.code = IOPHY_CTL_FRAME_SIZE;
1064 ioPhyCtl.params.xferFrameSize = INPUT_FRAME_SIZE_DEF;
1065 ioPhyControl(pInp->hIoPhy, &ioPhyCtl);
1066 pInp->phyXferSize = ioPhyCtl.params.xferFrameSize;
1068 if(pInp->preSyncState == IODATA_SYNC_PCM) {
1069 // If it was PCM, reconfigure McASP LLD to receive 16-bit packed bits
1070 mcaspStatus = mcaspRecfgWordWidth(pInp->hMcaspChan, Mcasp_WordLength_16);
1071 if(mcaspStatus != Audk2g_EOK) {
1072 return ASIP_ERR_MCASP_CFG;
1073 }
1075 // Start swapping data
1076 pInp->swapData = TRUE;
1077 }
1079 // Inform decoder to complete decoding previous frame
1080 pInp->sourceSelect = PAF_SOURCE_UNKNOWN;
1082 pInp->numFrameReceived = 0;
1083 pInp->asipProcState = ASIP_SOURCE_DETECTION;
1084 }
1085 else {
1086 pInp->numFrameReceived += 1;
1088 // Communicate input stream information to decoder through input buffer configuration
1089 asipUpdateInpBufConfig(pAstCfg, pInp);
1090 }
1092 asipStatus = asipDecodeProcessing(pP, pQ, pAsitCfg, pInp->sourceSelect);
1093 if(asipStatus != ASIP_NO_ERR) {
1094 return asipStatus;
1095 }
1097 //rxDecodePcm(pInp); // for PCM loopback testing
1098 break;
1100 default:
1101 break;
1102 }
1104 if(pInp->asipProcState != ASIP_SWITCH_TO_PCM) {
1105 ioDataReadComplete(pInp->hIoData);
1106 }
1108 return 0;
1109 } /* asipProcessing */
1111 /*======================================================================================
1112 * This function decides the input source based on auto-detection information.
1113 *====================================================================================*/
1114 //Int asipDecideSource(const PAF_ASIT_Params *pP, PAF_AST_Config *pAstCfg, asipDecProc_t *pDec)
1115 //{
1117 //}
1120 #ifndef IO_LOOPBACK_TEST
1121 #if OUTPUT_FRAME_LENGTH == INPUT_FRAME_LENGTH
1122 U8 pcmbuf[OUTPUT_FRAME_SIZE];
1123 #else
1124 #error Input frame length is not equal to output frame length!
1125 #endif
1127 Int rxDecodePcm(PAF_AST_IoInp *pInp)
1128 {
1129 ioDataCtl_t ioDataCtl;
1130 void *buffBase;
1131 void *dataStartAddress;
1132 size_t buffSize, frameSize, size1, size2;
1134 /* Get information for reading input data */
1135 ioDataCtl.code = IODATA_CTL_GET_INPBUFFINFO;
1136 ioDataControl(pInp->hIoData, &ioDataCtl);
1138 buffBase = ioDataCtl.param.dataReadInfo.buffBase;
1139 buffSize = ioDataCtl.param.dataReadInfo.buffSize;
1140 dataStartAddress = ioDataCtl.param.dataReadInfo.startAddress;
1141 frameSize = ioDataCtl.param.dataReadInfo.frameSize;
1143 // Copy PCM data to output buffer
1144 if(((size_t)dataStartAddress+frameSize) <= ((size_t)buffBase+buffSize)) {
1145 // Input buffer doesn't wrap around
1146 Cache_inv(dataStartAddress, frameSize, Cache_Type_ALL, TRUE);
1147 memcpy((void *)&pcmbuf[0], dataStartAddress, frameSize);
1148 }
1149 else {
1150 // Input buffer wraps around
1151 size1 = (size_t)buffBase + buffSize - (size_t)dataStartAddress;
1152 size2 = frameSize - size1;
1153 Cache_inv(dataStartAddress, size1, Cache_Type_ALL, TRUE);
1154 memcpy((void *)&pcmbuf[0], dataStartAddress, size1);
1156 Cache_inv(buffBase, size2, Cache_Type_ALL, TRUE);
1157 memcpy((void *)&pcmbuf[size1], buffBase, size2);
1158 }
1161 return ASIP_NO_ERR;
1162 }
1164 Int rxDecodeBitStream(PAF_AST_IoInp *pInp)
1165 {
1166 return ASIP_NO_ERR;
1167 }
1170 Int rxDecodePlayZero(PAF_AST_IoInp *pInp)
1171 {
1172 return ASIP_NO_ERR;
1173 }
1174 #endif
1176 void asipErrorHandling(PAF_AST_Config *pAstCfg, int asipErrno)
1177 {
1179 }
1181 /* Nothing past this line */