• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _AUDIO_EFFECTS_H
2 #define _AUDIO_EFFECTS_H
3 
4 /** AUDIO EFFECTS **/
5 
6 
7 /* CONFIG GET/SET */
8 #define CONFIG_CACHE			0
9 #define CONFIG_SET			1
10 #define CONFIG_GET			2
11 
12 /* CONFIG HEADER */
13 /*
14  * MODULE_ID,
15  * DEVICE,
16  * NUM_COMMANDS,
17  * COMMAND_ID_1,
18  * CONFIG_CACHE/SET/GET,
19  * OFFSET_1,
20  * LENGTH_1,
21  * VALUES_1,
22  * ...,
23  * ...,
24  * COMMAND_ID_2,
25  * CONFIG_CACHE/SET/GET,
26  * OFFSET_2,
27  * LENGTH_2,
28  * VALUES_2,
29  * ...,
30  * ...,
31  * COMMAND_ID_3,
32  * ...
33  */
34 
35 
36 /* CONFIG PARAM IDs */
37 #define VIRTUALIZER_MODULE		0x00001000
38 #define VIRTUALIZER_ENABLE		0x00001001
39 #define VIRTUALIZER_STRENGTH		0x00001002
40 #define VIRTUALIZER_OUT_TYPE		0x00001003
41 #define VIRTUALIZER_GAIN_ADJUST		0x00001004
42 #define VIRTUALIZER_ENABLE_PARAM_LEN		1
43 #define VIRTUALIZER_STRENGTH_PARAM_LEN		1
44 #define VIRTUALIZER_OUT_TYPE_PARAM_LEN		1
45 #define VIRTUALIZER_GAIN_ADJUST_PARAM_LEN	1
46 
47 #define REVERB_MODULE			0x00002000
48 #define REVERB_ENABLE			0x00002001
49 #define REVERB_MODE			0x00002002
50 #define REVERB_PRESET			0x00002003
51 #define REVERB_WET_MIX			0x00002004
52 #define REVERB_GAIN_ADJUST		0x00002005
53 #define REVERB_ROOM_LEVEL		0x00002006
54 #define REVERB_ROOM_HF_LEVEL		0x00002007
55 #define REVERB_DECAY_TIME		0x00002008
56 #define REVERB_DECAY_HF_RATIO		0x00002009
57 #define REVERB_REFLECTIONS_LEVEL	0x0000200a
58 #define REVERB_REFLECTIONS_DELAY	0x0000200b
59 #define REVERB_LEVEL			0x0000200c
60 #define REVERB_DELAY			0x0000200d
61 #define REVERB_DIFFUSION		0x0000200e
62 #define REVERB_DENSITY			0x0000200f
63 #define REVERB_ENABLE_PARAM_LEN			1
64 #define REVERB_MODE_PARAM_LEN			1
65 #define REVERB_PRESET_PARAM_LEN			1
66 #define REVERB_WET_MIX_PARAM_LEN		1
67 #define REVERB_GAIN_ADJUST_PARAM_LEN		1
68 #define REVERB_ROOM_LEVEL_PARAM_LEN		1
69 #define REVERB_ROOM_HF_LEVEL_PARAM_LEN		1
70 #define REVERB_DECAY_TIME_PARAM_LEN		1
71 #define REVERB_DECAY_HF_RATIO_PARAM_LEN		1
72 #define REVERB_REFLECTIONS_LEVEL_PARAM_LEN	1
73 #define REVERB_REFLECTIONS_DELAY_PARAM_LEN	1
74 #define REVERB_LEVEL_PARAM_LEN			1
75 #define REVERB_DELAY_PARAM_LEN			1
76 #define REVERB_DIFFUSION_PARAM_LEN		1
77 #define REVERB_DENSITY_PARAM_LEN		1
78 
79 #define BASS_BOOST_MODULE		0x00003000
80 #define BASS_BOOST_ENABLE		0x00003001
81 #define BASS_BOOST_MODE			0x00003002
82 #define BASS_BOOST_STRENGTH		0x00003003
83 #define BASS_BOOST_ENABLE_PARAM_LEN		1
84 #define BASS_BOOST_MODE_PARAM_LEN		1
85 #define BASS_BOOST_STRENGTH_PARAM_LEN		1
86 
87 #define EQ_MODULE			0x00004000
88 #define EQ_ENABLE			0x00004001
89 #define EQ_CONFIG			0x00004002
90 #define EQ_NUM_BANDS			0x00004003
91 #define EQ_BAND_LEVELS			0x00004004
92 #define EQ_BAND_LEVEL_RANGE		0x00004005
93 #define EQ_BAND_FREQS			0x00004006
94 #define EQ_SINGLE_BAND_FREQ_RANGE	0x00004007
95 #define EQ_SINGLE_BAND_FREQ		0x00004008
96 #define EQ_BAND_INDEX			0x00004009
97 #define EQ_PRESET_ID			0x0000400a
98 #define EQ_NUM_PRESETS			0x0000400b
99 #define EQ_PRESET_NAME			0x0000400c
100 #define EQ_ENABLE_PARAM_LEN			1
101 #define EQ_CONFIG_PARAM_LEN			3
102 #define EQ_CONFIG_PER_BAND_PARAM_LEN		5
103 #define EQ_NUM_BANDS_PARAM_LEN			1
104 #define EQ_BAND_LEVELS_PARAM_LEN		13
105 #define EQ_BAND_LEVEL_RANGE_PARAM_LEN		2
106 #define EQ_BAND_FREQS_PARAM_LEN			13
107 #define EQ_SINGLE_BAND_FREQ_RANGE_PARAM_LEN	2
108 #define EQ_SINGLE_BAND_FREQ_PARAM_LEN		1
109 #define EQ_BAND_INDEX_PARAM_LEN			1
110 #define EQ_PRESET_ID_PARAM_LEN			1
111 #define EQ_NUM_PRESETS_PARAM_LEN		1
112 #define EQ_PRESET_NAME_PARAM_LEN		32
113 
114 #define EQ_TYPE_NONE	0
115 #define EQ_BASS_BOOST	1
116 #define EQ_BASS_CUT	2
117 #define EQ_TREBLE_BOOST	3
118 #define EQ_TREBLE_CUT	4
119 #define EQ_BAND_BOOST	5
120 #define EQ_BAND_CUT	6
121 
122 #define SOFT_VOLUME_MODULE		0x00006000
123 #define SOFT_VOLUME_ENABLE		0x00006001
124 #define SOFT_VOLUME_GAIN_2CH		0x00006002
125 #define SOFT_VOLUME_GAIN_MASTER		0x00006003
126 #define SOFT_VOLUME_ENABLE_PARAM_LEN		1
127 #define SOFT_VOLUME_GAIN_2CH_PARAM_LEN		2
128 #define SOFT_VOLUME_GAIN_MASTER_PARAM_LEN	1
129 
130 #define SOFT_VOLUME2_MODULE		0x00007000
131 #define SOFT_VOLUME2_ENABLE		0x00007001
132 #define SOFT_VOLUME2_GAIN_2CH		0x00007002
133 #define SOFT_VOLUME2_GAIN_MASTER	0x00007003
134 #define SOFT_VOLUME2_ENABLE_PARAM_LEN		SOFT_VOLUME_ENABLE_PARAM_LEN
135 #define SOFT_VOLUME2_GAIN_2CH_PARAM_LEN		SOFT_VOLUME_GAIN_2CH_PARAM_LEN
136 #define SOFT_VOLUME2_GAIN_MASTER_PARAM_LEN	\
137 					SOFT_VOLUME_GAIN_MASTER_PARAM_LEN
138 
139 #define PBE_CONF_MODULE_ID	0x00010C2A
140 #define PBE_CONF_PARAM_ID	0x00010C49
141 
142 #define PBE_MODULE		0x00008000
143 #define PBE_ENABLE		0x00008001
144 #define PBE_CONFIG		0x00008002
145 #define PBE_ENABLE_PARAM_LEN		1
146 #define PBE_CONFIG_PARAM_LEN		28
147 
148 /* Command Payload length and size for Non-IID commands */
149 #define COMMAND_PAYLOAD_LEN	3
150 #define COMMAND_PAYLOAD_SZ	(COMMAND_PAYLOAD_LEN * sizeof(uint32_t))
151 /* Command Payload length and size for IID commands */
152 #define COMMAND_IID_PAYLOAD_LEN	4
153 #define COMMAND_IID_PAYLOAD_SZ	(COMMAND_IID_PAYLOAD_LEN * sizeof(uint32_t))
154 #define MAX_INBAND_PARAM_SZ	4096
155 #define Q27_UNITY		(1 << 27)
156 #define Q8_UNITY		(1 << 8)
157 #define CUSTOM_OPENSL_PRESET	18
158 
159 #define VIRTUALIZER_ENABLE_PARAM_SZ	\
160 			(VIRTUALIZER_ENABLE_PARAM_LEN*sizeof(uint32_t))
161 #define VIRTUALIZER_STRENGTH_PARAM_SZ	\
162 			(VIRTUALIZER_STRENGTH_PARAM_LEN*sizeof(uint32_t))
163 #define VIRTUALIZER_OUT_TYPE_PARAM_SZ	\
164 			(VIRTUALIZER_OUT_TYPE_PARAM_LEN*sizeof(uint32_t))
165 #define VIRTUALIZER_GAIN_ADJUST_PARAM_SZ	\
166 			(VIRTUALIZER_GAIN_ADJUST_PARAM_LEN*sizeof(uint32_t))
167 struct virtualizer_params {
168 	uint32_t device;
169 	uint32_t enable_flag;
170 	uint32_t strength;
171 	uint32_t out_type;
172 	int32_t gain_adjust;
173 };
174 
175 #define NUM_OSL_REVERB_PRESETS_SUPPORTED	6
176 #define REVERB_ENABLE_PARAM_SZ		\
177 			(REVERB_ENABLE_PARAM_LEN*sizeof(uint32_t))
178 #define REVERB_MODE_PARAM_SZ		\
179 			(REVERB_MODE_PARAM_LEN*sizeof(uint32_t))
180 #define REVERB_PRESET_PARAM_SZ		\
181 			(REVERB_PRESET_PARAM_LEN*sizeof(uint32_t))
182 #define REVERB_WET_MIX_PARAM_SZ		\
183 			(REVERB_WET_MIX_PARAM_LEN*sizeof(uint32_t))
184 #define REVERB_GAIN_ADJUST_PARAM_SZ	\
185 			(REVERB_GAIN_ADJUST_PARAM_LEN*sizeof(uint32_t))
186 #define REVERB_ROOM_LEVEL_PARAM_SZ	\
187 			(REVERB_ROOM_LEVEL_PARAM_LEN*sizeof(uint32_t))
188 #define REVERB_ROOM_HF_LEVEL_PARAM_SZ	\
189 			(REVERB_ROOM_HF_LEVEL_PARAM_LEN*sizeof(uint32_t))
190 #define REVERB_DECAY_TIME_PARAM_SZ	\
191 			(REVERB_DECAY_TIME_PARAM_LEN*sizeof(uint32_t))
192 #define REVERB_DECAY_HF_RATIO_PARAM_SZ	\
193 			(REVERB_DECAY_HF_RATIO_PARAM_LEN*sizeof(uint32_t))
194 #define REVERB_REFLECTIONS_LEVEL_PARAM_SZ	\
195 			(REVERB_REFLECTIONS_LEVEL_PARAM_LEN*sizeof(uint32_t))
196 #define REVERB_REFLECTIONS_DELAY_PARAM_SZ	\
197 			(REVERB_REFLECTIONS_DELAY_PARAM_LEN*sizeof(uint32_t))
198 #define REVERB_LEVEL_PARAM_SZ		\
199 			(REVERB_LEVEL_PARAM_LEN*sizeof(uint32_t))
200 #define REVERB_DELAY_PARAM_SZ		\
201 			(REVERB_DELAY_PARAM_LEN*sizeof(uint32_t))
202 #define REVERB_DIFFUSION_PARAM_SZ	\
203 			(REVERB_DIFFUSION_PARAM_LEN*sizeof(uint32_t))
204 #define REVERB_DENSITY_PARAM_SZ		\
205 			(REVERB_DENSITY_PARAM_LEN*sizeof(uint32_t))
206 struct reverb_params {
207 	uint32_t device;
208 	uint32_t enable_flag;
209 	uint32_t mode;
210 	uint32_t preset;
211 	uint32_t wet_mix;
212 	int32_t  gain_adjust;
213 	int32_t  room_level;
214 	int32_t  room_hf_level;
215 	uint32_t decay_time;
216 	uint32_t decay_hf_ratio;
217 	int32_t  reflections_level;
218 	uint32_t reflections_delay;
219 	int32_t  level;
220 	uint32_t delay;
221 	uint32_t diffusion;
222 	uint32_t density;
223 };
224 
225 #define BASS_BOOST_ENABLE_PARAM_SZ	\
226 			(BASS_BOOST_ENABLE_PARAM_LEN*sizeof(uint32_t))
227 #define BASS_BOOST_MODE_PARAM_SZ	\
228 			(BASS_BOOST_MODE_PARAM_LEN*sizeof(uint32_t))
229 #define BASS_BOOST_STRENGTH_PARAM_SZ	\
230 			(BASS_BOOST_STRENGTH_PARAM_LEN*sizeof(uint32_t))
231 struct bass_boost_params {
232 	uint32_t device;
233 	uint32_t enable_flag;
234 	uint32_t mode;
235 	uint32_t strength;
236 };
237 
238 
239 #define MAX_EQ_BANDS 12
240 #define MAX_OSL_EQ_BANDS 5
241 #define EQ_ENABLE_PARAM_SZ			\
242 			(EQ_ENABLE_PARAM_LEN*sizeof(uint32_t))
243 #define EQ_CONFIG_PARAM_SZ			\
244 			(EQ_CONFIG_PARAM_LEN*sizeof(uint32_t))
245 #define EQ_CONFIG_PER_BAND_PARAM_SZ		\
246 			(EQ_CONFIG_PER_BAND_PARAM_LEN*sizeof(uint32_t))
247 #define EQ_CONFIG_PARAM_MAX_LEN			(EQ_CONFIG_PARAM_LEN+\
248 			MAX_EQ_BANDS*EQ_CONFIG_PER_BAND_PARAM_LEN)
249 #define EQ_CONFIG_PARAM_MAX_SZ			\
250 			(EQ_CONFIG_PARAM_MAX_LEN*sizeof(uint32_t))
251 #define EQ_NUM_BANDS_PARAM_SZ			\
252 			(EQ_NUM_BANDS_PARAM_LEN*sizeof(uint32_t))
253 #define EQ_BAND_LEVELS_PARAM_SZ			\
254 			(EQ_BAND_LEVELS_PARAM_LEN*sizeof(uint32_t))
255 #define EQ_BAND_LEVEL_RANGE_PARAM_SZ		\
256 			(EQ_BAND_LEVEL_RANGE_PARAM_LEN*sizeof(uint32_t))
257 #define EQ_BAND_FREQS_PARAM_SZ			\
258 			(EQ_BAND_FREQS_PARAM_LEN*sizeof(uint32_t))
259 #define EQ_SINGLE_BAND_FREQ_RANGE_PARAM_SZ	\
260 			(EQ_SINGLE_BAND_FREQ_RANGE_PARAM_LEN*sizeof(uint32_t))
261 #define EQ_SINGLE_BAND_FREQ_PARAM_SZ		\
262 			(EQ_SINGLE_BAND_FREQ_PARAM_LEN*sizeof(uint32_t))
263 #define EQ_BAND_INDEX_PARAM_SZ			\
264 			(EQ_BAND_INDEX_PARAM_LEN*sizeof(uint32_t))
265 #define EQ_PRESET_ID_PARAM_SZ			\
266 			(EQ_PRESET_ID_PARAM_LEN*sizeof(uint32_t))
267 #define EQ_NUM_PRESETS_PARAM_SZ			\
268 			(EQ_NUM_PRESETS_PARAM_LEN*sizeof(uint8_t))
269 struct eq_config_t {
270 	int32_t eq_pregain;
271 	int32_t preset_id;
272 	uint32_t num_bands;
273 };
274 struct eq_per_band_config_t {
275 	int32_t band_idx;
276 	uint32_t filter_type;
277 	uint32_t freq_millihertz;
278 	int32_t  gain_millibels;
279 	uint32_t quality_factor;
280 };
281 struct eq_per_band_freq_range_t {
282 	uint32_t band_index;
283 	uint32_t min_freq_millihertz;
284 	uint32_t max_freq_millihertz;
285 };
286 
287 struct eq_params {
288 	uint32_t device;
289 	uint32_t enable_flag;
290 	struct eq_config_t config;
291 	struct eq_per_band_config_t per_band_cfg[MAX_EQ_BANDS];
292 	struct eq_per_band_freq_range_t per_band_freq_range[MAX_EQ_BANDS];
293 	uint32_t band_index;
294 	uint32_t freq_millihertz;
295 };
296 
297 #define PBE_ENABLE_PARAM_SZ	\
298 			(PBE_ENABLE_PARAM_LEN*sizeof(uint32_t))
299 #define PBE_CONFIG_PARAM_SZ	\
300 			(PBE_CONFIG_PARAM_LEN*sizeof(uint16_t))
301 struct pbe_config_t {
302 	int16_t  real_bass_mix;
303 	int16_t  bass_color_control;
304 	uint16_t main_chain_delay;
305 	uint16_t xover_filter_order;
306 	uint16_t bandpass_filter_order;
307 	int16_t  drc_delay;
308 	uint16_t rms_tav;
309 	int16_t exp_threshold;
310 	uint16_t exp_slope;
311 	int16_t comp_threshold;
312 	uint16_t comp_slope;
313 	uint16_t makeup_gain;
314 	uint32_t comp_attack;
315 	uint32_t comp_release;
316 	uint32_t exp_attack;
317 	uint32_t exp_release;
318 	int16_t limiter_bass_threshold;
319 	int16_t limiter_high_threshold;
320 	int16_t limiter_bass_makeup_gain;
321 	int16_t limiter_high_makeup_gain;
322 	int16_t limiter_bass_gc;
323 	int16_t limiter_high_gc;
324 	int16_t  limiter_delay;
325 	uint16_t reserved;
326 	/* place holder for filter coeffs to be followed */
327 	int32_t p1LowPassCoeffs[5*2];
328 	int32_t p1HighPassCoeffs[5*2];
329 	int32_t p1BandPassCoeffs[5*3];
330 	int32_t p1BassShelfCoeffs[5];
331 	int32_t p1TrebleShelfCoeffs[5];
332 } __attribute__((packed));
333 
334 struct pbe_params {
335 	uint32_t device;
336 	uint32_t enable_flag;
337 	uint32_t cfg_len;
338 	struct pbe_config_t config;
339 };
340 
341 #define SOFT_VOLUME_ENABLE_PARAM_SZ		\
342 			(SOFT_VOLUME_ENABLE_PARAM_LEN*sizeof(uint32_t))
343 #define SOFT_VOLUME_GAIN_MASTER_PARAM_SZ	\
344 			(SOFT_VOLUME_GAIN_MASTER_PARAM_LEN*sizeof(uint32_t))
345 #define SOFT_VOLUME_GAIN_2CH_PARAM_SZ		\
346 			(SOFT_VOLUME_GAIN_2CH_PARAM_LEN*sizeof(uint16_t))
347 struct soft_volume_params {
348 	uint32_t device;
349 	uint32_t enable_flag;
350 	uint32_t master_gain;
351 	uint32_t left_gain;
352 	uint32_t right_gain;
353 };
354 
355 struct msm_nt_eff_all_config {
356 	struct bass_boost_params bass_boost;
357 	struct pbe_params pbe;
358 	struct virtualizer_params virtualizer;
359 	struct reverb_params reverb;
360 	struct eq_params equalizer;
361 	struct soft_volume_params saplus_vol;
362 	struct soft_volume_params topo_switch_vol;
363 };
364 
365 #endif /*_MSM_AUDIO_EFFECTS_H*/
366