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/*    Includes                                                                      */
21/*                                                                                  */
22/************************************************************************************/
23
24#include "LVM_Tables.h"
25#include "LVM_Coeffs.h"
26
27/************************************************************************************/
28/*                                                                                  */
29/*    Treble Boost Filter Coefficients                                              */
30/*                                                                                  */
31/************************************************************************************/
32
33FO_C16_LShx_Coefs_t    LVM_TrebleBoostCoefs[] = {
34
35                    /* 22kHz sampling rate */
36                    {HPF_Fs22050_Gain1_A1,             /* Gain setting 1 */
37                     HPF_Fs22050_Gain1_A0,
38                     -HPF_Fs22050_Gain1_B1,
39                    HPF_Fs22050_Gain1_Shift},
40                    {HPF_Fs22050_Gain2_A1,             /* Gain setting 2 */
41                     HPF_Fs22050_Gain2_A0,
42                     -HPF_Fs22050_Gain2_B1,
43                    HPF_Fs22050_Gain2_Shift},
44                    {HPF_Fs22050_Gain3_A1,             /* Gain setting 3 */
45                     HPF_Fs22050_Gain3_A0,
46                     -HPF_Fs22050_Gain3_B1,
47                    HPF_Fs22050_Gain3_Shift},
48                    {HPF_Fs22050_Gain4_A1,             /* Gain setting 4 */
49                     HPF_Fs22050_Gain4_A0,
50                     -HPF_Fs22050_Gain4_B1,
51                    HPF_Fs22050_Gain4_Shift},
52                    {HPF_Fs22050_Gain5_A1,             /* Gain setting 5 */
53                     HPF_Fs22050_Gain5_A0,
54                     -HPF_Fs22050_Gain5_B1,
55                    HPF_Fs22050_Gain5_Shift},
56                    {HPF_Fs22050_Gain6_A1,             /* Gain setting 6 */
57                     HPF_Fs22050_Gain6_A0,
58                     -HPF_Fs22050_Gain6_B1,
59                    HPF_Fs22050_Gain6_Shift},
60                    {HPF_Fs22050_Gain7_A1,             /* Gain setting 7 */
61                     HPF_Fs22050_Gain7_A0,
62                     -HPF_Fs22050_Gain7_B1,
63                    HPF_Fs22050_Gain7_Shift},
64                    {HPF_Fs22050_Gain8_A1,             /* Gain setting 8 */
65                     HPF_Fs22050_Gain8_A0,
66                     -HPF_Fs22050_Gain8_B1,
67                    HPF_Fs22050_Gain8_Shift},
68                    {HPF_Fs22050_Gain9_A1,             /* Gain setting 9 */
69                     HPF_Fs22050_Gain9_A0,
70                     -HPF_Fs22050_Gain9_B1,
71                    HPF_Fs22050_Gain9_Shift},
72                    {HPF_Fs22050_Gain10_A1,             /* Gain setting 10 */
73                     HPF_Fs22050_Gain10_A0,
74                     -HPF_Fs22050_Gain10_B1,
75                    HPF_Fs22050_Gain10_Shift},
76                    {HPF_Fs22050_Gain11_A1,             /* Gain setting 11 */
77                     HPF_Fs22050_Gain11_A0,
78                     -HPF_Fs22050_Gain11_B1,
79                    HPF_Fs22050_Gain11_Shift},
80                    {HPF_Fs22050_Gain12_A1,             /* Gain setting 12 */
81                     HPF_Fs22050_Gain12_A0,
82                     -HPF_Fs22050_Gain12_B1,
83                    HPF_Fs22050_Gain12_Shift},
84                    {HPF_Fs22050_Gain13_A1,             /* Gain setting 13 */
85                     HPF_Fs22050_Gain13_A0,
86                     -HPF_Fs22050_Gain13_B1,
87                    HPF_Fs22050_Gain13_Shift},
88                    {HPF_Fs22050_Gain14_A1,             /* Gain setting 14 */
89                     HPF_Fs22050_Gain14_A0,
90                     -HPF_Fs22050_Gain14_B1,
91                    HPF_Fs22050_Gain14_Shift},
92                    {HPF_Fs22050_Gain15_A1,             /* Gain setting 15 */
93                     HPF_Fs22050_Gain15_A0,
94                     -HPF_Fs22050_Gain15_B1,
95                    HPF_Fs22050_Gain15_Shift},
96
97                    /* 24kHz sampling rate */
98                    {HPF_Fs24000_Gain1_A1,             /* Gain setting 1 */
99                     HPF_Fs24000_Gain1_A0,
100                     -HPF_Fs24000_Gain1_B1,
101                     HPF_Fs24000_Gain1_Shift},
102                    {HPF_Fs24000_Gain2_A1,             /* Gain setting 2 */
103                     HPF_Fs24000_Gain2_A0,
104                     -HPF_Fs24000_Gain2_B1,
105                     HPF_Fs24000_Gain2_Shift},
106                    {HPF_Fs24000_Gain3_A1,             /* Gain setting 3 */
107                     HPF_Fs24000_Gain3_A0,
108                     -HPF_Fs24000_Gain3_B1,
109                     HPF_Fs24000_Gain3_Shift},
110                    {HPF_Fs24000_Gain4_A1,             /* Gain setting 4 */
111                     HPF_Fs24000_Gain4_A0,
112                     -HPF_Fs24000_Gain4_B1,
113                     HPF_Fs24000_Gain4_Shift},
114                    {HPF_Fs24000_Gain5_A1,             /* Gain setting 5 */
115                     HPF_Fs24000_Gain5_A0,
116                     -HPF_Fs24000_Gain5_B1,
117                     HPF_Fs24000_Gain5_Shift},
118                    {HPF_Fs24000_Gain6_A1,             /* Gain setting 6 */
119                     HPF_Fs24000_Gain6_A0,
120                     -HPF_Fs24000_Gain6_B1,
121                     HPF_Fs24000_Gain6_Shift},
122                    {HPF_Fs24000_Gain7_A1,             /* Gain setting 7 */
123                     HPF_Fs24000_Gain7_A0,
124                     -HPF_Fs24000_Gain7_B1,
125                     HPF_Fs24000_Gain7_Shift},
126                    {HPF_Fs24000_Gain8_A1,             /* Gain setting 8 */
127                     HPF_Fs24000_Gain8_A0,
128                     -HPF_Fs24000_Gain8_B1,
129                     HPF_Fs24000_Gain8_Shift},
130                    {HPF_Fs24000_Gain9_A1,             /* Gain setting 9 */
131                     HPF_Fs24000_Gain9_A0,
132                     -HPF_Fs24000_Gain9_B1,
133                     HPF_Fs24000_Gain9_Shift},
134                    {HPF_Fs24000_Gain10_A1,             /* Gain setting 10 */
135                     HPF_Fs24000_Gain10_A0,
136                     -HPF_Fs24000_Gain10_B1,
137                     HPF_Fs24000_Gain10_Shift},
138                    {HPF_Fs24000_Gain11_A1,             /* Gain setting 11 */
139                     HPF_Fs24000_Gain11_A0,
140                     -HPF_Fs24000_Gain11_B1,
141                     HPF_Fs24000_Gain11_Shift},
142                    {HPF_Fs24000_Gain12_A1,             /* Gain setting 12 */
143                     HPF_Fs24000_Gain12_A0,
144                     -HPF_Fs24000_Gain12_B1,
145                     HPF_Fs24000_Gain12_Shift},
146                    {HPF_Fs24000_Gain13_A1,             /* Gain setting 13 */
147                     HPF_Fs24000_Gain13_A0,
148                     -HPF_Fs24000_Gain13_B1,
149                     HPF_Fs24000_Gain13_Shift},
150                    {HPF_Fs24000_Gain14_A1,             /* Gain setting 14 */
151                     HPF_Fs24000_Gain14_A0,
152                     -HPF_Fs24000_Gain14_B1,
153                     HPF_Fs24000_Gain14_Shift},
154                    {HPF_Fs24000_Gain15_A1,             /* Gain setting 15 */
155                     HPF_Fs24000_Gain15_A0,
156                     -HPF_Fs24000_Gain15_B1,
157                     HPF_Fs24000_Gain15_Shift},
158
159                    /* 32kHz sampling rate */
160                    {HPF_Fs32000_Gain1_A1,             /* Gain setting 1 */
161                     HPF_Fs32000_Gain1_A0,
162                     -HPF_Fs32000_Gain1_B1,
163                    HPF_Fs32000_Gain1_Shift},
164                    {HPF_Fs32000_Gain2_A1,             /* Gain setting 2 */
165                     HPF_Fs32000_Gain2_A0,
166                     -HPF_Fs32000_Gain2_B1,
167                    HPF_Fs32000_Gain2_Shift},
168                    {HPF_Fs32000_Gain3_A1,             /* Gain setting 3 */
169                     HPF_Fs32000_Gain3_A0,
170                     -HPF_Fs32000_Gain3_B1,
171                    HPF_Fs32000_Gain3_Shift},
172                    {HPF_Fs32000_Gain4_A1,             /* Gain setting 4 */
173                     HPF_Fs32000_Gain4_A0,
174                     -HPF_Fs32000_Gain4_B1,
175                    HPF_Fs32000_Gain4_Shift},
176                    {HPF_Fs32000_Gain5_A1,             /* Gain setting 5 */
177                     HPF_Fs32000_Gain5_A0,
178                     -HPF_Fs32000_Gain5_B1,
179                    HPF_Fs32000_Gain5_Shift},
180                    {HPF_Fs32000_Gain6_A1,             /* Gain setting 6 */
181                     HPF_Fs32000_Gain6_A0,
182                     -HPF_Fs32000_Gain6_B1,
183                    HPF_Fs32000_Gain6_Shift},
184                    {HPF_Fs32000_Gain7_A1,             /* Gain setting 7 */
185                     HPF_Fs32000_Gain7_A0,
186                     -HPF_Fs32000_Gain7_B1,
187                    HPF_Fs32000_Gain7_Shift},
188                    {HPF_Fs32000_Gain8_A1,             /* Gain setting 8 */
189                     HPF_Fs32000_Gain8_A0,
190                     -HPF_Fs32000_Gain8_B1,
191                    HPF_Fs32000_Gain8_Shift},
192                    {HPF_Fs32000_Gain9_A1,             /* Gain setting 9 */
193                     HPF_Fs32000_Gain9_A0,
194                     -HPF_Fs32000_Gain9_B1,
195                    HPF_Fs32000_Gain9_Shift},
196                    {HPF_Fs32000_Gain10_A1,             /* Gain setting 10 */
197                     HPF_Fs32000_Gain10_A0,
198                     -HPF_Fs32000_Gain10_B1,
199                    HPF_Fs32000_Gain10_Shift},
200                    {HPF_Fs32000_Gain11_A1,             /* Gain setting 11 */
201                     HPF_Fs32000_Gain11_A0,
202                     -HPF_Fs32000_Gain11_B1,
203                    HPF_Fs32000_Gain11_Shift},
204                    {HPF_Fs32000_Gain12_A1,             /* Gain setting 12 */
205                     HPF_Fs32000_Gain12_A0,
206                     -HPF_Fs32000_Gain12_B1,
207                    HPF_Fs32000_Gain12_Shift},
208                    {HPF_Fs32000_Gain13_A1,             /* Gain setting 13 */
209                     HPF_Fs32000_Gain13_A0,
210                     -HPF_Fs32000_Gain13_B1,
211                    HPF_Fs32000_Gain13_Shift},
212                    {HPF_Fs32000_Gain14_A1,             /* Gain setting 14 */
213                     HPF_Fs32000_Gain14_A0,
214                     -HPF_Fs32000_Gain14_B1,
215                    HPF_Fs32000_Gain14_Shift},
216                    {HPF_Fs32000_Gain15_A1,             /* Gain setting 15 */
217                     HPF_Fs32000_Gain15_A0,
218                     -HPF_Fs32000_Gain15_B1,
219                    HPF_Fs32000_Gain15_Shift},
220
221                    /* 44kHz sampling rate */
222                    {HPF_Fs44100_Gain1_A1,             /* Gain setting 1 */
223                     HPF_Fs44100_Gain1_A0,
224                     -HPF_Fs44100_Gain1_B1,
225                     HPF_Fs44100_Gain1_Shift},
226                    {HPF_Fs44100_Gain2_A1,             /* Gain setting 2 */
227                     HPF_Fs44100_Gain2_A0,
228                     -HPF_Fs44100_Gain2_B1,
229                     HPF_Fs44100_Gain2_Shift},
230                    {HPF_Fs44100_Gain3_A1,             /* Gain setting 3 */
231                     HPF_Fs44100_Gain3_A0,
232                     -HPF_Fs44100_Gain3_B1,
233                     HPF_Fs44100_Gain3_Shift},
234                    {HPF_Fs44100_Gain4_A1,             /* Gain setting 4 */
235                     HPF_Fs44100_Gain4_A0,
236                     -HPF_Fs44100_Gain4_B1,
237                     HPF_Fs44100_Gain4_Shift},
238                    {HPF_Fs44100_Gain5_A1,             /* Gain setting 5 */
239                     HPF_Fs44100_Gain5_A0,
240                     -HPF_Fs44100_Gain5_B1,
241                     HPF_Fs44100_Gain5_Shift},
242                    {HPF_Fs44100_Gain6_A1,             /* Gain setting 6 */
243                     HPF_Fs44100_Gain6_A0,
244                     -HPF_Fs44100_Gain6_B1,
245                     HPF_Fs44100_Gain6_Shift},
246                    {HPF_Fs44100_Gain7_A1,             /* Gain setting 7 */
247                     HPF_Fs44100_Gain7_A0,
248                     -HPF_Fs44100_Gain7_B1,
249                     HPF_Fs44100_Gain7_Shift},
250                    {HPF_Fs44100_Gain8_A1,             /* Gain setting 8 */
251                     HPF_Fs44100_Gain8_A0,
252                     -HPF_Fs44100_Gain8_B1,
253                     HPF_Fs44100_Gain8_Shift},
254                    {HPF_Fs44100_Gain9_A1,             /* Gain setting 9 */
255                     HPF_Fs44100_Gain9_A0,
256                     -HPF_Fs44100_Gain9_B1,
257                     HPF_Fs44100_Gain9_Shift},
258                    {HPF_Fs44100_Gain10_A1,             /* Gain setting 10 */
259                     HPF_Fs44100_Gain10_A0,
260                     -HPF_Fs44100_Gain10_B1,
261                     HPF_Fs44100_Gain10_Shift},
262                    {HPF_Fs44100_Gain11_A1,             /* Gain setting 11 */
263                     HPF_Fs44100_Gain11_A0,
264                     -HPF_Fs44100_Gain11_B1,
265                     HPF_Fs44100_Gain11_Shift},
266                    {HPF_Fs44100_Gain12_A1,             /* Gain setting 12 */
267                     HPF_Fs44100_Gain12_A0,
268                     -HPF_Fs44100_Gain12_B1,
269                     HPF_Fs44100_Gain12_Shift},
270                    {HPF_Fs44100_Gain13_A1,             /* Gain setting 13 */
271                     HPF_Fs44100_Gain13_A0,
272                     -HPF_Fs44100_Gain13_B1,
273                     HPF_Fs44100_Gain13_Shift},
274                    {HPF_Fs44100_Gain14_A1,             /* Gain setting 14 */
275                     HPF_Fs44100_Gain14_A0,
276                     -HPF_Fs44100_Gain14_B1,
277                     HPF_Fs44100_Gain14_Shift},
278                    {HPF_Fs44100_Gain15_A1,             /* Gain setting 15 */
279                     HPF_Fs44100_Gain15_A0,
280                     -HPF_Fs44100_Gain15_B1,
281                     HPF_Fs44100_Gain15_Shift},
282
283                    /* 48kHz sampling rate */
284                    {HPF_Fs48000_Gain1_A1,             /* Gain setting 1 */
285                     HPF_Fs48000_Gain1_A0,
286                     -HPF_Fs48000_Gain1_B1,
287                     HPF_Fs48000_Gain1_Shift},
288                    {HPF_Fs48000_Gain2_A1,             /* Gain setting 2 */
289                     HPF_Fs48000_Gain2_A0,
290                     -HPF_Fs48000_Gain2_B1,
291                     HPF_Fs48000_Gain2_Shift},
292                    {HPF_Fs48000_Gain3_A1,             /* Gain setting 3 */
293                     HPF_Fs48000_Gain3_A0,
294                     -HPF_Fs48000_Gain3_B1,
295                     HPF_Fs48000_Gain3_Shift},
296                    {HPF_Fs48000_Gain4_A1,             /* Gain setting 4 */
297                     HPF_Fs48000_Gain4_A0,
298                     -HPF_Fs48000_Gain4_B1,
299                     HPF_Fs48000_Gain4_Shift},
300                    {HPF_Fs48000_Gain5_A1,             /* Gain setting 5 */
301                     HPF_Fs48000_Gain5_A0,
302                     -HPF_Fs48000_Gain5_B1,
303                     HPF_Fs48000_Gain5_Shift},
304                    {HPF_Fs48000_Gain6_A1,             /* Gain setting 6 */
305                     HPF_Fs48000_Gain6_A0,
306                     -HPF_Fs48000_Gain6_B1,
307                     HPF_Fs48000_Gain6_Shift},
308                    {HPF_Fs48000_Gain7_A1,             /* Gain setting 7 */
309                     HPF_Fs48000_Gain7_A0,
310                     -HPF_Fs48000_Gain7_B1,
311                     HPF_Fs48000_Gain7_Shift},
312                    {HPF_Fs48000_Gain8_A1,             /* Gain setting 8 */
313                     HPF_Fs48000_Gain8_A0,
314                     -HPF_Fs48000_Gain8_B1,
315                     HPF_Fs48000_Gain8_Shift},
316                    {HPF_Fs48000_Gain9_A1,             /* Gain setting 9 */
317                     HPF_Fs48000_Gain9_A0,
318                     -HPF_Fs48000_Gain9_B1,
319                     HPF_Fs48000_Gain9_Shift},
320                    {HPF_Fs48000_Gain10_A1,             /* Gain setting 10 */
321                     HPF_Fs48000_Gain10_A0,
322                     -HPF_Fs48000_Gain10_B1,
323                     HPF_Fs48000_Gain10_Shift},
324                    {HPF_Fs48000_Gain11_A1,             /* Gain setting 11 */
325                     HPF_Fs48000_Gain11_A0,
326                     -HPF_Fs48000_Gain11_B1,
327                     HPF_Fs48000_Gain11_Shift},
328                    {HPF_Fs48000_Gain12_A1,             /* Gain setting 12 */
329                     HPF_Fs48000_Gain12_A0,
330                     -HPF_Fs48000_Gain12_B1,
331                     HPF_Fs48000_Gain12_Shift},
332                    {HPF_Fs48000_Gain13_A1,             /* Gain setting 13 */
333                     HPF_Fs48000_Gain13_A0,
334                     -HPF_Fs48000_Gain13_B1,
335                     HPF_Fs48000_Gain13_Shift},
336                    {HPF_Fs48000_Gain14_A1,             /* Gain setting 14 */
337                     HPF_Fs48000_Gain14_A0,
338                     -HPF_Fs48000_Gain14_B1,
339                     HPF_Fs48000_Gain14_Shift},
340                    {HPF_Fs48000_Gain15_A1,             /* Gain setting 15 */
341                     HPF_Fs48000_Gain15_A0,
342                     -HPF_Fs48000_Gain15_B1,
343                     HPF_Fs48000_Gain15_Shift}};
344
345
346/************************************************************************************/
347/*                                                                                    */
348/*    Volume control gain and time constant tables                                    */
349/*                                                                                    */
350/************************************************************************************/
351
352/* dB to linear conversion table */
353const LVM_INT16 LVM_VolumeTable[] = {
354    0x7FFF,             /*  0dB */
355    0x7215,             /* -1dB */
356    0x65AD,             /* -2dB */
357    0x5A9E,             /* -3dB */
358    0x50C3,             /* -4dB */
359    0x47FB,             /* -5dB */
360    0x4000};            /* -6dB */
361
362/************************************************************************************/
363/*                                                                                  */
364/*  Volume mixer time constants (100ms)                                             */
365/*                                                                                  */
366/************************************************************************************/
367
368#define LVM_MIX_TC_Fs8000      32580         /* Floating point value 0.994262695 */
369#define LVM_MIX_TC_Fs11025     32632         /* Floating point value 0.995849609 */
370#define LVM_MIX_TC_Fs12000     32643         /* Floating point value 0.996185303 */
371#define LVM_MIX_TC_Fs16000     32674         /* Floating point value 0.997131348 */
372#define LVM_MIX_TC_Fs22050     32700         /* Floating point value 0.997924805 */
373#define LVM_MIX_TC_Fs24000     32705         /* Floating point value 0.998077393 */
374#define LVM_MIX_TC_Fs32000     32721         /* Floating point value 0.998565674 */
375#define LVM_MIX_TC_Fs44100     32734         /* Floating point value 0.998962402 */
376#define LVM_MIX_TC_Fs48000     32737         /* Floating point value 0.999053955 */
377
378
379const LVM_INT16 LVM_MixerTCTable[] = {
380    LVM_MIX_TC_Fs8000,
381    LVM_MIX_TC_Fs11025,
382    LVM_MIX_TC_Fs12000,
383    LVM_MIX_TC_Fs16000,
384    LVM_MIX_TC_Fs22050,
385    LVM_MIX_TC_Fs24000,
386    LVM_MIX_TC_Fs32000,
387    LVM_MIX_TC_Fs44100,
388    LVM_MIX_TC_Fs48000};
389
390