1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef AUDIO_EXTN_H 18 #define AUDIO_EXTN_H 19 20 #include <cutils/str_parms.h> 21 22 #define HW_INFO_ARRAY_MAX_SIZE 32 23 24 struct snd_card_split { 25 char device[HW_INFO_ARRAY_MAX_SIZE]; 26 char snd_card[HW_INFO_ARRAY_MAX_SIZE]; 27 char form_factor[HW_INFO_ARRAY_MAX_SIZE]; 28 }; 29 30 void *audio_extn_extspk_init(struct audio_device *adev); 31 void audio_extn_extspk_deinit(void *extn); 32 void audio_extn_extspk_update(void* extn); 33 void audio_extn_extspk_set_mode(void* extn, audio_mode_t mode); 34 void audio_extn_extspk_set_voice_vol(void* extn, float vol); 35 struct snd_card_split *audio_extn_get_snd_card_split(); 36 void audio_extn_set_snd_card_split(const char* in_snd_card_name); 37 38 #ifndef SPKR_PROT_ENABLED 39 #define audio_extn_spkr_prot_init(adev) (0) 40 #define audio_extn_spkr_prot_start_processing(snd_device) (-EINVAL) 41 #define audio_extn_spkr_prot_calib_cancel(adev) (0) 42 #define audio_extn_spkr_prot_stop_processing(snd_device) (0) 43 #define audio_extn_spkr_prot_is_enabled() (false) 44 #define audio_extn_spkr_prot_get_acdb_id(snd_device) (-EINVAL) 45 #define audio_extn_get_spkr_prot_snd_device(snd_device) (snd_device) 46 #else 47 void audio_extn_spkr_prot_init(void *adev); 48 int audio_extn_spkr_prot_start_processing(snd_device_t snd_device); 49 void audio_extn_spkr_prot_stop_processing(snd_device_t snd_device); 50 bool audio_extn_spkr_prot_is_enabled(); 51 int audio_extn_spkr_prot_get_acdb_id(snd_device_t snd_device); 52 int audio_extn_get_spkr_prot_snd_device(snd_device_t snd_device); 53 void audio_extn_spkr_prot_calib_cancel(void *adev); 54 #endif 55 56 #ifndef HFP_ENABLED 57 #define audio_extn_hfp_is_active(adev) (0) 58 #define audio_extn_hfp_get_usecase() (-1) 59 #define audio_extn_hfp_set_parameters(adev, params) (0) 60 #define audio_extn_hfp_set_mic_mute(adev, state) (0) 61 62 #else 63 bool audio_extn_hfp_is_active(struct audio_device *adev); 64 65 audio_usecase_t audio_extn_hfp_get_usecase(); 66 67 void audio_extn_hfp_set_parameters(struct audio_device *adev, 68 struct str_parms *parms); 69 int audio_extn_hfp_set_mic_mute(struct audio_device *adev, bool state); 70 71 #endif 72 73 #ifndef USB_TUNNEL_ENABLED 74 #define audio_extn_usb_init(adev) (0) 75 #define audio_extn_usb_deinit() (0) 76 #define audio_extn_usb_add_device(device, card) (0) 77 #define audio_extn_usb_remove_device(device, card) (0) 78 #define audio_extn_usb_is_config_supported(bit_width, sample_rate, ch, pb) (false) 79 #define audio_extn_usb_enable_sidetone(device, enable) (0) 80 #define audio_extn_usb_set_sidetone_gain(parms, value, len) (0) 81 #define audio_extn_usb_is_capture_supported() (false) 82 #define audio_extn_usb_get_max_channels(dir) (0) 83 #define audio_extn_usb_get_max_bit_width(dir) (0) 84 #define audio_extn_usb_sup_sample_rates(t, s, l) (0) 85 #define audio_extn_usb_alive(adev) (false) 86 #else 87 void audio_extn_usb_init(void *adev); 88 void audio_extn_usb_deinit(); 89 void audio_extn_usb_add_device(audio_devices_t device, int card); 90 void audio_extn_usb_remove_device(audio_devices_t device, int card); 91 bool audio_extn_usb_is_config_supported(unsigned int *bit_width, 92 unsigned int *sample_rate, 93 unsigned int *ch, 94 bool is_playback); 95 int audio_extn_usb_enable_sidetone(int device, bool enable); 96 int audio_extn_usb_set_sidetone_gain(struct str_parms *parms, 97 char *value, int len); 98 bool audio_extn_usb_is_capture_supported(); 99 int audio_extn_usb_get_max_channels(bool is_playback); 100 int audio_extn_usb_get_max_bit_width(bool is_playback); 101 int audio_extn_usb_sup_sample_rates(bool is_playback, uint32_t *sr, uint32_t l); 102 bool audio_extn_usb_alive(int card); 103 #endif 104 105 106 #ifndef SOUND_TRIGGER_ENABLED 107 #define audio_extn_sound_trigger_init(adev) (0) 108 #define audio_extn_sound_trigger_deinit(adev) (0) 109 #define audio_extn_sound_trigger_update_device_status(snd_dev, event) (0) 110 #define audio_extn_sound_trigger_set_parameters(adev, parms) (0) 111 #define audio_extn_sound_trigger_check_and_get_session(in) (0) 112 #define audio_extn_sound_trigger_stop_lab(in) (0) 113 #define audio_extn_sound_trigger_read(in, buffer, bytes) (0) 114 115 #else 116 117 enum st_event_type { 118 ST_EVENT_SND_DEVICE_FREE, 119 ST_EVENT_SND_DEVICE_BUSY, 120 ST_EVENT_STREAM_FREE, 121 ST_EVENT_STREAM_BUSY 122 }; 123 typedef enum st_event_type st_event_type_t; 124 125 int audio_extn_sound_trigger_init(struct audio_device *adev); 126 void audio_extn_sound_trigger_deinit(struct audio_device *adev); 127 void audio_extn_sound_trigger_update_device_status(snd_device_t snd_device, 128 st_event_type_t event); 129 void audio_extn_sound_trigger_set_parameters(struct audio_device *adev, 130 struct str_parms *parms); 131 void audio_extn_sound_trigger_check_and_get_session(struct stream_in *in); 132 void audio_extn_sound_trigger_stop_lab(struct stream_in *in); 133 int audio_extn_sound_trigger_read(struct stream_in *in, void *buffer, 134 size_t bytes); 135 #endif 136 137 #ifndef DSM_FEEDBACK_ENABLED 138 #define audio_extn_dsm_feedback_enable(adev, snd_device, benable) (0) 139 #else 140 void audio_extn_dsm_feedback_enable(struct audio_device *adev, 141 snd_device_t snd_device, 142 bool benable); 143 #endif 144 145 void audio_extn_utils_send_default_app_type_cfg(void *platform, struct mixer *mixer); 146 int audio_extn_utils_send_app_type_cfg(struct audio_device *adev, 147 struct audio_usecase *usecase); 148 void audio_extn_utils_send_audio_calibration(struct audio_device *adev, 149 struct audio_usecase *usecase); 150 int audio_extn_utils_send_app_type_gain(struct audio_device *adev, 151 int app_type, 152 int *gain); 153 #ifndef HWDEP_CAL_ENABLED 154 #define audio_extn_hwdep_cal_send(snd_card, acdb_handle) (0) 155 #else 156 void audio_extn_hwdep_cal_send(int snd_card, void *acdb_handle); 157 #endif 158 159 #ifndef KPI_OPTIMIZE_ENABLED 160 #define audio_extn_perf_lock_init() (0) 161 #define audio_extn_perf_lock_acquire() (0) 162 #define audio_extn_perf_lock_release() (0) 163 #else 164 int audio_extn_perf_lock_init(void); 165 void audio_extn_perf_lock_acquire(void); 166 void audio_extn_perf_lock_release(void); 167 #endif /* KPI_OPTIMIZE_ENABLED */ 168 169 #ifndef HW_VARIANTS_ENABLED 170 #define hw_info_init(snd_card_name) (0) 171 #define hw_info_deinit(hw_info) (0) 172 #define hw_info_append_hw_type(hw_info,\ 173 snd_device, device_name) (0) 174 #else 175 void *hw_info_init(const char *snd_card_name); 176 void hw_info_deinit(void *hw_info); 177 void hw_info_append_hw_type(void *hw_info, snd_device_t snd_device, 178 char *device_name); 179 #endif /* HW_VARIANTS_ENABLED */ 180 181 typedef void (* snd_mon_cb)(void * stream, struct str_parms * parms); 182 #ifndef SND_MONITOR_ENABLED 183 #define audio_extn_snd_mon_init() (0) 184 #define audio_extn_snd_mon_deinit() (0) 185 #define audio_extn_snd_mon_register_listener(stream, cb) (0) 186 #define audio_extn_snd_mon_unregister_listener(stream) (0) 187 #else 188 int audio_extn_snd_mon_init(); 189 int audio_extn_snd_mon_deinit(); 190 int audio_extn_snd_mon_register_listener(void *stream, snd_mon_cb cb); 191 int audio_extn_snd_mon_unregister_listener(void *stream); 192 #endif 193 194 bool audio_extn_utils_resolve_config_file(char[]); 195 int audio_extn_utils_get_platform_info(const char* snd_card_name, 196 char* platform_info_file); 197 int audio_extn_utils_get_snd_card_num(); 198 #endif /* AUDIO_EXTN_H */ 199