/* 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.
 *
 *****************************************************************************/


//----------------------------------------------------------------------------
// Check direct compile this file
//----------------------------------------------------------------------------
#ifndef NO_IMP
#define NO_IMP
#include "drvcust_lib.c"
#define IMP_DRV_MAPLE_AUD_GET_API_AP_C
#endif  /* NO_IMP */
#include "macro_helper.h"

#include "drv_MapleApi.h"
#include "nptv_debug.h"
#include "bepqapi.h"

//----------------------------------------------------------------------------
// Check direct compile this file
//----------------------------------------------------------------------------
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
#undef NO_IMP
#include "macro_helper.h"
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */
//No more #include after this point!!

////////////////////////////////////////////////////////////////////////////////
extern AUTO_BACKLIGHT_SETS_INFO_T stBLight;
extern AUTO_COLORTEMP_SETS_INFO_T stCTInfo;
extern UINT32 bi1GammaOfst;
extern INT16 i2WB20PUIValue[3][21];
extern D_AP_BT_DELAY_MODE gBTDelay ;
extern CUST_COLOR_ADJUST_T bufColorAdust ;
extern CUST_WB_OFFSET_20P_EN_T bufWB_OFFSET_20P_EN ;

extern UINT8 gServiceInit;



////////////////////////////////////////////////////////////////////////////////
#define MAPLE_AP_DEBUG 1

////////////////////////////////////////////////////////////////////////////////
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
static void DEBUG_GetPictureSetting(CUST_PIC_SETTING_T* pPictureSetting)

{
    #if MAPLE_AP_DEBUG
    LOG(2, "====== DRVCUST_GetPictureSetting ======\n"); 
    LOG(2, "ePicMode            %d\n", pPictureSetting->ePicMode);                            
    LOG(2, "u1Backlight         %d\n", pPictureSetting->u1Backlight);                                 
    LOG(2, "u1Contrast          %d\n", pPictureSetting->u1Contrast);                                  
    LOG(2, "u1Brightness        %d\n", pPictureSetting->u1Brightness);                                
    LOG(2, "u1Color             %d\n", pPictureSetting->u1Color);                                     
    LOG(2, "u1Hue               %d\n", pPictureSetting->u1Hue);                                       
    LOG(2, "u1Sharpness         %d\n", pPictureSetting->u1Sharpness);                                 
    LOG(2, "eColTmp             %d\n", pPictureSetting->eColTmp);                             
    LOG(2, "eNoiseReduction     %d\n", pPictureSetting->eNoiseReduction);             
    LOG(2, "eMpegNoiseReduction %d\n", pPictureSetting->eMpegNoiseReduction);     
	LOG(2, "eRealityCreation	%d\n", pPictureSetting->eRealityCreation);                                 
    LOG(2, "eMasteredIn4K       %d\n", pPictureSetting->eMasteredIn4K);                             
    LOG(2, "i2Resolution	     %d\n", pPictureSetting->i2Resolution);             
    LOG(2, "i2NoiseFiltering	 %d\n", pPictureSetting->i2NoiseFiltering);  
    LOG(2, "eMotionFlow         %d\n", pPictureSetting->eMotionFlow);                     
	LOG(2, "i2MotionFlowSmoothness	     %d\n", pPictureSetting->i2MotionFlowSmoothness);             
    LOG(2, "i2MotionFlowClearness	 %d\n", pPictureSetting->i2MotionFlowClearness);  
    LOG(2, "eFilmMode           %d\n", pPictureSetting->eFilmMode);                       
    LOG(2, "eAdvContrastEnhancer    %d\n", pPictureSetting->eAdvContrastEnhancer);
    LOG(2, "eBlackCorrector     %d\n", pPictureSetting->eBlackCorrector);             
    LOG(2, "i2Gamma             %d\n", pPictureSetting->i2Gamma);    
	LOG(2, "eLedDynamicCtrl     %d\n", pPictureSetting->eLedDynamicCtrl); 
    LOG(2, "eLiveColor          %d\n", pPictureSetting->eLiveColor);                      
    LOG(2, "i2RGain			    %d\n", pPictureSetting->i2RGain);     
	LOG(2, "i2GGain			    %d\n", pPictureSetting->i2GGain);   
	LOG(2, "i2RGain			    %d\n", pPictureSetting->i2BGain);   
	LOG(2, "i2RBias			    %d\n", pPictureSetting->i2RBias);   
	LOG(2, "i2GBias			    %d\n", pPictureSetting->i2GBias);   
	LOG(2, "i2BBias			    %d\n", pPictureSetting->i2BBias);   
    LOG(2, "eSpeedPreference    %d\n", pPictureSetting->eSpeedPreference);   
	LOG(2, "eLedMotionMode   	%d\n", pPictureSetting->eLedMotionMode);
	LOG(2, "eXdr			    %d\n", pPictureSetting->eXdr);   
    LOG(2, "eDrange    			%d\n", pPictureSetting->eDrange);   
	LOG(2, "eColorSpace   	%d\n", pPictureSetting->eColorSpace);
    #endif
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
static void DEBUG_GetScreenSetting(CUST_SCREEN_SETTING_T* pScreenSetting)

{
    #if MAPLE_AP_DEBUG
    LOG(2, "====== DRVCUST_GetPictureSetting ======\n"); 
    LOG(2, "eWideMode            %d\n", pScreenSetting->eWideMode);   
	LOG(2, "eDisplayArea            %d\n", pScreenSetting->eDisplayArea);   
	LOG(2, "i2HCenter            %d\n", pScreenSetting->i2HCenter);   
	LOG(2, "i2VCenter            %d\n", pScreenSetting->i2VCenter);   
	LOG(2, "i2VerticalSize            %d\n", pScreenSetting->i2VerticalSize);   
	LOG(2, "eZoom            %d\n", pScreenSetting->eZoom);   
	LOG(2, "ePcWIdeMode            %d\n", pScreenSetting->ePcWIdeMode);   
	LOG(2, "i2PcPhase            %d\n", pScreenSetting->i2PcPhase);   
	LOG(2, "i2PcPitch            %d\n", pScreenSetting->i2PcPitch);   
	LOG(2, "i2PcHCenter            %d\n", pScreenSetting->i2PcHCenter);   
	LOG(2, "i2PcVCenter            %d\n", pScreenSetting->i2PcVCenter);   

    #endif
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
static void DEBUG_Get3DSetting(CUST_3D_SETTING_T* p3DSetting)

{
    #if MAPLE_AP_DEBUG
    LOG(2, "====== DEBUG_Get3DSetting ======\n"); 
    LOG(2, "e3dDisplay            %d\n", p3DSetting->e3dDisplay);   
	LOG(2, "i23dDepthAdjustment            %d\n", p3DSetting->i23dDepthAdjustment);   
	LOG(2, "e3dGlassBrightness            %d\n", p3DSetting->e3dGlassBrightness);   
    #endif
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
static void DEBUG_GetECOSetting(CUST_ECO_SETTING_T* pEcoSetting)

{
    #if MAPLE_AP_DEBUG
    LOG(2, "====== DEBUG_GetECOSetting ======\n"); 
    LOG(2, "ePowerSaving            %d\n", pEcoSetting->ePowerSaving);   
	LOG(2, "eLightSensor            %d\n", pEcoSetting->eLightSensor);   
    #endif
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
static void DEBUG_GetDemoModeSetting(CUST_DEMO_MODE_T* pDemoMode)

{
    #if MAPLE_AP_DEBUG
    LOG(2, "====== DEBUG_GetDemoModeSetting ======\n"); 
    LOG(2, "eDemoMode            %d\n", pDemoMode->eDemoMode);   
	LOG(2, "eDemoPattern            %d\n", pDemoMode->eDemoPattern);   
	LOG(2, "u4DemoOption            %d\n", pDemoMode->u4DemoOption);   
    #endif
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
static void DEBUG_GetDemoOSDMaskSetting(CUST_DEMO_OSD_MASK_T* pOsdMask)

{
    #if MAPLE_AP_DEBUG
	UINT32 i;
	
    LOG(2, "====== DEBUG_GetDemoOSDMaskSetting ======\n"); 
    LOG(2, "u1Num            %d\n", pOsdMask->u1Num);
	for(i = 0; i < 7; i++)
	{
		LOG(2, "rectArea[%d] u2X           %d\n", i, pOsdMask->rectArea[i].u2X);  
		LOG(2, "rectArea[%d] u2Y           %d\n", i, pOsdMask->rectArea[i].u2Y); 
		LOG(2, "rectArea[%d] u2Width       %d\n", i, pOsdMask->rectArea[i].u2Width); 
		LOG(2, "rectArea[%d] u2Height      %d\n", i, pOsdMask->rectArea[i].u2Height); 
	}
	LOG(2, "b4KCoordinate            %d\n", pOsdMask->b4KCoordinate);   
    #endif
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
static void DEBUG_GetWBOffsetSetting(CUST_WB_OFFSET_T* pWbOffset)

{
    #if MAPLE_AP_DEBUG
    LOG(2, "====== DEBUG_GetWBOffsetSetting ======\n"); 
    LOG(2, "i2ROffset1            %d\n", pWbOffset->i2ROffset1);
	LOG(2, "i2ROffset2            %d\n", pWbOffset->i2ROffset2);
	LOG(2, "i2ROffset3            %d\n", pWbOffset->i2ROffset3);
	LOG(2, "i2ROffset4            %d\n", pWbOffset->i2ROffset4);
	LOG(2, "i2ROffset5            %d\n", pWbOffset->i2ROffset5);
	LOG(2, "i2ROffset6            %d\n", pWbOffset->i2ROffset6);
	LOG(2, "i2ROffset7            %d\n", pWbOffset->i2ROffset7);
	LOG(2, "i2ROffset8            %d\n", pWbOffset->i2ROffset8);
	LOG(2, "i2ROffset9            %d\n", pWbOffset->i2ROffset9);
	LOG(2, "i2ROffset10            %d\n", pWbOffset->i2ROffset10);

	LOG(2, "i2ROffset11            %d\n", pWbOffset->i2ROffset11);
	LOG(2, "i2ROffset12            %d\n", pWbOffset->i2ROffset12);
	LOG(2, "i2ROffset13            %d\n", pWbOffset->i2ROffset13);
	LOG(2, "i2ROffset14            %d\n", pWbOffset->i2ROffset14);
	LOG(2, "i2ROffset15            %d\n", pWbOffset->i2ROffset15);
	LOG(2, "i2ROffset16            %d\n", pWbOffset->i2ROffset16);
	LOG(2, "i2ROffset17            %d\n", pWbOffset->i2ROffset17);
	LOG(2, "i2ROffset18            %d\n", pWbOffset->i2ROffset18);
	LOG(2, "i2ROffset19            %d\n", pWbOffset->i2ROffset19);
	LOG(2, "i2ROffset20            %d\n", pWbOffset->i2ROffset20);
	
	LOG(2, "i2GOffset1            %d\n", pWbOffset->i2GOffset1);
	LOG(2, "i2GOffset2            %d\n", pWbOffset->i2GOffset2);
	LOG(2, "i2GOffset3            %d\n", pWbOffset->i2GOffset3);
	LOG(2, "i2GOffset4            %d\n", pWbOffset->i2GOffset4);
	LOG(2, "i2GOffset5            %d\n", pWbOffset->i2GOffset5);
	LOG(2, "i2GOffset6            %d\n", pWbOffset->i2GOffset6);
	LOG(2, "i2GOffset7            %d\n", pWbOffset->i2GOffset7);
	LOG(2, "i2GOffset8            %d\n", pWbOffset->i2GOffset8);
	LOG(2, "i2GOffset9            %d\n", pWbOffset->i2GOffset9);
	LOG(2, "i2GOffset10            %d\n", pWbOffset->i2GOffset10);

	
	LOG(2, "i2GOffset11            %d\n", pWbOffset->i2GOffset11);
	LOG(2, "i2GOffset12            %d\n", pWbOffset->i2GOffset12);
	LOG(2, "i2GOffset13            %d\n", pWbOffset->i2GOffset13);
	LOG(2, "i2GOffset14            %d\n", pWbOffset->i2GOffset14);
	LOG(2, "i2GOffset15            %d\n", pWbOffset->i2GOffset15);
	LOG(2, "i2GOffset16            %d\n", pWbOffset->i2GOffset16);
	LOG(2, "i2GOffset17            %d\n", pWbOffset->i2GOffset17);
	LOG(2, "i2GOffset18            %d\n", pWbOffset->i2GOffset18);
	LOG(2, "i2GOffset19            %d\n", pWbOffset->i2GOffset19);
	LOG(2, "i2GOffset20            %d\n", pWbOffset->i2GOffset20);
	
	LOG(2, "i2BOffset1            %d\n", pWbOffset->i2BOffset1);
	LOG(2, "i2BOffset2            %d\n", pWbOffset->i2BOffset2);
	LOG(2, "i2BOffset3            %d\n", pWbOffset->i2BOffset3);
	LOG(2, "i2BOffset4            %d\n", pWbOffset->i2BOffset4);
	LOG(2, "i2BOffset5            %d\n", pWbOffset->i2BOffset5);
	LOG(2, "i2BOffset6            %d\n", pWbOffset->i2BOffset6);
	LOG(2, "i2BOffset7            %d\n", pWbOffset->i2BOffset7);
	LOG(2, "i2BOffset8            %d\n", pWbOffset->i2BOffset8);
	LOG(2, "i2BOffset9            %d\n", pWbOffset->i2BOffset9);
	LOG(2, "i2BOffset10            %d\n", pWbOffset->i2BOffset10);

	
	LOG(2,"i2BOffset11            %d\n", pWbOffset->i2BOffset11);
	LOG(2,"i2BOffset12            %d\n", pWbOffset->i2BOffset12);
	LOG(2,"i2BOffset13            %d\n", pWbOffset->i2BOffset13);
	LOG(2,"i2BOffset14            %d\n", pWbOffset->i2BOffset14);
	LOG(2,"i2BOffset15            %d\n", pWbOffset->i2BOffset15);
	LOG(2,"i2BOffset16            %d\n", pWbOffset->i2BOffset16);
	LOG(2,"i2BOffset17            %d\n", pWbOffset->i2BOffset17);
	LOG(2,"i2BOffset18            %d\n", pWbOffset->i2BOffset18);
	LOG(2,"i2BOffset19            %d\n", pWbOffset->i2BOffset19);
	LOG(2,"i2BOffset20            %d\n", pWbOffset->i2BOffset20);
	
    #endif
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
static void DEBUG_GetServiceSetting(CUST_SERVICE_SETTING_T* pServiceSetting)

{
    #if MAPLE_AP_DEBUG
    LOG(2, "====== DEBUG_GetServiceSetting ======\n"); 
    LOG(2, "u2RGain            %d\n", pServiceSetting->u2RGain);
	LOG(2, "u2GGain            %d\n", pServiceSetting->u2GGain);
	LOG(2, "u2BGain            %d\n", pServiceSetting->u2BGain);
	LOG(2, "u2ROffset            %d\n", pServiceSetting->u2ROffset);
	LOG(2, "u2GOffset            %d\n", pServiceSetting->u2GOffset);
	LOG(2, "u2BOffset            %d\n", pServiceSetting->u2BOffset);
    #endif
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */


////////////////////////////////////////////////////////////////////////////////
FUN_MACRO(void DRVCUST_GetPictureSetting(CUST_PIC_SETTING_T * pPictureSetting))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
    INT16 i2Cur;

	BEPQ_AP_Get_Pic_Setting(pPictureSetting);

	switch((D_AP_PIC_MODE)DRVCUST_GetUISmartPicId())
    {
        case D_AP_PIC_MODE_VIVID:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_VIVID;
            break;
		case D_AP_PIC_MODE_STANDARD:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_STANDARD;
            break;
		case D_AP_PIC_MODE_CINEMA:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_CINEMA;
            break;
		case D_AP_PIC_MODE_GAME:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_GAME;
            break;
		case D_AP_PIC_MODE_GRAPHICS:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_GRAPHICS;
            break;
		case D_AP_PIC_MODE_PHOTO:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_PHOTO;
            break;
		case D_AP_PIC_MODE_CUSTOM:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_CUSTOM;
            break;
		case D_AP_PIC_MODE_USER1:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_USER1;
            break;
		case D_AP_PIC_MODE_USER2:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_USER2;
            break;
		case D_AP_PIC_MODE_DV_DARK:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_DV_DARK;
            break;
		case D_AP_PIC_MODE_DV_BRIGHT:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_DV_BRIGHT;
            break;
		case D_AP_PIC_MODE_DV_VIVIDE:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_DV_VIVID;
            break;
		case D_AP_PIC_MODE_NETFLIX_DV:
			pPictureSetting->ePicMode = E_CUST_PIC_MODE_NETFLIX_DV;
        	break;
		case D_AP_PIC_MODE_NETFLIX_SDR:
			pPictureSetting->ePicMode = E_CUST_PIC_MODE_NETFLIX_SDR;
       		break;
		case D_AP_PIC_MODE_RESERVED_1:
			pPictureSetting->ePicMode = E_CUST_PIC_MODE_RESERVED1;
        	break;
		case D_AP_PIC_MODE_RESERVED_2:
			pPictureSetting->ePicMode = E_CUST_PIC_MODE_RESERVED2;
        	break;
		default:
            pPictureSetting->ePicMode = E_CUST_PIC_MODE_VIVID;
            break;
    }
	

    pPictureSetting->u1Backlight = stBLight.ui1BacklightLevel;    // d interface ??   
    
    PE_GetArg(0, PE_ARG_CONTRAST, &i2Cur);
    pPictureSetting->u1Contrast = (UINT8)i2Cur;   
    
    PE_GetArg(0, PE_ARG_BRIGHTNESS, &i2Cur);
    pPictureSetting->u1Brightness = (UINT8)i2Cur; 
    
    PE_GetArg(0, PE_ARG_SATURATION, &i2Cur);
    pPictureSetting->u1Color = (UINT8)i2Cur;  
    
    PE_GetArg(0, PE_ARG_HUE, &i2Cur);
    pPictureSetting->u1Hue = (UINT8)i2Cur;    
    
    PE_GetArg(0, PE_ARG_SHARPNESS, &i2Cur);    
    pPictureSetting->u1Sharpness = (UINT8)i2Cur;   
    
	switch((D_AP_PIC_COL_TMP)stCTInfo.ui1CTIndex)
    {
        case D_AP_PIC_COL_TMP_COOL:
            pPictureSetting->eColTmp = E_CUST_COL_TMP_COOL;
            break;
		case D_AP_PIC_COL_TMP_NATURAL:
            pPictureSetting->eColTmp = E_CUST_COL_TMP_NATURAL;
            break;
		case D_AP_PIC_COL_TMP_WARM:
            pPictureSetting->eColTmp = E_CUST_COL_TMP_WARM1;
            break;
		case D_AP_PIC_COL_TMP_EXPERT1:
            pPictureSetting->eColTmp = E_CUST_COL_TMP_EXPERT1;
            break;
		case D_AP_PIC_COL_TMP_EXPERT2:
		default:
            pPictureSetting->eColTmp = E_CUST_COL_TMP_EXPERT2;
            break;
    }
        
    PE_GetArg(0, PE_ARG_3D_NR, &i2Cur);
	switch((D_AP_PIC_NOISE_REDUCTION)i2Cur)
    {
        case D_AP_PIC_NOISE_REDUCTION_OFF:
            pPictureSetting->eNoiseReduction = E_CUST_NOISE_REDUCTION_OFF;
            break;
		case D_AP_PIC_NOISE_REDUCTION_LOW:
            pPictureSetting->eNoiseReduction = E_CUST_NOISE_REDUCTION_LOW;
            break;
		case D_AP_PIC_NOISE_REDUCTION_MID:
            pPictureSetting->eNoiseReduction = E_CUST_NOISE_REDUCTION_MID;
            break;
		case D_AP_PIC_NOISE_REDUCTION_HIGH:
            pPictureSetting->eNoiseReduction = E_CUST_NOISE_REDUCTION_HIGH;
            break;
		case D_AP_PIC_NOISE_REDUCTION_AUTO:
		default:
            pPictureSetting->eNoiseReduction = E_CUST_NOISE_REDUCTION_AUTO;
            break;
    }

    PE_GetArg(0, PE_ARG_MPEG_NR, &i2Cur);
	switch((D_AP_PIC_MPEG_NOISE_REDUCTION)i2Cur)
    {
        case D_AP_PIC_MPEG_NOISE_REDUCTION_OFF:
            pPictureSetting->eMpegNoiseReduction = E_CUST_MPEG_NOISE_REDUCTION_OFF;
            break;
		case D_AP_PIC_MPEG_NOISE_REDUCTION_LOW:
            pPictureSetting->eMpegNoiseReduction = E_CUST_MPEG_NOISE_REDUCTION_LOW;
            break;
		case D_AP_PIC_MPEG_NOISE_REDUCTION_MID:
            pPictureSetting->eMpegNoiseReduction = E_CUST_MPEG_NOISE_REDUCTION_MID;
            break;
		case D_AP_PIC_MPEG_NOISE_REDUCTION_HIGH:
            pPictureSetting->eMpegNoiseReduction = E_CUST_MPEG_NOISE_REDUCTION_HIGH;
            break;
		case D_AP_PIC_MPEG_NOISE_REDUCTION_AUTO:
		default:
            pPictureSetting->eMpegNoiseReduction = E_CUST_MPEG_NOISE_REDUCTION_AUTO;
            break;
    }

	//pPictureSetting->eRealityCreation = 0; //TBD
	//pPictureSetting->eMasteredIn4K = 0; //TBD
	//pPictureSetting->i2Resolution = 0; //TBD
	pPictureSetting->i2NoiseFiltering = 0; //TBD

	//pPictureSetting->eMotionFlow =0;

	//pPictureSetting->i2MotionFlowSmoothness = 0; //TBD

	//pPictureSetting->i2MotionFlowClearness = 0; //TBD

	//pPictureSetting->eFilmMode = 0; 


    PE_GetArg(0, PE_ARG_ADAPTIVE_LUMA, &i2Cur);  
	switch((D_AP_PIC_ADV_CONTRAST_ENHANCER)i2Cur)
    {
        case D_AP_PIC_ADV_CONTRAST_ENHANCER_OFF:
            pPictureSetting->eAdvContrastEnhancer = E_CUST_ADV_CONTRAST_ENHANCER_OFF;
            break;
		case D_AP_PIC_ADV_CONTRAST_ENHANCER_LOW:
            pPictureSetting->eAdvContrastEnhancer = E_CUST_ADV_CONTRAST_ENHANCER_LOW;
            break;
		case D_AP_PIC_ADV_CONTRAST_ENHANCER_MID:
            pPictureSetting->eAdvContrastEnhancer = E_CUST_ADV_CONTRAST_ENHANCER_MID;
            break;
		case D_AP_PIC_ADV_CONTRAST_ENHANCER_HIGH:
		default:
            pPictureSetting->eAdvContrastEnhancer = E_CUST_ADV_CONTRAST_ENHANCER_HIGH;
            break;
    }
    PE_GetArg(0, PE_ARG_BLACK_STRETCH, &i2Cur);
	switch((D_AP_PIC_BLACK_CORRECTOR)i2Cur)
    {
        case D_AP_PIC_BLACK_CORRECTOR_OFF:
            pPictureSetting->eBlackCorrector = E_CUST_BLACK_CORRECTOR_OFF;
            break;
		case D_AP_PIC_BLACK_CORRECTOR_LOW:
            pPictureSetting->eBlackCorrector = E_CUST_BLACK_CORRECTOR_LOW;
            break;
		case D_AP_PIC_BLACK_CORRECTOR_MID:
            pPictureSetting->eBlackCorrector = E_CUST_BLACK_CORRECTOR_MID;
            break;
		case D_AP_PIC_BLACK_CORRECTOR_HIGH:
		default:
            pPictureSetting->eBlackCorrector = E_CUST_BLACK_CORRECTOR_HIGH;
            break;
    }
  
    pPictureSetting->i2Gamma = (INT16)bi1GammaOfst;

	//pPictureSetting->eLedDynamicCtrl = 0; //TBD

    PE_GetArg(0, PE_ARG_SCE, &i2Cur);
	switch((D_AP_PIC_LIVE_COLOR)i2Cur)
    {
        case D_AP_PIC_LIVE_COLOR_OFF:
            pPictureSetting->eLiveColor = E_CUST_LIVE_COLOR_OFF;
            break;
		case D_AP_PIC_LIVE_COLOR_LOW:
            pPictureSetting->eLiveColor = E_CUST_LIVE_COLOR_LOW;
            break;
		case D_AP_PIC_LIVE_COLOR_MID:
            pPictureSetting->eLiveColor = E_CUST_LIVE_COLOR_MID;
            break;
		case D_AP_PIC_LIVE_COLOR_HIGH:
		default:
            pPictureSetting->eLiveColor = E_CUST_LIVE_COLOR_HIGH;
            break;
    }

	//pPictureSetting->i2RGain = 0; //TBD

	//pPictureSetting->i2GGain = 0; //TBD

	//pPictureSetting->i2BGain = 0; //TBD
    
	//pPictureSetting->i2RBias = 0; //TBD

	//pPictureSetting->i2GBias = 0; //TBD

	//pPictureSetting->i2BBias = 0; //TBD

    pPictureSetting->eSpeedPreference = 0;

	pPictureSetting->eLedMotionMode = (E_CUST_LED_MOTION_MODE)DRVCUST_GetLEDMotionFlag();

	//pPictureSetting->eXdr = 0; //TBD

	//pPictureSetting->eDrange= 0; //TBD

	//pPictureSetting->eColorSpace= 0; //TBD

}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_GetScreenSetting(CUST_SCREEN_SETTING_T * pScreenSetting))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
	BEPQ_AP_Get_WideMode_Setting(pScreenSetting);
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_Get3DSetting(CUST_3D_SETTING_T * p3dSetting))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{  
	BEPQ_AP_Get_3D_Setting(p3dSetting);
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_GetEcoSetting(CUST_ECO_SETTING_T * pEcoSetting))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
    pEcoSetting->ePowerSaving = stBLight.ui1PowerSavingMode;     
    pEcoSetting->eLightSensor = stBLight.ui1LightSensorOnOff;    
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_GetPhotoSetting(CUST_PHOTO_SETTING_T * pPhotoSetting))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
    // TBD
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_GetDemoMode(CUST_DEMO_MODE_T * pDemoMode))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
    BESYS_AP_Get_Demo_Mode(pDemoMode);
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_GetDemoOsdMaskArea(CUST_DEMO_OSD_MASK_T * pOsdMask))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
    BESYS_AP_Get_Demo_OSD_Mask(pOsdMask);
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */


FUN_MACRO(void DRVCUST_GetServiceSetting(CUST_SERVICE_SETTING_T * pServiceSetting))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
	
	if(gServiceInit)
	{
		BEPQ_AP_Get_CustService_Setting(pServiceSetting);
	}
	else
	{
		pServiceSetting->u2RGain = (DRVCUST_EepromReadByte(0x6A1) << 8) + DRVCUST_EepromReadByte(0x6A0);
		pServiceSetting->u2GGain = (DRVCUST_EepromReadByte(0x6AB) << 8) + DRVCUST_EepromReadByte(0x6AA);
		pServiceSetting->u2BGain = (DRVCUST_EepromReadByte(0x6B5) << 8) + DRVCUST_EepromReadByte(0x6B4);
		pServiceSetting->u2ROffset= (DRVCUST_EepromReadByte(0x681) << 8) + DRVCUST_EepromReadByte(0x680);
		pServiceSetting->u2GOffset= (DRVCUST_EepromReadByte(0x68B) << 8) + DRVCUST_EepromReadByte(0x68A);
		pServiceSetting->u2BOffset= (DRVCUST_EepromReadByte(0x695) << 8) + DRVCUST_EepromReadByte(0x694);
	}
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_GetServiceTransferSetting(CUST_SERVICE_TRANS_T * pServiceTrans))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
    BESYS_AP_Get_Service_Trans(pServiceTrans);
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_GetServiceVcomAdjust(CUST_SERVICE_VCOM_T * pServiceVcom))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
    BESYS_AP_Get_Service_VCom(pServiceVcom);
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(E_CUST_UI_INPUT_TARGET DRVCUST_GetUiInputTarget(void))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
    D_AP_INPUT_TYPE eType = BEPQ_AP_Get_Input_Type(SV_VP_MAIN);

    #if MAPLE_SYS_DEBUG    
    LOG(2, "====== DRVCUST_GetUiInputTarget ======\n"); 
    LOG(2, "InputType()        %d\n", eType); 
    #endif

	switch (eType)
    {
        case D_AP_INPUT_TYPE_A_RF:
        case D_AP_INPUT_TYPE_D_RF:	
		case D_AP_INPUT_TYPE_COMPOSITE:
		case D_AP_INPUT_TYPE_COMPONENT:
		case D_AP_INPUT_TYPE_SCART:
		case D_AP_INPUT_TYPE_A_PC:
		case D_AP_INPUT_TYPE_HDMI:
			return E_CUST_UI_INPUT_TARGET_DEFAULT;
			
		case D_AP_INPUT_TYPE_APPLICATION:
			return E_CUST_UI_INPUT_TARGET_VIDEO_APP;
			
		case D_AP_INPUT_TYPE_SONY_PHOTO_APP:
			return E_CUST_UI_INPUT_TARGET_PHOTO_APP;
			
		case D_AP_INPUT_TYPE_JELLY_FISH:
			return E_CUST_UI_INPUT_TARGET_GAME_APP;
			
		case D_AP_INPUT_TYPE_NETFLIX:
			return E_CUST_UI_INPUT_TARGET_OTT1;
			
		case D_AP_INPUT_TYPE_MIRACAST:
			return E_CUST_UI_INPUT_TARGET_WIFI_DISPLAY;

		case D_AP_INPUT_TYPE_GENERAL_APP:
			return E_CUST_UI_INPUT_TARGET_GEN_APP;
		case D_AP_INPUT_TYPE_RESERVE_1: // Netflix
			return E_CUST_UI_INPUT_TARGET_OTT1;
        default:        
            return E_CUST_UI_INPUT_TARGET_UNKNOWN;
    }
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_GetWhiteBalanceOffset(CUST_WB_OFFSET_T * pWbOffset))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
    pWbOffset->i2ROffset1= i2WB20PUIValue[0][1];
	pWbOffset->i2ROffset2= i2WB20PUIValue[0][2];
	pWbOffset->i2ROffset3= i2WB20PUIValue[0][3];
	pWbOffset->i2ROffset4= i2WB20PUIValue[0][4];
	pWbOffset->i2ROffset5= i2WB20PUIValue[0][5];
	pWbOffset->i2ROffset6= i2WB20PUIValue[0][6];
	pWbOffset->i2ROffset7= i2WB20PUIValue[0][7];
	pWbOffset->i2ROffset8= i2WB20PUIValue[0][8];
	pWbOffset->i2ROffset9= i2WB20PUIValue[0][9];
	pWbOffset->i2ROffset10= i2WB20PUIValue[0][10];
	
	pWbOffset->i2ROffset11= i2WB20PUIValue[0][11];
	pWbOffset->i2ROffset12= i2WB20PUIValue[0][12];
	pWbOffset->i2ROffset13= i2WB20PUIValue[0][13];
	pWbOffset->i2ROffset14= i2WB20PUIValue[0][14];
	pWbOffset->i2ROffset15= i2WB20PUIValue[0][15];
	pWbOffset->i2ROffset16= i2WB20PUIValue[0][16];
	pWbOffset->i2ROffset17= i2WB20PUIValue[0][17];
	pWbOffset->i2ROffset18= i2WB20PUIValue[0][18];
	pWbOffset->i2ROffset19= i2WB20PUIValue[0][19];
	pWbOffset->i2ROffset20= i2WB20PUIValue[0][20];
	
	pWbOffset->i2GOffset1= i2WB20PUIValue[1][1];
	pWbOffset->i2GOffset2= i2WB20PUIValue[1][2];
	pWbOffset->i2GOffset3= i2WB20PUIValue[1][3];
	pWbOffset->i2GOffset4= i2WB20PUIValue[1][4];
	pWbOffset->i2GOffset5= i2WB20PUIValue[1][5];
	pWbOffset->i2GOffset6= i2WB20PUIValue[1][6];
	pWbOffset->i2GOffset7= i2WB20PUIValue[1][7];
	pWbOffset->i2GOffset8= i2WB20PUIValue[1][8];
	pWbOffset->i2GOffset9= i2WB20PUIValue[1][9];
	pWbOffset->i2GOffset10= i2WB20PUIValue[1][10];
	
	pWbOffset->i2GOffset11= i2WB20PUIValue[1][11];
	pWbOffset->i2GOffset12= i2WB20PUIValue[1][12];
	pWbOffset->i2GOffset13= i2WB20PUIValue[1][13];
	pWbOffset->i2GOffset14= i2WB20PUIValue[1][14];
	pWbOffset->i2GOffset15= i2WB20PUIValue[1][15];
	pWbOffset->i2GOffset16= i2WB20PUIValue[1][16];
	pWbOffset->i2GOffset17= i2WB20PUIValue[1][17];
	pWbOffset->i2GOffset18= i2WB20PUIValue[1][18];
	pWbOffset->i2GOffset19= i2WB20PUIValue[1][19];
	pWbOffset->i2GOffset20= i2WB20PUIValue[1][20];
	
	pWbOffset->i2BOffset1= i2WB20PUIValue[2][1];
	pWbOffset->i2BOffset2= i2WB20PUIValue[2][2];
	pWbOffset->i2BOffset3= i2WB20PUIValue[2][3];
	pWbOffset->i2BOffset4= i2WB20PUIValue[2][4];
	pWbOffset->i2BOffset5= i2WB20PUIValue[2][5];
	pWbOffset->i2BOffset6= i2WB20PUIValue[2][6];
	pWbOffset->i2BOffset7= i2WB20PUIValue[2][7];
	pWbOffset->i2BOffset8= i2WB20PUIValue[2][8];
	pWbOffset->i2BOffset9= i2WB20PUIValue[2][9];
	pWbOffset->i2BOffset10= i2WB20PUIValue[2][10];
	
	pWbOffset->i2BOffset11= i2WB20PUIValue[2][11];
	pWbOffset->i2BOffset12= i2WB20PUIValue[2][12];
	pWbOffset->i2BOffset13= i2WB20PUIValue[2][13];
	pWbOffset->i2BOffset14= i2WB20PUIValue[2][14];
	pWbOffset->i2BOffset15= i2WB20PUIValue[2][15];
	pWbOffset->i2BOffset16= i2WB20PUIValue[2][16];
	pWbOffset->i2BOffset17= i2WB20PUIValue[2][17];
	pWbOffset->i2BOffset18= i2WB20PUIValue[2][18];
	pWbOffset->i2BOffset19= i2WB20PUIValue[2][19];
	pWbOffset->i2BOffset20= i2WB20PUIValue[2][20];
	

	//DEBUG_GetWBOffsetSetting(pWbOffset);
	
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_GetBTSetting(CUST_BT_SETTING_T * pBtSetting))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
    pBtSetting->eDelayMode = gBTDelay;
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_GetColorAdjust(CUST_COLOR_ADJUST_T * pColorAdjust))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
	if(pColorAdjust==NULL)
	{
		LOG(0, "pColorAdjust initial Failed !!!!\n");
		return;
	}
	
	pColorAdjust->i2RHue= bufColorAdust.i2RHue;
	pColorAdjust->i2RSaturation= bufColorAdust.i2RSaturation;
	pColorAdjust->i2RBrightness= bufColorAdust.i2RBrightness;

	pColorAdjust->i2YeHue= bufColorAdust.i2YeHue;
	pColorAdjust->i2YeSaturation= bufColorAdust.i2YeSaturation;
	pColorAdjust->i2YeBrightness= bufColorAdust.i2YeBrightness;
	
	pColorAdjust->i2GHue= bufColorAdust.i2GHue;
	pColorAdjust->i2GSaturation= bufColorAdust.i2GSaturation;
	pColorAdjust->i2GBrightness= bufColorAdust.i2GBrightness;
	
	pColorAdjust->i2CyHue= bufColorAdust.i2CyHue;
	pColorAdjust->i2CySaturation= bufColorAdust.i2CySaturation;
	pColorAdjust->i2CyBrightness= bufColorAdust.i2CyBrightness;
	
	pColorAdjust->i2BHue= bufColorAdust.i2BHue;
	pColorAdjust->i2BSaturation= bufColorAdust.i2BSaturation;
	pColorAdjust->i2BBrightness= bufColorAdust.i2BBrightness;
	
	pColorAdjust->i2MgHue= bufColorAdust.i2MgHue;
	pColorAdjust->i2MgSaturation= bufColorAdust.i2MgSaturation;
	pColorAdjust->i2MgBrightness= bufColorAdust.i2MgBrightness;
	

	
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */

FUN_MACRO(void DRVCUST_GetWhiteBalanceOffset20pEnable(CUST_WB_OFFSET_20P_EN_T * pWbOffset20pEn))
#ifdef IMP_DRV_MAPLE_AUD_GET_API_AP_C
{
	if(pWbOffset20pEn==NULL)
	{
		LOG(0, "pWbOffset20pEn initial Failed !!!!\n");
		return;
	}
	pWbOffset20pEn->eWbOfst20pEn = bufWB_OFFSET_20P_EN.eWbOfst20pEn;
}
#endif  /* IMP_DRV_MAPLE_AUD_GET_API_AP_C */
