Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1 | /* |
Robert Lee | 5821554 | 2019-07-15 20:55:12 +0800 | [diff] [blame] | 2 | * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 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. |
Krishna Kishor Jha | 10ad39f | 2022-02-21 17:02:47 +0530 | [diff] [blame] | 28 | |
| 29 | * Changes from Qualcomm Innovation Center are provided under the following license: |
| 30 | |
| 31 | * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. |
| 32 | |
| 33 | * Redistribution and use in source and binary forms, with or without |
| 34 | * modification, are permitted (subject to the limitations in the |
| 35 | * disclaimer below) provided that the following conditions are met: |
| 36 | |
| 37 | * * Redistributions of source code must retain the above copyright |
| 38 | * notice, this list of conditions and the following disclaimer. |
| 39 | |
| 40 | * * Redistributions in binary form must reproduce the above |
| 41 | * copyright notice, this list of conditions and the following |
| 42 | * disclaimer in the documentation and/or other materials provided |
| 43 | * with the distribution. |
| 44 | |
| 45 | * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its |
| 46 | * contributors may be used to endorse or promote products derived |
| 47 | * from this software without specific prior written permission. |
| 48 | |
| 49 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE |
| 50 | * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT |
| 51 | * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
| 52 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 53 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 54 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| 55 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 56 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 57 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 58 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| 59 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 60 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 61 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 62 | */ |
| 63 | |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 64 | #define LOG_TAG "platform_info" |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 65 | #define LOG_NDDEBUG 0 |
| 66 | |
| 67 | #include <errno.h> |
| 68 | #include <stdio.h> |
| 69 | #include <expat.h> |
Jiangen Jiao | 334224b | 2019-09-12 15:47:46 +0800 | [diff] [blame] | 70 | #include <pthread.h> |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 71 | #include <log/log.h> |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 72 | #include <cutils/str_parms.h> |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 73 | #include <audio_hw.h> |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 74 | #include "acdb.h" |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 75 | #include "platform_api.h" |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 76 | #include "audio_extn.h" |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 77 | #include <platform.h> |
Aniket Kumar Lata | f56b640 | 2016-10-27 12:03:18 -0700 | [diff] [blame] | 78 | #include <math.h> |
Fei Tong | c20ce93 | 2021-06-21 16:42:38 +0800 | [diff] [blame] | 79 | #ifdef LINUX_ENABLED |
| 80 | #include <float.h> |
| 81 | #endif |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 82 | |
Revathi Uddaraju | 1eac8b0 | 2017-05-18 17:13:33 +0530 | [diff] [blame] | 83 | #ifdef DYNAMIC_LOG_ENABLED |
| 84 | #include <log_xml_parser.h> |
| 85 | #define LOG_MASK HAL_MOD_FILE_PLATFORM_INFO |
| 86 | #include <log_utils.h> |
| 87 | #endif |
| 88 | |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 89 | #define BUF_SIZE 1024 |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 90 | char vendor_config_path[VENDOR_CONFIG_PATH_MAX_LENGTH]; |
| 91 | char platform_info_xml_path_file[VENDOR_CONFIG_FILE_MAX_LENGTH]; |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 92 | |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 93 | typedef enum { |
| 94 | ROOT, |
| 95 | ACDB, |
Vikram Panduranga | df59cae | 2017-08-03 18:04:55 -0700 | [diff] [blame] | 96 | MODULE, |
| 97 | AEC, |
| 98 | NS, |
Amit Shekhar | 5a39c91 | 2014-10-14 15:39:30 -0700 | [diff] [blame] | 99 | BITWIDTH, |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 100 | PCM_ID, |
| 101 | BACKEND_NAME, |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 102 | INTERFACE_NAME, |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 103 | CONFIG_PARAMS, |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 104 | OPERATOR_SPECIFIC, |
Aniket Kumar Lata | f56b640 | 2016-10-27 12:03:18 -0700 | [diff] [blame] | 105 | GAIN_LEVEL_MAPPING, |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 106 | APP_TYPE, |
Dhanalakshmi Siddani | 21be3ac | 2016-12-29 14:31:08 +0530 | [diff] [blame] | 107 | ACDB_METAINFO_KEY, |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 108 | MICROPHONE_CHARACTERISTIC, |
| 109 | SND_DEVICES, |
| 110 | INPUT_SND_DEVICE, |
| 111 | INPUT_SND_DEVICE_TO_MIC_MAPPING, |
| 112 | SND_DEV, |
| 113 | MIC_INFO, |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 114 | CUSTOM_MTMX_PARAMS, |
| 115 | CUSTOM_MTMX_PARAM_COEFFS, |
Carter Hsu | 32a6236 | 2018-10-15 15:01:42 -0700 | [diff] [blame] | 116 | EXTERNAL_DEVICE_SPECIFIC, |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 117 | CUSTOM_MTMX_IN_PARAMS, |
| 118 | CUSTOM_MTMX_PARAM_IN_CH_INFO, |
Guodong Hu | 1d46f34 | 2019-06-28 16:57:30 +0800 | [diff] [blame] | 119 | MMSECNS, |
Juyu Chen | 918e1e1 | 2019-08-08 15:28:18 -0700 | [diff] [blame] | 120 | AUDIO_SOURCE_DELAY, |
Krishna Kishor Jha | 10ad39f | 2022-02-21 17:02:47 +0530 | [diff] [blame] | 121 | #ifdef SOFT_VOLUME |
| 122 | SOFT_VOLUME_PARAMS, |
| 123 | #endif |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 124 | } section_t; |
| 125 | |
| 126 | typedef void (* section_process_fn)(const XML_Char **attr); |
| 127 | |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 128 | const char* get_platform_xml_path() |
| 129 | { |
| 130 | audio_get_vendor_config_path(vendor_config_path, sizeof(vendor_config_path)); |
| 131 | /* Get path for platorm_info_xml_path_name in vendor */ |
| 132 | snprintf(platform_info_xml_path_file, sizeof(platform_info_xml_path_file), |
| 133 | "%s/%s", vendor_config_path, PLATFORM_INFO_XML_PATH_NAME); |
| 134 | return platform_info_xml_path_file; |
| 135 | } |
| 136 | |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 137 | static void process_acdb_id(const XML_Char **attr); |
Vikram Panduranga | df59cae | 2017-08-03 18:04:55 -0700 | [diff] [blame] | 138 | static void process_audio_effect(const XML_Char **attr, effect_type_t effect_type); |
| 139 | static void process_effect_aec(const XML_Char **attr); |
| 140 | static void process_effect_ns(const XML_Char **attr); |
Amit Shekhar | 5a39c91 | 2014-10-14 15:39:30 -0700 | [diff] [blame] | 141 | static void process_bit_width(const XML_Char **attr); |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 142 | static void process_pcm_id(const XML_Char **attr); |
| 143 | static void process_backend_name(const XML_Char **attr); |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 144 | static void process_interface_name(const XML_Char **attr); |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 145 | static void process_config_params(const XML_Char **attr); |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 146 | static void process_root(const XML_Char **attr); |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 147 | static void process_operator_specific(const XML_Char **attr); |
Aniket Kumar Lata | f56b640 | 2016-10-27 12:03:18 -0700 | [diff] [blame] | 148 | static void process_gain_db_to_level_map(const XML_Char **attr); |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 149 | static void process_app_type(const XML_Char **attr); |
Dhanalakshmi Siddani | 21be3ac | 2016-12-29 14:31:08 +0530 | [diff] [blame] | 150 | static void process_acdb_metainfo_key(const XML_Char **attr); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 151 | static void process_microphone_characteristic(const XML_Char **attr); |
| 152 | static void process_snd_dev(const XML_Char **attr); |
| 153 | static void process_mic_info(const XML_Char **attr); |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 154 | static void process_custom_mtmx_params(const XML_Char **attr); |
| 155 | static void process_custom_mtmx_param_coeffs(const XML_Char **attr); |
Carter Hsu | 32a6236 | 2018-10-15 15:01:42 -0700 | [diff] [blame] | 156 | static void process_external_dev(const XML_Char **attr); |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 157 | static void process_custom_mtmx_in_params(const XML_Char **attr); |
| 158 | static void process_custom_mtmx_param_in_ch_info(const XML_Char **attr); |
Guodong Hu | 1d46f34 | 2019-06-28 16:57:30 +0800 | [diff] [blame] | 159 | static void process_fluence_mmsecns(const XML_Char **attr); |
Juyu Chen | 918e1e1 | 2019-08-08 15:28:18 -0700 | [diff] [blame] | 160 | static void process_audio_source_delay(const XML_Char **attr); |
Krishna Kishor Jha | 10ad39f | 2022-02-21 17:02:47 +0530 | [diff] [blame] | 161 | #ifdef SOFT_VOLUME |
| 162 | static void process_soft_volume_params(const XML_Char **attr); |
| 163 | #endif |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 164 | |
| 165 | static section_process_fn section_table[] = { |
| 166 | [ROOT] = process_root, |
| 167 | [ACDB] = process_acdb_id, |
Vikram Panduranga | df59cae | 2017-08-03 18:04:55 -0700 | [diff] [blame] | 168 | [AEC] = process_effect_aec, |
| 169 | [NS] = process_effect_ns, |
Amit Shekhar | 5a39c91 | 2014-10-14 15:39:30 -0700 | [diff] [blame] | 170 | [BITWIDTH] = process_bit_width, |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 171 | [PCM_ID] = process_pcm_id, |
| 172 | [BACKEND_NAME] = process_backend_name, |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 173 | [INTERFACE_NAME] = process_interface_name, |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 174 | [CONFIG_PARAMS] = process_config_params, |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 175 | [OPERATOR_SPECIFIC] = process_operator_specific, |
| 176 | [APP_TYPE] = process_app_type, |
Aniket Kumar Lata | f56b640 | 2016-10-27 12:03:18 -0700 | [diff] [blame] | 177 | [GAIN_LEVEL_MAPPING] = process_gain_db_to_level_map, |
Dhanalakshmi Siddani | 21be3ac | 2016-12-29 14:31:08 +0530 | [diff] [blame] | 178 | [ACDB_METAINFO_KEY] = process_acdb_metainfo_key, |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 179 | [MICROPHONE_CHARACTERISTIC] = process_microphone_characteristic, |
| 180 | [SND_DEV] = process_snd_dev, |
| 181 | [MIC_INFO] = process_mic_info, |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 182 | [CUSTOM_MTMX_PARAMS] = process_custom_mtmx_params, |
| 183 | [CUSTOM_MTMX_PARAM_COEFFS] = process_custom_mtmx_param_coeffs, |
Carter Hsu | 32a6236 | 2018-10-15 15:01:42 -0700 | [diff] [blame] | 184 | [EXTERNAL_DEVICE_SPECIFIC] = process_external_dev, |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 185 | [CUSTOM_MTMX_IN_PARAMS] = process_custom_mtmx_in_params, |
| 186 | [CUSTOM_MTMX_PARAM_IN_CH_INFO] = process_custom_mtmx_param_in_ch_info, |
Guodong Hu | 1d46f34 | 2019-06-28 16:57:30 +0800 | [diff] [blame] | 187 | [MMSECNS] = process_fluence_mmsecns, |
Juyu Chen | 918e1e1 | 2019-08-08 15:28:18 -0700 | [diff] [blame] | 188 | [AUDIO_SOURCE_DELAY] = process_audio_source_delay, |
Krishna Kishor Jha | 10ad39f | 2022-02-21 17:02:47 +0530 | [diff] [blame] | 189 | #ifdef SOFT_VOLUME |
| 190 | [SOFT_VOLUME_PARAMS] = process_soft_volume_params, |
| 191 | #endif |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 192 | }; |
| 193 | |
| 194 | static section_t section; |
| 195 | |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 196 | struct platform_info { |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 197 | caller_t caller; |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 198 | void *platform; |
| 199 | struct str_parms *kvpairs; |
| 200 | }; |
| 201 | |
| 202 | static struct platform_info my_data; |
Weiyin Jiang | 13bcdde | 2019-09-06 16:59:32 +0800 | [diff] [blame] | 203 | static pthread_mutex_t parser_lock = PTHREAD_MUTEX_INITIALIZER; |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 204 | |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 205 | |
| 206 | struct audio_string_to_enum { |
| 207 | const char* name; |
| 208 | unsigned int value; |
| 209 | }; |
| 210 | |
| 211 | static snd_device_t in_snd_device; |
| 212 | |
| 213 | static const struct audio_string_to_enum mic_locations[AUDIO_MICROPHONE_LOCATION_CNT] = { |
| 214 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_LOCATION_UNKNOWN), |
| 215 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_LOCATION_MAINBODY), |
| 216 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_LOCATION_MAINBODY_MOVABLE), |
| 217 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_LOCATION_PERIPHERAL), |
| 218 | }; |
| 219 | |
| 220 | static const struct audio_string_to_enum mic_directionalities[AUDIO_MICROPHONE_DIRECTIONALITY_CNT] = { |
| 221 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_DIRECTIONALITY_OMNI), |
| 222 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_DIRECTIONALITY_BI_DIRECTIONAL), |
| 223 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_DIRECTIONALITY_UNKNOWN), |
| 224 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_DIRECTIONALITY_CARDIOID), |
| 225 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_DIRECTIONALITY_HYPER_CARDIOID), |
| 226 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_DIRECTIONALITY_SUPER_CARDIOID), |
| 227 | }; |
| 228 | |
| 229 | static const struct audio_string_to_enum mic_channel_mapping[AUDIO_MICROPHONE_CHANNEL_MAPPING_CNT] = { |
| 230 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_CHANNEL_MAPPING_UNUSED), |
| 231 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_CHANNEL_MAPPING_DIRECT), |
| 232 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_MICROPHONE_CHANNEL_MAPPING_PROCESSED), |
| 233 | }; |
| 234 | |
| 235 | static const struct audio_string_to_enum device_in_types[] = { |
| 236 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_AMBIENT), |
| 237 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_COMMUNICATION), |
| 238 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BUILTIN_MIC), |
| 239 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET), |
| 240 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_WIRED_HEADSET), |
| 241 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_AUX_DIGITAL), |
| 242 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_HDMI), |
| 243 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_VOICE_CALL), |
| 244 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_TELEPHONY_RX), |
| 245 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BACK_MIC), |
| 246 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_REMOTE_SUBMIX), |
| 247 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET), |
| 248 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET), |
| 249 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_USB_ACCESSORY), |
| 250 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_USB_DEVICE), |
| 251 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_FM_TUNER), |
| 252 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_TV_TUNER), |
| 253 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_LINE), |
| 254 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_SPDIF), |
| 255 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BLUETOOTH_A2DP), |
| 256 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_LOOPBACK), |
| 257 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_IP), |
| 258 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BUS), |
| 259 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_PROXY), |
| 260 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_USB_HEADSET), |
| 261 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_BLUETOOTH_BLE), |
| 262 | AUDIO_MAKE_STRING_FROM_ENUM(AUDIO_DEVICE_IN_DEFAULT), |
| 263 | }; |
| 264 | |
| 265 | enum { |
| 266 | AUDIO_MICROPHONE_CHARACTERISTIC_NONE = 0u, // 0x0 |
| 267 | AUDIO_MICROPHONE_CHARACTERISTIC_SENSITIVITY = 1u, // 0x1 |
| 268 | AUDIO_MICROPHONE_CHARACTERISTIC_MAX_SPL = 2u, // 0x2 |
| 269 | AUDIO_MICROPHONE_CHARACTERISTIC_MIN_SPL = 4u, // 0x4 |
| 270 | AUDIO_MICROPHONE_CHARACTERISTIC_ORIENTATION = 8u, // 0x8 |
| 271 | AUDIO_MICROPHONE_CHARACTERISTIC_GEOMETRIC_LOCATION = 16u, // 0x10 |
| 272 | AUDIO_MICROPHONE_CHARACTERISTIC_ALL = 31u, /* ((((SENSITIVITY | MAX_SPL) | MIN_SPL) |
| 273 | | ORIENTATION) | GEOMETRIC_LOCATION) */ |
| 274 | }; |
| 275 | |
| 276 | static bool find_enum_by_string(const struct audio_string_to_enum * table, const char * name, |
| 277 | int32_t len, unsigned int *value) |
| 278 | { |
| 279 | if (table == NULL) { |
| 280 | ALOGE("%s: table is NULL", __func__); |
| 281 | return false; |
| 282 | } |
| 283 | |
| 284 | if (name == NULL) { |
| 285 | ALOGE("null key"); |
| 286 | return false; |
| 287 | } |
| 288 | |
| 289 | for (int i = 0; i < len; i++) { |
| 290 | if (!strcmp(table[i].name, name)) { |
| 291 | *value = table[i].value; |
| 292 | return true; |
| 293 | } |
| 294 | } |
| 295 | return false; |
| 296 | } |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 297 | |
| 298 | static struct audio_custom_mtmx_params_info mtmx_params_info; |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 299 | static struct audio_custom_mtmx_in_params_info mtmx_in_params_info; |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 300 | |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 301 | static void process_root(const XML_Char **attr __unused) |
| 302 | { |
| 303 | } |
| 304 | |
Krishna Kishor Jha | 10ad39f | 2022-02-21 17:02:47 +0530 | [diff] [blame] | 305 | #ifdef SOFT_VOLUME |
| 306 | /**mapping usecase and soft volume params **/ |
| 307 | static void process_soft_volume_params(const XML_Char **attr) |
| 308 | { |
| 309 | int index; |
| 310 | |
| 311 | if (strcmp(attr[0], "name") != 0) { |
| 312 | ALOGE("%s: 'name' not found, no pcm_id set!", __func__); |
| 313 | goto done; |
| 314 | } |
| 315 | |
| 316 | index = platform_get_usecase_index((char *)attr[1]); |
| 317 | if (index < 0) { |
| 318 | ALOGE("%s: usecase %s not found!", |
| 319 | __func__, attr[1]); |
| 320 | goto done; |
| 321 | } |
| 322 | |
| 323 | if (strcmp(attr[2], "period") != 0) { |
| 324 | ALOGE("%s: ramp period not mentioned", __func__); |
| 325 | goto done; |
| 326 | } |
| 327 | |
| 328 | int period = atoi((char *)attr[3]); |
| 329 | |
| 330 | if (strcmp(attr[4], "step") != 0) { |
| 331 | ALOGE("%s: ramp period not mentioned", __func__); |
| 332 | goto done; |
| 333 | } |
| 334 | int step = atoi((char *)attr[5]); |
| 335 | |
| 336 | if (strcmp(attr[6], "curve") != 0) { |
| 337 | ALOGE("%s: usecase id not mentioned", __func__); |
| 338 | goto done; |
| 339 | } |
| 340 | |
| 341 | int curve = atoi((char *)attr[7]); |
| 342 | |
| 343 | if (platform_set_soft_step_volume_params(index, period, step, curve) < 0) { |
| 344 | ALOGE("%s: usecase %s period %d step %d curve %d ", |
| 345 | __func__, attr[1], period, step, curve); |
| 346 | goto done; |
| 347 | } |
| 348 | |
| 349 | done: |
| 350 | return; |
| 351 | } |
| 352 | #endif |
| 353 | |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 354 | /* mapping from usecase to pcm dev id */ |
| 355 | static void process_pcm_id(const XML_Char **attr) |
| 356 | { |
| 357 | int index; |
| 358 | |
| 359 | if (strcmp(attr[0], "name") != 0) { |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 360 | ALOGE("%s: 'name' not found, no pcm_id set!", __func__); |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 361 | goto done; |
| 362 | } |
| 363 | |
| 364 | index = platform_get_usecase_index((char *)attr[1]); |
| 365 | if (index < 0) { |
| 366 | ALOGE("%s: usecase %s not found!", |
| 367 | __func__, attr[1]); |
| 368 | goto done; |
| 369 | } |
| 370 | |
| 371 | if (strcmp(attr[2], "type") != 0) { |
| 372 | ALOGE("%s: usecase type not mentioned", __func__); |
| 373 | goto done; |
| 374 | } |
| 375 | |
| 376 | int type = -1; |
| 377 | |
| 378 | if (!strcasecmp((char *)attr[3], "in")) { |
| 379 | type = 1; |
| 380 | } else if (!strcasecmp((char *)attr[3], "out")) { |
| 381 | type = 0; |
| 382 | } else { |
| 383 | ALOGE("%s: type must be IN or OUT", __func__); |
| 384 | goto done; |
| 385 | } |
| 386 | |
| 387 | if (strcmp(attr[4], "id") != 0) { |
| 388 | ALOGE("%s: usecase id not mentioned", __func__); |
| 389 | goto done; |
| 390 | } |
| 391 | |
| 392 | int id = atoi((char *)attr[5]); |
| 393 | |
| 394 | if (platform_set_usecase_pcm_id(index, type, id) < 0) { |
| 395 | ALOGE("%s: usecase %s type %d id %d was not set!", |
| 396 | __func__, attr[1], type, id); |
| 397 | goto done; |
| 398 | } |
| 399 | |
| 400 | done: |
| 401 | return; |
| 402 | } |
| 403 | |
| 404 | /* backend to be used for a device */ |
| 405 | static void process_backend_name(const XML_Char **attr) |
| 406 | { |
| 407 | int index; |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 408 | char *hw_interface = NULL; |
Ashish Jain | d150d4c | 2017-02-03 18:44:34 +0530 | [diff] [blame] | 409 | char *backend = NULL; |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 410 | |
| 411 | if (strcmp(attr[0], "name") != 0) { |
| 412 | ALOGE("%s: 'name' not found, no ACDB ID set!", __func__); |
| 413 | goto done; |
| 414 | } |
| 415 | |
| 416 | index = platform_get_snd_device_index((char *)attr[1]); |
| 417 | if (index < 0) { |
| 418 | ALOGE("%s: Device %s not found, no ACDB ID set!", |
| 419 | __func__, attr[1]); |
| 420 | goto done; |
| 421 | } |
| 422 | |
| 423 | if (strcmp(attr[2], "backend") != 0) { |
Ashish Jain | d150d4c | 2017-02-03 18:44:34 +0530 | [diff] [blame] | 424 | if (strcmp(attr[2], "interface") == 0) |
| 425 | hw_interface = (char *)attr[3]; |
| 426 | } else { |
| 427 | backend = (char *)attr[3]; |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 428 | } |
| 429 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 430 | if (attr[4] != NULL) { |
| 431 | if (strcmp(attr[4], "interface") != 0) { |
| 432 | hw_interface = NULL; |
| 433 | } else { |
| 434 | hw_interface = (char *)attr[5]; |
| 435 | } |
| 436 | } |
| 437 | |
Ashish Jain | d150d4c | 2017-02-03 18:44:34 +0530 | [diff] [blame] | 438 | if (platform_set_snd_device_backend(index, backend, hw_interface) < 0) { |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 439 | ALOGE("%s: Device %s backend %s was not set!", |
| 440 | __func__, attr[1], attr[3]); |
| 441 | goto done; |
| 442 | } |
| 443 | |
| 444 | done: |
| 445 | return; |
| 446 | } |
| 447 | |
Aniket Kumar Lata | f56b640 | 2016-10-27 12:03:18 -0700 | [diff] [blame] | 448 | static void process_gain_db_to_level_map(const XML_Char **attr) |
| 449 | { |
| 450 | struct amp_db_and_gain_table tbl_entry; |
| 451 | |
| 452 | if ((strcmp(attr[0], "db") != 0) || |
| 453 | (strcmp(attr[2], "level") != 0)) { |
| 454 | ALOGE("%s: invalid attribute passed %s %sexpected amp db level", |
| 455 | __func__, attr[0], attr[2]); |
| 456 | goto done; |
| 457 | } |
| 458 | |
| 459 | tbl_entry.db = atof(attr[1]); |
| 460 | tbl_entry.amp = exp(tbl_entry.db * 0.115129f); |
| 461 | tbl_entry.level = atoi(attr[3]); |
| 462 | |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 463 | //custome level should be > 0. Level 0 is fixed for default |
| 464 | CHECK(tbl_entry.level > 0); |
| 465 | |
Aniket Kumar Lata | f56b640 | 2016-10-27 12:03:18 -0700 | [diff] [blame] | 466 | ALOGV("%s: amp [%f] db [%f] level [%d]", __func__, |
| 467 | tbl_entry.amp, tbl_entry.db, tbl_entry.level); |
| 468 | platform_add_gain_level_mapping(&tbl_entry); |
| 469 | |
| 470 | done: |
| 471 | return; |
| 472 | } |
| 473 | |
| 474 | |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 475 | static void process_acdb_id(const XML_Char **attr) |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 476 | { |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 477 | int index; |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 478 | |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 479 | if (strcmp(attr[0], "name") != 0) { |
| 480 | ALOGE("%s: 'name' not found, no ACDB ID set!", __func__); |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 481 | goto done; |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 482 | } |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 483 | |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 484 | index = platform_get_snd_device_index((char *)attr[1]); |
| 485 | if (index < 0) { |
Helen Zeng | 6a16ad7 | 2014-02-23 22:04:44 -0800 | [diff] [blame] | 486 | ALOGE("%s: Device %s in platform info xml not found, no ACDB ID set!", |
| 487 | __func__, attr[1]); |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 488 | goto done; |
| 489 | } |
| 490 | |
| 491 | if (strcmp(attr[2], "acdb_id") != 0) { |
Helen Zeng | 6a16ad7 | 2014-02-23 22:04:44 -0800 | [diff] [blame] | 492 | ALOGE("%s: Device %s in platform info xml has no acdb_id, no ACDB ID set!", |
| 493 | __func__, attr[1]); |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 494 | goto done; |
| 495 | } |
| 496 | |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 497 | if (platform_set_snd_device_acdb_id(index, atoi((char *)attr[3])) < 0) { |
| 498 | ALOGE("%s: Device %s, ACDB ID %d was not set!", |
Helen Zeng | 6a16ad7 | 2014-02-23 22:04:44 -0800 | [diff] [blame] | 499 | __func__, attr[1], atoi((char *)attr[3])); |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 500 | goto done; |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 501 | } |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 502 | |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 503 | done: |
| 504 | return; |
| 505 | } |
| 506 | |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 507 | static void process_operator_specific(const XML_Char **attr) |
| 508 | { |
| 509 | snd_device_t snd_device = SND_DEVICE_NONE; |
| 510 | |
| 511 | if (strcmp(attr[0], "name") != 0) { |
| 512 | ALOGE("%s: 'name' not found", __func__); |
| 513 | goto done; |
| 514 | } |
| 515 | |
| 516 | snd_device = platform_get_snd_device_index((char *)attr[1]); |
| 517 | if (snd_device < 0) { |
| 518 | ALOGE("%s: Device %s in %s not found, no ACDB ID set!", |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 519 | __func__, (char *)attr[3], get_platform_xml_path()); |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 520 | goto done; |
| 521 | } |
| 522 | |
| 523 | if (strcmp(attr[2], "operator") != 0) { |
| 524 | ALOGE("%s: 'operator' not found", __func__); |
| 525 | goto done; |
| 526 | } |
| 527 | |
| 528 | if (strcmp(attr[4], "mixer_path") != 0) { |
| 529 | ALOGE("%s: 'mixer_path' not found", __func__); |
| 530 | goto done; |
| 531 | } |
| 532 | |
| 533 | if (strcmp(attr[6], "acdb_id") != 0) { |
| 534 | ALOGE("%s: 'acdb_id' not found", __func__); |
| 535 | goto done; |
| 536 | } |
| 537 | |
| 538 | platform_add_operator_specific_device(snd_device, (char *)attr[3], (char *)attr[5], atoi((char *)attr[7])); |
| 539 | |
| 540 | done: |
| 541 | return; |
| 542 | } |
| 543 | |
Carter Hsu | 32a6236 | 2018-10-15 15:01:42 -0700 | [diff] [blame] | 544 | static void process_external_dev(const XML_Char **attr) |
| 545 | { |
| 546 | snd_device_t snd_device = SND_DEVICE_NONE; |
| 547 | |
| 548 | if (strcmp(attr[0], "name") != 0) { |
| 549 | ALOGE("%s: 'name' not found", __func__); |
| 550 | goto done; |
| 551 | } |
| 552 | |
| 553 | snd_device = platform_get_snd_device_index((char *)attr[1]); |
| 554 | if (snd_device < 0) { |
| 555 | ALOGE("%s: Device %s in %s not found, no ACDB ID set!", |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 556 | __func__, (char *)attr[3], get_platform_xml_path()); |
Carter Hsu | 32a6236 | 2018-10-15 15:01:42 -0700 | [diff] [blame] | 557 | goto done; |
| 558 | } |
| 559 | |
| 560 | if (strcmp(attr[2], "usbid") != 0) { |
| 561 | ALOGE("%s: 'usbid' not found", __func__); |
| 562 | goto done; |
| 563 | } |
| 564 | |
| 565 | if (strcmp(attr[4], "acdb_id") != 0) { |
| 566 | ALOGE("%s: 'acdb_id' not found", __func__); |
| 567 | goto done; |
| 568 | } |
| 569 | |
| 570 | platform_add_external_specific_device(snd_device, (char *)attr[3], atoi((char *)attr[5])); |
| 571 | |
| 572 | done: |
| 573 | return; |
| 574 | } |
| 575 | |
Vikram Panduranga | df59cae | 2017-08-03 18:04:55 -0700 | [diff] [blame] | 576 | static void process_audio_effect(const XML_Char **attr, effect_type_t effect_type) |
| 577 | { |
| 578 | int index; |
| 579 | struct audio_effect_config effect_config; |
| 580 | |
| 581 | if (strcmp(attr[0], "name") != 0) { |
| 582 | ALOGE("%s: 'name' not found, no MODULE ID set!", __func__); |
| 583 | goto done; |
| 584 | } |
| 585 | |
| 586 | index = platform_get_snd_device_index((char *)attr[1]); |
| 587 | if (index < 0) { |
| 588 | ALOGE("%s: Device %s in platform info xml not found, no MODULE ID set!", |
| 589 | __func__, attr[1]); |
| 590 | goto done; |
| 591 | } |
| 592 | |
| 593 | if (strcmp(attr[2], "module_id") != 0) { |
| 594 | ALOGE("%s: Device %s in platform info xml has no module_id, no MODULE ID set!", |
| 595 | __func__, attr[2]); |
| 596 | goto done; |
| 597 | } |
| 598 | |
| 599 | if (strcmp(attr[4], "instance_id") != 0) { |
| 600 | ALOGE("%s: Device %s in platform info xml has no instance_id, no INSTANCE ID set!", |
| 601 | __func__, attr[4]); |
| 602 | goto done; |
| 603 | } |
| 604 | |
| 605 | if (strcmp(attr[6], "param_id") != 0) { |
| 606 | ALOGE("%s: Device %s in platform info xml has no param_id, no PARAM ID set!", |
| 607 | __func__, attr[6]); |
| 608 | goto done; |
| 609 | } |
| 610 | |
| 611 | if (strcmp(attr[8], "param_value") != 0) { |
| 612 | ALOGE("%s: Device %s in platform info xml has no param_value, no PARAM VALUE set!", |
| 613 | __func__, attr[8]); |
| 614 | goto done; |
| 615 | } |
| 616 | |
| 617 | effect_config = (struct audio_effect_config){strtol((char *)attr[3], NULL, 0), |
| 618 | strtol((char *)attr[5], NULL, 0), |
| 619 | strtol((char *)attr[7], NULL, 0), |
| 620 | strtol((char *)attr[9], NULL, 0)}; |
| 621 | |
Vikram Panduranga | df59cae | 2017-08-03 18:04:55 -0700 | [diff] [blame] | 622 | if (platform_set_effect_config_data(index, effect_config, effect_type) < 0) { |
| 623 | ALOGE("%s: Effect = %d Device %s, MODULE/INSTANCE/PARAM ID %lu %lu %lu %lu was not set!", |
| 624 | __func__, effect_type, attr[1], strtol((char *)attr[3], NULL, 0), |
| 625 | strtol((char *)attr[5], NULL, 0), strtol((char *)attr[7], NULL, 0), |
| 626 | strtol((char *)attr[9], NULL, 0)); |
| 627 | goto done; |
| 628 | } |
| 629 | |
| 630 | done: |
| 631 | return; |
| 632 | } |
| 633 | |
| 634 | static void process_effect_aec(const XML_Char **attr) |
| 635 | { |
| 636 | process_audio_effect(attr, EFFECT_AEC); |
| 637 | return; |
| 638 | } |
| 639 | |
| 640 | static void process_effect_ns(const XML_Char **attr) |
| 641 | { |
| 642 | process_audio_effect(attr, EFFECT_NS); |
| 643 | return; |
| 644 | } |
| 645 | |
Guodong Hu | 1d46f34 | 2019-06-28 16:57:30 +0800 | [diff] [blame] | 646 | static void process_fluence_mmsecns(const XML_Char **attr) |
| 647 | { |
| 648 | int index; |
| 649 | struct audio_fluence_mmsecns_config fluence_mmsecns_config; |
| 650 | |
| 651 | if (strcmp(attr[0], "name") != 0) { |
| 652 | ALOGE("%s: 'name' not found, no MODULE ID set!", __func__); |
| 653 | goto done; |
| 654 | } |
| 655 | |
| 656 | index = platform_get_snd_device_index((char *)attr[1]); |
| 657 | if (index < 0) { |
| 658 | ALOGE("%s: Device %s in platform info xml not found, no MODULE ID set!", |
| 659 | __func__, attr[1]); |
| 660 | goto done; |
| 661 | } |
| 662 | |
| 663 | if (strcmp(attr[2], "topology_id") != 0) { |
| 664 | ALOGE("%s: Device %s in platform info xml has no topology_id, no MODULE ID set!", |
| 665 | __func__, attr[2]); |
| 666 | goto done; |
| 667 | } |
| 668 | |
| 669 | if (strcmp(attr[4], "module_id") != 0) { |
| 670 | ALOGE("%s: Device %s in platform info xml has no module_id, no MODULE ID set!", |
| 671 | __func__, attr[4]); |
| 672 | goto done; |
| 673 | } |
| 674 | |
| 675 | if (strcmp(attr[6], "instance_id") != 0) { |
| 676 | ALOGE("%s: Device %s in platform info xml has no instance_id, no INSTANCE ID set!", |
| 677 | __func__, attr[6]); |
| 678 | goto done; |
| 679 | } |
| 680 | |
| 681 | if (strcmp(attr[8], "param_id") != 0) { |
| 682 | ALOGE("%s: Device %s in platform info xml has no param_id, no PARAM ID set!", |
| 683 | __func__, attr[8]); |
| 684 | goto done; |
| 685 | } |
| 686 | |
| 687 | fluence_mmsecns_config = (struct audio_fluence_mmsecns_config){strtol((char *)attr[3], NULL, 0), |
| 688 | strtol((char *)attr[5], NULL, 0), |
| 689 | strtol((char *)attr[7], NULL, 0), |
| 690 | strtol((char *)attr[9], NULL, 0)}; |
| 691 | |
| 692 | |
| 693 | if (platform_set_fluence_mmsecns_config(fluence_mmsecns_config) < 0) { |
| 694 | ALOGE("%s: Device %s, TOPOLOGY/MODULE/INSTANCE/PARAM ID %lu %lu %lu %lu was not set!", |
| 695 | __func__, attr[1], strtol((char *)attr[3], NULL, 0), strtol((char *)attr[5], NULL, 0), |
| 696 | strtol((char *)attr[7], NULL, 0), strtol((char *)attr[9], NULL, 0)); |
| 697 | goto done; |
| 698 | } |
| 699 | |
| 700 | done: |
| 701 | return; |
| 702 | } |
Amit Shekhar | 5a39c91 | 2014-10-14 15:39:30 -0700 | [diff] [blame] | 703 | static void process_bit_width(const XML_Char **attr) |
| 704 | { |
| 705 | int index; |
| 706 | |
| 707 | if (strcmp(attr[0], "name") != 0) { |
| 708 | ALOGE("%s: 'name' not found, no ACDB ID set!", __func__); |
| 709 | goto done; |
| 710 | } |
| 711 | |
| 712 | index = platform_get_snd_device_index((char *)attr[1]); |
| 713 | if (index < 0) { |
| 714 | ALOGE("%s: Device %s in platform info xml not found, no ACDB ID set!", |
| 715 | __func__, attr[1]); |
| 716 | goto done; |
| 717 | } |
| 718 | |
| 719 | if (strcmp(attr[2], "bit_width") != 0) { |
| 720 | ALOGE("%s: Device %s in platform info xml has no bit_width, no ACDB ID set!", |
| 721 | __func__, attr[1]); |
| 722 | goto done; |
| 723 | } |
| 724 | |
| 725 | if (platform_set_snd_device_bit_width(index, atoi((char *)attr[3])) < 0) { |
| 726 | ALOGE("%s: Device %s, ACDB ID %d was not set!", |
| 727 | __func__, attr[1], atoi((char *)attr[3])); |
| 728 | goto done; |
| 729 | } |
| 730 | |
| 731 | done: |
| 732 | return; |
| 733 | } |
| 734 | |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 735 | static void process_interface_name(const XML_Char **attr) |
| 736 | { |
| 737 | int ret; |
| 738 | |
| 739 | if (strcmp(attr[0], "name") != 0) { |
| 740 | ALOGE("%s: 'name' not found, no Audio Interface set!", __func__); |
| 741 | |
| 742 | goto done; |
| 743 | } |
| 744 | |
| 745 | if (strcmp(attr[2], "interface") != 0) { |
| 746 | ALOGE("%s: Device %s has no Audio Interface set!", |
| 747 | __func__, attr[1]); |
| 748 | |
| 749 | goto done; |
| 750 | } |
| 751 | |
Karthik Reddy Katta | 508eca4 | 2015-05-11 13:43:18 +0530 | [diff] [blame] | 752 | if (strcmp(attr[4], "codec_type") != 0) { |
| 753 | ALOGE("%s: Device %s has no codec type set!", |
| 754 | __func__, attr[1]); |
| 755 | |
| 756 | goto done; |
| 757 | } |
| 758 | |
| 759 | ret = platform_set_audio_device_interface((char *)attr[1], (char *)attr[3], |
| 760 | (char *)attr[5]); |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 761 | if (ret < 0) { |
| 762 | ALOGE("%s: Audio Interface not set!", __func__); |
Apoorv Raghuvanshi | 2149216 | 2015-02-19 18:19:36 -0800 | [diff] [blame] | 763 | goto done; |
| 764 | } |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 765 | |
Apoorv Raghuvanshi | 2149216 | 2015-02-19 18:19:36 -0800 | [diff] [blame] | 766 | done: |
| 767 | return; |
| 768 | } |
Laxminath Kasam | 44f4940 | 2015-05-29 18:37:11 +0530 | [diff] [blame] | 769 | |
Juyu Chen | 918e1e1 | 2019-08-08 15:28:18 -0700 | [diff] [blame] | 770 | static void process_audio_source_delay(const XML_Char **attr) |
| 771 | { |
| 772 | audio_source_t audio_source = -1; |
| 773 | |
| 774 | if (strcmp(attr[0], "name") != 0) { |
| 775 | ALOGE("%s: 'name' not found", __func__); |
| 776 | goto done; |
| 777 | } |
George Gao | 9ba8a14 | 2020-07-23 14:30:03 -0700 | [diff] [blame] | 778 | |
Juyu Chen | 918e1e1 | 2019-08-08 15:28:18 -0700 | [diff] [blame] | 779 | audio_source = platform_get_audio_source_index((const char *)attr[1]); |
| 780 | |
| 781 | if (audio_source < 0) { |
| 782 | ALOGE("%s: audio_source %s is not defined", |
| 783 | __func__, (char *)attr[1]); |
| 784 | goto done; |
| 785 | } |
| 786 | |
| 787 | if (strcmp(attr[2], "delay") != 0) { |
| 788 | ALOGE("%s: 'delay' not found", __func__); |
| 789 | goto done; |
| 790 | } |
| 791 | |
| 792 | platform_set_audio_source_delay(audio_source, atoi((char *)attr[3])); |
| 793 | |
| 794 | done: |
| 795 | return; |
| 796 | } |
| 797 | |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 798 | static void process_config_params(const XML_Char **attr) |
| 799 | { |
| 800 | if (strcmp(attr[0], "key") != 0) { |
| 801 | ALOGE("%s: 'key' not found", __func__); |
| 802 | goto done; |
| 803 | } |
| 804 | |
| 805 | if (strcmp(attr[2], "value") != 0) { |
| 806 | ALOGE("%s: 'value' not found", __func__); |
| 807 | goto done; |
| 808 | } |
| 809 | |
| 810 | str_parms_add_str(my_data.kvpairs, (char*)attr[1], (char*)attr[3]); |
Aniket Kumar Lata | d64bfbd | 2019-07-09 12:01:16 -0700 | [diff] [blame] | 811 | if (my_data.caller == PLATFORM) |
| 812 | platform_set_parameters(my_data.platform, my_data.kvpairs); |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 813 | done: |
| 814 | return; |
| 815 | } |
| 816 | |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 817 | static void process_app_type(const XML_Char **attr) |
| 818 | { |
| 819 | if (strcmp(attr[0], "uc_type")) { |
| 820 | ALOGE("%s: uc_type not found", __func__); |
| 821 | goto done; |
| 822 | } |
| 823 | |
| 824 | if (strcmp(attr[2], "mode")) { |
| 825 | ALOGE("%s: mode not found", __func__); |
| 826 | goto done; |
| 827 | } |
| 828 | |
| 829 | if (strcmp(attr[4], "bit_width")) { |
| 830 | ALOGE("%s: bit_width not found", __func__); |
| 831 | goto done; |
| 832 | } |
| 833 | |
| 834 | if (strcmp(attr[6], "id")) { |
| 835 | ALOGE("%s: id not found", __func__); |
| 836 | goto done; |
| 837 | } |
| 838 | |
| 839 | if (strcmp(attr[8], "max_rate")) { |
| 840 | ALOGE("%s: max rate not found", __func__); |
| 841 | goto done; |
| 842 | } |
| 843 | |
| 844 | platform_add_app_type(attr[1], attr[3], atoi(attr[5]), atoi(attr[7]), |
| 845 | atoi(attr[9])); |
| 846 | done: |
| 847 | return; |
| 848 | } |
| 849 | |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 850 | static void process_microphone_characteristic(const XML_Char **attr) { |
| 851 | struct audio_microphone_characteristic_t microphone; |
| 852 | uint32_t curIdx = 0; |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 853 | char platform_info_xml_path[VENDOR_CONFIG_FILE_MAX_LENGTH]; |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 854 | |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 855 | strlcpy(platform_info_xml_path, get_platform_xml_path(), |
| 856 | sizeof(platform_info_xml_path)); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 857 | if (strcmp(attr[curIdx++], "valid_mask")) { |
| 858 | ALOGE("%s: valid_mask not found", __func__); |
| 859 | goto done; |
| 860 | } |
| 861 | uint32_t valid_mask = atoi(attr[curIdx++]); |
| 862 | |
| 863 | if (strcmp(attr[curIdx++], "device_id")) { |
| 864 | ALOGE("%s: device_id not found", __func__); |
| 865 | goto done; |
| 866 | } |
| 867 | if (strlen(attr[curIdx]) > AUDIO_MICROPHONE_ID_MAX_LEN) { |
| 868 | ALOGE("%s: device_id %s is too long", __func__, attr[curIdx]); |
| 869 | goto done; |
| 870 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 871 | strlcpy(microphone.device_id, attr[curIdx++], sizeof(microphone.device_id)); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 872 | |
| 873 | if (strcmp(attr[curIdx++], "type")) { |
| 874 | ALOGE("%s: device not found", __func__); |
| 875 | goto done; |
| 876 | } |
| 877 | if (!find_enum_by_string(device_in_types, (char*)attr[curIdx++], |
| 878 | ARRAY_SIZE(device_in_types), µphone.device)) { |
| 879 | ALOGE("%s: type %s in %s not found!", |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 880 | __func__, attr[--curIdx], platform_info_xml_path); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 881 | goto done; |
| 882 | } |
| 883 | |
| 884 | if (strcmp(attr[curIdx++], "address")) { |
| 885 | ALOGE("%s: address not found", __func__); |
| 886 | goto done; |
| 887 | } |
| 888 | if (strlen(attr[curIdx]) > AUDIO_DEVICE_MAX_ADDRESS_LEN) { |
| 889 | ALOGE("%s, address %s is too long", __func__, attr[curIdx]); |
| 890 | goto done; |
| 891 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 892 | strlcpy(microphone.address, attr[curIdx++], sizeof(microphone.address)); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 893 | if (strlen(microphone.address) == 0) { |
| 894 | // If the address is empty, populate the address according to device type. |
| 895 | if (microphone.device == AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 896 | strlcpy(microphone.address, AUDIO_BOTTOM_MICROPHONE_ADDRESS, sizeof(microphone.address)); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 897 | } else if (microphone.device == AUDIO_DEVICE_IN_BACK_MIC) { |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 898 | strlcpy(microphone.address, AUDIO_BACK_MICROPHONE_ADDRESS, sizeof(microphone.address)); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 899 | } |
| 900 | } |
| 901 | |
| 902 | if (strcmp(attr[curIdx++], "location")) { |
| 903 | ALOGE("%s: location not found", __func__); |
| 904 | goto done; |
| 905 | } |
| 906 | if (!find_enum_by_string(mic_locations, (char*)attr[curIdx++], |
| 907 | AUDIO_MICROPHONE_LOCATION_CNT, µphone.location)) { |
| 908 | ALOGE("%s: location %s in %s not found!", |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 909 | __func__, attr[--curIdx], platform_info_xml_path); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 910 | goto done; |
| 911 | } |
| 912 | |
| 913 | if (strcmp(attr[curIdx++], "group")) { |
| 914 | ALOGE("%s: group not found", __func__); |
| 915 | goto done; |
| 916 | } |
| 917 | microphone.group = atoi(attr[curIdx++]); |
| 918 | |
| 919 | if (strcmp(attr[curIdx++], "index_in_the_group")) { |
| 920 | ALOGE("%s: index_in_the_group not found", __func__); |
| 921 | goto done; |
| 922 | } |
| 923 | microphone.index_in_the_group = atoi(attr[curIdx++]); |
| 924 | |
| 925 | if (strcmp(attr[curIdx++], "directionality")) { |
| 926 | ALOGE("%s: directionality not found", __func__); |
| 927 | goto done; |
| 928 | } |
| 929 | if (!find_enum_by_string(mic_directionalities, (char*)attr[curIdx++], |
| 930 | AUDIO_MICROPHONE_DIRECTIONALITY_CNT, µphone.directionality)) { |
| 931 | ALOGE("%s: directionality %s in %s not found!", |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 932 | __func__, attr[--curIdx], platform_info_xml_path); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 933 | goto done; |
| 934 | } |
| 935 | |
| 936 | if (strcmp(attr[curIdx++], "num_frequency_responses")) { |
| 937 | ALOGE("%s: num_frequency_responses not found", __func__); |
| 938 | goto done; |
| 939 | } |
| 940 | microphone.num_frequency_responses = atoi(attr[curIdx++]); |
Ramjee Singh | f57ff2a | 2018-08-27 16:22:16 +0530 | [diff] [blame] | 941 | if (microphone.num_frequency_responses > AUDIO_MICROPHONE_MAX_FREQUENCY_RESPONSES) { |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 942 | ALOGE("%s: num_frequency_responses is too large", __func__); |
| 943 | goto done; |
| 944 | } |
| 945 | if (microphone.num_frequency_responses > 0) { |
| 946 | if (strcmp(attr[curIdx++], "frequencies")) { |
| 947 | ALOGE("%s: frequencies not found", __func__); |
| 948 | goto done; |
| 949 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 950 | char *context = NULL; |
| 951 | char *token = strtok_r((char *)attr[curIdx++], " ", &context); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 952 | uint32_t num_frequencies = 0; |
| 953 | while (token) { |
| 954 | microphone.frequency_responses[0][num_frequencies++] = atof(token); |
Weiyin Jiang | 20d3fa6 | 2018-08-01 18:06:27 +0800 | [diff] [blame] | 955 | if (num_frequencies >= AUDIO_MICROPHONE_MAX_FREQUENCY_RESPONSES) { |
Ramjee Singh | f57ff2a | 2018-08-27 16:22:16 +0530 | [diff] [blame] | 956 | break; |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 957 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 958 | token = strtok_r(NULL, " ", &context); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 959 | } |
| 960 | |
| 961 | if (strcmp(attr[curIdx++], "responses")) { |
| 962 | ALOGE("%s: responses not found", __func__); |
| 963 | goto done; |
| 964 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 965 | token = strtok_r((char *)attr[curIdx++], " ", &context); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 966 | uint32_t num_responses = 0; |
| 967 | while (token) { |
| 968 | microphone.frequency_responses[1][num_responses++] = atof(token); |
Weiyin Jiang | 20d3fa6 | 2018-08-01 18:06:27 +0800 | [diff] [blame] | 969 | if (num_responses >= AUDIO_MICROPHONE_MAX_FREQUENCY_RESPONSES) { |
Ramjee Singh | f57ff2a | 2018-08-27 16:22:16 +0530 | [diff] [blame] | 970 | break; |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 971 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 972 | token = strtok_r(NULL, " ", &context); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 973 | } |
| 974 | |
| 975 | if (num_frequencies != num_responses |
| 976 | || num_frequencies != microphone.num_frequency_responses) { |
| 977 | ALOGE("%s: num of frequency and response not match: %u, %u, %u", |
| 978 | __func__, num_frequencies, num_responses, microphone.num_frequency_responses); |
| 979 | goto done; |
| 980 | } |
| 981 | } |
| 982 | |
| 983 | if (valid_mask & AUDIO_MICROPHONE_CHARACTERISTIC_SENSITIVITY) { |
| 984 | if (strcmp(attr[curIdx++], "sensitivity")) { |
| 985 | ALOGE("%s: sensitivity not found", __func__); |
| 986 | goto done; |
| 987 | } |
| 988 | microphone.sensitivity = atof(attr[curIdx++]); |
| 989 | } else { |
| 990 | microphone.sensitivity = AUDIO_MICROPHONE_SENSITIVITY_UNKNOWN; |
| 991 | } |
| 992 | |
| 993 | if (valid_mask & AUDIO_MICROPHONE_CHARACTERISTIC_MAX_SPL) { |
| 994 | if (strcmp(attr[curIdx++], "max_spl")) { |
| 995 | ALOGE("%s: max_spl not found", __func__); |
| 996 | goto done; |
| 997 | } |
| 998 | microphone.max_spl = atof(attr[curIdx++]); |
| 999 | } else { |
| 1000 | microphone.max_spl = AUDIO_MICROPHONE_SPL_UNKNOWN; |
| 1001 | } |
| 1002 | |
| 1003 | if (valid_mask & AUDIO_MICROPHONE_CHARACTERISTIC_MIN_SPL) { |
| 1004 | if (strcmp(attr[curIdx++], "min_spl")) { |
| 1005 | ALOGE("%s: min_spl not found", __func__); |
| 1006 | goto done; |
| 1007 | } |
| 1008 | microphone.min_spl = atof(attr[curIdx++]); |
| 1009 | } else { |
| 1010 | microphone.min_spl = AUDIO_MICROPHONE_SPL_UNKNOWN; |
| 1011 | } |
| 1012 | |
| 1013 | if (valid_mask & AUDIO_MICROPHONE_CHARACTERISTIC_ORIENTATION) { |
| 1014 | if (strcmp(attr[curIdx++], "orientation")) { |
| 1015 | ALOGE("%s: orientation not found", __func__); |
| 1016 | goto done; |
| 1017 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 1018 | char *context = NULL; |
| 1019 | char *token = strtok_r((char *)attr[curIdx++], " ", &context); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1020 | float orientation[3]; |
| 1021 | uint32_t idx = 0; |
| 1022 | while (token) { |
| 1023 | orientation[idx++] = atof(token); |
Weiyin Jiang | 20d3fa6 | 2018-08-01 18:06:27 +0800 | [diff] [blame] | 1024 | if (idx >= 3) { |
Ramjee Singh | f57ff2a | 2018-08-27 16:22:16 +0530 | [diff] [blame] | 1025 | break; |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1026 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 1027 | token = strtok_r(NULL, " ", &context); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1028 | } |
Ramjee Singh | f57ff2a | 2018-08-27 16:22:16 +0530 | [diff] [blame] | 1029 | if (idx != 3) { |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1030 | ALOGE("%s: orientation invalid", __func__); |
| 1031 | goto done; |
| 1032 | } |
| 1033 | microphone.orientation.x = orientation[0]; |
| 1034 | microphone.orientation.y = orientation[1]; |
| 1035 | microphone.orientation.z = orientation[2]; |
| 1036 | } else { |
| 1037 | microphone.orientation.x = 0.0f; |
| 1038 | microphone.orientation.y = 0.0f; |
| 1039 | microphone.orientation.z = 0.0f; |
| 1040 | } |
| 1041 | |
| 1042 | if (valid_mask & AUDIO_MICROPHONE_CHARACTERISTIC_GEOMETRIC_LOCATION) { |
| 1043 | if (strcmp(attr[curIdx++], "geometric_location")) { |
| 1044 | ALOGE("%s: geometric_location not found", __func__); |
| 1045 | goto done; |
| 1046 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 1047 | char *context = NULL; |
| 1048 | char *token = strtok_r((char *)attr[curIdx++], " ", &context); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1049 | float geometric_location[3]; |
| 1050 | uint32_t idx = 0; |
| 1051 | while (token) { |
| 1052 | geometric_location[idx++] = atof(token); |
Weiyin Jiang | 20d3fa6 | 2018-08-01 18:06:27 +0800 | [diff] [blame] | 1053 | if (idx >= 3) { |
Ramjee Singh | f57ff2a | 2018-08-27 16:22:16 +0530 | [diff] [blame] | 1054 | break; |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1055 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 1056 | token = strtok_r(NULL, " ", &context); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1057 | } |
Ramjee Singh | f57ff2a | 2018-08-27 16:22:16 +0530 | [diff] [blame] | 1058 | if (idx != 3) { |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1059 | ALOGE("%s: geometric_location invalid", __func__); |
| 1060 | goto done; |
| 1061 | } |
| 1062 | microphone.geometric_location.x = geometric_location[0]; |
| 1063 | microphone.geometric_location.y = geometric_location[1]; |
| 1064 | microphone.geometric_location.z = geometric_location[2]; |
| 1065 | } else { |
| 1066 | microphone.geometric_location.x = AUDIO_MICROPHONE_COORDINATE_UNKNOWN; |
| 1067 | microphone.geometric_location.y = AUDIO_MICROPHONE_COORDINATE_UNKNOWN; |
| 1068 | microphone.geometric_location.z = AUDIO_MICROPHONE_COORDINATE_UNKNOWN; |
| 1069 | } |
| 1070 | |
| 1071 | platform_set_microphone_characteristic(my_data.platform, microphone); |
| 1072 | done: |
| 1073 | return; |
| 1074 | } |
| 1075 | |
| 1076 | static void process_snd_dev(const XML_Char **attr) |
| 1077 | { |
| 1078 | uint32_t curIdx = 0; |
| 1079 | in_snd_device = SND_DEVICE_NONE; |
| 1080 | |
| 1081 | if (strcmp(attr[curIdx++], "in_snd_device")) { |
| 1082 | ALOGE("%s: snd_device not found", __func__); |
| 1083 | return; |
| 1084 | } |
| 1085 | in_snd_device = platform_get_snd_device_index((char *)attr[curIdx++]); |
| 1086 | if (in_snd_device < SND_DEVICE_IN_BEGIN || |
| 1087 | in_snd_device >= SND_DEVICE_IN_END) { |
| 1088 | ALOGE("%s: Sound device not valid", __func__); |
| 1089 | in_snd_device = SND_DEVICE_NONE; |
| 1090 | } |
| 1091 | |
| 1092 | return; |
| 1093 | } |
| 1094 | |
| 1095 | static void process_mic_info(const XML_Char **attr) |
| 1096 | { |
| 1097 | uint32_t curIdx = 0; |
| 1098 | struct mic_info microphone; |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 1099 | char platform_info_xml_path[VENDOR_CONFIG_FILE_MAX_LENGTH]; |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1100 | |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 1101 | strlcpy(platform_info_xml_path, get_platform_xml_path(), |
| 1102 | sizeof(platform_info_xml_path)); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1103 | memset(µphone.channel_mapping, AUDIO_MICROPHONE_CHANNEL_MAPPING_UNUSED, |
| 1104 | sizeof(microphone.channel_mapping)); |
| 1105 | |
| 1106 | if (strcmp(attr[curIdx++], "mic_device_id")) { |
| 1107 | ALOGE("%s: mic_device_id not found", __func__); |
| 1108 | goto on_error; |
| 1109 | } |
| 1110 | strlcpy(microphone.device_id, |
| 1111 | (char *)attr[curIdx++], AUDIO_MICROPHONE_ID_MAX_LEN); |
| 1112 | |
| 1113 | if (strcmp(attr[curIdx++], "channel_mapping")) { |
| 1114 | ALOGE("%s: channel_mapping not found", __func__); |
| 1115 | goto on_error; |
| 1116 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 1117 | char *context = NULL; |
| 1118 | const char *token = strtok_r((char *)attr[curIdx++], " ", &context); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1119 | uint32_t idx = 0; |
| 1120 | while (token) { |
| 1121 | if (!find_enum_by_string(mic_channel_mapping, token, |
| 1122 | AUDIO_MICROPHONE_CHANNEL_MAPPING_CNT, |
| 1123 | µphone.channel_mapping[idx++])) { |
| 1124 | ALOGE("%s: channel_mapping %s in %s not found!", |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 1125 | __func__, attr[--curIdx], platform_info_xml_path); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1126 | goto on_error; |
| 1127 | } |
Ramjee Singh | 83e1eb1 | 2018-07-11 16:22:46 +0530 | [diff] [blame] | 1128 | token = strtok_r(NULL, " ", &context); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1129 | } |
| 1130 | microphone.channel_count = idx; |
| 1131 | |
| 1132 | platform_set_microphone_map(my_data.platform, in_snd_device, |
| 1133 | µphone); |
| 1134 | return; |
| 1135 | on_error: |
| 1136 | in_snd_device = SND_DEVICE_NONE; |
| 1137 | return; |
| 1138 | } |
| 1139 | |
| 1140 | |
Dhanalakshmi Siddani | 21be3ac | 2016-12-29 14:31:08 +0530 | [diff] [blame] | 1141 | /* process acdb meta info key value */ |
| 1142 | static void process_acdb_metainfo_key(const XML_Char **attr) |
| 1143 | { |
| 1144 | if (strcmp(attr[0], "name") != 0) { |
| 1145 | ALOGE("%s: 'name' not found", __func__); |
| 1146 | goto done; |
| 1147 | } |
| 1148 | |
| 1149 | if (strcmp(attr[2], "value") != 0) { |
| 1150 | ALOGE("%s: 'value' not found", __func__); |
| 1151 | goto done; |
| 1152 | } |
| 1153 | |
| 1154 | int key = atoi((char *)attr[3]); |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1155 | switch(my_data.caller) { |
| 1156 | case ACDB_EXTN: |
| 1157 | if(acdb_set_metainfo_key(my_data.platform, (char*)attr[1], key) < 0) { |
| 1158 | ALOGE("%s: key %d was not set!", __func__, key); |
| 1159 | goto done; |
| 1160 | } |
| 1161 | break; |
| 1162 | case PLATFORM: |
| 1163 | if(platform_set_acdb_metainfo_key(my_data.platform, (char*)attr[1], key) < 0) { |
| 1164 | ALOGE("%s: key %d was not set!", __func__, key); |
| 1165 | goto done; |
| 1166 | } |
| 1167 | break; |
| 1168 | default: |
| 1169 | ALOGE("%s: unknown caller!", __func__); |
Dhanalakshmi Siddani | 21be3ac | 2016-12-29 14:31:08 +0530 | [diff] [blame] | 1170 | } |
| 1171 | |
| 1172 | done: |
| 1173 | return; |
| 1174 | } |
| 1175 | |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 1176 | static void process_custom_mtmx_param_in_ch_info(const XML_Char **attr) |
| 1177 | { |
| 1178 | uint32_t attr_idx = 0; |
| 1179 | int32_t in_ch_idx = -1; |
| 1180 | struct audio_custom_mtmx_in_params *mtmx_in_params = NULL; |
| 1181 | |
| 1182 | mtmx_in_params = platform_get_custom_mtmx_in_params((void *)my_data.platform, |
| 1183 | &mtmx_in_params_info); |
| 1184 | if (mtmx_in_params == NULL) { |
| 1185 | ALOGE("%s: mtmx in params with given param info, not found", __func__); |
| 1186 | return; |
| 1187 | } |
| 1188 | |
| 1189 | if (strcmp(attr[attr_idx++], "in_channel_index") != 0) { |
| 1190 | ALOGE("%s: 'in_channel_index' not found", __func__); |
| 1191 | return; |
| 1192 | } |
| 1193 | |
| 1194 | in_ch_idx = atoi((char *)attr[attr_idx++]); |
| 1195 | if (in_ch_idx < 0 || in_ch_idx >= MAX_IN_CHANNELS) { |
| 1196 | ALOGE("%s: invalid input channel index(%d)", __func__, in_ch_idx); |
| 1197 | return; |
| 1198 | } |
| 1199 | |
| 1200 | if (strcmp(attr[attr_idx++], "channel_count") != 0) { |
| 1201 | ALOGE("%s: 'channel_count' not found", __func__); |
| 1202 | return; |
| 1203 | } |
| 1204 | mtmx_in_params->in_ch_info[in_ch_idx].ch_count = atoi((char *)attr[attr_idx++]); |
| 1205 | |
| 1206 | if (strcmp(attr[attr_idx++], "device") != 0) { |
| 1207 | ALOGE("%s: 'device' not found", __func__); |
| 1208 | return; |
| 1209 | } |
| 1210 | strlcpy(mtmx_in_params->in_ch_info[in_ch_idx].device, attr[attr_idx++], |
| 1211 | sizeof(mtmx_in_params->in_ch_info[in_ch_idx].device)); |
| 1212 | |
| 1213 | if (strcmp(attr[attr_idx++], "interface") != 0) { |
| 1214 | ALOGE("%s: 'interface' not found", __func__); |
| 1215 | return; |
| 1216 | } |
| 1217 | strlcpy(mtmx_in_params->in_ch_info[in_ch_idx].hw_interface, attr[attr_idx++], |
| 1218 | sizeof(mtmx_in_params->in_ch_info[in_ch_idx].hw_interface)); |
| 1219 | |
| 1220 | if (!strncmp(mtmx_in_params->in_ch_info[in_ch_idx].device, |
| 1221 | ENUM_TO_STRING(AUDIO_DEVICE_IN_BUILTIN_MIC), |
| 1222 | sizeof(mtmx_in_params->in_ch_info[in_ch_idx].device))) |
| 1223 | mtmx_in_params->mic_ch = mtmx_in_params->in_ch_info[in_ch_idx].ch_count; |
| 1224 | else if (!strncmp(mtmx_in_params->in_ch_info[in_ch_idx].device, |
| 1225 | ENUM_TO_STRING(AUDIO_DEVICE_IN_LOOPBACK), |
| 1226 | sizeof(mtmx_in_params->in_ch_info[in_ch_idx].device))) |
| 1227 | mtmx_in_params->ec_ref_ch = mtmx_in_params->in_ch_info[in_ch_idx].ch_count; |
Avinash Chandra | d7296d4 | 2021-08-04 15:07:47 +0530 | [diff] [blame] | 1228 | else if (!strncmp(mtmx_in_params->in_ch_info[in_ch_idx].device, |
| 1229 | ENUM_TO_STRING(AUDIO_DEVICE_IN_SPEAKER_MIC2), |
| 1230 | sizeof(mtmx_in_params->in_ch_info[in_ch_idx].device))) |
| 1231 | mtmx_in_params->i2s_ch = mtmx_in_params->in_ch_info[in_ch_idx].ch_count; |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 1232 | |
| 1233 | mtmx_in_params->ip_channels += mtmx_in_params->in_ch_info[in_ch_idx].ch_count; |
| 1234 | } |
| 1235 | |
| 1236 | static void process_custom_mtmx_in_params(const XML_Char **attr) |
| 1237 | { |
Chaithanya Krishna Bacharaju | 3e94c91 | 2019-05-27 11:25:44 +0530 | [diff] [blame] | 1238 | int attr_idx = 0, i = 0; |
| 1239 | char *context = NULL, *value = NULL; |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 1240 | |
| 1241 | if (strcmp(attr[attr_idx++], "usecase") != 0) { |
| 1242 | ALOGE("%s: 'usecase' not found", __func__); |
| 1243 | return; |
| 1244 | } |
Chaithanya Krishna Bacharaju | 3e94c91 | 2019-05-27 11:25:44 +0530 | [diff] [blame] | 1245 | /* Check if multi usecases are supported for this custom mtrx params */ |
| 1246 | value = strtok_r((char *)attr[attr_idx++], ",", &context); |
| 1247 | while (value && (i < CUSTOM_MTRX_PARAMS_MAX_USECASE)) { |
| 1248 | mtmx_in_params_info.usecase_id[i++] = platform_get_usecase_index(value); |
| 1249 | value = strtok_r(NULL, ",", &context); |
| 1250 | } |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 1251 | |
| 1252 | if (strcmp(attr[attr_idx++], "out_channel_count") != 0) { |
| 1253 | ALOGE("%s: 'out_channel_count' not found", __func__); |
| 1254 | return; |
| 1255 | } |
| 1256 | mtmx_in_params_info.op_channels = atoi((char *)attr[attr_idx++]); |
| 1257 | |
| 1258 | platform_add_custom_mtmx_in_params((void *)my_data.platform, &mtmx_in_params_info); |
| 1259 | |
| 1260 | } |
| 1261 | |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 1262 | static void process_custom_mtmx_param_coeffs(const XML_Char **attr) |
| 1263 | { |
| 1264 | uint32_t attr_idx = 0, out_ch_idx = -1, ch_coeff_count = 0; |
Chaithanya Krishna Bacharaju | 3e94c91 | 2019-05-27 11:25:44 +0530 | [diff] [blame] | 1265 | uint32_t ip_channels = 0, op_channels = 0, idx = 0; |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 1266 | char *context = NULL, *ch_coeff_value = NULL; |
| 1267 | struct audio_custom_mtmx_params *mtmx_params = NULL; |
| 1268 | |
| 1269 | if (strcmp(attr[attr_idx++], "out_channel_index") != 0) { |
| 1270 | ALOGE("%s: 'out_channel_index' not found", __func__); |
| 1271 | return; |
| 1272 | } |
| 1273 | out_ch_idx = atoi((char *)attr[attr_idx++]); |
| 1274 | |
| 1275 | if (out_ch_idx < 0 || out_ch_idx >= mtmx_params_info.op_channels) { |
| 1276 | ALOGE("%s: invalid out channel index(%d)", __func__, out_ch_idx); |
| 1277 | return; |
| 1278 | } |
| 1279 | |
| 1280 | if (strcmp(attr[attr_idx++], "values") != 0) { |
| 1281 | ALOGE("%s: 'values' not found", __func__); |
| 1282 | return; |
| 1283 | } |
| 1284 | mtmx_params = platform_get_custom_mtmx_params((void *)my_data.platform, |
Chaithanya Krishna Bacharaju | 3e94c91 | 2019-05-27 11:25:44 +0530 | [diff] [blame] | 1285 | &mtmx_params_info, &idx); |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 1286 | if (mtmx_params == NULL) { |
| 1287 | ALOGE("%s: mtmx params with given param info, not found", __func__); |
| 1288 | return; |
| 1289 | } |
| 1290 | ch_coeff_value = strtok_r((char *)attr[attr_idx++], " ", &context); |
| 1291 | ip_channels = mtmx_params->info.ip_channels; |
| 1292 | op_channels = mtmx_params->info.op_channels; |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 1293 | while(ch_coeff_value && ch_coeff_count < ip_channels) { |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 1294 | mtmx_params->coeffs[ip_channels * out_ch_idx + ch_coeff_count++] |
| 1295 | = atoi(ch_coeff_value); |
| 1296 | ch_coeff_value = strtok_r(NULL, " ", &context); |
| 1297 | } |
| 1298 | if (ch_coeff_count != mtmx_params->info.ip_channels || |
| 1299 | ch_coeff_value != NULL) |
| 1300 | ALOGE("%s: invalid/malformed coefficient values", __func__); |
| 1301 | } |
| 1302 | |
| 1303 | static void process_custom_mtmx_params(const XML_Char **attr) |
| 1304 | { |
Chaithanya Krishna Bacharaju | 3e94c91 | 2019-05-27 11:25:44 +0530 | [diff] [blame] | 1305 | int attr_idx = 0, i = 0; |
| 1306 | char *context = NULL, *value = NULL; |
| 1307 | |
| 1308 | memset(&mtmx_params_info, 0, sizeof(mtmx_params_info)); |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 1309 | |
| 1310 | if (strcmp(attr[attr_idx++], "param_id") != 0) { |
| 1311 | ALOGE("%s: 'param_id' not found", __func__); |
| 1312 | return; |
| 1313 | } |
| 1314 | mtmx_params_info.id = atoi((char *)attr[attr_idx++]); |
| 1315 | |
| 1316 | if (strcmp(attr[attr_idx++], "in_channel_count") != 0) { |
| 1317 | ALOGE("%s: 'in_channel_count' not found", __func__); |
| 1318 | return; |
| 1319 | } |
| 1320 | mtmx_params_info.ip_channels = atoi((char *)attr[attr_idx++]); |
| 1321 | |
| 1322 | if (strcmp(attr[attr_idx++], "out_channel_count") != 0) { |
| 1323 | ALOGE("%s: 'out_channel_count' not found", __func__); |
| 1324 | return; |
| 1325 | } |
| 1326 | mtmx_params_info.op_channels = atoi((char *)attr[attr_idx++]); |
| 1327 | |
| 1328 | if (strcmp(attr[attr_idx++], "usecase") != 0) { |
| 1329 | ALOGE("%s: 'usecase' not found", __func__); |
| 1330 | return; |
| 1331 | } |
Chaithanya Krishna Bacharaju | 3e94c91 | 2019-05-27 11:25:44 +0530 | [diff] [blame] | 1332 | |
| 1333 | /* check if multi usecases are supported for this custom mtrx params */ |
| 1334 | value = strtok_r((char *)attr[attr_idx++], ",", &context); |
| 1335 | while (value && (i < CUSTOM_MTRX_PARAMS_MAX_USECASE)) { |
| 1336 | mtmx_params_info.usecase_id[i++] = platform_get_usecase_index(value); |
| 1337 | value = strtok_r(NULL, ",", &context); |
| 1338 | } |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 1339 | |
| 1340 | if (strcmp(attr[attr_idx++], "snd_device") != 0) { |
| 1341 | ALOGE("%s: 'snd_device' not found", __func__); |
| 1342 | return; |
| 1343 | } |
| 1344 | mtmx_params_info.snd_device = platform_get_snd_device_index((char *)attr[attr_idx++]); |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 1345 | |
Chaithanya Krishna Bacharaju | 3e94c91 | 2019-05-27 11:25:44 +0530 | [diff] [blame] | 1346 | if ((attr[attr_idx] != NULL) && (strcmp(attr[attr_idx++], "fe_id") == 0)) { |
| 1347 | i = 0; |
| 1348 | value = strtok_r((char *)attr[attr_idx++], ",", &context); |
| 1349 | while (value && (i < CUSTOM_MTRX_PARAMS_MAX_USECASE)) { |
| 1350 | mtmx_params_info.fe_id[i++] = atoi(value); |
| 1351 | value = strtok_r(NULL, ",", &context); |
| 1352 | } |
| 1353 | |
| 1354 | attr_idx++; |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 1355 | } |
| 1356 | |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 1357 | platform_add_custom_mtmx_params((void *)my_data.platform, &mtmx_params_info); |
| 1358 | |
| 1359 | } |
| 1360 | |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1361 | static void start_tag(void *userdata __unused, const XML_Char *tag_name, |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1362 | const XML_Char **attr) |
| 1363 | { |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1364 | if (my_data.caller == ACDB_EXTN) { |
| 1365 | if(strcmp(tag_name, "acdb_metainfo_key") == 0) { |
| 1366 | section = ACDB_METAINFO_KEY; |
| 1367 | } else if (strcmp(tag_name, "param") == 0) { |
| 1368 | if ((section != CONFIG_PARAMS) && (section != ACDB_METAINFO_KEY)) { |
| 1369 | ALOGE("param tag only supported with CONFIG_PARAMS section"); |
| 1370 | return; |
| 1371 | } |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1372 | |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1373 | section_process_fn fn = section_table[section]; |
| 1374 | fn(attr); |
Aniket Kumar Lata | f56b640 | 2016-10-27 12:03:18 -0700 | [diff] [blame] | 1375 | } |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1376 | } else if(my_data.caller == PLATFORM) { |
| 1377 | if (strcmp(tag_name, "bit_width_configs") == 0) { |
| 1378 | section = BITWIDTH; |
| 1379 | } else if (strcmp(tag_name, "acdb_ids") == 0) { |
| 1380 | section = ACDB; |
Vikram Panduranga | df59cae | 2017-08-03 18:04:55 -0700 | [diff] [blame] | 1381 | } else if (strcmp(tag_name, "module_ids") == 0) { |
| 1382 | section = MODULE; |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1383 | } else if (strcmp(tag_name, "pcm_ids") == 0) { |
| 1384 | section = PCM_ID; |
| 1385 | } else if (strcmp(tag_name, "backend_names") == 0) { |
| 1386 | section = BACKEND_NAME; |
| 1387 | } else if (strcmp(tag_name, "config_params") == 0) { |
| 1388 | section = CONFIG_PARAMS; |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1389 | } else if (strcmp(tag_name, "operator_specific") == 0) { |
| 1390 | section = OPERATOR_SPECIFIC; |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1391 | } else if (strcmp(tag_name, "interface_names") == 0) { |
| 1392 | section = INTERFACE_NAME; |
| 1393 | } else if (strcmp(tag_name, "gain_db_to_level_mapping") == 0) { |
| 1394 | section = GAIN_LEVEL_MAPPING; |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1395 | } else if (strcmp(tag_name, "app_types") == 0) { |
| 1396 | section = APP_TYPE; |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1397 | } else if(strcmp(tag_name, "acdb_metainfo_key") == 0) { |
| 1398 | section = ACDB_METAINFO_KEY; |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1399 | } else if (strcmp(tag_name, "microphone_characteristics") == 0) { |
| 1400 | section = MICROPHONE_CHARACTERISTIC; |
| 1401 | } else if (strcmp(tag_name, "snd_devices") == 0) { |
| 1402 | section = SND_DEVICES; |
Krishna Kishor Jha | 10ad39f | 2022-02-21 17:02:47 +0530 | [diff] [blame] | 1403 | #ifdef SOFT_VOLUME |
| 1404 | } else if (strcmp(tag_name, "soft_vol_params") == 0) { |
| 1405 | section = SOFT_VOLUME_PARAMS; |
| 1406 | #endif |
| 1407 | } else if (strcmp(tag_name, "device") == 0) { |
Guodong Hu | 1d46f34 | 2019-06-28 16:57:30 +0800 | [diff] [blame] | 1408 | if ((section != ACDB) && (section != AEC) && (section != NS) && (section != MMSECNS) && |
Vikram Panduranga | df59cae | 2017-08-03 18:04:55 -0700 | [diff] [blame] | 1409 | (section != BACKEND_NAME) && (section != BITWIDTH) && |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1410 | (section != INTERFACE_NAME) && (section != OPERATOR_SPECIFIC)) { |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1411 | ALOGE("device tag only supported for acdb/backend names/bitwitdh/interface names"); |
| 1412 | return; |
| 1413 | } |
Aniket Kumar Lata | f56b640 | 2016-10-27 12:03:18 -0700 | [diff] [blame] | 1414 | |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1415 | /* call into process function for the current section */ |
| 1416 | section_process_fn fn = section_table[section]; |
| 1417 | fn(attr); |
| 1418 | } else if (strcmp(tag_name, "gain_level_map") == 0) { |
| 1419 | if (section != GAIN_LEVEL_MAPPING) { |
| 1420 | ALOGE("usecase tag only supported with GAIN_LEVEL_MAPPING section"); |
| 1421 | return; |
| 1422 | } |
| 1423 | |
| 1424 | section_process_fn fn = section_table[GAIN_LEVEL_MAPPING]; |
| 1425 | fn(attr); |
| 1426 | } else if (strcmp(tag_name, "usecase") == 0) { |
| 1427 | if (section != PCM_ID) { |
| 1428 | ALOGE("usecase tag only supported with PCM_ID section"); |
| 1429 | return; |
| 1430 | } |
| 1431 | |
| 1432 | section_process_fn fn = section_table[PCM_ID]; |
| 1433 | fn(attr); |
| 1434 | } else if (strcmp(tag_name, "param") == 0) { |
| 1435 | if ((section != CONFIG_PARAMS) && (section != ACDB_METAINFO_KEY)) { |
| 1436 | ALOGE("param tag only supported with CONFIG_PARAMS section"); |
| 1437 | return; |
| 1438 | } |
| 1439 | |
| 1440 | section_process_fn fn = section_table[section]; |
| 1441 | fn(attr); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1442 | } else if (strcmp(tag_name, "aec") == 0) { |
Vikram Panduranga | df59cae | 2017-08-03 18:04:55 -0700 | [diff] [blame] | 1443 | if (section != MODULE) { |
| 1444 | ALOGE("aec tag only supported with MODULE section"); |
| 1445 | return; |
| 1446 | } |
| 1447 | section = AEC; |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1448 | } else if (strcmp(tag_name, "ns") == 0) { |
Vikram Panduranga | df59cae | 2017-08-03 18:04:55 -0700 | [diff] [blame] | 1449 | if (section != MODULE) { |
| 1450 | ALOGE("ns tag only supported with MODULE section"); |
| 1451 | return; |
| 1452 | } |
| 1453 | section = NS; |
Guodong Hu | 1d46f34 | 2019-06-28 16:57:30 +0800 | [diff] [blame] | 1454 | } else if (strcmp(tag_name, "mmsecns") == 0) { |
| 1455 | if (section != MODULE) { |
| 1456 | ALOGE("mmsecns tag only supported with MODULE section"); |
| 1457 | return; |
| 1458 | } |
| 1459 | section = MMSECNS; |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1460 | } else if (strcmp(tag_name, "gain_level_map") == 0) { |
| 1461 | if (section != GAIN_LEVEL_MAPPING) { |
| 1462 | ALOGE("gain_level_map tag only supported with GAIN_LEVEL_MAPPING section"); |
| 1463 | return; |
| 1464 | } |
| 1465 | |
| 1466 | section_process_fn fn = section_table[GAIN_LEVEL_MAPPING]; |
| 1467 | fn(attr); |
| 1468 | } else if (!strcmp(tag_name, "app")) { |
| 1469 | if (section != APP_TYPE) { |
| 1470 | ALOGE("app tag only valid in section APP_TYPE"); |
| 1471 | return; |
| 1472 | } |
| 1473 | |
| 1474 | section_process_fn fn = section_table[APP_TYPE]; |
| 1475 | fn(attr); |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1476 | } else if (strcmp(tag_name, "microphone") == 0) { |
| 1477 | if (section != MICROPHONE_CHARACTERISTIC) { |
| 1478 | ALOGE("microphone tag only supported with MICROPHONE_CHARACTERISTIC section"); |
| 1479 | return; |
| 1480 | } |
| 1481 | section_process_fn fn = section_table[MICROPHONE_CHARACTERISTIC]; |
| 1482 | fn(attr); |
| 1483 | } else if (strcmp(tag_name, "input_snd_device") == 0) { |
| 1484 | if (section != SND_DEVICES) { |
| 1485 | ALOGE("input_snd_device tag only supported with SND_DEVICES section"); |
| 1486 | return; |
| 1487 | } |
| 1488 | section = INPUT_SND_DEVICE; |
| 1489 | } else if (strcmp(tag_name, "input_snd_device_mic_mapping") == 0) { |
| 1490 | if (section != INPUT_SND_DEVICE) { |
| 1491 | ALOGE("input_snd_device_mic_mapping tag only supported with INPUT_SND_DEVICE section"); |
| 1492 | return; |
| 1493 | } |
| 1494 | section = INPUT_SND_DEVICE_TO_MIC_MAPPING; |
| 1495 | } else if (strcmp(tag_name, "snd_dev") == 0) { |
| 1496 | if (section != INPUT_SND_DEVICE_TO_MIC_MAPPING) { |
| 1497 | ALOGE("snd_dev tag only supported with INPUT_SND_DEVICE_TO_MIC_MAPPING section"); |
| 1498 | return; |
| 1499 | } |
| 1500 | section_process_fn fn = section_table[SND_DEV]; |
| 1501 | fn(attr); |
| 1502 | } else if (strcmp(tag_name, "mic_info") == 0) { |
| 1503 | if (section != INPUT_SND_DEVICE_TO_MIC_MAPPING) { |
| 1504 | ALOGE("mic_info tag only supported with INPUT_SND_DEVICE_TO_MIC_MAPPING section"); |
| 1505 | return; |
| 1506 | } |
| 1507 | if (in_snd_device == SND_DEVICE_NONE) { |
| 1508 | ALOGE("%s: Error in previous tags, do not process mic info", __func__); |
| 1509 | return; |
| 1510 | } |
| 1511 | section_process_fn fn = section_table[MIC_INFO]; |
| 1512 | fn(attr); |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 1513 | } else if (strcmp(tag_name, "custom_mtmx_params") == 0) { |
| 1514 | if (section != ROOT) { |
| 1515 | ALOGE("custom_mtmx_params tag supported only in ROOT section"); |
| 1516 | return; |
| 1517 | } |
| 1518 | section = CUSTOM_MTMX_PARAMS; |
| 1519 | section_process_fn fn = section_table[section]; |
| 1520 | fn(attr); |
| 1521 | } else if (strcmp(tag_name, "custom_mtmx_param_coeffs") == 0) { |
| 1522 | if (section != CUSTOM_MTMX_PARAMS) { |
| 1523 | ALOGE("custom_mtmx_param_coeffs tag supported only with CUSTOM_MTMX_PARAMS section"); |
| 1524 | return; |
| 1525 | } |
| 1526 | section = CUSTOM_MTMX_PARAM_COEFFS; |
| 1527 | section_process_fn fn = section_table[section]; |
| 1528 | fn(attr); |
Carter Hsu | 32a6236 | 2018-10-15 15:01:42 -0700 | [diff] [blame] | 1529 | } else if (strcmp(tag_name, "external_specific_dev") == 0) { |
| 1530 | section = EXTERNAL_DEVICE_SPECIFIC; |
| 1531 | } else if (strcmp(tag_name, "ext_device") == 0) { |
| 1532 | section_process_fn fn = section_table[section]; |
| 1533 | fn(attr); |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 1534 | } else if (strcmp(tag_name, "custom_mtmx_in_params") == 0) { |
| 1535 | if (section != ROOT) { |
| 1536 | ALOGE("custom_mtmx_in_params tag supported only in ROOT section"); |
| 1537 | return; |
| 1538 | } |
| 1539 | section = CUSTOM_MTMX_IN_PARAMS; |
| 1540 | section_process_fn fn = section_table[section]; |
| 1541 | fn(attr); |
| 1542 | } else if (strcmp(tag_name, "custom_mtmx_param_in_chs") == 0) { |
| 1543 | if (section != CUSTOM_MTMX_IN_PARAMS) { |
| 1544 | ALOGE("custom_mtmx_param_in_chs tag supported only with CUSTOM_MTMX_IN_PARAMS section"); |
| 1545 | return; |
| 1546 | } |
| 1547 | section = CUSTOM_MTMX_PARAM_IN_CH_INFO; |
Avinash Chandra | d7296d4 | 2021-08-04 15:07:47 +0530 | [diff] [blame] | 1548 | section_process_fn fn = section_table[section]; |
| 1549 | fn(attr); |
Juyu Chen | 918e1e1 | 2019-08-08 15:28:18 -0700 | [diff] [blame] | 1550 | } else if (strcmp(tag_name, "audio_input_source_delay") == 0) { |
| 1551 | section = AUDIO_SOURCE_DELAY; |
| 1552 | } else if (strcmp(tag_name, "audio_source_delay") == 0) { |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 1553 | section_process_fn fn = section_table[section]; |
| 1554 | fn(attr); |
Krishna Kishor Jha | 10ad39f | 2022-02-21 17:02:47 +0530 | [diff] [blame] | 1555 | #ifdef SOFT_VOLUME |
| 1556 | } else if (strcmp(tag_name, "vol_params") == 0) { |
| 1557 | section = SOFT_VOLUME_PARAMS; |
| 1558 | section_process_fn fn = section_table[section]; |
| 1559 | fn(attr); |
| 1560 | #endif |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 1561 | } |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1562 | } else { |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1563 | if(strcmp(tag_name, "config_params") == 0) { |
| 1564 | section = CONFIG_PARAMS; |
| 1565 | } else if (strcmp(tag_name, "param") == 0) { |
| 1566 | if (section != CONFIG_PARAMS) { |
| 1567 | ALOGE("param tag only supported with CONFIG_PARAMS section"); |
| 1568 | return; |
| 1569 | } |
| 1570 | |
| 1571 | section_process_fn fn = section_table[section]; |
| 1572 | fn(attr); |
| 1573 | } |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1574 | } |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1575 | return; |
| 1576 | } |
| 1577 | |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1578 | static void end_tag(void *userdata __unused, const XML_Char *tag_name) |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1579 | { |
Amit Shekhar | 5a39c91 | 2014-10-14 15:39:30 -0700 | [diff] [blame] | 1580 | if (strcmp(tag_name, "bit_width_configs") == 0) { |
| 1581 | section = ROOT; |
| 1582 | } else if (strcmp(tag_name, "acdb_ids") == 0) { |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1583 | section = ROOT; |
Vikram Panduranga | df59cae | 2017-08-03 18:04:55 -0700 | [diff] [blame] | 1584 | } else if (strcmp(tag_name, "module_ids") == 0) { |
| 1585 | section = ROOT; |
| 1586 | } else if (strcmp(tag_name, "aec") == 0) { |
| 1587 | section = MODULE; |
| 1588 | } else if (strcmp(tag_name, "ns") == 0) { |
| 1589 | section = MODULE; |
Guodong Hu | 1d46f34 | 2019-06-28 16:57:30 +0800 | [diff] [blame] | 1590 | } else if (strcmp(tag_name, "mmsecns") == 0) { |
| 1591 | section = MODULE; |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1592 | } else if (strcmp(tag_name, "pcm_ids") == 0) { |
| 1593 | section = ROOT; |
Krishna Kishor Jha | 10ad39f | 2022-02-21 17:02:47 +0530 | [diff] [blame] | 1594 | #ifdef SOFT_VOLUME |
| 1595 | } else if (strcmp(tag_name, "soft_volume_params") == 0) { |
| 1596 | section = ROOT; |
| 1597 | #endif |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1598 | } else if (strcmp(tag_name, "backend_names") == 0) { |
| 1599 | section = ROOT; |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 1600 | } else if (strcmp(tag_name, "config_params") == 0) { |
| 1601 | section = ROOT; |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1602 | } else if (strcmp(tag_name, "operator_specific") == 0) { |
| 1603 | section = ROOT; |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 1604 | } else if (strcmp(tag_name, "interface_names") == 0) { |
| 1605 | section = ROOT; |
Aniket Kumar Lata | f56b640 | 2016-10-27 12:03:18 -0700 | [diff] [blame] | 1606 | } else if (strcmp(tag_name, "gain_db_to_level_mapping") == 0) { |
| 1607 | section = ROOT; |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1608 | } else if (strcmp(tag_name, "app_types") == 0) { |
| 1609 | section = ROOT; |
Dhanalakshmi Siddani | 21be3ac | 2016-12-29 14:31:08 +0530 | [diff] [blame] | 1610 | } else if (strcmp(tag_name, "acdb_metainfo_key") == 0) { |
| 1611 | section = ROOT; |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1612 | } else if (strcmp(tag_name, "microphone_characteristics") == 0) { |
| 1613 | section = ROOT; |
| 1614 | } else if (strcmp(tag_name, "snd_devices") == 0) { |
| 1615 | section = ROOT; |
Carter Hsu | 32a6236 | 2018-10-15 15:01:42 -0700 | [diff] [blame] | 1616 | } else if (strcmp(tag_name, "external_specific_dev") == 0) { |
| 1617 | section = ROOT; |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1618 | } else if (strcmp(tag_name, "input_snd_device") == 0) { |
| 1619 | section = SND_DEVICES; |
| 1620 | } else if (strcmp(tag_name, "input_snd_device_mic_mapping") == 0) { |
| 1621 | section = INPUT_SND_DEVICE; |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 1622 | } else if (strcmp(tag_name, "custom_mtmx_params") == 0) { |
| 1623 | section = ROOT; |
| 1624 | } else if (strcmp(tag_name, "custom_mtmx_param_coeffs") == 0) { |
| 1625 | section = CUSTOM_MTMX_PARAMS; |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 1626 | } else if (strcmp(tag_name, "custom_mtmx_in_params") == 0) { |
| 1627 | section = ROOT; |
| 1628 | } else if (strcmp(tag_name, "custom_mtmx_param_in_chs") == 0) { |
| 1629 | section = CUSTOM_MTMX_IN_PARAMS; |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1630 | } |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1631 | } |
| 1632 | |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1633 | int platform_info_init(const char *filename, void *platform, caller_t caller_type) |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1634 | { |
| 1635 | XML_Parser parser; |
| 1636 | FILE *file; |
| 1637 | int ret = 0; |
| 1638 | int bytes_read; |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1639 | void *buf; |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1640 | char platform_info_file_name[MIXER_PATH_MAX_LENGTH]= {0}; |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 1641 | char platform_info_xml_path[VENDOR_CONFIG_FILE_MAX_LENGTH]; |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1642 | |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 1643 | strlcpy(platform_info_xml_path, get_platform_xml_path(), |
| 1644 | sizeof(platform_info_xml_path)); |
Weiyin Jiang | 13bcdde | 2019-09-06 16:59:32 +0800 | [diff] [blame] | 1645 | pthread_mutex_lock(&parser_lock); |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1646 | if (filename == NULL) |
Saurav Kumar | dba3caf | 2020-05-29 20:53:55 +0530 | [diff] [blame] | 1647 | strlcpy(platform_info_file_name, platform_info_xml_path, |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1648 | MIXER_PATH_MAX_LENGTH); |
| 1649 | else |
| 1650 | strlcpy(platform_info_file_name, filename, MIXER_PATH_MAX_LENGTH); |
| 1651 | |
| 1652 | ALOGV("%s: platform info file name is %s", __func__, |
| 1653 | platform_info_file_name); |
| 1654 | |
| 1655 | file = fopen(platform_info_file_name, "r"); |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1656 | section = ROOT; |
| 1657 | |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1658 | if (!file) { |
| 1659 | ALOGD("%s: Failed to open %s, using defaults.", |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1660 | __func__, platform_info_file_name); |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1661 | ret = -ENODEV; |
| 1662 | goto done; |
| 1663 | } |
| 1664 | |
| 1665 | parser = XML_ParserCreate(NULL); |
| 1666 | if (!parser) { |
| 1667 | ALOGE("%s: Failed to create XML parser!", __func__); |
| 1668 | ret = -ENODEV; |
| 1669 | goto err_close_file; |
| 1670 | } |
| 1671 | |
Vignesh Kulothungan | 5539688 | 2017-04-20 14:37:02 -0700 | [diff] [blame] | 1672 | my_data.caller = caller_type; |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 1673 | my_data.platform = platform; |
| 1674 | my_data.kvpairs = str_parms_create(); |
| 1675 | |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1676 | XML_SetElementHandler(parser, start_tag, end_tag); |
| 1677 | |
| 1678 | while (1) { |
| 1679 | buf = XML_GetBuffer(parser, BUF_SIZE); |
| 1680 | if (buf == NULL) { |
| 1681 | ALOGE("%s: XML_GetBuffer failed", __func__); |
| 1682 | ret = -ENOMEM; |
| 1683 | goto err_free_parser; |
| 1684 | } |
| 1685 | |
| 1686 | bytes_read = fread(buf, 1, BUF_SIZE, file); |
| 1687 | if (bytes_read < 0) { |
| 1688 | ALOGE("%s: fread failed, bytes read = %d", __func__, bytes_read); |
| 1689 | ret = bytes_read; |
| 1690 | goto err_free_parser; |
| 1691 | } |
| 1692 | |
| 1693 | if (XML_ParseBuffer(parser, bytes_read, |
| 1694 | bytes_read == 0) == XML_STATUS_ERROR) { |
| 1695 | ALOGE("%s: XML_ParseBuffer failed, for %s", |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 1696 | __func__, platform_info_file_name); |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1697 | ret = -EINVAL; |
| 1698 | goto err_free_parser; |
| 1699 | } |
| 1700 | |
| 1701 | if (bytes_read == 0) |
| 1702 | break; |
| 1703 | } |
| 1704 | |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1705 | err_free_parser: |
| 1706 | XML_ParserFree(parser); |
| 1707 | err_close_file: |
| 1708 | fclose(file); |
| 1709 | done: |
Weiyin Jiang | 13bcdde | 2019-09-06 16:59:32 +0800 | [diff] [blame] | 1710 | pthread_mutex_unlock(&parser_lock); |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 1711 | return ret; |
| 1712 | } |