1 /* 2 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. 3 * Not a Contribution. 4 * 5 * Copyright (C) 2013 The Android Open Source Project 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 #ifndef AUDIO_EXTN_H 21 #define AUDIO_EXTN_H 22 23 #include <cutils/str_parms.h> 24 25 #ifndef PCM_OFFLOAD_ENABLED 26 #define AUDIO_FORMAT_PCM_OFFLOAD 0x17000000UL 27 #define AUDIO_FORMAT_PCM_16_BIT_OFFLOAD (AUDIO_FORMAT_PCM_OFFLOAD | AUDIO_FORMAT_PCM_SUB_16_BIT) 28 #define AUDIO_FORMAT_PCM_24_BIT_OFFLOAD (AUDIO_FORMAT_PCM_OFFLOAD | AUDIO_FORMAT_PCM_SUB_8_24_BIT) 29 #define AUDIO_OFFLOAD_CODEC_FORMAT "music_offload_codec_format" 30 #define audio_is_offload_pcm(format) (0) 31 #endif 32 33 #ifndef AFE_PROXY_ENABLED 34 #define AUDIO_DEVICE_OUT_PROXY 0x40000 35 #endif 36 37 #ifndef COMPRESS_VOIP_ENABLED 38 #define AUDIO_OUTPUT_FLAG_VOIP_RX 0x4000 39 #endif 40 41 #ifndef INCALL_MUSIC_ENABLED 42 #define AUDIO_OUTPUT_FLAG_INCALL_MUSIC 0x8000 43 #endif 44 45 #ifndef AUDIO_DEVICE_OUT_FM_TX 46 #define AUDIO_DEVICE_OUT_FM_TX 0x8000000 47 #endif 48 49 #ifndef FLAC_OFFLOAD_ENABLED 50 #define AUDIO_FORMAT_FLAC 0x1B000000UL 51 #endif 52 53 #ifndef WMA_OFFLOAD_ENABLED 54 #define AUDIO_FORMAT_WMA 0x12000000UL 55 #define AUDIO_FORMAT_WMA_PRO 0x13000000UL 56 #endif 57 58 #ifndef ALAC_OFFLOAD_ENABLED 59 #define AUDIO_FORMAT_ALAC 0x1C000000UL 60 #endif 61 62 #ifndef APE_OFFLOAD_ENABLED 63 #define AUDIO_FORMAT_APE 0x1D000000UL 64 #endif 65 66 #ifndef COMPRESS_METADATA_NEEDED 67 #define audio_extn_parse_compress_metadata(out, parms) (0) 68 #else 69 int audio_extn_parse_compress_metadata(struct stream_out *out, 70 struct str_parms *parms); 71 #endif 72 73 #ifdef PCM_OFFLOAD_ENABLED_24 74 #define PCM_OUTPUT_BIT_WIDTH (config->offload_info.bit_width) 75 #else 76 #define PCM_OUTPUT_BIT_WIDTH (CODEC_BACKEND_DEFAULT_BIT_WIDTH) 77 #endif 78 79 #define MAX_LENGTH_MIXER_CONTROL_IN_INT (128) 80 81 void audio_extn_set_parameters(struct audio_device *adev, 82 struct str_parms *parms); 83 84 void audio_extn_get_parameters(const struct audio_device *adev, 85 struct str_parms *query, 86 struct str_parms *reply); 87 88 #ifndef ANC_HEADSET_ENABLED 89 #define audio_extn_get_anc_enabled() (0) 90 #define audio_extn_should_use_fb_anc() (0) 91 #define audio_extn_should_use_handset_anc(in_channels) (0) 92 #else 93 bool audio_extn_get_anc_enabled(void); 94 bool audio_extn_should_use_fb_anc(void); 95 bool audio_extn_should_use_handset_anc(int in_channels); 96 #endif 97 98 #ifndef FLUENCE_ENABLED 99 #define audio_extn_set_fluence_parameters(adev, parms) (0) 100 #define audio_extn_get_fluence_parameters(adev, query, reply) (0) 101 #else 102 void audio_extn_set_fluence_parameters(struct audio_device *adev, 103 struct str_parms *parms); 104 int audio_extn_get_fluence_parameters(const struct audio_device *adev, 105 struct str_parms *query, struct str_parms *reply); 106 #endif 107 108 #ifndef AFE_PROXY_ENABLED 109 #define audio_extn_set_afe_proxy_channel_mixer(adev,channel_count) (0) 110 #define audio_extn_read_afe_proxy_channel_masks(out) (0) 111 #define audio_extn_get_afe_proxy_channel_count() (0) 112 #else 113 int32_t audio_extn_set_afe_proxy_channel_mixer(struct audio_device *adev, 114 int channel_count); 115 int32_t audio_extn_read_afe_proxy_channel_masks(struct stream_out *out); 116 int32_t audio_extn_get_afe_proxy_channel_count(); 117 118 #endif 119 120 #ifndef USB_HEADSET_ENABLED 121 #define audio_extn_usb_init(adev) (0) 122 #define audio_extn_usb_deinit() (0) 123 #define audio_extn_usb_start_playback(adev) (0) 124 #define audio_extn_usb_stop_playback() (0) 125 #define audio_extn_usb_start_capture(adev) (0) 126 #define audio_extn_usb_stop_capture() (0) 127 #define audio_extn_usb_set_proxy_sound_card(sndcard_idx) (0) 128 #define audio_extn_usb_is_proxy_inuse() (0) 129 #else 130 void initPlaybackVolume(); 131 void audio_extn_usb_init(void *adev); 132 void audio_extn_usb_deinit(); 133 void audio_extn_usb_start_playback(void *adev); 134 void audio_extn_usb_stop_playback(); 135 void audio_extn_usb_start_capture(void *adev); 136 void audio_extn_usb_stop_capture(); 137 void audio_extn_usb_set_proxy_sound_card(uint32_t sndcard_idx); 138 bool audio_extn_usb_is_proxy_inuse(); 139 #endif 140 141 #ifndef SPLIT_A2DP_ENABLED 142 #define audio_extn_a2dp_init() (0) 143 #define audio_extn_a2dp_start_playback() (0) 144 #define audio_extn_a2dp_stop_playback() (0) 145 #define audio_extn_a2dp_set_parameters(parms) (0) 146 #else 147 void audio_extn_a2dp_init(); 148 void audio_extn_a2dp_start_playback(); 149 void audio_extn_a2dp_stop_playback(); 150 void audio_extn_a2dp_set_parameters(struct str_parms *parms); 151 #endif 152 153 #ifndef SSR_ENABLED 154 #define audio_extn_ssr_init(in) (0) 155 #define audio_extn_ssr_deinit() (0) 156 #define audio_extn_ssr_update_enabled() (0) 157 #define audio_extn_ssr_get_enabled() (0) 158 #define audio_extn_ssr_read(stream, buffer, bytes) (0) 159 #else 160 int32_t audio_extn_ssr_init(struct stream_in *in); 161 int32_t audio_extn_ssr_deinit(); 162 void audio_extn_ssr_update_enabled(); 163 bool audio_extn_ssr_get_enabled(); 164 int32_t audio_extn_ssr_read(struct audio_stream_in *stream, 165 void *buffer, size_t bytes); 166 #endif 167 168 #ifndef HW_VARIANTS_ENABLED 169 #define hw_info_init(snd_card_name) (0) 170 #define hw_info_deinit(hw_info) (0) 171 #define hw_info_append_hw_type(hw_info,\ 172 snd_device, device_name) (0) 173 #else 174 void *hw_info_init(const char *snd_card_name); 175 void hw_info_deinit(void *hw_info); 176 void hw_info_append_hw_type(void *hw_info, snd_device_t snd_device, 177 char *device_name); 178 #endif 179 180 #ifndef AUDIO_LISTEN_ENABLED 181 #define audio_extn_listen_init(adev, snd_card) (0) 182 #define audio_extn_listen_deinit(adev) (0) 183 #define audio_extn_listen_update_device_status(snd_dev, event) (0) 184 #define audio_extn_listen_update_stream_status(uc_info, event) (0) 185 #define audio_extn_listen_set_parameters(adev, parms) (0) 186 #else 187 enum listen_event_type { 188 LISTEN_EVENT_SND_DEVICE_FREE, 189 LISTEN_EVENT_SND_DEVICE_BUSY, 190 LISTEN_EVENT_STREAM_FREE, 191 LISTEN_EVENT_STREAM_BUSY 192 }; 193 typedef enum listen_event_type listen_event_type_t; 194 195 int audio_extn_listen_init(struct audio_device *adev, unsigned int snd_card); 196 void audio_extn_listen_deinit(struct audio_device *adev); 197 void audio_extn_listen_update_device_status(snd_device_t snd_device, 198 listen_event_type_t event); 199 void audio_extn_listen_update_stream_status(struct audio_usecase *uc_info, 200 listen_event_type_t event); 201 void audio_extn_listen_set_parameters(struct audio_device *adev, 202 struct str_parms *parms); 203 #endif /* AUDIO_LISTEN_ENABLED */ 204 205 #ifndef SOUND_TRIGGER_ENABLED 206 #define audio_extn_sound_trigger_init(adev) (0) 207 #define audio_extn_sound_trigger_deinit(adev) (0) 208 #define audio_extn_sound_trigger_update_device_status(snd_dev, event) (0) 209 #define audio_extn_sound_trigger_update_stream_status(uc_info, event) (0) 210 #define audio_extn_sound_trigger_set_parameters(adev, parms) (0) 211 #define audio_extn_sound_trigger_check_and_get_session(in) (0) 212 #define audio_extn_sound_trigger_stop_lab(in) (0) 213 #else 214 215 enum st_event_type { 216 ST_EVENT_SND_DEVICE_FREE, 217 ST_EVENT_SND_DEVICE_BUSY, 218 ST_EVENT_STREAM_FREE, 219 ST_EVENT_STREAM_BUSY 220 }; 221 typedef enum st_event_type st_event_type_t; 222 223 int audio_extn_sound_trigger_init(struct audio_device *adev); 224 void audio_extn_sound_trigger_deinit(struct audio_device *adev); 225 void audio_extn_sound_trigger_update_device_status(snd_device_t snd_device, 226 st_event_type_t event); 227 void audio_extn_sound_trigger_update_stream_status(struct audio_usecase *uc_info, 228 st_event_type_t event); 229 void audio_extn_sound_trigger_set_parameters(struct audio_device *adev, 230 struct str_parms *parms); 231 void audio_extn_sound_trigger_check_and_get_session(struct stream_in *in); 232 void audio_extn_sound_trigger_stop_lab(struct stream_in *in); 233 #endif 234 235 #ifndef AUXPCM_BT_ENABLED 236 #define audio_extn_read_xml(adev, mixer_card, MIXER_XML_PATH, \ 237 MIXER_XML_PATH_AUXPCM) (-ENOSYS) 238 #else 239 int32_t audio_extn_read_xml(struct audio_device *adev, uint32_t mixer_card, 240 const char* mixer_xml_path, 241 const char* mixer_xml_path_auxpcm); 242 #endif /* AUXPCM_BT_ENABLED */ 243 #ifndef SPKR_PROT_ENABLED 244 #define audio_extn_spkr_prot_init(adev) (0) 245 #define audio_extn_spkr_prot_start_processing(snd_device) (-EINVAL) 246 #define audio_extn_spkr_prot_calib_cancel(adev) (0) 247 #define audio_extn_spkr_prot_stop_processing(snd_device) (0) 248 #define audio_extn_spkr_prot_is_enabled() (false) 249 #define audio_extn_spkr_prot_get_acdb_id(snd_device) (-EINVAL) 250 #define audio_extn_get_spkr_prot_snd_device(snd_device) (snd_device) 251 #else 252 void audio_extn_spkr_prot_init(void *adev); 253 int audio_extn_spkr_prot_start_processing(snd_device_t snd_device); 254 void audio_extn_spkr_prot_stop_processing(snd_device_t snd_device); 255 bool audio_extn_spkr_prot_is_enabled(); 256 int audio_extn_spkr_prot_get_acdb_id(snd_device_t snd_device); 257 int audio_extn_get_spkr_prot_snd_device(snd_device_t snd_device); 258 void audio_extn_spkr_prot_calib_cancel(void *adev); 259 #endif 260 261 #ifndef COMPRESS_CAPTURE_ENABLED 262 #define audio_extn_compr_cap_init(in) (0) 263 #define audio_extn_compr_cap_enabled() (0) 264 #define audio_extn_compr_cap_format_supported(format) (0) 265 #define audio_extn_compr_cap_usecase_supported(usecase) (0) 266 #define audio_extn_compr_cap_get_buffer_size(format) (0) 267 #define audio_extn_compr_cap_read(in, buffer, bytes) (0) 268 #define audio_extn_compr_cap_deinit() (0) 269 #else 270 void audio_extn_compr_cap_init(struct stream_in *in); 271 bool audio_extn_compr_cap_enabled(); 272 bool audio_extn_compr_cap_format_supported(audio_format_t format); 273 bool audio_extn_compr_cap_usecase_supported(audio_usecase_t usecase); 274 size_t audio_extn_compr_cap_get_buffer_size(audio_format_t format); 275 size_t audio_extn_compr_cap_read(struct stream_in *in, 276 void *buffer, size_t bytes); 277 void audio_extn_compr_cap_deinit(); 278 #endif 279 280 #if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS1_DOLBY_DAP_ENABLED) 281 void audio_extn_dolby_set_dmid(struct audio_device *adev); 282 #else 283 #define audio_extn_dolby_set_dmid(adev) (0) 284 #endif 285 286 287 #if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS1_DOLBY_DAP_ENABLED) || defined(DS2_DOLBY_DAP_ENABLED) 288 void audio_extn_dolby_set_license(struct audio_device *adev); 289 #else 290 #define audio_extn_dolby_set_license(adev) (0) 291 #endif 292 293 #ifndef DS1_DOLBY_DAP_ENABLED 294 #define audio_extn_dolby_set_endpoint(adev) (0) 295 #else 296 void audio_extn_dolby_set_endpoint(struct audio_device *adev); 297 #endif 298 299 300 #if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS2_DOLBY_DAP_ENABLED) 301 bool audio_extn_is_dolby_format(audio_format_t format); 302 int audio_extn_dolby_get_snd_codec_id(struct audio_device *adev, 303 struct stream_out *out, 304 audio_format_t format); 305 #else 306 #define audio_extn_is_dolby_format(format) (0) 307 #define audio_extn_dolby_get_snd_codec_id(adev, out, format) (0) 308 #endif 309 310 #ifndef DS1_DOLBY_DDP_ENABLED 311 #define audio_extn_ddp_set_parameters(adev, parms) (0) 312 #define audio_extn_dolby_send_ddp_endp_params(adev) (0) 313 #else 314 void audio_extn_ddp_set_parameters(struct audio_device *adev, 315 struct str_parms *parms); 316 void audio_extn_dolby_send_ddp_endp_params(struct audio_device *adev); 317 #endif 318 319 #ifndef HFP_ENABLED 320 #define audio_extn_hfp_is_active(adev) (0) 321 #define audio_extn_hfp_get_usecase() (-1) 322 #else 323 bool audio_extn_hfp_is_active(struct audio_device *adev); 324 audio_usecase_t audio_extn_hfp_get_usecase(); 325 #endif 326 327 #ifndef DEV_ARBI_ENABLED 328 #define audio_extn_dev_arbi_init() (0) 329 #define audio_extn_dev_arbi_deinit() (0) 330 #define audio_extn_dev_arbi_acquire(snd_device) (0) 331 #define audio_extn_dev_arbi_release(snd_device) (0) 332 #else 333 int audio_extn_dev_arbi_init(); 334 int audio_extn_dev_arbi_deinit(); 335 int audio_extn_dev_arbi_acquire(snd_device_t snd_device); 336 int audio_extn_dev_arbi_release(snd_device_t snd_device); 337 #endif 338 339 #ifndef PM_SUPPORT_ENABLED 340 #define audio_extn_pm_set_parameters(params) (0) 341 #define audio_extn_pm_vote(void) (0) 342 #define audio_extn_pm_unvote(void) (0) 343 #else 344 void audio_extn_pm_set_parameters(struct str_parms *parms); 345 int audio_extn_pm_vote (void); 346 void audio_extn_pm_unvote(void); 347 #endif 348 349 void audio_extn_utils_update_streams_output_cfg_list(void *platform, 350 struct mixer *mixer, 351 struct listnode *streams_output_cfg_list); 352 void audio_extn_utils_dump_streams_output_cfg_list( 353 struct listnode *streams_output_cfg_list); 354 void audio_extn_utils_release_streams_output_cfg_list( 355 struct listnode *streams_output_cfg_list); 356 void audio_extn_utils_update_stream_app_type_cfg(void *platform, 357 struct listnode *streams_output_cfg_list, 358 audio_devices_t devices, 359 audio_output_flags_t flags, 360 audio_format_t format, 361 uint32_t sample_rate, 362 uint32_t bit_width, 363 struct stream_app_type_cfg *app_type_cfg); 364 int audio_extn_utils_send_app_type_cfg(struct audio_usecase *usecase); 365 void audio_extn_utils_send_audio_calibration(struct audio_device *adev, 366 struct audio_usecase *usecase); 367 #ifdef DS2_DOLBY_DAP_ENABLED 368 #define LIB_DS2_DAP_HAL "vendor/lib/libhwdaphal.so" 369 #define SET_HW_INFO_FUNC "dap_hal_set_hw_info" 370 typedef enum { 371 SND_CARD = 0, 372 HW_ENDPOINT = 1, 373 DMID = 2, 374 DEVICE_BE_ID_MAP = 3, 375 DAP_BYPASS = 4, 376 } dap_hal_hw_info_t; 377 typedef int (*dap_hal_set_hw_info_t)(int32_t hw_info, void* data); 378 typedef struct { 379 int (*device_id_to_be_id)[2]; 380 int len; 381 } dap_hal_device_be_id_map_t; 382 383 int audio_extn_dap_hal_init(int snd_card); 384 int audio_extn_dap_hal_deinit(); 385 void audio_extn_dolby_ds2_set_endpoint(struct audio_device *adev); 386 int audio_extn_ds2_enable(struct audio_device *adev); 387 int audio_extn_dolby_set_dap_bypass(struct audio_device *adev, int state); 388 void audio_extn_ds2_set_parameters(struct audio_device *adev, 389 struct str_parms *parms); 390 391 #else 392 #define audio_extn_dap_hal_init(snd_card) (0) 393 #define audio_extn_dap_hal_deinit() (0) 394 #define audio_extn_dolby_ds2_set_endpoint(adev) (0) 395 #define audio_extn_ds2_enable(adev) (0) 396 #define audio_extn_dolby_set_dap_bypass(adev, state) (0) 397 #define audio_extn_ds2_set_parameters(adev, parms); (0) 398 #endif 399 typedef enum { 400 DAP_STATE_ON = 0, 401 DAP_STATE_BYPASS, 402 }; 403 #ifndef AUDIO_FORMAT_E_AC3_JOC 404 #define AUDIO_FORMAT_E_AC3_JOC 0x19000000UL 405 #endif 406 407 #ifndef AUDIO_FORMAT_DTS_LBR 408 #define AUDIO_FORMAT_DTS_LBR 0x1E000000UL 409 #endif 410 411 int read_line_from_file(const char *path, char *buf, size_t count); 412 413 #ifndef KPI_OPTIMIZE_ENABLED 414 #define audio_extn_perf_lock_init() (0) 415 #define audio_extn_perf_lock_acquire() (0) 416 #define audio_extn_perf_lock_release() (0) 417 #else 418 int audio_extn_perf_lock_init(void); 419 void audio_extn_perf_lock_acquire(void); 420 void audio_extn_perf_lock_release(void); 421 #endif /* KPI_OPTIMIZE_ENABLED */ 422 #endif /* AUDIO_EXTN_H */ 423