| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2004-2011 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: nexus_audio_equalizer.h $ |
|---|
| 39 | * $brcm_Revision: 3 $ |
|---|
| 40 | * $brcm_Date: 9/15/11 3:25p $ |
|---|
| 41 | * |
|---|
| 42 | * API Description: |
|---|
| 43 | * API name: AudioEqualizer |
|---|
| 44 | * Generic APIs for audio equalizer control. |
|---|
| 45 | * |
|---|
| 46 | * Revision History: |
|---|
| 47 | * |
|---|
| 48 | * $brcm_Log: /nexus/modules/audio/7422/include/nexus_audio_equalizer.h $ |
|---|
| 49 | * |
|---|
| 50 | * 3 9/15/11 3:25p jgarrett |
|---|
| 51 | * SWDTV-8673: Adding shutdown attribute for kernelmode cleanup |
|---|
| 52 | * |
|---|
| 53 | * 2 8/24/11 5:31p jgarrett |
|---|
| 54 | * SW7344-176: Adding null_allowed attribute for kernelmode |
|---|
| 55 | * |
|---|
| 56 | * 1 8/18/11 5:51p jgarrett |
|---|
| 57 | * SWDTV-6306: Merge DTV APE changes to main branch |
|---|
| 58 | * |
|---|
| 59 | * Nexus_APE_Integration/1 7/1/11 5:51p jgarrett |
|---|
| 60 | * SWDTV-6306: Integrated to latest 7422 baseline and nexus audio |
|---|
| 61 | * directory structure |
|---|
| 62 | * |
|---|
| 63 | * 8 11/10/10 7:00p jhaberf |
|---|
| 64 | * SW35230-1934: Extended audio equalizer support for more combination of |
|---|
| 65 | * filters on the same output. |
|---|
| 66 | * |
|---|
| 67 | * 7 5/3/10 5:23p jgarrett |
|---|
| 68 | * SW3548-2910: Adding custom EQ support |
|---|
| 69 | * |
|---|
| 70 | * 6 3/26/10 10:35a jgarrett |
|---|
| 71 | * SW3548-2859: Adding subwoofer EQ support |
|---|
| 72 | * |
|---|
| 73 | * 5 2/8/10 3:46p jgarrett |
|---|
| 74 | * SW3548-2739: Enabling secondary equalizer mode |
|---|
| 75 | * |
|---|
| 76 | * 4 7/13/09 10:44a jgarrett |
|---|
| 77 | * PR 56061: Adding subsonic filter |
|---|
| 78 | * |
|---|
| 79 | * 3 11/12/08 11:27a jgarrett |
|---|
| 80 | * PR 42028: Adding Parametric EQ mode |
|---|
| 81 | * |
|---|
| 82 | * 2 10/6/08 5:15a jgarrett |
|---|
| 83 | * PR 42027: Adding two-band eq mode |
|---|
| 84 | * |
|---|
| 85 | * 1 9/25/08 5:07p jgarrett |
|---|
| 86 | * PR 46055: Revising equalizer API |
|---|
| 87 | * |
|---|
| 88 | ***************************************************************************/ |
|---|
| 89 | #ifndef NEXUS_AUDIO_EQUALIZER_H__ |
|---|
| 90 | #define NEXUS_AUDIO_EQUALIZER_H__ |
|---|
| 91 | |
|---|
| 92 | #include "nexus_types.h" |
|---|
| 93 | #include "nexus_audio_types.h" |
|---|
| 94 | #include "nexus_audio_output.h" |
|---|
| 95 | |
|---|
| 96 | #ifdef __cplusplus |
|---|
| 97 | extern "C" { |
|---|
| 98 | #endif |
|---|
| 99 | |
|---|
| 100 | /*=************************************ |
|---|
| 101 | Interface: AudioOutput |
|---|
| 102 | |
|---|
| 103 | Header file: nexus_audio_equalizer.h |
|---|
| 104 | |
|---|
| 105 | Module: Audio |
|---|
| 106 | |
|---|
| 107 | Description: Interface for audio output equalizer settings |
|---|
| 108 | |
|---|
| 109 | **************************************/ |
|---|
| 110 | |
|---|
| 111 | /*************************************************************************** |
|---|
| 112 | Summary: |
|---|
| 113 | Audio Equalizer Handle |
|---|
| 114 | ***************************************************************************/ |
|---|
| 115 | typedef struct NEXUS_AudioEqualizer *NEXUS_AudioEqualizerHandle; |
|---|
| 116 | |
|---|
| 117 | /*************************************************************************** |
|---|
| 118 | Summary: |
|---|
| 119 | Audio Equalizer Mode |
|---|
| 120 | ***************************************************************************/ |
|---|
| 121 | typedef enum NEXUS_AudioEqualizerMode |
|---|
| 122 | { |
|---|
| 123 | NEXUS_AudioEqualizerMode_eDisabled, /* Equalizer disabled */ |
|---|
| 124 | NEXUS_AudioEqualizerMode_eTone, /* Enables tone control (bass/treble) */ |
|---|
| 125 | NEXUS_AudioEqualizerMode_eFiveBand, /* Enables 5-band equalizer control */ |
|---|
| 126 | NEXUS_AudioEqualizerMode_eParametric, /* Enables 7-band PEQ control */ |
|---|
| 127 | NEXUS_AudioEqualizerMode_eCustom, /* Enables custom equalizer filter coefficients */ |
|---|
| 128 | NEXUS_AudioEqualizerMode_eCascadedParametric,/* Cascaded PEQ to the same output */ |
|---|
| 129 | NEXUS_AudioEqualizerMode_eMax |
|---|
| 130 | } NEXUS_AudioEqualizerMode; |
|---|
| 131 | |
|---|
| 132 | /*************************************************************************** |
|---|
| 133 | Summary: |
|---|
| 134 | Parametric EQ window step - time for phase in/out for filter change |
|---|
| 135 | ***************************************************************************/ |
|---|
| 136 | typedef enum NEXUS_AudioEqualizerWindowStep |
|---|
| 137 | { |
|---|
| 138 | NEXUS_AudioEqualizerWindowStep_eNone, /* No window */ |
|---|
| 139 | NEXUS_AudioEqualizerWindowStep_e170_6, /* 170.6ms at 48kHz */ |
|---|
| 140 | NEXUS_AudioEqualizerWindowStep_e85_3, /* 85.3ms at 48kHz */ |
|---|
| 141 | NEXUS_AudioEqualizerWindowStep_e42_6, /* 42.6ms at 48kHz */ |
|---|
| 142 | NEXUS_AudioEqualizerWindowStep_e21_3, /* 21.3ms at 48kHz */ |
|---|
| 143 | NEXUS_AudioEqualizerWindowStep_e10_6, /* 10.6ms at 48kHz */ |
|---|
| 144 | NEXUS_AudioEqualizerWindowStep_e5_3, /* 5.3ms at 48kHz */ |
|---|
| 145 | NEXUS_AudioEqualizerWindowStep_e2_6, /* 2.6ms at 48kHz */ |
|---|
| 146 | NEXUS_AudioEqualizerWindowStep_eMax |
|---|
| 147 | } NEXUS_AudioEqualizerWindowStep; |
|---|
| 148 | |
|---|
| 149 | /*************************************************************************** |
|---|
| 150 | Summary: |
|---|
| 151 | Bass Management Settings |
|---|
| 152 | ***************************************************************************/ |
|---|
| 153 | typedef struct NEXUS_AudioEqualizerBassManagementSettings |
|---|
| 154 | { |
|---|
| 155 | unsigned cutOffFreqLP; /* Low Pass Cut off Frequency in Hz */ |
|---|
| 156 | unsigned cutOffFreqHP; /* High Pass Cut off Frequency in Hz */ |
|---|
| 157 | unsigned leftInToLeftOut; /* Mixing: Left In Contribution to Left Out (0-0x800000) */ |
|---|
| 158 | unsigned rightInToRightOut; /* Mixing: Right In Contribution to Right Out (0-0x800000) */ |
|---|
| 159 | unsigned subToLeftOut; /* Mixing: LFE Contribution to Left Out (0-0x800000) */ |
|---|
| 160 | unsigned subToRightOut; /* Mixing: LFE Contribution to Right Out (0-0x800000) */ |
|---|
| 161 | } NEXUS_AudioEqualizerBassManagementSettings; |
|---|
| 162 | |
|---|
| 163 | |
|---|
| 164 | #define NEXUS_AUDIO_EQUALIZER_MAX_CUSTOM_COEFFICIENTS (8) |
|---|
| 165 | #define NEXUS_MAX_CASCADED_PARAMETRIC_EQ (3) |
|---|
| 166 | #define NEXUS_AUDIO_EQUALIZER_MAX_ADDITIONAL_MODE (2) |
|---|
| 167 | |
|---|
| 168 | /*************************************************************************** |
|---|
| 169 | Summary: |
|---|
| 170 | Audio Equalizer Settings |
|---|
| 171 | ***************************************************************************/ |
|---|
| 172 | typedef struct NEXUS_AudioEqualizerSettings |
|---|
| 173 | { |
|---|
| 174 | NEXUS_AudioEqualizerMode mode; /* Primary equalizer mode */ |
|---|
| 175 | NEXUS_AudioEqualizerMode secondaryMode; /* Secondary equalizer mode if combining two modes. If not used, set to NEXUS_AudioEqualizerMode_eDisabled. */ |
|---|
| 176 | NEXUS_AudioEqualizerMode additionalModes[NEXUS_AUDIO_EQUALIZER_MAX_ADDITIONAL_MODE]; /* Additional equalizer modes that can be combined. */ |
|---|
| 177 | struct |
|---|
| 178 | { |
|---|
| 179 | struct |
|---|
| 180 | { |
|---|
| 181 | int bass; /* Gain Specified in 1/100 dB. Values range from -10dB (-1000) to +10dB (+1000) */ |
|---|
| 182 | int treble; /* Gain Specified in 1/100 dB. Values range from -10dB (-1000) to +10dB (+1000) */ |
|---|
| 183 | unsigned bassFrequency; /* Bass center frequency in Hz */ |
|---|
| 184 | unsigned bassBandWidthFrequency; /* Bass bandwidth frequency in Hz */ |
|---|
| 185 | unsigned trebleFrequency; /* Treble center frequency in Hz */ |
|---|
| 186 | unsigned trebleBandWidthFrequency; /* Treble bandwidth frequency in Hz */ |
|---|
| 187 | } tone; |
|---|
| 188 | struct |
|---|
| 189 | { |
|---|
| 190 | int gain100Hz; /* Specified in 1/100 dB. Values range from -10dB (-1000) to +10dB (+1000) */ |
|---|
| 191 | int gain300Hz; /* Specified in 1/100 dB. Values range from -10dB (-1000) to +10dB (+1000) */ |
|---|
| 192 | int gain1000Hz; /* Specified in 1/100 dB. Values range from -10dB (-1000) to +10dB (+1000) */ |
|---|
| 193 | int gain3000Hz; /* Specified in 1/100 dB. Values range from -10dB (-1000) to +10dB (+1000) */ |
|---|
| 194 | int gain10000Hz;/* Specified in 1/100 dB. Values range from -10dB (-1000) to +10dB (+1000) */ |
|---|
| 195 | } fiveBand; |
|---|
| 196 | struct |
|---|
| 197 | { |
|---|
| 198 | struct |
|---|
| 199 | { |
|---|
| 200 | unsigned peak; /* Peak frequency in Hz */ |
|---|
| 201 | int gain; /* Specified in 1/100 dB. Values range from -12dB (-1200) to +12dB (+1200) */ |
|---|
| 202 | unsigned q; /* Peak Frequency Q gain specified in 1/100 (e.g. .33 = 33) */ |
|---|
| 203 | } bandSettings[7]; |
|---|
| 204 | |
|---|
| 205 | NEXUS_AudioEqualizerWindowStep windowStep; /* time for phase in/out for filter change */ |
|---|
| 206 | } parametric; |
|---|
| 207 | struct |
|---|
| 208 | { |
|---|
| 209 | /* Please see the description of BRAP_EqualizerCustomSettings in magnum/portinginterface/rap/xxxx/brap.h for |
|---|
| 210 | a description of how to program these values properly. */ |
|---|
| 211 | unsigned numFilters; /* Number of biquad IIR filters to be programmed. Ranges from 0..8. */ |
|---|
| 212 | int32_t coefficient0[NEXUS_AUDIO_EQUALIZER_MAX_CUSTOM_COEFFICIENTS]; |
|---|
| 213 | int32_t coefficient1[NEXUS_AUDIO_EQUALIZER_MAX_CUSTOM_COEFFICIENTS]; |
|---|
| 214 | int32_t coefficient2[NEXUS_AUDIO_EQUALIZER_MAX_CUSTOM_COEFFICIENTS]; |
|---|
| 215 | int32_t coefficient3[NEXUS_AUDIO_EQUALIZER_MAX_CUSTOM_COEFFICIENTS]; |
|---|
| 216 | int32_t coefficient4[NEXUS_AUDIO_EQUALIZER_MAX_CUSTOM_COEFFICIENTS]; |
|---|
| 217 | } custom; |
|---|
| 218 | struct |
|---|
| 219 | { |
|---|
| 220 | /* This is a cascaded mode of Parametric EQ that can be applied to the same output port */ |
|---|
| 221 | bool enabled; |
|---|
| 222 | struct |
|---|
| 223 | { |
|---|
| 224 | unsigned peak; /* Peak frequency in Hz */ |
|---|
| 225 | int gain; /* Specified in 1/100 dB. Values range from -12dB (-1200) to +12dB (+1200) */ |
|---|
| 226 | unsigned q; /* Peak Frequency Q gain specified in 1/100 (e.g. .33 = 33) */ |
|---|
| 227 | } bandSettings[7]; |
|---|
| 228 | |
|---|
| 229 | NEXUS_AudioEqualizerWindowStep windowStep; /* time for phase in/out for filter change */ |
|---|
| 230 | } cascadedParametric[NEXUS_MAX_CASCADED_PARAMETRIC_EQ]; |
|---|
| 231 | } modeSettings; |
|---|
| 232 | |
|---|
| 233 | bool subsonicFilterEnabled; /* If true, the subsonic (high-pass) filter is enabled. */ |
|---|
| 234 | bool subwooferFilterEnabled; /* If true, the subwoofer (low-pass) filter is enabled. */ |
|---|
| 235 | unsigned subsonicFrequency; /* Subsonic filter frequency (in Hz) Ranges from 40..315Hz */ |
|---|
| 236 | unsigned subwooferFrequency; /* Subwoofer filter frequency (in Hz) Ranges from 40..315Hz */ |
|---|
| 237 | |
|---|
| 238 | bool bassManagementEnabled; /* True to enable bass management (define cut off frequencies and mixing parameters) */ |
|---|
| 239 | NEXUS_AudioEqualizerBassManagementSettings bassManagementSettings; |
|---|
| 240 | |
|---|
| 241 | } NEXUS_AudioEqualizerSettings; |
|---|
| 242 | |
|---|
| 243 | /*************************************************************************** |
|---|
| 244 | Summary: |
|---|
| 245 | Get default settings of an audio equalizer |
|---|
| 246 | ***************************************************************************/ |
|---|
| 247 | void NEXUS_AudioEqualizer_GetDefaultSettings( |
|---|
| 248 | NEXUS_AudioEqualizerSettings *pSettings /* [out] Default Settings */ |
|---|
| 249 | ); |
|---|
| 250 | |
|---|
| 251 | /*************************************************************************** |
|---|
| 252 | Summary: |
|---|
| 253 | Open an equalizer |
|---|
| 254 | ***************************************************************************/ |
|---|
| 255 | NEXUS_AudioEqualizerHandle NEXUS_AudioEqualizer_Open( /* attr{destructor=NEXUS_AudioEqualizer_Close} */ |
|---|
| 256 | unsigned index, |
|---|
| 257 | const NEXUS_AudioEqualizerSettings *pSettings /* attr{null_allowed=y} */ |
|---|
| 258 | ); |
|---|
| 259 | |
|---|
| 260 | /*************************************************************************** |
|---|
| 261 | Summary: |
|---|
| 262 | Close an equalizer |
|---|
| 263 | ***************************************************************************/ |
|---|
| 264 | void NEXUS_AudioEqualizer_Close( |
|---|
| 265 | NEXUS_AudioEqualizerHandle equalizer |
|---|
| 266 | ); |
|---|
| 267 | |
|---|
| 268 | /*************************************************************************** |
|---|
| 269 | Summary: |
|---|
| 270 | Get settings of an audio equalizer |
|---|
| 271 | ***************************************************************************/ |
|---|
| 272 | void NEXUS_AudioEqualizer_GetSettings( |
|---|
| 273 | NEXUS_AudioEqualizerHandle equalizer, |
|---|
| 274 | NEXUS_AudioEqualizerSettings *pSettings /* [out] Current Settings */ |
|---|
| 275 | ); |
|---|
| 276 | |
|---|
| 277 | /*************************************************************************** |
|---|
| 278 | Summary: |
|---|
| 279 | Set settings of an audio equalizer |
|---|
| 280 | ***************************************************************************/ |
|---|
| 281 | NEXUS_Error NEXUS_AudioEqualizer_SetSettings( |
|---|
| 282 | NEXUS_AudioEqualizerHandle equalizer, |
|---|
| 283 | const NEXUS_AudioEqualizerSettings *pSettings |
|---|
| 284 | ); |
|---|
| 285 | |
|---|
| 286 | /*************************************************************************** |
|---|
| 287 | Summary: |
|---|
| 288 | Connect an equalizer to an output |
|---|
| 289 | |
|---|
| 290 | Description: |
|---|
| 291 | This can only be called when all inputs to the specified output are |
|---|
| 292 | stopped. |
|---|
| 293 | ***************************************************************************/ |
|---|
| 294 | NEXUS_Error NEXUS_AudioOutput_SetEqualizer( |
|---|
| 295 | NEXUS_AudioOutput output, |
|---|
| 296 | NEXUS_AudioEqualizerHandle equalizer /* Pass NULL to remove any equalizer connected to this output */ |
|---|
| 297 | ); |
|---|
| 298 | |
|---|
| 299 | #ifdef __cplusplus |
|---|
| 300 | } |
|---|
| 301 | #endif |
|---|
| 302 | |
|---|
| 303 | #endif /* #ifndef NEXUS_AUDIO_EQUALIZER_H__ */ |
|---|
| 304 | |
|---|