audio_effects.h 11 KB

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