audio_effects.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*
  2. * Copyright (c) 2013, 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. #ifndef _AUDIO_EFFECTS_H
  14. #define _AUDIO_EFFECTS_H
  15. /** AUDIO EFFECTS **/
  16. /* CONFIG GET/SET */
  17. #define CONFIG_CACHE 0
  18. #define CONFIG_SET 1
  19. #define CONFIG_GET 2
  20. /* CONFIG HEADER */
  21. /*
  22. MODULE_ID,
  23. DEVICE,
  24. NUM_COMMANDS,
  25. COMMAND_ID_1,
  26. CONFIG_CACHE/SET/GET,
  27. OFFSET_1,
  28. LENGTH_1,
  29. VALUES_1,
  30. ...,
  31. ...,
  32. COMMAND_ID_2,
  33. CONFIG_CACHE/SET/GET,
  34. OFFSET_2,
  35. LENGTH_2,
  36. VALUES_2,
  37. ...,
  38. ...,
  39. COMMAND_ID_3,
  40. ...
  41. */
  42. /* CONFIG PARAM IDs */
  43. #define VIRTUALIZER_MODULE 0x00001000
  44. #define VIRTUALIZER_ENABLE 0x00001001
  45. #define VIRTUALIZER_STRENGTH 0x00001002
  46. #define VIRTUALIZER_OUT_TYPE 0x00001003
  47. #define VIRTUALIZER_GAIN_ADJUST 0x00001004
  48. #define VIRTUALIZER_ENABLE_PARAM_LEN 1
  49. #define VIRTUALIZER_STRENGTH_PARAM_LEN 1
  50. #define VIRTUALIZER_OUT_TYPE_PARAM_LEN 1
  51. #define VIRTUALIZER_GAIN_ADJUST_PARAM_LEN 1
  52. #define REVERB_MODULE 0x00002000
  53. #define REVERB_ENABLE 0x00002001
  54. #define REVERB_MODE 0x00002002
  55. #define REVERB_PRESET 0x00002003
  56. #define REVERB_WET_MIX 0x00002004
  57. #define REVERB_GAIN_ADJUST 0x00002005
  58. #define REVERB_ROOM_LEVEL 0x00002006
  59. #define REVERB_ROOM_HF_LEVEL 0x00002007
  60. #define REVERB_DECAY_TIME 0x00002008
  61. #define REVERB_DECAY_HF_RATIO 0x00002009
  62. #define REVERB_REFLECTIONS_LEVEL 0x0000200a
  63. #define REVERB_REFLECTIONS_DELAY 0x0000200b
  64. #define REVERB_LEVEL 0x0000200c
  65. #define REVERB_DELAY 0x0000200d
  66. #define REVERB_DIFFUSION 0x0000200e
  67. #define REVERB_DENSITY 0x0000200f
  68. #define REVERB_ENABLE_PARAM_LEN 1
  69. #define REVERB_MODE_PARAM_LEN 1
  70. #define REVERB_PRESET_PARAM_LEN 1
  71. #define REVERB_WET_MIX_PARAM_LEN 1
  72. #define REVERB_GAIN_ADJUST_PARAM_LEN 1
  73. #define REVERB_ROOM_LEVEL_PARAM_LEN 1
  74. #define REVERB_ROOM_HF_LEVEL_PARAM_LEN 1
  75. #define REVERB_DECAY_TIME_PARAM_LEN 1
  76. #define REVERB_DECAY_HF_RATIO_PARAM_LEN 1
  77. #define REVERB_REFLECTIONS_LEVEL_PARAM_LEN 1
  78. #define REVERB_REFLECTIONS_DELAY_PARAM_LEN 1
  79. #define REVERB_LEVEL_PARAM_LEN 1
  80. #define REVERB_DELAY_PARAM_LEN 1
  81. #define REVERB_DIFFUSION_PARAM_LEN 1
  82. #define REVERB_DENSITY_PARAM_LEN 1
  83. #define BASS_BOOST_MODULE 0x00003000
  84. #define BASS_BOOST_ENABLE 0x00003001
  85. #define BASS_BOOST_MODE 0x00003002
  86. #define BASS_BOOST_STRENGTH 0x00003003
  87. #define BASS_BOOST_ENABLE_PARAM_LEN 1
  88. #define BASS_BOOST_MODE_PARAM_LEN 1
  89. #define BASS_BOOST_STRENGTH_PARAM_LEN 1
  90. #define EQ_MODULE 0x00004000
  91. #define EQ_ENABLE 0x00004001
  92. #define EQ_CONFIG 0x00004002
  93. #define EQ_NUM_BANDS 0x00004003
  94. #define EQ_BAND_LEVELS 0x00004004
  95. #define EQ_BAND_LEVEL_RANGE 0x00004005
  96. #define EQ_BAND_FREQS 0x00004006
  97. #define EQ_SINGLE_BAND_FREQ_RANGE 0x00004007
  98. #define EQ_SINGLE_BAND_FREQ 0x00004008
  99. #define EQ_BAND_INDEX 0x00004009
  100. #define EQ_PRESET_ID 0x0000400a
  101. #define EQ_NUM_PRESETS 0x0000400b
  102. #define EQ_PRESET_NAME 0x0000400c
  103. #define EQ_ENABLE_PARAM_LEN 1
  104. #define EQ_CONFIG_PARAM_LEN 3
  105. #define EQ_CONFIG_PER_BAND_PARAM_LEN 5
  106. #define EQ_NUM_BANDS_PARAM_LEN 1
  107. #define EQ_BAND_LEVELS_PARAM_LEN 13
  108. #define EQ_BAND_LEVEL_RANGE_PARAM_LEN 2
  109. #define EQ_BAND_FREQS_PARAM_LEN 13
  110. #define EQ_SINGLE_BAND_FREQ_RANGE_PARAM_LEN 2
  111. #define EQ_SINGLE_BAND_FREQ_PARAM_LEN 1
  112. #define EQ_BAND_INDEX_PARAM_LEN 1
  113. #define EQ_PRESET_ID_PARAM_LEN 1
  114. #define EQ_NUM_PRESETS_PARAM_LEN 1
  115. #define EQ_PRESET_NAME_PARAM_LEN 32
  116. #define EQ_TYPE_NONE 0
  117. #define EQ_BASS_BOOST 1
  118. #define EQ_BASS_CUT 2
  119. #define EQ_TREBLE_BOOST 3
  120. #define EQ_TREBLE_CUT 4
  121. #define EQ_BAND_BOOST 5
  122. #define EQ_BAND_CUT 6
  123. #define COMMAND_PAYLOAD_LEN 3
  124. #define COMMAND_PAYLOAD_SZ (COMMAND_PAYLOAD_LEN * sizeof(uint32_t))
  125. #define MAX_INBAND_PARAM_SZ 4096
  126. #define Q27_UNITY (1 << 27)
  127. #define Q8_UNITY (1 << 8)
  128. #define CUSTOM_OPENSL_PRESET 18
  129. #define VIRTUALIZER_ENABLE_PARAM_SZ \
  130. (VIRTUALIZER_ENABLE_PARAM_LEN*sizeof(uint32_t))
  131. #define VIRTUALIZER_STRENGTH_PARAM_SZ \
  132. (VIRTUALIZER_STRENGTH_PARAM_LEN*sizeof(uint32_t))
  133. #define VIRTUALIZER_OUT_TYPE_PARAM_SZ \
  134. (VIRTUALIZER_OUT_TYPE_PARAM_LEN*sizeof(uint32_t))
  135. #define VIRTUALIZER_GAIN_ADJUST_PARAM_SZ \
  136. (VIRTUALIZER_GAIN_ADJUST_PARAM_LEN*sizeof(uint32_t))
  137. struct virtualizer_params {
  138. uint32_t device;
  139. uint32_t enable_flag;
  140. uint32_t strength;
  141. uint32_t out_type;
  142. int32_t gain_adjust;
  143. };
  144. #define NUM_OSL_REVERB_PRESETS_SUPPORTED 6
  145. #define REVERB_ENABLE_PARAM_SZ \
  146. (REVERB_ENABLE_PARAM_LEN*sizeof(uint32_t))
  147. #define REVERB_MODE_PARAM_SZ \
  148. (REVERB_MODE_PARAM_LEN*sizeof(uint32_t))
  149. #define REVERB_PRESET_PARAM_SZ \
  150. (REVERB_PRESET_PARAM_LEN*sizeof(uint32_t))
  151. #define REVERB_WET_MIX_PARAM_SZ \
  152. (REVERB_WET_MIX_PARAM_LEN*sizeof(uint32_t))
  153. #define REVERB_GAIN_ADJUST_PARAM_SZ \
  154. (REVERB_GAIN_ADJUST_PARAM_LEN*sizeof(uint32_t))
  155. #define REVERB_ROOM_LEVEL_PARAM_SZ \
  156. (REVERB_ROOM_LEVEL_PARAM_LEN*sizeof(uint32_t))
  157. #define REVERB_ROOM_HF_LEVEL_PARAM_SZ \
  158. (REVERB_ROOM_HF_LEVEL_PARAM_LEN*sizeof(uint32_t))
  159. #define REVERB_DECAY_TIME_PARAM_SZ \
  160. (REVERB_DECAY_TIME_PARAM_LEN*sizeof(uint32_t))
  161. #define REVERB_DECAY_HF_RATIO_PARAM_SZ \
  162. (REVERB_DECAY_HF_RATIO_PARAM_LEN*sizeof(uint32_t))
  163. #define REVERB_REFLECTIONS_LEVEL_PARAM_SZ \
  164. (REVERB_REFLECTIONS_LEVEL_PARAM_LEN*sizeof(uint32_t))
  165. #define REVERB_REFLECTIONS_DELAY_PARAM_SZ \
  166. (REVERB_REFLECTIONS_DELAY_PARAM_LEN*sizeof(uint32_t))
  167. #define REVERB_LEVEL_PARAM_SZ \
  168. (REVERB_LEVEL_PARAM_LEN*sizeof(uint32_t))
  169. #define REVERB_DELAY_PARAM_SZ \
  170. (REVERB_DELAY_PARAM_LEN*sizeof(uint32_t))
  171. #define REVERB_DIFFUSION_PARAM_SZ \
  172. (REVERB_DIFFUSION_PARAM_LEN*sizeof(uint32_t))
  173. #define REVERB_DENSITY_PARAM_SZ \
  174. (REVERB_DENSITY_PARAM_LEN*sizeof(uint32_t))
  175. struct reverb_params {
  176. uint32_t device;
  177. uint32_t enable_flag;
  178. uint32_t mode;
  179. uint32_t preset;
  180. uint32_t wet_mix;
  181. int32_t gain_adjust;
  182. int32_t room_level;
  183. int32_t room_hf_level;
  184. uint32_t decay_time;
  185. uint32_t decay_hf_ratio;
  186. int32_t reflections_level;
  187. uint32_t reflections_delay;
  188. int32_t level;
  189. uint32_t delay;
  190. uint32_t diffusion;
  191. uint32_t density;
  192. };
  193. #define BASS_BOOST_ENABLE_PARAM_SZ \
  194. (BASS_BOOST_ENABLE_PARAM_LEN*sizeof(uint32_t))
  195. #define BASS_BOOST_MODE_PARAM_SZ \
  196. (BASS_BOOST_MODE_PARAM_LEN*sizeof(uint32_t))
  197. #define BASS_BOOST_STRENGTH_PARAM_SZ \
  198. (BASS_BOOST_STRENGTH_PARAM_LEN*sizeof(uint32_t))
  199. struct bass_boost_params {
  200. uint32_t device;
  201. uint32_t enable_flag;
  202. uint32_t mode;
  203. uint32_t strength;
  204. };
  205. #define MAX_EQ_BANDS 12
  206. #define MAX_OSL_EQ_BANDS 5
  207. #define EQ_ENABLE_PARAM_SZ \
  208. (EQ_ENABLE_PARAM_LEN*sizeof(uint32_t))
  209. #define EQ_CONFIG_PARAM_SZ \
  210. (EQ_CONFIG_PARAM_LEN*sizeof(uint32_t))
  211. #define EQ_CONFIG_PER_BAND_PARAM_SZ \
  212. (EQ_CONFIG_PER_BAND_PARAM_LEN*sizeof(uint32_t))
  213. #define EQ_CONFIG_PARAM_MAX_LEN (EQ_CONFIG_PARAM_LEN+\
  214. MAX_EQ_BANDS*EQ_CONFIG_PER_BAND_PARAM_LEN)
  215. #define EQ_CONFIG_PARAM_MAX_SZ \
  216. (EQ_CONFIG_PARAM_MAX_LEN*sizeof(uint32_t))
  217. #define EQ_NUM_BANDS_PARAM_SZ \
  218. (EQ_NUM_BANDS_PARAM_LEN*sizeof(uint32_t))
  219. #define EQ_BAND_LEVELS_PARAM_SZ \
  220. (EQ_BAND_LEVELS_PARAM_LEN*sizeof(uint32_t))
  221. #define EQ_BAND_LEVEL_RANGE_PARAM_SZ \
  222. (EQ_BAND_LEVEL_RANGE_PARAM_LEN*sizeof(uint32_t))
  223. #define EQ_BAND_FREQS_PARAM_SZ \
  224. (EQ_BAND_FREQS_PARAM_LEN*sizeof(uint32_t))
  225. #define EQ_SINGLE_BAND_FREQ_RANGE_PARAM_SZ \
  226. (EQ_SINGLE_BAND_FREQ_RANGE_PARAM_LEN*sizeof(uint32_t))
  227. #define EQ_SINGLE_BAND_FREQ_PARAM_SZ \
  228. (EQ_SINGLE_BAND_FREQ_PARAM_LEN*sizeof(uint32_t))
  229. #define EQ_BAND_INDEX_PARAM_SZ \
  230. (EQ_BAND_INDEX_PARAM_LEN*sizeof(uint32_t))
  231. #define EQ_PRESET_ID_PARAM_SZ \
  232. (EQ_PRESET_ID_PARAM_LEN*sizeof(uint32_t))
  233. #define EQ_NUM_PRESETS_PARAM_SZ \
  234. (EQ_NUM_PRESETS_PARAM_LEN*sizeof(uint8_t))
  235. struct eq_config_t {
  236. int32_t eq_pregain;
  237. int32_t preset_id;
  238. uint32_t num_bands;
  239. };
  240. struct eq_per_band_config_t {
  241. int32_t band_idx;
  242. uint32_t filter_type;
  243. uint32_t freq_millihertz;
  244. int32_t gain_millibels;
  245. uint32_t quality_factor;
  246. };
  247. struct eq_per_band_freq_range_t {
  248. uint32_t band_index;
  249. uint32_t min_freq_millihertz;
  250. uint32_t max_freq_millihertz;
  251. };
  252. struct eq_params {
  253. uint32_t device;
  254. uint32_t enable_flag;
  255. struct eq_config_t config;
  256. struct eq_per_band_config_t per_band_cfg[MAX_EQ_BANDS];
  257. struct eq_per_band_freq_range_t per_band_freq_range[MAX_EQ_BANDS];
  258. uint32_t band_index;
  259. uint32_t freq_millihertz;
  260. };
  261. #endif /*_MSM_AUDIO_EFFECTS_H*/