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 | |
| 33 | #include "ahal_config_helper.h" |
| 34 | #include <cutils/properties.h> |
| 35 | #include <log/log.h> |
| 36 | |
| 37 | struct 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 | |
| 54 | AHalConfigHelper* AHalConfigHelper::mConfigHelper; |
| 55 | |
| 56 | void 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 */ |
| 77 | false, /* DSM_FEEDBACK */ |
| 78 | true, /* USB_OFFLOAD */ |
| 79 | false, /* USB_OFFLOAD_BURST_MODE */ |
| 80 | false, /* USB_OFFLOAD_SIDETONE_VOLM */ |
| 81 | true, /* A2DP_OFFLOAD */ |
| 82 | true, /* VBAT */ |
| 83 | true, /* COMPRESS_METADATA_NEEDED */ |
| 84 | false, /* COMPRESS_VOIP */ |
| 85 | false, /* DYNAMIC_ECNS */ |
| 86 | }; |
| 87 | } else { |
| 88 | mConfigs = { |
| 89 | true, /* SND_MONITOR */ |
| 90 | false, /* COMPRESS_CAPTURE */ |
| 91 | false, /* SOURCE_TRACK */ |
| 92 | false, /* SSREC */ |
| 93 | false, /* AUDIOSPHERE */ |
| 94 | false, /* AFE_PROXY */ |
| 95 | false, /* USE_DEEP_AS_PRIMARY_OUTPUT */ |
| 96 | false, /* HDMI_EDID */ |
| 97 | false, /* KEEP_ALIVE */ |
| 98 | false, /* HIFI_AUDIO */ |
| 99 | false, /* RECEIVER_AIDED_STEREO */ |
| 100 | false, /* KPI_OPTIMIZE */ |
| 101 | false, /* DISPLAY_PORT */ |
| 102 | false, /* FLUENCE */ |
| 103 | false, /* CUSTOM_STEREO */ |
| 104 | false, /* ANC_HEADSET */ |
| 105 | false, /* DSM_FEEDBACK */ |
| 106 | true, /* USB_OFFLOAD */ |
| 107 | false, /* USB_OFFLOAD_BURST_MODE */ |
| 108 | false, /* USB_OFFLOAD_SIDETONE_VOLM */ |
| 109 | true, /* A2DP_OFFLOAD */ |
| 110 | false, /* VBAT */ |
| 111 | false, /* COMPRESS_METADATA_NEEDED */ |
| 112 | false, /* COMPRESS_VOIP */ |
| 113 | false, /* DYNAMIC_ECNS */ |
| 114 | }; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | AHalValues* AHalConfigHelper::getAHalValues() |
| 119 | { |
| 120 | ALOGV("%s: enter", __FUNCTION__); |
| 121 | retrieveConfigs(); |
| 122 | return &mConfigs; |
| 123 | } |
| 124 | |
| 125 | void AHalConfigHelper::retrieveConfigs() |
| 126 | { |
| 127 | ALOGV("%s: enter", __FUNCTION__); |
| 128 | // ToDo: Add logic to query AHalValues from config store |
| 129 | // once support is added to it |
| 130 | return; |
| 131 | } |
| 132 | |
| 133 | extern "C" { |
| 134 | |
| 135 | AHalValues* confValues = nullptr; |
| 136 | |
| 137 | void audio_extn_ahal_config_helper_init(bool is_vendor_enhanced_fwk) |
| 138 | { |
| 139 | AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance(); |
| 140 | if (confInstance) |
| 141 | confInstance->initDefaultConfig(is_vendor_enhanced_fwk); |
| 142 | } |
| 143 | |
| 144 | AHalValues* audio_extn_get_feature_values() |
| 145 | { |
| 146 | AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance(); |
| 147 | if (confInstance) |
| 148 | confValues = confInstance->getAHalValues(); |
| 149 | return confValues; |
| 150 | } |
| 151 | |
| 152 | bool audio_extn_is_config_from_remote() |
| 153 | { |
| 154 | AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance(); |
| 155 | if (confInstance) |
| 156 | return confInstance->isRemote; |
| 157 | return false; |
| 158 | } |
| 159 | |
| 160 | } // extern C |