/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/


#include "drv_MapleApi.h"
#include "b2r_drvif.h"
#include "vdp_if.h"
#include "vdec_if.h"
#include "drv_hdmi.h"
#include "nptv_debug.h"
#include "bepqapi.h"
#include "msdc_if.h"
#include "x_pdwnc.h"
#include "CustomCtrl.h"
#include "pe_if.h"
#include "mute_if.h"
#include "drv_display.h"
#include "osd_drvif.h"
#include "drv_lcdim_v2.h"
#include "ostg_if.h"
#include "drv_scart.h"


#include "vdp_display.h"


////////////////////////////////////////////////////////////////////////////////
#define MAPLE_SYS_DEBUG 1

extern UINT32 dwOpticalSensorAvgValue;
extern BOOL fgYUVout;
extern SRM_TV_MODE_T _eApplicationMode;
extern UINT8 gAgingInit;

extern LCDTIMING_INFO_T lcdtimingInfo;
#if defined(SUPPORT_PANEL_GRAPH_MODE)
extern TIMING_INFO_T GFXTimingInfo;
#endif

#ifdef CC_PowerCons_Ctrl
extern UINT8 C_BL_POWER_LIMIT;
#endif

extern UINT8 gWFDProtocol;

E_CUST_PIC_CONTROL_STATE CUST_PIC_CONTROL_STATE;

////////////////////////////////////////////////////////////////////////////////
static void DEBUG_GetSignalFormat(UINT8 bPath, CUST_SIG_FMT_T* pSignalFormat)
{
    #if MAPLE_SYS_DEBUG
    LOG(2, "====== DRVCUST_GetSignalFormat(%d) ======\n", bPath);
    LOG(2, "eSigSta             %d\n", pSignalFormat->eSigSta);  	
    LOG(2, "u4Width             %d\n", pSignalFormat->u4Width); 				
    LOG(2, "u4Height            %d\n", pSignalFormat->u4Height);        	
    LOG(2, "u4CodecWidth        %d\n", pSignalFormat->u4CodecWidth);   
    LOG(2, "u4CodecHeight       %d\n", pSignalFormat->u4CodecHeight); 	
    LOG(2, "eContentType	    %d\n", pSignalFormat->eContentType);   
    LOG(2, "eScanType	        %d\n", pSignalFormat->eScanType); 			
    LOG(2, "eColorSystem	    %d\n", pSignalFormat->eColorSystem);   
    LOG(2, "eFrameRate	        %d\n", pSignalFormat->eFrameRate); 			
    LOG(2, "eStreamingType	    %d\n", pSignalFormat->eStreamingType); 
    LOG(2, "eDimension	        %d\n", pSignalFormat->eDimension); 			
    LOG(2, "e3dFormat	        %d\n", pSignalFormat->e3dFormat); 			
    LOG(2, "eColorimetry	    %d\n", pSignalFormat->eColorimetry);  // ?
    LOG(2, "eColorFormat	    %d\n", pSignalFormat->eColorFormat);  // ?
    LOG(2, "eColorDepth	        %d\n", pSignalFormat->eColorDepth); 		
    LOG(2, "eColorSpace	        %d\n", pSignalFormat->eColorSpace);    	
    LOG(2, "ePhotoColorSpace 	%d\n", pSignalFormat->ePhotoColorSpace);
    LOG(2, "eDynamicRange	    %d\n", pSignalFormat->eDynamicRange); 
    LOG(2, "eAspect	            %d\n", pSignalFormat->eAspect); 				
    LOG(2, "eVideoCodec	        %d\n", pSignalFormat->eVideoCodec); 		
    LOG(2, "eHdmi4kPhoto	    %d\n", pSignalFormat->eHdmi4kPhoto); 
	LOG(2, "eHdrType	    	%d\n", pSignalFormat->eHDRType);
    #endif
}
static void DEBUG_GetOutputVideoFormat(CUST_OUT_FMT_T* pOutVdoFmt)
{
    #if MAPLE_SYS_DEBUG
    LOG(2, "====== DRVCUST_GetOutputVideoFormat ======\n");
    LOG(2, "u4Htotal		    %d\n", pOutVdoFmt->u4Htotal);
    LOG(2, "u4Vtotal		    %d\n", pOutVdoFmt->u4Vtotal);
    LOG(2, "u4ActX			    %d\n", pOutVdoFmt->u4ActX);
    LOG(2, "u4ActY			    %d\n", pOutVdoFmt->u4ActY);
    LOG(2, "u4ActWidth		    %d\n", pOutVdoFmt->u4ActWidth);
    LOG(2, "u4ActHeight		    %d\n", pOutVdoFmt->u4ActHeight);
    LOG(2, "eFrameRate		    %d\n", pOutVdoFmt->eFrameRate);
    LOG(2, "eDimension		    %d\n", pOutVdoFmt->eDimension);
    LOG(2, "e3dFormat		    %d\n", pOutVdoFmt->e3dFormat);
    LOG(2, "eColorimetry	    %d\n", pOutVdoFmt->eColorimetry);
    LOG(2, "eColorFormat	    %d\n", pOutVdoFmt->eColorFormat);
    LOG(2, "eColorDepth		    %d\n", pOutVdoFmt->eColorDepth);
    LOG(2, "eColorSpace		    %d\n", pOutVdoFmt->eColorSpace);
    LOG(2, "eDynamicRange	    %d\n", pOutVdoFmt->eDynamicRange);
    LOG(2, "ePath			    %d\n", pOutVdoFmt->ePath);
	LOG(2, "bCtrlBitValid		%d\n", pOutVdoFmt->bCtrlBitValid);
    #endif
}

static void DEBUG_GetVideoFrameDelay(CUST_VDO_DELAY_INFO_T* pVdoDelayInfo)
{    
    #if MAPLE_SYS_DEBUG
    LOG(2, "====== DRVCUST_GetVideoFrameDelay ======\n");
    LOG(2, "u4MCVP              %d\n", pVdoDelayInfo->u4MCVP);                  
    LOG(2, "u4Scaler            %d\n", pVdoDelayInfo->u4Scaler);                
    LOG(2, "u4MJC               %d\n", pVdoDelayInfo->u4MJC);       
    #endif
}

static void DEBUG_GetMCVPMeter(CUST_MCVP_METER_T* pMcvpMeter)
{    

    LOG(2, "====== DRVCUST_GetMCVPMeter ======\n");
    LOG(2, "u1NoiseLevel              %d\n", pMcvpMeter->u1NoiseLevel);                  
    LOG(2, "u1BlockNoiseLevel            %d\n", pMcvpMeter->u1BlockNoiseLevel);                
    LOG(2, "u4FrmDiff               %d\n", pMcvpMeter->u4FrmDiff);     
	LOG(2, "u1FreqHpfH              %d\n", pMcvpMeter->u1FreqHpfH);                  
    LOG(2, "u1FreqHpfV            %d\n", pMcvpMeter->u1FreqHpfV);                
    LOG(2, "u1FreqBpfH               %d\n", pMcvpMeter->u1FreqBpfH);

}


////////////////////////////////////////////////////////////////////////////////
E_CUST_INPUT_TYPE DRVCUST_GetInputType(UINT8 bPath)
{    
    D_AP_INPUT_TYPE eType = BEPQ_AP_Get_Input_Type(bPath);

	switch (eType)
    {
        case D_AP_INPUT_TYPE_A_RF:
			return E_CUST_INPUT_TYPE_A_RF;
			
        case D_AP_INPUT_TYPE_D_RF:
			return E_CUST_INPUT_TYPE_D_RF;
			
		case D_AP_INPUT_TYPE_COMPOSITE:
			return E_CUST_INPUT_TYPE_COMPOSITE;
			
		case D_AP_INPUT_TYPE_COMPONENT:
			return E_CUST_INPUT_TYPE_COMPONENT;
			
		case D_AP_INPUT_TYPE_SCART:
			return E_CUST_INPUT_TYPE_SCART;
			
		case D_AP_INPUT_TYPE_A_PC:
			return E_CUST_INPUT_TYPE_A_PC;
			
		case D_AP_INPUT_TYPE_HDMI:
			return E_CUST_INPUT_TYPE_HDMI;
			
		case D_AP_INPUT_TYPE_APPLICATION:
			return E_CUST_INPUT_TYPE_USB;
			
		case D_AP_INPUT_TYPE_SONY_PHOTO_APP:
			return E_CUST_INPUT_TYPE_DNLA;
			
		case D_AP_INPUT_TYPE_JELLY_FISH:
			return E_CUST_INPUT_TYPE_IPTV;
			
		case D_AP_INPUT_TYPE_SKYPE:
			return E_CUST_INPUT_TYPE_BROWSER;
			
		case D_AP_INPUT_TYPE_MIRACAST:
			return E_CUST_INPUT_TYPE_WIFI_DISPLAY;

		case D_AP_INPUT_TYPE_GENERAL_APP:
        default:        
            return E_CUST_INPUT_TYPE_UNKNOWN;
    }
    
}

void DRVCUST_GetSignalFormat(UINT8 bPath, CUST_SIG_FMT_T* pSignalFormat)
{
    UINT8 bSignalType = bGetSignalType(bPath);
    UINT8 u1ColorSys = vDrvGetColorSystem(bPath);
    UINT8 u1ColorDepth = bHDMIGetColorDepth();
	UINT8 u1ScartMode = bDrvGetScartInputMode();
    UINT32 u4HDRType = SV_HDR_TYPE_SDR;
    UINT32 u4VideoRange;

	VDEC_CHROMA_SIMPLE_INFO_T rChromaSimpleInfo;
	B2R_CUST_INFO_T t_B2RCustInfo;	
	UINT8   u1AspInfo = 0;
	E_CUST_INPUT_TYPE eInputType = BEPQ_AP_Get_Input_Type(bPath);
	CUST_PIC_SETTING_T rPicInfoFromAP;
	E_HDMI_HDR_EOTF eHdmiHDREotf = EOTF_UNKNOWN;
	
	BEPQ_AP_Get_Pic_Setting(&rPicInfoFromAP);
	
	if(!B2R_Get_Cust_info(bPath, B2R_GET_TYPE_CUST_INFO, &t_B2RCustInfo, sizeof(B2R_CUST_INFO_T)))
	{
		    LOG(2, "\n====== B2R_Get_Cust_info fail ======\n");
	}

	if(!B2R_Get_Cust_info(bPath, B2R_GET_TYPE_ASPINFO, &u1AspInfo, sizeof(UINT8)))
	{
		    LOG(2, "\n====== B2R_Get_Cust_ASP_info fail ======\n");
	}
	
    switch (bDrvVideoSignalStatus(bPath))
    {
        case SV_VDO_STABLE:
            pSignalFormat->eSigSta = E_CUST_SIG_STA_STABLE;
            break;
        case SV_VDO_NOSIGNAL:
            pSignalFormat->eSigSta = E_CUST_SIG_STA_NO_SIG;
            break;
        case SV_VDO_NOSUPPORT:    
        case SV_VDO_UNKNOWN:
        default:        
            pSignalFormat->eSigSta = E_CUST_SIG_STA_UNKNOWN;
            break;
    }
    
    pSignalFormat->u4Width = wDrvVideoInputWidth(bPath);
    pSignalFormat->u4Height = wDrvVideoInputHeight(bPath);
    
    if(bSignalType == SV_ST_MPEG)
    {
		pSignalFormat->u4CodecWidth = t_B2RCustInfo.rResolution.u4OrgWidth;
	    pSignalFormat->u4CodecHeight= t_B2RCustInfo.rResolution.u4OrgHeight;
    }
	else
	{
		pSignalFormat->u4CodecWidth = 0;
	    pSignalFormat->u4CodecHeight= 0;
	}
    if ((bSignalType == SV_ST_VGA) || (BEPQ_AP_Get_Input_Type(bPath) == E_CUST_INPUT_TYPE_BROWSER))
    {
        pSignalFormat->eContentType = E_CUST_CONTENT_TYPE_GRAPHICS;    
    }
    else if (bSignalType == SV_ST_DVI)
    {
        pSignalFormat->eContentType = bDviIsNativeVideoTiming() 
            ? E_CUST_CONTENT_TYPE_VIDEO : E_CUST_CONTENT_TYPE_GRAPHICS; 
    }   
    else
    {
        pSignalFormat->eContentType = E_CUST_CONTENT_TYPE_VIDEO;    // VIDEO todo : photo
    }
    
    pSignalFormat->eScanType = bDrvVideoIsSrcInterlace(bPath) 
        ? E_CUST_SCAN_TYPE_INTERLACE : E_CUST_SCAN_TYPE_PROGRESSIVE;

    if ((bSignalType == SV_ST_TV) || (bSignalType == SV_ST_AV) || (bSignalType == SV_ST_SV)) 
    {
        switch((UINT8)bHwTvdMode())
        {
            case(UINT8)SV_CS_SECAM:
                pSignalFormat->eColorSystem = E_CUST_COLOR_SYSTEM_SECAM;
                break;        
            case(UINT8)SV_CS_NTSC358:
                pSignalFormat->eColorSystem = E_CUST_COLOR_SYSTEM_NTSC_358;
                break;    
            case(UINT8)SV_CS_NTSC443:
                pSignalFormat->eColorSystem = E_CUST_COLOR_SYSTEM_NTSC_443;
                break;           
            case(UINT8)SV_CS_PAL_M:
                pSignalFormat->eColorSystem = E_CUST_COLOR_SYSTEM_PAL_M;
                break;           
            case(UINT8)SV_CS_PAL_N:
                pSignalFormat->eColorSystem = E_CUST_COLOR_SYSTEM_PAL_N;
                break;        
            case(UINT8)SV_CS_PAL_60:
                pSignalFormat->eColorSystem = E_CUST_COLOR_SYSTEM_PAL60;
                break;        
            case(UINT8)SV_CS_PAL:
                pSignalFormat->eColorSystem = E_CUST_COLOR_SYSTEM_PAL;
                break;    
            default:
                pSignalFormat->eColorSystem = E_CUST_COLOR_SYSTEM_UNKNOWN;
                break;   
        }
    }
    else
    {
        pSignalFormat->eColorSystem = E_CUST_COLOR_SYSTEM_UNKNOWN;
    }

    switch (bDrvVideoGetRefreshRate(bPath))
    {
        case 8:
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_8;
            break;
        case 10:
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_10;
            break;
        case 12:
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_12;
            break;
        case 24:
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_24;
            break;
        case 25:
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_25;
            break;
        case 30:
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_30;
            break;        
        case 48:
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_48;
            break;
        case 50:
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_50;
            break;
        case 96:
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_96;
            break;                  
        case 100:
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_100;
            break;  
        case 120:
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_120;
            break;  
        case 60:           
        default:        
            pSignalFormat->eFrameRate = E_CUST_FRAME_RATE_60;
            break;                 
    }
    if(bSignalType == SV_ST_MPEG)
    {
	    if(t_B2RCustInfo.u4resolutionChg)
	    {
	        pSignalFormat->eStreamingType = E_CUST_STREAMING_TYPE_ADAPTIVE;   
	    }
	    else
	    {
	        pSignalFormat->eStreamingType = E_CUST_STREAMING_TYPE_NORMAL; 
	    }
    }
	else
	{
		pSignalFormat->eStreamingType = E_CUST_STREAMING_TYPE_NORMAL; 
	}
    switch(u4DrvTDTVGetTag3D(bPath))
    {
        case TDTV_TAG3D_NOT_SUPPORT:
            pSignalFormat->eDimension = E_CUST_DIMENSION_2D;
            pSignalFormat->e3dFormat = E_CUST_3D_FMT_UNKNOWN;
            break;
        case TDTV_TAG3D_FS:
            pSignalFormat->eDimension = E_CUST_DIMENSION_3D;
            pSignalFormat->e3dFormat = E_CUST_3D_FMT_FS;
            break;
        case TDTV_TAG3D_FP:
            pSignalFormat->eDimension = E_CUST_DIMENSION_3D;
            pSignalFormat->e3dFormat = E_CUST_3D_FMT_FP;
            break;
        case TDTV_TAG3D_TB:
            pSignalFormat->eDimension = E_CUST_DIMENSION_3D;
            pSignalFormat->e3dFormat = E_CUST_3D_FMT_TB;
            break;
        case TDTV_TAG3D_SBS:
            pSignalFormat->eDimension = E_CUST_DIMENSION_3D;
            pSignalFormat->e3dFormat = E_CUST_3D_FMT_SS;
            break;
        case TDTV_TAG3D_LI:
        case TDTV_TAG3D_CB:
        case TDTV_TAG3D_DA:
            pSignalFormat->eDimension = E_CUST_DIMENSION_3D;
            pSignalFormat->e3dFormat = E_CUST_3D_FMT_UNKNOWN;
            break;
        case TDTV_TAG3D_2D:
        default:
            pSignalFormat->eDimension = E_CUST_DIMENSION_2D;
            pSignalFormat->e3dFormat = E_CUST_3D_FMT_UNKNOWN;
            break;
    }

    if(((bSignalType == SV_ST_TV) || (bSignalType == SV_ST_AV) || (bSignalType == SV_ST_SV))
        ||((bSignalType == SV_ST_MPEG)&&((t_B2RCustInfo.eColorID == ColorSpace_sRGB)||
            (t_B2RCustInfo.eColorID == ColorSpace_sYCC)||(t_B2RCustInfo.eColorID == ColorSpace_AdobeRGB)))
        ||((bSignalType == SV_ST_DVI)&&(DRVCUST_HDMIIsPhotoMode())))
    {
        pSignalFormat->eColorimetry = E_CUST_COLMT_601; 
    }
    else if((bSignalType == SV_ST_DVI)&&(DRVCUST_HDMIWithValidAviInfo()))
    {
        switch(DRVCUST_HDMIGetColorimetry())
        {  
            case SV_COLOR_HDMI_Colorimetry_601:
            case SV_COLOR_HDMI_Colorimetry_XVYCC601:
            case SV_COLOR_HDMI_Colorimetry_sYCC601:
            case SV_COLOR_HDMI_Colorimetry_AdobeYCC601:
                pSignalFormat->eColorimetry = E_CUST_COLMT_601;
                break;
            case SV_COLOR_HDMI_Colorimetry_709:
            case SV_COLOR_HDMI_Colorimetry_XVYCC709:
                pSignalFormat->eColorimetry = E_CUST_COLMT_709;
                break;
            case SV_COLOR_HDMI_Colorimetry_BT2020:
                pSignalFormat->eColorimetry = E_CUST_COLMT_2020;
                break;
            case SV_COLOR_HDMI_Colorimetry_RGB:
            case SV_COLOR_HDMI_Colorimetry_AdobeRGB:
            case SV_COLOR_HDMI_Colorimetry_UnKnown:
            default:    
                pSignalFormat->eColorimetry = E_CUST_COLMT_UNKOWN;
                break;
        }
    }
    else
    {
        pSignalFormat->eColorimetry = (pSignalFormat->u4Height >= 720) ? 
                                      E_CUST_COLMT_709 : E_CUST_COLMT_601;
    }

    /*
    switch(u1ColorSys)
    {
        case SV_COLOR_YCBCR_SD:
            pSignalFormat->eColorimetry = E_CUST_COLMT_601;    
            break;
        case SV_COLOR_YCBCR_HD:    
            pSignalFormat->eColorimetry = E_CUST_COLMT_709;    
            break;
        case SV_COLOR_YUV_2020:     // PQ : TBD
            pSignalFormat->eColorimetry = E_CUST_COLMT_2020;   
            break;
        case SV_COLOR_RGB_SD:
        case SV_COLOR_RGB_HD:
        case SV_COLOR_YUV_NTSC: 
        case SV_COLOR_YUV_NTSCJ:        
        case SV_COLOR_YUV_PAL:
        default:
            pSignalFormat->eColorimetry = E_CUST_COLMT_UNKOWN;    // PQ
            break;
    }
    */
    
    if ((u1ColorSys == SV_COLOR_RGB_SD) || (u1ColorSys == SV_COLOR_RGB_HD))
    {        
        pSignalFormat->eColorFormat = E_CUST_COL_FMT_RGB;       
    }
    else if (bSignalType == SV_ST_DVI)
    {
        pSignalFormat->eColorFormat = bHDMI422Input() ? E_CUST_COL_FMT_YUV_422 : E_CUST_COL_FMT_YUV_444;  
    }
    else if (bSignalType == SV_ST_MPEG)
    {
        pSignalFormat->eColorFormat = E_CUST_COL_FMT_YUV_420;  
    }
	else if ((eInputType == E_CUST_INPUT_TYPE_SCART) && (u1ScartMode == SCART_COLOR_RGB))
    {
        pSignalFormat->eColorFormat = E_CUST_COL_FMT_RGB;  
    }
    else
    {
        pSignalFormat->eColorFormat = E_CUST_COL_FMT_YUV_422;   // VIDEO todo : photo
    }

    if (bSignalType == SV_ST_VGA)
    {
        pSignalFormat->eColorDepth = E_CUST_COL_DEPTH_8; 
    }
    else if (bSignalType == SV_ST_DVI)
    {
        switch (u1ColorDepth)
        {            
            case 1:
                pSignalFormat->eColorDepth = E_CUST_COL_DEPTH_10;     
                break;
            case 2:
                pSignalFormat->eColorDepth = E_CUST_COL_DEPTH_12;  
                break;
            default:
            case 0:
                pSignalFormat->eColorDepth = E_CUST_COL_DEPTH_8;   
                break;
         }
    }
    else
    {
        pSignalFormat->eColorDepth = E_CUST_COL_DEPTH_10;   // VIDEO todo : photo
    }
    if (bSignalType == SV_ST_DVI)
    {  
	    switch(DRVCUST_HDMIGetVideoColorSpace())    //DVI video
        {
            case SV_COLOR_HDMI_Normal:
                pSignalFormat->eColorSpace = E_CUST_COL_SPACE_NORMAL;
                break;
            case SV_COLOR_HDMI_xvYCC:
                pSignalFormat->eColorSpace = E_CUST_COL_SPACE_XV_COLOR;
                break;
            case SV_COLOR_HDMI_BT2020:
                pSignalFormat->eColorSpace = E_CUST_COL_SPACE_BT2020;
                break;
            case SV_COLOR_HDMI_BT2020c:
                pSignalFormat->eColorSpace = E_CUST_COL_SPACE_BT202C;
                break;
            case SV_COLOR_HDMI_sRGB:
            case SV_COLOR_HDMI_Adobe_RGB:
            case SV_COLOR_HDMI_sYCC:
            default:
                pSignalFormat->eColorSpace = E_CUST_COL_SPACE_UNKNOWN;
                break;
        }      
        switch(DRVCUST_HDMIGetPhotoColorSpace())    //DVI Photo
        {
            case SV_COLOR_HDMI_sRGB:
	            pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_SRGB;
                break;
            case SV_COLOR_HDMI_sYCC:
                pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_SYCC;
                break;
            case SV_COLOR_HDMI_Adobe_RGB:
	            pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_ADOBE_RGB;
                break;
            case SV_COLOR_HDMI_xvYCC:
            case SV_COLOR_HDMI_BT2020:
            case SV_COLOR_HDMI_BT2020c:
            case SV_COLOR_HDMI_Normal:
            default:
	            pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_UNKNOWN;
                break;
        }
    }
    else if(bSignalType == SV_ST_MPEG)
    {
	    switch(t_B2RCustInfo.eColorID)
	    {
	    	case ColorSpace_Normal:
	            pSignalFormat->eColorSpace = E_CUST_COL_SPACE_NORMAL; 
				pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_UNKNOWN;
			    break;
			case ColorSpace_XVColor:
	            pSignalFormat->eColorSpace = E_CUST_COL_SPACE_XV_COLOR; 
				pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_UNKNOWN;
			    break;
		    case ColorSpace_BT202C:
	            pSignalFormat->eColorSpace = E_CUST_COL_SPACE_BT202C;  
				pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_UNKNOWN;
			    break;
			case ColorSpace_BT2020:
	            pSignalFormat->eColorSpace = E_CUST_COL_SPACE_BT2020;  
				pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_UNKNOWN;
			    break;
			case ColorSpace_sRGB:
				pSignalFormat->eColorSpace = E_CUST_COL_SPACE_UNKNOWN;
	            pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_SRGB;  
			    break;
			case ColorSpace_sYCC:
				pSignalFormat->eColorSpace = E_CUST_COL_SPACE_UNKNOWN;
	            pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_SYCC;  
			    break;
			case ColorSpace_AdobeRGB:
				pSignalFormat->eColorSpace = E_CUST_COL_SPACE_UNKNOWN;
	            pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_ADOBE_RGB; 
			    break;
			case ColorSpace_NS: 
			default:
			    pSignalFormat->eColorSpace = E_CUST_COL_SPACE_UNKNOWN;
			    pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_UNKNOWN;
			    break;
		}
    }
    else
    {
        pSignalFormat->eColorSpace = E_CUST_COL_SPACE_NORMAL;
        pSignalFormat->ePhotoColorSpace = E_CUST_PHOTO_COL_SPACE_UNKNOWN;
    }

    switch (bSignalType)
    {
        case SV_ST_DVI:
            u4VideoRange = bHDMIRgbRange();
            u4VideoRange = (u4VideoRange == SV_HDMI_RANGE_DEFAULT) ? DRVCUST_HDMIRange(bPath) : u4VideoRange;
            break;
        case SV_ST_VGA:
            u4VideoRange = SV_HDMI_RANGE_FULL;
            break;
		case SV_ST_MPEG:
			u4VideoRange = DRVCUST_GetVideoRange(bPath);
            u4VideoRange = (u4VideoRange == SV_HDMI_RANGE_DEFAULT) ? DRVCUST_HDMIRange(bPath) : u4VideoRange;
			break;
        default:
            u4VideoRange = SV_HDMI_RANGE_LIMIT;
            break;
    }

	if((eInputType ==  E_CUST_INPUT_TYPE_HDMI) || (eInputType ==  E_CUST_INPUT_TYPE_WIFI_DISPLAY))
	{
		if(rPicInfoFromAP.eDrange == E_CUST_DRANGE_UI_AUTO)
		{
			switch (u4VideoRange)
		    {
		        case SV_HDMI_RANGE_FULL:
		            pSignalFormat->eDynamicRange = E_CUST_DRANGE_FULL;       
		            break;
		        case SV_HDMI_RANGE_LIMIT:
		            pSignalFormat->eDynamicRange = E_CUST_DRANGE_LIMITED;       
		            break;
		        default:
		            pSignalFormat->eDynamicRange = E_CUST_DRANGE_LIMITED;
		            break;
		    }
		}
		else if(rPicInfoFromAP.eDrange == E_CUST_DRANGE_UI_FULL)
		{
			pSignalFormat->eDynamicRange = E_CUST_DRANGE_FULL; 
		}
		else
		{
			pSignalFormat->eDynamicRange = E_CUST_DRANGE_LIMITED; 
		}
	}
	else
	{
		pSignalFormat->eDynamicRange = E_CUST_DRANGE_LIMITED; 
	}
    
    
    
    //pSignalFormat->eAspect = E_CUST_ASPECT_UNKNOWN;             // VIDEO : TBD	
    if(bSignalType == SV_ST_MPEG)
	{
        switch(u1AspInfo)
        {
            case MPEG_ASPECT_RATIO_4_3:
                pSignalFormat->eAspect = E_CUST_ASPECT_4_3;   
                break;
            case MPEG_ASPECT_RATIO_16_9:
                pSignalFormat->eAspect = E_CUST_ASPECT_16_9;
                break;                
            default:
                pSignalFormat->eAspect = E_CUST_ASPECT_UNKNOWN;
                break;
        }
    }
    else if(bSignalType == SV_ST_DVI)
    {
        pSignalFormat->eAspect = (E_CUST_ASPECT)DRVCUST_HDMIGetAspectRatio();
    }
    else
    {
        pSignalFormat->eAspect = E_CUST_ASPECT_UNKNOWN;
    }
        
    if(bSignalType == SV_ST_MPEG)
    {
	    switch(t_B2RCustInfo.eCodecInfo)
	    {
			case E_VDEC_CODEC_MPEG1:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_MPEG1;   
			    break;
			case E_VDEC_CODEC_MPEG2:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_MPEG2;  
			    break;
			case E_VDEC_CODEC_MPEG4_VISUAL:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_MPEG4_VISUAL;  
			    break;
			case E_VDEC_CODEC_AVC:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_AVC; 
			    break;
			case E_VDEC_CODEC_HEVC:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_HEVC; 
			    break;
			case E_VDEC_CODEC_AVS:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_AVS;  
			    break;
			case E_VDEC_CODEC_XVID:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_XVID;  
			    break;
			case E_VDEC_CODEC_VC1:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_VC1;   
			    break;
			case E_VDEC_CODEC_REAL:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_REAL;  
			    break;
			case E_VDEC_CODEC_VP8:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_VP8;  
			    break;
			case E_VDEC_CODEC_MOTION_JPEG:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_MOTION_JPEG;  
			    break;
			case E_VDEC_CODEC_JPEG:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_JPEG; 
				break;
	        case E_VDEC_CODEC_MPO:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_MPO;  
			    break;
			case E_VDEC_CODEC_RAW:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_RAW;  
				break;
			case E_VDEC_CODEC_VP9:
	            pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_REAL;  
				break;
			default:
			    pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_UNKNOWN;
			    break;
		}
    }
	else
	{
		pSignalFormat->eVideoCodec = E_CUST_VDO_CODEC_UNKNOWN;
	}
	if (VDEC_QueryChromaInfo(bPath, &rChromaSimpleInfo))
	{
		switch(rChromaSimpleInfo.u4ChromaSampleLocTypeBottomField)
			{
				case 0:
					pSignalFormat->eCromaSample = E_CUST_CHROMA_SAMPLE_TYPE_0;   
					break;
				case 1:
					pSignalFormat->eCromaSample = E_CUST_CHROMA_SAMPLE_TYPE_1;  
					break;
				case 2:
					pSignalFormat->eCromaSample = E_CUST_CHROMA_SAMPLE_TYPE_2;  
					break;
				case 3:
					pSignalFormat->eCromaSample = E_CUST_CHROMA_SAMPLE_TYPE_3; 
					break;
				case 4:
					pSignalFormat->eCromaSample = E_CUST_CHROMA_SAMPLE_TYPE_4; 
					break;
				case 5:
					pSignalFormat->eCromaSample = E_CUST_CHROMA_SAMPLE_TYPE_5;	
					break;
				default:
					pSignalFormat->eCromaSample = E_CUST_CHROMA_SAMPLE_TYPE_INVALID;
					break;
			}
	}
	else
	{
		pSignalFormat->eCromaSample = E_CUST_CHROMA_SAMPLE_TYPE_INVALID;
	}
	if(bSignalType == SV_ST_DVI)
	{
        pSignalFormat->eHdmi4kPhoto = u1HDMI_Get4KPStatus() ? E_CUST_HDMI_4K_PHOTO_ON : E_CUST_HDMI_4K_PHOTO_OFF;   
	}
	else
	{
        pSignalFormat->eHdmi4kPhoto =  E_CUST_HDMI_4K_PHOTO_OFF;   
	}
	switch(bSignalType)
	{
		case SV_ST_DVI:
			//u4HDRType = (UINT32)DRVCUST_HDMIGetHDRType(SV_VP_MAIN);
			eHdmiHDREotf = eHdmiGetHdrType();
			switch(eHdmiHDREotf)
			{
				case SMPTE_ST2048:
					u4HDRType = E_CUST_HDR_TYPE_HDR1;
					break;
				case FUTURE_EOTF:
					u4HDRType = E_CUST_HDR_TYPE_HDR2;
					break;
				default:
					u4HDRType = E_CUST_HDR_TYPE_SDR;
					break;
			}
			break;
		case SV_ST_MPEG:
			if(t_B2RCustInfo.tHdrDetectInfo.u4SEIHDRContent == 18)
			{
				u4HDRType = SV_HDR_TYPE_HDR2;
			}
			else if(t_B2RCustInfo.tHdrDetectInfo.u4SEIHDRContent == 16)
			{
				u4HDRType = SV_HDR_TYPE_HDR1;
			}
			else if(t_B2RCustInfo.tHdrDetectInfo.u4VUIHDRContent== 16)
			{
				u4HDRType = SV_HDR_TYPE_HDR1;
			}
			else if(t_B2RCustInfo.tHdrDetectInfo.u4VUIHDRContent== 18)
			{
				u4HDRType = SV_HDR_TYPE_HDR2;
			}
			else
			{
				u4HDRType = SV_HDR_TYPE_SDR;
			}
			
			break;
		default:
			u4HDRType = SV_HDR_TYPE_SDR;
			break;
			
	}


	pSignalFormat->eHDRType = u4HDRType;
	DEBUG_GetSignalFormat(bPath, pSignalFormat);

}

E_CUST_WINDOW_MODE DRVCUST_GetWindowMode(void)
{
    SRM_TV_MODE_T mode = SRM_GetTvMode();

    switch (mode)
    {        
        case SRM_TV_MODE_TYPE_PIP:
            return E_CUST_WINDOW_MODE_PIP;
        case SRM_TV_MODE_TYPE_POP:
            return E_CUST_WINDOW_MODE_PAP;
        default:
        case SRM_TV_MODE_TYPE_NORMAL:
            return E_CUST_WINDOW_MODE_SINGLE;
    }
}

E_CUST_MUTE_STATE DRVCUST_GetPlaneMuteState(UINT8 bPath)
{
	BOOL bMute;
	bMute =  ((bPath == SV_VP_MAIN) ? fgMainMuteOn() : fgPIPMuteOn());
    return bMute ? E_CUST_MUTE_STATE_MUTE : E_CUST_MUTE_STATE_UNMUTE;
}

E_CUST_MUTE_STATE DRVCUST_GetOutputMuteState(UINT8 u1TxPath)
{
    if (u1TxPath) // Physical Gfx
    {
        return u4DrvGfxOutputMute() ? E_CUST_MUTE_STATE_MUTE : E_CUST_MUTE_STATE_UNMUTE;
    }
    else // Physical Video
    {
        return u4DrvVideoOutputMute() ? E_CUST_MUTE_STATE_MUTE : E_CUST_MUTE_STATE_UNMUTE;
    }
}

void DRVCUST_GetOutputPosition(UINT8 bPath, CUST_OUT_POSI_T* pOutPosition)
{   
     if ((bPath == 0) && (GetPANEL4K2K_TYPE() == PANEL_TYPE_4K2K_60))
     {
        #if defined(CC_MT5890) && defined(CC_SUPPORT_4KBE)
        extern CONTROL_BIT_VB1_T gVB1ControlBit;
        #endif

        pOutPosition->u4X = 0;
        pOutPosition->u4Y = 0;
        pOutPosition->u4Width = 3840;
        pOutPosition->u4Height = 2160;
        #if defined(CC_MT5890) && defined(CC_SUPPORT_4KBE)
        pOutPosition->u4Width = gVB1ControlBit.u4PicHSize;
        pOutPosition->u4Height = gVB1ControlBit.u4PicVSize;
        #endif
     }
	 else
	 {
	 	VRM_INFO_T* vrmInfo = VRMGetVRMInfo(bPath, VRM_MODULE_MIXER);
	 	if(vrmInfo)
	 	{
            if((bGetVideoDecType(bPath) == SV_VD_NA) || (bGetVideoDecType(bPath) == SV_VD_MAX))
            {
                pOutPosition->u4X = 0;
                pOutPosition->u4Y = 0;
                pOutPosition->u4Width = 0;
                pOutPosition->u4Height = 0;
            }
            else
            {
		 	    pOutPosition->u4X = vrmInfo->u2X;
	            pOutPosition->u4Y = vrmInfo->u2Y;
	            pOutPosition->u4Width = vrmInfo->u2Width;
	            pOutPosition->u4Height = vrmInfo->u2Height;
            }
		 }
	 }
	 
#if MAPLE_SYS_DEBUG
	 LOG(2, "====== DRVCUST_GetOutputPosition ======\n");
	 LOG(2, "u4X 			 %d\n", pOutPosition->u4X);
	 LOG(2, "u4Y 			 %d\n", pOutPosition->u4Y);
	 LOG(2, "u4Width 		 %d\n", pOutPosition->u4Width);
	 LOG(2, "u4Height		 %d\n", pOutPosition->u4Height);
	 LOG(2, "bPath 		 %d\n", bPath);
	 LOG(2, "PanelType 		 %d\n", GetPANEL4K2K_TYPE());
#endif
	 
}

void DRVCUST_GetSourceArea(UINT8 u1BeHandle, CUST_SRC_AREA_T* pSclReq)
{
    UINT8 u1Path;
	UINT32 u4Width;
	UINT32 u4Height;
	UINT16 u2MainSrcWidth;
	UINT16 u2MainSrcHeight;
	RDispInfo* dispInfo;
	u1Path = DRVCUST_GetPathByBeHandle(u1BeHandle);
    dispInfo= getDispInfo(u1Path);
	u2MainSrcWidth = wDrvVideoInputWidth(SV_VP_MAIN);
	u2MainSrcHeight= wDrvVideoInputHeight(SV_VP_MAIN);
	
	pSclReq->u4SrcX 			= 0;//prVrmInfo->u2X;
	pSclReq->u4SrcY 			= 0;//prVrmInfo->u2Y;
	pSclReq->u4SrcWidth 		= 1920;//prVrmInfo->u2Width;
	pSclReq->u4SrcHeight		= 1080;//prVrmInfo->u2Height;
	
	u4Width  = u4GetPlaneWidth(u1GetOutputPlane(u1Path));
	u4Height = u4GetPlaneHeight(u1GetOutputPlane(u1Path));
	if (u4Width == 0 || u4Height == 0)
	{
		printf("Plane Weight/Height(%d,%d) error!!!!!!!!!!!!!!!!!!!!!\n",u4Width,u4Height);
	   // return (SV_FAIL);
	}
	switch(GetPANEL4K2K_TYPE())
	{
		case PANEL_TYPE_4K2K_60:
			if(u1Path == SV_VP_MAIN)
			{
			    if(u2MainSrcWidth == 0 || u2MainSrcHeight == 0)
		    	{
		    	    pSclReq->u4SrcWidth		= 3840;//prVrmInfo->u2Width;
					pSclReq->u4SrcHeight		= 2160;//prVrmInfo->u2Height; 
		    	}
				else
				{
					pSclReq->u4SrcWidth		= u2MainSrcWidth;//prVrmInfo->u2Width;
					pSclReq->u4SrcHeight		= u2MainSrcHeight;//prVrmInfo->u2Height; 
				}
			}
			else if(u1Path == SV_VP_PIP)
			{
				pSclReq->u4SrcX		= DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4X,	  VDP_MAX_REGION_WIDTH);
				pSclReq->u4SrcWidth	= DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4Width,  VDP_MAX_REGION_WIDTH);
				pSclReq->u4SrcY		= DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Y,	  VDP_MAX_REGION_HEIGHT);
				pSclReq->u4SrcHeight = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Height, VDP_MAX_REGION_HEIGHT);
			}
			else//gfx path
			{
				 switch(GraphMode_GetPanelType())
				{
					 case PANEL_TYPE_4K2K_30:
						pSclReq->u4SrcWidth		= 3840;//prVrmInfo->u2Width;
						pSclReq->u4SrcHeight		= 2160;//prVrmInfo->u2Height;
						break;
					case PANEL_TYPE_4K1K_60:
					case PANEL_TYPE_2K1K_60:
					default:
						pSclReq->u4SrcWidth		= 1920;//prVrmInfo->u2Width;
						pSclReq->u4SrcHeight		= 1080;//prVrmInfo->u2Height;
						break;
				}
			}
			break;
		case PANEL_TYPE_4K1K_60:
			if((u1Path == SV_VP_MAIN) || (u1Path == SV_VP_PIP))
			{
				pSclReq->u4SrcX	= (u1Path == SV_VP_MAIN)? 0 : 1920;//prVrmInfo->u2X;
			}
			else //GFX path
			{
				switch(GraphMode_GetPanelType())
				{
					 case PANEL_TYPE_4K2K_30:
						pSclReq->u4SrcWidth		= 3840;//prVrmInfo->u2Width;
						pSclReq->u4SrcHeight		= 2160;//prVrmInfo->u2Height;
						break;
					case PANEL_TYPE_4K1K_60:
					case PANEL_TYPE_2K1K_60:
					default:
						pSclReq->u4SrcWidth		= 1920;//prVrmInfo->u2Width;
						pSclReq->u4SrcHeight		= 1080;//prVrmInfo->u2Height;
						break;
				}
			}
			break;
		case PANEL_TYPE_4K2K_30:
			if((u1Path == SV_VP_MAIN) || (u1Path == SV_VP_PIP))//4k photo in pq path
			{
				pSclReq->u4SrcWidth		= 3840;//prVrmInfo->u2Width;
				pSclReq->u4SrcHeight		= 2160;//prVrmInfo->u2Height; 
			}
			else //GFX path
			{
				switch(GraphMode_GetPanelType())
				{
					 case PANEL_TYPE_4K2K_30:
						pSclReq->u4SrcWidth		= 3840;//prVrmInfo->u2Width;
						pSclReq->u4SrcHeight		= 2160;//prVrmInfo->u2Height;
						break;
					case PANEL_TYPE_4K1K_60:
					case PANEL_TYPE_2K1K_60:
					default:
						pSclReq->u4SrcWidth		= 1920;//prVrmInfo->u2Width;
						pSclReq->u4SrcHeight		= 1080;//prVrmInfo->u2Height;
						break;
				}
			}
			break;
		case PANEL_TYPE_MAX:
			pSclReq->u4SrcX	= (u1Path == SV_VP_MAIN)? 0 : 1920;//prVrmInfo->u2X;
			break;
		case PANEL_TYPE_2K1K_120:
		default:
			break;			
	}
	 #if MAPLE_SYS_DEBUG
	 LOG(2,"in DRVCUST_GetSourceArea u1Path (%d),SRCR(x,y,w,h)=(%d,%d,%d,%d)\n",u1Path,pSclReq->u4SrcX,pSclReq->u4SrcY,pSclReq->u4SrcWidth,pSclReq->u4SrcHeight);
	 #endif
}

void DRVCUST_GetScalingRequest(UINT8 u1BeHandle, CUST_DEST_AREA_T* pSclReq)
{
    UINT8 u1Path;
   // UCHAR ucFull;
   // VDP_REGION_T rVdpRegion;
	RDispInfo* dispInfo;
	UINT32 u4Width;
	UINT32 u4Height;
    u1Path = DRVCUST_GetPathByBeHandle(u1BeHandle);
	if(u1Path <= SV_VP_PIP)
	{
        dispInfo = getDispInfo(u1Path);
	}
	else
	{//fix klocwork warning
	    dispInfo = getDispInfo(SV_VP_MAIN);
	}
	pSclReq->u4DestX			= 0;
	pSclReq->u4DestY 		= 0;
	pSclReq->u4DestWidth 	= 3840;
	pSclReq->u4DestHeight	= 2160;
    u4Width  = u4GetPlaneWidth(u1GetOutputPlane(u1Path));
	u4Height = u4GetPlaneHeight(u1GetOutputPlane(u1Path));
	if (u4Width == 0 || u4Height == 0)
    {
        printf("Plane Weight/Height(%d,%d) error!!!!!!!!!!!!!!!!!!!!!\n",u4Width,u4Height);
       // return (SV_FAIL);
    }
	switch(GetPANEL4K2K_TYPE())
	{
	    case PANEL_TYPE_4K2K_60:
			if(u1Path == SV_VP_MAIN)//wide mode output window calculate by 4KBE in bypass path and Dest area always be (0,0,3840,2160)
			{
				if(bIsScalerInput444(SV_VP_MAIN) && (bGetSignalType(SV_VP_MAIN) == SV_ST_DVI))//When hdmi pc timing and in bypass path, screen mode
				//will calculate by 4KBE in bypass path and Dest area always be (0,0,3840,2160)
				{
					pSclReq->u4DestX			= 0;
					pSclReq->u4DestY 		= 0;
					pSclReq->u4DestWidth 	= 3840;
					pSclReq->u4DestHeight	= 2160;
				}
				else
				{
				    pSclReq->u4DestX      = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4X,      VDP_MAX_REGION_WIDTH);
				    pSclReq->u4DestWidth  = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4Width,  VDP_MAX_REGION_WIDTH);
				    pSclReq->u4DestY      = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Y,      VDP_MAX_REGION_HEIGHT);
				    pSclReq->u4DestHeight = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Height, VDP_MAX_REGION_HEIGHT);
				}
			}
			else
			{
			    pSclReq->u4DestX      = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4X,      VDP_MAX_REGION_WIDTH);
			    pSclReq->u4DestWidth  = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4Width,  VDP_MAX_REGION_WIDTH);
			    pSclReq->u4DestY      = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Y,      VDP_MAX_REGION_HEIGHT);
			    pSclReq->u4DestHeight = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Height, VDP_MAX_REGION_HEIGHT);
			}
			break;
		case PANEL_TYPE_4K1K_60:
			if(_eApplicationMode == SRM_TV_MODE_TYPE_POP)//pop case output window controled by BE
			{
			    //transfer (0~10000) to pixel-based output window
			    if((u1Path == SV_VP_MAIN) || (u1Path == SV_VP_PIP))
		    	{
				    pSclReq->u4DestX      = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4X,      VDP_MAX_REGION_WIDTH) * 2;
				    pSclReq->u4DestWidth  = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4Width,  VDP_MAX_REGION_WIDTH) * 2;
				    pSclReq->u4DestY      = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Y,      VDP_MAX_REGION_HEIGHT) * 2;
				    pSclReq->u4DestHeight = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Height, VDP_MAX_REGION_HEIGHT) * 2;
		    	}
			}
			else//single or PIP
			{
			    if(u1Path == SV_VP_PIP)
		    	{
				    //transfer (0~10000) to pixel-based output window
				    pSclReq->u4DestX      = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4X,      VDP_MAX_REGION_WIDTH) * 2;
				    pSclReq->u4DestWidth  = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4Width,  VDP_MAX_REGION_WIDTH) * 2;
				    pSclReq->u4DestY      = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Y,      VDP_MAX_REGION_HEIGHT) * 2;
				    pSclReq->u4DestHeight = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Height, VDP_MAX_REGION_HEIGHT) * 2;
		    	}
			}
			break;
		 case PANEL_TYPE_4K2K_30:
			if(u1Path == SV_VP_MAIN)
			{
			    pSclReq->u4DestX      = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4X,      VDP_MAX_REGION_WIDTH);
			    pSclReq->u4DestWidth  = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4Width,  VDP_MAX_REGION_WIDTH);
			    pSclReq->u4DestY      = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Y,      VDP_MAX_REGION_HEIGHT);
			    pSclReq->u4DestHeight = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Height, VDP_MAX_REGION_HEIGHT);
			}
			break;
		case PANEL_TYPE_MAX:
			if(u1Path == SV_VP_PIP)//avoid first play sub when tv bootup
	    	{
			    //transfer (0~10000) to pixel-based output window
			    pSclReq->u4DestX      = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4X,      VDP_MAX_REGION_WIDTH) * 2;
			    pSclReq->u4DestWidth  = DIVIDE_WITH_ROUND(u4Width  * dispInfo->rOutRegion.u4Width,  VDP_MAX_REGION_WIDTH) * 2;
			    pSclReq->u4DestY      = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Y,      VDP_MAX_REGION_HEIGHT) * 2;
			    pSclReq->u4DestHeight = DIVIDE_WITH_ROUND(u4Height * dispInfo->rOutRegion.u4Height, VDP_MAX_REGION_HEIGHT) * 2;
	    	}
			break;	
		case PANEL_TYPE_2K1K_120:
		default:
			break;			
	}
	#if MAPLE_SYS_DEBUG
	LOG(2,"in DRVCUST_GetScalingRequest PNL type(%d),u1Path(%d),OUTR(x,y,w,h)=(%d,%d,%d,%d)\n",GetPANEL4K2K_TYPE(),u1Path,pSclReq->u4DestX,pSclReq->u4DestY,pSclReq->u4DestWidth,pSclReq->u4DestHeight);
    #endif
}

void DRVCUST_GetOutputFormat(UINT8 u1TxPath, CUST_OUT_FMT_T* pOutFmt)
{
	UINT8 u1FrameRate;
       
    if (u1TxPath == 0)
    {
    	/*
        pOutFmt->u4ActX = 384;//vrmInfo->u2X;
        pOutFmt->u4ActY = 36;//vrmInfo->u2Y;
        pOutFmt->u4ActWidth = 3840;//vrmInfo->u2Width;
        pOutFmt->u4ActHeight = 1080;//= vrmInfo->u2Height;
        pOutFmt->u4Htotal = 4400;//vrmInfo->u2HTotal;       
        pOutFmt->u4Vtotal = 1125;//vrmInfo->u2VTotal;
        */
       	pOutFmt->u4ActX = lcdtimingInfo.u4HSyncWidth+ lcdtimingInfo.u4HBP;
        pOutFmt->u4ActY = lcdtimingInfo.u4VSyncWidth + lcdtimingInfo.u4VBP;
        pOutFmt->u4ActWidth = lcdtimingInfo.u4HActive;
        pOutFmt->u4ActHeight = lcdtimingInfo.u4VActive;
        pOutFmt->u4Htotal = lcdtimingInfo.u4HTotal;   
        pOutFmt->u4Vtotal = lcdtimingInfo.u4VTotal;   
        u1FrameRate = vDrvGetLCDFreq();

	
 
    switch(u4DrvTDTVDispModeQuery())
    {
        case E_TD_OUT_3D_FS:
            pOutFmt->eDimension = E_CUST_DIMENSION_3D;
            pOutFmt->e3dFormat = E_CUST_3D_FMT_FS;
            break;
        case E_TD_OUT_3D_LI:
            pOutFmt->eDimension = E_CUST_DIMENSION_3D;
            pOutFmt->e3dFormat = E_CUST_3D_FMT_LI;
            break;
        case E_TD_OUT_NATIVE:
        default:
            pOutFmt->eDimension = E_CUST_DIMENSION_2D;
            pOutFmt->e3dFormat = E_CUST_3D_FMT_UNKNOWN;
            break;
    }  
    

    switch(PANEL_GetControlWord() & DISP_BIT_MSK)
    {
        case DISP_24BIT:
            pOutFmt->eColorDepth = E_CUST_COL_DEPTH_8;
            break;
        case DISP_30BIT:
            pOutFmt->eColorDepth = E_CUST_COL_DEPTH_10;
            break;
        case DISP_36BIT:
            pOutFmt->eColorDepth = E_CUST_COL_DEPTH_12;
            break;
        default:
            pOutFmt->eColorDepth = E_CUST_COL_DEPTH_UNKNOWN;
            break;
    }

	if(fgYUVout)
	{
		pOutFmt->eColorimetry = E_CUST_COLMT_601; 
		pOutFmt->eColorFormat = E_CUST_COL_FMT_YUV_444;
		pOutFmt->eColorSpace = E_CUST_COL_SPACE_NORMAL;     
    	pOutFmt->eDynamicRange = E_CUST_DRANGE_LIMITED;  
	}
	else
	{
		pOutFmt->eColorimetry = E_CUST_COLMT_UNKOWN;
		pOutFmt->eColorFormat = E_CUST_COL_FMT_RGB;
		pOutFmt->eColorSpace = E_CUST_COL_SPACE_UNKNOWN;     
    	pOutFmt->eDynamicRange = E_CUST_DRANGE_FULL; 
	}
    
      
    pOutFmt->ePath = (pOutFmt->u4ActHeight > 1088) ? E_CUST_PATH_BYPASS: E_CUST_PATH_PQ;
	pOutFmt->bCtrlBitValid = (pOutFmt->u4ActHeight > 1088) ? 1 : 0;
	if(fgPhotoRasterModeIn4k && (bGetSignalType(SV_VP_MAIN) == SV_ST_MPEG))//4k photo only in pq path
	{
	    pOutFmt->ePath = E_CUST_PATH_PQ;
		pOutFmt->bCtrlBitValid = 0;
	}
		
    }
	else
	{
	    #if defined(SUPPORT_PANEL_GRAPH_MODE)
		pOutFmt->u4ActX = GFXTimingInfo.u4HSyncWidth+ GFXTimingInfo.u4HBP;
        pOutFmt->u4ActY = GFXTimingInfo.u4VSyncWidth + GFXTimingInfo.u4VBP;
        pOutFmt->u4ActWidth = GFXTimingInfo.u4HActive;
        pOutFmt->u4ActHeight = GFXTimingInfo.u4VActive;
        pOutFmt->u4Htotal = GFXTimingInfo.u4HTotal;   
        pOutFmt->u4Vtotal = GFXTimingInfo.u4VTotal;   
        u1FrameRate =  GFXTimingInfo.u1FrameRate; 
        #endif

		pOutFmt->eDimension = E_CUST_DIMENSION_2D;
        pOutFmt->e3dFormat = E_CUST_3D_FMT_UNKNOWN;
		pOutFmt->eColorDepth = E_CUST_COL_DEPTH_8;
		pOutFmt->eColorimetry = E_CUST_COLMT_UNKOWN;
		pOutFmt->eColorFormat = E_CUST_COL_FMT_RGB;
		pOutFmt->eColorSpace = E_CUST_COL_SPACE_UNKNOWN;     
    	pOutFmt->eDynamicRange = E_CUST_DRANGE_FULL; 

		pOutFmt->ePath = E_CUST_PATH_BYPASS;
		pOutFmt->bCtrlBitValid = 1;
	}
	
	switch (u1FrameRate)
    {
        case 8:
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_8;
            break;
        case 10:
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_10;
            break;
        case 12:
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_12;
            break;
        case 24:
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_24;
            break;
        case 25:
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_25;
            break;
        case 30:
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_30;
            break;        
        case 48:
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_48;
            break;
        case 50:
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_50;
            break;
        case 96:
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_96;
            break;                  
        case 100:
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_100;
            break;  
        case 120:
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_120;
            break;  
        case 60:           
        default:        
            pOutFmt->eFrameRate = E_CUST_FRAME_RATE_60;
            break;                 
    }  
	DEBUG_GetOutputVideoFormat(pOutFmt);

}

UINT8 DRVCUST_GetBorderPlaneRequest(UINT8 u1BeHandle)
{
	return 0;//to do
}

UINT8 DRVCUST_GetBlurRequest(UINT8 u1BeHandle)
{
	return 0;//to do
}


void DRVCUST_GetMCVPMeter(CUST_MCVP_METER_T* pMcvpMeter)
{
    pMcvpMeter->u1NoiseLevel = u1DrvNRGetOriNoiseLevel();
    pMcvpMeter->u1BlockNoiseLevel = u1DrvNXNRGetBlkConf();
    pMcvpMeter->u4FrmDiff = u4DrvDIGetMotionLevel();
    vDrvDIGetFreqStatus(&pMcvpMeter->u1FreqHpfV, &pMcvpMeter->u1FreqHpfH, &pMcvpMeter->u1FreqBpfH);

}

E_CUST_CADENSE DRVCUST_GetCadense(void)
{
    EXTERN UINT8 bDrvGetFilmStatus(void);
    EXTERN UINT8 u1DI_Is50HZ;  
    UINT8 u1FilmMode = bDrvGetFilmStatus();
    E_CUST_CADENSE bCustCandense;
    
    if(u1DI_Is50HZ == SV_TRUE)
    {
        switch(u1FilmMode)
        {
            case E_DI_FILM_22:
                bCustCandense = E_CUST_CADENSE_22;
                break;
            case E_DI_FILM_44:
                bCustCandense = E_CUST_CADENSE_44;
                break;
            case E_DI_FILM_66:
                bCustCandense = E_CUST_CADENSE_66;
                break;
            default:
                bCustCandense = E_CUST_CADENSE_UNKOWN;
                break;
        }
    }
    else  	
    {
        switch(u1FilmMode)
        {
            case E_DI_FILM_32:
                bCustCandense = E_CUST_CADENSE_32;
                break;
            case E_DI_FILM_22:
                bCustCandense = E_CUST_CADENSE_22;
                break;
            case E_DI_FILM_2224:
                bCustCandense = E_CUST_CADENSE_2224;
                break;
            case E_DI_FILM_2332:
                bCustCandense = E_CUST_CADENSE_2332;
                break;
            case E_DI_FILM_32322:
                bCustCandense = E_CUST_CADENSE_32322;
                break;
            case E_DI_FILM_55:
                bCustCandense = E_CUST_CADENSE_55;
                break;
            case E_DI_FILM_64:
                bCustCandense = E_CUST_CADENSE_64;
                break;
            case E_DI_FILM_87:
                bCustCandense = E_CUST_CADENSE_87;
                break;
            default:
                bCustCandense = E_CUST_CADENSE_UNKOWN;
                break;
        }
    }
    #if MAPLE_SYS_DEBUG    
    //LOG(2, "\n====== DRVCUST_GetCadense: (%d)======\n",bCustCandense); 
    #endif
    return bCustCandense;
}

E_CUST_FRAME_RATE DRVCUST_GetMJCInputFrequency(void)
{
	E_CUST_FRAME_RATE ret;	
    VRM_INFO_T* vrmInfo;
    
    vrmInfo = VRMGetVRMInfo(SV_VP_MAIN, VRM_MODULE_MJC);

    switch (vrmInfo->u2FrameRate)
    {
        case 8:
            ret = E_CUST_FRAME_RATE_8;
            break;
        case 10:
            ret = E_CUST_FRAME_RATE_10;
            break;
        case 12:
            ret = E_CUST_FRAME_RATE_12;
            break;
        case 24:
            ret = E_CUST_FRAME_RATE_24;
            break;
        case 25:
            ret = E_CUST_FRAME_RATE_25;
            break;
        case 30:
            ret = E_CUST_FRAME_RATE_30;
            break;        
        case 48:
            ret = E_CUST_FRAME_RATE_48;
            break;
        case 50:
            ret = E_CUST_FRAME_RATE_50;
            break;
        case 96:
            ret = E_CUST_FRAME_RATE_96;
            break;                  
        case 100:
            ret = E_CUST_FRAME_RATE_100;
            break;  
        case 120:
            ret = E_CUST_FRAME_RATE_120;
            break;  
        case 60:           
        default:        
            ret = E_CUST_FRAME_RATE_60;
            break;                 
    }
	return ret;
}


void DRVCUST_GetPostProcMeter(CUST_POST_PROC_METER_T* pPostProcMeter)
{
    UINT16 u2Window[4];  
    vDrvGetSatHistWindow(u2Window);
    pPostProcMeter->u4X = u2Window[0];    
    pPostProcMeter->u4Y = u2Window[1];    
    pPostProcMeter->u4Width = u2Window[2] - u2Window[0] + 1;
    pPostProcMeter->u4Height = u2Window[3] - u2Window[1] + 1;
    vDrvGetAPLLR(&pPostProcMeter->u1APLL, &pPostProcMeter->u1APLR);
	vDrvGetASLLR(&pPostProcMeter->u1ASLL, &pPostProcMeter->u1ASLR);
    vDrvGetLuma65HistLR(pPostProcMeter->u2LumaHistL, pPostProcMeter->u2LumaHistR, 0);
    vDrvGetInputLumaMaxLR(&pPostProcMeter->u1LumaMaxL, &pPostProcMeter->u1LumaMaxR);
    vDrvGetInputLumaMinLR(&pPostProcMeter->u1LumaMinL, &pPostProcMeter->u1LumaMinR);
	vDrvGetInputLumaSumLR(&pPostProcMeter->u4LumaSumL, &pPostProcMeter->u4LumaSumR);
	vDrvGetSatHistLR(pPostProcMeter->u2SatHistL, pPostProcMeter->u2SatHistR, 0);
    vDrvGetHueHistLR(pPostProcMeter->u2HueHistL, pPostProcMeter->u2HueHistR, 0);   
	
}

void DRVCUST_GetLdMeter(CUST_LD_METER_T* pLdMeter)
{
	vDrvLcdimGetBlkinfo(pLdMeter->u1LdMaxRGB);
	u1DrvGetRGBHist(pLdMeter->u2LdMaxHist, 4096);
	vDrvGetLcDimDimmingResultHW(pLdMeter->u2LdDimInfo);
}

UINT8 DRVCUST_GetAnalogDecNoiseLevel(UINT8 bPath)
{
    // signal level : db value
    if (bGetVideoDecType(bPath) == SV_VD_TVD3D) 
    {
        return bTvdSignalStrengthLevel(1);
    }
	else
	{
	    return 0;
	}
}


UINT8 DRVCUST_GetOpticalSensorLevel(void)
{    
    return dwOpticalSensorAvgValue;
}

UINT8 DRVCUST_GetTemperatureSensorLevel(void)
{
	INT32 i4ReadTemperature = CustomQueryTemperature();
	UINT8 u1Temperature = 0;
	
	u1Temperature = (i4ReadTemperature & 0xFF);
	
	if(i4ReadTemperature & 0xFFFFFF00)
	{
		u1Temperature = 0;
	}
	
	return u1Temperature;
}

UINT8 DRVCUST_GetBLPowerLimit(void)
{
	#ifdef CC_PowerCons_Ctrl
	return C_BL_POWER_LIMIT;
	#endif
	return 255;
}


UINT8 DRVCUST_GetPwmSetting(void)
{    
    return 0;   // PQ
}

void DRVCUST_GetVideoFrameDelay(CUST_VDO_DELAY_INFO_T* pVdoDelayInfo)
{
    pVdoDelayInfo->u4MCVP = u1DrvDIGetFrameDelay10x(SV_VP_MAIN);
    pVdoDelayInfo->u4Scaler = u1DrvScpipGetFrmDelay10x(SV_VP_MAIN);
    pVdoDelayInfo->u4MJC = u1DrvMJCGetFrmDelay10x();    

}

void DRVCUST_GetHistoryData(CUST_HISTORY_DATA_T* pHistoryData)
{
    BESYS_AP_Get_History_Data(pHistoryData);    // APP
}

void DRVCUST_GetPowerState(CUST_POWER_STATE_T* pPowerState)
{
    UINT8 u1Val=0;
	
    if(ostg_get_fgPanelPowerState())
    {
    	pPowerState->ePanelState = E_CUST_PANEL_STATE_ON;
    }
	else
	{
    	pPowerState->ePanelState = E_CUST_PANEL_STATE_OFF;
    }
	
	EEPROM_Read(0xb105, (UINT32)(void *)&u1Val, 1);
	if(u1Val ==1)
	{
	   pPowerState->ePanelState = E_CUST_PANEL_STATE_OFF;
	   Printf("Panel ID match error return DRVCUST_GetPowerState = OFF \n");
	}	
	//LOG(2, "ePanelState	    %d\n", pPowerState->ePanelState); 
}

UINT32 DRVCUST_GetDecoderAvgBitRate(UINT8 ucEsId)
{    
    UINT32 u4BitRate = 0;    
    VDEC_GetDataSizePerSecond(ucEsId, &u4BitRate);   

    return u4BitRate;
}


UINT32 DRVCUST_BePartitionRead(E_CUST_BE_PART ePartId, UINT32 u4Offset, VOID *pvBuf, UINT32 u4BufSize)
{
	UINT64 u8Offset;
	UINT32 u4RelPartId=0 ;

    LOG(2, "DRVCUST_BePartitionRead\n");
	if(ePartId >= E_CUST_PART_MAX)
	{
		Printf("%s error : partid is invalid\n", __FUNCTION__);
		return 1 ;
	}
	if (DRVCUST_InitQuery(eBELPartitionId, &u4RelPartId) != 0 )
	{
		Printf("%s error query BE ID\n", __FUNCTION__);
		return 1;
	}
	u4RelPartId += ePartId ;

	u8Offset = ((UINT64)((UINT64)u4RelPartId << 32)) | u4Offset ;
	return MSDCPART_Read(u8Offset, (UINT32) pvBuf, u4BufSize);
}

UINT16 DRVCUST_GetAdcValue(E_CUST_ADC_PORT eAdcPort)
{
	UINT32 u4Channel ;
#if 0 //todo
	switch (eAdcPort)
    {
        case E_CUST_ADC_PORT_SCART_FS:
			break;
        case E_CUST_ADC_PORT_KEY:
			break;
        case E_CUST_ADC_PORT_LIGHT_SENSOR:
			break;
		case E_CUST_ADC_PORT_BL_ERR_DET:
			break;
		case E_CUST_ADC_PORT_3_3V_DET:
			break;
		case E_CUST_ADC_PORT_5V_DET:
			break;
		case E_CUST_ADC_PORT_PANEL_PWR_DET:
			break;
		case E_CUST_ADC_PORT_12V_DET:
			break;
		case E_CUST_ADC_PORT_RF_AGC:
			break;
        default:        
			break;

    }
#else
	u4Channel = eAdcPort;
#endif

	return (UINT16) PDWNC_ReadServoADCChannelValue(u4Channel) ;

}

void DRVCUST_GetScreenSaver(CUST_SCREEN_SAVER_T* pScreenSaver)
{
	BESYS_AP_Get_Screen_Saver(pScreenSaver);    // APP
}

void DRVCUST_GetAgingMode(CUST_AGING_MODE_T* pAgingMode)
{
	if(gAgingInit)
	{
		BESYS_AP_Get_Aging_Mode(pAgingMode);    // APP
	}
	else
	{
		pAgingMode->bAgingMode = DRVCUST_EepromReadByte(0x7D0);	//get from EEProm
	}
	//LOG(2, "DRVCUST_GetAgingMode  = %d\n", pAgingMode->bAgingMode);
}

void DRVCUST_GetTvOutputFormat(CUST_TV_OUT_FMT_T* pTvOutFmt)
{
	switch (arMJCPrm.arFRCConfig.u13DModeOut)
    {
        
		case E_VDO_MJC_OUT_2D:
			pTvOutFmt->eDimension = E_CUST_DIMENSION_2D; 
			break;
		case E_VD0_MJC_OUT_FS:
		case E_VD0_MJC_OUT_HPR:
        case E_VD0_MJC_OUT_FPR:
			pTvOutFmt->eDimension = E_CUST_DIMENSION_3D; 
			break;
		case E_VD0_MJC_OUT_OTHER:
			pTvOutFmt->eDimension = E_CUST_DIMENSION_UNKNOWN; 
			break;	
        default:    
			pTvOutFmt->eDimension = E_CUST_DIMENSION_2D; 
			break;

    }

}

void DRVCUST_GetMuffinScalerInfo(UINT8 bPath, CUST_SCL_AREA_T* pScalerArea)
{
	VRM_INFO_T* vrmInfo;
	
    vrmInfo = VRMGetVRMInfo(bPath, VRM_MODULE_PDS);

	pScalerArea->t_DownScalerInput.u4Width = vrmInfo->u2Width;
	pScalerArea->t_DownScalerInput.u4Height= vrmInfo->u2Height;

	vrmInfo = VRMGetVRMInfo(bPath, VRM_MODULE_REGEN);

	pScalerArea->t_DownScalerOutput.u4Width = vrmInfo->u2Width;
	pScalerArea->t_DownScalerOutput.u4Height= vrmInfo->u2Height;

	vrmInfo = VRMGetVRMInfo(bPath, VRM_MODULE_FSC);

	pScalerArea->t_ScalerInput.u4Width = vrmInfo->u2Width;
	pScalerArea->t_ScalerInput.u4Height= vrmInfo->u2Height;

	vrmInfo = VRMGetVRMInfo(bPath, VRM_MODULE_MIXER);

	pScalerArea->t_ScalerOutput.u4Width = vrmInfo->u2Width;
	pScalerArea->t_ScalerOutput.u4Height= vrmInfo->u2Height;

	
}

void DRVCUST_GetOsdState(BOOL* bOsdState)
{
	if(bOsdState == NULL)
    {        
        Printf("DRVCUST_GetOsdState NULL pointer \n");
        return;
    }
	*bOsdState = OSD_BASE_IsDisplaying();
}

void DRVCUST_GetModelVariationInfoStartAddress(UINT32* pAddress)
{
	if(pAddress == NULL)
    {        
        Printf("DRVCUST_GetModelVariationInfoStartAddress NULL pointer \n");
        return;
    }
	*pAddress = 0x10000;
}

void DRVCUST_GetScreenMirroringConfig(UINT8 bPath, CUST_SCR_MIRROR_CONFIG_T* pScrMirrorConfig)
{
	D_AP_INPUT_TYPE eType = BEPQ_AP_Get_Input_Type(bPath);

	if(eType == D_AP_INPUT_TYPE_MIRACAST)
		{
		
		if(gWFDProtocol == 0)
		{
			pScrMirrorConfig->eProtocol = CUST_SCR_MIRROR_PROTOCOL_UDP;
		}
		else if(gWFDProtocol == 1)
		{
			pScrMirrorConfig->eProtocol = CUST_SCR_MIRROR_PROTOCOL_TCP;
		}
		else
		{
			pScrMirrorConfig->eProtocol = CUST_SCR_MIRROR_PROTOCOL_UNKNOWN;
		}
	}
	else
	{
		pScrMirrorConfig->eProtocol = CUST_SCR_MIRROR_PROTOCOL_UNKNOWN;
	}
}

void DRVCUST_GetPicControlState(E_CUST_PIC_CONTROL_STATE *pPicControlState)
{
	*pPicControlState = CUST_PIC_CONTROL_STATE;
}

