163 files changed, 13 insertions, 62934 deletions
diff --git a/tvapi/libtv/tvsetting/audio_cfg.cpp b/tvapi/libtv/tvsetting/audio_cfg.cpp deleted file mode 100644 index 682173b..0000000 --- a/tvapi/libtv/tvsetting/audio_cfg.cpp +++ b/dev/null @@ -1,723 +0,0 @@ -#define LOG_TAG "audio_cfg" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <android/log.h> -#include <cutils/properties.h> - -#include "../tvsetting/CTvSetting.h" -#include "../tvconfig/tvconfig.h" -#include "audio_cfg.h" - -#include "CTvLog.h" - -static const char AudioAmpMainVolLutBaseNameTable[CC_GET_TYPE_CNT][128] = {"audio.amp.mainvol.tv.lutbuf",//0 - "audio.amp.mainvol.av.lutbuf",//1 - "audio.amp.mainvol.comp.lutbuf",//2 - "audio.amp.mainvol.hdmi.lutbuf",//3 - "audio.amp.mainvol.vga.lutbuf",//4 - "audio.amp.mainvol.mpeg.lutbuf",//5 - "audio.amp.mainvol.hdmi4k2k.lutbuf",//6 - "audio.amp.mainvol.usb4k2k.lutbuf"//7 - }; - -static const int Default_EQGain_Table[24] = { - // - 50, 50, 50, 50, 50, 50, // SM_STD - 70, 60, 50, 60, 70, 50, // SM_MUSIC - 25, 50, 70, 66, 25, 50, // SM_NEWS - 75, 65, 50, 65, 75, 50, // SM_THEATER -}; - -static const int Default_AVoutGain_Table[9] = { - //PGA_IN ADC_Capture DAC_Playback - 11, 92, 255, // CC_AUDIO_IN_SOURCE_LINEIN - 11, 92, 255, //CC_AUDIO_IN_SOURCE_HDMI - 11, 92, 255, //CC_AUDIO_IN_SOURCE_ATV -}; - -int GetAudioAmpMasterNolinePointData(int get_type, const char *value_buf, int data_buf[]) -{ - const char *config_value; - if (value_buf != NULL) { - config_value = config_get_str(CFG_SECTION_TV, value_buf, "null"); - } else { - switch (get_type) { - case CC_GET_LUT_TV: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.tv", "null"); - } - break; - case CC_GET_LUT_AV: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.av", "null"); - } - break; - case CC_GET_LUT_COMP: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.comp", "null"); - } - break; - case CC_GET_LUT_HDMI: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.hdmi", "null"); - } - break; - case CC_GET_LUT_VGA: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.vga", "null"); - } - break; - case CC_GET_LUT_MPEG: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.mpeg", "null"); - } - break; - case CC_GET_LUT_HDMI_4K2K: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.hdmi4k2k", "null"); - } - break; - case CC_GET_LUT_USB_4K2K: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.usb4k2k", "null"); - } - break; - default: { - config_value = "null"; - } - break; - } - } - if (strcasecmp(config_value, "null") == 0) { - //LOGE("%s, can't get config \"%s\"!!!\n", CFG_SECTION_TV, key_str); - return -1; - } - - char *pSave; - char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; - - memset((void *)data_str, 0, sizeof(data_str)); - strncpy(data_str, config_value, sizeof(data_str) - 1); - char *token = strtok_r(data_str, ",", &pSave); - int bufferDataIndex = 0; - while (token != NULL) { - data_buf[bufferDataIndex] = strtol(token, NULL, 10); - bufferDataIndex ++; - token = strtok_r(NULL, ",", &pSave); - } - - return 0; -} - -int GetDefault_EQGain_Table(int *EqTable) -{ - memcpy(EqTable, Default_EQGain_Table, sizeof(Default_EQGain_Table)); - - return 0; -} - -int GetAudioEQPresetBufferPtr(int *EqTable) -{ - int bufs_count = 0, buf_item_count = 0; - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.eq.presetbuf", "null"); - if (strcasecmp(config_value, "null") == 0) { - return -1; - } - - char *pSave; - char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; - - memset((void *)data_str, 0, sizeof(data_str)); - strncpy(data_str, config_value, sizeof(data_str) - 1); - char *token = strtok_r(data_str, ",", &pSave); - int allIndex = 0, bufferDataIndex = 0; - while (token != NULL) { - if (allIndex == 0) { - bufs_count = strtol(token, NULL, 10); - } else if (allIndex == 1) { - buf_item_count = strtol(token, NULL, 10); - } else if (allIndex >= 2) { - EqTable[bufferDataIndex] = strtol(token, NULL, 10); - bufferDataIndex ++; - } - - token = strtok_r(NULL, ",", &pSave); - allIndex ++; - } - - return 0; -} - -/** - * @param:get_type - * @return:data_buf - */ -const char *GetAudioAmpMainvolTableBaseName(int get_type) -{ - return AudioAmpMainVolLutBaseNameTable[get_type]; -} - -int GetAudioAmpMainvolBuf(const char *TableKeyName, int data_buf[]) -{ - int bufs_count = 0, buf_item_count = 0; - const char *config_value; - - config_value = config_get_str(CFG_SECTION_TV, TableKeyName, "null"); - if (strcasecmp(config_value, "null") == 0) { - return -1; - } - char *pSave; - char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; - memset((void *)data_str, 0, sizeof(data_str)); - strncpy(data_str, config_value, sizeof(data_str) - 1); - char *token = strtok_r(data_str, ",", &pSave); - int allIndex = 0, bufferDataIndex = 0; - while (token != NULL) { - if (allIndex == 0) { - bufs_count = strtol(token, NULL, 10); - } else if (allIndex == 1) { - buf_item_count = strtol(token, NULL, 10); - } else if (allIndex >= 2) { - data_buf[bufferDataIndex] = strtol(token, NULL, 10); - bufferDataIndex ++; - } - token = strtok_r(NULL, ",", &pSave); - allIndex ++; - } - - return 0; -} - -/** - * @param:get_type - * @return:data_buf - */ -int GetAudioAmpSupbassvolBuf(int get_type, int data_buf[]) -{ - int bufs_count = 0, buf_item_count = 0; - const char *config_value; - - switch (get_type) { - case CC_GET_LUT_TV: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.tv.lutbuf", "null"); - } - - break; - case CC_GET_LUT_AV: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.av.lutbuf", "null"); - } - break; - case CC_GET_LUT_COMP: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.comp.lutbuf", "null"); - } - break; - case CC_GET_LUT_HDMI: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.hdmi.lutbuf", "null"); - } - break; - case CC_GET_LUT_VGA: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.vga.lutbuf", "null"); - } - - break; - case CC_GET_LUT_MPEG: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.mpeg.lutbuf", "null"); - } - - break; - case CC_GET_LUT_HDMI_4K2K: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.hdmi4k2k.lb.name", "null"); - } - - break; - case CC_GET_LUT_USB_4K2K: { - config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.usb4k2k.lb.name", "null"); - } - - break; - default: { - config_value = "null"; - } - break; - } - - if (strcasecmp(config_value, "null") == 0) { - return -1; - } - char *pSave; - char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; - memset((void *)data_str, 0, sizeof(data_str)); - strncpy(data_str, config_value, sizeof(data_str) - 1); - char *token = strtok_r(data_str, ",", &pSave); - int allIndex = 0, bufferDataIndex = 0; - while (token != NULL) { - if (allIndex == 0) { - bufs_count = strtol(token, NULL, 10); - } else if (allIndex == 1) { - buf_item_count = strtol(token, NULL, 10); - } else if (allIndex >= 2) { - data_buf[bufferDataIndex] = strtol(token, NULL, 10); - bufferDataIndex ++; - } - token = strtok_r(NULL, ",", &pSave); - allIndex ++; - } - - return 0; -} - -int GetAudioAmplifierMasterNoLineSwitchFlag() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.switch", "null"); - - if (strcmp(config_value, "null") == 0) { - return 0; - } - - return strtol(config_value, NULL, 10); -} - -int GetAudioAmplifierSupperBassNoLineSwitchFlag() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supperbass.noline.switch", "null"); - - if (strcmp(config_value, "null") == 0) { - return 0; - } - - return strtol(config_value, NULL, 10); -} - -int GetAudioAmplifierMasterNoLinePointsCount() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.cnt", "null"); - - if (strcmp(config_value, "null") == 0) { - return 11; - } - - return strtol(config_value, NULL, 10); -} - -int GetAudioAmplifierSupperBassNoLinePointsCount() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supperbass.noline.point.cnt", "null"); - - if (strcmp(config_value, "null") == 0) { - return 5; - } - - return strtol(config_value, NULL, 10); -} - -int GetAudioAmplifierBalanceExchangeCFG() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.balance.exchg", "null"); - - // if (data_buf[0] >= 0 && data_buf[0] <= 100) { - // LOGD("%s, we have get the index buffer.\n", CFG_SECTION_TV); - // return 0; - // } - - if (strcmp(config_value, "null") == 0) { - return 0; //return 0 to disable balance exchange - } - - return strtol(config_value, NULL, 10); -} - -int GetAudioMainVolLutBufCFGIndexModifyEnable() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.cfgindex.mod.en", "null"); - - if (strcmp(config_value, "null") == 0) { - return 0; - } - - return strtoul(config_value, NULL, 10); -} - -int GetAudioMainVolLutBufNameModifyUbootenvCFG() -{ - char config_value[PROPERTY_VALUE_MAX]; - - memset(config_value, '\0', 32); - property_get("ubootenv.var.ampindex", config_value, "null"); - - if (strcasecmp(config_value, "null") == 0) { - return 0; - } - - return strtoul(config_value, NULL, 10); -} - - -int GetAudioMainVolLutBufNameModifyEnableCFG() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.mainvol.lutbufname.mod.en", "null"); - - if (strcmp(config_value, "null") == 0) { - return 0; - } - - return strtoul(config_value, NULL, 10); -} - - -int GetAudioSupperBassVolLutBufCFGIndexModifyEnable() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supperbass.cfgindex.mod.en", "null"); - - if (strcmp(config_value, "null") == 0) { - return 0; - } - - return strtoul(config_value, NULL, 10); -} - -int GetAudioSupperBassVolLutBufNameModifyEnableCFG() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.lutbufname.mod.en", "null"); - - if (strcmp(config_value, "null") == 0) { - return 0; - } - - return strtoul(config_value, NULL, 10); -} - - -int GetAudioDVISupportEnable() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.dvi.support.enable", "null"); - - if (strcmp(config_value, "null") == 0) { - return 0; - } - - return strtoul(config_value, NULL, 10); -} - - -int GetTvAudioCardName(char tv_card_name_buf[]) -{ - const char *value = config_get_str(CFG_SECTION_TV, "audio.tv.card.name", "null"); - - strcpy(tv_card_name_buf, value); - if (strcmp(value, "null") == 0) { - strcpy(tv_card_name_buf, "AMLSYNO9629"); - } - - return 0; -} - -int GetTvAudioCardNeedSet() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.tv.card.needset", "null"); - if (strcmp(config_value, "null") == 0) { - return 0; - } - - if (strtoul(config_value, NULL, 10) == 0) { - return 0; - } - - return 1; -} - -int GetAudioEffectAmplifierGainCfg(const char *cfg_name, int def_gain_val, int max_gain_val) -{ - int tmp_val; - const char *config_value = config_get_str(CFG_SECTION_TV, cfg_name, "null"); - if (strcmp(config_value, "null") == 0) { - tmp_val = def_gain_val; - } else { - tmp_val = strtoul(config_value, NULL, 10); - if (tmp_val < 0 || tmp_val > max_gain_val) { - tmp_val = def_gain_val; - } - } - LOGD("%s = %d\n", cfg_name, tmp_val); - return tmp_val; -} - - -int GetAudioSRSSourroundEnableCFG() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.srs.sourround.enable", "null"); - - if (strcmp(config_value, "null") == 0) { - return 0; - } - - return strtoul(config_value, NULL, 10); -} - -int GetAudioSRSGainCfg(const char *cfg_name, int def_gain_val) -{ - int tmp_val = 0; - const char *config_value = config_get_str(CFG_SECTION_TV, cfg_name, "null"); - - if (strcmp(config_value, "null") == 0) { - tmp_val = def_gain_val; - } else { - if (tmp_val < 0 || tmp_val > 100) { - tmp_val = def_gain_val; - LOGE("Error setting: %s = %d (0~100)\n", cfg_name, tmp_val); - } - tmp_val = strtoul(config_value, NULL, 10); - } - //LOGD(" %s = %d\n", cfg_name, tmp_val); - return tmp_val; -} - -int GetAudioSRSSupperBassTrubassSpeakerSizeCfg() -{ - char cfg_name[128] = { 0 }; - - strcpy(cfg_name, CFG_AUDIO_SRS_TRUBASS_SPEAKERSIZE); - - const char *config_value = config_get_str(CFG_SECTION_TV, cfg_name, "null"); - - if (strcmp(config_value, "null") == 0) { - return -1; - } - - int tmp_val = strtoul(config_value, NULL, 10); - if (tmp_val < 0 || tmp_val > 7) { - tmp_val = -1; - } - - return tmp_val; -} - -int GetAudioDumpDataEnableFlagCfg() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.dump.data.en", "null"); - - if (strcmp(config_value, "null") == 0) { - return 0; - } - - return strtol(config_value, NULL, 10); -} - -int GetAudioSupperBassSwitchDisableCFG() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.supperbass.switch.disable", "null"); - - if (strcmp(config_value, "null") == 0) { - return 0; - } - - return strtoul(config_value, NULL, 10); -} - -int GetAudioWallEffectTypeCfg() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.walleffect.type", "null"); - - if (strcmp(config_value, "null") == 0) { - return 0; - } - - return strtol(config_value, NULL, 10); -} - -int Get2d4gHeadsetEnable() -{ - const char *config_value = config_get_str ( CFG_SECTION_TV, "tvin.2d4G.headset.en", "null" ); - if (strcmp(config_value, "enable") == 1) { - return 1; - } - - - return 0; -} - -const char *GetAudExtDacLibPath() -{ - return config_get_str(CFG_SECTION_TV, "audio.external.dac.libpath", "/system/lib/libdac.so"); -} - -int GetKaraokAvEnable() -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.switch.karaok.av.enable", "null"); - if (strtoul(config_value, NULL, 10) == 1) - return 1; - - return 0; -} - -int GetDefaultAvOutGainBuf(int *nAvoutTable) -{ - memcpy(nAvoutTable, Default_AVoutGain_Table, sizeof(Default_AVoutGain_Table)); - - return 0; -} - -int GetAvOutGainBuf_Cfg(int *nAvoutTable) -{ - int bufs_count = 0, buf_item_count = 0; - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.avoutgain.presetbuf", "null"); - if (strcasecmp(config_value, "null") == 0) { - // LOGE("%s, can't get config \"%s\"!!!\n", CFG_SECTION_TV, key_str); - return -1; - } - - char *pSave; - char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; - - memset((void *)data_str, 0, sizeof(data_str)); - strncpy(data_str, config_value, sizeof(data_str) - 1); - char *token = strtok_r(data_str, ",", &pSave); - int allIndex = 0, bufferDataIndex = 0; - while (token != NULL) { - if (allIndex == 0) { - bufs_count = strtol(token, NULL, 10); - } else if (allIndex == 1) { - buf_item_count = strtol(token, NULL, 10); - } else if (allIndex >= 2) { - nAvoutTable[bufferDataIndex] = strtol(token, NULL, 10); - bufferDataIndex ++; - } - - token = strtok_r(NULL, ",", &pSave); - allIndex ++; - } - - return 0; -} - -int GetADCDigitalCaptureVol_Cfg(void) -{ - int capture_vol = 0; - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.adc.digital.capture.vol", "null"); - - if (strcmp(config_value, "null") == 0) { - return -1; - } - - return strtoul(config_value, NULL, 10); -} - -int GetAudioInternalDacPGAInGain_Cfg(void) -{ - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.internal.dac.pga_in.gain", "null"); - - if (strcmp(config_value, "null") == 0) { - return 16; - } - - return strtol(config_value, NULL, 10); -} - -int GetAudioInternalDACDigitalPlayBackVolume_Cfg(int audio_src_in_type) -{ - const char *config_value = NULL; - - if (audio_src_in_type == 2) { // CC_AUDIO_IN_SOURCE_HDMI - config_value = config_get_str(CFG_SECTION_TV, "audio.internal.dac.playback.volume_hdmi", "null"); - } else if (audio_src_in_type == 0) { // CC_AUDIO_IN_SOURCE_LINEIN - config_value = config_get_str(CFG_SECTION_TV, "audio.internal.dac.playback.volume_linein", "null"); - } else if (audio_src_in_type == 1) { // CC_AUDIO_IN_SOURCE_ATV - config_value = config_get_str(CFG_SECTION_TV, "audio.internal.dac.playback.volume_atv", "null"); - } - - if (strcmp(config_value, "null") == 0) { - return 255; - } - - return strtol(config_value, NULL, 10); -} - -int GetAudioOutputSwapStatus(tv_source_input_t source_input) -{ - int sw_status = 0; - const char *config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.enable", "null"); - if ( strcmp ( config_value, "enable" ) == 0 ) { - switch (source_input) { - case SOURCE_AV1: - config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.av1", "null"); - break; - case SOURCE_AV2: - config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.av2", "null"); - break; - case SOURCE_HDMI1: - config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.hdmi1", "null"); - break; - case SOURCE_HDMI2: - config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.hdmi2", "null"); - break; - case SOURCE_HDMI3: - config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.hdmi3", "null"); - break; - case SOURCE_TV: - config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.tv", "null"); - break; - case SOURCE_DTV: - config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.dtv", "null"); - break; - case SOURCE_MPEG: - config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.mpeg", "null"); - break; - default: - break; - } - - } - - sw_status = atoi ( config_value ); - return sw_status; -} - -int GetAudioArchitectureTypeCFG() -{ - static int architecture_type = -1; - const char *config_value = NULL; - - config_value = config_get_str ( CFG_SECTION_TV, "audio.architecture.type", "null" ); - if (strcasecmp(config_value, "null") == 0) { - architecture_type = CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC; - } else if ((strcasecmp(config_value, "t866_external_dac_offboard_fbc") == 0) || (strcasecmp(config_value, "g9tv_external_dac_offboard_fbc") == 0)) { - architecture_type = CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC; - } else if ((strcasecmp(config_value, "t866_external_dac_offboard_customer_lib") == 0) || (strcasecmp(config_value, "g9tv_external_dac_customer_lib") == 0)) { - architecture_type = CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB; - } else if ((strcasecmp(config_value, "t866_external_dac_offboard_digital") == 0) || (strcasecmp(config_value, "g9tv_external_dac_digital") == 0)) { - architecture_type = CC_DAC_G9TV_EXTERNAL_DAC_DIGITAL; - } else if ((strcasecmp(config_value, "t866_external_dac_onboard") == 0) || (strcasecmp(config_value, "g9tv_external_dac_onboard") == 0)) { - architecture_type = CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD; - } else if ((strcasecmp(config_value, "t866_iternal_dac") == 0) || (strcasecmp(config_value, "g9tv_iternal_dac") == 0)) { - architecture_type = CC_DAC_G9TV_INTERNAL_DAC; - } - - return architecture_type; -} - -static int gAudioResampleType = -1; -int GetAudioResampleTypeCFG() -{ - char *token = NULL; - const char *strDelimit = ","; - const char *config_value = NULL; - char cfg_buf[1024]; - - if (gAudioResampleType == -1) { - gAudioResampleType = 0; - - char *pSave; - config_value = config_get_str ( CFG_SECTION_TV, "audio.resample.type", "null" ); - strncpy(cfg_buf, config_value, sizeof(cfg_buf)); - if (strcmp(cfg_buf, "") != 0) { - token = strtok_r(cfg_buf, strDelimit, &pSave); - while (token != NULL) { - if (strcasecmp(token, "hw") == 0) { - gAudioResampleType |= CC_AUD_RESAMPLE_TYPE_HW; - } else if (strcasecmp(token, "sw") == 0) { - gAudioResampleType |= CC_AUD_RESAMPLE_TYPE_SW; - } - - token = strtok_r(NULL, strDelimit, &pSave); - } - } else { - gAudioResampleType = CC_AUD_RESAMPLE_TYPE_SW; //if can't find config string, allow sw resample - } - } - - return gAudioResampleType; -} - |