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

/*-----------------------------------------------------------------------------
 *
 * $Author: brianpc.huang $
 * $Date: 2015/05/29 $
 * $RCSfile: drv_tdc.h,v $
 * $Revision: #1 $
 *
 *---------------------------------------------------------------------------*/

#ifndef _DRV_TDC_H_
#define _DRV_TDC_H_

#define ACTIVE_WIN_NTSC_X_START		(UINT32)0x08B
#define ACTIVE_WIN_NTSC_X_LENGTH	(UINT32)0x2FB
#define ACTIVE_WIN_NTSC_Y_START		(UINT32)0x012
#define ACTIVE_WIN_NTSC_Y_LENGTH	(UINT32)0x103
#define ACTIVE_WIN_DEMO_NTSC_X_START		(UINT32)0x1F4 //For right demo

#define ACTIVE_WIN_PAL_X_START		(UINT32)0x091
#define ACTIVE_WIN_PAL_X_LENGTH		(UINT32)0x3B1
#define ACTIVE_WIN_PAL_Y_START		(UINT32)0x017
#define ACTIVE_WIN_PAL_Y_LENGTH		(UINT32)0x136
#define ACTIVE_WIN_DEMO_PAL_X_START		(UINT32)0x1FC //For right demo

#define ACTIVE_WIN_PAL_M_X_START	(UINT32)0x08B
#define ACTIVE_WIN_PAL_M_X_LENGTH	(UINT32)0x2F9
#define ACTIVE_WIN_PAL_M_Y_START	(UINT32)0x013
#define ACTIVE_WIN_PAL_M_Y_LENGTH	(UINT32)0x103
#define ACTIVE_WIN_DEMO_PAL_M_X_START		(UINT32)0x1F4 //For right demo

#define ACTIVE_WIN_PAL_N_X_START	(UINT32)0x095
#define ACTIVE_WIN_PAL_N_X_LENGTH	(UINT32)0x2FB
#define ACTIVE_WIN_PAL_N_Y_START	(UINT32)0x017
#define ACTIVE_WIN_PAL_N_Y_LENGTH	(UINT32)0x136
#define ACTIVE_WIN_DEMO_PAL_N_X_START		(UINT32)0x1F4 //For right demo

#define DRAM_CMP_NTSC_HIGHBW	0x1D
#define DRAM_CMP_NTSC_LOWBW		0x17
#define DRAM_CMP_PAL_HIGHBW		0x24
#define DRAM_CMP_PAL_LOWBW		0x19

#define ADAPTIVE_2D_COMB_SHARP 1
#define ADAPTIVE_APL_DETECT	0
#define ADAPTIVE_POST_NOTCH_FILTER	1
#define ADAPTIVE_GOH            0
#define GOH_FROM_1D             0


#define ADAPTIVE_CCS_ON_BW      1


#if ADAPTIVE_2D_COMB_SHARP
	#define MOTION_SMALL	0x08000L
	#define MOTION_BIG		0x40000L
	#define SHARP_WEAK		0x40
	#define SHARP_STRONG	0x58
#endif // #if ADAPTIVE_2D_COMB_SHARP

#if ADAPTIVE_APL_DETECT
    #define APL_STILLFRAME	0x50 //0x48
	#define APL_PENALITY	0x30
	#define APL_MB_PULL2D	0x30
	#define COUNT_MB		(UINT32)0x10000L
#endif // #if ADAPTIVE_APL_DETECT

#if ADAPTIVE_CCS_ON_BW
    #define CCS_ENABLE_COLOR_TH 0x2500000L
#endif // #if ADAPTIVE_CCS_ON_BW




/**************************************************************************
 * Imported variables (optional)
 *************************************************************************/

/**************************************************************************
 * Global/Static variables
 *************************************************************************/
extern UINT8 _bTDCConf;
extern UINT8 _bTDCEnable;


typedef enum
{
	E_TDC_HIGH_BW,
	E_TDC_LOW_BW
} E_TDC_DAMODE;

/**************************************************************************
 * Function Members
 *************************************************************************/
void vDrvTDCInit(void);
void vDrvTDCSetDramBase(void);
void vDrvTDCSetDramMode(UINT8 b10BitMode);
void vDrvTDCSetDAMode(UINT8 bMode);
void vDrvTDCSaveBW(UINT8 bOnOff);
void vDrvTDCSet(void);
void vTdc3dProc(void);
void vDrvTDCDemo(UINT8 bOnOff, UINT8 bRegion, UINT16 wXCenter);
void vDrvTDCOnOff(UINT8 bOnOff);
void vDrvTDCActive(UINT8 bOnOff);
BOOL fgDrvTDCEnableChk(void);

void vDrvTDCSetStart(UINT16 wStart);
void vDrvTDCSetLength(UINT16 wLength);
void vDrvTDCSetTop(UINT16 wTop);
void vDrvTDCSetBottom(UINT16 wBottom);
UINT16 wDrvTDCGetStart(void);
UINT16 wDrvTDCGetLength(void);
UINT16 wDrvTDCGetTop(void);
UINT16 wDrvTDCGetBottom(void);
extern void vDrvTDCSrmCb(UINT32 u4Arg1, UINT32 u4Arg2, UINT32 u4PDSize, UINT32 u4SramMode);
extern void vTvd3dSetAAF(UINT8 bValue);
UINT8 u1DrvTDCChkDramOvfUdf(void);
void vDrvTDCClearDramStatus(void);
void vTdcColorPatch(void);
void vTdcUS14Patch(void);
void vTdcCrossColorProc(void);

#endif // #ifndef _DRV_TDC_H_

