blob: e46b8f33c828a3c12261ae0f28058518460a1ac2 [file] [log] [blame]
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -08001/*
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 Lata808e8d62019-01-28 22:54:28 -080033#include <cutils/properties.h>
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -080034#include <dlfcn.h>
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -080035#include <log/log.h>
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -080036#include "ahal_config_helper.h"
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -080037
38struct AHalConfigHelper {
39 static AHalConfigHelper* mConfigHelper;
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -080040 AHalConfigHelper() {};
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -080041
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -080042 static AHalConfigHelper* getAHalConfInstance() {
43 if (!mConfigHelper)
44 mConfigHelper = new AHalConfigHelper();
45 return mConfigHelper;
46 }
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -080047 void initConfigHelper(bool isVendorEnhancedFwk);
48 void getAHalValues(AHalValues* *confValues);
49 AHalValues defaultConfigs;
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -080050};
51
52AHalConfigHelper* AHalConfigHelper::mConfigHelper;
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -080053static AHalValues* (*getAHalConfigs)() = nullptr;
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -080054
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -080055void AHalConfigHelper::initConfigHelper(bool isVendorEnhancedFwk)
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -080056{
57 ALOGV("%s: enter", __FUNCTION__);
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -080058
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 Latab91e4cf2019-02-11 18:55:23 -080065 dlclose(handle);
Weiyin Jiang2995f662019-04-17 14:25:12 +080066 handle = nullptr;
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -080067 }
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 Panickerb904fbe2019-04-04 13:28:07 +0530101 false, /* WSA*/
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800102 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 Mirpurid750ac52019-04-12 18:33:55 -0700108 false, /* MAXX_AUDIO */
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800109 true, /* COMPRESS_METADATA_NEEDED */
110 false, /* INCALL_MUSIC */
111 false, /* COMPRESS_VOIP */
Arun Mirpurie008ed22019-03-21 11:21:04 -0700112 true /* DYNAMIC_ECNS */
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800113 };
114#else
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800115 if (isVendorEnhancedFwk) {
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800116 defaultConfigs = {
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800117 true, /* SND_MONITOR */
118 false, /* COMPRESS_CAPTURE */
119 true, /* SOURCE_TRACK */
120 true, /* SSREC */
121 true, /* AUDIOSPHERE */
122 true, /* AFE_PROXY */
123 false, /* USE_DEEP_AS_PRIMARY_OUTPUT */
124 true, /* HDMI_EDID */
125 true, /* KEEP_ALIVE */
126 false, /* HIFI_AUDIO */
127 true, /* RECEIVER_AIDED_STEREO */
128 true, /* KPI_OPTIMIZE */
129 true, /* DISPLAY_PORT */
130 true, /* FLUENCE */
131 true, /* CUSTOM_STEREO */
132 true, /* ANC_HEADSET */
Arun Mirpuri5dc77802019-02-26 16:32:42 -0800133 true, /* SPKR_PROT */
134 true, /* FM_POWER_OPT */
135 false, /* EXTERNAL_QDSP */
136 false, /* EXTERNAL_SPEAKER */
137 false, /* EXTERNAL_SPEAKER_TFA */
138 false, /* HWDEP_CAL */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800139 false, /* DSM_FEEDBACK */
140 true, /* USB_OFFLOAD */
141 false, /* USB_OFFLOAD_BURST_MODE */
142 false, /* USB_OFFLOAD_SIDETONE_VOLM */
143 true, /* A2DP_OFFLOAD */
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800144 true, /* HFP */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800145 true, /* VBAT */
Sujin Panickerb904fbe2019-04-04 13:28:07 +0530146 false, /* WSA*/
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800147 true, /* EXT_HW_PLUGIN */
148 false, /* RECORD_PLAY_CONCURRENCY */
149 true, /* HDMI_PASSTHROUGH */
150 true, /* CONCURRENT_CAPTURE */
151 true, /* COMPRESS_IN */
152 true, /* BATTERY_LISTENER */
Arun Mirpurid750ac52019-04-12 18:33:55 -0700153 false, /* MAXX_AUDIO */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800154 true, /* COMPRESS_METADATA_NEEDED */
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800155 true, /* INCALL_MUSIC */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800156 false, /* COMPRESS_VOIP */
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800157 true, /* DYNAMIC_ECNS */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800158 };
159 } else {
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800160 defaultConfigs = {
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800161 true, /* SND_MONITOR */
162 false, /* COMPRESS_CAPTURE */
163 false, /* SOURCE_TRACK */
164 false, /* SSREC */
165 false, /* AUDIOSPHERE */
166 false, /* AFE_PROXY */
167 false, /* USE_DEEP_AS_PRIMARY_OUTPUT */
168 false, /* HDMI_EDID */
169 false, /* KEEP_ALIVE */
170 false, /* HIFI_AUDIO */
171 false, /* RECEIVER_AIDED_STEREO */
172 false, /* KPI_OPTIMIZE */
173 false, /* DISPLAY_PORT */
174 false, /* FLUENCE */
175 false, /* CUSTOM_STEREO */
176 false, /* ANC_HEADSET */
Arun Mirpuri5dc77802019-02-26 16:32:42 -0800177 true, /* SPKR_PROT */
178 false, /* FM_POWER_OPT */
179 true, /* EXTERNAL_QDSP */
180 true, /* EXTERNAL_SPEAKER */
181 false, /* EXTERNAL_SPEAKER_TFA */
182 true, /* HWDEP_CAL */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800183 false, /* DSM_FEEDBACK */
184 true, /* USB_OFFLOAD */
185 false, /* USB_OFFLOAD_BURST_MODE */
186 false, /* USB_OFFLOAD_SIDETONE_VOLM */
187 true, /* A2DP_OFFLOAD */
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800188 true, /* HFP */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800189 false, /* VBAT */
Sujin Panickerb904fbe2019-04-04 13:28:07 +0530190 false, /* WSA*/
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800191 false, /* EXT_HW_PLUGIN */
192 false, /* RECORD_PLAY_CONCURRENCY */
193 false, /* HDMI_PASSTHROUGH */
194 true, /* CONCURRENT_CAPTURE */
195 false, /* COMPRESS_IN */
196 false, /* BATTERY_LISTENER */
Arun Mirpurid750ac52019-04-12 18:33:55 -0700197 true, /* MAXX_AUDIO */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800198 false, /* COMPRESS_METADATA_NEEDED */
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800199 true, /* INCALL_MUSIC */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800200 false, /* COMPRESS_VOIP */
Arun Mirpurie008ed22019-03-21 11:21:04 -0700201 false /* DYNAMIC_ECNS */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800202 };
203 }
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800204#endif
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800205}
206
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800207void AHalConfigHelper::getAHalValues(AHalValues* *confValues)
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800208{
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800209 if (getAHalConfigs != nullptr)
210 *confValues = getAHalConfigs();
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800211
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800212 if (*confValues == nullptr) {
213 ALOGI("%s: Could not retrieve flags from configstore, setting defaults",
214 __FUNCTION__);
215 *confValues = &defaultConfigs;
216 }
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800217}
218
219extern "C" {
220
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800221void audio_extn_ahal_config_helper_init(bool is_vendor_enhanced_fwk)
222{
223 AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance();
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800224 if (confInstance != nullptr)
225 confInstance->initConfigHelper(is_vendor_enhanced_fwk);
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800226}
227
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800228void audio_extn_get_feature_values(AHalValues* *confValues)
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800229{
230 AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance();
Aniket Kumar Latab91e4cf2019-02-11 18:55:23 -0800231 if (confInstance != nullptr)
232 confInstance->getAHalValues(confValues);
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800233}
234
235} // extern C