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.                   */
21 /*                                                                                  */
22 /*  This files includes all definitions, types, structures and function             */
23 /*  prototypes required by the execution layer.                                     */
24 /*                                                                                  */
25 /************************************************************************************/
26 
27 #ifndef __LVCS_PRIVATE_H__
28 #define __LVCS_PRIVATE_H__
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33 
34 
35 /************************************************************************************/
36 /*                                                                                  */
37 /*  Includes                                                                        */
38 /*                                                                                  */
39 /************************************************************************************/
40 
41 #include "LVCS.h"                               /* Calling or Application layer definitions */
42 #include "LVCS_StereoEnhancer.h"                /* Stereo enhancer module definitions */
43 #include "LVCS_ReverbGenerator.h"               /* Reverberation module definitions */
44 #include "LVCS_Equaliser.h"                     /* Equaliser module definitions */
45 #include "LVCS_BypassMix.h"                     /* Bypass Mixer module definitions */
46 #include "LVM_Timer.h"
47 
48 
49 /************************************************************************************/
50 /*                                                                                  */
51 /*  Defines                                                                         */
52 /*                                                                                  */
53 /************************************************************************************/
54 
55 /* Configuration switch controls */
56 #define LVCS_STEREOENHANCESWITCH    0x0001      /* Stereo enhancement enable control */
57 #define LVCS_REVERBSWITCH           0x0002      /* Reverberation enable control */
58 #define LVCS_EQUALISERSWITCH        0x0004      /* Equaliser enable control */
59 #define LVCS_BYPASSMIXSWITCH        0x0008      /* Bypass mixer enable control */
60 #define LVCS_COMPGAINFRAME          64          /* Compressor gain update interval */
61 
62 /* Memory */
63 #define LVCS_SCRATCHBUFFERS              6      /* Number of buffers required for inplace processing */
64 
65 /* General */
66 #define LVCS_INVALID                0xFFFF      /* Invalid init parameter */
67 #define LVCS_BYPASS_MIXER_TC        100         /* Bypass mixer time */
68 
69 /* Access to external coefficients table */
70 #define LVCS_NR_OF_FS                    9
71 #define LVCS_NR_OF_CHAN_CFG              2
72 
73 
74 /************************************************************************************/
75 /*                                                                                  */
76 /*  Types                                                                           */
77 /*                                                                                  */
78 /************************************************************************************/
79 
80 typedef LVM_UINT16  LVCS_Configuration_t;       /* Internal algorithm configuration */
81 
82 typedef enum
83 {
84     LVCS_HEADPHONE  = 0,
85     LVCS_DEVICE_MAX = LVM_MAXENUM
86 } LVCS_OutputDevice_en;
87 
88 
89 /************************************************************************************/
90 /*                                                                                  */
91 /*  Structures                                                                      */
92 /*                                                                                  */
93 /************************************************************************************/
94 
95 /* Volume correction structure */
96 typedef struct
97 {
98 #ifdef BUILD_FLOAT
99     LVM_FLOAT   CompFull;                       /* Post CS compression 100% effect */
100     LVM_FLOAT   CompMin;                        /* Post CS compression 0% effect */
101     LVM_FLOAT   GainFull;                       /* CS gain correct 100% effect */
102     LVM_FLOAT   GainMin;                        /* CS gain correct 0% effect */
103 #else
104     LVM_INT16   CompFull;                       /* Post CS compression 100% effect */
105     LVM_INT16   CompMin;                        /* Post CS compression 0% effect */
106     LVM_INT16   GainFull;                       /* CS gain correct 100% effect */
107     LVM_INT16   GainMin;                        /* CS gain correct 0% effect */
108 #endif
109 } LVCS_VolCorrect_t;
110 
111 /* Instance structure */
112 typedef struct
113 {
114     /* Public parameters */
115     LVCS_MemTab_t           MemoryTable;        /* Instance memory allocation table */
116     LVCS_Params_t           Params;             /* Instance parameters */
117     LVCS_Capabilities_t     Capabilities;       /* Initialisation capabilities */
118 
119     /* Private parameters */
120     LVCS_OutputDevice_en    OutputDevice;       /* Selected output device type */
121     LVCS_VolCorrect_t       VolCorrect;         /* Volume correction settings */
122 #ifndef BUILD_FLOAT
123     LVM_INT16               TransitionGain;     /* Transition gain */
124     LVM_INT16               CompressGain;       /* Last used compressor gain*/
125 #else
126     LVM_FLOAT               TransitionGain;     /* Transition gain */
127     LVM_FLOAT               CompressGain;       /* Last used compressor gain*/
128 #endif
129 
130     /* Sub-block configurations */
131     LVCS_StereoEnhancer_t   StereoEnhancer;     /* Stereo enhancer configuration */
132     LVCS_ReverbGenerator_t  Reverberation;      /* Reverberation configuration */
133     LVCS_Equaliser_t        Equaliser;          /* Equaliser configuration */
134     LVCS_BypassMix_t        BypassMix;          /* Bypass mixer configuration */
135 
136     /* Bypass variable */
137     LVM_INT16               MSTarget0;                          /* Mixer state control variable for smooth transtion */
138     LVM_INT16               MSTarget1;                          /* Mixer state control variable for smooth transtion */
139     LVM_INT16               bInOperatingModeTransition;         /* Operating mode transition flag */
140     LVM_INT16               bTimerDone;                         /* Timer completion flag */
141     LVM_Timer_Params_t      TimerParams;                        /* Timer parameters */
142     LVM_Timer_Instance_t    TimerInstance;                      /* Timer instance */
143 
144 } LVCS_Instance_t;
145 
146 /* Coefficient Structure */
147 typedef struct
148 {
149 #ifdef BUILD_FLOAT
150     Biquad_FLOAT_Instance_t       EqualiserBiquadInstance;
151     Biquad_FLOAT_Instance_t       ReverbBiquadInstance;
152     Biquad_FLOAT_Instance_t       SEBiquadInstanceMid;
153     Biquad_FLOAT_Instance_t       SEBiquadInstanceSide;
154 #else
155     Biquad_Instance_t       EqualiserBiquadInstance;
156     Biquad_Instance_t       ReverbBiquadInstance;
157     Biquad_Instance_t       SEBiquadInstanceMid;
158     Biquad_Instance_t       SEBiquadInstanceSide;
159 #endif
160 } LVCS_Coefficient_t;
161 
162 /* Data Structure */
163 typedef struct
164 {
165 #ifdef BUILD_FLOAT
166     Biquad_2I_Order2_FLOAT_Taps_t EqualiserBiquadTaps;
167     Biquad_2I_Order2_FLOAT_Taps_t ReverbBiquadTaps;
168     Biquad_1I_Order1_FLOAT_Taps_t SEBiquadTapsMid;
169     Biquad_1I_Order2_FLOAT_Taps_t SEBiquadTapsSide;
170 #else
171     Biquad_2I_Order2_Taps_t EqualiserBiquadTaps;
172     Biquad_2I_Order2_Taps_t ReverbBiquadTaps;
173     Biquad_1I_Order1_Taps_t SEBiquadTapsMid;
174     Biquad_1I_Order2_Taps_t SEBiquadTapsSide;
175 #endif
176 } LVCS_Data_t;
177 
178 void LVCS_TimerCallBack (   void* hInstance,
179                             void* pCallBackParams,
180                             LVM_INT32 CallbackParam);
181 
182 
183 #ifdef __cplusplus
184 }
185 #endif /* __cplusplus */
186 
187 #endif      /* PRIVATE_H */
188 
189 
190