• 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 #pragma once
16 
17 #include <driver/int_types.h>
18 #include <common/bk_include.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 
25 typedef void (*fft_isr_t)(void *param);
26 
27 
28 /**
29  * @brief FFT defines
30  * @defgroup bk_api_fft_defs macos
31  * @ingroup bk_api_fft
32  * @{
33  */
34 
35 #define BK_ERR_FFT_NOT_INIT			(BK_ERR_FFT_BASE - 1) /**< FFT driver not init */
36 #define BK_ERR_FFT_PARAM			(BK_ERR_FFT_BASE - 2) /**< FFT parameter invalid */
37 
38 /**
39  * @}
40  */
41 
42 /**
43  * @brief FFT enum defines
44  * @defgroup bk_api_aud_enum FFT enums
45  * @ingroup bk_api_fft
46  * @{
47  */
48 
49 typedef enum {
50 	FFT_WORK_MODE_FFT = 0, /**< FFT fft work mode */
51 	FFT_WORK_MODE_IFFT,    /**< FFT ifft work mode */
52 	FFT_WORK_MODE_MAX,
53 } fft_work_mode_t;
54 
55 typedef enum {
56 	FFT_MODE_NORMAL = 0, /**< FFT normal mode */
57 	FFT_MODE_BK5130,     /**< FFT bk5130 mode */
58 	FFT_MODE_MAX,
59 } fft_mode_t;
60 
61 typedef enum {
62 	FFT_IFFT_DISABLE = 0, /**< IFFT disable */
63 	FFT_IFFT_ENABLE,      /**< IFFT enable */
64 	FFT_IFFT_MAX,
65 } fft_ifft_en_t;
66 
67 typedef enum {
68 	FFT_INT_DISABLE = 0, /**< FFT interrupt disable */
69 	FFT_INT_ENABLE,      /**< FFT interrupt enable */
70 	FFT_INT_MAX,
71 } fft_int_en_t;
72 
73 typedef enum {
74 	FFT_DISABLE = 0, /**< FFT disable */
75 	FFT_ENABLE,      /**< FFT enable */
76 	FFT_ENABLE_MAX,
77 } fft_enable_t;
78 
79 typedef enum {
80 	FFT_GAT_ON = 0, /**< FFT gat on */
81 	FFT_GAT_OFF,    /**< FFT gat off */
82 	FFT_GAT_MAX,
83 } fft_gat_t;
84 
85 typedef enum {
86 	FFT_FIR_MODE_SIGNAL = 0, /**< FIR signal mode */
87 	FFT_FIR_MODE_DUAL,       /**< FIR dual mode */
88 	FFT_FIR_MODE_MAX,
89 } fft_fir_mode_t;
90 
91 typedef enum {
92 	FFT_FIR_INT_DISABLE = 0, /**< FIR interrupt disable */
93 	FFT_FIR_INT_ENABLE,      /**< FIR interrupt enable */
94 	FFT_FIR_INT_MAX,
95 } fft_fir_int_en_t;
96 
97 typedef enum {
98 	FFT_FIR_DISABLE = 0, /**< FIR disable */
99 	FFT_FIR_ENABLE,      /**< FIR enable */
100 	FFT_FIR_ENABLE_MAX,
101 } fft_fir_en_t;
102 
103 typedef enum {
104 	FFT_SELF_PROC_MODE0 = 0, /**< Self process mode1 */
105 	FFT_SELF_PROC_MODE1,     /**< Self process mode2 */
106 	FFT_SELF_PROC_MODE_MAX,
107 } fft_self_proc_mode_t;
108 
109 typedef enum {
110 	FFT_SELECT_MEMORY0 = 0, /**< FFT select Memroy0 */
111 	FFT_SELECT_MEMORY1,     /**< FFT select Memroy1 */
112 	FFT_SELECT_MEMORY_MAX,
113 } fft_memory_config_t;
114 
115 
116 /**
117  * @}
118  */
119 
120 /**
121  * @brief FFT struct defines
122  * @defgroup bk_api_aud_structs structs in FFT
123  * @ingroup bk_api_fft
124  * @{
125  */
126 
127 typedef struct {
128 	icu_int_src_t int_src;
129 	int_group_isr_t isr;
130 } fft_int_config_t;
131 
132 typedef struct {
133 	int16 *i_out;
134 	int16 *q_out;
135 	uint32_t busy_flag;
136 	uint32_t size;
137 } fft_driver_t;
138 
139 typedef struct {
140 	/* fifo status */
141 	bool fft_done;       /**< FFT fft process done */
142 	bool fir_done;       /**< FFT fir process done */
143 	bool self_proc_done; /**< FFT self process done */
144 	bool start_trigger;  /**< FFT start trigger flag */
145 	uint32_t bit_ext;    /**< FFT fft bit extend */
146 } fft_status_t;
147 
148 typedef struct {
149 	bool fft_int_enable;
150 	bool fir_int_enable;
151 } fft_int_status;
152 
153 
154 typedef struct
155 {
156 	fft_work_mode_t mode;
157 	uint32_t *inbuf;
158 	uint32_t size;
159 } fft_input_t;
160 
161 typedef struct
162 {
163 	uint32_t mode;
164 	uint32_t fir_len;
165 	int16 *coef_c0;
166 	int16 *coef_c1;
167 	int16 *input_d0;
168 	int16 *input_d1;
169 } fft_fir_input_t;
170 
171 /**
172  * @}
173  */
174 
175 
176 #ifdef __cplusplus
177 }
178 #endif
179