/* 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: gfx_drvif.h,v $
 * $Revision: #1 $
 *
 *---------------------------------------------------------------------------*/

/** @file gfx_drvif.h
 *  gfx driver internal public interfaces
 *  
 */

#ifndef GFX_DRVIF_H
#define GFX_DRVIF_H

#include "gfx_common_if.h"

//---------------------------------------------------------------------------
// Include files
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
// Configurations
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
// Inter-file functions
//---------------------------------------------------------------------------

//extern INT32 _GFX_IsFlushing(void);

//extern void _GFX_SetFlushStatus(INT32 i4Status);

extern void _GFX_Init(volatile GFX_CMDQUE_T *rGfxCmdQue,
        volatile UINT64 **cmdQueBuf);

extern void _GFX_Reset(void);

extern void _GFX_Wait(void);

extern void _GFX_Wait_Vdp(void);
extern void _GFX_MwFlush(void);

extern void _GFX_Flush(void);

extern void _GFX_Lock(void);

extern void _GFX_TryLock(void);

extern void _GFX_Unlock(void);

extern void _GFX_LockCmdque(void);

extern void _GFX_UnlockCmdque(void);

extern INT32 _GFX_QueryHwIdle(void);

extern void _GFX_SetNotify(void(*pfnNotifyFunc)(UINT32));

extern void _GFX_SetDst(UINT8 *pu1Base, UINT32 u4ColorMode, UINT32 u4Pitch);

extern void _GFX_SetSrc(UINT8 *pu1Base, UINT32 u4ColorMode, UINT32 u4Pitch);

extern void _GFX_SetAlpha(UINT32 u4Alpha);

extern void _GFX_SetColor(UINT32 u4Color);

extern void _GFX_Fill(UINT32 u4DstX, UINT32 u4DstY, UINT32 u4Width,
        UINT32 u4Height);

extern void _GFX_HLine(UINT32 u4DstX, UINT32 u4DstY, UINT32 u4Width);

extern void _GFX_VLine(UINT32 u4DstX, UINT32 u4DstY, UINT32 u4Height);

extern void _GFX_SetBltOpt(UINT32 u4Switch, UINT32 u4ColorMin,
        UINT32 u4ColorMax);

extern void _GFX_BitBlt(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height);

extern void _GFX_Set_Src_ColorKey(UINT32 u4SrcColorKey);

extern void _GFX_Blend(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height);

extern void _GFX_Compose(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height, UINT32 u4Ar,
        UINT32 u4Mode);

extern void _GFX_AlphaComposePass(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height, UINT32 u4Pass,
        UINT32 u4Param);

extern void _GFX_SetColCnvFmt(UINT32 u4YCFmt, UINT32 u4SwapMode,
        UINT32 u4VidStd, UINT32 u4VidSys);

extern void _GFX_SetColCnvSrc(UINT8 *pu1SrcLuma, UINT32 u4SrcLumaPitch,
        UINT8 *pu1SrcChroma, UINT32 u4SrcChromaPitch, UINT32 u4FieldPic);

extern void _GFX_ColConv(UINT32 u4DstX, UINT32 u4DstY, UINT32 u4Width,
        UINT32 u4Height);

extern void _GFX_StretchBlt(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4SrcW,
        UINT32 u4SrcH, UINT32 u4DstX, UINT32 u4DstY, UINT32 u4DstW,
        UINT32 u4DstH);

extern void _GFX_AlphaMapBitBlt(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height);

extern void _GFX_SetRopOpt(UINT32 u4RopCode);

extern void _GFX_RopBitBlt(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height);

extern void _GFX_ComposeLoop(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height, UINT32 u4Ar,
        UINT32 u4OpCode, UINT32 u4RectSrc);

extern void _GFX_ComposeLoopImprove(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height, UINT32 u4Ar,
        UINT32 u4OpCode, UINT32 u4RectSrc);


extern void _GFX_SetIdx2DirSrc(UINT8 *pu1Base, UINT32 u4SrcCM);

extern void _GFX_SetIdx2DirOpt(UINT8 *pu1PaletteBase, UINT32 u4MsbLeft,
        UINT32 u4StartByteAligned);

extern void _GFX_Idx2DirBitBlt(UINT32 u4DstX, UINT32 u4DstY, UINT32 u4Width,
        UINT32 u4Height);

extern void _GFX_2DMemCompare(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height);

extern INT32 _GFX_GetMemCompareResult(void);

extern void _GFX_SetHoriToVertLineOpt(UINT32 u4Is90dCcw);

extern void _GFX_HoriToVertLine(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4HoriLineWidth);

// normal driver
#if !defined(GFX_MINI_DRIVER)
extern void _GFX_SetGradOpt(UINT32 u4IncX, UINT32 u4IncY,
        const UINT32 asu4DeltaX[4], const UINT32 asu4DeltaY[4]);

extern void _GFX_GradFill(UINT32 u4X, UINT32 u4Y, UINT32 u4Width,
        UINT32 u4Height, UINT32 u4Mode);

extern void _GFX_DMA(UINT32 *pu4Dst, UINT32 *pu4Src, UINT32 u4NumWrd);

extern void _GFX_SetBmp(UINT8 *puu1Base, UINT32 u4BmpColorMode, UINT32 u4Width,
        UINT32 u4Height, UINT32 u4RunLen);

extern void _GFX_Bmp(UINT32 u4X, UINT32 u4Y);

extern void _GFX_ColorMap(UINT32 u4BmpCM, UINT32 u4CM,
        const UINT32 *psu4ColorMap);
#endif // #if !defined(GFX_MINI_DRIVER)

extern void _GFX_SetPremult(UINT32 u4PremultSrcR, UINT32 u4PremultDstR,
        UINT32 u4PremultDstW, UINT32 u4PremultOvrflw);

extern void _GFX_StretchAlphaCom(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4SrcW,
        UINT32 u4SrcH, UINT32 u4DstX, UINT32 u4DstY, UINT32 u4DstW,
        UINT32 u4DstH, UINT32 u4Ar, UINT32 u4OpCode);

//---------------------------------------------------------------------------
// Public functions (high-level APIs)
//---------------------------------------------------------------------------

extern INT32
        GFX_MemCompare(UINT8 *pu1DstBase, UINT8 *pu1SrcBase, UINT32 u4Size);

extern void GFX_RotateBmp(UINT8 *pu1DstBase, UINT32 u4DstPitch,
        UINT8 *pu1SrcBase, UINT32 u4SrcPitch, UINT32 u4Width, UINT32 u4Height,
        UINT32 u4ColorMode, UINT32 u4Is90Ccw);

extern void GFX_Memset(UINT8 *pu1Addr, UINT32 u4Size, UINT32 u4Color);

extern void GFX_CopyTopfieldToBotfield(UINT8 *pu1TopStartAddr,
        UINT32 u4TotalLines, UINT32 u4LineWidth);

extern void _GFX_ResetSrcDstParam(void);
extern void _VGFX_Enable(void);
extern void _VGFX_GeneralAlphaComSet(UINT32 u4ImgCm, UINT32 u4WbCm,
        UINT32 u4Ar, UINT32 u4OpCode, BOOL fgAlcomNormal, UINT32 u4PremultSrcR,
        UINT32 u4PremultDstR, UINT32 u4PremultDstW, UINT32 u4PremultOvrflw);

#endif // GFX_DRVIF_H
