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 137 138 #define COMMAND_PAYLOAD_LEN 3 139 #define COMMAND_PAYLOAD_SZ (COMMAND_PAYLOAD_LEN * sizeof(uint32_t)) 140 #define MAX_INBAND_PARAM_SZ 4096 141 #define Q27_UNITY (1 << 27) 142 #define Q8_UNITY (1 << 8) 143 #define CUSTOM_OPENSL_PRESET 18 144 145 #define VIRTUALIZER_ENABLE_PARAM_SZ \ 146 (VIRTUALIZER_ENABLE_PARAM_LEN*sizeof(uint32_t)) 147 #define VIRTUALIZER_STRENGTH_PARAM_SZ \ 148 (VIRTUALIZER_STRENGTH_PARAM_LEN*sizeof(uint32_t)) 149 #define VIRTUALIZER_OUT_TYPE_PARAM_SZ \ 150 (VIRTUALIZER_OUT_TYPE_PARAM_LEN*sizeof(uint32_t)) 151 #define VIRTUALIZER_GAIN_ADJUST_PARAM_SZ \ 152 (VIRTUALIZER_GAIN_ADJUST_PARAM_LEN*sizeof(uint32_t)) 153 struct virtualizer_params { 154 uint32_t device; 155 uint32_t enable_flag; 156 uint32_t strength; 157 uint32_t out_type; 158 int32_t gain_adjust; 159 }; 160 161 #define NUM_OSL_REVERB_PRESETS_SUPPORTED 6 162 #define REVERB_ENABLE_PARAM_SZ \ 163 (REVERB_ENABLE_PARAM_LEN*sizeof(uint32_t)) 164 #define REVERB_MODE_PARAM_SZ \ 165 (REVERB_MODE_PARAM_LEN*sizeof(uint32_t)) 166 #define REVERB_PRESET_PARAM_SZ \ 167 (REVERB_PRESET_PARAM_LEN*sizeof(uint32_t)) 168 #define REVERB_WET_MIX_PARAM_SZ \ 169 (REVERB_WET_MIX_PARAM_LEN*sizeof(uint32_t)) 170 #define REVERB_GAIN_ADJUST_PARAM_SZ \ 171 (REVERB_GAIN_ADJUST_PARAM_LEN*sizeof(uint32_t)) 172 #define REVERB_ROOM_LEVEL_PARAM_SZ \ 173 (REVERB_ROOM_LEVEL_PARAM_LEN*sizeof(uint32_t)) 174 #define REVERB_ROOM_HF_LEVEL_PARAM_SZ \ 175 (REVERB_ROOM_HF_LEVEL_PARAM_LEN*sizeof(uint32_t)) 176 #define REVERB_DECAY_TIME_PARAM_SZ \ 177 (REVERB_DECAY_TIME_PARAM_LEN*sizeof(uint32_t)) 178 #define REVERB_DECAY_HF_RATIO_PARAM_SZ \ 179 (REVERB_DECAY_HF_RATIO_PARAM_LEN*sizeof(uint32_t)) 180 #define REVERB_REFLECTIONS_LEVEL_PARAM_SZ \ 181 (REVERB_REFLECTIONS_LEVEL_PARAM_LEN*sizeof(uint32_t)) 182 #define REVERB_REFLECTIONS_DELAY_PARAM_SZ \ 183 (REVERB_REFLECTIONS_DELAY_PARAM_LEN*sizeof(uint32_t)) 184 #define REVERB_LEVEL_PARAM_SZ \ 185 (REVERB_LEVEL_PARAM_LEN*sizeof(uint32_t)) 186 #define REVERB_DELAY_PARAM_SZ \ 187 (REVERB_DELAY_PARAM_LEN*sizeof(uint32_t)) 188 #define REVERB_DIFFUSION_PARAM_SZ \ 189 (REVERB_DIFFUSION_PARAM_LEN*sizeof(uint32_t)) 190 #define REVERB_DENSITY_PARAM_SZ \ 191 (REVERB_DENSITY_PARAM_LEN*sizeof(uint32_t)) 192 struct reverb_params { 193 uint32_t device; 194 uint32_t enable_flag; 195 uint32_t mode; 196 uint32_t preset; 197 uint32_t wet_mix; 198 int32_t gain_adjust; 199 int32_t room_level; 200 int32_t room_hf_level; 201 uint32_t decay_time; 202 uint32_t decay_hf_ratio; 203 int32_t reflections_level; 204 uint32_t reflections_delay; 205 int32_t level; 206 uint32_t delay; 207 uint32_t diffusion; 208 uint32_t density; 209 }; 210 211 #define BASS_BOOST_ENABLE_PARAM_SZ \ 212 (BASS_BOOST_ENABLE_PARAM_LEN*sizeof(uint32_t)) 213 #define BASS_BOOST_MODE_PARAM_SZ \ 214 (BASS_BOOST_MODE_PARAM_LEN*sizeof(uint32_t)) 215 #define BASS_BOOST_STRENGTH_PARAM_SZ \ 216 (BASS_BOOST_STRENGTH_PARAM_LEN*sizeof(uint32_t)) 217 struct bass_boost_params { 218 uint32_t device; 219 uint32_t enable_flag; 220 uint32_t mode; 221 uint32_t strength; 222 }; 223 224 225 #define MAX_EQ_BANDS 12 226 #define MAX_OSL_EQ_BANDS 5 227 #define EQ_ENABLE_PARAM_SZ \ 228 (EQ_ENABLE_PARAM_LEN*sizeof(uint32_t)) 229 #define EQ_CONFIG_PARAM_SZ \ 230 (EQ_CONFIG_PARAM_LEN*sizeof(uint32_t)) 231 #define EQ_CONFIG_PER_BAND_PARAM_SZ \ 232 (EQ_CONFIG_PER_BAND_PARAM_LEN*sizeof(uint32_t)) 233 #define EQ_CONFIG_PARAM_MAX_LEN (EQ_CONFIG_PARAM_LEN+\ 234 MAX_EQ_BANDS*EQ_CONFIG_PER_BAND_PARAM_LEN) 235 #define EQ_CONFIG_PARAM_MAX_SZ \ 236 (EQ_CONFIG_PARAM_MAX_LEN*sizeof(uint32_t)) 237 #define EQ_NUM_BANDS_PARAM_SZ \ 238 (EQ_NUM_BANDS_PARAM_LEN*sizeof(uint32_t)) 239 #define EQ_BAND_LEVELS_PARAM_SZ \ 240 (EQ_BAND_LEVELS_PARAM_LEN*sizeof(uint32_t)) 241 #define EQ_BAND_LEVEL_RANGE_PARAM_SZ \ 242 (EQ_BAND_LEVEL_RANGE_PARAM_LEN*sizeof(uint32_t)) 243 #define EQ_BAND_FREQS_PARAM_SZ \ 244 (EQ_BAND_FREQS_PARAM_LEN*sizeof(uint32_t)) 245 #define EQ_SINGLE_BAND_FREQ_RANGE_PARAM_SZ \ 246 (EQ_SINGLE_BAND_FREQ_RANGE_PARAM_LEN*sizeof(uint32_t)) 247 #define EQ_SINGLE_BAND_FREQ_PARAM_SZ \ 248 (EQ_SINGLE_BAND_FREQ_PARAM_LEN*sizeof(uint32_t)) 249 #define EQ_BAND_INDEX_PARAM_SZ \ 250 (EQ_BAND_INDEX_PARAM_LEN*sizeof(uint32_t)) 251 #define EQ_PRESET_ID_PARAM_SZ \ 252 (EQ_PRESET_ID_PARAM_LEN*sizeof(uint32_t)) 253 #define EQ_NUM_PRESETS_PARAM_SZ \ 254 (EQ_NUM_PRESETS_PARAM_LEN*sizeof(uint8_t)) 255 struct eq_config_t { 256 int32_t eq_pregain; 257 int32_t preset_id; 258 uint32_t num_bands; 259 }; 260 struct eq_per_band_config_t { 261 int32_t band_idx; 262 uint32_t filter_type; 263 uint32_t freq_millihertz; 264 int32_t gain_millibels; 265 uint32_t quality_factor; 266 }; 267 struct eq_per_band_freq_range_t { 268 uint32_t band_index; 269 uint32_t min_freq_millihertz; 270 uint32_t max_freq_millihertz; 271 }; 272 273 struct eq_params { 274 uint32_t device; 275 uint32_t enable_flag; 276 struct eq_config_t config; 277 struct eq_per_band_config_t per_band_cfg[MAX_EQ_BANDS]; 278 struct eq_per_band_freq_range_t per_band_freq_range[MAX_EQ_BANDS]; 279 uint32_t band_index; 280 uint32_t freq_millihertz; 281 }; 282 283 #endif /*_MSM_AUDIO_EFFECTS_H*/ 284