• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef __AEC_H__
16 #define __AEC_H__
17 #include <stdint.h>
18 
19 #ifdef  __cplusplus
20 extern "C" {
21 #endif//__cplusplus
22 
23 //#define AEC_MAX_MIC_DELAY       (2000)
24 
25 
26 /**
27  * @brief AEC enum defines
28  * @defgroup AEC enums
29  * @ingroup AEC
30  * @{
31  */
32 
33 enum AEC_CTRL_CMD
34 {
35 	AEC_CTRL_CMD_NULL = 0,
36 
37 	AEC_CTRL_CMD_GET_MIC_DELAY,    /**< Get mic delay */
38 	AEC_CTRL_CMD_SET_MIC_DELAY,    /**< Set mic delay */
39 
40 	AEC_CTRL_CMD_GET_EC_DEPTH,     /**< Get ec depth */
41 	AEC_CTRL_CMD_SET_EC_DEPTH,     /**< Set ec depth */
42 
43 	AEC_CTRL_CMD_GET_NS_LEVEL,     /**<Get ns level */
44 	AEC_CTRL_CMD_SET_NS_LEVEL,     /**<Set ns level */
45 
46 	AEC_CTRL_CMD_GET_DRC,          /**<Get drc */
47 	AEC_CTRL_CMD_SET_DRC,          /**<Set drc */
48 
49 	AEC_CTRL_CMD_GET_FLAGS,        /**<Get flags */
50 	AEC_CTRL_CMD_SET_FLAGS,        /**<Set flags */
51 
52 	AEC_CTRL_CMD_SET_VOL,          /**<Set volum */
53 	AEC_CTRL_CMD_SET_REF_SCALE,    /**<Set reference scale */
54 	AEC_CTRL_CMD_SET_TxRxThr,      /**<Set TxRxThr */
55 	AEC_CTRL_CMD_SET_TxRxFlr,      /**<Set TxRxFlr */
56 	AEC_CTRL_CMD_SET_NS_PARA,      /**<Set ns parameter */
57 	AEC_CTRL_CMD_SET_PARAMS,       /**<Set parameters */
58 
59 	AEC_CTRL_CMD_GET_RX_BUF,       /**<Get rx buffer addr */
60 	AEC_CTRL_CMD_GET_TX_BUF,       /**<Get tx buffer addr */
61 	AEC_CTRL_CMD_GET_OUT_BUF,      /**<Get output buffer addr */
62 	AEC_CTRL_CMD_GET_FRAME_SAMPLE, /**<Get frame sample */
63 };
64 
65 /**
66  * @}
67  */
68 	typedef struct _AECContext AECContext;         /**<AEC struct */
69 
70 /**
71  * @brief AUD struct defines
72  * @defgroup bk_api_aud_structs structs in AUD
73  * @ingroup bk_api_aud
74  * @{
75  */
76 
77 
78 /**
79  * @}
80  */
81 
82 
83 /**
84  * @brief AEC API
85  * @defgroup AEC API group
86  * @{
87  */
88 
89 
90 /**
91  * @brief     Get AECContext size (byte)
92  *
93  * @return
94  *    - uint32_t: size(byte)
95  */
96 uint32_t aec_size    (void);
97 
98 /**
99  * @brief     Init aec
100  *
101  * This API init aec function :
102  *  - Set aec parameters
103  *  - Init fft parameters
104  *
105  * Usage example:
106  *
107  *
108  *     AECContext* aec = NULL;
109  *
110  *     //malloc aec memory
111  *     aec = (AECContext*)os_malloc(aec_size());
112  *
113  *     //init aec
114  *     aec_init(aec, 16000);
115  *
116  *
117  * @param aec aec parameters
118  * @param fs frame sample 8K/16K
119  *
120  * @return none
121  */
122 void aec_init    (AECContext* aec, int16_t fs);
123 
124 /**
125  * @brief     Control aec
126  *
127  * This API control aec function :
128  *  - Set aec parameters
129  *  - Get data addr
130  *
131  * Usage example:
132  *
133  *
134  *     AECContext* aec = NULL;
135  *
136  *     //malloc aec memory
137  *     aec = (AECContext*)os_malloc(aec_size());
138  *
139  *     //init aec
140  *     aec_init(aec, 16000);
141  *
142  *     //set mic delay
143  *     aec_ctrl(aec, AEC_CTRL_CMD_SET_MIC_DELAY, 10);
144  *
145  *
146  * @param aec aec parameters
147  * @param cmd control command in enum AEC_CTRL_CMD
148  * @param arg value
149  *
150  * @return none
151  */
152 void aec_ctrl    (AECContext* aec, uint32_t cmd, uint32_t arg);
153 
154 /**
155  * @brief     Control aec
156  *
157  * This API control aec function :
158  *  - Set aec parameters
159  *  - Get data addr
160  *
161  * Usage example:
162  *
163  *
164  *     AECContext* aec = NULL;
165  *
166  *     //malloc aec memory
167  *     aec = (AECContext*)os_malloc(aec_size());
168  *
169  *     //init aec
170  *     aec_init(aec, 16000);
171  *
172  *     //aec excute work
173  *     aec_proc (aec, rin, sin, out);
174  *
175  *
176  * @param aec aec parameters
177  * @param rin reference data
178  * @param sin source data
179  * @param out output data
180  *
181  * @return none
182  */
183 void aec_proc    (AECContext* aec, int16_t* rin, int16_t* sin, int16_t* out);
184 
185 /**
186  * @}
187  */
188 
189 #ifdef  __cplusplus
190 }
191 #endif//__cplusplus
192 
193 #endif//__AEC_H__
194