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


/*****************************************************************************
 *
 * Filename:
 * ---------
 *   $Workfile: mtk_tve.h $ 
 *
 * Project:
 * --------
 *   MT5391
 *
 * Description:
 * ------------
 *   TVE customization
 *   
 * Author:
 * -------
 *   
 *
 * Unauthorized use, practice, perform, copy, distribution, reproduction,
 * or disclosure of this information in whole or in part is prohibited.
 *-----------------------------------------------------------------------------
 *
 * $Author: brianpc.huang $
 * $Date: 2015/05/29 $
 * $RCSfile: mtk_tve.c,v $
 * $Revision: #1 $
 *
 *---------------------------------------------------------------------------*/
#ifndef _TVE_CUSTOMIZATION_H_
#define _TVE_CUSTOMIZATION_H_

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

#include "x_typedef.h"
#include "u_common.h"
#include "source_select.h"

#include "tve_if.h"
/* TVE OUT FORMAT */
#define TVE_OUT_FORMAT 1 // 0:480i 1: 576i

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

/**
 * @brief TVE CONFIG TABLE
 */
MOD_MACRO const UINT8 TVE_CONFIG_TABLE[][2]
#ifdef IMP_MTK_TVE_C
 = 
{
  { SV_TVE_DAC_BYPASS_SIF,        SV_TVE_DAC_BYPASS_SIF},     //VSSS_ATV    =0,
  { SV_TVE_DAC_BYPASS_DEMOD, SV_TVE_DAC_BYPASS_DEMOD},    //VSS_ATD     =1, 
  { SV_TVE_DAC_BYPASS_CVBS,  SV_TVE_DAC_BYPASS_CVBS},     //VSS_CVBS    =2,
  { SV_TVE_DAC_BYPASS_CVBS,  SV_TVE_DAC_BYPASS_CVBS},     //VSS_SV      =3,
  { SV_TVE_DAC_PIP,          SV_TVE_DAC_PIP},             //VSS_YPBPR   =4,
  { SV_TVE_DAC_PIP,          SV_TVE_DAC_PIP},             //VSS_VGACOMP =5,
  { SV_TVE_DAC_PIP,          SV_TVE_DAC_PIP},             //VSS_VGA     =6,
  { SV_TVE_DAC_PIP,          SV_TVE_DAC_PIP},             //VSS_HDMI    =7,
  { SV_TVE_DAC_PIP,          SV_TVE_DAC_PIP},             //VSS_DVI     =8,
  { SV_TVE_DAC_PIP,          SV_TVE_DAC_PIP},             //VSS_DTV     =9,
  { SV_TVE_DAC_PIP,          SV_TVE_DAC_PIP},             //VSS_DTD     =10,
  { SV_TVE_DAC_BYPASS_CVBS,  SV_TVE_DAC_BYPASS_CVBS},     //VSS_SCART   =11,
  { SV_TVE_DAC_PIP,          SV_TVE_DAC_PIP},             //VSS_OSDENCODE=12,	
  { SV_TVE_NA,               SV_TVE_NA},                  //VSS_RESERVE =13,
}
#endif  /* IMP_MTK_TVE_C */
;


/*
 * @brief vApiTVEGetConfig(UINT8 u1SrcType, UINT8* pu1Type )
 * @param u1SrcType: source Type
 * @param ptTveConfig: TVE Out1 Type/Src/Reset
 * @retval void
 */
FUN_MACRO(void vApiTVEGetConfig(UINT8 u1SrcType,UINT8 * pu1Type))
#ifdef IMP_MTK_TVE_C
{
    UINT8 u1SrcMajor = VSS_MAJOR(u1SrcType);

    if(pu1Type == NULL) return;    

    if(u1SrcMajor > VSS_RESERVE)
    {
        u1SrcMajor = VSS_RESERVE;
    }

    pu1Type[0] = TVE_CONFIG_TABLE[u1SrcMajor][0]; 
    pu1Type[1] = TVE_CONFIG_TABLE[u1SrcMajor][1]; 
   
    return;
}
#endif  /* IMP_MTK_TVE_C */


/**
 * @brief vApiTVEOutPathSelect(UINT8 u1OutID, UINT8 u1OutType)
 * @param  u1OutID: SV_TVE_SCART_OUT_1/SV_TVE_SCART_OUT_2
 * @param u1OutType: TVE Out Type
 * @retval void
 */

FUN_MACRO(void vApiTVEOutPathSelect(UINT8 u1OutID,UINT8 u1OutType))
#ifdef IMP_MTK_TVE_C
{	
	if (u1OutID == SV_TVE_SCART_OUT_1)
	{
	    switch (u1OutType)
	    {
	      case SV_TVE_DAC_BYPASS_CVBS:
	      case SV_TVE_DAC_BYPASS_DEMOD:
	      case SV_TVE_DAC_PIP:
	      case SV_TVE_DAC_VIDEO_IN:
//	      		 GPIO_SetOut(16, 1);
	      	        break;
	      case SV_TVE_HW_BYPASS:
//	      		 GPIO_SetOut(16, 0);
	      	        break;
	      case SV_TVE_D2S_BYPASS:
	      case SV_TVE_NA:
             case SV_TVE_MAX:
             default:
             	        break;	      	        
	    }
	}
	else if (u1OutID == SV_TVE_SCART_OUT_2)
	{
	    switch (u1OutType)
	    {
	      case SV_TVE_DAC_BYPASS_CVBS:
	      case SV_TVE_DAC_BYPASS_DEMOD:
	      case SV_TVE_DAC_PIP:
	      case SV_TVE_DAC_VIDEO_IN:
	      case SV_TVE_D2S_BYPASS:
	      case SV_TVE_HW_BYPASS:
	      case SV_TVE_NA:
             case SV_TVE_MAX:
             default:
             	        break;	      	        
	    }	
	}	
}
#endif  /* IMP_MTK_TVE_C */

#endif // _TVE_CUSTOMIZATION_H_
