• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 application layer interface of Concert Sound and Concert        */
21 /*  Sound EX.                                                                           */
22 /*                                                                                      */
23 /*  This files includes all definitions, types, structures and function                 */
24 /*  prototypes required by the calling layer. All other types, structures and           */
25 /*  functions are private.                                                              */
26 /*                                                                                      */
27 /****************************************************************************************/
28 /*                                                                                      */
29 /*  Note: 1                                                                             */
30 /*  =======                                                                             */
31 /*  The algorithm can execute either with separate input and output buffers or with     */
32 /*  a common buffer, i.e. the data is processed in-place. If the buffers are the        */
33 /*  same then the MIPs will be slightly higher and an extra stereo scratch buffer is    */
34 /*  required.                                                                           */
35 /*                                                                                      */
36 /****************************************************************************************/
37 /*                                                                                      */
38 /*  Note: 2                                                                             */
39 /*  =======                                                                             */
40 /*  Two data formats are support Stereo and Mono-In-Stereo. The data is interleaved as  */
41 /*  follows:                                                                            */
42 /*              Byte Offset         Stereo Input         Mono-In-Stereo Input           */
43 /*              ===========         ============         ====================           */
44 /*                  0               Left Sample #1          Mono Sample #1              */
45 /*                  2               Right Sample #1         Mono Sample #1              */
46 /*                  4               Left Sample #2          Mono Sample #2              */
47 /*                  6               Right Sample #2         Mono Sample #2              */
48 /*                  .                      .                     .                      */
49 /*                  .                      .                     .                      */
50 /*                                                                                      */
51 /*  Mono format data is not supported, the calling routine must convert a Mono stream   */
52 /*  in to Mono-In-Stereo format.                                                        */
53 /*                                                                                      */
54 /****************************************************************************************/
55 
56 #ifndef LVCS_H
57 #define LVCS_H
58 
59 /****************************************************************************************/
60 /*                                                                                      */
61 /*  Includes                                                                            */
62 /*                                                                                      */
63 /****************************************************************************************/
64 
65 #include "LVM_Types.h"
66 #include "LVM_Common.h"
67 
68 /****************************************************************************************/
69 /*                                                                                      */
70 /*  Definitions                                                                         */
71 /*                                                                                      */
72 /****************************************************************************************/
73 
74 /* Effect Level */
75 #define LVCS_EFFECT_LOW 16384    /* Effect scaling 50% */
76 #define LVCS_EFFECT_MEDIUM 24576 /* Effect scaling 75% */
77 #define LVCS_EFFECT_HIGH 32767   /* Effect Scaling 100% */
78 
79 /* Callback events */
80 #define LVCS_EVENT_NONE 0x0000   /* Not a valid event */
81 #define LVCS_EVENT_ALGOFF 0x0001 /* CS has completed switch off */
82 
83 /****************************************************************************************/
84 /*                                                                                      */
85 /*  Types                                                                               */
86 /*                                                                                      */
87 /****************************************************************************************/
88 
89 /* Instance handle */
90 typedef void* LVCS_Handle_t;
91 
92 /* Operating modes */
93 typedef enum { LVCS_OFF = 0, LVCS_ON = 15, LVCS_MAX = LVM_MAXENUM } LVCS_Modes_en;
94 
95 /* Function return status */
96 typedef enum {
97     LVCS_SUCCESS = 0,        /* Successful return from a routine */
98     LVCS_NULLADDRESS = 1,    /* NULL allocation address */
99     LVCS_TOOMANYSAMPLES = 2, /* Maximum block size exceeded */
100     LVCS_STATUSMAX = LVM_MAXENUM
101 } LVCS_ReturnStatus_en;
102 
103 /*
104  * Source data formats
105  */
106 typedef enum {
107     LVCS_STEREO = 0,
108     LVCS_MONOINSTEREO = 1,
109     LVCS_SOURCEMAX = LVM_MAXENUM
110 } LVCS_SourceFormat_en;
111 
112 /*
113  * Supported output devices
114  */
115 typedef enum {
116     LVCS_HEADPHONES = 0,
117     LVCS_EX_HEADPHONES = 1,
118     LVCS_SPEAKERTYPE_MAX = LVM_MAXENUM
119 } LVCS_SpeakerType_en;
120 
121 /*
122  * Speaker Coefficients Table
123  */
124 typedef struct {
125     void* pTable1;
126     void* pTable2;
127     void* pTable3;
128     void* pTable4;
129     void* pTable5;
130     void* pTable6;
131     void* pTable7;
132     void* pTable8;
133 } LVCS_CSMS_Coef_Tables_t;
134 
135 /****************************************************************************************/
136 /*                                                                                      */
137 /*  Structures                                                                          */
138 /*                                                                                      */
139 /****************************************************************************************/
140 
141 /* Concert Sound parameter structure */
142 typedef struct {
143     LVCS_Modes_en OperatingMode;       /* Algorithm mode */
144     LVCS_SpeakerType_en SpeakerType;   /* Output device type */
145     LVCS_SourceFormat_en SourceFormat; /* Source data format */
146     LVM_Mode_en CompressorMode;        /* Non-Linear Compressor Mode */
147     LVM_Fs_en SampleRate;              /* Sampling rate */
148     LVM_INT16 EffectLevel;             /* Effect level */
149     LVM_UINT16 ReverbLevel;            /* Reverb level in % */
150     LVM_INT32 NrChannels;
151 } LVCS_Params_t;
152 
153 /* Concert Sound Capability structure */
154 typedef struct {
155     /* General parameters */
156     LVM_UINT16 MaxBlockSize; /* Maximum block size in sample pairs */
157 
158     /* Callback parameters */
159     LVM_Callback CallBack; /* Bundle callback */
160     void* pBundleInstance; /* Bundle instance handle */
161 
162 } LVCS_Capabilities_t;
163 
164 /****************************************************************************************/
165 /*                                                                                      */
166 /*  Function Prototypes                                                                 */
167 /*                                                                                      */
168 /****************************************************************************************/
169 
170 /************************************************************************************/
171 /*                                                                                  */
172 /* FUNCTION:                LVCS_Init                                               */
173 /*                                                                                  */
174 /* DESCRIPTION:                                                                     */
175 /*  Create and initialisation function for the Concert Sound module                 */
176 /*                                                                                  */
177 /* PARAMETERS:                                                                      */
178 /*  phInstance              Pointer to instance handle                              */
179 /*  pCapabilities           Pointer to the capabilities structure                   */
180 /*  pScratch                Pointer to the scratch buffer                           */
181 /*                                                                                  */
182 /* RETURNS:                                                                         */
183 /*  LVCS_Success            Initialisation succeeded                                */
184 /*  LVDBE_NULLADDRESS       One or more memory has a NULL pointer                   */
185 /*                                                                                  */
186 /* NOTES:                                                                           */
187 /*  1.  This function must not be interrupted by the LVCS_Process function          */
188 /*                                                                                  */
189 /************************************************************************************/
190 LVCS_ReturnStatus_en LVCS_Init(LVCS_Handle_t* phInstance, LVCS_Capabilities_t* pCapabilities,
191                                void* pScratch);
192 
193 /************************************************************************************/
194 /*                                                                                  */
195 /* FUNCTION:                LVCS_DeInit                                             */
196 /*                                                                                  */
197 /* DESCRIPTION:                                                                     */
198 /*  Free memories created during the LVCS_Init call including instance handle       */
199 /*                                                                                  */
200 /* PARAMETERS:                                                                      */
201 /*  phInstance              Pointer to instance handle                              */
202 /*                                                                                  */
203 /* NOTES:                                                                           */
204 /*  1.  This function must not be interrupted by the LVCS_Process function          */
205 /*                                                                                  */
206 /************************************************************************************/
207 void LVCS_DeInit(LVCS_Handle_t* phInstance);
208 
209 /****************************************************************************************/
210 /*                                                                                      */
211 /* FUNCTION:                 LVCS_GetParameters                                         */
212 /*                                                                                      */
213 /* DESCRIPTION:                                                                         */
214 /*  Request the Concert Sound parameters. The current parameter set is returned         */
215 /*  via the parameter pointer.                                                          */
216 /*                                                                                      */
217 /* PARAMETERS:                                                                          */
218 /*  hInstance                Instance handle                                            */
219 /*  pParams                  Pointer to an empty parameter structure                    */
220 /*                                                                                      */
221 /* RETURNS:                                                                             */
222 /*  LVCS_Success             Always succeeds                                            */
223 /*                                                                                      */
224 /* NOTES:                                                                               */
225 /*  1.  This function may be interrupted by the LVCS_Process function                   */
226 /*                                                                                      */
227 /****************************************************************************************/
228 
229 LVCS_ReturnStatus_en LVCS_GetParameters(LVCS_Handle_t hInstance, LVCS_Params_t* pParams);
230 
231 /****************************************************************************************/
232 /*                                                                                      */
233 /* FUNCTION:                LVCS_Control                                                */
234 /*                                                                                      */
235 /* DESCRIPTION:                                                                         */
236 /*  Sets or changes the Concert Sound parameters.                                       */
237 /*                                                                                      */
238 /* PARAMETERS:                                                                          */
239 /*  hInstance               Instance handle                                             */
240 /*  pParams                 Pointer to a parameter structure                            */
241 /*                                                                                      */
242 /* RETURNS:                                                                             */
243 /*  LVCS_Success            Succeeded                                                   */
244 /*                                                                                      */
245 /* NOTES:                                                                               */
246 /*  1.  This function must not be interrupted by the LVCS_Process function              */
247 /*                                                                                      */
248 /****************************************************************************************/
249 
250 LVCS_ReturnStatus_en LVCS_Control(LVCS_Handle_t hInstance, LVCS_Params_t* pParams);
251 
252 /****************************************************************************************/
253 /*                                                                                      */
254 /* FUNCTION:                LVCS_Process                                                */
255 /*                                                                                      */
256 /* DESCRIPTION:                                                                         */
257 /*  Process function for the Concert Sound module. The implementation supports two      */
258 /*  variants of the algorithm, one for headphones and one for mobile speakers.          */
259 /*                                                                                      */
260 /* PARAMETERS:                                                                          */
261 /*  hInstance               Instance handle                                             */
262 /*  pInData                 Pointer to the input data                                   */
263 /*  pOutData                Pointer to the output data                                  */
264 /*  NumSamples              Number of samples in the input buffer                       */
265 /*                                                                                      */
266 /* RETURNS:                                                                             */
267 /*  LVCS_Success            Succeeded                                                   */
268 /*  LVCS_TooManySamples     NumSamples was larger than the maximum block size           */
269 /*                                                                                      */
270 /* NOTES:                                                                               */
271 /*                                                                                      */
272 /****************************************************************************************/
273 LVCS_ReturnStatus_en LVCS_Process(LVCS_Handle_t hInstance, const LVM_FLOAT* pInData,
274                                   LVM_FLOAT* pOutData, LVM_UINT16 NumSamples);
275 
276 #endif /* LVCS_H */
277