1 /*
2  * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 and
6  * only version 2 as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  */
13 
14 #ifndef _AUDIO_EFFECTS_H
15 #define _AUDIO_EFFECTS_H
16 
17 /** AUDIO EFFECTS **/
18 
19 
20 /* CONFIG GET/SET */
21 #define CONFIG_CACHE			0
22 #define CONFIG_SET			1
23 #define CONFIG_GET			2
24 
25 /* CONFIG HEADER */
26 /*
27 
28 	MODULE_ID,
29 	DEVICE,
30 	NUM_COMMANDS,
31 	COMMAND_ID_1,
32 	CONFIG_CACHE/SET/GET,
33 	OFFSET_1,
34 	LENGTH_1,
35 	VALUES_1,
36 	...,
37 	...,
38 	COMMAND_ID_2,
39 	CONFIG_CACHE/SET/GET,
40 	OFFSET_2,
41 	LENGTH_2,
42 	VALUES_2,
43 	...,
44 	...,
45 	COMMAND_ID_3,
46 	...
47 */
48 
49 
50 /* CONFIG PARAM IDs */
51 #define VIRTUALIZER_MODULE		0x00001000
52 #define VIRTUALIZER_ENABLE		0x00001001
53 #define VIRTUALIZER_STRENGTH		0x00001002
54 #define VIRTUALIZER_OUT_TYPE		0x00001003
55 #define VIRTUALIZER_GAIN_ADJUST		0x00001004
56 #define VIRTUALIZER_ENABLE_PARAM_LEN		1
57 #define VIRTUALIZER_STRENGTH_PARAM_LEN		1
58 #define VIRTUALIZER_OUT_TYPE_PARAM_LEN		1
59 #define VIRTUALIZER_GAIN_ADJUST_PARAM_LEN	1
60 
61 #define REVERB_MODULE			0x00002000
62 #define REVERB_ENABLE			0x00002001
63 #define REVERB_MODE			0x00002002
64 #define REVERB_PRESET			0x00002003
65 #define REVERB_WET_MIX			0x00002004
66 #define REVERB_GAIN_ADJUST		0x00002005
67 #define REVERB_ROOM_LEVEL		0x00002006
68 #define REVERB_ROOM_HF_LEVEL		0x00002007
69 #define REVERB_DECAY_TIME		0x00002008
70 #define REVERB_DECAY_HF_RATIO		0x00002009
71 #define REVERB_REFLECTIONS_LEVEL	0x0000200a
72 #define REVERB_REFLECTIONS_DELAY	0x0000200b
73 #define REVERB_LEVEL			0x0000200c
74 #define REVERB_DELAY			0x0000200d
75 #define REVERB_DIFFUSION		0x0000200e
76 #define REVERB_DENSITY			0x0000200f
77 #define REVERB_ENABLE_PARAM_LEN			1
78 #define REVERB_MODE_PARAM_LEN			1
79 #define REVERB_PRESET_PARAM_LEN			1
80 #define REVERB_WET_MIX_PARAM_LEN		1
81 #define REVERB_GAIN_ADJUST_PARAM_LEN		1
82 #define REVERB_ROOM_LEVEL_PARAM_LEN		1
83 #define REVERB_ROOM_HF_LEVEL_PARAM_LEN		1
84 #define REVERB_DECAY_TIME_PARAM_LEN		1
85 #define REVERB_DECAY_HF_RATIO_PARAM_LEN		1
86 #define REVERB_REFLECTIONS_LEVEL_PARAM_LEN	1
87 #define REVERB_REFLECTIONS_DELAY_PARAM_LEN	1
88 #define REVERB_LEVEL_PARAM_LEN			1
89 #define REVERB_DELAY_PARAM_LEN			1
90 #define REVERB_DIFFUSION_PARAM_LEN		1
91 #define REVERB_DENSITY_PARAM_LEN		1
92 
93 #define BASS_BOOST_MODULE		0x00003000
94 #define BASS_BOOST_ENABLE		0x00003001
95 #define BASS_BOOST_MODE			0x00003002
96 #define BASS_BOOST_STRENGTH		0x00003003
97 #define BASS_BOOST_ENABLE_PARAM_LEN		1
98 #define BASS_BOOST_MODE_PARAM_LEN		1
99 #define BASS_BOOST_STRENGTH_PARAM_LEN		1
100 
101 #define EQ_MODULE			0x00004000
102 #define EQ_ENABLE			0x00004001
103 #define EQ_CONFIG			0x00004002
104 #define EQ_NUM_BANDS			0x00004003
105 #define EQ_BAND_LEVELS			0x00004004
106 #define EQ_BAND_LEVEL_RANGE		0x00004005
107 #define EQ_BAND_FREQS			0x00004006
108 #define EQ_SINGLE_BAND_FREQ_RANGE	0x00004007
109 #define EQ_SINGLE_BAND_FREQ		0x00004008
110 #define EQ_BAND_INDEX			0x00004009
111 #define EQ_PRESET_ID			0x0000400a
112 #define EQ_NUM_PRESETS			0x0000400b
113 #define EQ_PRESET_NAME			0x0000400c
114 #define EQ_ENABLE_PARAM_LEN			1
115 #define EQ_CONFIG_PARAM_LEN			3
116 #define EQ_CONFIG_PER_BAND_PARAM_LEN		5
117 #define EQ_NUM_BANDS_PARAM_LEN			1
118 #define EQ_BAND_LEVELS_PARAM_LEN		13
119 #define EQ_BAND_LEVEL_RANGE_PARAM_LEN		2
120 #define EQ_BAND_FREQS_PARAM_LEN			13
121 #define EQ_SINGLE_BAND_FREQ_RANGE_PARAM_LEN	2
122 #define EQ_SINGLE_BAND_FREQ_PARAM_LEN		1
123 #define EQ_BAND_INDEX_PARAM_LEN			1
124 #define EQ_PRESET_ID_PARAM_LEN			1
125 #define EQ_NUM_PRESETS_PARAM_LEN		1
126 #define EQ_PRESET_NAME_PARAM_LEN		32
127 
128 #define EQ_TYPE_NONE	0
129 #define EQ_BASS_BOOST	1
130 #define EQ_BASS_CUT	2
131 #define EQ_TREBLE_BOOST	3
132 #define EQ_TREBLE_CUT	4
133 #define EQ_BAND_BOOST	5
134 #define EQ_BAND_CUT	6
135 
136 #define SOFT_VOLUME_MODULE		0x00006000
137 #define SOFT_VOLUME_ENABLE		0x00006001
138 #define SOFT_VOLUME_GAIN_2CH		0x00006002
139 #define SOFT_VOLUME_GAIN_MASTER		0x00006003
140 #define SOFT_VOLUME_ENABLE_PARAM_LEN		1
141 #define SOFT_VOLUME_GAIN_2CH_PARAM_LEN		2
142 #define SOFT_VOLUME_GAIN_MASTER_PARAM_LEN	1
143 
144 #define SOFT_VOLUME2_MODULE		0x00007000
145 #define SOFT_VOLUME2_ENABLE		0x00007001
146 #define SOFT_VOLUME2_GAIN_2CH		0x00007002
147 #define SOFT_VOLUME2_GAIN_MASTER	0x00007003
148 #define SOFT_VOLUME2_ENABLE_PARAM_LEN		SOFT_VOLUME_ENABLE_PARAM_LEN
149 #define SOFT_VOLUME2_GAIN_2CH_PARAM_LEN		SOFT_VOLUME_GAIN_2CH_PARAM_LEN
150 #define SOFT_VOLUME2_GAIN_MASTER_PARAM_LEN	\
151 					SOFT_VOLUME_GAIN_MASTER_PARAM_LEN
152 
153 #define COMMAND_PAYLOAD_LEN	3
154 #define COMMAND_PAYLOAD_SZ	(COMMAND_PAYLOAD_LEN * sizeof(uint32_t))
155 #define MAX_INBAND_PARAM_SZ	4096
156 #define Q27_UNITY		(1 << 27)
157 #define Q8_UNITY		(1 << 8)
158 #define CUSTOM_OPENSL_PRESET	18
159 
160 #define VIRTUALIZER_ENABLE_PARAM_SZ	\
161 			(VIRTUALIZER_ENABLE_PARAM_LEN*sizeof(uint32_t))
162 #define VIRTUALIZER_STRENGTH_PARAM_SZ	\
163 			(VIRTUALIZER_STRENGTH_PARAM_LEN*sizeof(uint32_t))
164 #define VIRTUALIZER_OUT_TYPE_PARAM_SZ	\
165 			(VIRTUALIZER_OUT_TYPE_PARAM_LEN*sizeof(uint32_t))
166 #define VIRTUALIZER_GAIN_ADJUST_PARAM_SZ	\
167 			(VIRTUALIZER_GAIN_ADJUST_PARAM_LEN*sizeof(uint32_t))
168 struct virtualizer_params {
169 	uint32_t device;
170 	uint32_t enable_flag;
171 	uint32_t strength;
172 	uint32_t out_type;
173 	int32_t gain_adjust;
174 };
175 
176 #define NUM_OSL_REVERB_PRESETS_SUPPORTED	6
177 #define REVERB_ENABLE_PARAM_SZ		\
178 			(REVERB_ENABLE_PARAM_LEN*sizeof(uint32_t))
179 #define REVERB_MODE_PARAM_SZ		\
180 			(REVERB_MODE_PARAM_LEN*sizeof(uint32_t))
181 #define REVERB_PRESET_PARAM_SZ		\
182 			(REVERB_PRESET_PARAM_LEN*sizeof(uint32_t))
183 #define REVERB_WET_MIX_PARAM_SZ		\
184 			(REVERB_WET_MIX_PARAM_LEN*sizeof(uint32_t))
185 #define REVERB_GAIN_ADJUST_PARAM_SZ	\
186 			(REVERB_GAIN_ADJUST_PARAM_LEN*sizeof(uint32_t))
187 #define REVERB_ROOM_LEVEL_PARAM_SZ	\
188 			(REVERB_ROOM_LEVEL_PARAM_LEN*sizeof(uint32_t))
189 #define REVERB_ROOM_HF_LEVEL_PARAM_SZ	\
190 			(REVERB_ROOM_HF_LEVEL_PARAM_LEN*sizeof(uint32_t))
191 #define REVERB_DECAY_TIME_PARAM_SZ	\
192 			(REVERB_DECAY_TIME_PARAM_LEN*sizeof(uint32_t))
193 #define REVERB_DECAY_HF_RATIO_PARAM_SZ	\
194 			(REVERB_DECAY_HF_RATIO_PARAM_LEN*sizeof(uint32_t))
195 #define REVERB_REFLECTIONS_LEVEL_PARAM_SZ	\
196 			(REVERB_REFLECTIONS_LEVEL_PARAM_LEN*sizeof(uint32_t))
197 #define REVERB_REFLECTIONS_DELAY_PARAM_SZ	\
198 			(REVERB_REFLECTIONS_DELAY_PARAM_LEN*sizeof(uint32_t))
199 #define REVERB_LEVEL_PARAM_SZ		\
200 			(REVERB_LEVEL_PARAM_LEN*sizeof(uint32_t))
201 #define REVERB_DELAY_PARAM_SZ		\
202 			(REVERB_DELAY_PARAM_LEN*sizeof(uint32_t))
203 #define REVERB_DIFFUSION_PARAM_SZ	\
204 			(REVERB_DIFFUSION_PARAM_LEN*sizeof(uint32_t))
205 #define REVERB_DENSITY_PARAM_SZ		\
206 			(REVERB_DENSITY_PARAM_LEN*sizeof(uint32_t))
207 struct reverb_params {
208 	uint32_t device;
209 	uint32_t enable_flag;
210 	uint32_t mode;
211 	uint32_t preset;
212 	uint32_t wet_mix;
213 	int32_t  gain_adjust;
214 	int32_t  room_level;
215 	int32_t  room_hf_level;
216 	uint32_t decay_time;
217 	uint32_t decay_hf_ratio;
218 	int32_t  reflections_level;
219 	uint32_t reflections_delay;
220 	int32_t  level;
221 	uint32_t delay;
222 	uint32_t diffusion;
223 	uint32_t density;
224 };
225 
226 #define BASS_BOOST_ENABLE_PARAM_SZ	\
227 			(BASS_BOOST_ENABLE_PARAM_LEN*sizeof(uint32_t))
228 #define BASS_BOOST_MODE_PARAM_SZ	\
229 			(BASS_BOOST_MODE_PARAM_LEN*sizeof(uint32_t))
230 #define BASS_BOOST_STRENGTH_PARAM_SZ	\
231 			(BASS_BOOST_STRENGTH_PARAM_LEN*sizeof(uint32_t))
232 struct bass_boost_params {
233 	uint32_t device;
234 	uint32_t enable_flag;
235 	uint32_t mode;
236 	uint32_t strength;
237 };
238 
239 
240 #define MAX_EQ_BANDS 12
241 #define MAX_OSL_EQ_BANDS 5
242 #define EQ_ENABLE_PARAM_SZ			\
243 			(EQ_ENABLE_PARAM_LEN*sizeof(uint32_t))
244 #define EQ_CONFIG_PARAM_SZ			\
245 			(EQ_CONFIG_PARAM_LEN*sizeof(uint32_t))
246 #define EQ_CONFIG_PER_BAND_PARAM_SZ		\
247 			(EQ_CONFIG_PER_BAND_PARAM_LEN*sizeof(uint32_t))
248 #define EQ_CONFIG_PARAM_MAX_LEN			(EQ_CONFIG_PARAM_LEN+\
249 			MAX_EQ_BANDS*EQ_CONFIG_PER_BAND_PARAM_LEN)
250 #define EQ_CONFIG_PARAM_MAX_SZ			\
251 			(EQ_CONFIG_PARAM_MAX_LEN*sizeof(uint32_t))
252 #define EQ_NUM_BANDS_PARAM_SZ			\
253 			(EQ_NUM_BANDS_PARAM_LEN*sizeof(uint32_t))
254 #define EQ_BAND_LEVELS_PARAM_SZ			\
255 			(EQ_BAND_LEVELS_PARAM_LEN*sizeof(uint32_t))
256 #define EQ_BAND_LEVEL_RANGE_PARAM_SZ		\
257 			(EQ_BAND_LEVEL_RANGE_PARAM_LEN*sizeof(uint32_t))
258 #define EQ_BAND_FREQS_PARAM_SZ			\
259 			(EQ_BAND_FREQS_PARAM_LEN*sizeof(uint32_t))
260 #define EQ_SINGLE_BAND_FREQ_RANGE_PARAM_SZ	\
261 			(EQ_SINGLE_BAND_FREQ_RANGE_PARAM_LEN*sizeof(uint32_t))
262 #define EQ_SINGLE_BAND_FREQ_PARAM_SZ		\
263 			(EQ_SINGLE_BAND_FREQ_PARAM_LEN*sizeof(uint32_t))
264 #define EQ_BAND_INDEX_PARAM_SZ			\
265 			(EQ_BAND_INDEX_PARAM_LEN*sizeof(uint32_t))
266 #define EQ_PRESET_ID_PARAM_SZ			\
267 			(EQ_PRESET_ID_PARAM_LEN*sizeof(uint32_t))
268 #define EQ_NUM_PRESETS_PARAM_SZ			\
269 			(EQ_NUM_PRESETS_PARAM_LEN*sizeof(uint8_t))
270 struct eq_config_t {
271 	int32_t eq_pregain;
272 	int32_t preset_id;
273 	uint32_t num_bands;
274 };
275 struct eq_per_band_config_t {
276 	int32_t band_idx;
277 	uint32_t filter_type;
278 	uint32_t freq_millihertz;
279 	int32_t  gain_millibels;
280 	uint32_t quality_factor;
281 };
282 struct eq_per_band_freq_range_t {
283 	uint32_t band_index;
284 	uint32_t min_freq_millihertz;
285 	uint32_t max_freq_millihertz;
286 };
287 
288 struct eq_params {
289 	uint32_t device;
290 	uint32_t enable_flag;
291 	struct eq_config_t config;
292 	struct eq_per_band_config_t per_band_cfg[MAX_EQ_BANDS];
293 	struct eq_per_band_freq_range_t per_band_freq_range[MAX_EQ_BANDS];
294 	uint32_t band_index;
295 	uint32_t freq_millihertz;
296 };
297 
298 #define SOFT_VOLUME_ENABLE_PARAM_SZ		\
299 			(SOFT_VOLUME_ENABLE_PARAM_LEN*sizeof(uint32_t))
300 #define SOFT_VOLUME_GAIN_MASTER_PARAM_SZ	\
301 			(SOFT_VOLUME_GAIN_MASTER_PARAM_LEN*sizeof(uint32_t))
302 #define SOFT_VOLUME_GAIN_2CH_PARAM_SZ		\
303 			(SOFT_VOLUME_GAIN_2CH_PARAM_LEN*sizeof(uint16_t))
304 struct soft_volume_params {
305 	uint32_t device;
306 	uint32_t enable_flag;
307 	uint32_t master_gain;
308 	uint32_t left_gain;
309 	uint32_t right_gain;
310 };
311 
312 struct msm_nt_eff_all_config {
313 	struct bass_boost_params bass_boost;
314 	struct virtualizer_params virtualizer;
315 	struct reverb_params reverb;
316 	struct eq_params equalizer;
317 	struct soft_volume_params saplus_vol;
318 	struct soft_volume_params topo_switch_vol;
319 };
320 
321 #endif /*_MSM_AUDIO_EFFECTS_H*/
322