Files
BPI-CM9-Linux/aml-comp/vendor/amlogic/aml_pqserver/libpq/CPQControl.cpp
T

13555 lines
424 KiB
C++

/*
* Copyright (c) 2014 Amlogic, Inc. All rights reserved.
*
* This source code is subject to the terms and conditions defined in the
* file 'LICENSE' which is part of this source code package.
*
* Description: c++ file
*/
#define LOG_MODULE_TAG "PQ"
#define LOG_CLASS_TAG "CPQControl"
#include <math.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <string.h>
#include <pthread.h>
#include <errno.h>
#include "CPQControl.h"
#include "SyncDataBase.h"
#include "ldim/aml_hal_ld.h"
#include "panel/aml_hal_lcd.h"
#include "amdv/aml_hal_amdv.h"
#include "vdin/aml_hal_vdin.h"
#include "pq/aml_hal_di.h"
#include "pq/aml_hal_memc.h"
#include "pq/aml_hal_pq.h"
#include "display/aml_hal_display.h"
#define PI 3.14159265358979
CPQControl *CPQControl::mInstance = NULL;
pthread_mutex_t PqControlMutex = PTHREAD_MUTEX_INITIALIZER;
CPQControl *CPQControl::GetInstance()
{
if (NULL == mInstance)
mInstance = new CPQControl();
return mInstance;
}
CPQControl::CPQControl()
{
memset(rgbfrompq, 0, sizeof(tcon_rgb_ogo_t));
memset(&mCurrentSourceInputInfo, 0, sizeof(source_input_param_t));
memset(&mCurrentSignalInfo, 0, sizeof(struct tvin_parm_s));
memset(&mCurrentTvinInfo, 0, sizeof(tvin_inputparam_t));
memset(&mRegsData, 0x0, sizeof(am_regs_t));
memset(&mRegsDataNew, 0x0, sizeof(am_regs_t));
memset(&mPreFilmMakerMode, 0x0, sizeof(mPreFilmMakerMode));
}
CPQControl::~CPQControl()
{
}
void CPQControl::CPQControlInit()
{
//open vpp module
mAmvppFd = VPPOpenModule();
if (mAmvppFd < 0) {
LOGE("Open amvecm module failed!\n");
} else {
LOGD("Open amvecm module success!\n");
}
//open VPQ module
mVpqFd = VpqOpenModule();
if (mVpqFd < 0) {
LOGE("Open vpq module failed!\n");
} else {
LOGD("Open vpq module success!\n");
}
// open amvideo module
mAmvideoFd = VideoOpenModule();
if (mAmvideoFd < 0) {
LOGE("Open amvideo module failed!\n");
} else {
LOGD("Open amvideo module success!\n");
}
//open DI module
mDiFd = DIOpenModule();
if (mDiFd < 0) {
LOGE("Open DI module failed!\n");
} else {
LOGD("Open DI module success!\n");
}
//open MEMC module
mDpssMemcFd = DPSS_MEMCOpenModule();
if (mDpssMemcFd < 0) {
mMemcFd = MEMCOpenModule();
}
if ((mDpssMemcFd < 0) && (mMemcFd < 0)) {
LOGE("Open MEMC module failed!\n");
} else {
LOGD("Open MEMC module success!\n");
}
//open LCD module
mLcdFd = LCDOpenModule();
if (mLcdFd < 0) {
LOGE("Open lcd failed\n");
} else {
LOGD("Open lcd success\n");
}
//open vdin module
mpVdin = CVdin::getInstance();
//Load config file
mPQConfigFile = CConfigFile::GetInstance();
SetFlagByCfg();
//load DV config file
char dvbinpath[128] = {0};
char dvcfgpath[128] = {0};
mPQConfigFile->GetDvFilePath(dvbinpath, dvcfgpath);
mDolbyVision = new CDolbyVision(dvbinpath, dvcfgpath);
//open DB
char dstPqDbPath[128] = {0};
mPQdb = new CPQdb();
mPQConfigFile->GetPqdbPath(dstPqDbPath);
int ret = mPQdb->openPqDB(dstPqDbPath);
if (ret != 0) {
mbDatabaseMatchChipStatus = false;
LOGE("open pq DB failed!\n");
} else {
LOGD("open pq DB success!\n");
mbDatabaseMatchChipStatus = isPqDatabaseMachChip();
}
//open overscan DB
if (mbCpqCfg_separate_db_enable) {
char dstOverscanDbPath[128] = {0};
mpOverScandb = new COverScandb();
mPQConfigFile->GetOverscandbPath(dstOverscanDbPath);
ret = mpOverScandb->openOverScanDB(dstOverscanDbPath);
if (ret != 0) {
SYS_LOGE("open overscan DB failed!\n");
} else {
SYS_LOGD("open overscan DB success!\n");
}
}
//ldim init
char dstLdimBinPath[128] = {0};
mPQConfigFile->GetLdimBinPath(dstLdimBinPath);
SYS_LOGD("ldim.bin path:%s\n", dstLdimBinPath);
AML_HAL_LD_SetBinFilePath(dstLdimBinPath);
AML_HAL_LD_Init();
//get Chip Type
mChipType = GetChipType();
mPQdb->PQ_GetPqDbMatchType(mChipType);
//init source
mCurrentSourceInputInfo.source_input = SOURCE_MPEG;
mCurrentSourceInputInfo.trans_fmt = TVIN_TFMT_2D;
mSourceInputForSaveParam = SOURCE_MPEG;
pthread_mutex_lock(&PqControlMutex); //for coverity
mCurrentSourceInputInfo.sig_fmt = TVIN_SIG_FMT_HDMI_1920X1080P_60HZ;
pthread_mutex_unlock(&PqControlMutex);
//check output mode
// must do before load pq param
mPQdb->mOutPutType = CheckOutPutMode(SOURCE_MPEG);
//SQL Init
mDataBase = CPQDataBase::GetInstance();
mDataBase->setObserver(this);
mDataBase->Init(NULL);
//mWBDataBase = WhitebalanceDataBase::GetInstance();
if (CheckSSMData()) {
LOGD("CheckSSMData success\n");
}
//load display mode setting
vpp_display_mode_t display_mode = (vpp_display_mode_t)GetDisplayMode();
SetDisplayMode(display_mode, 1);
//Load PQ seting
if (LoadPQSettings() < 0) {
LOGE("Load PQ failed\n");
} else {
LOGD("Load PQ success\n");
}
//set DynamicBackLight
DynamicBackLightInit();
//HLG tone mapping init
HlgToneMappingInit();
//cabc pq
SetCabc();
//aad pq
SetAad();
SetLCDhdrinfo();
//Vframe size
mCDevicePollCheckThread.setObserver(this);
mCDevicePollCheckThread.StartCheck();
mUEventObserver.setUeventObserverCallBack(this);
mUEventObserver.StartUEventThead();
InitAutoNr();
mInitialized = true;
}
void CPQControl::CPQControlUnInit()
{
//close amvecm module
VPPCloseModule();
//close vpq module
VpqCloseModule();
//close amvideo module
VideoCloseModule();
//close DI module
DICloseModule();
//close lcd
LCDCloseModule();
//close vdin
if (mpVdin != NULL) {
delete mpVdin;
mpVdin = NULL;
}
//close dobly vision
if (mDolbyVision != NULL) {
delete mDolbyVision;
mDolbyVision = NULL;
}
if (mSSMAction!= NULL) {
delete mSSMAction;
mSSMAction = NULL;
}
if (mPQdb != NULL) {
//closed DB
mPQdb->closeDb();
delete mPQdb;
mPQdb = NULL;
}
if (mpOverScandb != NULL) {
mpOverScandb->closeDb();
delete mpOverScandb;
mpOverScandb = NULL;
}
if (mPQConfigFile != NULL) {
delete mPQConfigFile;
mPQConfigFile = NULL;
}
if (mDataBase != NULL) {
delete mDataBase;
mDataBase = NULL;
}
//if (mWBDataBase != NULL) {
// delete mWBDataBase;
// mWBDataBase = NULL;
//}
}
int CPQControl::VPPOpenModule(void)
{
if (mAmvppFd < 0) {
mAmvppFd = open(VPP_DEV_PATH, O_RDWR);
LOGD("amvecm module path: %s.\n", VPP_DEV_PATH);
if (mAmvppFd < 0) {
LOGE("Open amvecm module, error(%s)!\n", strerror(errno));
return -1;
}
} else {
LOGD("amvecm module has been opened before!\n");
}
return mAmvppFd;
}
int CPQControl::VPPCloseModule(void)
{
if (mAmvppFd >= 0) {
close(mAmvppFd);
mAmvppFd = -1;
}
return 0;
}
int CPQControl::VPPDeviceIOCtl(int request, ...)
{
int ret = -1;
va_list ap;
void *arg;
va_start(ap, request);
arg = va_arg ( ap, void * );
va_end(ap);
ret = ioctl(mAmvppFd, request, arg);
return ret;
}
int CPQControl::VpqOpenModule(void)
{
if (mVpqFd < 0) {
mVpqFd = open("/dev/" VPQ_DEVICE_NAME, O_RDWR);
if (mVpqFd < 0) {
LOGE("Open vpq module, error(%s)\n", strerror(errno));
return -1;
}
} else {
LOGD("vpq OpenModule has been opened before!\n");
}
return mVpqFd;
}
int CPQControl::VpqCloseModule(void)
{
if (mVpqFd >= 0) {
close ( mVpqFd);
mVpqFd = -1;
}
return 0;
}
int CPQControl::VpqDeviceIOCtl(int request, ...)
{
int ret = -1;
va_list ap;
void *arg;
va_start(ap, request);
arg = va_arg ( ap, void * );
va_end(ap);
ret = ioctl(mVpqFd, request, arg);
return ret;
}
int CPQControl::VideoOpenModule(void)
{
if (mAmvideoFd < 0) {
mAmvideoFd = open(VIDEO_DEV_PATH, O_RDWR);
LOGD("amvideo module path: %s.\n", VIDEO_DEV_PATH);
if (mAmvideoFd < 0) {
LOGE("Open amvideo module, error(%s)!\n", strerror(errno));
return -1;
}
} else {
LOGD("amvideo module has been opened before!\n");
}
return mAmvideoFd;
}
int CPQControl::VideoCloseModule(void)
{
if (mAmvideoFd >= 0) {
close(mAmvideoFd);
mAmvideoFd = -1;
}
return 0;
}
int CPQControl::VideoDeviceIOCtl(int request, ...)
{
int ret = -1;
va_list ap;
void *arg;
va_start(ap, request);
arg = va_arg ( ap, void * );
va_end(ap);
ret = ioctl(mAmvideoFd, request, arg);
return ret;
}
int CPQControl::DIOpenModule(void)
{
if (mDiFd < 0) {
mDiFd = open(DI_DEV_PATH, O_RDWR);
LOGD("DI Module path: %s.\n", DI_DEV_PATH);
if (mDiFd < 0) {
LOGE("Open DI module, error(%s)!\n", strerror(errno));
return -1;
}
}
return mDiFd;
}
int CPQControl::DICloseModule(void)
{
if (mDiFd>= 0) {
close ( mDiFd);
mDiFd = -1;
}
return 0;
}
int CPQControl::DIDeviceIOCtl(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(mDiFd, request, arg);
return tmp_ret;
}
int CPQControl::AFEDeviceIOCtl ( int request, ... )
{
int tmp_ret = -1;
int afe_dev_fd = -1;
va_list ap;
void *arg;
afe_dev_fd = open ( AFE_DEV_PATH, O_RDWR );
if ( afe_dev_fd >= 0 ) {
va_start ( ap, request );
arg = va_arg ( ap, void * );
va_end ( ap );
tmp_ret = ioctl ( afe_dev_fd, request, arg );
close(afe_dev_fd);
return tmp_ret;
} else {
LOGE ( "Open tvafe module error(%s).\n", strerror ( errno ));
return -1;
}
}
int CPQControl::MEMCOpenModule(void)
{
if (mMemcFd < 0) {
mMemcFd = open(CPQ_MEMC_SYSFS, O_RDWR);
LOGD("MEMC OpenModule path: %s", CPQ_MEMC_SYSFS);
if (mMemcFd < 0) {
LOGE("Open MEMC module, error(%s)!\n", strerror(errno));
return -1;
}
}
return mMemcFd;
}
int CPQControl::MEMCCloseModule(void)
{
if (mMemcFd>= 0) {
close ( mMemcFd);
mMemcFd = -1;
}
return 0;
}
int CPQControl::MEMCDeviceIOCtl(int request, ...)
{
int tmp_ret = -1;
if (mMemcFd < 0) {
return tmp_ret;
}
va_list ap;
void *arg;
va_start(ap, request);
arg = va_arg ( ap, void * );
va_end(ap);
tmp_ret = ioctl(mMemcFd, request, arg);
return tmp_ret;
}
int CPQControl::DPSS_MEMCOpenModule(void)
{
if (mDpssMemcFd < 0) {
mDpssMemcFd = open(DPSS_FRC_DEVICE_NAME, O_RDWR);
LOGD("DPSS MEMC OpenModule path: %s", DPSS_FRC_DEVICE_NAME);
if (mDpssMemcFd < 0) {
LOGE("Open DPSS MEMC module, error(%s)!\n", strerror(errno));
return -1;
}
}
return mDpssMemcFd;
}
int CPQControl::DPSS_MEMCCloseModule(void)
{
if (mDpssMemcFd>= 0) {
close (mDpssMemcFd);
mDpssMemcFd = -1;
}
return 0;
}
int CPQControl::DPSS_MEMCDeviceIOCtl(int request, ...)
{
int tmp_ret = -1;
if (mDpssMemcFd < 0) {
return tmp_ret;
}
va_list ap;
void *arg;
va_start(ap, request);
arg = va_arg ( ap, void * );
va_end(ap);
tmp_ret = ioctl(mDpssMemcFd, request, arg);
return tmp_ret;
}
int CPQControl::LCDOpenModule(void)
{
if (mLcdFd < 0) {
mLcdFd = open(LCD_PATH, O_RDWR);
LOGD("lcd module path: %s\n", LCD_PATH);
if (mLcdFd < 0) {
LOGE("Open lcd module, error(%s)\n", strerror(errno));
return -1;
}
} else {
LOGD("lcd module has been opened before\n");
}
return mLcdFd;
}
int CPQControl::LCDCloseModule(void)
{
if (mLcdFd >= 0) {
close( mLcdFd);
mLcdFd = -1;
}
return 0;
}
int CPQControl::LCDDeviceIOCtl(int request, ...)
{
int ret = -1;
va_list ap;
void *arg;
va_start(ap, request);
arg = va_arg ( ap, void * );
va_end(ap);
ret = ioctl(mLcdFd, request, arg);
return ret;
}
void CPQControl::onVframeSizeChange()
{
char temp[8];
memset(temp, 0, sizeof(temp));
int ret = pqReadSys(SYSFS_VIDEO_EVENT_PATH, temp, sizeof(temp));
if (ret > 0) {
int eventFlagValue = strtol(temp, NULL, 16);
LOGD("%s: event value = %d(0x%x)\n", __FUNCTION__, eventFlagValue, eventFlagValue);
int frameszieEventFlag = (eventFlagValue & 0x1) >> 0;
int hdrTypeEventFlag = (eventFlagValue & 0x2) >> 1;
int videoPlayStartEventFlag = (eventFlagValue & 0x4) >> 2;
int videoPlayStopEventFlag = (eventFlagValue & 0x8) >> 3;
int videoPlayAxisEventFlag = (eventFlagValue & 0x10) >> 4;
int FilmmakerModeFlag = (eventFlagValue & 0x20) >> 5;
int FilmmakerModeDisableFlag = (eventFlagValue & 0x40) >> 6;
SYS_LOGD("%s: \n"
"framesizeEventFlag = %d, hdrTypeEventFlag = %d,\n"
"videoPlayStartEventFlag = %d, videoPlayStopEventFlag = %d,\n"
"videoPlayAxisEventFlag = %d, FilmmakerModeFlag = %d,\n"
"FilmmakerModeDisableFlag = %d, sliceNumFlag = N/A,\n",
__FUNCTION__,
frameszieEventFlag, hdrTypeEventFlag, videoPlayStartEventFlag, videoPlayStopEventFlag,
videoPlayAxisEventFlag, FilmmakerModeFlag, FilmmakerModeDisableFlag);
if ((videoPlayStartEventFlag == 1) && (videoPlayStopEventFlag == 0)) {
mbVideoIsPlaying = true;
} else if ((videoPlayStartEventFlag == 0) && (videoPlayStopEventFlag == 1)) {
mbVideoIsPlaying = false;
} else {
LOGD("%s: not videoplay on/off event\n", __FUNCTION__);
}
if (((mCurrentSourceInputInfo.source_input == SOURCE_DTV) || (mCurrentSourceInputInfo.source_input == SOURCE_MPEG))
&& (frameszieEventFlag == 0x1 || (hdrTypeEventFlag == 0x1 && GetDecoderHdrSdrChangedFlag()))) {
source_input_param_t new_source_input_param;
new_source_input_param.source_input = mCurrentSourceInputInfo.source_input;
new_source_input_param.trans_fmt = mCurrentSourceInputInfo.trans_fmt;
new_source_input_param.sig_fmt = getVideoResolutionToFmt();
SetCurrentSourceInputInfo(new_source_input_param);
}
if (FilmmakerModeFlag == 1) {
LOGD("%s: VIDEO_PROP_CHANGE_FMM trigger amlvideo_poll event wake_up\n", __FUNCTION__);
mbFilmmakerModeFlag = true;
Cpq_SetFilmMakerMode();
} else if (FilmmakerModeDisableFlag == 1) {
LOGD("%s: VIDEO_PROP_CHANGE_FMM_DISABLE trigger amlvideo_poll event wake_up\n", __FUNCTION__);
mbFilmmakerModeFlag = false;
Cpq_SetFilmMakerMode();
}
} else {
LOGE("%s: read video event failed!\n", __FUNCTION__);
}
}
bool CPQControl::GetDecoderHdrSdrChangedFlag(void)
{
bool hdr_type_changed = false;
enum hdr_type_e newHdrType = HDRTYPE_NONE;
newHdrType = Cpq_GetSourceHDRType(mCurrentSourceInputInfo.source_input);
if ((newHdrType == HDRTYPE_SDR || newHdrType == HDRTYPE_NONE) &&
(mCurrentHdrType != HDRTYPE_SDR && mCurrentHdrType != HDRTYPE_NONE)) { //!SDR switch to SDR, ex exit hdr play to OSD
hdr_type_changed = true;
} else if ((newHdrType != HDRTYPE_SDR && newHdrType != HDRTYPE_NONE) &&
(mCurrentHdrType == HDRTYPE_SDR || mCurrentHdrType == HDRTYPE_NONE)) { //SDR switch to !SDR, ex dv play
hdr_type_changed = true;
} else if ((newHdrType != HDRTYPE_SDR && newHdrType != HDRTYPE_NONE) && //!SDR switch to !SDR, ex hdr10 and primehdr switch to each other
(mCurrentHdrType != HDRTYPE_SDR && mCurrentHdrType != HDRTYPE_NONE) && newHdrType != mCurrentHdrType) {
hdr_type_changed = true;
} else {
}
LOGD("%s: hdr_type_changed = %d\n", __FUNCTION__, hdr_type_changed);
return hdr_type_changed;
}
int CPQControl::GetWindowStatus(void)
{
window_mode_t newWindowStatus = WINDOW_FULL;
int width = 0, height = 0;
char axisValue[32] = {0};
char resolutionVal[32] = {0};
int readRet = pqReadSys(SYSFS_VIDEO_AXIS_PATH, axisValue, sizeof(axisValue));
if (readRet == -1) {
LOGD("%s: read videoAxis failed!\n",__FUNCTION__);
} else {
char *buf = strtok(axisValue, " ");
int position[4] = {0};
int i = 0;
while (buf != NULL) {
position[i++] = atoi(buf);
buf = strtok(NULL, " ");
}
pqReadSys(SYSFS_DEVICE_RESOLUTION, resolutionVal, sizeof(resolutionVal));
if (strncasecmp(resolutionVal, "1366x768", strlen ("1366x768")) == 0) {
width = 1366;
height = 768;
} else if (strncasecmp(resolutionVal, "3840x2160", strlen ("3840x2160")) == 0) {
width = 3840;
height = 2160;
} else if (strncasecmp(resolutionVal, "1920x1080", strlen ("1920x1080")) == 0) {
width = 1920;
height = 1080;
} else {
LOGD("video display resolution is = (%s) not define , default it", resolutionVal);
width = 1366;
height = 768;
}
if ((position[0] == 0) && (position[1] == 0) &&(position[2] == -1) && (position[3] == -1)) {//device first on
newWindowStatus = WINDOW_LUNCHER;
} else {
if (GetVideoPlayStatus() == 1) {
if (((width - (position[2] - position[0]) <= 40) && (height - (position[3] - position[1]) <= 40))
|| ((width - (position[2] - position[0]) >= width) && (height - (position[3] - position[1]) >= height))) {
newWindowStatus = WINDOW_FULL;
} else {
newWindowStatus = WINDOW_PREVIEW;
}
} else {
newWindowStatus = WINDOW_LUNCHER;
}
}
}
LOGD("%s: newWindowStatus = %d!\n",__FUNCTION__, newWindowStatus);
return (int)newWindowStatus;
}
enum tvin_sig_fmt_e CPQControl::getVideoResolutionToFmt()
{
int ret = -1;
int fd = -1;
char buf[32] = {0};
enum tvin_sig_fmt_e sig_fmt = TVIN_SIG_FMT_HDMI_1920X1080P_60HZ;
fd = open(SYS_VIDEO_FRAME_HEIGHT, O_RDONLY);
if (fd < 0) {
LOGE("[%s] open: %s error!\n", __FUNCTION__, SYS_VIDEO_FRAME_HEIGHT);
return sig_fmt;
}
ret = read(fd, buf, sizeof(buf));
if (ret > 0) {
int height = atoi(buf);
if (height <= 480) {
sig_fmt = TVIN_SIG_FMT_HDMI_720X480P_60HZ;
} else if (height > 480 && height <= 576) {
sig_fmt = TVIN_SIG_FMT_HDMI_720X576P_50HZ;
} else if (height > 576 && height <= 720) {
sig_fmt = TVIN_SIG_FMT_HDMI_1280X720P_60HZ;
} else if (height > 720 && height <= 1088) {
sig_fmt = TVIN_SIG_FMT_HDMI_1920X1080P_60HZ;
} else {
sig_fmt = TVIN_SIG_FMT_HDMI_3840_2160_00HZ;
}
} else {
LOGE("[%s] read error!\n", __FUNCTION__);
}
close(fd);
return sig_fmt;
}
int CPQControl::Cpq_GetAllmAndVrrInfo(void)
{
int ret = -1;
struct tvin_latency_s allmInfo;
struct vdin_vrr_freesync_param_s vrrparm;
memset(&allmInfo, 0x0, sizeof(struct tvin_latency_s));
memset(&vrrparm, 0x0, sizeof(struct vdin_vrr_freesync_param_s));
ret = mpVdin->Tvin_GetAllmInfo(&allmInfo);
LOGD("%s allm_mode: %d, it_content: %d, cn_type: %d\n", __FUNCTION__,
allmInfo.allm_mode, allmInfo.it_content, allmInfo.cn_type);
mCurrentTvinInfo.allmInfo.allm_mode = allmInfo.allm_mode;
mCurrentTvinInfo.allmInfo.it_content = allmInfo.it_content;
mCurrentTvinInfo.allmInfo.cn_type = allmInfo.cn_type;
ret |= mpVdin->Tvin_GetVrrFreesyncParm(&vrrparm);
LOGD("%s cur_vrr_status: %d\n", __FUNCTION__, vrrparm.cur_vrr_status);
mCurrentTvinInfo.vrrparm.cur_vrr_status = vrrparm.cur_vrr_status;
LOGD("%s get info %s\n", __FUNCTION__, (ret < 0) ? "fail" : "success");
return ret;
}
vdin_sig_info_t CPQControl::GetVdinSigInfo(void)
{
vdin_sig_info_t sig_info;
struct tvin_parm_s tvin_param;
memset(&sig_info, 0, sizeof(vdin_sig_info_t));
memset(&tvin_param, 0, sizeof(struct tvin_parm_s));
if (mpVdin->Tvin_GetVdinParam(&tvin_param) >= 0) {
sig_info.fps = tvin_param.info.fps;
}
if (Cpq_GetAllmAndVrrInfo() >= 0) {
sig_info.allm_mode = mCurrentTvinInfo.allmInfo.allm_mode;
sig_info.it_content = mCurrentTvinInfo.allmInfo.it_content;
sig_info.cn_type = mCurrentTvinInfo.allmInfo.cn_type;
sig_info.vrr_mode = mCurrentTvinInfo.vrrparm.cur_vrr_status;
}
return sig_info;
}
int CPQControl::SetCurrenSourceInfo(struct tvin_parm_s *sig_info)
{
if (mCurrentSignalInfo.info.trans_fmt != sig_info->info.trans_fmt
|| mCurrentSignalInfo.info.fmt != sig_info->info.fmt
|| mCurrentSignalInfo.info.status != sig_info->info.status
|| mCurrentSignalInfo.port != sig_info->port
|| mCurrentSignalInfo.info.signal_type != sig_info->info.signal_type) {
mCurrentSignalInfo.info.trans_fmt = sig_info->info.trans_fmt;
mCurrentSignalInfo.info.fmt = sig_info->info.fmt;
mCurrentSignalInfo.info.status = sig_info->info.status;
mCurrentSignalInfo.info.cfmt = sig_info->info.cfmt;
mCurrentSignalInfo.info.signal_type = sig_info->info.signal_type;
mCurrentSignalInfo.info.fps = sig_info->info.fps;
mCurrentSignalInfo.info.is_dvi = sig_info->info.is_dvi;
mCurrentSignalInfo.info.aspect_ratio = sig_info->info.aspect_ratio;
mCurrentSignalInfo.port = sig_info->port;
tv_source_input_t SourceInput;
SourceInput = mpVdin->Tvin_PortToSourceInput(sig_info->port);
if ((SourceInput == SOURCE_MPEG)
|| (SourceInput != SOURCE_MPEG && mCurrentSignalInfo.info.status == TVIN_SIG_STATUS_STABLE)) {
source_input_param_t source_input_param;
memset(&source_input_param, 0x0, sizeof(source_input_param_t));
Cpq_GetAllmAndVrrInfo();
mCurrentTvinInfo.is_dvi = mCurrentSignalInfo.info.is_dvi;
mCurrentTvinInfo.hdr_info = mCurrentSignalInfo.info.signal_type;
source_input_param.source_input = SourceInput;
source_input_param.sig_fmt = mCurrentSignalInfo.info.fmt;
source_input_param.trans_fmt = mCurrentSignalInfo.info.trans_fmt;
SetCurrentSourceInputInfo(source_input_param);
Cpq_SetFilmMakerMode();
}
}
return 0;
}
void CPQControl::onSigStatusChange(void)
{
struct tvin_parm_s tempSignalInfo;
int ret = mpVdin->Tvin_GetVdinParam(&tempSignalInfo);
if (ret < 0) {
LOGD("%s Get Signal Info error\n", __FUNCTION__);
} else {
SetCurrenSourceInfo(&tempSignalInfo);
LOGD("%s source_input is %d, port is %d, sig_fmt is %d, status is %d, isDVI is %d, signal_type is 0x%x\n", __FUNCTION__,
mCurrentSourceInputInfo.source_input, mCurrentSignalInfo.port, mCurrentSignalInfo.info.fmt, mCurrentSignalInfo.info.status,
mCurrentSignalInfo.info.is_dvi, mCurrentSignalInfo.info.signal_type);
}
return;
}
void CPQControl::onAllmOrVrrStatusChange(void)
{
int ret = -1;
ret = Cpq_GetAllmAndVrrInfo();
if (ret < 0) {
LOGD("%s Get vrr or allm status error\n", __FUNCTION__);
} else {
Cpq_SetPqModeToMonitor(AUTO_BY_SIG_CHG_DV_ALLM);
Cpq_SetPqModeToGame(AUTO_BY_SIG_CHG_DV_ALLM);
Cpq_SetFilmMakerMode();
}
}
void CPQControl::stopVdin(void)
{
SetCurrentSource(SOURCE_MPEG);
struct tvin_parm_s tempSignalInfo;
tempSignalInfo.info.trans_fmt = TVIN_TFMT_2D;
tempSignalInfo.info.fmt = TVIN_SIG_FMT_NULL;
tempSignalInfo.info.status = TVIN_SIG_STATUS_NULL;
tempSignalInfo.info.cfmt = TVIN_COLOR_FMT_MAX;
tempSignalInfo.info.signal_type = 0;
tempSignalInfo.info.fps = 60;
tempSignalInfo.info.is_dvi = 0;
tempSignalInfo.info.aspect_ratio = TVIN_ASPECT_NULL;
tempSignalInfo.port = TVIN_PORT_MPEG0;
SetCurrenSourceInfo(&tempSignalInfo);
}
void CPQControl::onUevent(uevent_data_t *ueventData)
{
LOGD("%s matchName:%s\n", __FUNCTION__, ueventData->matchName);
int ret = -1;
struct vdin_event_info SignalEventInfo;
memset(&SignalEventInfo, 0, sizeof(struct vdin_event_info));
ret = mpVdin->Tvin_GetSignalEventInfo(&SignalEventInfo);
if (ret < 0) {
stopVdin();
LOGD("Get vidn event error!\n");
} else {
tv_source_input_type_t source_type = mpVdin->Tvin_SourceInputToSourceInputType(mCurrentSourceInputInfo.source_input);
enum tvin_sg_chg_flg vdinEventType = (enum tvin_sg_chg_flg)SignalEventInfo.event_sts;
switch (vdinEventType) {
case TVIN_SIG_CHG_SDR2HDR:
case TVIN_SIG_CHG_HDR2SDR:
case TVIN_SIG_CHG_DV2NO:
case TVIN_SIG_CHG_NO2DV: {
LOGD("%s: hdr info change!\n", __FUNCTION__);
struct tvin_info_s vdinSignalInfo;
memset(&vdinSignalInfo, 0, sizeof(struct tvin_info_s));
ret = mpVdin->Tvin_GetSignalInfo(&vdinSignalInfo);
if (ret < 0) {
LOGD("%s: Get vidn event error!\n", __FUNCTION__);
} else {
if ((mCurrentSignalInfo.info.status == TVIN_SIG_STATUS_STABLE)
&& (mCurrentSignalInfo.info.signal_type != vdinSignalInfo.signal_type)) {
if (source_type == SOURCE_TYPE_HDMI) {
SetCurrentHdrInfo(vdinSignalInfo.signal_type);
}
mCurrentSignalInfo.info.signal_type = vdinSignalInfo.signal_type;
} else {
LOGD("%s: hdmi signal don't stable!\n", __FUNCTION__);
}
}
break;
}
case TVIN_SIG_CHG_COLOR_FMT:
LOGD("%s: no need do any thing for colorFmt change!\n", __FUNCTION__);
break;
case TVIN_SIG_CHG_RANGE:
LOGD("%s: no need do any thing for colorRange change!\n", __FUNCTION__);
break;
case TVIN_SIG_CHG_BIT:
LOGD("%s: no need do any thing for color bit deepth change!\n", __FUNCTION__);
break;
case TVIN_SIG_CHG_VS_FRQ:
LOGD("%s: no need do any thing for VS_FRQ change!\n", __FUNCTION__);
break;
case TVIN_SIG_CHG_STS:
LOGD("%s: vdin signal status change!\n", __FUNCTION__);
onSigStatusChange();
break;
case TVIN_SIG_CHG_AFD: {
LOGD("%s: AFD info change!\n", __FUNCTION__);
if (source_type == SOURCE_TYPE_HDMI) {
struct tvin_info_s newSignalInfo;
memset(&newSignalInfo, 0, sizeof(struct tvin_info_s));
int ret = mpVdin->Tvin_GetSignalInfo(&newSignalInfo);
if (ret < 0) {
LOGD("%s: Get Signal Info error!\n", __FUNCTION__);
} else {
if ((newSignalInfo.status == TVIN_SIG_STATUS_STABLE) &&
(mCurrentSignalInfo.info.aspect_ratio != newSignalInfo.aspect_ratio)) {
SetCurrentAspectRatioInfo(newSignalInfo.aspect_ratio);
mCurrentSignalInfo.info.aspect_ratio = newSignalInfo.aspect_ratio;
} else {
LOGD("%s: signal not stable or same AFD info!\n", __FUNCTION__);
}
}
}
break;
}
case TVIN_SIG_CHG_DV_ALLM:
case TVIN_SIG_CHG_VRR:
LOGD("%s: allm || vrr info change!\n", __FUNCTION__);
onAllmOrVrrStatusChange();
break;
case TVIN_SIG_CHG_CLOSE_FE:
stopVdin();
break;
default:
LOGD("%s: invalid vdin event!\n", __FUNCTION__);
break;
}
}
}
void CPQControl::onTXStatusChange()
{
LOGD("%s!\n", __FUNCTION__);
SetCurrentSourceInputInfo(mCurrentSourceInputInfo);
}
int CPQControl::LoadPQSettings()
{
int ret = 0;
if (!mbCpqCfg_pq_enable) {
SYS_LOGD("All PQ module disabled\n");
struct pq_ctrl_s pqControlVal;
memset(&pqControlVal, 0, sizeof(struct pq_ctrl_s));
struct vpp_pq_ctrl_s amvecmConfigVal;
memset(&amvecmConfigVal, 0, sizeof(struct vpp_pq_ctrl_s));
amvecmConfigVal.length = 14;//this is the count of pq_ctrl_s option
amvecmConfigVal.ptr = &pqControlVal;
ret = VPPDeviceIOCtl(AMVECM_IOC_S_PQ_CTRL, &amvecmConfigVal);
if (ret < 0) {
SYS_LOGE("%s error: %s\n", __FUNCTION__, strerror(errno));
}
} else {
SYS_LOGD("%s source_input: %d, sig_fmt: 0x%x(%d), trans_fmt: 0x%x\n", __FUNCTION__,
mCurrentSourceInputInfo.source_input, mCurrentSourceInputInfo.sig_fmt,
mCurrentSourceInputInfo.sig_fmt, mCurrentSourceInputInfo.trans_fmt);
ret |= Set_PictureMode((vpp_picture_mode_t)GetPQMode());
ret |= LoadPQTableSettings();
}
return ret;
}
int CPQControl::LoadPQTableSettings()
{
int ret = 0;
PICTURE_SETTING_GLOBAL GLOBAL;
if (GetPictureStructDataGlobal(&GLOBAL)) {
SYS_LOGD("%s: \n"
"aipq_enable: %3d, aipq_mode: %3d, aisr_enable: %3d, aisr_mode: %3d\n"
"EyeProtection: N/A, LocalDimming: N/A, ai_color: %3d, FilmMakerEnable: %3d\n"
"Sdr2Hdr: %3d, Backlight: %3d, Backlight1: %3d, Backlight2: %3d\n"
"osd_Brightness:%3d, osd_Contrast: %3d, osd_Sat: %3d, osd_Hue: %3d\n"
"osd_sharpness: %3d, SBTMMode: N/A, hdr_switch: N/A, hdr10p_switch: N/A\n",
__FUNCTION__,
GLOBAL.aipq_enable, GLOBAL.aipq_mode, GLOBAL.aisr_enable, GLOBAL.aisr_mode,
/*GLOBAL.EyeProtection, GLOBAL.LocalDimming,*/ GLOBAL.ai_color, GLOBAL.FilmMakerEnable,
GLOBAL.Sdr2Hdr, GLOBAL.Backlight.val_display, GLOBAL.Backlight.val_display1, GLOBAL.Backlight.val_display2,
GLOBAL.osd_Brightness, GLOBAL.osd_Contrast, GLOBAL.osd_Saturation, GLOBAL.osd_Hue,
GLOBAL.osd_sharpness/*, GLOBAL.SBTMMode, GLOBAL.hdr_switch, GLOBAL.hdr10p_switch*/);
ret |= AiParamLoad();
enableAipq(GLOBAL.aipq_enable == 1 ? true : false);
ret |= Cpq_SetAiSrMode((aisr_mode_e)GLOBAL.aisr_mode, mCurrentSourceInputInfo);
//to do
//ret |= Cpq_SetSDR2HDR(GLOBAL.Sdr2Hdr);
//ret |= Cpq_SetHDROnOff(GLOBAL.hdr_switch);
//ret |= Cpq_SetHDR10PlusOnOff(GLOBAL.hdr10p_switch);
//ret |= Cpq_SetLocalDimming((vpp_pq_level_t)GLOBAL.LocalDimming);
//ret |= Cpq_SetAipqMode((aipq_mode_e)GLOBAL.aipq_mode, mCurrentSourceInputInfo);
//ret |= Cpq_SetAiColor(GLOBAL.ai_color);
//ret |= Cpq_SetOSDBrightness(GLOBAL.osd_Brightness);
//ret |= Cpq_SetOSDContrast(GLOBAL.osd_Contrast);
//ret |= Cpq_SetOSDSaturationHue(GLOBAL.osd_Saturation, GLOBAL.osd_Hue);
//Cpq_SetOsdSharpnessVariableParam();
//ret |= Cpq_SetOsdSharpnessLevel(GLOBAL.osd_sharpness);
//ret |= Cpq_SetOsdSharpnessFixedParam(0);
//ret |= Cpq_SetBackLight2(GLOBAL.Backlight.val_display1);
//ret |= Cpq_SetBackLight3(GLOBAL.Backlight.val_display2);
//ret |= Cpq_SetSBTMMode(GLOBAL.SBTMMode);
} else {
SYS_LOGE("GetPictureStructDataGlobal fail\n");
}
ret |= Cpq_SetXVYCCMode(VPP_XVYCC_MODE_STANDARD, mCurrentSourceInputInfo);
ret |= Cpq_SetDIModuleParam(mCurrentSourceInputInfo);
/*if ((SOURCE_TV == mCurrentSourceInputInfo.source_input) ||
(SOURCE_AV1 == mCurrentSourceInputInfo.source_input) ||
(SOURCE_AV2 == mCurrentSourceInputInfo.source_input)) {
ret |= SetCVD2Values();
}*/
PICTURE_SETTING_BY_SRC BySrc;
if (GetPictureStructDataBySrc(&BySrc)) {
SYS_LOGD("%s: \n"
"memc: %d\n"
"off: [%2d, %2d]\n"
"low: [%2d, %2d]\n"
"mid: [%2d, %2d]\n"
"high:[%2d, %2d]\n"
"user:[%2d, %2d]\n"
"LocalDimming: %d, DisplayMode: %d, McDiMode: %d,\n"
"AutoGameEnable: %d, AutoMonitorEnable: %d\n",
__FUNCTION__,
BySrc.Memc,
BySrc.memc[MEMC_MODE_OFF].DeJudderLevel, BySrc.memc[MEMC_MODE_OFF].DeBlurLevel,
BySrc.memc[MEMC_MODE_LOW].DeJudderLevel, BySrc.memc[MEMC_MODE_LOW].DeBlurLevel,
BySrc.memc[MEMC_MODE_MID].DeJudderLevel, BySrc.memc[MEMC_MODE_MID].DeBlurLevel,
BySrc.memc[MEMC_MODE_HIGH].DeJudderLevel, BySrc.memc[MEMC_MODE_HIGH].DeBlurLevel,
BySrc.memc[MEMC_MODE_USER].DeJudderLevel, BySrc.memc[MEMC_MODE_USER].DeBlurLevel,
BySrc.LocalDimming, BySrc.DisplayMode, BySrc.McDiMode,
BySrc.AutoGameEnable, BySrc.AutoMonitorEnable);
ret |= Cpq_SetLocalDimming((vpp_pq_level_t)BySrc.LocalDimming);
ret |= Cpq_SetMemcMode(BySrc.Memc, mCurrentSourceInputInfo);
ret |= Cpq_SetMcDiMode((vpp_mcdi_mode_t)BySrc.McDiMode, mCurrentSourceInputInfo);
} else {
SYS_LOGE("%s GetPictureStructDataBySrc fail\n",__FUNCTION__);
}
if (ret < 0) {
SYS_LOGE("%s Some modules failed to set in PQTableSettings, please check!\n",__FUNCTION__);
}
SYS_LOGD("%s Done!\n",__FUNCTION__);
return ret;
}
//reset current input source picture ui setting by Reset_Picture
int CPQControl::ResetPictureUiSetting(void)
{
ResetPictureModeBySrc();
ResetPictureModeDataBySrc();
ResetColorTemperatureDataBySrc();
ResetWhiteBalanceGammaDataBySrc();
ResetPictureStructDataBySrc();
mbResetPicture = true;
return 0;
}
bool CPQControl::LoadPictureModeDbSetting(void)
{
int i = 0, j = 0, k = 0, index = 0;
const char *buf = NULL;
if (!mbCpqCfg_new_picture_mode_enable) {
SYS_LOGE("%s new picture disable!\n", __FUNCTION__);
return false;
}
if (!CheckPQModeTableInDb()) {
SYS_LOGE("%s CheckPQModeTableInDb fail\n", __FUNCTION__);
return false;
}
SYS_LOGD("%s start\n", __FUNCTION__);
SYS_LOGD("Load Nonlinear start\n");
NonlinearModeType Nonlinear = {
/* osd0 osd25 osd50 osd75 osd100*/
0, 64, 128, 192, 255, //_BRIGHTNESS 0~255
0, 64, 128, 192, 255, //_CONTRAST 0~255
0, 64, 128, 192, 255, //_SATURATION 0~255
0, 64, 128, 192, 255, //_HUE 0~255
0, 64, 127, 192, 255, //_SHARPNESS 0~255
0, 64, 128, 192, 255, //_BACKLIGHT 0~255
};
if (!mDataBase->SetNonlinearData(&Nonlinear, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT))
return false;
if (!mDataBase->SetDefaultNonlinearData(&Nonlinear, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT))
return false;
SYS_LOGD("Load Nonlinear end\n");
SYS_LOGD("%s Load PQ MODE start\n", __FUNCTION__);
PICTURE_MODE_DEFAULT PQMode;
memset(&PQMode, 0, sizeof(PICTURE_MODE_DEFAULT));
PQMode.Picture = PICTURE_MODE_STANDARD;
PQMode.Picture_DOLVI = PICTURE_MODE_AMDOLBY_BRIGHT;
PQMode.Picture_HDR = PICTURE_MODE_STANDARD;
PQMode.Picture_HLG = PICTURE_MODE_STANDARD;
PQMode.Picture_HDRP = PICTURE_MODE_STANDARD;
if (!mDataBase->SetPictureMode(&PQMode, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT))
return false;
if (!mDataBase->SetLastPictureMode(&PQMode, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT))
return false;
if (!mDataBase->SetDefaultPictureMode(&PQMode, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT))
return false;
SYS_LOGD("Load PQ MODE end\n");
SYS_LOGD("Load PQ MODE Params start\n");
vpp_pictur_mode_para_t picture;
memset(&picture, 0, sizeof(vpp_pictur_mode_para_t));
index = 0;
for (i = 0; i < PQ_SRC_MAX; i++) {
for (j = 0; j < PQ_FMT_MAX; j++) {
for (k = 0; k < PICTURE_MODE_MAX; k++) {
if (mPQdb->PQ_GetPictureModeParams((pq_source_input_t)i, (pq_sig_fmt_t)j, (vpp_picture_mode_t)k, &picture) == 0) {
picture.Deblock = picture.MpegNr;
picture.Demosquito = picture.MpegNr;
if (!mDataBase->SetPictureModeData((PICTURE_MODE_PARAM *)&picture, i, j, k))
return false;
if (!mDataBase->SetDefaultPictureModeData((PICTURE_MODE_PARAM *)&picture, i, j, k))
return false;
index++;
}
}
}
}
if (index == 0) {
SYS_LOGE("%s PQ_GetPictureModeParams fail\n",__FUNCTION__);
return false;
}
SYS_LOGD("Load PQ MODE Params end\n");
SYS_LOGD("Load Color Temp start\n");
tcon_rgb_ogo_t ColorTemp;
memset(&ColorTemp, 0, sizeof(tcon_rgb_ogo_t));
index = 0;
for (i = 0; i < PQ_SRC_MAX; i++) {
for (j = 0; j < PQ_FMT_MAX; j++) {
for (k = 0; k < COLOR_TMP_MODE_MAX; k++) {
if (mPQdb->PQ_GetColorTemperatureData((vpp_color_temperature_mode_t)k, (pq_source_input_t)i, (pq_sig_fmt_t)j, &ColorTemp) == 0) {
if (!mDataBase->SetColorTemperatureData((COLORTEMP_DATA *)&ColorTemp, i, j, k))
return false;
if (!mDataBase->SetDefaultColorTemperatureData((COLORTEMP_DATA *)&ColorTemp, i, j, k))
return false;
index++;
}
}
}
}
if (index == 0) {
SYS_LOGE("%s PQ_GetColorTemperatureData fail\n",__FUNCTION__);
return false;
}
SYS_LOGD("Load Color Temp end\n");
SYS_LOGD("Load Color Temp offset start\n");
COLORTEMP_OFFSET_DATA rgbOffset;
memset(&rgbOffset, 0, sizeof(COLORTEMP_OFFSET_DATA));
for (i = 0; i < COLOR_TMP_MODE_MAX; i++) {
if (!mDataBase->SetRGBOffsetData(&rgbOffset, i, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT))
return false;
if (!mDataBase->SetDefaultRGBOffsetData(&rgbOffset, i, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT))
return false;
}
SYS_LOGD("Load Color Temp offset end\n");
SYS_LOGD("Load wb Gamma start\n");
GAMMA_OFFSET_DATA WBGamm;
memset(&WBGamm, 0, sizeof(WB_GAMMA_TABLE));
WBGamm.enable = 1;
for (i = 0; i < COLOR_TMP_MODE_MAX; i++) {
for (j = 0; j < WB_GAMMA_MODE_MAX; j++) {
if (!mDataBase->SetGammaOffsetData(&WBGamm, i, j, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT))
return false;
if (!mDataBase->SetDefaultGammaOffsetData(&WBGamm, i, j, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT))
return false;
}
}
SYS_LOGD("Load wb Gamma end\n");
SYS_LOGD("Load color customize start\n");
TABLE_CMS param_cm;
memset(&param_cm, 0, sizeof(TABLE_CMS));
Cpq_GetColorCustomizeDefValue(&param_cm);
if (!mDataBase->SetColorCustomizeData(&param_cm, PICTURE_MODE_STANDARD, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT))
return false;
if (!mDataBase->SetDefaultColorCustomizeData(&param_cm, PICTURE_MODE_STANDARD, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT))
return false;
SYS_LOGD("Load color customize end\n");
SYS_LOGD("Load By Source start\n");
PICTURE_SETTING_BY_SRC BySource;
memset(&BySource, 0, sizeof(PICTURE_SETTING_BY_SRC));
BySource.McDiMode = mPQConfigFile->GetInt(CFG_SECTION_PQ, CFG_MCDI_DEF, VPP_MCDI_MODE_STANDARD);
BySource.LocalDimming = mPQConfigFile->GetInt(CFG_SECTION_PQ, CFG_LOCALDIMMING_DEF, VPP_PQ_LV_OFF);
BySource.Memc = mPQConfigFile->GetInt(CFG_SECTION_PQ, CFG_MEMCMODE_DEF, VPP_MEMC_MODE_HIGH);
BySource.DisplayMode = mPQConfigFile->GetInt(CFG_SECTION_PQ, CFG_DISPLAYMODE_DEF, VPP_DISPLAY_MODE_NORMAL);
buf = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_MEMCDEBLURLEVEL_DEF, NULL);
int Deblur_para[MEMC_MODE_MAX] = {0, 3, 6, 10, 10};
if (buf != NULL)
pqTransformStringToInt(buf, Deblur_para);
for (j = 0; j < MEMC_MODE_MAX; j++) {
BySource.memc[j].DeBlurLevel = Deblur_para[j];
}
buf = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_MEMCDEJUDDERLEVEL_DEF, NULL);
int DeJudder_para[MEMC_MODE_MAX] = {0, 3, 6, 10, 10};
if (buf != NULL)
pqTransformStringToInt(buf, DeJudder_para);
for (j = 0; j < MEMC_MODE_MAX; j++) {
BySource.memc[j].DeJudderLevel = DeJudder_para[j];
}
if (!mDataBase->SetPictureStructDataBySrc(&BySource, PQ_SRC_DEFAULT))
return false;
if (!mDataBase->SetDefaultPictureStructDataBySrc(&BySource, PQ_SRC_DEFAULT))
return false;
SYS_LOGD("Load By Source end\n");
SYS_LOGD("Load Global start\n");
PICTURE_SETTING_GLOBAL Global;
memset(&Global, 0, sizeof(PICTURE_SETTING_GLOBAL));
Global.aipq_enable = 0;
Global.aisr_mode = 1;
Global.osd_Brightness = 50;
Global.osd_Contrast = 50;
Global.osd_Hue = 0;
Global.osd_Saturation = 50;
Global.WBGammaPoint = WB_GAMMA_MODE_11POINT;
Global.FilmMakerEnable = mPQConfigFile->GetInt(CFG_SECTION_PQ, CFG_FMM_MODE_DEF, FILM_MAKER_MODE_DISABLE);
if (!mDataBase->SetPictureStructDataGlobal(&Global))
return false;
if (!mDataBase->SetDefaultPictureStructDataGlobal(&Global))
return false;
SYS_LOGD("Load Global end\n");
SYS_LOGD("Load LVDS start\n");
buf = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_LVDSSSC_DEF, NULL);
int lvds_ssc_buf[3] = {0, 0, 0};
if (buf != NULL)
pqTransformStringToInt(buf, lvds_ssc_buf);
LCD_LVDS_SSC lvds_ssc;
memset(&lvds_ssc, 0, sizeof(LCD_LVDS_SSC));
lvds_ssc.level = (unsigned int)lvds_ssc_buf[0];
lvds_ssc.freq = (unsigned int)lvds_ssc_buf[1];
lvds_ssc.mode = (unsigned int)lvds_ssc_buf[2];
for (i = 0; i < 8; i++) { //8 panel
if (!mDataBase->SetLvdsSscData(&lvds_ssc, i))
return false;
}
SYS_LOGD("Load LVDS end\n");
SYS_LOGD("%s end\n", __FUNCTION__);
return true;
}
bool CPQControl::CheckSSMData(void)
{
//SSM file check
const char *config_value;
std::string filePath1;
std::string filePath2;
config_value = mPQConfigFile->GetSettingDataFilePath(CFG_SECTION_PQ, CFG_PQ_SETTINGDATA_FILE_PATH, NULL);
if (!config_value) {
LOGD("%s: read setting data file path failed,use default path:%s\n", __FUNCTION__, PQ_SETTINGDATA_DEFAULT_PATH);
filePath1 = PQ_SETTINGDATA_DEFAULT_PATH;
} else {
LOGD("%s: setting data file path is %s\n", __FUNCTION__, config_value);
filePath1 = config_value;
}
config_value = mPQConfigFile->GetWhiteBalanceFilePath(CFG_SECTION_PQ, CFG_PQ_WHITEBALANCE_FILE_PATH, NULL);
if (!config_value) {
LOGD("%s: read whitebalance data file path failed,use default path:%s\n", __FUNCTION__, PQ_WHITEBALANCE_DEFAULT_PATH);
filePath2 = PQ_WHITEBALANCE_DEFAULT_PATH;
} else {
LOGD("%s: whitebalance data file path is %s\n", __FUNCTION__, config_value);
filePath2 = config_value;
}
mSSMAction = SSMAction::getInstance();
if (!mSSMAction->Check(filePath1.c_str(), filePath2.c_str())) {
LOGI("%s: check ssmdata fail, skip sync\n", __FUNCTION__);
return false;
}
if (!SyncDataBase::GetInstance()->SyncDataBaseInit()) {
LOGI("%s: SyncDataBaseInit fail\n", __FUNCTION__);
return false;
}
return true;
}
int CPQControl::Set_PictureMode(vpp_picture_mode_t pq_mode)
{
int ret = 0;
SetPcGameMode(pq_mode);
ret |= SetDisplayMode((vpp_display_mode_t)GetDisplayMode(), 0);
ret |= SetPQPictureMode(pq_mode);
if (ret < 0) {
SYS_LOGE("%s failed!\n",__FUNCTION__);
} else {
SYS_LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::SetPQPictureMode(vpp_picture_mode_t pq_mode)
{
int ret = 0;
SetFacColorParams(mCurrentSourceInputInfo, pq_mode);
PICTURE_MODE_PARAM PictureMode;
if (!GetPictureModeData(&PictureMode, pq_mode)) {
SYS_LOGE("%s: GetPictureModeData fail!\n", __FUNCTION__);
return -1;
}
SYS_LOGI("%s:\n"
"PictureMode: %3d.\n"
"Brightness: %3d, Contrast: %3d, Saturation: %3d, Hue: %3d\n"
"Sharpness: %3d, Backlight: %3d, Nr: %3d, DynamicContrast: %3d\n"
"ColorGamut: %3d, ColorTemperature: %3d, LocalContrast: %3d, BlackStretch: %3d\n"
"BlueStretch: %3d, MpegNr: %3d, ChromaCoring: %3d, DvMode: %3d\n"
"DvDarkDetail: %3d, SuperResolution: %3d, GammaMidLuminance %3d, CmLevel: %3d\n"
"HdrTmo: %3d, DynamicBackLight: %3d, EyeProtection: %3d, SmoothPlus: %3d\n"
"WhiteStretch: %3d\n",
__FUNCTION__,
pq_mode,
PictureMode.Brightness, PictureMode.Contrast, PictureMode.Saturation, PictureMode.Hue,
PictureMode.Sharpness, PictureMode.Backlight, PictureMode.Nr, PictureMode.DynamicContrast,
PictureMode.ColorGamut, PictureMode.ColorTemperature, PictureMode.LocalContrast, PictureMode.BlackStretch,
PictureMode.BlueStretch, PictureMode.MpegNr, PictureMode.ChromaCoring, PictureMode.AmlDolbyMode,
PictureMode.AmlDolbyDarkDetail, PictureMode.SuperResolution, PictureMode.GammaMidLuminance, PictureMode.CmLevel,
PictureMode.HdrTmo, PictureMode.DynamicBacklight, PictureMode.EyeProtection, PictureMode.SmoothPlus,
PictureMode.WhiteStretch);
ret |= Cpq_SetColorBaseMode((vpp_color_basemode_t)PictureMode.CmLevel, mCurrentSourceInputInfo);
ret |= Cpq_SetBrightness(PictureMode.Brightness, mCurrentSourceInputInfo);
ret |= Cpq_SetContrast(PictureMode.Contrast, mCurrentSourceInputInfo);
ret |= Cpq_SetSaturation(PictureMode.Saturation, mCurrentSourceInputInfo);
ret |= Cpq_SetHue(PictureMode.Hue, mCurrentSourceInputInfo);
ret |= Cpq_SetSharpness(PictureMode.Sharpness, mCurrentSourceInputInfo);
ret |= Cpq_SetSuperResolution(PictureMode.SuperResolution);
ret |= Cpq_SetNoiseReductionMode((vpp_noise_reduction_mode_t)PictureMode.Nr, mCurrentSourceInputInfo);
ret |= Cpq_SetDnlpMode((Dynamic_contrast_mode_t)PictureMode.DynamicContrast, mCurrentSourceInputInfo);
ret |= Cpq_SetLocalContrastMode((local_contrast_mode_t)PictureMode.LocalContrast);
ret |= Cpq_SetColorGamutMode((vpp_colorgamut_mode_t)PictureMode.ColorGamut);
ret |= Cpq_BlackStretch(PictureMode.BlackStretch, mCurrentSourceInputInfo);
ret |= Cpq_SetWhiteStretch(PictureMode.WhiteStretch, mCurrentSourceInputInfo);
ret |= Cpq_BlueStretch(PictureMode.BlueStretch, mCurrentSourceInputInfo);
ret |= Cpq_ChromaCoring(PictureMode.ChromaCoring, mCurrentSourceInputInfo);
ret |= Cpq_SetDeblockMode((vpp_deblock_mode_t)PictureMode.Deblock, mCurrentSourceInputInfo);
ret |= Cpq_SetDemoSquitoMode((vpp_demosquito_mode_t)PictureMode.Demosquito, mCurrentSourceInputInfo);
ret |= Cpq_SetSmoothPlusMode((vpp_smooth_plus_mode_t)PictureMode.SmoothPlus, mCurrentSourceInputInfo);
ret |= Cpq_SetWhitebalance(PictureMode.ColorTemperature, PictureMode.GammaMidLuminance);
//hdr tmo
ret |= Cpq_SetHDRTMOMode(PictureMode.HdrTmo);
//amldolby
ret |= Cpq_SetAmdolbyPQMode(PictureMode.AmlDolbyMode);
ret |= Cpq_SetAmdolbyDarkDetail(PictureMode.AmlDolbyDarkDetail);
//Blend CMS
TABLE_CMS param;
if (GetColorCustomizeData(&param, pq_mode)) {
if (param.CmsEnable == 0) {
memset(&param, 0, sizeof(TABLE_CMS));
}
for (int i = VPP_COLOR_9_PURPLE; i < VPP_COLOR_9_MAX; i++) {
Cpq_SetColorCustomize((vpp_cms_color_t)i, VPP_CMS_TYPE_SAT, param.CmsColor[i].sat);
Cpq_SetColorCustomize((vpp_cms_color_t)i, VPP_CMS_TYPE_HUE, param.CmsColor[i].hue);
Cpq_SetColorCustomize((vpp_cms_color_t)i, VPP_CMS_TYPE_LUMA, param.CmsColor[i].luma);
}
}
if (ret < 0) {
SYS_LOGE("%s failed!\n",__FUNCTION__);
} else {
SYS_LOGD("%s success! pq_mode: %d\n",__FUNCTION__, pq_mode);
}
return ret;
}
void CPQControl::SetPcGameMode(vpp_picture_mode_t pq_mode)
{
//enable or disable game/pc mode
if ((mCurrentSourceInputInfo.source_input == SOURCE_HDMI1) ||
(mCurrentSourceInputInfo.source_input == SOURCE_HDMI2) ||
(mCurrentSourceInputInfo.source_input == SOURCE_HDMI3) ||
(mCurrentSourceInputInfo.source_input == SOURCE_HDMI4)) {//HDMI source;
int last_pq_mode = GetLastPQMode();
if (last_pq_mode == VPP_PICTURE_MODE_GAME) {
if (pq_mode == VPP_PICTURE_MODE_GAME) {//game mode on and monitor mode off;
Cpq_SetGameMode(MODE_ON);
Cpq_SetPCMode(MODE_OFF);
} else if (pq_mode == VPP_PICTURE_MODE_MONITOR) {//game mode off and monitor mode on;
Cpq_SetGameMode(MODE_OFF);
Cpq_SetPCMode(MODE_ON);
} else {//game mode off and monitor mode off;
Cpq_SetGameMode(MODE_OFF);
Cpq_SetPCMode(MODE_OFF);
}
} else if (last_pq_mode == VPP_PICTURE_MODE_MONITOR) {
if (pq_mode == VPP_PICTURE_MODE_MONITOR) {//game mode off and monitor mode on;
Cpq_SetGameMode(MODE_OFF);
Cpq_SetPCMode(MODE_ON);
} else if (pq_mode == VPP_PICTURE_MODE_GAME) {//game mode on and monitor mode off;
Cpq_SetGameMode(MODE_ON);
Cpq_SetPCMode(MODE_OFF);
} else {//game mode off and monitor mode off;
Cpq_SetGameMode(MODE_OFF);
Cpq_SetPCMode(MODE_OFF);
}
} else {
if (pq_mode == VPP_PICTURE_MODE_GAME) {//game mode on and monitor mode off;
Cpq_SetGameMode(MODE_ON);
Cpq_SetPCMode(MODE_OFF);
} else if (pq_mode == VPP_PICTURE_MODE_MONITOR) {//game mode off and monitor mode on;
Cpq_SetGameMode(MODE_OFF);
Cpq_SetPCMode(MODE_ON);
} else {//game mode off and monitor mode off;
Cpq_SetGameMode(MODE_OFF);
Cpq_SetPCMode(MODE_OFF);
}
}
} else {//other source, game mode off and monitor mode off;
if (mInitialized) {
Cpq_SetGameMode(MODE_OFF);
Cpq_SetPCMode(MODE_OFF);
}
}
return;
}
int CPQControl::SetFacColorParams(source_input_param_t source_input_param, vpp_picture_mode_t pqMode)
{
int ret = 0;
ret |= Cpq_SetSharpnessVariableParam(source_input_param);
ret |= Cpq_SetSharpness0VariableParam(source_input_param);
ret |= Cpq_SetSharpness1VariableParam(source_input_param);
if (ret < 0) {
SYS_LOGE("%s failed\n",__FUNCTION__);
} else {
SYS_LOGD("%s success! pqMode: %d\n",__FUNCTION__, pqMode);
}
return ret;
}
pq_source_input_t CPQControl::CheckPQSource(tv_source_input_t source)
{
pq_source_input_t src = PQ_SRC_DEFAULT;
switch (source) {
case SOURCE_TV:
src = PQ_SRC_TV;
break;
case SOURCE_AV1:
src = PQ_SRC_AV1;
break;
case SOURCE_AV2:
src = PQ_SRC_AV2;
break;
case SOURCE_YPBPR1:
src = PQ_SRC_YPBPR1;
break;
case SOURCE_YPBPR2:
src = PQ_SRC_YPBPR2;
break;
case SOURCE_HDMI1:
src = PQ_SRC_HDMI1;
break;
case SOURCE_HDMI2:
src = PQ_SRC_HDMI2;
break;
case SOURCE_HDMI3:
src = PQ_SRC_HDMI3;
break;
case SOURCE_HDMI4:
src = PQ_SRC_HDMI4;
break;
case SOURCE_VGA:
src = PQ_SRC_VGA;
break;
case SOURCE_MPEG:
src = PQ_SRC_MPEG;
break;
case SOURCE_DTV:
src = PQ_SRC_DTV;
break;
case SOURCE_SVIDEO:
src = PQ_SRC_SVIDEO;
break;
case SOURCE_IPTV:
src = PQ_SRC_IPTV;
break;
case SOURCE_DUMMY:
src = PQ_SRC_DUMMY;
break;
case SOURCE_SPDIF:
src = PQ_SRC_SPDIF;
break;
case SOURCE_ADTV:
src = PQ_SRC_ADTV;
break;
default:
src = PQ_SRC_DEFAULT;
break;
}
return src;
}
pq_sig_fmt_t CPQControl::CheckPQTimming(enum hdr_type_e hdr_type)
{
pq_sig_fmt_t timming = PQ_FMT_DEFAULT;
switch (hdr_type) {
case HDRTYPE_HDR10:
timming = PQ_FMT_HDR;
break;
case HDRTYPE_HDR10PLUS:
timming = PQ_FMT_HDRP;
break;
case HDRTYPE_DOVI:
timming = PQ_FMT_DOLVI;
break;
case HDRTYPE_HLG:
timming = PQ_FMT_HLG;
break;
case HDRTYPE_SDR:
timming = PQ_FMT_SDR;
break;
default:
timming = PQ_FMT_DEFAULT;
break;
}
return timming;
}
bool CPQControl::CheckPQLoadTableSourceInput(source_input_param_t SourceInput)
{
LOGD("%s SigFmt in = %d{0x%x}\n",__FUNCTION__, SourceInput.sig_fmt, SourceInput.sig_fmt);
if ((SourceInput.source_input >= SOURCE_HDMI1 && SourceInput.source_input <= SOURCE_HDMI4) ||
(SourceInput.source_input == SOURCE_DTV) ||
(SourceInput.source_input == SOURCE_MPEG)) {
switch (SourceInput.sig_fmt) {
case TVIN_SIG_FMT_HDMI_640X480P_60HZ:
case TVIN_SIG_FMT_HDMI_720X480P_60HZ:
case TVIN_SIG_FMT_HDMI_1440X480I_60HZ:
case TVIN_SIG_FMT_HDMI_1440X240P_60HZ:
case TVIN_SIG_FMT_HDMI_2880X480I_60HZ:
case TVIN_SIG_FMT_HDMI_2880X240P_60HZ:
case TVIN_SIG_FMT_HDMI_1440X480P_60HZ:
case TVIN_SIG_FMT_HDMI_1440X288P_50HZ:
case TVIN_SIG_FMT_HDMI_2880X288P_50HZ:
case TVIN_SIG_FMT_HDMI_2880X480P_60HZ:
case TVIN_SIG_FMT_HDMI_720X480P_120HZ:
case TVIN_SIG_FMT_HDMI_1440X480I_120HZ:
case TVIN_SIG_FMT_HDMI_720X480P_240HZ:
case TVIN_SIG_FMT_HDMI_1440X480I_240HZ:
case TVIN_SIG_FMT_HDMI_720X400_00HZ:
case TVIN_SIG_FMT_HDMI_720X480P_60HZ_FRAME_PACKING:
case TVIN_SIG_FMT_HDMI_640X480P_72HZ:
case TVIN_SIG_FMT_HDMI_640X480P_75HZ:
case TVIN_SIG_FMT_HDMI_720X350_00HZ:
case TVIN_SIG_FMT_HDMI_960X540_60HZ:
case TVIN_SIG_FMT_HDMI_640X350_85HZ:
case TVIN_SIG_FMT_HDMI_640X400_85HZ:
case TVIN_SIG_FMT_HDMI_848X480_60HZ:
case TVIN_SIG_FMT_HDMI_720X480I_60HZ:
case TVIN_SIG_FMT_HDMI_720X240:
case TVIN_SIG_FMT_HDMI_360X480I:
case TVIN_SIG_FMT_HDMI_360X480P:
case TVIN_SIG_FMT_BT656IN_480I_60HZ:
case TVIN_SIG_FMT_BT601IN_480I_60HZ:
case TVIN_SIG_FMT_CAMERA_640X480P_30HZ:
if (mCurrentHdrType == HDRTYPE_HDR10)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDR10_480;
else if (mCurrentHdrType == HDRTYPE_HLG)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HLG_480;
else if (mCurrentHdrType == HDRTYPE_HDR10PLUS)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDRPLUS_480;
else if (mCurrentHdrType == HDRTYPE_DOVI)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_AMLDOLBY_480;
else
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_NULL;
break;
case TVIN_SIG_FMT_HDMI_720X576P_50HZ:
case TVIN_SIG_FMT_HDMI_1440X576I_50HZ:
case TVIN_SIG_FMT_HDMI_2880X576I_50HZ:
case TVIN_SIG_FMT_HDMI_1440X576P_50HZ:
case TVIN_SIG_FMT_HDMI_2880X576P_50HZ:
case TVIN_SIG_FMT_HDMI_720X576P_100HZ:
case TVIN_SIG_FMT_HDMI_720X576P_200HZ:
case TVIN_SIG_FMT_HDMI_1440X576I_200HZ:
case TVIN_SIG_FMT_HDMI_800X600_00HZ:
case TVIN_SIG_FMT_HDMI_720X576P_50HZ_FRAME_PACKING:
case TVIN_SIG_FMT_HDMI_3840X600_00HZ:
case TVIN_SIG_FMT_HDMI_720X576I_50HZ:
case TVIN_SIG_FMT_HDMI_360X576I:
case TVIN_SIG_FMT_HDMI_360X576P:
case TVIN_SIG_FMT_BT656IN_576I_50HZ:
case TVIN_SIG_FMT_BT601IN_576I_50HZ:
case TVIN_SIG_FMT_CAMERA_800X600P_30HZ:
if (mCurrentHdrType == HDRTYPE_HDR10)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDR10_576;
else if (mCurrentHdrType == HDRTYPE_HLG)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HLG_576;
else if (mCurrentHdrType == HDRTYPE_HDR10PLUS)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDRPLUS_576;
else if (mCurrentHdrType == HDRTYPE_DOVI)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_AMLDOLBY_576;
else
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_NULL;
break;
case TVIN_SIG_FMT_HDMI_1280X720P_60HZ:
case TVIN_SIG_FMT_HDMI_1280X720P_50HZ:
case TVIN_SIG_FMT_HDMI_1280X720P_100HZ:
case TVIN_SIG_FMT_HDMI_1280X720P_120HZ:
case TVIN_SIG_FMT_HDMI_1280X720P_24HZ:
case TVIN_SIG_FMT_HDMI_1280X720P_25HZ:
case TVIN_SIG_FMT_HDMI_1280X720P_30HZ:
case TVIN_SIG_FMT_HDMI_1280X720P_60HZ_FRAME_PACKING:
case TVIN_SIG_FMT_HDMI_1280X720P_50HZ_FRAME_PACKING:
case TVIN_SIG_FMT_HDMI_1280X720P_24HZ_FRAME_PACKING:
case TVIN_SIG_FMT_HDMI_1280X720P_30HZ_FRAME_PACKING:
case TVIN_SIG_FMT_HDMI_1024X768_00HZ:
case TVIN_SIG_FMT_HDMI_1280X768_00HZ:
case TVIN_SIG_FMT_HDMI_1280X800_00HZ:
case TVIN_SIG_FMT_HDMI_1280X960_00HZ:
case TVIN_SIG_FMT_HDMI_1280X1024_00HZ:
case TVIN_SIG_FMT_HDMI_1360X768_00HZ:
case TVIN_SIG_FMT_HDMI_1366X768_00HZ:
case TVIN_SIG_FMT_HDMI_1440X900_00HZ:
case TVIN_SIG_FMT_HDMI_1400X1050_00HZ:
case TVIN_SIG_FMT_HDMI_1680X1050_00HZ:
case TVIN_SIG_FMT_HDMI_1600X900_60HZ:
case TVIN_SIG_FMT_HDMI_1152X864_00HZ:
case TVIN_SIG_FMT_CAMERA_1024X768P_30HZ:
case TVIN_SIG_FMT_CAMERA_1280X720P_30HZ:
if (mCurrentHdrType == HDRTYPE_HDR10)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDR10_720;
else if (mCurrentHdrType == HDRTYPE_HLG)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HLG_720;
else if (mCurrentHdrType == HDRTYPE_HDR10PLUS)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDRPLUS_720;
else if (mCurrentHdrType == HDRTYPE_DOVI)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_AMLDOLBY_720;
else
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_NULL;
break;
case TVIN_SIG_FMT_HDMI_1920X1080I_60HZ:
case TVIN_SIG_FMT_HDMI_1920X1080P_60HZ:
case TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_A:
case TVIN_SIG_FMT_HDMI_1920X1080P_50HZ:
case TVIN_SIG_FMT_HDMI_1920X1080P_24HZ:
case TVIN_SIG_FMT_HDMI_1920X1080P_25HZ:
case TVIN_SIG_FMT_HDMI_1920X1080P_30HZ:
case TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_B:
case TVIN_SIG_FMT_HDMI_1920X1080I_100HZ:
case TVIN_SIG_FMT_HDMI_1920X1080I_120HZ:
case TVIN_SIG_FMT_HDMI_1920X1080P_120HZ:
case TVIN_SIG_FMT_HDMI_1920X1080P_100HZ:
case TVIN_SIG_FMT_HDMI_1920X1080I_60HZ_FRAME_PACKING:
case TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_FRAME_PACKING:
case TVIN_SIG_FMT_HDMI_1920X1080P_24HZ_FRAME_PACKING:
case TVIN_SIG_FMT_HDMI_1920X1080P_30HZ_FRAME_PACKING:
case TVIN_SIG_FMT_HDMI_1600X1200_00HZ:
case TVIN_SIG_FMT_HDMI_1920X1200_00HZ:
case TVIN_SIG_FMT_HDMI_1920X1080I_60HZ_ALTERNATIVE:
case TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_ALTERNATIVE:
case TVIN_SIG_FMT_HDMI_1920X1080P_24HZ_ALTERNATIVE:
case TVIN_SIG_FMT_HDMI_1920X1080P_30HZ_ALTERNATIVE:
case TVIN_SIG_FMT_HDMI_2688X1520_00HZ:
case TVIN_SIG_FMT_HDMI_2560X1440_00HZ:
case TVIN_SIG_FMT_HDMI_1792X1344_85HZ:
case TVIN_SIG_FMT_HDMI_1856X1392_00HZ:
case TVIN_SIG_FMT_HDMI_1920X1440_00HZ:
case TVIN_SIG_FMT_HDMI_2048X1152_60HZ:
case TVIN_SIG_FMT_HDMI_2560X1600_00HZ:
case TVIN_SIG_FMT_HDMI_2560X1080P_24HZ:
case TVIN_SIG_FMT_HDMI_2560X1080P_25HZ:
case TVIN_SIG_FMT_HDMI_2560X1080P_30HZ:
case TVIN_SIG_FMT_HDMI_2560X1080P_50HZ:
case TVIN_SIG_FMT_HDMI_2560X1080P_60HZ:
case TVIN_SIG_FMT_HDMI_2560X1080P_100HZ:
case TVIN_SIG_FMT_HDMI_2560X1080P_120HZ:
case TVIN_SIG_FMT_HDMI_3840X1080P_60HZ:
case TVIN_SIG_FMT_CAMERA_1920X1080P_30HZ:
if (mCurrentHdrType == HDRTYPE_HDR10)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDR10_1080;
else if (mCurrentHdrType == HDRTYPE_HLG)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HLG_1080;
else if (mCurrentHdrType == HDRTYPE_HDR10PLUS)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDRPLUS_1080;
else if (mCurrentHdrType == HDRTYPE_DOVI)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_AMLDOLBY_1080;
else
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_NULL;
break;
case TVIN_SIG_FMT_HDMI_3840_2160_00HZ:
case TVIN_SIG_FMT_HDMI_4096_2160_00HZ:
case TVIN_SIG_FMT_HDMI_1920X2160_60HZ:
case TVIN_SIG_FMT_HDMI_5120X2880:
case TVIN_SIG_FMT_HDMI_2560X2880:
if (mCurrentHdrType == HDRTYPE_HDR10)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDR10_4K2K;
else if (mCurrentHdrType == HDRTYPE_HLG)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HLG_4K2K;
else if (mCurrentHdrType == HDRTYPE_HDR10PLUS)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDRPLUS_4K2K;
else if (mCurrentHdrType == HDRTYPE_DOVI)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_AMLDOLBY_4K2K;
else
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_NULL;
break;
case TVIN_SIG_FMT_HDMI_7680X4320:
case TVIN_SIG_FMT_HDMI_3840X4320:
if (mCurrentHdrType == HDRTYPE_HDR10)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDR_8K;
else if (mCurrentHdrType == HDRTYPE_HLG)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HLG_8K;
else if (mCurrentHdrType == HDRTYPE_HDR10PLUS)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_HDRPLUS_8K;
else if (mCurrentHdrType == HDRTYPE_DOVI)
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_AMLDOLBY_8K;
else
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_NULL;
break;
default:
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_NULL;
break;
}
} else {
mPQdb->mLoadSigFmt = TVIN_SIG_FMT_NULL;
}
LOGD("%s LoadSigFmt out = %d{0x%x}\n",__FUNCTION__, mPQdb->mLoadSigFmt, mPQdb->mLoadSigFmt);
return true;
}
int CPQControl::SetAmdolbyDarkDetail(int mode, int is_save)
{
SYS_LOGD("%s, mode = %d\n", __FUNCTION__, mode);
int ret = Cpq_SetAmdolbyDarkDetail(mode);
if (ret == 0 && is_save == 1) {
ret = SaveAmdolbyDarkDetail(mode);
}
if (ret < 0) {
SYS_LOGE("%s failed!\n",__FUNCTION__);
} else {
SYS_LOGD("%s success!\n",__FUNCTION__);
}
return 0;
}
int CPQControl::GetAmdolbyDarkDetail(void)
{
int mode = -1;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return mode;
}
mode = para.AmlDolbyDarkDetail;
SYS_LOGD("%s, source: %d, timming: %d, mode = %d\n", __FUNCTION__, CurSource, CurTimming, mode);
return mode;
}
int CPQControl::SaveAmdolbyDarkDetail(int value)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.AmlDolbyDarkDetail = value;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d value: %d fail\n",__FUNCTION__, CurSource, CurTimming, value);
return -1;
}
SYS_LOGI("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetAmdolbyDarkDetail(int mode)
{
if (mode < 0) {
SYS_LOGD("%s Skip dv dark detail!\n",__FUNCTION__);
return 0;
}
int ret = -1;
ret = mDolbyVision->SetAmdolbyPQDarkDetail(mode);
if (ret < 0)
SYS_LOGE("%s failed!\n",__FUNCTION__);
else
SYS_LOGD("%s success! mode: %d\n",__FUNCTION__, mode);
return ret;
}
int CPQControl::Cpq_SetAmdolbyPQMode(int mode)
{
if (mode < 0) {
SYS_LOGD("%s Skip DV Mode\n",__FUNCTION__);
return 0;
}
int ret = mDolbyVision->SetAmdolbyPQMode((dolby_pq_mode_t)mode);
if (ret < 0)
SYS_LOGE("%s failed!\n",__FUNCTION__);
return ret;
}
int CPQControl::Cpq_LoadRegs(am_regs_t *regs)
{
if (regs->length == 0) {
SYS_LOGD("%s--Regs is NULL\n", __FUNCTION__);
return -1;
}
int count_retry = 20;
int ret = 0;
while (count_retry) {
ret = VPPDeviceIOCtl(AMVECM_IOC_LOAD_REG, regs);
if (ret < 0) {
SYS_LOGE("%s, error(%s), errno(%d)\n", __FUNCTION__, strerror(errno), errno);
if (errno == EBUSY) {
SYS_LOGE("%s, %s, retry...\n", __FUNCTION__, strerror(errno));
count_retry--;
usleep(20 * 1000); // sleep 20ms to avoid busy
continue;
}
}
break;
}
return ret;
}
int CPQControl::Cpq_LoadDisplayModeRegs(struct ve_pq_load_s regs)
{
if (regs.length == 0) {
SYS_LOGD("%s--Regs is NULL!\n", __FUNCTION__);
return -1;
}
int count_retry = 20;
int ret = 0;
while (count_retry) {
ret = VPPDeviceIOCtl(AMVECM_IOC_SET_OVERSCAN, &regs);
if (ret < 0) {
SYS_LOGE("%s, error(%s), errno(%d)\n", __FUNCTION__, strerror(errno), errno);
if (errno == EBUSY) {
SYS_LOGE("%s, %s, retry...\n", __FUNCTION__, strerror(errno));
count_retry--;
continue;
}
}
break;
}
return ret;
}
int CPQControl::DI_LoadRegs(struct am_pq_parm_s di_regs)
{
int count_retry = 20;
int ret = 0;
while (count_retry) {
ret = DIDeviceIOCtl(AMDI_IOC_SET_PQ_PARM, &di_regs);
if (ret < 0) {
SYS_LOGE("%s, error(%s), errno(%d)\n", __FUNCTION__, strerror(errno), errno);
if (errno == EBUSY) {
SYS_LOGE("%s, %s, retry...\n", __FUNCTION__, strerror(errno));
count_retry--;
continue;
}
}
break;
}
return ret;
}
int CPQControl::Cpq_SetDIModuleParam(source_input_param_t source_input_param)
{
if (!mbCpqCfg_di_enable) {
LOGD("DI module disabled!\n");
return 0;
}
if (mbCpqCfg_dpss_enable) {
struct vpq_xlr_param_s param;
memset(&param, 0, sizeof(struct vpq_xlr_param_s));
if (mPQdb->PQ_GetDpssDiParams(source_input_param, &param) < 0) {
LOGE("%s: PQ_GetDpssDiParams failed!\n", __FUNCTION__);
return -1;
}
if (VpqDeviceIOCtl(VPQ_IOC_SET_XLR_DPSS, &param) < 0) {
LOGE("%s: VPQ_IOC_SET_XLR_DPSS failed!\n", __FUNCTION__);
return -1;
}
} else {
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetDIParams(source_input_param, regs) < 0) {
LOGE("%s GetDIParams failed!\n", __FUNCTION__);
return -1;
}
if (regs->length == 0) {
LOGE("%s: get DI Module Param failed!\n", __FUNCTION__);
return-1;
}
struct am_pq_parm_s di_regs;
memset(&di_regs, 0x0, sizeof(struct am_pq_parm_s));
di_regs.table_name |= TABLE_NAME_DI;
di_regs.table_len = regs->length;
struct am_reg_s tmp_buf[regs->length];
for (unsigned int i=0;i<regs->length;i++) {
tmp_buf[i].addr = regs->am_reg[i].addr;
tmp_buf[i].mask = regs->am_reg[i].mask;
tmp_buf[i].type = regs->am_reg[i].type;
tmp_buf[i].val = regs->am_reg[i].val;
}
di_regs.table_ptr = tmp_buf;
if (DI_LoadRegs(di_regs) < 0) {
LOGE("%s failed!\n", __FUNCTION__);
return -1;
}
}
LOGD("%s success!\n", __FUNCTION__);
return 0;
}
int CPQControl::SetPQMode(int pq_mode, int is_save)
{
SYS_LOGI("%s, source: %d, timming: %d, pq_mode: %d\n", __FUNCTION__, CurSource, CurTimming, pq_mode);
int ret = -1;
int cur_mode = GetPQMode();
SYS_LOGD("%s, cur_mode: %d\n", __FUNCTION__, cur_mode);
if (cur_mode == pq_mode && mbResetPicture != true) {
SYS_LOGD("%s Same PQ mode,no need set again!\n", __FUNCTION__);
ret = 0;
return ret;
}
if (is_save == 1) {
SavePQMode(pq_mode);
}
ret = Set_PictureMode((vpp_picture_mode_t)pq_mode);
Cpq_SetPqModeManualChanged(pq_mode);
if (mbResetPicture == true) {
mbResetPicture = false;
}
if (ret < 0) {
SYS_LOGE("%s failed!\n", __FUNCTION__);
} else {
SYS_LOGD("%s success!\n", __FUNCTION__);
}
return ret;
}
int CPQControl::GetPQMode(void)
{
int mode = VPP_PICTURE_MODE_STANDARD;
if (GetPictureMode((vpp_picture_mode_t *)&mode) != true) {
SYS_LOGE("%s GetPictureMode failed!\n", __FUNCTION__);
return mode;
}
if (mode < VPP_PICTURE_MODE_STANDARD || mode >= VPP_PICTURE_MODE_MAX) {
mode = VPP_PICTURE_MODE_STANDARD;
}
return mode;
}
int CPQControl::SavePQMode(int pq_mode)
{
SYS_LOGD("%s, source:%d, timming: %d, mode:%d\n", __FUNCTION__, CurSource, CurTimming, pq_mode);
if (SetPictureMode((vpp_picture_mode_t)pq_mode) != true) {
SYS_LOGE("%s: SetPictureMode fail\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::GetLastPQMode(void)
{
int mode = VPP_PICTURE_MODE_STANDARD;
if (GetLastPictureMode((vpp_picture_mode_t *)&mode) != true) {
SYS_LOGE("%s GetLastPictureMode failed!\n", __FUNCTION__);
return mode;
}
if (mode < VPP_PICTURE_MODE_STANDARD || mode >= VPP_PICTURE_MODE_MAX) {
mode = VPP_PICTURE_MODE_STANDARD;
}
SYS_LOGD("%s, source: %d, mode: %d\n", __FUNCTION__, CurSource, mode);
return mode;
}
int CPQControl::SaveLastPQMode(int pq_mode)
{
SYS_LOGD("%s, source: %d, timing: %d, mode: %d\n", __FUNCTION__, CurSource, CurTimming, pq_mode);
if (SetLastPictureMode((vpp_picture_mode_t)pq_mode) != true) {
SYS_LOGE("%s: SetLastPictureMode fail\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactorySetPictureMode(int source, int HdrType, int pq_mode)
{
SYS_LOGD("%s, source:%d, timming: %d, mode:%d\n", __FUNCTION__, source, HdrType, pq_mode);
if (SetPictureModeBySource((vpp_picture_mode_t)pq_mode, source, HdrType) != true) {
SYS_LOGE("%s: SetPictureModeBySource fail\n", __FUNCTION__);
return -1;
}
SYS_LOGD("%s: success\n", __FUNCTION__);
return 0;
}
int CPQControl::FactoryGetPictureMode(int source, int HdrType)
{
int pq_mode = VPP_PICTURE_MODE_STANDARD;
if (GetPictureModeBySource((vpp_picture_mode_t *)&pq_mode, source, HdrType) != true) {
SYS_LOGE("%s FactoryGetPictureMode failed!\n", __FUNCTION__);
}
if (pq_mode < VPP_PICTURE_MODE_STANDARD || pq_mode >= VPP_PICTURE_MODE_MAX) {
pq_mode = VPP_PICTURE_MODE_STANDARD;
}
return pq_mode;
}
int CPQControl::Cpq_SetVppPCMode(game_pc_mode_t pcStatus)
{
char val[64] = {0};
//0:enablepc mode,1:disable pc mode for amvecm
unsigned int status = 0;
if (pcStatus == MODE_ON) {
status = 0;
} else {
status = 1;
}
sprintf(val, "%d", status);
return pqWriteSys(AMVECM_PC_MODE_PATH, val);
}
int CPQControl::Cpq_SetVdinPCMode(game_pc_mode_t pcStatus)
{
return mpVdin->Tvin_SetPCMode(pcStatus);
}
int CPQControl::Cpq_SetPCMode(game_pc_mode_t pcStatus)
{
SYS_LOGD("%s: pcStatus:%d\n", __FUNCTION__, pcStatus);
int ret = 0;
//pc mode
if ((pcStatus == MODE_ON)
|| (pcStatus == MODE_OFF)) {
Cpq_SetVdinPCMode(pcStatus);
Cpq_SetVppPCMode(pcStatus);
}
return ret;
}
int CPQControl::Cpq_SetVdinGameMode(game_pc_mode_t gameStatus)
{
return mpVdin->Tvin_SetGameMode(gameStatus);
}
int CPQControl::Cpq_SetGameMode(game_pc_mode_t gameStatus)
{
SYS_LOGD("%s: gameStatus:%d\n", __FUNCTION__, gameStatus);
int ret = 0;
//game mode
if (gameStatus != mGamemode) {
mGamemode = gameStatus;
Cpq_SetVdinGameMode(gameStatus);
}
return ret;
}
//color temperature
int CPQControl::SetColorTemperature(int temp_mode, int is_save)
{
SYS_LOGD("%s: source:%d, mode: %d\n", __FUNCTION__, mCurrentSourceInputInfo.source_input, temp_mode);
int ret = Cpq_SetWhitebalance(temp_mode, GetGammaValue());
if (ret == 0 && is_save == 1) {
ret = SaveColorTemperature((vpp_color_temperature_mode_t)temp_mode);
}
if (ret < 0) {
SYS_LOGE("%s failed!\n",__FUNCTION__);
} else {
SYS_LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetColorTemperature(void)
{
int mode = COLOR_TMP_MODE_STANDARD;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return mode;
}
mode = para.ColorTemperature;
if (mode < 0 || mode >= COLOR_TMP_MODE_MAX) {
mode = COLOR_TMP_MODE_STANDARD;
}
SYS_LOGD("%s: source: %d, timming: %d mode: %d!\n",__FUNCTION__, CurSource, CurTimming, mode);
return mode;
}
int CPQControl::SaveColorTemperature(int value)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.ColorTemperature = value;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d mode: %d fail\n",__FUNCTION__, CurSource, CurTimming, value);
return -1;
}
SYS_LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetColorTemperature(int level)
{
if (!mbCpqCfg_whitebalance_enable) {
SYS_LOGD("%s ColorTemperature disabled!\n",__FUNCTION__);
return 0;
}
tcon_rgb_ogo_t rgbogo;
memset(&rgbogo, 0, sizeof(tcon_rgb_ogo_t));
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, level)) {
SYS_LOGD("%s Get ColorTemp from CRI_DATA\n",__FUNCTION__);
} else if (GetColorTemperatureData(&rgbogo, level)) {
SYS_LOGD("%s Get ColorTemp from SSMDATA\n",__FUNCTION__);
} else {
SYS_LOGE("%s have no data\n",__FUNCTION__);
return -1;
}
int eye_protection = GetEyeProtectionMode(mCurrentSourceInputInfo.source_input);
rgbogo.r_gain = rgbogo.r_gain + Cpq_GetEyeProtectionOffset(R_GAIN, eye_protection);
rgbogo.g_gain = rgbogo.g_gain + Cpq_GetEyeProtectionOffset(G_GAIN, eye_protection);
rgbogo.b_gain = rgbogo.b_gain + Cpq_GetEyeProtectionOffset(B_GAIN, eye_protection);
if (Cpq_SetRGBOGO(&rgbogo) < 0) {
SYS_LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
SYS_LOGD("level[%d], Enable[%d], [%d %d %d %d %d %d %d %d %d]\n", level, rgbogo.en,
rgbogo.r_gain, rgbogo.g_gain, rgbogo.b_gain,
rgbogo.r_post_offset, rgbogo.g_post_offset, rgbogo.b_post_offset,
rgbogo.r_pre_offset, rgbogo.g_pre_offset, rgbogo.b_pre_offset);
return 0;
}
int CPQControl::Cpq_SetWhitebalance(int level, int gamma)
{
int ret = 0;
ret |= Cpq_SetColorTemperature(level);
ret |= Cpq_LoadGamma((vpp_gamma_curve_t)gamma, (vpp_color_temperature_mode_t)level);
if (ret < 0) {
SYS_LOGE("%s fail\n",__FUNCTION__);
} else {
SYS_LOGD("%s success! level: %d\n",__FUNCTION__, level);
}
return ret;
}
int CPQControl::SetColorTempParams(int ColorTemp, tcon_rgb_ogo_t *param)
{
if (!mbCpqCfg_whitebalance_enable) {
SYS_LOGD("whitebalance module disabled!\n");
return 0;
}
int eye_protection = GetEyeProtectionMode(mSourceInputForSaveParam);
param->r_gain = param->r_gain + Cpq_GetEyeProtectionOffset(R_GAIN, eye_protection);
param->g_gain = param->g_gain + Cpq_GetEyeProtectionOffset(G_GAIN, eye_protection);
param->b_gain = param->b_gain + Cpq_GetEyeProtectionOffset(B_GAIN, eye_protection);
if (Cpq_SetRGBOGO(param) != 0) {
SYS_LOGE("%s Cpq_SetRGBOGO fail\n", __FUNCTION__);
return -1;
}
if (!SetColorTemperatureData(param, ColorTemp)) {
SYS_LOGE("%s SetColorTemperatureData failed\n", __FUNCTION__);
return -1;
}
SYS_LOGD("Enable = %5d\n"
"rgain = %5d, ggain = %5d, bgain = %5d\n"
"roffset = %5d, goffset = %5d, boffset = %5d\n"
"rpre_offset = %5d, gpre_offset = %5d, bpre_offset = %5d\n",
param->en,
param->r_gain, param->g_gain, param->b_gain,
param->r_post_offset, param->g_post_offset, param->b_post_offset,
param->r_pre_offset, param->g_pre_offset, param->b_pre_offset);
SYS_LOGD("%s success\n", __FUNCTION__);
return 0;
}
tvpq_rgb_ogo_t CPQControl::GetColorTempParams(int ColorTemp)
{
tcon_rgb_ogo_t param;
tvpq_rgb_ogo_t output;
memset(&param, 0, sizeof(tcon_rgb_ogo_t));
memset(&output, 0, sizeof(tvpq_rgb_ogo_t));
if (!GetColorTemperatureData(&param, ColorTemp)) {
SYS_LOGE("%s GetColorTemperatureData failed\n", __FUNCTION__);
return output;
}
memcpy(&output, &param, sizeof(tcon_rgb_ogo_t));
return output;
}
//Brightness
int CPQControl::SetBrightness(int value, int is_save)
{
SYS_LOGD("%s, source: %d, timming: %d, value = %d\n", __FUNCTION__, CurSource, CurTimming, value);
int ret = Cpq_SetBrightness(value, mCurrentSourceInputInfo);
if (ret == 0 && is_save == 1) {
ret = SaveBrightness(value);
}
if (ret < 0) {
SYS_LOGE("%s failed!\n",__FUNCTION__);
} else {
SYS_LOGD("%s success!\n",__FUNCTION__);
}
return ret ;
}
int CPQControl::GetBrightness(void)
{
int data = 50;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return data;
}
data = para.Brightness;
if (data < 0 || data > 100) {
data = 50;
}
SYS_LOGI("%s, source: %d, timming: %d, value = %d\n", __FUNCTION__, CurSource, CurTimming, data);
return data;
}
int CPQControl::SaveBrightness(int value)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.Brightness = value;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d value: %d fail\n",__FUNCTION__, CurSource, CurTimming, value);
return -1;
}
SYS_LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetBrightnessBasicParam(source_input_param_t source_input_param)
{
int ret = -1;
ret = mPQdb->LoadVppBasicParam(TVPQ_DATA_BRIGHTNESS, source_input_param);
if (ret < 0)
LOGE("%s failed\n",__FUNCTION__);
return ret;
}
int CPQControl::Cpq_SetBrightness(int value, source_input_param_t source_input_param)
{
if (!mbCpqCfg_amvecm_basic_enable && !mbCpqCfg_amvecm_basic_withOSD_enable) {
LOGD("%s: brightness disabled\n", __FUNCTION__);
return 0;
}
if (value < 0 || value > 100) {
LOGE("%s:Brightness out of range\n", __FUNCTION__);
return -1;
}
if (Cpq_SetVideoBrightness(GetNonlinearOsdRemapVal(_BRIGHTNESS, value)) < 0) {
LOGE("%s:Cpq_SetVideoBrightness failed\n", __FUNCTION__);
return -1;
}
LOGD("%s success! value: %d\n",__FUNCTION__, value);
return 0;
}
int CPQControl::Cpq_SetVideoBrightness(int value)
{
SYS_LOGD("Cpq_SetVideoBrightness brightness : %d\n", value);
int data = (((value == 255) ? 256 : value) * (BRIGHTNESS_MAX - BRIGHTNESS_MIN) / 256) - BRIGHTNESS_MAX; //-512 ~ 512
if (data > BRIGHTNESS_MAX) data = BRIGHTNESS_MAX;
if (data < BRIGHTNESS_MIN) data = BRIGHTNESS_MIN;
SYS_LOGD("to Driver brightness : %d\n", data);
struct am_vdj_mode_s params;
memset(&params, 0, sizeof(params));
if (mbCpqCfg_amvecm_basic_enable) {
params.flag |= 0x1;
params.brightness = data;
}
if (mbCpqCfg_amvecm_basic_withOSD_enable) {
params.flag |= (0x1<<1);
params.brightness2 = data;
}
int ret = VPPDeviceIOCtl(AMVECM_IOC_S_PIC_MODE, &params);
if (ret < 0) {
LOGE("%s error: %s\n", __FUNCTION__, strerror(errno));
}
return ret;
}
//Contrast
int CPQControl::SetContrast(int value, int is_save)
{
LOGD("%s, source: %d, value = %d\n", __FUNCTION__, mSourceInputForSaveParam, value);
int ret = Cpq_SetContrast(value, mCurrentSourceInputInfo);
if ((ret == 0) && (is_save == 1)) {
ret = SaveContrast(value);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetContrast(void)
{
int data = 50;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return data;
}
data = para.Contrast;
if (data < 0 || data > 100) {
data = 50;
}
SYS_LOGD("%s, source: %d, timming: %d, value = %d\n", __FUNCTION__, CurSource, CurTimming, data);
return data;
}
int CPQControl::SaveContrast(int value)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.Contrast = value;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d value: %d fail\n",__FUNCTION__, CurSource, CurTimming, value);
return -1;
}
SYS_LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetContrastBasicParam(source_input_param_t source_input_param)
{
int ret = -1;
ret = mPQdb->LoadVppBasicParam(TVPQ_DATA_CONTRAST, source_input_param);
if (ret < 0)
LOGE("%s failed\n", __FUNCTION__);
return ret;
}
int CPQControl::Cpq_SetContrast(int value, source_input_param_t source_input_param)
{
if (!mbCpqCfg_amvecm_basic_enable && !mbCpqCfg_amvecm_basic_withOSD_enable) {
SYS_LOGD("%s: contrast disabled\n", __FUNCTION__);
return 0;
}
if (value < 0 || value > 100) {
SYS_LOGE("%s: Contrast out of range\n", __FUNCTION__);
return -1;
}
if (Cpq_SetVideoContrast(GetNonlinearOsdRemapVal(_CONTRAST, value)) < 0) {
SYS_LOGE("%s: Cpq_SetVideoContrast failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetVideoContrast(int value)
{
SYS_LOGD("Cpq_SetVideoContrast: %d\n", value);
int data = ((((value == 255) ? 256 : value) * ((CONTRAST_MAX + 1) - CONTRAST_MIN)) / 256) - (CONTRAST_MAX + 1);
if (data > CONTRAST_MAX) data = CONTRAST_MAX;
if (data < CONTRAST_MIN) data = CONTRAST_MIN;
SYS_LOGD("to Driver Contrast: %d\n", data);
struct am_vdj_mode_s params;
memset(&params, 0, sizeof(params));
if (mbCpqCfg_amvecm_basic_enable) {
params.flag |= (0x1<<4);
params.contrast = data;
}
if (mbCpqCfg_amvecm_basic_withOSD_enable) {
params.flag |= (0x1<<5);
params.contrast2 = data;
}
int ret = VPPDeviceIOCtl(AMVECM_IOC_S_PIC_MODE, &params);
if (ret < 0) {
LOGE("%s error: %s\n", __FUNCTION__, strerror(errno));
}
return ret;
}
//Saturation
int CPQControl::SetSaturation(int value, int is_save)
{
LOGD("%s, source: %d, value = %d\n", __FUNCTION__, mSourceInputForSaveParam, value);
int ret = Cpq_SetSaturation(value, mCurrentSourceInputInfo);
if ((ret == 0) && (is_save == 1)) {
ret = SaveSaturation(value);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetSaturation(void)
{
int data = 50;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return data;
}
data = para.Saturation;
if (data < 0 || data > 100) {
data = 50;
}
SYS_LOGD("%s, source: %d, timming: %d, value = %d\n", __FUNCTION__, CurSource, CurTimming, data);
return data;
}
int CPQControl::SaveSaturation(int value)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.Saturation = value;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d value: %d fail\n",__FUNCTION__, CurSource, CurTimming, value);
return -1;
}
SYS_LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetSaturationBasicParam(source_input_param_t source_input_param)
{
int ret = -1;
ret = mPQdb->LoadVppBasicParam(TVPQ_DATA_SATURATION, source_input_param);
if (ret < 0)
LOGE("%s failed\n",__FUNCTION__);
return ret;
}
int CPQControl::Cpq_SetSaturation(int value, source_input_param_t source_input_param)
{
if (!mbCpqCfg_amvecm_basic_enable && !mbCpqCfg_amvecm_basic_withOSD_enable) {
SYS_LOGD("%s: saturation disabled\n", __FUNCTION__);
return 0;
}
if (value < 0 || value > 100) {
SYS_LOGE("%s: Saturation out of range\n", __FUNCTION__);
return -1;
}
int hue_level = 0;
if (((source_input_param.source_input == SOURCE_TV) ||
(source_input_param.source_input == SOURCE_AV1) ||
(source_input_param.source_input == SOURCE_AV2)) &&
((source_input_param.sig_fmt == TVIN_SIG_FMT_CVBS_NTSC_M) ||
(source_input_param.sig_fmt == TVIN_SIG_FMT_CVBS_NTSC_443))) {
hue_level = 100 - GetHue();
} else {
hue_level = 50;
}
int saturation = GetNonlinearOsdRemapVal(_SATURATION, value);
int hue = GetNonlinearOsdRemapVal(_HUE, hue_level);
if (Cpq_SetVideoSaturationHue(saturation, hue) < 0) {
SYS_LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
SYS_LOGD("%s success! value: %d\n",__FUNCTION__, value);
return 0;
}
//Hue
int CPQControl::SetHue(int value, int is_save)
{
LOGD("%s, source: %d, value = %d\n", __FUNCTION__, CurSource, value);
int ret = Cpq_SetHue(value, mCurrentSourceInputInfo);
if ((ret == 0) && (is_save == 1)) {
ret = SaveHue(value);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetHue(void)
{
int data = 50;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return data;
}
data = para.Hue;
if (data < 0 || data > 100) {
data = 50;
}
SYS_LOGD("%s, source: %d, timming: %d value = %d\n", __FUNCTION__, CurSource, CurTimming, data);
return data;
}
int CPQControl::SaveHue(int value)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.Hue = value;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d value: %d fail\n",__FUNCTION__, CurSource, CurTimming, value);
return -1;
}
SYS_LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetHueBasicParam(source_input_param_t source_input_param)
{
int ret = -1;
ret = mPQdb->LoadVppBasicParam(TVPQ_DATA_HUE, source_input_param);
if (ret < 0)
LOGE("%s failed\n",__FUNCTION__);
return ret;
}
int CPQControl::Cpq_SetHue(int value, source_input_param_t source_input_param)
{
if (!mbCpqCfg_amvecm_basic_enable && !mbCpqCfg_amvecm_basic_withOSD_enable) {
SYS_LOGD("%s: hue disabled\n", __FUNCTION__);
return 0;
}
if (value < 0 || value > 100) {
SYS_LOGE("%s: Hue out of range\n", __FUNCTION__);
return -1;
}
int saturation_params = GetNonlinearOsdRemapVal(_SATURATION, GetSaturation());
int hue_params = GetNonlinearOsdRemapVal(_HUE, value);
if (Cpq_SetVideoSaturationHue(saturation_params, hue_params) < 0) {
SYS_LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
SYS_LOGD("%s success! value: %d\n",__FUNCTION__, value);
return 0;
}
int CPQControl::Cpq_SetVideoSaturationHue(int satVal, int hueVal)
{
SYS_LOGD("%s, Cpq_SetVideoSaturationHue: %d %d\n", __FUNCTION__, satVal, hueVal);
int data_hue = ((((hueVal == 255) ? 256 : hueVal) * (HUE_MAX - HUE_MIN)) / 256) - HUE_MAX;
if (data_hue > HUE_MAX) data_hue = HUE_MAX;
if (data_hue < HUE_MIN) data_hue = HUE_MIN;
int data_sat = (((satVal == 255) ? 256 : satVal) * ((SATURATION_MAX + 1) - SATURATION_MIN) / 256) - (SATURATION_MAX + 1);
if (data_sat > SATURATION_MAX) data_sat = SATURATION_MAX;
if (data_sat < SATURATION_MIN) data_sat = SATURATION_MIN;
SYS_LOGD("%s: to Driver Saturation = %d, Hue = %d\n",__FUNCTION__, data_sat, data_hue);
signed long temp;
struct am_vdj_mode_s params;
memset(&params, 0, sizeof(params));
video_set_saturation_hue(data_sat, data_hue, &temp);
if (mbCpqCfg_amvecm_basic_enable) {
params.flag |= (0x1 << 2);
params.saturation_hue = temp;
}
if (mbCpqCfg_amvecm_basic_withOSD_enable) {
params.flag |= (0x1 << 3);
params.saturation_hue_post = temp;
}
int ret = VPPDeviceIOCtl(AMVECM_IOC_S_PIC_MODE, &params);
if (ret < 0) {
LOGE("%s error: %s\n", __FUNCTION__, strerror(errno));
}
return ret;
}
void CPQControl::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 (mb > 511) mb = 511;
if (mb < -512) mb = -512;
*mab = ((ma & 0x3ff) << 16) | (mb & 0x3ff);
}
void CPQControl::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 < -128) sat16 = -128;
if (hue16 > 127) hue16 = 127;
if (hue16 < -128) hue16 = -128;
*sat = (signed char)sat16;
*hue = (signed char)hue16;
}
//sharpness
bool CPQControl::HasSharpness(void)
{
if (mbCpqCfg_sharpness_enable || mbCpqCfg_sharpness0_enable || mbCpqCfg_sharpness1_enable || mbCpqCfg_sharpnesspi_enable) {
return true;
}
return false;
}
int CPQControl::SetSharpness(int value, int is_save)
{
LOGD("%s, source: %d, timming: %d, value = %d\n", __FUNCTION__, CurSource, CurTimming, value);
int ret = Cpq_SetSharpness(value, mCurrentSourceInputInfo);
if ((ret== 0) && (is_save == 1)) {
ret = SaveSharpness(value);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetSharpness(void)
{
int data = 50;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return data;
}
data = para.Sharpness;
if (data < 0 || data > 100) {
data = 50;
}
SYS_LOGD("%s, source: %d, timming: %d, value = %d\n", __FUNCTION__, CurSource, CurTimming, data);
return data;
}
int CPQControl::SaveSharpness(int value)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.Sharpness = value;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d value: %d fail\n",__FUNCTION__, CurSource, CurTimming, value);
return -1;
}
SYS_LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetSharpness(int value, source_input_param_t source_input_param)
{
int ret = 0;
int sharpness = GetNonlinearOsdRemapVal(_SHARPNESS, value);
ret |= Cpq_SetSharpnessVariable(sharpness, source_input_param);
ret |= Cpq_SetSharpness0Variable(sharpness, source_input_param);
ret |= Cpq_SetSharpness1Variable(sharpness, source_input_param);
if (ret < 0) {
SYS_LOGE("%s: Fail !\n", __FUNCTION__);
} else {
SYS_LOGD("%s: Success ! value: %d\n", __FUNCTION__, sharpness);
}
return ret;
}
int CPQControl::Cpq_SetSharpnessVariable(int value, source_input_param_t source_input_param)
{
if (!mbDatabaseMatchChipStatus) {
LOGD("%s: DB don't match chip\n", __FUNCTION__);
return 0;
}
if (!mbCpqCfg_sharpness_enable) {
LOGD("%s: sharpness disabled\n", __FUNCTION__);
return 0;
}
am_regs_t *regs = &mRegsData;
am_regs_t *tmp_reg = &mRegsDataNew;
memset(regs, 0x0, sizeof(am_regs_t));
memset(tmp_reg, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetSharpness0Params(source_input_param, value, regs) < 0) {
LOGE("%s: PQ_GetSharpness0Params failed\n", __FUNCTION__);
return -1;
}
MergeSameAddrVal(regs, tmp_reg);
if (Cpq_LoadRegs(tmp_reg) < 0) {
LOGE("%s: Cpq_LoadRegs failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetSharpness0Variable(int value, source_input_param_t source_input_param)
{
if (!mbDatabaseMatchChipStatus) {
LOGD("%s: DB don't match chip\n", __FUNCTION__);
return 0;
}
if (!mbCpqCfg_sharpness0_enable) {
LOGD("%s: sharpness0 disabled\n", __FUNCTION__);
return 0;
}
am_regs_t *regs = &mRegsData;
am_regs_t *tmp_reg = &mRegsDataNew;
memset(regs, 0x0, sizeof(am_regs_t));
memset(tmp_reg, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetSharpness0Params(source_input_param, value, regs) < 0) {
LOGE("%s: PQ_GetSharpness0Params failed\n", __FUNCTION__);
return -1;
}
MergeSameAddrVal(regs, tmp_reg);
if (Cpq_LoadRegs(tmp_reg) < 0) {
LOGE("%s: Cpq_LoadRegs failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetSharpness1Variable(int value, source_input_param_t source_input_param)
{
if (!mbDatabaseMatchChipStatus) {
LOGD("%s: DB don't match chip\n", __FUNCTION__);
return 0;
}
if (!mbCpqCfg_sharpness1_enable) {
LOGD("%s: sharpness1 disabled\n", __FUNCTION__);
return 0;
}
am_regs_t *regs = &mRegsData;
am_regs_t *tmp_reg = &mRegsDataNew;
memset(regs, 0x0, sizeof(am_regs_t));
memset(tmp_reg, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetSharpness1Params(source_input_param, value, regs) < 0) {
LOGE("%s: PQ_GetSharpness1Params failed\n", __FUNCTION__);
return -1;
}
MergeSameAddrVal(regs, tmp_reg);
if (Cpq_LoadRegs(tmp_reg) < 0) {
LOGE("%s: Cpq_LoadRegs failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::MergeSameAddrVal(am_regs_t *regs, am_regs_t *tmp_reg)
{
unsigned int i = 0, k = 0;
for (i = 0; i < regs->length; i++) {
if (regs->am_reg[i].addr == regs->am_reg[i+1].addr) {
regs->am_reg[i+1].mask |= regs->am_reg[i].mask;
regs->am_reg[i+1].val |= regs->am_reg[i].val;
} else {
tmp_reg->am_reg[k].type = regs->am_reg[i].type;
tmp_reg->am_reg[k].addr = regs->am_reg[i].addr;
tmp_reg->am_reg[k].mask = regs->am_reg[i].mask;
tmp_reg->am_reg[k].val = regs->am_reg[i].val;
k++;
}
}
tmp_reg->length = k;
/*LOGD("###length = %d.\n", tmp_reg.length);
for (i=0;i<tmp_reg.length;i++) {
LOGD("###type: %u, addr: %u, mask: %u, val: %u\n", tmp_reg.am_reg[i].type, tmp_reg.am_reg[i].addr, tmp_reg.am_reg[i].mask, tmp_reg.am_reg[i].val);
}*/
return 0;
}
//SuperResolution
int CPQControl::SetSuperResolution(int value, int is_save)
{
if (is_save) {
SaveSuperResolution(value);
}
if (Cpq_SetSuperResolution(value) < 0) {
LOGE("%s: value %d fail\n", __FUNCTION__, value);
return -1;
}
LOGD("%s: success! value: %d, is_save: %d\n", __FUNCTION__, value, is_save);
return 0;
}
int CPQControl::GetSuperResolution(void)
{
int value = VPP_SUPER_RESOLUTION_OFF;
PICTURE_MODE_PARAM params;
if (!GetPictureModeData(&params)) {
SYS_LOGE("%s: fail\n",__FUNCTION__);
return value;
}
value = params.SuperResolution;
if (value < VPP_SUPER_RESOLUTION_OFF || value > VPP_SUPER_RESOLUTION_MAX) {
value = VPP_SUPER_RESOLUTION_OFF;
}
SYS_LOGD("%s: success value: %d\n", __FUNCTION__, value);
return value;
}
int CPQControl::SaveSuperResolution(int value)
{
PICTURE_MODE_PARAM params;
if (!GetPictureModeData(&params)) {
SYS_LOGE("%s: GetPictureModeData fail\n",__FUNCTION__);
return -1;
}
params.SuperResolution = value;
if (!SetPictureModeData(&params)) {
SYS_LOGE("%s: SetPictureModeData fail\n",__FUNCTION__);
return -1;
}
SYS_LOGD("%s: success SuperResolution = %d\n", __FUNCTION__, value);
return 0;
}
int CPQControl::Cpq_SetSuperResolution(int value)
{
int ret = 0;
//sharpness
ret |= Cpq_SetSharpnessFixedParam(value, mCurrentSourceInputInfo);
//sharpness 0
ret |= Cpq_SetSharpness0FixedParam(value, mCurrentSourceInputInfo);
//sharpness 1
ret |= Cpq_SetSharpness1FixedParam(value, mCurrentSourceInputInfo);
if (ret < 0) {
LOGE("%s: Fail !\n", __FUNCTION__);
} else {
LOGD("%s: Success ! value: %d\n", __FUNCTION__, value);
}
return ret;
}
int CPQControl::Cpq_SetSharpnessFixedParam(int mode, source_input_param_t source_input_param)
{
if (!mbDatabaseMatchChipStatus) {
LOGD("%s: DB don't match chip\n", __FUNCTION__);
return 0;
}
if (!mbCpqCfg_sharpness_enable) {
LOGD("%s: sharpness disable!\n", __FUNCTION__);
return 0;
}
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetSharpnessFixedParams(mode, source_input_param, regs) < 0) {
LOGE("%s: PQ_GetSharpnessFixedParams failed\n", __FUNCTION__);
return -1;
}
if (Cpq_LoadRegs(regs) < 0) {
LOGE("%s failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetSharpnessVariableParam(source_input_param_t source_input_param)
{
if (!mbDatabaseMatchChipStatus) {
LOGD("%s: DB don't match chip\n", __FUNCTION__);
return 0;
}
if (!mbCpqCfg_sharpness_enable) {
LOGD("%s: sharpness disable!\n", __FUNCTION__);
return 0;
}
if (mPQdb->PQ_SetSharpnessVariableParams(source_input_param) < 0) {
LOGE("%s failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetSharpness0FixedParam(int mode, source_input_param_t source_input_param)
{
if (!mbDatabaseMatchChipStatus) {
LOGD("%s: DB don't match chip\n", __FUNCTION__);
return 0;
}
if (!mbCpqCfg_sharpness0_enable) {
LOGD("%s: sharpness0 disable!\n", __FUNCTION__);
return 0;
}
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetSharpness0FixedParams(mode, source_input_param, regs) < 0) {
LOGE("%s: PQ_GetSharpness0FixedParams failed\n", __FUNCTION__);
return -1;
}
if (Cpq_LoadRegs(regs) < 0) {
LOGE("%s failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetSharpness0VariableParam(source_input_param_t source_input_param)
{
if (!mbDatabaseMatchChipStatus) {
LOGD("%s: DB don't match chip\n", __FUNCTION__);
return 0;
}
if (!mbCpqCfg_sharpness0_enable) {
LOGD("%s: sharpness0 disable!\n", __FUNCTION__);
return 0;
}
if (mPQdb->PQ_SetSharpness0VariableParams(source_input_param) < 0) {
LOGE("%s failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetSharpness1FixedParam(int mode, source_input_param_t source_input_param)
{
if (!mbDatabaseMatchChipStatus) {
LOGD("%s: DB don't match chip\n", __FUNCTION__);
return 0;
}
if (!mbCpqCfg_sharpness1_enable) {
LOGD("%s: sharpness1 disable!\n", __FUNCTION__);
return 0;
}
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetSharpness1FixedParams(mode, source_input_param, regs) < 0) {
LOGE("%s: PQ_GetSharpness1FixedParams failed\n", __FUNCTION__);
return -1;
}
if (Cpq_LoadRegs(regs) < 0) {
LOGE("%s failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetSharpness1VariableParam(source_input_param_t source_input_param)
{
if (!mbDatabaseMatchChipStatus) {
LOGD("%s: DB don't match chip\n", __FUNCTION__);
return 0;
}
if (!mbCpqCfg_sharpness1_enable) {
LOGD("%s: sharpness1 disable!\n", __FUNCTION__);
return 0;
}
if (mPQdb->PQ_SetSharpness1VariableParams(source_input_param) < 0) {
LOGE("%s failed\n", __FUNCTION__);
return -1;
}
return 0;
}
void CPQControl::InitAutoNr(void)
{
int ret = -1;
const char *buff = NULL;
int buf[128] = {0};
buff = mPQConfigFile->GetString(CFG_SECTION_AUTO_NR, CFG_AUTO_NR_MOTION_TH, NULL);
pqTransformStringToInt(buff, buf);
if (buff != NULL) {
char str1[128] = {0};
sprintf(str1, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", "motion_th",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9],
buf[10], buf[11], buf[12], buf[13], buf[14]);
LOGE("%s str1 = %s\n", __FUNCTION__, str1);
ret = pqWriteSys(AML_AUTO_NR_PARAMS, str1);
}
buff = mPQConfigFile->GetString(CFG_SECTION_AUTO_NR, CFG_AUTO_NR_MOTION_LP_YGAIN, NULL);
pqTransformStringToInt(buff, buf);
if (buff != NULL) {
char str2[128] = {0};
sprintf(str2, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", "motion_lp_ygain",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9],
buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);
LOGE("%s str2 = %s\n", __FUNCTION__, str2);
ret |= pqWriteSys(AML_AUTO_NR_PARAMS, str2);
}
buff = mPQConfigFile->GetString(CFG_SECTION_AUTO_NR, CFG_AUTO_NR_MOTION_HP_YGAIN, NULL);
pqTransformStringToInt(buff, buf);
if (buff != NULL) {
char str3[128] = {0};
sprintf(str3, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", "motion_hp_ygain",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9],
buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);
LOGE("%s str3 = %s\n", __FUNCTION__, str3);
ret |= pqWriteSys(AML_AUTO_NR_PARAMS, str3);
}
buff = mPQConfigFile->GetString(CFG_SECTION_AUTO_NR, CFG_AUTO_NR_MOTION_LP_CGAIN, NULL);
pqTransformStringToInt(buff, buf);
if (buff != NULL) {
char str4[128] = {0};
sprintf(str4, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", "motion_lp_cgain",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9],
buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);
LOGE("%s str4 = %s\n", __FUNCTION__, str4);
ret |= pqWriteSys(AML_AUTO_NR_PARAMS, str4);
}
buff = mPQConfigFile->GetString(CFG_SECTION_AUTO_NR, CFG_AUTO_NR_MOTION_HP_CGAIN, NULL);
pqTransformStringToInt(buff, buf);
if (buff != NULL) {
char str5[128] = {0};
sprintf(str5, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", "motion_hp_cgain",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9],
buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);
LOGE("%s str5 = %s\n", __FUNCTION__, str5);
ret |= pqWriteSys(AML_AUTO_NR_PARAMS, str5);
}
buff = mPQConfigFile->GetString(CFG_SECTION_AUTO_NR, CFG_AUTO_NR_APL_GAIN, NULL);
pqTransformStringToInt(buff, buf);
if (buff != NULL) {
char str6[128] = {0};
sprintf(str6, "%s %d %d %d %d %d %d %d %d", "apl_gain",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
LOGE("%s str6 = %s\n", __FUNCTION__, str6);
ret |= pqWriteSys(AML_AUTO_NR_PARAMS, str6);
}
if (ret < 0) {
LOGE("%s failed\n", __FUNCTION__);
}
return;
}
//NoiseReductionMode
int CPQControl::SetNoiseReductionMode(int nr_mode, int is_save)
{
LOGD("%s, source: %d, timming: %d, value = %d\n", __FUNCTION__, CurSource, CurTimming, nr_mode);
int ret = Cpq_SetNoiseReductionMode((vpp_noise_reduction_mode_t)nr_mode, mCurrentSourceInputInfo);
if ((ret ==0) && (is_save == 1)) {
ret = SaveNoiseReductionMode((vpp_noise_reduction_mode_t)nr_mode);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetNoiseReductionMode(void)
{
int mode = VPP_NOISE_REDUCTION_MODE_MID;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return mode;
}
mode = para.Nr;
if (mode < 0 || mode > VPP_NOISE_REDUCTION_MODE_AUTO) {
mode = VPP_NOISE_REDUCTION_MODE_MID;
}
SYS_LOGD("%s, source: %d, timming: %d, value = %d\n", __FUNCTION__, CurSource, CurTimming, mode);
return mode;
}
int CPQControl::SaveNoiseReductionMode(int nr_mode)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.Nr = nr_mode;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d mode: %d fail\n",__FUNCTION__, CurSource, CurTimming, nr_mode);
return -1;
}
SYS_LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetNoiseReductionMode(vpp_noise_reduction_mode_t nr_mode, source_input_param_t source_input_param)
{
if (!mbCpqCfg_nr_enable) {
LOGE("NoiseReduction is disabled\n");
return 0;
}
if (mbCpqCfg_dpss_enable) {
struct vpq_dnr_param_s param;
memset(&param, 0, sizeof(struct vpq_dnr_param_s));
if (mPQdb->PQ_GetDpssNR2Params(nr_mode, source_input_param, &param) < 0) {
SYS_LOGE("%s: PQ_GetDpssNR2Params failed!\n", __FUNCTION__);
return -1;
}
if (VpqDeviceIOCtl(VPQ_IOC_SET_NR_DPSS, &param) < 0) {
SYS_LOGE("%s: VPQ_IOC_SET_NR_DPSS failed!\n", __FUNCTION__);
return -1;
}
} else {
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetNR2Params(nr_mode, source_input_param, regs) < 0) {
LOGE("PQ_GetNR2Params failed\n");
return -1;
}
struct am_pq_parm_s di_regs;
memset(&di_regs, 0x0, sizeof(struct am_pq_parm_s));
di_regs.table_name = TABLE_NAME_NR;
di_regs.table_len = regs->length;
struct am_reg_s tmp_buf[regs->length];
for (unsigned int i = 0; i < regs->length; i++) {
tmp_buf[i].addr = regs->am_reg[i].addr;
tmp_buf[i].mask = regs->am_reg[i].mask;
tmp_buf[i].type = regs->am_reg[i].type;
tmp_buf[i].val = regs->am_reg[i].val;
}
di_regs.table_ptr = tmp_buf;
if (DI_LoadRegs(di_regs) < 0) {
LOGE("%s failed\n",__FUNCTION__);
}
}
LOGD("%s success! nr_mode: %d\n",__FUNCTION__, nr_mode);
return 0;
}
//Gamma
int CPQControl::SetGammaValue(vpp_gamma_curve_t gamma_curve, int is_save)
{
LOGD("%s, source: %d, value = %d\n", __FUNCTION__, mCurrentSourceInputInfo.source_input, gamma_curve);
int ret = 0;
ret |= Cpq_LoadGamma(gamma_curve, (vpp_color_temperature_mode_t)GetColorTemperature());
if ((ret == 0) && (is_save == 1)) {
ret = SaveGammaValue((int)gamma_curve);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetGammaValue(void)
{
int gammaValue = 0;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return gammaValue;
}
gammaValue = para.GammaMidLuminance;
SYS_LOGD("%s, source: %d, timming: %d, value = %d\n", __FUNCTION__, CurSource, CurTimming, gammaValue);
return gammaValue;
}
int CPQControl::SaveGammaValue(int gamma)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.GammaMidLuminance = gamma;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d gamma: %d fail\n",__FUNCTION__, CurSource, CurTimming, gamma);
return -1;
}
return 0;
}
int CPQControl::Cpq_LoadGamma(vpp_gamma_curve_t gamma_curve, vpp_color_temperature_mode_t level)
{
if (!mInitialized) {
return 0;
}
if (!mbCpqCfg_gamma_enable) {
LOGD("Gamma module disabled!\n");
return 0;
}
int ret = 0;
GAMMA_TABLE Gamma;
memset(&Gamma, 0, sizeof(GAMMA_TABLE));
ret |= GetBaseGammaData((int)level, &Gamma);
ret |= GetWBGammaData((int)level, &Gamma);
ret |= GetGammaPowerData((int)gamma_curve, &Gamma);
if (ret < 0) {
LOGE("%s, fail!\n", __FUNCTION__);
} else {
ret |= Cpq_SetGammaTbl_R((unsigned short *)Gamma.R.data);
ret |= Cpq_SetGammaTbl_G((unsigned short *)Gamma.G.data);
ret |= Cpq_SetGammaTbl_B((unsigned short *)Gamma.B.data);
}
if (ret < 0) {
LOGE("%s, fail!\n", __FUNCTION__);
} else {
LOGD("%s, success! gamma_curve: %d, level: %d\n", __FUNCTION__, gamma_curve, level);
}
return ret;
}
int CPQControl::GetBaseGammaData(int level, GAMMA_TABLE *pData)
{
if (pData == NULL) {
LOGE("%s, pData is NULL\n", __FUNCTION__);
return -1;
}
int ret = 0;
if (FactoryGetGammaDataTable(pData, level)) {
ret = 0;
LOGD("%s, Get Gamma Table from Cri data\n", __FUNCTION__);
} else {
ret |= mPQdb->PQ_GetGammaWhiteBalanceSpecialTable((vpp_color_temperature_mode_t)level, "Red", &pData->R);
ret |= mPQdb->PQ_GetGammaWhiteBalanceSpecialTable((vpp_color_temperature_mode_t)level, "Green", &pData->G);
ret |= mPQdb->PQ_GetGammaWhiteBalanceSpecialTable((vpp_color_temperature_mode_t)level, "Blue", &pData->B);
if (ret == 0)
LOGD("%s, Get Gamma Table from pq.db\n", __FUNCTION__);
}
if (ret < 0) {
for (int i = 0; i < mPQdb->Gamma_nodes; i++) {
pData->R.data[i] = (i * 4);
if (pData->R.data[i] > 1023)
pData->R.data[i] = 1023;
pData->G.data[i] = (i * 4);
if (pData->G.data[i] > 1023)
pData->G.data[i] = 1023;
pData->B.data[i] = (i * 4);
if (pData->B.data[i] > 1023)
pData->B.data[i] = 1023;
}
LOGE("%s: from pq.db fail, gen a linearity Table\n", __FUNCTION__);
ret = 0;
}
if (ret < 0) {
LOGE("%s: Fail\n", __FUNCTION__);
} else {
LOGD("%s: Success! level: %d, Gamma node = %d\n", __FUNCTION__, level, mPQdb->Gamma_nodes);
}
return ret;
}
unsigned int BT1886_GAMMA_256[256] = {
0x00000,0x00C48,0x0118C,0x015F2,0x019F6,0x01DC4,0x02171,0x02509,0x02893,0x02C13,0x02F8C,0x03302,0x03674,0x039E4,0x03D53,0x040C2,
0x04431,0x047A0,0x04B10,0x04E81,0x051F3,0x05566,0x058DB,0x05C51,0x05FC8,0x06341,0x066BC,0x06A38,0x06DB6,0x07135,0x074B6,0x07839,
0x07BBD,0x07F43,0x082CA,0x08653,0x089DD,0x08D6A,0x090F7,0x09486,0x09817,0x09BA9,0x09F3D,0x0A2D2,0x0A669,0x0AA01,0x0AD9A,0x0B135,
0x0B4D2,0x0B86F,0x0BC0E,0x0BFAF,0x0C350,0x0C6F3,0x0CA98,0x0CE3D,0x0D1E4,0x0D58C,0x0D935,0x0DCE0,0x0E08C,0x0E439,0x0E7E7,0x0EB96,
0x0EF46,0x0F2F8,0x0F6AB,0x0FA5F,0x0FE14,0x101CA,0x10581,0x10939,0x10CF2,0x110AC,0x11468,0x11824,0x11BE2,0x11FA0,0x1235F,0x12720,
0x12AE1,0x12EA4,0x13267,0x1362B,0x139F0,0x13DB6,0x1417E,0x14546,0x1490E,0x14CD8,0x150A3,0x1546F,0x1583B,0x15C08,0x15FD7,0x163A6,
0x16776,0x16B46,0x16F18,0x172EA,0x176BD,0x17A92,0x17E66,0x1823C,0x18613,0x189EA,0x18DC2,0x1919B,0x19574,0x1994F,0x19D2A,0x1A105,
0x1A4E2,0x1A8BF,0x1AC9E,0x1B07C,0x1B45C,0x1B83C,0x1BC1D,0x1BFFF,0x1C3E1,0x1C7C4,0x1CBA8,0x1CF8D,0x1D372,0x1D758,0x1DB3E,0x1DF26,
0x1E30D,0x1E6F6,0x1EADF,0x1EEC9,0x1F2B4,0x1F69F,0x1FA8B,0x1FE77,0x20264,0x20652,0x20A40,0x20E2F,0x2121F,0x2160F,0x21A00,0x21DF2,
0x221E4,0x225D6,0x229CA,0x22DBD,0x231B2,0x235A7,0x2399D,0x23D93,0x2418A,0x24581,0x24979,0x24D71,0x2516A,0x25564,0x2595E,0x25D59,
0x26154,0x26550,0x2694D,0x26D49,0x27147,0x27545,0x27944,0x27D43,0x28142,0x28543,0x28943,0x28D44,0x29146,0x29548,0x2994B,0x29D4E,
0x2A152,0x2A557,0x2A95B,0x2AD61,0x2B166,0x2B56D,0x2B974,0x2BD7B,0x2C183,0x2C58B,0x2C994,0x2CD9D,0x2D1A7,0x2D5B1,0x2D9BC,0x2DDC7,
0x2E1D2,0x2E5DE,0x2E9EB,0x2EDF8,0x2F206,0x2F614,0x2FA22,0x2FE31,0x30240,0x30650,0x30A60,0x30E71,0x31282,0x31694,0x31AA6,0x31EB8,
0x322CB,0x326DF,0x32AF2,0x32F07,0x3331B,0x33730,0x33B46,0x33F5C,0x34372,0x34789,0x34BA0,0x34FB8,0x353D0,0x357E9,0x35C01,0x3601B,
0x36435,0x3684F,0x36C69,0x37084,0x374A0,0x378BB,0x37CD8,0x380F4,0x38511,0x3892F,0x38D4C,0x3916B,0x39589,0x399A8,0x39DC8,0x3A1E7,
0x3A607,0x3AA28,0x3AE49,0x3B26A,0x3B68C,0x3BAAE,0x3BED0,0x3C2F3,0x3C717,0x3CB3A,0x3CF5E,0x3D382,0x3D7A7,0x3DBCC,0x3DFF2,0x3E418,
};
unsigned int BT1886_GAMMA_257[257] = {
0x00000,0x000A0,0x0019D,0x002CD,0x00426,0x005A0,0x00737,0x008E7,0x00AAF,0x00C8B,0x00E7B,0x0107E,0x01292,0x014B6,0x016EA,0x0192D,
0x01B7E,0x01DDC,0x02048,0x022C0,0x02545,0x027D5,0x02A71,0x02D18,0x02FCA,0x03286,0x0354D,0x0381D,0x03AF8,0x03DDC,0x040C9,0x043BF,
0x046BF,0x049C7,0x04CD8,0x04FF1,0x05312,0x0563C,0x0596E,0x05CA7,0x05FE8,0x06331,0x06681,0x069D9,0x06D38,0x0709E,0x0740B,0x0777F,
0x07AFA,0x07E7C,0x08205,0x08594,0x08929,0x08CC5,0x09068,0x09410,0x097BF,0x09B74,0x09F2F,0x0A2F1,0x0A6B8,0x0AA84,0x0AE57,0x0B230,
0x0B60E,0x0B9F2,0x0BDDB,0x0C1CA,0x0C5BF,0x0C9B9,0x0CDB8,0x0D1BC,0x0D5C6,0x0D9D5,0x0DDEA,0x0E203,0x0E622,0x0EA45,0x0EE6E,0x0F29B,
0x0F6CE,0x0FB05,0x0FF42,0x10383,0x107C9,0x10C13,0x11062,0x114B6,0x1190F,0x11D6C,0x12192,0x12561,0x12931,0x12D03,0x130D7,0x134AE,
0x13886,0x13C5F,0x1403B,0x14419,0x147F8,0x14BD9,0x14FBC,0x153A1,0x15787,0x15B70,0x15F59,0x16345,0x16733,0x16B22,0x16F12,0x17305,
0x176F9,0x17AEF,0x17EE6,0x182DF,0x186DA,0x18AD6,0x18ED4,0x192D3,0x196D4,0x19AD6,0x19EDA,0x1A2E0,0x1A6E7,0x1AAF0,0x1AEFA,0x1B305,
0x1B712,0x1BB21,0x1BF31,0x1C342,0x1C755,0x1CB6A,0x1CF7F,0x1D397,0x1D7AF,0x1DBC9,0x1DFE5,0x1E401,0x1E820,0x1EC3F,0x1F060,0x1F482,
0x1F8A6,0x1FCCB,0x200F1,0x20519,0x20942,0x20D6C,0x21197,0x215C4,0x219F2,0x21E22,0x22252,0x22684,0x22AB8,0x22EEC,0x23322,0x23759,
0x23B91,0x23FCA,0x24405,0x24841,0x24C7E,0x250BC,0x254FB,0x2593C,0x25D7E,0x261C1,0x26605,0x26A4A,0x26E91,0x272D9,0x27721,0x27B6B,
0x27FB6,0x28403,0x28850,0x28C9F,0x290EE,0x2953F,0x29991,0x29DE4,0x2A238,0x2A68D,0x2AAE3,0x2AF3A,0x2B393,0x2B7EC,0x2BC47,0x2C0A2,
0x2C4FF,0x2C95D,0x2CDBC,0x2D21B,0x2D67C,0x2DADE,0x2DF41,0x2E3A5,0x2E80A,0x2EC70,0x2F0D7,0x2F53F,0x2F9A9,0x2FE13,0x3027E,0x306EA,
0x30B57,0x30FC5,0x31434,0x318A4,0x31D15,0x32187,0x325FA,0x32A6E,0x32EE3,0x33359,0x337D0,0x33C48,0x340C0,0x3453A,0x349B5,0x34E30,
0x352AD,0x3572A,0x35BA8,0x36028,0x364A8,0x36929,0x36DAB,0x3722E,0x376B2,0x37B37,0x37FBC,0x38443,0x388CA,0x38D53,0x391DC,0x39666,
0x39AF1,0x39F7D,0x3A40A,0x3A898,0x3AD26,0x3B1B5,0x3B646,0x3BAD7,0x3BF69,0x3C3FC,0x3C88F,0x3CD24,0x3D1B9,0x3D650,0x3DAE7,0x3DF7F,
0x3E418,
};
int CPQControl::GetGammaPowerData(int level, GAMMA_TABLE *pData)
{
if (pData == NULL) {
LOGE("%s, pData is NULL\n", __FUNCTION__);
return -1;
}
int ret = 0;
if (level == VPP_GAMMA_CURVE_BT1886) {
if (mPQdb->Gamma_nodes == 256) {
ret |= DBGammaBlend(&pData->R, BT1886_GAMMA_256);
ret |= DBGammaBlend(&pData->G, BT1886_GAMMA_256);
ret |= DBGammaBlend(&pData->B, BT1886_GAMMA_256);
} else {
ret |= DBGammaBlend(&pData->R, BT1886_GAMMA_257);
ret |= DBGammaBlend(&pData->G, BT1886_GAMMA_257);
ret |= DBGammaBlend(&pData->B, BT1886_GAMMA_257);
}
} else {
double GammaPower = GetGammaPower((vpp_gamma_curve_t)level);
ret |= GammaOperation::GetInstance()->GammaOperation_BaseGammaConvert(pData->R.data, 2.2, GammaPower, mPQdb->Gamma_nodes);
ret |= GammaOperation::GetInstance()->GammaOperation_BaseGammaConvert(pData->G.data, 2.2, GammaPower, mPQdb->Gamma_nodes);
ret |= GammaOperation::GetInstance()->GammaOperation_BaseGammaConvert(pData->B.data, 2.2, GammaPower, mPQdb->Gamma_nodes);
}
if (ret < 0) {
LOGE("%s, fail\n", __FUNCTION__);
} else {
LOGD("%s: Success! GammaPower: %d\n", __FUNCTION__, level);
}
return ret;
}
float x_2point[4] = {PERCENT_0, PERCENT_20, PERCENT_80, PERCENT_100};
float x_10point[11] = {PERCENT_0, PERCENT_10, PERCENT_20, PERCENT_30, PERCENT_40, PERCENT_50, PERCENT_60, PERCENT_70, PERCENT_80, PERCENT_90, PERCENT_100};
float x_11point[12] = {PERCENT_0, PERCENT_5, PERCENT_10, PERCENT_20, PERCENT_30, PERCENT_40, PERCENT_50, PERCENT_60, PERCENT_70, PERCENT_80, PERCENT_90, PERCENT_100};
float x_20point[21] = {PERCENT_0, PERCENT_5, PERCENT_10, PERCENT_15, PERCENT_20, PERCENT_25, PERCENT_30, PERCENT_35, PERCENT_40, PERCENT_45, PERCENT_50,
PERCENT_55, PERCENT_60, PERCENT_65, PERCENT_70, PERCENT_75, PERCENT_80, PERCENT_85, PERCENT_90, PERCENT_95, PERCENT_100};
int CPQControl::GetWBGammaData(int level, GAMMA_TABLE *pData)
{
if (pData == NULL) {
LOGE("%s, pData is NULL\n", __FUNCTION__);
return -1;
}
WB_GAMMA_TABLE Param;
if (!GetWhitebalanceGammaData(&Param, level)) {
LOGE("%s, ssm_data Have no data\n", __FUNCTION__);
return -1;
}
if (Param.ENABLE == 0) {
LOGD("%s, WBGamma disable\n", __FUNCTION__);
return 0;
}
if (FactoryGetWhitebalanceGammaData(&Param.WB_GAMMA_DATA, level)) {
LOGD("%s, get Data fro CRI DATA\n", __FUNCTION__);
} else {
LOGD("%s, get Data fro SSM DATA\n", __FUNCTION__);
}
float *x = NULL;
int PointNum = 0;
switch (GetWbGammaMode()) {
case WB_GAMMA_MODE_2POINT:
PointNum = 4;
x = (float *)malloc(PointNum * sizeof(float));
memcpy(x, x_2point, PointNum * sizeof(float));
break;
case WB_GAMMA_MODE_10POINT:
PointNum = 11;
x = (float *)malloc(PointNum * sizeof(float));
memcpy(x, x_10point, PointNum * sizeof(float));
break;
case WB_GAMMA_MODE_11POINT:
PointNum = 12;
x = (float *)malloc(PointNum * sizeof(float));
memcpy(x, x_11point, PointNum * sizeof(float));
break;
case WB_GAMMA_MODE_20POINT:
PointNum = 21;
x = (float *)malloc(PointNum * sizeof(float));
memcpy(x, x_20point, PointNum * sizeof(float));
break;
default:
PointNum = 12;
x = (float *)malloc(PointNum * sizeof(float));
memcpy(x, x_11point, PointNum * sizeof(float));
break;
}
if (mPQdb->Gamma_nodes == 257)
x[PointNum - 1] = PERCENT_100_257;
float *y_r = (float *)malloc(PointNum * sizeof(float));
float *y_g = (float *)malloc(PointNum * sizeof(float));
float *y_b = (float *)malloc(PointNum * sizeof(float));
for (int i = 0; i < PointNum; i++) {
int index = x[i];
y_r[i] = (float)(pData->R.data[index] + Param.WB_GAMMA_DATA.R_OFFSET[i]);
if (y_r[i] < 0.0) y_r[i] = 0.0;
if (y_r[i] > 1023.0) y_r[i] = 1023.0;
y_g[i] = (float)(pData->G.data[index] + Param.WB_GAMMA_DATA.G_OFFSET[i]);
if (y_g[i] < 0.0) y_g[i] = 0.0;
if (y_g[i] > 1023.0) y_g[i] = 1023.0;
y_b[i] = (float)(pData->B.data[index] + Param.WB_GAMMA_DATA.B_OFFSET[i]);
if (y_b[i] < 0.0) y_b[i] = 0.0;
if (y_b[i] > 1023.0) y_b[i] = 1023.0;
}
interpolation_info_t output;
output.x = x;
output.y = y_r;
if (CubeInterpolationProcess(&output, pData->R.data, PointNum) != 0) {
LOGE("%s CubeInterpolationProcess R fail\n",__FUNCTION__);
free(x);
free(y_r);
free(y_g);
free(y_b);
return -1;
}
output.y = y_g;
if (CubeInterpolationProcess(&output, pData->G.data, PointNum) != 0) {
LOGE("%s CubeInterpolationProcess G fail\n",__FUNCTION__);
free(x);
free(y_r);
free(y_g);
free(y_b);
return -1;
}
output.y = y_b;
if (CubeInterpolationProcess(&output, pData->B.data, PointNum) != 0) {
LOGE("%s CubeInterpolationProcess B fail\n",__FUNCTION__);
free(x);
free(y_r);
free(y_g);
free(y_b);
return -1;
}
free(x);
free(y_r);
free(y_g);
free(y_b);
return 0;
}
int CPQControl::CubeInterpolationProcess(interpolation_info_t *output, unsigned short *gamma, int num_points)
{
interpolation_info_t *output_ptr = NULL;
int i; /* loop index, as usual */
int ret = -1;
/* result of the interpolation */
float result;
output_ptr = GammaOperation::GetInstance()->nat_cubic_spline(num_points, output);
/* Now use our spline on each val we made up */
for (i = 0; i < mPQdb->Gamma_nodes; i++) {
/* Make sure to test the return value before we use the result */
if ((ret = GammaOperation::GetInstance()->evaluate(output_ptr, (float)i, &result)) < 0) {
/* Should fail on none of the inputs */
//LOGE("%s evaluate failed: %d\n", __FUNCTION__, ret);
return ret;
}
/* print the input x value and the interpolated y */
//LOGE("%s %.2f,%.2f\n", __FUNCTION__, (float)i, result);
gamma[i] = (unsigned short)result;
if (i > 0) {
if (gamma[i - 1] > gamma[i]) {
gamma[i] = gamma[i - 1];
}
}
if (gamma[i] >= 1020) {
gamma[i] = 1020;
}
//LOGE("%s gamma.data[%d] = %hd\n", __FUNCTION__, i, gamma[i]);
}
return ret;
}
int CPQControl::DBGammaBlend(tcon_gamma_table_t *wb_gamma, unsigned int *index_gamma)
{
unsigned int i, final_value;
unsigned int blend_alp, blend_bet;
tcon_gamma_table_t target_gamma;
unsigned int Node = (unsigned int)mPQdb->Gamma_nodes;
for (i = 1; i < (Node - 1); i++) {
blend_alp = index_gamma[i] / 1000;
blend_bet = index_gamma[i] % 1000;
if (blend_alp > (Node - 1)) {
LOGD("%s, blend_gamma->data[%d] = %d\n", __FUNCTION__, i, index_gamma[i]);
LOGD("%s, blend_alp = %d\n", __FUNCTION__, blend_alp);
LOGD("%s, blend_bet = %d\n", __FUNCTION__, blend_bet);
continue;
}
final_value = wb_gamma->data[blend_alp] + (wb_gamma->data[blend_alp + 1] - wb_gamma->data[blend_alp]) * blend_bet / 1000;
target_gamma.data[i] = (unsigned short)final_value;
}
target_gamma.data[0] = wb_gamma->data[0];
target_gamma.data[Node - 1] = wb_gamma->data[Node - 1];
memcpy(wb_gamma, &target_gamma, sizeof(tcon_gamma_table_t));
return 0;
}
double CPQControl::GetGammaPower(vpp_gamma_curve_t mode)
{
double gamma_power = 2.2;
switch (mode) {
case VPP_GAMMA_CURVE_DEFAULT:
gamma_power = 2.2;
break;
case VPP_GAMMA_CURVE_1:
gamma_power = 1.7;
break;
case VPP_GAMMA_CURVE_2:
gamma_power = 1.8;
break;
case VPP_GAMMA_CURVE_3:
gamma_power = 1.9;
break;
case VPP_GAMMA_CURVE_4:
gamma_power = 2.0;
break;
case VPP_GAMMA_CURVE_5:
gamma_power = 2.1;
break;
case VPP_GAMMA_CURVE_6:
gamma_power = 2.2;
break;
case VPP_GAMMA_CURVE_7:
gamma_power = 2.3;
break;
case VPP_GAMMA_CURVE_8:
gamma_power = 2.4;
break;
case VPP_GAMMA_CURVE_9:
gamma_power = 2.5;
break;
case VPP_GAMMA_CURVE_10:
gamma_power = 2.6;
break;
case VPP_GAMMA_CURVE_11:
gamma_power = 2.7;
break;
default:
gamma_power = 2.2;
break;
}
return gamma_power;
}
int CPQControl::SetWbGammaEnable(int enable)
{
int colortemp = GetColorTemperature();
WB_GAMMA_TABLE pData;
if (GetWhitebalanceGammaData(&pData, colortemp)) {
LOGD("%s, Get Whitebalance Gamma Data from ssmdata\n", __FUNCTION__);
} else {
LOGE("%s, Have no data\n", __FUNCTION__);
return -1;
}
pData.ENABLE = enable;
if (!SetWhitebalanceGammaData(&pData, colortemp)) {
LOGE("%s, SetWhitebalanceGammaData fail\n", __FUNCTION__);
return -1;
}
if (Cpq_LoadGamma((vpp_gamma_curve_t)GetGammaValue(), (vpp_color_temperature_mode_t)colortemp) < 0) {
LOGE("%s, Cpq_LoadGamma fail\n", __FUNCTION__);
return -1;
}
LOGD("%s success\n",__FUNCTION__);
return 0;
}
int CPQControl::GetWbGammaEnable(void)
{
WB_GAMMA_TABLE pData;
if (GetWhitebalanceGammaData(&pData, GetColorTemperature())) {
LOGD("%s, Get Whitebalance Gamma Data from ssmdata\n", __FUNCTION__);
} else {
LOGE("%s, Have no data\n", __FUNCTION__);
return 0;
}
int enable = pData.ENABLE;
if (enable < 0 || enable > 1) {
enable = 0;
}
LOGD("%s enable: %d\n",__FUNCTION__, enable);
return enable;
}
int CPQControl::SetWbGammaMode(int mode)
{
int colortemp = GetColorTemperature();
PICTURE_SETTING_GLOBAL pData;
if (!GetPictureStructDataGlobal(&pData)) {
LOGE("%s GetPictureStructDataGlobal failed!\n",__FUNCTION__);
return -1;
}
if (pData.WBGammaPoint != mode) {
pData.WBGammaPoint = mode;
if (!SetPictureStructDataGlobal(&pData)) {
LOGE("%s SetPictureStructDataGlobal failed!\n",__FUNCTION__);
return -1;
}
} else {
LOGD("%s, same mode %d!\n", __FUNCTION__, mode);
return 0;
}
if (Cpq_LoadGamma((vpp_gamma_curve_t)GetGammaValue(), (vpp_color_temperature_mode_t)colortemp) < 0) {
LOGE("%s, Cpq_LoadGammafail\n", __FUNCTION__);
return -1;
}
LOGD("%s, success!\n", __FUNCTION__);
return 0;
}
int CPQControl::GetWbGammaMode(void)
{
int mode = WB_GAMMA_MODE_11POINT;
PICTURE_SETTING_GLOBAL pData;
if (!GetPictureStructDataGlobal(&pData)) {
LOGE("%s GetPictureStructDataGlobal failed!\n",__FUNCTION__);
return -1;
}
mode = pData.WBGammaPoint;
if (mode < WB_GAMMA_MODE_2POINT || mode >= WB_GAMMA_MODE_MAX) {
mode = WB_GAMMA_MODE_11POINT;
}
return mode;
}
int CPQControl::SetWhitebalanceGamma(int channel, int point, int offset)
{
if (channel >= MAX_CH) {
LOGE("%s, channel = %d, out of range\n", __FUNCTION__, channel);
return -1;
}
if (point >= MAX_WB_GAMMA_POINT) {
LOGE("%s, point = %d, out of range\n", __FUNCTION__, point);
return -1;
}
int colortemp = GetColorTemperature();
WB_GAMMA_TABLE pData;
if (GetWhitebalanceGammaData(&pData, colortemp)) {
LOGD("%s, Get Whitebalance Gamma Data from ssmdata\n", __FUNCTION__);
} else {
LOGE("%s, Have no data\n", __FUNCTION__);
return -1;
}
if (channel == RED_CH)
pData.WB_GAMMA_DATA.R_OFFSET[point] = offset;
else if (channel == GREEN_CH)
pData.WB_GAMMA_DATA.G_OFFSET[point] = offset;
else if (channel == BLUE_CH)
pData.WB_GAMMA_DATA.B_OFFSET[point] = offset;
else
return -1;
if (!SetWhitebalanceGammaData(&pData, colortemp)) {
LOGE("%s, SetWhitebalanceGammaData fail\n", __FUNCTION__);
return -1;
}
if (Cpq_LoadGamma((vpp_gamma_curve_t)GetGammaValue(), (vpp_color_temperature_mode_t)colortemp) < 0) {
LOGE("%s, Cpq_LoadGamma fail\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::GetWhitebalanceGamma(int channel, int point)
{
int offset = 0;
if (channel >= MAX_CH) {
LOGE("%s, channel = %d, out of range\n", __FUNCTION__, channel);
return offset;
}
if (point >= MAX_WB_GAMMA_POINT) {
LOGE("%s, point = %d, out of range\n", __FUNCTION__, point);
return offset;
}
int colortemp = GetColorTemperature();
WB_GAMMA_TABLE pData;
if (GetWhitebalanceGammaData(&pData, colortemp)) {
LOGD("%s, Get Whitebalance Gamma Data from ssmdata\n", __FUNCTION__);
} else {
LOGE("%s, Have no data\n", __FUNCTION__);
return 0;
}
if (channel == RED_CH)
offset = pData.WB_GAMMA_DATA.R_OFFSET[point];
else if (channel == GREEN_CH)
offset = pData.WB_GAMMA_DATA.G_OFFSET[point];
else if (channel == BLUE_CH)
offset = pData.WB_GAMMA_DATA.B_OFFSET[point];
else
offset = 0;
return offset;
}
int CPQControl::FactorySetWhitebalanceGamma(int colortemp, int channel, int point, int offset)
{
if (channel >= MAX_CH) {
LOGE("%s, channel = %d, out of range\n", __FUNCTION__, channel);
return -1;
}
if (point >= MAX_WB_GAMMA_POINT) {
LOGE("%s, point = %d, out of range\n", __FUNCTION__, point);
return -1;
}
CheckCriDataWhitebalanceGammaData();
WB_GAMMA_TABLE_DATA pData;
if (!FactoryGetWhitebalanceGammaData(&pData, colortemp)) {
LOGE("%s, FactoryGetWhitebalanceGammaData fail\n", __FUNCTION__);
return -1;
}
if (channel == RED_CH)
pData.R_OFFSET[point] = offset;
else if (channel == GREEN_CH)
pData.G_OFFSET[point] = offset;
else if (channel == BLUE_CH)
pData.B_OFFSET[point] = offset;
else
return -1;
if (!FactorySetWhitebalanceGammaData(&pData, colortemp)) {
LOGE("%s, FactorySetWhitebalanceGammaData fail\n", __FUNCTION__);
return -1;
}
if (Cpq_LoadGamma((vpp_gamma_curve_t)GetGammaValue(), (vpp_color_temperature_mode_t)colortemp) < 0) {
LOGE("%s, Cpq_LoadGamma fail\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetWhitebalanceGamma(int colortemp, int channel, int point)
{
int offset = 0;
if (channel >= MAX_CH) {
LOGE("%s, channel = %d, out of range\n", __FUNCTION__, channel);
return offset;
}
if (point >= MAX_WB_GAMMA_POINT) {
LOGE("%s, point = %d, out of range\n", __FUNCTION__, point);
return offset;
}
CheckCriDataWhitebalanceGammaData();
WB_GAMMA_TABLE_DATA pData;
if (!FactoryGetWhitebalanceGammaData(&pData, colortemp)) {
LOGE("%s, GetWhitebalanceGammaData fail\n", __FUNCTION__);
return offset;
}
if (channel == RED_CH)
offset = pData.R_OFFSET[point];
else if (channel == GREEN_CH)
offset = pData.G_OFFSET[point];
else if (channel == BLUE_CH)
offset = pData.B_OFFSET[point];
else
offset = 0;
return offset;
}
int CPQControl::FactorySetGammaTable(unsigned int *pData, int type, int level, int len)
{
if (pData == NULL || len > GAMMA_NUMBER) {
LOGE("%s invalid value len = %d\n",__FUNCTION__, len);
return -1;
}
if (type >= MAX_CH) {
LOGE("%s invalid value type = %d\n",__FUNCTION__, type);
return -1;
}
if (level < 0 || level >= VPP_COLOR_TEMPERATURE_MODE_MAX) {
LOGE("%s invalid value level = %d\n",__FUNCTION__, level);
return -1;
}
int i;
tcon_gamma_table_t Gamma;
memset(&Gamma, 0, sizeof(tcon_gamma_table_t));
for (i = 0; i < len; ++i) {
Gamma.data[i] = (pData[i] > 1023) ? 1023 : pData[i];
}
for (; i < GAMMA_NUMBER; ++i) {
Gamma.data[i] = 1023;
}
if (!mSSMAction->SetGammaDataTable(&Gamma, level, type)) {
LOGE("%s mWBDataBase->SetGammaTableData fail len = %d\n",__FUNCTION__, len);
return -1;
}
// to driver
if (type == RED_CH)
Cpq_SetGammaTbl_R((unsigned short *)Gamma.data);
else if (type == GREEN_CH)
Cpq_SetGammaTbl_G((unsigned short *)Gamma.data);
else if (type == BLUE_CH)
Cpq_SetGammaTbl_B((unsigned short *)Gamma.data);
else
return -1;
LOGI("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::FactoryGetGammaTable(unsigned int *pData, int type, int level, int len)
{
if (pData == NULL || len > GAMMA_NUMBER) {
LOGE("%s invalid value len = %d\n",__FUNCTION__, len);
return -1;
}
if (type >= MAX_CH) {
LOGE("%s invalid value type = %d\n",__FUNCTION__, type);
return -1;
}
if (level < 0 || level >= VPP_COLOR_TEMPERATURE_MODE_MAX) {
LOGE("%s invalid value level = %d\n",__FUNCTION__, level);
return -1;
}
int i;
tcon_gamma_table_t Gamma;
memset(&Gamma, 0, sizeof(tcon_gamma_table_t));
if (!mSSMAction->GetGammaDataTable(&Gamma, level, type)) {
LOGE("%s mWBDataBase->GetGammaDataTable fail len = %d\n",__FUNCTION__, len);
return -1;
}
for (i = 0; i < len; ++i) {
pData[i] = Gamma.data[i];
}
for (; i < GAMMA_NUMBER; ++i) {
pData[i] = 1023;
}
LOGI("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::FactoryClearGammaTable(void)
{
int i, j;
tcon_gamma_table_t Gamma;
memset(&Gamma, 0, sizeof(tcon_gamma_table_t));
for (i = 0; i < VPP_COLOR_TEMPERATURE_MODE_MAX; i++) {
for (j = 0; j < MAX_CH; j ++) {
if (mSSMAction->GetGammaDataTable(&Gamma, i, j)) {
if (!mSSMAction->ClearGammaDataTable(i, j)) {
LOGE("%s colortemp: %d, type: %d fail!\n", __FUNCTION__, i, j);
break;
}
LOGD("%s Clear colortemp: %d, type: %d Data!\n", __FUNCTION__, i, j);
}
}
}
return 0;
}
int CPQControl::SetGammaPattern(int enable, int R, int G, int B)
{
if (enable == 0) {
return Cpq_LoadGamma((vpp_gamma_curve_t)GetGammaValue(), (vpp_color_temperature_mode_t)GetColorTemperature());
}
tcon_gamma_table_t WB_GAMMA_R, WB_GAMMA_G, WB_GAMMA_B;
for (int i = 0; i < 257; i++) {
WB_GAMMA_R.data[i] = R * 4;
WB_GAMMA_G.data[i] = G * 4;
WB_GAMMA_B.data[i] = B * 4;
if (WB_GAMMA_R.data[i] > 1023) WB_GAMMA_R.data[i] = 1023;
if (WB_GAMMA_G.data[i] > 1023) WB_GAMMA_G.data[i] = 1023;
if (WB_GAMMA_B.data[i] > 1023) WB_GAMMA_B.data[i] = 1023;
}
Cpq_SetGammaTbl_R(WB_GAMMA_R.data);
Cpq_SetGammaTbl_G(WB_GAMMA_G.data);
Cpq_SetGammaTbl_B(WB_GAMMA_B.data);
return true;
}
int CPQControl::Cpq_SetGammaTbl_R(unsigned short red[GAMMA_NUMBER])
{
struct tcon_gamma_table_s Redtbl;
int ret = -1;
unsigned int i = 0;
for (i = 0; i < sizeof(Redtbl)/sizeof(__u16); i++) {
Redtbl.data[i] = red[i];
}
ret = VPPDeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_R, &Redtbl);
if (ret < 0) {
LOGE("%s error(%s)!\n", __FUNCTION__, strerror(errno));
}
return ret;
}
int CPQControl::Cpq_SetGammaTbl_G(unsigned short green[GAMMA_NUMBER])
{
struct tcon_gamma_table_s Greentbl;
int ret = -1;
unsigned int i = 0;
for (i = 0; i < sizeof(Greentbl)/sizeof(__u16); i++) {
Greentbl.data[i] = green[i];
}
ret = VPPDeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_G, &Greentbl);
if (ret < 0) {
LOGE("%s error(%s)!\n", __FUNCTION__, strerror(errno));
}
return ret;
}
int CPQControl::Cpq_SetGammaTbl_B(unsigned short blue[GAMMA_NUMBER])
{
struct tcon_gamma_table_s Bluetbl;
int ret = -1;
unsigned int i = 0;
for (i = 0; i < sizeof(Bluetbl)/sizeof(__u16); i++) {
Bluetbl.data[i] = blue[i];
}
ret = VPPDeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_B, &Bluetbl);
if (ret < 0) {
LOGE("%s error(%s)!\n", __FUNCTION__, strerror(errno));
}
return ret;
}
//MEMC
bool CPQControl::HasMemcFunc(void)
{
if ((mMemcFd > 0 || mDpssMemcFd > 0) && (mbCpqCfg_memc_enable)) {
SYS_LOGD("%s, has memc\n", __FUNCTION__);
return true;
}
SYS_LOGD("%s, has NO memc\n", __FUNCTION__);
return false;
}
int CPQControl::Memc_enable(int enable)
{
int ret = DPSS_MEMCDeviceIOCtl(DPSS_FRC_IOC_SET_MEMC_ON_OFF, &enable);
if (ret < 0) {
ret = MEMCDeviceIOCtl(FRC_IOC_SET_MEMC_ON_OFF, &enable);
}
if (ret >= 0) {
LOGD("%s, sucess\n", __FUNCTION__);
} else {
LOGE("%s, fail\n", __FUNCTION__);
}
return ret;
}
int CPQControl::SetMemcMode(int memc_mode, int is_save)
{
LOGD("%s, mode = %d\n", __FUNCTION__, memc_mode);
int ret = -1;
ret = Cpq_SetMemcMode(memc_mode, mCurrentSourceInputInfo);
if (ret == 0 && is_save == 1) {
ret = SaveMemcMode((vpp_memc_mode_t)memc_mode);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetMemcMode()
{
int level = VPP_MEMC_MODE_OFF;
PICTURE_SETTING_BY_SRC para;
if (!GetPictureStructDataBySrc(&para)) {
LOGE("%s: GetPictureStructDataBySrc fail!\n",__FUNCTION__);
return level;
}
level = para.Memc;
if (level < VPP_MEMC_MODE_OFF || level >= VPP_MEMC_MODE_MAX) {
level = VPP_MEMC_MODE_OFF;
}
return level;
}
int CPQControl::SaveMemcMode(vpp_memc_mode_t memc_mode)
{
LOGD("%s, source: %d, mode = %d\n", __FUNCTION__, mSourceInputForSaveParam, memc_mode);
PICTURE_SETTING_BY_SRC para;
if (!GetPictureStructDataBySrc(&para)) {
LOGE("%s: GetPictureStructDataBySrc fail!\n",__FUNCTION__);
return -1;
}
para.Memc = memc_mode;
if (!SetPictureStructDataBySrc(&para)) {
LOGE("%s: SetPictureStructDataBySrc fail!\n",__FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetMemcMode(int memc_mode, source_input_param_t source_input_param)
{
if (!mbCpqCfg_memc_enable) {
LOGD("Memc module disabled!!!\n");
return 0;
}
if (memc_mode < 0 || memc_mode >= MEMC_MODE_MAX) {
SYS_LOGE("memc_mode: %d outoff range!!!\n", memc_mode);
return -1;
}
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData)) {
LOGE("%s: GetPictureStructDataBySrc fail!\n",__FUNCTION__);
return -1;
}
int ret = 0;
int DeJudder_level = pData.memc[memc_mode].DeJudderLevel;
int DeBlur_Level = pData.memc[memc_mode].DeBlurLevel;
ret |= Cpq_SetMemcDeJudderLevel(DeJudder_level, source_input_param);
ret |= Cpq_SetMemcDeBlurLevel(DeBlur_Level, source_input_param);
if (memc_mode == VPP_MEMC_MODE_OFF)
Memc_enable(0);
else
Memc_enable(1);
if (ret < 0)
LOGE("%s failed!\n",__FUNCTION__);
else
LOGD("%s success! memc_mode: %d\n",__FUNCTION__, memc_mode);
return ret;
}
int CPQControl::SetMemcDeBlurLevel(int level, int is_save)
{
LOGD("%s, source: %d, level = %d\n", __FUNCTION__, mSourceInputForSaveParam, level);
int ret = -1;
ret = Cpq_SetMemcDeBlurLevel(level, mCurrentSourceInputInfo);
if ((ret ==0) && (is_save == 1)) {
ret = SaveMemcDeBlurLevel(level);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetMemcDeBlurLevel(void)
{
int level = 0;
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData)) {
LOGE("%s GetPictureStructDataBySrc failed\n", __FUNCTION__);
return level;
}
int mode = GetMemcMode();
if (mode < MEMC_MODE_OFF || mode >= MEMC_MODE_MAX) {
mode = MEMC_MODE_OFF;
LOGE("%s, mode out of range, use default!!\n", __FUNCTION__);
}
level = pData.memc[mode].DeBlurLevel;
LOGD("%s, success! source: %d, timming: %d, level = %d\n", __FUNCTION__, CurSource, CurTimming, level);
return level;
}
int CPQControl::SaveMemcDeBlurLevel(int level)
{
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData)) {
LOGE("%s GetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
int mode = GetMemcMode();
if (mode < MEMC_MODE_OFF || mode >= MEMC_MODE_MAX) {
mode = MEMC_MODE_OFF;
LOGE("%s, mode out of range, use default!!\n", __FUNCTION__);
}
pData.memc[mode].DeBlurLevel = level;
if (!SetPictureStructDataBySrc(&pData)) {
LOGE("%s SetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
LOGI("%s, success! source: %d, timming: %d, level = %d\n", __FUNCTION__, CurSource, CurTimming, level);
return 0;
}
int CPQControl::Cpq_SetMemcDeBlurLevel(int level, source_input_param_t source_input_param)
{
if (!mbCpqCfg_memc_enable) {
LOGD("%s memc Disabled!\n",__FUNCTION__);
return 0;
}
if (DPSS_MEMCDeviceIOCtl(DPSS_FRC_IOC_SET_DEBLUR_LEVEL, &level) < 0) {
if (MEMCDeviceIOCtl(FRC_IOC_SET_DEBLUR_LEVEL, &level) < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
}
LOGD("%s, success! source: %d, timming: %d, level = %d\n", __FUNCTION__, CurSource, CurTimming, level);
return 0;
}
int CPQControl::SetMemcDeJudderLevel(int level, int is_save)
{
LOGD("%s, source: %d, level = %d\n", __FUNCTION__, mSourceInputForSaveParam, level);
int ret = -1;
ret = Cpq_SetMemcDeJudderLevel(level, mCurrentSourceInputInfo);
if ((ret ==0) && (is_save == 1)) {
ret = SaveMemcDeJudderLevel(level);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetMemcDeJudderLevel(void)
{
int level = 0;
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData)) {
LOGE("%s GetPictureStructDataBySrc failed\n", __FUNCTION__);
return level;
}
int mode = GetMemcMode();
if (mode < MEMC_MODE_OFF || mode >= MEMC_MODE_MAX) {
mode = MEMC_MODE_OFF;
LOGE("%s, mode out of range, use default!!\n", __FUNCTION__);
}
level = pData.memc[mode].DeJudderLevel;
LOGD("%s, source: %d, timming: %d, level = %d\n", __FUNCTION__, CurSource, CurTimming, level);
return level;
}
int CPQControl::SaveMemcDeJudderLevel(int level)
{
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData)) {
LOGE("%s GetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
int mode = GetMemcMode();
if (mode < MEMC_MODE_OFF || mode >= MEMC_MODE_MAX) {
mode = MEMC_MODE_OFF;
LOGE("%s, mode out of range, use default!!\n", __FUNCTION__);
}
pData.memc[mode].DeJudderLevel = level;
if (!SetPictureStructDataBySrc(&pData)) {
LOGE("%s SetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
LOGD("%s, success! source: %d, timming: %d, level = %d\n", __FUNCTION__, CurSource, CurTimming, level);
return 0;
}
int CPQControl::Cpq_SetMemcDeJudderLevel(int level, source_input_param_t source_input_param)
{
if (!mbCpqCfg_memc_enable) {
LOGD("%s memc Disabled!\n",__FUNCTION__);
return 0;
}
if (DPSS_MEMCDeviceIOCtl(DPSS_FRC_IOC_SET_MEMC_LEVEL, &level) < 0) {
if (MEMCDeviceIOCtl(FRC_IOC_SET_MEMC_LEVEL, &level) < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
}
LOGD("%s, success! source: %d, timming: %d, level = %d\n", __FUNCTION__, CurSource, CurTimming, level);
return 0;
}
//Displaymode
int CPQControl::SetDisplayMode(vpp_display_mode_t display_mode, int is_save)
{
LOGD("%s, source: %d, value = %d\n", __FUNCTION__, mCurrentSourceInputInfo.source_input, display_mode);
int ret = -1;
if (mbCpqCfg_display_overscan_enable) {
//dtvkit process afd function,driver need output full
if (display_mode == VPP_DISPLAY_MODE_NORMAL) {
pqWriteSys(VPP_AFD_MODULE_ASPECT_MODE, "0 0");//set auto to afd before pq display
}
if (mbDtvKitEnable && (display_mode == VPP_DISPLAY_MODE_NORMAL)) {
ret = Cpq_SetDisplayModeAllTiming(mCurrentSourceInputInfo.source_input, display_mode);
ret = Cpq_SetDisplayModeScreenMode(mCurrentSourceInputInfo.source_input, display_mode);
} else if ((mCurrentSourceInputInfo.source_input == SOURCE_DTV)
|| (mCurrentSourceInputInfo.source_input == SOURCE_TV)
|| (mCurrentSourceInputInfo.source_input == SOURCE_AV1)
|| (mCurrentSourceInputInfo.source_input == SOURCE_AV2)) {
ret = Cpq_SetDisplayModeAllTiming(mCurrentSourceInputInfo.source_input, display_mode);
} else {
ret = Cpq_SetDisplayModeAllTiming(mCurrentSourceInputInfo.source_input, display_mode);
ret = Cpq_SetDisplayModeOneTiming(mCurrentSourceInputInfo.source_input, display_mode);
}
if (display_mode != VPP_DISPLAY_MODE_NORMAL) {
pqWriteSys(VPP_AFD_MODULE_ASPECT_MODE, "0 5");//set custom to afd after pq display
}
if ((ret == 0) && (is_save == 1)) {
ret = SaveDisplayMode(display_mode);
}
} else {
LOGD("%s Display overscan disabled!\n", __FUNCTION__);
ret= 0;
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetDisplayMode()
{
int mode = VPP_DISPLAY_MODE_169;
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData)) {
LOGE("%s GetPictureStructDataBySrc failed\n", __FUNCTION__);
return mode;
}
mode = pData.DisplayMode;
if (mode < VPP_DISPLAY_MODE_169 || mode >= VPP_DISPLAY_MODE_MAX) {
mode = VPP_DISPLAY_MODE_169;
}
LOGD("%s, source: %d, value = %d\n", __FUNCTION__, CurSource, mode);
return mode;
}
int CPQControl::SaveDisplayMode(vpp_display_mode_t display_mode)
{
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData)) {
LOGE("%s GetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
pData.DisplayMode = (int)display_mode;
if (!SetPictureStructDataBySrc(&pData)) {
LOGE("%s SetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetDisplayModeScreenMode(tv_source_input_t source_input, vpp_display_mode_t display_mode)
{
int ret = 0;
int ScreenModeValue = Cpq_GetScreenModeValue(display_mode);
if (source_input == SOURCE_DTV) {//DTVKIT
if ((mbDtvKitEnable && (ScreenModeValue == SCREEN_MODE_NORMAL)) || (!mbDtvKitEnable)) {
ScreenModeValue = SCREEN_MODE_FULL_STRETCH;
}
} else if (source_input == SOURCE_MPEG) {//MPEG
if ((mbDtvKitEnable && (ScreenModeValue == SCREEN_MODE_NORMAL)) || (!mbDtvKitEnable)) {
ScreenModeValue = SCREEN_MODE_FULL_STRETCH;
}
} else if ((source_input >= SOURCE_HDMI1) && (source_input <= SOURCE_HDMI4)) {//hdmi source
if (display_mode == VPP_DISPLAY_MODE_NORMAL) {//auto mode
if (mCurrentAfdInfo == TVIN_ASPECT_4x3_FULL) {
ScreenModeValue = SCREEN_MODE_4_3;
} else if (mCurrentAfdInfo == TVIN_ASPECT_14x9_FULL) {
ScreenModeValue = SCREEN_MODE_NORMAL;
} else if (mCurrentAfdInfo == TVIN_ASPECT_16x9_FULL) {
ScreenModeValue = SCREEN_MODE_16_9;
} else {
LOGD("%s: invalid AFD status\n", __FUNCTION__);
}
}
}
LOGD("%s: screenmode:%d\n", __FUNCTION__, ScreenModeValue);
Cpq_SetVideoScreenMode(ScreenModeValue);
return ret;
}
int CPQControl::SaveDisplayModeBySrc(int source_input, int display_mode)
{
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData, src)) {
LOGE("%s GetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
pData.DisplayMode = display_mode;
if (!SetPictureStructDataBySrc(&pData, src)) {
LOGE("%s SetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetDisplayModeOneTiming(tv_source_input_t source_input, vpp_display_mode_t display_mode)
{
int ret = -1;
tvin_cutwin_t cutwin;
if (mbCpqCfg_separate_db_enable) {
ret = mpOverScandb->PQ_GetOverscanParams(mCurrentSourceInputInfo, display_mode, &cutwin);
}
if (ret == 0) {
int ScreenModeValue = Cpq_GetScreenModeValue(display_mode);
if (source_input == SOURCE_DTV) {//DTVKIT
cutwin.vs = 0;
cutwin.hs = 0;
cutwin.ve = 0;
cutwin.he = 0;
if ((mbDtvKitEnable && (ScreenModeValue == SCREEN_MODE_NORMAL))
||(!mbDtvKitEnable)) {
ScreenModeValue = SCREEN_MODE_FULL_STRETCH;
}
} else if (source_input == SOURCE_MPEG) {//MPEG
cutwin.vs = 0;
cutwin.hs = 0;
cutwin.ve = 0;
cutwin.he = 0;
if ((mbDtvKitEnable && (ScreenModeValue == SCREEN_MODE_NORMAL))
||(!mbDtvKitEnable)) {
ScreenModeValue = SCREEN_MODE_FULL_STRETCH;
}
} else if ((source_input >= SOURCE_HDMI1) && (source_input <= SOURCE_HDMI4)) {//hdmi source
if (GetPQMode() == VPP_PICTURE_MODE_MONITOR) {//hdmi monitor mode
cutwin.vs = 0;
cutwin.hs = 0;
cutwin.ve = 0;
cutwin.he = 0;
}
if (display_mode == VPP_DISPLAY_MODE_NORMAL) {//auto mode
if (mCurrentAfdInfo == TVIN_ASPECT_4x3_FULL) {
ScreenModeValue = SCREEN_MODE_4_3;
} else if (mCurrentAfdInfo == TVIN_ASPECT_14x9_FULL) {
ScreenModeValue = SCREEN_MODE_NORMAL;
} else if (mCurrentAfdInfo == TVIN_ASPECT_16x9_FULL) {
ScreenModeValue = SCREEN_MODE_16_9;
} else {
LOGE("%s: invalid AFD status.\n", __FUNCTION__);
}
}
}
LOGD("%s: screenmode:%d hs:%d he:%d vs:%d ve:%d\n", __FUNCTION__, ScreenModeValue, cutwin.hs, cutwin.he, cutwin.vs, cutwin.ve);
Cpq_SetVideoCrop(cutwin.vs, cutwin.hs, cutwin.ve, cutwin.he);
Cpq_SetVideoScreenMode(ScreenModeValue);
} else {
LOGD("PQ_GetOverscanParams failed!\n");
}
return ret;
}
int CPQControl::Cpq_SetDisplayModeAllTiming(tv_source_input_t source_input, vpp_display_mode_t display_mode)
{
int i = 0, ScreenModeValue = 0, AFDFlag = 0, adapted_mode = 0;
int ret = -1;
struct ve_pq_load_s ve_pq_load_reg;
memset(&ve_pq_load_reg, 0, sizeof(struct ve_pq_load_s));
ve_pq_load_reg.param_id = TABLE_NAME_OVERSCAN;
ve_pq_load_reg.length = SIG_TIMING_TYPE_MAX;
ve_pq_table_t ve_pq_table[SIG_TIMING_TYPE_MAX];
tvin_cutwin_t cutwin[SIG_TIMING_TYPE_MAX];
memset(ve_pq_table, 0, sizeof(ve_pq_table));
memset(cutwin, 0, sizeof(cutwin));
enum tvin_sig_fmt_e sig_fmt[SIG_TIMING_TYPE_MAX];
ve_pq_timing_type_t flag[SIG_TIMING_TYPE_MAX];
sig_fmt[0] = TVIN_SIG_FMT_HDMI_720X480P_60HZ;
sig_fmt[1] = TVIN_SIG_FMT_HDMI_720X576P_50HZ;
sig_fmt[2] = TVIN_SIG_FMT_HDMI_1280X720P_60HZ;
sig_fmt[3] = TVIN_SIG_FMT_HDMI_1920X1080P_60HZ;
sig_fmt[4] = TVIN_SIG_FMT_HDMI_3840_2160_00HZ;
sig_fmt[5] = TVIN_SIG_FMT_CVBS_NTSC_M;
sig_fmt[6] = TVIN_SIG_FMT_CVBS_NTSC_443;
sig_fmt[7] = TVIN_SIG_FMT_CVBS_PAL_I;
sig_fmt[8] = TVIN_SIG_FMT_CVBS_PAL_M;
sig_fmt[9] = TVIN_SIG_FMT_CVBS_PAL_60;
sig_fmt[10] = TVIN_SIG_FMT_CVBS_PAL_CN;
sig_fmt[11] = TVIN_SIG_FMT_CVBS_SECAM;
sig_fmt[12] = TVIN_SIG_FMT_CVBS_NTSC_50;
flag[0] = SIG_TIMING_TYPE_SD_480;
flag[1] = SIG_TIMING_TYPE_SD_576;
flag[2] = SIG_TIMING_TYPE_HD;
flag[3] = SIG_TIMING_TYPE_FHD;
flag[4] = SIG_TIMING_TYPE_UHD;
flag[5] = SIG_TIMING_TYPE_NTSC_M;
flag[6] = SIG_TIMING_TYPE_NTSC_443;
flag[7] = SIG_TIMING_TYPE_PAL_I;
flag[8] = SIG_TIMING_TYPE_PAL_M;
flag[9] = SIG_TIMING_TYPE_PAL_60;
flag[10] = SIG_TIMING_TYPE_PAL_CN;
flag[11] = SIG_TIMING_TYPE_SECAM;
flag[12] = SIG_TIMING_TYPE_NTSC_50;
source_input_param_t source_input_param;
source_input_param.source_input = source_input;
source_input_param.trans_fmt = mCurrentSourceInputInfo.trans_fmt;
ScreenModeValue = Cpq_GetScreenModeValue(display_mode);
//non dtvkit,driver process afd
if (display_mode == VPP_DISPLAY_MODE_NORMAL) { //auto mode
AFDFlag = 1;
} else {
AFDFlag = 0;
}
//dtvkit process afd function,driver need output full
if (mbDtvKitEnable && (ScreenModeValue == SCREEN_MODE_NORMAL)) {
adapted_mode = 0;
ScreenModeValue = SCREEN_MODE_FULL_STRETCH;
AFDFlag = 0;
ve_pq_table[0].src_timing = (adapted_mode << 31) |
(AFDFlag << 30) |
((ScreenModeValue & 0x7f) << 24) |
((source_input & 0x7f) << 16 ) |
(0x0);
ve_pq_table[0].value1 = 0;
ve_pq_table[0].value2 = 0;
ve_pq_load_reg.param_ptr = &ve_pq_table;
ret = 0;
} else if (source_input == SOURCE_DTV) {//DTV
for (i = 0; i < SIG_TIMING_TYPE_NTSC_M; i++) {
adapted_mode = 1;
ve_pq_table[i].src_timing = (adapted_mode << 31) |
(AFDFlag << 30) |
((ScreenModeValue & 0x7f) << 24) |
((source_input & 0x7f) << 16 ) |
(flag[i]);
source_input_param.sig_fmt = sig_fmt[i];
if (mbCpqCfg_separate_db_enable) {
ret = mpOverScandb->PQ_GetOverscanParams(source_input_param, display_mode, cutwin+i);
}
if (display_mode >= VPP_DISPLAY_MODE_FULL_STRETCH && display_mode <= VPP_DISPLAY_MODE_169_COMBINED) {
LOGD("%s: Project mode!\n", __FUNCTION__);
ret = 0;
cutwin[i].he = 0;
cutwin[i].hs = 0;
cutwin[i].ve = 0;
cutwin[i].vs = 0;
}
//dtvkit process afd function,driver need output full
if (mbDtvKitEnable && (ScreenModeValue == SCREEN_MODE_FULL_STRETCH)) {
cutwin[i].he = 0;
cutwin[i].hs = 0;
cutwin[i].ve = 0;
cutwin[i].vs = 0;
}
if (ret == 0) {
LOGD("signal_fmt:0x%x, AFDFlag:%d,screen mode:%d he:%d hs:%d ve:%d vs:%d!\n", sig_fmt[i], AFDFlag, ScreenModeValue, cutwin[i].he, cutwin[i].hs, cutwin[i].ve, cutwin[i].vs);
ve_pq_table[i].value1 = ((cutwin[i].he & 0xffff)<<16) | (cutwin[i].hs & 0xffff);
ve_pq_table[i].value2 = ((cutwin[i].ve & 0xffff)<<16) | (cutwin[i].vs & 0xffff);
} else {
LOGE("PQ_GetOverscanParams failed!\n");
}
}
ve_pq_load_reg.param_ptr = &ve_pq_table;
} else if ((source_input == SOURCE_TV) || (source_input == SOURCE_AV1) || (source_input == SOURCE_AV2)) {//ATV AV SOURCE
for (i = SIG_TIMING_TYPE_NTSC_M; i < SIG_TIMING_TYPE_MAX; i++) {
adapted_mode = 1;
ve_pq_table[i].src_timing = (adapted_mode << 31) |
(AFDFlag << 30) |
((ScreenModeValue & 0x7f) << 24) |
((source_input & 0x7f) << 16 ) |
(flag[i]);
source_input_param.sig_fmt = sig_fmt[i];
if (mbCpqCfg_separate_db_enable) {
ret = mpOverScandb->PQ_GetOverscanParams(source_input_param, display_mode, cutwin+i);
}
if (ret == 0) {
LOGD("signal_fmt:0x%x, screen mode:%d hs:%d he:%d vs:%d ve:%d!\n", sig_fmt[i], ScreenModeValue, cutwin[i].he, cutwin[i].hs, cutwin[i].ve, cutwin[i].vs);
ve_pq_table[i].value1 = ((cutwin[i].he & 0xffff)<<16) | (cutwin[i].hs & 0xffff);
ve_pq_table[i].value2 = ((cutwin[i].ve & 0xffff)<<16) | (cutwin[i].vs & 0xffff);
} else {
LOGE("PQ_GetOverscanParams failed!\n");
}
}
ve_pq_load_reg.param_ptr = &ve_pq_table;
} else {//HDMI && MPEG
adapted_mode = 0;
ve_pq_table[0].src_timing = (adapted_mode << 31) |
(AFDFlag << 30) |
((ScreenModeValue & 0x7f) << 24) |
((source_input & 0x7f) << 16 ) |
(0x0);
ve_pq_table[0].value1 = 0;
ve_pq_table[0].value2 = 0;
ve_pq_load_reg.param_ptr = &ve_pq_table;
ret = 0;
}
if (ret == 0) {
LOGD("source_input:%d, adapted_mode:%d, AFDFlag:%d,screen mode:%d\n", source_input, adapted_mode, AFDFlag, ScreenModeValue);
ret = Cpq_LoadDisplayModeRegs(ve_pq_load_reg);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
} else {
LOGD("%s success!\n",__FUNCTION__);
return 0;
}
}
int CPQControl::Cpq_GetScreenModeValue(vpp_display_mode_t display_mode)
{
int value = SCREEN_MODE_16_9;
switch ( display_mode ) {
case VPP_DISPLAY_MODE_169:
value = SCREEN_MODE_16_9;
break;
case VPP_DISPLAY_MODE_MODE43:
value = SCREEN_MODE_4_3;
break;
case VPP_DISPLAY_MODE_NORMAL:
value = SCREEN_MODE_NORMAL;
break;
case VPP_DISPLAY_MODE_FULL:
value = SCREEN_MODE_NONLINEAR;
Cpq_SetNonLinearFactor(20);
break;
case VPP_DISPLAY_MODE_NOSCALEUP:
value = SCREEN_MODE_NORMAL_NOSCALEUP;
break;
case VPP_DISPLAY_MODE_FULL_STRETCH:
value = SCREEN_MODE_FULL_STRETCH;
break;
case VPP_DISPLAY_MODE_43_IGNORE:
value = SCREEN_MODE_4_3_IGNORE;
break;
case VPP_DISPLAY_MODE_43_LETTER_BOX:
value = SCREEN_MODE_4_3_LETTER_BOX;
break;
case VPP_DISPLAY_MODE_43_PAN_SCAN:
value = SCREEN_MODE_4_3_PAN_SCAN;
break;
case VPP_DISPLAY_MODE_43_COMBINED:
value = SCREEN_MODE_4_3_COMBINED;
break;
case VPP_DISPLAY_MODE_169_IGNORE:
value = SCREEN_MODE_16_9_IGNORE;
break;
case VPP_DISPLAY_MODE_169_LETTER_BOX:
value = SCREEN_MODE_16_9_LETTER_BOX;
break;
case VPP_DISPLAY_MODE_169_PAN_SCAN:
value = SCREEN_MODE_16_9_PAN_SCAN;
break;
case VPP_DISPLAY_MODE_169_COMBINED:
value = SCREEN_MODE_16_9_COMBINED;
break;
case VPP_DISPLAY_MODE_MOVIE:
case VPP_DISPLAY_MODE_PERSON:
case VPP_DISPLAY_MODE_CAPTION:
case VPP_DISPLAY_MODE_CROP:
case VPP_DISPLAY_MODE_CROP_FULL:
case VPP_DISPLAY_MODE_ZOOM:
default:
value = SCREEN_MODE_FULL_STRETCH;
break;
}
return value;
}
int CPQControl::Cpq_SetVideoScreenMode(int value)
{
LOGD("%s, value = %d\n", __FUNCTION__, value);
char val[64] = {0};
sprintf(val, "%d", value);
pqWriteSys(SCREEN_MODE_PATH, val);
return 0;
}
int CPQControl::Cpq_SetVideoCrop(int Voffset0, int Hoffset0, int Voffset1, int Hoffset1)
{
char set_str[32];
int wr_size;
LOGD("Cpq_SetVideoCrop value: %d %d %d %d\n", Voffset0, Hoffset0, Voffset1, Hoffset1);
int fd = open(CROP_PATH, O_RDWR);
if (fd < 0) {
LOGE("Open %s error(%s)!\n", CROP_PATH, strerror(errno));
return -1;
}
memset(set_str, 0, 32);
sprintf(set_str, "%d %d %d %d", Voffset0, Hoffset0, Voffset1, Hoffset1);
wr_size = write(fd, set_str, strlen(set_str));
if (wr_size < 0) {
LOGE("write error = %s\n", strerror(errno));
}
close(fd);
return 0;
}
int CPQControl::Cpq_SetNonLinearFactor(int value)
{
LOGD("Cpq_SetNonLinearFactor : %d\n", value);
FILE *fp = fopen(NOLINER_FACTORY, "w");
if (fp == NULL) {
LOGE("Open %s error(%s)!\n", NOLINER_FACTORY, strerror(errno));
return -1;
}
fprintf(fp, "%d", value);
fclose(fp);
fp = NULL;
return 0;
}
int CPQControl::SetCurrentAspectRatioInfo(enum tvin_aspect_ratio_e aspectRatioInfo)
{
int ret = 0;
if (mCurrentAfdInfo != aspectRatioInfo) {
mCurrentAfdInfo = aspectRatioInfo;
LOGD("%s mCurrentAfdInfo:%d\n", __FUNCTION__, mCurrentAfdInfo);
vpp_display_mode_t display_mode = (vpp_display_mode_t)GetDisplayMode();
ret = SetDisplayMode(display_mode, 1);
} else {
LOGE("%s: same AFD info\n", __FUNCTION__);
}
return ret;
}
//lcd hdr info
int CPQControl::Cpq_SetHdrInfo(const struct lcd_optical_info_s *plcd_hdrinfo)
{
int ret = 0;
ret = LCDDeviceIOCtl(LCD_IOC_CMD_SET_HDR_INFO, plcd_hdrinfo);
if (ret < 0) {
LOGE("%s error(%s)\n", __FUNCTION__, strerror(errno));
}
return ret;
}
int CPQControl::SetLCDhdrinfo(void)
{
int ret = -1;
struct lcd_optical_info_s lcd_hdrinfo;
if (mPQdb->PQ_GetLCDHDRInfoParams(mCurrentSourceInputInfo, &lcd_hdrinfo) == 0) {
ret = Cpq_SetHdrInfo(&lcd_hdrinfo);
} else {
LOGE("mPQdb->PQ_GetLCDHDRInfoParams failed\n");
}
if (ret < 0) {
LOGE("%s failed\n", __FUNCTION__);
} else {
LOGD("%s success\n", __FUNCTION__);
}
return ret;
}
//Backlight
int CPQControl::SetBacklight(int value, int is_save)
{
int ret = -1;
LOGD("%s: value = %d\n", __FUNCTION__, value);
if (value < 0 || value > 100) {
value = DEFAULT_BACKLIGHT_BRIGHTNESS;
}
if (isFileExist(LDIM_PATH)) {//local diming
int temp = (value * 255 / 100);
Cpq_SetBackLight(temp);
}
if (is_save == 1) {
ret = SaveBacklight(value);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
} else {
LOGD("%s success!\n",__FUNCTION__);
return 0;
}
}
int CPQControl::GetBacklight(void)
{
int data = 0;
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData)) {
SYS_LOGE("%s: GetPictureModeData fail\n",__FUNCTION__);
return data;
}
data = pData.Backlight;
if (data < 0 || data > 100) {
data = DEFAULT_BACKLIGHT_BRIGHTNESS;
}
return data;
}
int CPQControl::SaveBacklight(int value)
{
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData)) {
SYS_LOGE("%s GetPictureModeData failed!\n",__FUNCTION__);
return -1;
}
pData.Backlight = value;
if (!SetPictureModeData(&pData)) {
SYS_LOGE("%s SetPictureModeData failed!\n",__FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetBackLight(int value)
{
LOGD("%s, value = %d\n",__FUNCTION__, value);
char val[64] = {0};
sprintf(val, "%d", value);
return pqWriteSys(BACKLIGHT_PATH, val);
}
void CPQControl::Cpq_GetBacklight(int *value)
{
int ret = 0;
char buf[64] = {0};
ret = pqReadSys(BACKLIGHT_PATH, buf, sizeof(buf));
if (ret > 0) {
ret = strtol(buf, NULL, 10);
} else {
ret = 0;
}
*value = ret;
}
void CPQControl::Set_Backlight(int value)
{
Cpq_SetBackLight(value);
}
//dynamic backlight
int CPQControl::SetDynamicBacklight(Dynamic_backlight_status_t mode, int is_save)
{
LOGD("%s, mode = %d\n",__FUNCTION__, mode);
int ret = -1;
if (isFileExist(LDIM_PATH)) {//local diming
char val[64] = {0};
sprintf(val, "%d", mode);
pqWriteSys(LDIM_CONTROL_PATH, val);
}
if (is_save == 1) {
ret = SaveDynamicBacklight((int)mode);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetDynamicBacklight()
{
int mode = DYNAMIC_BACKLIGHT_OFF;
vpp_picture_mode_t pq_mode = (vpp_picture_mode_t)GetPQMode();
vpp_pictur_mode_para_t para;
if (!GetPictureModeData(&para, pq_mode)) {
LOGE("%s, GetPictureModeData fail!\n", __FUNCTION__);
return mode;
}
mode = para.DynamicBacklight;
if (mode < DYNAMIC_BACKLIGHT_OFF || mode > DYNAMIC_BACKLIGHT_HIGH) {
LOGE("%s: value: %d out of range, use default DYNAMIC_BACKLIGHT_OFF\n", __FUNCTION__, mode);
mode = DYNAMIC_BACKLIGHT_OFF;
}
return mode;
}
int CPQControl::SaveDynamicBacklight(int mode)
{
vpp_picture_mode_t pq_mode = (vpp_picture_mode_t)GetPQMode();
vpp_pictur_mode_para_t para;
if (!GetPictureModeData(&para, pq_mode)) {
LOGE("%s, GetPictureModeData fail!\n", __FUNCTION__);
return -1;
}
para.DynamicBacklight = mode;
if (!SetPictureModeData(&para, pq_mode)) {
LOGE("%s, SetPictureModeData fail!\n", __FUNCTION__);
return -1;
}
LOGD("%s: success! source: %d, timming: %d, mode = %d\n", __FUNCTION__, CurSource, CurTimming, mode);
return 0;
}
int CPQControl::DynamicBackLightInit(void)
{
int ret = 0;
Dynamic_backlight_status_t mode = (Dynamic_backlight_status_t)GetDynamicBacklight();
ret = SetDynamicBacklight(mode, 1);
if (!isFileExist(LDIM_PATH)) {
if (isFileExist(BACKLIGHT_PATH)) {
mDynamicBackLight.setObserver(this);
mDynamicBackLight.startDected();
} else {
LOGD("No auto backlight module!\n");
}
}
return ret;
}
int CPQControl::GetHistParam(struct ve_hist_s *hist)
{
memset(hist, 0, sizeof(struct ve_hist_s));
int ret = VPPDeviceIOCtl(AMVECM_IOC_G_HIST_AVG, hist);
if (ret < 0) {
//LOGE("GetAVGHistParam, error(%s)!\n", strerror(errno));
hist->ave = -1;
}
return ret;
}
bool CPQControl::isFileExist(const char *file_name)
{
struct stat tmp_st;
int ret = -1;
ret = stat(file_name, &tmp_st);
if (ret != 0 ) {
LOGE("%s, %s don't exist!\n", __FUNCTION__, file_name);
return false;
} else {
return true;
}
}
void CPQControl::GetDynamicBacklighConfig(int *thtf, int *lut_mode, int *heigh_param, int *low_param)
{
*thtf = mPQConfigFile->GetInt(CFG_SECTION_BACKLIGHT, CFG_AUTOBACKLIGHT_THTF, 0);
*lut_mode = mPQConfigFile->GetInt(CFG_SECTION_BACKLIGHT, CFG_AUTOBACKLIGHT_LUTMODE, 1);
const char *buf = NULL;
buf = mPQConfigFile->GetString(CFG_SECTION_BACKLIGHT, CFG_AUTOBACKLIGHT_LUTHIGH, NULL);
pqTransformStringToInt(buf, heigh_param);
buf = mPQConfigFile->GetString(CFG_SECTION_BACKLIGHT, CFG_AUTOBACKLIGHT_LUTLOW, NULL);
pqTransformStringToInt(buf, low_param);
}
void CPQControl::GetDynamicBacklighParam(dynamic_backlight_Param_t *DynamicBacklightParam)
{
int value = 0;
struct ve_hist_s hist;
memset(&hist, 0, sizeof(struct ve_hist_s));
GetHistParam(&hist);
DynamicBacklightParam->hist.ave = hist.ave;
DynamicBacklightParam->hist.sum = hist.sum;
DynamicBacklightParam->hist.width = hist.width;
DynamicBacklightParam->hist.height = hist.height;
Cpq_GetBacklight(&value);
DynamicBacklightParam->CurBacklightValue = value;
DynamicBacklightParam->UiBackLightValue = GetBacklight();
DynamicBacklightParam->CurDynamicBacklightMode = (Dynamic_backlight_status_t)GetDynamicBacklight();
DynamicBacklightParam->VideoStatus = GetVideoPlayStatus();
}
int CPQControl::GetVideoPlayStatus(void)
{
int curVideoState = 0;
if (mbVideoIsPlaying) {
curVideoState = 1;//video playing
} else {
curVideoState = 0;//video stoping
}
return curVideoState;
}
int CPQControl::SetLocalContrastMode(local_contrast_mode_t mode, int is_save)
{
LOGD("%s: mode is %d!\n",__FUNCTION__, mode);
int ret = -1;
if (mbCpqCfg_local_contrast_enable) {
ret = Cpq_SetLocalContrastMode(mode);
if ((ret == 0) && (is_save == 1)) {
ret = SaveLocalContrastMode(mode);
}
} else {
LOGD("%s: local contrast module disabled!\n",__FUNCTION__);
ret = 0;
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetLocalContrastMode(void)
{
int mode = LOCAL_CONTRAST_MODE_MID;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return mode;
}
mode = para.LocalContrast;
if (mode < LOCAL_CONTRAST_MODE_OFF || mode > LOCAL_CONTRAST_MODE_MAX) {
mode = LOCAL_CONTRAST_MODE_MID;
}
SYS_LOGD("%s, source: %d, timming: %d, value = %d\n", __FUNCTION__, CurSource, CurTimming, mode);
return mode;
}
int CPQControl::SaveLocalContrastMode(local_contrast_mode_t mode)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.LocalContrast = (int)mode;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d mode: %d fail\n",__FUNCTION__, CurSource, CurTimming, mode);
return -1;
}
SYS_LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetLocalContrastMode(local_contrast_mode_t mode)
{
if (!mbDatabaseMatchChipStatus) {
LOGD("%s: DB don't match chip\n", __FUNCTION__);
return 0;
}
if (!mbCpqCfg_local_contrast_enable) {
LOGD("%s LocalContrast Disabled\n",__FUNCTION__);
return 0;
}
struct ve_lc_curve_parm_s lc_param;
memset(&lc_param, 0x0, sizeof(struct ve_lc_curve_parm_s));
if (mPQdb->PQ_GetLocalContrastNodeParams(mCurrentSourceInputInfo, mode, &lc_param) < 0) {
LOGE("%s: PQ_GetLocalContrastNodeParams failed\n", __FUNCTION__ );
return -1;
}
if (VPPDeviceIOCtl(AMVECM_IOC_S_LC_CURVE, &lc_param) < 0) {
LOGE("%s VPPDeviceIOCtl failed\n",__FUNCTION__);
return -1;
}
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetLocalContrastRegParams(mCurrentSourceInputInfo, mode, regs) < 0) {
LOGE("%s: PQ_GetLocalContrastRegParams failed\n", __FUNCTION__ );
return -1;
}
if (Cpq_LoadRegs(regs) < 0) {
LOGE("%s Cpq_LoadRegs failed\n",__FUNCTION__);
return -1;
}
LOGD("%s success! mode: %d\n",__FUNCTION__, mode);
return 0;
}
//load aad pq
int CPQControl::Cpq_SetAAD(const struct db_aad_param_s *pAAD)
{
int ret = VPPDeviceIOCtl(AMVECM_IOC_S_AAD_PARAM, pAAD);
if (ret < 0) {
LOGE("%s error(%s)\n", __FUNCTION__, strerror(errno));
}
return ret;
}
int CPQControl::SetAad(void)
{
int ret = -1;
if (mbCpqCfg_aad_enable) {
aad_param_t newaad;
if (mPQdb->PQ_GetAADParams(mCurrentSourceInputInfo, &newaad) == 0) {
struct db_aad_param_s db_newaad;
db_newaad.aad_param_cabc_aad_en = newaad.aad_param_cabc_aad_en;
db_newaad.aad_param_aad_en = newaad.aad_param_aad_en;
db_newaad.aad_param_tf_en = newaad.aad_param_tf_en;
db_newaad.aad_param_force_gain_en = newaad.aad_param_force_gain_en;
db_newaad.aad_param_sensor_mode = newaad.aad_param_sensor_mode;
db_newaad.aad_param_mode = newaad.aad_param_mode;
db_newaad.aad_param_dist_mode = newaad.aad_param_dist_mode;
db_newaad.aad_param_tf_alpha = newaad.aad_param_tf_alpha;
db_newaad.aad_param_sensor_input[0] = newaad.aad_param_sensor_input[0];
db_newaad.aad_param_sensor_input[1] = newaad.aad_param_sensor_input[1];
db_newaad.aad_param_sensor_input[2] = newaad.aad_param_sensor_input[2];
db_newaad.db_LUT_Y_gain.length = newaad.aad_param_LUT_Y_gain_len;
db_newaad.db_LUT_Y_gain.cabc_aad_param_ptr_len = (long long)&(newaad.aad_param_LUT_Y_gain);
db_newaad.db_LUT_RG_gain.length = newaad.aad_param_LUT_RG_gain_len;
db_newaad.db_LUT_RG_gain.cabc_aad_param_ptr_len = (long long)&(newaad.aad_param_LUT_RG_gain);
db_newaad.db_LUT_BG_gain.length = newaad.aad_param_LUT_BG_gain_len;
db_newaad.db_LUT_BG_gain.cabc_aad_param_ptr_len = (long long)&(newaad.aad_param_LUT_BG_gain);
db_newaad.db_gain_lut.length = newaad.aad_param_gain_lut_len;
db_newaad.db_gain_lut.cabc_aad_param_ptr_len = (long long)&(newaad.aad_param_gain_lut);
db_newaad.db_xy_lut.length = newaad.aad_param_xy_lut_len;
db_newaad.db_xy_lut.cabc_aad_param_ptr_len = (long long)&(newaad.aad_param_xy_lut);
ret = Cpq_SetAAD(&db_newaad);
} else {
LOGE("mPQdb->PQ_GetAADParams failed\n");
}
} else {
LOGD("AAD module disabled\n");
ret = 0;
}
if (ret < 0) {
LOGE("%s failed\n",__FUNCTION__);
} else {
LOGD("%s succes\n",__FUNCTION__);
}
return ret;
}
//load aad pq
int CPQControl::Cpq_SetCABC(const struct db_cabc_param_s *pCABC)
{
int ret = VPPDeviceIOCtl(AMVECM_IOC_S_CABC_PARAM, pCABC);
if (ret < 0) {
LOGE("%s error(%s)\n", __FUNCTION__, strerror(errno));
}
return ret;
}
int CPQControl::SetCabc(void)
{
int ret = -1;
if (mbCpqCfg_cabc_enable) {
cabc_param_t newcabc;
if (mPQdb->PQ_GetCABCParams(mCurrentSourceInputInfo, &newcabc) == 0) {
struct db_cabc_param_s db_newcabc;
db_newcabc.cabc_param_cabc_en = newcabc.cabc_param_cabc_en;
db_newcabc.cabc_param_hist_mode = newcabc.cabc_param_hist_mode;
db_newcabc.cabc_param_tf_en = newcabc.cabc_param_tf_en;
db_newcabc.cabc_param_sc_flag = newcabc.cabc_param_sc_flag;
db_newcabc.cabc_param_bl_map_mode = newcabc.cabc_param_bl_map_mode;
db_newcabc.cabc_param_bl_map_en = newcabc.cabc_param_bl_map_en;
db_newcabc.cabc_param_temp_proc = newcabc.cabc_param_temp_proc;
db_newcabc.cabc_param_max95_ratio = newcabc.cabc_param_max95_ratio;
db_newcabc.cabc_param_hist_blend_alpha = newcabc.cabc_param_hist_blend_alpha;
db_newcabc.cabc_param_init_bl_min = newcabc.cabc_param_init_bl_min;
db_newcabc.cabc_param_init_bl_max = newcabc.cabc_param_init_bl_max;
db_newcabc.cabc_param_tf_alpha = newcabc.cabc_param_tf_alpha;
db_newcabc.cabc_param_sc_hist_diff_thd = newcabc.cabc_param_sc_hist_diff_thd;
db_newcabc.cabc_param_sc_apl_diff_thd = newcabc.cabc_param_sc_apl_diff_thd;
db_newcabc.cabc_param_patch_bl_th = newcabc.cabc_param_patch_bl_th;
db_newcabc.cabc_param_patch_on_alpha = newcabc.cabc_param_patch_on_alpha;
db_newcabc.cabc_param_patch_bl_off_th = newcabc.cabc_param_patch_bl_off_th;
db_newcabc.cabc_param_patch_off_alpha = newcabc.cabc_param_patch_off_alpha;
db_newcabc.db_o_bl_cv.length = newcabc.cabc_param_o_bl_cv_len;
db_newcabc.db_o_bl_cv.cabc_aad_param_ptr_len = (long long)&(newcabc.cabc_param_o_bl_cv);
db_newcabc.db_maxbin_bl_cv.length = newcabc.cabc_param_maxbin_bl_cv_len;
db_newcabc.db_maxbin_bl_cv.cabc_aad_param_ptr_len = (long long)&(newcabc.cabc_param_maxbin_bl_cv);
ret = Cpq_SetCABC(&db_newcabc);
} else {
LOGE("mPQdb->PQ_GetCABCParams failed\n");
}
} else {
LOGD("CABC module disabled\n");
ret = 0;
}
if (ret < 0) {
LOGE("%s failed\n",__FUNCTION__);
} else {
LOGD("%s succes\n",__FUNCTION__);
}
return ret;
}
int CPQControl::SetDnlpMode(Dynamic_contrast_mode_t mode, int is_save)
{
LOGD("%s src = %d, timming = %d, mode = %d!\n",__FUNCTION__, CurSource, CurTimming, mode);
int ret = -1;
ret = Cpq_SetDnlpMode(mode, mCurrentSourceInputInfo);
if (ret == 0) {
ret = SaveDnlpMode((Dynamic_contrast_mode_t)mode);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetDnlpMode()
{
int level = DYNAMIC_CONTRAST_MID;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return level;
}
level = para.DynamicContrast;
SYS_LOGI("%s, source_input = %d, mode is %d\n",__FUNCTION__, mCurrentSourceInputInfo.source_input, level);
return level;
}
int CPQControl::SaveDnlpMode(Dynamic_contrast_mode_t mode)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.DynamicContrast = (int)mode;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d mode: %d fail\n",__FUNCTION__, CurSource, CurTimming, mode);
return -1;
}
SYS_LOGI("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetDnlpMode(Dynamic_contrast_mode_t level, source_input_param_t source_input_param)
{
if (!mbCpqCfg_dnlp_enable) {
LOGD("%s DnlpMode Disabled\n", __FUNCTION__);
return 0;
}
struct ve_dnlp_curve_param_s newdnlp;
memset(&newdnlp, 0, sizeof(ve_dnlp_curve_param_s));
if (mPQdb->PQ_GetDNLPParams(mCurrentSourceInputInfo, level, &newdnlp) < 0) {
LOGE("mPQdb->PQ_GetDNLPParams failed!\n");
return -1;
}
if (VPPDeviceIOCtl(AMVECM_IOC_VE_NEW_DNLP, &newdnlp) < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
LOGD("%s success! level: %d\n",__FUNCTION__, level);
return 0;
}
int CPQControl::Cpq_SetDNLPStatus(enum dnlp_state_e status)
{
int ret = VPPDeviceIOCtl(AMVECM_IOC_S_DNLP_STATE, &status);
if (ret < 0) {
LOGE("%s error(%s)\n", __FUNCTION__, strerror(errno));
}
return ret;
}
int CPQControl::SetColorBaseMode(vpp_color_basemode_t basemode, int isSave)
{
LOGD("%s, source: %d, value:%d\n", __FUNCTION__, mCurrentSourceInputInfo.source_input, basemode);
int ret = Cpq_SetColorBaseMode(basemode, mCurrentSourceInputInfo);
if ((ret ==0) && (isSave == 1)) {
ret = SaveColorBaseMode(basemode);
}
if (ret < 0) {
LOGE("%s failed\n",__FUNCTION__);
} else {
LOGD("%s success\n",__FUNCTION__);
}
return ret;
}
vpp_color_basemode_t CPQControl::GetColorBaseMode(void)
{
int data = VPP_COLOR_BASE_MODE_OFF;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return (vpp_color_basemode_t)data;
}
data = para.CmLevel;
if (data < VPP_COLOR_BASE_MODE_OFF || data >= VPP_COLOR_BASE_MODE_MAX) {
data = VPP_COLOR_BASE_MODE_OPTIMIZE;
}
SYS_LOGD("%s: mode is %d\n", __FUNCTION__, data);
return (vpp_color_basemode_t)data;
}
int CPQControl::SaveColorBaseMode(vpp_color_basemode_t basemode)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.CmLevel = basemode;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d data: %d fail\n",__FUNCTION__, CurSource, CurTimming, basemode);
return -1;
}
SYS_LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetColorBaseMode(vpp_color_basemode_t basemode, source_input_param_t source_input_param)
{
if (!mbCpqCfg_cm2_enable) {
LOGD("CM module disabled\n");
return 0;
}
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetCM2Params((vpp_color_management2_t)basemode, source_input_param, regs) < 0) {
LOGE("PQ_GetCM2Params failed\n");
return -1;
}
if (Cpq_LoadRegs(regs) < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
LOGD("%s success! basemode: %d\n",__FUNCTION__, basemode);
return 0;
}
int CPQControl::SetColorCustomize(vpp_cms_color_t color, vpp_cms_type_t type, int value, int isSave)
{
LOGD("%s color: %d, type: %d, value: %d, isSave: %d\n", __FUNCTION__, color, type, value, isSave);
int ret = 0;
if (type > VPP_CMS_TYPE_LUMA) {
LOGE("%s type is error, not CM module request\n",__FUNCTION__);
return ret;
}
if (!GetColorCustomizeEnable())
return Cpq_SetColorCustomizeEnable(0);
else
Cpq_SetColorCustomizeEnable(1);
ret |= Cpq_SetColorCustomize(color, type, value);
if ((ret == 0) && (isSave == 1)) {
SaveColorCustomize(color, type, value);
}
if (ret < 0) {
LOGE("%s failed\n",__FUNCTION__);
} else {
LOGD("%s success\n",__FUNCTION__);
}
return ret;
}
vpp_single_color_param_cm_t CPQControl::GetColorCustomize(vpp_cms_color_t color)
{
TABLE_CMS param;
memset(&param, 0, sizeof(TABLE_CMS));
if (!GetColorCustomizeData(&param)) {
LOGE("%s GetColorCustomizeData failed!\n", __FUNCTION__);
}
for (int i = VPP_COLOR_9_PURPLE; i < VPP_COLOR_9_MAX; i++) {
LOGD("%s param.data[%d].sat/hue/luma: %d %d %d\n", __FUNCTION__, i, param.CmsColor[i].sat, param.CmsColor[i].hue, param.CmsColor[i].luma);
}
vpp_single_color_param_cm_t single_param;
memset(&single_param, 0, sizeof(vpp_single_color_param_cm_t));
single_param.sat = param.CmsColor[color].sat;
single_param.hue = param.CmsColor[color].hue;
single_param.luma = param.CmsColor[color].luma;
return single_param;
}
int CPQControl::SaveColorCustomize(vpp_cms_color_t color, vpp_cms_type_t type, int value)
{
TABLE_CMS param;
memset(&param, 0, sizeof(TABLE_CMS));
if (!GetColorCustomizeData(&param)) {
LOGE("%s GetColorCustomizeData failed!\n", __FUNCTION__);
return -1;
}
if (type == VPP_CMS_TYPE_SAT) {
param.CmsColor[color].sat = value;
} else if (type == VPP_CMS_TYPE_HUE) {
param.CmsColor[color].hue = value;
} else if (type == VPP_CMS_TYPE_LUMA) {
param.CmsColor[color].luma = value;
}
if (!SetColorCustomizeData(&param)) {
LOGE("%s SetColorCustomizeData failed!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetColorCustomize(vpp_cms_color_t color, vpp_cms_type_t type, int value)
{
struct cm_color_md pData;
memset(&pData, 0, sizeof(struct cm_color_md));
pData.color_type = cm_9_color;
pData.cm_9_color_md = (enum ecm2colormode)color;
pData.cm_14_color_md = cm_14_ecm2colormode_max;
pData.color_value = GetDriverValueMap(type, value);
LOGD("%s cm_9_color_md = %d, cm_14_color_md = %d, color_value = %d.\n", __FUNCTION__, pData.cm_9_color_md, pData.cm_14_color_md, pData.color_value);
int ret = 0;
switch (type) {
case VPP_CMS_TYPE_SAT:
ret = VPPDeviceIOCtl(AMVECM_IOC_S_CMS_SAT, &pData);
break;
case VPP_CMS_TYPE_HUE:
ret = VPPDeviceIOCtl(AMVECM_IOC_S_CMS_HUE_HS, &pData);
break;
case VPP_CMS_TYPE_LUMA:
ret = VPPDeviceIOCtl(AMVECM_IOC_S_CMS_LUMA, &pData);
break;
default:
break;
}
if (ret < 0) {
LOGE("%s failed!\n", __FUNCTION__);
}
return ret;
}
int CPQControl::Cpq_SetColorCustomizeEnable(int enable)
{
if (mColorTuneEnable == enable) {
return 0;
}
mColorTuneEnable = enable;
TABLE_CMS param;
if (enable) {
if (!GetColorCustomizeData(&param)) {
LOGE("%s GetColorCustomizeData failed!\n", __FUNCTION__);
return -1;
}
} else {
memset(&param, 0, sizeof(TABLE_CMS));
}
int ret = 0;
for (int i = VPP_COLOR_9_PURPLE; i < VPP_COLOR_9_MAX; i++) {
ret |= Cpq_SetColorCustomize((vpp_cms_color_t)i, VPP_CMS_TYPE_SAT, param.CmsColor[i].sat);
ret |= Cpq_SetColorCustomize((vpp_cms_color_t)i, VPP_CMS_TYPE_HUE, param.CmsColor[i].hue);
ret |= Cpq_SetColorCustomize((vpp_cms_color_t)i, VPP_CMS_TYPE_LUMA, param.CmsColor[i].luma);
}
return ret;
}
int CPQControl::SetColorCustomizeEnable(int enable)
{
int ret = 0;
TABLE_CMS param;
memset(&param, 0, sizeof(TABLE_CMS));
GetColorCustomizeData(&param);
ret = Cpq_SetColorCustomizeEnable(param.CmsEnable);
param.CmsEnable = enable;
SetColorCustomizeData(&param);
if (ret < 0) {
LOGE("%s failed\n",__FUNCTION__);
} else {
LOGD("%s success\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetColorCustomizeEnable(void)
{
int enable = 0;
TABLE_CMS param;
memset(&param, 0, sizeof(TABLE_CMS));
GetColorCustomizeData(&param);
enable = param.CmsEnable;
if (enable < 0 || enable > 1) {
enable = 0;
}
LOGD("%s enable: %d\n",__FUNCTION__, enable);
return enable;
}
int CPQControl::GetDriverValueMap(vpp_cms_type_t type, int value)
{
switch (type) {
case VPP_CMS_TYPE_SAT:
if (value < 0) {
value = (value * (0 - CMS_SAT_MIN)) / 50;
} else {
value = (value * CMS_SAT_MAX) / 50;
}
if (value < CMS_SAT_MIN) value = CMS_SAT_MIN;
if (value > CMS_SAT_MAX) value = CMS_SAT_MAX;
break;
case VPP_CMS_TYPE_HUE:
value = (((value + 50) * (CMS_HUE_MAX - CMS_HUE_MIN)) / 100) - CMS_HUE_MAX;
if (value < CMS_HUE_MIN) value = CMS_HUE_MIN;
if (value > CMS_HUE_MAX) value = CMS_HUE_MAX;
break;
case VPP_CMS_TYPE_LUMA:
value = (((value + 50) * (CMS_LUMA_MAX - CMS_LUMA_MIN)) / 100) - CMS_LUMA_MAX;
if (value < CMS_LUMA_MIN) value = CMS_LUMA_MIN;
if (value > CMS_LUMA_MAX) value = CMS_LUMA_MAX;
break;
default:
break;
}
return value;
}
int CPQControl::SetColorCustomizeBy3DLut(vpp_cms_6color_t color, vpp_cms_type_t type, int value, int isSave)
{
int ret = -1;
LOGD("%s color:%d, type:%d, value:%d, isSave:%d\n", __FUNCTION__, color, type, value, isSave);
if (type < VPP_CMS_TYPE_RED) {
LOGE("%s type is error, not 3DLUT module request\n",__FUNCTION__);
return ret;
}
ret = Cpq_SetColorCustomizeBy3DLut(color, type, value);
if ((ret == 0) && (isSave == 1)) {
ret = SaveColorCustomizeBy3DLut(color, type, value);
}
if (ret < 0) {
LOGE("%s failed\n",__FUNCTION__);
} else {
LOGD("%s success\n",__FUNCTION__);
}
return ret;
}
vpp_single_color_param_3dlut_t CPQControl::GetColorCustomizeBy3DLut(vpp_cms_6color_t color)
{
TABLE_CMS_3DLUT param;
if (GetColorCustomizeDataBy3Dlut(&param)) {
LOGE("%s GetColorCustomizeDataBy3Dlut failed!\n", __FUNCTION__);
}
for (int i = VPP_COLOR_6_RED; i < VPP_COLOR_6_MAX; i++) {
LOGD("%s param.data[%d].red/green/blue: %d %d %d\n", __FUNCTION__, i, param.CmsColor[i].red, param.CmsColor[i].green, param.CmsColor[i].blue);
}
vpp_single_color_param_3dlut_t single_param;
memset(&single_param, 0, sizeof(vpp_single_color_param_3dlut_t));
single_param.red = param.CmsColor[color].red;
single_param.green = param.CmsColor[color].green;
single_param.blue = param.CmsColor[color].blue;
return single_param;
}
int CPQControl::SaveColorCustomizeBy3DLut(vpp_cms_6color_t color, vpp_cms_type_t type, int value)
{
TABLE_CMS_3DLUT param;
if (GetColorCustomizeDataBy3Dlut(&param)) {
LOGE("%s GetColorCustomizeDataBy3Dlut failed!\n", __FUNCTION__);
return -1;
}
if (type == VPP_CMS_TYPE_RED) {
param.CmsColor[color].red = value;
} else if (type == VPP_CMS_TYPE_GREEN) {
param.CmsColor[color].green = value;
} else if (type == VPP_CMS_TYPE_BLUE) {
param.CmsColor[color].blue = value;
}
if (SetColorCustomizeDataBy3Dlut(&param)) {
LOGE("%s SetColorCustomizeDataBy3Dlut failed!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetColorCustomizeBy3DLut(vpp_cms_6color_t color, vpp_cms_type_t type, int value)
{
int gain = 0;
TABLE_CMS_3DLUT param;
if (GetColorCustomizeDataBy3Dlut(&param)) {
LOGE("%s GetColorCustomizeDataBy3Dlut failed!\n", __FUNCTION__);
return -1;
}
struct color_tune_parm_s pData;
memset(&pData, 0, sizeof(struct color_tune_parm_s));
pData.en = param.CmsEnable;
pData.rgain_r = param.CmsColor[VPP_COLOR_6_RED].red;
pData.rgain_g = param.CmsColor[VPP_COLOR_6_RED].green;
pData.rgain_b = param.CmsColor[VPP_COLOR_6_RED].blue;
pData.ggain_r = param.CmsColor[VPP_COLOR_6_GREEN].red;
pData.ggain_g = param.CmsColor[VPP_COLOR_6_GREEN].green;
pData.ggain_b = param.CmsColor[VPP_COLOR_6_GREEN].blue;
pData.bgain_r = param.CmsColor[VPP_COLOR_6_BLUE].red;
pData.bgain_g = param.CmsColor[VPP_COLOR_6_BLUE].green;
pData.bgain_b = param.CmsColor[VPP_COLOR_6_BLUE].blue;
pData.cgain_r = param.CmsColor[VPP_COLOR_6_CYAN].red;
pData.cgain_g = param.CmsColor[VPP_COLOR_6_CYAN].green;
pData.cgain_b = param.CmsColor[VPP_COLOR_6_CYAN].blue;
pData.mgain_r = param.CmsColor[VPP_COLOR_6_MAGENTA].red;
pData.mgain_g = param.CmsColor[VPP_COLOR_6_MAGENTA].green;
pData.mgain_b = param.CmsColor[VPP_COLOR_6_MAGENTA].blue;
pData.ygain_r = param.CmsColor[VPP_COLOR_6_YELLOW].red;
pData.ygain_g = param.CmsColor[VPP_COLOR_6_YELLOW].green;
pData.ygain_b = param.CmsColor[VPP_COLOR_6_YELLOW].blue;
if (value < -100 || value > 100) {
value = 0;
}
gain = value * 2048 / 200;
switch (color) {
case VPP_COLOR_6_RED:
if (type == VPP_CMS_TYPE_RED) {
pData.rgain_r = gain;
} else if (type == VPP_CMS_TYPE_GREEN) {
pData.rgain_g = gain;
} else if (type == VPP_CMS_TYPE_BLUE) {
pData.rgain_b = gain;
}
break;
case VPP_COLOR_6_GREEN:
if (type == VPP_CMS_TYPE_RED) {
pData.ggain_r = gain;
} else if (type == VPP_CMS_TYPE_GREEN) {
pData.ggain_g = gain;
} else if (type == VPP_CMS_TYPE_BLUE) {
pData.ggain_b = gain;
}
break;
case VPP_COLOR_6_BLUE:
if (type == VPP_CMS_TYPE_RED) {
pData.bgain_r = gain;
} else if (type == VPP_CMS_TYPE_GREEN) {
pData.bgain_g = gain;
} else if (type == VPP_CMS_TYPE_BLUE) {
pData.bgain_b = gain;
}
break;
case VPP_COLOR_6_CYAN:
if (type == VPP_CMS_TYPE_RED) {
pData.cgain_r = gain;
} else if (type == VPP_CMS_TYPE_GREEN) {
pData.cgain_g = gain;
} else if (type == VPP_CMS_TYPE_BLUE) {
pData.cgain_b = gain;
}
break;
case VPP_COLOR_6_MAGENTA:
if (type == VPP_CMS_TYPE_RED) {
pData.mgain_r = gain;
} else if (type == VPP_CMS_TYPE_GREEN) {
pData.mgain_g = gain;
} else if (type == VPP_CMS_TYPE_BLUE) {
pData.mgain_b = gain;
}
break;
case VPP_COLOR_6_YELLOW:
if (type == VPP_CMS_TYPE_RED) {
pData.ygain_r = gain;
} else if (type == VPP_CMS_TYPE_GREEN) {
pData.ygain_g = gain;
} else if (type == VPP_CMS_TYPE_BLUE) {
pData.ygain_b = gain;
}
break;
default:
break;
}
if (VPPDeviceIOCtl(AMVECM_IOC_S_COLOR_TUNE, &pData) < 0) {
LOGE("%s AMVECM_IOC_S_COLOR_TUNE error(%s)\n", __FUNCTION__, strerror(errno));
return -1;
}
return 0;
}
int CPQControl::Cpq_GetColorCustomizeDefValue(TABLE_CMS *pCmsCm)
{
int i = 0;
const char *buff = NULL;
//color customize(CM) default value
pCmsCm->CmsEnable = 1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_CM_READ, NULL);
pqTransformStringToInt(buff, (int *)&pCmsCm->CmsColor[VPP_COLOR_9_RED]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_CM_GREEN, NULL);
pqTransformStringToInt(buff, (int *)&pCmsCm->CmsColor[VPP_COLOR_9_GREEN]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_CM_BLUE, NULL);
pqTransformStringToInt(buff, (int *)&pCmsCm->CmsColor[VPP_COLOR_9_BLUE]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_CM_CYAN, NULL);
pqTransformStringToInt(buff, (int *)&pCmsCm->CmsColor[VPP_COLOR_9_CYAN]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_CM_PURPLE, NULL);
pqTransformStringToInt(buff, (int *)&pCmsCm->CmsColor[VPP_COLOR_9_PURPLE]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_CM_YELLOW, NULL);
pqTransformStringToInt(buff, (int *)&pCmsCm->CmsColor[VPP_COLOR_9_YELLOW]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_CM_SKIN, NULL);
pqTransformStringToInt(buff, (int *)&pCmsCm->CmsColor[VPP_COLOR_9_SKIN]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_CM_YELLOW_GREEN, NULL);
pqTransformStringToInt(buff, (int *)&pCmsCm->CmsColor[VPP_COLOR_9_YELLOW_GREEN]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_CM_BLUE_GREEN, NULL);
pqTransformStringToInt(buff, (int *)&pCmsCm->CmsColor[VPP_COLOR_9_BLUE_GREEN]);
if (!buff) return -1;
for (i = VPP_COLOR_9_PURPLE; i < VPP_COLOR_9_MAX; i++) {
LOGD("%s pCmsCm color:%d, %d %d %d\n", __FUNCTION__,
i, pCmsCm->CmsColor[i].sat, pCmsCm->CmsColor[i].hue, pCmsCm->CmsColor[i].luma);
}
return 0;
}
int CPQControl::Cpq_GetColorCustomize3DlutDefValue(TABLE_CMS_3DLUT *pCms3DLut)
{
int i = 0;
const char *buff = NULL;
//color customize(3DLUT) default value
pCms3DLut->CmsEnable = 1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_3DLUT_RED, NULL);
pqTransformStringToInt(buff, (int *)&pCms3DLut->CmsColor[VPP_COLOR_6_RED]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_3DLUT_GREEN, NULL);
pqTransformStringToInt(buff, (int *)&pCms3DLut->CmsColor[VPP_COLOR_6_GREEN]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_3DLUT_BLUE, NULL);
pqTransformStringToInt(buff, (int *)&pCms3DLut->CmsColor[VPP_COLOR_6_BLUE]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_3DLUT_CYAN, NULL);
pqTransformStringToInt(buff, (int *)&pCms3DLut->CmsColor[VPP_COLOR_6_CYAN]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_3DLUT_MAGENTA, NULL);
pqTransformStringToInt(buff, (int *)&pCms3DLut->CmsColor[VPP_COLOR_6_MAGENTA]);
if (!buff) return -1;
buff = mPQConfigFile->GetString(CFG_SECTION_CMS, CFG_CMS_3DLUT_YELLOW, NULL);
pqTransformStringToInt(buff, (int *)&pCms3DLut->CmsColor[VPP_COLOR_6_YELLOW]);
if (!buff) return -1;
for (i = VPP_COLOR_6_RED; i < VPP_COLOR_6_MAX; i++) {
LOGD("%s pCms3DLut color:%d, %d %d %d\n", __FUNCTION__,
i, pCms3DLut->CmsColor[i].red, pCms3DLut->CmsColor[i].green, pCms3DLut->CmsColor[i].blue);
}
return 0;
}
int CPQControl::ResetColorCustomize(vpp_cms_method_t mode)
{
if (mode == VPP_CMS_METHOD_CM) {
ResetColorCustomizeDataAll();
} else if (mode == VPP_CMS_METHOD_3DLUT) {
ResetColorCustomizeDataBy3DlutAll();
} else {
LOGE("%s mode is out of range\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::SetColorGamutMode(int value, int is_save)
{
SYS_LOGD("%s value:%d, is_save:%d\n", __FUNCTION__, value, is_save);
int ret = Cpq_SetColorGamutMode((vpp_colorgamut_mode_t)value);
if ((ret == 0) && (is_save == 1)) {
ret = SaveColorGamutMode(value);
}
if (ret < 0) {
LOGE("%s fail\n", __FUNCTION__);
return ret;
}
return ret;
}
int CPQControl::GetColorGamutMode(void)
{
int data = VPP_COLORGAMUT_MODE_AUTO;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s GetPictureModeData source: %d, timming: %d fail\n", __FUNCTION__, CurSource, CurTimming);
return -1;
}
data = para.ColorGamut;
if (data < 0 || data >= VPP_COLORGAMUT_MODE_MAX) {
data = VPP_COLORGAMUT_MODE_AUTO;
}
SYS_LOGI("%s source: %d, timming :%d, value: %d\n", __FUNCTION__, CurSource, CurTimming, data);
return data;
}
int CPQControl::SaveColorGamutMode(int value)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s GetPictureModeData source: %d, timming: %d fail\n", __FUNCTION__, CurSource, CurTimming);
return -1;
}
para.ColorGamut = value;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s SetPictureModeData source: %d, timming: %d value: %d fail\n", __FUNCTION__, CurSource, CurTimming, value);
return -1;
}
SYS_LOGD("%s success\n", __FUNCTION__);
return 0;
}
unsigned int color_SRGB[8] = {32000, 16500, 15000, 30000, 7500, 3000, 15635, 16450};
unsigned int color_ADOBE[8] = {32000, 16500, 10500, 35500, 7500, 3000, 15635, 16450};
unsigned int color_BT2020[8] = {35400, 14600, 8500, 39850, 6550, 2300, 15635, 16450};
unsigned int color_DCIP3[8] = {34000, 16000, 13250, 34500, 7500, 3000, 15635, 16450};
int CPQControl::Cpq_SetColorGamutMode(vpp_colorgamut_mode_t value)
{
if (!mbCpqCfg_color_space_enable) {
LOGD("%s ColorGamut disable\n", __FUNCTION__);
return 0;
}
if (Cpq_SetColorGamutModeNew(value) == 0) {
LOGD("%s Gamut new mode\n", __FUNCTION__);
} else if (Cpq_SetColorGamutModeSrcDest(value) == 0) {
LOGD("%s Gamut src dest mode\n", __FUNCTION__);
} else {
LOGE("%s %d fail\n", __FUNCTION__, value);
return -1;
}
LOGD("%s %d success\n", __FUNCTION__, value);
return 0;
}
int CPQControl::Cpq_SetColorGamutModeNew(vpp_colorgamut_mode_t value)
{
int ret = Cpq_SetColorGamutWrapper(value);
int ret0 = Cpq_SetColorGamut(value);
if (ret < 0 && ret0 < 0) {
LOGE("%s %d fail!\n", __FUNCTION__, value);
return -1;
} else {
LOGD("%s %d success!\n", __FUNCTION__, value);
return 0;
}
}
int CPQControl::Cpq_SetColorGamutWrapper(vpp_colorgamut_mode_t value)
{
int isSupportGamutWrapper = 0;
if (VPPDeviceIOCtl(AMVECM_IOC_G_SUPPORT_GMT_WRAPPER, &isSupportGamutWrapper) < 0) {
LOGE("%s AMVECM_IOC_G_SUPPORT_GMT_WRAPPER fail\n", __FUNCTION__);
}
if (isSupportGamutWrapper != 1) {
LOGD("%s not support Gamut Wrapper\n", __FUNCTION__);
return -1;
}
int Enable = 1;
if (VPPDeviceIOCtl(AMVECM_IOC_S_GMT_WRAPPER_EN, &Enable) < 0) {
LOGE("%s AMVECM_IOC_S_GMT_WRAPPER_EN %d fail\n", __FUNCTION__, Enable);
return -1;
}
int ctrl_mode = gamut_mtrx_only;
if (value == VPP_COLORGAMUT_MODE_AUTO) {
ctrl_mode = drv_ctrl;
return VPPDeviceIOCtl(AMVECM_IOC_S_GMT_WRAPPER_MODE, &ctrl_mode);
}
if (VPPDeviceIOCtl(AMVECM_IOC_S_GMT_WRAPPER_MODE, &ctrl_mode) < 0) {
LOGE("%s AMVECM_IOC_S_GMT_WRAPPER_MODE %d fail\n", __FUNCTION__, ctrl_mode);
return -1;
}
//channel GamutWrapper0
struct hdr_gamut_data_s GamutWrapper0 = {0};
if (mPQdb->PQ_GetColorGamutMode((int)value, 2, mCurrentSourceInputInfo, &GamutWrapper0) < 0) {
LOGE("%s GamutWrapper0 mPQdb->PQ_GetColorGamutMode %d fail\n", __FUNCTION__, value);
return -1;
}
if (VPPDeviceIOCtl(AMVECM_IOC_S_GMT_WRAPPER0_COEF, &GamutWrapper0) < 0) {
LOGE("%s AMVECM_IOC_S_GMT_WRAPPER0_COEF fail\n", __FUNCTION__);
return -1;
}
//channel GamutWrapper1
struct hdr_gamut_data_s GamutWrapper1 = {0};
if (mPQdb->PQ_GetColorGamutMode((int)value, 3, mCurrentSourceInputInfo, &GamutWrapper1) < 0) {
LOGE("%s GamutWrapper1 mPQdb->PQ_GetColorGamutMode %d fail\n", __FUNCTION__, value);
return -1;
}
if (VPPDeviceIOCtl(AMVECM_IOC_S_GMT_WRAPPER_COEF, &GamutWrapper1) < 0) {
LOGE("%s AMVECM_IOC_S_GMT_WRAPPER_COEF fail\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetColorGamut(vpp_colorgamut_mode_t value)
{
if (!mbCpqCfg_gamut_enable) {
LOGE("%s Gamut disable!\n", __FUNCTION__);
return -1;
}
int Enable = 1;
if (VPPDeviceIOCtl(AMVECM_IOC_S_GAMUT_CONV_EN, &Enable) < 0) {
LOGE("%s AMVECM_IOC_S_GAMUT_CONV_EN %d fail\n", __FUNCTION__, Enable);
return -1;
}
int ctrl_mode = gamut_mtrx_only;
if (value == VPP_COLORGAMUT_MODE_AUTO) {
ctrl_mode = drv_ctrl;
return VPPDeviceIOCtl(AMVECM_IOC_S_HDR_TOP_CTRL_MODE, &ctrl_mode);
}
if (VPPDeviceIOCtl(AMVECM_IOC_S_HDR_TOP_CTRL_MODE, &ctrl_mode) < 0) {
LOGE("%s AMVECM_IOC_S_HDR_TOP_CTRL_MODE %d fail\n", __FUNCTION__, ctrl_mode);
return -1;
}
//channel Gamut(hdr core)
struct hdr_gamut_data_s GamutData = {0};
if (mPQdb->PQ_GetColorGamutMode((int)value, 1, mCurrentSourceInputInfo, &GamutData) < 0) {
LOGE("%s mPQdb->PQ_GetColorGamutMode %d fail\n", __FUNCTION__, value);
return -1;
}
if (VPPDeviceIOCtl(AMVECM_IOC_S_HDR_GAMUT_COEF, &GamutData) < 0) {
LOGE("%s AMVECM_IOC_S_HDR_GAMUT_COEF fail\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_SetColorGamutModeSrcDest(vpp_colorgamut_mode_t value)
{
int pri_en = 1;
enum gamut_conv_enable_e conv_en = gamut_conv_on;
struct primary_s color_pri{};
switch (value) {
case VPP_COLORGAMUT_MODE_AUTO:
pri_en = 0;
break;
case VPP_COLORGAMUT_MODE_NATIVE:
conv_en = gamut_conv_off;
pri_en = 0;
break;
case VPP_COLORGAMUT_MODE_SRGB:
memcpy(color_pri.src, color_SRGB, sizeof(unsigned int) * 8);
break;
case VPP_COLORGAMUT_MODE_DCI_P3:
memcpy(color_pri.src, color_DCIP3, sizeof(unsigned int) * 8);
break;
case VPP_COLORGAMUT_MODE_ADOBE_RGB:
memcpy(color_pri.src, color_ADOBE, sizeof(unsigned int) * 8);
break;
case VPP_COLORGAMUT_MODE_BT2020:
memcpy(color_pri.src, color_BT2020, sizeof(unsigned int) * 8);
break;
default:
LOGD("%s input value output range\n", __FUNCTION__);
return 0;
}
PANLE_INFO panel_intfo;
memset(&panel_intfo, 0, sizeof(PANLE_INFO));
if (mPQdb->PQ_GetColorGamutDestParams(0, &panel_intfo) != 0) {
LOGE("%s can not get dest pri, use default srgb!\n", __FUNCTION__);
// default setting
panel_intfo.primaries_r_x = color_SRGB[0];
panel_intfo.primaries_r_y = color_SRGB[1];
panel_intfo.primaries_g_x = color_SRGB[2];
panel_intfo.primaries_g_y = color_SRGB[3];
panel_intfo.primaries_b_x = color_SRGB[4];
panel_intfo.primaries_b_y = color_SRGB[5];
panel_intfo.white_point_x = color_SRGB[6];
panel_intfo.white_point_y = color_SRGB[7];
}
color_pri.dest[0] = panel_intfo.primaries_r_x;
color_pri.dest[1] = panel_intfo.primaries_r_y;
color_pri.dest[2] = panel_intfo.primaries_g_x;
color_pri.dest[3] = panel_intfo.primaries_g_y;
color_pri.dest[4] = panel_intfo.primaries_b_x;
color_pri.dest[5] = panel_intfo.primaries_b_y;
color_pri.dest[6] = panel_intfo.white_point_x;
color_pri.dest[7] = panel_intfo.white_point_y;
LOGD("%s conv_en: %d, pri_en: %d\n", __FUNCTION__, conv_en, pri_en);
if (VPPDeviceIOCtl(AMVECM_IOC_S_GAMUT_CONV_EN, &conv_en) < 0) {
LOGE("%s AMVECM_IOC_S_GAMUT_CONV_EN fail\n", __FUNCTION__);
return -1;
}
if (VPPDeviceIOCtl(AMVECM_IOC_COLOR_PRI_EN, &pri_en) < 0) {
LOGE("%s AMVECM_IOC_COLOR_PRI_EN fail\n", __FUNCTION__);
return -1;
}
if ((pri_en == 1) && (VPPDeviceIOCtl(AMVECM_IOC_COLOR_PRIMARY, &color_pri)) < 0) {
LOGE("%s AMVECM_IOC_COLOR_PRIMARY fail\n", __FUNCTION__);
return -1;
}
if (pri_en == 1) {
LOGD("%s mode: %d, src[%u, %u, %u, %u, %u, %u, %u, %u]!\n", __FUNCTION__, value,
color_pri.src[0], color_pri.src[1], color_pri.src[2], color_pri.src[3],
color_pri.src[4], color_pri.src[5], color_pri.src[6], color_pri.src[7]);
LOGD("%s mode: %d, dest[%u, %u, %u, %u, %u, %u, %u, %u]!\n", __FUNCTION__, value,
color_pri.dest[0], color_pri.dest[1], color_pri.dest[2], color_pri.dest[3],
color_pri.dest[4], color_pri.dest[5], color_pri.dest[6], color_pri.dest[7]);
}
return 0;
}
//SmoothPlus mode
int CPQControl::SetSmoothPlusMode(int smoothplus_mode, int is_save)
{
LOGD("%s, source: %d, value = %d\n", __FUNCTION__, mSourceInputForSaveParam, smoothplus_mode);
int ret = Cpq_SetSmoothPlusMode((vpp_smooth_plus_mode_t)smoothplus_mode, mCurrentSourceInputInfo);
if ((ret ==0) && (is_save == 1)) {
ret = SaveSmoothPlusMode((vpp_smooth_plus_mode_t)smoothplus_mode);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetSmoothPlusMode(void)
{
int mode = VPP_SMOOTH_PLUS_MODE_MID;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d mode: %d fail\n",__FUNCTION__,
CurSource, CurTimming, mode);
return mode;
}
mode = para.SmoothPlus;
if (mode < VPP_SMOOTH_PLUS_MODE_OFF || mode > VPP_SMOOTH_PLUS_MODE_AUTO) {
mode = VPP_SMOOTH_PLUS_MODE_MID;
}
SYS_LOGI("%s, source: %d, timming: %d, value = %d\n", __FUNCTION__, CurSource, CurTimming, mode);
return mode;
}
int CPQControl::SaveSmoothPlusMode(int smoothplus_mode)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.SmoothPlus = smoothplus_mode;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d smoothplus_mode: %d fail\n",__FUNCTION__,
CurSource, CurTimming, smoothplus_mode);
return -1;
}
SYS_LOGI("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetSmoothPlusMode(vpp_smooth_plus_mode_t smoothplus_mode, source_input_param_t source_input_param)
{
if (!mbCpqCfg_smoothplus_enable) {
LOGD("Smooth Plus disabled\n");
return 0;
}
if (mbCpqCfg_dpss_enable) {
struct vpq_dct_param_s param;
memset(&param, 0, sizeof(struct vpq_dct_param_s));
if (mPQdb->PQ_GetDpssSmoothPlusParams(smoothplus_mode, source_input_param, &param) < 0) {
SYS_LOGE("%s: PQ_GetDpssSmoothPlusParams failed!\n", __FUNCTION__);
return -1;
}
if (VpqDeviceIOCtl(VPQ_IOC_SET_SMOOTHPLUS_DPSS, &param) < 0) {
SYS_LOGE("%s: VPQ_IOC_SET_SMOOTHPLUS_DPSS failed!\n", __FUNCTION__);
return -1;
}
} else {
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetSmoothPlusParams(smoothplus_mode, source_input_param, regs) < 0) {
LOGE("PQ_GetSmoothPlusParams failed!\n");
return -1;
}
struct am_pq_parm_s di_regs;
memset(&di_regs, 0x0,sizeof(struct am_pq_parm_s));
di_regs.table_name = TABLE_NAME_SMOOTHPLUS;
di_regs.table_len = regs->length;
struct am_reg_s tmp_buf[regs->length];
for (unsigned int i=0;i<regs->length;i++) {
tmp_buf[i].addr = regs->am_reg[i].addr;
tmp_buf[i].mask = regs->am_reg[i].mask;
tmp_buf[i].type = regs->am_reg[i].type;
tmp_buf[i].val = regs->am_reg[i].val;
}
di_regs.table_ptr = tmp_buf;
if (DI_LoadRegs(di_regs) < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
}
LOGD("%s success! smoothplus_mode: %d\n",__FUNCTION__, smoothplus_mode);
return 0;
}
int CPQControl::HlgToneMappingInit(void)
{
int ret = 0;
mHlgToneMapping = new CHlgToneMapping();
int gainValue[149] = {0};
PANLE_INFO panel_intfo;
memset(&panel_intfo, 0, sizeof(PANLE_INFO));
if (mPQdb->PQ_GetColorGamutDestParams(0, &panel_intfo) != 0) {
LOGD("%s can not get dest luma, use default luma!\n", __FUNCTION__);
// default setting
panel_intfo.luma_max = 350;
}
LOGD("%s luma_max = %d!\n", __FUNCTION__, panel_intfo.luma_max);
mHlgToneMapping->hlg_sdr_process(panel_intfo.luma_max, gainValue);
ret = SetHDRTMData(gainValue);
if (ret != 0) {
LOGE("%s failed!\n", __FUNCTION__);
}
return ret;
}
int CPQControl::SetHDRTMData(int *reGain)
{
int ret = -1;
if (reGain == NULL) {
LOGD("%s: reGain is NULL.\n", __FUNCTION__);
} else {
struct hdr_tone_mapping_s hdrToneMapping;
memset(&hdrToneMapping, 0, sizeof(struct hdr_tone_mapping_s));
hdrToneMapping.lut_type = HLG_LUT;
hdrToneMapping.lutlength = 149;
hdrToneMapping.tm_lut = reGain;
LOGD("hdrToneMapping.lut_type = %d\n", hdrToneMapping.lut_type);
LOGD("hdrToneMapping.lutlength = %d\n", hdrToneMapping.lutlength);
//LOGD("hdrToneMapping.tm_lut = %s\n", hdrToneMapping.tm_lut);
ret = VPPDeviceIOCtl(AMVECM_IOC_S_HDR_TM, &hdrToneMapping);
}
if (ret < 0) {
LOGE("%s error(%s)!\n", __FUNCTION__, strerror(errno));
return -1;
} else {
LOGD("%s success!\n", __FUNCTION__);
}
return 0;
}
//HDR TMO
int CPQControl::SetHdrToneMappingMode(hdr_tmo_t mode, int is_save)
{
LOGD("%s, source: %d, timming: %d, mode = %d\n", __FUNCTION__, CurSource, CurTimming, mode);
int ret = Cpq_SetHDRTMOMode((int)mode);
if ((ret == 0) && (is_save == 1)) {
ret = SaveHDRTMOMode(mode);
}
if (ret < 0) {
LOGE("%s failed\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetHdrToneMappingMode()
{
int mode = HDR_TMO_DYNAMIC;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s failed!\n",__FUNCTION__);
return mode;
}
mode = para.HdrTmo;
if (mode < HDR_TMO_OFF || mode > HDR_TMO_STATIC) {
mode = HDR_TMO_DYNAMIC;
}
return mode;
}
int CPQControl::SaveHDRTMOMode(hdr_tmo_t mode)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.HdrTmo = mode;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d mode: %d fail\n",__FUNCTION__, CurSource, CurTimming, mode);
return -1;
}
SYS_LOGI("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetHDRTMOMode(int mode)
{
if (!mbCpqCfg_hdrtmo_enable) {
LOGD("hdr tmo disabled\n");
return 0;
}
if (mode < 0) {
LOGD("Skip hdr tmo\n");
return 0;
}
struct hdr_tmo_sw hdrtmo_param;
if (mPQdb->PQ_GetHDRTMOParams(mCurrentSourceInputInfo, (hdr_tmo_t)mode, &hdrtmo_param) < 0) {
LOGE("mPQdb->PQ_GetHDRTMOParams failed!\n");
return -1;
}
if (VPPDeviceIOCtl(AMVECM_IOC_S_HDR_TMO, &hdrtmo_param) < 0) {
LOGE("VPPDeviceIOCtl AMVECM_IOC_S_HDR_TMO failed!\n");
return -1;
}
LOGD("%s success! mode: %d\n",__FUNCTION__, mode);
return 0;
}
int CPQControl::SetBlackExtensionParam(source_input_param_t source_input_param)
{
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
int ret = -1;
ret = mPQdb->PQ_GetBlackExtensionParams(source_input_param, regs);
if (ret < 0) {
LOGE("%s: PQ_GetBlackExtensionParams failed!\n", __FUNCTION__);
} else {
ret = Cpq_LoadRegs(regs);
}
if (ret < 0) {
LOGE("%s failed!\n", __FUNCTION__);
} else {
LOGD("%s success!\n", __FUNCTION__);
}
return ret;
}
int CPQControl::SetMpegNr(vpp_pq_level_t mode, int is_save)
{
LOGD("%s: src: %d, timming: %d, mode is %d\n", __FUNCTION__, CurSource, CurTimming, mode);
int ret = -1;
ret = Cpq_SetMpegNr(mode, mCurrentSourceInputInfo);
if ((ret == 0) && (is_save == 1)) {
ret = SaveMpegNr(mode);
}
if (ret < 0) {
LOGE("%s failed\n", __FUNCTION__);
} else {
LOGD("%s success\n", __FUNCTION__);
}
return ret;
}
int CPQControl::GetMpegNr(void)
{
int mode = VPP_PQ_LV_OFF;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return mode;
}
mode = para.MpegNr;
SYS_LOGD("%s: MpegNr = %d \n", __FUNCTION__, mode);
return mode;
}
int CPQControl::SaveMpegNr(vpp_pq_level_t mode)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.MpegNr = mode;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d mode: %d fail\n",__FUNCTION__, CurSource, CurTimming, mode);
return -1;
}
SYS_LOGD("%s success!\n", __FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetMpegNr(vpp_pq_level_t mode, source_input_param_t source_input_param)
{
int ret = 0;
ret |= Cpq_SetDeblockMode((vpp_deblock_mode_t) mode, source_input_param);
ret |= Cpq_SetDemoSquitoMode((vpp_demosquito_mode_t) mode, source_input_param);
if (ret < 0)
LOGE("%s failed!\n",__FUNCTION__);
else
LOGD("%s success! mode: %d\n",__FUNCTION__, mode);
return ret;
}
int CPQControl::SetDeblockMode(vpp_deblock_mode_t mode, int is_save)
{
LOGD("%s: src = %d, timming = %d, mode is %d\n", __FUNCTION__, CurSource, CurTimming, mode);
int ret = -1;
ret = Cpq_SetDeblockMode(mode, mCurrentSourceInputInfo);
if ((ret == 0) && (is_save == 1)) {
ret = SaveDeblockMode(mode);
}
if (ret < 0) {
LOGE("%s failed!\n", __FUNCTION__);
} else {
LOGD("%s success!\n", __FUNCTION__);
}
return ret;
}
int CPQControl::GetDeblockMode(void)
{
int mode = VPP_DEBLOCK_MODE_OFF;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return mode;
}
mode = para.Deblock;
if (mode < VPP_DEBLOCK_MODE_OFF || mode > VPP_DEBLOCK_MODE_AUTO)
mode = VPP_DEBLOCK_MODE_OFF;
return mode;
}
int CPQControl::SaveDeblockMode(vpp_deblock_mode_t mode)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.Deblock = mode;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d mode: %d fail\n",__FUNCTION__, CurSource, CurTimming, mode);
return -1;
}
SYS_LOGD("%s success\n", __FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetDeblockMode(vpp_deblock_mode_t deblock_mode, source_input_param_t source_input_param)
{
if (!mbCpqCfg_deblock_enable) {
LOGD("PQ_GetDeblockParams Disabled!\n");
return 0;
}
if (mbCpqCfg_dpss_enable) {
struct vpq_dblk_param_s param;
memset(&param, 0, sizeof(struct vpq_dblk_param_s));
if (mPQdb->PQ_GetDpssDeblockParams(deblock_mode, source_input_param, &param) < 0) {
LOGE("%s: PQ_GetDpssDeblockParams failed!\n", __FUNCTION__);
return -1;
}
if (VpqDeviceIOCtl(VPQ_IOC_SET_DEBLOCK_DPSS, &param) < 0) {
LOGE("%s: VPQ_IOC_SET_DEBLOCK_DPSS failed!\n", __FUNCTION__);
return -1;
}
} else {
am_regs_t *regs = &mRegsData;
struct am_pq_parm_s di_regs;
memset(regs, 0x0, sizeof(am_regs_t));
memset(&di_regs, 0x0,sizeof(struct am_pq_parm_s));
if (mPQdb->PQ_GetDeblockParams(deblock_mode, source_input_param, regs) < 0) {
LOGE("PQ_GetDeblockParams failed!\n");
return -1;
}
di_regs.table_name = TABLE_NAME_DEBLOCK;
di_regs.table_len = regs->length;
struct am_reg_s tmp_buf[regs->length];
for (unsigned int i=0;i<regs->length;i++) {
tmp_buf[i].addr = regs->am_reg[i].addr;
tmp_buf[i].mask = regs->am_reg[i].mask;
tmp_buf[i].type = regs->am_reg[i].type;
tmp_buf[i].val = regs->am_reg[i].val;
}
di_regs.table_ptr = tmp_buf;
if (DI_LoadRegs(di_regs) < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
}
LOGD("%s success! deblock_mode: %d\n",__FUNCTION__, deblock_mode);
return 0;
}
int CPQControl::SetDemoSquitoMode(vpp_demosquito_mode_t mode, int is_save)
{
LOGD("%s: src = %d, timming = %d, mode is %d\n", __FUNCTION__, CurSource, CurTimming, mode);
int ret = -1;
ret = Cpq_SetDemoSquitoMode(mode, mCurrentSourceInputInfo);
if ((ret == 0) && (is_save == 1)) {
ret = SaveDemoSquitoMode(mode);
}
if (ret < 0) {
LOGE("%s failed\n", __FUNCTION__);
} else {
LOGD("%s success\n", __FUNCTION__);
}
return ret;
}
int CPQControl::GetDemoSquitoMode(void)
{
int mode = VPP_DEMOSQUITO_MODE_OFF;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return mode;
}
mode = para.Demosquito;
if (mode < VPP_DEMOSQUITO_MODE_OFF || mode > VPP_DEMOSQUITO_MODE_AUTO)
mode = VPP_DEMOSQUITO_MODE_OFF;
return mode;
}
int CPQControl::SaveDemoSquitoMode(vpp_demosquito_mode_t mode)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.Demosquito = mode;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d mode: %d fail\n",__FUNCTION__, CurSource, CurTimming, mode);
return -1;
}
SYS_LOGD("%s success\n", __FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetDemoSquitoMode(vpp_demosquito_mode_t DeMosquito_mode, source_input_param_t source_input_param)
{
if (!mbCpqCfg_demoSquito_enable) {
LOGD("DemoSquitoMode Disabled!\n");
return 0;
}
if (mbCpqCfg_dpss_enable) {
struct vpq_demosquito_param_s param;
memset(&param, 0, sizeof(struct vpq_demosquito_param_s));
if (mPQdb->PQ_GetDpssDemoSquitoParams(DeMosquito_mode, source_input_param, &param) < 0) {
SYS_LOGE("%s: PQ_GetDpssDemoSquitoParams failed!\n", __FUNCTION__);
return -1;
}
if (VpqDeviceIOCtl(VPQ_IOC_SET_DEMOSQUITO_DPSS, &param) < 0) {
SYS_LOGE("%s: VPQ_IOC_SET_DEMOSQUITO_DPSS failed!\n", __FUNCTION__);
return -1;
}
} else {
int ret = 0;
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
ret = mPQdb->PQ_GetDemoSquitoParams(DeMosquito_mode, source_input_param, regs);
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
} else if (ret == 1) {
LOGI("%s As DemoSquito disable !\n",__FUNCTION__);
return 0;
} else {
LOGI("%s Get DemoSquito Table success !\n",__FUNCTION__);
}
struct am_pq_parm_s di_regs;
memset(&di_regs, 0x0,sizeof(struct am_pq_parm_s));
di_regs.table_name = TABLE_NAME_DEMOSQUITO;
di_regs.table_len = regs->length;
struct am_reg_s tmp_buf[regs->length];
for (unsigned int i = 0; i < regs->length; i++) {
tmp_buf[i].addr = regs->am_reg[i].addr;
tmp_buf[i].mask = regs->am_reg[i].mask;
tmp_buf[i].type = regs->am_reg[i].type;
tmp_buf[i].val = regs->am_reg[i].val;
}
di_regs.table_ptr = tmp_buf;
if (DI_LoadRegs(di_regs) < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
}
LOGD("%s success! DeMosquito_mode: %d\n",__FUNCTION__, DeMosquito_mode);
return 0;
}
int CPQControl::SetMcDiMode(vpp_mcdi_mode_e mode, int is_save)
{
LOGD("%s: mode is %d\n", __FUNCTION__, mode);
int ret = -1;
ret = Cpq_SetMcDiMode(mode , mCurrentSourceInputInfo);
if ((ret == 0) && (is_save == 1)) {
ret = SaveMcDiMode(mode);
}
if (ret < 0) {
LOGE("%s failed\n", __FUNCTION__);
} else {
LOGD("%s success\n", __FUNCTION__);
}
return ret;
}
int CPQControl::GetMcDiMode(void)
{
int mode = VPP_MCDI_MODE_OFF;
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData)) {
LOGE("%s GetPictureStructDataBySrc failed\n", __FUNCTION__);
return mode;
}
mode = pData.McDiMode;
if (mode < VPP_MCDI_MODE_OFF || mode >= VPP_MCDI_MODE_MAX)
mode = VPP_MCDI_MODE_OFF;
LOGD("%s: mode is %d\n", __FUNCTION__, mode);
return mode;
}
int CPQControl::SaveMcDiMode(vpp_mcdi_mode_e mode)
{
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData)) {
LOGE("%s GetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
pData.McDiMode = mode;
if (!SetPictureStructDataBySrc(&pData)) {
LOGE("%s SetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
LOGD("%s success\n", __FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetMcDiMode(vpp_mcdi_mode_e McDi_mode, source_input_param_t source_input_param)
{
if (!mbCpqCfg_mcdi_enable) {
LOGD("MCDI Disabled!\n");
return 0;
}
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetMCDIParams(McDi_mode, source_input_param, regs) < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
struct am_pq_parm_s di_regs;
memset(&di_regs, 0x0,sizeof(struct am_pq_parm_s));
di_regs.table_name = TABLE_NAME_MCDI;
di_regs.table_len = regs->length;
struct am_reg_s tmp_buf[regs->length];
for (unsigned int i=0;i<regs->length;i++) {
tmp_buf[i].addr = regs->am_reg[i].addr;
tmp_buf[i].mask = regs->am_reg[i].mask;
tmp_buf[i].type = regs->am_reg[i].type;
tmp_buf[i].val = regs->am_reg[i].val;
}
di_regs.table_ptr = tmp_buf;
if (DI_LoadRegs(di_regs) < 0) {
LOGE("%s failed!\n",__FUNCTION__);
return -1;
}
LOGD("%s success! McDi_mode: %d\n",__FUNCTION__, McDi_mode);
return 0;
}
int CPQControl::SetBlackStretch(int level, int is_save)
{
LOGD("%s, level = %d\n", __FUNCTION__, level);
int ret = -1;
ret = Cpq_BlackStretch(level, mCurrentSourceInputInfo);
if (ret == 0 && is_save == 1) {
SaveBlackStretch(level);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetBlackStretch(void)
{
int level = VPP_PQ_LV_OFF;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return level;
}
level = para.BlackStretch;
if (level < VPP_PQ_LV_OFF || level >= VPP_PQ_LV_MAX) {
level = VPP_PQ_LV_OFF;
}
SYS_LOGI("%s:source: %d, timming: %d, value: %d\n", __FUNCTION__, CurSource, CurTimming, level);
return level;
}
int CPQControl::SaveBlackStretch(int level)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.BlackStretch = level;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d level: %d fail\n",__FUNCTION__, CurSource, CurTimming, level);
return -1;
}
SYS_LOGI("%s %d success!\n",__FUNCTION__, level);
return 0;
}
int CPQControl::Cpq_BlackStretch(int level, source_input_param_t source_input_param)
{
if (!mbCpqCfg_blackextension_enable) {
LOGD("%s: BlackStretch disabled!\n", __FUNCTION__);
return 0;
}
int ret = -1;
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
ret = mPQdb->PQ_GetBlackStretchParams(level,source_input_param, regs);
if (ret < 0) {
LOGE("%s: PQ_GetBlackStretchParams failed!\n", __FUNCTION__);
} else {
ret = Cpq_LoadRegs(regs);
}
if (ret < 0)
LOGE("%s failed!\n",__FUNCTION__);
else
LOGD("%s success! level: %d\n",__FUNCTION__, level);
return ret;
}
int CPQControl::SetWhiteStretch(int level, int is_save)
{
LOGD("%s level:%d, is_save:%d\n", __FUNCTION__, level, is_save);
if (Cpq_SetWhiteStretch(level, mCurrentSourceInputInfo) < 0) {
LOGE("%s failed!\n", __FUNCTION__);
return -1;
}
if (is_save == 1) {
SaveWhiteStretch(level);
}
LOGD("%s success!\n", __FUNCTION__);
return 0;
}
int CPQControl::GetWhiteStretch(void)
{
int level = VPP_PQ_LV_OFF;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return level;
}
level = para.WhiteStretch;
if (level < VPP_PQ_LV_OFF || level >= VPP_PQ_LV_MAX) {
level = VPP_PQ_LV_OFF;
}
SYS_LOGI("%s:source: %d, timming: %d, value: %d\n", __FUNCTION__, CurSource, CurTimming, level);
return level;
}
int CPQControl::SaveWhiteStretch(int level)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.WhiteStretch = level;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d level: %d fail\n",__FUNCTION__, CurSource, CurTimming, level);
return -1;
}
SYS_LOGI("%s %d success!\n",__FUNCTION__, level);
return 0;
}
int CPQControl::Cpq_SetWhiteStretch(int level, source_input_param_t source_input_param)
{
if (!mbCpqCfg_whiteextension_enable) {
LOGD("%s WhiteStretch disabled!\n", __FUNCTION__);
return 0;
}
LOGD("%s level:%d\n", __FUNCTION__, level);
struct ve_ble_whe_param_s params;
memset(&params, 0x0, sizeof(struct ve_ble_whe_param_s));
if (mPQdb->PQ_GetWhiteStretchParams(level, source_input_param, &params) < 0) {
LOGE("%s PQ_GetWhiteStretchParams failed!\n", __FUNCTION__);
return -1;
}
if (VPPDeviceIOCtl(AMVECM_IOC_S_BLE_WHE, &params) < 0) {
LOGE("%s failed!\n", __FUNCTION__);
return -1;
}
LOGD("%s success!\n", __FUNCTION__);
return 0;
}
int CPQControl::SetBlueStretch(int level, int is_save)
{
LOGD("%s, level = %d\n", __FUNCTION__, level);
int ret = -1;
ret = Cpq_BlueStretch(level, mCurrentSourceInputInfo);
if (ret == 0 && is_save == 1) {
SaveBlueStretch(level);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetBlueStretch(void)
{
int level = VPP_PQ_LV_OFF;
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return level;
}
level = para.BlueStretch;
if (level < VPP_PQ_LV_OFF || level >= VPP_PQ_LV_MAX) {
level = VPP_PQ_LV_OFF;
}
SYS_LOGD("%s: source: %d, timming: %d level: %d\n",__FUNCTION__, CurSource, CurTimming, level);
return level;
}
int CPQControl::SaveBlueStretch(int level)
{
PICTURE_MODE_PARAM para;
if (!GetPictureModeData(&para)) {
SYS_LOGE("%s: GetPictureModeData source: %d, timming: %d fail\n",__FUNCTION__, CurSource, CurTimming);
return -1;
}
para.BlueStretch = level;
if (!SetPictureModeData(&para)) {
SYS_LOGE("%s: SetPictureModeData source: %d, timming: %d level: %d fail\n",__FUNCTION__, CurSource, CurTimming, level);
return -1;
}
SYS_LOGI("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_BlueStretch(int level,source_input_param_t source_input_param)
{
if (!mbCpqCfg_bluestretch_enable) {
LOGD("%s: BlueStretch disabled!\n", __FUNCTION__);
return 0;
}
int ret = -1;
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
ret = mPQdb->PQ_GetBlueStretchParams(level,source_input_param, regs);
if (ret < 0) {
LOGE("%s: PQ_GetBlueStretchParams failed!\n", __FUNCTION__);
} else {
ret = Cpq_LoadRegs(regs);
}
if (ret < 0)
LOGE("%s failed!\n",__FUNCTION__);
else
LOGE("%s success! level: %d\n",__FUNCTION__, level);
return ret;
}
int CPQControl::SetChromaCoring(int level, int is_save)
{
LOGD("%s, level = %d\n", __FUNCTION__, level);
int ret = -1;
ret = Cpq_ChromaCoring(level, mCurrentSourceInputInfo);
if (ret == 0 && is_save == 1) {
SaveChromaCoring(level);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetChromaCoring(void)
{
int level = VPP_PQ_LV_OFF;
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData)) {
SYS_LOGE("%s GetPictureModeData failed\n", __FUNCTION__);
return -1;
}
level = pData.ChromaCoring;
if (level < VPP_PQ_LV_OFF || level >= VPP_PQ_LV_MAX) {
level = VPP_PQ_LV_OFF;
}
return level;
}
int CPQControl::SaveChromaCoring(int level)
{
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData)) {
SYS_LOGE("%s GetPictureModeData failed\n", __FUNCTION__);
return -1;
}
pData.ChromaCoring = level;
if (!SetPictureModeData(&pData)) {
SYS_LOGE("%s SetPictureModeData failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::Cpq_ChromaCoring(int level,source_input_param_t source_input_param)
{
if (!mbCpqCfg_chromacoring_enable) {
LOGD("%s: ChromaCoring disabled!\n", __FUNCTION__);
return 0;
}
int ret = -1;
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
ret = mPQdb->PQ_GetChromaCoringParams(level,source_input_param, regs);
if (ret < 0) {
LOGE("%s: PQ_GetChromaCoringParams failed!\n", __FUNCTION__);
} else {
ret = Cpq_LoadRegs(regs);
}
if (ret < 0)
LOGE("%s failed!\n",__FUNCTION__);
else
LOGD("%s success! level: %d\n",__FUNCTION__, level);
return ret;
}
//av/atv decode
int CPQControl::SetCVD2Values(void)
{
if (!mbCpqCfg_cvd2_enable) {
LOGD("%s cvd2 disable\n", __FUNCTION__);
return 0;
}
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetCVD2Params(mCurrentSourceInputInfo, regs) < 0) {
LOGE ( "%s, PQ_GetCVD2Params failed\n", __FUNCTION__);
return -1;
}
if (AFEDeviceIOCtl(TVIN_IOC_LOAD_REG, regs) < 0) {
LOGE ( "%s: ioctl failed\n", __FUNCTION__);
return -1;
}
LOGD("%s success\n", __FUNCTION__);
return 0;
}
//PQ Factory
int CPQControl::FactoryResetPQMode(void)
{
ResetPictureModeDataAll();
return 0;
}
int CPQControl::FactoryResetColorTemp(void)
{
ResetColorTemperatureDataAll();
ResetWhiteBalanceGammaDataAll();
return 0;
}
int CPQControl::FactorySetPQMode_Brightness(source_input_param_t source_input_param, int pq_mode, int brightness)
{
pq_source_input_t source = CheckPQSource(source_input_param.source_input);
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s GetPictureModeData failed\n", __FUNCTION__);
return -1;
}
pData.Brightness = brightness;
if (!SetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s SetPictureModeData failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetPQMode_Brightness(source_input_param_t source_input_param, int pq_mode)
{
pq_source_input_t source = CheckPQSource(source_input_param.source_input);
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s GetPictureModeCustomData failed\n", __FUNCTION__);
return -1;
}
return pData.Brightness;
}
int CPQControl::FactorySetPQMode_Contrast(source_input_param_t source_input_param, int pq_mode, int contrast)
{
pq_source_input_t source = CheckPQSource(source_input_param.source_input);
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s GetPictureModeData failed\n", __FUNCTION__);
return -1;
}
pData.Contrast = contrast;
if (!SetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s SetPictureModeData failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetPQMode_Contrast(source_input_param_t source_input_param, int pq_mode)
{
pq_source_input_t source = CheckPQSource(source_input_param.source_input);
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s GetPictureModeData failed\n", __FUNCTION__);
return -1;
}
return pData.Contrast;
}
int CPQControl::FactorySetPQMode_Saturation(source_input_param_t source_input_param, int pq_mode, int saturation)
{
pq_source_input_t source = CheckPQSource(source_input_param.source_input);
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s GetPictureModeData failed\n", __FUNCTION__);
return -1;
}
pData.Saturation = saturation;
if (!SetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s SetPictureModeData failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetPQMode_Saturation(source_input_param_t source_input_param, int pq_mode)
{
pq_source_input_t source = CheckPQSource(source_input_param.source_input);
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s GetPictureModeData failed\n", __FUNCTION__);
return -1;
}
return pData.Saturation;
}
int CPQControl::FactorySetPQMode_Hue(source_input_param_t source_input_param, int pq_mode, int hue)
{
pq_source_input_t source = CheckPQSource(source_input_param.source_input);
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s GetPictureModeData failed\n", __FUNCTION__);
return -1;
}
pData.Hue = hue;
if (!SetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s SetPictureModeData failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetPQMode_Hue(source_input_param_t source_input_param, int pq_mode)
{
pq_source_input_t source = CheckPQSource(source_input_param.source_input);
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s GetPictureModeData failed\n", __FUNCTION__);
return -1;
}
return pData.Hue;
}
int CPQControl::FactorySetPQMode_Sharpness(source_input_param_t source_input_param, int pq_mode, int sharpness)
{
pq_source_input_t source = CheckPQSource(source_input_param.source_input);
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s GetPictureModeData failed\n", __FUNCTION__);
return -1;
}
pData.Sharpness = sharpness;
if (!SetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s SetPictureModeData failed\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetPQMode_Sharpness(source_input_param_t source_input_param, int pq_mode)
{
pq_source_input_t source = CheckPQSource(source_input_param.source_input);
PICTURE_MODE_PARAM pData;
if (!GetPictureModeData(&pData, (PICTURE_MODE)pq_mode, source, CurTimming)) {
SYS_LOGE("%s GetPictureModeData failed\n", __FUNCTION__);
return -1;
}
return pData.Sharpness;
}
int CPQControl::FactorySetWhiteBalanceRedGain(int source_input, int colortemp_mode, int rgain)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
pq_wb_rgb_data_path_t data_path = WB_RGB_DATA_PATH_NULL;
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_CRI;
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_SSM;
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.r_gain = rgain;
if (data_path == WB_RGB_DATA_PATH_CRI) {
if (!FactorySetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGE("%s FactorySetWhitebalanceRGBGainOffsetData fail!\n", __FUNCTION__);
return -1;
}
} else if (data_path == WB_RGB_DATA_PATH_SSM) {
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
}
int eye_protection = GetEyeProtectionMode(mSourceInputForSaveParam);
rgbogo.r_gain = rgbogo.r_gain + Cpq_GetEyeProtectionOffset(R_GAIN, eye_protection);
rgbogo.g_gain = rgbogo.g_gain + Cpq_GetEyeProtectionOffset(G_GAIN, eye_protection);
rgbogo.b_gain = rgbogo.b_gain + Cpq_GetEyeProtectionOffset(B_GAIN, eye_protection);
if (Cpq_SetRGBOGO(&rgbogo) != 0) {
LOGE("%s error!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactorySaveWhiteBalanceRedGain(int source_input, int colortemp_mode, int rgain)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.r_gain = rgain;
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetWhiteBalanceRedGain(int source_input, int colortemp_mode)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
return rgbogo.r_gain;
}
int CPQControl::FactorySetWhiteBalanceGreenGain(int source_input, int colortemp_mode, int ggain)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
pq_wb_rgb_data_path_t data_path = WB_RGB_DATA_PATH_NULL;
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_CRI;
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_SSM;
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.g_gain = ggain;
if (data_path == WB_RGB_DATA_PATH_CRI) {
if (!FactorySetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGE("%s FactorySetWhitebalanceRGBGainOffsetData fail!\n", __FUNCTION__);
return -1;
}
} else if (data_path == WB_RGB_DATA_PATH_SSM) {
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
}
int eye_protection = GetEyeProtectionMode(mSourceInputForSaveParam);
rgbogo.r_gain = rgbogo.r_gain + Cpq_GetEyeProtectionOffset(R_GAIN, eye_protection);
rgbogo.g_gain = rgbogo.g_gain + Cpq_GetEyeProtectionOffset(G_GAIN, eye_protection);
rgbogo.b_gain = rgbogo.b_gain + Cpq_GetEyeProtectionOffset(B_GAIN, eye_protection);
if (Cpq_SetRGBOGO(&rgbogo) != 0) {
LOGE("%s error!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactorySaveWhiteBalanceGreenGain(int source_input, int colortemp_mode, int ggain)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.g_gain = ggain;
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetWhiteBalanceGreenGain(int source_input, int colortemp_mode)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
return rgbogo.g_gain;
}
int CPQControl::FactorySetWhiteBalanceBlueGain(int source_input, int colortemp_mode, int bgain)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
pq_wb_rgb_data_path_t data_path = WB_RGB_DATA_PATH_NULL;
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_CRI;
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_SSM;
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.b_gain = bgain;
if (data_path == WB_RGB_DATA_PATH_CRI) {
if (!FactorySetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGE("%s FactorySetWhitebalanceRGBGainOffsetData fail!\n", __FUNCTION__);
return -1;
}
} else if (data_path == WB_RGB_DATA_PATH_SSM) {
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
}
int eye_protection = GetEyeProtectionMode(mSourceInputForSaveParam);
rgbogo.r_gain = rgbogo.r_gain + Cpq_GetEyeProtectionOffset(R_GAIN, eye_protection);
rgbogo.g_gain = rgbogo.g_gain + Cpq_GetEyeProtectionOffset(G_GAIN, eye_protection);
rgbogo.b_gain = rgbogo.b_gain + Cpq_GetEyeProtectionOffset(B_GAIN, eye_protection);
if (Cpq_SetRGBOGO(&rgbogo) != 0) {
LOGE("%s error!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactorySaveWhiteBalanceBlueGain(int source_input, int colortemp_mode, int bgain)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.b_gain = bgain;
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetWhiteBalanceBlueGain(int source_input, int colortemp_mode)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
return rgbogo.b_gain;
}
int CPQControl::FactorySetWhiteBalanceRedPostOffset(int source_input, int colortemp_mode, int roffset)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
pq_wb_rgb_data_path_t data_path = WB_RGB_DATA_PATH_NULL;
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_CRI;
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_SSM;
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.r_post_offset = roffset;
if (data_path == WB_RGB_DATA_PATH_CRI) {
if (!FactorySetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGE("%s FactorySetWhitebalanceRGBGainOffsetData fail!\n", __FUNCTION__);
return -1;
}
} else if (data_path == WB_RGB_DATA_PATH_SSM) {
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
}
int eye_protection = GetEyeProtectionMode(mSourceInputForSaveParam);
rgbogo.r_gain = rgbogo.r_gain + Cpq_GetEyeProtectionOffset(R_GAIN, eye_protection);
rgbogo.g_gain = rgbogo.g_gain + Cpq_GetEyeProtectionOffset(G_GAIN, eye_protection);
rgbogo.b_gain = rgbogo.b_gain + Cpq_GetEyeProtectionOffset(B_GAIN, eye_protection);
if (Cpq_SetRGBOGO(&rgbogo) != 0) {
LOGE("%s error!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactorySaveWhiteBalanceRedPostOffset(int source_input, int colortemp_mode, int roffset)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.r_post_offset = roffset;
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetWhiteBalanceRedPostOffset(int source_input, int colortemp_mode)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
return rgbogo.r_post_offset;
}
int CPQControl::FactorySetWhiteBalanceGreenPostOffset(int source_input, int colortemp_mode, int goffset)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
pq_wb_rgb_data_path_t data_path = WB_RGB_DATA_PATH_NULL;
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_CRI;
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_SSM;
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.g_post_offset = goffset;
if (data_path == WB_RGB_DATA_PATH_CRI) {
if (!FactorySetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGE("%s FactorySetWhitebalanceRGBGainOffsetData fail!\n", __FUNCTION__);
return -1;
}
} else if (data_path == WB_RGB_DATA_PATH_SSM) {
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
}
int eye_protection = GetEyeProtectionMode(mSourceInputForSaveParam);
rgbogo.r_gain = rgbogo.r_gain + Cpq_GetEyeProtectionOffset(R_GAIN, eye_protection);
rgbogo.g_gain = rgbogo.g_gain + Cpq_GetEyeProtectionOffset(G_GAIN, eye_protection);
rgbogo.b_gain = rgbogo.b_gain + Cpq_GetEyeProtectionOffset(B_GAIN, eye_protection);
if (Cpq_SetRGBOGO(&rgbogo) != 0) {
LOGE("%s error!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactorySaveWhiteBalanceGreenPostOffset(int source_input, int colortemp_mode, int goffset)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.g_post_offset = goffset;
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetWhiteBalanceGreenPostOffset(int source_input, int colortemp_mode)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
return rgbogo.g_post_offset;
}
int CPQControl::FactorySetWhiteBalanceBluePostOffset(int source_input, int colortemp_mode, int boffset)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
pq_wb_rgb_data_path_t data_path = WB_RGB_DATA_PATH_NULL;
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_CRI;
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
data_path = WB_RGB_DATA_PATH_SSM;
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.b_post_offset = boffset;
if (data_path == WB_RGB_DATA_PATH_CRI) {
if (!FactorySetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGE("%s FactorySetWhitebalanceRGBGainOffsetData fail!\n", __FUNCTION__);
return -1;
}
} else if (data_path == WB_RGB_DATA_PATH_SSM) {
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
}
int eye_protection = GetEyeProtectionMode(mSourceInputForSaveParam);
rgbogo.r_gain = rgbogo.r_gain + Cpq_GetEyeProtectionOffset(R_GAIN, eye_protection);
rgbogo.g_gain = rgbogo.g_gain + Cpq_GetEyeProtectionOffset(G_GAIN, eye_protection);
rgbogo.b_gain = rgbogo.b_gain + Cpq_GetEyeProtectionOffset(B_GAIN, eye_protection);
if (Cpq_SetRGBOGO(&rgbogo) != 0) {
LOGE("%s error!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactorySaveWhiteBalanceBluePostOffset(int source_input, int colortemp_mode, int boffset)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
rgbogo.b_post_offset = boffset;
if (!SetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGE("%s SetColorTemperatureDataBySrcTimming fail!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetWhiteBalanceBluePostOffset(int source_input, int colortemp_mode)
{
tcon_rgb_ogo_t rgbogo;
memset (&rgbogo, 0, sizeof (rgbogo));
pq_source_input_t src = CheckPQSource((tv_source_input_t)source_input);
if (FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from cri_data \n", __FUNCTION__);
} else if (GetColorTemperatureDataBySrcTimming(&rgbogo, src, CurTimming, colortemp_mode)) {
LOGD("%s Get RGBGainOffset from ssm_data \n", __FUNCTION__);
} else {
LOGE("%s fail!\n", __FUNCTION__);
return -1;
}
return rgbogo.b_post_offset;
}
int CPQControl::FactorySetRGBGainOffset(int colortemp_mode, tcon_rgb_ogo_t params)
{
CheckCriDataWhitebalanceRGBGainOffsetData();
if (!FactorySetWhitebalanceRGBGainOffsetData(&params, colortemp_mode)) {
LOGE("%s error!\n", __FUNCTION__);
return -1;
}
int eye_protection = GetEyeProtectionMode(mCurrentSourceInputInfo.source_input);
params.r_gain = params.r_gain + Cpq_GetEyeProtectionOffset(R_GAIN, eye_protection);
params.g_gain = params.g_gain + Cpq_GetEyeProtectionOffset(G_GAIN, eye_protection);
params.b_gain = params.b_gain + Cpq_GetEyeProtectionOffset(B_GAIN, eye_protection);
if (Cpq_SetRGBOGO(&params) != 0) {
LOGE("%s error!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryGetRGBGainOffset(int colortemp_mode, tcon_rgb_ogo_t *params)
{
CheckCriDataWhitebalanceRGBGainOffsetData();
if (!FactoryGetWhitebalanceRGBGainOffsetData(params, colortemp_mode)) {
LOGE("%s error!\n", __FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::FactoryResetNonlinear(void)
{
return mPQdb->PQ_ResetAllNoLineParams();
}
int CPQControl::FactorySetParamsDefault(void)
{
FactoryResetPQMode();
FactoryResetNonlinear();
FactoryResetColorTemp();
if (mbCpqCfg_separate_db_enable) {
mpOverScandb->PQ_ResetAllOverscanParams();
} else {
mPQdb->PQ_ResetAllOverscanParams();
}
return 0;
}
int CPQControl::FactorySetNolineParams(source_input_param_t source_input_param, int type, noline_params_t noline_params)
{
int ret = -1;
switch (type) {
case NOLINE_PARAMS_TYPE_BRIGHTNESS:
ret = mPQdb->PQ_SetNoLineAllBrightnessParams(source_input_param.source_input,
noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75,
noline_params.osd100);
break;
case NOLINE_PARAMS_TYPE_CONTRAST:
ret = mPQdb->PQ_SetNoLineAllContrastParams(source_input_param.source_input,
noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75,
noline_params.osd100);
break;
case NOLINE_PARAMS_TYPE_SATURATION:
ret = mPQdb->PQ_SetNoLineAllSaturationParams(source_input_param.source_input,
noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75,
noline_params.osd100);
break;
case NOLINE_PARAMS_TYPE_HUE:
ret = mPQdb->PQ_SetNoLineAllHueParams(source_input_param.source_input,
noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75,
noline_params.osd100);
break;
case NOLINE_PARAMS_TYPE_SHARPNESS:
ret = mPQdb->PQ_SetNoLineAllSharpnessParams(source_input_param.source_input,
noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75,
noline_params.osd100);
break;
case NOLINE_PARAMS_TYPE_VOLUME:
ret = mPQdb->PQ_SetNoLineAllVolumeParams(source_input_param.source_input,
noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75,
noline_params.osd100);
break;
default:
break;
}
return ret;
}
noline_params_t CPQControl::FactoryGetNolineParams(source_input_param_t source_input_param, int 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 = mPQdb->PQ_GetNoLineAllBrightnessParams(source_input_param.source_input,
&noline_params.osd0, &noline_params.osd25, &noline_params.osd50,
&noline_params.osd75, &noline_params.osd100);
break;
case NOLINE_PARAMS_TYPE_CONTRAST:
ret = mPQdb->PQ_GetNoLineAllContrastParams(source_input_param.source_input,
&noline_params.osd0, &noline_params.osd25, &noline_params.osd50,
&noline_params.osd75, &noline_params.osd100);
break;
case NOLINE_PARAMS_TYPE_SATURATION:
ret = mPQdb->PQ_GetNoLineAllSaturationParams(source_input_param.source_input,
&noline_params.osd0, &noline_params.osd25, &noline_params.osd50,
&noline_params.osd75, &noline_params.osd100);
break;
case NOLINE_PARAMS_TYPE_HUE:
ret = mPQdb->PQ_GetNoLineAllHueParams(source_input_param.source_input,
&noline_params.osd0, &noline_params.osd25, &noline_params.osd50,
&noline_params.osd75, &noline_params.osd100);
break;
case NOLINE_PARAMS_TYPE_SHARPNESS:
ret = mPQdb->PQ_GetNoLineAllSharpnessParams(source_input_param.source_input,
&noline_params.osd0, &noline_params.osd25, &noline_params.osd50,
&noline_params.osd75, &noline_params.osd100);
break;
case NOLINE_PARAMS_TYPE_VOLUME:
ret = mPQdb->PQ_GetNoLineAllVolumeParams(source_input_param.source_input,
&noline_params.osd0, &noline_params.osd25, &noline_params.osd50,
&noline_params.osd75, &noline_params.osd100);
break;
default:
break;
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return noline_params;
}
int CPQControl::FactorySetHdrMode(int mode)
{
return SetHDRMode(mode);
}
int CPQControl::FactoryGetHdrMode(void)
{
return GetHDRMode();
}
int CPQControl::FactorySetOverscanParams(source_input_param_t source_input_param, vpp_display_mode_t dmode, tvin_cutwin_t cutwin_t)
{
int ret = -1;
LOGD("%s %d %d %d %d %d %d %d %d\n", __FUNCTION__,
source_input_param.source_input, source_input_param.sig_fmt, source_input_param.trans_fmt,
dmode, cutwin_t.hs, cutwin_t.he, cutwin_t.vs, cutwin_t.ve);
if (mbCpqCfg_separate_db_enable) {
ret = mpOverScandb->PQ_SetOverscanParams(source_input_param, dmode, cutwin_t);
}
if (ret != 0) {
LOGE("%s failed.\n", __FUNCTION__);
} else {
LOGD("%s success.\n", __FUNCTION__);
}
return ret;
}
tvin_cutwin_t CPQControl::FactoryGetOverscanParams(source_input_param_t source_input_param, vpp_display_mode_t dmode)
{
int ret = -1;
tvin_cutwin_t cutwin_t;
memset(&cutwin_t, 0, sizeof(cutwin_t));
LOGD("%s %d %d %d %d\n", __FUNCTION__,
source_input_param.source_input, source_input_param.sig_fmt, source_input_param.trans_fmt, dmode);
if (source_input_param.trans_fmt < TVIN_TFMT_2D || source_input_param.trans_fmt > TVIN_TFMT_3D_LDGD) {
return cutwin_t;
}
if (mbCpqCfg_separate_db_enable) {
ret = mpOverScandb->PQ_GetOverscanParams(source_input_param, dmode, &cutwin_t);
}
LOGD("%s %d %d %d %d\n", __FUNCTION__,
cutwin_t.hs, cutwin_t.he, cutwin_t.vs, cutwin_t.ve);
if (ret != 0) {
LOGE("%s failed.\n", __FUNCTION__);
} else {
LOGD("%s success.\n", __FUNCTION__);
}
return cutwin_t;
}
int CPQControl::FactorySetGamma(int gamma_r_value, int gamma_g_value, int gamma_b_value)
{
int ret = 0;
tcon_gamma_table_t gamma_r, gamma_g, gamma_b;
memset(gamma_r.data, (unsigned short)gamma_r_value, sizeof(tcon_gamma_table_t));
memset(gamma_g.data, (unsigned short)gamma_g_value, sizeof(tcon_gamma_table_t));
memset(gamma_b.data, (unsigned short)gamma_b_value, sizeof(tcon_gamma_table_t));
ret |= Cpq_SetGammaTbl_R((unsigned short *) gamma_r.data);
ret |= Cpq_SetGammaTbl_G((unsigned short *) gamma_g.data);
ret |= Cpq_SetGammaTbl_B((unsigned short *) gamma_b.data);
return ret;
}
int CPQControl::FcatorySSMRestore(void)
{
resetAllUserSettingParam();
return 0;
}
int CPQControl::Cpq_SetXVYCCMode(vpp_xvycc_mode_t xvycc_mode, source_input_param_t source_input_param)
{
int ret = -1;
am_regs_t *regs = &mRegsData;
am_regs_t *regs_1 = &mRegsDataNew;
memset(regs, 0x0, sizeof(am_regs_t));
memset(regs_1, 0x0, sizeof(am_regs_t));
if (mbCpqCfg_xvycc_enable) {
if (mPQdb->PQ_GetXVYCCParams((vpp_xvycc_mode_t) xvycc_mode, source_input_param, regs, regs_1) == 0) {
ret = Cpq_LoadRegs(regs);
ret |= Cpq_LoadRegs(regs_1);
} else {
LOGE("PQ_GetXVYCCParams failed!\n");
}
} else {
LOGD("XVYCC Moudle disabled!\n");
ret = 0;
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::Cpq_SetRGBOGO(const struct tcon_rgb_ogo_s *rgbogo)
{
int ret = VPPDeviceIOCtl(AMVECM_IOC_S_RGB_OGO, rgbogo);
if (ret < 0) {
LOGE("%s failed(%s)\n", __FUNCTION__, strerror(errno));
}
return ret;
}
int CPQControl::Cpq_GetRGBOGO(const struct tcon_rgb_ogo_s *rgbogo)
{
int ret = VPPDeviceIOCtl(AMVECM_IOC_G_RGB_OGO, rgbogo);
if (ret < 0) {
LOGE("%s failed(%s)!\n", __FUNCTION__, strerror(errno));
}
return ret;
}
int CPQControl::Cpq_SetGammaOnOff(int onoff)
{
int ret = -1;
if (onoff == 1) {
LOGD("%s: enable gamma!\n", __FUNCTION__);
ret = VPPDeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_EN);
} else {
LOGD("%s: disable gamma!\n", __FUNCTION__);
ret = VPPDeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_DIS);
}
if (ret < 0) {
LOGE("%s error(%s)!\n", __FUNCTION__, strerror(errno));
}
return ret;
}
int CPQControl::FactorySetDNLPCurveParams(source_input_param_t source_input_param, int level, int final_gain)
{
int ret = -1;
int cur_final_gain = -1;
char tmp_buf[128];
cur_final_gain = mPQdb->PQ_GetDNLPGains(source_input_param, (Dynamic_contrast_mode_t)level);
if (cur_final_gain == final_gain) {
LOGD("FactorySetDNLPCurveParams, same value, no need to update!");
return ret;
} else {
LOGD("%s final_gain = %d \n", __FUNCTION__, final_gain);
sprintf(tmp_buf, "%s %s %d", "w", "final_gain", final_gain);
pqWriteSys("/sys/class/amvecm/dnlp_debug", tmp_buf);
ret |= mPQdb->PQ_SetDNLPGains(source_input_param, (Dynamic_contrast_mode_t)level, final_gain);
}
return ret;
}
int CPQControl::FactoryGetDNLPCurveParams(source_input_param_t source_input_param, int level)
{
return mPQdb->PQ_GetDNLPGains(source_input_param, (Dynamic_contrast_mode_t)level);
}
int CPQControl::FactorySetNoiseReductionParams(source_input_param_t source_input_param, vpp_noise_reduction_mode_t nr_mode, int addr, int val)
{
return mPQdb->PQ_SetNoiseReductionParams(nr_mode, source_input_param, addr, val);
}
int CPQControl::FactoryGetNoiseReductionParams(source_input_param_t source_input_param, vpp_noise_reduction_mode_t nr_mode, int addr)
{
return mPQdb->PQ_GetNoiseReductionParams(nr_mode, source_input_param, addr);
}
int CPQControl::SetEyeProtectionMode(tv_source_input_t source_input __unused, int level, int is_save __unused)
{
LOGD("%s: mode:%d!\n", __FUNCTION__, level);
int ret = -1;
ret = SaveEyeProtectionMode(level);
ret |= Cpq_SetColorTemperature(GetColorTemperature());
if (ret < 0)
LOGE("%s failed!\n",__FUNCTION__);
else
LOGD("%s success!\n",__FUNCTION__);
return ret;
}
int CPQControl::GetEyeProtectionMode(tv_source_input_t source_input)
{
int mode = -1;
vpp_picture_mode_t pq_mode = (vpp_picture_mode_t)GetPQMode();
vpp_pictur_mode_para_t para;
if (!GetPictureModeData(&para, pq_mode)) {
LOGE("%s, GetPictureModeData fail!\n", __FUNCTION__);
return mode;
}
mode = para.EyeProtection;
if (mode < VPP_PQ_LV_OFF || mode > VPP_PQ_LV_HIGH) {
LOGE("%s: mode: %d out of range, use default 0!\n",__FUNCTION__, mode);
mode = VPP_PQ_LV_OFF;
}
LOGD("%s: success! source: %d, timming: %d, mode: %d!\n", __FUNCTION__, CurSource, CurTimming, mode);
return mode;
}
int CPQControl::SaveEyeProtectionMode(int level)
{
vpp_picture_mode_t pq_mode = (vpp_picture_mode_t)GetPQMode();
vpp_pictur_mode_para_t para;
if (!GetPictureModeData(&para, pq_mode)) {
LOGE("%s, GetPictureModeData fail!\n", __FUNCTION__);
return -1;
}
para.EyeProtection = level;
if (!SetPictureModeData(&para, pq_mode)) {
LOGE("%s, SetPictureModeData fail!\n", __FUNCTION__);
return -1;
}
LOGD("%s: success! source: %d, timming: %d, mode: %d!\n", __FUNCTION__, CurSource, CurTimming, level);
return 0;
}
int CPQControl::Cpq_GetEyeProtectionOffset(int type, int level)
{
int eye_offset_default = 0;
switch (level) {
case VPP_PQ_LV_OFF: eye_offset_default = 0; break;
case VPP_PQ_LV_LOW: eye_offset_default = 180; break;
case VPP_PQ_LV_MID: eye_offset_default = 210; break;
case VPP_PQ_LV_HIGH: eye_offset_default = 240; break;
default: eye_offset_default = 0; break;
}
char cfg_level[64] = {0};
snprintf(cfg_level, sizeof(cfg_level), "%s_%d", CFG_EYE_PROTECTION, level);
int eye_offset = 0;
switch (type) {
case R_GAIN:
eye_offset = mPQConfigFile->GetInt(cfg_level, CFG_EYE_R_GAIN, eye_offset_default);
break;
case G_GAIN:
eye_offset = mPQConfigFile->GetInt(cfg_level, CFG_EYE_G_GAIN, 0);
break;
case B_GAIN:
eye_offset = mPQConfigFile->GetInt(cfg_level, CFG_EYE_B_GAIN, eye_offset_default*(-1));
break;
default:
eye_offset = 0;
break;
}
return eye_offset;
}
int CPQControl::SetFlagByCfg(void)
{
struct pq_ctrl_s pqControlVal;
memset(&pqControlVal, 0x0, sizeof(struct pq_ctrl_s));
const char *config_value;
//load hdmi auto flag
config_value = mPQConfigFile->GetString(CFG_SECTION_HDMI, CGF_HDMI_AUTOSWITCH_ALLM_EN, "disable" );
if (strcmp(config_value, "enable") == 0 ) {
mbAllmModeCfg_enable = true;
} else {
mbAllmModeCfg_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_HDMI, CGF_HDMI_AUTOSWITCH_ITCONTENT_EN, "disable" );
if (strcmp(config_value, "enable") == 0 ) {
mbItcontentModeCfg_enable = true;
} else {
mbItcontentModeCfg_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_HDMI, CGF_HDMI_AUTOSWITCH_DVI_EN, "disable" );
if (strcmp(config_value, "enable") == 0 ) {
mbDviModeCfg_enable = true;
} else {
mbDviModeCfg_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_BIG_SMALL_DB_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_separate_db_enable = true;
} else {
mbCpqCfg_separate_db_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_ALL_PQ_MODULE_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_pq_enable = true;
} else {
mbCpqCfg_pq_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_DI_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_di_enable = true;
} else {
mbCpqCfg_di_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_MCDI_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_mcdi_enable = true;
pqWriteSys(MCDI_MODULE_CONTROL_PATH, "1");
} else {
mbCpqCfg_mcdi_enable = false;
pqWriteSys(MCDI_MODULE_CONTROL_PATH, "0");
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_DEBLOCK_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_deblock_enable = true;
pqWriteSys(DEBLOCK_MODULE_CONTROL_PATH, "13");//bit2~bit3
} else {
mbCpqCfg_deblock_enable = false;
pqWriteSys(DEBLOCK_MODULE_CONTROL_PATH, "1");
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_DEMOSQUITO_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_demoSquito_enable = true;
pqWriteSys(DEMOSQUITO_MODULE_CONTROL_PATH, "1");//bit0
} else {
mbCpqCfg_demoSquito_enable = false;
pqWriteSys(DEMOSQUITO_MODULE_CONTROL_PATH, "0");
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_NOISEREDUCTION_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_nr_enable = true;
pqWriteSys(NR2_MODULE_CONTROL_PATH, "1");
} else {
mbCpqCfg_nr_enable = false;
pqWriteSys(NR2_MODULE_CONTROL_PATH, "0");
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_SHARPNESS_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_sharpness_enable = true;
pqControlVal.sharpness0_en = 1;
} else {
mbCpqCfg_sharpness_enable = false;
pqControlVal.sharpness0_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_SHARPNESS0_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_sharpness0_enable = true;
pqControlVal.sharpness0_en = 1;
} else {
mbCpqCfg_sharpness0_enable = false;
pqControlVal.sharpness0_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_SHARPNESS1_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_sharpness1_enable = true;
pqControlVal.sharpness1_en = 1;
} else {
mbCpqCfg_sharpness1_enable = false;
pqControlVal.sharpness1_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_SHARPNESSPI_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_sharpnesspi_enable = true;
} else {
mbCpqCfg_sharpnesspi_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_DNLP_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_dnlp_enable = true;
pqControlVal.dnlp_en = 1;
Cpq_SetDNLPStatus(DNLP_ON);
} else {
mbCpqCfg_dnlp_enable = false;
pqControlVal.dnlp_en = 0;
Cpq_SetDNLPStatus(DNLP_OFF);
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_CM2_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_cm2_enable = true;
pqControlVal.cm_en = 1;
} else {
mbCpqCfg_cm2_enable = false;
pqControlVal.cm_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_AMVECM_BASCI_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_amvecm_basic_enable = true;
pqControlVal.vadj1_en = 1;
} else {
mbCpqCfg_amvecm_basic_enable = false;
pqControlVal.vadj1_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_AMVECM_BASCI_WITHOSD_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_amvecm_basic_withOSD_enable = true;
pqControlVal.vadj2_en = 1;
} else {
mbCpqCfg_amvecm_basic_withOSD_enable = false;
pqControlVal.vadj2_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_CONTRAST_RGB_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_contrast_rgb_enable = true;
pqControlVal.vd1_ctrst_en = 1;
} else {
mbCpqCfg_contrast_rgb_enable = false;
pqControlVal.vd1_ctrst_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_CONTRAST_RGB_WITHOSD_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_contrast_rgb_withOSD_enable = true;
pqControlVal.post_ctrst_en = 1;
} else {
mbCpqCfg_contrast_rgb_withOSD_enable = false;
pqControlVal.post_ctrst_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_WHITEBALANCE_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_whitebalance_enable = true;
pqControlVal.wb_en = 1;
} else {
mbCpqCfg_whitebalance_enable = false;
pqControlVal.wb_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_GAMMA_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_gamma_enable = true;
pqControlVal.gamma_en = 1;
} else {
mbCpqCfg_gamma_enable = false;
pqControlVal.gamma_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_LOCAL_CONTRAST_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_local_contrast_enable = true;
pqControlVal.lc_en = 1;
} else {
mbCpqCfg_local_contrast_enable = false;
pqControlVal.lc_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_BLACKEXTENSION_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_blackextension_enable = true;
pqControlVal.black_ext_en = 1;
} else {
mbCpqCfg_blackextension_enable = false;
pqControlVal.black_ext_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_WHITEEXTENSION_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_whiteextension_enable = true;
pqControlVal.black_ext_en = 1;
} else {
mbCpqCfg_whiteextension_enable = false;
pqControlVal.black_ext_en = 0;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_XVYCC_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_xvycc_enable = true;
} else {
mbCpqCfg_xvycc_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_DISPLAY_OVERSCAN_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_display_overscan_enable = true;
} else {
mbCpqCfg_display_overscan_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_HDMI, CFG_HDMI_OUT_WITH_FBC_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_hdmi_out_with_fbc_enable = true;
} else {
mbCpqCfg_hdmi_out_with_fbc_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_BACKLIGHT, CFG_LCD_HDR_INFO_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_lcd_hdrinfo_enable = true;
} else {
mbCpqCfg_lcd_hdrinfo_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_CVD2_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_cvd2_enable = true;
} else {
mbCpqCfg_cvd2_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_PQ_MODE_CHECK_SOURCE_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_pq_param_check_source_enable = true;
} else {
mbCpqCfg_pq_param_check_source_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_AI_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_ai_enable = true;
} else {
mbCpqCfg_ai_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_AICOLOR_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_aicolor_enable = true;
} else {
mbCpqCfg_aicolor_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_SMOOTHPLUS_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_smoothplus_enable = true;
} else {
mbCpqCfg_smoothplus_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_HDRTMO_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_hdrtmo_enable = true;
} else {
mbCpqCfg_hdrtmo_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_MEMC_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_memc_enable = true;
} else {
mbCpqCfg_memc_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_AAD_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_aad_enable = true;
} else {
mbCpqCfg_aad_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_CABC_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_cabc_enable = true;
} else {
mbCpqCfg_cabc_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_BLACK_BLUE_CHROMA_DB_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_separate_black_blue_chorma_db_enable = true;
} else {
mbCpqCfg_separate_black_blue_chorma_db_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_BLUESTRETCH_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_bluestretch_enable = true;
} else {
mbCpqCfg_bluestretch_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_CHROMA_COR_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_chromacoring_enable = true;
} else {
mbCpqCfg_chromacoring_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_BACKLIGHT_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_backlight_enable = true;
} else {
mbCpqCfg_backlight_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_GLOBAL_DIMMING_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_global_dimming_enable = true;
} else {
mbCpqCfg_global_dimming_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_LOCAL_DIMMING_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_local_dimming_enable = true;
} else {
mbCpqCfg_local_dimming_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_AISR_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_aisr_enable = true;
} else {
mbCpqCfg_aisr_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_INLINEAISR_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_inlineaisr_enable = true;
} else {
mbCpqCfg_inlineaisr_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_HDMI_COLOR_RANGE_MODE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_color_range_mode_enable = true;
} else {
mbCpqCfg_color_range_mode_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_COLOR_SPACE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_color_space_enable = true;
} else {
mbCpqCfg_color_space_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_GAMUT_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_gamut_enable = true;
} else {
mbCpqCfg_gamut_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_SUPER_RESOLUTION, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_super_resolution_enable = true;
} else {
mbCpqCfg_super_resolution_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_FILM_MODE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_film_mode_enable = true;
} else {
mbCpqCfg_film_mode_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_NEW_PICTURE_MODE_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_new_picture_mode_enable = true;
} else {
mbCpqCfg_new_picture_mode_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_DPSS_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_dpss_enable = true;
} else {
mbCpqCfg_dpss_enable = false;
}
config_value = mPQConfigFile->GetString(CFG_SECTION_PQ, CFG_EYE_PROTECTION_ENABLE, "disable");
if (strcmp(config_value, "enable") == 0) {
mbCpqCfg_eye_protection_enable = true;
} else {
mbCpqCfg_eye_protection_enable = false;
}
struct vpp_pq_ctrl_s amvecmConfigVal;
//struct vpp_pq_ctrl_s amvecmConfigVal = {0, {(void *)"0"}};
memset(&amvecmConfigVal, 0, sizeof(struct vpp_pq_ctrl_s));
amvecmConfigVal.length = 14;//this is the count of pq_ctrl_s option
amvecmConfigVal.ptr = &pqControlVal;
int ret = VPPDeviceIOCtl(AMVECM_IOC_S_PQ_CTRL, &amvecmConfigVal);
if (ret < 0) {
LOGE("%s error: %s!\n", __FUNCTION__, strerror(errno));
}
Cpq_SetVadjEnableStatus(pqControlVal.vadj1_en, pqControlVal.vadj2_en);
return 0;
}
int CPQControl::HasPqCaseFunc(pq_case_func_e type)
{
bool func_en = false;
switch (type) {
default: func_en = false; break;
case PQ_CASE_FUNC_PICTURE_MODE: func_en = true; break;
case PQ_CASE_FUNC_BACKLIGHT: func_en = mbCpqCfg_backlight_enable; break;
case PQ_CASE_FUNC_CONTRAST: func_en = mbCpqCfg_amvecm_basic_enable; break;
case PQ_CASE_FUNC_BRIGHTNESS: func_en = mbCpqCfg_amvecm_basic_enable; break;
case PQ_CASE_FUNC_SATURATION: func_en = mbCpqCfg_amvecm_basic_enable; break;
case PQ_CASE_FUNC_HUE: func_en = mbCpqCfg_amvecm_basic_enable; break;
case PQ_CASE_FUNC_SHARPNESS: func_en = HasSharpness(); break;
case PQ_CASE_FUNC_ASPECT_RATIO: func_en = mbCpqCfg_display_overscan_enable; break;
case PQ_CASE_FUNC_AI_PQ: func_en = mbCpqCfg_ai_enable; break;
case PQ_CASE_FUNC_AI_COLOR: func_en = mbCpqCfg_aicolor_enable; break;
case PQ_CASE_FUNC_AI_SR: func_en = HasAiSrFunc(); break;
case PQ_CASE_FUNC_GAMMA: func_en = mbCpqCfg_gamma_enable; break;
case PQ_CASE_FUNC_MANUAL_GAMMA: func_en = mbCpqCfg_gamma_enable; break;
case PQ_CASE_FUNC_COLOR_TEMP: func_en = mbCpqCfg_whitebalance_enable; break;
case PQ_CASE_FUNC_COLOR_MANAGEMENT: func_en = mbCpqCfg_cm2_enable; break;
case PQ_CASE_FUNC_COLOR_CUSTOMIZE: func_en = mbCpqCfg_cm2_enable; break;
case PQ_CASE_FUNC_COLOR_RANGE_MODE: func_en = mbCpqCfg_color_range_mode_enable; break;
case PQ_CASE_FUNC_COLOR_SPACE: func_en = mbCpqCfg_color_space_enable; break;
case PQ_CASE_FUNC_GLOBAL_DIMMING: func_en = mbCpqCfg_global_dimming_enable; break;
case PQ_CASE_FUNC_LOCAL_DIMMING: func_en = mbCpqCfg_local_dimming_enable; break;
case PQ_CASE_FUNC_BLACK_STRETCH: func_en = mbCpqCfg_blackextension_enable; break;
case PQ_CASE_FUNC_DNLP: func_en = mbCpqCfg_dnlp_enable; break;
case PQ_CASE_FUNC_LOCAL_CONTRAST: func_en = mbCpqCfg_local_contrast_enable; break;
case PQ_CASE_FUNC_SR: func_en = mbCpqCfg_super_resolution_enable; break;
case PQ_CASE_FUNC_DNR: func_en = mbCpqCfg_nr_enable; break;
case PQ_CASE_FUNC_DEBLOCK: func_en = mbCpqCfg_deblock_enable; break;
case PQ_CASE_FUNC_DEMOSQUITO: func_en = mbCpqCfg_demoSquito_enable; break;
case PQ_CASE_FUNC_DECONTOUR: func_en = mbCpqCfg_smoothplus_enable; break;
case PQ_CASE_FUNC_MEMC: func_en = mbCpqCfg_memc_enable; break;
case PQ_CASE_FUNC_FILM_MODE: func_en = mbCpqCfg_film_mode_enable; break;
case PQ_CASE_FUNC_AISR_DEMO_LR_SHOW: func_en = HasAisrDemoLeftRightShow(); break;
case PQ_CASE_FUNC_WHITE_STRETCH: func_en = mbCpqCfg_whiteextension_enable; break;
case PQ_CASE_FUNC_RESET: func_en = true; break;
case PQ_CASE_FUNC_EYEPROTECTION_MODE: func_en = mbCpqCfg_eye_protection_enable; break;
}
LOGD("%s type:%d, func_en:%d\n", __FUNCTION__, type, func_en);
return func_en;
}
int CPQControl::GetChipType(void)
{
int ret = 0;
int chip_type = 0; /*detail chip type please refer enum meson_cpuid_type_e*/
ret = VPPDeviceIOCtl(AMVECM_IOC_G_CHIP_TYPE, &chip_type);
if (ret < 0) {
LOGE("%s error(%s)!\n", __FUNCTION__, strerror(errno));
return -1;
}
LOGD("%s, chip_type:%d\n", __FUNCTION__, chip_type);
return chip_type;
}
int CPQControl::SetPLLValues(source_input_param_t source_input_param)
{
am_regs_t *regs = &mRegsData;
memset(regs, 0x0, sizeof(am_regs_t));
int ret = 0;
if (mPQdb->PQ_GetPLLParams (source_input_param, regs ) == 0 ) {
ret = AFEDeviceIOCtl(TVIN_IOC_LOAD_REG, regs);
if ( ret < 0 ) {
LOGE ( "%s error(%s)!\n", __FUNCTION__, strerror(errno));
return -1;
}
} else {
LOGE ( "%s, PQ_GetPLLParams failed!\n", __FUNCTION__ );
return -1;
}
return 0;
}
int CPQControl::Cpq_SSMReadNTypes(int id, int data_len, int offset)
{
int value = 0;
int ret = 0;
ret = mSSMAction->SSMReadNTypes(id, data_len, &value, offset);
if (ret < 0) {
LOGE("Cpq_SSMReadNTypes, error(%s).\n", strerror ( errno ) );
return -1;
} else {
return value;
}
}
int CPQControl::Cpq_SSMWriteNTypes(int id, int data_len, int data_buf, int offset)
{
int ret = 0;
ret = mSSMAction->SSMWriteNTypes(id, data_len, &data_buf, offset);
if (ret < 0) {
LOGE("Cpq_SSMWriteNTypes, error(%s).\n", strerror ( errno ) );
}
return ret;
}
int CPQControl::Cpq_GetSSMActualAddr(int id)
{
return mSSMAction->GetSSMActualAddr(id);
}
int CPQControl::Cpq_GetSSMActualSize(int id)
{
return mSSMAction->GetSSMActualSize(id);
}
int CPQControl::SSMRecovery(void)
{
return mSSMAction->SSMRecovery();
}
int CPQControl::Cpq_GetSSMStatus()
{
return mSSMAction->GetSSMStatus();
}
int CPQControl::SetCurrentSourceInputInfo(source_input_param_t source_input_param)
{
pthread_mutex_lock(&PqControlMutex);
LOGD("%s:new source info: source=%d,sigFmt=%d(0x%x)\n", __FUNCTION__,
source_input_param.source_input, source_input_param.sig_fmt, source_input_param.sig_fmt);
//get hdr type
enum hdr_type_e newHdrType = HDRTYPE_SDR;
newHdrType = Cpq_GetSourceHDRType(source_input_param.source_input);
if (mCurrentHdrType != newHdrType) {
LOGD("%s: callback hdr type to client %d %d\n", __FUNCTION__, newHdrType, mCurrentHdrType);
Cpq_SetHdrType(newHdrType);
}
if (newHdrType == HDRTYPE_SDR || newHdrType == HDRTYPE_NONE) {
mPQdb->mHdrStatus = false;
} else {
mPQdb->mHdrStatus = true;
}
LOGD("%s: mCurrentHdrType is %d, newHdrType is %d, hdrStatus is %d!\n", __FUNCTION__,
mCurrentHdrType, newHdrType, mPQdb->mHdrStatus);
if ((mCurrentSourceInputInfo.source_input != source_input_param.source_input) ||
(mCurrentHdrType != newHdrType)) {
mSatisfyEvent = true;
}
//check pq src timming
pq_src_param_t PqSrcTim;
PqSrcTim.pq_source_input = CheckPQSource(source_input_param.source_input);
PqSrcTim.pq_sig_fmt = CheckPQTimming(newHdrType);
LOGD("%s: PqSrcTim.pq_source_input:%d PqSrcTim.pq_sig_fmt:%d\n", __FUNCTION__, PqSrcTim.pq_source_input, PqSrcTim.pq_sig_fmt);
//get output type
output_type_t NewOutputType = OUTPUT_TYPE_LVDS;
NewOutputType = CheckOutPutMode(source_input_param.source_input);
if ((mCurrentSourceInputInfo.source_input != source_input_param.source_input) ||
(mCurrentSourceInputInfo.sig_fmt != source_input_param.sig_fmt) ||
(mCurrentSourceInputInfo.trans_fmt != source_input_param.trans_fmt) ||
(mCurrentHdrType != newHdrType) ||
(mCurrentOutputType != NewOutputType) ||
(CurSource != PqSrcTim.pq_source_input) ||
(CurTimming != PqSrcTim.pq_sig_fmt)) {
LOGD("%s: update source input info\n", __FUNCTION__);
CurSource = PqSrcTim.pq_source_input;
CurTimming = PqSrcTim.pq_sig_fmt;
mCurrentSourceInputInfo.source_input = source_input_param.source_input;
mCurrentSourceInputInfo.trans_fmt = source_input_param.trans_fmt;
mCurrentSourceInputInfo.sig_fmt = source_input_param.sig_fmt;
mCurrentOutputType = NewOutputType;
mSourceInputForSaveParam = mCurrentSourceInputInfo.source_input;
mCurrentHdrType = newHdrType;
mPQdb->mHdrType = newHdrType;
if (mbCpqCfg_separate_db_enable) {
mpOverScandb->mHdrType = newHdrType;
}
//load display mode setting
vpp_display_mode_t display_mode = (vpp_display_mode_t)GetDisplayMode();
SetDisplayMode(display_mode, 1);
//judge&trigger to set game/monitor or not, when switch vdin different signal
Cpq_SetPqModeToMonitor(AUTO_BY_SIG_CHG_STS_DIFF_SIG);
Cpq_SetPqModeToGame(AUTO_BY_SIG_CHG_STS_DIFF_SIG);
//load pq setting
if (source_input_param.sig_fmt == TVIN_SIG_FMT_NULL) {//exit source
mCurrentHdrType = HDRTYPE_NONE;
mPQdb->mHdrType = HDRTYPE_NONE;
if (mbCpqCfg_separate_db_enable) {
mpOverScandb->mHdrType = HDRTYPE_NONE;
}
mCurrentTvinInfo.hdr_info = 0;
if ((mCurrentSourceInputInfo.source_input == SOURCE_MPEG)
|| (mCurrentSourceInputInfo.source_input == SOURCE_DTV)) {
mCurrentSourceInputInfo.sig_fmt = TVIN_SIG_FMT_HDMI_1920X1080P_60HZ;
//LoadPQSettings();
} else if ((mCurrentSourceInputInfo.source_input == SOURCE_TV)
|| (mCurrentSourceInputInfo.source_input == SOURCE_AV1)
|| (mCurrentSourceInputInfo.source_input == SOURCE_AV2)) {
mCurrentSourceInputInfo.sig_fmt = TVIN_SIG_FMT_CVBS_NTSC_M;
} else {
mCurrentSourceInputInfo.sig_fmt = TVIN_SIG_FMT_HDMI_1920X1080P_60HZ;
}
CurTimming = PQ_FMT_SDR;
CheckPQLoadTableSourceInput(mCurrentSourceInputInfo);
} else if (source_input_param.sig_fmt == TVIN_SIG_FMT_MAX) {//enter nosignal
mCurrentHdrType = HDRTYPE_NONE;
mPQdb->mHdrType = HDRTYPE_NONE;
if (mbCpqCfg_separate_db_enable) {
mpOverScandb->mHdrType = HDRTYPE_NONE;
}
mCurrentTvinInfo.hdr_info = 0;
if ((mCurrentSourceInputInfo.source_input == SOURCE_TV)
|| (mCurrentSourceInputInfo.source_input == SOURCE_AV1)
|| (mCurrentSourceInputInfo.source_input == SOURCE_AV2)) {
mCurrentSourceInputInfo.sig_fmt = TVIN_SIG_FMT_CVBS_NTSC_M;
} else {
mCurrentSourceInputInfo.sig_fmt = TVIN_SIG_FMT_HDMI_1920X1080P_60HZ;
}
CurTimming = PQ_FMT_SDR;
CheckPQLoadTableSourceInput(mCurrentSourceInputInfo);
LoadPQSettings();
} else {//play video
CheckPQLoadTableSourceInput(mCurrentSourceInputInfo);
LoadPQSettings();
}
if (mSatisfyEvent) {
if (mCurrentSourceInputInfo.source_input < SOURCE_HDMI1 ||
mCurrentSourceInputInfo.source_input > SOURCE_HDMI4)
mbLowLatency = false; //ex:from hdmi mbLowLatency to mpeg, need reset mbLowLatency
Cpq_SetPqModeAutoChanged(GetPQMode(), (int)mCurrentHdrType, (int)mCurrentSourceInputInfo.source_input, mbLowLatency);
mSatisfyEvent = false;
}
} else {
LOGD("%s: same signal, no need set\n", __FUNCTION__);
//judge&trigger to set game/monitor or not, when switch vdin same signal, patch for vdin
Cpq_SetPqModeToMonitor(AUTO_BY_SIG_CHG_STS_SAME_SIG);
Cpq_SetPqModeToGame(AUTO_BY_SIG_CHG_STS_SAME_SIG);
}
if (mCurrentSignalInfo.info.status == TVIN_SIG_STATUS_STABLE) {
//load cvd2 parameter for cvbs decode
if (((SOURCE_TV == mCurrentSourceInputInfo.source_input)
|| (SOURCE_AV1 == mCurrentSourceInputInfo.source_input)
|| (SOURCE_AV2 == mCurrentSourceInputInfo.source_input))) {
SetCVD2Values();
}
}
pthread_mutex_unlock(&PqControlMutex);
return 0;
}
bool CPQControl::IsAllmVrrUiFuncCtrl(int *allm_func_ctrl, int *vrr_func_ctrl)
{
char buf_allm[32] = {0};
char buf_vrr[32] = {0};
//read UI HDMI_ALLM_EN status
pqReadSys(HDMI_SET_ALLM_PARAM, buf_allm, sizeof(buf_allm));
//read UI VRR_EN status
pqReadSys(HDMI_VRR_ENABLED, buf_vrr, sizeof(buf_vrr));
LOGD("%s: buf_allm:%s buf_vrr:%s\n", __FUNCTION__, buf_allm, buf_vrr);
sscanf(buf_allm, "%*[^:]:%d", allm_func_ctrl);
sscanf(buf_vrr, "%*[^:]:%d", vrr_func_ctrl);
LOGD("%s: *allm_func_ctrl:%d *vrr_func_ctrl:%d\n", __FUNCTION__, *allm_func_ctrl, *vrr_func_ctrl);
if (*allm_func_ctrl > 0 || *vrr_func_ctrl > 0) {
return true;
}
return false;
}
bool CPQControl::IsAllmVrrGameMode(void)
{
int allm_func_ctrl = 0; //ui hdmi_allm_en status
int vrr_func_ctrl = 0; //ui vrr_en status
int game_condition = 0; //bit0:hdmi allm game; bit1:vrr game; bit2:dlby allm game
if (IsAllmVrrUiFuncCtrl(&allm_func_ctrl, &vrr_func_ctrl) == false) {
LOGD("%s: allm and vrr ui all disable status\n", __FUNCTION__);
}
//when ui enable, check vdin allm_mode bit0(hdmi allm)
if (allm_func_ctrl > 0) {
if ((mCurrentTvinInfo.allmInfo.allm_mode & ALLM_MODE_HDMI) ||
(mCurrentTvinInfo.allmInfo.it_content && mCurrentTvinInfo.allmInfo.cn_type == GAME)) {
game_condition = 1;
}
}
//when ui enable, check vdin vrr infor
if (vrr_func_ctrl > 0) {
if (mCurrentTvinInfo.vrrparm.cur_vrr_status != VDIN_VRR_OFF &&
mCurrentTvinInfo.vrrparm.cur_vrr_status != VDIN_VRR_LATENCY) {
game_condition = (game_condition | 2);
}
}
//no UI link, but need check vdin allm_mode bit1(dlby allm)
if (mCurrentTvinInfo.allmInfo.allm_mode & ALLM_MODE_DLBY) {
game_condition = (game_condition | 4);
}
LOGD("%s: game_condition:%d\n", __FUNCTION__, game_condition);
return (mbLowLatency = (game_condition > 0) ? true : false);
}
int CPQControl::Cpq_SetPqModeToGame(pq_mode_by_signal_t mode)
{
LOGD("%s: mode:%d src:%d fmt:%d\n", __FUNCTION__, mode, CurSource, CurTimming);
if (mCurrentSourceInputInfo.source_input < SOURCE_HDMI1 ||
mCurrentSourceInputInfo.source_input > SOURCE_HDMI4)
return 0;
if (IsAllmVrrGameMode()) {
LOGD("%s: set to game mode\n", __FUNCTION__);
if (mode == AUTO_BY_SIG_CHG_DV_ALLM ||
mode == AUTO_BY_SIG_CHG_STS_SAME_SIG) {
//set & save pq mode to game
SetPQMode((int)VPP_PICTURE_MODE_GAME, 1);
} else if (mode == AUTO_BY_SIG_CHG_STS_DIFF_SIG) {
//save pq mode to game, effect is by LoadPQUISettings()
SavePQMode((int)VPP_PICTURE_MODE_GAME);
} else {
//nothing now
}
//callback to upper
Cpq_SetPqModeAutoChanged((int)VPP_PICTURE_MODE_GAME, (int)mCurrentHdrType, (int)mCurrentSourceInputInfo.source_input, mbLowLatency);
//remember which src + which timming done game setting, for next time to recovery
aAllmSrcFmtFlag[CurSource][CurTimming] = true;
} else {
if (aAllmSrcFmtFlag[CurSource][CurTimming] == true) {
int last_pq_mode = GetLastPQMode();
LOGD("%s: recovery to last pq mode:%d\n", __FUNCTION__, last_pq_mode);
if (mode == AUTO_BY_SIG_CHG_DV_ALLM ||
mode == AUTO_BY_SIG_CHG_STS_SAME_SIG) {
SetPQMode(last_pq_mode, 1);
} else if (mode == AUTO_BY_SIG_CHG_STS_DIFF_SIG) {
SavePQMode(last_pq_mode);
} else {
//nothing now
}
Cpq_SetPqModeAutoChanged(last_pq_mode, (int)mCurrentHdrType, (int)mCurrentSourceInputInfo.source_input, mbLowLatency);
aAllmSrcFmtFlag[CurSource][CurTimming] = false;
} else {
LOGD("%s: no need recovery\n", __FUNCTION__);
}
}
return 0;
}
bool CPQControl::IsAllmDviMonitorMode(void)
{
if (mCurrentTvinInfo.allmInfo.it_content && ((mCurrentTvinInfo.allmInfo.cn_type == GRAPHICS) || (mCurrentTvinInfo.allmInfo.cn_type == PHOTO))) {
LOGD("%s:vesa fmt, autoswitch to monitor mode!\n", __FUNCTION__);
return true;
}
if (mCurrentTvinInfo.is_dvi) {
LOGD("%s:DVI fmt, autoswitch to monitor mode!\n", __FUNCTION__);
return true;
}
return false;
}
int CPQControl::Cpq_SetPqModeToMonitor(pq_mode_by_signal_t mode)
{
LOGD("%s: mode:%d src:%d fmt:%d\n", __FUNCTION__, mode, CurSource, CurTimming);
if (mCurrentSourceInputInfo.source_input < SOURCE_HDMI1 ||
mCurrentSourceInputInfo.source_input > SOURCE_HDMI4)
return 0;
if (IsAllmDviMonitorMode()) {
LOGD("%s: set to monitor mode\n", __FUNCTION__);
if (mode == AUTO_BY_SIG_CHG_DV_ALLM ||
mode == AUTO_BY_SIG_CHG_STS_SAME_SIG) {
//set & save pq mode to monitor
SetPQMode((int)VPP_PICTURE_MODE_MONITOR, 1);
} else if (mode == AUTO_BY_SIG_CHG_STS_DIFF_SIG) {
//save pq mode to monitor, effect is by LoadPQUISettings()
SavePQMode((int)VPP_PICTURE_MODE_MONITOR);
} else {
//nothing now
}
//callback to upper
Cpq_SetPqModeAutoChanged((int)VPP_PICTURE_MODE_MONITOR, (int)mCurrentHdrType, (int)mCurrentSourceInputInfo.source_input, mbLowLatency);
//remember which src + which timming done monitor setting, for next time to recovery
aPCSrcFmtFlag[CurSource][CurTimming] = true;
} else {
if (aPCSrcFmtFlag[CurSource][CurTimming] == true) {
int last_pq_mode = GetLastPQMode();
LOGD("%s: recovery to last pq mode:%d\n", __FUNCTION__, last_pq_mode);
if (mode == AUTO_BY_SIG_CHG_DV_ALLM ||
mode == AUTO_BY_SIG_CHG_STS_SAME_SIG) {
SetPQMode(last_pq_mode, 1);
} else if (mode == AUTO_BY_SIG_CHG_STS_DIFF_SIG) {
SavePQMode(last_pq_mode);
} else {
//nothing now
}
Cpq_SetPqModeAutoChanged(last_pq_mode, (int)mCurrentHdrType, (int)mCurrentSourceInputInfo.source_input, mbLowLatency);
aPCSrcFmtFlag[CurSource][CurTimming] = false;
} else {
LOGD("%s: no need recovery\n", __FUNCTION__);
}
}
return 0;
}
int CPQControl::Cpq_SetPqModeToFilmMaker(int ui_fmm, int drv_fmm)
{
LOGD("%s: ui_fmm:%d drv_fmm:%d\n", __FUNCTION__, ui_fmm, drv_fmm);
if (ui_fmm == (int)FILM_MAKER_MODE_AUTO) {
if (drv_fmm == 1) {
LOGD("%s: set to filmmaker\n", __FUNCTION__);
SetPQMode((int)VPP_PICTURE_MODE_FILM_MAKER, 1);
//remember which src + which timming done FMM setting, for next time to recovery
aFmmSrcFmtFlag[CurSource][CurTimming] = true;
} else {
if (aFmmSrcFmtFlag[CurSource][CurTimming] == true) {
int last_pq_mode = GetLastPQMode();
LOGD("%s: recovery to last pq mode:%d\n", __FUNCTION__, last_pq_mode);
SetPQMode(last_pq_mode, 1);
aFmmSrcFmtFlag[CurSource][CurTimming] = false;
} else {
LOGD("%s: no need recovery\n", __FUNCTION__);
}
}
} else {
if (aFmmSrcFmtFlag[CurSource][CurTimming] == true) {
int last_pq_mode = GetLastPQMode();
LOGD("%s: recovery to last pq mode:%d\n", __FUNCTION__, last_pq_mode);
SetPQMode(last_pq_mode, 1);
aFmmSrcFmtFlag[CurSource][CurTimming] = false;
} else {
LOGD("%s: no need recovery\n", __FUNCTION__);
}
}
return 0;
}
int CPQControl::SetCurrentSource(tv_source_input_t source_input)
{
LOGD("%s: source_input = %d\n", __FUNCTION__, source_input);
source_input_param_t new_source_input_param;
new_source_input_param.source_input = source_input;
new_source_input_param.trans_fmt = mCurrentSourceInputInfo.trans_fmt;
new_source_input_param.sig_fmt = getVideoResolutionToFmt();
SetCurrentSourceInputInfo(new_source_input_param);
return 0;
}
source_input_param_t CPQControl::GetCurrentSourceInputInfo()
{
pthread_mutex_lock(&PqControlMutex);
source_input_param_t info = mCurrentSourceInputInfo;
pthread_mutex_unlock(&PqControlMutex);
return info;
}
int CPQControl::FactoryGetRGBPattern() {
char value[33] = {0};
int len = pqReadSys(VIDEO_RGB_SCREEN, value, (sizeof(value) - 1));
if (len > 0)
value[len] = '\0';
else
memset(value, '\0', sizeof(value));
return strtol(value, NULL, 10);
}
int CPQControl::FactorySetRGBPattern(int r, int g, int b) {
int value = ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff);
char str[32] = {0};
sprintf(str, "%d", value);
int ret = pqWriteSys(VIDEO_RGB_SCREEN, str);
return ret;
}
int CPQControl::FactorySetDDRSSC(int step) {
if (step < 0 || step > 5) {
LOGE ("%s, step = %d is too long", __FUNCTION__, step);
return -1;
}
return mSSMAction->SSMSaveDDRSSC(step);
}
int CPQControl::FactoryGetDDRSSC() {
unsigned char data = 0;
mSSMAction->SSMReadDDRSSC(&data);
return data;
}
/*1000ppm each level*/
int CPQControl::FactorySetLVDSSSCLevel(int level)
{
if (level > 4)
level = 4;
LOGD("%s,SSC_level = %d", __FUNCTION__, level);
struct aml_lcd_ss_ctl_s ssm_param;
memset(&ssm_param, 0, sizeof(struct aml_lcd_ss_ctl_s));
if (LCDDeviceIOCtl(LCD_IOC_CMD_GET_SS, &ssm_param) < 0) {
LOGE("%s,LCD_IOC_CMD_GET_SS fail", __FUNCTION__);
return -1;
}
ssm_param.level = level;
if (LCDDeviceIOCtl(LCD_IOC_CMD_SET_SS, &ssm_param) < 0) {
LOGE("%s,LCD_IOC_CMD_SET_SS fail", __FUNCTION__);
return -1;
}
return SaveLVDSSSCParams(&ssm_param);
}
int CPQControl::FactoryGetLVDSSSCLevel(void)
{
int level = 0;
struct aml_lcd_ss_ctl_s ssm_param;
memset(&ssm_param, 0, sizeof(struct aml_lcd_ss_ctl_s));
if (GetLVDSSSCParams(&ssm_param) < 0) {
LOGD ("%s,GetLVDSSSCParams fail", __FUNCTION__);
}
level = ssm_param.level;
return level;
}
/*Frep step range:
step 0 : 29.5KHZ
step 1 : 31.5KHZ
step 2 : 50KHZ
step 3 : 75KHZ
step 4 : 100KHZ
step 5 : 150KHZ
step 5 : 200KHZ*/
int CPQControl::FactorySetLVDSSSCFrep(int step)
{
if (step > 6)
step = 6;
LOGD("%s,SSC_Frep = %d", __FUNCTION__, step);
struct aml_lcd_ss_ctl_s ssm_param;
memset(&ssm_param, 0, sizeof(struct aml_lcd_ss_ctl_s));
if (LCDDeviceIOCtl(LCD_IOC_CMD_GET_SS, &ssm_param) < 0) {
LOGE("%s,LCD_IOC_CMD_GET_SS fail", __FUNCTION__);
return -1;
}
ssm_param.freq = step;
if (LCDDeviceIOCtl(LCD_IOC_CMD_SET_SS, &ssm_param) < 0) {
LOGD("%s,LCD_IOC_CMD_SET_SS fail", __FUNCTION__);
return -1;
}
return SaveLVDSSSCParams(&ssm_param);
}
int CPQControl::FactoryGetLVDSSSCFrep(void)
{
int setp = 0;
struct aml_lcd_ss_ctl_s ssm_param;
memset(&ssm_param, 0, sizeof(struct aml_lcd_ss_ctl_s));
if (GetLVDSSSCParams(&ssm_param) < 0) {
LOGD ("%s,GetLVDSSSCParams fail", __FUNCTION__);
}
setp = ssm_param.freq;
return setp;
}
/* mode:
mode 0 : center ss
mode 1 : up ss
mode 2 : down ss */
int CPQControl::FactorySetLVDSSSCMode(int mode)
{
if (mode > 3)
mode = 0;
LOGD("%s,SSC_mode = %d", __FUNCTION__, mode);
struct aml_lcd_ss_ctl_s ssm_param;
memset(&ssm_param, 0, sizeof(struct aml_lcd_ss_ctl_s));
if (LCDDeviceIOCtl(LCD_IOC_CMD_GET_SS, &ssm_param) < 0) {
LOGE("%s,LCD_IOC_CMD_GET_SS fail", __FUNCTION__);
return -1;
}
ssm_param.mode = mode;
if (LCDDeviceIOCtl(LCD_IOC_CMD_SET_SS, &ssm_param) < 0) {
LOGE("%s,LCD_IOC_CMD_SET_SS fail", __FUNCTION__);
return -1;
}
return SaveLVDSSSCParams(&ssm_param);
}
int CPQControl::FactoryGetLVDSSSCMode(void)
{
int mode = 0;
struct aml_lcd_ss_ctl_s ssm_param;
memset(&ssm_param, 0, sizeof(struct aml_lcd_ss_ctl_s));
if (GetLVDSSSCParams(&ssm_param) < 0) {
LOGD ("%s,GetLVDSSSCParams fail", __FUNCTION__);
}
mode = ssm_param.mode;
return mode;
}
int CPQControl::GetLVDSSSCParams(struct aml_lcd_ss_ctl_s *param)
{
const char *PanelIdx = "0";//config_get_str ( CFG_SECTION_TV, "get.panel.index", "0" ); can't parse ini file in systemcontrol
int panel_idx = strtoul(PanelIdx, NULL, 10);
if (!mDataBase->GetLvdsSscData((LCD_LVDS_SSC *)param, panel_idx)) {
return -1;
}
return 0;
}
int CPQControl::SaveLVDSSSCParams(struct aml_lcd_ss_ctl_s *param)
{
const char *PanelIdx = "0";//config_get_str ( CFG_SECTION_TV, "get.panel.index", "0" ); can't parse ini file in systemcontrol
int panel_idx = strtoul(PanelIdx, NULL, 10);
if (!mDataBase->SetLvdsSscData((LCD_LVDS_SSC *)param, panel_idx)) {
return -1;
}
return 0;
}
int CPQControl::SetDecodeLumaParamsCheckVal(int param_type, int val)
{
int ret = 0;
switch (param_type) {
case VIDEO_DECODE_BRIGHTNESS: {
if (val < 0 || val > 511) {
ret = -1;
} else {
ret = 0;
}
break;
}
case VIDEO_DECODE_CONTRAST: {
if (val < 0 || val > 1023) {
ret = -1;
} else {
ret = 0;
}
break;
}
case VIDEO_DECODE_SATURATION: {
if (val < 0 || val > 255) {
ret = -1;
} else {
ret = 0;
}
break;
}
default:
break;
}
return ret;
}
int CPQControl::FactorySetDecodeLumaParams(source_input_param_t source_input_param, int param_type, int val)
{
unsigned int tmp_val;
char tmp_buf[128];
int addr, reg_mask;
int bri_val, con_val;
if (SetDecodeLumaParamsCheckVal(param_type, val) < 0) {
LOGE("%s, error: val[%d] is out of range", __FUNCTION__, val);
return -1;
}
if (param_type == VIDEO_DECODE_BRIGHTNESS) {
addr = 0x157;
reg_mask = 0x1ff;
}else if (param_type == VIDEO_DECODE_CONTRAST) {
addr = 0x157;
reg_mask = 0x3ff0000;
}else if (param_type == VIDEO_DECODE_SATURATION) {
addr = DECODE_SAT_ADDR;
reg_mask = 0xff;
} else {
LOGE("%s, error: param_type[%d] is not supported", __FUNCTION__, param_type);
return -1;
}
tmp_val = mPQdb->PQ_GetCVD2Param(source_input_param, addr, param_type, reg_mask);
LOGD("%s, get value is %d, try to set value: %d\n", __FUNCTION__, tmp_val, val);
switch (param_type) {
case VIDEO_DECODE_BRIGHTNESS: {
tmp_val &= ~0x1ff;
tmp_val |= val;
tmp_val |= (0x8 << 12);
tmp_val |= (0x8 << 28);
con_val = (mPQdb->PQ_GetCVD2Param(source_input_param, addr, VIDEO_DECODE_CONTRAST, 0x3ff0000) >> 16) & 0x3ff;
tmp_val |= (con_val << 16);
LOGD("%s: setting val is %d", __FUNCTION__, tmp_val);
sprintf(tmp_buf, "%s %x %x", "wv", tmp_val, 0x157);
pqWriteSys("/sys/class/tvafe/tvafe0/reg", tmp_buf);
break;
}
case VIDEO_DECODE_CONTRAST: {
tmp_val &= ~0x3ff0000;
tmp_val |= (val << 16);
tmp_val |= (0x8 << 12);
tmp_val |= (0x8 << 28);
bri_val = mPQdb->PQ_GetCVD2Param(source_input_param, addr, VIDEO_DECODE_BRIGHTNESS, 0x1ff) & 0x1ff;
tmp_val |= bri_val;
sprintf(tmp_buf, "%s %x %x", "wv", tmp_val, 0x157);
pqWriteSys("/sys/class/tvafe/tvafe0/reg", tmp_buf);
break;
}
case VIDEO_DECODE_SATURATION: {
tmp_val &= ~0xff;
tmp_val |= val;
sprintf(tmp_buf, "%s %x %x", "wv", tmp_val, DECODE_SAT_ADDR);
pqWriteSys("/sys/class/tvafe/tvafe0/reg", tmp_buf);
break;
}
}
mPQdb->PQ_SetCVD2Param(source_input_param, addr, tmp_val, param_type, reg_mask);
return 0;
}
int CPQControl::FactoryGetDecodeLumaParams(source_input_param_t source_input_param, int param_type)
{
unsigned int rval = 0;
unsigned int reg_val = 0;
int ret = -1;
int addr, reg_mask;
if (param_type == VIDEO_DECODE_BRIGHTNESS) {
addr = 0x157;
reg_mask = 0x1ff;
}else if (param_type == VIDEO_DECODE_CONTRAST) {
addr = 0x157;
reg_mask = 0x3ff0000;
}else if (param_type == VIDEO_DECODE_SATURATION) {
addr = DECODE_SAT_ADDR;
reg_mask = 0xff;
} else {
LOGE("%s, error: param_type[%d] is not supported", __FUNCTION__, param_type);
return -1;
}
ret = mPQdb->PQ_GetCVD2Param(source_input_param, addr, param_type, reg_mask);
if (ret < 0) {
LOGE("%s, PQ_GetCVD2Param fail", __FUNCTION__);
return rval;
} else {
reg_val = ret;
}
switch (param_type) {
case VIDEO_DECODE_BRIGHTNESS: {
rval = reg_val & 0x1ff;
break;
}
case VIDEO_DECODE_CONTRAST: {
rval = (reg_val >> 16) & 0x3ff;
break;
}
case VIDEO_DECODE_SATURATION: {
rval = reg_val & 0xff;
break;
}
}
LOGD("%s, type [%d], get reg_val: %u, ret val: %u\n", __FUNCTION__, param_type, reg_val, rval);
return rval;
}
int CPQControl::FactorySetGrayPattern(int value) {
if (value < 0) {
value = 0;
} else if (value > 255) {
value = 255;
}
value = value << 16 | 0x8080;
LOGD("%s /sys/class/video/test_screen : %x", __FUNCTION__, value);
FILE *fp = fopen(TEST_SCREEN, "w");
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;
return 0;
}
int CPQControl::FactoryGetGrayPattern() {
int value = 0;
int arg_num;
FILE *fp = fopen(TEST_SCREEN, "r+");
if (fp == NULL) {
LOGE("Open /sys/class/video/test_screen error(%s)!\n", strerror(errno));
return -1;
}
arg_num = fscanf(fp, "%x", &value);
if (arg_num < 0) {
LOGE("arg_num: %d\n", arg_num);
}
LOGD("%s /sys/class/video/test_screen %x", __FUNCTION__, value);
fclose(fp);
fp = NULL;
if (value < 0) {
return 0;
} else {
value = value >> 16;
if (value > 255) {
value = 255;
}
return value;
}
}
int CPQControl::SetHDRMode(int mode)
{
int ret = -1;
if ((mCurrentSourceInputInfo.source_input == SOURCE_MPEG) ||
((mCurrentSourceInputInfo.source_input >= SOURCE_HDMI1) && mCurrentSourceInputInfo.source_input <= SOURCE_HDMI4)) {
ret = VPPDeviceIOCtl(AMVECM_IOC_S_CSCTYPE, &mode);
if (ret < 0) {
LOGE("%s error: %s!\n", __FUNCTION__, strerror(errno));
}
} else {
LOGE("%s: Current source no hdr status!\n", __FUNCTION__);
}
return ret;
}
int CPQControl::GetHDRMode()
{
enum vpp_matrix_csc_e mode = VPP_MATRIX_NULL;
if ((mCurrentSourceInputInfo.source_input == SOURCE_MPEG) ||
((mCurrentSourceInputInfo.source_input >= SOURCE_HDMI1) && mCurrentSourceInputInfo.source_input <= SOURCE_HDMI4)) {
int ret = VPPDeviceIOCtl(AMVECM_IOC_G_CSCTYPE, &mode);
if (ret < 0) {
LOGE("%s error: %s!\n", __FUNCTION__, strerror(errno));
mode = VPP_MATRIX_NULL;
} else {
LOGD("%s: mode is %d\n", __FUNCTION__, mode);
}
} else {
LOGD("%s: Current source no hdr status!\n", __FUNCTION__);
}
return mode;
}
enum hdr_type_e CPQControl::Cpq_GetSourceHDRType(tv_source_input_t source_input)
{
enum hdr_type_e newHdrType = HDRTYPE_SDR;
if ((source_input == SOURCE_MPEG)
||(source_input == SOURCE_DTV)) {
if (!mbVideoIsPlaying) {
newHdrType = HDRTYPE_SDR;
} else {
char buf[32] = {0};
int ret = pqReadSys(SYS_VIDEO_HDR_FMT, buf, sizeof(buf));
if (ret < 0) {
newHdrType = HDRTYPE_SDR;
LOGE("%s error: %s\n", __FUNCTION__, strerror(errno));
} else {
if (0 == strcmp(buf, "src_fmt = SDR")) {
newHdrType = HDRTYPE_SDR;
} else if (0 == strcmp(buf, "src_fmt = HDR10")) {
newHdrType = HDRTYPE_HDR10;
} else if (0 == strcmp(buf, "src_fmt = HDR10+")) {
newHdrType = HDRTYPE_HDR10PLUS;
} else if (0 == strcmp(buf, "src_fmt = HDR10 prime")) {
newHdrType = HDRTYPE_PRIMESL;
} else if (0 == strcmp(buf, "src_fmt = HLG")) {
newHdrType = HDRTYPE_HLG;
} else if (0 == strcmp(buf, "src_fmt = AM_DolbyVision")) {
newHdrType = HDRTYPE_DOVI;
} else if (0 == strcmp(buf, "src_fmt = MVC")) {
newHdrType = HDRTYPE_MVC;
} else {
LOGD("%s: invalid hdr type!\n", __FUNCTION__);
newHdrType = HDRTYPE_SDR;
}
}
}
} else if ((source_input == SOURCE_HDMI1)
|| (source_input == SOURCE_HDMI2)
|| (source_input == SOURCE_HDMI3)
|| (source_input == SOURCE_HDMI4)) {
int signalRange = (mCurrentTvinInfo.hdr_info >> 29) & 0x1;
int signalColorPrimaries = (mCurrentTvinInfo.hdr_info >> 16) & 0xff;
int signalTransferCharacteristic = (mCurrentTvinInfo.hdr_info >> 8) & 0xff;
int dvFlag = (mCurrentTvinInfo.hdr_info >> 30) & 0x1;
LOGD("%s: signalRange=0x%x, signalColorPrimaries=0x%x, signalTransferCharacteristic=0x%x, dvFlag=0x%x\n",
__FUNCTION__, signalRange, signalColorPrimaries, signalTransferCharacteristic, dvFlag);
if (((signalTransferCharacteristic == 0xe) || (signalTransferCharacteristic == 0x12))
&& (signalColorPrimaries == 0x9)) {
newHdrType = HDRTYPE_HLG;
} else if ((signalTransferCharacteristic == 0x30) && (signalColorPrimaries == 0x9)) {
newHdrType = HDRTYPE_HDR10PLUS;
} else if ((signalTransferCharacteristic == 0x10) || (signalColorPrimaries == 0x9)) {
newHdrType = HDRTYPE_HDR10;
} else if (dvFlag == 0x1) {
newHdrType = HDRTYPE_DOVI;
} else {
newHdrType = HDRTYPE_SDR;
}
} else {
LOGD("%s: This source no hdr status\n", __FUNCTION__);
newHdrType = HDRTYPE_SDR;
}
return newHdrType;
}
tvpq_databaseinfo_t CPQControl::GetDbVersionInfo(db_name_t name, db_version_type_t type) {
bool val = false;
tvpq_databaseinfo_t ver_info;
memset(&ver_info, 0, sizeof(tvpq_databaseinfo_t));
database_attribute_t dbAttribute;
switch (name) {
case DB_NAME_PQ:
val = mPQdb->PQ_GetDataBaseAttribute(&dbAttribute);
break;
case DB_NAME_OVERSCAN:
val = mpOverScandb->GetOverScanDbVersion(dbAttribute.ToolVersion, dbAttribute.ProjectVersion, dbAttribute.dbversion, dbAttribute.GenerateTime);
break;
default:
val = mPQdb->PQ_GetDataBaseAttribute(&dbAttribute);;
break;
}
if (val) {
if (type == DB_VER_TYPE_TOOL_VER) {
if (strlen(dbAttribute.ToolVersion.c_str()) <= sizeof(ver_info.version)/sizeof(char)) {
strcpy(ver_info.version, dbAttribute.ToolVersion.c_str());
LOGD("%s: ToolVersion:%s\n", __FUNCTION__, ver_info.version);
}
} else if (type == DB_VER_TYPE_PROJECT_VER) {
if (strlen(dbAttribute.ProjectVersion.c_str()) <= sizeof(ver_info.version)/sizeof(char)) {
strcpy(ver_info.version, dbAttribute.ProjectVersion.c_str());
LOGD("%s: ProjectVersion:%s\n", __FUNCTION__, ver_info.version);
}
} else if (type == DB_VER_TYPE_GENERATE_TIME) {
if (strlen(dbAttribute.GenerateTime.c_str()) <= sizeof(ver_info.version)/sizeof(char)) {
strcpy(ver_info.version, dbAttribute.GenerateTime.c_str());
LOGD("%s: GenerateTime:%s\n", __FUNCTION__, ver_info.version);
}
} else if (type == DB_VER_TYPE_CHIP_VER) {
if (strlen(dbAttribute.ChipVersion.c_str()) <= sizeof(ver_info.version)/sizeof(char)) {
strcpy(ver_info.version, dbAttribute.ChipVersion.c_str());
LOGD("%s: ChipVersion:%s\n", __FUNCTION__, ver_info.version);
}
} else if (type == DB_VER_TYPE_DB_VER) {
if (strlen(dbAttribute.dbversion.c_str()) <= sizeof(ver_info.version)/sizeof(char)) {
strcpy(ver_info.version, dbAttribute.dbversion.c_str());
LOGD("%s: DbVersion:%s\n", __FUNCTION__, ver_info.version);
}
} else {
LOGE("%s: db ver type is out range\n", __FUNCTION__);
}
}
return ver_info;
}
int CPQControl::GetSourceHDRType()
{
LOGD("%s: hdr type is %d\n", __FUNCTION__, mCurrentHdrType);
return mCurrentHdrType;
}
int CPQControl::SetCurrentHdrInfo(int hdrInfo)
{
int ret = 0;
if (mCurrentTvinInfo.hdr_info != (unsigned int)hdrInfo) {
mCurrentTvinInfo.hdr_info = (unsigned int)hdrInfo;
LOGD("%s: HDR info=0x%x\n", __FUNCTION__, mCurrentTvinInfo.hdr_info);
SetCurrentSourceInputInfo(mCurrentSourceInputInfo);
} else {
LOGD("%s: same HDR info\n", __FUNCTION__);
}
return ret;
}
int CPQControl::SetDtvKitSourceEnable(bool isEnable)
{
mbDtvKitEnable = isEnable;
LOGD("%s: mbDtvKitEnable:%d\n", __FUNCTION__, mbDtvKitEnable);
return 0;
}
//AI
int CPQControl::SetAipqEnable(bool isEnable)
{
enableAipq(isEnable);
PICTURE_SETTING_GLOBAL pData;
if (!GetPictureStructDataGlobal(&pData)) {
LOGE("%s GetPictureStructDataGlobal failed!\n",__FUNCTION__);
return -1;
}
pData.aipq_enable = isEnable ? 1 : 0;
if (!SetPictureStructDataGlobal(&pData)) {
LOGE("%s SetPictureStructDataGlobal failed!\n",__FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::GetAipqEnable()
{
int data = 0;
PICTURE_SETTING_GLOBAL pData;
if (!GetPictureStructDataGlobal(&pData)) {
LOGE("%s GetPictureStructDataGlobal failed!\n",__FUNCTION__);
return data;
}
data = pData.aipq_enable;
if (data < 0 || data > 1) {
data = 0;
}
LOGI("%s, data:%d\n", __FUNCTION__, data);
return data;
}
void CPQControl::enableAipq(bool isEnable)
{
if (!mbCpqCfg_ai_enable) {
LOGE("%s ai is disable\n", __FUNCTION__);
return;
}
pqWriteSys(DECODER_COMMON_PARAMETERS_DEBUG_VDETECT, isEnable ? "1" : "0");
pqWriteSys(VDETECT_AIPQ_ENABLE, isEnable ? "1" : "0");
}
int CPQControl::AiParamLoad(void)
{
if (!mbCpqCfg_ai_enable) {
LOGE("%s ai is disable\n", __FUNCTION__);
return 0;
}
int ret = -1;
struct aipq_load_s aiRegs;
memset(&aiRegs, 0, sizeof(struct aipq_load_s));
ret = mPQdb->PQ_GetAIParams(mCurrentSourceInputInfo, &aiRegs);
if (ret >= 0) {
LOGD("%s: width: %d, height: %d, array: %s.\n", __FUNCTION__, aiRegs.width, aiRegs.height, (char *)aiRegs.table_ptr);
ret = VPPDeviceIOCtl(AMVECM_IOC_S_AIPQ_TABLE, &aiRegs);
if (ret < 0) {
LOGE("%s: iocontrol failed\n", __FUNCTION__);
}
} else {
LOGE("%s: get AI pq params failed\n", __FUNCTION__);
}
if (ret < 0) {
LOGE("%s failed\n", __FUNCTION__);
} else {
LOGD("%s success\n", __FUNCTION__);
}
return ret;
}
bool CPQControl::HasAiSrFunc(void)
{
bool ret = false;
if (mbCpqCfg_aisr_enable || mbCpqCfg_inlineaisr_enable) {
ret = true;
}
LOGD("%s, has aisr or not:%d\n", __FUNCTION__, ret);
return ret;
}
int CPQControl::SetAiSrMode(aisr_mode_e mode, int is_save)
{
int ret = -1;
LOGD("%s, mode = %d\n", __FUNCTION__, mode);
ret = Cpq_SetAiSrMode(mode, mCurrentSourceInputInfo);
if ((ret == 0) && (is_save == 1)) {
ret = SaveAiSrMode((int)mode);
}
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetAiSrMode(void)
{
int data = 0;
PICTURE_SETTING_GLOBAL pData;
if (!GetPictureStructDataGlobal(&pData)) {
LOGE("%s GetPictureStructDataGlobal failed!\n",__FUNCTION__);
return data;
}
data = pData.aisr_mode;
if (data < VPP_PQ_LV_OFF || data >= VPP_PQ_LV_MAX)
data = VPP_PQ_LV_OFF;
LOGI("%s, data = %d\n", __FUNCTION__, data);
return data;
}
int CPQControl::SaveAiSrMode(int mode)
{
PICTURE_SETTING_GLOBAL pData;
if (!GetPictureStructDataGlobal(&pData)) {
LOGE("%s GetPictureStructDataGlobal failed!\n",__FUNCTION__);
return -1;
}
pData.aisr_mode = mode;
if (!SetPictureStructDataGlobal(&pData)) {
LOGE("%s SetPictureStructDataGlobal failed!\n",__FUNCTION__);
return -1;
}
LOGI("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::GetAiSrModeRange(void)
{
int data = 4; //off; low; mid; hig
if (mChipType == 0x38) { //MESON_CPU_MAJOR_ID_T3 = 0x38
data = 2; //off; on
}
return data;
}
int CPQControl::Cpq_SetAiSrEnable(bool enable)
{
if ((!mbCpqCfg_aisr_enable) && (!mbCpqCfg_inlineaisr_enable)) {
LOGD("%s disabled\n", __FUNCTION__);
return 0;
}
if (mChipType == 0x47 || mChipType == 0x48 || mChipType == 0x43 || mChipType == 0x4B) { //MESON_CPU_MAJOR_ID_S7D || MESON_CPU_MAJOR_ID_S6 || MESON_CPU_MAJOR_ID_T6W || MESON_CPU_MAJOR_ID_T6X
int aisr_en = (int)enable;
if (VideoDeviceIOCtl(AMSTREAM_IOC_SET_AISR_EN, &aisr_en) < 0) {
LOGE("%s failed!\n", __FUNCTION__);
return -1;
}
} else { // there is no driver device for old chips aisr function, so can't change note to iocmd
if (pqWriteSys(VIDEO_AISR_ENABLE, enable ? "1" : "0") < 0) {
LOGE("%s failed!\n", __FUNCTION__);
return -1;
}
}
return 0;
}
int CPQControl::Cpq_SetAiSrMode(aisr_mode_e mode, source_input_param_t source_input_param)
{
int ret = 0;
ret |= Cpq_SetNNAiSrMode(mode, source_input_param);
ret |= Cpq_SetInLineAiSrMode(mode, source_input_param);
if (ret < 0) {
LOGE("%s failed!\n",__FUNCTION__);
} else {
LOGD("%s success!\n",__FUNCTION__);
}
return ret;
}
int CPQControl::Cpq_SetNNAiSrMode(aisr_mode_e mode, source_input_param_t source_input_param)
{
LOGD("%s mode = %d\n", __FUNCTION__, mode);
if (!mbCpqCfg_aisr_enable) {
LOGD("%s NN AiSr disabled\n", __FUNCTION__);
return 0;
}
if (mChipType == 0x38) { //MESON_CPU_MAJOR_ID_T3 = 0x38
LOGD("%s two level aisr project, no need load reg table\n", __FUNCTION__);
return Cpq_SetAiSrEnable((mode > AISR_MODE_OFF) ? true : false);
}
am_regs_t* regs = (am_regs_t*)malloc(sizeof(am_regs_t));
if (!regs) {
LOGE("%s failed to allocate memory for regs!\n", __FUNCTION__);
return -1;
}
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetNNAiSrParams(mode, source_input_param, regs) < 0) {
LOGE("%s PQ_GetNNAiSrParams failed!\n", __FUNCTION__);
free(regs);
return -1;
}
if (Cpq_LoadRegs(regs) < 0) {
LOGE("%s failed!\n",__FUNCTION__);
free(regs);
return -1;
}
free(regs);
Cpq_SetAiSrEnable((mode > AISR_MODE_OFF) ? true : false);
LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetInLineAiSrMode(aisr_mode_e mode, source_input_param_t source_input_param)
{
LOGD("%s mode = %d\n", __FUNCTION__, mode);
if (!mbCpqCfg_inlineaisr_enable) {
LOGD("%s InLine AiSr disabled\n", __FUNCTION__);
return 0;
}
if (mChipType == 0x38) { //MESON_CPU_MAJOR_ID_T3 = 0x38
LOGD("%s two level aisr project, no need load reg table\n", __FUNCTION__);
return Cpq_SetAiSrEnable((mode > AISR_MODE_OFF) ? true : false);
}
am_regs_t* regs = (am_regs_t*)malloc(sizeof(am_regs_t));
if (!regs) {
LOGE("%s failed to allocate memory for regs!\n", __FUNCTION__);
return -1;
}
memset(regs, 0x0, sizeof(am_regs_t));
if (mPQdb->PQ_GetInLineAiSrParams(mode, source_input_param, regs) < 0) {
LOGE("%s PQ_GetInLineAiSrParams failed!\n", __FUNCTION__);
free(regs);
return -1;
}
if (Cpq_LoadRegs(regs) < 0) {
LOGE("%s failed!\n",__FUNCTION__);
free(regs);
return -1;
}
free(regs);
Cpq_SetAiSrEnable((mode > AISR_MODE_OFF) ? true : false);
LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::SetLocalDimming(int level, int is_save)
{
SYS_LOGD("%s, level:%d\n", __FUNCTION__, level);
int ret = Cpq_SetLocalDimming((vpp_pq_level_t)level);
if (ret == 0 && is_save == 1) {
ret = SaveLocalDimming(level);
}
if (ret < 0) {
SYS_LOGE("%s failed\n",__FUNCTION__);
} else {
SYS_LOGD("%s success\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetLocalDimming(void)
{
int level = VPP_PQ_LV_OFF;
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData)) {
LOGE("%s GetPictureStructDataBySrc failed\n", __FUNCTION__);
return level;
}
level = pData.LocalDimming;
if (level < VPP_PQ_LV_OFF || level >= VPP_PQ_LV_MAX) {
level = VPP_PQ_LV_OFF;
}
LOGI("%s, source: %d, level = %d\n", __FUNCTION__, CurSource, level);
return level;
}
int CPQControl::SaveLocalDimming(int level)
{
PICTURE_SETTING_BY_SRC pData;
if (!GetPictureStructDataBySrc(&pData)) {
LOGE("%s GetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
pData.LocalDimming = level;
if (!SetPictureStructDataBySrc(&pData)) {
LOGE("%s SetPictureStructDataBySrc failed\n", __FUNCTION__);
return -1;
}
LOGD("%s success!\n",__FUNCTION__);
return 0;
}
int CPQControl::Cpq_SetLocalDimming(vpp_pq_level_t level)
{
if (!mbCpqCfg_local_dimming_enable) {
LOGE("%s: LocalDimming disabled!\n", __FUNCTION__);
return 0;
}
if (AML_HAL_LD_SetLevelIdx((unsigned char)level) != API_OK) {
SYS_LOGE("%s, AML_HAL_LD_SetLevelIdx fail\n", __FUNCTION__);
return -1;
}
LOGD("%s success! level: %d\n",__FUNCTION__, level);
return 0;
}
int CPQControl::SetFilmMakerMode(pq_film_maker_mode_t mode, int is_save)
{
LOGD("%s, mode = %d\n", __FUNCTION__, mode);
int ret = 0;
if (is_save == 1) {
ret |= SaveFilmMakerMode(mode);
}
ret |= Cpq_SetFilmMakerMode();
if (ret < 0) {
LOGE("%s failed\n",__FUNCTION__);
} else {
LOGD("%s success\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetFilmMakerMode(void)
{
int mode = FILM_MAKER_MODE_DISABLE;
PICTURE_SETTING_GLOBAL pData;
if (!GetPictureStructDataGlobal(&pData)) {
LOGE("%s GetPictureStructDataGlobal failed!\n",__FUNCTION__);
return mode;
}
mode = pData.FilmMakerEnable;
if (mode < FILM_MAKER_MODE_DISABLE || mode >= FILM_MAKER_MODE_MAX) {
mode = FILM_MAKER_MODE_DISABLE;
}
LOGD("%s, mode = %d\n", __FUNCTION__, mode);
return mode;
}
int CPQControl::SaveFilmMakerMode(pq_film_maker_mode_t mode)
{
PICTURE_SETTING_GLOBAL pData;
if (!GetPictureStructDataGlobal(&pData)) {
LOGE("%s GetPictureStructDataGlobal failed!\n",__FUNCTION__);
return -1;
}
pData.FilmMakerEnable = mode;
if (!SetPictureStructDataGlobal(&pData)) {
LOGE("%s SetPictureStructDataGlobal failed!\n",__FUNCTION__);
return -1;
}
return 0;
}
int PQDemoMemcState = PQ_DEMO_STATE_OFF;
int PQDemoAisrState = PQ_DEMO_STATE_OFF;
int PQDemoAisrWin = PQ_DEMO_AISR_WIN_ON;
int CPQControl::SetPQModuleDemoState(pq_module_demo_t modules, pq_module_demo_state_t state)
{
LOGD("%s, modules:%d, state:%d\n",__FUNCTION__, modules, state);
int ret = -1;
switch (modules) {
case PQ_DEMO_MEMC://left memc on, right memc off
if (HasMemcFunc()) {
ret = DPSS_MEMCDeviceIOCtl(DPSS_FRC_IOC_SET_MEMC_DMEO_MODE, &state);//t6w dpss memc demo mode
if (ret < 0) {
ret = pqWriteSys(PQ_MODULE_MEMC_DEMO_WIN, (state == 1) ? "demo_win 1" : "demo_win 0");
LOGD("%s, no use dpss memc demo mode, use /sys/class/frc/param\n",__FUNCTION__);
}
PQDemoMemcState = state;
} else {
LOGE("%s MEMC Module disabled\n",__FUNCTION__);
ret = -1;
}
break;
case PQ_DEMO_AISR:
if (mbCpqCfg_aisr_enable || mbCpqCfg_inlineaisr_enable) {
ret = pqWriteSys(PQ_MODULE_AISR_DEMO_EN, (state == 1) ? "1" : "0");
PQDemoAisrState = state;
if (state == PQ_DEMO_STATE_ON && mCurrentOutputType == OUTPUT_TYPE_LVDS) {//tv
ret = pqWriteSys(PQ_MODULE_AISR_DEMO_AXIS, "0 0 1919 2159");//default 4k
} else if (state == PQ_DEMO_STATE_ON && mCurrentOutputType != OUTPUT_TYPE_LVDS) {//ott
if (mOutPutFrameHeightType == UHD_HEIGHT_4320) {
ret = pqWriteSys(PQ_MODULE_AISR_DEMO_AXIS, "0 0 3839 4319");//8k output
} else if (mOutPutFrameHeightType == UHD_HEIGHT_2160) {
ret = pqWriteSys(PQ_MODULE_AISR_DEMO_AXIS, "0 0 1919 2159");//4k output
} else if (mOutPutFrameHeightType <= FHD_HEIGHT_1080) {
ret = pqWriteSys(PQ_MODULE_AISR_DEMO_AXIS, "0 0 960 1079");//1080 output
}
} else {
LOGD("%s AISR Module Demo disabled\n",__FUNCTION__);
}
} else {
LOGE("%s AISR Module disabled\n",__FUNCTION__);
ret = -1;
}
break;
default:
LOGE("%s This Module:%d is missing \n",__FUNCTION__, modules);
ret = -1;
break;
}
if (ret < 0) {
LOGE("%s failed\n",__FUNCTION__);
} else {
LOGD("%s success\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetPQModuleDemoState(int modules)
{
int state = 0;
switch (modules) {
case PQ_DEMO_MEMC:
state = PQDemoMemcState;
break;
case PQ_DEMO_AISR:
state = PQDemoAisrState;
break;
default:
LOGE("%s This Module:%d is missing \n",__FUNCTION__, modules);
break;
}
if (state < PQ_DEMO_STATE_OFF || state >= PQ_DEMO_STATE_MAX) {
LOGE("%s state:%d out of range\n", __FUNCTION__, state);
state = PQ_DEMO_STATE_OFF;
}
return state;
}
int CPQControl::SetPQModuleDemoAisrWin(pq_module_demo_aisr_win_t aisr_win)
{
LOGD("%s, aisr_win:%d\n",__FUNCTION__, aisr_win);
int ret = -1;
ret = pqWriteSys(PQ_MODULE_AISR_DEMO_WIN, (aisr_win == 1) ? "1" : "0");
PQDemoAisrWin = aisr_win;
if (ret < 0) {
LOGE("%s failed\n",__FUNCTION__);
} else {
LOGD("%s success\n",__FUNCTION__);
}
return ret;
}
int CPQControl::GetPQModuleDemoAisrWin(void)
{
int aisr_win = 0;
aisr_win = PQDemoAisrWin;
if (aisr_win < PQ_DEMO_AISR_WIN_OFF || aisr_win >= PQ_DEMO_AISR_WIN_MAX) {
LOGE("%s aisr_win: %d out of range\n", __FUNCTION__, aisr_win);
aisr_win = PQ_DEMO_AISR_WIN_ON;
}
return aisr_win;
}
int CPQControl::SetPQModuleDemoAisrAxis(pq_module_demo_aisr_axis_t axis)
{
LOGD("%s axis x/y start/end:%d %d %d %d\n", __FUNCTION__, axis.xstart, axis.ystart, axis.xend, axis.yend);
int ret = -1;
std::string result;
result = std::to_string(axis.xstart) + std::string(" ")
+ std::to_string(axis.ystart) + std::string(" ")
+std::to_string(axis.xend) + std::string(" ")
+ std::to_string(axis.yend);
LOGD("%s result:%s\n", __FUNCTION__, result.c_str());
ret = pqWriteSys(PQ_MODULE_AISR_DEMO_AXIS, result.c_str());
if (ret < 0) {
LOGE("%s failed\n", __FUNCTION__);
} else {
LOGD("%s success\n", __FUNCTION__);
}
return ret;
}
pq_module_demo_aisr_axis_t CPQControl::GetPQModuleDemoAisrAxis(void)
{
pq_module_demo_aisr_axis_t axis;
memset(&axis, 0, sizeof(pq_module_demo_aisr_axis_t));
//temp not implement, reserve api
return axis;
}
bool CPQControl::HasAisrDemoLeftRightShow(void)
{
bool ret = false;
if (mChipType == 0x47 || mChipType == 0x48 || mChipType == 0x43 || mChipType == 0x4B) {
//MESON_CPU_MAJOR_ID_S7D || MESON_CPU_MAJOR_ID_S6
ret = true;
}
LOGD("%s, has aisr demo left/right show or not:%d\n", __FUNCTION__, ret);
return ret;
}
void CPQControl::resetAllUserSettingParam()
{
ResetNonlinearDataAll();
ResetColorTemperatureDataAll();
ResetColorCustomizeDataAll();
ResetPictureStructDataBySrcAll();
ResetPictureStructDataGlobal();
ResetPictureModeAll();
ResetPictureModeDataAll();
return;
}
int CPQControl::pqWriteSys(const char *path, const char *val)
{
int fd;
if ((fd = open(path, O_RDWR)) < 0) {
LOGE("writeSys, open %s error(%s)\n", path, strerror (errno));
return -1;
}
int len = write(fd, val, strlen(val));
close(fd);
return len;
}
int CPQControl::pqReadSys(const char *path, char *buf, int count)
{
int fd, len;
if ( NULL == buf ) {
LOGE("buf is NULL.\n");
return -1;
}
if ((fd = open(path, O_RDONLY)) < 0) {
LOGE("pqReadSys, open %s error(%s).\n", path, strerror (errno));
return -1;
}
len = read(fd, buf, count);
if (len < 0) {
LOGE("pqReadSys %s error, %s\n", path, strerror(errno));
close(fd);
return len;
}
int i , j;
for (i = 0, j = 0; i <= len -1; i++) {
//change '\0' to 0x20(spacing), otherwise the string buffer will be cut off ,if the last char is '\0' should not replace it
if (0x0 == buf[i] && i < len - 1) {
buf[i] = 0x20;
}
/* delete all the character of '\n' */
if (0x0a != buf[i]) {
buf[j++] = buf[i];
}
}
buf[j] = 0x0;
close(fd);
return len;
}
void CPQControl::pqTransformStringToInt(const char *buf, int *val)
{
if (buf != NULL) {
//LOGD("%s: %s\n", __FUNCTION__, buf);
char temp_buf[256] = {'\0'};
char *p = NULL;
int i = 0;
if (strlen(buf) <= sizeof(temp_buf)/sizeof(char)) {
strcpy(temp_buf, buf);
}
p = strtok(temp_buf, ",");
while (NULL != p) {
val[i++] = atoi(p);
p = strtok(NULL, ",");
}
} else {
LOGE("%s:Invalid param!\n", __FUNCTION__);
}
return;
}
int CPQControl::Cpq_GetInputVideoFrameHeight(tv_source_input_t source_input)
{
int inputFrameHeight = 0;
char inputModeBuf[32] = {0};
if (pqReadSys(SYS_VIDEO_FRAME_HEIGHT, inputModeBuf, sizeof(inputModeBuf)) > 0) {
inputFrameHeight = atoi(inputModeBuf);
} else {
LOGD("Read %s failed!\n", SYS_VIDEO_FRAME_HEIGHT);
}
if (inputFrameHeight <= 0) {
LOGD("%s: inputFrameHeight is invalid, return default value!\n", __FUNCTION__);
inputFrameHeight = 1080;
} else if (inputFrameHeight > 0 && inputFrameHeight < 480) {
LOGD("%s: such as Youtube/etc 360/240/... video!\n", __FUNCTION__);
inputFrameHeight = 480;
}
LOGD("%s: inputFrameHeight is %d!\n", __FUNCTION__, inputFrameHeight);
return inputFrameHeight;
}
//table about db TVOUT_CVBS with input/output resolution
int Table_TvoutWithIOResolution[TABLE_TYPE_MAX][RESOLUTION_MAX][RESOLUTION_MAX] = {
/*480 576 720 1080 2160 4320*/
{ //SDR
/*480*/ {OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_480_720, OUTPUT_TYPE_HDMI_480_1080, OUTPUT_TYPE_HDMI_480_2160, OUTPUT_TYPE_HDMI_480_2160},
/*576*/ {OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_576_720, OUTPUT_TYPE_HDMI_576_1080, OUTPUT_TYPE_HDMI_576_2160, OUTPUT_TYPE_HDMI_576_2160},
/*720*/ {OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_720_1080, OUTPUT_TYPE_HDMI_720_2160, OUTPUT_TYPE_HDMI_720_2160},
/*1080*/{OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_1080_2160, OUTPUT_TYPE_HDMI_1080_2160},
/*2160*/{OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_4K, OUTPUT_TYPE_HDMI_4K},
/*4320*/{OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE}
},
{ //HDR
/*480*/ {OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_480_720_HDR, OUTPUT_TYPE_HDMI_480_1080_HDR, OUTPUT_TYPE_HDMI_480_2160_HDR, OUTPUT_TYPE_HDMI_480_2160_HDR},
/*576*/ {OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_576_720_HDR, OUTPUT_TYPE_HDMI_576_1080_HDR, OUTPUT_TYPE_HDMI_576_2160_HDR, OUTPUT_TYPE_HDMI_576_2160_HDR},
/*720*/ {OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_720_1080_HDR, OUTPUT_TYPE_HDMI_720_2160_HDR, OUTPUT_TYPE_HDMI_720_2160_HDR},
/*1080*/{OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_1080_2160_HDR,OUTPUT_TYPE_HDMI_1080_2160_HDR},
/*2160*/{OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_4K_HDR, OUTPUT_TYPE_HDMI_4K_HDR},
/*4320*/{OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR, OUTPUT_TYPE_HDMI_NOSCALE_HDR}
},
{ //4K 120HZ
/*480*/ {OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_480_4K120, OUTPUT_TYPE_HDMI_NOSCALE},
/*576*/ {OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_576_4K120, OUTPUT_TYPE_HDMI_NOSCALE},
/*720*/ {OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_720_4K120, OUTPUT_TYPE_HDMI_NOSCALE},
/*1080*/{OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_1080_4K120, OUTPUT_TYPE_HDMI_NOSCALE},
/*2160*/{OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_4K_4K120, OUTPUT_TYPE_HDMI_NOSCALE},
/*4320*/{OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE}
},
{ //4K 120HZ HDR
/*480*/ {OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_480_4K120_HDR, OUTPUT_TYPE_HDMI_NOSCALE},
/*576*/ {OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_576_4K120_HDR, OUTPUT_TYPE_HDMI_NOSCALE},
/*720*/ {OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_720_4K120_HDR, OUTPUT_TYPE_HDMI_NOSCALE},
/*1080*/{OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_1080_4K120_HDR, OUTPUT_TYPE_HDMI_NOSCALE},
/*2160*/{OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_4K_4K120_HDR, OUTPUT_TYPE_HDMI_NOSCALE},
/*4320*/{OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE, OUTPUT_TYPE_HDMI_NOSCALE}
}
};
//table about resolution height thread value
int Table_ResolutionHeightThread[RESOLUTION_MAX][2] = {
//type value
{SD_HEIGHT_480, 480},
{SD_HEIGHT_576, 576},
{HD_HEIGHT_720, 720},
{FHD_HEIGHT_1080, 1080},
{UHD_HEIGHT_2160, 2160},
{UHD_HEIGHT_4320, 4320}
};
output_type_t CPQControl::MapDbTvoutWithIOResolution(int inputFrameHeight, int outputFrameHeight)
{
output_type_t OutPutType = OUTPUT_TYPE_LVDS;
LOGD("%s inputFrameHeight %d outputFrameHeight %d\n", __FUNCTION__, inputFrameHeight, outputFrameHeight);
if (mPQdb->mDbMatchType == MATCH_TYPE_MBOX_S5 ||
mPQdb->mDbMatchType == MATCH_TYPE_MBOX_S7D ||
mPQdb->mDbMatchType == MATCH_TYPE_MBOX_S6) {
int index_in = 0, index_out = 0, table_type = 0;
for (int i = 0; i < RESOLUTION_MAX; i++) { //pick up input index
if (inputFrameHeight < Table_ResolutionHeightThread[i][1]) {
index_in = i - 1;
break;
}
if (inputFrameHeight >= Table_ResolutionHeightThread[UHD_HEIGHT_4320][1]) { //input 8k
index_in = 5;
}
}
for (int j = 0; j < RESOLUTION_MAX; j++) { //pick up output index
if (outputFrameHeight < Table_ResolutionHeightThread[j][1]) {
index_out = j - 1;
break;
}
if (outputFrameHeight >= Table_ResolutionHeightThread[UHD_HEIGHT_4320][1]) { //8k output
index_out = 5;
}
}
if (mPQdb->mHdrStatus == true) {
if (mDisplayMode4k120 == true || mDisplayMode4k100 == true) {
table_type = 3;
} else {
table_type = 1;
}
} else {
if (mDisplayMode4k120 == true || mDisplayMode4k100 == true) {
table_type = 2;
} else {
table_type = 0;
}
}
mOutPutFrameHeightType = (resolution_height_type_t)index_out;
LOGD("%s table_type %d index_in %d index_out %d mOutPutFrameHeightType %d\n", __FUNCTION__, table_type, index_in, index_out, mOutPutFrameHeightType);
OutPutType = (output_type_t)Table_TvoutWithIOResolution[table_type][index_in][index_out];
//if (!mInitialized) { //patch for adjust aisr/etc menu in launcher after boot up
// OutPutType = OUTPUT_TYPE_HDMI_1080_2160;
//}
} else { //old project logic
if (inputFrameHeight > 1088) {//inputsource is 4k
OutPutType = OUTPUT_TYPE_HDMI_4K;
} else {
if (inputFrameHeight >= outputFrameHeight) {//input height >= output height
OutPutType = OUTPUT_TYPE_HDMI_NOSCALE;
} else {//input height < output height
if (inputFrameHeight > 720 && inputFrameHeight <= 1088) {//inputsource is 1080
OutPutType = OUTPUT_TYPE_HDMI_NOSCALE;
} else if (inputFrameHeight > 576 && inputFrameHeight <= 720) {//inputsource is 720
if (outputFrameHeight == 4096) {
OutPutType = OUTPUT_TYPE_HDMI_HD_4096;
} else if (outputFrameHeight >= inputFrameHeight * 2) {
OutPutType = OUTPUT_TYPE_HDMI_HD_UPSCALE;
} else {
OutPutType = OUTPUT_TYPE_HDMI_NOSCALE;
}
} else {//inputsource is 480
if (outputFrameHeight == 4096) {
OutPutType = OUTPUT_TYPE_HDMI_SD_4096;
} else if ((outputFrameHeight * 8) >= (inputFrameHeight * 15)) {
OutPutType = OUTPUT_TYPE_HDMI_SD_UPSCALE;
} else {
OutPutType = OUTPUT_TYPE_HDMI_NOSCALE;
}
}
}
}
}
LOGD("%s OutPutType %d\n", __FUNCTION__, OutPutType);
return OutPutType;
}
output_type_t CPQControl::CheckOutPutMode(tv_source_input_t source_input)
{
output_type_t OutPutType = OUTPUT_TYPE_LVDS;
if (!isFileExist(HDMI_OUTPUT_CHECK_PATH)) {//LVDS output
OutPutType = OUTPUT_TYPE_LVDS;
} else {
int outputFrameHeight = 1080;
char outputModeBuf[32] = {0};
if ((pqReadSys(SYS_DISPLAY_MODE_PATH, outputModeBuf, sizeof(outputModeBuf)) < 0) || (strlen(outputModeBuf) == 0)) {
LOGD("Read %s failed!\n", SYS_DISPLAY_MODE_PATH);
} else {
LOGD("%s: current output mode is %s!\n", __FUNCTION__, outputModeBuf);
if (strstr(outputModeBuf, "null")) {
return OUTPUT_TYPE_MAX;
} else if (strstr(outputModeBuf, "480cvbs")) {//NTSC output
OutPutType = OUTPUT_TYPE_NTSC;
} else if(strstr(outputModeBuf, "576cvbs")) {//PAL output
OutPutType = OUTPUT_TYPE_PAL;
} else {//HDMI output
//get output height
if (strstr(outputModeBuf, "smpte")) {
outputFrameHeight = 4096;
} else {
const char delim[2] = "p";
char *token;
token = strtok(outputModeBuf, delim);
if (token != NULL) {
outputFrameHeight = atoi(token);
}
}
LOGD("%s: outputFrameHeight: %d\n", __FUNCTION__, outputFrameHeight);
if (strstr(outputModeBuf, "120hz")) {
mDisplayMode4k120 = true;
} else if (strstr(outputModeBuf, "100hz")) {
mDisplayMode4k100 = true;
} else {
mDisplayMode4k120 = false;
mDisplayMode4k100= false;
}
LOGD("%s: mDisplayMode4k120:%d mDisplayMode4k100:%d!\n", __FUNCTION__, mDisplayMode4k120, mDisplayMode4k100);
//check outputmode
if ((source_input == SOURCE_MPEG)
|| (source_input == SOURCE_DTV)
|| (source_input == SOURCE_HDMI1)
|| (source_input == SOURCE_HDMI2)
|| (source_input == SOURCE_HDMI3)
|| (source_input == SOURCE_HDMI4)) {//hdmi/dtv/mpeg input
int inputFrameHeight = Cpq_GetInputVideoFrameHeight(source_input);
OutPutType = MapDbTvoutWithIOResolution(inputFrameHeight, outputFrameHeight);
} else {//atv/av input
if (outputFrameHeight >= 720) {
OutPutType = OUTPUT_TYPE_HDMI_SD_UPSCALE;
} else {
OutPutType = OUTPUT_TYPE_HDMI_NOSCALE;
}
}
}
}
}
LOGD("%s: output mode is %d\n", __FUNCTION__, OutPutType);
mPQdb->mOutPutType = OutPutType;
return OutPutType;
}
bool CPQControl::CheckPQModeTableInDb(void)
{
bool ret = mPQdb->CheckPQModeTableInDb();
if (ret) {
LOGD("pq mode table exist\n");
} else {
LOGD("pq mode table don't exist\n");
}
return ret;
}
bool CPQControl::isPqDatabaseMachChip()
{
bool matchStatus = false;
enum meson_cpu_ver_e chipVersion = VER_NULL;
database_attribute_t dbAttribute;
mPQdb->PQ_GetDataBaseAttribute(&dbAttribute);
if (dbAttribute.ChipVersion.length() == 0) {
LOGD("%s: ChipVersion is null!\n", __FUNCTION__);
chipVersion = VER_NULL;
} else {
int flagPosition = dbAttribute.ChipVersion.find("_");
std::string versionStr = dbAttribute.ChipVersion.substr(flagPosition+1, 1);
LOGD("%s: versionStr is %s!\n", __FUNCTION__, versionStr.c_str());
if (versionStr == "A") {
chipVersion = VER_A;
} else if (versionStr == "B") {
chipVersion = VER_B;
} else if (versionStr == "C") {
chipVersion = VER_C;
} else {
chipVersion = VER_NULL;
}
}
if (chipVersion == VER_NULL) {
LOGD("%s: database don't have chipversion!\n", __FUNCTION__);
matchStatus = true;
} else {
int ret = VPPDeviceIOCtl(AMVECM_IOC_S_MESON_CPU_VER, &chipVersion);
if (ret < 0) {
LOGD("%s: database don't match chip!\n", __FUNCTION__);
matchStatus = false;
} else {
LOGD("%s: database is match chip!\n", __FUNCTION__);
matchStatus = true;
}
}
return matchStatus;
}
int CPQControl::Cpq_SetVadjEnableStatus(int isvadj1Enable, int isvadj2Enable)
{
LOGD("%s: isvadj1Enable = %d, isvadj2Enable = %d.\n", __FUNCTION__, isvadj1Enable, isvadj2Enable);
int ret = -1;
if ((!mbCpqCfg_amvecm_basic_enable) && (!mbCpqCfg_amvecm_basic_withOSD_enable)) {
ret = 0;
LOGD("%s: all vadj module disabled.\n", __FUNCTION__);
} else {
struct am_vdj_mode_s params;
memset(&params, 0, sizeof(params));
params.flag |= (0x1<<6);
params.vadj1_en = isvadj1Enable;
params.vadj2_en = isvadj2Enable;
ret = VPPDeviceIOCtl(AMVECM_IOC_S_PIC_MODE, &params);
if (ret < 0) {
LOGE("%s error: %s!\n", __FUNCTION__, strerror(errno));
}
}
return ret;
}
//for callback to upper client
int CPQControl::Cpq_SetHdrType(int data)
{
if (mpObserver != NULL) {
LOGD("%s data %d\n", __FUNCTION__, data);
PQControlCb::HdrTypeCb cb_data;
cb_data.mHdrType = data;
mpObserver->GetCbDataFromLibpq(cb_data);
} else {
LOGD("%s mpObserver is NULL\n", __FUNCTION__);
}
return 0;
}
int CPQControl::Cpq_SetAllmStatus(void)
{
int mAllmGameMode = 0;
if (mCurrentSourceInputInfo.source_input >= SOURCE_HDMI1 &&
mCurrentSourceInputInfo.source_input <= SOURCE_HDMI4) {
if ((mCurrentTvinInfo.allmInfo.allm_mode & ALLM_MODE_HDMI_AND_DLBY) ||
(mCurrentTvinInfo.allmInfo.it_content && mCurrentTvinInfo.allmInfo.cn_type == GAME) ||
(mCurrentTvinInfo.vrrparm.cur_vrr_status != VDIN_VRR_OFF)) {
mAllmGameMode = 1;
}
} else {
LOGD("%s: reset mPreAllmGameMode\n", __FUNCTION__);
mPreAllmGameMode = 0;
}
LOGD("%s: mAllmGameMode:%d mPreAllmGameMode:%d\n", __FUNCTION__, mAllmGameMode, mPreAllmGameMode);
if (mPreAllmGameMode != mAllmGameMode) {
if (mpObserver != NULL) {
PQControlCb::AllmGameModeCb cb_data;
cb_data.mAllmGameMode = mAllmGameMode;
mpObserver->GetCbDataFromLibpq(cb_data);
} else {
LOGD("%s mpObserver is NULL\n", __FUNCTION__);
return -1;
}
mPreAllmGameMode = mAllmGameMode;
}
return 0;
}
int CPQControl::Cpq_SetFilmMakerMode(void)
{
int mFilmMakerMode = 0;
int ui_fmm = (int)FILM_MAKER_MODE_DISABLE;
LOGD("%s: mCurrentSourceInputInfo.source_input:%d, CurSource:%d, CurTimming:%d\n", __FUNCTION__,
mCurrentSourceInputInfo.source_input, CurSource, CurTimming);
if (mCurrentSourceInputInfo.source_input >= SOURCE_HDMI1 &&
mCurrentSourceInputInfo.source_input <= SOURCE_HDMI4) {
if (mCurrentTvinInfo.allmInfo.it_content &&
mCurrentTvinInfo.allmInfo.cn_type == CINEMA) {
mFilmMakerMode = 1;
}
} else if (mCurrentSourceInputInfo.source_input == SOURCE_MPEG) {
if (mbFilmmakerModeFlag == true) {
mFilmMakerMode = 1;
}
} else {
//nothing
}
ui_fmm = GetFilmMakerMode();
if (ui_fmm == (int)FILM_MAKER_MODE_DISABLE) {
//when ui func is disable, no need care driver fmm infor is on or off
mFilmMakerMode = 0;
LOGD("%s: fix mFilmMakerMode to 0 when ui is disable\n", __FUNCTION__);
}
LOGD("%s: mFilmMakerMode:%d, mPreFilmMakerMode[%d]:%d\n", __FUNCTION__,
mFilmMakerMode, CurSource, mPreFilmMakerMode[CurSource]);
if (mPreFilmMakerMode[CurSource] != mFilmMakerMode) {
Cpq_SetPqModeToFilmMaker(ui_fmm, mFilmMakerMode);
if (mpObserver != NULL) {
PQControlCb::FilmMakerModeCb cb_data;
cb_data.mFilmMakerMode = mFilmMakerMode;
mpObserver->GetCbDataFromLibpq(cb_data);
} else {
LOGD("%s mpObserver is NULL\n", __FUNCTION__);
return -1;
}
mPreFilmMakerMode[CurSource] = mFilmMakerMode;
}
return 0;
}
int CPQControl::Cpq_SetRefreshRate(void)
{
char frame_rate[10] = {0};
int mRefreshRate = 0;
if (pqReadSys(SYS_VIDEO_FRAME_RATE, frame_rate, sizeof(frame_rate)) > 0) {
LOGD("%s frame_rate %s\n", __FUNCTION__, frame_rate);
mRefreshRate = atoi(frame_rate);
} else {
LOGD("%s read %s failed\n", __FUNCTION__, SYS_VIDEO_FRAME_RATE);
return -1;
}
LOGD("%s: mRefreshRate:%d mPreRefreshRate:%d\n", __FUNCTION__, mRefreshRate, mPreRefreshRate);
if (mPreRefreshRate != mRefreshRate) {
if (mpObserver != NULL) {
PQControlCb::RefreshRateCb cb_data;
cb_data.mRefreshRate = mRefreshRate;
mpObserver->GetCbDataFromLibpq(cb_data);
} else {
LOGD("%s mpObserver is NULL\n", __FUNCTION__);
return -1;
}
mPreRefreshRate = mRefreshRate;
}
return 0;
}
int CPQControl::Cpq_SetPqModeAutoChanged(int pq_mode, int hdr_type, int input_src, bool low_latency)
{
if (mPrePqModeInfo[0] == pq_mode &&
mPrePqModeInfo[1] == hdr_type &&
mPrePqModeInfo[2] == input_src &&
mPrePqModeInfo[3] == (int)low_latency)
return 0;
if (mpObserver != NULL) {
LOGD("%s pq_mode %d, hdr_type %d, input_src %d, low_latency %d\n", __FUNCTION__,
pq_mode, hdr_type, input_src, low_latency);
PQControlCb::PqModeChangedCb cb_data;
cb_data.pq_mode_info.pq_mode = pq_mode;
cb_data.pq_mode_info.hdr_type = hdr_type;
cb_data.pq_mode_info.input_src = input_src;
cb_data.pq_mode_info.low_latency = low_latency;
mpObserver->GetCbDataFromLibpq(cb_data);
mPrePqModeInfo[0] = pq_mode;
mPrePqModeInfo[1] = hdr_type;
mPrePqModeInfo[2] = input_src;
mPrePqModeInfo[3] = (int)low_latency;
} else {
LOGD("%s mpObserver is NULL\n", __FUNCTION__);
}
return 0;
}
int CPQControl::Cpq_SetPqModeManualChanged(int data)
{
if (mpObserver != NULL) {
LOGD("%s data %d\n", __FUNCTION__, data);
PQControlCb::PictureModeCb cb_data;
cb_data.mPictureMode = data;
mpObserver->GetCbDataFromLibpq(cb_data);
} else {
LOGD("%s mpObserver is NULL\n", __FUNCTION__);
}
return 0;
}
//for callback to upper client end
int CPQControl::SetSharpnessParamsCheckVal(int param_type, int val)
{
int ret = 0;
switch (param_type) {
case H_GAIN_HIGH:
case H_GAIN_LOW:
case V_GAIN_HIGH:
case V_GAIN_LOW:
case D_GAIN_HIGH:
case D_GAIN_LOW:
case PKGAIN_VSLUMALUT7:
case PKGAIN_VSLUMALUT6:
case PKGAIN_VSLUMALUT5:
case PKGAIN_VSLUMALUT4:
case PKGAIN_VSLUMALUT3:
case PKGAIN_VSLUMALUT2:
case PKGAIN_VSLUMALUT1:
case PKGAIN_VSLUMALUT0: {
if (val < 0 || val > 15) {
ret = -1;
} else {
ret = 0;
}
break;
}
case HP_DIAG_CORE:
case BP_DIAG_CORE: {
if (val < 0 || val > 63) {
ret = -1;
} else {
ret = 0;
}
break;
}
}
return ret;
}
int CPQControl::MatchSharpnessRegAddr(int param_type, int isHd)
{
if (isHd) {
if (param_type >= H_GAIN_HIGH && param_type <= D_GAIN_LOW) {
return SHARPNESS_HD_GAIN;
} else if (param_type == HP_DIAG_CORE) {
return SHARPNESS_HD_HP_DIAG_CORE;
} else if (param_type == BP_DIAG_CORE) {
return SHARPNESS_HD_BP_DIAG_CORE;
} else if (param_type >= PKGAIN_VSLUMALUT7 && param_type <=PKGAIN_VSLUMALUT0) {
return SHARPNESS_HD_PKGAIN_VSLUMA;
} else {
LOGD("%s, error: param_type[%d] is not supported", __FUNCTION__, param_type);
return -1;
}
}
if (param_type >= H_GAIN_HIGH && param_type <= D_GAIN_LOW) {
return SHARPNESS_SD_GAIN;
} else if (param_type == HP_DIAG_CORE) {
return SHARPNESS_SD_HP_DIAG_CORE;
} else if (param_type == BP_DIAG_CORE) {
return SHARPNESS_SD_BP_DIAG_CORE;
} else if (param_type >= PKGAIN_VSLUMALUT7 && param_type <=PKGAIN_VSLUMALUT0) {
return SHARPNESS_SD_PKGAIN_VSLUMA;
} else {
LOGD("%s, error: param_type[%d] is not supported", __FUNCTION__, param_type);
return -1;
}
return -1;
}
unsigned int CPQControl::GetSharpnessRegVal(int addr)
{
char tmp_buf[128] = {0};
char rval[32] = {0};
sprintf(tmp_buf, "%s %x", "r", addr);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
pqReadSys(PQ_SET_RW_INTERFACE, rval, sizeof(rval));
return atoi(rval);
}
int CPQControl::FactorySetSharpnessParams(source_input_param_t source_input_param, sharpness_timing_t sr_timing, int param_type, int val)
{
int tmp_val;
char tmp_buf[128];
int addr;
if (SetSharpnessParamsCheckVal(param_type, val) < 0) {
LOGD("%s, error: val[%d] is out of range", __FUNCTION__, val);
return -1;
}
addr = MatchSharpnessRegAddr(param_type, sr_timing);
tmp_val = mPQdb->PQ_GetSharpnessAdvancedParams(source_input_param, addr, sr_timing);
if (tmp_val == 0) {
tmp_val = GetSharpnessRegVal(addr);
}
LOGD("%s, get value is %d, try to set value: %d\n", __FUNCTION__, tmp_val, val);
switch (param_type) {
case H_GAIN_HIGH: {
LOGD("%s, type [%d], get val: %u\n", __FUNCTION__, param_type, tmp_val);
tmp_val = tmp_val & (~(0xf << 28));
LOGD("%s, type [%d], get val: %u\n", __FUNCTION__, param_type, tmp_val);
tmp_val |= (val << 28);
LOGD("%s, setting value : %u", __FUNCTION__, tmp_val);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_GAIN, tmp_val);
pqWriteSys( PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case H_GAIN_LOW: {
LOGD("%s, type [%d], get val: %d\n", __FUNCTION__, param_type, tmp_val);
tmp_val &= (~(0xf << 12));
tmp_val |= (val << 12);
LOGD("%s, setting value : %d", __FUNCTION__, tmp_val);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_GAIN, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case V_GAIN_HIGH: {
tmp_val &= (~(0xf << 24));
tmp_val |= (val << 24);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_GAIN, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case V_GAIN_LOW: {
tmp_val &= ~(0xf << 8);
tmp_val |= (val << 8);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_GAIN, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case D_GAIN_HIGH: {
tmp_val &= ~(0xf << 20);
tmp_val |= (val << 20);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_GAIN, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case D_GAIN_LOW: {
tmp_val &= ~(0xf << 4);
tmp_val |= (val << 4);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_GAIN, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case HP_DIAG_CORE: {
tmp_val &= ~0x3f;
tmp_val |= val;
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_HP_DIAG_CORE, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case BP_DIAG_CORE: {
tmp_val &= ~0x3f;
tmp_val |= val;
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_BP_DIAG_CORE, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case PKGAIN_VSLUMALUT7: {
tmp_val &= ~(0xf << 28);
tmp_val |= (val << 28);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_PKGAIN_VSLUMA, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case PKGAIN_VSLUMALUT6: {
tmp_val &= ~(0xf << 24);
tmp_val |= (val << 24);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_PKGAIN_VSLUMA, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case PKGAIN_VSLUMALUT5: {
tmp_val &= ~(0xf << 20);
tmp_val |= (val << 20);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_PKGAIN_VSLUMA, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case PKGAIN_VSLUMALUT4: {
tmp_val &= ~(0xf << 16);
tmp_val |= (val << 16);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_PKGAIN_VSLUMA, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case PKGAIN_VSLUMALUT3: {
tmp_val &= ~(0xf << 12);
tmp_val |= (val << 12);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_PKGAIN_VSLUMA, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case PKGAIN_VSLUMALUT2: {
tmp_val &= ~(0xf << 8);
tmp_val |= (val << 8);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_PKGAIN_VSLUMA, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case PKGAIN_VSLUMALUT1: {
tmp_val &= ~(0xf << 4);
tmp_val |= (val << 4);
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_PKGAIN_VSLUMA, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
case PKGAIN_VSLUMALUT0: {
tmp_val &= ~0xf;
tmp_val |= val;
sprintf(tmp_buf, "%s %x %x", "w", SHARPNESS_SD_PKGAIN_VSLUMA, tmp_val);
pqWriteSys(PQ_SET_RW_INTERFACE, tmp_buf);
break;
}
default:
break;
}
mPQdb->PQ_SetSharpnessAdvancedParams(source_input_param, addr, tmp_val, sr_timing);
return 0;
}
int CPQControl::FactoryGetSharpnessParams(source_input_param_t source_input_param, sharpness_timing_t sr_timing, int param_type)
{
unsigned int rval = 0;
unsigned int reg_val = 0;
int addr;
addr = MatchSharpnessRegAddr(param_type, sr_timing);
reg_val = mPQdb->PQ_GetSharpnessAdvancedParams(source_input_param, addr, sr_timing);
if (reg_val == 0)
{
reg_val = GetSharpnessRegVal(addr);
}
switch (param_type) {
case H_GAIN_HIGH: {
LOGD("%s, type [%d], get val: %u\n", __FUNCTION__, param_type, reg_val);
rval = (reg_val >> 28) & 0xf;
LOGD("%s, type [%d], get val: %u\n", __FUNCTION__, param_type, rval);
break;
}
case H_GAIN_LOW: {
rval = (reg_val >> 12) & 0xf;
break;
}
case V_GAIN_HIGH: {
rval = (reg_val >> 24) & 0xf;
break;
}
case V_GAIN_LOW: {
rval = (reg_val >> 8) & 0xf;
break;
}
case D_GAIN_HIGH: {
rval = (reg_val >> 20) & 0xf;
break;
}
case D_GAIN_LOW: {
rval = (reg_val >> 4) & 0xf;
break;
}
case HP_DIAG_CORE: {
rval = reg_val & 0x3f;
break;
}
case BP_DIAG_CORE: {
rval = reg_val & 0x3f;
break;
}
case PKGAIN_VSLUMALUT7: {
rval = (reg_val >> 28) & 0xf;
break;
}
case PKGAIN_VSLUMALUT6: {
rval = (reg_val >> 24) & 0xf;
break;
}
case PKGAIN_VSLUMALUT5: {
rval = (reg_val >> 20) & 0xf;
break;
}
case PKGAIN_VSLUMALUT4: {
rval = (reg_val >> 16) & 0xf;
break;
}
case PKGAIN_VSLUMALUT3: {
rval = (reg_val >> 12) & 0xf;
break;
}
case PKGAIN_VSLUMALUT2: {
rval = (reg_val >> 8) & 0xf;
break;
}
case PKGAIN_VSLUMALUT1: {
rval = (reg_val >> 4) & 0xf;
break;
}
case PKGAIN_VSLUMALUT0: {
rval = reg_val & 0xf;
break;
}
default:
break;
}
LOGD("%s, type [%d], get reg_val: %u, ret val: %u\n", __FUNCTION__, param_type, reg_val, rval);
return rval;
}
int CPQControl::FactorySetPQEn(int pq_type, int isEnable)
{
char pq_enable_buf[128];
LOGD("%s pq_type =%d , isEnable =%d \n",__FUNCTION__,pq_type, isEnable);
switch (pq_type) {
case ALL: {
if (!isEnable) {
sprintf(pq_enable_buf, "%s", "vpp_pq disable");
} else {
sprintf(pq_enable_buf, "%s", "vpp_pq enable");
}
pqWriteSys("/sys/class/amvecm/debug", pq_enable_buf);
break;
}
case COLOR: {
if (VPPDeviceIOCtl(AMVECM_IOC_S_CM_CTRL, &isEnable) < 0)
LOGE("ioctl AMVECM_IOC_S_CM_CTRL failed");
break;
}
case SHARPNESS_SD: {
break;
}
case SHARPNESS_HD: {
break;
}
case _3D_NR_GAIN: {
if (!isEnable) {
sprintf(pq_enable_buf, "%s %x %x %x %x", "bw", 0x2dff, 0, 18, 1);
} else {
sprintf(pq_enable_buf, "%s %x %x %x %x", "bw", 0x2dff, 1, 18, 1);
}
pqWriteSys("/sys/class/amvecm/pq_reg_rw", pq_enable_buf);
break;
}
case _2D_NR_GAIN: {
if (!isEnable) {
sprintf(pq_enable_buf, "%s %x %x %x %x", "bw", 0x2dff, 0, 4, 1);
} else {
sprintf(pq_enable_buf, "%s %x %x %x %x", "bw", 0x2dff, 1, 4, 1);
}
pqWriteSys("/sys/class/amvecm/pq_reg_rw", pq_enable_buf);
break;
}
case DCI: {
if (!isEnable) {
Cpq_SetDNLPStatus(DNLP_OFF);
} else {
Cpq_SetDNLPStatus(DNLP_ON);
}
break;
}
case GAMMA: {
if (!isEnable) {
sprintf(pq_enable_buf, "%s", "gamma disable");
} else {
sprintf(pq_enable_buf, "%s", "gamma enable");
}
pqWriteSys("/sys/class/amvecm/debug", pq_enable_buf);
break;
}
case FMD: {
if (!isEnable) {
sprintf(pq_enable_buf, "%s", "37 0");
} else {
sprintf(pq_enable_buf, "%s", "37 1");
}
pqWriteSys("/sys/kernel/debug/di_top/mw_di", pq_enable_buf);
break;
}
case CTI_SR0: {
if (!isEnable) {
sprintf(pq_enable_buf, "%s %x %x %x %x", "bw", 0x322e, 0, 28, 1);
} else {
sprintf(pq_enable_buf, "%s %x %x %x %x", "bw", 0x322e, 1, 28, 1);
}
pqWriteSys("/sys/class/amvecm/pq_reg_rw", pq_enable_buf);
break;
}
case CTI_SR1: {
if (!isEnable) {
sprintf(pq_enable_buf, "%s %x %x %x %x", "bw", 0x32ae, 0, 28, 1);
} else {
sprintf(pq_enable_buf, "%s %x %x %x %x", "bw", 0x32ae, 1, 28, 1);
}
pqWriteSys("/sys/class/amvecm/pq_reg_rw", pq_enable_buf);
break;
}
case DEJAGGY_SR0: {
if (!isEnable) {
sprintf(pq_enable_buf, "%s", "sr0_dejaggy_dis");
} else {
sprintf(pq_enable_buf, "%s", "sr0_dejaggy_en");
}
pqWriteSys("/sys/class/amvecm/pq_user_set", pq_enable_buf);
break;
}
case DEJAGGY_SR1: {
if (!isEnable) {
sprintf(pq_enable_buf, "%s", "sr1_dejaggy_dis");
} else {
sprintf(pq_enable_buf, "%s", "sr1_dejaggy_en");
}
pqWriteSys("/sys/class/amvecm/pq_user_set", pq_enable_buf);
break;
}
case DRT_SR0: {
if (!isEnable) {
sprintf(pq_enable_buf, "%s", "sr0_derec_dis");
} else {
sprintf(pq_enable_buf, "%s", "sr0_derec_en");
}
pqWriteSys("/sys/class/amvecm/pq_user_set", pq_enable_buf);
break;
}
case DRT_SR1: {
if (!isEnable) {
sprintf(pq_enable_buf, "%s", "sr1_derec_dis");
} else {
sprintf(pq_enable_buf, "%s", "sr1_derec_en");
}
pqWriteSys("/sys/class/amvecm/pq_user_set", pq_enable_buf);
break;
}
case BLACK_STRETCH: {
break;
}
default:
break;
}
return 0;
}
int CPQControl::FactoryGetPQEn(int pq_type)
{
int ret = -1;
return ret;
}
int CPQControl::FactoryResetPictureModeData(void)
{
int ret = 0;
if (!ResetUserPictureModeData())
ret = -1;
return ret;
}
int CPQControl::FactoryResetAllPictureModeData(void)
{
int ret = 0;
if (!ResetPictureModeDataAll())
ret = -1;
if (!ResetPictureStructDataBySrcAll())
ret |= -1;
return ret;
}
int CPQControl::FactoryGetPictureModeData(int pqmode, pq_mode_parameters *params)
{
vpp_pictur_mode_para_t Data;
if (!GetPictureModeData(&Data, (vpp_picture_mode_t)pqmode)) {
LOGE("%s GetPictureModeData fail\n", __FUNCTION__);
return -1;
}
params->backlight = Data.Backlight;
params->brightness = Data.Brightness;
params->contrast = Data.Contrast;
params->saturation = Data.Saturation;
params->sharpness = Data.Sharpness;
params->gamma = Data.GammaMidLuminance;
params->local_contrast = Data.LocalContrast;
params->dynamic_contrast = Data.DynamicContrast;
params->super_resolution = Data.SuperResolution;
params->color_temperature = Data.ColorTemperature;
params->hue = Data.Hue;
params->hdr_tone_mapping = Data.HdrTmo;
params->color_gamut = Data.ColorGamut;
params->noise_reduction = Data.Nr;
params->MPEG_noise_reduction = Data.MpegNr;
params->dynamic_backlight = GetDynamicBacklight();
params->eye_protection = GetEyeProtectionMode(SOURCE_INVALID);
params->display_mode = GetDisplayMode();
params->smooth_plus = GetSmoothPlusMode();
return 0;
}
int CPQControl::FactoryGetDefaultPictureModeData(int pqmode, pq_mode_parameters *params)
{
PICTURE_MODE_PARAM Data;
if (!GetDefaultPictureModeData(&Data, (PICTURE_MODE)pqmode)) {
LOGE("%s getDefaultPictureModeData fail\n", __FUNCTION__);
return -1;
}
params->backlight = Data.Backlight;
params->brightness = Data.Brightness;
params->contrast = Data.Contrast;
params->saturation = Data.Saturation;
params->sharpness = Data.Sharpness;
params->gamma = Data.GammaMidLuminance;
params->local_contrast = Data.LocalContrast;
params->dynamic_contrast = Data.DynamicContrast;
params->super_resolution = Data.SuperResolution;
params->color_temperature = Data.ColorTemperature;
params->hue = Data.Hue;
params->hdr_tone_mapping = Data.HdrTmo;
params->color_gamut = Data.ColorGamut;
params->noise_reduction = Data.Nr;
params->MPEG_noise_reduction = Data.MpegNr;
params->dynamic_backlight = Data.DynamicBacklight;
params->eye_protection = Data.EyeProtection;
params->smooth_plus = Data.SmoothPlus;
PICTURE_SETTING_BY_SRC bySource;
if (GetDefaultPictureStructDataBySrc(&bySource)) {
params->display_mode = bySource.DisplayMode;
}
return 0;
}
int CPQControl::FactoryGetDefaultAllPQData(all_pq_parameters *params)
{
//default pqmode params
PICTURE_MODE_PARAM Data;
if (!GetDefaultPictureModeData(&Data)) {
LOGE("%s getDefaultPictureModeData fail\n", __FUNCTION__);
return -1;
}
params->PictureModeData.backlight = Data.Backlight;
params->PictureModeData.brightness = Data.Brightness;
params->PictureModeData.contrast = Data.Contrast;
params->PictureModeData.saturation = Data.Saturation;
params->PictureModeData.sharpness = Data.Sharpness;
params->PictureModeData.gamma = Data.GammaMidLuminance;
params->PictureModeData.local_contrast = Data.LocalContrast;
params->PictureModeData.dynamic_contrast = Data.DynamicContrast;
params->PictureModeData.super_resolution = Data.SuperResolution;
params->PictureModeData.color_temperature = Data.ColorTemperature;
params->PictureModeData.hue = Data.Hue;
params->PictureModeData.hdr_tone_mapping = Data.HdrTmo;
params->PictureModeData.color_gamut = Data.ColorGamut;
params->PictureModeData.noise_reduction = Data.Nr;
params->PictureModeData.MPEG_noise_reduction = Data.MpegNr;
params->PictureModeData.dynamic_backlight = Data.DynamicBacklight;
params->PictureModeData.eye_protection = Data.EyeProtection;
params->PictureModeData.smooth_plus = Data.SmoothPlus;
PICTURE_SETTING_BY_SRC bySource;
if (GetDefaultPictureStructDataBySrc((&bySource))) {
params->PictureModeData.display_mode = bySource.DisplayMode;
}
GAMMA_OFFSET_DATA wbGamma;
if (getDefaultWhiteBalanceGammaData(&wbGamma)) {
memcpy(&params->WBGammaData, &wbGamma.Gamma, sizeof(WB_GAMMA_TABLE_DATA));
}
TABLE_CMS Cms;
if (GetDefaultColorCustomizeData(&Cms)) {
for (int i = 0; i < VPP_COLOR_9_MAX; i++) {
params->color_tune.data[i].sat = Cms.CmsColor[i].sat;
params->color_tune.data[i].hue = Cms.CmsColor[i].hue;
params->color_tune.data[i].luma = Cms.CmsColor[i].luma;
}
}
return 0;
}
int CPQControl::FactoryCopyPictureModeDataFromPQMode(int picmode)
{
vpp_pictur_mode_para_t pData;
if (!GetPictureModeData(&pData, (vpp_picture_mode_t)picmode)) {
LOGE("%s, GetPictureModeData fail pq mode %d params\n", __FUNCTION__, picmode);
return -1;
}
if (!SetPictureModeData(&pData, (vpp_picture_mode_t)GetPQMode())) {
LOGE("%s, SetPictureModeData fail pq mode %d params\n", __FUNCTION__, picmode);
return -1;
}
if (SetPQPictureMode((vpp_picture_mode_t)picmode) < 0) {
LOGE("%s, SetPQPictureMode fail pq mode %d params\n", __FUNCTION__, picmode);
return -1;
}
return 0;
}
int CPQControl::FactoryCopyPictureModeDataToAllSource(void)
{
vpp_picture_mode_t picmode = (vpp_picture_mode_t)GetPQMode();
vpp_pictur_mode_para_t pData;
if (!GetPictureModeData(&pData, picmode)) {
LOGE("%s, GetPictureModeData fail pq mode %d params\n", __FUNCTION__, picmode);
return -1;
}
vpp_pictur_mode_para_t param;
for (int i = PQ_SRC_DEFAULT; i < PQ_SRC_MAX; i++) {
if (i != CurSource) {
if (GetPictureModeData((PICTURE_MODE_PARAM *)&param, (PICTURE_MODE)picmode, (pq_source_input_t)i, CurTimming)) {
if (!SetPictureModeData((PICTURE_MODE_PARAM *)&pData, (PICTURE_MODE)picmode, (pq_source_input_t)i, CurTimming)) {
LOGE("[%s] setPictureModeData src:%d, timing:%d mode %d failed", __FUNCTION__, i, CurTimming, picmode);
}
}
}
}
return 0;
}
int CPQControl::SetPQByPassLevel(int level)
{
LOGD("%s, level = %d\n",__FUNCTION__, level);
int ret = 0;
if (level > 0)
ret = pqWriteSys("/sys/class/amvecm/debug", "vpp_pq disable");
else
ret = pqWriteSys("/sys/class/amvecm/debug", "vpp_pq enable");
if (ret < 0) {
LOGD("%s, fail\n",__FUNCTION__);
return -1;
}
return 0;
}
int CPQControl::GetNonlinearOsdRemapVal(nonline_params_type_t type, int Value)
{
NonlinearModeType pData;
if (!GetNonlinearData(&pData)) {
LOGE("%s: GetNonlinearData fail\n", __FUNCTION__);
return -1;
}
if (Value < 0 || Value > 100) {
LOGE("%s: Invalid input value %d, must be between 0-100\n", __FUNCTION__, Value);
return -1;
}
int temp = 0;
unsigned char startPoint = 0, endPoint = 0;
unsigned char point0 = 0;
unsigned char point25 = 0;
unsigned char point50 = 0;
unsigned char point75 = 0;
unsigned char point100 = 0;
switch (type) {
case _BRIGHTNESS:
point0 = pData.Brightness_0;
point25 = pData.Brightness_25;
point50 = pData.Brightness_50;
point75 = pData.Brightness_75;
point100 = pData.Brightness_100;
break;
case _CONTRAST:
point0 = pData.Contrast_0;
point25 = pData.Contrast_25;
point50 = pData.Contrast_50;
point75 = pData.Contrast_75;
point100 = pData.Contrast_100;
break;
case _SATURATION:
point0 = pData.Saturation_0;
point25 = pData.Saturation_25;
point50 = pData.Saturation_50;
point75 = pData.Saturation_75;
point100 = pData.Saturation_100;
break;
case _HUE:
point0 = pData.Hue_0;
point25 = pData.Hue_25;
point50 = pData.Hue_50;
point75 = pData.Hue_75;
point100 = pData.Hue_100;
break;
case _SHARPNESS:
point0 = pData.Sharpness_0;
point25 = pData.Sharpness_25;
point50 = pData.Sharpness_50;
point75 = pData.Sharpness_75;
point100 = pData.Sharpness_100;
break;
case _BACKLIGHT:
point0 = pData.Backlight_0;
point25 = pData.Backlight_25;
point50 = pData.Backlight_50;
point75 = pData.Backlight_75;
point100 = pData.Backlight_100;
break;
default:
break;
}
if (point0 > 255 || point25 > 255 || point50 > 255 || point75 > 255 || point100 > 255) {
LOGE("%s: Invalid data points detected, using default linear mapping\n", __FUNCTION__);
return (point100 * Value) / 100;
}
if (Value < 25) {
startPoint = point0;
endPoint = point25;
temp = Value;
} else if (Value < 50) {
startPoint = point25;
endPoint = point50;
temp = Value - 25;
} else if (Value < 75) {
startPoint = point50;
endPoint = point75;
temp = Value - 50;
} else {
startPoint = point75;
endPoint = point100;
temp = Value - 75;
}
if (endPoint >= startPoint) {
int64_t diff = static_cast<int64_t>(endPoint) - static_cast<int64_t>(startPoint);
int64_t calculation = diff * temp / 25;
temp = static_cast<int>(calculation) + startPoint;
} else {
int64_t diff = static_cast<int64_t>(startPoint) - static_cast<int64_t>(endPoint);
int64_t calculation = diff * temp / 25;
if (calculation > startPoint) {
temp = 0;
} else {
temp = startPoint - static_cast<int>(calculation);
}
}
if (temp < 0) {
LOGE("%s: Clamping negative result to 0\n", __FUNCTION__);
temp = 0;
} else if (temp > 255) {
LOGE("%s: Clamping excessive result to 255\n", __FUNCTION__);
temp = 255;
}
return temp;
}
bool CPQControl::SetPictureMode(vpp_picture_mode_t PictureMode)
{
PICTURE_MODE_DEFAULT params;
if (getPictureMode(&params) != true) {
LOGE("%s: getPictureMode fail \n", __FUNCTION__);
return false;
}
switch (mCurrentHdrType) {
case HDRTYPE_DOVI:
params.Picture_DOLVI = PictureMode;
break;
case HDRTYPE_HDR10:
params.Picture_HDR = PictureMode;
break;
case HDRTYPE_HDR10PLUS:
params.Picture_HDRP = PictureMode;
break;
case HDRTYPE_HLG:
params.Picture_HLG = PictureMode;
break;
case HDRTYPE_SDR:
params.Picture = PictureMode;
break;
default:
params.Picture = PictureMode;
break;
}
if (setPictureMode(&params) != true) {
LOGE("%s: setPictureMode fail \n", __FUNCTION__);
return false;
}
return true;
}
bool CPQControl::GetPictureMode(vpp_picture_mode_t *PictureMode)
{
PICTURE_MODE_DEFAULT params;
if (getPictureMode(&params) != true) {
LOGE("%s: getPictureMode fail \n", __FUNCTION__);
return false;
}
switch (mCurrentHdrType) {
case HDRTYPE_DOVI:
*PictureMode = (vpp_picture_mode_t)params.Picture_DOLVI;
break;
case HDRTYPE_HDR10:
*PictureMode = (vpp_picture_mode_t)params.Picture_HDR;
break;
case HDRTYPE_HDR10PLUS:
*PictureMode = (vpp_picture_mode_t)params.Picture_HDRP;
break;
case HDRTYPE_HLG:
*PictureMode = (vpp_picture_mode_t)params.Picture_HLG;
break;
case HDRTYPE_SDR:
*PictureMode = (vpp_picture_mode_t)params.Picture;
break;
default:
*PictureMode = (vpp_picture_mode_t)params.Picture;
break;
}
return true;
}
bool CPQControl::SetLastPictureMode(vpp_picture_mode_t PictureMode)
{
PICTURE_MODE_DEFAULT params;
if (getLastPictureMode(&params) != true) {
LOGE("%s: getLastPictureMode fail \n", __FUNCTION__);
return false;
}
switch (mCurrentHdrType) {
case HDRTYPE_DOVI:
params.Picture_DOLVI = PictureMode;
break;
case HDRTYPE_HDR10:
params.Picture_HDR = PictureMode;
break;
case HDRTYPE_HDR10PLUS:
params.Picture_HDRP = PictureMode;
break;
case HDRTYPE_HLG:
params.Picture_HLG = PictureMode;
break;
case HDRTYPE_SDR:
params.Picture = PictureMode;
break;
default:
params.Picture = PictureMode;
break;
}
if (setLastPictureMode(&params) != true) {
LOGE("%s: setLastPictureMode fail \n", __FUNCTION__);
return false;
}
return true;
}
bool CPQControl::GetLastPictureMode(vpp_picture_mode_t *PictureMode)
{
PICTURE_MODE_DEFAULT params;
if (getLastPictureMode(&params) != true) {
LOGE("%s: getLastPictureMode fail \n", __FUNCTION__);
return false;
}
switch (mCurrentHdrType) {
case HDRTYPE_DOVI:
*PictureMode = (vpp_picture_mode_t)params.Picture_DOLVI;
break;
case HDRTYPE_HDR10:
*PictureMode = (vpp_picture_mode_t)params.Picture_HDR;
break;
case HDRTYPE_HDR10PLUS:
*PictureMode = (vpp_picture_mode_t)params.Picture_HDRP;
break;
case HDRTYPE_HLG:
*PictureMode = (vpp_picture_mode_t)params.Picture_HLG;
break;
case HDRTYPE_SDR:
*PictureMode = (vpp_picture_mode_t)params.Picture;
break;
default:
*PictureMode = (vpp_picture_mode_t)params.Picture;
break;
}
return true;
}
bool CPQControl::SetPictureModeBySource(vpp_picture_mode_t PictureMode, int source, int timming)
{
PICTURE_MODE_DEFAULT params;
if (getPictureMode(&params, (pq_source_input_t)source, (pq_sig_fmt_t)timming) != true) {
LOGE("%s: GetPictureMode fail \n", __FUNCTION__);
return false;
}
switch (mCurrentHdrType) {
case HDRTYPE_DOVI:
params.Picture_DOLVI = PictureMode;
break;
case HDRTYPE_HDR10:
params.Picture_HDR = PictureMode;
break;
case HDRTYPE_HDR10PLUS:
params.Picture_HDRP = PictureMode;
break;
case HDRTYPE_HLG:
params.Picture_HLG = PictureMode;
break;
case HDRTYPE_SDR:
params.Picture = PictureMode;
break;
default:
params.Picture = PictureMode;
break;
}
if (setPictureMode(&params, (pq_source_input_t)source, (pq_sig_fmt_t)timming) != true) {
LOGE("%s: SetPictureMode fail \n", __FUNCTION__);
return false;
}
return true;
}
bool CPQControl::GetPictureModeBySource(vpp_picture_mode_t *PictureMode, int source, int timming)
{
PICTURE_MODE_DEFAULT params;
if (getPictureMode(&params, (pq_source_input_t)source, (pq_sig_fmt_t)timming) != true) {
LOGE("%s: GetPictureMode fail \n", __FUNCTION__);
return false;
}
switch (mCurrentHdrType) {
case HDRTYPE_DOVI:
*PictureMode = (vpp_picture_mode_t)params.Picture_DOLVI;
break;
case HDRTYPE_HDR10:
*PictureMode = (vpp_picture_mode_t)params.Picture_HDR;
break;
case HDRTYPE_HDR10PLUS:
*PictureMode = (vpp_picture_mode_t)params.Picture_HDRP;
break;
case HDRTYPE_HLG:
*PictureMode = (vpp_picture_mode_t)params.Picture_HLG;
break;
case HDRTYPE_SDR:
*PictureMode = (vpp_picture_mode_t)params.Picture;
break;
default:
*PictureMode = (vpp_picture_mode_t)params.Picture;
break;
}
return true;
}
bool CPQControl::SetColorTemperatureData(tcon_rgb_ogo_t *params, int level)
{
return setColorTemperatureData((COLORTEMP_DATA *)params, level);
}
bool CPQControl::GetColorTemperatureData(tcon_rgb_ogo_t *params, int level)
{
return getColorTemperatureData((COLORTEMP_DATA *)params, level);
}
bool CPQControl::SetColorTemperatureDataBySrcTimming(tcon_rgb_ogo_t *params, pq_source_input_t src, pq_sig_fmt_t timming, int level)
{
return setColorTemperatureData((COLORTEMP_DATA *)params, level, src, timming);
}
bool CPQControl::GetColorTemperatureDataBySrcTimming(tcon_rgb_ogo_t *params, pq_source_input_t src, pq_sig_fmt_t timming, int level)
{
return getColorTemperatureData((COLORTEMP_DATA *)params, level, src, timming);
}
bool CPQControl::SetWhitebalanceGammaData(WB_GAMMA_TABLE *params, int level)
{
return setWhiteBalanceGammaData((GAMMA_OFFSET_DATA *)params, level);
}
bool CPQControl::GetWhitebalanceGammaData(WB_GAMMA_TABLE *params, int level)
{
return getWhiteBalanceGammaData((GAMMA_OFFSET_DATA *)params, level);
}
bool CPQControl::SetColorCustomizeDataBy3Dlut(TABLE_CMS_3DLUT *params, vpp_picture_mode_t mode, pq_source_input_t source, pq_sig_fmt_t timming)
{
if (mSSMAction == NULL ) {
return false;
}
if (source == PQ_SRC_MAX)
source = CurSource;
if (timming == PQ_FMT_MAX)
timming = CurTimming;
if (mode == VPP_PICTURE_MODE_MAX)
mode = (vpp_picture_mode_t)GetPQMode();
return mSSMAction->SetColorCustomizeDataBy3DLut(params, (int)mode, (int)source, (int)timming);
}
bool CPQControl::GetColorCustomizeDataBy3Dlut(TABLE_CMS_3DLUT *params, vpp_picture_mode_t mode, pq_source_input_t source, pq_sig_fmt_t timming)
{
if (mSSMAction == NULL ) {
return false;
}
if (source == PQ_SRC_MAX)
source = CurSource;
if (timming == PQ_FMT_MAX)
timming = CurTimming;
if (mode == VPP_PICTURE_MODE_MAX)
mode = (vpp_picture_mode_t)GetPQMode();
if (mSSMAction->GetColorCustomizeDataBy3DLut(params, mode, source, timming)) {
return true;
}
if (mSSMAction->GetColorCustomizeDataBy3DLut(params, mode, PQ_SRC_DEFAULT, timming)) {
return true;
}
if (mSSMAction->GetColorCustomizeDataBy3DLut(params, mode, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
if (mSSMAction->GetColorCustomizeDataBy3DLut(params, VPP_PICTURE_MODE_STANDARD, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::ResetUserColorCustomizeDataBy3Dlut(vpp_picture_mode_t mode, pq_source_input_t source, pq_sig_fmt_t timming)
{
if (mSSMAction == NULL) {
return false;
}
if (source == PQ_SRC_MAX)
source = CurSource;
if (timming == PQ_FMT_MAX)
timming = CurTimming;
if (mode == VPP_PICTURE_MODE_MAX)
mode = (vpp_picture_mode_t)GetPQMode();
TABLE_CMS_3DLUT params;
if (mSSMAction->GetColorCustomizeDataBy3DLut(&params, mode, source, timming)) {
memset(&params, 0, sizeof(TABLE_CMS_3DLUT));
Cpq_GetColorCustomize3DlutDefValue(&params);
if (!mSSMAction->SetColorCustomizeDataBy3DLut(&params, (int)mode, (int)source, (int)timming)) {
LOGE("[%s] SetColorCustomizeDataBy3DLut src:%d, timing:%d, PictureMode:%d failed", __FUNCTION__, source, timming, mode);
return false;
}
LOGD("[%s] source:%d, timing:%d, PictureMode:%d Data Done!", __FUNCTION__, source, timming, mode);
}
return true;
}
bool CPQControl::ResetColorCustomizeDataBy3DlutAll(void)
{
LOGD("%s: start!\n", __FUNCTION__);
for (int i = 0; i < PQ_SRC_MAX; i++) {
for (int j = 0; j < PQ_FMT_MAX; j++) {
for (int l = 0; l < VPP_PICTURE_MODE_MAX; l++) {
ResetUserColorCustomizeDataBy3Dlut((vpp_picture_mode_t)l, (pq_source_input_t)i, (pq_sig_fmt_t)j);
}
}
}
LOGD("%s: done!\n", __FUNCTION__);
return true;
}
//CRI DATA
bool CPQControl::FactoryGetWhitebalanceRGBGainOffsetData(tcon_rgb_ogo_t *pData, int level)
{
if (mSSMAction == NULL ) {
return false;
}
return mSSMAction->CriDataGetWhitebalanceRGBGainOffsetData(pData, level);
}
bool CPQControl::FactorySetWhitebalanceRGBGainOffsetData(tcon_rgb_ogo_t *pData, int level)
{
if (mSSMAction == NULL ) {
return false;
}
return mSSMAction->CriDataSetWhitebalanceRGBGainOffsetData(pData, level);
}
bool CPQControl::CheckCriDataWhitebalanceRGBGainOffsetData(void)
{
tcon_rgb_ogo_t rgbogo;
int colortemp = GetColorTemperature();
if (!FactoryGetWhitebalanceRGBGainOffsetData(&rgbogo, colortemp)) {
for (int i = VPP_COLOR_TEMPERATURE_MODE_STANDARD; i < VPP_COLOR_TEMPERATURE_MODE_MAX; i++) {
if (i != VPP_COLOR_TEMPERATURE_MODE_USER) {
if (GetColorTemperatureData(&rgbogo, i)) {
if (!FactorySetWhitebalanceRGBGainOffsetData(&rgbogo, i)) {
LOGE("%s FactorySetWhitebalanceRGBGainOffsetData colortemp: %d fail\n", __FUNCTION__, i);
}
}
}
}
}
return true;
}
bool CPQControl::FactoryGetWhitebalanceGammaData(WB_GAMMA_TABLE_DATA *pData, int level)
{
return mSSMAction->CriDataGetWhitebalanceGammaData(pData, level, GetWbGammaMode());
}
bool CPQControl::FactorySetWhitebalanceGammaData(WB_GAMMA_TABLE_DATA *pData, int level)
{
return mSSMAction->CriDataSetWhitebalanceGammaData(pData, level, GetWbGammaMode());
}
bool CPQControl::CheckCriDataWhitebalanceGammaData(void)
{
WB_GAMMA_TABLE pData;
int mode = GetWbGammaMode();
if (!mSSMAction->CriDataGetWhitebalanceGammaData(&pData.WB_GAMMA_DATA, GetColorTemperature(), mode)) {
for (int i = VPP_COLOR_TEMPERATURE_MODE_STANDARD; i < VPP_COLOR_TEMPERATURE_MODE_MAX; i++) {
if (GetWhitebalanceGammaData(&pData, i)) {
if (!mSSMAction->CriDataSetWhitebalanceGammaData(&pData.WB_GAMMA_DATA, i, mode)) {
LOGD("%s: CriDataSetWhitebalanceGammaData fail level = %d\n", __FUNCTION__, i);
}
}
}
}
return true;
}
bool CPQControl::FactoryGetGammaDataTable(GAMMA_TABLE *pData, int level)
{
if (!mSSMAction->GetGammaDataTable(&pData->R, level, RED_CH)) {
return false;
}
if (!mSSMAction->GetGammaDataTable(&pData->G, level, GREEN_CH)) {
return false;
}
if (!mSSMAction->GetGammaDataTable(&pData->B, level, BLUE_CH)) {
return false;
}
return true;
}
bool CPQControl::FactorySetGammaDataTable(GAMMA_TABLE *pData, int level)
{
if (!mSSMAction->SetGammaDataTable(&pData->R, level, RED_CH)) {
return false;
}
if (!mSSMAction->SetGammaDataTable(&pData->G, level, GREEN_CH)) {
return false;
}
if (!mSSMAction->SetGammaDataTable(&pData->B, level, BLUE_CH)) {
return false;
}
return true;
}
//TV_PICTURE
bool CPQControl::setPictureMode(PICTURE_MODE_DEFAULT *params, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
return mDataBase->SetPictureMode(params, source, timming);
}
bool CPQControl::getPictureMode(PICTURE_MODE_DEFAULT *params, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (mDataBase->GetPictureMode(params, source, timming)) {
return true;
}
if (mDataBase->GetPictureMode(params, PQ_SRC_DEFAULT, timming)) {
return true;
}
if (mDataBase->GetPictureMode(params, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::getDefaultPictureMode(PICTURE_MODE_DEFAULT *params, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (mDataBase->GetDefaultPictureMode(params, source, timming)) {
return true;
}
if (mDataBase->GetDefaultPictureMode(params, PQ_SRC_DEFAULT, timming)) {
return true;
}
if (mDataBase->GetDefaultPictureMode(params, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::setLastPictureMode(PICTURE_MODE_DEFAULT *params, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
return mDataBase->SetLastPictureMode(params, source, timming);
}
bool CPQControl::getLastPictureMode(PICTURE_MODE_DEFAULT *params, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (mDataBase->GetLastPictureMode(params, source, timming)) {
return true;
}
if (mDataBase->GetLastPictureMode(params, PQ_SRC_DEFAULT, timming)) {
return true;
}
if (mDataBase->GetLastPictureMode(params, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::ResetUserPictureMode(int source, int timming)
{
if (mDataBase == NULL ) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
PICTURE_MODE_DEFAULT params;
if (mDataBase->GetPictureMode(&params, source, timming)) {
if (!getDefaultPictureMode(&params, source, timming)) {
SYS_LOGE("[%s] GetDefaultPictureModeType src: %d, timing: %d failed", __FUNCTION__, source, timming);
return false;
}
if (!setPictureMode(&params, source, timming)) {
SYS_LOGE("[%s] SetPictureMode src: %d, timing: %d failed", __FUNCTION__, source, timming);
return false;
}
SYS_LOGD("[%s] source:%d, timing:%d Data Done!", __FUNCTION__, source, timming);
}
return true;
}
bool CPQControl::ResetPictureModeBySrc(void)
{
SYS_LOGD("%s: start!\n", __FUNCTION__);
for (int j = 0; j < PQ_FMT_MAX; j++) {
ResetUserPictureMode(CurSource, j);
}
SYS_LOGD("%s: done!\n", __FUNCTION__);
return true;
}
bool CPQControl::ResetPictureModeAll(void)
{
SYS_LOGD("%s: start!\n", __FUNCTION__);
for (int i = 0; i < PQ_SRC_MAX; i++) {
for (int j = 0; j < PQ_FMT_MAX; j++) {
ResetUserPictureMode(i, j);
}
}
SYS_LOGD("%s: done!\n", __FUNCTION__);
return true;
}
bool CPQControl::SetPictureModeData(PICTURE_MODE_PARAM *params, int PictureMode, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (PictureMode == _CURRENT)
PictureMode = GetPQMode();
if (!mDataBase->SetPictureModeData(params, source, timming, PictureMode)) {
return false;
}
return true;
}
bool CPQControl::GetPictureModeData(PICTURE_MODE_PARAM *params, int PictureMode, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (PictureMode == _CURRENT)
PictureMode = GetPQMode();
if (mDataBase->GetPictureModeData(params, source, timming, PictureMode)) {
return true;
}
if (mDataBase->GetPictureModeData(params, PQ_SRC_DEFAULT, timming, PictureMode)) {
return true;
}
if (mDataBase->GetPictureModeData(params, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT, PictureMode)) {
return true;
}
return false;
}
bool CPQControl::GetDefaultPictureModeData(PICTURE_MODE_PARAM *params, int PictureMode, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (PictureMode == _CURRENT)
PictureMode = GetPQMode();
if (mDataBase->GetDefaultPictureModeData(params, source, timming, PictureMode)) {
return true;
}
if (mDataBase->GetDefaultPictureModeData(params, PQ_SRC_DEFAULT, timming, PictureMode)) {
return true;
}
if (mDataBase->GetDefaultPictureModeData(params, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT, PictureMode)) {
return true;
}
return false;
}
bool CPQControl::ResetUserPictureModeData(int mode, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (mode == _CURRENT)
mode = GetPQMode();
PICTURE_MODE_PARAM params;
if (mDataBase->GetPictureModeData(&params, source, timming, mode)) {
if (!GetDefaultPictureModeData(&params, mode, source, timming)) {
SYS_LOGE("[%s] GetDefaultPictureModeParam src:%d, timing:%d mode %d failed", __FUNCTION__, source, timming, mode);
return false;
}
if (!SetPictureModeData(&params, mode, source, timming)) {
SYS_LOGE("[%s] SetPictureModeData src:%d, timing:%d mode %d failed", __FUNCTION__, source, timming, mode);
return false;
}
}
return true;
}
bool CPQControl::ResetPictureModeDataBySrc(void)
{
SYS_LOGD("%s: start\n", __FUNCTION__);
for (int i = 0; i < PQ_FMT_MAX; i++) {
for (int j = 0; j < PICTURE_MODE_MAX; j++) {
ResetUserPictureModeData(j, CurSource, i);
}
}
SYS_LOGD("%s: done\n", __FUNCTION__);
return true;
}
bool CPQControl::ResetPictureModeDataAll(void)
{
SYS_LOGD("%s: start\n", __FUNCTION__);
for (int i = 0; i < PQ_SRC_MAX; i++) {
for (int j = 0; j < PQ_FMT_MAX; j++) {
for (int k = 0; k < PICTURE_MODE_MAX; k++) {
ResetUserPictureModeData(k, i, j);
}
}
}
SYS_LOGD("%s: done\n", __FUNCTION__);
return true;
}
bool CPQControl::SetNonlinearData(NonlinearModeType *params, int source, int timming)
{
if (mDataBase == NULL ) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
return mDataBase->SetNonlinearData(params, source, timming);
}
bool CPQControl::GetNonlinearData(NonlinearModeType *params, int source, int timming)
{
if (mDataBase == NULL ) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (mDataBase->GetNonlinearData(params, source, timming)) {
return true;
}
if (mDataBase->GetNonlinearData(params, PQ_SRC_DEFAULT, timming)) {
return true;
}
if (mDataBase->GetNonlinearData(params, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::GetDefaultNonlinearData(NonlinearModeType *params, int source, int timming)
{
if (mDataBase == NULL ) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (mDataBase->GetDefaultNonlinearData(params, source, timming)) {
return true;
}
if (mDataBase->GetDefaultNonlinearData(params, PQ_SRC_DEFAULT, timming)) {
return true;
}
if (mDataBase->GetDefaultNonlinearData(params, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::ResetUserNonlinearData(int source, int timming)
{
if (mDataBase == NULL ) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
NonlinearModeType params;
if (mDataBase->GetNonlinearData(&params, source, timming)) {
if (!GetDefaultNonlinearData(&params, source, timming)) {
SYS_LOGE("[%s] GetDefaultNonlinearData src:%d, timing:%d failed", __FUNCTION__, source, timming);
return false;
}
if (!SetNonlinearData(&params, source, timming)) {
SYS_LOGE("[%s] SetNonlinearData src:%d, timing:%d failed", __FUNCTION__, source, timming);
return false;
}
SYS_LOGD("[%s] source:%d, timing:%d Data Done!", __FUNCTION__, source, timming);
}
return true;
}
bool CPQControl::ResetNonlinearDataAll(void)
{
SYS_LOGD("%s: start!\n", __FUNCTION__);
for (int i = 0; i < PQ_SRC_MAX; i++) {
for (int j = 0; j < PQ_FMT_MAX; j++) {
ResetUserNonlinearData(i, j);
}
}
SYS_LOGD("%s: done!\n", __FUNCTION__);
return true;
}
bool CPQControl::setColorTemperatureData(COLORTEMP_DATA *params, int level, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (level == _CURRENT)
level = GetColorTemperature();
if (!mDataBase->SetColorTemperatureData(params, source, timming, level)) {
return false;
}
return true;
}
bool CPQControl::getColorTemperatureData(COLORTEMP_DATA *params, int level, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (level == _CURRENT)
level = GetColorTemperature();
if (mDataBase->GetColorTemperatureData(params, source, timming, level)) {
return true;
}
if (mDataBase->GetColorTemperatureData(params, PQ_SRC_DEFAULT, timming, level)) {
return true;
}
if (mDataBase->GetColorTemperatureData(params, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT, level)) {
return true;
}
return false;
}
bool CPQControl::getDefaultColorTemperatureData(COLORTEMP_DATA *params, int level, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (level == _CURRENT)
level = GetColorTemperature();
if (mDataBase->GetDefaultColorTemperatureData(params, source, timming, level)) {
return true;
}
if (mDataBase->GetDefaultColorTemperatureData(params, PQ_SRC_DEFAULT, timming, level)) {
return true;
}
if (mDataBase->GetDefaultColorTemperatureData(params, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT, level)) {
return true;
}
return false;
}
bool CPQControl::ResetUserColorTemperatureData(int level, int source , int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (level == _CURRENT)
level = GetColorTemperature();
COLORTEMP_DATA params;
if (mDataBase->GetColorTemperatureData(&params, source, timming, level)) {
if (!getDefaultColorTemperatureData(&params, level, source, timming)) {
SYS_LOGE("[%s] GetDefaultColorTemperatureData src:%d, timing:%d level %d failed", __FUNCTION__, source, timming, level);
return false;
}
if (!setColorTemperatureData(&params, level, source, timming)) {
SYS_LOGE("[%s] mDataBase->SetColorTemperatureData src:%d, timing:%d mode %d failed", __FUNCTION__, source, timming, level);
return false;
}
}
return true;
}
bool CPQControl::ResetColorTemperatureDataBySrc(void)
{
SYS_LOGD("%s: start\n", __FUNCTION__);
for (int j = 0; j < PQ_FMT_MAX; j++) {
for (int k = 0; k < COLOR_TMP_MODE_MAX; k++) {
ResetUserColorTemperatureData(k, CurSource, j);
}
}
SYS_LOGD("%s: done\n", __FUNCTION__);
return true;
}
bool CPQControl::ResetColorTemperatureDataAll(void)
{
SYS_LOGD("%s: start\n", __FUNCTION__);
for (int i = 0; i < PQ_SRC_MAX; i++) {
for (int j = 0; j < PQ_FMT_MAX; j++) {
for (int k = 0; k < VPP_COLOR_TEMPERATURE_MODE_MAX; k++) {
ResetUserColorTemperatureData(k, i, j);
}
}
}
SYS_LOGD("%s: done\n", __FUNCTION__);
return true;
}
bool CPQControl::setWhiteBalanceGammaData(GAMMA_OFFSET_DATA *params, int level, int mode, int source, int timming)
{
if (mDataBase == NULL ) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (level == _CURRENT)
level = GetColorTemperature();
if (mode == _CURRENT)
mode = GetWbGammaMode();
if (mDataBase->SetGammaOffsetData(params, level, mode, source, timming) == true) {
return true;
}
return false;
}
bool CPQControl::getWhiteBalanceGammaData(GAMMA_OFFSET_DATA *params, int level, int mode, int source, int timming)
{
if (mDataBase == NULL ) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (level == _CURRENT)
level = GetColorTemperature();
if (mode == _CURRENT)
mode = GetWbGammaMode();
if (mDataBase->GetGammaOffsetData(params, level, mode, source, timming)) {
return true;
}
if (mDataBase->GetGammaOffsetData(params, level, mode, PQ_SRC_DEFAULT, timming)) {
return true;
}
if (mDataBase->GetGammaOffsetData(params, level, mode, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
if (mDataBase->GetGammaOffsetData(params, level, WB_GAMMA_MODE_2POINT, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::getDefaultWhiteBalanceGammaData(GAMMA_OFFSET_DATA *params, int level, int mode, int source, int timming)
{
if (mDataBase == NULL ) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (level == _CURRENT)
level = GetColorTemperature();
if (mode == _CURRENT)
mode = GetWbGammaMode();
if (mDataBase->GetDefaultGammaOffsetData(params, level, mode, source, timming)) {
return true;
}
if (mDataBase->GetDefaultGammaOffsetData(params, level, mode, PQ_SRC_DEFAULT, timming)) {
return true;
}
if (mDataBase->GetDefaultGammaOffsetData(params, level, mode, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
if (mDataBase->GetDefaultGammaOffsetData(params, level, WB_GAMMA_MODE_2POINT, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::ResetUserWhiteBalanceGammaData(int level, int mode, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
GAMMA_OFFSET_DATA params;
if (mDataBase->GetGammaOffsetData(&params, level, mode, source, timming)) {
if (!getDefaultWhiteBalanceGammaData(&params, level, mode, source, timming)) {
SYS_LOGE("[%s] GetDefaultWhiteBalanceGammaData src:%d, timing:%d, ColorTemp:%d mode: %d failed",__FUNCTION__, source, timming, level, mode);
return false;
}
if (!setWhiteBalanceGammaData(&params, level, mode, source, timming)) {
SYS_LOGE("[%s] SetWhiteBalanceGammaData src:%d, timing:%d, ColorTemp:%d mode: %d failed",__FUNCTION__, source, timming, level, mode);
return false;
}
SYS_LOGD("[%s] source:%d, timing:%d, ColorTemp:%d mode: %d Data Done!", __FUNCTION__, source, timming, level, mode);
}
return true;
}
bool CPQControl::ResetWhiteBalanceGammaDataBySrc(void)
{
SYS_LOGD("%s: start!\n", __FUNCTION__);
for (int j = 0; j < PQ_FMT_MAX; j++) {
for (int k = 0; k < VPP_COLOR_TEMPERATURE_MODE_MAX; k++) {
for (int m = 0; m < WB_GAMMA_MODE_MAX; m++) {
ResetUserWhiteBalanceGammaData(k, m, CurSource, j);
}
}
}
SYS_LOGD("%s: done!\n", __FUNCTION__);
return true;
}
bool CPQControl::ResetWhiteBalanceGammaDataAll(void)
{
SYS_LOGD("%s: start!\n", __FUNCTION__);
for (int i = 0; i < PQ_SRC_MAX; i++) {
for (int j = 0; j < PQ_FMT_MAX; j++) {
for (int k = 0; k < COLOR_TMP_MODE_MAX; k++) {
for (int m = 0; m < WB_GAMMA_MODE_MAX; m++) {
ResetUserWhiteBalanceGammaData(k, m, i, j);
}
}
}
}
SYS_LOGD("%s: done!\n", __FUNCTION__);
return true;
}
bool CPQControl::SetColorCustomizeData(TABLE_CMS *params, int mode, int source, int timming)
{
if (mDataBase == NULL ) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (mode == _CURRENT)
mode = GetPQMode();
return mDataBase->SetColorCustomizeData(params, mode, source, timming);
}
bool CPQControl::GetColorCustomizeData(TABLE_CMS *params, int mode, int source, int timming)
{
if (mDataBase == NULL ) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (mode == _CURRENT)
mode = GetPQMode();
if (mDataBase->GetColorCustomizeData(params, mode, source, timming)) {
return true;
}
if (mDataBase->GetColorCustomizeData(params, mode, PQ_SRC_DEFAULT, timming)) {
return true;
}
if (mDataBase->GetColorCustomizeData(params, mode, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
if (mDataBase->GetColorCustomizeData(params, PICTURE_MODE_STANDARD, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::GetDefaultColorCustomizeData(TABLE_CMS *params, int mode, int source, int timming)
{
if (mDataBase == NULL ) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (mode == _CURRENT)
mode = GetPQMode();
if (mDataBase->GetDefaultColorCustomizeData(params, mode, source, timming)) {
return true;
}
if (mDataBase->GetDefaultColorCustomizeData(params, mode, PQ_SRC_DEFAULT, timming)) {
return true;
}
if (mDataBase->GetDefaultColorCustomizeData(params, mode, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
if (mDataBase->GetDefaultColorCustomizeData(params, PICTURE_MODE_STANDARD, PQ_SRC_DEFAULT, PQ_FMT_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::ResetUserColorCustomizeData(int mode, int source, int timming)
{
if (mDataBase == NULL) {
return false;
}
if (source == _CURRENT)
source = CurSource;
if (timming == _CURRENT)
timming = CurTimming;
if (mode == _CURRENT)
mode = GetPQMode();
TABLE_CMS params;
if (mDataBase->GetColorCustomizeData(&params, mode, source, timming)) {
if (!GetDefaultColorCustomizeData(&params, mode, source, timming)) {
SYS_LOGE("[%s] GetDefaultColorCustomizeData src:%d, timing:%d, PictureMode:%d failed",__FUNCTION__, source, timming, mode);
return false;
}
if (!SetColorCustomizeData(&params, mode, source, timming)) {
SYS_LOGE("[%s] SetColorCustomizeData src:%d, timing:%d, PictureMode:%d failed",__FUNCTION__, source, timming, mode);
return false;
}
SYS_LOGD("[%s] source:%d, timing:%d, PictureMode:%d Data Done!", __FUNCTION__, source, timming, mode);
}
return true;
}
bool CPQControl::ResetColorCustomizeDataBySrc(void)
{
SYS_LOGD("%s: start!\n", __FUNCTION__);
for (int j = 0; j < PQ_FMT_MAX; j++) {
for (int l = 0; l < PICTURE_MODE_MAX; l++) {
ResetUserColorCustomizeData(l, CurSource, j);
}
}
SYS_LOGD("%s: done!\n", __FUNCTION__);
return true;
}
bool CPQControl::ResetColorCustomizeDataAll(void)
{
SYS_LOGD("%s: start!\n", __FUNCTION__);
for (int i = 0; i < PQ_SRC_MAX; i++) {
for (int j = 0; j < PQ_FMT_MAX; j++) {
for (int l = 0; l < PICTURE_MODE_MAX; l++) {
ResetUserColorCustomizeData(l, i, j);
}
}
}
SYS_LOGD("%s: done!\n", __FUNCTION__);
return true;
}
bool CPQControl::SetPictureStructDataBySrc(PICTURE_SETTING_BY_SRC *params, int source)
{
if (mDataBase == NULL ) {
SYS_LOGE("[%s] mDataBase is NULL", __FUNCTION__);
return false;
}
if (source == _CURRENT)
source = CurSource;
return mDataBase->SetPictureStructDataBySrc(params, source);
}
bool CPQControl::GetPictureStructDataBySrc(PICTURE_SETTING_BY_SRC *params, int source)
{
if (mDataBase == NULL ) {
SYS_LOGE("[%s] mDataBase is NULL", __FUNCTION__);
return false;
}
if (source == _CURRENT)
source = CurSource;
if (mDataBase->GetPictureStructDataBySrc(params, source)) {
return true;
}
if (mDataBase->GetPictureStructDataBySrc(params, PQ_SRC_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::GetDefaultPictureStructDataBySrc(PICTURE_SETTING_BY_SRC *params, int source)
{
if (mDataBase == NULL ) {
SYS_LOGE("[%s] mDataBase is NULL", __FUNCTION__);
return false;
}
if (source == _CURRENT)
source = CurSource;
if (mDataBase->GetDefaultPictureStructDataBySrc(params, source)) {
return true;
}
if (mDataBase->GetDefaultPictureStructDataBySrc(params, PQ_SRC_DEFAULT)) {
return true;
}
return false;
}
bool CPQControl::ResetUserPictureStructDataBySrc(int source)
{
if (mDataBase == NULL ) {
SYS_LOGE("[%s] mDataBase is NULL", __FUNCTION__);
return false;
}
if (source == _CURRENT)
source = CurSource;
PICTURE_SETTING_BY_SRC params;
if (mDataBase->GetPictureStructDataBySrc(&params, source)) {
if (!GetDefaultPictureStructDataBySrc(&params, source)) {
SYS_LOGE("[%s] GetDefaultPictureStructDataBySrc src:%d failed", __FUNCTION__, source);
return false;
}
if (!SetPictureStructDataBySrc(&params, source)) {
SYS_LOGE("[%s] SetPictureStructDataBySrc src:%d failed", __FUNCTION__, source);
return false;
}
SYS_LOGD("[%s] source:%d Data Done!", __FUNCTION__, source);
}
return true;
}
bool CPQControl::ResetPictureStructDataBySrc(void)
{
return ResetUserPictureStructDataBySrc(CurSource);
}
bool CPQControl::ResetPictureStructDataBySrcAll(void)
{
SYS_LOGD("%s: start!\n", __FUNCTION__);
for (int i = 0; i < PQ_SRC_MAX; i++) {
ResetUserPictureStructDataBySrc(i);
}
SYS_LOGD("%s: done!\n", __FUNCTION__);
return true;
}
bool CPQControl::SetPictureStructDataGlobal(PICTURE_SETTING_GLOBAL *params)
{
if (mDataBase == NULL ) {
SYS_LOGE("[%s] mDataBase is NULL", __FUNCTION__);
return false;
}
return mDataBase->SetPictureStructDataGlobal(params);
}
bool CPQControl::GetPictureStructDataGlobal(PICTURE_SETTING_GLOBAL *params)
{
if (mDataBase == NULL ) {
SYS_LOGE("[%s] mDataBase is NULL", __FUNCTION__);
return false;
}
return mDataBase->GetPictureStructDataGlobal(params);
}
bool CPQControl::ResetPictureStructDataGlobal(void)
{
if (mDataBase == NULL ) {
SYS_LOGE("[%s] mDataBase is NULL", __FUNCTION__);
return false;
}
PICTURE_SETTING_GLOBAL params;
if (!mDataBase->GetDefaultPictureStructDataGlobal(&params)) {
SYS_LOGE("[%s] GetDefaultPictureStructDataGlobal failed", __FUNCTION__);
return false;
}
return mDataBase->SetPictureStructDataGlobal(&params);
}
//WHITE_BALANCE
bool CPQControl::factoryGetWhitebalanceRGBGainOffsetData(COLORTEMP_DATA *pData, int level)
{
if (mWBDataBase == NULL ) {
return false;
}
if (level == _CURRENT)
level = GetColorTemperature();
return mWBDataBase->GetRGBGainOffsetData(pData, level);
}
bool CPQControl::factorySetWhitebalanceRGBGainOffsetData(COLORTEMP_DATA *pData, int level)
{
if (mWBDataBase == NULL ) {
return false;
}
if (level == _CURRENT)
level = GetColorTemperature();
return mWBDataBase->SetRGBGainOffsetData(pData, level);
}
bool CPQControl::factoryGetMultipointGammaData(GAMMA_OFFSET_DATA *pData, int level, int mode)
{
if (mWBDataBase == NULL ) {
return false;
}
if (level == _CURRENT)
level = GetColorTemperature();
if (mode == _CURRENT)
mode = GetWbGammaMode();
return mWBDataBase->GetWhitebalanceGammaData(pData, level, mode);
}
bool CPQControl::factorySetMultipointGammaData(GAMMA_OFFSET_DATA *pData, int level, int mode)
{
if (mWBDataBase == NULL ) {
return false;
}
if (level == _CURRENT)
level = GetColorTemperature();
if (mode == _CURRENT)
mode = GetWbGammaMode();
return mWBDataBase->SetWhitebalanceGammaData(pData, level, mode);
}
bool CPQControl::factorySetGammaTableData(GAMMA_TABLE *pData, int level)
{
if (mWBDataBase == NULL ) {
return false;
}
if (!mWBDataBase->SetGammaTableData(&pData->R, level, RED_CH))
return false;
if (!mWBDataBase->SetGammaTableData(&pData->G, level, GREEN_CH))
return false;
if (!mWBDataBase->SetGammaTableData(&pData->B, level, BLUE_CH))
return false;
return true;
}
bool CPQControl::factoryGetGammaTableData(GAMMA_TABLE *pData, int level)
{
if (mWBDataBase == NULL ) {
return false;
}
if (!mWBDataBase->GetGammaTableData(&pData->R, level, RED_CH))
return false;
if (!mWBDataBase->GetGammaTableData(&pData->G, level, GREEN_CH))
return false;
if (!mWBDataBase->GetGammaTableData(&pData->B, level, BLUE_CH))
return false;
return true;
}