source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/ape/7552/bape_priv.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 75.3 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2006-2012, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bape_priv.h $
11 * $brcm_Revision: Hydra_Software_Devel/88 $
12 * $brcm_Date: 3/21/12 3:00p $
13 *
14 * Module Description: Audio PI Private Interfaces
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/ape/7422/bape_priv.h $
19 *
20 * Hydra_Software_Devel/88   3/21/12 3:00p gskerl
21 * SW7429-18: Added prototype for BAPE_InputPort_P_BurstPreambleToCodec().
22 *
23 * Hydra_Software_Devel/87   3/12/12 12:15p gskerl
24 * SW7429-18: Removed unreferenced #define statements.
25 *
26 * Hydra_Software_Devel/86   3/7/12 4:39p jgarrett
27 * SW7435-24: Adding DSP index for decode and dsp mixer
28 *
29 * Hydra_Software_Devel/86   3/7/12 4:35p jgarrett
30 * SW7435-24: Adding DSP index for decode and dsp mixer
31 *
32 * Hydra_Software_Devel/85   2/23/12 10:53a jgarrett
33 * SW7405-5003: Removing BKNI_Memcmp where structures aren't copied with
34 * BKNI_Memcpy
35 *
36 * Hydra_Software_Devel/84   2/21/12 6:41p jgarrett
37 * SW7231-363: Propagating codec and mono format changes properly
38 *
39 * Hydra_Software_Devel/83   2/16/12 3:00p jgarrett
40 * SW7552-188: Removing dummy mixer outputs.  MAI CBIT formatting no
41 * longer requires this
42 *
43 * Hydra_Software_Devel/82   2/15/12 2:39p gskerl
44 * SW7429-18: Added audio format fields to the BAPE_InputCapture struct.
45 *
46 * Hydra_Software_Devel/81   2/9/12 11:21a jgarrett
47 * SW7425-2074: Enabling input halt and revising MAI shutown for
48 * multichannel PCM
49 *
50 * Hydra_Software_Devel/80   2/8/12 4:48p jgarrett
51 * SW7346-572: Adding playback settings
52 *
53 * Hydra_Software_Devel/79   2/3/12 4:29p jgarrett
54 * SW7425-2268: Initial bringup of voice conferencing support
55 *
56 * Hydra_Software_Devel/78   2/2/12 7:04p gskerl
57 * SW7429-18: Removed prototypes for all SpdifRx_P_* functions because
58 * their functionality has been moved into bape_spdif_input.c and
59 * bape_mai_input.c.
60 *
61 * Hydra_Software_Devel/77   2/2/12 4:48p jgarrett
62 * SW7425-2268: Adding EchoCanceller
63 *
64 * Hydra_Software_Devel/76   1/31/12 6:17p jgarrett
65 * SW7425-2268: Adding initial voice conferencing support
66 *
67 * Hydra_Software_Devel/75   1/27/12 5:11p jgarrett
68 * SW7429-55: Changing ncoRequired to builtinNco
69 *
70 * Hydra_Software_Devel/74   1/27/12 4:49p jgarrett
71 * SW7429-55: Adding ncoRequired field to OutputPort
72 *
73 * Hydra_Software_Devel/73   1/17/12 2:50p gskerl
74 * SW7429-18: Changed argument to BAPE_SpdifRx_P_GetRxStatus() from
75 * BAPE_MaiInputFormatDetectionStatus to
76 * BAPE_SpdifInputFormatDetectionStatus.
77 *
78 * Hydra_Software_Devel/72   1/6/12 5:27p gskerl
79 * SW7429-18: Added BAPE_P_NUM_ELEMS macro
80 *
81 * Hydra_Software_Devel/71   12/7/11 4:50p jgarrett
82 * SW7429-18: Extending input port FCI ID's to 16 bits
83 *
84 * Hydra_Software_Devel/70   12/2/11 3:19p jgarrett
85 * SW7346-578: Adding ability to change some mixer settings without
86 * destroying and re-creating the mixer
87 *
88 * Hydra_Software_Devel/69   12/1/11 6:45p gskerl
89 * SW7429-18: Don't define the srcCoeffAllocated[] field of BAPE_Device
90 * when BAPE_CHIP_MAX_SRC_COEFF_CHUNKS isn't defined.
91 *
92 * Hydra_Software_Devel/68   11/30/11 4:26p jgarrett
93 * SW7429-18: Adding stubs for SPDIF/MAI inputs on 7429
94 *
95 * Hydra_Software_Devel/67   11/14/11 3:23p gskerl
96 * SW7429-18: Merging 7429 changes back to main branch.
97 *
98 * Hydra_Software_Devel/SW7429-18/4   11/4/11 5:02p gskerl
99 * SW7429-18: Merged in changes from /main/Hydra_Software_Devel.
100 *
101 * Hydra_Software_Devel/SW7429-18/3   11/4/11 4:41p jgarrett
102 * SW7429-18: Adding channel status bits
103 *
104 * Hydra_Software_Devel/SW7429-18/2   10/26/11 12:44p jgarrett
105 * SW7429-18: Merging latest changes from main branch
106 *
107 * Hydra_Software_Devel/SW7429-18/1   10/21/11 6:29p jgarrett
108 * SW7429-18: Initial compileable version for 7429
109 *
110 * Hydra_Software_Devel/66   11/2/11 12:40p gskerl
111 * SW7231-129: Added sampleRateConverterRampStep to BAPE_Device structure.
112 *
113 * Hydra_Software_Devel/65   11/1/11 2:12p gskerl
114 * SW7231-129: Added outputVolumeRampState to BAPE_Device structure.
115 *
116 * Hydra_Software_Devel/64   10/25/11 1:17p gskerl
117 * SW7231-129: Added timebase field to BAPE_AudioNco struct.
118 *
119 * Hydra_Software_Devel/63   10/14/11 12:11p jgarrett
120 * SW7425-468: Adding hooks for NRT DSP mixer support
121 *
122 * Hydra_Software_Devel/62   9/19/11 3:21p gskerl
123 * SW7231-129: Added prototype for BAPE_P_ReleaseUnusedPathResources().
124 *
125 * Hydra_Software_Devel/61   9/14/11 6:58p jgarrett
126 * SW7425-1045: Adding unmapped settings and status values for some
127 * decoder algorithms
128 *
129 * Hydra_Software_Devel/60   8/26/11 9:50p sgadara
130 * SWDTV-6627: [35233] Add Equalizer support
131 *
132 * Hydra_Software_Devel/59   8/25/11 6:22p gskerl
133 * SW7425-1119: Changed return type for BAPE_MixerInterface.stop to be
134 * void
135 *
136 * Hydra_Software_Devel/58   8/24/11 1:44p jgarrett
137 * SWDTV-8271: Reversing SPDIF/HDMI input ISRs on 352xx
138 *
139 * Hydra_Software_Devel/57   8/24/11 12:47p jgarrett
140 * SWDTV-8271: Fixing #includes for SPDIF_RCVR_1
141 *
142 * Hydra_Software_Devel/56   8/24/11 11:53a jgarrett
143 * SW7425-724: Adding RF Audio Encoder
144 *
145 * Hydra_Software_Devel/55   8/23/11 1:25p gskerl
146 * SW7425-1119: Added prototypes and stubs for BAPE_Mixer_Start() and
147 * BAPE_Mixer_Stop(). For now, they just return BERR_NOT_SUPPORTED
148 *
149 * Hydra_Software_Devel/52   8/2/11 3:27p jgarrett
150 * SWDTV-8150: Adding mixer output connection support
151 *
152 * Hydra_Software_Devel/51   7/15/11 5:51p jgarrett
153 * SWDTV-6761: Adding StudioSound API
154 *
155 * Hydra_Software_Devel/50   7/8/11 6:38p jgarrett
156 * SWDTV-6760: Adding I2sMultiOutput
157 *
158 * Hydra_Software_Devel/49   7/8/11 4:24p gskerl
159 * SW7552-72: Added support for NCO/Mclkgen audio clock sources
160 *
161 * Hydra_Software_Devel/48   7/6/11 4:55p jgarrett
162 * SW7358-62: Storing a local copy of the XptContextMap structure
163 *
164 * Hydra_Software_Devel/47   6/29/11 5:00p jgarrett
165 * SW7425-620: Allowing multichannel/compressed outputs from a decoder to
166 * override to PCM if the codec does not support multichannel/compressed
167 * output
168 *
169 * Hydra_Software_Devel/46   6/22/11 12:26p gskerl
170 * SW7425-321: Added data structures for NCOs (cloned from PLLs)
171 *
172 * Hydra_Software_Devel/45   6/20/11 7:02p jgarrett
173 * SW7425-406: Adding input scaling coefficients to mixer
174 *
175 * Hydra_Software_Devel/44   6/16/11 3:06p gskerl
176 * SW7425-321: Renamed BAPE_PllStatus to BAPE_AudioPll, pllStatus to
177 * audioPll, eliminated unused baseAddress and fsChannel fields, added
178 * populating of baseSampleRate and freqCh1 fields.
179 *
180 * Hydra_Software_Devel/43   6/14/11 7:18p gskerl
181 * SW7425-321: Added prototype for BAPE_Mixer_P_PrintMixers()
182 *
183 * Hydra_Software_Devel/42   6/14/11 3:45p jgarrett
184 * SW7425-406: Merge to main branch
185 *
186 * Hydra_Software_Devel/SW7425-406/2   6/13/11 7:27p jgarrett
187 * SW7425-406: Updates for new BDSP_Task_AddStageInput APIs
188 *
189 * Hydra_Software_Devel/SW7425-406/1   6/3/11 6:28p jgarrett
190 * SW7425-406: Adding inter-task buffer descriptors to connection
191 *
192 * Hydra_Software_Devel/41   6/1/11 6:30p jgarrett
193 * SW7425-406: Adding DSP Mixer connection resources
194 *
195 * Hydra_Software_Devel/40   5/31/11 6:37p jgarrett
196 * SW7425-406: Adding initial DSP mixer code
197 *
198 * Hydra_Software_Devel/39   5/27/11 7:49p gskerl
199 * SW7425-321: Split mixer code into multiple files. Added framework for
200 * dispatching mixer API calls to multiple mixer types.
201 *
202 * Hydra_Software_Devel/38   5/27/11 4:56p jgarrett
203 * SW7425-408: Propagating decoder settings for AAC/AC3 to DDRE in MS11
204 * usage modes
205 *
206 * Hydra_Software_Devel/37   5/20/11 5:16p jgarrett
207 * SW7425-402: Adding error code to handle output enable callback failing.
208 *
209 * Hydra_Software_Devel/36   5/18/11 2:29p gskerl
210 * SW7231-128: Added BCHP_PWR support to APE
211 *
212 * Hydra_Software_Devel/35   5/14/11 11:56a jgarrett
213 * SW7425-407: Adding DV258 Support
214 *
215 * Hydra_Software_Devel/34   5/14/11 11:33a jgarrett
216 * SWDTV-6763: Adding 3D Surround
217 *
218 * Hydra_Software_Devel/33   5/13/11 6:39p jgarrett
219 * SW7425-410: Adding AVL
220 *
221 * Hydra_Software_Devel/32   5/12/11 4:39p piyushg
222 * SW7425-401: Added PCM playback support for non-interleaved and
223 * multichannel data
224 *
225 * Hydra_Software_Devel/31   5/12/11 12:01p gskerl
226 * SW7422-354: Fixed to support APE compilation on 35230
227 *
228 * Hydra_Software_Devel/30   5/11/11 7:04p jgarrett
229 * SW7422-410: Adding CustomProcessing
230 *
231 * Hydra_Software_Devel/29   5/2/11 7:37p gskerl
232 * SW7422-354: Added enum for BAPE_OutputPortType
233 *
234 * Hydra_Software_Devel/28   4/20/11 7:02p gskerl
235 * SW7425-384: Refactored BAPE_P_SetFsTiming_isr() to improve PLLCLKSEL
236 * logic and to add support for multiple DACS
237 *
238 * Hydra_Software_Devel/27   4/18/11 10:09p jgarrett
239 * SW7425-361: Refactoring DSP branch decisions
240 *
241 * Hydra_Software_Devel/26   4/17/11 1:55p jgarrett
242 * SW7425-288: Adding audio codec to metadata
243 *
244 * Hydra_Software_Devel/25   4/16/11 12:15p jgarrett
245 * SW7425-371: Removing tab characters
246 *
247 * Hydra_Software_Devel/24   4/11/11 5:54p jgarrett
248 * SWDTV-6305: Adding ADC/RF Inputs for DTV
249 *
250 * Hydra_Software_Devel/23   4/6/11 1:24a jgarrett
251 * SW35330-35: Merge to main branch
252 *
253 * Hydra_Software_Devel/SW35330-35/2   4/5/11 7:13p jgarrett
254 * SW35330-35: PCM Playback working on 35230
255 *
256 * Hydra_Software_Devel/SW35330-35/1   4/5/11 12:50p jgarrett
257 * SW35330-35: FMM Abstraction refactoring to support DTV
258 *
259 * Hydra_Software_Devel/22   3/27/11 12:32p piyushg
260 * SW7422-364: Rearrange Callback enable/disable calls and other
261 * bug fixes for HDMI input.
262 *
263 * Hydra_Software_Devel/21   3/24/11 10:28a jgarrett
264 * SW7422-364: Fixing compilation errors on systems without HDMI or SPDIF
265 * input
266 *
267 * Hydra_Software_Devel/20   3/23/11 11:07a piyushg
268 * SW7422-364: Initial checking for HDMI input support.
269 *
270 * Hydra_Software_Devel/19   3/22/11 3:01p gskerl
271 * SW7422-146: Changed audio output connector callbacks to take the output
272 * connector as an argument
273 *
274 * Hydra_Software_Devel/18   3/21/11 7:08p jgarrett
275 * SW7422-356: Adding MuxOutput
276 *
277 * Hydra_Software_Devel/17   3/18/11 6:04p gskerl
278 * SW7422-146: Changed audio input connector callbacks to take the connect
279 * handle as an argument
280 *
281 * Hydra_Software_Devel/16   3/11/11 6:02p jgarrett
282 * SW7422-146: Decoder supports external inputs
283 *
284 * Hydra_Software_Devel/15   3/10/11 7:03p jgarrett
285 * SW7422-146: Refactored DFIFO code, added support for input capture from
286 * compressed/multichannel
287 *
288 * Hydra_Software_Devel/14   3/9/11 4:42p piyushg
289 * SW7422-146: Add HDMI and SPDIF callback handles to BAPE_Device
290 * structure.
291 *
292 * Hydra_Software_Devel/13   3/3/11 6:31p jgarrett
293 * SW7422-146: Adding SRC and DSOLA and path review feedback
294 *
295 * Hydra_Software_Devel/12   3/1/11 3:26p jgarrett
296 * SW7422-146: Moving samlpe rate to input port from input capture
297 *
298 * Hydra_Software_Devel/11   2/28/11 1:28p jgarrett
299 * SW7422-146: Filter graph reworked to remove mixer dependencies
300 *
301 * Hydra_Software_Devel/10   2/22/11 5:43p jgarrett
302 * SW7422-146: Implemented type renaming based on filter graph review
303 * comments
304 *
305 * Hydra_Software_Devel/9   2/15/11 4:08p jgarrett
306 * SW7422-146: Adding additional codec settings and types
307 *
308 * Hydra_Software_Devel/8   2/10/11 5:45p gskerl
309 * SW7422-146: Changed calling sequence for the audio output setMclk_isr
310 * callbacks
311 *
312 * Hydra_Software_Devel/7   2/2/11 2:17p jgarrett
313 * SW7422-146: Adding decoder status placeholder
314 *
315 * Hydra_Software_Devel/6   1/28/11 3:38p jgarrett
316 * SW7422-146: Adding support for simul handling of DDP/WMA-Pro/Generic
317 *
318 * Hydra_Software_Devel/5   1/27/11 5:47p jgarrett
319 * SW7422-146: Adding support for multichannel and ac3 user parameters
320 *
321 * Hydra_Software_Devel/4   1/19/11 2:58p jgarrett
322 * SW7422-146: Initial decode/passthrough of ac3
323 *
324 * Hydra_Software_Devel/3   1/7/11 5:21p jgarrett
325 * SW7422-146: Adding SPDIF/HDMI input APIs
326 *
327 * Hydra_Software_Devel/2   1/6/11 2:33p jgarrett
328 * SW7422-146: Adding initial input capture API
329 *
330 * Hydra_Software_Devel/1   12/17/10 4:11p jgarrett
331 * SW7422-146: Nexus APE integration on 7422
332 *
333 ***************************************************************************/
334
335#ifndef BAPE_PRIV_H_
336#define BAPE_PRIV_H_
337
338#include "bstd.h"
339#include "bkni.h"
340#include "bape.h"
341#include "bdsp.h"
342#include "blst_slist.h"
343#include "blst_squeue.h"
344#include "bape_chip_priv.h"
345#include "bape_reg_priv.h"
346#if defined BCHP_HDMI_RCVR_CTRL_REG_START
347#include "bchp_hdmi_rcvr_ctrl.h"
348#elif defined BCHP_AUD_FMM_IOP_IN_HDMI_0_REG_START
349#include "bchp_aud_fmm_iop_in_hdmi_0.h"
350#endif
351#if defined BCHP_SPDIF_RCVR_CTRL_REG_START
352#include "bchp_spdif_rcvr_ctrl.h"
353#include "bchp_spdif_rcvr_esr.h"
354#include "bchp_hdmi_rcvr_ctrl.h"
355#include "bchp_hdmi_rcvr_esr.h"
356#elif defined BCHP_SPDIF_RCVR_CTRL0_REG_START
357#include "bchp_spdif_rcvr_ctrl0.h"
358#include "bchp_spdif_rcvr_ctrl1.h"
359#include "bchp_spdif_rcvr_esr0.h"
360#include "bchp_spdif_rcvr_esr1.h"
361#elif defined BCHP_AUD_FMM_IOP_IN_SPDIF_0_REG_START
362#include "bchp_aud_fmm_iop_in_spdif_0.h"
363#endif
364
365/* Debug objects */
366BDBG_OBJECT_ID_DECLARE(BAPE_Device);
367BDBG_OBJECT_ID_DECLARE(BAPE_BufferNode);
368BDBG_OBJECT_ID_DECLARE(BAPE_Decoder);
369BDBG_OBJECT_ID_DECLARE(BAPE_Mixer);
370BDBG_OBJECT_ID_DECLARE(BAPE_OutputPort);
371BDBG_OBJECT_ID_DECLARE(BAPE_PathConnector);
372BDBG_OBJECT_ID_DECLARE(BAPE_PathConnection);
373BDBG_OBJECT_ID_DECLARE(BAPE_InputPort);
374BDBG_OBJECT_ID_DECLARE(BAPE_PathNode);
375BDBG_OBJECT_ID_DECLARE(BAPE_Playback);
376BDBG_OBJECT_ID_DECLARE(BAPE_InputCapture);
377BDBG_OBJECT_ID_DECLARE(BAPE_EchoCanceller);
378
379/* Shorthand to indicate the number of elements in an array. */
380#define BAPE_P_NUM_ELEMS(x)  (sizeof(x) / sizeof (x)[0])
381
382/***************************************************************************
383Summary:
384PLL Status
385***************************************************************************/
386typedef struct BAPE_AudioPll
387{
388    unsigned baseSampleRate;
389    unsigned long freqCh1;
390    BLST_S_HEAD(PllMixerList, BAPE_Mixer) mixerList;    /* List of mixers using this PLL */
391    BAPE_PllSettings settings;
392} BAPE_AudioPll;
393
394/***************************************************************************
395Summary:
396PLL Status
397***************************************************************************/
398typedef struct BAPE_AudioNco
399{
400    unsigned baseSampleRate;
401    unsigned long ncoFreq;
402    BAVC_Timebase timebase;
403    BLST_S_HEAD(NcoMixerList, BAPE_Mixer) mixerList;    /* List of mixers using this NCO */
404} BAPE_AudioNco;
405
406/***************************************************************************
407Summary:
408L3 interrupt structure
409***************************************************************************/
410typedef struct BAPE_L3Interrupt
411{
412    BINT_CallbackFunc callback_isr;
413    void *pParam1;
414    int param2;
415} BAPE_L3Interrupt;
416
417/***************************************************************************
418Summary:
419Decoder State
420***************************************************************************/
421typedef enum BAPE_DecoderState
422{
423    BAPE_DecoderState_eStopped,             /* Not running */
424    BAPE_DecoderState_eStarted,             /* Running in normal operation */
425    BAPE_DecoderState_ePaused,              /* Running, paused */
426    BAPE_DecoderState_eDisabled,            /* Prepared for flush from started state */
427    BAPE_DecoderState_eDisabledPaused,      /* Prepared for flush from paused state */
428    BAPE_DecoderState_eMax
429} BAPE_DecoderState;
430
431/***************************************************************************
432Summary:
433FCI ID Type
434***************************************************************************/
435typedef uint16_t BAPE_FciId;
436
437/***************************************************************************
438Summary:
439Invalid FCI ID
440***************************************************************************/
441#define BAPE_FCI_ID_INVALID (0x3ff)
442
443/***************************************************************************
444Summary:
445FCI ID Group
446***************************************************************************/
447typedef struct BAPE_FciIdGroup
448{
449    BAPE_FciId ids[BAPE_ChannelPair_eMax];
450} BAPE_FciIdGroup;
451
452/***************************************************************************
453Summary:
454Init FCI ID Group
455***************************************************************************/
456#define BAPE_FciIdGroup_Init(pGroup) \
457do \
458{ \
459    unsigned i; \
460    for ( i = 0; i < BAPE_ChannelPair_eMax; i++ ) \
461    { \
462        (pGroup)->ids[i] = BAPE_FCI_ID_INVALID; \
463    } \
464} while (0)
465
466/***************************************************************************
467Summary:
468Determine number of active channel pairs in an FCI group
469***************************************************************************/
470#define BAPE_FciIdGroup_GetNumChannelPairs(group) (((group).ids[3] != BAPE_FCI_ID_INVALID)?4:((group).ids[2] != BAPE_FCI_ID_INVALID)?3:((group).ids[1] != BAPE_FCI_ID_INVALID)?2:((group).ids[0] != BAPE_FCI_ID_INVALID)?1:0)
471
472/***************************************************************************
473Summary:
474Determine number of active channel pairs in an FCI group
475***************************************************************************/
476#define BAPE_FciIdGroup_IsEqual(group1,group2) (((group1).ids[0] == (group2).ids[0]) && ((group1).ids[1] == (group2).ids[1]) && ((group1).ids[2] == (group2).ids[2]) && ((group1).ids[3] == (group2).ids[3]))
477
478/***************************************************************************
479Summary:
480Source FIFO Group Handle
481***************************************************************************/
482typedef struct BAPE_SfifoGroup *BAPE_SfifoGroupHandle;
483
484/***************************************************************************
485Summary:
486Destination FIFO Group Handle
487***************************************************************************/
488typedef struct BAPE_DfifoGroup *BAPE_DfifoGroupHandle;
489
490/***************************************************************************
491Summary:
492Sample Rate Converter Group Handle
493***************************************************************************/
494typedef struct BAPE_SrcGroup *BAPE_SrcGroupHandle;
495
496/***************************************************************************
497Summary:
498Sample Rate Converter Group Handle
499***************************************************************************/
500typedef struct BAPE_SrcMemory *BAPE_SrcMemoryHandle;
501
502/***************************************************************************
503Summary:
504Mixer Group Handle
505***************************************************************************/
506typedef struct BAPE_MixerGroup *BAPE_MixerGroupHandle;
507
508/***************************************************************************
509Summary:
510Loopback Group Handle
511***************************************************************************/
512typedef struct BAPE_LoopbackGroup *BAPE_LoopbackGroupHandle;
513
514/***************************************************************************
515Summary:
516Dummysink Group Handle
517***************************************************************************/
518typedef struct BAPE_DummysinkGroup *BAPE_DummysinkGroupHandle;
519
520/***************************************************************************
521Summary:
522Device Handle
523***************************************************************************/
524typedef struct BAPE_Device
525{
526    BDBG_OBJECT(BAPE_Device)
527
528    /* Open Parameters */
529    BCHP_Handle chpHandle;
530    BREG_Handle regHandle;
531    BMEM_Handle memHandle;
532    BINT_Handle intHandle;
533    BTMR_Handle tmrHandle;
534    BDSP_Handle dspHandle;
535    BAPE_Settings settings;
536   
537    /* Buffer Sizes */
538    unsigned pcmBufferSize;
539    unsigned compressedBufferSize;
540
541    /* Ramp Step Sizes */
542    uint32_t outputVolumeRampStep;
543    uint32_t sampleRateConverterRampStep;
544
545    /* Free Buffer Lists */
546    BLST_S_HEAD(PcmBufferList, BAPE_BufferNode) pcmBufferList;
547    BLST_S_HEAD(CompressedBufferList, BAPE_BufferNode) compressedBufferList;
548
549    /* Software resource allocation */
550#if BAPE_CHIP_MAX_DECODERS > 0
551    BDSP_ContextHandle       dspContext;
552    unsigned                 numDsps;
553    BAPE_DecoderHandle       decoders[BAPE_CHIP_MAX_DECODERS];
554    struct 
555    {
556        BAPE_DecoderState state;
557        BAPE_DecoderStartSettings startSettings;
558    } decoderWatchdogInfo[BAPE_CHIP_MAX_DECODERS];
559#endif
560#if BAPE_CHIP_MAX_INPUT_CAPTURES > 0
561    BAPE_InputCaptureHandle  inputCaptures[BAPE_CHIP_MAX_INPUT_CAPTURES];
562#endif
563#if BAPE_CHIP_MAX_PLAYBACKS > 0
564    BAPE_PlaybackHandle      playbacks[BAPE_CHIP_MAX_PLAYBACKS];
565#endif
566#if BAPE_CHIP_MAX_DACS > 0
567    BAPE_DacHandle           dacs[BAPE_CHIP_MAX_DACS];
568#endif
569#if BAPE_CHIP_MAX_I2S_OUTPUTS > 0
570    BAPE_I2sOutputHandle     i2sOutputs[BAPE_CHIP_MAX_I2S_OUTPUTS];
571#endif
572#if BAPE_CHIP_MAX_I2S_MULTI_OUTPUTS > 0
573    BAPE_I2sMultiOutputHandle     i2sMultiOutputs[BAPE_CHIP_MAX_I2S_MULTI_OUTPUTS];
574#endif
575#if BAPE_CHIP_MAX_SPDIF_OUTPUTS > 0
576    BAPE_SpdifOutputHandle   spdifOutputs[BAPE_CHIP_MAX_SPDIF_OUTPUTS];
577#endif
578#if BAPE_CHIP_MAX_MAI_OUTPUTS > 0
579    BAPE_MaiOutputHandle     maiOutputs[BAPE_CHIP_MAX_MAI_OUTPUTS];
580#endif
581#if BAPE_CHIP_MAX_OUTPUT_CAPTURES > 0
582    BAPE_OutputCaptureHandle outputCaptures[BAPE_CHIP_MAX_OUTPUT_CAPTURES];
583#endif
584#if BAPE_CHIP_MAX_DUMMYSINKS > 0
585    BAPE_DummyOutputHandle     dummyOutputs[BAPE_CHIP_MAX_DUMMYSINKS];
586#endif
587#if BAPE_CHIP_MAX_I2S_INPUTS > 0
588    BAPE_I2sInputHandle      i2sInputs[BAPE_CHIP_MAX_I2S_INPUTS];
589#endif
590#if BAPE_CHIP_MAX_SPDIF_INPUTS > 0
591    BAPE_SpdifInputHandle    spdifInputs[BAPE_CHIP_MAX_SPDIF_INPUTS];
592#endif
593#if BAPE_CHIP_MAX_MAI_INPUTS > 0
594    BAPE_MaiInputHandle      maiInputs[BAPE_CHIP_MAX_MAI_INPUTS];
595#endif
596#if BAPE_CHIP_MAX_AUDIO_RETURN_CHANNELS > 0
597    BAPE_AudioReturnChannelHandle      audioReturnChannels[BAPE_CHIP_MAX_AUDIO_RETURN_CHANNELS];
598#endif
599#if BAPE_CHIP_MAX_RFMODS > 0
600    BAPE_RfModHandle         rfmods[BAPE_CHIP_MAX_RFMODS];
601#endif
602#if BAPE_CHIP_MAX_ADC_INPUTS > 0
603    BAPE_AdcInputHandle      adcInputs[BAPE_CHIP_MAX_ADC_INPUTS];
604#endif
605
606    BLST_S_HEAD(MixerList, BAPE_Mixer) mixerList;
607    BLST_S_HEAD(MuxOutputList, BAPE_MuxOutput) muxOutputList;
608
609#if BAPE_CHIP_MAX_PLLS > 0
610    /* PLL Status */
611    BAPE_AudioPll   audioPlls[BAPE_CHIP_MAX_PLLS];
612#endif
613#if BAPE_CHIP_MAX_NCOS > 0
614    /* PLL Status */
615    BAPE_AudioNco   audioNcos[BAPE_CHIP_MAX_NCOS];
616#endif
617
618    /* Groups */
619    BAPE_SfifoGroupHandle     sfifoGroups[BAPE_CHIP_MAX_SFIFO_GROUPS];
620    BAPE_DfifoGroupHandle     dfifoGroups[BAPE_CHIP_MAX_DFIFO_GROUPS];
621    BAPE_SrcGroupHandle       srcGroups[BAPE_CHIP_MAX_SRC_GROUPS];
622    BAPE_MixerGroupHandle     mixerGroups[BAPE_CHIP_MAX_MIXER_GROUPS];
623#if BAPE_CHIP_MAX_LOOPBACK_GROUPS > 0
624    BAPE_LoopbackGroupHandle  loopbackGroups[BAPE_CHIP_MAX_LOOPBACK_GROUPS];
625#endif
626#if BAPE_CHIP_MAX_DUMMYSINK_GROUPS > 0
627    BAPE_DummysinkGroupHandle dummysinkGroups[BAPE_CHIP_MAX_DUMMYSINK_GROUPS];
628#endif
629
630    /* SRC Memory Heaps (DTV-Only) */
631    BMEM_Heap_Handle srcCoefHeap;
632    BMEM_Heap_Handle srcScratchHeap;
633
634    /* Interrupts */
635    BINT_CallbackHandle isrBfEsr1;
636    BINT_CallbackHandle isrBfEsr2;
637    BINT_CallbackHandle isrBfEsr3;
638    BINT_CallbackHandle isrBfEsr4;
639    BAPE_L3Interrupt sourceRbufFreemark[BAPE_CHIP_MAX_SFIFOS];
640    BAPE_L3Interrupt destRbufFullmark[BAPE_CHIP_MAX_DFIFOS];
641    BAPE_L3Interrupt destRbufOverflow[BAPE_CHIP_MAX_DFIFOS];
642
643    /* Hardware resource allocation map */
644    bool sfifoAllocated[BAPE_CHIP_MAX_SFIFOS];
645    bool dfifoAllocated[BAPE_CHIP_MAX_DFIFOS];
646    bool srcAllocated[BAPE_CHIP_MAX_SRCS];
647#ifdef BAPE_CHIP_MAX_SRC_COEFF_CHUNKS
648    bool srcCoeffAllocated[BAPE_CHIP_MAX_SRC_COEFF_CHUNKS];
649#endif
650    bool mixerAllocated[BAPE_CHIP_MAX_MIXERS];
651    bool playbackAllocated[BAPE_CHIP_MAX_MIXER_PLAYBACKS];
652    bool dummysinkAllocated[BAPE_CHIP_MAX_DUMMYSINKS];
653#if BAPE_CHIP_MAX_LOOPBACKS > 0
654    bool loopbackAllocated[BAPE_CHIP_MAX_LOOPBACKS];
655#endif
656#if BAPE_CHIP_MAX_FS > 0
657    bool fsAllocated[BAPE_CHIP_MAX_FS];
658#endif
659    bool adaptRateAllocated[BAPE_CHIP_MAX_ADAPTRATE_CONTROLLERS];
660
661    /* Usage Tracking for DP Playback */
662    BAPE_FciId playbackFci[BAPE_CHIP_MAX_MIXER_PLAYBACKS];
663    uint8_t playbackReferenceCount[BAPE_CHIP_MAX_MIXER_PLAYBACKS];
664
665    /* Interrupts */
666    BAPE_InterruptHandlers interrupts;
667
668    bool bStandby; 
669} BAPE_Device;
670
671/***************************************************************************
672Summary:
673Data Source Types
674***************************************************************************/
675typedef enum BAPE_DataSource
676{
677    BAPE_DataSource_eDspBuffer,
678    BAPE_DataSource_eHostBuffer,
679    BAPE_DataSource_eDfifo,
680    BAPE_DataSource_eFci,           /* Other FCI source (SRC/Mixer/Splitter/Speaker Mgmt) */
681    BAPE_DataSource_eMax
682} BAPE_DataSource;
683
684/***************************************************************************
685Summary:
686Buffer types for pooled resources
687***************************************************************************/
688typedef enum BAPE_BufferType
689{
690    BAPE_BufferType_ePcm,
691    BAPE_BufferType_eCompressed,
692    BAPE_BufferType_eMax
693}BAPE_BufferType;
694
695/***************************************************************************
696Summary:
697Buffer Node
698***************************************************************************/
699typedef struct BAPE_BufferNode
700{
701    BDBG_OBJECT(BAPE_BufferNode)
702    BLST_S_ENTRY(BAPE_BufferNode) node;
703    void *pMemory;
704    uint32_t offset;
705    unsigned bufferSize;
706    BAPE_BufferType type;
707} BAPE_BufferNode;
708
709/***************************************************************************
710Summary:
711Invalid Branch/Stage ID's
712***************************************************************************/
713#define BAPE_BRANCH_ID_INVALID ((unsigned)-1)
714#define BAPE_STAGE_ID_INVALID ((unsigned)-1)
715
716/***************************************************************************
717Summary:
718Generic Mixer Input Structure
719***************************************************************************/
720typedef struct BAPE_PathConnector
721{
722    BDBG_OBJECT(BAPE_PathConnector)
723    struct BAPE_PathNode *pParent;
724    bool compressed;
725    bool mono;
726    bool useBufferPool;         /* If true, buffers are allocated from the buffer pool.  If false, they are handled externally (e.g. playback). */
727    bool ppmCorrection;         /* If true, ppm correction/adaptive rate control is requested on this path. */
728    unsigned numChannelPairs;
729    unsigned sampleRate;
730    unsigned maxSampleRate, minSampleRate;  /* Not currently used, but may be used to determine if multiple SRC resources are needed or not */
731    BAVC_AudioCompressionStd codec;         /* Valid if compressed is true */
732
733    /* Data Source Type */
734    BAPE_DataSource dataSource;
735
736    /* FW Source Information */
737    unsigned branchId, stageId;                     /* Branch/Stage data will be sent from */
738    BDSP_TaskCreateSettings *pTaskCreateSettings;   /* Task Creation Settings - Only valid during allocatePath call */
739    BDSP_TaskHandle task;                           /* Task Handle - Becomes valid prior to start call and invalid prior to stop */
740
741    /* Links to downstream connections */
742    BLST_SQ_HEAD(ConnectionList, BAPE_PathConnection) connectionList;
743    /* Buffer resources if useBufferBool is true */
744    BAPE_BufferNode *pBuffers[BAPE_ChannelPair_eMax];
745    /* Name */
746    const char *pName;
747} BAPE_PathConnector;
748
749/***************************************************************************
750Summary:
751Init a connector
752***************************************************************************/
753#define BAPE_P_InitPathConnector(input, connectorParent) \
754   do {\
755         BKNI_Memset((input),0,sizeof(BAPE_PathConnector));\
756         BDBG_OBJECT_SET((input),BAPE_PathConnector);\
757         (input)->dataSource = BAPE_DataSource_eMax; \
758         (input)->pParent=(connectorParent);\
759         BLST_SQ_INIT(&(input)->connectionList); \
760         (input)->branchId = BAPE_BRANCH_ID_INVALID; \
761         (input)->stageId = BAPE_STAGE_ID_INVALID; \
762         (input)->pName = ""; \
763         (input)->codec = BAVC_AudioCompressionStd_ePcm; \
764   } while(0)
765
766/***************************************************************************
767Summary:
768Path Node Type
769***************************************************************************/
770typedef enum BAPE_PathNodeType
771{
772    BAPE_PathNodeType_eDecoder,                     /* subtype=BAVC_AudioCompressionStd */
773    BAPE_PathNodeType_ePlayback,
774    BAPE_PathNodeType_eInputCapture,
775    BAPE_PathNodeType_ePostProcessor,               /* subtype=BAPE_PostProcessorType */
776    BAPE_PathNodeType_eEncoder,                     /* subtype=BAVC_AudioCompressionStd */
777    BAPE_PathNodeType_eRfEncoder,                   /* subtype=BAPE_RfAudioEncoding */
778    BAPE_PathNodeType_eMixer,                       /* subtype=BAPE_MixerType */
779    BAPE_PathNodeType_eEqualizer,
780    BAPE_PathNodeType_eMuxOutput,
781    BAPE_PathNodeType_eEchoCanceller,               /* subtype=BAPE_EchoCancellerAlgorithm */
782    BAPE_PathNodeType_eMax
783} BAPE_PathNodeType;
784
785/***************************************************************************
786Summary:
787Path Node State
788***************************************************************************/
789typedef enum BAPE_PathNodeState
790{
791    BAPE_PathNodeState_eIdle,
792    BAPE_PathNodeState_eAllocatingPath,
793    BAPE_PathNodeState_eAllocatedPath,
794    BAPE_PathNodeState_eConfiguredPath,
795    BAPE_PathNodeState_eStarted,   
796    BAPE_PathNodeState_eMax
797} BAPE_PathNodeState;
798
799/***************************************************************************
800Summary:
801Post Processor Type
802***************************************************************************/
803typedef enum BAPE_PostProcessorType
804{
805    BAPE_PostProcessorType_eDdre,
806    BAPE_PostProcessorType_eDolbyVolume,
807    BAPE_PostProcessorType_eTruSurround,
808    BAPE_PostProcessorType_eTruVolume,
809    BAPE_PostProcessorType_eStudioSound,
810    BAPE_PostProcessorType_eAudysseyAdv,
811    BAPE_PostProcessorType_eAudysseyAbx,
812    BAPE_PostProcessorType_e3dSurround,
813    BAPE_PostProcessorType_eDolbyDigitalReencoder,
814    BAPE_PostProcessorType_eAutoVolumeLevel,
815    BAPE_PostProcessorType_eCustom,
816    BAPE_PostProcessorType_eMax
817} BAPE_PostProcessorType;
818
819/***************************************************************************
820Summary:
821Path Node
822***************************************************************************/
823typedef struct BAPE_PathNode
824{
825    BDBG_OBJECT(BAPE_PathNode)
826
827    BAPE_PathNodeType type;
828    unsigned subtype;
829    void *pHandle;              /* Pointer to actual object handle */
830    unsigned numPaths;          /* Number of data paths/connectors */
831    BAPE_Handle deviceHandle;
832    bool monoInputValid;        /* If this node can support mono input this must be true.  It is very uncommon,
833                                   so this saves having a check in every single node type. */
834
835    BAPE_PathNodeState state;
836    unsigned numStarts;         /* Number of times start has been called.  Stop must be called the same number of times.  */
837
838    struct
839    {
840        BAPE_PathConnector connector;
841    } paths[BAPE_ConnectorFormat_eMax];
842
843    BLST_S_HEAD(UpstreamList, BAPE_PathConnection) upstreamList;
844
845    const char *pName;
846
847    /* Inter-Node Callbacks */
848    BERR_Code (*allocatePathFromInput)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
849    void      (*freePathFromInput)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
850    BERR_Code (*allocatePathToOutput)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
851    void      (*freePathToOutput)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
852    BERR_Code (*configPathFromInput)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
853    BERR_Code (*configPathToOutput)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
854    BERR_Code (*startPathFromInput)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
855    void      (*stopPathFromInput)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
856    BERR_Code (*startPathToOutput)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
857    void      (*stopPathToOutput)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
858    void      (*inputSampleRateChange_isr)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
859    BERR_Code (*inputFormatChange)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
860    void      (*inputMute)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection, bool enabled);
861    BERR_Code (*connectorSupported)(struct BAPE_PathNode *pNode, BAPE_PathConnector *pConnector);
862    BERR_Code (*outputConnectionAdded)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
863    void      (*outputConnectionRemoved)(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
864
865    /* InputPort->Node Callbacks */
866    BERR_Code (*inputPortFormatChange_isr)(struct BAPE_PathNode *pNode, BAPE_InputPort port);
867
868    /* Cleanup Callback */
869    void      (*removeInput)(struct BAPE_PathNode *pNode, BAPE_PathConnector *pConnector);
870} BAPE_PathNode;
871
872/***************************************************************************
873Summary:
874Init a connector
875***************************************************************************/
876#define BAPE_P_InitPathNode(node, nodetype, nodesubtype, nPaths, devHandle, handle) \
877   do {\
878         unsigned i;\
879         BKNI_Memset((node),0,sizeof(BAPE_PathNode));\
880         BDBG_OBJECT_SET((node),BAPE_PathNode);\
881         (node)->pHandle=(handle);\
882         (node)->type=(nodetype);\
883         (node)->subtype=(nodesubtype);\
884         (node)->numPaths=(nPaths);\
885         (node)->deviceHandle=(devHandle);\
886         BDBG_OBJECT_ASSERT((devHandle), BAPE_Device);\
887         for ( i = 0; i < (nPaths); i++ ) \
888         { \
889             BAPE_P_InitPathConnector(&(node)->paths[i].connector, (node)); \
890         } \
891         BLST_S_INIT(&(node)->upstreamList); \
892   } while(0)
893
894/***************************************************************************
895Summary:
896Output Path Status
897***************************************************************************/
898typedef struct BAPE_PathNodeOutputStatus
899{
900    unsigned numPaths;
901    struct
902    {
903        unsigned directConnections;      /* Number of connections at the first level */
904        unsigned totalConnections;       /* Total number of downstream connections */
905        unsigned totalBranches;          /* Total number of downstream branches */
906        unsigned totalStereoOutputs;         /* Total number of stereo outputs into the FMM */
907        unsigned totalMultichannelOutputs;   /* Total number of multichannel outputs into the FMM */
908        unsigned totalCompressedOutputs;     /* Total number of compressed outputs into the FMM */
909        unsigned totalMonoOutputs;           /* Total number of mono outputs into the FMM */
910    } pathStatus[BAPE_ConnectorFormat_eMax];
911
912    unsigned activeConnectors;       /* Number of active connectors */
913    unsigned directConnections;      /* Number of connections at the first level of all connectors */
914    unsigned totalConnections;       /* Total number of downstream connections including all connectors */
915    unsigned totalBranches;          /* Total number of downstream branches including all connectors */
916    unsigned totalStereoOutputs;         /* Total number of stereo outputs into the FMM */
917    unsigned totalMultichannelOutputs;   /* Total number of multichannel outputs into the FMM */
918    unsigned totalCompressedOutputs;     /* Total number of compressed outputs into the FMM */
919    unsigned totalMonoOutputs;           /* Total number of mono outputs into the FMM */
920} BAPE_PathNodeOutputStatus;
921
922/***************************************************************************
923Summary:
924Invalid Stream ID
925***************************************************************************/
926#define BAPE_STREAM_ID_INVALID (0xff)
927
928/***************************************************************************
929Summary:
930Connection from an upstream connector to a downstream node
931***************************************************************************/
932typedef struct BAPE_PathConnection
933{
934    BDBG_OBJECT(BAPE_PathConnection)
935    BAPE_PathConnector *pSource;
936    BAPE_PathNode *pSink;
937    BLST_S_ENTRY(BAPE_PathConnection) upstreamNode;
938    BLST_SQ_ENTRY(BAPE_PathConnection) downstreamNode;
939    unsigned numChannelPairs;
940    unsigned sampleRate;
941    bool ppmCorrection;
942    bool compressed;
943    bool mono;
944    BAVC_AudioCompressionStd codec;
945
946    /* FMM Input Details */
947    BAPE_FciIdGroup inputFciGroup;
948
949    /* FMM Resources */
950    BAPE_SfifoGroupHandle       sfifoGroup;
951    BAPE_SrcGroupHandle         srcGroup;
952    BAPE_MixerGroupHandle       mixerGroup;
953    BAPE_DfifoGroupHandle       dfifoGroup;
954    BAPE_LoopbackGroupHandle    loopbackGroup;
955
956    /* Buffers for DSP mixer/Echo Canceller connections */
957    BAPE_BufferNode *pLoopbackBuffers[BAPE_ChannelPair_eMax];
958    BDSP_AF_P_sIO_BUFFER *pInterTaskIoDescriptor;
959    void *pInterTaskIoBuffer;
960    BDSP_AF_P_sIO_GENERIC_BUFFER *pInterTaskGenericDescriptor;
961    void *pInterTaskGenericBuffer;
962
963    /* DSP Mixer/Echo Canceller Input Handle */
964    BDSP_TaskStageInputHandle taskInput;
965} BAPE_PathConnection;
966
967/***************************************************************************
968Summary:
969Timing Source Options
970***************************************************************************/
971typedef enum BAPE_MclkSource
972{
973    BAPE_MclkSource_eNone,
974    BAPE_MclkSource_ePll0,
975    BAPE_MclkSource_ePll1,
976    BAPE_MclkSource_ePll2,
977    BAPE_MclkSource_eHifidac0,
978    BAPE_MclkSource_eHifidac1,
979    BAPE_MclkSource_eHifidac2,
980    BAPE_MclkSource_eNco0,
981    BAPE_MclkSource_eNco1,
982    BAPE_MclkSource_eNco2,
983    BAPE_MclkSource_eMax
984} BAPE_MclkSource;
985
986#define BAPE_MCLKSOURCE_IS_PLL(mclkSource)  (mclkSource >= BAPE_MclkSource_ePll0     && mclkSource <= BAPE_MclkSource_ePll2)
987#define BAPE_MCLKSOURCE_IS_DAC(mclkSource)  (mclkSource >= BAPE_MclkSource_eHifidac0 && mclkSource <= BAPE_MclkSource_eHifidac2)
988#define BAPE_MCLKSOURCE_IS_NCO(mclkSource)  (mclkSource >= BAPE_MclkSource_eNco0     && mclkSource <= BAPE_MclkSource_eNco2)
989
990/***************************************************************************
991Summary:
992Mixer Interface Structure to store callbacks for mixer functions.
993***************************************************************************/
994typedef struct BAPE_MixerInterface {
995    void      (*destroy)            (BAPE_MixerHandle handle);
996    BERR_Code (*start)              (BAPE_MixerHandle handle);
997    void      (*stop)               (BAPE_MixerHandle handle);
998    BERR_Code (*addInput)           (BAPE_MixerHandle handle, BAPE_Connector input, const BAPE_MixerAddInputSettings *pSettings);
999    BERR_Code (*removeInput)        (BAPE_MixerHandle handle, BAPE_Connector input );
1000    BERR_Code (*removeAllInputs)    (BAPE_MixerHandle handle);
1001    BERR_Code (*addOutput)          (BAPE_MixerHandle handle, BAPE_OutputPort output );
1002    BERR_Code (*removeOutput)       (BAPE_MixerHandle handle, BAPE_OutputPort output );
1003    BERR_Code (*removeAllOutputs)   (BAPE_MixerHandle handle);
1004    BERR_Code (*getInputVolume)     (BAPE_MixerHandle handle, BAPE_Connector input, BAPE_MixerInputVolume *pVolume);
1005    BERR_Code (*setInputVolume)     (BAPE_MixerHandle handle, BAPE_Connector input, const BAPE_MixerInputVolume *pVolume);
1006    BERR_Code (*applyOutputVolume)  (BAPE_MixerHandle handle, BAPE_OutputPort output);
1007    BERR_Code (*setSettings)        (BAPE_MixerHandle hMixer, const BAPE_MixerSettings *pSettings);
1008} BAPE_MixerInterface ;
1009
1010/***************************************************************************
1011Summary:
1012Mixer Structure
1013***************************************************************************/
1014typedef struct BAPE_Mixer
1015{
1016    BDBG_OBJECT(BAPE_Mixer)
1017    const BAPE_MixerInterface *interface;
1018    unsigned running;
1019    bool     startedExplicity;  /* true => mixer was started with BAPE_Mixer_Start()*/
1020    bool compressed;
1021    bool ready;
1022    unsigned numChannelPairs;
1023    unsigned index;   
1024    unsigned numMixerGroups;
1025    unsigned fs;
1026    unsigned sampleRate;
1027    unsigned numOutputs;
1028    unsigned numOutputConnections;  /* Number of output connections.  Used when connecting a standard mixer to another FMM node such as eq or mixer. */
1029    BAPE_PathNode pathNode;
1030    BAPE_MclkSource mclkSource;
1031    BAPE_MixerGroupHandle mixerGroups[BAPE_CHIP_MAX_MIXERS];
1032    BAPE_Handle deviceHandle;
1033    BAPE_MixerSettings settings;
1034    BAPE_Connector master;
1035    BAPE_Connector inputs[BAPE_CHIP_MAX_MIXER_INPUTS];
1036    bool inputMuted[BAPE_CHIP_MAX_MIXER_INPUTS];
1037    bool inputRunning[BAPE_CHIP_MAX_MIXER_INPUTS];
1038    BAPE_MixerInputVolume inputVolume[BAPE_CHIP_MAX_MIXER_INPUTS];
1039#if BAPE_CHIP_MAX_DSP_MIXERS > 0
1040    BDSP_TaskHandle task;
1041    BDSP_TaskCreateSettings taskCreateSettings;
1042    BDSP_CIT_P_FwBranchInfo *pPrimaryBranch;
1043    BDSP_AF_P_sSINGLE_CIRC_BUFFER *pFeedbackBufferDescriptor;
1044    void *pFeedbackBuffer;
1045#endif
1046    BLST_S_HEAD(OutputList, BAPE_OutputPortObject) outputList;
1047    BLST_S_ENTRY(BAPE_Mixer) pllNode;
1048    BLST_S_ENTRY(BAPE_Mixer) ncoNode;
1049    BLST_S_ENTRY(BAPE_Mixer) node;
1050} BAPE_Mixer;
1051
1052/***************************************************************************
1053Summary:
1054Output Port Types
1055***************************************************************************/
1056typedef enum BAPE_OutputPortType
1057{
1058    BAPE_OutputPortType_eI2sOutput,
1059    BAPE_OutputPortType_eI2sMultiOutput,
1060    BAPE_OutputPortType_eMaiOutput,
1061    BAPE_OutputPortType_eSpdifOutput,
1062    BAPE_OutputPortType_eDac,
1063    BAPE_OutputPortType_eDummyOutput,
1064    BAPE_OutputPortType_eOutputCapture,
1065    BAPE_OutputPortType_eMax
1066}BAPE_OutputPortType;
1067
1068/***************************************************************************
1069Summary:
1070Generic Mixer Output Structure
1071***************************************************************************/
1072typedef struct BAPE_OutputPortObject
1073{
1074    BDBG_OBJECT(BAPE_OutputPort)
1075    BAPE_OutputPortType type;       /* type of output device this port belongs to */
1076    unsigned index;                 /* index with respect to type */
1077    void *pHandle;                  /* pointer to the specific output device */
1078    BAPE_MixerHandle mixer;                         /* NULL if not connected (set by mixer) */
1079    BLST_S_ENTRY(BAPE_OutputPortObject) node;       /* This is the node used in a mixer's linked list to manage a list of outputs (set by mixer) */
1080    unsigned maxChannelPairs;
1081    BAPE_MclkSource mclkOutput;     /* If this output generates an MCLK (e.g. DAC), which one is it? */
1082    bool compressedSupported;
1083    bool muteInMixer;
1084    bool fsTiming;                  /* If this output slaves to an Fs source, this is true. */
1085    bool pllRequired;               /* If this output should always use a PLL this is true. */
1086    bool builtinNco;                /* If this is true, an output has its own NCO timing source (e.g. DAC). */
1087
1088    /* Primary APE_Mixer <-> Output Mapping */
1089    BAPE_MixerGroupHandle sourceMixerGroup; /* (Set by mixer) */
1090    unsigned sourceMixerOutputIndex;        /* (Set by mixer) */
1091    BAPE_FciIdGroup sourceMixerFci;         /* (Set by mixer) */
1092
1093    BAPE_OutputVolume volume;                       /* (Set by mixer) */
1094
1095    void (*setTimingParams_isr)(BAPE_OutputPort output, unsigned sampleRate, BAVC_Timebase timebase);
1096    void (*setMclk_isr)(BAPE_OutputPort output, BAPE_MclkSource mclkSource, unsigned pllChannel, unsigned mclkFreqToFsRatio);
1097    void (*setFs)(BAPE_OutputPort output, unsigned fsNum);
1098    void (*setMute)(BAPE_OutputPort output, bool muted, bool sync);
1099    BERR_Code (*enable)(BAPE_OutputPort output);
1100    void      (*disable)(BAPE_OutputPort output);
1101    const char *pName;
1102} BAPE_OutputPortObject;
1103
1104/***************************************************************************
1105Summary:
1106Init an output port
1107***************************************************************************/
1108#define BAPE_P_InitOutputPort(output, typ, indx, handle) \
1109   do {\
1110         unsigned _idx;\
1111         BKNI_Memset((output),0,sizeof(BAPE_OutputPortObject));\
1112         BDBG_OBJECT_SET((output),BAPE_OutputPort);\
1113         (output)->type = typ; \
1114         (output)->index = indx; \
1115         (output)->pHandle=handle;\
1116         for ( _idx = 0; _idx < BAPE_Channel_eMax; _idx++ ) { (output)->volume.volume[_idx] = 0x800000; }\
1117            BAPE_FciIdGroup_Init(&(output)->sourceMixerFci); \
1118   } while(0)
1119
1120/***************************************************************************
1121Summary:
1122Input Port Types
1123***************************************************************************/
1124typedef enum BAPE_InputPortType
1125{
1126    BAPE_InputPortType_eI2s,
1127    BAPE_InputPortType_eMai,
1128    BAPE_InputPortType_eSpdif,
1129    BAPE_InputPortType_eRf,
1130    BAPE_InputPortType_eAdc,
1131    BAPE_InputPortType_eMax
1132}BAPE_InputPortType;
1133
1134/***************************************************************************
1135Summary:
1136Generic InputPort Structure
1137***************************************************************************/
1138typedef struct BAPE_InputPortObject
1139{
1140    BDBG_OBJECT(BAPE_InputPort)
1141    BAPE_InputPortType type;    /* type of output device this port belongs to */   
1142    unsigned index;             /* index with respect to type */                   
1143    void *pHandle;              /* pointer to the specific output device */       
1144    BAPE_PathNode *pConsumer;                         /* Consumer path node */
1145    uint16_t streamId[BAPE_ChannelPair_eMax];         /* Input stream ID */
1146    unsigned sampleRate;                              /* Sample Rate in Hz (0 if unknown) */
1147    unsigned numChannelPairs;                         /* Number of input channel pairs */
1148    bool compressed;                                  /* True if data is compressed */
1149    void (*enable)(BAPE_InputPort  inputPort);        /* Called when consumer starts */
1150    void (*disable)(BAPE_InputPort inputPort);        /* Called when consumer stops */
1151    BERR_Code (*consumerAttached)(BAPE_InputPort inputPort, BAPE_PathNode *pConsumer);       /* Called when a new consumer attaches */
1152    void      (*consumerDetached)(BAPE_InputPort inputPort, BAPE_PathNode *pConsumer);       /* Called when a consumer detaches */   
1153    const char *pName;
1154} BAPE_InputPortObject;
1155
1156/***************************************************************************
1157Summary:
1158Init an input port
1159***************************************************************************/
1160#define BAPE_P_InitInputPort(input, typ, indx, handle) \
1161   do {\
1162         unsigned i;\
1163         BKNI_Memset((input),0,sizeof(BAPE_InputPortObject));\
1164         BDBG_OBJECT_SET((input),BAPE_InputPort);\
1165         (input)->type = typ; \
1166         (input)->index = indx; \
1167         (input)->pHandle=handle;\
1168         for ( i = 0; i < BAPE_ChannelPair_eMax; i++ ) { (input)->streamId[i] = BAPE_STREAM_ID_INVALID; }\
1169   } while(0)
1170
1171
1172/**********************************************************************
1173Summary: SPDIF Receiver Stream Type
1174Description: Enum represents the type of stream that comes through SPDIF In
1175**********************************************************************/
1176typedef enum BAPE_SpdifRx_StreamType
1177{
1178   BAPE_SpdifRx_StreamType_eLinear      = 0,    /* The stream type is PCM */
1179   BAPE_SpdifRx_StreamType_eCompressed  = 1,    /* Compressed stream */
1180   BAPE_SpdifRx_StreamType_eMax                 /* Invalid value */
1181} BAPE_SpdifRx_StreamType;
1182
1183/**********************************************************************
1184Summary:
1185    HDMI Receiver Digital Input Format
1186Description:
1187   This structure returns information of Digital Input format whenever there
1188   is a change in the format. It is used for the notification to the application
1189   about the change in the format.
1190Notes:
1191    This structure will be passed on to application callback function
1192    on Digital input format change
1193**********************************************************************/
1194typedef struct BAPE_P_SpdifRx_InputFormat
1195{
1196    BAPE_SpdifRx_StreamType eStreamType;   /* Input Format. May be linear or compressed  */
1197    BAVC_AudioCompressionStd eType;       /* Audio Type. This fiels is valid only when the stream type is compressed */
1198    unsigned eSampleRate;   /* Input Sampling Rate. This field in only valid when the stream is PCM (linear) */
1199}BAPE_P_SpdifRx_InputFormat;
1200
1201/***************************************************************************
1202Summary:
1203    This enumeration is used by the HDMI Rx for the State Machine Implementation
1204    in detecting the input change.
1205***************************************************************************/ 
1206typedef enum BAPE_P_SpdifRx_InputState
1207{   
1208    BAPE_P_SpdifRx_InputState_eStreamNone,
1209    BAPE_P_SpdifRx_InputState_eStreamPCM,
1210    BAPE_P_SpdifRx_InputState_eStreamHdmiPCM,   
1211    BAPE_P_SpdifRx_InputState_eStreamPendingCompress,
1212    BAPE_P_SpdifRx_InputState_eStreamGoodCompress,
1213    BAPE_P_SpdifRx_InputState_eInvalid,
1214    BAPE_P_SpdifRx_InputState_eMax
1215}BAPE_P_SpdifRx_InputState;
1216
1217/***************************************************************************
1218Summary:
1219    This structure is used as input by the HDMI Rx State Machine Implementation
1220    in detecting the input change.
1221***************************************************************************/ 
1222typedef struct BAPE_P_SpdifRx_DetectChange_InputParams
1223{
1224    BAPE_P_SpdifRx_InputState eCurrentState;        /* The Current Input State according to the detection logic */ 
1225    uint32_t                 ui32CurrentCompState; /* The Current Compressed state. Valid only if the eCurrentState is GoodCompress */
1226    uint32_t                 ui32CurrentEsrStatus; /* The Current Esr Status Value stored in hRapch. */
1227
1228}BAPE_P_SpdifRx_DetectChange_InputParams;
1229
1230/***************************************************************************
1231Summary:
1232    This structure is given as output by HDMI Rx State Machine Implementation
1233    in detecting the input change.
1234***************************************************************************/
1235typedef struct BAPE_P_SpdifRx_DetectChange_OutputParams
1236{
1237    BAPE_P_SpdifRx_InputState  eNewState;        /* The Changed/New Input State according to the detection logic */ 
1238    uint32_t                  ui32NewCompState; /* The Changed/New Compressed state. Valid only if the eNewState is GoodCompress */
1239    BAPE_P_SpdifRx_InputFormat sInputFormatInfo; /* The information on the new changed input */
1240}BAPE_P_SpdifRx_DetectChange_OutputParams;
1241
1242/***************************************************************************
1243Summary:
1244Notify consumers that the format has changed
1245***************************************************************************/
1246BERR_Code BAPE_InputPort_P_FormatChanged_isr(
1247    BAPE_InputPort inputPort
1248    );
1249
1250/***************************************************************************
1251Summary:
1252Attach a consumer to an input port
1253***************************************************************************/
1254BERR_Code BAPE_InputPort_P_AttachConsumer(
1255    BAPE_InputPort inputPort,
1256    BAPE_PathNode *pConsumer
1257    );
1258
1259/***************************************************************************
1260Summary:
1261Detach a consumer from an input port
1262***************************************************************************/
1263BERR_Code BAPE_InputPort_P_DetachConsumer(
1264    BAPE_InputPort inputPort,
1265    BAPE_PathNode *pConsumer
1266    );
1267
1268/***************************************************************************
1269Summary:
1270Get FCI Ids for Input Ports
1271***************************************************************************/
1272void BAPE_InputPort_P_GetOutputFciIds(
1273    BAPE_DecoderHandle handle,
1274    BAPE_FciIdGroup *pFciGroup      /* [out] */
1275    );
1276
1277/***************************************************************************
1278Summary:
1279Convert IEC-61937 Burst Preamble C to a codec type.
1280***************************************************************************/
1281void BAPE_InputPort_P_BurstPreambleToCodec(
1282    uint32_t burstPreamble,
1283    BAVC_AudioCompressionStd *codec
1284    );
1285
1286#ifdef BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_RDADDR
1287/***************************************************************************
1288Summary:
1289Rinbguffer Stride
1290***************************************************************************/
1291#define BAPE_P_RINGBUFFER_STRIDE (BCHP_AUD_FMM_BF_CTRL_RINGBUF_1_RDADDR-BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_RDADDR)
1292
1293/***************************************************************************
1294Summary:
1295Helpers to get ringbuffer register addresses from source channel id
1296***************************************************************************/
1297#define BAPE_P_SFIFO_TO_RINBGUFFER(id) (2*(id))
1298#define BAPE_P_SFIFO_TO_RDADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_RDADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1299#define BAPE_P_SFIFO_TO_WRADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_WRADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1300#define BAPE_P_SFIFO_TO_BASEADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_BASEADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1301#define BAPE_P_SFIFO_TO_ENDADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_ENDADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1302#define BAPE_P_SFIFO_TO_FREEFULL_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_FREEFULL_MARK + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1303#define BAPE_P_SFIFO_TO_WRPOINT_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_START_WRPOINT + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1304
1305/***************************************************************************
1306Summary:
1307Helpers to get ringbuffer register addresses from destination channel id
1308***************************************************************************/
1309#define BAPE_P_DFIFO_TO_RINBGUFFER(id) ((2*(id)) + BAPE_P_SFIFO_TO_RINBGUFFER(BAPE_CHIP_MAX_SFIFOS))
1310#define BAPE_P_DFIFO_TO_RDADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_RDADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id)+BAPE_CHIP_MAX_SFIFOS)))
1311#define BAPE_P_DFIFO_TO_WRADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_WRADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id)+BAPE_CHIP_MAX_SFIFOS)))
1312#define BAPE_P_DFIFO_TO_BASEADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_BASEADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id)+BAPE_CHIP_MAX_SFIFOS)))
1313#define BAPE_P_DFIFO_TO_ENDADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_ENDADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id)+BAPE_CHIP_MAX_SFIFOS)))
1314#define BAPE_P_DFIFO_TO_FREEFULL_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_FREEFULL_MARK + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id)+BAPE_CHIP_MAX_SFIFOS)))
1315#define BAPE_P_DFIFO_TO_WRPOINT_REG(id) (BCHP_AUD_FMM_BF_CTRL_RINGBUF_0_START_WRPOINT + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id)+BAPE_CHIP_MAX_SFIFOS)))
1316
1317#else
1318/* Newer 7429-style RDB */
1319/***************************************************************************
1320Summary:
1321Rinbguffer Stride
1322***************************************************************************/
1323#define BAPE_P_RINGBUFFER_STRIDE (BCHP_AUD_FMM_BF_CTRL_SOURCECH_RINGBUF_1_RDADDR-BCHP_AUD_FMM_BF_CTRL_SOURCECH_RINGBUF_0_RDADDR)
1324
1325/***************************************************************************
1326Summary:
1327Helpers to get ringbuffer register addresses from source channel id
1328***************************************************************************/
1329#define BAPE_P_SFIFO_TO_RINBGUFFER(id) (2*(id))
1330#define BAPE_P_SFIFO_TO_RDADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_SOURCECH_RINGBUF_0_RDADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1331#define BAPE_P_SFIFO_TO_WRADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_SOURCECH_RINGBUF_0_WRADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1332#define BAPE_P_SFIFO_TO_BASEADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_SOURCECH_RINGBUF_0_BASEADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1333#define BAPE_P_SFIFO_TO_ENDADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_SOURCECH_RINGBUF_0_ENDADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1334#define BAPE_P_SFIFO_TO_FREEFULL_REG(id) (BCHP_AUD_FMM_BF_CTRL_SOURCECH_RINGBUF_0_FREEFULL_MARK + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1335#define BAPE_P_SFIFO_TO_WRPOINT_REG(id) (BCHP_AUD_FMM_BF_CTRL_SOURCECH_RINGBUF_0_START_WRPOINT + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1336
1337/***************************************************************************
1338Summary:
1339Helpers to get ringbuffer register addresses from destination channel id
1340***************************************************************************/
1341#define BAPE_P_DFIFO_TO_RINBGUFFER(id) ((2*(id)) + BAPE_P_SFIFO_TO_RINBGUFFER(BAPE_CHIP_MAX_SFIFOS))
1342#define BAPE_P_DFIFO_TO_RDADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_DESTCH_RINGBUF_0_RDADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1343#define BAPE_P_DFIFO_TO_WRADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_DESTCH_RINGBUF_0_WRADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1344#define BAPE_P_DFIFO_TO_BASEADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_DESTCH_RINGBUF_0_BASEADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1345#define BAPE_P_DFIFO_TO_ENDADDR_REG(id) (BCHP_AUD_FMM_BF_CTRL_DESTCH_RINGBUF_0_ENDADDR + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1346#define BAPE_P_DFIFO_TO_FREEFULL_REG(id) (BCHP_AUD_FMM_BF_CTRL_DESTCH_RINGBUF_0_FREEFULL_MARK + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1347#define BAPE_P_DFIFO_TO_WRPOINT_REG(id) (BCHP_AUD_FMM_BF_CTRL_DESTCH_RINGBUF_0_START_WRPOINT + (2*BAPE_P_RINGBUFFER_STRIDE*((uint32_t)(id))))
1348#endif
1349
1350/***************************************************************************
1351Summary:
1352Init the L3 interrupt handlers
1353***************************************************************************/
1354BERR_Code BAPE_P_InitInterrupts(
1355    BAPE_Handle handle
1356    );
1357
1358/***************************************************************************
1359Summary:
1360Uninit the L3 interrupt handlers
1361***************************************************************************/
1362void BAPE_P_UninitInterrupts(
1363    BAPE_Handle handle
1364    );
1365
1366/***************************************************************************
1367Summary:
1368Enable/Disable a source channel freemark interrupt
1369***************************************************************************/
1370BERR_Code BAPE_P_SetSourceChannelFreemarkInterrupt(
1371    BAPE_Handle handle,
1372    unsigned sourceChannelId,
1373    BINT_CallbackFunc callback_isr,
1374    void *pParam1,
1375    int param2
1376    );
1377
1378/***************************************************************************
1379Summary:
1380Enable/Disable a destination channel fullmark interrupt
1381***************************************************************************/
1382BERR_Code BAPE_P_SetDfifoFullmarkInterrupt(
1383    BAPE_Handle handle,
1384    unsigned destChannelId,
1385    BINT_CallbackFunc callback_isr,
1386    void *pParam1,
1387    int param2
1388    );
1389
1390/***************************************************************************
1391Summary:
1392Enable/Disable a destination channel overflow interrupt
1393***************************************************************************/
1394BERR_Code BAPE_P_SetDfifoOverflowInterrupt(
1395    BAPE_Handle handle,
1396    unsigned destChannelId,
1397    BINT_CallbackFunc callback_isr,
1398    void *pParam1,
1399    int param2
1400    );
1401
1402/***************************************************************************
1403Summary:
1404Helper to get the SPDIF channel status code for a sample rate (IEC60958-3)
1405***************************************************************************/
1406unsigned BAPE_P_GetSampleRateCstatCode(unsigned sampleRate);
1407
1408/***************************************************************************
1409Summary:
1410Create a "Standard" mixer
1411***************************************************************************/
1412BERR_Code BAPE_StandardMixer_P_Create(
1413    BAPE_Handle deviceHandle,
1414    const BAPE_MixerSettings *pSettings,
1415    BAPE_MixerHandle *pHandle               /* [out] */
1416    );
1417
1418/***************************************************************************
1419Summary:
1420Create a DSP mixer
1421***************************************************************************/
1422BERR_Code BAPE_DspMixer_P_Create(
1423    BAPE_Handle deviceHandle,
1424    const BAPE_MixerSettings *pSettings,
1425    BAPE_MixerHandle *pHandle               /* [out] */
1426    );
1427
1428/***************************************************************************
1429Summary:
1430Find the index of a mixer input connector
1431***************************************************************************/
1432#define BAPE_MIXER_INPUT_INDEX_INVALID ((unsigned)-1)
1433unsigned BAPE_Mixer_P_FindInputIndex(BAPE_MixerHandle mixer, BAPE_Connector input);
1434
1435/***************************************************************************
1436Summary:
1437Return the default mixer input volume
1438***************************************************************************/
1439void BAPE_Mixer_P_GetDefaultInputVolume(BAPE_MixerInputVolume *pVolume);
1440
1441/***************************************************************************
1442Summary:
1443Apply the volume setting to a mixer's output
1444***************************************************************************/
1445BERR_Code BAPE_Mixer_P_ApplyOutputVolume(BAPE_MixerHandle mixer, BAPE_OutputPort output);
1446
1447/***************************************************************************
1448Summary:
1449Print information (using BDBG_LOG) about a BAPE_PathNode.
1450***************************************************************************/
1451BERR_Code BAPE_Mixer_P_PrintNodeInfo( BAPE_PathNode *pPathNode, int level, int index);
1452
1453/***************************************************************************
1454Summary:
1455Print a mixer-centric representation of the audio filter graph (for all
1456mixers).
1457***************************************************************************/
1458BERR_Code BAPE_Mixer_P_PrintMixers(BAPE_Handle deviceHandle);
1459
1460/***************************************************************************
1461Summary:
1462Print a representation of the audio filter graph (for all downstream
1463PathNodes).
1464***************************************************************************/
1465BERR_Code BAPE_Mixer_P_PrintDownstreamNodes(BAPE_PathNode *pPathNode);
1466
1467/***************************************************************************
1468Summary:
1469Print a representation of the audio filter graph (for all downstream
1470PathNodes).
1471***************************************************************************/
1472const char *BAPE_Mixer_P_MclkSourceToText(BAPE_MclkSource mclkSource);
1473
1474/***************************************************************************
1475Summary:
1476Attach a mixer to a PLL
1477***************************************************************************/
1478void BAPE_P_AttachMixerToPll(BAPE_MixerHandle mixer, BAPE_Pll pll);
1479
1480/***************************************************************************
1481Summary:
1482Detach a mixer from a PLL
1483***************************************************************************/
1484void BAPE_P_DetachMixerFromPll(BAPE_MixerHandle mixer, BAPE_Pll pll);
1485
1486/***************************************************************************
1487Summary:
1488Update PLL sample rate
1489***************************************************************************/
1490BERR_Code BAPE_P_UpdatePll_isr(BAPE_Handle handle, BAPE_Pll pll);
1491
1492/***************************************************************************
1493Summary:
1494Attach a mixer to a NCO
1495***************************************************************************/
1496void BAPE_P_AttachMixerToNco(BAPE_MixerHandle mixer, BAPE_Nco nco);
1497
1498/***************************************************************************
1499Summary:
1500Detach a mixer from a NCO
1501***************************************************************************/
1502void BAPE_P_DetachMixerFromNco(BAPE_MixerHandle mixer, BAPE_Nco nco);
1503
1504/***************************************************************************
1505Summary:
1506Update NCO sample rate
1507***************************************************************************/
1508BERR_Code BAPE_P_UpdateNco_isr(BAPE_Handle handle, BAPE_Nco nco);
1509
1510/***************************************************************************
1511Summary:
1512Allocate buffers from the resource pool
1513***************************************************************************/
1514BAPE_BufferNode *BAPE_P_AllocateBuffer(
1515    BAPE_Handle handle,
1516    BAPE_BufferType type
1517    );
1518
1519/***************************************************************************
1520Summary:
1521Release buffers to the resource pool
1522***************************************************************************/
1523void BAPE_P_FreeBuffer(
1524    BAPE_Handle handle,
1525    BAPE_BufferNode *pNode
1526    );
1527
1528/***************************************************************************
1529Summary:
1530Allocate FMM Resource
1531***************************************************************************/
1532typedef enum BAPE_FmmResourceType
1533{
1534    BAPE_FmmResourceType_eSfifo,
1535    BAPE_FmmResourceType_eDfifo,
1536    BAPE_FmmResourceType_eSrc,
1537    BAPE_FmmResourceType_eMixer,
1538    BAPE_FmmResourceType_ePlayback,
1539    BAPE_FmmResourceType_eDummysink,
1540    BAPE_FmmResourceType_eLoopback,
1541    BAPE_FmmResourceType_eFs,
1542    BAPE_FmmResourceType_eAdaptiveRate,
1543    BAPE_FmmResourceType_eMax
1544} BAPE_FmmResourceType;
1545
1546/***************************************************************************
1547Summary:
1548Allocate FMM Resource
1549***************************************************************************/
1550#if 1
1551#define BAPE_P_AllocateFmmResource(h,r,n,f) BAPE_P_AllocateFmmResource_tagged((h),(r),(n),(f),__FILE__,__LINE__);
1552BERR_Code BAPE_P_AllocateFmmResource_tagged(BAPE_Handle handle, BAPE_FmmResourceType resourceType, unsigned numChannelPairs, unsigned *pFirstResource, const char *pFile, unsigned line);
1553#else
1554BERR_Code BAPE_P_AllocateFmmResource(
1555    BAPE_Handle handle, 
1556    BAPE_FmmResourceType resourceType, 
1557    unsigned numChannelPairs, 
1558    unsigned *pFirstResource
1559    );
1560#endif
1561
1562/***************************************************************************
1563Summary:
1564Free FMM Resource
1565***************************************************************************/
1566void BAPE_P_FreeFmmResource(
1567    BAPE_Handle handle, 
1568    BAPE_FmmResourceType resourceType, 
1569    unsigned numChannelPairs, 
1570    unsigned firstResource
1571    );
1572
1573/***************************************************************************
1574Summary:
1575Release all unused path resources.
1576***************************************************************************/
1577void BAPE_P_ReleaseUnusedPathResources(BAPE_Handle handle);
1578
1579/***************************************************************************
1580Summary:
1581Allocate Input Buffers from the resource pool
1582***************************************************************************/
1583BERR_Code BAPE_P_AllocateInputBuffers(BAPE_Handle handle, BAPE_Connector input);
1584
1585/***************************************************************************
1586Summary:
1587Free Input Buffers to the resource pool
1588***************************************************************************/
1589void BAPE_P_FreeInputBuffers(BAPE_Handle handle, BAPE_Connector input);
1590
1591/***************************************************************************
1592Summary:
1593Determine if a MuxOutput object has been started
1594***************************************************************************/
1595bool BAPE_MuxOutput_P_IsRunning(BAPE_MuxOutputHandle handle);
1596
1597#if defined BCHP_AUD_FMM_MS_CTRL_REG_START
1598/***************************************************************************
1599Summary:
1600Microsequencer FW version
1601***************************************************************************/
1602extern const uint32_t g_BAPE_MS_FirmwareVersion[4];
1603
1604/***************************************************************************
1605Summary:
1606Microsequencer FW
1607***************************************************************************/
1608#include "bchp_aud_fmm_ms_ctrl.h"
1609extern const uint32_t g_BAPE_MS_Firmware[BCHP_AUD_FMM_MS_CTRL_USEQ_INSTi_ARRAY_END + 1];
1610#endif
1611
1612/***************************************************************************
1613Summary:
1614Decoder Handle
1615***************************************************************************/
1616typedef struct BAPE_Decoder
1617{
1618    BDBG_OBJECT(BAPE_Decoder)
1619    BAPE_Handle deviceHandle;
1620    unsigned index;
1621    BAPE_PathNode node;
1622    char name[10]; /* Decoder %u */
1623
1624    /* Basic State Information */
1625    bool independentDelay;
1626    bool passthrough;
1627    bool simul;
1628    bool stereoOnMultichannel;
1629    bool stereoOnCompressed;
1630    BAPE_PathNodeOutputStatus outputStatus;
1631    BAPE_DecoderState state;
1632    BAPE_DecoderSettings settings;
1633    BAPE_DecoderStartSettings startSettings;
1634    BAVC_XptContextMap contextMap;
1635    BAPE_DecoderTsmSettings tsmSettings;   
1636
1637    /* Codec-specific settings */
1638    /* TODO: Codec settings should be stored in the individual structures and not the full union to save space. */
1639    BAPE_DecoderCodecSettings ac3Settings, ac3PlusSettings;
1640    BAPE_DecoderCodecSettings aacSettings, aacPlusSettings;
1641    BAPE_DecoderCodecSettings wmaProSettings;
1642    BAPE_DecoderCodecSettings dtsSettings;
1643    BAPE_DecoderCodecSettings adpcmSettings;
1644    BAPE_DecoderInterruptHandlers interrupts;
1645
1646    /* DSP Task Information */
1647    BDSP_TaskHandle task;
1648    BDSP_TaskCreateSettings taskCreateSettings;
1649    BDSP_CIT_P_FwBranchInfo primaryBranch;
1650    unsigned dspIndex;
1651    unsigned sampleRate;
1652    unsigned mode;
1653    unsigned dsolaBranch, dsolaStage;
1654    BDSP_AudioBitRateChangeInfo bitRateInfo;
1655
1656    /* DFIFO Input Information */
1657    unsigned inputChannelPairs;
1658    bool inputCompressed;                                   
1659    BAPE_DfifoGroupHandle inputDfifoGroup;
1660    BAPE_BufferNode *pInputBuffers[BAPE_ChannelPair_eMax];
1661
1662    /* Required for Multi-stream Decoding  */
1663    bool fwMixerMaster;
1664    BAPE_DolbyDigitalReencodeHandle ddre;
1665    BAPE_MixerHandle fwMixer;   
1666} BAPE_Decoder;
1667
1668/***************************************************************************
1669Summary:
1670Set a decoder's sample rate
1671***************************************************************************/
1672void BAPE_Decoder_P_SetSampleRate_isr(BAPE_DecoderHandle handle, unsigned sampleRate);
1673
1674/***************************************************************************
1675Summary:
1676Get default codec specifics for the DSP codecs
1677***************************************************************************/
1678void BAPE_Decoder_P_GetDefaultCodecSettings(BAPE_DecoderHandle handle);
1679
1680/***************************************************************************
1681Summary:
1682Apply codec settings to DSP
1683***************************************************************************/
1684BERR_Code BAPE_Decoder_P_ApplyCodecSettings(BAPE_DecoderHandle handle);
1685
1686/***************************************************************************
1687Summary:
1688Get codec status from DSP
1689***************************************************************************/
1690BERR_Code BAPE_Decoder_P_GetCodecStatus(BAPE_DecoderHandle handle, BAPE_DecoderStatus *pStatus);
1691
1692/***************************************************************************
1693Summary:
1694Propagate settings between decoder and DDRE
1695***************************************************************************/
1696BERR_Code BAPE_DolbyDigitalReencode_P_SettingsChanged(
1697    BAPE_DolbyDigitalReencodeHandle handle, 
1698    BAPE_DecoderHandle decoder
1699    );
1700
1701/***************************************************************************
1702Summary:
1703Playback Handle Structure
1704***************************************************************************/
1705typedef struct BAPE_Playback
1706{
1707    BDBG_OBJECT(BAPE_Playback)
1708    BAPE_Handle deviceHandle;
1709    unsigned index;
1710    BAPE_PathNode node;
1711    BAPE_PathConnection *pMaster;
1712    BAPE_PlaybackStartSettings startSettings;
1713    void *pBuffer[BAPE_Channel_eMax];
1714    BAPE_PlaybackSettings settings;
1715    unsigned bufferSize;
1716    unsigned numBuffers;
1717    unsigned threshold;
1718    unsigned bufferDepth;   /* Required for pre-start buffer fills (used in looparound mode) */
1719    BAPE_PlaybackInterruptHandlers interrupts;
1720    bool running;
1721    char name[12]; /* Playback %d */
1722} BAPE_Playback;
1723
1724/***************************************************************************
1725Summary:
1726Input Capture Handle Structure
1727***************************************************************************/
1728typedef struct BAPE_InputCapture
1729{
1730    BDBG_OBJECT(BAPE_InputCapture)
1731    BAPE_Handle deviceHandle;
1732    unsigned index;
1733    BAPE_PathNode node;
1734    BAPE_PathConnection *pMaster;
1735    BAPE_InputCaptureOpenSettings openSettings;
1736    BAPE_InputCaptureStartSettings startSettings;
1737    BAPE_InputCaptureInterruptHandlers interrupts;
1738    BAPE_DfifoGroupHandle dfifoGroup;
1739    BAPE_PathConnection *pMasterConnection;         /* Master for SFIFO master/slave designation */
1740    unsigned inputSampleRate;                       /* Sample Rate in Hz (0 if unknown) */
1741    unsigned inputChannelPairs;                     /* Number of input channel pairs */
1742    bool     inputCompressed;                       /* True if data is compressed */
1743    bool running;
1744    char name[16];  /* InputCapture %d */
1745} BAPE_InputCapture;
1746
1747/***************************************************************************
1748Summary:
1749Echo Canceller Handle Structure
1750***************************************************************************/
1751typedef struct BAPE_EchoCanceller
1752{
1753    BDBG_OBJECT(BAPE_EchoCanceller)
1754    BAPE_Handle deviceHandle;
1755    BAPE_PathNode localNode, remoteNode;    /* Need two nodes to distinguish the local vs. remote input paths.  They don't behave the same way. */
1756    BAPE_EchoCancellerSettings settings;
1757    BAPE_SpeexEchoCancellerSettings speexSettings;
1758    BAPE_Connector localInput, remoteInput;
1759    bool localStarted, remoteStarted;
1760
1761    /* Inter-task communication details */
1762    BDSP_AF_P_sIO_BUFFER *pInterTaskIoDescriptor;
1763    void *pInterTaskIoBuffer;
1764    BDSP_AF_P_sIO_GENERIC_BUFFER *pInterTaskGenericDescriptor;
1765    void *pInterTaskGenericBuffer;
1766} BAPE_EchoCanceller;
1767
1768/***************************************************************************
1769Summary:
1770Get the address of a mixer's config register
1771***************************************************************************/
1772uint32_t BAPE_P_GetMixerConfigAddress(unsigned mixerId);
1773
1774/***************************************************************************
1775Summary:
1776Invalid Fs handle
1777***************************************************************************/
1778#define BAPE_FS_INVALID ((unsigned)-1)
1779
1780/***************************************************************************
1781Summary:
1782Allocate an Fs timing source
1783***************************************************************************/
1784unsigned BAPE_P_AllocateFs(BAPE_Handle handle);
1785
1786/***************************************************************************
1787Summary:
1788Free an Fs timing source
1789***************************************************************************/
1790void BAPE_P_FreeFs(BAPE_Handle handle, unsigned fs);
1791
1792/***************************************************************************
1793Summary:
1794Set the timing parameters for an Fs timing source
1795***************************************************************************/
1796void BAPE_P_SetFsTiming_isr(
1797    BAPE_Handle handle, 
1798    unsigned fsIndex, 
1799    BAPE_MclkSource mclkSource, 
1800    unsigned pllChannel, 
1801    unsigned mclkFreqToFsRatio
1802    );
1803
1804/***************************************************************************
1805Summary:
1806Map User settings to DSP for TruVolume.  Required in both StudioSound
1807and TruVolume.
1808***************************************************************************/
1809BERR_Code BAPE_TruVolume_P_ConvertSettingsToDsp(
1810    const BAPE_TruVolumeSettings *pSettings, 
1811    BDSP_Raaga_Audio_TruVolumeUserConfig *pUserConfig
1812    );
1813
1814/***************************************************************************
1815Summary:
1816Map User settings to DSP for TruSurroundHd.  Required in both StudioSound
1817and TruSurroundHd.
1818***************************************************************************/
1819BERR_Code BAPE_TruSurroundHd_P_ConvertSettingsToDsp(
1820    const BAPE_TruSurroundHdSettings *pSettings, 
1821    unsigned numChannelPairs,
1822    BDSP_Raaga_Audio_TruSurrndHDConfigParams *pUserConfig
1823    );
1824
1825#if BAPE_CHIP_MAX_SPDIF_OUTPUTS > 0 || BAPE_CHIP_MAX_MAI_OUTPUTS > 0
1826/***************************************************************************
1827Summary:
1828SPDIF Channel Status Bits
1829***************************************************************************/
1830typedef struct BAPE_Spdif_P_ChannelStatusBits
1831{
1832    uint32_t bits[3];
1833}BAPE_Spdif_P_ChannelStatusBits;
1834
1835/***************************************************************************
1836Summary:
1837Setup Channel Status Bits for SPDIF or HDMI outputs
1838***************************************************************************/
1839void BAPE_P_MapSpdifChannelStatusToBits_isr(
1840    BAPE_OutputPort output,
1841    const BAPE_SpdifChannelStatus *pChannelStatus,
1842    BAPE_Spdif_P_ChannelStatusBits *pBits           /* [out] */
1843    );
1844#endif
1845
1846/* These must be after definition of path types above */
1847#include "bape_dsp_utils_priv.h"
1848#include "bape_path_priv.h"
1849#include "bape_fmm_priv.h"
1850
1851#endif /* #ifndef BAPE_PRIV_H_ */
1852
Note: See TracBrowser for help on using the repository browser.