/* 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: xiaojun.zhu $
 * $Date: 2015/08/08 $
 * $RCSfile: gfx_if.h,v $
 * $Revision: #2 $
 *
 *---------------------------------------------------------------------------*/

/** @file gfx_if.h
 *  gfx driver main interfaces
 *  
 */

#ifndef GFX_IF_H
#define GFX_IF_H

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


/*lint -save -e961 */
#include "x_common.h"
#include "x_typedef.h"
#include "x_timer.h"
#include "x_assert.h"
#include "x_os.h"
//#include "x_bim.h"
#include "x_clksrc.h"
#include "x_hal_5381.h"
#include "x_hal_926.h"
/*lint -restore */

#include "gfx_common_if.h"

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


//---------------------------------------------------------------------------
// Constant definitions
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
// Macro definitions
//---------------------------------------------------------------------------


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


//---------------------------------------------------------------------------
// Public functions
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
//  GFX_Init
//
/** Initialize gfx driver.
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_Init(void);

//---------------------------------------------------------------------------
//  GFX_Reset
//
/** Reset engine.
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_Reset(void);

//---------------------------------------------------------------------------
//  GFX_Wait
//
/** Wait for flushing engine completely.
 *  
 *  @retval void
 */
//---------------------------------------------------------------------------

extern void GFX_Wait(void);

extern void GFX_Wait_Vdp(void);

extern void GFX_Wait_Timeout(INT32 i4Timeout);

//---------------------------------------------------------------------------
//  GFX_MwFlush
//
/** Flush cmdque and force engine to do operations (for MW use).
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_MwFlush(void);

//---------------------------------------------------------------------------
//  GFX_Flush
//
/** Flush cmdque and force engine to do operations (for Drv use).
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_Flush(void);

extern void GFX_DFB_Flush(void);

//---------------------------------------------------------------------------
//  GFX_Lock
//
/** Take the gfx resource.
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_Lock(void);

//---------------------------------------------------------------------------
//  GFX_TryLock
//
/** Try to take the gfx resource.
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_TryLock(void);

//---------------------------------------------------------------------------
//  GFX_Unlock
//
/** Release the gfx resource.
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_Unlock(void);

//---------------------------------------------------------------------------
//  GFX_LockCmdque
//
/** Take the gfx-cmdq resource.
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_LockCmdque(void);

//---------------------------------------------------------------------------
//  GFX_UnlockCmdque
//
/** Release the gfx-cmdq resource.
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_UnlockCmdque(void);

//---------------------------------------------------------------------------
//  GFX_QueryHwIdle
//
/** Query engine status.
 *
 *  @retval 1   Idle
 *  @retval 0   Busy
 */
//---------------------------------------------------------------------------
extern INT32 GFX_QueryHwIdle(void);

//---------------------------------------------------------------------------
//  GFX_SetNotify
//
/** Set notify function (for MW use).
 *
 *  @param  pfnNotifyFunc   The callback function pointer
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetNotify(void(*pfnNotifyFunc)(UINT32));

//---------------------------------------------------------------------------
//  GFX_SetDst
//
/** Set destination region.
 *
 *  @param  pu1Base     The base address of the dst region
 *  @param  u4ColorMode The color mode of the dst region
 *  @param  u4Pitch     The pitch of the dst region
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetDst(UINT8 *pu1Base, UINT32 u4ColorMode, UINT32 u4Pitch);

//---------------------------------------------------------------------------
//  GFX_SetSrc
//
/** Set source region.
 *
 *  @param  pu1Base     The base address of the src region
 *  @param  u4ColorMode The color mode of the src region
 *  @param  u4Pitch     The pitch of the src region
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetSrc(UINT8 *pu1Base, UINT32 u4ColorMode, UINT32 u4Pitch);


extern void GFX_SetThird(UINT8 *pu1Base, UINT32 u4ColorMode, UINT32 u4Pitch);
//---------------------------------------------------------------------------
//  GFX_SetAlpha
//
/** Set global alpha.
 *
 *  @param  u4Alpha     The global alpha
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetAlpha(UINT32 u4Alpha);

extern void GFX_SetMaxAlphaEn(UINT32 u4Enable);
//---------------------------------------------------------------------------
//  GFX_SetColor
//
/** Set rectangular color.
 *
 *  @param  u4Color     The rectangular color
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetColor(UINT32 u4Color);

//---------------------------------------------------------------------------
//  GFX_Fill
//
/** Fill rectangle with rectangular color.
 *
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the rectangle
 *  @param  u4Height    The height of the rectangle
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_Fill(UINT32 u4DstX, UINT32 u4DstY, UINT32 u4Width,
        UINT32 u4Height);

//---------------------------------------------------------------------------
//  GFX_HLine
//
/** Draw horizontal line.
 *
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the line
 * 
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_HLine(UINT32 u4DstX, UINT32 u4DstY, UINT32 u4Width);

//---------------------------------------------------------------------------
//  GFX_VLine
//
/** Draw vertical line.
 *
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Height    The height of the line
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_VLine(UINT32 u4DstX, UINT32 u4DstY, UINT32 u4Height);

//---------------------------------------------------------------------------
//  GFX_SetBltOpt
//
/** Set bitblt option.
 *
 *  @param  u4Switch    The option flag of BitBlt
 *  @param  u4ColorMin  The dst color key min
 *  @param  u4ColorMax  The dst color key max
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void
        GFX_SetBltOpt(UINT32 u4Switch, UINT32 u4ColorMin, UINT32 u4ColorMax);

//---------------------------------------------------------------------------
//  GFX_BitBlt
//
/** Bit blit operation.
 *  
 *  @param  u4SrcX      The x coordinate of the src region
 *  @param  u4SrcY      The y coordinate of the src region
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the extent
 *  @param  u4Height    The height of the extent
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_BitBlt(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height);

//---------------------------------------------------------------------------
//  GFX_Blend
//
/** Alpha blending operation.
 *  
 *  @param  u4SrcX      The x coordinate of the src region
 *  @param  u4SrcY      The y coordinate of the src region
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the extent
 *  @param  u4Height    The height of the extent
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_Blend(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height);

//---------------------------------------------------------------------------
//  GFX_AlphaComposePass
//
/** Alpha compose pass operation.
 *  
 *  @param  u4SrcX      The x coordinate of the src region
 *  @param  u4SrcY      The y coordinate of the src region
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the extent
 *  @param  u4Height    The height of the extent
 *  @param  u4Pass      The pass method
 *  @param  u4Param     The global alpha
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_AlphaComposePass(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height, UINT32 u4Pass,
        UINT32 u4Param);

//---------------------------------------------------------------------------
//  GFX_SetColCnvFmt
//
/** Set ycbcr to rgb color conversion format.
 *
 *  @param  u4YCFmt     The yc format
 *  @param  u4SwapMode  The swap mode
 *  @param  u4VidStd    The video standard
 *  @param  u4VidSys    The video system
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetColCnvFmt(UINT32 u4YCFmt, UINT32 u4SwapMode,
        UINT32 u4VidStd, UINT32 u4VidSys);

//---------------------------------------------------------------------------
//  GFX_SetColCnvSrc
//
/** Set color conversion source region.
 *
 *  @param  pu1SrcLuma          The base address of the luma region
 *  @param  u4SrcLumaPitch      The pitch of the luma region
 *  @param  pu1SrcChroma        The base address of the chroma region
 *  @param  u4SrcChromaPitch    The pitch of the chroma region
 *  @param  u4FieldPic          The field mode
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetColCnvSrc(UINT8 *pu1SrcLuma, UINT32 u4SrcLumaPitch,
        UINT8 *pu1SrcChroma, UINT32 u4SrcChromaPitch, UINT32 u4FieldPic);

//---------------------------------------------------------------------------
//  GFX_ColConv
//
/** Convert ycbcr to rgb.
 *
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the extent
 *  @param  u4Height    The height of the extent
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_ColConv(UINT32 u4DstX, UINT32 u4DstY, UINT32 u4Width,
        UINT32 u4Height);

extern void GFX_SetDstWrRgb24Bit(UINT32 u4Dst);

//---------------------------------------------------------------------------
//  GFX_StretchBlt
//
/** Stretch bitblt (repeat or drop).
 *  
 *  @param  u4SrcX      The x coordinate of the src region
 *  @param  u4SrcY      The y coordinate of the src region
 *  @param  u4SrcW      The width of the src extent
 *  @param  u4SrcH      The height of the src extent
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4DstW      The width of the dst extent
 *  @param  u4DstH      The height of the dst extent
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_StretchBlt(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4SrcW,
        UINT32 u4SrcH, UINT32 u4DstX, UINT32 u4DstY, UINT32 u4DstW,
        UINT32 u4DstH);

//---------------------------------------------------------------------------
//  GFX_AlphaMapBitBlt
//
/** Alpha-map bitblt operation.
 *  
 *  @param  u4SrcX      The x coordinate of the src region
 *  @param  u4SrcY      The y coordinate of the src region
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the extent
 *  @param  u4Height    The height of the extent
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_AlphaMapBitBlt(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height);

//---------------------------------------------------------------------------
//  GFX_SetRopOpt
//
/** Set rop bitblt option.
 *
 *  @param  u4RopCode       The rop code
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetRopOpt(UINT32 u4RopCode);

//---------------------------------------------------------------------------
//  GFX_RopBitBlt
//
/** Rop bitblt operation.
 *  
 *  @param  u4SrcX      The x coordinate of the src region
 *  @param  u4SrcY      The y coordinate of the src region
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the extent
 *  @param  u4Height    The height of the extent
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_RopBitBlt(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height);

//---------------------------------------------------------------------------
//  GFX_ComposeLoop
//
/** Loop mode alpha composition.
 *  
 *  @param  u4SrcX      The x coordinate of the src region
 *  @param  u4SrcY      The y coordinate of the src region
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the extent
 *  @param  u4Height    The height of the extent
 *  @param  u4Ar        The global alpha
 *  @param  u4OpCode    The PD rules
 *  @param  u4RectSrc   The flag of src extent is filled rectangular color
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_ComposeLoop(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height, UINT32 u4Ar,
        UINT32 u4OpCode, UINT32 u4RectSrc);

//---------------------------------------------------------------------------
//  GFX_SetIdx2DirSrc
//
/** Set index to direct color bitblt source region.
 *
 *  @param  pu1Base     The base address of the src region
 *  @param  u4SrcCM     The color mode of the src region
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetIdx2DirSrc(UINT8 *pu1Base, UINT32 u4SrcCM);

//---------------------------------------------------------------------------
//  GFX_SetIdx2DirOpt
//
/** Set index to direct color bitblt option.
 *
 *  @param  pu1PaletteBase      The base address of the palette
 *  @param  u4MsbLeft           The flag of left pixel location in one byte
 *  @param  u4StartByteAligned  The flag of src line start byte aligned
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetIdx2DirOpt(UINT8 *pu1PaletteBase, UINT32 u4MsbLeft,
        UINT32 u4StartByteAligned);

//---------------------------------------------------------------------------
//  GFX_Idx2DirBitBlt
//
/** index to direct color bitblt operation.
 *
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the extent
 *  @param  u4Height    The height of the extent
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_Idx2DirBitBlt(UINT32 u4DstX, UINT32 u4DstY, UINT32 u4Width,
        UINT32 u4Height);

//---------------------------------------------------------------------------
//  GFX_2DMemCompare
//
/** 2D memory compare operation.
 *  
 *  @param  u4SrcX      The x coordinate of the src region
 *  @param  u4SrcY      The y coordinate of the src region
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the extent
 *  @param  u4Height    The height of the extent
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_2DMemCompare(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height);

//---------------------------------------------------------------------------
//  GFX_GetMemCompareResult
//
/** Get memory compare result.
 *
 *  @retval 1   With difference
 *  @retval 0   No difference
 */
//---------------------------------------------------------------------------
extern INT32 GFX_GetMemCompareResult(void);

//#ifdef CC_GFX_COMPOSITION_IMPROVE
extern void GFX_SetCharCM(BOOL flag,UINT32 u4SrcCM);
extern void GFX_ComposeLoopImprove(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4Width, UINT32 u4Height, UINT32 u4Ar,
        UINT32 u4OpCode, UINT32 u4RectSrc);

//#endif

//---------------------------------------------------------------------------
//  GFX_SetHoriToVertLineOpt
//
/** Set horizontal line to vertical line option.
 *
 *  @param  u4Is90dCcw      The flag of 90" clockwise or counterclockwise
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetHoriToVertLineOpt(UINT32 u4Is90dCcw);

//---------------------------------------------------------------------------
//  GFX_HoriToVertLine
//
/** Horizontal line to vertical line operation.
 *  
 *  @param  u4SrcX      The x coordinate of the src region
 *  @param  u4SrcY      The y coordinate of the src region
 *  @param  u4DstX      The x coordinate of the dst region
 *  @param  u4DstY      The y coordinate of the dst region
 *  @param  u4Width     The width of the horizontal line
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_HoriToVertLine(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4DstX,
        UINT32 u4DstY, UINT32 u4HoriLineWidth);

//---------------------------------------------------------------------------
//  GFX_SetExtCmdQue
//
/** Horizontal line to vertical line operation.
 *  
 *  @param  u4SrcX      The x coordinate of the src region
 *  @param  u4SrcY      The y coordinate of the src region
 *
 *  @retval void
 */
//---------------------------------------------------------------------------
extern void GFX_SetExtCmdQue(volatile GFX_CMDQUE_T *prGfxCmdQue,
        volatile UINT64 *pu8CmdQueBuf, UINT32 u4Config);

extern void GFX_SetDirectFBMem(UINT32 u4Addr, UINT32 u4Size);

extern BOOL GFX_ColorConvert(void* pvDstInfo, UPTR u4SrcAddr, UINT32 u4DstCM,
        UINT8 u1Alpha);
extern void GFX_NewCompressBlt(UINT8 *pu1SrcBase, UINT32 u4SrcX, UINT32 u4SrcY,
        UINT32 u4SrcCM, UINT32 u4SrcPitch, UINT8 *pu1DstBase, UINT32 u4Width,
        UINT32 u4Height, UINT32 u4BufHeight, BOOL u4RollBackEn,
        UINT32 u4QualityMode, UINT32 u4BpCompAddrEnd, UINT32 u4_blt_fg,
        BOOL fgBurstRead, BOOL fgLineSeparate,void *pt_gfx_mmu);

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

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

extern void GFX_GeneralAlphaCom(UINT32 u4Width, UINT32 u4Height, UINT32 u4Ar,
        UINT32 u4OpCode, UINT32 u4RectSrc, UINT32 u4ThirdEnable,
        BOOL fgAlcomNormal, BOOL fgOnePassCompress);
extern void (*pfnGFX_DMANotify)(UINT32, void*);
extern void GFX_SetDMAStatus(INT32 i4Status);

extern INT32 GFX_IsDMA(void);

extern void* GFX_GetDMATag(void);

extern void GFX_MMU_Set_Cfg(void* pt_gfx_mmu);
extern void GFX_MMU_Set_Enable(UINT32 u4_enable);
extern void GFX_MMU_Setting(UINT32 u4Enable, UINT32 u4SrcEnable, UINT32 u4DstEnable);

extern UINT32 GFX_Get_Cm_Size(GFX_COLOR_MODE_T e_cm);
extern void GFX_Flush_Invalid_DCache(void);

extern BOOL GFX_ColorConvert_YC(void* pvDstInfo, UPTR u4SrcAddrY,
        UPTR u4SrcAddrC, UINT32 u4DstCM, UINT8 u1Alpha, UINT32 u4SrcPitch);


extern void GFX_SetXORColor(UINT32 u4Color);
extern void GFX_Set_PRE_COLORIZE(BOOL u4PreColorize);
extern void GFX_Set_SrcAlReplace(UINT32 u4SrcAlRep);
extern void GFX_Set_FlashColCnvInfo(UINT8 *pu1SrcY, UINT32 u4SrcYPitch,
        UINT8 *pu1SrcCbCr, UINT32 u4SrcCbCrPitch, UINT8 * u4DstAdress,
        UINT32 u4SrcWidth, UINT32 u4SrcHeight);
extern void GFX_Set_SrcDst(UINT8 *pu1SrcY, UINT32 u4SrcYPitch,
        UINT8 *pu1SrcCbCr, UINT32 u4SrcCbCrPitch, UINT8 * u4DstAdress,
        UINT32 u4DstPitch,UINT32 u4DstColorMode,UINT32 u4DstX,UINT32 u4DstY,
        UINT32 u4SrcWidth, UINT32 u4SrcHeight);
extern void GFX_Set_ColConvInfo(UINT32 u4YCFmt, UINT32 u4SwapMode, UINT32 u4VidStd,
        UINT32 u4VidSys,UINT32 u4FieldPic,UINT32 u4Alpha);

extern void GFX_YCbCrBlockToRaster_2Buf(UINT8 *pu1SrcY, UINT32 u4SrcYPitch, UINT8 *pu1SrcCbCr, 
        UINT32 u4SrcCbCrPitch, UINT8 * u4DstAdress,UINT32 u4SrcWidth,UINT32 u4SrcHeight);
extern void GFX_YCbCrBlockToRaster_3Buf(UINT8 *pu1SrcY, UINT32 u4SrcYPitch, UINT8 *pu1SrcCbCr, 
        UINT32 u4SrcCbCrPitch, UINT8 * u4DstAdress,UINT32 u4SrcWidth,UINT32 u4SrcHeight,void *pt_gfx_mmu);

extern void GFX_YCbCrBlockToRaster_2Buf_WithPitch(UINT8 *pu1SrcY, UINT32 u4SrcYPitch,
        UINT8 *pu1SrcCbCr, UINT32 u4SrcCbCrPitch, UINT8 * u4DstAdress,
        UINT32 u4SrcWidth, UINT32 u4SrcHeight , UINT32 u4Dst_Pitch);
extern void GFX_YCbCrBlockToRaster_3Buf_WidthPitch(UINT8 *pu1SrcY, UINT32 u4SrcYPitch,
        UINT8 *pu1SrcCbCr, UINT32 u4SrcCbCrPitch, UINT8 * u4DstAdress,
        UINT32 u4SrcWidth, UINT32 u4SrcHeight, UINT32 u4WriteNoPitch, UINT32 u4Dst_Pitch);


extern void GFX_YCbCr420ToARGB32(UINT8 *pu1SrcY, UINT32 u4SrcYPitch,
        UINT8 *pu1SrcCbCr, UINT32 u4SrcCbCrPitch, UINT8 * u4DstAdress,
        UINT32 u4SrcWidth, UINT32 u4SrcHeight, UINT32 u4AlphaValue,
        UINT32 u4FieldPic);
extern void GFX_Memset(UINT8 *pu1Addr, UINT32 u4Width, UINT32 Height,
        UINT32 u4Color);

extern UINT32 GFX_Get_IMGRZ_CM(UINT32 u4_gfx_cm);
extern UINT32 GFX_Check_DirectFBMem(UINT32 u4_addr);
extern void GFX_Stretchblit(void* pt_this);
extern void GFX_Stretch_Alphacom(void* pv_this);    
extern void GFX_Set3DFlag(BOOL b3DFlag);
extern BOOL GFX_Get3DFlag(void);
extern void GFX_Flush_Invalid_DCache(void);
extern void GFX_SetRotate_90(UINT32 u4Is90Ccw, UINT32 u4_dst_rd, UINT32 u4_dst_wr);
extern void GFX_StretchBlt_forYBlock(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4SrcW, UINT32 u4SrcH,
            UINT32 u4DstX, UINT32 u4DstY, UINT32 u4DstW, UINT32 u4DstH);
extern void GFX_StretchBlt_forUVBlock(UINT32 u4SrcX, UINT32 u4SrcY, UINT32 u4SrcW, UINT32 u4SrcH,
            UINT32 u4DstX, UINT32 u4DstY, UINT32 u4DstW, UINT32 u4DstH);
            
extern void GFX_SetLegalAddr(UINT32 u4Enable,UPTR u4Start, UPTR u4End);
extern void GFX_MemsetAsync(UINT8 *pu1Addr, UINT32 u4_width,UINT32 u4_height, UINT32 u4_value);
extern void GFX_Task_Lock(void);
extern void GFX_Task_Unlock(void);
extern void GFX_Task_Thread(void* pvArg);
extern UINT32 GFX_Task_Is_Init(void);
extern UINT64 GFX_Task_Send(void* pv_data, UINT32 u4_size, UINT32 u4_type);
extern void GFX_Task_Wait_Sync(void);


extern void gfx_dfb_set_dbg_info(UINT32 u4_type,UINT32 u4_val);
extern UINT32 gfx_dfb_get_dbg_info(UINT32 u4_type);

extern void GFX_Rotate_Blit(GFX_ROTATE_BLIT_T *pt_this);

extern UPTR GFX_GetTmpBuf(void);
extern void GFX_SetTmpBuf(UINT32 u4_val);
extern UINT32 GFX_GetTmpBufSize(void);
extern void GFX_SetTmpBufSize(UINT32 u4_val);
#ifdef CC_GFX_TMP_BUF_IOVA_SUPPORT
extern void GFX_ReleaseTmpBuf(void);
#endif
extern void fb_gfx_setup_cmdq(void);
extern void GFX_YCbCr420Swap2ToARGB32(UINT8 *pu1SrcY, UINT32 u4SrcYPitch,
        UINT8 *pu1SrcCbCr, UINT32 u4SrcCbCrPitch, UINT8 * u4DstAdress,
        UINT32 u4SrcWidth, UINT32 u4SrcHeight, UINT32 u4AlphaValue,
        UINT32 u4FieldPic,UINT32 u4Sys,UINT32 u4Std,UINT32 u4Vfull);

#ifdef CC_SUPPORT_STR
extern void GFX_pm_suspend(void);
extern void GFX_pm_resume(void);
#endif

extern void GFX_TmpBuf_Lock(void);
extern void GFX_TmpBuf_Unock(void);

VOID GFX_Transform(UINT32 u4SrcAddr, UINT32 u4SrcWidth, UINT32 u4SrcHeight, UINT32 u4SrcPitch, UINT32 u4SrcColorMode, BOOL fgSrcVirtual,
	UINT32 u4DstAddr, UINT32 u4DstWidth, UINT32 u4DstHeight, UINT32 u4DstPitch, UINT32 u4DstColorMode, BOOL fgDstVirtual);


extern UINT32 GFX_Get_DbgLvl(void);
extern void GFX_Set_Dlta(UINT32 u4_s,UINT32 u4_ms);
extern void GFX_Task_List_Dcache_Add(UINT32 u4_type);

extern UINT32 GFX_GetDirectFBMem_Addr(void);
extern UINT32 GFX_GetDirectFBMem_Size(void);

#endif // GFX_IF_H

