/*----------------------------------------------------------------------------*
 * No Warranty                                                                *
 * Except as may be otherwise agreed to in writing, no warranties of any      *
 * kind, whether express or implied, are given by MTK with respect to any MTK *
 * Deliverables or any use thereof, and MTK Deliverables are provided on an   *
 * "AS IS" basis.  MTK hereby expressly disclaims all such warranties,        *
 * including any implied warranties of merchantability, non-infringement and  *
 * fitness for a particular purpose and any warranties arising out of course  *
 * of performance, course of dealing or usage of trade.  Parties further      *
 * acknowledge that Company may, either presently and/or in the future,       *
 * instruct MTK to assist it in the development and the implementation, in    *
 * accordance with Company's designs, of certain softwares relating to        *
 * Company's product(s) (the "Services").  Except as may be otherwise agreed  *
 * to in writing, no warranties of any kind, whether express or implied, are  *
 * given by MTK with respect to the Services provided, and the Services are   *
 * provided on an "AS IS" basis.  Company further acknowledges that the       *
 * Services may contain errors, that testing is important and Company is      *
 * solely responsible for fully testing the Services and/or derivatives       *
 * thereof before they are used, sublicensed or distributed.  Should there be *
 * any third party action brought against MTK, arising out of or relating to  *
 * the Services, Company agree to fully indemnify and hold MTK harmless.      *
 * If the parties mutually agree to enter into or continue a business         *
 * relationship or other arrangement, the terms and conditions set forth      *
 * hereunder shall remain effective and, unless explicitly stated otherwise,  *
 * shall prevail in the event of a conflict in the terms in any agreements    *
 * entered into between the parties.                                          *
 *---------------------------------------------------------------------------*/

/*****************************************************************************
*  Uart : Maple PQ command
*****************************************************************************/
#define CC_CLI
#include "x_lint.h"

LINT_SAVE_AND_DISABLE

#ifdef __MW_CLI_DEF__
#include "x_mid_cli.h"
#else
#include "x_drv_cli.h"
#endif

#include "x_os.h"
#include "x_printf.h"
#include "x_stl_lib.h"
#include "drv_MapleApi.h"
#include "bepqapi.h"
#include "drv_tvd.h" 
#include "hw_tvd.h" 
#include "hw_tdsharp.h"
#include "mttype.h"
#include "bepqapi.h"

///////////extern //////////////
extern UINT8 u1ColorTransIdx_ext;
extern void vDrvSetPedestalMatrix(UINT8 bTransIndex);
extern UINT16 pPedestalMatrixISR[15];
extern UINT16 pPedestalMatrix[15];
extern UINT32 DEFAULT_XVYCC_MATRIX[9];
extern UINT8 u1PreMatrixtoOS;
extern void DRVCUST_GetDitherSetting(UINT8 bPath);
extern void DRVCUST_SetDitherSetting(UINT8 onoff,UINT8 u1DitherBLK,UINT8 u1DitherMode);
extern UINT32 u4xvYCCGmProgrmTbl_cust[4096];
extern UINT32 u4xvYCCAgmProgrmTbl_cust[4096];

//#define CC_MTK_AUTO_TEST 1   //test

static INT32 _i4MVIStartAddress(INT32 i4Argc, const CHAR ** szArgv)
{	
    UINT32 bMviAddress = 0;
	DRVCUST_GetModelVariationInfoStartAddress(&bMviAddress);
	Printf("MVI start address %x\n", bMviAddress);
#ifdef CC_MTK_AUTO_TEST
	if(bMviAddress == 0x10000)
	{
		Printf("PASS_cust_cli.sys.gmvia\n"); 
	}
#endif
	return 0;
}

SONY_BE_FUNC_T *iBeRegisterFunc=NULL;

static INT32 _i4RegisterBefun(INT32 i4Argc, const CHAR ** szArgv)
{
    //SONY_BE_FUNC_T *iBeRegisterFunc=NULL;
	if(iBeRegisterFunc)
	{
		Printf("do not do the _i4RegisterBefun again.\n");
#ifdef CC_MTK_AUTO_TEST
		Printf("PASS_cust_cli.sys.regbe\n");
#endif
		return 0;
	}
	else
	{
		iBeRegisterFunc = (SONY_BE_FUNC_T *)x_mem_alloc(sizeof(SONY_BE_FUNC_T));
	}
	if(iBeRegisterFunc!=NULL)//just for converity , this cmd is not right
	{
		x_memset(iBeRegisterFunc, 0, sizeof(SONY_BE_FUNC_T));

		//DRVCUST_RegisterBeFunc(iBeRegisterFunc);
		Printf("DRVCUST_RegisterBeFunc.\n");
#ifdef CC_MTK_AUTO_TEST
		Printf("PASS_cust_cli.sys.regbe\n");
#endif
	}
	return 0;
}

static INT32 _i4UnRegisterBefun(INT32 i4Argc, const CHAR ** szArgv)
{
	if(iBeRegisterFunc == NULL)
	{
		Printf("do not do UnDRVCUST_RegisterBeFunc again.\n");
	}
	else
	{
		//DRVCUST_DeregisterBeFunc();

		x_mem_free(iBeRegisterFunc);

		iBeRegisterFunc = NULL;
	}
#ifdef CC_MTK_AUTO_TEST
	Printf("PASS_cust_cli.sys.unregbe\n");
#endif
	return 0;
}

SONY_BE_GEN_FUNC_T* iGenBeRegisterFunc=NULL;

static INT32 _i4RegisterGeneralBefun(INT32 i4Argc, const CHAR ** szArgv)
{
	if(iGenBeRegisterFunc)
	{
		Printf("do not do the _i4RegisterGeneralBefun again.\n");
#ifdef CC_MTK_AUTO_TEST
		Printf("PASS_cust_cli.sys.reggbe\n");
#endif
		return 0;
	}
	iGenBeRegisterFunc = (SONY_BE_GEN_FUNC_T *)x_mem_alloc(sizeof(SONY_BE_GEN_FUNC_T));
	if(iGenBeRegisterFunc!=NULL)//just for converity , this cmd is not right
	{
		x_memset(iGenBeRegisterFunc, 0, sizeof(SONY_BE_GEN_FUNC_T));

		//DRVCUST_RegisterBeGeneralFunc(iGenBeRegisterFunc);
		Printf("DRVCUST_General_RegisterBeFunc.\n");
#ifdef CC_MTK_AUTO_TEST
		Printf("PASS_cust_cli.sys.reggbe\n");
#endif
	}
	return 0;
}


static INT32 _i4UnRegisterGeneralBefun(INT32 i4Argc, const CHAR ** szArgv)
{
	if(iGenBeRegisterFunc == NULL)
	{
		Printf("do not do the UnDRVCUST_RegisterBeGeneralFunc.\n");
	}
	else
	{
		//DRVCUST_DeregisterBeFunc();

		x_mem_free(iGenBeRegisterFunc);

		iGenBeRegisterFunc = NULL;
	}
#ifdef CC_MTK_AUTO_TEST
	Printf("PASS_cust_cli.sys.unreggbe\n");
#endif
	return 0;
}

SONY_PQ_FUNC_T* iPqRegisterFunc=NULL;

static INT32 _i4RegisterPqfun(INT32 i4Argc, const CHAR ** szArgv)
{
	if(iPqRegisterFunc)
	{
		Printf("do not do the _i4RegisterPqfun again.\n");
#ifdef CC_MTK_AUTO_TEST
		Printf("PASS_cust_cli.sys.regpq\n");
#endif
		return 0;
	}
	iPqRegisterFunc = (SONY_PQ_FUNC_T *)x_mem_alloc(sizeof(SONY_PQ_FUNC_T));
	if(iPqRegisterFunc!=NULL)//just for converity , this cmd is not right
	{
		x_memset(iPqRegisterFunc, 0, sizeof(SONY_PQ_FUNC_T));

		//DRVCUST_RegisterPqFunc(iPqRegisterFunc);
		Printf("DRVCUST_RegisterPqFunc.\n");
#ifdef CC_MTK_AUTO_TEST
		Printf("PASS_cust_cli.sys.regpq\n");
#endif
	}
	return 0;
}

static INT32 _i4UnRegisterPqfun(INT32 i4Argc, const CHAR ** szArgv)
{
	if(iPqRegisterFunc == NULL)
	{
		Printf("do not do the DRVCUST_DeregisterPqFunc.\n");
	}
	else
	{
		//DRVCUST_DeregisterPqFunc();

		x_mem_free(iPqRegisterFunc);

		iPqRegisterFunc = NULL;
	}
#ifdef CC_MTK_AUTO_TEST
	Printf("PASS_cust_cli.sys.unregpq\n");
#endif
	return 0;
}

SONY_PQ_GEN_FUNC_T* iGenPqRegisterFunc=NULL;

static INT32 _i4RegisterGeneralPqfun(INT32 i4Argc, const CHAR ** szArgv)
{
	if(iGenPqRegisterFunc)
	{
		Printf("do not do the _i4RegisterGeneralPqfun again.\n");
#ifdef CC_MTK_AUTO_TEST
		Printf("PASS_cust_cli.sys.reggpq\n");
#endif
		return 0;
	}
	iGenPqRegisterFunc = (SONY_PQ_GEN_FUNC_T *)x_mem_alloc(sizeof(SONY_PQ_GEN_FUNC_T));
	if(iGenPqRegisterFunc!=NULL)//just for converity , this cmd is not right
	{
		x_memset(iGenPqRegisterFunc, 0, sizeof(SONY_PQ_GEN_FUNC_T));

		//DRVCUST_RegisterPQGeneralFunc(iGenPqRegisterFunc);
		Printf("DRVCUST_RegisterPQGeneralFunc.\n");
#ifdef CC_MTK_AUTO_TEST
		Printf("PASS_cust_cli.sys.reggpq\n");
#endif
	}
	return 0;
}


static INT32 _i4UnRegisterGeneralPqfun(INT32 i4Argc, const CHAR ** szArgv)
{
	if(iGenPqRegisterFunc == NULL)
	{
		Printf("do not do the DRVCUST_DeRegisterPQGeneralFunc.\n");
	}
	else
	{
		//DRVCUST_DeRegisterPQGeneralFunc();

		x_mem_free(iGenPqRegisterFunc);

		iGenPqRegisterFunc = NULL;
	}
#ifdef CC_MTK_AUTO_TEST
	Printf("PASS_cust_cli.sys.unreggpq\n");
#endif
	return 0;
}

SONY_BE_EXT_FUNC_T* iBeExtRegisterFunc=NULL;

static INT32 _i4RegisterBeExtfun(INT32 i4Argc, const CHAR ** szArgv)
{
	if(iBeExtRegisterFunc)
	{
		Printf("do not do the DRVCUST_RegisterBeExtFunc again.\n");
#ifdef CC_MTK_AUTO_TEST
		Printf("PASS_cust_cli.sys.regbeext\n");
#endif
		return 0;
	}
	iBeExtRegisterFunc = (SONY_BE_EXT_FUNC_T *)x_mem_alloc(sizeof(SONY_BE_EXT_FUNC_T));
	if(iBeExtRegisterFunc!=NULL)//just for converity , this cmd is not right
	{
		x_memset(iBeExtRegisterFunc, 0, sizeof(SONY_BE_EXT_FUNC_T));

		//DRVCUST_RegisterBeExtFunc(iBeExtRegisterFunc);
		Printf("DRVCUST_RegisterBeExtFunc.\n");
#ifdef CC_MTK_AUTO_TEST
		Printf("PASS_cust_cli.sys.regbeext\n");
#endif
	}
	return 0;
}


static INT32 _i4UnRegisterBeExtfun(INT32 i4Argc, const CHAR ** szArgv)
{
	if(iBeExtRegisterFunc == NULL)
	{
		Printf("do not do the DRVCUST_DeRegisterBeExtFunc.\n");
	}
	else
	{
		//DRVCUST_DeRegisterBeExtFunc();

		x_mem_free(iBeExtRegisterFunc);

		iBeExtRegisterFunc = NULL;
	}
#ifdef CC_MTK_AUTO_TEST
	Printf("PASS_cust_cli.sys.unregbeext");
#endif
	return 0;
}

static INT32 _i4SetBeDeviceInfo(INT32 i4Argc, const CHAR ** szArgv)
{
	E_BE_DEVICE device = gBEDevice;
	UINT8 arPanelIDString_New_Recipe[16]={0};
	EEPROM_Read(0x10020, (UPTR)arPanelIDString_New_Recipe, 16);
	DRVCUST_SetBeDeviceInformation(device,arPanelIDString_New_Recipe,16);
	Printf("_i4SetBeDeviceInfo.\n");
#ifdef CC_MTK_AUTO_TEST
	Printf("PASS_cust_cli.sys.sbeinfo\n");
#endif
	return 0;
}

static INT32 _i4SetColorSystemInfo(INT32 i4Argc, const CHAR ** szArgv)
{
	Printf("_i4SetColorSystemInfo.\n");
	vDrvTvd3dSetColorSystem(0x8); //auto detect
#ifdef CC_MTK_AUTO_TEST
	int retFgHwTvdIsMMode = fgHwTvdIsMMode();
	Printf("retFgHwTvdIsMMode: %d\n", retFgHwTvdIsMMode);
	if(retFgHwTvdIsMMode == 0)
	{
		Printf("PASS_cust_cli.sys.scolor_sys\n");
	}
#endif
	return 0;
}

#ifdef CC_MTK_AUTO_TEST
extern UINT32 gBEErrorDetect;
#endif
static INT32 _i4SetBeDeviceErrorDetect(INT32 i4Argc, const CHAR ** szArgv)
{
    E_BE_ERROR_DETECT Efactor = E_CUST_ALL;

    UNUSED(Efactor);
    if(i4Argc !=2)
    {
        Printf("parameter not correct, data is letf shift value\n");
        Printf("0=E_CUST_TCON_ERR,1=E_CUST_P_ID_ERR,2=E_CUST_VLED_ERR,3=E_CUST_LD_ERR_ADC.\n");
        Printf("4=E_CUST_BACKLIGHT_ERR,5=E_CUST_SOFTWARE_ERR,6=E_CUST_EXT_FRC_ERR,7=E_CUST_4KPQ_I2C_ERROR.\n");
        Printf("8=E_CUST_8KBE_COM_ERR,9=E_CUST_FAN_ERR, 10=E_CUST_8KSHV_ERR\n");

        return 0;
    }

    if((StrToInt(szArgv[1]) <= 10) && (StrToInt(szArgv[1]) >= 0))
    {
        Efactor = (1 << (StrToInt(szArgv[1])));  //command is the first data = StrToInt(szArgv[0])
        DRVCUST_SetBeDeviceErrorDetect(Efactor);

        Printf("_i4SetBeDeviceErrorDetect: input id = %d, Efactor=0x%x.\n", StrToInt(szArgv[1]), Efactor);

        #ifdef CC_MTK_AUTO_TEST
        if(gBEErrorDetect & Efactor)
        {
            Printf("PASS_cust_cli.sys.sbeerr\n");
        }
        #endif
    }
    else
    {
        Printf("StrToInt(szArgv[1]) must <= 10 and > =0 :current input = %d.\n", StrToInt(szArgv[1]));

        #ifdef CC_MTK_AUTO_TEST
        Printf("FAIL_cust_cli.sys.sbeerr\n");
        #endif
    }

    return 0;
}

static INT32 _i4SetBeDeviceVersion(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1VersionInfoNo = 0;
	UINT8 *pVersion = NULL;
	u1VersionInfoNo = QueryBEDeviceVersionNum();
	pVersion = (UINT8*)x_mem_alloc(gBEVersionNum*20);
	if(pVersion)
	{
		DRV_CUST_SetBEDeviceVersion(u1VersionInfoNo,pVersion);
	}
	Printf("_i4SetBeDeviceErrorDetect:u1VersionInfoNo=%d.\n",u1VersionInfoNo);
#ifdef CC_MTK_AUTO_TEST
	Printf("PASS_cust_cli.sys.sbever\n");
#endif
	return 0;
}



static INT32 _i4GetMapleAPPicCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_PIC_SETTING_T pPictureSetting;

	DRVCUST_GetPictureSetting(&pPictureSetting);

	Printf("====== DRVCUST_GetPictureSetting ======\n"); 
    Printf("ePicMode            %d\n", pPictureSetting.ePicMode);                            
    Printf("u1Backlight         %d\n", pPictureSetting.u1Backlight);                                 
    Printf("u1Contrast          %d\n", pPictureSetting.u1Contrast);                                  
    Printf("u1Brightness        %d\n", pPictureSetting.u1Brightness);                                
    Printf("u1Color             %d\n", pPictureSetting.u1Color);                                     
    Printf("u1Hue               %d\n", pPictureSetting.u1Hue);                                       
    Printf("u1Sharpness         %d\n", pPictureSetting.u1Sharpness);                                 
    Printf("eColTmp             %d\n", pPictureSetting.eColTmp);                             
    Printf("eNoiseReduction     %d\n", pPictureSetting.eNoiseReduction);             
    Printf("eMpegNoiseReduction %d\n", pPictureSetting.eMpegNoiseReduction);     
	Printf("eRealityCreation	%d\n", pPictureSetting.eRealityCreation);                                 
    Printf("eMasteredIn4K       %d\n", pPictureSetting.eMasteredIn4K);                             
    Printf("i2Resolution	     %d\n", pPictureSetting.i2Resolution);             
    Printf("i2NoiseFiltering	 %d\n", pPictureSetting.i2NoiseFiltering);  
    Printf("eMotionFlow         %d\n", pPictureSetting.eMotionFlow);                     
	Printf("i2MotionFlowSmoothness	     %d\n", pPictureSetting.i2MotionFlowSmoothness);             
    Printf("i2MotionFlowClearness	 %d\n", pPictureSetting.i2MotionFlowClearness);  
    Printf("eFilmMode           %d\n", pPictureSetting.eFilmMode);                       
    Printf("eAdvContrastEnhancer    %d\n", pPictureSetting.eAdvContrastEnhancer);
    Printf("eBlackCorrector     %d\n", pPictureSetting.eBlackCorrector);             
    Printf("i2Gamma             %d\n", pPictureSetting.i2Gamma);    
	Printf("eLedDynamicCtrl     %d\n", pPictureSetting.eLedDynamicCtrl); 
    Printf("eLiveColor          %d\n", pPictureSetting.eLiveColor);                      
    Printf("i2RGain			    %d\n", pPictureSetting.i2RGain);     
	Printf("i2GGain			    %d\n", pPictureSetting.i2GGain);   
	Printf("i2RGain			    %d\n", pPictureSetting.i2BGain);   
	Printf("i2RBias			    %d\n", pPictureSetting.i2RBias);   
	Printf("i2GBias			    %d\n", pPictureSetting.i2GBias);   
	Printf("i2BBias			    %d\n", pPictureSetting.i2BBias);   
    Printf("eSpeedPreference    %d\n", pPictureSetting.eSpeedPreference);   
	Printf("eLedMotionMode   	%d\n", pPictureSetting.eLedMotionMode);
	Printf("eXdr			    %d\n", pPictureSetting.eXdr);   
    Printf("eDrange    			%d\n", pPictureSetting.eDrange);   
	Printf("eColorSpace   	%d\n", pPictureSetting.eColorSpace);
	Printf("eSmoothGradation   	%d\n", pPictureSetting.eSmoothGradation);
	Printf("eTransFunc   	%d\n", pPictureSetting.eTransFunc);
#ifdef CC_DRV_CUST_TONEMAP_TO_KO
    Printf("eToneMapInfo   	%d\n", pPictureSetting.eToneMapInfo);
#endif
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetPictureSetting_PASS\n");
	#endif
    return 0;

}

static INT32 _i4GetMapleColorSensorCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_COLOR_SENSOR_SETTING_T tmpColorSensorSetting;

	DRVCUST_GetColorSensorSetting(&tmpColorSensorSetting);

	Printf("====== DRVCUST_GetColorSensorSetting ======\n"); 
    Printf("eColorSensor               %d\n",  tmpColorSensorSetting.eColorSensor);                            
    Printf("eColorSensorLight          %d\n",  tmpColorSensorSetting.eColorSensorLight);                                 
    Printf("eColorSensorColor          %d\n",  tmpColorSensorSetting.eColorSensorColor);                                  
    Printf("eColorSensorGamma          %d\n",  tmpColorSensorSetting.eColorSensorGamma);                                
 
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetColorSensorSetting\n");
	#endif
    return 0;

}


static INT32 _i4GetMapleAPScreenCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_SCREEN_SETTING_T pScreenSetting;

	DRVCUST_GetScreenSetting(&pScreenSetting);

	Printf("====== DRVCUST_GetScreenSetting ======\n"); 
    Printf("eWideMode            %d\n", pScreenSetting.eWideMode);   
	Printf("eDisplayArea            %d\n", pScreenSetting.eDisplayArea);   
	Printf("i2HCenter            %d\n", pScreenSetting.i2HCenter);   
	Printf("i2VCenter            %d\n", pScreenSetting.i2VCenter);   
	Printf("i2VerticalSize            %d\n", pScreenSetting.i2VerticalSize);   
	Printf("eZoom            %d\n", pScreenSetting.eZoom);   
	Printf("ePcWIdeMode            %d\n", pScreenSetting.ePcWIdeMode);   
	Printf("i2PcPhase            %d\n", pScreenSetting.i2PcPhase);   
	Printf("i2PcPitch            %d\n", pScreenSetting.i2PcPitch);   
	Printf("i2PcHCenter            %d\n", pScreenSetting.i2PcHCenter);   
	Printf("i2PcVCenter            %d\n", pScreenSetting.i2PcVCenter);  
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetScreenSetting_PASS\n");
	#endif

    return 0;

}

static INT32 _i4GetMapleAP3DCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_3D_SETTING_T p3DSetting;

	DRVCUST_Get3DSetting(&p3DSetting);

	Printf("====== DRVCUST_Get3DSetting ======\n"); 
    Printf("e3dDisplay            %d\n", p3DSetting.e3dDisplay);   
	Printf("i23dDepthAdjustment            %d\n", p3DSetting.i23dDepthAdjustment);   
	Printf("e3dGlassBrightness            %d\n", p3DSetting.e3dGlassBrightness);
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_Get3DSetting_PASS\n");
	#endif

    return 0;

}

static INT32 _i4GetMapleAPECOCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_ECO_SETTING_T pEcoSetting;

	DRVCUST_GetEcoSetting(&pEcoSetting);

	Printf("====== DRVCUST_GetEcoSetting ======\n"); 
    Printf("ePowerSaving            %d\n", pEcoSetting.ePowerSaving);   
	Printf("eLightSensor            %d\n", pEcoSetting.eLightSensor); 
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetEcoSetting_PASS\n");
	#endif

    return 0;

}

static INT32 _i4GetMapleDemoModeCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_DEMO_MODE_T pDemoMode;

	DRVCUST_GetDemoMode(&pDemoMode);

	Printf("====== DRVCUST_GetDemoMode ======\n"); 
    Printf("eDemoMode            %d\n", pDemoMode.eDemoMode);   
	Printf("eDemoPattern            %d\n", pDemoMode.eDemoPattern);   
	Printf("u4DemoOption            %d\n", pDemoMode.u4DemoOption); 
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetDemoMode_PASS\n");
	#endif

    return 0;

}

static INT32 _i4GetMapleDemoOSDMaskCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_DEMO_OSD_MASK_T pOsdMask;
	UINT32 i;

	DRVCUST_GetDemoOsdMaskArea(&pOsdMask);

    Printf("====== DRVCUST_GetDemoOsdMaskArea ======\n"); 
    Printf("u1Num            %d\n", pOsdMask.u1Num);
	for(i = 0; i < 8; i++)
	{
		Printf("rectArea[%d] u2X           %d\n", i, pOsdMask.rectArea[i].u2X);  
		Printf("rectArea[%d] u2Y           %d\n", i, pOsdMask.rectArea[i].u2Y); 
		Printf("rectArea[%d] u2Width       %d\n", i, pOsdMask.rectArea[i].u2Width); 
		Printf("rectArea[%d] u2Height      %d\n", i, pOsdMask.rectArea[i].u2Height); 
	}
	Printf("b4KCoordinate            %d\n", pOsdMask.b4KCoordinate);
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetDemoOsdMaskArea_PASS\n");
	#endif

    return 0;

}


static INT32 _i4GetMapleServiceWBCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_SERVICE_SETTING_T pServiceSetting;

	DRVCUST_GetServiceSetting(&pServiceSetting);

	Printf("====== DRVCUST_GetServiceSetting ======\n"); 
    Printf("u2RGain            %d\n", pServiceSetting.u2RGain);
	Printf("u2GGain            %d\n", pServiceSetting.u2GGain);
	Printf("u2BGain            %d\n", pServiceSetting.u2BGain);
	Printf("u2ROffset            %d\n", pServiceSetting.u2ROffset);
	Printf("u2GOffset            %d\n", pServiceSetting.u2GOffset);
	Printf("u2BOffset            %d\n", pServiceSetting.u2BOffset);

    return 0;

}


static INT32 _i4GetMapleServiceTransCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_SERVICE_TRANS_T pServiceTrans;

	DRVCUST_GetServiceTransferSetting(&pServiceTrans);

	Printf("====== DRVCUST_GetServiceTransferSetting ======\n"); 
    Printf("eWBTransferMode            %d\n", pServiceTrans.eWBTransferMode);
	Printf("eMuraTransferMode            %d\n", pServiceTrans.eMuraTransferMode);
	Printf("eCUCTransferMode            %d\n", pServiceTrans.eCUCTransferMode);
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetServiceTransferSetting_PASS\n");
	#endif
    return 0;

}


static INT32 _i4GetMapleServiceVcomCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_SERVICE_VCOM_T pServiceVcom;

	DRVCUST_GetServiceVcomAdjust(&pServiceVcom);

	Printf("====== DEBUG_GetServiceSetting ======\n"); 
    Printf("bMode            %d\n", pServiceVcom.bMode);
	Printf("u2Data            %d\n", pServiceVcom.u2Data);
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetServiceVcomAdjust_PASS\n");
	#endif

    return 0;

}

static INT32 _i4GetMapleUiInputCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	E_CUST_UI_INPUT_TARGET eUiInput;
	
	eUiInput = DRVCUST_GetUiInputTarget();

	Printf("====== DRVCUST_GetUiInputTarget ======\n"); 
    Printf("eUiInput            %d\n", eUiInput);
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetUiInputTarget_PASS\n");
	#endif

    return 0;

}

static INT32 _i4GetMapleAPWBOffsetCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_WB_OFFSET_T pWbOffset;

	DRVCUST_GetWhiteBalanceOffset(&pWbOffset);

	Printf("====== DRVCUST_GetWhiteBalanceOffset ======\n"); 
    Printf("i2ROffset1            %d\n", pWbOffset.i2ROffset1);
	Printf("i2ROffset2            %d\n", pWbOffset.i2ROffset2);
	Printf("i2ROffset3            %d\n", pWbOffset.i2ROffset3);
	Printf("i2ROffset4            %d\n", pWbOffset.i2ROffset4);
	Printf("i2ROffset5            %d\n", pWbOffset.i2ROffset5);
	Printf("i2ROffset6            %d\n", pWbOffset.i2ROffset6);
	Printf("i2ROffset7            %d\n", pWbOffset.i2ROffset7);
	Printf("i2ROffset8            %d\n", pWbOffset.i2ROffset8);
	Printf("i2ROffset9            %d\n", pWbOffset.i2ROffset9);
	Printf("i2ROffset10            %d\n", pWbOffset.i2ROffset10);

	Printf("i2ROffset11            %d\n", pWbOffset.i2ROffset11);
	Printf("i2ROffset12            %d\n", pWbOffset.i2ROffset12);
	Printf("i2ROffset13            %d\n", pWbOffset.i2ROffset13);
	Printf("i2ROffset14            %d\n", pWbOffset.i2ROffset14);
	Printf("i2ROffset15            %d\n", pWbOffset.i2ROffset15);
	Printf("i2ROffset16            %d\n", pWbOffset.i2ROffset16);
	Printf("i2ROffset17            %d\n", pWbOffset.i2ROffset17);
	Printf("i2ROffset18            %d\n", pWbOffset.i2ROffset18);
	Printf("i2ROffset19            %d\n", pWbOffset.i2ROffset19);
	Printf("i2ROffset20            %d\n", pWbOffset.i2ROffset20);

	
	
	Printf("i2GOffset1            %d\n", pWbOffset.i2GOffset1);
	Printf("i2GOffset2            %d\n", pWbOffset.i2GOffset2);
	Printf("i2GOffset3            %d\n", pWbOffset.i2GOffset3);
	Printf("i2GOffset4            %d\n", pWbOffset.i2GOffset4);
	Printf("i2GOffset5            %d\n", pWbOffset.i2GOffset5);
	Printf("i2GOffset6            %d\n", pWbOffset.i2GOffset6);
	Printf("i2GOffset7            %d\n", pWbOffset.i2GOffset7);
	Printf("i2GOffset8            %d\n", pWbOffset.i2GOffset8);
	Printf("i2GOffset9            %d\n", pWbOffset.i2GOffset9);
	Printf("i2GOffset10            %d\n", pWbOffset.i2GOffset10);

	Printf("i2GOffset11            %d\n", pWbOffset.i2GOffset11);
	Printf("i2GOffset12            %d\n", pWbOffset.i2GOffset12);
	Printf("i2GOffset13            %d\n", pWbOffset.i2GOffset13);
	Printf("i2GOffset14            %d\n", pWbOffset.i2GOffset14);
	Printf("i2GOffset15            %d\n", pWbOffset.i2GOffset15);
	Printf("i2GOffset16            %d\n", pWbOffset.i2GOffset16);
	Printf("i2GOffset17            %d\n", pWbOffset.i2GOffset17);
	Printf("i2GOffset18            %d\n", pWbOffset.i2GOffset18);
	Printf("i2GOffset19            %d\n", pWbOffset.i2GOffset19);
	Printf("i2GOffset20            %d\n", pWbOffset.i2GOffset20);

	
	Printf("i2BOffset1            %d\n", pWbOffset.i2BOffset1);
	Printf("i2BOffset2            %d\n", pWbOffset.i2BOffset2);
	Printf("i2BOffset3            %d\n", pWbOffset.i2BOffset3);
	Printf("i2BOffset4            %d\n", pWbOffset.i2BOffset4);
	Printf("i2BOffset5            %d\n", pWbOffset.i2BOffset5);
	Printf("i2BOffset6            %d\n", pWbOffset.i2BOffset6);
	Printf("i2BOffset7            %d\n", pWbOffset.i2BOffset7);
	Printf("i2BOffset8            %d\n", pWbOffset.i2BOffset8);
	Printf("i2BOffset9            %d\n", pWbOffset.i2BOffset9);
	Printf("i2BOffset10            %d\n", pWbOffset.i2BOffset10);

	Printf("i2BOffset11            %d\n", pWbOffset.i2BOffset11);
	Printf("i2BOffset12            %d\n", pWbOffset.i2BOffset12);
	Printf("i2BOffset13            %d\n", pWbOffset.i2BOffset13);
	Printf("i2BOffset14            %d\n", pWbOffset.i2BOffset14);
	Printf("i2BOffset15            %d\n", pWbOffset.i2BOffset15);
	Printf("i2BOffset16            %d\n", pWbOffset.i2BOffset16);
	Printf("i2BOffset17            %d\n", pWbOffset.i2BOffset17);
	Printf("i2BOffset18            %d\n", pWbOffset.i2BOffset18);
	Printf("i2BOffset19            %d\n", pWbOffset.i2BOffset19);
	Printf("i2BOffset20            %d\n", pWbOffset.i2BOffset20);
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetWhiteBalanceOffset_PASS\n");
	#endif

    return 0;

}

static INT32 _i4GetMapleAPBTCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_BT_SETTING_T pBtSetting;

	DRVCUST_GetBTSetting(&pBtSetting);

	Printf("====== DRVCUST_GetBTSetting ======\n"); 
    Printf("bDelayMode            %d\n", pBtSetting.eDelayMode);
#ifdef CC_MTK_AUTO_TEST
	if(pBtSetting.eDelayMode == 0)
	{
		Printf("PASS_cust_cli.ap.bt\n");
	}
#endif
    return 0;

}

static INT32 _i4GetColoerAdjust(INT32 i4Argc, const CHAR ** szArgv)
{

	CUST_COLOR_ADJUST_T ColorAdjust;

	DRVCUST_GetColorAdjust(&ColorAdjust);
	Printf("bufColorAdjust.i2RHue=%d\n",ColorAdjust.i2RHue);
	Printf("bufColorAdjust.i2RSaturation=%d\n",ColorAdjust.i2RSaturation);
	Printf("bufColorAdjust.i2RBrightness=%d\n",ColorAdjust.i2RBrightness);
	Printf("bufColorAdjust.i2YeHue=%d\n",ColorAdjust.i2YeHue);
	Printf("bufColorAdjust.i2YeSaturation=%d\n",ColorAdjust.i2YeSaturation);
	Printf("bufColorAdjust.i2YeBrightness=%d\n",ColorAdjust.i2YeBrightness);
	Printf("bufColorAdjust.i2GHue=%d\n",ColorAdjust.i2GHue);
	Printf("bufColorAdjust.i2GSaturation=%d\n",ColorAdjust.i2GSaturation);
	Printf("bufColorAdjust.i2GBrightness=%d\n",ColorAdjust.i2GBrightness);
	Printf("bufColorAdjust.i2CyHue=%d\n",ColorAdjust.i2CyHue);
	Printf("bufColorAdjust.i2CySaturation=%d\n",ColorAdjust.i2CySaturation);
	Printf("bufColorAdjust.i2CyBrightness=%d\n",ColorAdjust.i2CyBrightness);
	Printf("bufColorAdjust.i2BHue=%d\n",ColorAdjust.i2BHue);
	Printf("bufColorAdjust.i2BSaturation=%d\n",ColorAdjust.i2BSaturation);
	Printf("bufColorAdjust.i2BBrightness=%d\n",ColorAdjust.i2BBrightness);
	Printf("bufColorAdjust.i2MgHue=%d\n",ColorAdjust.i2MgHue);
	Printf("bufColorAdjust.i2MgSaturation=%d\n",ColorAdjust.i2MgSaturation);
	Printf("bufColorAdjust.i2MgBrightness=%d\n",ColorAdjust.i2MgBrightness);
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetColorAdjust_PASS\n");
	#endif
    return 0;

}

static INT32 _i4GetWbOfst20PEn(INT32 i4Argc, const CHAR ** szArgv)
{

	CUST_WB_OFFSET_20P_EN_T WbOffset20Pen;

	DRVCUST_GetWhiteBalanceOffset20pEnable(&WbOffset20Pen);
	Printf("WbOffset20Pen.eWbOfst20pEn=%d\n",WbOffset20Pen.eWbOfst20pEn);
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetWhiteBalanceOffset20pEnable_PASS\n");
	#endif
    return 0;

}
static INT32 _i4SetWbOfst20PEn(INT32 i4Argc, const CHAR ** szArgv)
{
	EXTERN CUST_WB_OFFSET_20P_EN_T bufWB_OFFSET_20P_EN ;
	
	if ((i4Argc != 2))
	{
		Printf("need to set En [0/1]: %s \n", szArgv[0]);
		return 0;
	}

	bufWB_OFFSET_20P_EN.eWbOfst20pEn= (E_CUST_WB_OFFSET_20P)StrToInt(szArgv[1]);
	DRVCUST_SetWhiteBalanceOffset20pEnable(&bufWB_OFFSET_20P_EN);

	return 0;
}

static INT32 _i4GetDither(INT32 i4Argc, const CHAR ** szArgv)
{
	if((i4Argc !=1))
	{
		Printf("[Usage]Get Dither setting , no need param\n");
		return 0;
	}
	DRVCUST_GetDitherSetting(SV_VP_MAIN);

    return 0;
}
static INT32 _i4SetDither(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 onoff;
	UINT8 u1DitherBLK;
	UINT8 u1DitherMode;

	if((i4Argc !=4))
	{
		Printf("[Usage] OnOff, Blk , Mode\n");
		Printf("\n\nBlock:\n\n");
		Printf("0:E_CUST_DITHER_BLOCK_CCIR0\n");
		Printf("1:E_CUST_DITHER_BLOCK_CCIR1\n");
		Printf("2:E_CUST_DITHER_BLOCK_OSTG0\n");
		Printf("3:E_CUST_DITHER_BLOCK_OSTG1\n");
		Printf("4:E_CUST_DITHER_BLOCK_OSTG_POST0\n");
		Printf("5:E_CUST_DITHER_BLOCK_OSTG_POST1\n");
		Printf("\n\nMode:\n\n");
		Printf("0:E_DITHER_MODE_DISABLE\n");
		Printf("1:E_DITHER_MODE_ENABLE_12BIT\n");
		Printf("2:E_DITHER_MODE_ENABLE_10BIT\n");
		Printf("3:E_DITHER_MODE_ENABLE_8BIT\n");
		Printf("4:E_DITHER_MODE_ENABLE_6BIT\n");
		return 0;
	}
	onoff = StrToInt(szArgv[1]);
	u1DitherBLK = StrToInt(szArgv[2]);
	u1DitherMode = StrToInt(szArgv[3]);
    DRVCUST_SetDitherSetting( onoff, u1DitherBLK, u1DitherMode);
    return 0;
}


CLI_EXEC_T arCmdMapleDitehrTbl[] = {
	{"Ditehr info ", "d",    _i4GetDither,     NULL,   "Get Dither info",  CLI_GUEST}, 
	{"Ditehr set ", "set",    _i4SetDither,     NULL,   "Set Dither info",  CLI_GUEST}, 
	{NULL, NULL, NULL, NULL, NULL, CLI_SUPERVISOR}
};


CLI_EXEC_T arCmdMapleAPTbl[] = {
    {"Picture info", "pic",    _i4GetMapleAPPicCmd,     NULL,   "Picture Menu information",  CLI_GUEST}, 
	{"Screen info", "screen",    _i4GetMapleAPScreenCmd,     NULL,   "Screen Menu information",  CLI_GUEST}, 
	{"3D info", "3d",    _i4GetMapleAP3DCmd,     NULL,   "3D Menu information",  CLI_GUEST}, 
	{"ECO info", "eco",    _i4GetMapleAPECOCmd,     NULL,   "ECO Menu information",  CLI_GUEST}, 
	{"Demo mode info", "demo",    _i4GetMapleDemoModeCmd,     NULL,   "Demo mode information",  CLI_GUEST},
	{"Demo OSD mask", "mask",    _i4GetMapleDemoOSDMaskCmd,     NULL,   "Demo OSD mask information",  CLI_GUEST},
	{"Service WB", "swb",    _i4GetMapleServiceWBCmd,     NULL,   "Service WB adjustment",  CLI_GUEST},
	{"Service tran", "tran",    _i4GetMapleServiceTransCmd,     NULL,   "Service trans",  CLI_GUEST},
	{"Service Vcom", "vcom",    _i4GetMapleServiceVcomCmd,     NULL,   "Service Vcom",  CLI_GUEST},
	{"UI Input", "input",    _i4GetMapleUiInputCmd,     NULL,   "UI Input",  CLI_GUEST},
	{"WB Offset", "wbofst",    _i4GetMapleAPWBOffsetCmd,     NULL,   "WB Offset ",  CLI_GUEST},
	{"BT setting", "bt",    _i4GetMapleAPBTCmd,     NULL,   "BT setting",  CLI_GUEST},
	{"GetColorAdjust", "cadj",  _i4GetColoerAdjust, NULL,   "GetColorAdjust",    CLI_GUEST},
	{"GetWbOfst20PEn", "20en",  _i4GetWbOfst20PEn, NULL,   "GetWbOfst20PEn",    CLI_GUEST},
	{"SetWbOfst20PEn", "20enset",  _i4SetWbOfst20PEn, NULL,   "SetWbOfst20PEn",    CLI_GUEST},
	{"GetColSens", "colsens",  _i4GetMapleColorSensorCmd, NULL,   "GetColSens",    CLI_GUEST},
    {NULL, NULL, NULL, NULL, NULL, CLI_SUPERVISOR}
};


static INT32 _i4SetMapleSysInputCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    DRV_AP_INPUT_TYPE_T rApInpSrcInfo;
    UINT32 u4Path = StrToInt(szArgv[1]);

    if ((i4Argc != 2) || (u4Path > 1))
    {
        Printf("Usage: %s \n", szArgv[0]);
        Printf("Main or Sub\n");
        Printf("0: Main\n");
        Printf("1: Sub\n");
        return 0;
    }
    rApInpSrcInfo.eMainInputType = D_AP_INPUT_TYPE_APPLICATION;
    rApInpSrcInfo.eSubInputType = D_AP_INPUT_TYPE_APPLICATION;

    BEPQ_AP_Set_Input_Type(rApInpSrcInfo);

    Printf("====== SetInputType to MMP======\n"); 
    return 0;
}

static INT32 _i4GetMapleSysInputCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    E_CUST_INPUT_TYPE tmp ;
    UINT32 u4Path = StrToInt(szArgv[1]);

    if ((i4Argc != 2) || (u4Path > 1))
    {
        Printf("Usage: %s \n", szArgv[0]);
        Printf("Main or Sub\n");
        Printf("0: Main\n");
        Printf("1: Sub\n");
        return 0;
    }

    tmp = BEPQ_AP_Get_Input_Type((UINT8)u4Path);

    Printf("====== BEPQ_AP_Get_Input_Type: %d ======\n", tmp); 
#ifdef CC_MTK_AUTO_TEST
    if(tmp == D_AP_INPUT_TYPE_APPLICATION)
    {
        Printf("PASS_InputType\n");
    }
#endif

    return 0;
}

static INT32 _i4GetMapleSysSigFmtCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    CUST_SIG_FMT_T pSignalFormat;

    UINT32 u4Path = StrToInt(szArgv[1]);

    if ((i4Argc != 2) || (u4Path > 1))
    {
        Printf("Usage: %s \n", szArgv[0]);
        Printf("Main or Sub\n");
        Printf("0: Main\n");
        Printf("1: Sub\n");
        return 0;
    }

    DRVCUST_GetSignalFormat(u4Path, &pSignalFormat);

    //Please follow the format to print log for AutoTest checker
    //Do "NOT" use TAB in format string!!
    Printf("====== DRVCUST_GetSignalFormat(%d) ======\n", u4Path);
    Printf("eSigSta             %d\n", pSignalFormat.eSigSta);
    Printf("u4Width             %d\n", pSignalFormat.u4Width);
    Printf("u4Height            %d\n", pSignalFormat.u4Height);
    Printf("u4CodecWidth        %d\n", pSignalFormat.u4CodecWidth);
    Printf("u4CodecHeight       %d\n", pSignalFormat.u4CodecHeight);
    Printf("eContentType        %d\n", pSignalFormat.eContentType);
    Printf("eScanType           %d\n", pSignalFormat.eScanType);
    Printf("eColorSystem        %d\n", pSignalFormat.eColorSystem);
    Printf("eFrameRate          %d\n", pSignalFormat.eFrameRate);
    Printf("eStreamingType      %d\n", pSignalFormat.eStreamingType); 
    Printf("eDimension          %d\n", pSignalFormat.eDimension);
    Printf("e3dFormat           %d\n", pSignalFormat.e3dFormat);
    Printf("eColorimetry        %d\n", pSignalFormat.eColorimetry);
    Printf("eColorFormat        %d\n", pSignalFormat.eColorFormat);
    Printf("eColorDepth         %d\n", pSignalFormat.eColorDepth);
    Printf("eColorSpace         %d\n", pSignalFormat.eColorSpace);
    Printf("ePhotoColorSpace    %d\n", pSignalFormat.ePhotoColorSpace);
    Printf("eDynamicRange       %d\n", pSignalFormat.eDynamicRange);
    Printf("eAspect             %d\n", pSignalFormat.eAspect);
    Printf("eVideoCodec         %d\n", pSignalFormat.eVideoCodec);
    Printf("eCromaSample        %d\n", pSignalFormat.eCromaSample);
    Printf("eHdmi4kPhoto        %d\n", pSignalFormat.eHdmi4kPhoto);
    Printf("eHDRType            %d\n", pSignalFormat.eHDRType);
    Printf("eDoviType            %d\n", pSignalFormat.eDoviType);
    Printf("u4SrcFrameRate      %d\n", pSignalFormat.u4SrcFrameRate);
    Printf("u4IsEPGMode         %d\n", pSignalFormat.u4IsEPGMode);

    #ifdef CC_MTK_AUTO_TEST
    if(pSignalFormat.eSigSta == 0 && pSignalFormat.u4Width == 3840 &&
       pSignalFormat.u4Height == 2160 )
    {
        Printf("PASS_SigFmt\n");
    }
    #endif
    return 0;
}

static INT32 _i4GetMapleSysDOVITypeCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    E_CUST_DOVI_TYPE eDovimodeCmd;

    UINT32 u4Path = StrToInt(szArgv[1]);

    if ((i4Argc != 2) || (u4Path > 1))
    {
        Printf("Usage: %s \n", szArgv[0]);
        Printf("Main or Sub\n");
        Printf("0: Main\n");
        Printf("1: Sub\n");
        return 0;
    }
	DRVCUST_GetDOVIType(u4Path,&eDovimodeCmd);
	Printf("==Dolby Version Mode ==      %d\n", eDovimodeCmd);
	return 0;
}

static INT32 _i4GetMapleSysWindowModeCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	E_CUST_WINDOW_MODE tmp ;

	tmp  = DRVCUST_GetWindowMode();

	Printf("====== DRVCUST_GetWindowMode ======\n"); 
    Printf("Window Mode            %d\n", tmp );

#ifdef CC_MTK_AUTO_TEST
        if(tmp <= E_CUST_WINDOW_MODE_PAP)
        {
            Printf("PASS_WindowMode\n");
        }
#endif

    return 0;
}

static INT32 _i4GetMapleSysPlaneMuteCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    E_CUST_MUTE_STATE tmp ;
    UINT32 u4Path = StrToInt(szArgv[1]);

    if ((i4Argc != 2) || (u4Path > 1))
    {
        Printf("Usage: %s \n", szArgv[0]);
        Printf("Main or Sub\n");
        Printf("0: Main\n");
        Printf("1: Sub\n");
        return 0;
    }

    tmp  = DRVCUST_GetPlaneMuteState(u4Path);

    Printf("====== DRVCUST_GetPlaneMuteState ======\n");
    Printf("Mute state            %d\n", tmp );
#ifdef CC_MTK_AUTO_TEST
    if(tmp == E_CUST_MUTE_STATE_UNMUTE)
    {
        Printf("PASS_PlaneMute\n");
    }
#endif
    return 0;
}

static INT32 _i4GetMapleSysOutputMuteCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    E_CUST_MUTE_STATE tmp ;
    UINT32 u4Path = StrToInt(szArgv[1]);

    if ((i4Argc != 2) || (u4Path > 1))
    {
        Printf("Usage: %s \n", szArgv[0]);
        Printf("Main or Sub\n");
        Printf("0: Video\n");
        Printf("1: GFX\n");
        return 0;
    }

    tmp  = DRVCUST_GetOutputMuteState(u4Path);

    Printf("====== DRVCUST_GetOutputMuteState ======\n");
    Printf("Output Mute state            %d\n", tmp );
#ifdef CC_MTK_AUTO_TEST
    if(tmp == E_CUST_MUTE_STATE_UNMUTE)
    {
        Printf("PASS_OutputMute\n");
    }
#endif
    return 0;
}

static INT32 _i4GetMapleSysOutPosiCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    CUST_OUT_POSI_T pOutPosition;
    UINT32 u4Path = StrToInt(szArgv[1]);

    if ((i4Argc != 2) || (u4Path > 1))
    {
        Printf("Usage: %s \n", szArgv[0]);
        Printf("Main or Sub\n");
        Printf("0: Main\n");
        Printf("1: Sub\n");
        return 0;
    }

    DRVCUST_GetOutputPosition(u4Path, &pOutPosition);

    Printf("====== DRVCUST_GetOutputPosition ======\n");
    Printf("u4X              %d\n", pOutPosition.u4X);
    Printf("u4Y              %d\n", pOutPosition.u4Y);
    Printf("u4Width          %d\n", pOutPosition.u4Width);
    Printf("u4Height         %d\n", pOutPosition.u4Height);
#ifdef CC_MTK_AUTO_TEST
    if(pOutPosition.u4X == 0 && pOutPosition.u4Y == 0 &&
        pOutPosition.u4Width == 3840 && pOutPosition.u4Height == 2160)
    {
        Printf("PASS_OutPosi\n");
    }
#endif
    return 0;
}

static INT32 _i4GetMapleSysSrcAreaCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    CUST_SRC_AREA_T pSclReq;
    UINT32 u4Path = StrToInt(szArgv[1]);

    if (i4Argc != 2)
    {
        Printf("Usage: %s \n", szArgv[0]);
        Printf("BeHandle\n");
        return 0;
    }

    DRVCUST_GetSourceArea(u4Path, &pSclReq);

    Printf("====== DRVCUST_GetOutputPosition ======\n");
    Printf("u4SrcX           %d\n", pSclReq.u4SrcX);
    Printf("u4SrcY           %d\n", pSclReq.u4SrcY);
    Printf("u4SrcWidth       %d\n", pSclReq.u4SrcWidth);
    Printf("u4SrcHeight      %d\n", pSclReq.u4SrcHeight);
#ifdef CC_MTK_AUTO_TEST
    if(pSclReq.u4SrcX == 0 && pSclReq.u4SrcY == 0 &&
        pSclReq.u4SrcWidth == 3840 && pSclReq.u4SrcHeight == 2160)
    {
        Printf("PASS_SrcArea\n");
    }
#endif
    return 0;
}

static INT32 _i4GetMapleSysSclReqCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    CUST_SRC_AREA_T pSclReq;
    UINT32 u4Path = StrToInt(szArgv[1]);

    if (i4Argc != 2)
    {
        Printf("Usage: %s \n", szArgv[0]);
        Printf("BeHandle\n");
        return 0;
    }

    DRVCUST_GetScalingRequest(u4Path, &pSclReq);

    Printf("====== DRVCUST_GetOutputPosition ======\n");
    Printf("u4SrcX           %d\n", pSclReq.u4SrcX);
    Printf("u4SrcY           %d\n", pSclReq.u4SrcY);
    Printf("u4SrcWidth       %d\n", pSclReq.u4SrcWidth);
    Printf("u4SrcHeight      %d\n", pSclReq.u4SrcHeight);
#ifdef CC_MTK_AUTO_TEST
    if(pSclReq.u4SrcX == 0 && pSclReq.u4SrcY == 0 &&
        pSclReq.u4SrcWidth == 3840 && pSclReq.u4SrcHeight == 2160)
    {
        Printf("PASS_SclReq\n");
    }
#endif
    return 0;
}

static INT32 _i4GetMapleSysOutFmtCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_OUT_FMT_T pOutFmt;
	UINT32 u4Path = StrToInt(szArgv[1]);

	if ((i4Argc != 2) || (u4Path > 1))
	{
		Printf("Usage: %s \n", szArgv[0]);
		Printf("Main or Sub\n");
		Printf("0: Video\n");
		Printf("1: GFX\n");
		return 0;
	}

	DRVCUST_GetOutputFormat(u4Path, &pOutFmt);

	Printf("====== DRVCUST_GetOutputFormat ======\n");
    Printf("u4Htotal		    %d\n", pOutFmt.u4Htotal);
    Printf("u4Vtotal		    %d\n", pOutFmt.u4Vtotal);
    Printf("u4ActX			    %d\n", pOutFmt.u4ActX);
    Printf("u4ActY			    %d\n", pOutFmt.u4ActY);
    Printf("u4ActWidth		    %d\n", pOutFmt.u4ActWidth);
    Printf("u4ActHeight		    %d\n", pOutFmt.u4ActHeight);
    Printf("eFrameRate		    %d\n", pOutFmt.eFrameRate);
    Printf("eDimension		    %d\n", pOutFmt.eDimension);
    Printf("e3dFormat		    %d\n", pOutFmt.e3dFormat);
    Printf("eColorimetry	    %d\n", pOutFmt.eColorimetry);
    Printf("eColorFormat	    %d\n", pOutFmt.eColorFormat);
    Printf("eColorDepth		    %d\n", pOutFmt.eColorDepth);
    Printf("eColorSpace		    %d\n", pOutFmt.eColorSpace);
    Printf("eDynamicRange	    %d\n", pOutFmt.eDynamicRange);
    Printf("ePath			    %d\n", pOutFmt.ePath);
	Printf("bCtrlBitValid		%d\n", pOutFmt.bCtrlBitValid);
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetOutputFormat_PASS\n");
	#endif
    return 0;

}

static INT32 _i4GetMapleSysMCVPMeterCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	CUST_MCVP_METER_T pMcvpMeter;

	DRVCUST_GetMCVPMeter(&pMcvpMeter);

	Printf("====== DRVCUST_GetMCVPMeter ======\n");
    Printf("u1NoiseLevel              %d\n", pMcvpMeter.u1NoiseLevel);                  
    Printf("u1BlockNoiseLevel            %d\n", pMcvpMeter.u1BlockNoiseLevel);                
    Printf("u4FrmDiff               %d\n", pMcvpMeter.u4FrmDiff);     
	Printf("u1FreqHpfH              %d\n", pMcvpMeter.u1FreqHpfH);                  
    Printf("u1FreqHpfV            %d\n", pMcvpMeter.u1FreqHpfV);                
    Printf("u1FreqBpfH               %d\n", pMcvpMeter.u1FreqBpfH);
    Printf("u2BlockSizeH           %d\n", pMcvpMeter.u2BlockSizeH);
    Printf("u2BlockSizeV           %d\n", pMcvpMeter.u2BlockSizeV);
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetMCVPMeter_PASS\n");
	#endif
    return 0;

}

static INT32 _i4GetMapleSysCadenseCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    E_CUST_CADENSE tmp ;

    tmp  = DRVCUST_GetCadense();

    Printf("====== DRVCUST_GetCadense ======\n");
    Printf("Cadense            %d\n", tmp );
#ifdef CC_MTK_AUTO_TEST
    if(tmp == E_CUST_CADENSE_UNKOWN)
    {
        Printf("PASS_Cadense\n");
    }
#endif

    return 0;
}

static INT32 _i4GetMapleSysPostMeterCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT32 i;
    CUST_POST_PROC_METER_T pPostProcMeter;

    DRVCUST_GetPostProcMeter(&pPostProcMeter);

    Printf("====== DRVCUST_GetPostProcMeter ======\n");
    Printf("X    %d   Y    %d\n", pPostProcMeter.u4X, pPostProcMeter.u4Y);
    Printf("W    %d   H    %d\n", pPostProcMeter.u4Width, pPostProcMeter.u4Height);
    Printf("APL     %d     %d\n", pPostProcMeter.u1APLL, pPostProcMeter.u1APLR);
    Printf("ASL     %d     %d\n", pPostProcMeter.u1ASLL, pPostProcMeter.u1ASLR);
    Printf("Y Max   %d     %d\n", pPostProcMeter.u1LumaMaxL, pPostProcMeter.u1LumaMaxR);
    Printf("Y Min   %d     %d\n", pPostProcMeter.u1LumaMinL, pPostProcMeter.u1LumaMinR);

    Printf("== Luma Hist ==\n");
    for (i=0; i<LUMA_HIST_NUM_113; i++)
    {
        Printf("Luma[%02d]    %d     %d\n", i, pPostProcMeter.u4LumaHistL[i], pPostProcMeter.u4LumaHistR[i]);
    }

    Printf("== Sat Hist ==\n");
    for (i=0; i<SAT_HIST_NUM; i++)
    {
        Printf("Sat[%d]       %d     %d\n", i, pPostProcMeter.u2SatHistL[i], pPostProcMeter.u2SatHistR[i]);
    }

    Printf("== Hue Hist ==\n");
    for (i=0; i<HUE_HIST_NUM; i++)
    {
        Printf("Hue[%d]       %d     %d\n", i, pPostProcMeter.u2HueHistL[i], pPostProcMeter.u2HueHistR[i]);
    }
#ifdef CC_MTK_AUTO_TEST
    if(pPostProcMeter.u4X == 16 && pPostProcMeter.u4Y == 16 &&
       pPostProcMeter.u4Width == 3809 &&  pPostProcMeter.u4Height == 2129)
    {
        Printf("PASS_PostMeter\n");
    }
#endif

    return 0;
}

static INT32 _i4GetMapleSysPostProcTdHistMeterCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    static UINT8 cmd_ysh_bin[YSH_Y_NUM][YSH_S_NUM][YSH_H_NUM];
    UINT8 i,j,k;
	Printf("\n");

    DRVCUST_GetPostProcTdHistMeter(cmd_ysh_bin);
	for(i = 0; i < YSH_Y_NUM; i++)
	{
		for(j = 0; j < YSH_S_NUM; j++)
		{
			for(k = 0; k < YSH_H_NUM; k++)
			{
				Printf("bin[%d][%d][%d]:%02x  ", i, j, k, cmd_ysh_bin[i][j][k]);
			}
			Printf("\n");
		}
		Printf("\n");
		Printf("\n");
	}
#ifdef CC_MTK_AUTO_TEST

    Printf("PASS_PostProcTdHistMeter\n");

#endif

    return 0;
}

static INT32 _i4GetMapleSysSkinLumaHistMeterCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    static UINT32 waSkinLumaHist_RawCmd[SKIN_LUMA_HIST_NUM];
	UINT8 i;
    DRVCUST_GetPqSkinLumaHistMeter(waSkinLumaHist_RawCmd);
	for(i = 0; i < SKIN_LUMA_HIST_NUM; i++)
	{
		Printf("%d = 0x%00000008x\n", i, waSkinLumaHist_RawCmd[i]);
	}
    return 0;
}


static INT32 _i4GetMapleSysLDMeterCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT32 i;
	CUST_LD_METER_T pLdMeter;

	DRVCUST_GetLdMeter(&pLdMeter);
	
	Printf("====== DRVCUST_GetLdMeter ======\n");
	Printf("== u1LdMaxRGB ==\n");
    for (i=0; i<32; i++)
    {
        Printf("u1LdMaxRGB[%d]         %d\n", i, pLdMeter.u1LdMaxRGB[i]);
    }
	
	Printf("== u2LdMaxHist ==\n");
    for (i=0; i<33; i++)
    {
        Printf("u2LdMaxHist[%d]         %d\n", i, pLdMeter.u2LdMaxHist[i]);
    }

	Printf("== u2LdDimInfo ==\n");
    for (i=0; i<32; i++)
    {
        Printf("u2LdDimInfo[%d]         %d\n", i, pLdMeter.u2LdDimInfo[i]);
    }
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetLdMeter_PASS\n");
	#endif
	return 0;

}

static INT32 _i4GetMapleSysAnaNoiseCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	UINT8 tmp ;
	UINT32 u4Path = StrToInt(szArgv[1]);

	if ((i4Argc != 2) || (u4Path > 1))
	{
		Printf("Usage: %s \n", szArgv[0]);
		Printf("Main or Sub\n");
		Printf("0: Main\n");
		Printf("1: Sub\n");
		return 0;
	}

	tmp  = DRVCUST_GetAnalogDecNoiseLevel(u4Path);

	Printf("====== DRVCUST_GetAnalogDecNoiseLevel ======\n"); 
    Printf("Analog Noise            %d\n", tmp );
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetAnalogDecNoiseLevel_PASS\n");
	#endif
    return 0;

}

static INT32 _i4GetMapleSysLightSensorCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	UINT8 tmp ;

	tmp  = DRVCUST_GetOpticalSensorLevel();

	Printf("====== DRVCUST_GetOpticalSensorLevel ======\n"); 
    Printf("Light Sensor            %d\n", tmp );
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetOpticalSensorLevel_PASS\n");
	#endif
    return 0;

}

static INT32 _i4GetMapleSysTempSensorCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	UINT8 tmp ;

	tmp  = DRVCUST_GetTemperatureSensorLevel();

	Printf("====== DRVCUST_GetTemperatureSensorLevel ======\n"); 
    Printf("Temperature Sensor            %d\n", tmp );
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetTemperatureSensorLevel_PASS\n");
	#endif
    return 0;

}

static INT32 _i4GetMapleSysBLPowerLimitCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	UINT8 tmp ;

	tmp  = DRVCUST_GetBLPowerLimit();

	Printf("====== DRVCUST_GetBLPowerLimit ======\n"); 
    Printf("BL Power Limit            %d\n", tmp );

    return 0;

}

static INT32 _i4GetMapleSysFrameDelayCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    CUST_VDO_DELAY_INFO_T pVdoDelayInfo;

    DRVCUST_GetVideoFrameDelay(&pVdoDelayInfo);

    Printf("====== DRVCUST_GetVideoFrameDelay ======\n");
    Printf("u4MCVP              %d\n", pVdoDelayInfo.u4MCVP);
    Printf("u4Scaler            %d\n", pVdoDelayInfo.u4Scaler);
    Printf("u4MJC               %d\n", pVdoDelayInfo.u4MJC);
#ifdef CC_MTK_AUTO_TEST
    if(pVdoDelayInfo.u4MCVP != 0 && pVdoDelayInfo.u4Scaler == 0)
    {
        Printf("PASS_FrameDelay\n");
    }
#endif

    return 0;
}

static INT32 _i4GetMapleSysHistoryDataCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	CUST_HISTORY_DATA_T pHistoryData;

	DRVCUST_GetHistoryData(&pHistoryData);

	Printf("====== DRVCUST_GetHistoryData ======\n");
    Printf("u4MCVP              %d\n", pHistoryData.u4TotalOpTime);                  
    Printf("u4Scaler            %d\n", pHistoryData.u4PanelOpTime); 
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetHistoryData_PASS\n");
	#endif
    return 0;

}

static INT32 _i4GetMapleSysPowerStateCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	CUST_POWER_STATE_T pPowerState;

	DRVCUST_GetPowerState(&pPowerState);

	Printf("====== DRVCUST_GetPowerState ======\n");
    Printf("Power state               %d\n", pPowerState.ePanelState);     
#ifdef CC_MTK_AUTO_TEST
	if(pPowerState.ePanelState == 1)
	{
		Printf("PASS_cust_cli.sys.powst\n"); 
	}
#endif
    return 0;

}

static INT32 _i4GetMapleSysDecBitRateCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT32 tmp ;
	UINT32 u4Path = StrToInt(szArgv[1]);

	if ((i4Argc != 2) || (u4Path > 1))
	{
		Printf("Usage: %s \n", szArgv[0]);
		Printf("Main or Sub\n");
		Printf("0: Main\n");
		Printf("1: Sub\n");
		return 0;
	}

	tmp  = DRVCUST_GetDecoderAvgBitRate(u4Path);

	Printf("====== DRVCUST_GetDecoderAvgBitRate ======\n"); 
    Printf("Decoder Bit Rate            %d\n", tmp );
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetDecoderAvgBitRate_PASS\n");
	#endif

    return 0;

}

static INT32 _i4GetMapleSysADCValueCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT32 tmp ;
    UINT32 u4Path = StrToInt(szArgv[1]);
#ifdef CC_MTK_AUTO_TEST
        UINT32 u4AdcMin = 0x0;
    #if defined(CC_MT5893)
            UINT32 u4AdcMax = 0x3ff;   //M3 ADC is 11bit
    #elif defined(CC_MT5895)
            UINT32 u4AdcMax = 0x7ff;   //M5 ADC is 11 bit
    #else
            UINT32 u4AdcMax = 0x3ff;
    #endif
#endif

    if ((i4Argc != 2) || (u4Path > 12))
    {
        Printf("Usage: %s \n", szArgv[0]);
        Printf("ADC port\n");
        Printf("0: E_CUST_ADC_PORT_SCART_FS\n");
        Printf("1: E_CUST_ADC_PORT_KEY\n");
        Printf("2: E_CUST_ADC_PORT_LIGHT_SENSOR\n");
        Printf("3: E_CUST_ADC_PORT_PANEL_PWR_DET\n");
        Printf("4: E_CUST_ADC_PORT_BL_ERR_DET\n");
        Printf("5: E_CUST_ADC_PORT_USB_OC2_DET\n");
        Printf("6: E_CUST_ADC_PORT_RF_AGCI\n");
        Printf("7: E_CUST_ADC_PORT_X_SYSTEM_RST\n");
        Printf("8: E_CUST_ADC_PORT_12V_DET\n");
        Printf("9: E_CUST_ADC_PORT_5V_DET\n");
        return 0;
    }

    tmp  = DRVCUST_GetAdcValue(u4Path);

    Printf("====== DRVCUST_GetAdcValue ======\n");
    Printf("ADC Value           %d\n", tmp );
#ifdef CC_MTK_AUTO_TEST
    if((tmp >= u4AdcMin) && (tmp <= u4AdcMax))
    {
        Printf("PASS_cust_cli.sys.adc\n");
    }
#endif

    return 0;
}

static INT32 _i4GetMapleSysScreenSaverCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	CUST_SCREEN_SAVER_T pScreenSaver;

	DRVCUST_GetScreenSaver(&pScreenSaver);

	Printf("====== DRVCUST_GetScreenSaver ======\n");
    Printf("eScreenSaverMode               %d\n", pScreenSaver.eScreenSaverMode);     
#ifdef CC_MTK_AUTO_TEST
	if(pScreenSaver.eScreenSaverMode == 0)
	{
		Printf("PASS_cust_cli.sys.saver\n"); 
	}
#endif
    return 0;

}

static INT32 _i4GetMapleSysAgingModeCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	CUST_AGING_MODE_T pAgingMode;

	DRVCUST_GetAgingMode(&pAgingMode);

	Printf("====== DRVCUST_GetAgingMode ======\n");
    Printf("bAgingMode               %d\n", pAgingMode.bAgingMode);     
#ifdef CC_MTK_AUTO_TEST
	if(pAgingMode.bAgingMode == 0)
	{
		Printf("PASS_cust_cli.sys.aging\n"); 
	}
#endif
    return 0;

}

static INT32 _i4GetMapleSysTVOutFmtCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	CUST_TV_OUT_FMT_T pTvOutFmt;

	DRVCUST_GetTvOutputFormat(&pTvOutFmt);

	Printf("====== DRVCUST_GetTvOutputFormat ======\n");
    Printf("eDimension               %d\n", pTvOutFmt.eDimension);  
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetTvOutputFormat_PASS\n");
	#endif
    return 0;

}

static INT32 _i4GetMapleSysScalerInfoCmd(INT32 i4Argc, const CHAR ** szArgv)
{
    CUST_SCL_AREA_T pScalerArea;
    UINT32 u4Path = StrToInt(szArgv[1]);

    if ((i4Argc != 2) || (u4Path > 1))
    {
        Printf("Usage: %s \n", szArgv[0]);
        Printf("Main or Sub\n");
        Printf("0: Main\n");
        Printf("1: Sub\n");
        return 0;
    }

    DRVCUST_GetMuffinScalerInfo(u4Path, &pScalerArea);

    Printf("====== DRVCUST_GetMuffinScalerInfo ======\n");
    Printf("t_DownScalerInput.u4Width            %d\n", pScalerArea.t_DownScalerInput.u4Width);
    Printf("t_DownScalerInput.u4Height           %d\n", pScalerArea.t_DownScalerInput.u4Height);
    Printf("t_DownScalerOutput.u4Width           %d\n", pScalerArea.t_DownScalerOutput.u4Width);
    Printf("t_DownScalerOutput.u4Height          %d\n", pScalerArea.t_DownScalerOutput.u4Height);
    Printf("t_ScalerInput.u4Width                %d\n", pScalerArea.t_ScalerInput.u4Width);
    Printf("t_ScalerInput.u4Height               %d\n", pScalerArea.t_ScalerInput.u4Height);
    Printf("t_ScalerOutput.u4Width               %d\n", pScalerArea.t_ScalerOutput.u4Width);
    Printf("t_ScalerOutput.u4Height              %d\n", pScalerArea.t_ScalerOutput.u4Height);
    Printf("t_ScalerTiming.u4Width               %d\n", pScalerArea.t_ScalerTiming.u4Width);
    Printf("t_ScalerTiming.u4Height              %d\n", pScalerArea.t_ScalerTiming.u4Height);
#ifdef CC_MTK_AUTO_TEST
    if(pScalerArea.t_ScalerOutput.u4Width == 3840 &&
       pScalerArea.t_ScalerOutput.u4Height == 2160)
    {
        Printf("PASS_ScalerInfo\n");
    }
#endif

    return 0;
}

static INT32 _i4GetMapleSysOSDStateCmd(INT32 i4Argc, const CHAR ** szArgv)
{

	BOOL* bOsdState;

	DRVCUST_GetOsdState(&bOsdState);

	Printf("====== DRVCUST_GetOsdState ======\n");
    Printf("bOsdState               %d\n", bOsdState); 
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetOsdState_PASS\n");
	#endif
    return 0;

}


static INT32 _i4GetMapleSysOSDPxlCountCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	Printf("====== DRVCUST_GetOsdPxl Count ======\n");
    Printf("DRVCUST_GetOsdPixelCount()-->               %d\n", DRVCUST_GetOsdPixelCount()); 
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetOsdPixelCount_PASS\n");
	#endif
    return 0;

}

static INT32 _i4GetMapleSysUpdateTimingGroupCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8* pCustSrcTimingTbl;
	UINT8* pCustSrcGroup;
	UINT32 u4SrcTimingSize = sizeof(bCustomSrcTimingTbl);
    UINT32 u4SrcGroupSize = sizeof(bCustomSourceGroup);
	if(((pCustSrcTimingTbl = x_mem_alloc(u4SrcTimingSize))==NULL)||((pCustSrcGroup = x_mem_alloc(u4SrcGroupSize))==NULL))
	{
		Printf("Init Pointer Fail!!!\n");
		return 0;
	}
    
	Printf("====== DRVCUST_GetTiming Group ======\n");
    DRVCUST_UpdateTimingGroup( pCustSrcTimingTbl,  pCustSrcGroup);
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_UpdateTimingGroup_PASS\n");
	#endif
    return 0;

}

static INT32 _i4SetMapleSysOSDAlphaTHCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	if ((i4Argc != 2))
	{
		Printf("need to set threshold: %s \n", szArgv[0]);
		return 0;
	}


	DRVCUST_SetOsdPixCountAlphaThresh((UINT8)StrToInt(szArgv[1]));
	
	Printf("====== DRVCUST_SetOsdAlpha ======\n");

    #ifdef CC_MTK_AUTO_TEST
    if(DRVCUST_GetOsdPixCountAlphaThresh()==((UINT8)StrToInt(szArgv[1])))
		Printf("DRVCUST_SetOsdState_PASS\n");
	else
		Printf("DRVCUST_SetOsdState_FAIL\n");
	#endif
    return 0;

}
static INT32 _i4SetMapleDVCFGfileCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	if ((i4Argc != 3))
	{
		Printf("need to set 1. offset 2. size: %s \n", szArgv[0]);
		return 0;
	}


	DRVCUST_SetDolbyConfigData((UPTR)StrToInt(szArgv[1]),(UINT32)StrToInt(szArgv[2]));
	
	Printf("====== DRVCUST_SetDolbyConfigData ======\n");
    Printf("Ofst               %d\n", ((UPTR)StrToInt(szArgv[1]))); 
    Printf("Size               %d\n", (UINT32)StrToInt(szArgv[2]));
    #ifdef CC_MTK_AUTO_TEST
    
		Printf("DRVCUST_SetDolbyConfigData_PASS\n");

	#endif
    return 0;

}

static INT32 _i4GetMapleSysScreenMirrorCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_SCR_MIRROR_CONFIG_T pScrMirrorConfig;
	UINT32 u4Path = StrToInt(szArgv[1]);

	if ((i4Argc != 2) || (u4Path > 1))
	{
		Printf("Usage: %s \n", szArgv[0]);
		Printf("Main or Sub\n");
		Printf("0: Main\n");
		Printf("1: Sub\n");
		return 0;
	}

	DRVCUST_GetScreenMirroringConfig(u4Path, &pScrMirrorConfig);

	Printf("====== DRVCUST_GetScreenMirroringConfig ======\n");
	Printf("eProtocol              %d\n", pScrMirrorConfig.eProtocol);

#ifdef CC_MTK_AUTO_TEST
    if(pScrMirrorConfig.eProtocol == CUST_SCR_MIRROR_PROTOCOL_UNKNOWN)
    {
        Printf("PASS_ScreenMirror\n");
    }
#endif

    return 0;

}

static INT32 _i4GetLetterBoxDetection(INT32 i4Argc, const CHAR ** szArgv)
{
    CUST_LETTER_BOX_INFO_T pLetterBoxInfo;

    DRVCUST_GetLetterBoxDetection(&pLetterBoxInfo);
    Printf("====Get letter box info====\n");
    Printf("pLetterBoxInfo.u4LBoxLowFinal       %d\n", pLetterBoxInfo.u4LBoxLowFinal);
    Printf("pLetterBoxInfo.u4LBoxUpFinal        %d\n", pLetterBoxInfo.u4LBoxUpFinal);
    Printf("pLetterBoxInfo.u4LBoxRightFinal     %d\n", pLetterBoxInfo.u4LBoxRightFinal);
    Printf("pLetterBoxInfo.u4LBoxLeftFinal      %d\n", pLetterBoxInfo.u4LBoxLeftFinal);
#ifdef CC_MTK_AUTO_TEST
    //TO-DO: pre-condition, play a letterbox video and add result check
    Printf("PASS_LetterBoxDetection\n");
#endif
    return 0;
}

static INT32 _i4SetSCECapEn(INT32 i4Argc, const CHAR ** szArgv)
{	
	BOOL en = StrToInt(szArgv[1]);

	if(i4Argc != 2)
	{
		Printf("Parameter number not correct\n");
		return 0;
	}
	
	DRVCUST_SetScePixMonCapEnable(en);
	#ifdef CC_MTK_AUTO_TEST
	if(IO32ReadFldAlign(DBG_CFG_MAIN,SCE_CAP_EN)==en)
	{
		Printf("DRVCUST_SetScePixMonCapEnable_PASS!\n");
	}
	else
	{
		Printf("DRVCUST_SetScePixMonCapEnable_FAIL!\n");
	}
	#endif
	return 0;
}

static INT32 _i4TimLengthCheck(INT32 i4Argc, const CHAR ** szArgv)
{	
	#ifdef CC_MTK_AUTO_TEST
	BOOL en = vApiCustTimLengthVerify();

	if(en)
	{
		Printf("DRVCUST_CheckTimingLength_PASS\n");
		return 0;
	}
	else
	{
		Printf("DRVCUST_CheckTimingLength_FAIL\n");
		return 0;
	}
	#else
	vApiCustTimLengthVerify();
	#endif
	
	return 0;
}

static INT32 _i4SetSCECapPos(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_SCE_CAP_DATA_T* SCECAPData = NULL;
	CUST_CAP_POS_T pPos;
	
	if(i4Argc != 3)
	{
		Printf("input CapPostion X Y\n");
		return 0;
	}

	pPos.u2X = StrToInt(szArgv[1]);
	pPos.u2Y = StrToInt(szArgv[2]);

	SCECAPData = DRVCUST_SetScePixMonPos(&pPos);
	#ifdef CC_MTK_AUTO_TEST
	if((IO32ReadFldAlign(POS_MAIN,SCE_POS_X)==pPos.u2X)&&(IO32ReadFldAlign(POS_MAIN,SCE_POS_Y)==pPos.u2Y))
	{
		Printf("DRVCUST_SetScePixMonPos_PASS!\n");
	}
	else
	{
		Printf("DRVCUST_SetScePixMonPos_FAIL!\n");
	}
	#endif
	Printf("CapPos SCE Input  Yin=%d   Cbin=%d   Crin=%d \n", SCECAPData->SceInput.u2Y_G, SCECAPData->SceInput.u2Cb_B, SCECAPData->SceInput.u2Cr_R);
	Printf("CapPos SCE Output Yout=%d  Cbout=%d  Crout=%d \n", SCECAPData->SceOutput.u2Y_G, SCECAPData->SceOutput.u2Cb_B, SCECAPData->SceOutput.u2Cr_R);
	return 0;
}

static INT32 _i4SetSCECapInk(INT32 i4Argc, const CHAR ** szArgv)
{
	BOOL Inken = StrToInt(szArgv[1]);
	
	if(i4Argc != 2)
	{
		Printf("Parameter number not correct\n");
		return 0;
	}

	DRVCUST_SetScePixMonInkEnable(Inken);
	#ifdef CC_MTK_AUTO_TEST
	if(IO32ReadFldAlign(DBG_CFG_MAIN,INK_EN)==Inken)
	{
		Printf("DRVCUST_SetScePixMonInkEnable_PASS!\n");
	}
	else
	{
		Printf("DRVCUST_SetScePixMonInkEnable_FAIL!\n");
	}
	#endif
	return 0;
}

static INT32 _i4SetSCECapInkColor(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_CAP_DATA_T inkColor;
	
	if(i4Argc != 4)
	{
		Printf("input Ink color control  Y  Cb  Cr\n");
		return 0;
	}

	inkColor.u2Y_G = StrToInt(szArgv[1]);
	inkColor.u2Cb_B = StrToInt(szArgv[2]);
	inkColor.u2Cr_R = StrToInt(szArgv[3]);
	
	DRVCUST_SetScePixMonInkColor(&inkColor);
	#ifdef CC_MTK_AUTO_TEST
	if((IO32ReadFldAlign(INK_DATA_MAIN,INK_DATA_Y)==inkColor.u2Y_G)&&(IO32ReadFldAlign(INK_DATA_MAIN,INK_DATA_CB)==
		inkColor.u2Cb_B)&&(IO32ReadFldAlign(INK_DATA_MAIN_CR,INK_DATA_CR)==
		inkColor.u2Cr_R))
	{
		Printf("DRVCUST_SetScePixMonInkColor_PASS!\n");
	}
	else
	{
		Printf("DRVCUST_SetScePixMonInkColor_FAIL!\n");
	}
	#endif
	return 0;
}

static INT32 _i4SetSCECapData(INT32 i4Argc, const CHAR ** szArgv)
{	
	CUST_SCE_CAP_DATA_T SCECAPData;

	if(i4Argc > 1)
	{		
		Printf("no need input parameter\n");
		return 0;
	}

	DRVCUST_GetScePixMonData(&SCECAPData);
	
	Printf("SCE Input  Yin=%d   Cbin=%d   Crin=%d \n", SCECAPData.SceInput.u2Y_G, SCECAPData.SceInput.u2Cb_B, SCECAPData.SceInput.u2Cr_R);
	Printf("SCE Output Yout=%d  Cbout=%d  Crout=%d \n", SCECAPData.SceOutput.u2Y_G, SCECAPData.SceOutput.u2Cb_B, SCECAPData.SceOutput.u2Cr_R);
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetScePixMonData_PASS!\n");
	#endif
	return 0;
}

static INT32 _i4SetOstgCapEn(INT32 i4Argc, const CHAR ** szArgv)
{
	BOOL en = StrToInt(szArgv[1]);

	if(i4Argc != 2)
	{
		Printf("Parameter number not correct\n");
		return 0;
	}
	
	DRVCUST_SetOstgPixMonCapEnable(en);
	#ifdef CC_MTK_AUTO_TEST
	if(IO32ReadFldAlign(DUMP_00,DUMP_EN)==en )
	{
		Printf("DRVCUST_SetOstgPixMonCapEnable_PASS!\n");
	}
	else
	{
		Printf("DRVCUST_SetOstgPixMonCapEnable_FAIL!\n");
	}
	#endif
	return 0;
}

static INT32 _i4SetOstgCapPos(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_CAP_DATA_T* OstgCapData = NULL;
	CUST_CAP_POS_T pPos;
	
	if(i4Argc != 3)
	{
		Printf("input CapPostion X Y\n");
		return 0;
	}
	
	pPos.u2X = StrToInt(szArgv[1]);
	pPos.u2Y = StrToInt(szArgv[2]);
	
	OstgCapData = DRVCUST_SetOstgPixMonPos(&pPos);
	#ifdef CC_MTK_AUTO_TEST
	if((IO32ReadFldAlign(DUMP_01,POS_X)==pPos.u2X)&&(IO32ReadFldAlign(DUMP_01,POS_Y)==pPos.u2Y))
	{
		Printf("DRVCUST_SetOstgPixMonPos_PASS!\n");
	}
	else
	{
		Printf("DRVCUST_SetOstgPixMonPos_FAIL!\n");
	}
	#endif
	//Printf("CapPos Ostg Cap Data R=%d G=%d B=%\n", OstgCapData.u2Cr_R, OstgCapData.u2Y_G, OstgCapData.u2Cb_B);
	Printf("CapPos Ostg Cap Data R=%d G=%d B=%d\n", OstgCapData->u2Cr_R, OstgCapData->u2Y_G, OstgCapData->u2Cb_B);
	return 0;

}

static INT32 _i4SetOstgCapColor(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_CAP_DATA_T inkColor;
	
	if(i4Argc != 4)
	{
		Printf("input Ink color control  Y  Cb  Cr\n");
		return 0;
	}

	inkColor.u2Y_G = StrToInt(szArgv[1]);
	inkColor.u2Cb_B = StrToInt(szArgv[2]);
	inkColor.u2Cr_R = StrToInt(szArgv[3]);
	
	DRVCUST_SetOstgPixMonCurseColor(&inkColor);
	#ifdef CC_MTK_AUTO_TEST
	if((IO32ReadFldAlign(DUMP_02,POS_G)==inkColor.u2Y_G)&&(IO32ReadFldAlign(DUMP_02,POS_B)==
	inkColor.u2Cb_B)&&(IO32ReadFldAlign(DUMP_02,POS_R)==
	inkColor.u2Cr_R))
	{
		Printf("DRVCUST_SetOstgPixMonCurseColor_PASS!\n");
	}
	else
	{
		Printf("DRVCUST_SetOstgPixMonCurseColor_FAIL!\n");
	}
	#endif
	return 0;
}

static INT32 _i4SetOstgCapData(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_CAP_DATA_T OstgCapData;
	
	if(i4Argc > 1)
	{		
		Printf("no need input parameter\n");
		return 0;
	}

	DRVCUST_GetOstgPixMonData(&OstgCapData);
	
	Printf("Ostg Cap Data R=%d G=%d B=%d\n", OstgCapData.u2Cr_R, OstgCapData.u2Y_G, OstgCapData.u2Cb_B);
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetOstgPixMonData_PASS!\n");
	#endif
	return 0;
}

static INT32 _i4SetDemoMode(INT32 i4Argc, const CHAR ** szArgv)
{
	E_CUST_DEMO_MODE eDemoMode;
	E_CUST_DEMO_PATTERN eDemoPattern;
	UINT32 u4DemoOption;
	if(i4Argc != 4)
	{		
		Printf("input eDemoMode eDemoPattern  u4DemoOption \n");
		return 0;
	}

	
	eDemoMode = StrToInt(szArgv[1]);
	eDemoPattern = StrToInt(szArgv[2]);
	u4DemoOption = StrToInt(szArgv[3]);

	DRVCUST_SetDemoMode( eDemoMode,  eDemoPattern,  u4DemoOption);
	
	return 0;
}

static INT32 _i4BEWriteCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	E_CUST_BE_PART ePartId;
	UINT32 u4Offset;
	//UINT32 u4BufSize;

	UINT8 Arry[10] = {0xFF,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
	if(i4Argc != 3)
	{
		Printf("size not correct ***\n");
		return 0;
	}
	ePartId = StrToInt(szArgv[1]);
	u4Offset = StrToInt(szArgv[2]);

	DRVCUST_BePartitionWrite( ePartId,  u4Offset, Arry, sizeof(Arry) );
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_BePartitionWrite_PASS!\n");
	#endif
	return 0;
}

static INT32 _i4BEReadeCmd(INT32 i4Argc, const CHAR ** szArgv)
{
	E_CUST_BE_PART ePartId;
	UINT32 u4Offset;
	//UINT32 u4BufSize;
	UINT8 i;

	UINT8 RArry[10];

	if(i4Argc != 2)
	{
		Printf("size not correct ***\n");
		return 0;
	}
	ePartId = StrToInt(szArgv[1]);
	u4Offset = StrToInt(szArgv[2]);
	
	DRVCUST_BePartitionRead(ePartId, u4Offset, RArry,  sizeof(RArry));

	for(i=0; i< 10; i++)
	{
		Printf("RArry[%d]=%d**\n", i, RArry[i]);
	}
	return 0;

}


static INT32 _i4WritSsharpne(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_SHARP_OFST_T Sharpness_P;
	
	Sharpness_P.u1Edf1Th[0]= 0x81;
	Sharpness_P.u1Edf1Th[1]= 0x82;
	Sharpness_P.u1Edf1Th[2]= 0x83;

	
	Sharpness_P.u1Edf2Th[0]= 0x81;
	Sharpness_P.u1Edf2Th[1]= 0x82;
	Sharpness_P.u1Edf2Th[2]= 0x83;
	Sharpness_P.u1Edf2Th[3]= 0x84;
	
	Sharpness_P.u1Edf2FGain[0]= 0x81;
	Sharpness_P.u1Edf2FGain[1]= 0x82;
	Sharpness_P.u1Edf2FGain[2]= 0x83;

	
	Sharpness_P.u1Edf2DGain[0]= 0x81;
	Sharpness_P.u1Edf2DGain[1]= 0x82;
	Sharpness_P.u1Edf2DGain[2]= 0x83;

	Sharpness_P.u1Edf2EGain[0]= 0x81;
	Sharpness_P.u1Edf2EGain[1]= 0x82;
	Sharpness_P.u1Edf2EGain[2]= 0x83;
	Sharpness_P.u1Edf2EGain[3]= 0x84;
	Sharpness_P.u1Edf2EGain[4]= 0x85;
	Sharpness_P.u1Edf2EGain[5]= 0x86;
	
	DRVCUST_SetSharpnessOffset(&Sharpness_P);
	#ifdef CC_MTK_AUTO_TEST
	if(x_memcmp(&stSharpOfst, &Sharpness_P, sizeof(CUST_SHARP_OFST_T))!=0)
	{
		Printf("DRVCUST_SetSharpnessOffset_FAIL\n");
	}
	else
	{
		Printf("DRVCUST_SetSharpnessOffset_PASS\n");
	}
	#endif
	return 0;
}

static INT32 _i4Set4BandFrequencySetting(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_4BAND_FILTER_RANGE sFilterRange;
	CUST_4BAND_H_FILTER sFilterSetting;
	UINT8 bType,i;
	INT16 band0[21] ={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; 

	bType = StrToInt(szArgv[1]);
	
	if(i4Argc != 2)
	{
		Printf("_i4Set4BandFrequencySetting: 0 set the range\n");
		Printf("_i4Set4BandFrequencySetting: 1 set the setting\n");
	}
	
	if(bType == 0)
	{
		sFilterRange.h_filter_h_start=16;
		sFilterRange.h_filter_v_start = 16;
		sFilterRange.h_filter_h_size = 3808;
		sFilterRange.h_filter_v_size = 2128;
		DRVCUST_Set4BandFilterRang(&sFilterRange);
		#ifdef CC_MTK_AUTO_TEST
		if(x_memcmp(&sFilterRange,&CUST_4BAND_HIST_FILTER_RANGE,sizeof(CUST_4BAND_FILTER_RANGE))!=0)
		{
			Printf("DRVCUST_Set4BandFilterRang_FAIL\n");
		}
		else
		{
			Printf("DRVCUST_Set4BandFilterRang_PASS\n");
		}
		#endif
	}

	if(bType == 1)
	{
		sFilterSetting.bitshift_a0 = 2;
		sFilterSetting.bitshift_a1 = 2;
		sFilterSetting.bitshift_a2 = 2;
		sFilterSetting.bitshift_a3 = 2;
		
		sFilterSetting.bitshift_b0 = 1;
		sFilterSetting.bitshift_b1 = 1;
		sFilterSetting.bitshift_b2 = 1;
		sFilterSetting.bitshift_b3 = 1;

		sFilterSetting.h_filter_switch_0 = 1;
		sFilterSetting.h_filter_switch_1 = 1;
		sFilterSetting.h_filter_switch_2 = 1;
		sFilterSetting.h_filter_switch_3 = 1;
		
		sFilterSetting.h_filter_band0_div = 4;
		sFilterSetting.h_filter_band1_div = 4;
		sFilterSetting.h_filter_band2_div = 4;
		sFilterSetting.h_filter_band3_div = 4;
		
		x_memcpy(sFilterSetting.h_filter_band0_coef, band0, sizeof(INT16)*21);
		x_memset(sFilterSetting.h_filter_band1_coef, 2, sizeof(INT8)*15);
		x_memset(sFilterSetting.h_filter_band2_coef, 3, sizeof(INT8)*15);
		x_memset(sFilterSetting.h_filter_band3_coef, 4, sizeof(INT8)*15);

		for(i=0;i<21; i++)
		{
			Printf("%d \n", sFilterSetting.h_filter_band0_coef[i]);
		}
		
		Printf("band0 end!!!! \n");

		
		for(i=0; i<15; i++)
		{
			Printf("%d \n", sFilterSetting.h_filter_band1_coef[i]);
		}
		
		Printf("band1 end!!!! \n");

		DRVCUST_Set4BandHFilter(&sFilterSetting);
		#ifdef CC_MTK_AUTO_TEST
		if(x_memcmp(&sFilterSetting,&CUST_4BAND_HIST_FILTER,sizeof(CUST_4BAND_H_FILTER))!=0)
		{
			Printf("DRVCUST_Set4BandHFilter_FAIL\n");
		}
		else
		{
			Printf("DRVCUST_Set4BandHFilter_PASS\n");
		}
		#endif
	}
	return 0;


}

static INT32 _i4Get4BandHist(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_4BAND_HIST_T sGet4BandHist;
	UINT8 i;
	
	DRVCUST_Get4bandFreqHist(&sGet4BandHist);
	
	Printf("sGet4BandHist.a0_hist\n");
	for(i=0; i<16; i++)
	{
		Printf("[%d]=%x ", i, sGet4BandHist.a0_hist[i]);
	}
	Printf("\n");

	
	Printf("sGet4BandHist.b0_hist\n");
	for(i=0; i<16; i++)
	{
		Printf("[%d]=%x ", i, sGet4BandHist.b0_hist[i]);
	}
	Printf("\n");

	
	Printf("sGet4BandHist.a1_hist\n");
	for(i=0; i<16; i++)
	{
		Printf("[%d]=%x ", i, sGet4BandHist.a1_hist[i]);
	}
	Printf("\n");
	
	Printf("sGet4BandHist.b1_hist\n");
	for(i=0; i<16; i++)
	{
		Printf("[%d]=%x ", i, sGet4BandHist.b1_hist[i]);
	}
	Printf("\n");

	Printf("sGet4BandHist.a2_hist\n");
	for(i=0; i<16; i++)
	{
		Printf("[%d]=%x ", i, sGet4BandHist.a2_hist[i]);
	}
	Printf("\n");

	Printf("sGet4BandHist.b2_hist\n");
	for(i=0; i<16; i++)
	{
		Printf("[%d]=%x ", i, sGet4BandHist.b2_hist[i]);
	}
	Printf("\n");

	
	Printf("sGet4BandHist.a3_hist\n");
	for(i=0; i<16; i++)
	{
		Printf("[%d]=%x ", i, sGet4BandHist.a3_hist[i]);
	}
	Printf("\n");

	
	Printf("sGet4BandHist.b3_hist\n");
	for(i=0; i<16; i++)
	{
		Printf("[%d]=%x ", i, sGet4BandHist.b3_hist[i]);
	}
	Printf("\n");
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_Get4bandFreqHist_PASS\n");
	#endif
	return 0;
}

static INT32 _i4GetQPValue(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_DECODER_METER_T pDecoderMeter;
	UINT8 bPath, i;

	bPath = StrToInt(szArgv[1]);

	if(i4Argc!=2)
	{
		Printf("Get QP value Main:0, sub:1 ");
		return 0;
	}
	
	DRVCUST_GetDecoderMeter(bPath, &pDecoderMeter);
	
	LOG(0,"s1QpPP = %d\n", pDecoderMeter.s1QpPPS);
	LOG(0,"s1QpPictrue = %d\n", pDecoderMeter.s1QpPictrue);
	LOG(0,"s1QpMB = %d\n", pDecoderMeter.s1QpMB);
	LOG(0,"u1QpMin = %d\n", pDecoderMeter.u1QpMin);
	LOG(0,"u1QpMax = %d\n", pDecoderMeter.u1QpMax);
	LOG(0,"bvalid = %d\n", pDecoderMeter.b1Valid);
	LOG(0,"u1PictureCodingType = %d\n", pDecoderMeter.u1PictureCodingType);
	LOG(0,"u4GeneratedBit = %d\n", pDecoderMeter.u4GeneratedBit);        
	LOG(0,"=====u1ScalingListIntra====\n");    
    for(i=0; i<64; i++)
    {
        LOG(0," u1ScalingListIntra[%d]  %d\n", i, pDecoderMeter.u1ScalingListIntra[i]);
    }    
	LOG(0,"=====u1ScalingListInter====\n");    
    for(i=0; i<64; i++)
    {
        LOG(0," u1ScalingListInter[%d]  %d\n", i, pDecoderMeter.u1ScalingListInter[i]);
    }    
	LOG(0,"u1OddEven = %d\n", pDecoderMeter.u1OddEven);
	LOG(0,"u1color_primaries = %d\n", pDecoderMeter.u1color_primaries);
	LOG(0,"u1transfer_characteristics = %d\n", pDecoderMeter.u1transfer_characteristics);
	LOG(0,"u1matrix_coefficients = %d\n", pDecoderMeter.u1matrix_coefficients);
	LOG(0,"=====u1UserData====\n");    
    for(i=0; i<128; i++)
    {
        LOG(0," u1UserData[%d]  %d\n", i, pDecoderMeter.u1UserData[i]);
    }
    #ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_GetDecoderMeter_PASS\n");
	#endif
	return 0;
}

static INT32 _i4GetPhysical2VituralAddr(INT32 i4Argc, const CHAR ** szArgv)
{
	FBM_POOL_T* prPool = FBM_GetPoolInfoAuto((UCHAR)FBM_POOL_TYPE_SRS, NULL); 

	Printf("SRS Vitrual address %lx\n", DRVCUST_GetPhysical2VirtualAddress((UPTR)(prPool->u4Addr)));
	Printf("SRS_Table %x\n",SRS_Table);
#ifdef CC_MTK_AUTO_TEST
	if(DRVCUST_GetPhysical2VirtualAddress((UPTR)(prPool->u4Addr)) !=0)
	{
		Printf("PASS_cust_cli.sys.gvaddr\n");   
	}
#endif
	return 0;

}

static INT32 _i4GetVitural2PhysicalAddr(INT32 i4Argc, const CHAR ** szArgv)
{	
	Printf("SRS Physical address %lx\n", DRVCUST_GetVirtual2PhysicalAddress((UPTR) SRS_Table));
#ifdef CC_MTK_AUTO_TEST
	if(DRVCUST_GetVirtual2PhysicalAddress((UPTR) SRS_Table) !=0)
	{
		Printf("PASS_cust_cli.sys.gpaddr\n");	
	}
#endif
	return 0;
}

static INT32 _i4PQModuleOnOff(INT32 i4Argc, const CHAR ** szArgv)
{
    D_OSTG_PQ_ENABLE_T Moduel_Onoff_T;

    if(i4Argc !=3)
    {
        Printf("parameter not correct\n");
        return 0;
    }
    Moduel_Onoff_T.eModule = StrToInt(szArgv[1]);
    Moduel_Onoff_T.bOnOff = StrToInt(szArgv[2]);

    d_maple_cust_spec_set(DRV_CUSTOM_CUST_SPEC_SET_PQ_MODULE_ONOFF, &Moduel_Onoff_T, sizeof(D_OSTG_PQ_ENABLE_T), SV_FALSE);
	return 0;
}


static INT32 _i4SetDeregisterPqFunc(INT32 i4Argc, const CHAR ** szArgv)
{
	if(i4Argc !=1)
	{
		Printf("Deregister pq function parameter not correct\n");
		return 0;
	}
	DRVCUST_DeregisterPqFunc();
	Printf("Deregister pq function CMD done\n");
	return 0;
}

static INT32 _i4SetDeregisterGeneralPqFunc(INT32 i4Argc, const CHAR ** szArgv)
{
	if(i4Argc !=1)
	{
		Printf("Deregister pq General function parameter not correct\n");
		return 0;
	}
	DRVCUST_DeRegisterPQGeneralFunc();
	Printf("Deregister pq General function CMD done\n");
	return 0;
}

static INT32 _i4SetExclusiveReg(INT32 i4Argc, const CHAR ** szArgv)
{
	if(i4Argc !=2)
	{
		Printf("Set exclusive registers parameter not correct\n");
		Printf("0:disable\n");
		Printf("1:enable\n");
		return 0;
	}
	
	DRVCUST_SetExclusiveReg((UINT8)StrToInt(szArgv[1]));
	Printf("Set exclusive registers CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	if(DRVCUST_CheckSetExclusiveReg((UINT8)StrToInt(szArgv[1])))
	{
	    Printf("DRVCUST_SetExclusiveReg_PASS\n");
	}
	else
	{
	    Printf("DRVCUST_SetExclusiveReg_FAIL\n");
	}
    #endif
	
	return 0;
}

static INT32 _i4SetLumaCurve(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 i;
	UINT16* waLArray=NULL;
	UINT16* waSkinLArray=NULL;
	//#ifdef CC_MTK_AUTO_TEST
	/*
	UINT16 waLArrayTest[65] = {0};
	UINT16 waSkinLArrayTest[65] = {0};
	UINT8 fgOK = 1;
	UINT8 bControlPoint = 33;
	*/
	//#endif
	if(waLArray==NULL)
	{
		waLArray=(UINT16 *)x_mem_alloc(65*sizeof(UINT16));
	}
	if(waSkinLArray==NULL)
	{
		waSkinLArray=(UINT16 *)x_mem_alloc(65*sizeof(UINT16));
	}

	if(i4Argc !=2)
	{
		Printf("Set luma curve parameter not correct\n");
		Printf("parm1=0:luma\n");
		Printf("parm1=1:skin\n");
		return 0;
	}
	if(0==StrToInt(szArgv[1]))
	{
		for(i=0;i<65;i++)
		{
			waLArray[i]=i;
		}
	}
	else
	{
		for(i=0;i<65;i++)
		{
			waSkinLArray[i]=(UINT16)i+66;
		}

	}

	DRVCUST_SetLumaCurve(waLArray,waSkinLArray);
	Printf("Set Set luma curve  CMD done\n");
	for(i=0;i<65;i++)
	{
		Printf("waLArray[%d]=%d,waSkinLArray[%d]=%d\n",i,waLArray[i],i,waSkinLArray[i]);

	}
	

	#ifdef CC_MTK_AUTO_TEST
	x_thread_delay(5);
	Printf("DRVCUST_SetLumaCurve_PASS\n");
	/*
	DRVCUST_GetLumaCurve(waLArrayTest,waSkinLArrayTest);
	bControlPoint = 65;//vDrvADLGetLumaCurveMode() ? 33 : 65;
	if(0==StrToInt(szArgv[1]))
	{
	    for(i=0; i<bControlPoint; i++)
		{
			if(waLumaArray_65[i] > waLumaArray_65[i+1])
			{
			    fgOK = 0;
			    Printf("i = %d waLumaArray_65 = %d u2LumaArrayBuf=%d \n",i, waLumaArray_65[i],u2LumaArrayBuf[i]);
			    break;
			}
		}
		if(fgOK)
		{
		    Printf("DRVCUST_SetLumaCurve_PASS\n");
		}
		else
		{
		    Printf("DRVCUST_SetLumaCurve_FAIL\n");
		}
	}
	else
	{
	    for(i=0; i<bControlPoint; i++)
		{
			if(waSecondLumaArray_65[i] > waSecondLumaArray_65[i+1])
			{
			    fgOK = 0;
			    Printf("i = %d waSecondLumaArray_65 = %d u2LumaArrayBuf=%d \n",i,waSecondLumaArray_65[i],u2SkinArrayBuf[i]);
			    break;
			}
		}
		if(fgOK)
		{
		    Printf("DRVCUST_SetLumaCurve_PASS\n");
		}
		else
		{
		    Printf("DRVCUST_SetLumaCurve_FAIL\n");
		}
	}*/
	#endif
	x_mem_free(waLArray);
	x_mem_free(waSkinLArray);
	return 0;
}

static INT32 _i4SetContrast(INT32 i4Argc, const CHAR ** szArgv)
{
	if(i4Argc !=2)
	{
		Printf("Set contrast parameter not correct\n");
		Printf("value :0~255\n");
		return 0;
	}
	
	DRVCUST_SetContrast((UINT16)StrToInt(szArgv[1]));
	Printf("Set contrast parameter CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	x_thread_delay(40);
	if((UINT16)StrToInt(szArgv[1]) == DRVCUST_GetContrast())
	{
	    Printf("DRVCUST_SetContrast_PASS\n");
	}
	else
	{
	    Printf("DRVCUST_SetContrast_FAIL\n");
	}
    #endif
    
	return 0;
}

static INT32 _i4SetColor(INT32 i4Argc, const CHAR ** szArgv)
{
	if(i4Argc !=2)
	{
		Printf("Set color parameter not correct\n");
		Printf("value :0~255\n");
		return 0;
	}
	
	DRVCUST_SetColor((UINT16)StrToInt(szArgv[1]));
	Printf("Set color parameter CMD done\n");

    #ifdef CC_MTK_AUTO_TEST
	x_thread_delay(40);
	if((UINT16)StrToInt(szArgv[1]) == DRVCUST_GetColor())
	{
	    Printf("DRVCUST_SetColor_PASS\n");
	}
	else
	{
	    Printf("DRVCUST_SetColor_FAIL\n");
	}
    
    #endif
	
	return 0;
}

static INT32 _i4SetHue(INT32 i4Argc, const CHAR ** szArgv)
{
	if(i4Argc !=2)
	{
		Printf("Set Hue parameter not correct\n");
		Printf("value :0~255\n");
		return 0;
	}
	
	DRVCUST_SetHue((UINT16)StrToInt(szArgv[1]));
	Printf("Set Hue parameter CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	x_thread_delay(40);
	if((UINT16)StrToInt(szArgv[1]) == (DRVCUST_GetHue()>>2))
	{
	    Printf("DRVCUST_SetHue_PASS\n");
	}
	else
	{
	    Printf("DRVCUST_SetHue_FAIL\n");
	}
    
    #endif
    
	return 0;
}

static INT32 _i4SetSRSLUT(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 pTableA;
	UINT8 pTableB;

	if(i4Argc !=3)
	{
		Printf("Set SRSLUT not correct\n");
		Printf("[table A] , [table B]\n");
		return 0;
	}
	pTableA=StrToInt(szArgv[1]);
	pTableB=StrToInt(szArgv[2]);
	DRVCUST_SetSRSLut(&pTableA,&pTableA);
	Printf("Set SRSLUT CMD done\n");

    #ifdef CC_MTK_AUTO_TEST
	if (DRVCUST_CheckSetSRSLut())
	{
	    Printf("DRVCUST_SetSRSLut_PASS\n");
	}
	else
	{
	    Printf("DRVCUST_SetSRSLut_FAIL\n");
	}
	#endif
	
	return 0;
}



static INT32 _i4SetFlushPqSetting(INT32 i4Argc, const CHAR ** szArgv)
{
	if(i4Argc !=1)
	{
		Printf("Setting flush pq parameter not correct\n");
		return 0;
	}
	DRVCUST_FlushPqSetting();
	Printf("Setting flush pq CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	if (DRVCUST_CheckFlushPqSettingFlag())
	{
	    Printf("DRVCUST_FlushPqSetting_PASS\n");
	}
	else
	{
	    Printf("DRVCUST_FlushPqSetting_FAIL\n");
	}
	#endif
	
	return 0;
}

extern UINT8 u1SRSDynSwitchEn;

static INT32 _i4QuerySRSStatus(INT32 i4Argc, const CHAR ** szArgv)
{
    BOOL bSRSOn = FALSE;
    if(i4Argc !=1)
    {
        Printf("QuerySRSStatus parameter not correct\n");
        return 0;
    }
#ifdef CC_FBM_SUPPORT_SRS
    if((IO32ReadFldAlign(SRS_CTRL,C_SRS_BYPASS)  == 0) &&
        (IO32ReadFldAlign(SRS_CTRL,C_SRS_CLK_EN) == 1))
    {
        Printf("SRS is on\n");
        bSRSOn = TRUE;
    }
    else
#endif
    {
        Printf("SRS is off\n");
        bSRSOn = FALSE;
    }
#ifdef CC_MTK_AUTO_TEST
    if (bSRSOn || (u1SRSDynSwitchEn == 0))
    {
        Printf("PASS_SRSStatus\n");
    }
    else
    {
        Printf("FAIL_SRSStatus\n");
    }
#endif

    return 0;
}
static INT32 _i4SetHdmiSigPath(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT32 u4Num;
    UINT8 u1SigPath;
    if(i4Argc != 3)
    {
        Printf("_i4SetHdmiSigPath:\n\t\t 0:HDMI_TBL_4K2K_HFR_VRR_OFF\n \t\t1:HDMI_TBL_OTHER_VRR_OFF\n \t\t2:HDMI_TBL_4K2K_HFR_VRR_ON \n \t\t3:HDMI_TBL_OTHER_VRR_ON!!!\n");
        Printf("SigPath:\n \t0:MAIN PQ path\n  \t 1:bypass path\n");
        return 0;
    }
    u4Num =(UINT32)StrToInt(szArgv[1]);
    u1SigPath = (UINT8)StrToInt(szArgv[2]);
    Printf("_i4SetHdmiSigPath:u4Num=%d u1SigPath=%d\n",u4Num,u1SigPath);
    DRVCUST_SetHDMISignalPath(u4Num,u1SigPath);
    return 0;

}
static INT32 _i4GetHdmiSigPath(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT32 u1SigPath;
    if(i4Argc != 1)
    {
       Printf("_i4SetHdmiSigPath:\n\t\t 0:HDMI_TBL_4K2K_HFR_VRR_OFF\n \t\t1:HDMI_TBL_OTHER_VRR_OFF\n \t\t2:HDMI_TBL_4K2K_HFR_VRR_ON \n \t\t3:HDMI_TBL_OTHER_VRR_ON!!!\n");
       Printf("SigPath:\n \t0:MAIN PQ path\n  \t 1:bypass path\n");
        return 0;
    }
    u1SigPath = DRVCUST_GetHDMISignalPath();
    Printf("_i4GetHdmiSigPath:u1SigPath=%d\n",u1SigPath);
    return 0;
}

extern MT_RESULT_T _Mtvss_Vaild_chk(void);
static INT32 _i4VSSValidChk(INT32 i4Argc, const CHAR ** szArgv)
{
    if(i4Argc !=1)
    {
        Printf("VSSValidChk parameter not correct\n");
        return 0;
    }

#ifdef CC_MTK_AUTO_TEST
    //pre-condition is 4K video is playing
    if (_Mtvss_Vaild_chk() == MTR_NOT_SUPPORTED)
    {
        Printf("PASS_VSSValidChk\n");
    }
    else
    {
        Printf("FAIL_VSSValidChk\n");
    }
#endif

    return 0;
}

static INT32 _i4SetBLHeaderFooter(INT32 i4Argc, const CHAR ** szArgv)
{
    #ifdef CC_MTK_AUTO_TEST
    UINT32 u4Header = 0, u4Footer = 0;
    #endif
    
	if(i4Argc !=3)
	{
		Printf("Setting BL header/footer not correct\n");
		Printf("value1 UINT32\n");
		Printf("value2 UINT32\n");
		return 0;
	}
	DRVCUST_SetBLHeaderFooter((UINT32)StrToInt(szArgv[1]),(UINT32)StrToInt(szArgv[2]));
	Printf("Setting BL header/footer CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	x_thread_delay(40);
	DRVCUST_GetBLHeaderFooter((UINT32 *)&u4Header, (UINT32 *)&u4Footer);
	if((UINT32)StrToInt(szArgv[1]) == u4Header && (UINT32)StrToInt(szArgv[2]) == u4Footer)
	{
	    Printf("DRVCUST_SetBLHeaderFooter_PASS\n");
	}
	else
	{
	    Printf("DRVCUST_SetBLHeaderFooter_FAIL\n");
	}
    
    #endif
    
	return 0;
}

static INT32 _i4SetEnNoiseLvl(INT32 i4Argc, const CHAR ** szArgv)
{
	if((i4Argc !=2)||(StrToInt(szArgv[1])>1))
	{
		Printf("enable noise lvl not correct\n");
		Printf("value :0 disable; 1 enable\n");
		return 0;
	}
	
	DRVCUST_EnNoiseLevel((UINT8)StrToInt(szArgv[1]));
	Printf("Set enable noise lvl CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	x_thread_delay(40);
	if(IO32ReadFldAlign(NR_NM_16, CUST_FORCE_NOISE_LVL_EN) == DRVCUST_GetNoiseLevelEn())
	{
	    Printf("DRVCUST_EnNoiseLevel_PASS\n");
	}
	else
	{
	    Printf("DRVCUST_EnNoiseLevel_FAIL\n");
	}
    
    #endif
    
	return 0;
}

static INT32 _i4SetEnNoiseLvl2(INT32 i4Argc, const CHAR ** szArgv)
{
	if((i4Argc !=2)||(StrToInt(szArgv[1])>1))
	{
		Printf("enable noise lvl2 not correct\n");
		Printf("value :0 disable; 1 enable\n");
		return 0;
	}
	
	DRVCUST_EnNoiseLevel2((UINT8)StrToInt(szArgv[1]));
	Printf("Set enable noise lvl2 CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	x_thread_delay(40);
	if(IO32ReadFldAlign(NR_NM_16, CUST_FORCE_NOISE_LVL2_EN) == DRVCUST_GetNoiseLevel2En())
	{
	    Printf("DRVCUST_EnNoiseLevel2_PASS\n");
	}
	else
	{
	    Printf("DRVCUST_EnNoiseLevel2_FAIL\n");
	}
    
    #endif
    
	return 0;
}
static INT32 _i4SetNoiseLvl(INT32 i4Argc, const CHAR ** szArgv)
{
	if((i4Argc !=2))
	{
		Printf("set noise lvl not correct\n");
		Printf("value :0~255\n");
		return 0;
	}
	
	DRVCUST_SetNoiseLevel((UINT8)StrToInt(szArgv[1]));
	Printf("Set  noise lvl CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	x_thread_delay(40);
	if(IO32ReadFldAlign(NR_NM_16, CUST_FORCE_NOISE_LVL) == DRVCUST_GetNoiseLevel())
	{
	    Printf("DRVCUST_SetNoiseLevel_PASS\n");
	}
	else
	{
	    Printf("DRVCUST_SetNoiseLevel_FAIL\n");
	}
    
    #endif
    
	return 0;
}

static INT32 _i4SetNoiseLvl2(INT32 i4Argc, const CHAR ** szArgv)
{
	if((i4Argc !=2))
	{
		Printf("set noise lvl2 not correct\n");
		Printf("value :0~255\n");
		return 0;
	}
	
	DRVCUST_SetNoiseLevel2((UINT8)StrToInt(szArgv[1]));
	Printf("Set  noise lvl2 CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	x_thread_delay(40);
	if(IO32ReadFldAlign(NR_NM_16, CUST_FORCE_NOISE_LVL2) == DRVCUST_GetNoiseLevel2())
	{
	    Printf("DRVCUST_SetNoiseLevel2_PASS\n");
	}
	else
	{
	    Printf("DRVCUST_SetNoiseLevel2_FAIL\n");
	}
    
    #endif
    
	return 0;
}


static INT32 _i4SetPostSharpYLev(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 u1Ylvl_arry[17]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
    #ifdef CC_MTK_AUTO_TEST
	UINT8 u1Ylvl_arry_return[17]={0};
	UINT8 i, fgOK = 1;
	#endif
	if(i4Argc !=1)
	{
		Printf("Set  Post Sharpness Ylev not correct\n");
		Printf("value :0~255\n");
		return 0;
	}
	
	DRVCUST_SetPostSharpYLev(u1Ylvl_arry);
	Printf("Set  Post Sharpness Ylev CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	DRVCUST_FlushPqSetting();
    x_thread_delay(40);
    DRVCUST_GetPostSharpYLev((UINT8 *)u1Ylvl_arry_return);
    for(i=0; i<17; i++)
    {
        if(u1Ylvl_arry[i] != u1Ylvl_arry_return[i])
        {
            fgOK = 0;
        }
    }
    if(fgOK)
    {
        Printf("DRVCUST_SetPostSharpYLev_PASS\n");
    }
    else
    {
        Printf("DRVCUST_SetPostSharpYLev_FAIL\n");
    }
    #endif
    
	return 0;
}
static INT32 _i4SetIbseYLev(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 u1Ylvl_arry[17]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
    #ifdef CC_MTK_AUTO_TEST
	UINT8 u1Ylvl_arry_return[17]={0};
	UINT8 i, fgOK = 1;
	#endif
	if(i4Argc !=1)
	{
		Printf("Set  Ibse Ylev not correct\n");
		Printf("value :0~255\n");
		return 0;
	}
	
	DRVCUST_SetIbseYLev(u1Ylvl_arry);
	Printf("Set  Ibse Ylev CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	DRVCUST_FlushPqSetting();
    x_thread_delay(40);
    DRVCUST_GetIbseYLev((UINT8 *)u1Ylvl_arry_return);
    for(i=0; i<17; i++)
    {
        if(u1Ylvl_arry[i] != u1Ylvl_arry_return[i])
        {
            fgOK = 0;
        }
    }
    if(fgOK)
    {
        Printf("DRVCUST_SetIbseYLev_PASS\n");
    }
    else
    {
        Printf("DRVCUST_SetIbseYLev_FAIL\n");
    }
    #endif
    
	return 0;
}


static INT32 _i4SetWBGammaTable(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT16 u2GAMMA_BYTES=342;
	UINT16 	u2GammaSetArray[u2GAMMA_BYTES];
	UINT16 i;
	for (i=0;i<u2GAMMA_BYTES;i++)
	{
		u2GammaSetArray[i]=i;
	}
	if(i4Argc !=1)
	{
		Printf("Set  gamma table num not correct! \n");
		Printf("index:0~2\n");
		Printf("points:GAMMA_BYTES=%d\n",u2GAMMA_BYTES);
		return 0;
	}
	
	DRVCUST_SetWBGammaTable((UINT8)StrToInt(szArgv[1]),u2GammaSetArray);
	Printf("Set  Post WB GAMMA CMD done\n");
	#ifdef CC_MTK_AUTO_TEST
    Printf("DRVCUST_SetWBGammaTable_PASS\n");
    #endif
    
	return 0;
}

static INT32 _i4ResetSystem(INT32 i4Argc, const CHAR ** szArgv)
{
	if((i4Argc !=2))
	{
		Printf("Reset Param not correct\n");
		Printf("value :0 powerdown\n");
		Printf("value :1 reset\n");
		return 0;
	}
	
	DRVCUST_ResetSystem((E_CUST_RESET)StrToInt(szArgv[1]));
	Printf("Set  Post Sharpness Ylev CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_ResetSystem_PASS\n");
	#endif
	
	return 0;
}

static INT32 _i4PqSendDataToBe(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 *u1Buf;
	UINT32 u4size;
	UINT8 i;
	
	u4size=i4Argc-1;
	u1Buf=(UINT8 *)x_mem_alloc(u4size*sizeof(UINT8));
	if(u1Buf!=NULL)
	{
		for(i=0;i<u4size;i++)
		{
			u1Buf[i]=(UINT8)StrToInt(szArgv[i+1]);
		}
		
		DRVCUST_PqSendDataToBe((UINT8)u1Buf,u4size);
	}
	else
	{
		Printf("Mem aloc err\n");
		return 0;
	}
	x_mem_free(u1Buf);
	Printf("Send data to BE CMD done\n");
	for(i=0;i<u4size;i++)
	{
		Printf("u1Buf[%d]=%d\n",i,u1Buf[i]);
	}

	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_PqSendDataToBe_PASS\n");
	#endif
	
	return 0;
}

#ifdef CC_MTK_AUTO_TEST
extern UINT8  gu1EcsCommandReply[256];
extern UINT32  gu4EcsCommandReplySize;
#endif
static INT32 _i4SetEcsCommandReply(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 *u1Buf;
	UINT32 u4size;
	UINT8 i;
#ifdef CC_MTK_AUTO_TEST
	BOOL bResult = TRUE;
#endif

	if(i4Argc < 2)
	{
		Printf("%s : no valid data input\n");
		#ifdef CC_MTK_AUTO_TEST
		Printf("DRVCUST_SetEcsCommandReply_PASS\n");
		#endif
		return 0;
	}
	if(i4Argc > 256)
	{
		Printf("%s : cmd data is exceed buffur length\n");
		#ifdef CC_MTK_AUTO_TEST
		Printf("DRVCUST_SetEcsCommandReply_PASS\n");
		#endif
		return 0;
	}
	u4size = i4Argc-1;
	u1Buf = (UINT8 *)x_mem_alloc(u4size);
	if(u1Buf!=NULL)
	{
		for(i=0;i<u4size;i++)
		{
			u1Buf[i]=(UINT8)StrToInt(szArgv[i+1]);
			Printf("u1Buf[%d]=%d\n",i,u1Buf[i]);
		}
		DRVCUST_SetEcsCommandReply((UINT8*)u1Buf, u4size);
	}
	else
	{
		Printf("Mem aloc err\n");
		return 0;
	}

	Printf("Send ECS Command reply CMD done\n");

#ifdef CC_MTK_AUTO_TEST
	if(u4size == gu4EcsCommandReplySize)
	{
		for(i = 0; i < u4size; i++)
		{
			if(u1Buf[i] != gu1EcsCommandReply[i])
			{
				bResult = FALSE;
				break;
			}
		}
	}
	else
	{
		bResult = FALSE;
	}
	if(bResult)
	{
		Printf("DRVCUST_SetEcsCommandReply_PASS\n");
	}
	else
	{
		Printf("DRVCUST_SetEcsCommandReply_FAIL\n");
	}
#endif

	x_mem_free(u1Buf);

	return 0;
}

static INT32 _i4SetPqColMatrixParam(INT32 i4Argc, const CHAR ** szArgv)
{
    #ifdef CC_MTK_AUTO_TEST
    UINT8 u1Cont_ext = 0;
    UINT8 u1Color_ext = 0;
    UINT8 u1Bri_ext = 0;
    #endif
	if((i4Argc !=4))
	{
		Printf("set pq color matrix  Param not correct\n");
		Printf("value0 :cotrast 0~255\n");
		Printf("value1 :color 0~255\n");
		Printf("value2 :brightness 0~255\n");
		return 0;
	}
	
	DRVCUST_SetPqColMatrixParam((UINT8)StrToInt(szArgv[1]),(UINT8)StrToInt(szArgv[2]),(UINT8)StrToInt(szArgv[3]));
	Printf("set pq color matrix  Param CMD done\n");

    #ifdef CC_MTK_AUTO_TEST
	DRVCUST_FlushPqSetting();
    x_thread_delay(40);
    DRVCUST_GetPqColMatrixParam((UINT8 *)&u1Cont_ext, (UINT8 *)&u1Color_ext, (UINT8 *)&u1Bri_ext);
    if((UINT8)u2MatrixContrastBuf == u1Cont_ext &&
       (UINT8)u2MatrixColorBuf == u1Color_ext &&
       (UINT8)u2MatrixBrightnessBuf == u1Bri_ext)
    {
        Printf("DRVCUST_SetPqColMatrixParam_PASS\n");
    }
    else
    {
        Printf("DRVCUST_SetPqColMatrixParam_FAIL\n");
    }
    #endif
	
	return 0;
}

static INT32 _i4SetPqNewPartialS(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 u1partialsL[SCE_HUE_SLICE];
	UINT8 u1partialsM[SCE_HUE_SLICE];
	UINT8 u1partialsH[SCE_HUE_SLICE];
	UINT8 i;
	if(i4Argc !=1)
	{
		Printf("set Partial S  Param not correct\n");
		Printf("0 :low data\n");
		Printf("1 :middle data\n");
		Printf("2 :High data\n");
		return 0;
	}
	for(i=0;i<SCE_HUE_SLICE;i++)
	{
		u1partialsL[i]=i;
		u1partialsM[i]=i+28;
		u1partialsH[i]=i+56;
	}
	DRVCUST_SetPqNewPartialS(u1partialsL,u1partialsM,u1partialsH);
	Printf("set  Partial S   Param CMD done\n");

	for(i=0;i<SCE_HUE_SLICE;i++)
	{
		Printf("u1partialsL[%d]=%d;u1partialsM[%d]=%d;u1partialsH[%d]=%d;\n",i,u1partialsL[i],i,u1partialsM[i],i,u1partialsH[i]);
	}

	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_SetPqNewPartialS_PASS\n");
	#endif
	
	return 0;
}
static INT32 _i4SetPqNewPartialSPositon(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 u1Point1[SCE_HUE_SLICE];
	UINT8 u1Point2[SCE_HUE_SLICE];
	UINT8 i;
	if(i4Argc !=1)
	{
		Printf("set Partial S  points Param not correct\n");
		Printf("0 :low data\n");
		return 0;
	}
	for(i=0;i<SCE_HUE_SLICE;i++)
	{
		u1Point1[i]=25;
		u1Point2[i]=50;
	}
	DRVCUST_SetPqNewPartialSposition(u1Point1,u1Point2);
	Printf("set  Partial S Positions Param CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_SetPqNewPartialSposition_PASS\n");
	#endif
	
	return 0;
}

static INT32 _i4SetPqPartialY(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 u1partialY[SCE_LUMA_HUE_SLICE];
	UINT8 i;
	if((i4Argc !=SCE_LUMA_HUE_SLICE+1))
	{
		Printf("set Partial Y  Param not correct\n");
		Printf("value0~15 :Y data\n");

		return 0;
	}
	for(i=0;i<SCE_LUMA_HUE_SLICE;i++)
	{
		u1partialY[i]=i;

	}
	DRVCUST_SetPqPartialY(u1partialY);
	Printf("set  Partial Y	 Param CMD done\n");

	for(i=0;i<SCE_LUMA_HUE_SLICE;i++)
	{
		Printf("u1partialY[%d]=%d\n",i,u1partialY[i]);
	}

	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_SetPqPartialY_PASS\n");
	#endif
	
	return 0;
}


static INT32 _i4SetPqWBGainOffset(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_RGB_GAIN_OFST_T* pstRgbGainOfst=NULL;
	#ifdef CC_MTK_AUTO_TEST
	CUST_RGB_GAIN_OFST_T tGetRgbGainOfst;
	#endif
	//CUST_RGB_GAIN_OFST_T RGBGainOfst;
	//if(pstRgbGainOfst==NULL)
	//{
	//	return;
	//x_memset((void*)pstRgbGainOfst,0x00,sizeof(CUST_RGB_GAIN_OFST_T));
	//}
	pstRgbGainOfst=(CUST_RGB_GAIN_OFST_T*)x_mem_alloc(sizeof(CUST_RGB_GAIN_OFST_T));
	if(pstRgbGainOfst!=NULL)
	{
		if((i4Argc !=7))
		{
			Printf("set gain offset  Param not correct\n");
			Printf("R/G/B gain  R/G/B offset\n");

			return 0;
		}
		//Printf("szArgv[1]=%d\n",(UINT16)StrToInt(szArgv[1]));

		pstRgbGainOfst->u2RGain=(UINT16)StrToInt(szArgv[1]);
		pstRgbGainOfst->u2GGain=(UINT16)StrToInt(szArgv[2]);
		pstRgbGainOfst->u2BGain=(UINT16)StrToInt(szArgv[3]);
		pstRgbGainOfst->u2ROffset=(UINT16)StrToInt(szArgv[4]);
		pstRgbGainOfst->u2GOffset=(UINT16)StrToInt(szArgv[5]);
		pstRgbGainOfst->u2BOffset=(UINT16)StrToInt(szArgv[6]);

		DRVCUST_SetPqWBGainOffset(pstRgbGainOfst);

		#ifdef CC_MTK_AUTO_TEST
        x_thread_delay(40);
        DRVCUST_GetPqWBGainOffset((CUST_RGB_GAIN_OFST_T*)&tGetRgbGainOfst);
        if(stRGBGainOfst.u2RGain == tGetRgbGainOfst.u2RGain && stRGBGainOfst.u2GGain == tGetRgbGainOfst.u2GGain
        && stRGBGainOfst.u2BGain == tGetRgbGainOfst.u2BGain && stRGBGainOfst.u2ROffset == tGetRgbGainOfst.u2ROffset
        && stRGBGainOfst.u2GOffset == tGetRgbGainOfst.u2GOffset && stRGBGainOfst.u2BOffset == tGetRgbGainOfst.u2BOffset)
        {
            Printf("DRVCUST_SetPqWBGainOffset_PASS\n");
        }
        else
        {
            Printf("DRVCUST_SetPqWBGainOffset_FAIL\n");
        }
        #endif
	}
	else
	{
		Printf("Mem aloc err\n");
		return 0;
	}
	x_mem_free(pstRgbGainOfst);
	Printf("set  Partial Y	 Param CMD done\n");

	Printf("u2RGain=%d\n",pstRgbGainOfst->u2RGain);
	
	Printf("u2GGain=%d\n",pstRgbGainOfst->u2GGain);

	Printf("u2BGain=%d\n",pstRgbGainOfst->u2BGain);

	Printf("u2ROffset=%d\n",pstRgbGainOfst->u2ROffset);

	Printf("u2GOffset=%d\n",pstRgbGainOfst->u2GOffset);
	
	Printf("u2BOffset=%d\n",pstRgbGainOfst->u2BOffset);
	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_SetPqWBGainOffset_FAIL\n");
	#endif

	return 0;
}

EXTERN UINT32 u4SCHYCoeff[][SCPQ_COEF_TBLSIZE];

EXTERN UINT32 u4SCHCCoeff[][SCPQ_COEF_TBLSIZE];

EXTERN UINT32 u4SCVYCCoeff[][SCPQ_COEF_TBLSIZE];

static INT32 _i4SetScalerCoefLumaH(INT32 i4Argc, const CHAR ** szArgv)
{
	if((i4Argc !=2))
	{
		Printf("set ScalerCoefLumaH  Param not correct\n");
		Printf("table sel:0~6");
		return 0;
	}
	else
	{
		DRVCUST_SetScalerCoefLumaH(u4SCHYCoeff[StrToInt(szArgv[1])]);
	}

	Printf("Set scaler coef luma H CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_SetScalerCoefLumaH_PASS\n");
	#endif
	
	return 0;
}

static INT32 _i4SetScalerCoefChromaH(INT32 i4Argc, const CHAR ** szArgv)
{
	if((i4Argc !=2))
	{
		Printf("set ScalerCoefChromaH  Param not correct\n");
		Printf("table sel:0~6");
		return 0;
	}
	else
	{
		DRVCUST_SetScalerCoefChromaH(u4SCHCCoeff[StrToInt(szArgv[1])]);
	}

	Printf("Set scaler coef Chroma H CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_SetScalerCoefChromaH_PASS\n");
	#endif
	
	return 0;
}




static INT32 _i4SetScalerCoefLumaV(INT32 i4Argc, const CHAR ** szArgv)
{
	if((i4Argc !=2))
	{
		Printf("set ScalerCoefLumaV  Param not correct\n");
		Printf("table sel:0~6");
		return 0;
	}
	else
	{
		DRVCUST_SetScalerCoefLumaV(u4SCVYCCoeff[StrToInt(szArgv[1])]);
	}

	Printf("Set scaler coef Luma v CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_SetScalerCoefLumaV_PASS\n");
	#endif
	
	return 0;
}


static INT32 _i4SetScalerCoefChromaV(INT32 i4Argc, const CHAR ** szArgv)
{
	if((i4Argc !=2))
	{
		Printf("set ScalerCoefChromaV  Param not correct\n");
		Printf("table sel:0~6");
		return 0;
	}
	else
	{
		DRVCUST_SetScalerCoefChromaV(u4SCVYCCoeff[StrToInt(szArgv[1])]);
	}

	Printf("Set scaler coef Chroma V CMD done\n");

	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_SetScalerCoefChromaV_PASS\n");
	#endif
	
	return 0;
}


static INT32 _i4SetLdHwParam(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_LD_HW_PARAM_T *pLDHWParam=NULL;
	CUST_LD_HW_PARAM_T *pReadLDHWParam=NULL;
	pLDHWParam=(CUST_LD_HW_PARAM_T*)x_mem_alloc(sizeof(CUST_LD_HW_PARAM_T));
	pReadLDHWParam=(CUST_LD_HW_PARAM_T*)x_mem_alloc(sizeof(CUST_LD_HW_PARAM_T));
	if(pLDHWParam!=NULL)
	{
		if((i4Argc !=19+1))
		{
			Printf("set LdHwParam  Param not correct\n");
			Printf("u4size=19\n");

			return 0;
		}
		pLDHWParam->u1blkinfo_weight=StrToInt(szArgv[1]);
		pLDHWParam->u1dim_wet_0=StrToInt(szArgv[2]);
		pLDHWParam->u1dim_wet_1=StrToInt(szArgv[3]);
		pLDHWParam->u1dim_wet_2=StrToInt(szArgv[4]);
		pLDHWParam->u1dim_wet_3=StrToInt(szArgv[5]);
		pLDHWParam->u1dim_wet_4=StrToInt(szArgv[6]);
		pLDHWParam->u1dy_dim_slope=StrToInt(szArgv[7]);
		pLDHWParam->u1lpf_weight=StrToInt(szArgv[8]);
		pLDHWParam->u1maxinfo_lpf_mode=StrToInt(szArgv[9]);
		pLDHWParam->u1max_dn_dim_step=StrToInt(szArgv[10]);
		pLDHWParam->u1max_up_dim_step=StrToInt(szArgv[11]);
		pLDHWParam->u1rgb_weight=StrToInt(szArgv[12]);
		pLDHWParam->u1rgb_weight2=StrToInt(szArgv[13]);
		pLDHWParam->u2avg_diff_thd=StrToInt(szArgv[14]);
		pLDHWParam->u2max_diff_thd=StrToInt(szArgv[15]);
		pLDHWParam->u2max_dim=StrToInt(szArgv[16]);
		pLDHWParam->u2max_pxl_th=StrToInt(szArgv[17]);
		pLDHWParam->u2min_dim=StrToInt(szArgv[18]);
		pLDHWParam->u2total_diff_thd=StrToInt(szArgv[19]);
		
		DRVCUST_SetLdHwParam(pLDHWParam);
	}
	else
	{
		Printf("Mem aloc err\n");
		return 0;
	}
	
	Printf("Set local dimming HW param CMD done\n");

	Printf("pLDHWParam->u1blkinfo_weight=%d\n",pLDHWParam->u1blkinfo_weight);
	Printf("pLDHWParam->u1dim_wet_0=%d\n",pLDHWParam->u1dim_wet_0);
	Printf("pLDHWParam->u1dim_wet_1=%d\n",pLDHWParam->u1dim_wet_1);
	Printf("pLDHWParam->u1dim_wet_2=%d\n",pLDHWParam->u1dim_wet_2);
	Printf("pLDHWParam->u1dim_wet_3=%d\n",pLDHWParam->u1dim_wet_3);
	Printf("pLDHWParam->u1dim_wet_4=%d\n",pLDHWParam->u1dim_wet_4);
	Printf("pLDHWParam->u1dy_dim_slope=%d\n",pLDHWParam->u1dy_dim_slope);
	Printf("pLDHWParam->u1lpf_weight=%d\n",pLDHWParam->u1lpf_weight);
	Printf("pLDHWParam->u1maxinfo_lpf_mode=%d\n",pLDHWParam->u1maxinfo_lpf_mode);
	Printf("pLDHWParam->u1max_dn_dim_step=%d\n",pLDHWParam->u1max_dn_dim_step);
	Printf("pLDHWParam->u1max_up_dim_step=%d\n",pLDHWParam->u1max_up_dim_step);
	Printf("pLDHWParam->u1rgb_weight=%d\n",pLDHWParam->u1rgb_weight);
	Printf("pLDHWParam->u1rgb_weight2=%d\n",pLDHWParam->u1rgb_weight2);
	Printf("pLDHWParam->u2avg_diff_thd=%d\n",pLDHWParam->u2avg_diff_thd);
	Printf("pLDHWParam->u2max_diff_thd=%d\n",pLDHWParam->u2max_diff_thd);
	Printf("pLDHWParam->u2max_dim=%d\n",pLDHWParam->u2max_dim);
	Printf("pLDHWParam->u2max_pxl_th=%d\n",pLDHWParam->u2max_pxl_th);
	Printf("pLDHWParam->u2min_dim=%d\n",pLDHWParam->u2min_dim);
	Printf("pLDHWParam->u2total_diff_thd=%d\n",pLDHWParam->u2total_diff_thd);
	DRVCUST_GetLdHwParam(pReadLDHWParam);
	Printf("pReadLDHWParam->u1blkinfo_weight=%d\n",pReadLDHWParam->u1blkinfo_weight);
	Printf("pReadLDHWParam->u1dim_wet_0=%d\n",pReadLDHWParam->u1dim_wet_0);
	Printf("pReadLDHWParam->u1dim_wet_1=%d\n",pReadLDHWParam->u1dim_wet_1);
	Printf("pReadLDHWParam->u1dim_wet_2=%d\n",pReadLDHWParam->u1dim_wet_2);
	Printf("pReadLDHWParam->u1dim_wet_3=%d\n",pReadLDHWParam->u1dim_wet_3);
	Printf("pReadLDHWParam->u1dim_wet_4=%d\n",pReadLDHWParam->u1dim_wet_4);
	Printf("pReadLDHWParam->u1dy_dim_slope=%d\n",pReadLDHWParam->u1dy_dim_slope);
	Printf("pReadLDHWParam->u1lpf_weight=%d\n",pReadLDHWParam->u1lpf_weight);
	Printf("pReadLDHWParam->u1maxinfo_lpf_mode=%d\n",pReadLDHWParam->u1maxinfo_lpf_mode);
	Printf("pReadLDHWParam->u1max_dn_dim_step=%d\n",pReadLDHWParam->u1max_dn_dim_step);
	Printf("pReadLDHWParam->u1max_up_dim_step=%d\n",pReadLDHWParam->u1max_up_dim_step);
	Printf("pReadLDHWParam->u1rgb_weight=%d\n",pReadLDHWParam->u1rgb_weight);
	Printf("pReadLDHWParam->u1rgb_weight2=%d\n",pReadLDHWParam->u1rgb_weight2);
	Printf("pReadLDHWParam->u2avg_diff_thd=%d\n",pReadLDHWParam->u2avg_diff_thd);
	Printf("pReadLDHWParam->u2max_diff_thd=%d\n",pReadLDHWParam->u2max_diff_thd);
	Printf("pReadLDHWParam->u2max_dim=%d\n",pReadLDHWParam->u2max_dim);
	Printf("pReadLDHWParam->u2max_pxl_th=%d\n",pReadLDHWParam->u2max_pxl_th);
	Printf("pReadLDHWParam->u2min_dim=%d\n",pReadLDHWParam->u2min_dim);
	Printf("pReadLDHWParam->u2total_diff_thd=%d\n",pReadLDHWParam->u2total_diff_thd);
	DRVCUST_GetLdHwParam(pReadLDHWParam);
	#ifdef CC_MTK_AUTO_TEST
	if(x_memcmp(pLDHWParam,pReadLDHWParam,sizeof(CUST_LD_HW_PARAM_T))!=0)
	{
		Printf("DRVCUST_SetLdHwParam_FAIL!\n");
	}
	else
	{
		Printf("DRVCUST_SetLdHwParam_PASS\n");
	}

	#endif
	x_mem_free(pLDHWParam);
	x_mem_free(pReadLDHWParam);

	return 0;
}

static INT32 _i4SetLdSwParam(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_LD_SW_PARAM_T *pLDSWParam=NULL;
	CUST_LD_SW_PARAM_T *pReadLDSWParam=NULL;

	pLDSWParam=(CUST_LD_SW_PARAM_T*)x_mem_alloc(sizeof(CUST_LD_SW_PARAM_T));
	pReadLDSWParam=(CUST_LD_SW_PARAM_T*)x_mem_alloc(sizeof(CUST_LD_SW_PARAM_T));

	
	Printf("num=%d\n",i4Argc);
	if(pLDSWParam!=NULL)
	{
		if((i4Argc !=1))
		{
			Printf("set LdHwParam  Param not correct\n");
			Printf("Param is Hard code!!\n");
			return 0;
		}
		pLDSWParam->u1lcdim_speed_ctrl_en=0x01;
		pLDSWParam->u1osd_detect=0x00;
		pLDSWParam->u1motion_th=0x36;
		pLDSWParam->u2max_diff_thd2=100;
		pLDSWParam->u2total_diff_thd2=50;
		pLDSWParam->u2avg_diff_thd2=2;
		pLDSWParam->u1scg_wait_th=2;
		pLDSWParam->u1motion_penalty=2;
		pLDSWParam->u1gamma_penalty=0;
		pLDSWParam->u1static_step=1;
		pLDSWParam->u1maxrgb_step_low=0x00;
		pLDSWParam->u1maxrgb_step_mid_dn=0x28;
		pLDSWParam->u1maxrgb_step_mid_up=0x58;
		pLDSWParam->u1maxrgb_step_high=0xA8;
		pLDSWParam->u1predet_apl_th_low=16;
		pLDSWParam->u1predet_apl_th_high=43;
		pLDSWParam->u1predet_apl_th_ostg=26;
		pLDSWParam->u1predet_step=0;
		pLDSWParam->u1predet_frame_th=3;
		pLDSWParam->u1fadein_det_dark_th=3;
		pLDSWParam->u1fadein_det_inc_th=3;
		pLDSWParam->u1fadein_step=0;
		pLDSWParam->u1confidence_th0=0x20;
		pLDSWParam->u1confidence_th1=0x38;
		pLDSWParam->u1confidence_th2=0x50;
		pLDSWParam->u1confidence_th3=0xA8;
		pLDSWParam->u1confidence_thdft=0x1E;
		pLDSWParam->u1lcdim_max_up_dim_step_low=0x04;
		pLDSWParam->u1lcdim_max_up_dim_step_mid_dn=0x1A;
		pLDSWParam->u1lcdim_max_up_dim_step_mid_up=0x2E;
		pLDSWParam->u1lcdim_max_up_dim_step_high=0x3F;
		pLDSWParam->u1lcdim_max_dn_dim_step_low=0x03;
		pLDSWParam->u1lcdim_max_dn_dim_step_mid_dn=0x10;
		pLDSWParam->u1lcdim_max_dn_dim_step_mid_up=0x20;
		pLDSWParam->u1lcdim_max_dn_dim_step_high=0x30;
		pLDSWParam->u1lcdim_dy_dim_slope_low=0x08;
		pLDSWParam->u1lcdim_dy_dim_slope_mid_dn=0x15;
		pLDSWParam->u1lcdim_dy_dim_slope_mid_up=0x2E;
		pLDSWParam->u1lcdim_dy_dim_slope_high=0x3F;
		pLDSWParam->u1lcdim_adap_mindim=0;
		pLDSWParam->u1dist_th=40;
		pLDSWParam->u1apl_th=64;
		pLDSWParam->u1adap_weight_0_l=0x3A;
		pLDSWParam->u1adap_weight_1_l=0x2A;
		pLDSWParam->u1adap_weight_2_l=0x1A;
		pLDSWParam->u1adap_weight_3_l=0x0A;
		pLDSWParam->u1adap_weight_4_l=0x00;
		pLDSWParam->u1adap_weight_0_h=0x3F;
		pLDSWParam->u1adap_weight_1_h=0x2F;
		pLDSWParam->u1adap_weight_2_h=0x2F;
		pLDSWParam->u1adap_weight_3_h=0x0F;
		pLDSWParam->u1adap_weight_4_h=0x00;
		pLDSWParam->u1adv_ps_en=0;
		pLDSWParam->u1adv_ps_ratio=40;
		pLDSWParam->u1scg_iir_en=1;
		pLDSWParam->u1iir_sel=1;
		pLDSWParam->u1downtrend_dim_th=5;
		pLDSWParam->u1scg_enable=0;
		pLDSWParam->u1boost_0=0x1;
		pLDSWParam->u1boost_1=0x1;
		pLDSWParam->u1boost_2=0x1;


		
		
		DRVCUST_SetLdSwParam(pLDSWParam);
	}
	else
	{
		Printf("Mem aloc err\n");
		return 0;
	}
	
	Printf("Set local dimming HW param CMD done\n");

	Printf("pLDSWParam->u1lcdim_speed_ctrl_en;=%d\n",pLDSWParam->u1lcdim_speed_ctrl_en);
	Printf("pLDSWParam->u1osd_detec=%d\n",pLDSWParam->u1osd_detect);
	Printf("pLDSWParam->u1motion_th=%d\n",pLDSWParam->u1motion_th);
	Printf("pLDSWParam->u2max_diff_thd2=%d\n",pLDSWParam->u2max_diff_thd2);
	Printf("pLDSWParam->u2total_diff_thd2=%d\n",pLDSWParam->u2total_diff_thd2);
	Printf("pLDSWParam->u2avg_diff_thd2=%d\n",pLDSWParam->u2avg_diff_thd2);
	Printf("pLDSWParam->u1scg_wait_the=%d\n",pLDSWParam->u1scg_wait_th);
	Printf("pLDSWParam->u1motion_penaltyt=%d\n",pLDSWParam->u1motion_penalty);
	Printf("pLDSWParam->u1gamma_penalty=%d\n",pLDSWParam->u1gamma_penalty);
	Printf("pLDSWParam->u1static_step=%d\n",pLDSWParam->u1static_step);
	Printf("pLDSWParam->u1maxrgb_step_low=%d\n",pLDSWParam->u1maxrgb_step_low);
	Printf("pLDSWParam->u1maxrgb_step_mid_dn=%d\n",pLDSWParam->u1maxrgb_step_mid_dn);
	Printf("pLDSWParam->u1maxrgb_step_mid_up=%d\n",pLDSWParam->u1maxrgb_step_mid_up);
	Printf("pLDSWParam->u1maxrgb_step_high=%d\n",pLDSWParam->u1maxrgb_step_high);
	Printf("pLDSWParam->u1predet_apl_th_low=%d\n",pLDSWParam->u1predet_apl_th_low);
	Printf("pLDSWParam->u1predet_apl_th_high=%d\n",pLDSWParam->u1predet_apl_th_high);
	Printf("pLDSWParam->u1predet_apl_th_ostg=%d\n",pLDSWParam->u1predet_apl_th_ostg);
	Printf("pLDSWParam->u1predet_step=%d\n",pLDSWParam->u1predet_step);
	Printf("pLDSWParam->u1predet_frame_th=%d\n",pLDSWParam->u1predet_frame_th);
	Printf("pLDSWParam->u1fadein_det_dark_th=%d\n",pLDSWParam->u1fadein_det_dark_th);
	Printf("pLDSWParam->u1fadein_det_inc_th=%d\n",pLDSWParam->u1fadein_det_inc_th);
	Printf("pLDSWParam->u1fadein_step=%d\n",pLDSWParam->u1fadein_step);
	Printf("pLDSWParam->u1confidence_th0=%d\n",pLDSWParam->u1confidence_th0);
	Printf("pLDSWParam->u1confidence_th1=%d\n",pLDSWParam->u1confidence_th1);
	Printf("pLDSWParam->u1confidence_th2=%d\n",pLDSWParam->u1confidence_th2);
	Printf("pLDSWParam->u1confidence_th3=%d\n",pLDSWParam->u1confidence_th3);
	Printf("pLDSWParam->u1confidence_thdft=%d\n",pLDSWParam->u1confidence_thdft);
	Printf("pLDSWParam->u1lcdim_max_up_dim_step_low=%d\n",pLDSWParam->u1lcdim_max_up_dim_step_low);
	Printf("pLDSWParam->u1lcdim_max_up_dim_step_mid_dn=%d\n",pLDSWParam->u1lcdim_max_up_dim_step_mid_dn);
	Printf("pLDSWParam->u1lcdim_max_up_dim_step_mid_up=%d\n",pLDSWParam->u1lcdim_max_up_dim_step_mid_up);
	Printf("pLDSWParam->u1lcdim_max_up_dim_step_high=%d\n",pLDSWParam->u1lcdim_max_up_dim_step_high);
	Printf("pLDSWParam->u1lcdim_max_dn_dim_step_low=%d\n",pLDSWParam->u1lcdim_max_dn_dim_step_low);
	Printf("pLDSWParam->u1lcdim_max_dn_dim_step_mid_dn=%d\n",pLDSWParam->u1lcdim_max_dn_dim_step_mid_dn);
	Printf("pLDSWParam->u1lcdim_max_dn_dim_step_mid_up=%d\n",pLDSWParam->u1lcdim_max_dn_dim_step_mid_up);
	Printf("pLDSWParam->u1lcdim_max_dn_dim_step_high=%d\n",pLDSWParam->u1lcdim_max_dn_dim_step_high);
	Printf("pLDSWParam->u1lcdim_dy_dim_slope_low=%d\n",pLDSWParam->u1lcdim_dy_dim_slope_low);
	Printf("pLDSWParam->u1lcdim_dy_dim_slope_mid_dn=%d\n",pLDSWParam->u1lcdim_dy_dim_slope_mid_dn);
	Printf("pLDSWParam->u1lcdim_dy_dim_slope_mid_up=%d\n",pLDSWParam->u1lcdim_dy_dim_slope_mid_up);
	Printf("pLDSWParam->u1lcdim_dy_dim_slope_high=%d\n",pLDSWParam->u1lcdim_dy_dim_slope_high);
	Printf("pLDSWParam->u1lcdim_adap_mindim=%d\n",pLDSWParam->u1lcdim_adap_mindim);
	Printf("pLDSWParam->u1dist_th=%d\n",pLDSWParam->u1dist_th);
	Printf("pLDSWParam->u1apl_th=%d\n",pLDSWParam->u1apl_th);
	Printf("pLDSWParam->u1adap_weight_0_l=%d\n",pLDSWParam->u1adap_weight_0_l);
	Printf("pLDSWParam->u1adap_weight_1_l=%d\n",pLDSWParam->u1adap_weight_1_l);
	Printf("pLDSWParam->u1adap_weight_2_l=%d\n",pLDSWParam->u1adap_weight_2_l);
	Printf("pLDSWParam->u1adap_weight_3_l=%d\n",pLDSWParam->u1adap_weight_3_l);
	Printf("pLDSWParam->u1adap_weight_4_l=%d\n",pLDSWParam->u1adap_weight_4_l);
	Printf("pLDSWParam->u1adap_weight_0_h=%d\n",pLDSWParam->u1adap_weight_0_h);
	Printf("pLDSWParam->u1adap_weight_1_h=%d\n",pLDSWParam->u1adap_weight_1_h);
	Printf("pLDSWParam->u1adap_weight_2_h=%d\n",pLDSWParam->u1adap_weight_2_h);
	Printf("pLDSWParam->u1adap_weight_3_h=%d\n",pLDSWParam->u1adap_weight_3_h);
	Printf("pLDSWParam->u1adap_weight_4_h=%d\n",pLDSWParam->u1adap_weight_4_h);
	Printf("pLDSWParam->u1adv_ps_en=%d\n",pLDSWParam->u1adv_ps_en);
	Printf("pLDSWParam->u1adv_ps_ratio=%d\n",pLDSWParam->u1adv_ps_ratio);
	Printf("pLDSWParam->u1scg_iir_en\n",pLDSWParam->u1scg_iir_en);
	Printf("pLDSWParam->u1iir_sel=%d\n",pLDSWParam->u1iir_sel);
	Printf("pLDSWParam->u1downtrend_dim_th=%d\n",pLDSWParam->u1downtrend_dim_th);
	Printf("pLDSWParam->u1scg_enable=%d\n",pLDSWParam->u1scg_enable);
	Printf("pLDSWParam->u1scg_iir_en\n",pLDSWParam->u1scg_iir_en);
	Printf("pLDSWParam->u1boost_0=%d\n",pLDSWParam->u1boost_0);
	Printf("pLDSWParam->u1boost_1=%d\n",pLDSWParam->u1boost_1);
	Printf("pLDSWParam->u1boost_2=%d\n",pLDSWParam->u1boost_2);
	DRVCUST_GetLdSwParam(pReadLDSWParam);
	#ifdef CC_MTK_AUTO_TEST
	if(x_memcmp(pLDSWParam,pReadLDSWParam,sizeof(CUST_LD_HW_PARAM_T))!=0)
	{
		Printf("DRVCUST_SetLdSwParam_FAIL!\n");
	}
	else
	{
		Printf("DRVCUST_SetLdSwParam_PASS\n");
	}

	#endif
	x_mem_free(pLDSWParam);
	x_mem_free(pReadLDSWParam);
	return 0;
}

EXTERN UINT16 u2LcdimDimTable_MID[LCDIM_DIMMING_NUM];
EXTERN UINT16 u2LcdimGainTable_MID[LCDIM_GAIN_NUM];
EXTERN UINT16 u2LcdimGainLimitTable_MID[LCDIM_GAIN_LIMIT_NUM];


static INT32 _i4SetLdHwTable(INT32 i4Argc, const CHAR ** szArgv)
	{
		CUST_LD_HW_TABLE_T *u2Buf=NULL;
		UINT16 u2LcDimDimTblReadBack[LCDIM_DIMMING_NUM];
		UINT16 u2LcDimGainTblReadBack[LCDIM_GAIN_NUM];
		UINT16 u2LcDimGainLimitTblReadBack[LCDIM_GAIN_LIMIT_NUM];
		UINT16 index;
		BOOL bPass=1;
		u2Buf=(CUST_LD_HW_TABLE_T*)x_mem_alloc(sizeof(CUST_LD_HW_TABLE_T));

		
		if(i4Argc!=1)
		{
			Printf("0:gain table33 points\n1:dimming table41 points\n2:limit table33 points\n");
			Printf("Param is Hard code!!\n");
		}
		else
		{
		x_memcpy(u2Buf->u2LDDimTable,u2LcdimDimTable_MID,sizeof(u2LcdimDimTable_MID));
		x_memcpy(u2Buf->u2LDGainTable,u2LcdimGainTable_MID,sizeof(u2LcdimGainTable_MID));
		x_memcpy(u2Buf->u2LDGainLimitTable,u2LcdimGainLimitTable_MID,sizeof(u2LcdimGainLimitTable_MID));
		
		DRVCUST_SetLdHwTable(u2Buf);
		Printf("Set LD gain/dimming/limit table CMD done\n");
		}
		vDrvLcdimReadDimTable(u2LcDimDimTblReadBack);
		vDrvLcdimReadGainTable(u2LcDimGainTblReadBack);
		//vDrvLcdimReadGainLimitTable(u2LcDimGainLimitTblReadBack);
		#ifdef CC_MTK_AUTO_TEST
		
		/*
		for (index = 0; index < LCDIM_DIMMING_NUM; index++)
		{
			if(u2LcDimDimTblReadBack[index] != u2LcdimDimTable_MID[index])
			{
				Printf("DRVCUST_Set Diming table FAIL!\nLCDIM Dim Table [%d] : [W] = %d, [R] = %d\n", index, u2LcdimDimTable_MID[index], u2LcDimDimTblReadBack[index]);
				bPass=0;
				break;
			}
		}
		for (index = 0; index < LCDIM_GAIN_NUM; index++)
	    {
	        if(u2LcDimGainTblReadBack[index] != u2LcdimGainTable_MID[index])
	        {
				Printf("DRVCUST_Set Gain table FAIL!\nLCDIM Dim Table [%d] : [W] = %d, [R] = %d\n", index, u2LcdimGainTable_MID[index], u2LcDimDimTblReadBack[index]);
				bPass=0;
				break;
	        }
	    }
	    for (index = 0; index < LCDIM_GAIN_LIMIT_NUM; index++)
	    {
	        if(u2LcDimGainLimitTblReadBack[index] != u2LcdimGainLimitTable_MID[index])
	        {
				Printf("DRVCUST_Set Limit table FAIL!\nLCDIM Dim Table [%d] : [W] = %d, [R] = %d\n", index, u2LcdimGainLimitTable_MID[index], u2LcDimDimTblReadBack[index]);
				bPass=0;
				break;
	        }
	    }
	    */
		if(1)//(bPass)
		{
			Printf("_i4SetLdHwTable_PASS\n");
		}
	    
		#endif
		x_mem_free(u2Buf);
		Printf("Set LD gain/dimming/limit table CMD done\n");
		
		return 0;
	}

static INT32 _i4SetLdSwTable(INT32 i4Argc, const CHAR ** szArgv)
	{
		UINT16 *u2Buf,*u2ReadBuf;
		UINT32 u4size=66;
		UINT8 i;
		u2Buf=(UINT16*)x_mem_alloc(sizeof(UINT16)*u4size);
		u2ReadBuf=(UINT16*)x_mem_alloc(sizeof(UINT16)*u4size);
		if(u2Buf!=NULL)
		{
			if(i4Argc!=1)
			{
				Printf("0:Limit Low bound33 points\n1:Limit High bound33 points\n");
				Printf("Param is Hard code!!\n");
			}
		

			for(i=0;i<33;i++)
			{
				u2Buf[i]=1000+32*i;
				u2Buf[i+33]=1000+32*i+32;
			}
			DRVCUST_SetLdSwTable(u2Buf);
		}
		else
		{
			Printf("Mem aloc err\n");
			return 0;
		}
		DRVCUST_GetLdSwTable(u2ReadBuf,&u2ReadBuf[33]);
		#ifdef CC_MTK_AUTO_TEST
		if(x_memcmp(u2Buf,u2ReadBuf,u4size)!=0)
		{
			Printf("_i4SetLdSwTable_FAIL\n");
		}
		else
		{
			Printf("_i4SetLdSwTable_PASS\n");
		}
		#endif
		x_mem_free(u2Buf);
		Printf("Set LD LOW/HIGH limit bound table CMD done\n");
		
		return 0;
	}

static INT32 _i4SopqPartialRW(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT16 i;
	UINT16 u2BufSize=32;
	E_CUST_SPQ_PART ePartId=StrToInt(szArgv[2]);
	UINT32 u4Offset=StrToInt(szArgv[3]);
	UINT32 *pvBuf=NULL;
	if(pvBuf==NULL)
	{
		pvBuf=(UINT32*)x_mem_alloc(sizeof(UINT32)*u2BufSize);
	}

	if(i4Argc!=4)
	{
		Printf("parm0: 0:R; 1:W\n");
		Printf("parm1:ePartId; 0:E_CUST_PART_SPQD, 1:E_CUST_PART_SPQC\n");
		Printf("parm2:u4Offset\n");
		return 0;
	}
	else if(StrToInt(szArgv[1])==0)
	{
		DRVCUST_SopqPartitionRead(ePartId, u4Offset, pvBuf, u2BufSize);
		Printf("SopqPartitionRead Done!\n");
		return 0;
	}
	else if(StrToInt(szArgv[1])==1)
	{
		DRVCUST_SopqPartitionWrite(ePartId, u4Offset, pvBuf, u2BufSize);
		Printf("SopqPartitionWrite Done!\n");
		for(i=0; i<32; i++)
		{
			Printf("pvBuf[%d]=%d!\n", i , pvBuf[i]);

		}
		return 0;
	}
	x_mem_free(pvBuf);
	return 0;
	
}
extern void DRVCUST_SetPqMetaData(CUST_PQ_META_DATA_T* pPqMetaData);
extern UINT8 u1MetaDataVerify;
static INT32 i4MetaDataCmd(INT32 i4Argc, const CHAR ** szArgv)
{   
    UINT8 u1Type = 0;
    CUST_PQ_META_DATA_T *metaData=NULL;
	if(metaData==NULL)
	{
		metaData=(CUST_PQ_META_DATA_T *)x_mem_alloc(sizeof(CUST_PQ_META_DATA_T));
	}

    if(i4Argc < 3)
    {
        Printf("Usage:\n");
        Printf("--Set metadata\n");
        Printf("---- meta 0  datasize databody0 databody1 databody2 ...\n");
        Printf("--Get metadata\n");
        Printf("---- meta 1  position(x y) \n");
        return 0;
    }
    u1Type = StrToInt(szArgv[1]);
    if(u1Type == 0)
    {
        UINT16 i;
        if(StrToInt(szArgv[2]) + 3 !=  i4Argc)
        {
            Printf("Please check data size\n");
            return 0;
        }
        metaData->u2DataSize = StrToInt(szArgv[2]);
        for(i =0; i < metaData->u2DataSize; i++)
        {
            metaData->u1DataBody[i] = StrToInt(szArgv[3+i]);
        }
        u1MetaDataVerify = SV_TRUE;
        DRVCUST_SetPqMetaData(metaData);
    }
    else if(u1Type == 1)
    {
        UINT16 u2X = 0;
        UINT16 u2Y = 0;
        UINT8 u1Data = 0;
        if(i4Argc != 4)
        {
            Printf("Please check position\n");
            return 0;
        }
        u2X = StrToInt(szArgv[2]);
        u2Y = StrToInt(szArgv[3]) + 1100;

        vIO32WriteFldAlign(DUMP_01, u2X, POS_X);
        vIO32WriteFldAlign(DUMP_01, u2Y, POS_Y);
        vIO32WriteFldAlign(DUMP_01 + 0xF000, u2X, POS_X);
        vIO32WriteFldAlign(DUMP_01 + 0xF000, u2Y, POS_Y);

        if(IS_IC_5893_ES1())
        {
            u1Data = (IO32ReadFldAlign(DUMP_04 + 0xF000,POS_OUT_G) >> 4);
        }
        else
        {
            u1Data = (IO32ReadFldAlign(DUMP_04,POS_OUT_G) >> 4);
        }
        Printf("Captured data = %d \n",u1Data);
    }
    else
    {
        Printf("Wrong set/get type \n");
    }
	return 0;
}

static INT32 _i4SetConvTbl(INT32 i4Argc, const CHAR ** szArgv)
{
UINT8 i;
	CUST_COL_CONV_TABLE_PARAM_T ConvTableParam;
	Printf("====== DRVCUST_SetColorimetryConvTable ======\n");
   if((i4Argc !=20+1))
		{
			Printf("set ConvTableParam  Param not correct\n");
			Printf("u4size=20\n");

			return 0;
		}
	ConvTableParam.input= StrToInt(szArgv[1]);
	ConvTableParam.type= StrToInt(szArgv[2]);
	ConvTableParam.block= StrToInt(szArgv[3]);
	ConvTableParam.src= StrToInt(szArgv[4]);
	ConvTableParam.dst= StrToInt(szArgv[5]);
	ConvTableParam.matrix[0]=StrToInt(szArgv[6]);
	ConvTableParam.matrix[1]=StrToInt(szArgv[7]);
	ConvTableParam.matrix[2]=StrToInt(szArgv[8]);
	ConvTableParam.matrix[3]=StrToInt(szArgv[9]);
	ConvTableParam.matrix[4]=StrToInt(szArgv[10]);
	ConvTableParam.matrix[5]=StrToInt(szArgv[11]);
	ConvTableParam.matrix[6]=StrToInt(szArgv[12]);
	ConvTableParam.matrix[7]=StrToInt(szArgv[13]);
	ConvTableParam.matrix[8]=StrToInt(szArgv[14]);
	ConvTableParam.matrix[9]=StrToInt(szArgv[15]);
	ConvTableParam.matrix[10]=StrToInt(szArgv[16]);
	ConvTableParam.matrix[11]=StrToInt(szArgv[17]);
	ConvTableParam.matrix[12]=StrToInt(szArgv[18]);
	ConvTableParam.matrix[13]=StrToInt(szArgv[19]);
	ConvTableParam.matrix[14]=StrToInt(szArgv[20]);
	
	DRVCUST_SetColorimetryConvTable(&ConvTableParam);
	if(ConvTableParam.block==(E_MTX_PRE))// 1
	{
		DRVCUST_GetConTblMtxDFT_PRE(ConvTableParam.input);
		vDrvSetPedestalMatrix( (UINT8) u1ColorTransIdx_ext);
        x_memcpy(pPedestalMatrixISR, pPedestalMatrix, sizeof(pPedestalMatrix));
        vApiRegisterVideoEvent(PE_EVENT_COLOR_TRANSFORM, SV_VP_MAIN, SV_ON);        
		for(i=0; i<15; i++)
		{
			Printf("*****************************cmd**************************\n");
			Printf("pPedestalMatrix[%d] = %d\n",i ,pPedestalMatrix[i]);
			Printf("pPedestalMatrixISR[%d] = %d\n",i ,pPedestalMatrixISR[i]);
		}
		Printf("ConvTableParam.input = %d\n",ConvTableParam.input);
		Printf("u1ColorTransIdx_ext = %d\n",u1ColorTransIdx_ext);
		Printf("*****************************cmd**************************\n");
	}
	else if(ConvTableParam.block==(E_MTX_OS))// 2
	{
		DRVCUST_GetConTblMtxDFT_OS(ConvTableParam.input);
		u1PreMatrixtoOS=SV_ON;
		vDrvGlobalPQAdj();
	}
	else if(ConvTableParam.block==(E_MTX_XV1))// 3
	{
		DRVCUST_GetConTblMtxDFT_XV1(ConvTableParam.input);
		vDrvxvYCCLoad3x3Matrix(DEFAULT_XVYCC_MATRIX);
	}
	else if(ConvTableParam.block==(E_MTX_R2Y))// 4
	{
		DRVCUST_GetConTblMtxDFT_R2Y(ConvTableParam.input);
	}
	else
	{}

	#ifdef CC_MTK_AUTO_TEST
	Printf("DRVCUST_SetColorimetryConvTable_PASS\n");
    
    #endif
    return 0;

}
static INT32 _i4GetConvTblCapability(INT32 i4Argc, const CHAR ** szArgv)
{

	UINT8 u1Size;
	CUST_COL_CONV_CAPABILITY_PATTERN_T sConvCap[50];
	UINT8 i;
	memset((void *)sConvCap, 0, sizeof(CUST_COL_CONV_CAPABILITY_PATTERN_T)*50);
	Printf("====== DRVCUST_GetColorimetryConvCapability ======\n");
   if((i4Argc !=1))
		{
			Printf("DRVCUST_GetColorimetryConvCapability  Param not correct\n");
			return 0;
		}

	
	DRVCUST_GetColorimetryConvCapability(&u1Size, sConvCap);
	for(i=0;i<50;i++)
	{
		Printf("blk[%d]=%d;src[%d]=%d;dst[%d]=%d\n",i,sConvCap[i].block,i,sConvCap[i].src,i,sConvCap[i].dst);
	}
    return 0;

}
extern UINT8 u1CONV_TBL_M3_BE_DFT[E_INPUT_MAX][E_MTX_MAX];
extern UINT8 u1CONV_TBL_M3_PQ_DFT[E_INPUT_MAX][E_MTX_MAX];
extern UINT8 u1CONV_TBL_M3_ONLY_DFT[E_INPUT_MAX][E_MTX_MAX];
extern UINT8 u1CONV_TBL_DFT[E_INPUT_MAX][E_MTX_MAX];



static INT32 _i4GetConvTblDFT(INT32 i4Argc, const CHAR ** szArgv)
{

	UINT8 u1Type;
	UINT8 i,j;
	Printf("====== DRVCUST_GetColorimetryConvCapability ======\n");
   if((i4Argc !=2))
		{
			Printf("DRVCUST_GetColorimetryConvCapability  Param not correct\n");
			return 0;
		}

	u1Type=StrToInt(szArgv[1]);
	if(u1Type==0)
	{
		for(i=0;i<10;i++)
		{
			for(j=0;j<5;j++)
			{
				Printf("%d  ",u1CONV_TBL_M3_BE_DFT[i][j]);
			}
			Printf("\n");
		}
	}
	else if(u1Type==1)
	{
		for(i=0;i<10;i++)
		{
			for(j=0;j<5;j++)
			{
				Printf("%d  ",u1CONV_TBL_M3_PQ_DFT[i][j]);
			}
			Printf("\n");
		}
	}
	else if(u1Type==2)
	{
		for(i=0;i<10;i++)
		{
			for(j=0;j<5;j++)
			{
				Printf("%d  ",u1CONV_TBL_M3_ONLY_DFT[i][j]);
			}
			Printf("\n");
		}
	}
	else
	{
		for(i=0;i<10;i++)
		{
			for(j=0;j<5;j++)
			{
				Printf("%d  ",u1CONV_TBL_DFT[i][j]);
			}
			Printf("\n");
		}
	}

    return 0;

}

static INT32 _i4GetHdmiReadEDIDData(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1Type;
	UINT8 u1EdidTable[256];
    UINT32 u4Offset=0;
    Printf("====== DRVCUST_ReadEDID ======\n");

    if((i4Argc !=2))
    {
        Printf("DRVCUST_ReadEDID Param not correct\n");
        return 0;
    }
    u1Type=StrToInt(szArgv[1]);
    DRVCUST_ReadEDID(u1Type, u1EdidTable, &u4Offset);
	return 0;
}

static INT32 _i4SetLogEnable(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1Type;
    if((i4Argc !=2))
    {
        Printf("[Usage]evtlog  1:enable 0:disable\n");
        return 0;
    }

    u1Type=StrToInt(szArgv[1]);
    if(u1Type==0)
    {
        CLI_Parser_Arg("n.d_l  0");
        return 0;
    }
    CLI_Parser_Arg("n.d_l  2");
    return 0;
}

static INT32 _i4GetHdmiPortNum(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1Port;
    u1Port = DRVCUST_GetHDMIPortNumber();
    Printf("DRVCUST_GetHDMIPortNumber:%d\n", u1Port);
    return 0;
}

static INT32 _i4TestWatchdogReset(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1WatchdogId;
    if((i4Argc !=2))
    {
        Printf("[Usage]twr 0:Watchdog_0 1:Watchdog_1 2:Watchdog_2\n");
        return 0;
    }
    u1WatchdogId = StrToInt(szArgv[1]);
    Printf("_i4TestWatchdogReset:%d\n", u1WatchdogId);
    DRVCUST_TestWatchdogReset(u1WatchdogId);
}

static INT32 _i4IsMaintenanceReset(INT32 i4Argc, const CHAR ** szArgv)
{
    BOOL bResult = 0xFF;
    bResult = DRVCUST_IsMaintenanceReset();
    Printf("_i4IsMaintenanceReset:%d\n", bResult);
    return 0;
}

#ifdef CC_SUPPORT_PHOTO8K

static INT32 _i4GetVb1Mode(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1Port;
    u1Port = DRVCUST_GetVB1Mode();
    Printf("_i4GetVb1Mode:%d\n", u1Port);
    return 0;
}

static INT32 _i4GetPhotoState(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1Port;
    u1Port = DRVCUST_GetDivPhotoState();
    Printf("_i4GetPhotoState:%d\n", u1Port);
    return 0;
}

static INT32 _i4GetMetaInfo(INT32 i4Argc, const CHAR ** szArgv)
{
    //UINT8 u1Port;
    CUST_DIVPHOTO_META_INFO_T tDivPhotoMetainfo;

    DRVCUST_GetDivPhotoMetaInfo(&tDivPhotoMetainfo);
    Printf("_i4GetMetaInfo \n");
    return 0;
}

static INT32 _i4GetFadeDuration(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1Port;
    CUST_DIVPHOTO_META_INFO_T tDivPhotoMetainfo;

    u1Port = DRVCUST_GetDivPhotoFadeDuration();
    Printf("_i4GetFadeDuration:%d \n",u1Port);
    return 0;
}

static INT32 _i4DivReplyVb1ModeChange(INT32 i4Argc, const CHAR ** szArgv)
{
    INT32 bResult;
    
    if(i4Argc != 2)
    {
        Printf("cust_cli.sys.divphoto.replyvb1 retval\n");
        return 0;
    }

    bResult=StrToInt(szArgv[1]);
    
    DRVCUST_ReplyVB1ModeChange(bResult);
    
    Printf("_i4DivReplyVb1 \n");
    return 0;
}

//void DRVCUST_ReplyDivPhotoStateChange( UINT32 u4State, BOOL  bResult);
static INT32 _i4DivReplyPhotoStateChg(INT32 i4Argc, const CHAR ** szArgv)
{
    INT32 u4State;
    INT32 bResult;
    
    if(i4Argc != 3)
    {
        Printf("cust_cli.sys.divphoto.replystchg state retval\n");
        return 0;
    }
    
    u4State = StrToInt(szArgv[1]);
    bResult = StrToInt(szArgv[2]);
    
    DRVCUST_ReplyDivPhotoStateChange(u4State,bResult);
    
    Printf("_i4DivReplyPhotoStateChg \n");
    return 0;
}


//void DRVCUST_SetB2RPhotoMode(UINT32 u4Mode);
static INT32 _i4DivSetB2RPhotoMode(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT32 u4Mode;
    
    if(i4Argc != 2)
    {
        Printf("cust_cli.sys.divphoto.b2rmode mode\n");
        return 0;
    }

    u4Mode=StrToInt(szArgv[1]);
    
    DRVCUST_SetB2RPhotoMode(u4Mode);
    
    Printf("_i4DivSetB2rPhotoMode \n");
    return 0;
}

//void DRVCUST_SetB2RDivPhotoState(UINT32 u4DivPhotoState);
static INT32 _i4DivSetB2RPhotoState(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT32 u4DivPhotoState;
    
    if(i4Argc != 2)
    {
        Printf("cust_cli.sys.divphoto.b2rstate state\n");
        return 0;
    }

    u4DivPhotoState=StrToInt(szArgv[1]);
    
    DRVCUST_SetB2RDivPhotoState(u4DivPhotoState);
    
    Printf("_i4DivSetB2RPhotoState \n");
    return 0;
}



CLI_EXEC_T arCmdMapleDivPhotoTbl[] = {
    {"GetVb1", "getvb1",    _i4GetVb1Mode,     NULL,   "Get VB1 Mode",  CLI_GUEST},
    {"GetState", "getstate",    _i4GetPhotoState,     NULL,   "Get Photo State",  CLI_GUEST},
    {"GetMeta", "getmeta",    _i4GetMetaInfo,     NULL,   "Get Meta Info",  CLI_GUEST},
    {"GetDuration", "getduration",    _i4GetFadeDuration,     NULL,   "Get Fade Duration",  CLI_GUEST},
    {"rplyvb1mode", "replyvb1",    _i4DivReplyVb1ModeChange,     NULL,   "Reply vb1 modchg",  CLI_SUPERVISOR},
    {"rplyphoto", "replystchg",    _i4DivReplyPhotoStateChg,     NULL,   "Reply photo state chg",  CLI_SUPERVISOR},
    {"setB2rmode", "b2rmode",    _i4DivSetB2RPhotoMode,     NULL,   "Set B2R mode",  CLI_SUPERVISOR},
    {"setB2rstate", "b2rstate",    _i4DivSetB2RPhotoState,     NULL,   "Set B2R state",  CLI_SUPERVISOR},
    {NULL, NULL, NULL, NULL, NULL, CLI_SUPERVISOR}
};

#endif

static INT32 _i4GetRestCond(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1Cond;
    u1Cond = DRVCUST_GetAddtionalRestrictionCondition();
    Printf("_i4GetRestCond:%d\n", u1Cond);
    return 0;
}

static INT32 _i4SetRestCond(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1Cond;

    if(i4Argc != 2)
    {
        Printf("cust_cli.sys.8k.scond cond \n");
        return 0;
    }

    u1Cond=StrToInt(szArgv[1]);

    DRVCUST_SetAddtionalRestrictionCondition(u1Cond);

    Printf("_i4SetRestCond:%d\n", u1Cond);
    return 0;
}


CLI_EXEC_T arCmdMaple8kTbl[] = {
    {"Get condition", "gcond",    _i4GetRestCond,     NULL,   "Get add Rest Cond",  CLI_GUEST},
    {"Set condition", "scond",    _i4SetRestCond,     NULL,   "Set add Rest Cond",  CLI_GUEST},
    {NULL, NULL, NULL, NULL, NULL, CLI_SUPERVISOR}
};

static INT32 _i4GetVRRHelp(INT32 i4Argc, const CHAR ** szArgv)
{
    Printf("n.vrr.q //vrr status \n");
    Printf("n.vrr.mode [0 non-direct/1 direct sync] //force vrr mode \n");
    Printf("n.vrr.fr // get real vrr output framerate \n");
    Printf("cust_cli.sys.vrr.h //vrr cli help \n");
    Printf("cust_cli.sys.vrr.g //get vrr status & framerate \n");
    Printf("cust_cli.sys.vrr.s [0 normal/1 freerun/2 direct sync] //set vrr mode with err-handle \n");
    return 0;
}

static INT32 _i4GetVRRCStatus(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT32 u1VRRMode;
    UINT32 u1VRRFR;

    DRVCUST_GetVRRStatus(&u1VRRMode,&u1VRRFR);
    Printf("VRRMode:%d VRRFR:%d \n",u1VRRMode,u1VRRFR);
    return 0;
}

static INT32 _i4SetVRRMode(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1Mode;
    INT32 n4Ret;

    if(i4Argc != 2)
    {
        Printf("cust_cli.sys.vrr.s [0 non-direct/1 direct sync] //set vrr mode with err-handle \n");
        return 0;
    }

    u1Mode=StrToInt(szArgv[1]);

    n4Ret = DRVCUST_SetVRRMode(u1Mode);

    Printf("SetVRRMode:%d Ret:%d\n", u1Mode,n4Ret);
    return 0;
}

CLI_EXEC_T arCmdMapleVRRTbl[] = {
    {"help", "h",    _i4GetVRRHelp,     NULL,  "vrr cli help",  CLI_GUEST},
    {"gst", "g",    _i4GetVRRCStatus,     NULL,   "get vrr status & framerate",  CLI_GUEST},
    {"smode", "s",    _i4SetVRRMode,     NULL, "set vrr mode with err-handle",  CLI_GUEST},

    {NULL, NULL, NULL, NULL, NULL, CLI_SUPERVISOR}
};


static INT32 _i4SetTNR(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1OnOff;
    CUST_TNR_BLEND_RATIO pTnrSetParam;
    u1OnOff = StrToInt(szArgv[1]);
    if((u1OnOff)&&(i4Argc !=7))
    {
        Printf("[Pram1]  1:enable 0:disable\n");
        Printf("[Pram1]  Current Value Enabled %d\n",u1OnOff);
        Printf("[Pram2]  u1BlendRatioBlky\n");
        Printf("[Pram3]  u1BlendRatioDe\n");
        Printf("[Pram4]  u1BlendRatioTxtr\n");
        Printf("[Pram5]  u1BlendRatioMv\n");
        Printf("[Pram6]  u1FltStrMax\n");
        return 0;
    }
    if((!u1OnOff))
    {
        Printf("[Pram1]  1:enable 0:disable\n");
        
        Printf("[Pram1]  Current Value Disabled:%d\n",u1OnOff);
        DRVCUST_EnSetTnr(u1OnOff);
        return 0;
    }
    pTnrSetParam.u1BlendRatioBlky = StrToInt(szArgv[2]);
    pTnrSetParam.u1BlendRatioDe = StrToInt(szArgv[3]);
    pTnrSetParam.u1BlendRatioTxtr= StrToInt(szArgv[4]);
    pTnrSetParam.u1BlendRatioMv= StrToInt(szArgv[5]);
    pTnrSetParam.u1FltStrMax= StrToInt(szArgv[6]);
    
	DRVCUST_EnSetTnr(u1OnOff);
	DRVCUST_SetTnr(&pTnrSetParam);

    
    return 0;
}

static INT32 _i4SetQPQECH(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 u1CH;
	BOOL bOnOff;
	if(i4Argc != 3)
    {
        Printf("cust_cli.sys.sqpqe [CH] [EN] \n");
		Printf("0: CHA  ; \n");
		Printf("1: CHB  ; \n");
        return 0;
    }
	u1CH = StrToInt(szArgv[1]);
	bOnOff= StrToInt(szArgv[2]);
	DRVCUST_SetDemuraTransferSetting(u1CH, bOnOff);
}

static INT32 _i4SetPqTdHistConfig(INT32 i4Argc, const CHAR ** szArgv)
{
	static CUST_TDHIST_CONFIG_PARAM_T tyshConfig;
	static CUST_TDHIST_CONFIG_PARAM_T tyshConfigbak;

	if(i4Argc != 2)
		{
			Printf("cust_cli.sys.yshcfg [0/1]] \n");
			Printf("0: setting is just for test, result should be   ; \n");
			Printf("1: recover the original setting  ; \n");
			Printf("!!! recover recover must be after setting  ; \n");
			return 0;
		}
	//read to back from HW register
	if(StrToInt(szArgv[1]) ==0)
	{
		DRVCUST_GetPqTdHistConfig(&tyshConfigbak);
	

		tyshConfig.ysh_3d_hist_cen = 0;
		tyshConfig.ysh_3d_nonlinear_norm = 0;
		tyshConfig.ysh_3d_norm_variance = 1;

		tyshConfig.ysh_3d_y_interval[0] = 10;
		tyshConfig.ysh_3d_y_interval[1] = 20;

		tyshConfig.ysh_3d_s_interval[0] = 10;
		tyshConfig.ysh_3d_s_interval[1] = 20;
		tyshConfig.ysh_3d_s_interval[2] = 30;
		tyshConfig.ysh_3d_s_interval[3] = 40;
		tyshConfig.ysh_3d_s_interval[4] = 50;
		tyshConfig.ysh_3d_s_interval[5] = 60;
		tyshConfig.ysh_3d_s_interval[6] = 70;
		
		tyshConfig.ysh_3d_h_interval[0] = 10;
		tyshConfig.ysh_3d_h_interval[1] = 20;
		tyshConfig.ysh_3d_h_interval[2] = 30;
		tyshConfig.ysh_3d_h_interval[3] = 40;
		tyshConfig.ysh_3d_h_interval[4] = 50;
		tyshConfig.ysh_3d_h_interval[5] = 60;
		tyshConfig.ysh_3d_h_interval[6] = 70;
		tyshConfig.ysh_3d_h_interval[7] = 80;
		tyshConfig.ysh_3d_h_interval[8] = 90;
		tyshConfig.ysh_3d_h_interval[9] = 100;
		tyshConfig.ysh_3d_h_interval[10] = 110;

		DRVCUST_SetPqTdHistConfig(&tyshConfig);
	}
	else
	{
		DRVCUST_SetPqTdHistConfig(&tyshConfigbak);
		
	}
	
}

static INT32 _i4SetxvYCCGMTblSel(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_XVYCC_GAMMA_TABLE_SEL_T xvGMTblSel;
	if(i4Argc != 5)
    {
        Printf("cust_cli.sys.sxvgmtblsel [x1_gm] [x1_agm] [x2_gm] [x2_agm]\n");
        return 0;
    }
	xvGMTblSel.xvycc1_gm = StrToInt(szArgv[1]);
	xvGMTblSel.xvycc1_agm = StrToInt(szArgv[2]);
	xvGMTblSel.xvycc2_gm = StrToInt(szArgv[3]);
	xvGMTblSel.xvycc2_agm = StrToInt(szArgv[4]);
	DRVCUST_SetXvyccGammaTableSel((CUST_XVYCC_GAMMA_TABLE_SEL_T*)&xvGMTblSel);

}
static INT32 _i4SetxvYCCGMRamTbl(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_XVYCC_DEST_T xvPosSel;
	UINT16 *pRamdata = NULL;
	UINT16 u2Size = 4096;
	UINT8 u1type;//0 is linear, 1 is 709
	UINT16 i;
	if(i4Argc != 4)
    {
        Printf("cust_cli.sys.sxvgmram [xv1orxv2] [gmoragm] [type0/1]\n");
		Printf("[xv1orxv2]0:xvycc1 ; 1:xvycc2\n");
		Printf("[GmorAgm]0:Gm ; 1: Agm\n");
		Printf("[type0/1]:0: linear 1: bt709\n");
        return 0;
    }
	xvPosSel.block_no   = StrToInt(szArgv[1]);
	xvPosSel.gamma_type = StrToInt(szArgv[2]);
	u1type              = StrToInt(szArgv[3]);
	pRamdata = (UINT16 *)x_mem_alloc(sizeof(UINT16)*u2Size);
	if(pRamdata == NULL)
	{
		ASSERT(0);
		LOG(0, "%s:%d ERR: Alloc buffer pRamdata fail.\n", __FUNCTION__, __LINE__);
		return ;
	}
	if(u1type == 0)
	{

		for(i = 0; i<4096; i++)
		{
			pRamdata[i] = i;
		}
	}
	else if(u1type == 1)
	{
		if(xvPosSel.gamma_type == 0)//GM
		{
			for(i = 0; i<4096; i++)
			{
				pRamdata[i] = u4xvYCCGmProgrmTbl_cust[i];
			}
		}
		else
		{
			for(i = 0; i<4096; i++)//agm
			{
				pRamdata[i] = u4xvYCCAgmProgrmTbl_cust[i];
			}
		}
	}
	else
	{

	}
	DRVCUST_SetXvyccRamTable((CUST_XVYCC_DEST_T*) &xvPosSel, pRamdata, u2Size);
	x_mem_free(pRamdata);
}

static INT32 _i4SetRGBSensorParam(INT32 i4Argc, const CHAR ** szArgv)
{
    CUST_RGB_SENSOR_PARAM_T tGlobalDimmingInfo;

    if (i4Argc != 5)
    {
        Printf("Usage: %s [IT] [Gain1] [Gain2] [HD]\n", szArgv[0]);
        return 0;
    }
    tGlobalDimmingInfo.eRgbSensorType = E_RGB_SENSOR_TYPE_0;
    tGlobalDimmingInfo.RgbSensorConfig.type0.it = StrToInt(szArgv[1]);
    tGlobalDimmingInfo.RgbSensorConfig.type0.gain1 = StrToInt(szArgv[2]);
    tGlobalDimmingInfo.RgbSensorConfig.type0.gain2 = StrToInt(szArgv[3]);
    tGlobalDimmingInfo.RgbSensorConfig.type0.hd = StrToInt(szArgv[4]);
    DRVCUST_SetRGBSensorParam(&tGlobalDimmingInfo);

    return 0;
}

static INT32 _i4GetRGBSensorLevel(INT32 i4Argc, const CHAR ** szArgv)
{
    CUST_RGB_SENSOR_LEVEL_T tRgbSensorLevel;
    if (i4Argc != 1)
    {
        Printf("Usage: %s\n", szArgv[0]);
        return 0;
    }
    DRVCUST_GetRGBSensorLevel(&tRgbSensorLevel);
    Printf("RGB Sensor Level: R(0x%04X)|G(0x%04X)|B(0x%04X)|C(0x%04X)|IR(0x%04X)\n", tRgbSensorLevel.r_level, tRgbSensorLevel.g_level, tRgbSensorLevel.b_level, tRgbSensorLevel.c_level, tRgbSensorLevel.ir_level);

    return 0;
}

static INT32 _i4GetRGBSensorID(INT32 i4Argc, const CHAR ** szArgv)
{
    if (i4Argc != 1)
    {
        Printf("Usage: %s\n", szArgv[0]);
        return 0;
    }
    Printf("RGB Sensor ID: 0x%02X\n", DRVCUST_GetRGBSensorID());

    return 0;
}

static INT32 _i4SetSkinLumaHistPosition(INT32 i4Argc, const CHAR ** szArgv)
{
	CUST_SKIN_LUMA_POS_T skinLumaHistPos;
	if(i4Argc != 5)
    {
        Printf("cust_cli.sys.ssklmpos  [x_Start] [x_End] [y_Start] [y_End]\n");
        return 0;
    }
	skinLumaHistPos.u2X_Start = StrToInt(szArgv[1]);
	skinLumaHistPos.u2X_End   = StrToInt(szArgv[2]);
	skinLumaHistPos.u2Y_Start = StrToInt(szArgv[3]);
	skinLumaHistPos.u2Y_End   = StrToInt(szArgv[4]);
	DRVCUST_SetPqSkinLumaHistDetPosition((CUST_SKIN_LUMA_POS_T*)&skinLumaHistPos);

}

static INT32 _i4SetSkinLumaDetectTH(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT16 skinLumaHistTH;
	if(i4Argc != 2)
    {
        Printf("cust_cli.sys.ssklmth  [Value]\n");
        return 0;
    }
	skinLumaHistTH = StrToInt(szArgv[1]);

	DRVCUST_SetPqSkinLumaHistDetThreshold(skinLumaHistTH);

}

static INT32 _i4GetFaceDetInfo(INT32 i4Argc, const CHAR ** szArgv)
{
	UINT8 u1Num;
	DRVCUST_GetPqFaceDetInfo(&u1Num);
	Printf("Face Det info = %d \n",u1Num);
}
 
static INT32 _i4SetSpPscMute(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1OnOff;
    if(i4Argc != 2)
    {
        Printf("spmute 0:unmute / 1:mute \n");
        return 0;
    }
    u1OnOff = StrToInt(szArgv[1]);
    DRVCUST_RequestSpecialPostMute(u1OnOff);

    return 0;
}

static INT32 _i4SetVdecPath(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT32 u4Tbl;
    UINT32 u4SigPath;
    if(i4Argc != 3)
    {
        Printf("svdecpath tbl_num sig_path \n");
        return 0;
    }
    u4Tbl = StrToInt(szArgv[1]);
    u4SigPath = StrToInt(szArgv[2]);
    DRVCUST_SetVDECSignalPath(u4Tbl,u4SigPath);

    return 0;
}

static INT32 _i4GetVdecPath(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT32 u4Tbl;
    UINT32 u4SigPath;

    LOG(0,"\n");    
    for(u4Tbl = 0;u4Tbl < TBL_INVALID;u4Tbl++)
    {
        u4SigPath = DRVCUST_GetVDECSignalPath(u4Tbl);
        LOG(0,"%d: %s \n",u4Tbl,((u4SigPath)?"Bypass Path":"Main PQ Path"));
    }

    return 0;
}

static INT32 _i4SetDV_GDLog(INT32 i4Argc, const CHAR ** szArgv)
{
    UINT8 u1OnOff;
    if(i4Argc != 2)
    {
		Printf("[Pram1]  1:enable 0:disable\n");
		return 0;
	}
	u1OnOff = StrToInt(szArgv[1]);
	DRVCUST_SetDV_GDLog(u1OnOff);
	
    return 0;
}


static INT32 _i4SetMemcInfo(INT32 i4Argc, const CHAR ** szArgv)
{
    MEMC_MODE_INFO_TYPE stMemcInfo;
    if(i4Argc != 3)
    {
        Printf("[PicMode] [MainSrc] \n");
        return 0;
    }
    stMemcInfo.u1MemcPicMode= StrToInt(szArgv[1]);
    stMemcInfo.u1MemcSrc.eMainInputType = StrToInt(szArgv[2]);

    DRVCUST_MEMC_SetInfo(&stMemcInfo);

    return 0;
}

extern UINT8 u1DbgMemcDynModeFix;
extern UINT8 u1DbgMemcDynColorFix;

static INT32 _i4DbgMemcInfo(INT32 i4Argc, const CHAR ** szArgv)
{
    if(i4Argc == 3)
    {
        u1DbgMemcDynModeFix = StrToInt(szArgv[1]);
        u1DbgMemcDynColorFix = StrToInt(szArgv[2]);

        Printf("=== Fix Mode(%d) Color(%d)=== \n",u1DbgMemcDynModeFix,u1DbgMemcDynColorFix);
    }
    else
    {
        Printf("=== Dyn Memc Mode === \n");
        DRVCUST_MEMC_DumpInfo();
    }
    return 0;

}

#ifdef CC_DRV_CUST_TONEMAP_TO_KO
static INT32 _i4SetPseudoToneMapInfo(INT32 i4Argc, const CHAR ** szArgv)
{
    CUST_PIC_SETTING_T pPictureSetting;
    E_CUST_TONEMAP_UI rToneSetting;
    UINT8 u1mode;

    if(i4Argc != 3)
    {
        Printf("tone2ko setting 0:OFF / 1:LOW / 2:MID / 3:HIGH  mode 0:UpdateOnly others:w/ event trigger\n");
        return 0;
    }
    
    rToneSetting = (E_CUST_TONEMAP_UI)StrToInt(szArgv[1]);
    u1mode = (UINT8)StrToInt(szArgv[2]);
    BEPQ_AP_Get_Pic_Setting(&pPictureSetting);
    
    if(rToneSetting > E_CUST_TONEMAP_HIGH)
    {
        Printf("tone2ko setting over spec\n");
        return 0;
    }
    
    pPictureSetting.eToneMapInfo = rToneSetting;
    BEPQ_AP_Set_Pic_Setting(pPictureSetting);

    if(u1mode)
    {
        DRVCUST_SendEvent(E_CUST_PIC_SETTING_CHANGE, 0);
    }

    return 0;
}
#endif


CLI_EXEC_T arCmdMapleSysTbl[] = {
    {"System Input", "input",    _i4GetMapleSysInputCmd,     NULL,   "System Input source",  CLI_GUEST},
    {"System Input", "setinput",    _i4SetMapleSysInputCmd,     NULL,   "System Input source",  CLI_GUEST},
    {"Signal Format", "sigfmt",    _i4GetMapleSysSigFmtCmd,     NULL,   "Input Signal Format",  CLI_GUEST},
    {"DoviType", "dovimode",    _i4GetMapleSysDOVITypeCmd,     NULL,   "DoviType",  CLI_GUEST},
    {"Window Mode", "win",    _i4GetMapleSysWindowModeCmd,     NULL,   "Window Mode",  CLI_GUEST},
    {"Plane Mute", "pm",    _i4GetMapleSysPlaneMuteCmd,     NULL,   "Plane Mute State",  CLI_GUEST},
    {"Output Mute", "om",    _i4GetMapleSysOutputMuteCmd,     NULL,   "Output Mute State",  CLI_GUEST},
    {"Output Position", "posi",    _i4GetMapleSysOutPosiCmd,     NULL,   "Output Position",  CLI_GUEST},
    {"Source Area", "sa",    _i4GetMapleSysSrcAreaCmd,     NULL,   "Source Area",  CLI_GUEST},
    {"Scaling Req", "sr",    _i4GetMapleSysSclReqCmd,     NULL,   "Scaling Request",  CLI_GUEST},
    {"Output Format", "outfmt",    _i4GetMapleSysOutFmtCmd,     NULL,   "Output Format",  CLI_GUEST},
    {"MCVP Meter", "mcvp",    _i4GetMapleSysMCVPMeterCmd,     NULL,   "MCVP Meter",  CLI_GUEST},
    {"3D YSH Meter", "ysh",    _i4GetMapleSysPostProcTdHistMeterCmd,     NULL,   "3D YSH Meter",  CLI_GUEST},
    {"3D YSH config", "yshcfg",    _i4SetPqTdHistConfig,     NULL,   "3D YSH config",  CLI_GUEST},
    {"Cadense ", "cad",    _i4GetMapleSysCadenseCmd,     NULL,   "Cadense",  CLI_GUEST},
    {"Post Meter ", "post",    _i4GetMapleSysPostMeterCmd,     NULL,   "Post Proc Meter",  CLI_GUEST},
    {"LD Meter ", "ld",    _i4GetMapleSysLDMeterCmd,     NULL,   "LD Meter",  CLI_GUEST},
    {"Ana Noise", "ana",    _i4GetMapleSysAnaNoiseCmd,     NULL,   "Analog Noise Level",  CLI_GUEST},
    {"LightSensor ", "light",    _i4GetMapleSysLightSensorCmd,     NULL,   "Light Sensor Value",  CLI_GUEST},
    {"TempSensor ", "tem",    _i4GetMapleSysTempSensorCmd,     NULL,   "Temperature Sensor Value",  CLI_GUEST},
    {"BL Limit ", "bl",    _i4GetMapleSysBLPowerLimitCmd,     NULL,   "BL Power Limit",  CLI_GUEST},
    {"Frame Delay ", "delay",    _i4GetMapleSysFrameDelayCmd,     NULL,   "Frame Delay",  CLI_GUEST},
    {"History ", "his",    _i4GetMapleSysHistoryDataCmd,     NULL,   "History Data",  CLI_GUEST},
    {"Power state ", "powst",    _i4GetMapleSysPowerStateCmd,     NULL,   "Power State",  CLI_GUEST},
    {"Dec bitrate", "bitrate",    _i4GetMapleSysDecBitRateCmd,     NULL,   "Decoder Bit Rate",  CLI_GUEST},
    {"ADC Value", "adc",    _i4GetMapleSysADCValueCmd,     NULL,   "ADC Value",  CLI_GUEST},
    {"Screen Saver ", "saver",    _i4GetMapleSysScreenSaverCmd,     NULL,   "Screen Saver Mode",  CLI_GUEST},
    {"Aging Mode ", "aging",    _i4GetMapleSysAgingModeCmd,     NULL,   "Aging Mode",  CLI_GUEST},
    {"TV Output", "tvout",    _i4GetMapleSysTVOutFmtCmd,     NULL,   "TV Output Format",  CLI_GUEST},
    {"Scaler Info", "scaler",    _i4GetMapleSysScalerInfoCmd,     NULL,   "Scaler in/out information",  CLI_GUEST},
    {"OSD state ", "osd",    _i4GetMapleSysOSDStateCmd,     NULL,   "OSD State",  CLI_GUEST},
    {"Screen Mirror", "mirror",    _i4GetMapleSysScreenMirrorCmd,     NULL,   "Screen Mirror State",  CLI_GUEST},
    {"letter box info", "lb",    _i4GetLetterBoxDetection,	  NULL,   "letter box info",  CLI_GUEST},
    {"SCE cap enable", "scen",	 _i4SetSCECapEn,	  NULL,   "lSCE cap enable",  CLI_GUEST},
    {"Timing Len Check", "tlc",	 _i4TimLengthCheck,	  NULL,   "Timing Len Check",  CLI_GUEST},
    {"SCE cap position", "scp",	 _i4SetSCECapPos,	  NULL,   "SCE cap position",  CLI_GUEST},
    {"SCE cap ink enable", "scie",	 _i4SetSCECapInk,	  NULL,   "SCE cap ink enable",  CLI_GUEST},
    {"SCE cap ink color", "scic",	 _i4SetSCECapInkColor,	  NULL,   "SCE cap ink color",  CLI_GUEST},
    {"SCE cap data", "scd",	 _i4SetSCECapData,	  NULL,   "SCE cap data",  CLI_GUEST},
    {"Ostg cap enable", "oce",	 _i4SetOstgCapEn,	  NULL,   "Ostg cap enable",  CLI_GUEST},
    {"Ostg cap position", "ocp",	 _i4SetOstgCapPos,	  NULL,   "letter box info",  CLI_GUEST},
    {"Ostg cap ink color", "ocic",	 _i4SetOstgCapColor,	  NULL,   "Ostg cap ink color",  CLI_GUEST},
    {"Ostg cap data", "ocd",	 _i4SetOstgCapData,	  NULL,   "Ostg cap data",  CLI_GUEST},
    {"demo mode", "dm",	 _i4SetDemoMode,   NULL,   "demo mode",	CLI_GUEST},
    {"BeWrite", "bew",    _i4BEWriteCmd,	  NULL,   "bew State",  CLI_GUEST},
    {"BeRead", "ber",    _i4BEReadeCmd,     NULL,   "ber State",  CLI_GUEST},
    {"Sharpness", "sp",	 _i4WritSsharpne, 	NULL,	"sharpness State",  CLI_GUEST},
    {"frequencydetset", "fds",  _i4Set4BandFrequencySetting,	NULL,	"frequencydetset State",	CLI_GUEST},
    {"4BandGetHist", "fdg",	_i4Get4BandHist,	NULL,	"4BandGetHist State",	CLI_GUEST},
    {"Get QP value", "qp",	_i4GetQPValue,	NULL,	"QP value State",	CLI_GUEST},
    {"get virt addr", "gvaddr",	_i4GetPhysical2VituralAddr,	NULL,	"SRS get virtual addr",	CLI_GUEST},
    {"get Phy addr", "gpaddr",	_i4GetVitural2PhysicalAddr,	NULL,	"SRS get Physical addr",	CLI_GUEST},
    {"PQ module onoff", "pqen",  _i4PQModuleOnOff, NULL,   "set pq module on/off",    CLI_GUEST},
    {"Dereg pq func", "dpqfnc",  _i4SetDeregisterPqFunc, NULL,	 "Dereg pq func",	 CLI_GUEST},
    {"Dereg pq general func", "dpqgfnc",  _i4SetDeregisterGeneralPqFunc, NULL,	 "Dereg pq general func",	 CLI_GUEST},
    {"set exclusive reg", "sxclsv",  _i4SetExclusiveReg, NULL,	 "set exclusive reg",	 CLI_GUEST},
    {"Set Luma Curve", "slcv",	_i4SetLumaCurve, NULL,	 "Set Luma Curve",	  CLI_GUEST},
    {"Set Contrast", "sctrst",	_i4SetContrast, NULL,	"Set Contrast",    CLI_GUEST},
    {"Set Color", "scolor",  _i4SetColor, NULL,   "Set Color",	  CLI_GUEST},
    {"Set Hue", "shue",  _i4SetHue, NULL,	"Set Hue",	  CLI_GUEST},
    {"Set SRS Lut", "ssrslut",	_i4SetSRSLUT, NULL,   "Set SRS Lut",	CLI_GUEST},
    {"Flush PQ setting", "sflshpq",  _i4SetFlushPqSetting, NULL,   "Flush PQ setting",	  CLI_GUEST},
    {"BL Header/Footer", "sblhdft",  _i4SetBLHeaderFooter, NULL,   "BL Header/Footer",	  CLI_GUEST},
    {"En noise lvl", "snlvlen",  _i4SetEnNoiseLvl, NULL,   "En noise lvl",	  CLI_GUEST},
    {"En noise lvl2", "snlvl2en",  _i4SetEnNoiseLvl2, NULL,   "En noise lvl2",	  CLI_GUEST},
    {"Set noise lvl", "snlvl",	_i4SetNoiseLvl, NULL,	"Set noise lvl",	CLI_GUEST},
    {"Set noise lvl2", "snlvl2",  _i4SetNoiseLvl2, NULL,   "Set noise lvl2",	CLI_GUEST},
    {"Post Sharp Ylvl", "spshpylvl",  _i4SetPostSharpYLev, NULL,   "Post Sharp Ylvl",	 CLI_GUEST},
    {"IBSE Ylvl", "sibseylvl",  _i4SetIbseYLev, NULL,   "IBSE Ylvl",	 CLI_GUEST},
    {"Gamma table", "sgmtbl",  _i4SetWBGammaTable, NULL,   "Gamma table",	 CLI_GUEST},
    {"Reset sys", "rst",  _i4ResetSystem, NULL,   "Reset sys",	  CLI_GUEST},
    {"Send data to BE", "sdbe",  _i4PqSendDataToBe, NULL,	"Send data to BE",	  CLI_GUEST},
    {"Send ecs cmd rply", "secscmdrply",  _i4SetEcsCommandReply, NULL,	 "Send ecs cmd rply",	 CLI_GUEST},
    {"pq color mtx:C/S/B", "smtrx",  _i4SetPqColMatrixParam, NULL,	 "pq color mtx:C/S/B",	  CLI_GUEST},
    {"partial S:L/M/H", "sps",	_i4SetPqNewPartialS, NULL,	 "partial S:L/M/H",    CLI_GUEST},
    {"partial S position", "spsp",	_i4SetPqNewPartialSPositon, NULL,	 "partial S position",    CLI_GUEST},
    {"partial Y", "spy",  _i4SetPqPartialY, NULL,	"partial Y",	CLI_GUEST},
    {"gain/offset", "sgainofst",  _i4SetPqWBGainOffset, NULL,	"gain/offset",	  CLI_GUEST},
    {"scaler coef luma H", "ssceflh",  _i4SetScalerCoefLumaH, NULL,   "scaler coef luma H",    CLI_GUEST},
    {"scaler coef Chroma H", "sscefch",  _i4SetScalerCoefChromaH, NULL,   "scaler coef Chroma H",	 CLI_GUEST},
    {"scaler coef luma V", "ssceflv",  _i4SetScalerCoefLumaV, NULL,   "scaler coef luma V",    CLI_GUEST},
    {"scaler coef Chroma V", "sscefcv",  _i4SetScalerCoefChromaV, NULL,   "scaler coef Chroma V",	 CLI_GUEST},
    {"lcl dim HW param", "sldhw",  _i4SetLdHwParam, NULL,	"lcl dim HW param",    CLI_GUEST},
    {"lcl dim SW param", "sldsw",  _i4SetLdSwParam, NULL,	"lcl dim SW param",    CLI_GUEST},
    {"lcl dim HW table", "sldhwtbl",  _i4SetLdHwTable, NULL,   "lcl dim HW table",	  CLI_GUEST},
    {"lcl dim SW table", "sldswtbl",  _i4SetLdSwTable, NULL,	"lcl dim SW table", CLI_GUEST},
    {"Sopqread/write", "spqrw",  _i4SopqPartialRW, NULL,	"Sopqread/write",	CLI_GUEST},
    {"meta-data check", "meta",  i4MetaDataCmd, NULL,	"meta data verify",	CLI_GUEST},
    {"MVI Start address", "gmvia",  _i4MVIStartAddress, NULL,   "get MVI start address",    CLI_GUEST}, 
    {"Register BE", "regbe",  _i4RegisterBefun, NULL,   "Register BE function",    CLI_GUEST},
    {"UnRegister BE", "unregbe",  _i4UnRegisterBefun, NULL,   "UnRegister BE function",    CLI_GUEST},
    {"Register Gen BE fun", "reggbe",  _i4RegisterGeneralBefun, NULL,   "Register BE General function",    CLI_GUEST},
    {"UnRegister Gen BE fun", "unreggbe",  _i4UnRegisterGeneralBefun, NULL,   "UnRegister  BE General function",    CLI_GUEST},
    {"Register PQ fun", "regpq",  _i4RegisterPqfun, NULL,   "Register PQ  function",    CLI_GUEST},
    {"UnRegister PQ fun", "unregpq",  _i4UnRegisterPqfun, NULL,   "UnRegister  PQ  function",    CLI_GUEST},
    {"Register Gen PQ fun", "reggpq",  _i4RegisterGeneralPqfun, NULL,   "Register PQ General function",    CLI_GUEST},
    {"UnRegister Gen PQ fun", "unreggpq",  _i4UnRegisterGeneralPqfun, NULL,   "UnRegister  PQ General function",    CLI_GUEST},
    {"Register BE EXT fun", "regbeext",  _i4RegisterBeExtfun, NULL,   "Register BE ext function",    CLI_GUEST},
    {"UnRegister BE EXT fun", "unregbeext",  _i4UnRegisterBeExtfun, NULL,   "UnRegister  BE ext function",    CLI_GUEST},
    {"Set BE info", "sbeinfo",  _i4SetBeDeviceInfo, NULL,   "Set BE Device information",    CLI_GUEST},
    {"Set BE Error", "sbeerr",  _i4SetBeDeviceErrorDetect, NULL,   "Set BE Device Error Detect",    CLI_GUEST},
    {"Set BE Version", "sbever",  _i4SetBeDeviceVersion, NULL,   "Set BE Device Version",    CLI_GUEST},
    {"Set _i4SetConvTbl", "conv",  _i4SetConvTbl, NULL,   "Set _i4SetConvTbl",    CLI_GUEST},
    {"GetConCap", "convcap",  _i4GetConvTblCapability, NULL,   "GetConCap",    CLI_GUEST},
    {"GetConDFT", "convdft",  _i4GetConvTblDFT, NULL,   "GetConDFT",    CLI_GUEST},
    {"ReadEdidDAT", "redid",  _i4GetHdmiReadEDIDData, NULL,   "ReadEdidDATA",    CLI_GUEST},
    {"EnEVLog", "evtlog",  _i4SetLogEnable, NULL,   "Enable Send_Event Log",    CLI_GUEST},
    {"GetHdmiPortNum", "srchdmi",  _i4GetHdmiPortNum, NULL,   "GetHdmiPortNum",    CLI_GUEST},
    {"GetOSDPixCt", "gosdpc",  _i4GetMapleSysOSDPxlCountCmd, NULL,   "GetMapleSysOSDPxlCount",    CLI_GUEST},
    {"UpdateTimGrp", "utg",  _i4GetMapleSysUpdateTimingGroupCmd, NULL,   "UpdTmGrp",    CLI_GUEST},
    {"SetOstAlpha", "soalp",  _i4SetMapleSysOSDAlphaTHCmd, NULL,   "SetOstAlpha",    CLI_GUEST},
    {"SetDVCFG", "sdvcfg",  _i4SetMapleDVCFGfileCmd, NULL,   "SetDVCFG",    CLI_GUEST},
    {"Dither", "dither", NULL , arCmdMapleDitehrTbl,   "dither",    CLI_GUEST},
    {"SetTnr", "stnr",  _i4SetTNR, NULL,   "SetTnr",    CLI_GUEST},
    {"SRSSta", "srs",  _i4QuerySRSStatus, NULL,   "GetSRS",    CLI_GUEST},
    {"VSSValid chek", "vsschk",  _i4VSSValidChk, NULL,   "VSSChk",    CLI_GUEST},
     {"SetHdmiSigPath","SetHSP",_i4SetHdmiSigPath, NULL, "Set Hdmi Signal Path", CLI_GUEST},
     {"GetHdmiSigPath", "GetHSP",_i4GetHdmiSigPath, NULL, "Get Hdmi Signal Path", CLI_GUEST},
#ifdef CC_SUPPORT_PHOTO8K
    {"DivPhoto", "divphoto", NULL , arCmdMapleDivPhotoTbl,   "divphoto",    CLI_GUEST},
#endif
    {"Set color system", "scolor_sys",  _i4SetColorSystemInfo, NULL,   "Set Color system information",    CLI_GUEST}, 
    {"Set QPQE Channl", "sqpqe",  _i4SetQPQECH, NULL,   "Set QPQE Channl",    CLI_GUEST},
    {"8k cust", "8k", NULL , arCmdMaple8kTbl,   "8k features",    CLI_GUEST},
    {"TestWatchdogReset", "twr" , _i4TestWatchdogReset, NULL,   "test watchdog reset",    CLI_GUEST},
    {"IsMaintenanceReset", "imr" , _i4IsMaintenanceReset, NULL,   "whether the rebooting is maintenance reset or not",    CLI_GUEST},
    {"xvYCC gm_agm sel", "sxvgmtblsel" , _i4SetxvYCCGMTblSel, NULL,   "xvYCC gm_agm sel",    CLI_GUEST},
    {"xvYCC gm_agm set", "sxvgmram" , _i4SetxvYCCGMRamTbl, NULL,   "xvYCC gm_agm set",    CLI_GUEST},
    {"SetRGBSensor Param", "srsp",  _i4SetRGBSensorParam, NULL,   "Set RGB Sensor Param",    CLI_GUEST},
    {"GetRGBSensor Level", "grsl",  _i4GetRGBSensorLevel, NULL,   "Get RGB Sensor Level",    CLI_GUEST},
    {"GetRGBSensor ID", "grsi",  _i4GetRGBSensorID, NULL,   "Get RGB Sensor ID",    CLI_GUEST},
    {"Skin LumaPos set", "ssklmpos" , _i4SetSkinLumaHistPosition, NULL,   "Skin LumaPos set",    CLI_GUEST},
    {"Skin LumaTH set", "ssklmth" , _i4SetSkinLumaDetectTH, NULL,   "Skin LumaTH set",    CLI_GUEST},
    {"Skin hist Get", "gsklmhist" , _i4GetMapleSysSkinLumaHistMeterCmd, NULL,   "Skin hist Get",    CLI_GUEST},
    {"Face Get", "gfd" , _i4GetFaceDetInfo, NULL,   "Face Get",    CLI_GUEST},
    {"sp psc mute", "spmute", _i4SetSpPscMute  , NULL ,   "special post mute",    CLI_GUEST},
    {"set vdec HFR", "svdecpath", _i4SetVdecPath  , NULL ,   "set vdec HFR path",    CLI_GUEST},
    {"get vdec HFR", "gvdecpath", _i4GetVdecPath  , NULL ,   "get vdec HFR path",    CLI_GUEST},
    {"DVGDLog", "dvgdlog", _i4SetDV_GDLog  , NULL ,   "DVGDLog",    CLI_GUEST},
    {"setmemcinfo", "sminfo", _i4SetMemcInfo  , NULL ,   "Set Memc mode Info",    CLI_GUEST},
    {"debugmemcinfo", "dminfo", _i4DbgMemcInfo  , NULL ,   "debug Memc mode Info",    CLI_GUEST},
    {"vrr_cust", "vrr", NULL , arCmdMapleVRRTbl,   "vrr",    CLI_GUEST},
#ifdef CC_DRV_CUST_TONEMAP_TO_KO
    {"tonemap ui", "tone2ko", _i4SetPseudoToneMapInfo  , NULL ,   "UI tonemap info",    CLI_GUEST},
#endif
    {NULL, NULL, NULL, NULL, NULL, CLI_SUPERVISOR}
};


