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 #ifndef __LVEQNB_PRIVATE_H__
19 #define __LVEQNB_PRIVATE_H__
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24 
25 
26 /****************************************************************************************/
27 /*                                                                                      */
28 /*  Includes                                                                            */
29 /*                                                                                      */
30 /****************************************************************************************/
31 
32 #include "LVEQNB.h"                                     /* Calling or Application layer definitions */
33 #include "BIQUAD.h"
34 #include "LVC_Mixer.h"
35 
36 /****************************************************************************************/
37 /*                                                                                      */
38 /*  Defines                                                                             */
39 /*                                                                                      */
40 /****************************************************************************************/
41 
42 /* General */
43 #define LVEQNB_INVALID              0xFFFF              /* Invalid init parameter */
44 
45 /* Memory */
46 #define LVEQNB_INSTANCE_ALIGN       4                   /* 32-bit alignment for instance structures */
47 #define LVEQNB_DATA_ALIGN           4                   /* 32-bit alignment for structures */
48 #define LVEQNB_COEF_ALIGN           4                   /* 32-bit alignment for long words */
49 #ifdef SUPPORT_MC
50 /* Number of buffers required for inplace processing */
51 #define LVEQNB_SCRATCHBUFFERS       (LVM_MAX_CHANNELS * 2)
52 #else
53 #define LVEQNB_SCRATCHBUFFERS       4                   /* Number of buffers required for inplace processing */
54 #endif
55 #define LVEQNB_SCRATCH_ALIGN        4                   /* 32-bit alignment for long data */
56 
57 #define LVEQNB_BYPASS_MIXER_TC      100                 /* Bypass Mixer TC */
58 
59 /****************************************************************************************/
60 /*                                                                                      */
61 /*  Types                                                                               */
62 /*                                                                                      */
63 /****************************************************************************************/
64 
65 /* Filter biquad types */
66 typedef enum
67 {
68 #ifdef BUILD_FLOAT
69     LVEQNB_SinglePrecision_Float = -1,
70 #endif
71     LVEQNB_SinglePrecision = 0,
72     LVEQNB_DoublePrecision = 1,
73     LVEQNB_OutOfRange      = 2,
74     LVEQNB_BIQUADTYPE_MAX  = LVM_MAXINT_32
75 } LVEQNB_BiquadType_en;
76 
77 
78 /****************************************************************************************/
79 /*                                                                                      */
80 /*  Structures                                                                          */
81 /*                                                                                      */
82 /****************************************************************************************/
83 
84 
85 
86 /* Instance structure */
87 typedef struct
88 {
89     /* Public parameters */
90     LVEQNB_MemTab_t                 MemoryTable;        /* Instance memory allocation table */
91     LVEQNB_Params_t                 Params;             /* Instance parameters */
92     LVEQNB_Capabilities_t           Capabilities;       /* Instance capabilities */
93 
94     /* Aligned memory pointers */
95 #ifdef BUILD_FLOAT
96     LVM_FLOAT                      *pFastTemporary;        /* Fast temporary data base address */
97 #else
98     LVM_INT16                      *pFastTemporary;        /* Fast temporary data base address */
99 #endif
100 
101 #ifdef BUILD_FLOAT
102     Biquad_2I_Order2_FLOAT_Taps_t   *pEQNB_Taps_Float;        /* Equaliser Taps */
103     Biquad_FLOAT_Instance_t         *pEQNB_FilterState_Float; /* State for each filter band */
104 #else
105     /* Process variables */
106     Biquad_2I_Order2_Taps_t         *pEQNB_Taps;        /* Equaliser Taps */
107     Biquad_Instance_t               *pEQNB_FilterState; /* State for each filter band */
108 #endif
109 
110     /* Filter definitions and call back */
111     LVM_UINT16                      NBands;             /* Number of bands */
112     LVEQNB_BandDef_t                *pBandDefinitions;  /* Filter band definitions */
113     LVEQNB_BiquadType_en            *pBiquadType;       /* Filter biquad types */
114 
115     /* Bypass variable */
116 #ifdef BUILD_FLOAT
117     LVMixer3_2St_FLOAT_st     BypassMixer;
118 #else
119     LVMixer3_2St_st           BypassMixer;              /* Bypass mixer used in transitions */
120 #endif
121 
122     LVM_INT16               bInOperatingModeTransition; /* Operating mode transition flag */
123 
124 } LVEQNB_Instance_t;
125 
126 
127 /****************************************************************************************/
128 /*                                                                                      */
129 /* Function prototypes                                                                  */
130 /*                                                                                      */
131 /****************************************************************************************/
132 
133 void    LVEQNB_SetFilters(LVEQNB_Instance_t   *pInstance,
134                           LVEQNB_Params_t     *pParams);
135 
136 void    LVEQNB_SetCoefficients(LVEQNB_Instance_t    *pInstance);
137 
138 void    LVEQNB_ClearFilterHistory(LVEQNB_Instance_t *pInstance);
139 #ifdef BUILD_FLOAT
140 LVEQNB_ReturnStatus_en LVEQNB_SinglePrecCoefs(LVM_UINT16        Fs,
141                                               LVEQNB_BandDef_t  *pFilterDefinition,
142                                               PK_FLOAT_Coefs_t    *pCoefficients);
143 #else
144 LVEQNB_ReturnStatus_en LVEQNB_SinglePrecCoefs(LVM_UINT16        Fs,
145                                               LVEQNB_BandDef_t  *pFilterDefinition,
146                                               PK_C16_Coefs_t    *pCoefficients);
147 
148 LVEQNB_ReturnStatus_en LVEQNB_DoublePrecCoefs(LVM_UINT16        Fs,
149                                               LVEQNB_BandDef_t  *pFilterDefinition,
150                                               PK_C32_Coefs_t    *pCoefficients);
151 #endif
152 
153 LVM_INT32 LVEQNB_BypassMixerCallBack (void* hInstance, void *pGeneralPurpose, LVM_INT16 CallbackParam);
154 
155 #ifdef __cplusplus
156 }
157 #endif /* __cplusplus */
158 
159 #endif /* __LVEQNB_PRIVATE_H__ */
160 
161