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