1 /* 2 * Copyright (C) 2004-2010 NXP Software 3 * Copyright (C) 2010 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /************************************************************************************/ 19 /* */ 20 /* Header file for the private layer interface of concert sound bundle */ 21 /* */ 22 /* This files includes all definitions, types, structures and function */ 23 /* prototypes required by the execution layer. */ 24 /* */ 25 /************************************************************************************/ 26 27 #ifndef __LVM_PRIVATE_H__ 28 #define __LVM_PRIVATE_H__ 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif /* __cplusplus */ 33 34 35 /************************************************************************************/ 36 /* */ 37 /* Includes */ 38 /* */ 39 /************************************************************************************/ 40 41 #include "LVM.h" /* LifeVibes */ 42 #include "LVM_Common.h" /* LifeVibes common */ 43 #include "BIQUAD.h" /* Biquad library */ 44 #include "LVC_Mixer.h" /* Mixer library */ 45 #include "LVCS_Private.h" /* Concert Sound */ 46 #include "LVDBE_Private.h" /* Dynamic Bass Enhancement */ 47 #include "LVEQNB_Private.h" /* N-Band equaliser */ 48 #include "LVPSA_Private.h" /* Parametric Spectrum Analyzer */ 49 50 51 /************************************************************************************/ 52 /* */ 53 /* Defines */ 54 /* */ 55 /************************************************************************************/ 56 57 /* General */ 58 #define LVM_INVALID 0xFFFF /* Invalid init parameter */ 59 60 /* Memory */ 61 #define LVM_INSTANCE_ALIGN 4 /* 32-bit for structures */ 62 #define LVM_FIRSTCALL 0 /* First call to the buffer */ 63 #define LVM_MAXBLOCKCALL 1 /* Maximum block size calls to the buffer */ 64 #define LVM_LASTCALL 2 /* Last call to the buffer */ 65 #define LVM_FIRSTLASTCALL 3 /* Single call for small number of samples */ 66 67 /* Block Size */ 68 #define LVM_MIN_MAXBLOCKSIZE 16 /* Minimum MaxBlockSize Limit*/ 69 #define LVM_MANAGED_MAX_MAXBLOCKSIZE 8191 /* Maximum MaxBlockSzie Limit for Managed Buffer Mode*/ 70 #define LVM_UNMANAGED_MAX_MAXBLOCKSIZE 4096 /* Maximum MaxBlockSzie Limit for Unmanaged Buffer Mode */ 71 72 #define MAX_INTERNAL_BLOCKSIZE 8128 /* Maximum multiple of 64 below 8191*/ 73 74 #define MIN_INTERNAL_BLOCKSIZE 16 /* Minimum internal block size */ 75 #define MIN_INTERNAL_BLOCKSHIFT 4 /* Minimum internal block size as a power of 2 */ 76 #define MIN_INTERNAL_BLOCKMASK 0xFFF0 /* Minimum internal block size mask */ 77 78 #define LVM_PSA_DYNAMICRANGE 60 /* Spectral Dynamic range: used for offseting output*/ 79 #define LVM_PSA_BARHEIGHT 127 /* Spectral Bar Height*/ 80 81 #define LVM_TE_MIN_EFFECTLEVEL 0 /*TE Minimum EffectLevel*/ 82 #define LVM_TE_MAX_EFFECTLEVEL 15 /*TE Maximum Effect level*/ 83 84 #define LVM_VC_MIN_EFFECTLEVEL (-96) /*VC Minimum EffectLevel*/ 85 #define LVM_VC_MAX_EFFECTLEVEL 0 /*VC Maximum Effect level*/ 86 87 #define LVM_BE_MIN_EFFECTLEVEL 0 /*BE Minimum EffectLevel*/ 88 #define LVM_BE_MAX_EFFECTLEVEL 15 /*BE Maximum Effect level*/ 89 90 #define LVM_EQNB_MIN_BAND_FREQ 20 /*EQNB Minimum Band Frequency*/ 91 #define LVM_EQNB_MAX_BAND_FREQ 24000 /*EQNB Maximum Band Frequency*/ 92 #define LVM_EQNB_MIN_BAND_GAIN (-15) /*EQNB Minimum Band Frequency*/ 93 #define LVM_EQNB_MAX_BAND_GAIN 15 /*EQNB Maximum Band Frequency*/ 94 #define LVM_EQNB_MIN_QFACTOR 25 /*EQNB Minimum Q Factor*/ 95 #define LVM_EQNB_MAX_QFACTOR 1200 /*EQNB Maximum Q Factor*/ 96 #define LVM_EQNB_MIN_LPF_FREQ 1000 /*EQNB Minimum Low Pass Corner frequency*/ 97 #define LVM_EQNB_MIN_HPF_FREQ 20 /*EQNB Minimum High Pass Corner frequency*/ 98 #define LVM_EQNB_MAX_HPF_FREQ 1000 /*EQNB Maximum High Pass Corner frequency*/ 99 100 #define LVM_CS_MIN_EFFECT_LEVEL 0 /*CS Minimum Effect Level*/ 101 #define LVM_CS_MAX_REVERB_LEVEL 100 /*CS Maximum Reverb Level*/ 102 #define LVM_VIRTUALIZER_MAX_REVERB_LEVEL 100 /*Vitrualizer Maximum Reverb Level*/ 103 104 #define LVM_VC_MIXER_TIME 100 /*VC mixer time*/ 105 #define LVM_VC_BALANCE_MAX 96 /*VC balance max value*/ 106 #define LVM_VC_BALANCE_MIN (-96) /*VC balance min value*/ 107 108 /* Algorithm masks */ 109 #define LVM_CS_MASK 1 110 #define LVM_EQNB_MASK 2 111 #define LVM_DBE_MASK 4 112 #define LVM_VC_MASK 16 113 #define LVM_TE_MASK 32 114 #define LVM_PSA_MASK 2048 115 116 117 /************************************************************************************/ 118 /* */ 119 /* Structures */ 120 /* */ 121 /************************************************************************************/ 122 123 /* Memory region definition */ 124 typedef struct 125 { 126 LVM_UINT32 Size; /* Region size in bytes */ 127 LVM_UINT16 Alignment; /* Byte alignment */ 128 LVM_MemoryTypes_en Type; /* Region type */ 129 void *pBaseAddress; /* Pointer to the region base address */ 130 } LVM_IntMemoryRegion_t; 131 132 133 /* Memory table containing the region definitions */ 134 typedef struct 135 { 136 LVM_IntMemoryRegion_t Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */ 137 } LVM_IntMemTab_t; 138 139 140 /* Buffer Management */ 141 #ifdef BUILD_FLOAT 142 typedef struct 143 { 144 LVM_FLOAT *pScratch; /* Bundle scratch buffer */ 145 146 LVM_INT16 BufferState; /* Buffer status */ 147 LVM_FLOAT InDelayBuffer[6 * MIN_INTERNAL_BLOCKSIZE]; /* Input buffer delay line, \ 148 left and right */ 149 LVM_INT16 InDelaySamples; /* Number of samples in the input delay buffer */ 150 151 LVM_FLOAT OutDelayBuffer[2 * MIN_INTERNAL_BLOCKSIZE]; /* Output buffer delay \ 152 line */ 153 LVM_INT16 OutDelaySamples; /* Number of samples in the output delay buffer, \ 154 left and right */ 155 LVM_INT16 SamplesToOutput; /* Samples to write to the output */ 156 } LVM_Buffer_t; 157 #else 158 typedef struct 159 { 160 LVM_INT16 *pScratch; /* Bundle scratch buffer */ 161 162 LVM_INT16 BufferState; /* Buffer status */ 163 LVM_INT16 InDelayBuffer[6*MIN_INTERNAL_BLOCKSIZE]; /* Input buffer delay line, left and right */ 164 LVM_INT16 InDelaySamples; /* Number of samples in the input delay buffer */ 165 166 LVM_INT16 OutDelayBuffer[2*MIN_INTERNAL_BLOCKSIZE]; /* Output buffer delay line */ 167 LVM_INT16 OutDelaySamples; /* Number of samples in the output delay buffer, left and right */ 168 LVM_INT16 SamplesToOutput; /* Samples to write to the output */ 169 } LVM_Buffer_t; 170 #endif 171 172 /* Filter taps */ 173 typedef struct 174 { 175 #ifdef BUILD_FLOAT 176 Biquad_2I_Order1_FLOAT_Taps_t TrebleBoost_Taps; /* Treble boost Taps */ 177 #else 178 Biquad_2I_Order1_Taps_t TrebleBoost_Taps; /* Treble boost Taps */ 179 #endif 180 } LVM_TE_Data_t; 181 182 /* Coefficients */ 183 typedef struct 184 { 185 #ifdef BUILD_FLOAT 186 Biquad_FLOAT_Instance_t TrebleBoost_State; /* State for the treble boost filter */ 187 #else 188 Biquad_Instance_t TrebleBoost_State; /* State for the treble boost filter */ 189 #endif 190 } LVM_TE_Coefs_t; 191 192 typedef struct 193 { 194 /* Public parameters */ 195 LVM_MemTab_t MemoryTable; /* Instance memory allocation table */ 196 LVM_ControlParams_t Params; /* Control parameters */ 197 LVM_InstParams_t InstParams; /* Instance parameters */ 198 199 /* Private parameters */ 200 LVM_UINT16 ControlPending; /* Control flag to indicate update pending */ 201 LVM_ControlParams_t NewParams; /* New control parameters pending update */ 202 203 /* Buffer control */ 204 LVM_INT16 InternalBlockSize; /* Maximum internal block size */ 205 LVM_Buffer_t *pBufferManagement; /* Buffer management variables */ 206 LVM_INT16 SamplesToProcess; /* Input samples left to process */ 207 #ifdef BUILD_FLOAT 208 LVM_FLOAT *pInputSamples; /* External input sample pointer */ 209 LVM_FLOAT *pOutputSamples; /* External output sample pointer */ 210 #else 211 LVM_INT16 *pInputSamples; /* External input sample pointer */ 212 LVM_INT16 *pOutputSamples; /* External output sample pointer */ 213 #endif 214 215 /* Configuration number */ 216 LVM_INT32 ConfigurationNumber; 217 LVM_INT32 BlickSizeMultiple; 218 219 /* DC removal */ 220 #ifdef BUILD_FLOAT 221 Biquad_FLOAT_Instance_t DC_RemovalInstance; /* DC removal filter instance */ 222 #else 223 Biquad_Instance_t DC_RemovalInstance; /* DC removal filter instance */ 224 #endif 225 226 /* Concert Sound */ 227 LVCS_Handle_t hCSInstance; /* Concert Sound instance handle */ 228 LVCS_Instance_t CS_Instance; /* Concert Sound instance */ 229 LVM_INT16 CS_Active; /* Control flag */ 230 231 /* Equalizer */ 232 LVEQNB_Handle_t hEQNBInstance; /* N-Band Equaliser instance handle */ 233 LVEQNB_Instance_t EQNB_Instance; /* N-Band Equaliser instance */ 234 LVM_EQNB_BandDef_t *pEQNB_BandDefs; /* Local storage for new definitions */ 235 LVM_EQNB_BandDef_t *pEQNB_UserDefs; /* Local storage for the user's definitions */ 236 LVM_INT16 EQNB_Active; /* Control flag */ 237 238 /* Dynamic Bass Enhancement */ 239 LVDBE_Handle_t hDBEInstance; /* Dynamic Bass Enhancement instance handle */ 240 LVDBE_Instance_t DBE_Instance; /* Dynamic Bass Enhancement instance */ 241 LVM_INT16 DBE_Active; /* Control flag */ 242 243 /* Volume Control */ 244 #ifdef BUILD_FLOAT 245 LVMixer3_1St_FLOAT_st VC_Volume; /* Volume scaler */ 246 #else 247 LVMixer3_1St_st VC_Volume; /* Volume scaler */ 248 #endif 249 #ifdef BUILD_FLOAT 250 LVMixer3_2St_FLOAT_st VC_BalanceMix; /* VC balance mixer */ 251 #else 252 LVMixer3_2St_st VC_BalanceMix; /* VC balance mixer */ 253 #endif 254 LVM_INT16 VC_VolumedB; /* Gain in dB */ 255 LVM_INT16 VC_Active; /* Control flag */ 256 LVM_INT16 VC_AVLFixedVolume; /* AVL fixed volume */ 257 258 /* Treble Enhancement */ 259 LVM_TE_Data_t *pTE_Taps; /* Treble boost Taps */ 260 LVM_TE_Coefs_t *pTE_State; /* State for the treble boost filter */ 261 LVM_INT16 TE_Active; /* Control flag */ 262 263 /* Headroom */ 264 LVM_HeadroomParams_t NewHeadroomParams; /* New headroom parameters pending update */ 265 LVM_HeadroomParams_t HeadroomParams; /* Headroom parameters */ 266 LVM_HeadroomBandDef_t *pHeadroom_BandDefs; /* Local storage for new definitions */ 267 LVM_HeadroomBandDef_t *pHeadroom_UserDefs; /* Local storage for the user's definitions */ 268 LVM_UINT16 Headroom; /* Value of the current headroom */ 269 270 /* Spectrum Analyzer */ 271 pLVPSA_Handle_t hPSAInstance; /* Spectrum Analyzer instance handle */ 272 LVPSA_InstancePr_t PSA_Instance; /* Spectrum Analyzer instance */ 273 LVPSA_InitParams_t PSA_InitParams; /* Spectrum Analyzer initialization parameters */ 274 LVPSA_ControlParams_t PSA_ControlParams; /* Spectrum Analyzer control parameters */ 275 LVM_INT16 PSA_GainOffset; /* Tone control flag */ 276 LVM_Callback CallBack; 277 #ifdef BUILD_FLOAT 278 LVM_FLOAT *pPSAInput; /* PSA input pointer */ 279 #else 280 LVM_INT16 *pPSAInput; /* PSA input pointer */ 281 #endif 282 283 LVM_INT16 NoSmoothVolume; /* Enable or disable smooth volume changes*/ 284 285 } LVM_Instance_t; 286 287 288 /************************************************************************************/ 289 /* */ 290 /* Function Prototypes */ 291 /* */ 292 /************************************************************************************/ 293 294 LVM_ReturnStatus_en LVM_ApplyNewSettings(LVM_Handle_t hInstance); 295 296 void LVM_SetTrebleBoost( LVM_Instance_t *pInstance, 297 LVM_ControlParams_t *pParams); 298 299 void LVM_SetVolume( LVM_Instance_t *pInstance, 300 LVM_ControlParams_t *pParams); 301 302 LVM_INT32 LVM_VCCallBack(void* pBundleHandle, 303 void* pGeneralPurpose, 304 short CallBackParam); 305 306 void LVM_SetHeadroom( LVM_Instance_t *pInstance, 307 LVM_ControlParams_t *pParams); 308 #ifdef BUILD_FLOAT 309 void LVM_BufferIn( LVM_Handle_t hInstance, 310 const LVM_FLOAT *pInData, 311 LVM_FLOAT **pToProcess, 312 LVM_FLOAT **pProcessed, 313 LVM_UINT16 *pNumSamples); 314 #else 315 void LVM_BufferIn( LVM_Handle_t hInstance, 316 const LVM_INT16 *pInData, 317 LVM_INT16 **pToProcess, 318 LVM_INT16 **pProcessed, 319 LVM_UINT16 *pNumSamples); 320 #endif 321 #ifdef BUILD_FLOAT 322 void LVM_BufferOut( LVM_Handle_t hInstance, 323 LVM_FLOAT *pOutData, 324 LVM_UINT16 *pNumSamples); 325 #else 326 void LVM_BufferOut( LVM_Handle_t hInstance, 327 LVM_INT16 *pOutData, 328 LVM_UINT16 *pNumSamples); 329 #endif 330 331 LVM_INT32 LVM_AlgoCallBack( void *pBundleHandle, 332 void *pData, 333 LVM_INT16 callbackId); 334 335 #ifdef __cplusplus 336 } 337 #endif /* __cplusplus */ 338 339 #endif /* __LVM_PRIVATE_H__ */ 340 341