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 #else 61 bool audio_extn_hfp_is_active(struct audio_device *adev); 62 63 audio_usecase_t audio_extn_hfp_get_usecase(); 64 65 void audio_extn_hfp_set_parameters(struct audio_device *adev, 66 struct str_parms *parms); 67 #endif 68 69 #ifndef SOUND_TRIGGER_ENABLED 70 #define audio_extn_sound_trigger_init(adev) (0) 71 #define audio_extn_sound_trigger_deinit(adev) (0) 72 #define audio_extn_sound_trigger_update_device_status(snd_dev, event) (0) 73 #define audio_extn_sound_trigger_set_parameters(adev, parms) (0) 74 #define audio_extn_sound_trigger_check_and_get_session(in) (0) 75 #define audio_extn_sound_trigger_stop_lab(in) (0) 76 #define audio_extn_sound_trigger_read(in, buffer, bytes) (0) 77 78 #else 79 80 enum st_event_type { 81 ST_EVENT_SND_DEVICE_FREE, 82 ST_EVENT_SND_DEVICE_BUSY, 83 ST_EVENT_STREAM_FREE, 84 ST_EVENT_STREAM_BUSY 85 }; 86 typedef enum st_event_type st_event_type_t; 87 88 int audio_extn_sound_trigger_init(struct audio_device *adev); 89 void audio_extn_sound_trigger_deinit(struct audio_device *adev); 90 void audio_extn_sound_trigger_update_device_status(snd_device_t snd_device, 91 st_event_type_t event); 92 void audio_extn_sound_trigger_set_parameters(struct audio_device *adev, 93 struct str_parms *parms); 94 void audio_extn_sound_trigger_check_and_get_session(struct stream_in *in); 95 void audio_extn_sound_trigger_stop_lab(struct stream_in *in); 96 int audio_extn_sound_trigger_read(struct stream_in *in, void *buffer, 97 size_t bytes); 98 #endif 99 100 #ifndef DSM_FEEDBACK_ENABLED 101 #define audio_extn_dsm_feedback_enable(adev, snd_device, benable) (0) 102 #else 103 void audio_extn_dsm_feedback_enable(struct audio_device *adev, 104 snd_device_t snd_device, 105 bool benable); 106 #endif 107 108 #ifndef HWDEP_CAL_ENABLED 109 #define audio_extn_hwdep_cal_send(snd_card, acdb_handle) (0) 110 #else 111 void audio_extn_hwdep_cal_send(int snd_card, void *acdb_handle); 112 #endif 113 114 #ifndef KPI_OPTIMIZE_ENABLED 115 #define audio_extn_perf_lock_init() (0) 116 #define audio_extn_perf_lock_acquire() (0) 117 #define audio_extn_perf_lock_release() (0) 118 #else 119 int audio_extn_perf_lock_init(void); 120 void audio_extn_perf_lock_acquire(void); 121 void audio_extn_perf_lock_release(void); 122 #endif /* KPI_OPTIMIZE_ENABLED */ 123 124 #ifndef HW_VARIANTS_ENABLED 125 #define hw_info_init(snd_card_name) (0) 126 #define hw_info_deinit(hw_info) (0) 127 #define hw_info_append_hw_type(hw_info,\ 128 snd_device, device_name) (0) 129 #else 130 void *hw_info_init(const char *snd_card_name); 131 void hw_info_deinit(void *hw_info); 132 void hw_info_append_hw_type(void *hw_info, snd_device_t snd_device, 133 char *device_name); 134 #endif /* HW_VARIANTS_ENABLED */ 135 #endif /* AUDIO_EXTN_H */ 136