151 files changed, 45277 insertions, 47437 deletions
diff --git a/tvapi/libtv/vpp/CVpp.cpp b/tvapi/libtv/vpp/CVpp.cpp index 78a4318..d3cfdc4 100644 --- a/tvapi/libtv/vpp/CVpp.cpp +++ b/tvapi/libtv/vpp/CVpp.cpp @@ -23,3689 +23,3591 @@ #undef LOG_TAG #define LOG_TAG "CVpp" #endif -CVpp::CVpp() -{ - vpp_amvideo_fd = -1; - vpp_amvideo_3d_fd = -1; - mpPqData = new CPqData(); +CVpp::CVpp() { + vpp_amvideo_fd = -1; + vpp_amvideo_3d_fd = -1; + mpPqData = new CPqData(); } -CVpp::~CVpp() -{ - if(mpPqData != NULL) { - delete mpPqData; - mpPqData = NULL; - } +CVpp::~CVpp() { + if (mpPqData != NULL) { + delete mpPqData; + mpPqData = NULL; + } } -int CVpp::Vpp_Init ( void ) -{ - if (mpPqData->openDB() ) { - LOGW ( "%s, open pq failed!", __FUNCTION__ ); - } else { - LOGD ( "%s, open pq success!", __FUNCTION__ ); - } +int CVpp::Vpp_Init(const char *pq_db_path) { + LOGD("Vpp_Init pq_db_path = %s", pq_db_path); + if (mpPqData->openPqDB(pq_db_path)) { + LOGW("%s, open pq failed!", __FUNCTION__); + } else { + LOGD("%s, open pq success!", __FUNCTION__); + } - int ret = -1; - int backlight = 100; - int offset_r = 0, offset_g = 0, offset_b = 0, gain_r = 1024, gain_g = 1024, gain_b = 1024; + int ret = -1; + int backlight = 100; + int offset_r = 0, offset_g = 0, offset_b = 0, gain_r = 1024, gain_g = 1024, gain_b = 1024; - Vpp_GetVppConfig(); + Vpp_GetVppConfig(); - ret = VPP_OpenModule(); - backlight = Tv_GetBacklight ( SOURCE_TYPE_TV ); + ret = VPP_OpenModule(); + backlight = GetBacklight(SOURCE_TYPE_TV); - if ( mbVppCfg_backlight_init) { - backlight = ( backlight + 100 ) * 255 / 200; + if (mbVppCfg_backlight_init) { + backlight = (backlight + 100) * 255 / 200; - if ( backlight < 127 || backlight > 255 ) { - backlight = 255; - } - } + if (backlight < 127 || backlight > 255) { + backlight = 255; + } + } - Tv_SetBacklightWithoutSave ( backlight, SOURCE_TYPE_TV ); + SetBacklight(backlight, SOURCE_TYPE_TV, 0); - if ( SSMReadNonStandardValue() & 1 ) { - Set_Fixed_NonStandard ( 0 ); //close - } else { - Set_Fixed_NonStandard ( 2 ); //open - } + if (SSMReadNonStandardValue() & 1) { + Set_Fixed_NonStandard(0); //close + } else { + Set_Fixed_NonStandard(2); //open + } - Tv_LoadVppSettings ( SOURCE_TYPE_MPEG, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D ); + LoadVppSettings(SOURCE_TYPE_MPEG, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D); - return ret; + return ret; } -int CVpp::Vpp_Uninit ( void ) -{ - Vpp_ResetLastVppSettingsSourceType(); - VPP_CloseModule(); - mpPqData->closeDb(); - return 0; +int CVpp::Vpp_Uninit(void) { + Vpp_ResetLastVppSettingsSourceType(); + VPP_CloseModule(); + mpPqData->closeDb(); + return 0; } -CPqData *CVpp::getPqData() -{ - return mpPqData; +CPqData *CVpp::getPqData() { + return mpPqData; } -int CVpp::VPP_OpenModule ( void ) +int CVpp::doSuspend() { + return mpPqData->closeDb(); +} - if ( vpp_amvideo_fd < 0 ) { - vpp_amvideo_fd = open ( VPP_DEV_PATH, O_RDWR ); +int CVpp::doResume() +{ + return mpPqData->reopenDB(); +} +int CVpp::VPP_OpenModule(void) { - LOGD ( "~~~open~~~##VPP_OpenModule##VPP_DEV_PATH : %s##" , VPP_DEV_PATH); + if (vpp_amvideo_fd < 0) { + vpp_amvideo_fd = open(VPP_DEV_PATH, O_RDWR); - if ( vpp_amvideo_fd < 0 ) { - LOGE ( "Open vpp module, error(%s)!\n", strerror ( errno ) ); - return -1; - } - } + LOGD("~~~open~~~##VPP_OpenModule##VPP_DEV_PATH : %s##", VPP_DEV_PATH); + if (vpp_amvideo_fd < 0) { + LOGE("Open vpp module, error(%s)!\n", strerror(errno)); + return -1; + } + } - if ( vpp_amvideo_3d_fd < 0 ) { - vpp_amvideo_3d_fd = open ( VPP_3D_DEV_PATH, O_RDWR ); - LOGD ( "~~~open~~~##VPP_OpenModule##VPP_3D_DEV_PATH : %s##" , VPP_3D_DEV_PATH); + if (vpp_amvideo_3d_fd < 0) { + vpp_amvideo_3d_fd = open(VPP_3D_DEV_PATH, O_RDWR); + LOGD("~~~open~~~##VPP_OpenModule##VPP_3D_DEV_PATH : %s##", VPP_3D_DEV_PATH); - if ( vpp_amvideo_3d_fd < 0 ) { - LOGE ( "Open vpp 3d module, error(%s)!\n", strerror ( errno ) ); - return -1; - } - } + if (vpp_amvideo_3d_fd < 0) { + LOGE("Open vpp 3d module, error(%s)!\n", strerror(errno)); + return -1; + } + } - return vpp_amvideo_fd; + return vpp_amvideo_fd; } -int CVpp::VPP_CloseModule ( void ) -{ - if ( vpp_amvideo_fd >= 0 ) { - close ( vpp_amvideo_fd ); - vpp_amvideo_fd = -1; - } +int CVpp::VPP_CloseModule(void) { + if (vpp_amvideo_fd >= 0) { + close ( vpp_amvideo_fd); + vpp_amvideo_fd = -1; + } + if (vpp_amvideo_3d_fd >= 0) { + close ( vpp_amvideo_3d_fd); + vpp_amvideo_3d_fd = -1; + } - if ( vpp_amvideo_3d_fd >= 0 ) { - close ( vpp_amvideo_3d_fd ); - vpp_amvideo_3d_fd = -1; - } + return 0; +} + +int CVpp::VPP_DeviceIOCtl(int request, ...) { + int tmp_ret = -1; + va_list ap; + void *arg; + va_start(ap, request); + arg = va_arg ( ap, void * ); + va_end(ap); + tmp_ret = ioctl(vpp_amvideo_fd, request, arg); + return tmp_ret; +} + +int CVpp::Vpp_LoadRegs(am_regs_t regs) { + LOGD("~~~VPP_DeviceIOCtl~~~##Vpp_LoadRegs##AMVECM_IOC_LOAD_REG##"); + + int count_retry = 20; + int rt = 0; + while (count_retry) { + rt = VPP_DeviceIOCtl(AMVECM_IOC_LOAD_REG, ®s); + if (rt < 0) { + LOGE("%s, error(%s), errno(%d)\n", __FUNCTION__, strerror(errno), errno); + if (errno == EBUSY) { + LOGE("%s, %s, retry...\n", __FUNCTION__, strerror(errno)); + count_retry--; + continue; + } + break; + } + break; + } - return 0; + return rt; } - -int CVpp::VPP_DeviceIOCtl ( int request, ... ) -{ - int tmp_ret = -1; - va_list ap; - void *arg; - va_start ( ap, request ); - arg = va_arg ( ap, void * ); - va_end ( ap ); - tmp_ret = ioctl ( vpp_amvideo_fd, request, arg ); - return tmp_ret; +int CVpp::isPreviewWindow() { + char prop_value[PROPERTY_VALUE_MAX]; + memset(prop_value, '\0', PROPERTY_VALUE_MAX); + property_get("tv.is.preview.window", prop_value, "false"); + LOGD("%s, prop tv.is.preview.window is \"%s\".\n", __FUNCTION__, prop_value); + return (strcmp(prop_value, "true")==0) ? 1 : 0; } +int CVpp::LoadVppSettings(tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, + is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + int val = 0, ret = -1; + vpp_color_temperature_mode_t temp_mode = VPP_COLOR_TEMPERATURE_MODE_STANDARD; + vpp_picture_mode_t pqmode = VPP_PICTURE_MODE_STANDARD; + vpp_display_mode_t dispmode = VPP_DISPLAY_MODE_169; + vpp_noise_reduction_mode_t nr_mode = VPP_NOISE_REDUCTION_MODE_MID; + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); -int CVpp::Vpp_LoadRegs ( am_regs_t regs ) -{ - int rt = VPP_DeviceIOCtl ( AMVECM_IOC_LOAD_REG, ®s ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##Vpp_LoadRegs##AMVECM_IOC_LOAD_REG##" ); + if ((vpp_setting_last_source_type == source_type) && (vpp_setting_last_sig_fmt == sig_fmt) + /*&& ( vpp_setting_last_3d_status == status showbo mark)*/ + && (vpp_setting_last_trans_fmt == trans_fmt)) { + return -1; + } + + nr_mode = GetNoiseReductionMode(source_type); + ret |= Vpp_SetNoiseReductionMode(nr_mode, source_type, source_port, sig_fmt, is3d, trans_fmt); + ret |= Vpp_SetXVYCCMode(VPP_XVYCC_MODE_STANDARD, source_type, source_port, sig_fmt, is3d, + trans_fmt); + ret |= Vpp_SetMCDIMode(VPP_MCDI_MODE_STANDARD, source_type, source_port, sig_fmt, is3d, + trans_fmt); + ret |= Vpp_SetDeblockMode(VPP_DEBLOCK_MODE_MIDDLE, source_port, sig_fmt, is3d, trans_fmt); + + Vpp_LoadDI(source_type, sig_fmt, is3d, trans_fmt); + Vpp_LoadBasicRegs(source_type, sig_fmt, is3d, trans_fmt); + Vpp_LoadGamma(source_type, sig_fmt); + + ret |= Vpp_SetBaseColorMode(GetBaseColorMode(), source_port, sig_fmt, is3d, trans_fmt); + + if (isPreviewWindow()) { + temp_mode = GetColorTemperature(SOURCE_TYPE_MPEG); + if (temp_mode == VPP_COLOR_TEMPERATURE_MODE_USER) { + ret |= Vpp_SetColorTemperatureUser(temp_mode, SOURCE_TYPE_MPEG); + } else { + CheckColorTemperatureParamAlldata(TVIN_PORT_HDMI0, sig_fmt, trans_fmt); // check colortmp backup data + ret |= Vpp_SetColorTemperature(temp_mode, SOURCE_TYPE_MPEG, source_port, sig_fmt, trans_fmt); + } + } else { + temp_mode = GetColorTemperature(source_type); + if (temp_mode == VPP_COLOR_TEMPERATURE_MODE_USER) { + ret |= Vpp_SetColorTemperatureUser(temp_mode, source_type); + } else { + CheckColorTemperatureParamAlldata(TVIN_PORT_HDMI0, sig_fmt, trans_fmt); // check colortmp backup data + ret |= Vpp_SetColorTemperature(temp_mode, source_type, source_port, sig_fmt, trans_fmt); + } + } + + pqmode = GetPQMode(source_type); + ret |= Vpp_SetPQMode(pqmode, source_type, source_port, sig_fmt, is3d, trans_fmt); - if ( rt < 0 ) { - LOGE ( "Vpp_LoadRegs, error(%s)!\n", strerror ( errno ) ); - } + ret |= SetDNLP(source_type, source_port, sig_fmt, is3d, trans_fmt); - return rt; + vpp_setting_last_source_type = source_type; + vpp_setting_last_sig_fmt = sig_fmt; + //showbo mark vpp_setting_last_3d_status = status; + vpp_setting_last_trans_fmt = trans_fmt; + + return 0; } -int CVpp::Tv_LoadVppSettings ( tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt ) -{ - int val = 0, ret = -1; - vpp_color_temperature_mode_t temp_mode = VPP_COLOR_TEMPERATURE_MODE_STANDARD; - vpp_picture_mode_t pqmode = VPP_PICTURE_MODE_STANDARD; - vpp_display_mode_t dispmode = VPP_DISPLAY_MODE_169; - vpp_noise_reduction_mode_t nr_mode = VPP_NOISE_REDUCTION_MODE_MID; - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); +int CVpp::Vpp_GetVppConfig(void) { + const char *config_value; + int cfg_item_count = 0; + char *token = NULL; + const char *strDelimit = ","; + char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; - if ( ( vpp_setting_last_source_type == source_type ) - && ( vpp_setting_last_sig_fmt == sig_fmt ) - /*&& ( vpp_setting_last_3d_status == status showbo mark)*/ - && ( vpp_setting_last_trans_fmt == trans_fmt ) ) { - return -1; - } + config_value = config_get_str("TV", "vpp.pqmode.depend.bklight", "null"); - nr_mode = Tv_GetNoiseReductionMode ( source_type ); - ret |= Vpp_SetNoiseReductionMode ( nr_mode, source_type , source_port, sig_fmt, is3d, trans_fmt); - ret |= Vpp_SetXVYCCMode( VPP_XVYCC_MODE_STANDARD, source_type, source_port, sig_fmt, is3d, trans_fmt ); - ret |= Vpp_SetMCDIMode( VPP_MCDI_MODE_STANDARD, source_type , source_port, sig_fmt, is3d, trans_fmt ); + if (strcmp(config_value, "enable") == 0) { + mbVppCfg_pqmode_depend_bklight = true; + } else { + mbVppCfg_pqmode_depend_bklight = false; + } - Vpp_LoadBasicRegs ( source_type, sig_fmt, is3d, trans_fmt ); - Vpp_LoadGamma ( source_type, sig_fmt ); + config_value = config_get_str("TV", "vpp.color.temp.bysource", "enable"); - ret |= Vpp_SetBaseColorMode ( Tv_GetBaseColorMode() , source_port, sig_fmt, is3d, trans_fmt); + if (strcmp(config_value, "enable") == 0) { + mbVppCfg_colortemp_by_source = true; + } else { + mbVppCfg_colortemp_by_source = true; + } - temp_mode = Tv_GetColorTemperature ( source_type ); + config_value = config_get_str("TV", "vpp.panoroma.switch", "null"); - if ( temp_mode == VPP_COLOR_TEMPERATURE_MODE_USER ) { - ret |= Vpp_SetColorTemperatureUser ( temp_mode, source_type ); - } else { - CheckColorTemperatureParamAlldata(TVIN_PORT_HDMI0, sig_fmt, trans_fmt); // check colortmp backup data - ret |= Vpp_SetColorTemperature ( temp_mode, source_type , source_port, sig_fmt, trans_fmt); - } + if (strcmp(config_value, "enable") == 0) { + mbVppCfg_panorama_switch = true; + } else { + mbVppCfg_panorama_switch = false; + } - pqmode = Tv_GetPQMode ( source_type ); - ret |= Vpp_SetPQMode ( pqmode, source_type , source_port, sig_fmt, is3d, trans_fmt); + config_value = config_get_str("TV", "vpp.backlight.reverse", "null"); - ret |= Tv_SetDNLP(source_type , source_port, sig_fmt, is3d, trans_fmt); + if (strcmp(config_value, "enable") == 0) { + mbVppCfg_backlight_reverse = true; + } else { + mbVppCfg_backlight_reverse = false; + } - vpp_setting_last_source_type = source_type; - vpp_setting_last_sig_fmt = sig_fmt; - //showbo mark vpp_setting_last_3d_status = status; - vpp_setting_last_trans_fmt = trans_fmt; + config_value = config_get_str("TV", "vpp.backlight.init", "null"); - return 0; -} + if (strcmp(config_value, "enable") == 0) { + mbVppCfg_backlight_init = true; + } else { + mbVppCfg_backlight_init = false; + } + config_value = config_get_str("TV", "vpp.pqwithout.hue", "null"); + if (strcmp(config_value, "enable") == 0) { + mbVppCfg_pqmode_without_hue = true; + } else { + mbVppCfg_pqmode_without_hue = false; + } -int CVpp::Vpp_GetVppConfig ( void ) -{ - const char *config_value; - int cfg_item_count = 0; - char *token = NULL; - const char *strDelimit = ","; - char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; + config_value = config_get_str("TV", "vpp.hue.reverse", "null"); + + if (strcmp(config_value, "enable") == 0) { + mbVppCfg_hue_reverse = true; + } else { + mbVppCfg_hue_reverse = false; + } - config_value = config_get_str ( "TV", "vpp.pqmode.depend.bklight", "null" ); + config_value = config_get_str("TV", "vpp.gamma.onoff", "null"); - if ( strcmp ( config_value, "enable" ) == 0 ) { - mbVppCfg_pqmode_depend_bklight = true; - } else { - mbVppCfg_pqmode_depend_bklight = false; - } + if (strcmp(config_value, "disable") == 0) { + mbVppCfg_gamma_onoff = true; + } else { + mbVppCfg_gamma_onoff = false; + } + + config_value = config_get_str("TV", "vpp.whitebalance.same_param", "null"); - config_value = config_get_str ( "TV", "vpp.color.temp.bysource", "enable" ); + if (strcmp(config_value, "enable") == 0) { + mbVppCfg_whitebalance_sameparam = true; + } else { + mbVppCfg_whitebalance_sameparam = false; + } - if ( strcmp ( config_value, "enable" ) == 0 ) { - mbVppCfg_colortemp_by_source = true; - } else { - mbVppCfg_colortemp_by_source = true; - } + config_value = config_get_str("TV", "vpp.new.cm", "disable"); + + if (strcmp(config_value, "enable") == 0) { + mbVppCfg_new_cm = true; + } else { + mbVppCfg_new_cm = false; + } - config_value = config_get_str ( "TV", "vpp.panoroma.switch", "null" ); + config_value = config_get_str("TV", "vpp.new.nr", "disable"); - if ( strcmp ( config_value, "enable" ) == 0 ) { - mbVppCfg_panorama_switch = true; - } else { - mbVppCfg_panorama_switch = false; - } + if (strcmp(config_value, "enable") == 0) { + mbVppCfg_new_nr = true; + } else { + mbVppCfg_new_nr = false; + } - config_value = config_get_str ( "TV", "vpp.backlight.reverse", "null" ); + return 0; +} - if ( strcmp ( config_value, "enable" ) == 0 ) { - mbVppCfg_backlight_reverse = true; - } else { - mbVppCfg_backlight_reverse = false; - } +int CVpp::Vpp_LoadDI(tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, + is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + am_regs_t regs; + int ret = -1; + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); + if (mpPqData->getRegValues("GeneralDITable", source_port, sig_fmt, is3d, trans_fmt, ®s) > 0) { + if (Vpp_LoadRegs(regs) < 0) { + LOGE("%s, Vpp_LoadRegs failed!\n", __FUNCTION__); + } else { + ret = 0; + } + } else { + LOGE("%s getRegValues failed!\n", "Vpp_LoadDI"); + } + return ret; +} - config_value = config_get_str ( "TV", "vpp.backlight.init", "null" ); +int CVpp::Vpp_LoadBasicRegs(tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, + is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + am_regs_t regs; + int ret = -1, rangeRet = -1, formatRet = -1, enableFlag = -1; - if ( strcmp ( config_value, "enable" ) == 0 ) { - mbVppCfg_backlight_init = true; - } else { - mbVppCfg_backlight_init = false; - } + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); - config_value = config_get_str ( "TV", "vpp.pqwithout.hue", "null" ); + if (mpPqData->getRegValues("GeneralCommonTable", source_port, sig_fmt, is3d, trans_fmt, ®s) > 0) { + if (Vpp_LoadRegs(regs) < 0) { + LOGE("%s, Vpp_LoadRegs failed!\n", __FUNCTION__); + } else { + ret = 0; + } + } else { + LOGE("%s getRegValues failed!\n", "Vpp_LoadBasicRegs"); + } - if ( strcmp ( config_value, "enable" ) == 0 ) { - mbVppCfg_pqmode_without_hue = true; - } else { - mbVppCfg_pqmode_without_hue = false; - } + if (mpPqData->LoadAllPQData(source_port, sig_fmt, is3d, trans_fmt, enableFlag) == 0) { + ret = 0; + } else { + LOGE("%s, getPQData failed!\n", "Vpp_LoadBasicRegs"); + ret = -1; + } - config_value = config_get_str ( "TV", "vpp.hue.reverse", "null" ); + return ret; +} - if ( strcmp ( config_value, "enable" ) == 0 ) { - mbVppCfg_hue_reverse = true; - } else { - mbVppCfg_hue_reverse = false; - } +int CVpp::Vpp_ResetLastVppSettingsSourceType(void) { + vpp_setting_last_source_type = SOURCE_TYPE_MAX; + vpp_setting_last_sig_fmt = TVIN_SIG_FMT_MAX; + //showbo mark vpp_setting_last_3d_status = STATUS3D_MAX; + vpp_setting_last_trans_fmt = TVIN_TFMT_3D_MAX; + return 0; +} - config_value = config_get_str ( "TV", "vpp.gamma.onoff", "null" ); +int CVpp::VPP3D_DeviceIOCtl(int request, ...) { + int tmp_ret = -1; + va_list ap; + void *arg; - if ( strcmp ( config_value, "disable" ) == 0 ) { - mbVppCfg_gamma_onoff = true; - } else { - mbVppCfg_gamma_onoff = false; - } + if (vpp_amvideo_3d_fd >= 0) { + va_start(ap, request); + arg = va_arg ( ap, void * ); + va_end(ap); - config_value = config_get_str ( "TV", "vpp.whitebalance.same_param", "null" ); + tmp_ret = ioctl(vpp_amvideo_3d_fd, request, arg); + return tmp_ret; + } - if ( strcmp ( config_value, "enable" ) == 0 ) { - mbVppCfg_whitebalance_sameparam = true; - } else { - mbVppCfg_whitebalance_sameparam = false; - } + return -1; +} - config_value = config_get_str ( "TV", "vpp.new.cm", "disable" ); +int CVpp::Vpp_GetPQModeValue(tv_source_input_type_t source_type, vpp_picture_mode_t pq_mode, + vpp_pq_para_t *pq_para) { + vpp_pq_para_t parms; + vpp_picture_mode_t real_pq_mode; - if ( strcmp ( config_value, "enable" ) == 0 ) { - mbVppCfg_new_cm = true; - } else { - mbVppCfg_new_cm = false; - } + if (pq_para == NULL) { + return -1; + } - config_value = config_get_str ( "TV", "vpp.new.nr", "disable" ); + if (pq_mode == VPP_PICTURE_MODE_MOVIE) { + real_pq_mode = VPP_PICTURE_MODE_SOFT; + } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { + real_pq_mode = VPP_PICTURE_MODE_BRIGHT; + } else { + real_pq_mode = pq_mode; + } + if (mpPqData->PQ_GetPQModeParams(source_type, real_pq_mode, pq_para) == 0) { + if (mbVppCfg_pqmode_without_hue) { + SSMReadHue(source_type, &(pq_para->hue)); + } + if (pq_mode == VPP_PICTURE_MODE_MOVIE) { + pq_para->brightness -= 10; + pq_para->contrast -= 10; + pq_para->saturation -= 10; + pq_para->sharpness -= 10; + } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { + pq_para->brightness += 10; + pq_para->contrast += 10; + pq_para->saturation += 10; + pq_para->sharpness += 10; + } else { + } - if ( strcmp ( config_value, "enable" ) == 0 ) { - mbVppCfg_new_nr = true; - } else { - mbVppCfg_new_nr = false; - } + } else { + LOGE("%s, PQ_GetPQModeParams failed!\n", "Vpp_GetPQModeValue"); + return -1; + } - return 0; + return 0; } -int CVpp::Vpp_LoadBasicRegs ( tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt ) -{ - am_regs_t regs; - int ret = -1, rangeRet = -1, formatRet = -1, enableFlag = -1; +int CVpp::Vpp_SetPQParams(tv_source_input_type_t source_type, vpp_picture_mode_t pq_mode, + vpp_pq_para_t pq_para, tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, + tvin_trans_fmt_t trans_fmt) { + int ret = 0, brightness = 50, contrast = 50, saturation = 50, hue = 50, sharnpess = 50; + am_regs_t regs, regs_l; + int level; - if ( source_type == SOURCE_TYPE_HDMI ) { - rangeRet = GetFileAttrIntValue ( "/sys/module/tvin_hdmirx/parameters/rgb_quant_range" ); - formatRet = GetFileAttrIntValue ( "/sys/module/tvin_hdmirx/parameters/cur_colorspace" ); + if (pq_para.brightness >= 0 && pq_para.brightness <= 100) { + if (mpPqData->PQ_GetBrightnessParams(source_port, sig_fmt, is3d, trans_fmt, + pq_para.brightness, &brightness) == 0) { + } else { + LOGE("%s, PQ_GetBrightnessParams error!\n", "Vpp_SetPQParams"); + } - if ( rangeRet == LIMIT_RANGE && formatRet == RGB_FORMAT ) { - enableFlag = 1; - } - } + ret |= VPP_SetVideoBrightness(brightness); + } - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); + if (pq_para.contrast >= 0 && pq_para.contrast <= 100) { + if (mpPqData->PQ_GetContrastParams(source_port, sig_fmt, is3d, trans_fmt, pq_para.contrast, + &contrast) == 0) { + } else { + LOGE("%s, PQ_GetBrightnessParams error!\n", "Vpp_SetPQParams"); + } - if ( mpPqData->getRegValues ( source_port, sig_fmt, is3d, trans_fmt, ®s ) > 0 ) { - if ( Vpp_LoadRegs ( regs ) < 0 ) { - LOGE ( "%s, Vpp_LoadRegs failed!\n", __FUNCTION__ ); - } else { - ret = 0; - } - } else { - LOGE ( "%s getRegValues failed!\n", "Vpp_LoadBasicRegs" ); - } + ret |= VPP_SetVideoContrast(contrast); + } - if (mpPqData->LoadAllPQData ( source_port, sig_fmt, is3d, trans_fmt, enableFlag ) == 0 ) { - ret = 0; - } else { - LOGE ( "%s, getPQData failed!\n", "Vpp_LoadBasicRegs" ); - ret = -1; - } + if (pq_para.saturation >= 0 && pq_para.saturation <= 100) { + if (mpPqData->PQ_GetSaturationParams(source_port, sig_fmt, is3d, trans_fmt, + pq_para.saturation, &saturation) == 0) { + + if (mbVppCfg_hue_reverse) { + pq_para.hue = 100 - pq_para.hue; + } else { + pq_para.hue = pq_para.hue; + } + + if (mpPqData->PQ_GetHueParams(source_port, sig_fmt, is3d, trans_fmt, pq_para.hue, &hue) + == 0) { + if ((source_type == SOURCE_TYPE_TV || source_type == SOURCE_TYPE_AV) && (sig_fmt + == TVIN_SIG_FMT_CVBS_NTSC_M || sig_fmt == TVIN_SIG_FMT_CVBS_NTSC_443)) { + } else { + hue = 0; + } + } else { + LOGE("%s, PQ_GetHueParams error!\n", "Vpp_SetPQParams"); + } + } else { + LOGE("%s, PQ_GetSaturationParams error!\n", "Vpp_SetPQParams"); + } - return ret; -} + ret |= VPP_SetVideoSaturationHue(saturation, hue); + } + if (pq_para.sharpness >= 0 && pq_para.sharpness <= 100) { + level = pq_para.sharpness; + + if (mpPqData->PQ_GetSharpnessParams(source_port, sig_fmt, is3d, trans_fmt, level, ®s, + ®s_l) == 0) { + if (Vpp_LoadRegs(regs) < 0) { + LOGE("%s, load reg for sharpness0 failed!\n", __FUNCTION__); + } + if (mpPqData->getSharpnessFlag() == 6 && Vpp_LoadRegs(regs_l) < 0) { + LOGE("%s, load reg for sharpness1 failed!\n", __FUNCTION__); + } + } else { + LOGE("%s, PQ_GetSharpnessParams failed!\n", __FUNCTION__); + } + } + if (pq_mode == VPP_PICTURE_MODE_MOVIE) { + ret |= SetColorTemperature(VPP_COLOR_TEMPERATURE_MODE_WARM, source_type, 1); + } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { + ret |= SetColorTemperature(VPP_COLOR_TEMPERATURE_MODE_COLD, source_type, 1); + } -int CVpp::Vpp_ResetLastVppSettingsSourceType ( void ) -{ - vpp_setting_last_source_type = SOURCE_TYPE_MAX; - vpp_setting_last_sig_fmt = TVIN_SIG_FMT_MAX; - //showbo mark vpp_setting_last_3d_status = STATUS3D_MAX; - vpp_setting_last_trans_fmt = TVIN_TFMT_3D_MAX; - return 0; + return ret; } -int CVpp::VPP3D_DeviceIOCtl ( int request, ... ) -{ - int tmp_ret = -1; - va_list ap; - void *arg; +int CVpp::Vpp_SetPQMode(vpp_picture_mode_t pq_mode, tv_source_input_type_t source_type, + tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, + tvin_trans_fmt_t trans_fmt) { + vpp_pq_para_t pq_para; + int ret = -1; - if ( vpp_amvideo_3d_fd >= 0 ) { - va_start ( ap, request ); - arg = va_arg ( ap, void * ); - va_end ( ap ); + if (pq_mode == VPP_PICTURE_MODE_USER) { + ret = SSMReadBrightness(source_type, &pq_para.brightness); + ret = SSMReadContrast(source_type, &pq_para.contrast); + ret = SSMReadSaturation(source_type, &pq_para.saturation); + ret = SSMReadHue(source_type, &pq_para.hue); + ret = SSMReadSharpness(source_type, &pq_para.sharpness); + } /*else if (pq_mode == VPP_PICTURE_MODE_MOVIE) { + ret = Vpp_GetPQModeValue ( source_type, VPP_PICTURE_MODE_SOFT, &pq_para ); + pq_para.brightness -=10; + pq_para.contrast -=10; + pq_para.saturation -=10; + pq_para.sharpness -=10; + } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { + ret = Vpp_GetPQModeValue ( source_type, VPP_PICTURE_MODE_BRIGHT, &pq_para ); + pq_para.brightness +=10; + pq_para.contrast +=10; + pq_para.saturation +=10; + pq_para.sharpness +=10; + }*/else { + ret = Vpp_GetPQModeValue(source_type, pq_mode, &pq_para); + } - tmp_ret = ioctl ( vpp_amvideo_3d_fd, request, arg ); - return tmp_ret; - } + ret |= Vpp_SetPQParams(source_type, pq_mode, pq_para, source_port, sig_fmt, is3d, trans_fmt); - return -1; + return ret; } -int CVpp::Vpp_GetPQModeValue ( tv_source_input_type_t source_type, vpp_picture_mode_t pq_mode, vpp_pq_para_t *pq_para ) -{ - vpp_pq_para_t parms; - vpp_picture_mode_t real_pq_mode; - - if ( pq_para == NULL ) { - return -1; - } - - if (pq_mode == VPP_PICTURE_MODE_MOVIE) { - real_pq_mode = VPP_PICTURE_MODE_SOFT; - } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { - real_pq_mode = VPP_PICTURE_MODE_BRIGHT; - } else { - real_pq_mode = pq_mode; - } - if ( mpPqData->PQ_GetPQModeParams ( source_type, real_pq_mode, pq_para ) == 0 ) { - if ( mbVppCfg_pqmode_without_hue) { - SSMReadHue ( source_type, & ( pq_para->hue ) ); - } - if (pq_mode == VPP_PICTURE_MODE_MOVIE) { - pq_para->brightness -= 10; - pq_para->contrast -= 10; - pq_para->saturation -= 10; - pq_para->sharpness -= 10; - } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { - pq_para->brightness += 10; - pq_para->contrast += 10; - pq_para->saturation += 10; - pq_para->sharpness += 10; - } else {} - - } else { - LOGE ( "%s, PQ_GetPQModeParams failed!\n", "Vpp_GetPQModeValue" ); - return -1; - } - - return 0; -} - -int CVpp::Vpp_SetPQParams ( tv_source_input_type_t source_type, vpp_picture_mode_t pq_mode, vpp_pq_para_t pq_para , tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) -{ - int ret = 0, brightness = 50, contrast = 50, saturation = 50, hue = 50, sharnpess = 50; - am_regs_t regs; - int level; - - if ( pq_para.brightness >= 0 && pq_para.brightness <= 100 ) { - if ( mpPqData->PQ_GetBrightnessParams ( source_port, sig_fmt, is3d, trans_fmt, pq_para.brightness, &brightness ) == 0 ) { - } else { - LOGE ( "%s, PQ_GetBrightnessParams error!\n", "Vpp_SetPQParams" ); - } - - ret |= VPP_SetVideoBrightness ( brightness ); - } - - if ( pq_para.contrast >= 0 && pq_para.contrast <= 100 ) { - if ( mpPqData->PQ_GetContrastParams ( source_port, sig_fmt, is3d, trans_fmt, pq_para.contrast, &contrast ) == 0 ) { - } else { - LOGE ( "%s, PQ_GetBrightnessParams error!\n", "Vpp_SetPQParams" ); - } - - ret |= VPP_SetVideoContrast ( contrast ); - } - - if ( pq_para.saturation >= 0 && pq_para.saturation <= 100 ) { - if ( mpPqData->PQ_GetSaturationParams ( source_port, sig_fmt, is3d, trans_fmt, pq_para.saturation, &saturation ) == 0 ) { - - if ( mbVppCfg_hue_reverse) { - pq_para.hue = 100 - pq_para.hue; - } else { - pq_para.hue = pq_para.hue; - } - - if ( mpPqData->PQ_GetHueParams ( source_port, sig_fmt, is3d, trans_fmt, pq_para.hue, &hue ) == 0 ) { - if ( ( source_type == SOURCE_TYPE_TV || source_type == SOURCE_TYPE_AV ) - && ( sig_fmt == TVIN_SIG_FMT_CVBS_NTSC_M || sig_fmt == TVIN_SIG_FMT_CVBS_NTSC_443 ) ) { - } else { - hue = 0; - } - } else { - LOGE ( "%s, PQ_GetHueParams error!\n", "Vpp_SetPQParams" ); - } - } else { - LOGE ( "%s, PQ_GetSaturationParams error!\n", "Vpp_SetPQParams" ); - } - - ret |= VPP_SetVideoSaturationHue ( saturation, hue ); - } - - if ( pq_para.sharpness >= 0 && pq_para.sharpness <= 100) { - level = pq_para.sharpness; - - if ( mpPqData->PQ_GetSharpnessParams ( source_port, sig_fmt, is3d, trans_fmt, level, ®s ) == 0 ) { - if ( Vpp_LoadRegs ( regs ) < 0 ) { - LOGE ( "%s, PQ_GetSharpnessParams failed!\n", "Vpp_SetPQParams" ); - } - } else { - LOGE ( "%s, PQ_GetSharpnessParams failed!\n", "Vpp_SetPQParams" ); - } - } - - if (pq_mode == VPP_PICTURE_MODE_MOVIE) { - ret |= Tv_SetColorTemperature(VPP_COLOR_TEMPERATURE_MODE_WARM, source_type, 1); - } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { - ret |= Tv_SetColorTemperature(VPP_COLOR_TEMPERATURE_MODE_COLD, source_type, 1); - } - - return ret; -} - -int CVpp::Vpp_SetPQMode ( vpp_picture_mode_t pq_mode, tv_source_input_type_t source_type , tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) -{ - vpp_pq_para_t pq_para; - int ret = -1; - - if ( pq_mode == VPP_PICTURE_MODE_USER ) { - ret = SSMReadBrightness ( source_type, &pq_para.brightness ); - ret = SSMReadContrast ( source_type, &pq_para.contrast ); - ret = SSMReadSaturation ( source_type, &pq_para.saturation ); - ret = SSMReadHue ( source_type, &pq_para.hue ); - ret = SSMReadSharpness ( source_type, &pq_para.sharpness ); - } /*else if (pq_mode == VPP_PICTURE_MODE_MOVIE) { - ret = Vpp_GetPQModeValue ( source_type, VPP_PICTURE_MODE_SOFT, &pq_para ); - pq_para.brightness -=10; - pq_para.contrast -=10; - pq_para.saturation -=10; - pq_para.sharpness -=10; - } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { - ret = Vpp_GetPQModeValue ( source_type, VPP_PICTURE_MODE_BRIGHT, &pq_para ); - pq_para.brightness +=10; - pq_para.contrast +=10; - pq_para.saturation +=10; - pq_para.sharpness +=10; - }*/ else { - ret = Vpp_GetPQModeValue ( source_type, pq_mode, &pq_para ); - } - - ret |= Vpp_SetPQParams ( source_type, pq_mode, pq_para , source_port , sig_fmt , is3d , trans_fmt ); +int CVpp::SavePQMode(vpp_picture_mode_t pq_mode, tv_source_input_type_t source_type) { + vpp_pq_para_t pq_para; + int ret = -1; + int tmp_pic_mode = 0; - return ret; + tmp_pic_mode = (int) pq_mode; + ret = SSMSavePictureMode(source_type, tmp_pic_mode); + return ret; } -int CVpp::Tv_SavePQMode ( vpp_picture_mode_t pq_mode, tv_source_input_type_t source_type ) -{ - vpp_pq_para_t pq_para; - int ret = -1; - int tmp_pic_mode = 0; +int CVpp::SetPQMode(vpp_picture_mode_t pq_mode, tv_source_input_type_t source_type, + tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save) { + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); + + if (0 == Vpp_SetPQMode(pq_mode, source_type, source_port, sig_fmt, is3d, trans_fmt)) { + if (is_save == 1) { + return SavePQMode(pq_mode, source_type); + } else { + return 0; + } + } - tmp_pic_mode = ( int ) pq_mode; - ret = SSMSavePictureMode ( source_type, tmp_pic_mode ); - return ret; + LOGE("%s, failed!", "SetPQMode"); + return -1; } -int CVpp::Tv_SetPQMode ( vpp_picture_mode_t pq_mode, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save ) -{ - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); +vpp_picture_mode_t CVpp::GetPQMode(tv_source_input_type_t source_type) { + vpp_picture_mode_t data = VPP_PICTURE_MODE_STANDARD; + int tmp_pic_mode = 0; + + SSMReadPictureMode(source_type, &tmp_pic_mode); + data = (vpp_picture_mode_t) tmp_pic_mode; - if ( 0 == Vpp_SetPQMode ( pq_mode, source_type , source_port , sig_fmt , is3d , trans_fmt) ) { - if ( is_save == 1 ) { - return Tv_SavePQMode ( pq_mode, source_type ); - } else { - return 0; - } - } + if (data < VPP_PICTURE_MODE_STANDARD || data >= VPP_PICTURE_MODE_MAX) { + data = VPP_PICTURE_MODE_STANDARD; + } - LOGE ( "%s, failed!", "Tv_SetPQMode" ); - return -1; + return data; } -vpp_picture_mode_t CVpp::Tv_GetPQMode ( tv_source_input_type_t source_type ) -{ - vpp_picture_mode_t data = VPP_PICTURE_MODE_STANDARD; - int tmp_pic_mode = 0; +int CVpp::Vpp_SetColorDemoMode(vpp_color_demomode_t demomode) { + cm_regmap_t regmap; + unsigned long *temp_regmap; + int i = 0; + int tmp_demo_mode = 0; + vpp_display_mode_t displaymode = VPP_DISPLAY_MODE_MODE43; + switch (demomode) { + case VPP_COLOR_DEMO_MODE_YOFF: + temp_regmap = DemoColorYOffRegMap; + break; - SSMReadPictureMode ( source_type, &tmp_pic_mode ); - data = ( vpp_picture_mode_t ) tmp_pic_mode; + case VPP_COLOR_DEMO_MODE_COFF: + temp_regmap = DemoColorCOffRegMap; + break; - if ( data < VPP_PICTURE_MODE_STANDARD || data >= VPP_PICTURE_MODE_MAX ) { - data = VPP_PICTURE_MODE_STANDARD; - } + case VPP_COLOR_DEMO_MODE_GOFF: + temp_regmap = DemoColorGOffRegMap; + break; - return data; -} + case VPP_COLOR_DEMO_MODE_MOFF: + temp_regmap = DemoColorMOffRegMap; + break; -int CVpp::Vpp_SetColorDemoMode ( vpp_color_demomode_t demomode ) -{ - cm_regmap_t regmap; - unsigned long *temp_regmap; - int i = 0; - int tmp_demo_mode = 0; - vpp_display_mode_t displaymode = VPP_DISPLAY_MODE_MODE43; - - switch ( demomode ) { - case VPP_COLOR_DEMO_MODE_YOFF: - temp_regmap = DemoColorYOffRegMap; - break; - - case VPP_COLOR_DEMO_MODE_COFF: - temp_regmap = DemoColorCOffRegMap; - break; - - case VPP_COLOR_DEMO_MODE_GOFF: - temp_regmap = DemoColorGOffRegMap; - break; - - case VPP_COLOR_DEMO_MODE_MOFF: - temp_regmap = DemoColorMOffRegMap; - break; - - case VPP_COLOR_DEMO_MODE_ROFF: - temp_regmap = DemoColorROffRegMap; - break; - - case VPP_COLOR_DEMO_MODE_BOFF: - temp_regmap = DemoColorBOffRegMap; - break; - - case VPP_COLOR_DEMO_MODE_RGBOFF: - temp_regmap = DemoColorRGBOffRegMap; - break; - - case VPP_COLOR_DEMO_MODE_YMCOFF: - temp_regmap = DemoColorYMCOffRegMap; - break; - - case VPP_COLOR_DEMO_MODE_ALLOFF: - temp_regmap = DemoColorALLOffRegMap; - break; - - case VPP_COLOR_DEMO_MODE_ALLON: - default: - if ( displaymode == VPP_DISPLAY_MODE_MODE43 ) { - temp_regmap = DemoColorSplit4_3RegMap; - } else { - temp_regmap = DemoColorSplitRegMap; - } - - break; - } - - for ( i = 0; i < CM_REG_NUM; i++ ) { - regmap.reg[i] = temp_regmap[i]; - } - - if ( VPP_SetCMRegisterMap ( ®map ) == 0 ) { - tmp_demo_mode = demomode; - LOGD ( "%s, demomode[%d] success.", "Vpp_SetColorDemoMode", demomode ); - return 0; - } - - LOGE ( "%s, demomode[%d] failed.", "Vpp_SetColorDemoMode", demomode ); - return -1; -} - -int CVpp::Vpp_SetBaseColorMode ( vpp_color_basemode_t basemode , tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) -{ - int ret = -1; - am_regs_t regs; - LOGD ( "%s.\n", "Vpp_SetBaseColorMode" ); + case VPP_COLOR_DEMO_MODE_ROFF: + temp_regmap = DemoColorROffRegMap; + break; - if ( mbVppCfg_new_cm) { - if ( mpPqData->PQ_GetCM2Params ( ( vpp_color_management2_t ) basemode, source_port, sig_fmt, is3d, trans_fmt, ®s ) == 0 ) { - ret = Vpp_LoadRegs ( regs ); - } else { - LOGE ( "PQ_GetCM2Params failed!\n" ); - } - } + case VPP_COLOR_DEMO_MODE_BOFF: + temp_regmap = DemoColorBOffRegMap; + break; - return ret; -} + case VPP_COLOR_DEMO_MODE_RGBOFF: + temp_regmap = DemoColorRGBOffRegMap; + break; -int CVpp::Vpp_SetColorTemperatureUser ( vpp_color_temperature_mode_t temp_mode, tv_source_input_type_t source_type ) -{ - tcon_rgb_ogo_t rgbogo; - unsigned int gain_r, gain_g, gain_b; + case VPP_COLOR_DEMO_MODE_YMCOFF: + temp_regmap = DemoColorYMCOffRegMap; + break; - if ( SSMReadRGBGainRStart ( 0, &gain_r ) != 0 ) { - return -1; - } + case VPP_COLOR_DEMO_MODE_ALLOFF: + temp_regmap = DemoColorALLOffRegMap; + break; - rgbogo.r_gain = gain_r; + case VPP_COLOR_DEMO_MODE_ALLON: + default: + if (displaymode == VPP_DISPLAY_MODE_MODE43) { + temp_regmap = DemoColorSplit4_3RegMap; + } else { + temp_regmap = DemoColorSplitRegMap; + } - if ( SSMReadRGBGainGStart ( 0, &gain_g ) != 0 ) { - return -1; - } + break; + } - rgbogo.g_gain = gain_g; + for (i = 0; i < CM_REG_NUM; i++) { + regmap.reg[i] = temp_regmap[i]; + } - if ( SSMReadRGBGainBStart ( 0, &gain_b ) != 0 ) { - return -1; - } + if (VPP_SetCMRegisterMap(®map) == 0) { + tmp_demo_mode = demomode; + LOGD("%s, demomode[%d] success.", "Vpp_SetColorDemoMode", demomode); + return 0; + } - rgbogo.b_gain = gain_b; - rgbogo.r_post_offset = 0; - rgbogo.r_pre_offset = 0; - rgbogo.g_post_offset = 0; - rgbogo.g_pre_offset = 0; - rgbogo.b_post_offset = 0; - rgbogo.b_pre_offset = 0; + LOGE("%s, demomode[%d] failed.", "Vpp_SetColorDemoMode", demomode); + return -1; +} - if ( VPP_SetRGBOGO ( &rgbogo ) == 0 ) { - return 0; - } +int CVpp::Vpp_SetBaseColorMode(vpp_color_basemode_t basemode, tvin_port_t source_port, + tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + int ret = -1; + am_regs_t regs; + LOGD("%s.\n", "Vpp_SetBaseColorMode"); + + if (mbVppCfg_new_cm) { + if (mpPqData->PQ_GetCM2Params((vpp_color_management2_t) basemode, source_port, sig_fmt, + is3d, trans_fmt, ®s) == 0) { + ret = Vpp_LoadRegs(regs); + } else { + LOGE("PQ_GetCM2Params failed!\n"); + } + } - LOGE ( "%s, source_type_user[%d] failed.", "Vpp_SetColorTemperatureUser", source_type ); - return -1; + return ret; } -int CVpp::Vpp_SetColorTemperature ( vpp_color_temperature_mode_t Tempmode, tv_source_input_type_t source_type, tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt) -{ - tcon_rgb_ogo_t rgbogo, rgbPreOffset; - int ret = -1; +int CVpp::Vpp_SetColorTemperatureUser(vpp_color_temperature_mode_t temp_mode, + tv_source_input_type_t source_type) { + tcon_rgb_ogo_t rgbogo; + unsigned int gain_r, gain_g, gain_b; - if ( mbVppCfg_gamma_onoff) { - VPP_SetGammaOnOff ( 0 ); - } else { - VPP_SetGammaOnOff ( 1 ); - } + if (SSMReadRGBGainRStart(0, &gain_r) != 0) { + return -1; + } - GetColorTemperatureParams ( Tempmode, &rgbogo ); + rgbogo.r_gain = gain_r; - if ( VPP_SetRGBOGO ( &rgbogo ) == 0 ) { - return 0; - } + if (SSMReadRGBGainGStart(0, &gain_g) != 0) { + return -1; + } - LOGE ( "%s, source_type[%d] failed.", "Vpp_SetColorTemperature", source_type ); - return -1; -} + rgbogo.g_gain = gain_g; -int CVpp::Vpp_SetBrightness ( int value, tv_source_input_type_t source_type , tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt ) -{ - int ret = -1; - int params; - int level; + if (SSMReadRGBGainBStart(0, &gain_b) != 0) { + return -1; + } - if ( value >= 0 && value <= 100) { - level = value; - LOGD ( "%s.\n", "Vpp_SetBrightness" ); + rgbogo.b_gain = gain_b; + rgbogo.r_post_offset = 0; + rgbogo.r_pre_offset = 0; + rgbogo.g_post_offset = 0; + rgbogo.g_pre_offset = 0; + rgbogo.b_post_offset = 0; + rgbogo.b_pre_offset = 0; - if ( mpPqData->PQ_GetBrightnessParams ( source_port, sig_fmt, is3d, trans_fmt, level, ¶ms ) == 0 ) { - if ( VPP_SetVideoBrightness ( params ) == 0 ) { - return 0; - } - } else { - LOGE ( "%s, PQ_GetBrightnessParams failed!\n", "Vpp_SetBrightness" ); - } - } + if (VPP_SetRGBOGO(&rgbogo) == 0) { + return 0; + } - return ret; + LOGE("%s, source_type_user[%d] failed.", "Vpp_SetColorTemperatureUser", source_type); + return -1; } -int CVpp::VPP_SetVideoBrightness ( int value ) -{ - FILE *fp = NULL; - - fp = fopen ( "/sys/class/amvecm/brightness", "w" ); +int CVpp::Vpp_SetColorTemperature(vpp_color_temperature_mode_t Tempmode, + tv_source_input_type_t source_type, tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, + tvin_trans_fmt_t trans_fmt) { + tcon_rgb_ogo_t rgbogo, rgbPreOffset; + int ret = -1; - LOGD ( "~~~fopen~~~##VPP_SetVideoBrightness##%s : %d ##" , "/sys/class/amvecm/brightness", value); + if (mbVppCfg_gamma_onoff) { + VPP_SetGammaOnOff(0); + } else { + VPP_SetGammaOnOff(1); + } - if ( fp == NULL ) { - LOGE ( "Open /sys/class/amvecm/brightness error(%s)!\n", strerror ( errno ) ); - return -1; - } + GetColorTemperatureParams(Tempmode, &rgbogo); - fprintf ( fp, "%d", value ); - fclose ( fp ); - fp = NULL; + if (VPP_SetRGBOGO(&rgbogo) == 0) { + return 0; + } - return 0; + LOGE("%s, source_type[%d] failed.", "Vpp_SetColorTemperature", source_type); + return -1; } -int CVpp::Tv_SetBrightness ( int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save ) -{ - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); - - if ( 0 == Vpp_SetBrightness ( value, source_type, source_port, sig_fmt, is3d, trans_fmt ) ) { - if ( is_save == 1 ) { - return SSMSaveBrightness ( source_type, value ); - } else { - return 0; - } - } else { - LOGE ( "%s, failed!", "Tv_SetBrightness" ); - return -1; - } - return 0; -} - -int CVpp::Tv_GetBrightness ( tv_source_input_type_t source_type ) -{ - int data = 50; - vpp_pq_para_t pq_para; - vpp_picture_mode_t pq_mode = Tv_GetPQMode ( source_type ); +int CVpp::Vpp_SetBrightness(int value, tv_source_input_type_t source_type, tvin_port_t source_port, + tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + int ret = -1; + int params; + int level; + + if (value >= 0 && value <= 100) { + level = value; + LOGD("%s.\n", "Vpp_SetBrightness"); + + if (mpPqData->PQ_GetBrightnessParams(source_port, sig_fmt, is3d, trans_fmt, level, ¶ms) + == 0) { + if (VPP_SetVideoBrightness(params) == 0) { + return 0; + } + } else { + LOGE("%s, PQ_GetBrightnessParams failed!\n", "Vpp_SetBrightness"); + } + } - if ( pq_mode == VPP_PICTURE_MODE_USER ) { - SSMReadBrightness ( source_type, &data ); - } else { - if ( Vpp_GetPQModeValue ( source_type, pq_mode, &pq_para ) == 0 ) { - data = pq_para.brightness; - } - } + return ret; +} - if ( data < 0 || data > 100 ) { - data = 50; - } +int CVpp::VPP_SetVideoBrightness(int value) { + FILE *fp = NULL; - return data; -} + fp = fopen("/sys/class/amvecm/brightness", "w"); -int CVpp::Vpp_SetContrast ( int value, tv_source_input_type_t source_type , tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt ) -{ - int ret = -1; - int params; - int level; + LOGD("~~~fopen~~~##VPP_SetVideoBrightness##%s : %d ##", "/sys/class/amvecm/brightness", value); - if ( value >= 0 && value <= 100 ) { - level = value; - LOGD ( "%s.\n", "Vpp_SetContrast" ); + if (fp == NULL) { + LOGE("Open /sys/class/amvecm/brightness error(%s)!\n", strerror(errno)); + return -1; + } - if ( mpPqData->PQ_GetContrastParams ( source_port, sig_fmt, is3d, trans_fmt, level, ¶ms ) == 0 ) { - if ( VPP_SetVideoContrast ( params ) == 0 ) { - return 0; - } - } else { - LOGE ( "%s, PQ_GetContrastParams failed!\n", "Vpp_SetContrast" ); - } - } + fprintf(fp, "%d", value); + fclose(fp); + fp = NULL; - return ret; + return 0; } -int CVpp::VPP_SetVideoContrast ( int value ) -{ - FILE *fp = NULL; +int CVpp::SetBrightness(int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, + tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save) { + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); + + if (0 == Vpp_SetBrightness(value, source_type, source_port, sig_fmt, is3d, trans_fmt)) { + if (is_save == 1) { + return SSMSaveBrightness(source_type, value); + } else { + return 0; + } + } else { + LOGE("%s, failed!", "SetBrightness"); + return -1; + } + return 0; +} - fp = fopen ( "/sys/class/amvecm/contrast", "w" ); - LOGD ( "~~~fopen~~~##VPP_SetVideoContrast##%s : %d ##" , "/sys/class/amvecm/contrast", value); +int CVpp::GetBrightness(tv_source_input_type_t source_type) { + int data = 50; + vpp_pq_para_t pq_para; + vpp_picture_mode_t pq_mode = GetPQMode(source_type); - if ( fp == NULL ) { - LOGE ( "Open /sys/class/amvecm/contrast error(%s)!\n", strerror ( errno ) ); - return -1; - } + if (pq_mode == VPP_PICTURE_MODE_USER) { + SSMReadBrightness(source_type, &data); + } else { + if (Vpp_GetPQModeValue(source_type, pq_mode, &pq_para) == 0) { + data = pq_para.brightness; + } + } - fprintf ( fp, "%d", value ); - fclose ( fp ); - fp = NULL; + if (data < 0 || data > 100) { + data = 50; + } - return 0; + return data; } -int CVpp::Tv_SetContrast ( int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save ) -{ - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); +int CVpp::Vpp_SetContrast(int value, tv_source_input_type_t source_type, tvin_port_t source_port, + tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + int ret = -1; + int params; + int level; + + if (value >= 0 && value <= 100) { + level = value; + LOGD("%s.\n", "Vpp_SetContrast"); + + if (mpPqData->PQ_GetContrastParams(source_port, sig_fmt, is3d, trans_fmt, level, ¶ms) + == 0) { + if (VPP_SetVideoContrast(params) == 0) { + return 0; + } + } else { + LOGE("%s, PQ_GetContrastParams failed!\n", "Vpp_SetContrast"); + } + } - if ( 0 == Vpp_SetContrast ( value, source_type, source_port, sig_fmt, is3d, trans_fmt ) ) { - if ( is_save == 1 ) { - return SSMSaveContrast ( source_type, value ); - } else { - return 0; - } - } else { - LOGE ( "%s, failed!", "Tv_SetContrast" ); - return -1; - } + return ret; } -int CVpp::Tv_GetContrast ( tv_source_input_type_t source_type ) -{ - int data = 50; - vpp_pq_para_t pq_para; - vpp_picture_mode_t pq_mode = Tv_GetPQMode ( source_type ); +int CVpp::VPP_SetVideoContrast(int value) { + FILE *fp = NULL; + + fp = fopen("/sys/class/amvecm/contrast", "w"); + LOGD("~~~fopen~~~##VPP_SetVideoContrast##%s : %d ##", "/sys/class/amvecm/contrast", value); - if ( pq_mode == VPP_PICTURE_MODE_USER ) { - SSMReadContrast ( source_type, &data ); - } else { - if ( Vpp_GetPQModeValue ( source_type, pq_mode, &pq_para ) == 0 ) { - data = pq_para.contrast; - } - } + if (fp == NULL) { + LOGE("Open /sys/class/amvecm/contrast error(%s)!\n", strerror(errno)); + return -1; + } - if ( data < 0 || data > 100 ) { - data = 50; - } + fprintf(fp, "%d", value); + fclose(fp); + fp = NULL; - return data; + return 0; } -int CVpp::Vpp_SetSaturation ( int value, tv_source_input_type_t source_type , tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt ) -{ - int ret = -1; - int params; - int level; - int hue = 0; +int CVpp::SetContrast(int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, + tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save) { + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); - if ( value >= 0 && value <= 100) { - level = value; + if (0 == Vpp_SetContrast(value, source_type, source_port, sig_fmt, is3d, trans_fmt)) { + if (is_save == 1) { + return SSMSaveContrast(source_type, value); + } else { + return 0; + } + } else { + LOGE("%s, failed!", "SetContrast"); + return -1; + } +} - if ( mpPqData->PQ_GetSaturationParams ( source_port, sig_fmt, is3d, trans_fmt, level, ¶ms ) == 0 ) { - if ( VPP_SetVideoSaturationHue ( params, hue ) == 0 ) { - return 0; - } - } else { - } - } +int CVpp::GetContrast(tv_source_input_type_t source_type) { + int data = 50; + vpp_pq_para_t pq_para; + vpp_picture_mode_t pq_mode = GetPQMode(source_type); - return ret; -} + if (pq_mode == VPP_PICTURE_MODE_USER) { + SSMReadContrast(source_type, &data); + } else { + if (Vpp_GetPQModeValue(source_type, pq_mode, &pq_para) == 0) { + data = pq_para.contrast; + } + } -int CVpp::Tv_SetSaturation ( int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save ) -{ - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); + if (data < 0 || data > 100) { + data = 50; + } - if ( 0 == Vpp_SetSaturation ( value, source_type, source_port, sig_fmt, is3d, trans_fmt ) ) { - if ( is_save == 1 ) { - return SSMSaveSaturation ( source_type, value ); - } else { - return 0; - } - } else { - LOGE ( "%s, failed!", "Tv_SetSaturation" ); - return -1; - } + return data; } -int CVpp::Tv_GetSaturation ( tv_source_input_type_t source_type ) -{ - int data = 50; - vpp_pq_para_t pq_para; - vpp_picture_mode_t pq_mode = Tv_GetPQMode ( source_type ); +int CVpp::Vpp_SetSaturation(int value, tv_source_input_type_t source_type, tvin_port_t source_port, + tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + int ret = -1; + int params; + int level; + int hue = 0; + + if (value >= 0 && value <= 100) { + level = value; + + if (mpPqData->PQ_GetSaturationParams(source_port, sig_fmt, is3d, trans_fmt, level, ¶ms) + == 0) { + if (VPP_SetVideoSaturationHue(params, hue) == 0) { + return 0; + } + } else { + } + } - if ( pq_mode == VPP_PICTURE_MODE_USER ) { - SSMReadSaturation ( source_type, &data ); - } else { - if ( Vpp_GetPQModeValue ( source_type, pq_mode, &pq_para ) == 0 ) { - data = pq_para.saturation; - } - } + return ret; +} - if ( data < 0 || data > 100 ) { - data = 50; - } +int CVpp::SetSaturation(int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, + tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save) { + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); - return data; + if (0 == Vpp_SetSaturation(value, source_type, source_port, sig_fmt, is3d, trans_fmt)) { + if (is_save == 1) { + return SSMSaveSaturation(source_type, value); + } else { + return 0; + } + } else { + LOGE("%s, failed!", "SetSaturation"); + return -1; + } } -int CVpp::Vpp_SetHue ( int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, tvin_port_t source_port, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt ) -{ - int ret = -1; - int params, saturation_params; - int level, saturation_level; +int CVpp::GetSaturation(tv_source_input_type_t source_type) { + int data = 50; + vpp_pq_para_t pq_para; + vpp_picture_mode_t pq_mode = GetPQMode(source_type); - if ( value >= 0 && value <= 100 ) { - if ( mbVppCfg_hue_reverse) { - level = 100 - value; - } else { - level = value; - } + if (pq_mode == VPP_PICTURE_MODE_USER) { + SSMReadSaturation(source_type, &data); + } else { + if (Vpp_GetPQModeValue(source_type, pq_mode, &pq_para) == 0) { + data = pq_para.saturation; + } + } - if ( mpPqData->PQ_GetHueParams ( source_port, sig_fmt, is3d, trans_fmt, level, ¶ms ) == 0 ) { - saturation_level = Tv_GetSaturation ( source_type ); + if (data < 0 || data > 100) { + data = 50; + } - if ( mpPqData->PQ_GetSaturationParams ( source_port, sig_fmt, is3d, trans_fmt, saturation_level, &saturation_params ) == 0 ) { - } else { - saturation_params = -20; - } + return data; +} - if ( VPP_SetVideoSaturationHue ( saturation_params, params ) == 0 ) { - return 0; - } - } else { - LOGE ( "PQ_GetHueParams failed!\n" ); - } - } +int CVpp::Vpp_SetHue(int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, + tvin_port_t source_port, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + int ret = -1; + int params, saturation_params; + int level, saturation_level; + + if (value >= 0 && value <= 100) { + if (mbVppCfg_hue_reverse) { + level = 100 - value; + } else { + level = value; + } - return ret; -} + if (mpPqData->PQ_GetHueParams(source_port, sig_fmt, is3d, trans_fmt, level, ¶ms) == 0) { + saturation_level = GetSaturation(source_type); -int CVpp::Tv_SetHue ( int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save ) -{ - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); + if (mpPqData->PQ_GetSaturationParams(source_port, sig_fmt, is3d, trans_fmt, + saturation_level, &saturation_params) == 0) { + } else { + saturation_params = -20; + } - if ( 0 == Vpp_SetHue ( value, source_type, sig_fmt, source_port, is3d, trans_fmt ) ) { - if ( is_save == 1 ) { - return SSMSaveHue ( source_type, value ); - } else { - return 0; - } - } else { - LOGE ( "%s, failed!", "Tv_SetHue" ); - return -1; - } + if (VPP_SetVideoSaturationHue(saturation_params, params) == 0) { + return 0; + } + } else { + LOGE("PQ_GetHueParams failed!\n"); + } + } - return 0; + return ret; } -int CVpp::Tv_GetHue ( tv_source_input_type_t source_type ) -{ - int data = 50; - vpp_pq_para_t pq_para; - vpp_picture_mode_t pq_mode = Tv_GetPQMode ( source_type ); - - if ( pq_mode == VPP_PICTURE_MODE_USER ) { - SSMReadHue ( source_type, &data ); - } else { - if ( Vpp_GetPQModeValue ( source_type, pq_mode, &pq_para ) == 0 ) { - data = pq_para.hue; - } - } +int CVpp::SetHue(int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, + tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save) { + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); - if ( data < 0 || data > 100 ) { - data = 50; - } + if (0 == Vpp_SetHue(value, source_type, sig_fmt, source_port, is3d, trans_fmt)) { + if (is_save == 1) { + return SSMSaveHue(source_type, value); + } else { + return 0; + } + } else { + LOGE("%s, failed!", "SetHue"); + return -1; + } - return data; + return 0; } +int CVpp::GetHue(tv_source_input_type_t source_type) { + int data = 50; + vpp_pq_para_t pq_para; + vpp_picture_mode_t pq_mode = GetPQMode(source_type); + if (pq_mode == VPP_PICTURE_MODE_USER) { + SSMReadHue(source_type, &data); + } else { + if (Vpp_GetPQModeValue(source_type, pq_mode, &pq_para) == 0) { + data = pq_para.hue; + } + } -int CVpp::Vpp_SetSharpness ( int value, tv_source_input_type_t source_type , tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt ) -{ - int ret = -1; - am_regs_t regs; - int level; + if (data < 0 || data > 100) { + data = 50; + } - if ( value >= 0 && value <= 100 ) { - level = value; + return data; +} - if ( mpPqData->PQ_GetSharpnessParams ( source_port, sig_fmt, is3d, trans_fmt, level, ®s ) == 0 ) { - if ( Vpp_LoadRegs ( regs ) < 0 ) { - } else { - ret = 0; - } - } else { - } - } +int CVpp::Vpp_SetSharpness(int value, tv_source_input_type_t source_type, tvin_port_t source_port, + tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + int ret = -1; + am_regs_t regs, regs_l; + int level; + + if (value >= 0 && value <= 100) { + level = value; + + if (mpPqData->PQ_GetSharpnessParams(source_port, sig_fmt, is3d, trans_fmt, level, ®s, ®s_l) == 0) { + LOGD("%s, sharpness flag:%d\n", __FUNCTION__, mpPqData->getSharpnessFlag()); + if (mpPqData->getSharpnessFlag() == 6) { + if (Vpp_LoadRegs(regs) >= 0 && Vpp_LoadRegs(regs_l) >= 0) + ret = 0; + } else { + if (Vpp_LoadRegs(regs) >= 0) + ret = 0; + } + } else { + } + } - return ret; + return ret; } -int CVpp::Tv_SetSharpness ( int value, tv_source_input_type_t source_type, int is_enable, is_3d_type_t is3d, tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt, int is_save ) -{ - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); +int CVpp::SetSharpness(int value, tv_source_input_type_t source_type, int is_enable, + is_3d_type_t is3d, tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt, int is_save) { + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); - if ( Vpp_SetSharpness ( value, source_type, source_port, sig_fmt, is3d, trans_fmt) < 0 ) { - LOGE ( "%s, failed!", "Tv_SetSharpness" ); - return -1; - } + if (Vpp_SetSharpness(value, source_type, source_port, sig_fmt, is3d, trans_fmt) < 0) { + LOGE("%s, failed!", "SetSharpness"); + return -1; + } - if ( is_save == 1 ) { - if ( is_enable ) { - return SSMSaveSharpness ( source_type, value ); + if (is_save == 1) { + if (is_enable) { + return SSMSaveSharpness(source_type, value); - } - } + } + } - return 0; + return 0; } -int CVpp::Tv_GetSharpness ( tv_source_input_type_t source_type ) -{ - int data = 50; - vpp_pq_para_t pq_para; - vpp_picture_mode_t pq_mode = Tv_GetPQMode ( source_type ); +int CVpp::GetSharpness(tv_source_input_type_t source_type) { + int data = 50; + vpp_pq_para_t pq_para; + vpp_picture_mode_t pq_mode = GetPQMode(source_type); - if ( pq_mode == VPP_PICTURE_MODE_USER ) { - SSMReadSharpness ( source_type, &data ); - } else { - if ( Vpp_GetPQModeValue ( source_type, pq_mode, &pq_para ) == 0 ) { - data = pq_para.sharpness; - } - } + if (pq_mode == VPP_PICTURE_MODE_USER) { + SSMReadSharpness(source_type, &data); + } else { + if (Vpp_GetPQModeValue(source_type, pq_mode, &pq_para) == 0) { + data = pq_para.sharpness; + } + } - if ( data < 0 || data > 100 ) { - data = 50; - } + if (data < 0 || data > 100) { + data = 50; + } - LOGD ( "%s, data[%d].", "Tv_GetSharpness", data ); - return data; + LOGD("%s, data[%d].", "GetSharpness", data); + return data; } -int CVpp::Tv_SetColorSpaceMode ( vpp_color_space_type_t colorSpace ) -{ - int ret = -1, fileRet = -1; - SSMSaveColorSpaceStart ( colorSpace ); +int CVpp::SetColorSpaceMode(vpp_color_space_type_t colorSpace) { + int ret = -1, fileRet = -1; + SSMSaveColorSpaceStart(colorSpace); - switch ( colorSpace ) { - case VPP_COLOR_SPACE_RGB: - //marked by haifeng - // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1da1 0xc" ); - // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d70 0x208" ); - // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d71 0x74" ); - break; + switch (colorSpace) { + case VPP_COLOR_SPACE_RGB: + //marked by haifeng + // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1da1 0xc" ); + // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d70 0x208" ); + // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d71 0x74" ); + break; - case VPP_COLOR_SPACE_YUV: - //marked by haifeng - // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1da1 0xe" ); - // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d70 0x208" ); - // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d71 0x76" ); - break; + case VPP_COLOR_SPACE_YUV: + //marked by haifeng + // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1da1 0xe" ); + // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d70 0x208" ); + // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d71 0x76" ); + break; - default: - break; - } + default: + break; + } - return 0; + return 0; } -int CVpp::Vpp_SetNoiseReductionMode ( vpp_noise_reduction_mode_t nr_mode, tv_source_input_type_t source_type , tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt ) -{ - int ret = -1; - am_regs_t regs; - - if ( mbVppCfg_new_nr) { - if ( mpPqData->PQ_GetNR2Params ( ( vpp_noise_reduction2_mode_t ) nr_mode, source_port, sig_fmt, is3d, trans_fmt, ®s ) == 0 ) { - ret = Vpp_LoadRegs ( regs ); - } else { - LOGE ( "PQ_GetNR2Params failed!\n" ); - } - } +int CVpp::Vpp_SetNoiseReductionMode(vpp_noise_reduction_mode_t nr_mode, + tv_source_input_type_t source_type, tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, + is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + int ret = -1; + am_regs_t regs; + + if (mbVppCfg_new_nr) { + if (mpPqData->PQ_GetNR2Params((vpp_noise_reduction2_mode_t) nr_mode, source_port, sig_fmt, + is3d, trans_fmt, ®s) == 0) { + ret = Vpp_LoadRegs(regs); + } else { + LOGE("PQ_GetNR2Params failed!\n"); + } + } - return ret; + return ret; } -int CVpp::Tv_SaveNoiseReductionMode ( vpp_noise_reduction_mode_t nr_mode, tv_source_input_type_t source_type ) -{ - int tmp_save_noisereduction_mode = ( int ) nr_mode; - return SSMSaveNoiseReduction ( source_type, tmp_save_noisereduction_mode ); +int CVpp::SaveNoiseReductionMode(vpp_noise_reduction_mode_t nr_mode, + tv_source_input_type_t source_type) { + int tmp_save_noisereduction_mode = (int) nr_mode; + return SSMSaveNoiseReduction(source_type, tmp_save_noisereduction_mode); } -int CVpp::Tv_SetNoiseReductionMode ( vpp_noise_reduction_mode_t nr_mode, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt, int is_save ) -{ - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); - if ( 0 == Vpp_SetNoiseReductionMode ( nr_mode, source_type, source_port, sig_fmt, is3d, trans_fmt ) ) { - if ( is_save == 1 ) { - return Tv_SaveNoiseReductionMode ( nr_mode, source_type ); - } else { - return 0; - } - } +int CVpp::SetNoiseReductionMode(vpp_noise_reduction_mode_t nr_mode, + tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, + tvin_trans_fmt_t trans_fmt, int is_save) { + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); + if (0 == Vpp_SetNoiseReductionMode(nr_mode, source_type, source_port, sig_fmt, is3d, trans_fmt)) { + if (is_save == 1) { + return SaveNoiseReductionMode(nr_mode, source_type); + } else { + return 0; + } + } - LOGE ( "%s, failed!", __FUNCTION__ ); - return -1; + LOGE("%s, failed!", __FUNCTION__); + return -1; } -vpp_noise_reduction_mode_t CVpp::Tv_GetNoiseReductionMode ( tv_source_input_type_t source_type ) -{ - vpp_noise_reduction_mode_t data = VPP_NOISE_REDUCTION_MODE_MID; - int tmp_nr_mode = 0; +vpp_noise_reduction_mode_t CVpp::GetNoiseReductionMode(tv_source_input_type_t source_type) { + vpp_noise_reduction_mode_t data = VPP_NOISE_REDUCTION_MODE_MID; + int tmp_nr_mode = 0; - SSMReadNoiseReduction ( source_type, &tmp_nr_mode ); - data = ( vpp_noise_reduction_mode_t ) tmp_nr_mode; + SSMReadNoiseReduction(source_type, &tmp_nr_mode); + data = (vpp_noise_reduction_mode_t) tmp_nr_mode; - if ( data < VPP_NOISE_REDUCTION_MODE_OFF || data > VPP_NOISE_REDUCTION_MODE_AUTO ) { - data = VPP_NOISE_REDUCTION_MODE_MID; - } + if (data < VPP_NOISE_REDUCTION_MODE_OFF || data > VPP_NOISE_REDUCTION_MODE_AUTO) { + data = VPP_NOISE_REDUCTION_MODE_MID; + } - return data; + return data; } -int CVpp::Vpp_SetXVYCCMode ( vpp_xvycc_mode_t xvycc_mode, tv_source_input_type_t source_type, tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt ) -{ - int ret = -1; - am_regs_t regs, regs_1; - char prop_value[PROPERTY_VALUE_MAX]; - - memset ( prop_value, '\0', 16 ); - const char *config_value; - config_value = config_get_str ( "TV", "vpp.xvycc.switch_control", "null" ); - - if ( strcmp ( config_value, "enable" ) == 0 ) { - if ( mpPqData->PQ_GetXVYCCParams ( ( vpp_xvycc_mode_t ) xvycc_mode, source_port, sig_fmt, is3d, trans_fmt, ®s , ®s_1) == 0 ) { - ret = Vpp_LoadRegs ( regs ); - ret |= Vpp_LoadRegs ( regs_1 ); - } else { - LOGE ( "PQ_GetXVYCCParams failed!\n" ); - } - } else { - LOGE("disable xvycc!\n"); - } - return ret; +int CVpp::Vpp_SetXVYCCMode(vpp_xvycc_mode_t xvycc_mode, tv_source_input_type_t source_type, + tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, + tvin_trans_fmt_t trans_fmt) { + int ret = -1; + am_regs_t regs, regs_1; + char prop_value[PROPERTY_VALUE_MAX]; + + memset(prop_value, '\0', 16); + const char *config_value; + config_value = config_get_str("TV", "vpp.xvycc.switch_control", "null"); + + if (strcmp(config_value, "enable") == 0) { + if (mpPqData->PQ_GetXVYCCParams((vpp_xvycc_mode_t) xvycc_mode, source_port, sig_fmt, is3d, + trans_fmt, ®s, ®s_1) == 0) { + ret = Vpp_LoadRegs(regs); + ret |= Vpp_LoadRegs(regs_1); + } else { + LOGE("PQ_GetXVYCCParams failed!\n"); + } + } else { + LOGE("disable xvycc!\n"); + } + return ret; } +int CVpp::Vpp_SetMCDIMode(vpp_mcdi_mode_t mcdi_mode, tv_source_input_type_t source_type, + tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, + tvin_trans_fmt_t trans_fmt) { + int ret = -1; + am_regs_t regs; -int CVpp::Vpp_SetMCDIMode ( vpp_mcdi_mode_t mcdi_mode, tv_source_input_type_t source_type , tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) -{ - int ret = -1; - am_regs_t regs; - - if ( mpPqData->PQ_GetMCDIParams ( ( vpp_mcdi_mode_t ) mcdi_mode, source_port, sig_fmt, is3d, trans_fmt, ®s ) == 0 ) { - ret = Vpp_LoadRegs ( regs ); - } else { - LOGE ( "PQ_GetMCDIParams failed!\n" ); - } - return ret; + if (mpPqData->PQ_GetMCDIParams((vpp_mcdi_mode_t) mcdi_mode, source_port, sig_fmt, is3d, + trans_fmt, ®s) == 0) { + ret = Vpp_LoadRegs(regs); + } else { + LOGE("%s, PQ_GetMCDIParams failed!\n", __FUNCTION__); + } + return ret; } - -int CVpp::Vpp_LoadGammaDefault ( tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt ) +int CVpp::Vpp_SetDeblockMode(vpp_deblock_mode_t mode, tvin_port_t source_port, + tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { - int ret = -1; - int panel_id = 0; - tcon_gamma_table_t gamma_r, gamma_g, gamma_b; - - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); + int ret = -1; + am_regs_t regs; - LOGD ( "Enter %s.\n", __FUNCTION__ ); - ret = mpPqData->PQ_GetGammaTableR ( panel_id, source_port, sig_fmt, &gamma_r ); - ret |= mpPqData->PQ_GetGammaTableG ( panel_id, source_port, sig_fmt, &gamma_g ); - ret |= mpPqData->PQ_GetGammaTableB ( panel_id, source_port, sig_fmt, &gamma_b ); + if (mpPqData->PQ_GetDeblockParams(mode, source_port, sig_fmt, is3d, trans_fmt, ®s) == 0) { + ret = Vpp_LoadRegs(regs); + } else { + LOGE("%s PQ_GetDeblockParams failed!\n", __FUNCTION__); + } + return ret; +} - if ( ret == 0 ) { - VPP_SetGammaTbl_R ( ( unsigned short * ) gamma_r.data ); - VPP_SetGammaTbl_G ( ( unsigned short * ) gamma_g.data ); - VPP_SetGammaTbl_B ( ( unsigned short * ) gamma_b.data ); - } else { - LOGE ( "%s, PQ_GetGammaTable failed!", __FUNCTION__ ); - } +int CVpp::Vpp_LoadGammaDefault(tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt) { + int ret = -1; + int panel_id = 0; + tcon_gamma_table_t gamma_r, gamma_g, gamma_b; + + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); + + LOGD("Enter %s.\n", __FUNCTION__); + ret = mpPqData->PQ_GetGammaTableR(panel_id, source_port, sig_fmt, &gamma_r); + ret |= mpPqData->PQ_GetGammaTableG(panel_id, source_port, sig_fmt, &gamma_g); + ret |= mpPqData->PQ_GetGammaTableB(panel_id, source_port, sig_fmt, &gamma_b); + + if (ret == 0) { + VPP_SetGammaTbl_R((unsigned short *) gamma_r.data); + VPP_SetGammaTbl_G((unsigned short *) gamma_g.data); + VPP_SetGammaTbl_B((unsigned short *) gamma_b.data); + } else { + LOGE("%s, PQ_GetGammaTable failed!", __FUNCTION__); + } - return ret; + return ret; } -int CVpp::Vpp_LoadGammaSpecial ( int gammaValue ) -{ - int ret = -1; - int panel_id = 0; - tcon_gamma_table_t gamma_r, gamma_g, gamma_b; - - LOGD ( "Enter %s.\n", __FUNCTION__ ); - ret = mpPqData->PQ_GetGammaSpecialTable ( gammaValue, "Red", &gamma_r ); - ret |= mpPqData->PQ_GetGammaSpecialTable ( gammaValue, "Green", &gamma_g ); - ret |= mpPqData->PQ_GetGammaSpecialTable ( gammaValue, "Blue", &gamma_b ); - - if ( ret == 0 ) { - VPP_SetGammaTbl_R ( ( unsigned short * ) gamma_r.data ); - VPP_SetGammaTbl_G ( ( unsigned short * ) gamma_g.data ); - VPP_SetGammaTbl_B ( ( unsigned short * ) gamma_b.data ); - } else { - LOGE ( "%s, PQ_GetGammaSpecialTable failed!", __FUNCTION__ ); - } +int CVpp::Vpp_LoadGammaSpecial(int gammaValue) { + int ret = -1; + int panel_id = 0; + tcon_gamma_table_t gamma_r, gamma_g, gamma_b; + + LOGD("Enter %s.\n", __FUNCTION__); + ret = mpPqData->PQ_GetGammaSpecialTable(gammaValue, "Red", &gamma_r); + ret |= mpPqData->PQ_GetGammaSpecialTable(gammaValue, "Green", &gamma_g); + ret |= mpPqData->PQ_GetGammaSpecialTable(gammaValue, "Blue", &gamma_b); + + if (ret == 0) { + VPP_SetGammaTbl_R((unsigned short *) gamma_r.data); + VPP_SetGammaTbl_G((unsigned short *) gamma_g.data); + VPP_SetGammaTbl_B((unsigned short *) gamma_b.data); + } else { + LOGE("%s, PQ_GetGammaSpecialTable failed!", __FUNCTION__); + } - return ret; + return ret; } -int CVpp::Vpp_LoadGamma ( tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt ) -{ - int gammaValue = 0, ret = -1; +int CVpp::Vpp_LoadGamma(tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt) { + int gammaValue = 0, ret = -1; - if ( SSMReadGammaValue ( &gammaValue ) < 0 ) { - LOGE ( "%s, SSMReadGammaValue ERROR, So Load Default GAMMA!\n", __FUNCTION__ ); - ret = Vpp_LoadGammaDefault ( source_type, sig_fmt ); - return -1; - } + if (SSMReadGammaValue(&gammaValue) < 0) { + LOGE("%s, SSMReadGammaValue ERROR, So Load Default GAMMA!\n", __FUNCTION__); + ret = Vpp_LoadGammaDefault(source_type, sig_fmt); + return -1; + } - if ( gammaValue < -4 || gammaValue > 4 ) { - LOGE ( "%s, Gamma Value beyond the UI's range of -4 to 4 .\n", __FUNCTION__ ); - gammaValue = 0; - SSMSaveGammaValue ( gammaValue ); - } + if (gammaValue < -4 || gammaValue > 4) { + LOGE("%s, Gamma Value beyond the UI's range of -4 to 4 .\n", __FUNCTION__); + gammaValue = 0; + SSMSaveGammaValue(gammaValue); + } - switch ( gammaValue ) { - case 0: - ret = Vpp_LoadGammaDefault ( source_type, sig_fmt ); - break; + switch (gammaValue) { + case 0: + ret = Vpp_LoadGammaDefault(source_type, sig_fmt); + break; - default: - ret = Vpp_LoadGammaSpecial ( gammaValue ); - break; - } + default: + ret = Vpp_LoadGammaSpecial(gammaValue); + break; + } - return ret; + return ret; } -/*int CVpp::Tv_SetGammaValue(int gammaValue) -{ - int ret = -1; - tvin_sig_fmt_t sig_fmt = TVIN_SIG_FMT_NULL; - tv_source_input_type_t source_type = SOURCE_TYPE_TV; - sig_fmt = Tvin_GetSigFormat(); - source_type = Tvin_GetSrcInputType(); - LOGD("%s, source_type = %d, sig_fmt = %d, gammaValue = %d\n", __FUNCTION__, (int)source_type, - (int)sig_fmt, gammaValue); - if (gammaValue >= -4 || gammaValue <= 4) { - switch(gammaValue) { - case 0: - ret = Vpp_LoadGammaDefault(source_type, sig_fmt); - break; - default: - ret = Vpp_LoadGammaSpecial(gammaValue); - break; - } - if(0 == ret) - ret = SSMSaveGammaValue(gammaValue); +/*int CVpp::SetGammaValue(int gammaValue) + { + int ret = -1; + tvin_sig_fmt_t sig_fmt = TVIN_SIG_FMT_NULL; + tv_source_input_type_t source_type = SOURCE_TYPE_TV; + sig_fmt = Tvin_GetSigFormat(); + source_type = Tvin_GetSrcInputType(); + LOGD("%s, source_type = %d, sig_fmt = %d, gammaValue = %d\n", __FUNCTION__, (int)source_type, + (int)sig_fmt, gammaValue); + if (gammaValue >= -4 || gammaValue <= 4) { + switch (gammaValue) { + case 0: + ret = Vpp_LoadGammaDefault(source_type, sig_fmt); + break; + default: + ret = Vpp_LoadGammaSpecial(gammaValue); + break; + } + if (0 == ret) + ret = SSMSaveGammaValue(gammaValue); + } + return ret; + }*/ + +int CVpp::GetGammaValue() { + int gammaValue = 0; + + if (SSMReadGammaValue(&gammaValue) < 0) { + LOGE("%s, SSMReadGammaValue ERROR!!!\n", __FUNCTION__); + return -1; } - return ret; -}*/ - -int CVpp::Tv_GetGammaValue() -{ - int gammaValue = 0; - if ( SSMReadGammaValue ( &gammaValue ) < 0 ) { - LOGE ( "%s, SSMReadGammaValue ERROR!!!\n", __FUNCTION__ ); - return -1; - } - - return gammaValue; + return gammaValue; } -/*int CVpp::Tv_SetColorDemoMode ( vpp_color_demomode_t demomode ) -{ - tv_source_input_type_t source_type = Tvin_GetSrcInputType(); - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); - tvin_sig_fmt_t sig_fmt = Tvin_GetSigFormat(); - is_3d_type_t is3d = Tvin_Get3DStatus(); - tvin_trans_fmt_t trans_fmt = Tvin_GetSigTransFormat(); +/*int CVpp::SetColorDemoMode ( vpp_color_demomode_t demomode ) + { + tv_source_input_type_t source_type = Tvin_GetSrcInputType(); + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); + tvin_sig_fmt_t sig_fmt = Tvin_GetSigFormat(); + is_3d_type_t is3d = Tvin_Get3DStatus(); + tvin_trans_fmt_t trans_fmt = Tvin_GetSigTransFormat(); - return Tv_SetBaseColorMode ( VPP_COLOR_BASE_MODE_DEMO ,source_port,sig_fmt,status,trans_fmt); -}*/ + return SetBaseColorMode ( VPP_COLOR_BASE_MODE_DEMO ,source_port,sig_fmt,status,trans_fmt); + }*/ -vpp_color_demomode_t CVpp::Tv_GetColorDemoMode ( void ) -{ - vpp_color_demomode_t data = VPP_COLOR_DEMO_MODE_ALLON; - unsigned char tmp_demo_mode = 0; - SSMReadColorDemoMode ( &tmp_demo_mode ); - data = ( vpp_color_demomode_t ) tmp_demo_mode; +vpp_color_demomode_t CVpp::GetColorDemoMode(void) { + vpp_color_demomode_t data = VPP_COLOR_DEMO_MODE_ALLON; + unsigned char tmp_demo_mode = 0; + SSMReadColorDemoMode(&tmp_demo_mode); + data = (vpp_color_demomode_t) tmp_demo_mode; - if ( data < VPP_COLOR_DEMO_MODE_ALLON || data > VPP_COLOR_DEMO_MODE_ALLOFF ) { - data = VPP_COLOR_DEMO_MODE_ALLON; - } + if (data < VPP_COLOR_DEMO_MODE_ALLON || data > VPP_COLOR_DEMO_MODE_ALLOFF) { + data = VPP_COLOR_DEMO_MODE_ALLON; + } - return data; + return data; } +int CVpp::SetBaseColorModeWithoutSave(vpp_color_basemode_t basemode, tvin_port_t source_port, + tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + int ret = -1; + am_regs_t regs; + + if (mbVppCfg_new_cm) { + if (mpPqData->PQ_GetCM2Params((vpp_color_management2_t) basemode, source_port, sig_fmt, + is3d, trans_fmt, ®s) == 0) { + ret = Vpp_LoadRegs(regs); + } else { + LOGE("PQ_GetCM2Params failed!\n"); + } + } -int CVpp::Tv_SetBaseColorModeWithoutSave ( vpp_color_basemode_t basemode , tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) -{ - int ret = -1; - am_regs_t regs; - - if ( mbVppCfg_new_cm) { - if ( mpPqData->PQ_GetCM2Params ( ( vpp_color_management2_t ) basemode, source_port, sig_fmt, is3d, trans_fmt, ®s ) == 0 ) { - ret = Vpp_LoadRegs ( regs ); - } else { - LOGE ( "PQ_GetCM2Params failed!\n" ); - } - } - - return ret; + return ret; } -int CVpp::Tv_SaveBaseColorMode ( vpp_color_basemode_t basemode ) -{ - int ret = -1; +int CVpp::SaveBaseColorMode(vpp_color_basemode_t basemode) { + int ret = -1; - if ( basemode == VPP_COLOR_BASE_MODE_DEMO ) { - ret = 0; - } else { - ret |= SSMSaveColorBaseMode ( basemode ); - } + if (basemode == VPP_COLOR_BASE_MODE_DEMO) { + ret = 0; + } else { + ret |= SSMSaveColorBaseMode(basemode); + } - return ret; + return ret; } -int CVpp::Tv_SetBaseColorMode ( vpp_color_basemode_t basemode , tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) -{ - if ( 0 == Tv_SetBaseColorModeWithoutSave ( basemode, source_port, sig_fmt, is3d, trans_fmt) ) { - return Tv_SaveBaseColorMode ( basemode ); - } else { - LOGE ( "Tv_SetBaseColorMode() Failed!!!" ); - return -1; - } - return 0; +int CVpp::SetBaseColorMode(vpp_color_basemode_t basemode, tvin_port_t source_port, + tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + if (0 == SetBaseColorModeWithoutSave(basemode, source_port, sig_fmt, is3d, trans_fmt)) { + return SaveBaseColorMode(basemode); + } else { + LOGE("SetBaseColorMode() Failed!!!"); + return -1; + } + return 0; } -vpp_color_basemode_t CVpp::Tv_GetBaseColorMode ( void ) -{ - vpp_color_basemode_t data = VPP_COLOR_BASE_MODE_OFF; - unsigned char tmp_base_mode = 0; - SSMReadColorBaseMode ( &tmp_base_mode ); - data = ( vpp_color_basemode_t ) tmp_base_mode; +vpp_color_basemode_t CVpp::GetBaseColorMode(void) { + vpp_color_basemode_t data = VPP_COLOR_BASE_MODE_OFF; + unsigned char tmp_base_mode = 0; + SSMReadColorBaseMode(&tmp_base_mode); + data = (vpp_color_basemode_t) tmp_base_mode; - if ( data < VPP_COLOR_BASE_MODE_OFF || data >= VPP_COLOR_BASE_MODE_MAX ) { - data = VPP_COLOR_BASE_MODE_OPTIMIZE; - } + if (data < VPP_COLOR_BASE_MODE_OFF || data >= VPP_COLOR_BASE_MODE_MAX) { + data = VPP_COLOR_BASE_MODE_OPTIMIZE; + } - return data; + return data; } -int CVpp::Tv_SetColorTempWithoutSave ( vpp_color_temperature_mode_t Tempmode, tv_source_input_type_t source_type ) -{ - tcon_rgb_ogo_t rgbogo; - int ret = -1; +int CVpp::SetColorTempWithoutSave(vpp_color_temperature_mode_t Tempmode, + tv_source_input_type_t source_type) { + tcon_rgb_ogo_t rgbogo; + int ret = -1; - if ( mbVppCfg_whitebalance_sameparam) { - source_type = SOURCE_TYPE_TV; //set all source share to use one group - } + if (mbVppCfg_whitebalance_sameparam) { + source_type = SOURCE_TYPE_TV; //set all source share to use one group + } - if ( mbVppCfg_gamma_onoff) { - VPP_SetGammaOnOff ( 0 ); - } else { - VPP_SetGammaOnOff ( 1 ); - } + if (mbVppCfg_gamma_onoff) { + VPP_SetGammaOnOff(0); + } else { + VPP_SetGammaOnOff(1); + } - GetColorTemperatureParams ( Tempmode, &rgbogo ); + GetColorTemperatureParams(Tempmode, &rgbogo); - return VPP_SetRGBOGO ( &rgbogo ); + return VPP_SetRGBOGO(&rgbogo); } -int CVpp::Tv_SaveColorTemp ( vpp_color_temperature_mode_t Tempmode, tv_source_input_type_t source_type ) -{ - int ret = -1; - int tmp_temp_mode = 0; - tcon_rgb_ogo_t rgbogo; +int CVpp::SaveColorTemp(vpp_color_temperature_mode_t Tempmode, tv_source_input_type_t source_type) { + int ret = -1; + int tmp_temp_mode = 0; + tcon_rgb_ogo_t rgbogo; - if ( mbVppCfg_whitebalance_sameparam) { - source_type = SOURCE_TYPE_TV; //set all source share to use one group - } + if (mbVppCfg_whitebalance_sameparam) { + source_type = SOURCE_TYPE_TV; //set all source share to use one group + } - GetColorTemperatureParams ( Tempmode, &rgbogo ); + GetColorTemperatureParams(Tempmode, &rgbogo); - if ( Tempmode < VPP_COLOR_TEMPERATURE_MODE_USER ) { - ret = SSMSaveRGBGainRStart ( 0, rgbogo.r_gain ); - ret |= SSMSaveRGBGainGStart ( 0, rgbogo.g_gain ); - ret |= SSMSaveRGBGainBStart ( 0, rgbogo.b_gain ); - } + if (Tempmode < VPP_COLOR_TEMPERATURE_MODE_USER) { + ret = SSMSaveRGBGainRStart(0, rgbogo.r_gain); + ret |= SSMSaveRGBGainGStart(0, rgbogo.g_gain); + ret |= SSMSaveRGBGainBStart(0, rgbogo.b_gain); + } - tmp_temp_mode = ( int ) Tempmode; + tmp_temp_mode = (int) Tempmode; - if ( mbVppCfg_colortemp_by_source) { - ret |= SSMSaveColorTemperature ( ( int ) source_type, tmp_temp_mode ); - } else { - ret |= SSMSaveColorTemperature ( 0, tmp_temp_mode ); - } + if (mbVppCfg_colortemp_by_source) { + ret |= SSMSaveColorTemperature((int) source_type, tmp_temp_mode); + } else { + ret |= SSMSaveColorTemperature(0, tmp_temp_mode); + } - return ret; + return ret; } -int CVpp::Tv_SetColorTemperature ( vpp_color_temperature_mode_t Tempmode, tv_source_input_type_t source_type, int is_save ) -{ - if ( Tv_SetColorTempWithoutSave ( Tempmode, source_type ) < 0 ) { - LOGE ( "%s, failed!", __FUNCTION__ ); - return -1; - } else { - if ( is_save == 1 ) { - return Tv_SaveColorTemp ( Tempmode, source_type ); - } else { - return 0; - } - } -} - -vpp_color_temperature_mode_t CVpp::Tv_GetColorTemperature ( tv_source_input_type_t source_type ) -{ - vpp_color_temperature_mode_t data = VPP_COLOR_TEMPERATURE_MODE_STANDARD; - int tmp_temp_mode = 0; +int CVpp::SetColorTemperature(vpp_color_temperature_mode_t Tempmode, + tv_source_input_type_t source_type, int is_save) { + if (SetColorTempWithoutSave(Tempmode, source_type) < 0) { + LOGE("%s, failed!", __FUNCTION__); + return -1; + } else { + if (is_save == 1) { + return SaveColorTemp(Tempmode, source_type); + } else { + return 0; + } + } +} - if ( mbVppCfg_colortemp_by_source) { - SSMReadColorTemperature ( ( int ) source_type, &tmp_temp_mode ); - } else { - SSMReadColorTemperature ( 0, &tmp_temp_mode ); - } +vpp_color_temperature_mode_t CVpp::GetColorTemperature(tv_source_input_type_t source_type) { + vpp_color_temperature_mode_t data = VPP_COLOR_TEMPERATURE_MODE_STANDARD; + int tmp_temp_mode = 0; - data = ( vpp_color_temperature_mode_t ) tmp_temp_mode; + if (mbVppCfg_colortemp_by_source) { + SSMReadColorTemperature((int) source_type, &tmp_temp_mode); + } else { + SSMReadColorTemperature(0, &tmp_temp_mode); + } - if ( data < VPP_COLOR_TEMPERATURE_MODE_STANDARD || data > VPP_COLOR_TEMPERATURE_MODE_USER ) { - data = VPP_COLOR_TEMPERATURE_MODE_STANDARD; - } + data = (vpp_color_temperature_mode_t) tmp_temp_mode; + + if (data < VPP_COLOR_TEMPERATURE_MODE_STANDARD || data > VPP_COLOR_TEMPERATURE_MODE_USER) { + data = VPP_COLOR_TEMPERATURE_MODE_STANDARD; + } - return data; + return data; } -int CVpp::VPP_SetNonLinearFactor ( int value ) -{ - FILE *fp = NULL; +int CVpp::VPP_SetNonLinearFactor(int value) { + FILE *fp = NULL; - fp = fopen ( "/sys/class/video/nonlinear_factor", "w" ); - LOGD ( "~~~fopen~~~##VPP_SetNonLinearFactor##%s : %d ##" , "/sys/class/video/nonlinear_factor", value); + fp = fopen("/sys/class/video/nonlinear_factor", "w"); + LOGD("~~~fopen~~~##VPP_SetNonLinearFactor##%s : %d ##", "/sys/class/video/nonlinear_factor", + value); - if ( fp == NULL ) { - LOGE ( "Open /sys/class/video/nonlinear_factor error(%s)!\n", strerror ( errno ) ); - return -1; - } + if (fp == NULL) { + LOGE("Open /sys/class/video/nonlinear_factor error(%s)!\n", strerror(errno)); + return -1; + } - fprintf ( fp, "%d", value ); + fprintf(fp, "%d", value); - fclose ( fp ); - fp = NULL; + fclose(fp); + fp = NULL; - return 0; + return 0; } -vpp_display_mode_t CVpp::Tv_GetDisplayMode ( tv_source_input_type_t source_type ) -{ - vpp_display_mode_t data = VPP_DISPLAY_MODE_169; - int tmp_dis_mode = 0; +vpp_display_mode_t CVpp::GetDisplayMode(tv_source_input_type_t source_type) { + vpp_display_mode_t data = VPP_DISPLAY_MODE_169; + int tmp_dis_mode = 0; - SSMReadDisplayMode ( source_type, &tmp_dis_mode ); - data = ( vpp_display_mode_t ) tmp_dis_mode; + SSMReadDisplayMode(source_type, &tmp_dis_mode); + data = (vpp_display_mode_t) tmp_dis_mode; - return data; + return data; } +int CVpp::SetBacklightWithoutSave(int value, tv_source_input_type_t source_type) { + int backlight_value, backlight_reverse = 0; + int ret = -1; + int tmp_pic_mode = 0; + source_type = SOURCE_TYPE_TV; -int CVpp::Tv_SetBacklightWithoutSave ( int value, tv_source_input_type_t source_type ) -{ - int backlight_value, backlight_reverse = 0; - int ret = -1; - int tmp_pic_mode = 0; + if (value < 0 || value > 100) { + value = 100; + } - source_type = SOURCE_TYPE_TV; + if (mbVppCfg_backlight_reverse) { + backlight_value = (100 - value) * 255 / 100; + } else { + backlight_value = value * 255 / 100; + } - if ( value < 0 || value > 100 ) { - value = 100; - } + return VPP_SetBackLightLevel(backlight_value); +} - if ( mbVppCfg_backlight_reverse) { - backlight_value = ( 100 - value ) * 255 / 100; - } else { - backlight_value = value * 255 / 100; - } +int CVpp::VPP_SetBackLightLevel(int value) { + FILE *fp = NULL; + fp = fopen("/sys/class/backlight/aml-bl/brightness", "w"); + LOGD("~~~fopen~~~##VPP_SetBackLightLevel##%s : %d ##", + "/sys/class/backlight/aml-bl/brightness", value); - return VPP_SetBackLightLevel ( backlight_value ); -} + if (fp == NULL) { + LOGE("Open /sys/class/backlight/aml-bl/brightness error(%s)!\n", strerror(errno)); + return -1; + } -int CVpp::VPP_SetBackLightLevel ( int value ) -{ - FILE *fp = NULL; - const char *config_value; + fprintf(fp, "%d", value); - config_value = config_get_str ( "TV", "vpp.backlight.built_in_ctrl", "null" ); + fclose(fp); + fp = NULL; - if ( strcmp ( config_value, "enable" ) == 0 ) { - fp = fopen ( "/sys/class/backlight/aml-bl/brightness", "w" ); - LOGD ( "~~~fopen~~~##VPP_SetBackLightLevel##%s : %d ##" , "/sys/class/backlight/aml-bl/brightness", value); + return 0; +} - if ( fp == NULL ) { - LOGE ( "Open /sys/class/backlight/aml-bl/brightness error(%s)!\n", strerror ( errno ) ); - return -1; - } +int CVpp::SetBacklight(int value, tv_source_input_type_t source_type, int is_save) { + static const int MIN_BACKLIGHT_VALUE = 1; + if (value >= MIN_BACKLIGHT_VALUE) { + if (SetBacklightWithoutSave(value, source_type) < 0) { + LOGE("%s, failed !", __FUNCTION__); + return -1; + } - fprintf ( fp, "%d", value ); + } else { + if (SetBacklightWithoutSave(MIN_BACKLIGHT_VALUE, source_type) < 0) { + LOGE("%s, failed !", __FUNCTION__); + return -1; + } + } + if (is_save == 1) { + return SaveBacklight(value, source_type); + } else { + return 0; + } +} - fclose ( fp ); - fp = NULL; +int CVpp::GetBacklight(tv_source_input_type_t source_type) { + int data = 0; + vpp_pq_para_t pq_para; - return 0; - } else { - // TODO : control the backlight through the CEC. + if (mbVppCfg_pqmode_depend_bklight) { + vpp_picture_mode_t pq_mode = GetPQMode(source_type); - return 0; - } -} + if (pq_mode == VPP_PICTURE_MODE_USER) { + SSMReadBackLightVal(source_type, &data); + } else { + Vpp_GetPQModeValue(source_type, pq_mode, &pq_para); + data = pq_para.backlight; + } + } else { + source_type = SOURCE_TYPE_TV; + SSMReadBackLightVal(source_type, &data); + } -int CVpp::Tv_SetBacklight ( int value, tv_source_input_type_t source_type, int is_save ) -{ - if ( Tv_SetBacklightWithoutSave ( value, source_type ) < 0 ) { - LOGE ( "%s, failed !", __FUNCTION__ ); - return -1; - } + if (data < 0 || data > 100) { + data = 100; + } - if ( is_save == 1 ) { - return Tv_SaveBacklight ( value, source_type ); - } else { - return 0; - } + return data; } -int CVpp::Tv_GetBacklight ( tv_source_input_type_t source_type ) -{ - int data = 0; - vpp_pq_para_t pq_para; +int CVpp::SaveBacklight(int value, tv_source_input_type_t source_type) { + int backlight_value, backlight_reverse = 0; + int ret = -1; + int tmp_pic_mode = 0; - if ( mbVppCfg_pqmode_depend_bklight) { - vpp_picture_mode_t pq_mode = Tv_GetPQMode ( source_type ); + if (!mbVppCfg_pqmode_depend_bklight) { + source_type = SOURCE_TYPE_TV; + } - if ( pq_mode == VPP_PICTURE_MODE_USER ) { - SSMReadBackLightVal ( source_type, &data ); - } else { - Vpp_GetPQModeValue ( source_type, pq_mode, &pq_para ); - data = pq_para.backlight; - } - } else { - source_type = SOURCE_TYPE_TV; - SSMReadBackLightVal ( source_type, &data ); - } + if (value < 0 || value > 100) { + value = 100; + } - if ( data < 0 || data > 100 ) { - data = 100; - } + ret = SSMSaveBackLightVal(source_type, value); - return data; + return ret; } -int CVpp::Tv_SaveBacklight ( int value, tv_source_input_type_t source_type ) -{ - int backlight_value, backlight_reverse = 0; - int ret = -1; - int tmp_pic_mode = 0; +int CVpp::VPP_SetBackLight_Switch(int value) { + FILE *fp = NULL; + fp = fopen("/sys/class/backlight/aml-bl/bl_power", "w"); + LOGD("~~~fopen~~~##VPP_SetBackLight_Switch##%s : %d ##", + "/sys/class/backlight/aml-bl/bl_power", value); - if ( !mbVppCfg_pqmode_depend_bklight ) { - source_type = SOURCE_TYPE_TV; - } - - if ( value < 0 || value > 100 ) { - value = 100; - } + if (fp == NULL) { + LOGE("Open /sys/class/backlight/aml-bl/bl_power error(%s)!\n", strerror(errno)); + return -1; + } - ret = SSMSaveBackLightVal ( source_type, value ); + fprintf(fp, "%d", value); + fclose(fp); + fp = NULL; - return ret; + return 0; } -int CVpp::Tv_SetDNLP ( tv_source_input_type_t source_type, tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt ) -{ - unsigned int dnlp_switch = 0; +int CVpp::VPP_GetBackLight_Switch(void) { + FILE *fp = NULL; + int value; + + fp = fopen("/sys/class/backlight/aml-bl/bl_power", "w"); - int ret = -1; - int dnlpFlag = -1; - ve_dnlp_t dnlp; - ve_dnlp_table_t newdnlp; + if (fp == NULL) { + LOGE("Open /sys/class/backlight/aml-bl/bl_power error(%s)!\n", strerror(errno)); + return -1; + } - dnlp_switch = 1; + fscanf(fp, "%d", &value); + LOGD("~~~fopen~~~##VPP_GetBackLight_Switch##%s : %d ##", + "/sys/class/backlight/aml-bl/bl_power", value); + + fclose(fp); + fp = NULL; + if (value < 0) { + return 0; + } else { + return value; + } +} +int CVpp::SetDNLP(tv_source_input_type_t source_type, tvin_port_t source_port, + tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + unsigned int dnlp_switch = 0; - if ( mpPqData->PQ_GetDNLPParams ( source_port, sig_fmt, is3d, trans_fmt, &dnlp, &newdnlp, &dnlpFlag ) == 0 ) { - newdnlp.en = dnlp_switch; - LOGE ( "PQ_GetDNLPParams ok!\n" ); - LOGE ( "newdnlp.en:%d,newdnlp.method:%d,newdnlp.cliprate:%d,newdnlp.lowrange:%d,newdnlp.hghrange:%d,newdnlp.lowalpha:%d,newdnlp.midalpha:%d,newdnlp.hghalpha:%d\n", - newdnlp.en, newdnlp.method, newdnlp.cliprate, newdnlp.lowrange, newdnlp.hghrange, newdnlp.lowalpha, newdnlp.midalpha, newdnlp.hghalpha); - VPP_SetVENewDNLP ( &newdnlp ); - SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_en", "1" ); - ret = 1; - } else { - LOGE ( "mpPqData->PQ_GetDNLPParams failed!\n" ); - } + int ret = -1; + int dnlpFlag = -1; + ve_dnlp_t dnlp; + ve_dnlp_table_t newdnlp; + + dnlp_switch = 1; + + if (mpPqData->PQ_GetDNLPParams(source_port, sig_fmt, is3d, trans_fmt, &dnlp, &newdnlp, + &dnlpFlag) == 0) { + newdnlp.en = dnlp_switch; + LOGE("PQ_GetDNLPParams ok!\n"); + LOGE( + "newdnlp.en:%d,newdnlp.method:%d,newdnlp.cliprate:%d,newdnlp.lowrange:%d,newdnlp.hghrange:%d,newdnlp.lowalpha:%d,newdnlp.midalpha:%d,newdnlp.hghalpha:%d\n", + newdnlp.en, newdnlp.method, newdnlp.cliprate, newdnlp.lowrange, newdnlp.hghrange, + newdnlp.lowalpha, newdnlp.midalpha, newdnlp.hghalpha); + if (source_type == SOURCE_TYPE_DTV) { + SetFileAttrValue("/sys/module/am_vecm/parameters/dnlp_en", "0"); + } else { + VPP_SetVENewDNLP(&newdnlp); + SetFileAttrValue("/sys/module/am_vecm/parameters/dnlp_en", "1"); + } + ret = 1; + } else { + LOGE("mpPqData->PQ_GetDNLPParams failed!\n"); + } - return ret; + return ret; } -int CVpp::VPP_SetVEDNLP ( const struct ve_dnlp_s *pDNLP ) -{ - int rt = VPP_DeviceIOCtl ( AMVECM_IOC_VE_DNLP, pDNLP ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetVEDNLP##AMVECM_IOC_VE_DNLP##" ); +int CVpp::VPP_SetVEDNLP(const struct ve_dnlp_s *pDNLP) { + int rt = VPP_DeviceIOCtl(AMVECM_IOC_VE_DNLP, pDNLP); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEDNLP##AMVECM_IOC_VE_DNLP##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetVEDNLP, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetVEDNLP, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetVENewDNLP ( const ve_dnlp_table_t *pDNLP ) -{ - int rt = VPP_DeviceIOCtl ( AMVECM_IOC_VE_NEW_DNLP, pDNLP ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetVENewDNLP##AMVECM_IOC_VE_NEW_DNLP##" ); +int CVpp::VPP_SetVENewDNLP(const ve_dnlp_table_t *pDNLP) { + int rt = VPP_DeviceIOCtl(AMVECM_IOC_VE_NEW_DNLP, pDNLP); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVENewDNLP##AMVECM_IOC_VE_NEW_DNLP##"); - if ( rt < 0 ) { - LOGE ( "VPP_SetVENewDNLP, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("VPP_SetVENewDNLP, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::Tv_SetDnlp_OFF ( void ) -{ - if ( Vpp_SetDnlpOff() < 0 ) { - LOGE ( "%s failed.\n", __FUNCTION__ ); - return -1; - } else { - LOGE ( "%s success.\n", __FUNCTION__ ); - SSMSaveDnlpStart ( 1 ); //save dnlp status to e2rom - return 0; - } -} -int CVpp::Tv_SetDnlp_ON ( void ) -{ - if ( Vpp_SetDnlpOn() < 0 ) { - LOGE ( "%s failed.\n", __FUNCTION__ ); - return -1; - } else { - LOGE ( "%s success.\n", __FUNCTION__ ); - SSMSaveDnlpStart ( 0 ); //save dnlp status to e2rom - return 0; - } +int CVpp::SetDnlp_OFF(void) { + if (Vpp_SetDnlpOff() < 0) { + LOGE("%s failed.\n", __FUNCTION__); + return -1; + } else { + LOGE("%s success.\n", __FUNCTION__); + SSMSaveDnlpStart(1); //save dnlp status to e2rom + return 0; + } +} +int CVpp::SetDnlp_ON(void) { + if (Vpp_SetDnlpOn() < 0) { + LOGE("%s failed.\n", __FUNCTION__); + return -1; + } else { + LOGE("%s success.\n", __FUNCTION__); + SSMSaveDnlpStart(0); //save dnlp status to e2rom + return 0; + } } -int CVpp::Vpp_SetDnlpOff ( void ) -{ - //According linux driver to modify the AMSTREAM_IOC_VE_DNLP_DIS to the AMVECM_IOC_VE_DNLP_DIS. - //int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_DNLP_DIS); - int rt = VPP_DeviceIOCtl ( AMVECM_IOC_VE_DNLP_DIS ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##Vpp_SetDnlpOff##AMVECM_IOC_VE_DNLP_DIS##" ); +int CVpp::Vpp_SetDnlpOff(void) { + //According linux driver to modify the AMSTREAM_IOC_VE_DNLP_DIS to the AMVECM_IOC_VE_DNLP_DIS. + //int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_DNLP_DIS); + int rt = VPP_DeviceIOCtl(AMVECM_IOC_VE_DNLP_DIS); + LOGD("~~~VPP_DeviceIOCtl~~~##Vpp_SetDnlpOff##AMVECM_IOC_VE_DNLP_DIS##"); - if ( rt < 0 ) { - LOGE ( "Vpp_SetDnlpOff, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_SetDnlpOff, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::Vpp_SetDnlpOn ( void ) -{ - //According linux driver to modify the AMSTREAM_IOC_VE_DNLP_DIS to the AMVECM_IOC_VE_DNLP_DIS. - //int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_DNLP_EN); - int rt = VPP_DeviceIOCtl ( AMVECM_IOC_VE_DNLP_EN ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##Vpp_SetDnlpOn##AMVECM_IOC_VE_DNLP_EN##" ); +int CVpp::Vpp_SetDnlpOn(void) { + //According linux driver to modify the AMSTREAM_IOC_VE_DNLP_DIS to the AMVECM_IOC_VE_DNLP_DIS. + //int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_DNLP_EN); + int rt = VPP_DeviceIOCtl(AMVECM_IOC_VE_DNLP_EN); + LOGD("~~~VPP_DeviceIOCtl~~~##Vpp_SetDnlpOn##AMVECM_IOC_VE_DNLP_EN##"); - if ( rt < 0 ) { - LOGE ( "Vpp_SetDnlpOn, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_SetDnlpOn, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::Tv_GetDnlp_Status() -{ - unsigned char status = 0; - SSMReadDnlpStart ( &status ); - LOGD ( "%s, %d.", __FUNCTION__, status ); - return status; +int CVpp::GetDnlp_Status() { + unsigned char status = 0; + SSMReadDnlpStart(&status); + LOGD("%s, %d.", __FUNCTION__, status); + return status; } -int CVpp::VPP_SetRGBOGO ( const struct tcon_rgb_ogo_s *rgbogo ) -{ - int rt = VPP_DeviceIOCtl ( AMVECM_IOC_S_RGB_OGO, rgbogo ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetRGBOGO##AMVECM_IOC_S_RGB_OGO##" ); - usleep ( 50 * 1000 ); +int CVpp::VPP_SetRGBOGO(const struct tcon_rgb_ogo_s *rgbogo) { + int rt = VPP_DeviceIOCtl(AMVECM_IOC_S_RGB_OGO, rgbogo); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetRGBOGO##AMVECM_IOC_S_RGB_OGO##"); + usleep(50 * 1000); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetRGBOGO, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetRGBOGO, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_GetRGBOGO ( const struct tcon_rgb_ogo_s *rgbogo ) -{ - int rt = VPP_DeviceIOCtl ( AMVECM_IOC_G_RGB_OGO, rgbogo ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_GetRGBOGO##AMVECM_IOC_G_RGB_OGO##" ); +int CVpp::VPP_GetRGBOGO(const struct tcon_rgb_ogo_s *rgbogo) { + int rt = VPP_DeviceIOCtl(AMVECM_IOC_G_RGB_OGO, rgbogo); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_GetRGBOGO##AMVECM_IOC_G_RGB_OGO##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_GetRGBOGO, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_GetRGBOGO, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::Tv_SetRGBOGO_PostOffset(int rgb, int offset) -{ - tcon_rgb_ogo_t rgbogo; - - if ( VPP_GetRGBOGO ( &rgbogo ) < 0 ) return -1; - switch(rgb) { - case 0://r - rgbogo.r_post_offset = offset; - break; - case 1://g - rgbogo.g_post_offset = offset; - break; - case 2://b - rgbogo.b_post_offset = offset; - break; - default: - break; - } - if ( VPP_SetRGBOGO ( &rgbogo ) != 0 ) return -1; - int ret = 0; - switch(rgb) { - case 0: - ret = SSMSaveRGBPostOffsetRStart ( 0, offset); - break; - case 1: - ret = SSMSaveRGBPostOffsetGStart ( 0, offset); - break; - case 2: - ret = SSMSaveRGBPostOffsetBStart ( 0, offset); - break; - default: - break; - } - return ret; -} - -int CVpp::Tv_SetRGBOGO_Gain(int rgb, int gain) -{ - tcon_rgb_ogo_t rgbogo; - - if ( VPP_GetRGBOGO ( &rgbogo ) < 0 ) return -1; - - switch(rgb) { - case 0://r - rgbogo.r_gain = gain; - break; - case 1://g - rgbogo.g_gain = gain; - break; - case 2://b - rgbogo.b_gain = gain; - break; - default: - break; - } - - if ( VPP_SetRGBOGO ( &rgbogo ) != 0 ) return -1; - - int ret = 0; - switch(rgb) { - case 0: - ret = SSMSaveRGBGainRStart ( 0, gain); - break; - case 1: - ret = SSMSaveRGBGainGStart ( 0, gain); - break; - case 2: - ret = SSMSaveRGBGainBStart ( 0, gain); - break; - default: - break; - } - - return ret; -} - -int CVpp::Tv_GetRGBOGO_PostOffset ( int rgb ) +int CVpp::RGBGainValueSSMToRisterMapping(int gainValue) //0~255 { - int offset = 0; - int ret = 0; - switch(rgb) { - case 0: - ret = SSMReadRGBPostOffsetRStart ( 0, &offset ) ; - break; - case 1: - ret = SSMReadRGBPostOffsetGStart ( 0, &offset ) ; - break; - case 2: - ret = SSMReadRGBPostOffsetBStart ( 0, &offset ) ; - break; - default: - break; - } - - if ( offset < -1024 || offset > 1023 ) { - offset = 0; - } - - return offset; -} - -int CVpp::Tv_GetRGBOGO_Gain ( int rgb ) -{ - unsigned int gain = 0; - - int ret = 0; - switch(rgb) { - case 0: - ret = SSMReadRGBGainRStart ( 0, &gain ) ; - break; - case 1: - ret = SSMReadRGBGainGStart ( 0, &gain ) ; - break; - case 2: - ret = SSMReadRGBGainBStart ( 0, &gain ) ; - break; - default: - break; - } - - if ( /*gain_r < 0 || */gain > 2047 ) { - gain = 1024; - } - - return gain; -} - -//RGB GAIN:0~255 <-----> 512~1536 -int CVpp::Tv_RGBGainValueSSMToRisterMapping ( int gainValue ) //0~255 -{ - int mapValue = 0; + int mapValue = 0; - if ( gainValue < 0 || gainValue > 255 ) { - mapValue = 1024; - } else { - if ( gainValue == 255 ) { - mapValue = 1536; - } else { - mapValue = 512 + gainValue * ( 1536 - 512 ) / 256; - } - } + if (gainValue < 0 || gainValue > 255) { + mapValue = 1024; + } else { + if (gainValue == 255) { + mapValue = 1536; + } else { + mapValue = 512 + gainValue * (1536 - 512) / 256; + } + } - return mapValue;//512~1536 + return mapValue;//512~1536 } //RGB OFFSET:-128~127 <-----> -512~512 -int CVpp::Tv_RGBOffsetValueSSMToRisterMapping ( int offsetValue ) //-128~127 +int CVpp::RGBOffsetValueSSMToRisterMapping(int offsetValue) //-128~127 { - int mapValue = 0; + int mapValue = 0; - if ( offsetValue < -128 || offsetValue > 127 ) { - offsetValue = 0; - } + if (offsetValue < -128 || offsetValue > 127) { + offsetValue = 0; + } - if ( offsetValue == 127 ) { - mapValue = 512; - } else { - mapValue = 1024 * offsetValue / 256; - } + if (offsetValue == 127) { + mapValue = 512; + } else { + mapValue = 1024 * offsetValue / 256; + } - return mapValue;//-512~512 + return mapValue;//-512~512 } -int CVpp::Tv_FactorySetPQMode_Brightness ( int source_type, int pq_mode, int brightness ) -{ - int ret = -1; - vpp_pq_para_t pq_para; +int CVpp::FactorySetPQMode_Brightness(int source_type, int pq_mode, int brightness) { + int ret = -1; + vpp_pq_para_t pq_para; - if ( mpPqData->PQ_GetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) == 0 ) { - pq_para.brightness = brightness; + if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { + pq_para.brightness = brightness; - if ( mpPqData->PQ_SetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) == 0 ) { - ret = 0; - } else { - ret = 1; - } - } else { - ret = -1; - } + if (mpPqData->PQ_SetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { + ret = 0; + } else { + ret = 1; + } + } else { + ret = -1; + } - return ret; + return ret; } -int CVpp::Tv_FactoryGetPQMode_Brightness ( int source_type, int pq_mode ) -{ - vpp_pq_para_t pq_para; +int CVpp::FactoryGetPQMode_Brightness(int source_type, int pq_mode) { + vpp_pq_para_t pq_para; - if ( mpPqData->PQ_GetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) != 0 ) { - return -1; - } + if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) != 0) { + return -1; + } - return pq_para.brightness; + return pq_para.brightness; } +int CVpp::FactorySetPQMode_Contrast(int source_type, int pq_mode, int contrast) { + int ret = -1; + vpp_pq_para_t pq_para; -int CVpp::Tv_FactorySetPQMode_Contrast ( int source_type, int pq_mode, int contrast ) -{ - int ret = -1; - vpp_pq_para_t pq_para; - - if ( mpPqData->PQ_GetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) == 0 ) { - pq_para.contrast = contrast; + if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { + pq_para.contrast = contrast; - if ( mpPqData->PQ_SetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) == 0 ) { - ret = 0; - } else { - ret = 1; - } - } else { - ret = -1; - } + if (mpPqData->PQ_SetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { + ret = 0; + } else { + ret = 1; + } + } else { + ret = -1; + } - return ret; + return ret; } -int CVpp::Tv_FactoryGetPQMode_Contrast ( int source_type, int pq_mode ) -{ - vpp_pq_para_t pq_para; +int CVpp::FactoryGetPQMode_Contrast(int source_type, int pq_mode) { + vpp_pq_para_t pq_para; - if ( mpPqData->PQ_GetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) != 0 ) { - return -1; - } + if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) != 0) { + return -1; + } - return pq_para.contrast; + return pq_para.contrast; } -int CVpp::Tv_FactorySetPQMode_Saturation ( int source_type, int pq_mode, int saturation ) -{ - int ret = -1; - vpp_pq_para_t pq_para; +int CVpp::FactorySetPQMode_Saturation(int source_type, int pq_mode, int saturation) { + int ret = -1; + vpp_pq_para_t pq_para; - if ( mpPqData->PQ_GetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) == 0 ) { - pq_para.saturation = saturation; + if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { + pq_para.saturation = saturation; - if ( mpPqData->PQ_SetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) == 0 ) { - ret = 0; - } else { - ret = 1; - } - } else { - ret = -1; - } + if (mpPqData->PQ_SetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { + ret = 0; + } else { + ret = 1; + } + } else { + ret = -1; + } - return ret; + return ret; } -int CVpp::Tv_FactoryGetPQMode_Saturation ( int source_type, int pq_mode ) -{ - vpp_pq_para_t pq_para; +int CVpp::FactoryGetPQMode_Saturation(int source_type, int pq_mode) { + vpp_pq_para_t pq_para; - if ( mpPqData->PQ_GetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) != 0 ) { - return -1; - } + if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) != 0) { + return -1; + } - return pq_para.saturation; + return pq_para.saturation; } -int CVpp::Tv_FactorySetPQMode_Hue ( int source_type, int pq_mode, int hue ) -{ - int ret = -1; - vpp_pq_para_t pq_para; +int CVpp::FactorySetPQMode_Hue(int source_type, int pq_mode, int hue) { + int ret = -1; + vpp_pq_para_t pq_para; - if ( mpPqData->PQ_GetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) == 0 ) { - pq_para.hue = hue; + if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { + pq_para.hue = hue; - if ( mpPqData->PQ_SetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) == 0 ) { - ret = 0; - } else { - ret = 1; - } - } else { - ret = -1; - } + if (mpPqData->PQ_SetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { + ret = 0; + } else { + ret = 1; + } + } else { + ret = -1; + } - return ret; + return ret; } -int CVpp::Tv_FactoryGetPQMode_Hue ( int source_type, int pq_mode ) -{ - vpp_pq_para_t pq_para; +int CVpp::FactoryGetPQMode_Hue(int source_type, int pq_mode) { + vpp_pq_para_t pq_para; - if ( mpPqData->PQ_GetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) != 0 ) { - return -1; - } + if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) != 0) { + return -1; + } - return pq_para.hue; + return pq_para.hue; } -int CVpp::Tv_FactorySetPQMode_Sharpness ( int source_type, int pq_mode, int sharpness ) -{ - int ret = -1; - vpp_pq_para_t pq_para; +int CVpp::FactorySetPQMode_Sharpness(int source_type, int pq_mode, int sharpness) { + int ret = -1; + vpp_pq_para_t pq_para; - if ( mpPqData->PQ_GetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) == 0 ) { - pq_para.sharpness = sharpness; + if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { + pq_para.sharpness = sharpness; - if ( mpPqData->PQ_SetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) == 0 ) { - ret = 0; - } else { - ret = 1; - } - } else { - ret = -1; - } + if (mpPqData->PQ_SetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { + ret = 0; + } else { + ret = 1; + } + } else { + ret = -1; + } - return ret; + return ret; } -int CVpp::Tv_FactoryGetPQMode_Sharpness ( int source_type, int pq_mode ) -{ - vpp_pq_para_t pq_para; +int CVpp::FactoryGetPQMode_Sharpness(int source_type, int pq_mode) { + vpp_pq_para_t pq_para; - if ( mpPqData->PQ_GetPQModeParams ( ( tv_source_input_type_t ) source_type, ( vpp_picture_mode_t ) pq_mode, &pq_para ) != 0 ) { - return -1; - } + if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, + (vpp_picture_mode_t) pq_mode, &pq_para) != 0) { + return -1; + } - return pq_para.sharpness; + return pq_para.sharpness; } -unsigned short CVpp::CalColorTemperatureParamsChecksum ( void ) -{ - unsigned char data_buf[SSM_CR_RGBOGO_LEN]; - unsigned short sum = 0; - int cnt; - USUC usuc; +unsigned short CVpp::CalColorTemperatureParamsChecksum(void) { + unsigned char data_buf[SSM_CR_RGBOGO_LEN]; + unsigned short sum = 0; + int cnt; + USUC usuc; - SSMReadRGBOGOValue ( 0, SSM_CR_RGBOGO_LEN, data_buf ); + SSMReadRGBOGOValue(0, SSM_CR_RGBOGO_LEN, data_buf); - for ( cnt = 0; cnt < SSM_CR_RGBOGO_LEN; cnt++ ) { - sum += data_buf[cnt]; - } + for (cnt = 0; cnt < SSM_CR_RGBOGO_LEN; cnt++) { + sum += data_buf[cnt]; + } - //checksum = 0xff - sum % 0xff; + //checksum = 0xff - sum % 0xff; - LOGD ( "%s, sum = 0x%X.\n", __FUNCTION__, sum ); + LOGD("%s, sum = 0x%X.\n", __FUNCTION__, sum); - return sum; + return sum; } -int CVpp::SetColorTempParamsChecksum ( void ) -{ - int ret = 0; - USUC usuc; +int CVpp::SetColorTempParamsChecksum(void) { + int ret = 0; + USUC usuc; - usuc.s = CalColorTemperatureParamsChecksum(); + usuc.s = CalColorTemperatureParamsChecksum(); - LOGD ( "%s, sum = 0x%X.\n", __FUNCTION__, usuc.s ); + LOGD("%s, sum = 0x%X.\n", __FUNCTION__, usuc.s); - ret |= SSMSaveRGBOGOValue ( SSM_CR_RGBOGO_LEN, SSM_CR_RGBOGO_CHKSUM_LEN, usuc.c ); + ret |= SSMSaveRGBOGOValue(SSM_CR_RGBOGO_LEN, SSM_CR_RGBOGO_CHKSUM_LEN, usuc.c); - return ret; + return ret; } -unsigned short CVpp::GetColorTempParamsChecksum ( void ) -{ - USUC usuc; +unsigned short CVpp::GetColorTempParamsChecksum(void) { + USUC usuc; - SSMReadRGBOGOValue ( SSM_CR_RGBOGO_LEN, SSM_CR_RGBOGO_CHKSUM_LEN, usuc.c ); + SSMReadRGBOGOValue(SSM_CR_RGBOGO_LEN, SSM_CR_RGBOGO_CHKSUM_LEN, usuc.c); - LOGD ( "%s, sum = 0x%X.\n", __FUNCTION__, usuc.s ); + LOGD("%s, sum = 0x%X.\n", __FUNCTION__, usuc.s); - return usuc.s; + return usuc.s; } -int CVpp::CheckTempDataLable ( void ) -{ - USUC usuc; - USUC ret; +int CVpp::CheckTempDataLable(void) { + USUC usuc; + USUC ret; - SSMReadRGBOGOValue ( SSM_CR_RGBOGO_LEN - 2, 2, ret.c ); + SSMReadRGBOGOValue(SSM_CR_RGBOGO_LEN - 2, 2, ret.c); - usuc.c[0] = 0x55; - usuc.c[1] = 0xAA; + usuc.c[0] = 0x55; + usuc.c[1] = 0xAA; - if ( ( usuc.c[0] == ret.c[0] ) && ( usuc.c[1] == ret.c[1] ) ) { - LOGD ( "%s, lable ok.\n", __FUNCTION__ ); - return 1; - } else { - LOGD ( "%s, lable error.\n", "TV" ); - return 0; - } + if ((usuc.c[0] == ret.c[0]) && (usuc.c[1] == ret.c[1])) { + LOGD("%s, lable ok.\n", __FUNCTION__); + return 1; + } else { + LOGD("%s, lable error.\n", "TV"); + return 0; + } } -int CVpp::SetTempDataLable ( void ) -{ - USUC usuc; - int ret = 0; +int CVpp::SetTempDataLable(void) { + USUC usuc; + int ret = 0; - usuc.c[0] = 0x55; - usuc.c[1] = 0xAA; + usuc.c[0] = 0x55; + usuc.c[1] = 0xAA; - ret = SSMSaveRGBOGOValue ( SSM_CR_RGBOGO_LEN - 2, 2, usuc.c ); + ret = SSMSaveRGBOGOValue(SSM_CR_RGBOGO_LEN - 2, 2, usuc.c); - return ret; + return ret; } -int CVpp::GetColorTemperatureParams ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params ) -{ - // CheckColorTemperatureParamAlldata(source_port,sig_fmt,trans_fmt); +int CVpp::GetColorTemperatureParams(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params) { + // CheckColorTemperatureParamAlldata(source_port,sig_fmt,trans_fmt); - return ReadColorTemperatureParams ( Tempmode, params ); + return ReadColorTemperatureParams(Tempmode, params); } -int CVpp::ReadColorTemperatureParams ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params ) -{ - SUC suc; - USUC usuc; - int ret = 0; +int CVpp::ReadColorTemperatureParams(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params) { + SUC suc; + USUC usuc; + int ret = 0; - if ( VPP_COLOR_TEMPERATURE_MODE_STANDARD == Tempmode ) { //standard - ret |= SSMReadRGBOGOValue ( 0, 2, usuc.c ); - params->en = usuc.s; + if (VPP_COLOR_TEMPERATURE_MODE_STANDARD == Tempmode) { //standard + ret |= SSMReadRGBOGOValue(0, 2, usuc.c); + params->en = usuc.s; - ret |= SSMReadRGBOGOValue ( 2, 2, suc.c ); - params->r_pre_offset = suc.s; + ret |= SSMReadRGBOGOValue(2, 2, suc.c); + params->r_pre_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 4, 2, suc.c ); - params->g_pre_offset = suc.s; + ret |= SSMReadRGBOGOValue(4, 2, suc.c); + params->g_pre_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 6, 2, suc.c ); - params->b_pre_offset = suc.s; + ret |= SSMReadRGBOGOValue(6, 2, suc.c); + params->b_pre_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 8, 2, usuc.c ); - params->r_gain = usuc.s; + ret |= SSMReadRGBOGOValue(8, 2, usuc.c); + params->r_gain = usuc.s; - ret |= SSMReadRGBOGOValue ( 10, 2, usuc.c ); - params->g_gain = usuc.s; + ret |= SSMReadRGBOGOValue(10, 2, usuc.c); + params->g_gain = usuc.s; - ret |= SSMReadRGBOGOValue ( 12, 2, usuc.c ); - params->b_gain = usuc.s; + ret |= SSMReadRGBOGOValue(12, 2, usuc.c); + params->b_gain = usuc.s; - ret |= SSMReadRGBOGOValue ( 14, 2, suc.c ); - params->r_post_offset = suc.s; + ret |= SSMReadRGBOGOValue(14, 2, suc.c); + params->r_post_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 16, 2, suc.c ); - params->g_post_offset = suc.s; + ret |= SSMReadRGBOGOValue(16, 2, suc.c); + params->g_post_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 18, 2, suc.c ); - params->b_post_offset = suc.s; - } else if ( VPP_COLOR_TEMPERATURE_MODE_WARM == Tempmode ) { //warm - ret |= SSMReadRGBOGOValue ( 20, 2, usuc.c ); - params->en = usuc.s; + ret |= SSMReadRGBOGOValue(18, 2, suc.c); + params->b_post_offset = suc.s; + } else if (VPP_COLOR_TEMPERATURE_MODE_WARM == Tempmode) { //warm + ret |= SSMReadRGBOGOValue(20, 2, usuc.c); + params->en = usuc.s; - ret |= SSMReadRGBOGOValue ( 22, 2, suc.c ); - params->r_pre_offset = suc.s; + ret |= SSMReadRGBOGOValue(22, 2, suc.c); + params->r_pre_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 24, 2, suc.c ); - params->g_pre_offset = suc.s; + ret |= SSMReadRGBOGOValue(24, 2, suc.c); + params->g_pre_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 26, 2, suc.c ); - params->b_pre_offset = suc.s; + ret |= SSMReadRGBOGOValue(26, 2, suc.c); + params->b_pre_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 28, 2, usuc.c ); - params->r_gain = usuc.s; - ret |= SSMReadRGBOGOValue ( 30, 2, usuc.c ); - params->g_gain = usuc.s; + ret |= SSMReadRGBOGOValue(28, 2, usuc.c); + params->r_gain = usuc.s; + ret |= SSMReadRGBOGOValue(30, 2, usuc.c); + params->g_gain = usuc.s; - ret |= SSMReadRGBOGOValue ( 32, 2, usuc.c ); - params->b_gain = usuc.s; + ret |= SSMReadRGBOGOValue(32, 2, usuc.c); + params->b_gain = usuc.s; - ret |= SSMReadRGBOGOValue ( 34, 2, suc.c ); - params->r_post_offset = suc.s; + ret |= SSMReadRGBOGOValue(34, 2, suc.c); + params->r_post_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 36, 2, suc.c ); - params->g_post_offset = suc.s; + ret |= SSMReadRGBOGOValue(36, 2, suc.c); + params->g_post_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 38, 2, suc.c ); - params->b_post_offset = suc.s; - } else if ( VPP_COLOR_TEMPERATURE_MODE_COLD == Tempmode ) { //cool - ret |= SSMReadRGBOGOValue ( 40, 2, usuc.c ); - params->en = usuc.s; + ret |= SSMReadRGBOGOValue(38, 2, suc.c); + params->b_post_offset = suc.s; + } else if (VPP_COLOR_TEMPERATURE_MODE_COLD == Tempmode) { //cool + ret |= SSMReadRGBOGOValue(40, 2, usuc.c); + params->en = usuc.s; - ret |= SSMReadRGBOGOValue ( 42, 2, suc.c ); - params->r_pre_offset = suc.s; + ret |= SSMReadRGBOGOValue(42, 2, suc.c); + params->r_pre_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 44, 2, suc.c ); - params->g_pre_offset = suc.s; + ret |= SSMReadRGBOGOValue(44, 2, suc.c); + params->g_pre_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 46, 2, suc.c ); - params->b_pre_offset = suc.s; + ret |= SSMReadRGBOGOValue(46, 2, suc.c); + params->b_pre_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 48, 2, usuc.c ); - params->r_gain = usuc.s; - ret |= SSMReadRGBOGOValue ( 50, 2, usuc.c ); - params->g_gain = usuc.s; + ret |= SSMReadRGBOGOValue(48, 2, usuc.c); + params->r_gain = usuc.s; + ret |= SSMReadRGBOGOValue(50, 2, usuc.c); + params->g_gain = usuc.s; - ret |= SSMReadRGBOGOValue ( 52, 2, usuc.c ); - params->b_gain = usuc.s; - ret |= SSMReadRGBOGOValue ( 54, 2, suc.c ); - params->r_post_offset = suc.s; + ret |= SSMReadRGBOGOValue(52, 2, usuc.c); + params->b_gain = usuc.s; + ret |= SSMReadRGBOGOValue(54, 2, suc.c); + params->r_post_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 56, 2, suc.c ); - params->g_post_offset = suc.s; + ret |= SSMReadRGBOGOValue(56, 2, suc.c); + params->g_post_offset = suc.s; - ret |= SSMReadRGBOGOValue ( 58, 2, suc.c ); - params->b_post_offset = suc.s; - } + ret |= SSMReadRGBOGOValue(58, 2, suc.c); + params->b_post_offset = suc.s; + } - LOGD ( "%s, rgain[%d], ggain[%d],bgain[%d],roffset[%d],goffset[%d],boffset[%d]\n", __FUNCTION__, params->r_gain, params->g_gain, - params->b_gain, params->r_post_offset, params->g_post_offset, params->b_post_offset ); + LOGD("%s, rgain[%d], ggain[%d],bgain[%d],roffset[%d],goffset[%d],boffset[%d]\n", __FUNCTION__, + params->r_gain, params->g_gain, params->b_gain, params->r_post_offset, + params->g_post_offset, params->b_post_offset); - return ret; + return ret; } -int CVpp::SetColorTemperatureParams ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params ) -{ - // CheckColorTemperatureParamAlldata(source_port,sig_fmt,trans_fmt); +int CVpp::SetColorTemperatureParams(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params) { + // CheckColorTemperatureParamAlldata(source_port,sig_fmt,trans_fmt); - SaveColorTemperatureParams ( Tempmode, params ); - SetColorTempParamsChecksum(); + SaveColorTemperatureParams(Tempmode, params); + SetColorTempParamsChecksum(); - return 0; + return 0; } -int CVpp::SaveColorTemperatureParams ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params ) -{ - SUC suc; - USUC usuc; - int ret = 0; +int CVpp::SaveColorTemperatureParams(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params) { + SUC suc; + USUC usuc; + int ret = 0; - if ( VPP_COLOR_TEMPERATURE_MODE_STANDARD == Tempmode ) { //standard - usuc.s = params.en; - ret |= SSMSaveRGBOGOValue ( 0, 2, usuc.c ); + if (VPP_COLOR_TEMPERATURE_MODE_STANDARD == Tempmode) { //standard + usuc.s = params.en; + ret |= SSMSaveRGBOGOValue(0, 2, usuc.c); - suc.s = params.r_pre_offset; - ret |= SSMSaveRGBOGOValue ( 2, 2, suc.c ); + suc.s = params.r_pre_offset; + ret |= SSMSaveRGBOGOValue(2, 2, suc.c); - suc.s = params.g_pre_offset; - ret |= SSMSaveRGBOGOValue ( 4, 2, suc.c ); + suc.s = params.g_pre_offset; + ret |= SSMSaveRGBOGOValue(4, 2, suc.c); - suc.s = params.b_pre_offset; - ret |= SSMSaveRGBOGOValue ( 6, 2, suc.c ); + suc.s = params.b_pre_offset; + ret |= SSMSaveRGBOGOValue(6, 2, suc.c); - usuc.s = params.r_gain; - ret |= SSMSaveRGBOGOValue ( 8, 2, usuc.c ); + usuc.s = params.r_gain; + ret |= SSMSaveRGBOGOValue(8, 2, usuc.c); - usuc.s = params.g_gain; - ret |= SSMSaveRGBOGOValue ( 10, 2, usuc.c ); + usuc.s = params.g_gain; + ret |= SSMSaveRGBOGOValue(10, 2, usuc.c); - usuc.s = params.b_gain; - ret |= SSMSaveRGBOGOValue ( 12, 2, usuc.c ); + usuc.s = params.b_gain; + ret |= SSMSaveRGBOGOValue(12, 2, usuc.c); - suc.s = params.r_post_offset; - ret |= SSMSaveRGBOGOValue ( 14, 2, suc.c ); + suc.s = params.r_post_offset; + ret |= SSMSaveRGBOGOValue(14, 2, suc.c); - suc.s = params.g_post_offset; - ret |= SSMSaveRGBOGOValue ( 16, 2, suc.c ); + suc.s = params.g_post_offset; + ret |= SSMSaveRGBOGOValue(16, 2, suc.c); - suc.s = params.b_post_offset; - ret |= SSMSaveRGBOGOValue ( 18, 2, suc.c ); - } else if ( VPP_COLOR_TEMPERATURE_MODE_WARM == Tempmode ) { //warm - usuc.s = params.en; - ret |= SSMSaveRGBOGOValue ( 20, 2, usuc.c ); + suc.s = params.b_post_offset; + ret |= SSMSaveRGBOGOValue(18, 2, suc.c); + } else if (VPP_COLOR_TEMPERATURE_MODE_WARM == Tempmode) { //warm + usuc.s = params.en; + ret |= SSMSaveRGBOGOValue(20, 2, usuc.c); - suc.s = params.r_pre_offset; - ret |= SSMSaveRGBOGOValue ( 22, 2, suc.c ); + suc.s = params.r_pre_offset; + ret |= SSMSaveRGBOGOValue(22, 2, suc.c); - suc.s = params.g_pre_offset; - ret |= SSMSaveRGBOGOValue ( 24, 2, suc.c ); - suc.s = params.b_pre_offset; - ret |= SSMSaveRGBOGOValue ( 26, 2, suc.c ); + suc.s = params.g_pre_offset; + ret |= SSMSaveRGBOGOValue(24, 2, suc.c); + suc.s = params.b_pre_offset; + ret |= SSMSaveRGBOGOValue(26, 2, suc.c); - usuc.s = params.r_gain; - ret |= SSMSaveRGBOGOValue ( 28, 2, usuc.c ); + usuc.s = params.r_gain; + ret |= SSMSaveRGBOGOValue(28, 2, usuc.c); - usuc.s = params.g_gain; - ret |= SSMSaveRGBOGOValue ( 30, 2, usuc.c ); + usuc.s = params.g_gain; + ret |= SSMSaveRGBOGOValue(30, 2, usuc.c); - usuc.s = params.b_gain; - ret |= SSMSaveRGBOGOValue ( 32, 2, usuc.c ); + usuc.s = params.b_gain; + ret |= SSMSaveRGBOGOValue(32, 2, usuc.c); - suc.s = params.r_post_offset; - ret |= SSMSaveRGBOGOValue ( 34, 2, suc.c ); + suc.s = params.r_post_offset; + ret |= SSMSaveRGBOGOValue(34, 2, suc.c); - suc.s = params.g_post_offset; - ret |= SSMSaveRGBOGOValue ( 36, 2, suc.c ); + suc.s = params.g_post_offset; + ret |= SSMSaveRGBOGOValue(36, 2, suc.c); - suc.s = params.b_post_offset; - ret |= SSMSaveRGBOGOValue ( 38, 2, suc.c ); - } else if ( VPP_COLOR_TEMPERATURE_MODE_COLD == Tempmode ) { //cool - usuc.s = params.en; - ret |= SSMSaveRGBOGOValue ( 40, 2, usuc.c ); + suc.s = params.b_post_offset; + ret |= SSMSaveRGBOGOValue(38, 2, suc.c); + } else if (VPP_COLOR_TEMPERATURE_MODE_COLD == Tempmode) { //cool + usuc.s = params.en; + ret |= SSMSaveRGBOGOValue(40, 2, usuc.c); - suc.s = params.r_pre_offset; - ret |= SSMSaveRGBOGOValue ( 42, 2, suc.c ); + suc.s = params.r_pre_offset; + ret |= SSMSaveRGBOGOValue(42, 2, suc.c); - suc.s = params.g_pre_offset; - ret |= SSMSaveRGBOGOValue ( 44, 2, suc.c ); + suc.s = params.g_pre_offset; + ret |= SSMSaveRGBOGOValue(44, 2, suc.c); - suc.s = params.b_pre_offset; - ret |= SSMSaveRGBOGOValue ( 46, 2, suc.c ); + suc.s = params.b_pre_offset; + ret |= SSMSaveRGBOGOValue(46, 2, suc.c); - usuc.s = params.r_gain; - ret |= SSMSaveRGBOGOValue ( 48, 2, usuc.c ); + usuc.s = params.r_gain; + ret |= SSMSaveRGBOGOValue(48, 2, usuc.c); - usuc.s = params.g_gain; - ret |= SSMSaveRGBOGOValue ( 50, 2, usuc.c ); + usuc.s = params.g_gain; + ret |= SSMSaveRGBOGOValue(50, 2, usuc.c); - usuc.s = params.b_gain; - ret |= SSMSaveRGBOGOValue ( 52, 2, usuc.c ); + usuc.s = params.b_gain; + ret |= SSMSaveRGBOGOValue(52, 2, usuc.c); - suc.s = params.r_post_offset; - ret |= SSMSaveRGBOGOValue ( 54, 2, suc.c ); + suc.s = params.r_post_offset; + ret |= SSMSaveRGBOGOValue(54, 2, suc.c); - suc.s = params.g_post_offset; - ret |= SSMSaveRGBOGOValue ( 56, 2, suc.c ); + suc.s = params.g_post_offset; + ret |= SSMSaveRGBOGOValue(56, 2, suc.c); - suc.s = params.b_post_offset; - ret |= SSMSaveRGBOGOValue ( 58, 2, suc.c ); - } + suc.s = params.b_post_offset; + ret |= SSMSaveRGBOGOValue(58, 2, suc.c); + } - LOGD ( "%s, rgain[%d], ggain[%d],bgain[%d],roffset[%d],goffset[%d],boffset[%d]\n", __FUNCTION__, params.r_gain, params.g_gain, - params.b_gain, params.r_post_offset, params.g_post_offset, params.b_post_offset ); - return ret; + LOGD("%s, rgain[%d], ggain[%d],bgain[%d],roffset[%d],goffset[%d],boffset[%d]\n", __FUNCTION__, + params.r_gain, params.g_gain, params.b_gain, params.r_post_offset, + params.g_post_offset, params.b_post_offset); + return ret; } -int CVpp::CheckColorTemperatureParams ( void ) -{ - int i = 0; - tcon_rgb_ogo_t rgbogo; +int CVpp::CheckColorTemperatureParams(void) { + int i = 0; + tcon_rgb_ogo_t rgbogo; - for ( i = 0; i < 3; i++ ) { - ReadColorTemperatureParams ( ( vpp_color_temperature_mode_t ) i, &rgbogo ); + for (i = 0; i < 3; i++) { + ReadColorTemperatureParams((vpp_color_temperature_mode_t) i, &rgbogo); - if ( rgbogo.r_gain > 2047 || rgbogo.b_gain > 2047 || rgbogo.g_gain > 2047 - || rgbogo.r_gain < 0 || rgbogo.b_gain < 0 || rgbogo.g_gain < 0 ) { - if ( rgbogo.r_post_offset > 1023 || rgbogo.g_post_offset > 1023 || rgbogo.b_post_offset > 1023 - || rgbogo.r_post_offset < -1024 || rgbogo.g_post_offset < -1024 || rgbogo.b_post_offset < -1024 ) { - return 0; - } - } - } + if (rgbogo.r_gain > 2047 || rgbogo.b_gain > 2047 || rgbogo.g_gain > 2047 || rgbogo.r_gain + < 0 || rgbogo.b_gain < 0 || rgbogo.g_gain < 0) { + if (rgbogo.r_post_offset > 1023 || rgbogo.g_post_offset > 1023 || rgbogo.b_post_offset + > 1023 || rgbogo.r_post_offset < -1024 || rgbogo.g_post_offset < -1024 + || rgbogo.b_post_offset < -1024) { + return 0; + } + } + } - return 1; + return 1; } -int CVpp::RestoeColorTemperatureParamsFromDB ( tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt ) -{ - int i = 0; - tcon_rgb_ogo_t rgbogo; +int CVpp::RestoeColorTemperatureParamsFromDB(tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, + tvin_trans_fmt_t trans_fmt) { + int i = 0; + tcon_rgb_ogo_t rgbogo; - LOGD ( "%s, restore color temperature params from DB.\n", __FUNCTION__ ); + LOGD("%s, restore color temperature params from DB.\n", __FUNCTION__); - for ( i = 0; i < 3; i++ ) { - mpPqData->PQ_GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) i, source_port, sig_fmt, trans_fmt, &rgbogo ); - SaveColorTemperatureParams ( ( vpp_color_temperature_mode_t ) i, rgbogo ); - } + for (i = 0; i < 3; i++) { + mpPqData->PQ_GetColorTemperatureParams((vpp_color_temperature_mode_t) i, source_port, + sig_fmt, trans_fmt, &rgbogo); + SaveColorTemperatureParams((vpp_color_temperature_mode_t) i, rgbogo); + } - SetColorTempParamsChecksum(); + SetColorTempParamsChecksum(); - return 0; + return 0; } -int CVpp::CheckColorTemperatureParamAlldata ( tvin_port_t source_port , tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt ) -{ - if ( CheckTempDataLable() && ( CalColorTemperatureParamsChecksum() == GetColorTempParamsChecksum() ) ) { - LOGD ( "%s, color temperature param lable & checksum ok.\n", __FUNCTION__ ); +int CVpp::CheckColorTemperatureParamAlldata(tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, + tvin_trans_fmt_t trans_fmt) { + if (CheckTempDataLable() && (CalColorTemperatureParamsChecksum() + == GetColorTempParamsChecksum())) { + LOGD("%s, color temperature param lable & checksum ok.\n", __FUNCTION__); - if ( CheckColorTemperatureParams() == 0 ) { - LOGD ( "%s, color temperature params check failed.\n", __FUNCTION__ ); - RestoeColorTemperatureParamsFromDB(source_port, sig_fmt, trans_fmt); - } - } else { - LOGD ( "%s, color temperature param data error.\n", __FUNCTION__ ); + if (CheckColorTemperatureParams() == 0) { + LOGD("%s, color temperature params check failed.\n", __FUNCTION__); + RestoeColorTemperatureParamsFromDB(source_port, sig_fmt, trans_fmt); + } + } else { + LOGD("%s, color temperature param data error.\n", __FUNCTION__); - SetTempDataLable(); - RestoeColorTemperatureParamsFromDB(source_port, sig_fmt, trans_fmt); - } + SetTempDataLable(); + RestoeColorTemperatureParamsFromDB(source_port, sig_fmt, trans_fmt); + } - return 0; + return 0; } -int CVpp::Tv_FactorySetColorTemp_Rgain ( int source_type, int colortemp_mode, int rgain ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySetColorTemp_Rgain(int source_type, int colortemp_mode, int rgain) { + tcon_rgb_ogo_t rgbogo; - GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ); - rgbogo.r_gain = rgain; - LOGD ( "%s, source_type[%d], colortemp_mode[%d], rgain[%d].", __FUNCTION__, source_type, colortemp_mode, rgain ); - rgbogo.en = 1; + GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); + rgbogo.r_gain = rgain; + LOGD("%s, source_type[%d], colortemp_mode[%d], rgain[%d].", __FUNCTION__, source_type, + colortemp_mode, rgain); + rgbogo.en = 1; - if ( VPP_SetRGBOGO ( &rgbogo ) == 0 ) { - return 0; - } + if (VPP_SetRGBOGO(&rgbogo) == 0) { + return 0; + } - return -1; + return -1; } -int CVpp::Tv_FactorySaveColorTemp_Rgain ( int source_type, int colortemp_mode, int rgain ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySaveColorTemp_Rgain(int source_type, int colortemp_mode, int rgain) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - rgbogo.r_gain = rgain; - return SetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, rgbogo ); - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + rgbogo.r_gain = rgain; + return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); + } - LOGE ( "Tv_FactorySaveColorTemp_Rgain error!\n" ); - return -1; + LOGE("FactorySaveColorTemp_Rgain error!\n"); + return -1; } -int CVpp::Tv_FactoryGetColorTemp_Rgain ( int source_type, int colortemp_mode ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactoryGetColorTemp_Rgain(int source_type, int colortemp_mode) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - return rgbogo.r_gain; - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + return rgbogo.r_gain; + } - LOGE ( "Tv_FactoryGetColorTemp_Rgain error!\n" ); - return -1; + LOGE("FactoryGetColorTemp_Rgain error!\n"); + return -1; } -int CVpp::Tv_FactorySetColorTemp_Ggain ( int source_type, int colortemp_mode, int ggain ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySetColorTemp_Ggain(int source_type, int colortemp_mode, int ggain) { + tcon_rgb_ogo_t rgbogo; - GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ); - rgbogo.g_gain = ggain; - LOGD ( "%s, source_type[%d], colortemp_mode[%d], ggain[%d].", __FUNCTION__, source_type, colortemp_mode, ggain ); - rgbogo.en = 1; + GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); + rgbogo.g_gain = ggain; + LOGD("%s, source_type[%d], colortemp_mode[%d], ggain[%d].", __FUNCTION__, source_type, + colortemp_mode, ggain); + rgbogo.en = 1; - if ( VPP_SetRGBOGO ( &rgbogo ) == 0 ) { - return 0; - } + if (VPP_SetRGBOGO(&rgbogo) == 0) { + return 0; + } - return -1; + return -1; } -int CVpp::Tv_FactorySaveColorTemp_Ggain ( int source_type, int colortemp_mode, int ggain ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySaveColorTemp_Ggain(int source_type, int colortemp_mode, int ggain) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - rgbogo.g_gain = ggain; - return SetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, rgbogo ); - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + rgbogo.g_gain = ggain; + return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); + } - LOGE ( "Tv_FactorySaveColorTemp_Ggain error!\n" ); - return -1; + LOGE("FactorySaveColorTemp_Ggain error!\n"); + return -1; } -int CVpp::Tv_FactoryGetColorTemp_Ggain ( int source_type, int colortemp_mode ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactoryGetColorTemp_Ggain(int source_type, int colortemp_mode) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - return rgbogo.g_gain; - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + return rgbogo.g_gain; + } - LOGE ( "Tv_FactoryGetColorTemp_Ggain error!\n" ); - return -1; + LOGE("FactoryGetColorTemp_Ggain error!\n"); + return -1; } -int CVpp::Tv_FactorySetColorTemp_Bgain ( int source_type, int colortemp_mode, int bgain ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySetColorTemp_Bgain(int source_type, int colortemp_mode, int bgain) { + tcon_rgb_ogo_t rgbogo; - GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ); - rgbogo.b_gain = bgain; - LOGD ( "%s, source_type[%d], colortemp_mode[%d], bgain[%d].", __FUNCTION__, source_type, colortemp_mode, bgain ); - rgbogo.en = 1; + GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); + rgbogo.b_gain = bgain; + LOGD("%s, source_type[%d], colortemp_mode[%d], bgain[%d].", __FUNCTION__, source_type, + colortemp_mode, bgain); + rgbogo.en = 1; - if ( VPP_SetRGBOGO ( &rgbogo ) == 0 ) { - return 0; - } + if (VPP_SetRGBOGO(&rgbogo) == 0) { + return 0; + } - return -1; + return -1; } -int CVpp::Tv_FactorySaveColorTemp_Bgain ( int source_type, int colortemp_mode, int bgain ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySaveColorTemp_Bgain(int source_type, int colortemp_mode, int bgain) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - rgbogo.b_gain = bgain; - return SetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, rgbogo ); - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + rgbogo.b_gain = bgain; + return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); + } - LOGE ( "Tv_FactorySaveColorTemp_Bgain error!\n" ); - return -1; + LOGE("FactorySaveColorTemp_Bgain error!\n"); + return -1; } -int CVpp::Tv_FactoryGetColorTemp_Bgain ( int source_type, int colortemp_mode ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactoryGetColorTemp_Bgain(int source_type, int colortemp_mode) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - return rgbogo.b_gain; - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + return rgbogo.b_gain; + } - LOGE ( "Tv_FactoryGetColorTemp_Bgain error!\n" ); - return -1; + LOGE("FactoryGetColorTemp_Bgain error!\n"); + return -1; } -int CVpp::Tv_FactorySetColorTemp_Roffset ( int source_type, int colortemp_mode, int roffset ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySetColorTemp_Roffset(int source_type, int colortemp_mode, int roffset) { + tcon_rgb_ogo_t rgbogo; - GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ); - rgbogo.r_post_offset = roffset; - LOGD ( "%s, source_type[%d], colortemp_mode[%d], r_post_offset[%d].", __FUNCTION__, source_type, colortemp_mode, roffset ); - rgbogo.en = 1; + GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); + rgbogo.r_post_offset = roffset; + LOGD("%s, source_type[%d], colortemp_mode[%d], r_post_offset[%d].", __FUNCTION__, source_type, + colortemp_mode, roffset); + rgbogo.en = 1; - if ( VPP_SetRGBOGO ( &rgbogo ) == 0 ) { - return 0; - } + if (VPP_SetRGBOGO(&rgbogo) == 0) { + return 0; + } - return -1; + return -1; } -int CVpp::Tv_FactorySaveColorTemp_Roffset ( int source_type, int colortemp_mode, int roffset ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySaveColorTemp_Roffset(int source_type, int colortemp_mode, int roffset) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - rgbogo.r_post_offset = roffset; - return SetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, rgbogo ); - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + rgbogo.r_post_offset = roffset; + return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); + } - LOGE ( "Tv_FactorySaveColorTemp_Roffset error!\n" ); - return -1; + LOGE("FactorySaveColorTemp_Roffset error!\n"); + return -1; } -int CVpp::Tv_FactoryGetColorTemp_Roffset ( int source_type, int colortemp_mode ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactoryGetColorTemp_Roffset(int source_type, int colortemp_mode) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - return rgbogo.r_post_offset; - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + return rgbogo.r_post_offset; + } - LOGE ( "Tv_FactoryGetColorTemp_Roffset error!\n" ); - return -1; + LOGE("FactoryGetColorTemp_Roffset error!\n"); + return -1; } -int CVpp::Tv_FactorySetColorTemp_Goffset ( int source_type, int colortemp_mode, int goffset ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySetColorTemp_Goffset(int source_type, int colortemp_mode, int goffset) { + tcon_rgb_ogo_t rgbogo; - GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ); - rgbogo.g_post_offset = goffset; - LOGD ( "%s, source_type[%d], colortemp_mode[%d], g_post_offset[%d].", __FUNCTION__, source_type, colortemp_mode, goffset ); - rgbogo.en = 1; + GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); + rgbogo.g_post_offset = goffset; + LOGD("%s, source_type[%d], colortemp_mode[%d], g_post_offset[%d].", __FUNCTION__, source_type, + colortemp_mode, goffset); + rgbogo.en = 1; - if ( VPP_SetRGBOGO ( &rgbogo ) == 0 ) { - return 0; - } + if (VPP_SetRGBOGO(&rgbogo) == 0) { + return 0; + } - return -1; + return -1; } -int CVpp::Tv_FactorySaveColorTemp_Goffset ( int source_type, int colortemp_mode, int goffset ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySaveColorTemp_Goffset(int source_type, int colortemp_mode, int goffset) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - rgbogo.g_post_offset = goffset; - return SetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, rgbogo ); - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + rgbogo.g_post_offset = goffset; + return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); + } - LOGE ( "Tv_FactorySaveColorTemp_Goffset error!\n" ); - return -1; + LOGE("FactorySaveColorTemp_Goffset error!\n"); + return -1; } -int CVpp::Tv_FactoryGetColorTemp_Goffset ( int source_type, int colortemp_mode ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactoryGetColorTemp_Goffset(int source_type, int colortemp_mode) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - return rgbogo.g_post_offset; - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + return rgbogo.g_post_offset; + } - LOGE ( "Tv_FactoryGetColorTemp_Goffset error!\n" ); - return -1; + LOGE("FactoryGetColorTemp_Goffset error!\n"); + return -1; } -int CVpp::Tv_FactorySetColorTemp_Boffset ( int source_type, int colortemp_mode, int boffset ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySetColorTemp_Boffset(int source_type, int colortemp_mode, int boffset) { + tcon_rgb_ogo_t rgbogo; - GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ); - rgbogo.b_post_offset = boffset; - LOGD ( "%s, source_type[%d], colortemp_mode[%d], b_post_offset[%d].", __FUNCTION__, source_type, colortemp_mode, boffset ); - rgbogo.en = 1; + GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); + rgbogo.b_post_offset = boffset; + LOGD("%s, source_type[%d], colortemp_mode[%d], b_post_offset[%d].", __FUNCTION__, source_type, + colortemp_mode, boffset); + rgbogo.en = 1; - if ( VPP_SetRGBOGO ( &rgbogo ) == 0 ) { - return 0; - } + if (VPP_SetRGBOGO(&rgbogo) == 0) { + return 0; + } - return -1; + return -1; } -int CVpp::Tv_FactorySaveColorTemp_Boffset ( int source_type, int colortemp_mode, int boffset ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactorySaveColorTemp_Boffset(int source_type, int colortemp_mode, int boffset) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - rgbogo.b_post_offset = boffset; - return SetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, rgbogo ); - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + rgbogo.b_post_offset = boffset; + return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); + } - LOGE ( "Tv_FactorySaveColorTemp_Boffset error!\n" ); - return -1; + LOGE("FactorySaveColorTemp_Boffset error!\n"); + return -1; } -int CVpp::Tv_FactoryGetColorTemp_Boffset ( int source_type, int colortemp_mode ) -{ - tcon_rgb_ogo_t rgbogo; +int CVpp::FactoryGetColorTemp_Boffset(int source_type, int colortemp_mode) { + tcon_rgb_ogo_t rgbogo; - if ( 0 == GetColorTemperatureParams ( ( vpp_color_temperature_mode_t ) colortemp_mode, &rgbogo ) ) { - return rgbogo.b_post_offset; - } + if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { + return rgbogo.b_post_offset; + } - LOGE ( "Tv_FactoryGetColorTemp_Boffset error!\n" ); - return -1; + LOGE("FactoryGetColorTemp_Boffset error!\n"); + return -1; } -int CVpp::Tv_FactoryGetTestPattern ( void ) -{ - unsigned char data = VPP_TEST_PATTERN_NONE; - SSMReadTestPattern ( &data ); - return data; +int CVpp::FactoryGetTestPattern(void) { + unsigned char data = VPP_TEST_PATTERN_NONE; + SSMReadTestPattern(&data); + return data; } -int CVpp::Tv_FactoryResetPQMode ( void ) -{ - mpPqData->PQ_ResetAllPQModeParams(); - return 0; +int CVpp::FactoryResetPQMode(void) { + mpPqData->PQ_ResetAllPQModeParams(); + return 0; } -int CVpp::Tv_FactoryResetNonlinear ( void ) -{ - mpPqData->PQ_ResetAllNoLineParams(); - return 0; +int CVpp::FactoryResetNonlinear(void) { + mpPqData->PQ_ResetAllNoLineParams(); + return 0; } -int CVpp::Tv_FactoryResetColorTemp ( void ) -{ - mpPqData->PQ_ResetAllColorTemperatureParams(); - return 0; +int CVpp::FactoryResetColorTemp(void) { + mpPqData->PQ_ResetAllColorTemperatureParams(); + return 0; } -int CVpp::Tv_FactorySetParamsDefault ( void ) -{ - Tv_FactoryResetPQMode(); - Tv_FactoryResetNonlinear(); - Tv_FactoryResetColorTemp(); - mpPqData->PQ_ResetAllOverscanParams(); - return 0; +int CVpp::FactorySetParamsDefault(void) { + FactoryResetPQMode(); + FactoryResetNonlinear(); + FactoryResetColorTemp(); + mpPqData->PQ_ResetAllOverscanParams(); + return 0; } -int CVpp::Tv_FactorySetDDRSSC ( int step ) -{ - int ret = -1; +int CVpp::FactorySetDDRSSC(int step) { + int ret = -1; - switch ( step ) { - case 1: - // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac86" ); - break; + switch (step) { + case 1: + // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac86" ); + break; - case 2: - // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac85" ); - break; + case 2: + // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac85" ); + break; - case 3: - // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac75" ); - break; + case 3: + // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac75" ); + break; - case 4: - // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac65" ); - break; + case 4: + // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac65" ); + break; - case 5: - // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000acb3" ); - break; + case 5: + // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000acb3" ); + break; - case 0: - default: - // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac24" ); - break; - } + case 0: + default: + // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac24" ); + break; + } - if ( ret < 0 ) { - return -1; - } + if (ret < 0) { + return -1; + } - return SSMSaveDDRSSC ( step ); + return SSMSaveDDRSSC(step); } -int CVpp::Tv_FactoryGetDDRSSC ( void ) -{ - unsigned char data = 0; - SSMReadDDRSSC ( &data ); - return data; +int CVpp::FactoryGetDDRSSC(void) { + unsigned char data = 0; + SSMReadDDRSSC(&data); + return data; } -int CVpp::Tv_FactorySetLVDSSSC ( int step ) -{ - int ret = -1; - - switch ( step ) { - case 1: - // ret = Tv_MiscRegs ( "wc 0x109e 0x4d625012" ); - // ret |= Tv_MiscRegs ( "wc 0x109f 0x36130" ); - break; - - case 2: - // ret = Tv_MiscRegs ( "wc 0x109e 0x2d425012" ); - // ret |= Tv_MiscRegs ( "wc 0x109f 0x36130" ); - break; - - case 3: - // ret = Tv_MiscRegs ( "wc 0x109e 0x1d425012" ); - // ret |= Tv_MiscRegs ( "wc 0x109f 0x36130" ); - break; - - case 4: - // ret = Tv_MiscRegs ( "wc 0x109e 0x0d125012" ); - // ret |= Tv_MiscRegs ( "wc 0x109f 0x36130" ); - break; - - case 5: - // ret = Tv_MiscRegs ( "wc 0x109e 0x0e425012" ); - // ret |= Tv_MiscRegs ( "wc 0x109f 0x36130" ); - break; - - case 0: - default: - // ret = Tv_MiscRegs ( "wc 0x109e 0x6d625012" ); - // ret |= Tv_MiscRegs ( "wc 0x109f 0x36130" ); - break; - } - - if ( ret < 0 ) { - return -1; - } - - return SSMSaveLVDSSSC ( step ); +int CVpp::SetLVDSSSC(int step) { + int ret = -1; + if (step > 4) + step = 4; + ret = TvMisc_SetLVDSSSC(step); + return ret; } +int CVpp::FactorySetLVDSSSC(int step) { + int ret = -1; + unsigned char data[2] = {0,0}; + char cmd_tmp_1[128]; + int value = 0, panel_idx = 0, tmp = 0; + const char *PanelIdx; + if (step > 3) + step = 3; + + PanelIdx = config_get_str ( "TV", "get.panel.index", "0" ); + panel_idx = strtoul(PanelIdx, NULL, 10); + LOGD ("%s, panel_idx = %x",__FUNCTION__, panel_idx); + SSMReadLVDSSSC(data); + + //every 2 bits represent one panel, use 2 byte store 8 panels + value = (data[1]<<8)|data[0]; + step = step&0x03; + panel_idx = panel_idx*2; + tmp = 3 << panel_idx; + value = (value&(~tmp)) | (step << panel_idx); + data[0] = value & 0xFF; + data[1] = (value >> 8)& 0xFF; + LOGD ("%s, tmp = %x, save value = %x",__FUNCTION__, tmp,value); + + SetLVDSSSC(step); + return SSMSaveLVDSSSC(data); +} + +int CVpp::FactoryGetLVDSSSC(void) { + unsigned char data[2] = {0,0}; + int value = 0, panel_idx = 0; + const char *PanelIdx = config_get_str ( "TV", "get.panel.index", "0" ); + + panel_idx = strtoul(PanelIdx, NULL, 10); + SSMReadLVDSSSC(data); + value = (data[1]<<8)|data[0]; + value = (value >> (2 * panel_idx))&0x03; + LOGD ("%s, panel_idx = %x, value= %d",__FUNCTION__, panel_idx, value); + return value; +} + +noline_params_t CVpp::FactoryGetNolineParams(int type, int source_type) { + int ret = -1; + noline_params_t noline_params; + + memset(&noline_params, 0, sizeof(noline_params_t)); + + switch (type) { + case NOLINE_PARAMS_TYPE_BRIGHTNESS: + ret = mpPqData->PQ_GetNoLineAllBrightnessParams((tv_source_input_type_t) source_type, + &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, + &noline_params.osd75, &noline_params.osd100); + + case NOLINE_PARAMS_TYPE_CONTRAST: + ret = mpPqData->PQ_GetNoLineAllContrastParams((tv_source_input_type_t) source_type, + &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, + &noline_params.osd75, &noline_params.osd100); + + case NOLINE_PARAMS_TYPE_SATURATION: + ret = mpPqData->PQ_GetNoLineAllSaturationParams((tv_source_input_type_t) source_type, + &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, + &noline_params.osd75, &noline_params.osd100); + + case NOLINE_PARAMS_TYPE_HUE: + ret = mpPqData->PQ_GetNoLineAllHueParams((tv_source_input_type_t) source_type, + &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, + &noline_params.osd75, &noline_params.osd100); + + case NOLINE_PARAMS_TYPE_SHARPNESS: + ret = mpPqData->PQ_GetNoLineAllSharpnessParams((tv_source_input_type_t) source_type, + &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, + &noline_params.osd75, &noline_params.osd100); + + case NOLINE_PARAMS_TYPE_VOLUME: + ret = mpPqData->PQ_GetNoLineAllVolumeParams((tv_source_input_type_t) source_type, + &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, + &noline_params.osd75, &noline_params.osd100); + + default: + break; + } -int CVpp::Tv_FactoryGetLVDSSSC ( void ) -{ - unsigned char data = 0; - SSMReadLVDSSSC ( &data ); - return data; + return noline_params; } -noline_params_t CVpp::Tv_FactoryGetNolineParams ( int type, int source_type ) -{ - int ret = -1; - noline_params_t noline_params; - - memset ( &noline_params, 0, sizeof ( noline_params_t ) ); - - switch ( type ) { - case NOLINE_PARAMS_TYPE_BRIGHTNESS: - ret = mpPqData->PQ_GetNoLineAllBrightnessParams ( ( tv_source_input_type_t ) source_type, &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, &noline_params.osd75, &noline_params.osd100 ); - - case NOLINE_PARAMS_TYPE_CONTRAST: - ret = mpPqData->PQ_GetNoLineAllContrastParams ( ( tv_source_input_type_t ) source_type, &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, &noline_params.osd75, &noline_params.osd100 ); - - case NOLINE_PARAMS_TYPE_SATURATION: - ret = mpPqData->PQ_GetNoLineAllSaturationParams ( ( tv_source_input_type_t ) source_type, &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, &noline_params.osd75, &noline_params.osd100 ); - - case NOLINE_PARAMS_TYPE_HUE: - ret = mpPqData->PQ_GetNoLineAllHueParams ( ( tv_source_input_type_t ) source_type, &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, &noline_params.osd75, &noline_params.osd100 ); - - case NOLINE_PARAMS_TYPE_SHARPNESS: - ret = mpPqData->PQ_GetNoLineAllSharpnessParams ( ( tv_source_input_type_t ) source_type, &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, &noline_params.osd75, &noline_params.osd100 ); - - case NOLINE_PARAMS_TYPE_VOLUME: - ret = mpPqData->PQ_GetNoLineAllVolumeParams ( ( tv_source_input_type_t ) source_type, &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, &noline_params.osd75, &noline_params.osd100 ); +int CVpp::FactorySetNolineParams(int type, int source_type, noline_params_t noline_params) { + int ret = -1; - default: - break; - } + switch (type) { + case NOLINE_PARAMS_TYPE_BRIGHTNESS: + ret = mpPqData->PQ_SetNoLineAllBrightnessParams((tv_source_input_type_t) source_type, + noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, + noline_params.osd100); + break; + + case NOLINE_PARAMS_TYPE_CONTRAST: + ret = mpPqData->PQ_SetNoLineAllContrastParams((tv_source_input_type_t) source_type, + noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, + noline_params.osd100); + break; + + case NOLINE_PARAMS_TYPE_SATURATION: + ret = mpPqData->PQ_SetNoLineAllSaturationParams((tv_source_input_type_t) source_type, + noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, + noline_params.osd100); + + case NOLINE_PARAMS_TYPE_HUE: + ret = mpPqData->PQ_SetNoLineAllHueParams((tv_source_input_type_t) source_type, + noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, + noline_params.osd100); + + case NOLINE_PARAMS_TYPE_SHARPNESS: + ret = mpPqData->PQ_SetNoLineAllSharpnessParams((tv_source_input_type_t) source_type, + noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, + noline_params.osd100); + + case NOLINE_PARAMS_TYPE_VOLUME: + ret = mpPqData->PQ_SetNoLineAllVolumeParams((tv_source_input_type_t) source_type, + noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, + noline_params.osd100); + + default: + break; + } - return noline_params; + return ret; } -int CVpp::Tv_FactorySetNolineParams ( int type, int source_type, noline_params_t noline_params ) -{ - int ret = -1; - - switch ( type ) { - case NOLINE_PARAMS_TYPE_BRIGHTNESS: - ret = mpPqData->PQ_SetNoLineAllBrightnessParams ( ( tv_source_input_type_t ) source_type, noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, noline_params.osd100 ); - break; - - case NOLINE_PARAMS_TYPE_CONTRAST: - ret = mpPqData->PQ_SetNoLineAllContrastParams ( ( tv_source_input_type_t ) source_type, noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, noline_params.osd100 ); - break; +int CVpp::FactorySetOverscan(int source_type, int fmt, int status_3d, int trans_fmt, + tvin_cutwin_t cutwin_t) { + int ret = -1; + ret = mpPqData->PQ_SetOverscanParams((tv_source_input_type_t) source_type, + (tvin_sig_fmt_t) fmt, INDEX_2D, (tvin_trans_fmt_t) trans_fmt, cutwin_t); - case NOLINE_PARAMS_TYPE_SATURATION: - ret = mpPqData->PQ_SetNoLineAllSaturationParams ( ( tv_source_input_type_t ) source_type, noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, noline_params.osd100 ); + if (ret == 0) { + } else { + LOGE("%s, PQ_SetOverscanParams fail.\n", __FUNCTION__); + } + return ret; +} - case NOLINE_PARAMS_TYPE_HUE: - ret = mpPqData->PQ_SetNoLineAllHueParams ( ( tv_source_input_type_t ) source_type, noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, noline_params.osd100 ); +tvin_cutwin_t CVpp::FactoryGetOverscan(int source_type, int fmt, is_3d_type_t is3d, int trans_fmt) { + int ret = -1; + tvin_cutwin_t cutwin_t; + memset(&cutwin_t, 0, sizeof(cutwin_t)); - case NOLINE_PARAMS_TYPE_SHARPNESS: - ret = mpPqData->PQ_SetNoLineAllSharpnessParams ( ( tv_source_input_type_t ) source_type, noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, noline_params.osd100 ); + if (trans_fmt < TVIN_TFMT_2D || trans_fmt > TVIN_TFMT_3D_LDGD) { + return cutwin_t; + } - case NOLINE_PARAMS_TYPE_VOLUME: - ret = mpPqData->PQ_SetNoLineAllVolumeParams ( ( tv_source_input_type_t ) source_type, noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, noline_params.osd100 ); + ret = mpPqData->PQ_GetOverscanParams((tv_source_input_type_t) source_type, + (tvin_sig_fmt_t) fmt, is3d, (tvin_trans_fmt_t) trans_fmt, VPP_DISPLAY_MODE_169, + &cutwin_t); - default: - break; - } + if (ret == 0) { + } else { + LOGE("%s, PQ_GetOverscanParams faild.\n", __FUNCTION__); + } - return ret; + return cutwin_t; } -int CVpp::Tv_FactorySetOverscan ( int source_type, int fmt, int status_3d, int trans_fmt, tvin_cutwin_t cutwin_t ) -{ - int ret = -1; - ret = mpPqData->PQ_SetOverscanParams ( ( tv_source_input_type_t ) source_type, ( tvin_sig_fmt_t ) fmt, INDEX_2D, ( tvin_trans_fmt_t ) trans_fmt, cutwin_t ); - - if ( ret == 0 ) { - } else { - LOGE ( "%s, PQ_SetOverscanParams fail.\n", __FUNCTION__ ); - } - return ret; +int CVpp::FactorySetBacklightPWM_Frequency(int freq) { + LOGD("%s,FactorySetBacklightPWM_Frequency set freq %d .\n", __FUNCTION__, freq); + return 1; } -tvin_cutwin_t CVpp::Tv_FactoryGetOverscan ( int source_type, int fmt, is_3d_type_t is3d, int trans_fmt ) -{ - int ret = -1; - tvin_cutwin_t cutwin_t; - memset ( &cutwin_t, 0, sizeof ( cutwin_t ) ); - - if ( trans_fmt < TVIN_TFMT_2D || trans_fmt > TVIN_TFMT_3D_LDGD ) { - return cutwin_t; - } - - ret = mpPqData->PQ_GetOverscanParams ( ( tv_source_input_type_t ) source_type, ( tvin_sig_fmt_t ) fmt, is3d, ( tvin_trans_fmt_t ) trans_fmt, VPP_DISPLAY_MODE_169, &cutwin_t ); - - if ( ret == 0 ) { - } else { - LOGE ( "%s, PQ_GetOverscanParams faild.\n", __FUNCTION__ ); - } - - return cutwin_t; +int CVpp::FactoryGetBacklightPWM_Frequency(void) { + int freq = 50; + LOGD("%s,FactoryGetBacklightPWM_Frequency set freq %d .\n", "TV", freq); + return freq; } -int CVpp::Tv_FactorySetBacklightPWM_Frequency ( int freq ) -{ - LOGD("%s,Tv_FactorySetBacklightPWM_Frequency set freq %d .\n", __FUNCTION__, freq); - return 1; +int CVpp::FactorySetBacklight_Switch_status(int status) { + LOGD("%s,FactorySetBacklight_Switch_status set status %d .\n", __FUNCTION__, status); + return 1; } -int CVpp::Tv_FactoryGetBacklightPWM_Frequency ( void ) -{ - int freq = 50; - LOGD("%s,Tv_FactoryGetBacklightPWM_Frequency set freq %d .\n", "TV", freq); - return freq; +int CVpp::FactoryGetBacklight_Switch_status(void) { + int status = 1; + LOGD("%s,FactoryGetBacklight_Switch_status get status %d .\n", __FUNCTION__, status); + return status; } -int CVpp::Tv_FactorySetBacklight_Switch_status ( int status ) -{ - LOGD("%s,Tv_FactorySetBacklight_Switch_status set status %d .\n", __FUNCTION__, status); - return 1; +int CVpp::FactorySetBacklightPWM_Duty(int duty) { + LOGD("%s,FactorySetBacklight_Switch_status set duty %d .\n", __FUNCTION__, duty); + return 1; } -int CVpp::Tv_FactoryGetBacklight_Switch_status ( void ) -{ - int status = 1; - LOGD("%s,Tv_FactoryGetBacklight_Switch_status get status %d .\n", __FUNCTION__, status); - return status; +int CVpp::FactoryGetBacklightPWM_Duty(void) { + int duty = 1; + LOGD("%s,FactoryGetBacklight_Switch_status get duty %d .\n", __FUNCTION__, duty); + return duty; } -int CVpp::Tv_FactorySetBacklightPWM_Duty ( int duty ) -{ - LOGD("%s,Tv_FactorySetBacklight_Switch_status set duty %d .\n", __FUNCTION__, duty); - return 1; +int CVpp::FactorySetLVDS_ColorDepth(int depth) { + LOGD("%s,FactorySetLVDS_ColorDepth set depth %d .\n", "TV", depth); + return 1; } -int CVpp::Tv_FactoryGetBacklightPWM_Duty ( void ) -{ - int duty = 1; - LOGD("%s,Tv_FactoryGetBacklight_Switch_status get duty %d .\n", __FUNCTION__, duty); - return duty; +int CVpp::FactoryGetLVDS_ColorDepth(void) { + int depth = 1; + LOGD("%s,FactorySetLVDS_ColorDepth get freq %d .\n", __FUNCTION__, depth); + return depth; } -int CVpp::Tv_FactorySetLVDS_ColorDepth ( int depth ) -{ - LOGD("%s,Tv_FactorySetLVDS_ColorDepth set depth %d .\n", "TV", depth); - return 1; +int CVpp::FactorySetLVDS_ColorDither_status(int status) { + LOGD("%s,FactorySetLVDS_ColorDither_status set status %d .\n", __FUNCTION__, status); + return 1; } -int CVpp::Tv_FactoryGetLVDS_ColorDepth ( void ) -{ - int depth = 1; - LOGD("%s,Tv_FactorySetLVDS_ColorDepth get freq %d .\n", __FUNCTION__, depth); - return depth; +int CVpp::FactoryGetLVDS_ColorDither_status(void) { + int status = 1; + LOGD("%s,FactoryGetLVDS_ColorDither_status get status %d .\n", __FUNCTION__, status); + return status; } -int CVpp::Tv_FactorySetLVDS_ColorDither_status ( int status ) -{ - LOGD("%s,Tv_FactorySetLVDS_ColorDither_status set status %d .\n", __FUNCTION__, status); - return 1; +int CVpp::FactorySetLVDS_Mapping_status(int status) { + LOGD("%s,FactorySetLVDS_Mapping_status set status %d .\n", __FUNCTION__, status); + return 1; } -int CVpp::Tv_FactoryGetLVDS_ColorDither_status ( void ) -{ - int status = 1; - LOGD("%s,Tv_FactoryGetLVDS_ColorDither_status get status %d .\n", __FUNCTION__, status); - return status; +int CVpp::FactoryGetLVDS_Mapping_status(void) { + int status = 1; + LOGD("%s,FactoryGetLVDS_Mapping_status get status %d .\n", __FUNCTION__, status); + return status; } -int CVpp::Tv_FactorySetLVDS_Mapping_status ( int status ) -{ - LOGD("%s,Tv_FactorySetLVDS_Mapping_status set status %d .\n", __FUNCTION__, status); - return 1; +int CVpp::FactorySetLVDS_PortSwap_status(int status) { + LOGD("%s,FactorySetLVDS_PortSwap_status set status %d .\n", __FUNCTION__, status); + return 1; } -int CVpp::Tv_FactoryGetLVDS_Mapping_status ( void ) -{ - int status = 1; - LOGD("%s,Tv_FactoryGetLVDS_Mapping_status get status %d .\n", __FUNCTION__, status); - return status; +int CVpp::FactoryGetLVDS_PortSwap_status(void) { + int status = 1; + LOGD("%s,FactoryGetLVDS_PortSwap_status get status %d .\n", __FUNCTION__, status); + return status; } -int CVpp::Tv_FactorySetLVDS_PortSwap_status ( int status ) -{ - LOGD("%s,Tv_FactorySetLVDS_PortSwap_status set status %d .\n", __FUNCTION__, status); - return 1; +int CVpp::VPPSSMRestoreDefault() { + int i = 0, tmp_val = 0; + int tmp_panorama_nor = 0, tmp_panorama_full = 0; + int offset_r = 0, offset_g = 0, offset_b = 0, gain_r = 1024, gain_g = 1024, gain_b = 1024; + int8_t std_buf[6] = { 0, 0, 0, 0, 0, 0 }; + int8_t warm_buf[6] = { 0, 0, -8, 0, 0, 0 }; + int8_t cold_buf[6] = { -8, 0, 0, 0, 0, 0 }; + unsigned char tmp[2] = {0, 0}; + + SSMSaveColorDemoMode ( VPP_COLOR_DEMO_MODE_ALLON); + SSMSaveColorBaseMode ( VPP_COLOR_BASE_MODE_OPTIMIZE); + SSMSaveRGBGainRStart(0, gain_r); + SSMSaveRGBGainGStart(0, gain_g); + SSMSaveRGBGainBStart(0, gain_b); + SSMSaveRGBPostOffsetRStart(0, offset_r); + SSMSaveRGBPostOffsetGStart(0, offset_g); + SSMSaveRGBPostOffsetBStart(0, offset_b); + SSMSaveUserNatureLightSwitch(1); + SSMSaveGammaValue(0); + SSMSaveGraphyBacklight(100); + SSMSaveDBCStart(0); + SSMSaveDnlpStart(0); //0: ON,1: OFF,default is on + SSMSaveAPL(30); + SSMSaveAPL2(30); + SSMSaveBD(30); + SSMSaveBP(30); + + SSMSaveFBCELECmodeVal(11); + SSMSaveFBCN360BackLightVal(10); + SSMSaveFBCN360ColorTempVal(1); // standard colortemp + + SSMSaveFBCN310ColorTempVal(0); + SSMSaveFBCN310LightsensorVal(0); + SSMSaveFBCN310Dream_PanelVal(1); + SSMSaveFBCN310MULT_PQVal(1); + SSMSaveFBCN310MEMCVal(2); + SSMSaveFBCN310BackLightVal(254); + for (i = 0; i < 6; i++) { + SSMSaveRGBValueStart(i + VPP_COLOR_TEMPERATURE_MODE_STANDARD * 6, std_buf[i]); //0~5 + SSMSaveRGBValueStart(i + VPP_COLOR_TEMPERATURE_MODE_WARM * 6, warm_buf[i]); //6~11 + SSMSaveRGBValueStart(i + VPP_COLOR_TEMPERATURE_MODE_COLD * 6, cold_buf[i]); //12~17 + } + + for (i = 0; i < SOURCE_TYPE_MAX; i++) { + if (i == SOURCE_TYPE_HDMI) { + SSMSaveColorSpaceStart ( VPP_COLOR_SPACE_AUTO); + } + + tmp_val = VPP_COLOR_TEMPERATURE_MODE_STANDARD; + tmp_panorama_nor = VPP_PANORAMA_MODE_NORMAL; + tmp_panorama_full = VPP_PANORAMA_MODE_FULL; + + if (i == SOURCE_TYPE_HDMI) { + SSMSavePanoramaStart(i, tmp_panorama_full); + } else { + SSMSavePanoramaStart(i, tmp_panorama_nor); + } + + SSMSaveColorTemperature(i, tmp_val); + tmp_val = 50; + SSMSaveBrightness(i, tmp_val); + SSMSaveContrast(i, tmp_val); + SSMSaveSaturation(i, tmp_val); + SSMSaveHue(i, tmp_val); + SSMSaveSharpness(i, tmp_val); + tmp_val = VPP_PICTURE_MODE_STANDARD; + SSMSavePictureMode(i, tmp_val); + tmp_val = VPP_DISPLAY_MODE_169; + SSMSaveDisplayMode(i, tmp_val); + tmp_val = VPP_NOISE_REDUCTION_MODE_AUTO; + SSMSaveNoiseReduction(i, tmp_val); + tmp_val = 100; + SSMSaveBackLightVal(i, tmp_val); + } + + SSMSaveDDRSSC(0); + SSMSaveLVDSSSC(tmp); + return 0; } -int CVpp::Tv_FactoryGetLVDS_PortSwap_status ( void ) -{ - int status = 1; - LOGD("%s,Tv_FactoryGetLVDS_PortSwap_status get status %d .\n", __FUNCTION__, status); - return status; +int CVpp::VPPSSMFacRestoreDefault() { + return VPPSSMRestoreDefault(); } -int CVpp::VPPSSMRestoreDefault() -{ - int i = 0, tmp_val = 0; - int tmp_panorama_nor = 0, tmp_panorama_full = 0; - int offset_r = 0, offset_g = 0, offset_b = 0, gain_r = 1024, gain_g = 1024, gain_b = 1024; - int8_t std_buf[6] = {0, 0, 0, 0, 0, 0}; - int8_t warm_buf[6] = {0, 0, -8, 0, 0, 0}; - int8_t cold_buf[6] = { -8, 0, 0, 0, 0, 0}; - SSMSaveColorDemoMode ( VPP_COLOR_DEMO_MODE_ALLON ); - SSMSaveColorBaseMode ( VPP_COLOR_BASE_MODE_OPTIMIZE ); - SSMSaveRGBGainRStart ( 0, gain_r ); - SSMSaveRGBGainGStart ( 0, gain_g ); - SSMSaveRGBGainBStart ( 0, gain_b ); - SSMSaveRGBPostOffsetRStart ( 0, offset_r ); - SSMSaveRGBPostOffsetGStart ( 0, offset_g ); - SSMSaveRGBPostOffsetBStart ( 0, offset_b ); - SSMSaveUserNatureLightSwitch ( 1 ); - SSMSaveGammaValue ( 0 ); - SSMSaveGraphyBacklight ( 100 ); - SSMSaveDBCStart ( 0 ); - SSMSaveDnlpStart ( 0 ); //0: ON,1: OFF,default is on - SSMSaveAPL ( 30 ); - SSMSaveAPL2 ( 30 ); - SSMSaveBD ( 30 ); - SSMSaveBP ( 30 ); - - SSMSaveFBCELECmodeVal(11); - SSMSaveFBCN360BackLightVal(10); - SSMSaveFBCN360ColorTempVal(1); // standard colortemp - - for ( i = 0; i < 6; i++ ) { - SSMSaveRGBValueStart ( i + VPP_COLOR_TEMPERATURE_MODE_STANDARD * 6 , std_buf[i] ); //0~5 - SSMSaveRGBValueStart ( i + VPP_COLOR_TEMPERATURE_MODE_WARM * 6, warm_buf[i] ); //6~11 - SSMSaveRGBValueStart ( i + VPP_COLOR_TEMPERATURE_MODE_COLD * 6, cold_buf[i] ); //12~17 - } - - for ( i = 0; i < SOURCE_TYPE_MAX; i++ ) { - if ( i == SOURCE_TYPE_HDMI ) { - SSMSaveColorSpaceStart ( VPP_COLOR_SPACE_AUTO ); - } - - tmp_val = VPP_COLOR_TEMPERATURE_MODE_STANDARD; - tmp_panorama_nor = VPP_PANORAMA_MODE_NORMAL; - tmp_panorama_full = VPP_PANORAMA_MODE_FULL; - - if ( i == SOURCE_TYPE_HDMI ) { - SSMSavePanoramaStart ( i, tmp_panorama_full ); - } else { - SSMSavePanoramaStart ( i, tmp_panorama_nor ); - } - - SSMSaveColorTemperature ( i, tmp_val ); - tmp_val = 50; - SSMSaveBrightness ( i, tmp_val ); - SSMSaveContrast ( i, tmp_val ); - SSMSaveSaturation ( i, tmp_val ); - SSMSaveHue ( i, tmp_val ); - SSMSaveSharpness ( i, tmp_val ); - tmp_val = VPP_PICTURE_MODE_STANDARD; - SSMSavePictureMode ( i, tmp_val ); - tmp_val = VPP_DISPLAY_MODE_169; - SSMSaveDisplayMode ( i, tmp_val ); - tmp_val = VPP_NOISE_REDUCTION_MODE_MID; - SSMSaveNoiseReduction ( i, tmp_val ); - tmp_val = 100; - SSMSaveBackLightVal ( i, tmp_val ); - } - - SSMSaveDDRSSC ( 0 ); - SSMSaveLVDSSSC ( 0 ); - return 0; -} - -int CVpp::VPPSSMFacRestoreDefault() -{ - return VPPSSMRestoreDefault(); +int CVpp::SetRGBValue(vpp_color_temperature_mode_t temp_mode, unsigned char data_buf[]) { + int8_t r_gain = 0, b_gain = 0, g_gain = 0, r_offset = 0, g_offset = 0, b_offset = 0; + int ret = -1; + tcon_rgb_ogo_t rgbogo; + rgbogo.en = 1; + rgbogo.r_pre_offset = 0; + rgbogo.g_pre_offset = 0; + rgbogo.b_pre_offset = 0; + r_gain = data_buf[0]; + g_gain = data_buf[1]; + b_gain = data_buf[2]; + r_offset = data_buf[3]; + g_offset = data_buf[4]; + b_offset = data_buf[5]; + int mode = (int) temp_mode; + + switch (mode) { + case 1: + ret = SSMSaveRGBValueStart(0 + mode * 6, r_gain); + ret |= SSMSaveRGBValueStart(1 + mode * 6, g_gain); + ret |= SSMSaveRGBValueStart(2 + mode * 6, b_gain); + ret |= SSMSaveRGBValueStart(3 + mode * 6, r_offset); + ret |= SSMSaveRGBValueStart(4 + mode * 6, g_offset); + ret |= SSMSaveRGBValueStart(5 + mode * 6, b_offset); + break; + + case 2: + ret = SSMSaveRGBValueStart(0 + mode * 6, r_gain); + ret |= SSMSaveRGBValueStart(1 + mode * 6, g_gain); + ret |= SSMSaveRGBValueStart(2 + mode * 6, b_gain); + ret |= SSMSaveRGBValueStart(3 + mode * 6, r_offset); + ret |= SSMSaveRGBValueStart(4 + mode * 6, g_offset); + ret |= SSMSaveRGBValueStart(5 + mode * 6, b_offset); + break; + + case 0: + default: + ret = SSMSaveRGBValueStart(0, r_gain); + ret |= SSMSaveRGBValueStart(1, g_gain); + ret |= SSMSaveRGBValueStart(2, b_gain); + ret |= SSMSaveRGBValueStart(3, r_offset); + ret |= SSMSaveRGBValueStart(4, g_offset); + ret |= SSMSaveRGBValueStart(5, b_offset); + break; + } + + if (ret == 0) { + rgbogo.r_gain = RGBGainValueSSMToRisterMapping(r_gain + 128); + rgbogo.g_gain = RGBGainValueSSMToRisterMapping(g_gain + 128); + rgbogo.b_gain = RGBGainValueSSMToRisterMapping(b_gain + 128); + rgbogo.r_post_offset = RGBOffsetValueSSMToRisterMapping(r_offset); + rgbogo.g_post_offset = RGBOffsetValueSSMToRisterMapping(g_offset); + rgbogo.b_post_offset = RGBOffsetValueSSMToRisterMapping(b_offset); + ret |= VPP_SetRGBOGO(&rgbogo); + } + + return ret; } -int CVpp::Tv_SetRGBValue ( vpp_color_temperature_mode_t temp_mode, unsigned char data_buf[] ) -{ - int8_t r_gain = 0, b_gain = 0, g_gain = 0, r_offset = 0, g_offset = 0, b_offset = 0; - int ret = -1; - tcon_rgb_ogo_t rgbogo; - rgbogo.en = 1; - rgbogo.r_pre_offset = 0; - rgbogo.g_pre_offset = 0; - rgbogo.b_pre_offset = 0; - r_gain = data_buf[0]; - g_gain = data_buf[1]; - b_gain = data_buf[2]; - r_offset = data_buf[3]; - g_offset = data_buf[4]; - b_offset = data_buf[5]; - int mode = ( int ) temp_mode; - - switch ( mode ) { - case 1: - ret = SSMSaveRGBValueStart ( 0 + mode * 6, r_gain ); - ret |= SSMSaveRGBValueStart ( 1 + mode * 6, g_gain ); - ret |= SSMSaveRGBValueStart ( 2 + mode * 6, b_gain ); - ret |= SSMSaveRGBValueStart ( 3 + mode * 6, r_offset ); - ret |= SSMSaveRGBValueStart ( 4 + mode * 6, g_offset ); - ret |= SSMSaveRGBValueStart ( 5 + mode * 6, b_offset ); - break; - - case 2: - ret = SSMSaveRGBValueStart ( 0 + mode * 6, r_gain ); - ret |= SSMSaveRGBValueStart ( 1 + mode * 6, g_gain ); - ret |= SSMSaveRGBValueStart ( 2 + mode * 6, b_gain ); - ret |= SSMSaveRGBValueStart ( 3 + mode * 6, r_offset ); - ret |= SSMSaveRGBValueStart ( 4 + mode * 6, g_offset ); - ret |= SSMSaveRGBValueStart ( 5 + mode * 6, b_offset ); - break; - - case 0: - default: - ret = SSMSaveRGBValueStart ( 0, r_gain ); - ret |= SSMSaveRGBValueStart ( 1, g_gain ); - ret |= SSMSaveRGBValueStart ( 2, b_gain ); - ret |= SSMSaveRGBValueStart ( 3, r_offset ); - ret |= SSMSaveRGBValueStart ( 4, g_offset ); - ret |= SSMSaveRGBValueStart ( 5, b_offset ); - break; - } - - if ( ret == 0 ) { - rgbogo.r_gain = Tv_RGBGainValueSSMToRisterMapping ( r_gain + 128 ); - rgbogo.g_gain = Tv_RGBGainValueSSMToRisterMapping ( g_gain + 128 ); - rgbogo.b_gain = Tv_RGBGainValueSSMToRisterMapping ( b_gain + 128 ); - rgbogo.r_post_offset = Tv_RGBOffsetValueSSMToRisterMapping ( r_offset ); - rgbogo.g_post_offset = Tv_RGBOffsetValueSSMToRisterMapping ( g_offset ); - rgbogo.b_post_offset = Tv_RGBOffsetValueSSMToRisterMapping ( b_offset ); - ret |= VPP_SetRGBOGO ( &rgbogo ); - } - - return ret; -} - -int CVpp::Tv_GetRGBValue ( vpp_color_temperature_mode_t temp_mode, tcon_rgb_ogo_t *p_rgbogo ) -{ - int8_t r_gain = 0, b_gain = 0, g_gain = 0, r_offset = 0, g_offset = 0, b_offset = 0; - int ret = -1; - - p_rgbogo->en = 1; - p_rgbogo->r_pre_offset = 0; - p_rgbogo->g_pre_offset = 0; - p_rgbogo->b_pre_offset = 0; - p_rgbogo->r_gain = 0; - p_rgbogo->g_gain = 0; - p_rgbogo->b_gain = 0; - p_rgbogo->r_post_offset = 0; - p_rgbogo->g_post_offset = 0; - p_rgbogo->b_post_offset = 0; - int mode = ( int ) temp_mode; - - switch ( mode ) { - case 1: - ret = SSMReadRGBValueStart ( 0 + mode * 6, &r_gain ); - ret |= SSMReadRGBValueStart ( 1 + mode * 6, &g_gain ); - ret |= SSMReadRGBValueStart ( 2 + mode * 6, &b_gain ); - ret |= SSMReadRGBValueStart ( 3 + mode * 6, &r_offset ); - ret |= SSMReadRGBValueStart ( 4 + mode * 6, &g_offset ); - ret |= SSMReadRGBValueStart ( 5 + mode * 6, &b_offset ); - break; - - case 2: - ret = SSMReadRGBValueStart ( 0 + mode * 6, &r_gain ); - ret |= SSMReadRGBValueStart ( 1 + mode * 6, &g_gain ); - ret |= SSMReadRGBValueStart ( 2 + mode * 6, &b_gain ); - ret |= SSMReadRGBValueStart ( 3 + mode * 6, &r_offset ); - ret |= SSMReadRGBValueStart ( 4 + mode * 6, &g_offset ); - ret |= SSMReadRGBValueStart ( 5 + mode * 6, &b_offset ); - break; - - case 0: - default: - ret = SSMReadRGBValueStart ( 0, &r_gain ); - ret |= SSMReadRGBValueStart ( 1, &g_gain ); - ret |= SSMReadRGBValueStart ( 2, &b_gain ); - ret |= SSMReadRGBValueStart ( 3, &r_offset ); - ret |= SSMReadRGBValueStart ( 4, &g_offset ); - ret |= SSMReadRGBValueStart ( 5, &b_offset ); - break; - } - - p_rgbogo->r_gain = r_gain + 128; //r_gain:-128~127 - p_rgbogo->g_gain = g_gain + 128; - p_rgbogo->b_gain = b_gain + 128; - p_rgbogo->r_post_offset = r_offset; - p_rgbogo->g_post_offset = g_offset; - p_rgbogo->b_post_offset = b_offset; - - return ret; +int CVpp::GetRGBValue(vpp_color_temperature_mode_t temp_mode, tcon_rgb_ogo_t *p_rgbogo) { + int8_t r_gain = 0, b_gain = 0, g_gain = 0, r_offset = 0, g_offset = 0, b_offset = 0; + int ret = -1; + + p_rgbogo->en = 1; + p_rgbogo->r_pre_offset = 0; + p_rgbogo->g_pre_offset = 0; + p_rgbogo->b_pre_offset = 0; + p_rgbogo->r_gain = 0; + p_rgbogo->g_gain = 0; + p_rgbogo->b_gain = 0; + p_rgbogo->r_post_offset = 0; + p_rgbogo->g_post_offset = 0; + p_rgbogo->b_post_offset = 0; + int mode = (int) temp_mode; + + switch (mode) { + case 1: + ret = SSMReadRGBValueStart(0 + mode * 6, &r_gain); + ret |= SSMReadRGBValueStart(1 + mode * 6, &g_gain); + ret |= SSMReadRGBValueStart(2 + mode * 6, &b_gain); + ret |= SSMReadRGBValueStart(3 + mode * 6, &r_offset); + ret |= SSMReadRGBValueStart(4 + mode * 6, &g_offset); + ret |= SSMReadRGBValueStart(5 + mode * 6, &b_offset); + break; + + case 2: + ret = SSMReadRGBValueStart(0 + mode * 6, &r_gain); + ret |= SSMReadRGBValueStart(1 + mode * 6, &g_gain); + ret |= SSMReadRGBValueStart(2 + mode * 6, &b_gain); + ret |= SSMReadRGBValueStart(3 + mode * 6, &r_offset); + ret |= SSMReadRGBValueStart(4 + mode * 6, &g_offset); + ret |= SSMReadRGBValueStart(5 + mode * 6, &b_offset); + break; + + case 0: + default: + ret = SSMReadRGBValueStart(0, &r_gain); + ret |= SSMReadRGBValueStart(1, &g_gain); + ret |= SSMReadRGBValueStart(2, &b_gain); + ret |= SSMReadRGBValueStart(3, &r_offset); + ret |= SSMReadRGBValueStart(4, &g_offset); + ret |= SSMReadRGBValueStart(5, &b_offset); + break; + } + + p_rgbogo->r_gain = r_gain + 128; //r_gain:-128~127 + p_rgbogo->g_gain = g_gain + 128; + p_rgbogo->b_gain = b_gain + 128; + p_rgbogo->r_post_offset = r_offset; + p_rgbogo->g_post_offset = g_offset; + p_rgbogo->b_post_offset = b_offset; + + return ret; } #define PI 3.14159265358979 -void CVpp::video_set_saturation_hue ( signed char saturation, signed char hue, signed long *mab ) -{ - signed short ma = ( signed short ) ( cos ( ( float ) hue * PI / 128.0 ) * ( ( float ) saturation / 128.0 + 1.0 ) * 256.0 ); - signed short mb = ( signed short ) ( sin ( ( float ) hue * PI / 128.0 ) * ( ( float ) saturation / 128.0 + 1.0 ) * 256.0 ); - - if ( ma > 511 ) { - ma = 511; - } +void CVpp::video_set_saturation_hue(signed char saturation, signed char hue, signed long *mab) { + signed short ma = (signed short) (cos((float) hue * PI / 128.0) * ((float) saturation / 128.0 + + 1.0) * 256.0); + signed short mb = (signed short) (sin((float) hue * PI / 128.0) * ((float) saturation / 128.0 + + 1.0) * 256.0); + + if (ma > 511) { + ma = 511; + } - if ( ma < -512 ) { - ma = -512; - } + if (ma < -512) { + ma = -512; + } - if ( mb > 511 ) { - mb = 511; - } + if (mb > 511) { + mb = 511; + } - if ( mb < -512 ) { - mb = -512; - } + if (mb < -512) { + mb = -512; + } - *mab = ( ( ma & 0x3ff ) << 16 ) | ( mb & 0x3ff ); + *mab = ((ma & 0x3ff) << 16) | (mb & 0x3ff); } -void CVpp::video_get_saturation_hue ( signed char *sat, signed char *hue, signed long *mab ) -{ - signed long temp = *mab; - signed int ma = ( signed int ) ( ( temp << 6 ) >> 22 ); - signed int mb = ( signed int ) ( ( temp << 22 ) >> 22 ); - signed int sat16 = ( signed int ) ( ( sqrt ( ( ( float ) ma * ( float ) ma + ( float ) mb * ( float ) mb ) / 65536.0 ) - 1.0 ) * 128.0 ); - signed int hue16 = ( signed int ) ( atan ( ( float ) mb / ( float ) ma ) * 128.0 / PI ); +void CVpp::video_get_saturation_hue(signed char *sat, signed char *hue, signed long *mab) { + signed long temp = *mab; + signed int ma = (signed int) ((temp << 6) >> 22); + signed int mb = (signed int) ((temp << 22) >> 22); + signed int sat16 = (signed int) ((sqrt( + ((float) ma * (float) ma + (float) mb * (float) mb) / 65536.0) - 1.0) * 128.0); + signed int hue16 = (signed int) (atan((float) mb / (float) ma) * 128.0 / PI); - if ( sat16 > 127 ) { - sat16 = 127; - } + if (sat16 > 127) { + sat16 = 127; + } - if ( sat16 < -128 ) { - sat16 = -128; - } + if (sat16 < -128) { + sat16 = -128; + } - if ( hue16 > 127 ) { - hue16 = 127; - } + if (hue16 > 127) { + hue16 = 127; + } - if ( hue16 < -128 ) { - hue16 = -128; - } + if (hue16 < -128) { + hue16 = -128; + } - *sat = ( signed char ) sat16; - *hue = ( signed char ) hue16; + *sat = (signed char) sat16; + *hue = (signed char) hue16; } -int CVpp::VPP_SetVideoSaturationHue ( int satVal, int hueVal ) -{ - FILE *fp = NULL; - signed long temp; +int CVpp::VPP_SetVideoSaturationHue(int satVal, int hueVal) { + FILE *fp = NULL; + signed long temp; - fp = fopen ( "/sys/class/amvecm/saturation_hue", "w" ); - LOGD ( "~~~fopen~~~##VPP_SetVideoSaturationHue##%s : %d %d##" , "/sys/class/amvecm/saturation_hue", satVal, hueVal); + fp = fopen("/sys/class/amvecm/saturation_hue", "w"); + LOGD("~~~fopen~~~##VPP_SetVideoSaturationHue##%s : %d %d##", + "/sys/class/amvecm/saturation_hue", satVal, hueVal); - if ( fp == NULL ) { - LOGE ( "Open /sys/class/amvecm/saturation_hue error(%s)!\n", strerror ( errno ) ); - return -1; - } + if (fp == NULL) { + LOGE("Open /sys/class/amvecm/saturation_hue error(%s)!\n", strerror(errno)); + return -1; + } - video_set_saturation_hue ( satVal, hueVal, &temp ); - fprintf ( fp, "0x%lx", temp ); + video_set_saturation_hue(satVal, hueVal, &temp); + fprintf(fp, "0x%lx", temp); - fclose ( fp ); - fp = NULL; + fclose(fp); + fp = NULL; - return 0; + return 0; } -int CVpp::VPP_SetVideoSaturation ( int saturation ) -{ - FILE *fp = NULL; +int CVpp::VPP_SetVideoSaturation(int saturation) { + FILE *fp = NULL; - fp = fopen ( "/sys/class/amvecm/saturation_hue", "w" ); - LOGD ( "~~~fopen~~~##VPP_SetVideoSaturation##%s : %d ##" , "/sys/class/amvecm/saturation_hue", saturation); + fp = fopen("/sys/class/amvecm/saturation_hue", "w"); + LOGD("~~~fopen~~~##VPP_SetVideoSaturation##%s : %d ##", "/sys/class/amvecm/saturation_hue", + saturation); - if ( fp == NULL ) { - LOGE ( "Open /sys/class/amvecm/saturation_hue error(%s)!\n", strerror ( errno ) ); - return -1; - } + if (fp == NULL) { + LOGE("Open /sys/class/amvecm/saturation_hue error(%s)!\n", strerror(errno)); + return -1; + } - fprintf ( fp, "0x%x", saturation ); + fprintf(fp, "0x%x", saturation); - fclose ( fp ); - fp = NULL; + fclose(fp); + fp = NULL; - return 0; + return 0; } -int CVpp::VPP_SetVideoHue ( int hue ) -{ - FILE *fp = NULL; +int CVpp::VPP_SetVideoHue(int hue) { + FILE *fp = NULL; - fp = fopen ( "/sys/class/amvecm/saturation_hue", "w" ); - LOGD ( "~~~fopen~~~##VPP_SetVideoHue##%s : %d ##" , "/sys/class/amvecm/saturation_hue", hue); + fp = fopen("/sys/class/amvecm/saturation_hue", "w"); + LOGD("~~~fopen~~~##VPP_SetVideoHue##%s : %d ##", "/sys/class/amvecm/saturation_hue", hue); - if ( fp == NULL ) { - LOGE ( "Open /sys/class/amvecm/saturation_hue error(%s)!\n", strerror ( errno ) ); - return -1; - } + if (fp == NULL) { + LOGE("Open /sys/class/amvecm/saturation_hue error(%s)!\n", strerror(errno)); + return -1; + } - fprintf ( fp, "0x%x", hue ); + fprintf(fp, "0x%x", hue); - fclose ( fp ); - fp = NULL; - return 0; + fclose(fp); + fp = NULL; + return 0; } -int CVpp::VPP_SetGammaTbl_R ( unsigned short red[256] ) -{ - struct tcon_gamma_table_s Redtbl; - int rt = -1, i = 0; +int CVpp::VPP_SetGammaTbl_R(unsigned short red[256]) { + struct tcon_gamma_table_s Redtbl; + int rt = -1, i = 0; - for ( i = 0; i < 256; i++ ) { - Redtbl.data[i] = red[i]; - } + for (i = 0; i < 256; i++) { + Redtbl.data[i] = red[i]; + } - rt = VPP_DeviceIOCtl ( AMVECM_IOC_GAMMA_TABLE_R, &Redtbl ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetGammaTbl_R##AMVECM_IOC_GAMMA_TABLE_R##" ); + rt = VPP_DeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_R, &Redtbl); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetGammaTbl_R##AMVECM_IOC_GAMMA_TABLE_R##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetGammaTbl_R, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetGammaTbl_R, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetGammaTbl_G ( unsigned short green[256] ) -{ - struct tcon_gamma_table_s Greentbl; - int rt = -1, i = 0; +int CVpp::VPP_SetGammaTbl_G(unsigned short green[256]) { + struct tcon_gamma_table_s Greentbl; + int rt = -1, i = 0; - for ( i = 0; i < 256; i++ ) { - Greentbl.data[i] = green[i]; - } + for (i = 0; i < 256; i++) { + Greentbl.data[i] = green[i]; + } - rt = VPP_DeviceIOCtl ( AMVECM_IOC_GAMMA_TABLE_G, &Greentbl ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetGammaTbl_G##AMVECM_IOC_GAMMA_TABLE_G##" ); + rt = VPP_DeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_G, &Greentbl); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetGammaTbl_G##AMVECM_IOC_GAMMA_TABLE_G##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetGammaTbl_R, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetGammaTbl_R, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetGammaTbl_B ( unsigned short blue[256] ) -{ - struct tcon_gamma_table_s Bluetbl; - int rt = -1, i = 0; +int CVpp::VPP_SetGammaTbl_B(unsigned short blue[256]) { + struct tcon_gamma_table_s Bluetbl; + int rt = -1, i = 0; - for ( i = 0; i < 256; i++ ) { - Bluetbl.data[i] = blue[i]; - } + for (i = 0; i < 256; i++) { + Bluetbl.data[i] = blue[i]; + } - rt = VPP_DeviceIOCtl ( AMVECM_IOC_GAMMA_TABLE_B, &Bluetbl ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetGammaTbl_B##AMVECM_IOC_GAMMA_TABLE_B##" ); + rt = VPP_DeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_B, &Bluetbl); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetGammaTbl_B##AMVECM_IOC_GAMMA_TABLE_B##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetGammaTbl_R, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetGammaTbl_R, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetGammaOnOff ( unsigned char onoff ) -{ - int rt = -1; +int CVpp::VPP_SetGammaOnOff(unsigned char onoff) { + int rt = -1; - if ( onoff == 1 ) { - rt = VPP_DeviceIOCtl ( AMVECM_IOC_GAMMA_TABLE_EN ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetGammaOnOff##AMVECM_IOC_GAMMA_TABLE_EN##" ); - } + if (onoff == 1) { + rt = VPP_DeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_EN); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetGammaOnOff##AMVECM_IOC_GAMMA_TABLE_EN##"); + } - if ( onoff == 0 ) { - rt = VPP_DeviceIOCtl ( AMVECM_IOC_GAMMA_TABLE_DIS ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetGammaOnOff##AMVECM_IOC_GAMMA_TABLE_DIS##" ); - } + if (onoff == 0) { + rt = VPP_DeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_DIS); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetGammaOnOff##AMVECM_IOC_GAMMA_TABLE_DIS##"); + } - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetGammaOnOff, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetGammaOnOff, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetGrayPattern(int value) -{ +int CVpp::VPP_SetGrayPattern(int value) { - FILE *fp = NULL; - if (value < 0) { - value = 0; - } else if (value > 255) { - value = 255; - } - value = value << 16 | 0x8080; + FILE *fp = NULL; + if (value < 0) { + value = 0; + } else if (value > 255) { + value = 255; + } + value = value << 16 | 0x8080; - fp = fopen ( "/sys/class/video/test_screen", "w" ); - LOGD ( "~~~fopen~~~##VPP_SetGrayPattern##%s : %x ##" , "/sys/class/video/test_screen", value); + fp = fopen("/sys/class/video/test_screen", "w"); + LOGD("~~~fopen~~~##VPP_SetGrayPattern##%s : %x ##", "/sys/class/video/test_screen", value); - if ( fp == NULL ) { - LOGE ( "Open /sys/classs/video/test_screen error(%s)!\n", strerror ( errno ) ); - return -1; - } + if (fp == NULL) { + LOGE("Open /sys/classs/video/test_screen error(%s)!\n", strerror(errno)); + return -1; + } - fprintf ( fp, "0x%x", value ); - fclose ( fp ); - fp = NULL; + fprintf(fp, "0x%x", value); + fclose(fp); + fp = NULL; - return 0; + return 0; } -int CVpp::VPP_GetGrayPattern() -{ - FILE *fp = NULL; - int value; - fp = fopen ( "/sys/class/video/test_screen", "r+" ); +int CVpp::VPP_GetGrayPattern() { + FILE *fp = NULL; + int value; + fp = fopen("/sys/class/video/test_screen", "r+"); - LOGD ( "~~~fopen~~~##VPP_GetGrayPattern##%s ##" , "/sys/class/video/test_screen"); + LOGD("~~~fopen~~~##VPP_GetGrayPattern##%s ##", "/sys/class/video/test_screen"); - if ( fp == NULL ) { - LOGE ( "Open /sys/class/video/test_screen error(%s)!\n", strerror ( errno ) ); - return -1; - } + if (fp == NULL) { + LOGE("Open /sys/class/video/test_screen error(%s)!\n", strerror(errno)); + return -1; + } - fscanf ( fp, "%d", &value ); - fclose ( fp ); - fp = NULL; - if (value < 0) { - return 0; - } else { - value = value >> 16; - if (value > 255) { - value = 255; - } - return value; - } + fscanf(fp, "%d", &value); + fclose(fp); + fp = NULL; + if (value < 0) { + return 0; + } else { + value = value >> 16; + if (value > 255) { + value = 255; + } + return value; + } } -int CVpp::VPP_SetVideoNoiseReduction ( int value ) -{ - FILE *fp = NULL; +int CVpp::VPP_SplitScreenEffect(int width, int v_register) { + FILE *fp = fopen("/sys/class/amlogic/debug", "w"); + + if (fp == NULL) { + LOGE("Open /sys/class/amlogic/debug ERROR(%s)!!\n", strerror(errno)); + return -1; + } + LOGD("width = %x----v_register = %x", width, v_register); + fprintf(fp, "w %x v %x", width, v_register); + fclose(fp); + fp = NULL; + + return 0; +} +int CVpp::VPP_SetVideoNoiseReduction(int value) { + FILE *fp = NULL; - fp = fopen ( "/sys/class/deinterlace/di0/parameters", "w" ); - LOGD ( "~~~fopen~~~##VPP_SetVideoNoiseReduction##%s : %d ##" , "/sys/class/deinterlace/di0/parameters", value); + fp = fopen("/sys/class/deinterlace/di0/parameters", "w"); + LOGD("~~~fopen~~~##VPP_SetVideoNoiseReduction##%s : %d ##", + "/sys/class/deinterlace/di0/parameters", value); - if ( fp == NULL ) { - LOGE ( "Open /sys/class/deinterlace/di0/parameters ERROR(%s)!!\n", strerror ( errno ) ); - return -1; - } + if (fp == NULL) { + LOGE("Open /sys/class/deinterlace/di0/parameters ERROR(%s)!!\n", strerror(errno)); + return -1; + } - fprintf ( fp, "noise_reduction_level=%x", value ); - fclose ( fp ); - fp = NULL; + fprintf(fp, "noise_reduction_level=%x", value); + fclose(fp); + fp = NULL; - return 0; + return 0; } -int CVpp::VPP_SetDeinterlaceMode ( int value ) -{ - FILE *fp = NULL; +int CVpp::VPP_SetDeinterlaceMode(int value) { + FILE *fp = NULL; - fp = fopen ( "/sys/module/deinterlace/parameters/deinterlace_mode", "w" ); - LOGD ( "~~~fopen~~~##VPP_SetDeinterlaceMode##%s : %d ##" , "/sys/module/deinterlace/parameters/deinterlace_mode", value); + fp = fopen("/sys/module/deinterlace/parameters/deinterlace_mode", "w"); + LOGD("~~~fopen~~~##VPP_SetDeinterlaceMode##%s : %d ##", + "/sys/module/deinterlace/parameters/deinterlace_mode", value); - if ( fp == NULL ) { - LOGE ( "Open /sys/module/deinterlace/parameters/deinterlace_mode error(%s)!\n", strerror ( errno ) ); - return -1; - } + if (fp == NULL) { + LOGE("Open /sys/module/deinterlace/parameters/deinterlace_mode error(%s)!\n", + strerror(errno)); + return -1; + } - fprintf ( fp, "%d", value ); + fprintf(fp, "%d", value); - fclose ( fp ); - fp = NULL; + fclose(fp); + fp = NULL; - return 0; + return 0; } -int CVpp::Tv_GetHistogram_AVE ( void ) -{ - ve_hist_t hist; - hist.sum = 0; - hist.height = 0; - hist.width = 0; - hist.ave = 0; +int CVpp::GetHistogram_AVE(void) { + ve_hist_t hist; + hist.sum = 0; + hist.height = 0; + hist.width = 0; + hist.ave = 0; + + if (Vpp_GetAVGHistogram(&hist) == 0) { + LOGD("%s: %d.\n", __FUNCTION__, hist.ave); + } else { + LOGE("%s failed.\n", __FUNCTION__); + } + + return hist.ave; +} - if ( Vpp_GetAVGHistogram ( &hist ) == 0 ) { - LOGD ( "%s: %d.\n", __FUNCTION__, hist.ave ); - } else { - LOGE ( "%s failed.\n", __FUNCTION__ ); - } +int CVpp::Vpp_GetAVGHistogram(struct ve_hist_s *hist) { + //int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_G_HIST_AVG, hist); + int rt = VPP_DeviceIOCtl(AMVECM_IOC_G_HIST_AVG, hist); + LOGD("~~~VPP_DeviceIOCtl~~~##Vpp_GetAVGHistogram##AMVECM_IOC_G_HIST_AVG##"); + + if (rt < 0) { + LOGE("Vpp_GetAVGHistogram, error(%s)!\n", strerror(errno)); + } - return hist.ave; + return rt; } -int CVpp::Vpp_GetAVGHistogram ( struct ve_hist_s *hist ) -{ - //int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_G_HIST_AVG, hist); - int rt = VPP_DeviceIOCtl ( AMVECM_IOC_G_HIST_AVG, hist ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##Vpp_GetAVGHistogram##AMVECM_IOC_G_HIST_AVG##" ); +int CVpp::VPP_SetVEBlackExtension(const struct ve_bext_s *pBExt) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_BEXT, pBExt); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEBlackExtension##AMSTREAM_IOC_VE_BEXT##"); - if ( rt < 0 ) { - LOGE ( "Vpp_GetAVGHistogram, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetVEBlackExtension, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } +tvin_cutwin_t CVpp::GetOverscan(tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, + is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { + int ret = -1; + char tmp_buf[16]; + tvin_cutwin_t cutwin_t; + memset(&cutwin_t, 0, sizeof(cutwin_t)); -int CVpp::VPP_SetVEBlackExtension ( const struct ve_bext_s *pBExt ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_VE_BEXT, pBExt ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetVEBlackExtension##AMSTREAM_IOC_VE_BEXT##" ); + if (trans_fmt < TVIN_TFMT_2D || trans_fmt > TVIN_TFMT_3D_LDGD) { + return cutwin_t; + } - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetVEBlackExtension, error(%s)!\n", strerror ( errno ) ); - } + vpp_display_mode_t scrmode = GetDisplayMode(source_type); + ret = mpPqData->PQ_GetOverscanParams(source_type, fmt, is3d, trans_fmt, scrmode, &cutwin_t); - return rt; + return cutwin_t; } -tvin_cutwin_t CVpp::Tv_GetOverscan ( tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt ) -{ - int ret = -1; - char tmp_buf[16]; - tvin_cutwin_t cutwin_t; - memset ( &cutwin_t, 0, sizeof ( cutwin_t ) ); - - if ( trans_fmt < TVIN_TFMT_2D || trans_fmt > TVIN_TFMT_3D_LDGD ) { - return cutwin_t; - } - - if (source_type == SOURCE_TYPE_DTV) { - tmp_buf[0] = 0; - ret = 0; - if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 0, tmp_buf)) == 0) { - cutwin_t.vs = strtol(tmp_buf, NULL, 10); - } - if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 1, tmp_buf)) == 0) { - cutwin_t.hs = strtol(tmp_buf, NULL, 10); - } - if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 2, tmp_buf)) == 0) { - cutwin_t.ve = strtol(tmp_buf, NULL, 10); - } - if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 3, tmp_buf)) == 0) { - cutwin_t.he = strtol(tmp_buf, NULL, 10); - } - - if (ret < 0) { - cutwin_t.vs = 12; - cutwin_t.hs = 27; - cutwin_t.ve = 10; - cutwin_t.he = 24; - } - return cutwin_t; - } - - vpp_display_mode_t scrmode = Tv_GetDisplayMode ( source_type ); - ret = mpPqData->PQ_GetOverscanParams ( source_type, fmt, is3d, trans_fmt, scrmode, &cutwin_t ); - - if ( ret != 0 ) { - LOGW ( "%s, PQ_GetOverscanParams faild.\n", __FUNCTION__ ); - - if ( source_type == SOURCE_TYPE_TV ) { - if ( fmt == TVIN_SIG_FMT_CVBS_NTSC_M - || fmt == TVIN_SIG_FMT_CVBS_NTSC_443 ) { - cutwin_t.hs = 30; - cutwin_t.he = 720 - 30 - 1; - cutwin_t.vs = 2; - cutwin_t.ve = 240 - 2 - 1; - } else if ( fmt >= TVIN_SIG_FMT_CVBS_PAL_I && fmt <= TVIN_SIG_FMT_CVBS_SECAM ) { - cutwin_t.hs = 32; - cutwin_t.he = 720 - 32 - 1; - cutwin_t.vs = 6; - cutwin_t.ve = 288 - 8 - 1; - } - } - } - - return cutwin_t; -} - -int CVpp::VPP_SetVideoCrop ( int Voffset0, int Hoffset0, int Voffset1, int Hoffset1 ) -{ - int fd = -1; - char set_str[32]; +int CVpp::VPP_SetVideoCrop(int Voffset0, int Hoffset0, int Voffset1, int Hoffset1) { + int fd = -1; + char set_str[32]; - fd = open ( "/sys/class/video/crop", O_RDWR ); + fd = open("/sys/class/video/crop", O_RDWR); - LOGD ( "~~~open~~~##VPP_SetVideoCrop##%s : %d %d %d %d##" , "/sys/class/video/crop", Voffset0, Hoffset0, Voffset1, Hoffset1); + LOGD("~~~open~~~##VPP_SetVideoCrop##%s : %d %d %d %d##", "/sys/class/video/crop", Voffset0, + Hoffset0, Voffset1, Hoffset1); - if ( fd < 0 ) { - LOGE ( "Open /sys/class/video/crop error(%s)!\n", strerror ( errno ) ); - return -1; - } + if (fd < 0) { + LOGE("Open /sys/class/video/crop error(%s)!\n", strerror(errno)); + return -1; + } - memset ( set_str, 0, 32 ); - sprintf ( set_str, "%d %d %d %d", Voffset0, Hoffset0, Voffset1, Hoffset1 ); - write ( fd, set_str, strlen ( set_str ) ); - close ( fd ); + memset(set_str, 0, 32); + sprintf(set_str, "%d %d %d %d", Voffset0, Hoffset0, Voffset1, Hoffset1); + write(fd, set_str, strlen(set_str)); + close(fd); - return 0; + return 0; } -int CVpp::VPP_SetVESharpness ( const struct ve_hsvs_s *pHSVS ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_VE_HSVS, pHSVS ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetVESharpness##AMSTREAM_IOC_VE_HSVS##" ); +int CVpp::VPP_SetVESharpness(const struct ve_hsvs_s *pHSVS) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_HSVS, pHSVS); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVESharpness##AMSTREAM_IOC_VE_HSVS##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetVESharpness, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetVESharpness, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetVEChromaCoring ( const struct ve_ccor_s *pCCor ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_VE_CCOR, pCCor ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetVEChromaCoring##AMSTREAM_IOC_VE_CCOR##" ); +int CVpp::VPP_SetVEChromaCoring(const struct ve_ccor_s *pCCor) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_CCOR, pCCor); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEChromaCoring##AMSTREAM_IOC_VE_CCOR##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetVEChromaCoring, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetVEChromaCoring, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetVEBlueEnh ( const struct ve_benh_s *pBEnh ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_VE_BENH, pBEnh ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetVEBlueEnh##AMSTREAM_IOC_VE_BENH##" ); +int CVpp::VPP_SetVEBlueEnh(const struct ve_benh_s *pBEnh) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_BENH, pBEnh); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEBlueEnh##AMSTREAM_IOC_VE_BENH##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetVEBlueEnh, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetVEBlueEnh, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetVEDemo ( const struct ve_demo_s *pDemo ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_VE_DEMO, pDemo ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetVEDemo##AMSTREAM_IOC_VE_DEMO##" ); +int CVpp::VPP_SetVEDemo(const struct ve_demo_s *pDemo) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_DEMO, pDemo); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEDemo##AMSTREAM_IOC_VE_DEMO##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetVEDemo, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetVEDemo, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetVERegisterMap ( const struct ve_regmap_s *pRegMap ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_VE_REGMAP, pRegMap ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetVERegisterMap##AMSTREAM_IOC_VE_REGMAP##" ); +int CVpp::VPP_SetVERegisterMap(const struct ve_regmap_s *pRegMap) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_REGMAP, pRegMap); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVERegisterMap##AMSTREAM_IOC_VE_REGMAP##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetVERegisterMap, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetVERegisterMap, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetVEDebug ( const unsigned long long *pLData ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_VE_DEBUG, pLData ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetVEDebug##AMSTREAM_IOC_VE_DEBUG##" ); +int CVpp::VPP_SetVEDebug(const unsigned long long *pLData) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_DEBUG, pLData); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEDebug##AMSTREAM_IOC_VE_DEBUG##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetVEDebug, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetVEDebug, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetCMRegion ( const struct cm_region_s *pRegion ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_CM_REGION, pRegion ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetCMRegion##AMSTREAM_IOC_CM_REGION##" ); +int CVpp::VPP_SetCMRegion(const struct cm_region_s *pRegion) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_CM_REGION, pRegion); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetCMRegion##AMSTREAM_IOC_CM_REGION##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetCMRegion, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetCMRegion, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetCMTopLayer ( const struct cm_top_s *pTop ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_CM_TOP, pTop ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetCMTopLayer##AMSTREAM_IOC_CM_TOP##" ); +int CVpp::VPP_SetCMTopLayer(const struct cm_top_s *pTop) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_CM_TOP, pTop); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetCMTopLayer##AMSTREAM_IOC_CM_TOP##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetCMTopLayer, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetCMTopLayer, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetCMDemo ( const struct cm_demo_s *pDemo ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_CM_DEMO, pDemo ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetCMDemo##AMSTREAM_IOC_CM_DEMO##" ); +int CVpp::VPP_SetCMDemo(const struct cm_demo_s *pDemo) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_CM_DEMO, pDemo); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetCMDemo##AMSTREAM_IOC_CM_DEMO##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetCMDemo, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetCMDemo, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetCMRegisterMap ( struct cm_regmap_s *pRegMap ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_CM_REGMAP, pRegMap ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetCMRegisterMap##AMSTREAM_IOC_CM_REGMAP##" ); +int CVpp::VPP_SetCMRegisterMap(struct cm_regmap_s *pRegMap) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_CM_REGMAP, pRegMap); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetCMRegisterMap##AMSTREAM_IOC_CM_REGMAP##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetCMRegisterMap, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetCMRegisterMap, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetCMDebug ( const unsigned long long *pLData ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_CM_DEBUG, pLData ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetCMDebug##AMSTREAM_IOC_CM_DEBUG##" ); +int CVpp::VPP_SetCMDebug(const unsigned long long *pLData) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_CM_DEBUG, pLData); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetCMDebug##AMSTREAM_IOC_CM_DEBUG##"); - if ( rt < 0 ) { - LOGE ( "=VPP CPP=> set cm debug, error (%s)", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("=VPP CPP=> set cm debug, error (%s)", strerror(errno)); + } - return rt; + return rt; } -int CVpp::VPP_SetAVSyncEnable ( const unsigned int enable ) -{ - int rt = VPP_DeviceIOCtl ( AMSTREAM_IOC_SYNCENABLE, enable ); - LOGD ( "~~~VPP_DeviceIOCtl~~~##VPP_SetAVSyncEnable##AMSTREAM_IOC_SYNCENABLE##" ); +int CVpp::VPP_SetAVSyncEnable(const unsigned int enable) { + int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_SYNCENABLE, enable); + LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetAVSyncEnable##AMSTREAM_IOC_SYNCENABLE##"); - if ( rt < 0 ) { - LOGE ( "Vpp_api_SetAVSyncEnable, error(%s)!\n", strerror ( errno ) ); - } + if (rt < 0) { + LOGE("Vpp_api_SetAVSyncEnable, error(%s)!\n", strerror(errno)); + } - return rt; + return rt; +} +int CVpp::VPP_SetScalerPathSel(const unsigned int value) { + FILE *fp = NULL; + + fp = fopen("/sys/class/video/video_scaler_path_sel", "w"); + LOGD("~~~fopen~~~##VPP_SetScalerPathSel##%s : %d ##", "/sys/class/video/video_scaler_path_sel", + value); + if (fp == NULL) { + LOGE("Open /sys/class/video/video_scaler_path_sel error(%s)!\n", strerror(errno)); + return -1; + } + fprintf(fp, "%d", value); + fclose(fp); + fp = NULL; + return 0; } |