blob: 63f44abacc2733667c12faabae2e4e9c651b6d0b [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
33#include "ahal_config_helper.h"
34#include <cutils/properties.h>
35#include <log/log.h>
36
37struct AHalConfigHelper {
38 static AHalConfigHelper* mConfigHelper;
39
40 AHalConfigHelper() : isRemote(false) { };
41 static AHalConfigHelper* getAHalConfInstance() {
42 if (!mConfigHelper)
43 mConfigHelper = new AHalConfigHelper();
44 return mConfigHelper;
45 }
46 void initDefaultConfig(bool isVendorEnhancedFwk);
47 AHalValues* getAHalValues();
48 inline void retrieveConfigs();
49
50 AHalValues mConfigs;
51 bool isRemote; // configs specified from remote
52};
53
54AHalConfigHelper* AHalConfigHelper::mConfigHelper;
55
56void AHalConfigHelper::initDefaultConfig(bool isVendorEnhancedFwk)
57{
58 ALOGV("%s: enter", __FUNCTION__);
59 if (isVendorEnhancedFwk) {
60 mConfigs = {
61 true, /* SND_MONITOR */
62 false, /* COMPRESS_CAPTURE */
63 true, /* SOURCE_TRACK */
64 true, /* SSREC */
65 true, /* AUDIOSPHERE */
66 true, /* AFE_PROXY */
67 false, /* USE_DEEP_AS_PRIMARY_OUTPUT */
68 true, /* HDMI_EDID */
69 true, /* KEEP_ALIVE */
70 false, /* HIFI_AUDIO */
71 true, /* RECEIVER_AIDED_STEREO */
72 true, /* KPI_OPTIMIZE */
73 true, /* DISPLAY_PORT */
74 true, /* FLUENCE */
75 true, /* CUSTOM_STEREO */
76 true, /* ANC_HEADSET */
Arun Mirpuri5dc77802019-02-26 16:32:42 -080077 true, /* SPKR_PROT */
78 true, /* FM_POWER_OPT */
79 false, /* EXTERNAL_QDSP */
80 false, /* EXTERNAL_SPEAKER */
81 false, /* EXTERNAL_SPEAKER_TFA */
82 false, /* HWDEP_CAL */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -080083 false, /* DSM_FEEDBACK */
84 true, /* USB_OFFLOAD */
85 false, /* USB_OFFLOAD_BURST_MODE */
86 false, /* USB_OFFLOAD_SIDETONE_VOLM */
87 true, /* A2DP_OFFLOAD */
88 true, /* VBAT */
89 true, /* COMPRESS_METADATA_NEEDED */
90 false, /* COMPRESS_VOIP */
91 false, /* DYNAMIC_ECNS */
92 };
93 } else {
94 mConfigs = {
95 true, /* SND_MONITOR */
96 false, /* COMPRESS_CAPTURE */
97 false, /* SOURCE_TRACK */
98 false, /* SSREC */
99 false, /* AUDIOSPHERE */
100 false, /* AFE_PROXY */
101 false, /* USE_DEEP_AS_PRIMARY_OUTPUT */
102 false, /* HDMI_EDID */
103 false, /* KEEP_ALIVE */
104 false, /* HIFI_AUDIO */
105 false, /* RECEIVER_AIDED_STEREO */
106 false, /* KPI_OPTIMIZE */
107 false, /* DISPLAY_PORT */
108 false, /* FLUENCE */
109 false, /* CUSTOM_STEREO */
110 false, /* ANC_HEADSET */
Arun Mirpuri5dc77802019-02-26 16:32:42 -0800111 true, /* SPKR_PROT */
112 false, /* FM_POWER_OPT */
113 true, /* EXTERNAL_QDSP */
114 true, /* EXTERNAL_SPEAKER */
115 false, /* EXTERNAL_SPEAKER_TFA */
116 true, /* HWDEP_CAL */
Aniket Kumar Lata808e8d62019-01-28 22:54:28 -0800117 false, /* DSM_FEEDBACK */
118 true, /* USB_OFFLOAD */
119 false, /* USB_OFFLOAD_BURST_MODE */
120 false, /* USB_OFFLOAD_SIDETONE_VOLM */
121 true, /* A2DP_OFFLOAD */
122 false, /* VBAT */
123 false, /* COMPRESS_METADATA_NEEDED */
124 false, /* COMPRESS_VOIP */
125 false, /* DYNAMIC_ECNS */
126 };
127 }
128}
129
130AHalValues* AHalConfigHelper::getAHalValues()
131{
132 ALOGV("%s: enter", __FUNCTION__);
133 retrieveConfigs();
134 return &mConfigs;
135}
136
137void AHalConfigHelper::retrieveConfigs()
138{
139 ALOGV("%s: enter", __FUNCTION__);
140 // ToDo: Add logic to query AHalValues from config store
141 // once support is added to it
142 return;
143}
144
145extern "C" {
146
147AHalValues* confValues = nullptr;
148
149void audio_extn_ahal_config_helper_init(bool is_vendor_enhanced_fwk)
150{
151 AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance();
152 if (confInstance)
153 confInstance->initDefaultConfig(is_vendor_enhanced_fwk);
154}
155
156AHalValues* audio_extn_get_feature_values()
157{
158 AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance();
159 if (confInstance)
160 confValues = confInstance->getAHalValues();
161 return confValues;
162}
163
164bool audio_extn_is_config_from_remote()
165{
166 AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance();
167 if (confInstance)
168 return confInstance->isRemote;
169 return false;
170}
171
172} // extern C