/* 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: drv_scpos.h $
 *
 * Project:
 * --------
 *
 *
 * Description:
 * ------------
 *
 *
 * Author:
 * -------
 *
 *
 * Last changed:
 * -------------
 * $Author: brianpc.huang $
 *
 * $Modtime: 04/05/28 9:33a $
 *
 * $Revision: #1 $
*************************************************************************/

#ifndef _DRV_SCPOS_H_
#define _DRV_SCPOS_H_

#include "hw_scpos.h"
#include "hw_ospe.h"
#include "debug.h"
#include "feature.h"

#define vDrvMainMute(bOnOff) (vIO32WriteFldAlign(MUTE_00, bOnOff, R_M_MUTE_FRONT_EN))
#define vDrvPIPMute(bOnOff) (vIO32WriteFldAlign(MUTE_00, bOnOff, R_P_MUTE_FRONT_EN))
#define fgMainMuteOn() (IO32ReadFld(MUTE_00, R_M_MUTE_FRONT_EN))
#define fgPostMuteOn() (IO32ReadFld(MUTE_00, R_MUTE_POST_EN))

#define fgPIPMuteOn() (IO32ReadFld(MUTE_00, R_P_MUTE_FRONT_EN))

typedef enum
{
    QUICK_BLANK_NO_FUNCTION = 0,
    QUICK_BLANK_BY_MAIN = 2,
    QUICK_BLANK_BY_PIP = 3,
}E_QUICK_BLANK_MODE;

//----------------------------------------------------------------------------------
// public functions
//----------------------------------------------------------------------------------
// drv_scpos.c
EXTERN void vScpipSubSrcSel(UINT8 u1Sel);
EXTERN void vScpipOstgMonSrcSel(UINT8 u1Sel);
EXTERN UINT32 vScpipGetSubSrcSel(void);


EXTERN void vScpipHwInit(UINT8 bPath);

#if SUPPORT_HDTV_HARDWARE_MUTE
EXTERN void vScpipConfigHardwareMute(void);
EXTERN void vOSTGVideoPlaneHWMute(UINT8 bPath,UINT8 mode);
#endif

EXTERN void vScpipOutRGBColorOnOff(UINT8 bOnOff);
EXTERN void vScpipOutRGBColor(UINT8 RValue,UINT8 GValue,UINT8 BValue);

EXTERN UINT32 u4ScpipDirectSetDRAM(UINT32 u4VdpId, UINT32 u4X, UINT32 u4Y, UINT32 u4Width, UINT32 u4Height, UINT32 u4GBRYCbCr);

EXTERN void vDrvSetOSTGInPattern(UINT32 u4VdpId, UINT32 u4OnOff);
EXTERN void vDrvSetOSTGOutPattern(UINT32 u4OnOff);
EXTERN void vDrvSetOSTGOutPatternChg(UINT32 u4OnOff,UINT32 u4PatType,UINT32 u4PatSpd);

//-----------------------------------------------------------------------------
/** Brief of u4ScpipGetMinSrcRegionWidth.
 * Get Scalar minimun source region width.
 * @param u4VdpId video plane ID 0~1
 * @retval Frame Delay
 */
//-----------------------------------------------------------------------------
EXTERN UINT32 u4ScpipGetMinSrcRegionWidth(UINT8 u4VdpId);
EXTERN UINT32 u4ScpipGetMinSrcRegionHeight(UINT8 u4VdpId);
EXTERN void vScpipSetMirror(UINT8 bPath, UINT8 bOnOff);
EXTERN void vScpipSetFlip(UINT8 bPath, UINT8 bOnOff);
EXTERN void vScpipSetMirrorFlipAll(UINT8 bOnOff);

// added by peggy 20071004
#ifdef SUPPORT_DRAM_DUMP
EXTERN UINT8 bInitScalerDump(void);
EXTERN UINT8 bGetScalerDRAM(UINT32 u2X, UINT32 u2Y, UINT32 *pu2VR, UINT32 *pu2UB, UINT32 *pu2YG);
EXTERN UINT8 bGetScalerDRAMAverage(UINT32 u4X, UINT32 u4Y, UINT32 u4Width, UINT32 u4Height, UINT32 *pu4VR, UINT32 *pu4UB, UINT32 *pu4YG);
EXTERN UINT8 bReleaseScalerDump(void);

EXTERN UINT8 bInitLastStageDump(void);
EXTERN UINT8 bGetLastStageDRAM(UINT32 u2X, UINT32 u2Y, UINT32 *pu2R, UINT32 *pu2B, UINT32 *pu2G);
EXTERN UINT8 bReleaseLastStageDump(void);
#endif

typedef struct
{
    UINT32 dwAddr;
    UINT32 dwSize;
    UINT32 dwWidth;    
    UINT32 dwHeight;        
    UINT32 dwWINC;    
    UINT16 u2W_POS;        
    UINT16 u2R_POS;        
    UINT32 dwMHL;
    UINT32 dwMVL;
    UINT8 bIs444;
    UINT8 bIs10bit;
}tagDramDumpInfo_T;
EXTERN UINT32 u4ScpipCheckFifoOverflow(UINT32 u4VdpId);
EXTERN void vScpipResetFifoOverflow(UINT32 u4VdpId);

//----------------------------------------------------------------------------------
// inter-module functions
//----------------------------------------------------------------------------------
EXTERN void vOSTGSetBorderOnOff(UINT32 u4VdpId, UINT32 u4OnOff);
EXTERN void vOSTGSetBorderColor(UINT32 u4VdpId, UINT32 u4RGB);
EXTERN void vOSTGSetBorderParam(UINT32 u4VdpId, UINT32 u4X, UINT32 u4Y, UINT32 u4Width, UINT32 u4Height, UINT32 u4Thickness);

#endif
