Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
| 13 | * * Neither the name of The Linux Foundation nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | //#define LOG_NDEBUG 0 |
| 31 | #define LOG_TAG "ahal_config_helper" |
| 32 | |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 33 | #include <cutils/properties.h> |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 34 | #include <dlfcn.h> |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 35 | #include <log/log.h> |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 36 | #include "ahal_config_helper.h" |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 37 | |
| 38 | struct AHalConfigHelper { |
| 39 | static AHalConfigHelper* mConfigHelper; |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 40 | AHalConfigHelper() {}; |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 41 | |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 42 | static AHalConfigHelper* getAHalConfInstance() { |
| 43 | if (!mConfigHelper) |
| 44 | mConfigHelper = new AHalConfigHelper(); |
| 45 | return mConfigHelper; |
| 46 | } |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 47 | void initConfigHelper(bool isVendorEnhancedFwk); |
| 48 | void getAHalValues(AHalValues* *confValues); |
| 49 | AHalValues defaultConfigs; |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | AHalConfigHelper* AHalConfigHelper::mConfigHelper; |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 53 | static AHalValues* (*getAHalConfigs)() = nullptr; |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 54 | |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 55 | void AHalConfigHelper::initConfigHelper(bool isVendorEnhancedFwk) |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 56 | { |
| 57 | ALOGV("%s: enter", __FUNCTION__); |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 58 | |
| 59 | void *handle = dlopen(AUDIO_CONFIGSTORE_LIB_PATH, RTLD_NOW); |
| 60 | if (handle != nullptr) { |
| 61 | getAHalConfigs = (AHalValues*(*)()) |
| 62 | dlsym(handle, "getAudioHalExtConfigs"); |
| 63 | if (!getAHalConfigs) { |
| 64 | ALOGE("%s: Could not find symbol: %s", __FUNCTION__, dlerror()); |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 65 | dlclose(handle); |
Weiyin Jiang | 2995f66 | 2019-04-17 14:25:12 +0800 | [diff] [blame] | 66 | handle = nullptr; |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 67 | } |
| 68 | } |
| 69 | |
| 70 | #ifdef LINUX_ENABLED |
| 71 | defaultConfigs = { |
| 72 | true, /* SND_MONITOR */ |
| 73 | false, /* COMPRESS_CAPTURE */ |
| 74 | true, /* SOURCE_TRACK */ |
| 75 | true, /* SSREC */ |
| 76 | true, /* AUDIOSPHERE */ |
| 77 | true, /* AFE_PROXY */ |
| 78 | false, /* USE_DEEP_AS_PRIMARY_OUTPUT */ |
| 79 | true, /* HDMI_EDID */ |
| 80 | false, /* KEEP_ALIVE */ |
| 81 | false, /* HIFI_AUDIO */ |
| 82 | true, /* RECEIVER_AIDED_STEREO */ |
| 83 | true, /* KPI_OPTIMIZE */ |
| 84 | true, /* DISPLAY_PORT */ |
| 85 | true, /* FLUENCE */ |
| 86 | false, /* CUSTOM_STEREO */ |
| 87 | true, /* ANC_HEADSET */ |
| 88 | true, /* SPKR_PROT */ |
| 89 | true, /* FM_POWER_OPT */ |
| 90 | false, /* EXTERNAL_QDSP */ |
| 91 | false, /* EXTERNAL_SPEAKER */ |
| 92 | false, /* EXTERNAL_SPEAKER_TFA */ |
| 93 | false, /* HWDEP_CAL */ |
| 94 | false, /* DSM_FEEDBACK */ |
| 95 | true, /* USB_OFFLOAD */ |
| 96 | false, /* USB_OFFLOAD_BURST_MODE */ |
| 97 | false, /* USB_OFFLOAD_SIDETONE_VOLM */ |
| 98 | true, /* A2DP_OFFLOAD */ |
| 99 | true, /* HFP */ |
| 100 | true, /* VBAT */ |
Sujin Panicker | b904fbe | 2019-04-04 13:28:07 +0530 | [diff] [blame] | 101 | false, /* WSA*/ |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 102 | true, /* EXT_HW_PLUGIN */ |
| 103 | false, /* RECORD_PLAY_CONCURRENCY */ |
| 104 | true, /* HDMI_PASSTHROUGH */ |
| 105 | false, /* CONCURRENT_CAPTURE */ |
| 106 | false, /* COMPRESS_IN */ |
| 107 | false, /* BATTERY_LISTENER */ |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 108 | false, /* MAXX_AUDIO */ |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 109 | true, /* COMPRESS_METADATA_NEEDED */ |
| 110 | false, /* INCALL_MUSIC */ |
| 111 | false, /* COMPRESS_VOIP */ |
vivek mehta | ba5ed15 | 2019-05-03 17:28:25 -0700 | [diff] [blame^] | 112 | true, /* DYNAMIC_ECNS */ |
| 113 | false, /* AUDIO_ZOOM */ |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 114 | }; |
| 115 | #else |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 116 | if (isVendorEnhancedFwk) { |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 117 | defaultConfigs = { |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 118 | true, /* SND_MONITOR */ |
| 119 | false, /* COMPRESS_CAPTURE */ |
| 120 | true, /* SOURCE_TRACK */ |
| 121 | true, /* SSREC */ |
| 122 | true, /* AUDIOSPHERE */ |
| 123 | true, /* AFE_PROXY */ |
| 124 | false, /* USE_DEEP_AS_PRIMARY_OUTPUT */ |
| 125 | true, /* HDMI_EDID */ |
| 126 | true, /* KEEP_ALIVE */ |
| 127 | false, /* HIFI_AUDIO */ |
| 128 | true, /* RECEIVER_AIDED_STEREO */ |
| 129 | true, /* KPI_OPTIMIZE */ |
| 130 | true, /* DISPLAY_PORT */ |
| 131 | true, /* FLUENCE */ |
| 132 | true, /* CUSTOM_STEREO */ |
| 133 | true, /* ANC_HEADSET */ |
Arun Mirpuri | 5dc7780 | 2019-02-26 16:32:42 -0800 | [diff] [blame] | 134 | true, /* SPKR_PROT */ |
| 135 | true, /* FM_POWER_OPT */ |
| 136 | false, /* EXTERNAL_QDSP */ |
| 137 | false, /* EXTERNAL_SPEAKER */ |
| 138 | false, /* EXTERNAL_SPEAKER_TFA */ |
| 139 | false, /* HWDEP_CAL */ |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 140 | false, /* DSM_FEEDBACK */ |
| 141 | true, /* USB_OFFLOAD */ |
| 142 | false, /* USB_OFFLOAD_BURST_MODE */ |
| 143 | false, /* USB_OFFLOAD_SIDETONE_VOLM */ |
| 144 | true, /* A2DP_OFFLOAD */ |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 145 | true, /* HFP */ |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 146 | true, /* VBAT */ |
Sujin Panicker | b904fbe | 2019-04-04 13:28:07 +0530 | [diff] [blame] | 147 | false, /* WSA*/ |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 148 | true, /* EXT_HW_PLUGIN */ |
| 149 | false, /* RECORD_PLAY_CONCURRENCY */ |
| 150 | true, /* HDMI_PASSTHROUGH */ |
| 151 | true, /* CONCURRENT_CAPTURE */ |
| 152 | true, /* COMPRESS_IN */ |
| 153 | true, /* BATTERY_LISTENER */ |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 154 | false, /* MAXX_AUDIO */ |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 155 | true, /* COMPRESS_METADATA_NEEDED */ |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 156 | true, /* INCALL_MUSIC */ |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 157 | false, /* COMPRESS_VOIP */ |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 158 | true, /* DYNAMIC_ECNS */ |
vivek mehta | ba5ed15 | 2019-05-03 17:28:25 -0700 | [diff] [blame^] | 159 | false, /* AUDIO_ZOOM */ |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 160 | }; |
| 161 | } else { |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 162 | defaultConfigs = { |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 163 | true, /* SND_MONITOR */ |
| 164 | false, /* COMPRESS_CAPTURE */ |
| 165 | false, /* SOURCE_TRACK */ |
| 166 | false, /* SSREC */ |
| 167 | false, /* AUDIOSPHERE */ |
| 168 | false, /* AFE_PROXY */ |
| 169 | false, /* USE_DEEP_AS_PRIMARY_OUTPUT */ |
| 170 | false, /* HDMI_EDID */ |
| 171 | false, /* KEEP_ALIVE */ |
| 172 | false, /* HIFI_AUDIO */ |
| 173 | false, /* RECEIVER_AIDED_STEREO */ |
| 174 | false, /* KPI_OPTIMIZE */ |
| 175 | false, /* DISPLAY_PORT */ |
| 176 | false, /* FLUENCE */ |
| 177 | false, /* CUSTOM_STEREO */ |
| 178 | false, /* ANC_HEADSET */ |
Arun Mirpuri | 5dc7780 | 2019-02-26 16:32:42 -0800 | [diff] [blame] | 179 | true, /* SPKR_PROT */ |
| 180 | false, /* FM_POWER_OPT */ |
| 181 | true, /* EXTERNAL_QDSP */ |
| 182 | true, /* EXTERNAL_SPEAKER */ |
| 183 | false, /* EXTERNAL_SPEAKER_TFA */ |
| 184 | true, /* HWDEP_CAL */ |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 185 | false, /* DSM_FEEDBACK */ |
| 186 | true, /* USB_OFFLOAD */ |
| 187 | false, /* USB_OFFLOAD_BURST_MODE */ |
| 188 | false, /* USB_OFFLOAD_SIDETONE_VOLM */ |
| 189 | true, /* A2DP_OFFLOAD */ |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 190 | true, /* HFP */ |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 191 | false, /* VBAT */ |
Sujin Panicker | b904fbe | 2019-04-04 13:28:07 +0530 | [diff] [blame] | 192 | false, /* WSA*/ |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 193 | false, /* EXT_HW_PLUGIN */ |
| 194 | false, /* RECORD_PLAY_CONCURRENCY */ |
| 195 | false, /* HDMI_PASSTHROUGH */ |
| 196 | true, /* CONCURRENT_CAPTURE */ |
| 197 | false, /* COMPRESS_IN */ |
| 198 | false, /* BATTERY_LISTENER */ |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 199 | true, /* MAXX_AUDIO */ |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 200 | false, /* COMPRESS_METADATA_NEEDED */ |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 201 | true, /* INCALL_MUSIC */ |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 202 | false, /* COMPRESS_VOIP */ |
vivek mehta | ba5ed15 | 2019-05-03 17:28:25 -0700 | [diff] [blame^] | 203 | false, /* DYNAMIC_ECNS */ |
| 204 | true, /* AUDIO_ZOOM */ |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 205 | }; |
| 206 | } |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 207 | #endif |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 208 | } |
| 209 | |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 210 | void AHalConfigHelper::getAHalValues(AHalValues* *confValues) |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 211 | { |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 212 | if (getAHalConfigs != nullptr) |
| 213 | *confValues = getAHalConfigs(); |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 214 | |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 215 | if (*confValues == nullptr) { |
| 216 | ALOGI("%s: Could not retrieve flags from configstore, setting defaults", |
| 217 | __FUNCTION__); |
| 218 | *confValues = &defaultConfigs; |
| 219 | } |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | extern "C" { |
| 223 | |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 224 | void audio_extn_ahal_config_helper_init(bool is_vendor_enhanced_fwk) |
| 225 | { |
| 226 | AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance(); |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 227 | if (confInstance != nullptr) |
| 228 | confInstance->initConfigHelper(is_vendor_enhanced_fwk); |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 229 | } |
| 230 | |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 231 | void audio_extn_get_feature_values(AHalValues* *confValues) |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 232 | { |
| 233 | AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance(); |
Aniket Kumar Lata | b91e4cf | 2019-02-11 18:55:23 -0800 | [diff] [blame] | 234 | if (confInstance != nullptr) |
| 235 | confInstance->getAHalValues(confValues); |
Aniket Kumar Lata | 808e8d6 | 2019-01-28 22:54:28 -0800 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | } // extern C |