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 /************************************************************************************/ 31 /* */ 32 /* Includes */ 33 /* */ 34 /************************************************************************************/ 35 36 #include "LVM.h" /* LifeVibes */ 37 #include "LVM_Common.h" /* LifeVibes common */ 38 #include "BIQUAD.h" /* Biquad library */ 39 #include "LVC_Mixer.h" /* Mixer library */ 40 #include "LVCS_Private.h" /* Concert Sound */ 41 #include "LVDBE_Private.h" /* Dynamic Bass Enhancement */ 42 #include "LVEQNB_Private.h" /* N-Band equaliser */ 43 #include "LVPSA_Private.h" /* Parametric Spectrum Analyzer */ 44 45 /************************************************************************************/ 46 /* */ 47 /* Defines */ 48 /* */ 49 /************************************************************************************/ 50 51 /* General */ 52 #define LVM_INVALID 0xFFFF /* Invalid init parameter */ 53 54 /* Memory */ 55 #define LVM_INSTANCE_ALIGN 4 /* 32-bit for structures */ 56 #define LVM_FIRSTCALL 0 /* First call to the buffer */ 57 #define LVM_MAXBLOCKCALL 1 /* Maximum block size calls to the buffer */ 58 #define LVM_LASTCALL 2 /* Last call to the buffer */ 59 #define LVM_FIRSTLASTCALL 3 /* Single call for small number of samples */ 60 61 /* Block Size */ 62 #define LVM_MIN_MAXBLOCKSIZE 16 /* Minimum MaxBlockSize Limit*/ 63 #define LVM_MANAGED_MAX_MAXBLOCKSIZE 8191 /* Maximum MaxBlockSzie Limit for Managed Buffer Mode*/ 64 #define LVM_UNMANAGED_MAX_MAXBLOCKSIZE 4096 /* Maximum MaxBlockSzie Limit for Unmanaged Buffer Mode */ 65 66 #define MAX_INTERNAL_BLOCKSIZE 8128 /* Maximum multiple of 64 below 8191*/ 67 68 #define MIN_INTERNAL_BLOCKSIZE 16 /* Minimum internal block size */ 69 #define MIN_INTERNAL_BLOCKSHIFT 4 /* Minimum internal block size as a power of 2 */ 70 #define MIN_INTERNAL_BLOCKMASK 0xFFF0 /* Minimum internal block size mask */ 71 72 #define LVM_PSA_DYNAMICRANGE 60 /* Spectral Dynamic range: used for offseting output*/ 73 #define LVM_PSA_BARHEIGHT 127 /* Spectral Bar Height*/ 74 75 #define LVM_TE_MIN_EFFECTLEVEL 0 /*TE Minimum EffectLevel*/ 76 #define LVM_TE_MAX_EFFECTLEVEL 15 /*TE Maximum Effect level*/ 77 78 #define LVM_VC_MIN_EFFECTLEVEL (-96) /*VC Minimum EffectLevel*/ 79 #define LVM_VC_MAX_EFFECTLEVEL 0 /*VC Maximum Effect level*/ 80 81 #define LVM_BE_MIN_EFFECTLEVEL 0 /*BE Minimum EffectLevel*/ 82 #define LVM_BE_MAX_EFFECTLEVEL 15 /*BE Maximum Effect level*/ 83 84 #define LVM_EQNB_MIN_BAND_FREQ 20 /*EQNB Minimum Band Frequency*/ 85 #define LVM_EQNB_MAX_BAND_FREQ 24000 /*EQNB Maximum Band Frequency*/ 86 #define LVM_EQNB_MIN_BAND_GAIN (-15) /*EQNB Minimum Band Frequency*/ 87 #define LVM_EQNB_MAX_BAND_GAIN 15 /*EQNB Maximum Band Frequency*/ 88 #define LVM_EQNB_MIN_QFACTOR 25 /*EQNB Minimum Q Factor*/ 89 #define LVM_EQNB_MAX_QFACTOR 1200 /*EQNB Maximum Q Factor*/ 90 #define LVM_EQNB_MIN_LPF_FREQ 1000 /*EQNB Minimum Low Pass Corner frequency*/ 91 #define LVM_EQNB_MIN_HPF_FREQ 20 /*EQNB Minimum High Pass Corner frequency*/ 92 #define LVM_EQNB_MAX_HPF_FREQ 1000 /*EQNB Maximum High Pass Corner frequency*/ 93 94 #define LVM_CS_MIN_EFFECT_LEVEL 0 /*CS Minimum Effect Level*/ 95 #define LVM_CS_MAX_REVERB_LEVEL 100 /*CS Maximum Reverb Level*/ 96 #define LVM_VIRTUALIZER_MAX_REVERB_LEVEL 100 /*Vitrualizer Maximum Reverb Level*/ 97 98 #define LVM_VC_MIXER_TIME 100 /*VC mixer time*/ 99 #define LVM_VC_BALANCE_MAX 96 /*VC balance max value*/ 100 #define LVM_VC_BALANCE_MIN (-96) /*VC balance min value*/ 101 102 /* Algorithm masks */ 103 #define LVM_CS_MASK 1 104 #define LVM_EQNB_MASK 2 105 #define LVM_DBE_MASK 4 106 #define LVM_VC_MASK 16 107 #define LVM_TE_MASK 32 108 #define LVM_PSA_MASK 2048 109 110 /************************************************************************************/ 111 /* */ 112 /* Structures */ 113 /* */ 114 /************************************************************************************/ 115 116 /* Memory region definition */ 117 typedef struct 118 { 119 LVM_UINT32 Size; /* Region size in bytes */ 120 LVM_UINT16 Alignment; /* Byte alignment */ 121 LVM_MemoryTypes_en Type; /* Region type */ 122 void *pBaseAddress; /* Pointer to the region base address */ 123 } LVM_IntMemoryRegion_t; 124 125 /* Memory table containing the region definitions */ 126 typedef struct 127 { 128 LVM_IntMemoryRegion_t Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */ 129 } LVM_IntMemTab_t; 130 131 /* Buffer Management */ 132 typedef struct 133 { 134 LVM_FLOAT *pScratch; /* Bundle scratch buffer */ 135 136 LVM_INT16 BufferState; /* Buffer status */ 137 #ifdef SUPPORT_MC 138 LVM_FLOAT InDelayBuffer[3 * LVM_MAX_CHANNELS * MIN_INTERNAL_BLOCKSIZE]; 139 #else 140 LVM_FLOAT InDelayBuffer[6 * MIN_INTERNAL_BLOCKSIZE]; /* Input buffer delay line, \ 141 left and right */ 142 #endif 143 LVM_INT16 InDelaySamples; /* Number of samples in the input delay buffer */ 144 #ifdef SUPPORT_MC 145 LVM_FLOAT OutDelayBuffer[LVM_MAX_CHANNELS * MIN_INTERNAL_BLOCKSIZE]; 146 #else 147 LVM_FLOAT OutDelayBuffer[2 * MIN_INTERNAL_BLOCKSIZE]; /* Output buffer delay \ 148 line */ 149 #endif 150 LVM_INT16 OutDelaySamples; /* Number of samples in the output delay buffer, \ 151 left and right */ 152 LVM_INT16 SamplesToOutput; /* Samples to write to the output */ 153 } LVM_Buffer_t; 154 155 /* Filter taps */ 156 typedef struct 157 { 158 Biquad_2I_Order1_FLOAT_Taps_t TrebleBoost_Taps; /* Treble boost Taps */ 159 } LVM_TE_Data_t; 160 161 /* Coefficients */ 162 typedef struct 163 { 164 Biquad_FLOAT_Instance_t TrebleBoost_State; /* State for the treble boost filter */ 165 } LVM_TE_Coefs_t; 166 167 typedef struct 168 { 169 /* Public parameters */ 170 LVM_MemTab_t MemoryTable; /* Instance memory allocation table */ 171 LVM_ControlParams_t Params; /* Control parameters */ 172 LVM_InstParams_t InstParams; /* Instance parameters */ 173 174 /* Private parameters */ 175 LVM_UINT16 ControlPending; /* Control flag to indicate update pending */ 176 LVM_ControlParams_t NewParams; /* New control parameters pending update */ 177 178 /* Buffer control */ 179 LVM_INT16 InternalBlockSize; /* Maximum internal block size */ 180 LVM_Buffer_t *pBufferManagement; /* Buffer management variables */ 181 LVM_INT16 SamplesToProcess; /* Input samples left to process */ 182 LVM_FLOAT *pInputSamples; /* External input sample pointer */ 183 LVM_FLOAT *pOutputSamples; /* External output sample pointer */ 184 185 /* Configuration number */ 186 LVM_INT32 ConfigurationNumber; 187 LVM_INT32 BlickSizeMultiple; 188 189 /* DC removal */ 190 Biquad_FLOAT_Instance_t DC_RemovalInstance; /* DC removal filter instance */ 191 192 /* Concert Sound */ 193 LVCS_Handle_t hCSInstance; /* Concert Sound instance handle */ 194 LVCS_Instance_t CS_Instance; /* Concert Sound instance */ 195 LVM_INT16 CS_Active; /* Control flag */ 196 197 /* Equalizer */ 198 LVEQNB_Handle_t hEQNBInstance; /* N-Band Equaliser instance handle */ 199 LVEQNB_Instance_t EQNB_Instance; /* N-Band Equaliser instance */ 200 LVM_EQNB_BandDef_t *pEQNB_BandDefs; /* Local storage for new definitions */ 201 LVM_EQNB_BandDef_t *pEQNB_UserDefs; /* Local storage for the user's definitions */ 202 LVM_INT16 EQNB_Active; /* Control flag */ 203 204 /* Dynamic Bass Enhancement */ 205 LVDBE_Handle_t hDBEInstance; /* Dynamic Bass Enhancement instance handle */ 206 LVDBE_Instance_t DBE_Instance; /* Dynamic Bass Enhancement instance */ 207 LVM_INT16 DBE_Active; /* Control flag */ 208 209 /* Volume Control */ 210 LVMixer3_1St_FLOAT_st VC_Volume; /* Volume scaler */ 211 LVMixer3_2St_FLOAT_st VC_BalanceMix; /* VC balance mixer */ 212 LVM_INT16 VC_VolumedB; /* Gain in dB */ 213 LVM_INT16 VC_Active; /* Control flag */ 214 LVM_INT16 VC_AVLFixedVolume; /* AVL fixed volume */ 215 216 /* Treble Enhancement */ 217 LVM_TE_Data_t *pTE_Taps; /* Treble boost Taps */ 218 LVM_TE_Coefs_t *pTE_State; /* State for the treble boost filter */ 219 LVM_INT16 TE_Active; /* Control flag */ 220 221 /* Headroom */ 222 LVM_HeadroomParams_t NewHeadroomParams; /* New headroom parameters pending update */ 223 LVM_HeadroomParams_t HeadroomParams; /* Headroom parameters */ 224 LVM_HeadroomBandDef_t *pHeadroom_BandDefs; /* Local storage for new definitions */ 225 LVM_HeadroomBandDef_t *pHeadroom_UserDefs; /* Local storage for the user's definitions */ 226 LVM_UINT16 Headroom; /* Value of the current headroom */ 227 228 /* Spectrum Analyzer */ 229 pLVPSA_Handle_t hPSAInstance; /* Spectrum Analyzer instance handle */ 230 LVPSA_InstancePr_t PSA_Instance; /* Spectrum Analyzer instance */ 231 LVPSA_InitParams_t PSA_InitParams; /* Spectrum Analyzer initialization parameters */ 232 LVPSA_ControlParams_t PSA_ControlParams; /* Spectrum Analyzer control parameters */ 233 LVM_INT16 PSA_GainOffset; /* Tone control flag */ 234 LVM_Callback CallBack; 235 LVM_FLOAT *pPSAInput; /* PSA input pointer */ 236 237 LVM_INT16 NoSmoothVolume; /* Enable or disable smooth volume changes*/ 238 239 #ifdef SUPPORT_MC 240 LVM_INT16 NrChannels; 241 LVM_INT32 ChMask; 242 #endif 243 244 } LVM_Instance_t; 245 246 /************************************************************************************/ 247 /* */ 248 /* Function Prototypes */ 249 /* */ 250 /************************************************************************************/ 251 252 LVM_ReturnStatus_en LVM_ApplyNewSettings(LVM_Handle_t hInstance); 253 254 void LVM_SetTrebleBoost( LVM_Instance_t *pInstance, 255 LVM_ControlParams_t *pParams); 256 257 void LVM_SetVolume( LVM_Instance_t *pInstance, 258 LVM_ControlParams_t *pParams); 259 260 LVM_INT32 LVM_VCCallBack(void* pBundleHandle, 261 void* pGeneralPurpose, 262 short CallBackParam); 263 264 void LVM_SetHeadroom( LVM_Instance_t *pInstance, 265 LVM_ControlParams_t *pParams); 266 void LVM_BufferIn( LVM_Handle_t hInstance, 267 const LVM_FLOAT *pInData, 268 LVM_FLOAT **pToProcess, 269 LVM_FLOAT **pProcessed, 270 LVM_UINT16 *pNumSamples); 271 void LVM_BufferOut( LVM_Handle_t hInstance, 272 LVM_FLOAT *pOutData, 273 LVM_UINT16 *pNumSamples); 274 275 LVM_INT32 LVM_AlgoCallBack( void *pBundleHandle, 276 void *pData, 277 LVM_INT16 callbackId); 278 279 #endif /* __LVM_PRIVATE_H__ */ 280 281