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 #define LVEQNB_SCRATCHBUFFERS       4                   /* Number of buffers required for inplace processing */
50 #define LVEQNB_SCRATCH_ALIGN        4                   /* 32-bit alignment for long data */
51 
52 #define LVEQNB_BYPASS_MIXER_TC      100                 /* Bypass Mixer TC */
53 
54 /****************************************************************************************/
55 /*                                                                                      */
56 /*  Types                                                                               */
57 /*                                                                                      */
58 /****************************************************************************************/
59 
60 /* Filter biquad types */
61 typedef enum
62 {
63 #ifdef BUILD_FLOAT
64     LVEQNB_SinglePrecision_Float = -1,
65 #endif
66     LVEQNB_SinglePrecision = 0,
67     LVEQNB_DoublePrecision = 1,
68     LVEQNB_OutOfRange      = 2,
69     LVEQNB_BIQUADTYPE_MAX  = LVM_MAXINT_32
70 } LVEQNB_BiquadType_en;
71 
72 
73 /****************************************************************************************/
74 /*                                                                                      */
75 /*  Structures                                                                          */
76 /*                                                                                      */
77 /****************************************************************************************/
78 
79 
80 
81 /* Instance structure */
82 typedef struct
83 {
84     /* Public parameters */
85     LVEQNB_MemTab_t                 MemoryTable;        /* Instance memory allocation table */
86     LVEQNB_Params_t                 Params;             /* Instance parameters */
87     LVEQNB_Capabilities_t           Capabilities;       /* Instance capabilities */
88 
89     /* Aligned memory pointers */
90 #ifdef BUILD_FLOAT
91     LVM_FLOAT                      *pFastTemporary;        /* Fast temporary data base address */
92 #else
93     LVM_INT16                      *pFastTemporary;        /* Fast temporary data base address */
94 #endif
95 
96 #ifdef BUILD_FLOAT
97     Biquad_2I_Order2_FLOAT_Taps_t   *pEQNB_Taps_Float;        /* Equaliser Taps */
98     Biquad_FLOAT_Instance_t         *pEQNB_FilterState_Float; /* State for each filter band */
99 #else
100     /* Process variables */
101     Biquad_2I_Order2_Taps_t         *pEQNB_Taps;        /* Equaliser Taps */
102     Biquad_Instance_t               *pEQNB_FilterState; /* State for each filter band */
103 #endif
104 
105     /* Filter definitions and call back */
106     LVM_UINT16                      NBands;             /* Number of bands */
107     LVEQNB_BandDef_t                *pBandDefinitions;  /* Filter band definitions */
108     LVEQNB_BiquadType_en            *pBiquadType;       /* Filter biquad types */
109 
110     /* Bypass variable */
111 #ifdef BUILD_FLOAT
112     LVMixer3_2St_FLOAT_st     BypassMixer;
113 #else
114     LVMixer3_2St_st           BypassMixer;              /* Bypass mixer used in transitions */
115 #endif
116 
117     LVM_INT16               bInOperatingModeTransition; /* Operating mode transition flag */
118 
119 } LVEQNB_Instance_t;
120 
121 
122 /****************************************************************************************/
123 /*                                                                                      */
124 /* Function prototypes                                                                  */
125 /*                                                                                      */
126 /****************************************************************************************/
127 
128 void    LVEQNB_SetFilters(LVEQNB_Instance_t   *pInstance,
129                           LVEQNB_Params_t     *pParams);
130 
131 void    LVEQNB_SetCoefficients(LVEQNB_Instance_t    *pInstance);
132 
133 void    LVEQNB_ClearFilterHistory(LVEQNB_Instance_t *pInstance);
134 #ifdef BUILD_FLOAT
135 LVEQNB_ReturnStatus_en LVEQNB_SinglePrecCoefs(LVM_UINT16        Fs,
136                                               LVEQNB_BandDef_t  *pFilterDefinition,
137                                               PK_FLOAT_Coefs_t    *pCoefficients);
138 #else
139 LVEQNB_ReturnStatus_en LVEQNB_SinglePrecCoefs(LVM_UINT16        Fs,
140                                               LVEQNB_BandDef_t  *pFilterDefinition,
141                                               PK_C16_Coefs_t    *pCoefficients);
142 
143 LVEQNB_ReturnStatus_en LVEQNB_DoublePrecCoefs(LVM_UINT16        Fs,
144                                               LVEQNB_BandDef_t  *pFilterDefinition,
145                                               PK_C32_Coefs_t    *pCoefficients);
146 #endif
147 
148 LVM_INT32 LVEQNB_BypassMixerCallBack (void* hInstance, void *pGeneralPurpose, LVM_INT16 CallbackParam);
149 
150 #ifdef __cplusplus
151 }
152 #endif /* __cplusplus */
153 
154 #endif /* __LVEQNB_PRIVATE_H__ */
155 
156