| 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.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/20 $ |
|---|
| 12 | * $brcm_Date: 1/31/12 6:17p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: Audio Decoder Interface |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/ape/7422/bape.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/20 1/31/12 6:17p jgarrett |
|---|
| 21 | * SW7425-2268: Adding initial voice conferencing support |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/19 12/19/11 4:27p jgarrett |
|---|
| 24 | * SW7425-1018: Adding initial A/85 implementation |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/18 8/24/11 11:53a jgarrett |
|---|
| 27 | * SW7425-724: Adding RF Audio Encoder |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/17 8/12/11 6:53p jgarrett |
|---|
| 30 | * SWDTV-6627: Refactoring initial EQ code |
|---|
| 31 | * |
|---|
| 32 | * Hydra_Software_Devel/16 7/15/11 5:51p jgarrett |
|---|
| 33 | * SWDTV-6761: Adding StudioSound API |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/15 6/1/11 6:30p jgarrett |
|---|
| 36 | * SW7425-406: Updating buffer comments |
|---|
| 37 | * |
|---|
| 38 | * Hydra_Software_Devel/14 5/23/11 12:46p gskerl |
|---|
| 39 | * SW7231-128: Changed tabs to spaces |
|---|
| 40 | * |
|---|
| 41 | * Hydra_Software_Devel/13 5/18/11 2:30p gskerl |
|---|
| 42 | * SW7231-128: Added BCHP_PWR support to APE |
|---|
| 43 | * |
|---|
| 44 | * Hydra_Software_Devel/12 5/14/11 11:33a jgarrett |
|---|
| 45 | * SWDTV-6763: Adding 3D Surround |
|---|
| 46 | * |
|---|
| 47 | * Hydra_Software_Devel/11 5/14/11 11:22a jgarrett |
|---|
| 48 | * SWDTV-6762: Adding Audyssey ADV/ABX |
|---|
| 49 | * |
|---|
| 50 | * Hydra_Software_Devel/10 5/13/11 6:39p jgarrett |
|---|
| 51 | * SW7425-410: Adding AVL |
|---|
| 52 | * |
|---|
| 53 | * Hydra_Software_Devel/9 5/11/11 7:04p jgarrett |
|---|
| 54 | * SW7422-410: Adding CustomProcessing |
|---|
| 55 | * |
|---|
| 56 | * Hydra_Software_Devel/8 4/16/11 12:15p jgarrett |
|---|
| 57 | * SW7425-371: Removing tab characters |
|---|
| 58 | * |
|---|
| 59 | * Hydra_Software_Devel/7 4/11/11 5:54p jgarrett |
|---|
| 60 | * SWDTV-6305: Adding ADC/RF Inputs for DTV |
|---|
| 61 | * |
|---|
| 62 | * Hydra_Software_Devel/6 3/21/11 7:08p jgarrett |
|---|
| 63 | * SW7422-356: Adding MuxOutput |
|---|
| 64 | * |
|---|
| 65 | * Hydra_Software_Devel/5 2/22/11 5:43p jgarrett |
|---|
| 66 | * SW7422-146: Implemented type renaming based on filter graph review |
|---|
| 67 | * comments |
|---|
| 68 | * |
|---|
| 69 | * Hydra_Software_Devel/4 1/12/11 4:24p jgarrett |
|---|
| 70 | * SW7422-146: Adding additional APIs |
|---|
| 71 | * |
|---|
| 72 | * Hydra_Software_Devel/3 12/16/10 4:04p jgarrett |
|---|
| 73 | * SW7422-146: Initial compilable APE for 7422 |
|---|
| 74 | * |
|---|
| 75 | * Hydra_Software_Devel/2 12/14/10 2:39p jgarrett |
|---|
| 76 | * SW7408-146: Renaming MixerOutput to OutputPort |
|---|
| 77 | * |
|---|
| 78 | * Hydra_Software_Devel/1 12/14/10 2:16p jgarrett |
|---|
| 79 | * SW7422-146: Adding initial API for APE/DSP |
|---|
| 80 | * |
|---|
| 81 | ***************************************************************************/ |
|---|
| 82 | |
|---|
| 83 | #ifndef BAPE_H_ |
|---|
| 84 | #define BAPE_H_ |
|---|
| 85 | |
|---|
| 86 | #include "bchp.h" |
|---|
| 87 | #include "bint.h" |
|---|
| 88 | #include "bmem.h" |
|---|
| 89 | #include "breg_mem.h" |
|---|
| 90 | #include "btmr.h" |
|---|
| 91 | #include "bimg.h" |
|---|
| 92 | #include "bdsp.h" |
|---|
| 93 | #include "bape_types.h" |
|---|
| 94 | #include "bape_mixer.h" |
|---|
| 95 | #include "bape_decoder.h" |
|---|
| 96 | #include "bape_playback.h" |
|---|
| 97 | #include "bape_input.h" |
|---|
| 98 | #include "bape_output.h" |
|---|
| 99 | #include "bape_mux_output.h" |
|---|
| 100 | #include "bape_pll.h" |
|---|
| 101 | #include "bape_input_capture.h" |
|---|
| 102 | #include "bape_output_capture.h" |
|---|
| 103 | #include "bape_encoder.h" |
|---|
| 104 | #include "bape_dolby_digital_reencode.h" |
|---|
| 105 | #include "bape_dolby_volume.h" |
|---|
| 106 | #include "bape_tru_surround.h" |
|---|
| 107 | #include "bape_tru_volume.h" |
|---|
| 108 | #include "bape_custom_processing.h" |
|---|
| 109 | #include "bape_auto_volume_level.h" |
|---|
| 110 | #include "bape_audyssey_abx.h" |
|---|
| 111 | #include "bape_audyssey_adv.h" |
|---|
| 112 | #include "bape_3d_surround.h" |
|---|
| 113 | #include "bape_studio_sound.h" |
|---|
| 114 | #include "bape_equalizer.h" |
|---|
| 115 | #include "bape_rf_encoder.h" |
|---|
| 116 | #include "bape_echo_canceller.h" |
|---|
| 117 | |
|---|
| 118 | /*=************************ Module Overview ******************************** |
|---|
| 119 | APE (Audio Processing Engine) is a porting interface (PI) module that |
|---|
| 120 | controls the audio subsystem. This includes the AIO (mixer, inputs, outputs) |
|---|
| 121 | as well as the decode processor (DSP or CPU). |
|---|
| 122 | |
|---|
| 123 | Device: |
|---|
| 124 | ------- |
|---|
| 125 | An APE Device is identified by a device handle (BAPE_Handle). This is the |
|---|
| 126 | top-level interface to the audio subsystem. |
|---|
| 127 | |
|---|
| 128 | Decoder: |
|---|
| 129 | -------- |
|---|
| 130 | A decoder is capable of decoding digital audio into PCM samples and also |
|---|
| 131 | providing compressed passthrough of input data. This is identified by |
|---|
| 132 | a BAPE_DecoderHandle. Decoding is done in a decode processor, and the |
|---|
| 133 | output can be fed into a mixer. Optionally, post-processing (BAPE_Processor) |
|---|
| 134 | may be inserted between the decoder and the mixer. Decoders can read |
|---|
| 135 | from a RAVE context (BAVC_XptContextMap) or on some systems can read |
|---|
| 136 | from an input port (BAPE_InputPort). The latter is useful for external |
|---|
| 137 | inputs that provide compressed data (e.g. SPDIF) or inputs that require |
|---|
| 138 | post processing. |
|---|
| 139 | |
|---|
| 140 | Playback: |
|---|
| 141 | --------- |
|---|
| 142 | Playback is used for playing host-generated PCM data. It is also an |
|---|
| 143 | input to a mixer. |
|---|
| 144 | |
|---|
| 145 | InputCapture: |
|---|
| 146 | ------------- |
|---|
| 147 | InputCapture is used to capture PCM input from an input port (BAPE_InputPort) |
|---|
| 148 | and feeds data into a mixer. |
|---|
| 149 | |
|---|
| 150 | InputGroup: |
|---|
| 151 | ----------- |
|---|
| 152 | Input groups allow for multiple stereo inputs to be grouped together |
|---|
| 153 | and treated as multichannel data. This is useful if you want to combine |
|---|
| 154 | three stereo playback channels to generate 5.1 audio for example. Grouped |
|---|
| 155 | inputs will always start synchronously in the mixer. |
|---|
| 156 | |
|---|
| 157 | Mixer: |
|---|
| 158 | ------ |
|---|
| 159 | Mixers are used to mix one or more inputs to one or more outputs. A |
|---|
| 160 | mixer is always required to bind an output to its input(s). Mixers |
|---|
| 161 | provide input volume scaling as well as output volume scaling. All |
|---|
| 162 | inputs to a mixer must run at the same sample rate, and correspondingly |
|---|
| 163 | they will be sample rate converted to either a fixed sample rate value |
|---|
| 164 | or they can slave to a master input's sampling rate. It is possible |
|---|
| 165 | for an input to be routed to more than one mixer. For example, the |
|---|
| 166 | application may want different input volume levels applied to one |
|---|
| 167 | output vs. another one. For example, you could use two mixers to |
|---|
| 168 | send a decode input mixed with a playback input to one output setting |
|---|
| 169 | both inputs to half volume. You could simultaneously route the same |
|---|
| 170 | decode input to another output at full volume with no playback |
|---|
| 171 | by using two mixers and applying different volume levels to each. |
|---|
| 172 | Inputs to a mixer are connected using a generic connector type |
|---|
| 173 | (BAPE_Connector), and similarly outputs are connected using |
|---|
| 174 | a generic connector type (BAPE_OutputPort). |
|---|
| 175 | |
|---|
| 176 | Outputs: |
|---|
| 177 | -------- |
|---|
| 178 | Several different output types are supported by this module. They include |
|---|
| 179 | audio DACs (BAPE_DacHandle), SPDIF transmitters (BAPE_SpdifOutputHandle), |
|---|
| 180 | I2S transmitters (BAPE_I2sOutputHandle) and the MAI interface to HDMI |
|---|
| 181 | (BAPE_MaiOutputHandle). Outputs must always be connected to a single |
|---|
| 182 | mixer to receive data, even if they are receiving compressed output. |
|---|
| 183 | Output data can also be captured by the host by connecting an |
|---|
| 184 | BAPE_OutputCaptureHandle. |
|---|
| 185 | |
|---|
| 186 | Inputs: |
|---|
| 187 | ------- |
|---|
| 188 | External audio inputs are supported by this module. BAPE_I2sInput |
|---|
| 189 | represents an I2S receiver. In the future, other inputs may be |
|---|
| 190 | added as well. |
|---|
| 191 | |
|---|
| 192 | Example Connection Diagrams: |
|---|
| 193 | ---------------------------- |
|---|
| 194 | 1) Single decoder routed to DAC + SPDIF |
|---|
| 195 | BAPE_DecoderHandle (stereo data) -> BAPE_MixerHandle -> BAPE_DacHandle + BAPE_SpdifOutputHandle |
|---|
| 196 | |
|---|
| 197 | 2) Decoder + host data mixed to DAC, Decoder data routed directly to SPDIF (PCM) |
|---|
| 198 | BAPE_PlaybackHandle --------------\ |
|---|
| 199 | BAPE_DecoderHandle (stereo data) --> BAPE_MixerHandle1 -> BAPE_DacHandle |
|---|
| 200 | \-> BAPE_MixerHandle2 -> BAPE_SpdifOutputHandle |
|---|
| 201 | |
|---|
| 202 | 3) Decode to DAC with compressed passthrough to SPDIF |
|---|
| 203 | |
|---|
| 204 | BAPE_DecoderHandle1 (stereo data) -> BAPE_MixerHandle1 -> BAPE_DacHandle |
|---|
| 205 | BAPE_DecoderHandle2 (compressed data) -> BAPE_MixerHandle2 -> BAPE_SpdifOutputHandle |
|---|
| 206 | |
|---|
| 207 | 4) Decode to DAC and I2S with DAC delayed to compensate for an external |
|---|
| 208 | audio processor on I2S. |
|---|
| 209 | BAPE_DecoderHandle (stereo data) --> BAPE_MixerHandle1 (delay=0) -> BAPE_DacHandle |
|---|
| 210 | \-> BAPE_MixerHandle2 (delay=n) -> BAPE_I2sOutputHandle |
|---|
| 211 | |
|---|
| 212 | 5) I2S stereo input routed to DAC |
|---|
| 213 | BAPE_I2sInput -> BAPE_InputCapture -> BAPE_MixerHandle -> BAPE_DacHandle |
|---|
| 214 | |
|---|
| 215 | 6) Decode of primary audio mixed with decode of secondary audio (e.g. MP3 sound effect) |
|---|
| 216 | BAPE_DecoderHandle1 (stereo data) --> BAPE_MixerHandle -> BAPE_DacHandle |
|---|
| 217 | BAPE_DecoderHandle2 (stereo data) -/ |
|---|
| 218 | |
|---|
| 219 | ***************************************************************************/ |
|---|
| 220 | |
|---|
| 221 | /*************************************************************************** |
|---|
| 222 | Summary: |
|---|
| 223 | Device Settings |
|---|
| 224 | ***************************************************************************/ |
|---|
| 225 | typedef struct BAPE_Settings |
|---|
| 226 | { |
|---|
| 227 | unsigned maxDspTasks; /* Maximum DSP tasks. One task is required for each decoder and FW Mixer that will run concurrently. */ |
|---|
| 228 | unsigned maxIndependentDelay; /* Max independent delay value in ms */ |
|---|
| 229 | unsigned maxPcmSampleRate; /* Max PCM sample rate in Hz */ |
|---|
| 230 | bool rampPcmSamples; /* If true (default), PCM samples will be ramped up/down on startup, shutdown, and underflow conditions. |
|---|
| 231 | Set to false if you want to disable this feature for testing or verification purposes. */ |
|---|
| 232 | bool highBitRateEnabled; /* If set to true, compressed buffers are large enough to accomodate 4x the decode |
|---|
| 233 | sample rate. This is required for AC3+ Passthrough over HDMI. */ |
|---|
| 234 | unsigned numCompressedBuffers; /* Number of discrete compressed decoder output buffers required. This is the |
|---|
| 235 | number of outputs that will receive discrete compressed content. |
|---|
| 236 | Independent delay does not affect this number, only different content sources. */ |
|---|
| 237 | unsigned numPcmBuffers; /* Number of discrete PCM decoder output buffers required. This is the |
|---|
| 238 | number of outputs that will receive discrete stereo content plus the |
|---|
| 239 | number of outputs that will receive discrete multichannel output * the number |
|---|
| 240 | of channel pairs involved in multichannel (3 for 5.1, 4 for 7.1). |
|---|
| 241 | Independent delay does not affect this number, only different content sources. |
|---|
| 242 | These buffers are also used when non-DSP data sources (e.g. Playback or Equalizer) connect |
|---|
| 243 | as input to DSP mixers. */ |
|---|
| 244 | BAPE_LoudnessEquivalenceMode loudnessMode; /* Loudness Equivalence Mode. Default is BAPE_LoudnessEquivalenceMode_eNone. */ |
|---|
| 245 | } BAPE_Settings; |
|---|
| 246 | |
|---|
| 247 | /*************************************************************************** |
|---|
| 248 | Summary: |
|---|
| 249 | Get default settings for an audio processor |
|---|
| 250 | ***************************************************************************/ |
|---|
| 251 | void BAPE_GetDefaultSettings( |
|---|
| 252 | BAPE_Settings *pSettings /* [out] */ |
|---|
| 253 | ); |
|---|
| 254 | |
|---|
| 255 | /*************************************************************************** |
|---|
| 256 | Summary: |
|---|
| 257 | Open an audio processor |
|---|
| 258 | ***************************************************************************/ |
|---|
| 259 | BERR_Code BAPE_Open( |
|---|
| 260 | BAPE_Handle *pHandle, /* [out] returned handle */ |
|---|
| 261 | BCHP_Handle chpHandle, |
|---|
| 262 | BREG_Handle regHandle, |
|---|
| 263 | BMEM_Handle memHandle, |
|---|
| 264 | BINT_Handle intHandle, |
|---|
| 265 | BTMR_Handle tmrHandle, |
|---|
| 266 | BDSP_Handle dspHandle, |
|---|
| 267 | const BAPE_Settings *pSettings /* NULL will use default settings */ |
|---|
| 268 | ); |
|---|
| 269 | |
|---|
| 270 | /*************************************************************************** |
|---|
| 271 | Summary: |
|---|
| 272 | Close an audio processor |
|---|
| 273 | ***************************************************************************/ |
|---|
| 274 | void BAPE_Close( |
|---|
| 275 | BAPE_Handle handle |
|---|
| 276 | ); |
|---|
| 277 | |
|---|
| 278 | /*************************************************************************** |
|---|
| 279 | Summary: |
|---|
| 280 | Device Level Interrupts |
|---|
| 281 | ***************************************************************************/ |
|---|
| 282 | typedef struct BAPE_InterruptHandlers |
|---|
| 283 | { |
|---|
| 284 | struct |
|---|
| 285 | { |
|---|
| 286 | void (*pCallback_isr)(void *pParam1, int param2); |
|---|
| 287 | void *pParam1; |
|---|
| 288 | int param2; |
|---|
| 289 | } watchdog; |
|---|
| 290 | } BAPE_InterruptHandlers; |
|---|
| 291 | |
|---|
| 292 | /*************************************************************************** |
|---|
| 293 | Summary: |
|---|
| 294 | Get Currently Registered Interrupt Handlers |
|---|
| 295 | ***************************************************************************/ |
|---|
| 296 | void BAPE_GetInterruptHandlers( |
|---|
| 297 | BAPE_Handle handle, |
|---|
| 298 | BAPE_InterruptHandlers *pInterrupts /* [out] */ |
|---|
| 299 | ); |
|---|
| 300 | |
|---|
| 301 | /*************************************************************************** |
|---|
| 302 | Summary: |
|---|
| 303 | Set Interrupt Handlers |
|---|
| 304 | |
|---|
| 305 | Description: |
|---|
| 306 | To disable any unwanted interrupt, pass NULL for its callback routine |
|---|
| 307 | ***************************************************************************/ |
|---|
| 308 | BERR_Code BAPE_SetInterruptHandlers( |
|---|
| 309 | BAPE_Handle handle, |
|---|
| 310 | const BAPE_InterruptHandlers *pInterrupts |
|---|
| 311 | ); |
|---|
| 312 | |
|---|
| 313 | /*************************************************************************** |
|---|
| 314 | Summary: |
|---|
| 315 | Process a watchdog interrupt |
|---|
| 316 | ***************************************************************************/ |
|---|
| 317 | BERR_Code BAPE_ProcessWatchdogInterrupt( |
|---|
| 318 | BAPE_Handle handle |
|---|
| 319 | ); |
|---|
| 320 | |
|---|
| 321 | /*************************************************************************** |
|---|
| 322 | Summary: |
|---|
| 323 | Retrieve the audio path delay value in ms. |
|---|
| 324 | ***************************************************************************/ |
|---|
| 325 | void BAPE_GetDecoderPathDelay( |
|---|
| 326 | BAPE_Handle handle, |
|---|
| 327 | unsigned *pDelay /* [out] in ms */ |
|---|
| 328 | ); |
|---|
| 329 | |
|---|
| 330 | /*************************************************************************** |
|---|
| 331 | Summary: |
|---|
| 332 | Returns single null terminated line from the debug log |
|---|
| 333 | ***************************************************************************/ |
|---|
| 334 | BERR_Code BAPE_GetDebugLog( |
|---|
| 335 | BAPE_Handle handle, |
|---|
| 336 | char *buf, |
|---|
| 337 | size_t buf_len |
|---|
| 338 | ); |
|---|
| 339 | |
|---|
| 340 | /*************************************************************************** |
|---|
| 341 | Summary: |
|---|
| 342 | Standby settings. Currently unused. |
|---|
| 343 | ****************************************************************************/ |
|---|
| 344 | typedef struct BAPE_StandbySettings |
|---|
| 345 | { |
|---|
| 346 | bool dummy; /* placeholder to avoid compiler warning */ |
|---|
| 347 | } BAPE_StandbySettings; |
|---|
| 348 | |
|---|
| 349 | /*************************************************************************** |
|---|
| 350 | Summary: |
|---|
| 351 | Enter Standby mode |
|---|
| 352 | ***************************************************************************/ |
|---|
| 353 | BERR_Code BAPE_Standby( |
|---|
| 354 | BAPE_Handle handle, /* [in]APE device handle */ |
|---|
| 355 | BAPE_StandbySettings *pSettings /* [in] standby settings */ |
|---|
| 356 | ); |
|---|
| 357 | |
|---|
| 358 | /*************************************************************************** |
|---|
| 359 | Summary: |
|---|
| 360 | Resume from standby mode |
|---|
| 361 | ***************************************************************************/ |
|---|
| 362 | BERR_Code BAPE_Resume( |
|---|
| 363 | BAPE_Handle handle /* [in] APE device handle */ |
|---|
| 364 | ); |
|---|
| 365 | |
|---|
| 366 | #endif |
|---|
| 367 | |
|---|