audio: TV Configure  [1/2]

PD#SWPL-184688

Problem:
Switch different Tv Configure denpends on model name

Solution:
add relative logic

Verify:
yocto

Change-Id: Ic65ff1be20602eef682329333908030d39e44cd7
Signed-off-by: yanlei.li <yanlei.li@amlogic.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 46c6de4..c1943f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -105,8 +105,7 @@
 	list(APPEND EQ_DRC_FILES
 		aml_aq_hw/audio_eq_drc_compensation.c
 		aml_aq_hw/audio_eq_drc_parser.c
-		aml_aq_hw/ini/dictionary.c
-		aml_aq_hw/ini/iniparser.c)
+		)
 	add_definitions(-DUSE_EQ_DRC)
 endif()
 
@@ -226,6 +225,8 @@
 	utils/aml_reverb.c
 	utils/format.c
 	utils/aml_audio_uevent.c
+	utils/dictionary.c
+	utils/iniparser.c
 	vendor_process/audio_post_process.c
 	vendor_process/audio_effect_if.c
 	vendor_process/aml_audio_aec.c
@@ -310,8 +311,7 @@
 if(USE_EQ_DRC)
 	target_include_directories(audio_hal PRIVATE
 		./include/aml_aq_hw
-		./aml_aq_hw
-		./aml_aq_hw/ini)
+		./aml_aq_hw)
 	target_link_libraries(audio_hal ${PREBUILD_STATIC_LIBS})
 	target_compile_options(audio_hal PRIVATE -DAML_EQ_DRC)
 endif()
diff --git a/aml_aq_hw/audio_eq_drc_compensation.c b/aml_aq_hw/audio_eq_drc_compensation.c
index 2e58285..01bc0a3 100644
--- a/aml_aq_hw/audio_eq_drc_compensation.c
+++ b/aml_aq_hw/audio_eq_drc_compensation.c
@@ -26,23 +26,13 @@
 #include "audio_eq_drc_compensation.h"
 #include "aml_volume_utils.h"
 #include "aml_malloc_debug.h"
+#include "aml_conf_parser.h"
 
 #undef  LOG_TAG
 #define LOG_TAG  "audio_hw_primary"
 
 #define MODEL_SUM_DEFAULT_PATH "/vendor/etc/tvconfig/model/model_sum.ini"
 
-static struct audio_file_config_s dev_cfg[2] = {
-    {/*amlogic inner EQ & DRC*/
-        "AMLOGIC_SOC_INI_PATH",
-        "",
-    },
-    {/*ext amp EQ & DRC*/
-        "EXT_AMP_INI_PATH",
-        "",
-    }
-};
-
 uint32_t swapInt32(uint32_t value)
 {
     return ((value & 0x000000FF) << 24) |
@@ -57,24 +47,6 @@
            ((value & 0xFF00) >> 8) ;
 }
 
-static int get_model_name(char *model_name, int size)
-{
-    int ret = -1;
-    char node[PROPERTY_VALUE_MAX];
-
-    ret = property_get("vendor.tv.model_name", node, "");
-    if (ret <= 0) {
-        snprintf(model_name, size, "FHD");
-        ALOGD("%s: Can't get model name! use default model_name (%s)",
-            __FUNCTION__, model_name);
-    } else {
-        snprintf(model_name, size, "%s", node);
-        ALOGD("%s: Model Name (%s)", __FUNCTION__, model_name);
-    }
-
-    return ret;
-}
-
 static int eq_drc_ctl_value_set(int card, int val, char *name)
 {
     int ret = -1, i, num_ctl_values;
diff --git a/aml_aq_hw/audio_eq_drc_parser.c b/aml_aq_hw/audio_eq_drc_parser.c
index 0235ec6..62fc45b 100644
--- a/aml_aq_hw/audio_eq_drc_parser.c
+++ b/aml_aq_hw/audio_eq_drc_parser.c
@@ -40,15 +40,6 @@
 #define ITEM_LOGE(x...)
 #endif
 
-static int error_callback(const char *format, ...)
-{
-    va_list argptr;
-    va_start(argptr, format);
-    ITEM_LOGE(format, argptr);
-    va_end(argptr);
-    return 0;
-}
-
 static int parse_audio_source_gain_data(dictionary *pIniParser, struct eq_drc_data *p_attr)
 {
     p_attr->s_gain.enable = iniparser_getboolean(pIniParser, "source_gain:sg_enable", 0);
@@ -516,40 +507,6 @@
     return 0;
 }
 
-int parse_audio_sum(const char *file_name, char *model_name, struct audio_file_config_s *dev_cfg)
-{
-    dictionary *ini = NULL;
-    const char *ini_value = NULL;
-    char buf[128];
-
-    iniparser_set_error_callback(error_callback);
-
-    ini = iniparser_load(file_name);
-    if (ini == NULL) {
-        ITEM_LOGE("%s, INI load file (%s) error!\n", __FUNCTION__, file_name);
-        goto exit;
-    }
-
-    sprintf(buf, "%s:%s", model_name, dev_cfg->ini_header);
-    ini_value = iniparser_getstring(ini, buf, NULL);
-
-    if (ini_value == NULL || access(ini_value, F_OK) == -1) {
-        ITEM_LOGD("%s, INI File is not exist!\n", __FUNCTION__);
-        goto exit;
-    }
-
-    memset(dev_cfg->ini_file, 0, sizeof(dev_cfg->ini_file));
-    strncpy(dev_cfg->ini_file, ini_value, MAX_FILE_NAME_SIZE - 1);
-    ITEM_LOGD("%s, INI File -> (%s)\n", __FUNCTION__, dev_cfg->ini_file);
-
-    iniparser_freedict(ini);
-    return 0;
-
-exit:
-    iniparser_freedict(ini);
-    return -1;
-}
-
 int parse_audio_gain(char *file_name, struct eq_drc_data *p_attr)
 {
     dictionary *ini = NULL;
diff --git a/aml_aq_hw/audio_eq_drc_parser.h b/aml_aq_hw/audio_eq_drc_parser.h
index 417a461..c0acf5b 100644
--- a/aml_aq_hw/audio_eq_drc_parser.h
+++ b/aml_aq_hw/audio_eq_drc_parser.h
@@ -24,11 +24,7 @@
 #define MAX_INT_TABLE_MAX 2048
 #define MAX_STRING_TABLE_MAX 16384
 
-/*ini file parser*/
-struct audio_file_config_s {
-    char ini_header[MAX_NAME_SIZE];
-    char ini_file[MAX_FILE_NAME_SIZE];
-};
+
 
 /*software source gain in audio hal*/
 struct audio_source_gain_s {
@@ -145,7 +141,6 @@
 extern "C" {
 #endif
 
-int parse_audio_sum(const char *file_name, char *model_name, struct audio_file_config_s *dev_cfg);
 int parse_audio_gain(char *file_name, struct eq_drc_data *p_attr);
 int parse_audio_eq_drc_status(char *file_name, struct audio_eq_drc_info_s *p_attr);
 int parse_audio_eq_drc_table(char *file_name, struct audio_eq_drc_info_s *p_attr);
diff --git a/audio_hal/aml_config_data.c b/audio_hal/aml_config_data.c
index a99c23c..fa41b8a 100644
--- a/audio_hal/aml_config_data.c
+++ b/audio_hal/aml_config_data.c
@@ -24,11 +24,15 @@
 #include <hardware/audio.h>
 #include "aml_config_parser.h"
 #include "aml_config_data.h"
+#include "aml_conf_parser.h"
+#include "audio_hw_utils.h"
+
 #define PROPERTY_VALUE_MAX  256
 
 
 #define AML_AUDIO_CONFIG_FILE_PATH "/etc/halaudio/aml_audio_config.json"
 #define AML_AUDIO_AVSYNC_FILE_PATH "/etc/halaudio/audio_hal_delay_base.json"
+#define MODEL_SUM_DEFAULT_PATH "/vendor/etc/tvconfig/model/model_sum.ini"
 cJSON *audio_config_jason = NULL;
 cJSON *audio_avsync_jason = NULL;
 
@@ -43,9 +47,43 @@
     }
 }
 
+char *aml_audio_cfg_path_get(char *cfg_title)
+{
+    int ret, num;
+    int cfg_num = -1;
+    char model_name[50] = {0};
+    const char *filename = MODEL_SUM_DEFAULT_PATH;
+    ret = get_model_name(model_name, sizeof(model_name));
+    if (ret < 0) {
+        return NULL;
+    }
+    int dev_cfg_size = sizeof(dev_cfg)/ sizeof(struct audio_file_config_s);
+    for (num = 0; num < dev_cfg_size; num++ ) {
+        if (!strcmp(dev_cfg[num].ini_header ,cfg_title)) {
+            cfg_num = num;
+            break;
+        }
+    }
+    if (cfg_num < 0) {
+        ALOGE("Didn't find this cfg_title : %s", cfg_title);
+        return NULL;
+    }
+    ret = parse_audio_sum(filename, model_name, &dev_cfg[cfg_num]);
+    if (ret < 0) {
+        return NULL;
+    }
+    return dev_cfg[num].ini_file;
+}
+
 int aml_audio_avsync_parser()
 {
-    audio_avsync_jason = aml_config_parser(AML_AUDIO_AVSYNC_FILE_PATH);
+    char* config_path;
+    config_path = aml_audio_cfg_path_get("AMLOGIC_DELAY_BASE_PATH");
+    if (config_path != NULL) {
+        audio_avsync_jason = aml_config_parser(config_path);
+    } else {
+        audio_avsync_jason = aml_config_parser(AML_AUDIO_AVSYNC_FILE_PATH);
+    }
     if (audio_avsync_jason) {
         return 0;
     } else {
diff --git a/audio_hal/aml_config_data.h b/audio_hal/aml_config_data.h
index e28e84d..2e5eabe 100644
--- a/audio_hal/aml_config_data.h
+++ b/audio_hal/aml_config_data.h
@@ -35,4 +35,5 @@
 char* aml_get_jason_string_value(char* key);
 int audio_hal_property_list_loading();
 
+char *aml_audio_cfg_path_get(char *cfg_path);
 #endif
diff --git a/audio_hal/audio_hw.c b/audio_hal/audio_hw.c
index ab477ce..bf36c4b 100644
--- a/audio_hal/audio_hw.c
+++ b/audio_hal/audio_hw.c
@@ -8995,7 +8995,12 @@
                     adev->is_ms12_tuning_dat = is_ms12_tuning_dat_in_dut(DOLBY_TUNING_DAT);
                     if (adev->is_ms12_tuning_dat) {
                         memset(adev->ms12_tuning_dat_path, 0, AUDIO_HAL_CHAR_MAX_LEN);
-                        memcpy(adev->ms12_tuning_dat_path, DOLBY_TUNING_DAT, sizeof(DOLBY_TUNING_DAT));
+                        char *tuning_dat_ini_path = aml_audio_cfg_path_get("AMLOG_MS12_TUNING_DATA");
+                        if (is_ms12_tuning_dat_in_dut(tuning_dat_ini_path)) {
+                            memcpy(adev->ms12_tuning_dat_path, tuning_dat_ini_path, strlen(tuning_dat_ini_path));
+                        } else {
+                            memcpy(adev->ms12_tuning_dat_path, DOLBY_TUNING_DAT, sizeof(DOLBY_TUNING_DAT));
+                        }
                     } else {
                         ALOGE("DOLBY_TUNING_DAT is missing, updated dolby config to Y (%s)", str_val);
                         adev->dolby_ms12_audio_config = MS12_CONFIG_Y;
diff --git a/utils/aml_configs/aml_conf_parser.c b/utils/aml_configs/aml_conf_parser.c
index 4b7003c..27d28c5 100644
--- a/utils/aml_configs/aml_conf_parser.c
+++ b/utils/aml_configs/aml_conf_parser.c
@@ -34,7 +34,9 @@
 #include <cutils/log.h>
 #include <aml_conf_parser.h>
 #include <errno.h>
+#include <cutils/properties.h>
 #include "aml_malloc_debug.h"
+#include "iniparser.h"
 
 /*************************************************
     Utils
@@ -347,6 +349,87 @@
     return def_value;
 }
 
+struct audio_file_config_s dev_cfg[4] = {
+    {/*amlogic inner EQ & DRC*/
+        "AMLOGIC_SOC_INI_PATH",
+        "",
+    },
+    {/*ext amp EQ & DRC*/
+        "EXT_AMP_INI_PATH",
+        "",
+    },
+    {/*delay setting json*/
+        "AMLOGIC_DELAY_BASE_PATH",
+        "",
+    },
+    {
+        /*tuning data path*/
+        "AMLOG_MS12_TUNING_DATA",
+        "",
+    }
+};
+
+static int error_callback(const char *format, ...)
+{
+    va_list argptr;
+    va_start(argptr, format);
+    ALOGE(format, argptr);
+    va_end(argptr);
+    return 0;
+}
+
+int get_model_name(char *model_name, int size)
+{
+    int ret = -1;
+    char node[PROPERTY_VALUE_MAX];
+
+    ret = property_get("vendor.tv.model_name", node, "");
+    if (ret <= 0) {
+        snprintf(model_name, size, "FHD");
+        ALOGD("%s: Can't get model name! use default model_name (%s)",
+            __FUNCTION__, model_name);
+    } else {
+        snprintf(model_name, size, "%s", node);
+        ALOGD("%s: Model Name (%s)", __FUNCTION__, model_name);
+    }
+
+    return ret;
+}
+
+int parse_audio_sum(const char *file_name, char *model_name, struct audio_file_config_s *dev_cfg)
+{
+    dictionary *ini = NULL;
+    const char *ini_value = NULL;
+    char buf[128];
+
+    iniparser_set_error_callback(error_callback);
+
+    ini = iniparser_load(file_name);
+    if (ini == NULL) {
+        ALOGE("%s, INI load file (%s) error!\n", __FUNCTION__, file_name);
+        goto exit;
+    }
+
+    sprintf(buf, "%s:%s", model_name, dev_cfg->ini_header);
+    ini_value = iniparser_getstring(ini, buf, NULL);
+
+    if (ini_value == NULL || access(ini_value, F_OK) == -1) {
+        ALOGD("%s, INI File is not exist!\n", __FUNCTION__);
+        goto exit;
+    }
+
+    memset(dev_cfg->ini_file, 0, sizeof(dev_cfg->ini_file));
+    strncpy(dev_cfg->ini_file, ini_value, MAX_INI_FILE_NAME_SIZE - 1);
+    ALOGD("%s, INI File -> (%s)\n", __FUNCTION__, dev_cfg->ini_file);
+
+    iniparser_freedict(ini);
+    return 0;
+
+exit:
+    iniparser_freedict(ini);
+    return -1;
+}
+
 #ifndef AML_CONFIG_SUPPORT_READ_ONLY
 static int _save_to_file(struct parser *pParser, const char *filename)
 {
diff --git a/aml_aq_hw/ini/dictionary.c b/utils/dictionary.c
similarity index 100%
rename from aml_aq_hw/ini/dictionary.c
rename to utils/dictionary.c
diff --git a/utils/include/aml_conf_parser.h b/utils/include/aml_conf_parser.h
index ec00d39..0de0368 100644
--- a/utils/include/aml_conf_parser.h
+++ b/utils/include/aml_conf_parser.h
@@ -18,7 +18,8 @@
 #define _PARSER_H_
 
 #define MAX_INI_FILE_LINE_LEN (512)
-
+#define MAX_INI_NAME_SIZE (32)
+#define MAX_INI_FILE_NAME_SIZE (128)
 /*
  * example.conf
  * ----------------------------------------------------------------------------
@@ -78,6 +79,13 @@
     SECTION *mpFirstSection;                  // first section in this config file
 };
 
+/*ini file parser*/
+struct audio_file_config_s {
+    char ini_header[MAX_INI_NAME_SIZE];
+    char ini_file[MAX_INI_FILE_NAME_SIZE];
+};
+
+extern struct audio_file_config_s dev_cfg[4];
 /* load from */
 #define AML_PARAM_AUDIO_HAL_SYSTEM "/system/etc/tvaudiohal.conf"
 /* save to */
@@ -102,6 +110,9 @@
 int parser_set_string(struct parser *pParser, const char *section, const char *key, const char *value);
 int parser_set_int(struct parser *pParser, const char *section, const char *key, int value);
 int parser_set_float(struct parser *pParser, const char *section, const char *key, float value);
+
+int get_model_name(char *model_name, int size);
+int parse_audio_sum(const char *file_name, char *model_name, struct audio_file_config_s *dev_cfg);
 #endif
 
 #endif
diff --git a/aml_aq_hw/ini/dictionary.h b/utils/include/dictionary.h
similarity index 100%
rename from aml_aq_hw/ini/dictionary.h
rename to utils/include/dictionary.h
diff --git a/aml_aq_hw/ini/iniparser.h b/utils/include/iniparser.h
similarity index 100%
rename from aml_aq_hw/ini/iniparser.h
rename to utils/include/iniparser.h
diff --git a/utils/ini/IniParser.cpp b/utils/ini/IniParser.cpp
deleted file mode 100644
index e72048f..0000000
--- a/utils/ini/IniParser.cpp
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Copyright (C) 2017 Amlogic Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Author:  Shoufu Zhao <shoufu.zhao@amlogic.com>
- */
-
-#define LOG_TAG "audio_hw_utils_ini"
-#define LOG_NDEBUG 0
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <cutils/log.h>
-
-#include "ini.h"
-#include "IniParser.h"
-
-IniParser::IniParser() {
-    ALOGD("%s, entering...\n", __FUNCTION__);
-    mpFirstSection = NULL;
-    mpCurSection = NULL;
-
-    mpFileName[0] = '\0';
-}
-
-IniParser::~IniParser() {
-    ALOGD("%s, entering...\n", __FUNCTION__);
-    free();
-}
-
-int IniParser::parse(const char* filename) {
-    ALOGD("%s, entering...\n", __FUNCTION__);
-
-    strncpy(mpFileName, filename, CC_MAX_INI_FILE_NAME_LEN - 1);
-    return ini_parse(filename, handler, this);
-}
-
-int IniParser::parse_mem(char* file_buf) {
-    ALOGD("%s, entering...\n", __FUNCTION__);
-    return ini_parse_mem(file_buf, handler, this);
-}
-
-int IniParser::SetSaveFileName(const char* filename) {
-    ALOGD("%s, entering...\n", __FUNCTION__);
-
-    strncpy(mpFileName, filename, CC_MAX_INI_FILE_NAME_LEN - 1);
-    return 0;
-}
-
-void IniParser::free() {
-    ALOGD("%s, entering...\n", __FUNCTION__);
-
-    INI_SECTION* pNextSec = NULL;
-    for (INI_SECTION* pSec = mpFirstSection; pSec != NULL;) {
-        pNextSec = pSec->pNext;
-
-        INI_LINE* pNextLine = NULL;
-        for (INI_LINE* pLine = pSec->pLine; pLine != NULL;) {
-            pNextLine = pLine->pNext;
-
-            if (pLine != NULL) {
-#if CC_MEMORY_NEW_DEL_TRACE == 1
-                del_mem(__FUNCTION__, "pLine", pLine);
-#endif
-
-                delete pLine;
-                pLine = NULL;
-            }
-
-            pLine = pNextLine;
-        }
-
-        if (pSec != NULL) {
-#if CC_MEMORY_NEW_DEL_TRACE == 1
-            del_mem(__FUNCTION__, "pSec", pSec);
-#endif
-
-            delete pSec;
-            pSec = NULL;
-        }
-
-        pSec = pNextSec;
-    }
-
-    mpFirstSection = NULL;
-    mpCurSection = NULL;
-
-#if CC_MEMORY_NEW_DEL_TRACE == 1
-    printNewMemND(__FUNCTION__);
-    printDelMemND(__FUNCTION__);
-    clearMemND();
-#endif
-}
-
-void IniParser::trim(char *str, char ch) {
-    char* pStr;
-
-    pStr = str;
-    while (*pStr != '\0') {
-        if (*pStr == ch) {
-            char* pTmp = pStr;
-            while (*pTmp != '\0') {
-                *pTmp = *(pTmp + 1);
-                pTmp++;
-            }
-        } else {
-            pStr++;
-        }
-    }
-}
-
-void IniParser::trim(char *str) {
-    char* pStr = NULL;
-
-    pStr = strchr(str, '\n');
-    if (pStr != NULL) {
-        *pStr = 0;
-    }
-
-    int Len = strlen(str);
-    if (Len > 0) {
-        if (str[Len - 1] == '\r') {
-            str[Len - 1] = '\0';
-        }
-    }
-
-    pStr = strchr(str, '#');
-    if (pStr != NULL) {
-        *pStr = 0;
-    }
-
-    pStr = strchr(str, ';');
-    if (pStr != NULL) {
-        *pStr = 0;
-    }
-
-    trim(str, ' ');
-    trim(str, '{');
-    trim(str, '\\');
-    trim(str, '}');
-    trim(str, '\"');
-    return;
-}
-
-void IniParser::print() {
-    for (INI_SECTION* pSec = mpFirstSection; pSec != NULL; pSec = pSec->pNext) {
-        ALOGD("[%s]\n", pSec->Name);
-        for (INI_LINE* pLine = pSec->pLine; pLine != NULL; pLine = pLine->pNext) {
-            ALOGD("%s = %s\n", pLine->Name, pLine->Value);
-        }
-        ALOGD("\n\n\n");
-    }
-}
-
-INI_SECTION* IniParser::getSection(void* user, const char* section) {
-    IniParser* parser = (IniParser*) user;
-    if (parser == NULL) {
-        return NULL;
-    }
-
-    for (INI_SECTION* pSec = parser->mpFirstSection; pSec != NULL; pSec = pSec->pNext) {
-        if (strncmp(pSec->Name, section, strlen(section)) == 0) {
-            return pSec;
-        }
-    }
-
-    return NULL;
-}
-
-INI_LINE* IniParser::getKeyLineAtSec(INI_SECTION* pSec, const char* key) {
-    for (INI_LINE* pLine = pSec->pLine; pLine != NULL; pLine = pLine->pNext) {
-        if (strncmp(pLine->Name, key, strlen(key)) == 0) {
-            return pLine;
-        }
-    }
-    return NULL;
-}
-
-const char* IniParser::GetString(const char* section, const char* key,
-        const char* def_value) {
-    INI_SECTION* pSec = getSection(this, section);
-    if (pSec == NULL) {
-        //ALOGD("%s, section %s is NULL\n", __FUNCTION__, section);
-        return def_value;
-    }
-
-    INI_LINE* pLine = getKeyLineAtSec(pSec, key);
-    if (pLine == NULL) {
-        //ALOGD("%s, key \"%s\" is NULL\n", __FUNCTION__, key);
-        return def_value;
-    }
-
-    return pLine->Value;
-}
-
-int IniParser::SaveToFile(const char *filename) {
-    const char *fname = NULL;
-    FILE *fp = NULL;
-
-    if (filename == NULL) {
-        if (strlen(mpFileName) == 0) {
-            ALOGE("%s, save file name is NULL!!!\n", __FUNCTION__);
-            return -1;
-        } else {
-            fname = mpFileName;
-        }
-    } else {
-        fname = filename;
-    }
-
-    if ((fp = fopen (fname, "wb")) == NULL) {
-        ALOGE("%s, Open file \"%s\" ERROR (%s)!!!\n", __FUNCTION__, fname, strerror(errno));
-        return -1;
-    }
-
-    for (INI_SECTION* pSec = mpFirstSection; pSec != NULL; pSec = pSec->pNext) {
-        fprintf(fp, "[%s]\r\n", pSec->Name);
-        for (INI_LINE* pLine = pSec->pLine; pLine != NULL; pLine = pLine->pNext) {
-            fprintf(fp, "%s = %s\r\n", pLine->Name, pLine->Value);
-        }
-    }
-
-    fflush(fp);
-    fsync(fileno(fp));
-
-    fclose(fp);
-    fp = NULL;
-
-    return 0;
-}
-
-int IniParser::SetString(const char *section, const char *key, const char *value) {
-    setKeyValue(this, section, key, value, 1);
-    SaveToFile(NULL);
-    return 0;
-}
-
-INI_LINE* IniParser::newLine(const char* name, const char* value) {
-    INI_LINE* pLine = NULL;
-
-    pLine = new INI_LINE();
-    if (pLine != NULL) {
-        pLine->pNext = NULL;
-        strcpy(pLine->Name, name);
-        strcpy(pLine->Value, value);
-
-#if CC_MEMORY_NEW_DEL_TRACE == 1
-        new_mem(__FUNCTION__, "pLine", pLine);
-#endif
-    }
-
-    return pLine;
-}
-
-INI_SECTION* IniParser::newSection(const char* section, INI_LINE* pLine) {
-    INI_SECTION* pSec = NULL;
-
-    pSec = new INI_SECTION();
-    if (pSec != NULL) {
-        pSec->pLine = pLine;
-        pSec->pNext = NULL;
-        strcpy(pSec->Name, section);
-
-#if CC_MEMORY_NEW_DEL_TRACE == 1
-        new_mem(__FUNCTION__, "pSec", pSec);
-#endif
-    }
-
-    return pSec;
-}
-
-int IniParser::setKeyValue(void* user, const char* section, const char* key, const char* value, int set_mode) {
-    IniParser* parser = NULL;
-    INI_LINE* pLine = NULL;
-    INI_SECTION *pSec = NULL;
-
-    if (user == NULL || section == NULL || key == NULL || value == NULL) {
-        return 1;
-    }
-
-    parser = (IniParser*) user;
-
-    parser->trim((char *) value);
-    if (value[0] == '\0') {
-        return 1;
-    }
-
-    if (parser->mpFirstSection == NULL) {
-        pLine = newLine(key, value);
-        pSec = newSection(section, pLine);
-
-        parser->mpFirstSection = pSec;
-        parser->mpCurSection = pSec;
-        pSec->pCurLine = pLine;
-    } else {
-        pSec = getSection(user, section);
-        if (pSec == NULL) {
-            pLine = newLine(key, value);
-            pSec = newSection(section, pLine);
-
-            parser->mpCurSection->pNext = pSec;
-            parser->mpCurSection = pSec;
-            pSec->pCurLine = pLine;
-
-            pSec->pCurLine = pLine;
-        } else {
-            pLine = getKeyLineAtSec(pSec, key);
-            if (pLine == NULL) {
-                pLine = newLine(key, value);
-
-                pSec->pCurLine->pNext = pLine;
-                pSec->pCurLine = pLine;
-            } else {
-                if (set_mode == 1) {
-                    strcpy(pLine->Value, value);
-                } else {
-                    strcat(pLine->Value, value);
-                }
-            }
-        }
-    }
-
-    return 0;
-}
-
-int IniParser::handler(void* user, const char* section, const char* name,
-        const char* value) {
-    //ALOGD("%s, section = %s, name = %s, value = %s\n", __FUNCTION__, section, name, value);
-    setKeyValue(user, section, name, value, 0);
-    return 1;
-}
-
-#if CC_MEMORY_NEW_DEL_TRACE == 1
-
-#define CC_MEM_RECORD_CNT    (1024)
-
-typedef struct tag_memnd {
-    char fun_name[50];
-    char var_name[50];
-    void *ptr;
-} memnd;
-
-static memnd gMemNewItems[CC_MEM_RECORD_CNT];
-static int gMemNewInd = 0;
-
-static memnd gMemDelItems[CC_MEM_RECORD_CNT];
-static int gMemDelInd = 0;
-
-static void new_mem(const char *fun_name, const char *var_name, void *ptr) {
-    strcpy(gMemNewItems[gMemNewInd].fun_name, fun_name);
-    strcpy(gMemNewItems[gMemNewInd].var_name, var_name);
-    gMemNewItems[gMemNewInd].ptr = ptr;
-
-    gMemNewInd += 1;
-}
-
-static void del_mem(const char *fun_name, const char *var_name, void *ptr) {
-    strcpy(gMemDelItems[gMemDelInd].fun_name, fun_name);
-    strcpy(gMemDelItems[gMemDelInd].var_name, var_name);
-    gMemDelItems[gMemDelInd].ptr = ptr;
-
-    gMemDelInd += 1;
-}
-
-static void printMemND(const char *fun_name, memnd *tmp_nd, int tmp_cnt) {
-    //int i = 0;
-
-    ALOGD("fun_name = %s, fun_name = %s, total_cnt = %d\n", fun_name, (char *)tmp_nd, tmp_cnt);
-
-#if CC_MEMORY_NEW_DEL_TRACE_PRINT_ALL == 1
-    for (i = 0; i < tmp_cnt; i++) {
-        ALOGD("fun_name = %s, var_name = %s, ptr = %p\n", tmp_nd[i].fun_name, tmp_nd[i].var_name, tmp_nd[i].ptr);
-    }
-#endif
-}
-
-static void printDelMemND(const char *fun_name) {
-    ALOGD("fun_name = %s\n", fun_name);
-    printMemND(__FUNCTION__, gMemDelItems, gMemDelInd);
-}
-
-static void printNewMemND(const char *fun_name) {
-    ALOGD("fun_name = %s\n", fun_name);
-    printMemND(__FUNCTION__, gMemNewItems, gMemNewInd);
-}
-
-static void clearMemND() {
-    //int i = 0;
-
-    gMemNewInd = 0;
-    gMemDelInd = 0;
-    memset((void *)gMemNewItems, 0, sizeof(memnd) * CC_MEM_RECORD_CNT);
-    memset((void *)gMemDelItems, 0, sizeof(memnd) * CC_MEM_RECORD_CNT);
-}
-#endif
diff --git a/utils/ini/include/IniParser.h b/utils/ini/include/IniParser.h
deleted file mode 100644
index bc22394..0000000
--- a/utils/ini/include/IniParser.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2017 Amlogic Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Author:  Shoufu Zhao <shoufu.zhao@amlogic.com>
- */
-
-#ifndef __INI_PARSER_H__
-#define __INI_PARSER_H__
-
-#define CC_MAX_INI_FILE_NAME_LEN    (512)
-#define CC_MAX_INI_FILE_LINE_LEN    (2048)
-
-#define CC_MAX_INI_LINE_NAME_LEN    (128)
-
-typedef struct S_INI_LINE {
-    struct S_INI_LINE *pNext;
-    char Name[CC_MAX_INI_LINE_NAME_LEN];
-    char Value[CC_MAX_INI_FILE_LINE_LEN];
-} INI_LINE;
-
-typedef struct S_INI_SECTION {
-    INI_LINE* pLine;
-    INI_LINE* pCurLine;
-    struct S_INI_SECTION *pNext;
-    char Name[CC_MAX_INI_LINE_NAME_LEN];
-} INI_SECTION;
-
-class IniParser
-{
-public:
-    IniParser();
-    ~IniParser();
-
-    void free();
-    int parse(const char* fname);
-    int SetSaveFileName(const char* fname);
-    int parse_mem(char* file_buf);
-    static INI_SECTION* getSection(void* user, const char* section);
-    const char* GetString(const char* section, const char* key, const char* def_value);
-    int SetString(const char *section, const char *key, const char *value);
-    void print();
-
-private:
-    int SaveToFile(const char *filename);
-
-    static void trim(char *str, char ch);
-    static void trim(char *str);
-    static INI_LINE* getKeyLineAtSec(INI_SECTION* pSec, const char* key);
-    static int setKeyValue(void* user, const char* section, const char* name, const char* value, int set_mode);
-    static int handler(void* user, const char* section, const char* name, const char* value);
-    static INI_LINE* newLine(const char* name, const char* value);
-    static INI_SECTION* newSection(const char* section, INI_LINE* pLINE);
-
-private:
-    INI_SECTION* mpFirstSection;
-    INI_SECTION* mpCurSection;
-
-    char mpFileName[CC_MAX_INI_FILE_NAME_LEN];
-};
-
-//for memory new and delete debug
-#define CC_MEMORY_NEW_DEL_TRACE              (0)
-#define CC_MEMORY_NEW_DEL_TRACE_PRINT_ALL    (0)
-
-#if CC_MEMORY_NEW_DEL_TRACE == 1
-static void new_mem(const char *fun_name, const char *var_name, void *ptr);
-static void del_mem(const char *fun_name, const char *var_name, void *ptr);
-static void printDelMemND(const char *fun_name);
-static void printNewMemND(const char *fun_name);
-static void clearMemND();
-#endif
-
-#endif //__INI_PARSER_H__
diff --git a/utils/ini/include/ini.h b/utils/ini/include/ini.h
deleted file mode 100644
index b82dc02..0000000
--- a/utils/ini/include/ini.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2017 Amlogic Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* inih -- simple .INI file parser
-
- inih is released under the New BSD license (see LICENSE.txt). Go to the project
- home page for more info:
-
- http://code.google.com/p/inih/
-
- */
-
-#ifndef __INI_H__
-#define __INI_H__
-
-/* Make this header file easier to include in C++ code */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdio.h>
-
-/* Parse given INI-style file. May have [section]s, name=value pairs
- (whitespace stripped), and comments starting with ';' (semicolon). Section
- is "" if name=value pair parsed before any section heading. name:value
- pairs are also supported as a concession to Python's ConfigParser.
-
- For each name=value pair parsed, call handler function with given user
- pointer as well as section, name, and value (data only valid for duration
- of handler call). Handler should return nonzero on success, zero on error.
-
- Returns 0 on success, line number of first error on parse error (doesn't
- stop on first error), -1 on file open error, or -2 on memory allocation
- error (only when INI_USE_STACK is zero).
- */
-int ini_parse(const char* filename,
-        int (*handler)(void* user, const char* section, const char* name,
-                const char* value), void* user);
-
-/* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
- close the file when it's finished -- the caller must do that. */
-int ini_parse_file(FILE* file,
-        int (*handler)(void* user, const char* section, const char* name,
-                const char* value), void* user);
-
-int ini_parse_mem(const char* buf,
-        int (*handler)(void* user, const char* section, const char* name,
-                const char* value), void* user);
-
-/* Nonzero to allow multi-line value parsing, in the style of Python's
- ConfigParser. If allowed, ini_parse() will call the handler with the same
- name for each subsequent line parsed. */
-#ifndef INI_ALLOW_MULTILINE
-#define INI_ALLOW_MULTILINE 1
-#endif
-
-/* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
- the file. See http://code.google.com/p/inih/issues/detail?id=21 */
-#ifndef INI_ALLOW_BOM
-#define INI_ALLOW_BOM 1
-#endif
-
-/* Nonzero to use stack, zero to use heap (malloc/free). */
-#ifndef INI_USE_STACK
-#define INI_USE_STACK 1
-#endif
-
-/* Maximum line length for any line in INI file. */
-#ifndef INI_MAX_LINE
-#define INI_MAX_LINE 20000
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __INI_H__ */
diff --git a/utils/ini/include/ini_config.h b/utils/ini/include/ini_config.h
deleted file mode 100644
index aa31f0e..0000000
--- a/utils/ini/include/ini_config.h
+++ /dev/null
@@ -1,38 +0,0 @@
-
-/*
- * Copyright (C) 2017 Amlogic Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __INI_CONFIG_H__
-#define __INI_CONFIG_H__
-
-#if MODE_COMPILE_IN_PC
-    #define CS_DEFAULT_PANEL_INI_FILE_NAME             "input/panel/ID_0_Pnl_FACTORY.ini"
-    #define CS_DEFAULT_PANEL_PQ_DB_FILE_NAME           "input/pq/pq_default.bin"
-    #define CS_DEFAULT_AUDIO_PARAM_INI_FILE_NAME       "input/audio/eq_drc/aml_internal_hw_eq.ini"
-#else
-    #define CS_DEFAULT_PANEL_INI_FILE_NAME             "/system/etc/ID_0_Pnl_FACTORY.ini"
-    #define CS_DEFAULT_PANEL_PQ_DB_FILE_NAME           "/system/etc/pq_default.bin"
-    #define CS_DEFAULT_AUDIO_PARAM_INI_FILE_NAME       "/system/etc/ID_0_Aud_eq_drc_FACTORY.ini"
-#endif
-
-#define CC_RW_KEY_USE_OTHER_MODULE    (0)
-
-#if MODE_COMPILE_IN_PC
-    #define CC_RW_KEY_USE_OTHER_MODULE    (0)
-    #define CC_UBOOT_RW_SIMULATE
-#endif
-
-#endif //__INI_CONFIG_H__
diff --git a/utils/ini/ini.cpp b/utils/ini/ini.cpp
deleted file mode 100644
index dc73357..0000000
--- a/utils/ini/ini.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (C) 2017 Amlogic Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#define LOG_TAG "audio_hw_utils_ini"
-
-#define _CRT_SECURE_NO_WARNINGS
-//#pragma warning (disable: 4127)
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-
-#include "aml_malloc_debug.h"
-#include "ini.h"
-
-#if !INI_USE_STACK
-#include <stdlib.h>
-#endif
-
-#define MAX_SECTION 50
-#define MAX_NAME 50
-
-/* Strip whitespace chars off end of given string, in place. Return s. */
-static char* rstrip(char* s) {
-    char* p = s + strlen(s);
-    while (p > s && isspace((unsigned char) (*--p)))
-        *p = '\0';
-    return s;
-}
-
-/* Return pointer to first non-whitespace char in given string. */
-static char* lskip(const char* s) {
-    while (*s && isspace((unsigned char) (*s)))
-        s++;
-    return (char*) s;
-}
-
-/* Return pointer to first char c or ';' comment in given string, or pointer to
- null at end of string if neither found. ';' must be prefixed by a whitespace
- character to register as a comment. */
-static char* find_char_or_comment(const char* s, char c) {
-    int was_whitespace = 0;
-    while (*s && *s != c && !(was_whitespace && *s == ';')) {
-        was_whitespace = isspace((unsigned char) (*s));
-        s++;
-    }
-    return (char*) s;
-}
-
-/* Version of strncpy that ensures dest (size bytes) is null-terminated. */
-static char* strncpy0(char* dest, const char* src, size_t size) {
-    strncpy(dest, src, size);
-    dest[size - 1] = '\0';
-    return dest;
-}
-
-/* See documentation in header file. */
-int ini_parse_file(FILE* file,
-        int (*handler)(void*, const char*, const char*, const char*),
-        void* user) {
-    /* Uses a fair bit of stack (use heap instead if you need to) */
-#if INI_USE_STACK
-    char line[INI_MAX_LINE];
-#else
-    char* line;
-#endif
-    char section[MAX_SECTION] = "";
-    char prev_name[MAX_NAME] = "";
-
-    char* start;
-    char* end;
-    char* name;
-    char* value;
-    int lineno = 0;
-    int error = 0;
-
-#if !INI_USE_STACK
-    line = (char*)aml_audio_malloc(INI_MAX_LINE);
-    if (!line) {
-        return -2;
-    }
-#endif
-
-    /* Scan through file line by line */
-    while (fgets(line, INI_MAX_LINE, file) != NULL) {
-        lineno++;
-
-        start = line;
-#if INI_ALLOW_BOM
-        if (lineno == 1 && (unsigned char)start[0] == 0xEF &&
-                (unsigned char)start[1] == 0xBB &&
-                (unsigned char)start[2] == 0xBF) {
-            start += 3;
-        }
-#endif
-        start = lskip(rstrip(start));
-
-        if (*start == ';' || *start == '#') {
-            /* Per Python ConfigParser, allow '#' comments at start of line */
-        }
-        else if (*start == '[') {
-            /* A "[section]" line */
-            end = find_char_or_comment(start + 1, ']');
-            if (*end == ']') {
-                *end = '\0';
-                strncpy0(section, start + 1, sizeof(section));
-                *prev_name = '\0';
-            } else if (!error) {
-                /* No ']' found on section line */
-                error = lineno;
-            }
-        }
-#if INI_ALLOW_MULTILINE
-        else if (*prev_name && *start && (start > line || strstr(start, "=") == NULL)) {
-            /* Non-black line with leading whitespace, treat as continuation
-             of previous name's value (as per Python ConfigParser). */
-            if (!handler(user, section, prev_name, start) && !error)
-            error = lineno;
-        }
-#endif
-        else if (*start && *start != ';') {
-            /* Not a comment, must be a name[=:]value pair */
-            end = find_char_or_comment(start, '=');
-            if (*end != '=') {
-                end = find_char_or_comment(start, ':');
-            }
-            if (*end == '=' || *end == ':') {
-                *end = '\0';
-                name = rstrip(start);
-                value = lskip(end + 1);
-                end = find_char_or_comment(value, '\0');
-                if (*end == ';')
-                    *end = '\0';
-                rstrip(value);
-
-                /* Valid name[=:]value pair found, call handler */
-                strncpy0(prev_name, name, sizeof(prev_name));
-                if (!handler(user, section, name, value) && !error)
-                    error = lineno;
-            } else if (!error) {
-                /* No '=' or ':' found on name[=:]value line */
-                error = lineno;
-            }
-        }
-    }
-
-#if !INI_USE_STACK
-    aml_audio_free(line);
-#endif
-
-    return error;
-}
-
-int ini_parse_mem(const char* buf,
-        int (*handler)(void* user, const char* section, const char* name,
-                const char* value), void* user) {
-    char* bufptr = (char*) buf;
-
-    /* Uses a fair bit of stack (use heap instead if you need to) */
-#if INI_USE_STACK
-    char line[INI_MAX_LINE];
-#else
-    char* line;
-#endif
-    char section[MAX_SECTION] = "";
-    char prev_name[MAX_NAME] = "";
-
-    char* start;
-    char* end;
-    char* name;
-    char* value;
-    int lineno = 0;
-    int error = 0;
-
-#if !INI_USE_STACK
-    line = (char*)aml_audio_malloc(INI_MAX_LINE);
-    if (!line) {
-        return -2;
-    }
-#endif
-
-    while (1) {
-        int ncount = 0;
-        while (*bufptr != '\0') {
-            if (*bufptr == '\r' || *bufptr == '\n')
-                break;
-
-            line[ncount] = *bufptr++;
-            ncount++;
-        }
-        while (*bufptr == '\r' || *bufptr == '\n')
-            bufptr++;
-        line[ncount] = 0;
-
-        if (ncount == 0)
-            break;
-
-        /* Scan through file line by line */
-        //while (fgets(line, INI_MAX_LINE, file) != NULL) {
-        lineno++;
-
-        start = line;
-#if INI_ALLOW_BOM
-        if (lineno == 1 && (unsigned char)start[0] == 0xEF &&
-                (unsigned char)start[1] == 0xBB &&
-                (unsigned char)start[2] == 0xBF) {
-            start += 3;
-        }
-#endif
-        start = lskip(rstrip(start));
-
-        if (*start == ';' || *start == '#') {
-            /* Per Python ConfigParser, allow '#' comments at start of line */
-        }
-#if INI_ALLOW_MULTILINE
-        else if (*prev_name && *start && start > line) {
-            /* Non-black line with leading whitespace, treat as continuation
-             of previous name's value (as per Python ConfigParser). */
-            if (!handler(user, section, prev_name, start) && !error)
-            error = lineno;
-        }
-#endif
-        else if (*start == '[') {
-            /* A "[section]" line */
-            end = find_char_or_comment(start + 1, ']');
-            if (*end == ']') {
-                *end = '\0';
-                strncpy0(section, start + 1, sizeof(section));
-                *prev_name = '\0';
-            } else if (!error) {
-                /* No ']' found on section line */
-                error = lineno;
-            }
-        } else if (*start && *start != ';') {
-            /* Not a comment, must be a name[=:]value pair */
-            end = find_char_or_comment(start, '=');
-            if (*end != '=') {
-                end = find_char_or_comment(start, ':');
-            }
-            if (*end == '=' || *end == ':') {
-                *end = '\0';
-                name = rstrip(start);
-                value = lskip(end + 1);
-                end = find_char_or_comment(value, '\0');
-                if (*end == ';')
-                    *end = '\0';
-                rstrip(value);
-
-                /* Valid name[=:]value pair found, call handler */
-                strncpy0(prev_name, name, sizeof(prev_name));
-                if (!handler(user, section, name, value) && !error)
-                    error = lineno;
-            } else if (!error) {
-                /* No '=' or ':' found on name[=:]value line */
-                error = lineno;
-            }
-        }
-    }
-
-#if !INI_USE_STACK
-    aml_audio_free(line);
-#endif
-
-    return error;
-}
-
-/* See documentation in header file. */
-int ini_parse(const char* filename,
-        int (*handler)(void*, const char*, const char*, const char*),
-        void* user) {
-    FILE* file;
-    int error;
-
-    file = fopen(filename, "r");
-    if (!file)
-        return -1;
-    error = ini_parse_file(file, handler, user);
-    fclose(file);
-    return error;
-}
diff --git a/aml_aq_hw/ini/iniparser.c b/utils/iniparser.c
similarity index 100%
rename from aml_aq_hw/ini/iniparser.c
rename to utils/iniparser.c