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

/*-----------------------------------------------------------------------------
 * $RCSfile: mtal_mtmplayer_slide.c,v $
 * $Revision: #1 $
 *---------------------------------------------------------------------------*/
/** @file mtal_mtmplayer_slide.c
 */

/********************************************************************
  INCLUDE FILES
********************************************************************/
#include "imgrz_if.h"
#include "imgrz_drvif.h"
#include "mtal_mtmplayer_slide.h"

/********************************************************************
  MACRO CONSTANT DEFINITIONS
********************************************************************/


/********************************************************************
  TYPE DEFINITION
********************************************************************/
#define SLIDE_SEG_FULLSIZE      16
#define SLIDE_SEG_VHALFSIZE     12
#define SLIDE_SEG_WHALFSIZE     8

#if 0
VOID MTMPLAYER_BarSlideLR(IMG_VP_INFO_T rVpInfo)
{    
    RZ_VDO_SCL_PARAM_SET_T rScaleParamV;
    UINT32 u4I;
    
    for (u4I = 16; u4I <= rVpInfo.u4Width; u4I += 16)
    {
        rScaleParamV.u4IsRsIn = 1;        
        rScaleParamV.u4InMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[0];
        rScaleParamV.u4YSrcBufLen = ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YSrcHOffset = rVpInfo.u4Width - u4I;
        rScaleParamV.u4YSrcVOffset = 0;
        rScaleParamV.u4YSrcW = u4I;
        rScaleParamV.u4YSrcH = rVpInfo.u4Height;
        rScaleParamV.u4CSrcW = u4I >> 1;
        rScaleParamV.u4CSrcH = rVpInfo.u4Height;
        rScaleParamV.u4CSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[1];
        rScaleParamV.u4CSrcHOffset = (rVpInfo.u4Width - u4I) >> 1;
        rScaleParamV.u4CSrcVOffset = 0;
        rScaleParamV.u4IsRsOut = 1;
        rScaleParamV.u4OutMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4IsVdo2Osd = 0;     
        rScaleParamV.u4YTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[0];       
        rScaleParamV.u4YTgCM = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YTgBufLen = ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YTgHOffset = 0;
        rScaleParamV.u4YTgVOffset = 0;
        rScaleParamV.u4YTgW = u4I;
        rScaleParamV.u4YTgH = rVpInfo.u4Height;
        rScaleParamV.u4CTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[1];        
        rScaleParamV.u4CTgW = u4I >> 1;
        rScaleParamV.u4CTgH = rVpInfo.u4Height;        
        rScaleParamV.u4SrcSwap = 0;    
        IMGRZ_Lock();
        IMGRZ_ReInit();
        IMGRZ_SetScaleOpt(E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale((void *)(&rScaleParamV));           
        IMGRZ_Flush();
        IMGRZ_Wait();
        IMGRZ_Unlock();
    }
    return MTR_OK;
}
#endif


/**horizontal bar wipe effect
*@param rVpInfo vdp parameters
*@param fgL2R, TRUE: left to right, FALSE: right to left
*@retval
*/
VOID MTMPLAYER_BarWipeH(IMG_VP_INFO_T rVpInfo, BOOL fgL2R)
{    
    RZ_VDO_SCL_PARAM_SET_T rScaleParamV;
    UINT32 u4I;
    
    for (u4I = SLIDE_SEG_FULLSIZE; u4I <= rVpInfo.u4Width; u4I += SLIDE_SEG_FULLSIZE)
    {
        rScaleParamV.u4IsRsIn = 1;        
        rScaleParamV.u4InMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[0];
        rScaleParamV.u4YSrcBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YSrcHOffset = (fgL2R) ? u4I - SLIDE_SEG_FULLSIZE : rVpInfo.u4Width - u4I;
        rScaleParamV.u4YSrcVOffset = 0;
        rScaleParamV.u4YSrcW = SLIDE_SEG_FULLSIZE;
        rScaleParamV.u4YSrcH = rVpInfo.u4Height;
        rScaleParamV.u4CSrcW = SLIDE_SEG_FULLSIZE >> 1;
        rScaleParamV.u4CSrcH = rVpInfo.u4Height;
        rScaleParamV.u4CSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[1];
        rScaleParamV.u4CSrcHOffset = (fgL2R)?(u4I - SLIDE_SEG_FULLSIZE) >> 1:(rVpInfo.u4Width - u4I) >> 1;
        rScaleParamV.u4CSrcVOffset = 0;
        rScaleParamV.u4IsRsOut = 1;
        rScaleParamV.u4OutMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4IsVdo2Osd = 0;     
        rScaleParamV.u4YTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[0];       
        rScaleParamV.u4YTgCM = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YTgBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YTgHOffset = (fgL2R) ? u4I - SLIDE_SEG_FULLSIZE : rVpInfo.u4Width - u4I;
        rScaleParamV.u4YTgVOffset = 0;
        rScaleParamV.u4YTgW = SLIDE_SEG_FULLSIZE;
        rScaleParamV.u4YTgH = rVpInfo.u4Height;
        rScaleParamV.u4CTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[1];        
        rScaleParamV.u4CTgW = SLIDE_SEG_FULLSIZE >> 1;
        rScaleParamV.u4CTgH = rVpInfo.u4Height;        
        rScaleParamV.u4SrcSwap = 0;    
        IMGRZ_Lock_Ex(E_FIRST_RESIZER);
        IMGRZ_ReInit_Ex(E_FIRST_RESIZER);
        IMGRZ_SetScaleOpt_Ex(E_FIRST_RESIZER, E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale_Ex(E_FIRST_RESIZER, (void *)(&rScaleParamV));           
        IMGRZ_Flush_Ex(E_FIRST_RESIZER);
        IMGRZ_Wait_Ex(E_FIRST_RESIZER);
        IMGRZ_Unlock_Ex(E_FIRST_RESIZER);
        x_thread_delay(1);
    }
    return;
}


/**vertical bar wipe effect
*@param rVpInfo vdp parameters
*@param fgT2B, TRUE: top to bottom, FALSE: bottom to top
*@retval
*/
VOID MTMPLAYER_BarWipeV(IMG_VP_INFO_T rVpInfo, BOOL fgT2B)
{    
    RZ_VDO_SCL_PARAM_SET_T rScaleParamV;
    UINT32 u4I;
    
    for (u4I = SLIDE_SEG_FULLSIZE; u4I <= rVpInfo.u4Height; u4I += SLIDE_SEG_FULLSIZE)
    {
        rScaleParamV.u4IsRsIn = 1;        
        rScaleParamV.u4InMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[0];
        rScaleParamV.u4YSrcBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YSrcHOffset = 0;
        rScaleParamV.u4YSrcVOffset = (fgT2B) ? u4I - SLIDE_SEG_FULLSIZE : rVpInfo.u4Height - u4I;
        rScaleParamV.u4YSrcW = rVpInfo.u4Width;
        rScaleParamV.u4YSrcH = SLIDE_SEG_FULLSIZE;
        rScaleParamV.u4CSrcW = rVpInfo.u4Width >> 1;
        rScaleParamV.u4CSrcH = SLIDE_SEG_FULLSIZE;
        rScaleParamV.u4CSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[1];
        rScaleParamV.u4CSrcHOffset = 0;
        rScaleParamV.u4CSrcVOffset = (fgT2B) ? u4I - SLIDE_SEG_FULLSIZE : rVpInfo.u4Height - u4I;
        rScaleParamV.u4IsRsOut = 1;
        rScaleParamV.u4OutMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4IsVdo2Osd = 0;     
        rScaleParamV.u4YTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[0];       
        rScaleParamV.u4YTgCM = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YTgBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YTgHOffset = 0;
        rScaleParamV.u4YTgVOffset = (fgT2B) ? u4I - SLIDE_SEG_FULLSIZE : rVpInfo.u4Height - u4I;
        rScaleParamV.u4YTgW = rVpInfo.u4Width;
        rScaleParamV.u4YTgH = SLIDE_SEG_FULLSIZE;
        rScaleParamV.u4CTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[1];        
        rScaleParamV.u4CTgW = rVpInfo.u4Width >> 1;
        rScaleParamV.u4CTgH = SLIDE_SEG_FULLSIZE;        
        rScaleParamV.u4SrcSwap = 0;    
        IMGRZ_Lock_Ex(E_FIRST_RESIZER);
        IMGRZ_ReInit_Ex(E_FIRST_RESIZER);
        IMGRZ_SetScaleOpt_Ex(E_FIRST_RESIZER, E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale_Ex(E_FIRST_RESIZER, (void *)(&rScaleParamV));           
        IMGRZ_Flush_Ex(E_FIRST_RESIZER);
        IMGRZ_Wait_Ex(E_FIRST_RESIZER);
        IMGRZ_Unlock_Ex(E_FIRST_RESIZER);		
        x_thread_delay(1);
    }
    return;
}


/**box wipe effect
*@param rVpInfo vdp parameters
*@param fgT2B, TRUE: top to bottom, FALSE: bottom to top
*@param fgL2R, TRUE: left to right, FALSE: right to left
*@retval
*/
VOID MTMPLAYER_BoxWipe(IMG_VP_INFO_T rVpInfo, BOOL fgT2B, BOOL fgL2R)
{    
    RZ_VDO_SCL_PARAM_SET_T rScaleParamV;
    UINT32 u4I;
    
    for (u4I = SLIDE_SEG_FULLSIZE; u4I <= rVpInfo.u4Width; u4I += SLIDE_SEG_FULLSIZE)
    {
        rScaleParamV.u4IsRsIn = 1;        
        rScaleParamV.u4InMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[0];
        rScaleParamV.u4YSrcBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);        
        rScaleParamV.u4YSrcW = u4I;
        rScaleParamV.u4YSrcH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4YSrcHOffset = (fgL2R) ? 0 : rVpInfo.u4Width - u4I;
        rScaleParamV.u4YSrcVOffset = (fgT2B) ? 0 : rVpInfo.u4Height - rScaleParamV.u4YSrcH;
        rScaleParamV.u4CSrcW = u4I >> 1;
        rScaleParamV.u4CSrcH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[1];
        rScaleParamV.u4CSrcHOffset = (fgL2R) ? 0 : (rVpInfo.u4Width - u4I) >> 1;
        rScaleParamV.u4CSrcVOffset = (fgT2B) ? 0 : rVpInfo.u4Height - rScaleParamV.u4YSrcH;
        rScaleParamV.u4IsRsOut = 1;
        rScaleParamV.u4OutMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4IsVdo2Osd = 0;     
        rScaleParamV.u4YTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[0];       
        rScaleParamV.u4YTgCM = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YTgBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YTgHOffset = (fgL2R) ? 0 : rVpInfo.u4Width - u4I;
        rScaleParamV.u4YTgVOffset = (fgT2B) ? 0 : rVpInfo.u4Height - rScaleParamV.u4YSrcH;
        rScaleParamV.u4YTgW = u4I;
        rScaleParamV.u4YTgH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[1];        
        rScaleParamV.u4CTgW = u4I >> 1;
        rScaleParamV.u4CTgH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;        
        rScaleParamV.u4SrcSwap = 0;    
        IMGRZ_Lock_Ex(E_FIRST_RESIZER);
        IMGRZ_ReInit_Ex(E_FIRST_RESIZER);
        IMGRZ_SetScaleOpt_Ex(E_FIRST_RESIZER, E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale_Ex(E_FIRST_RESIZER, (void *)(&rScaleParamV));           
        IMGRZ_Flush_Ex(E_FIRST_RESIZER);
        IMGRZ_Wait_Ex(E_FIRST_RESIZER);
        IMGRZ_Unlock_Ex(E_FIRST_RESIZER);		
    }
    return;
}

#if 0
VOID MTMPLAYER_BoxWipeTR(IMG_VP_INFO_T rVpInfo)
{    
    RZ_VDO_SCL_PARAM_SET_T rScaleParamV;
    UINT32 u4I;
    
    for (u4I = SLIDE_SEG_FULLSIZE; u4I <= rVpInfo.u4Width; u4I += SLIDE_SEG_FULLSIZE)
    {
        rScaleParamV.u4IsRsIn = 1;        
        rScaleParamV.u4InMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[0];
        rScaleParamV.u4YSrcBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YSrcHOffset = rVpInfo.u4Width - u4I;
        rScaleParamV.u4YSrcVOffset = 0;
        rScaleParamV.u4YSrcW = u4I;
        rScaleParamV.u4YSrcH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CSrcW = u4I >> 1;
        rScaleParamV.u4CSrcH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[1];
        rScaleParamV.u4CSrcHOffset = (rVpInfo.u4Width - u4I) >> 1;
        rScaleParamV.u4CSrcVOffset = 0;
        rScaleParamV.u4IsRsOut = 1;
        rScaleParamV.u4OutMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4IsVdo2Osd = 0;     
        rScaleParamV.u4YTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[0];       
        rScaleParamV.u4YTgCM = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YTgBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YTgHOffset = rVpInfo.u4Width - u4I;
        rScaleParamV.u4YTgVOffset = 0;
        rScaleParamV.u4YTgW = u4I;
        rScaleParamV.u4YTgH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[1];        
        rScaleParamV.u4CTgW = u4I >> 1;
        rScaleParamV.u4CTgH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;        
        rScaleParamV.u4SrcSwap = 0;    
        IMGRZ_Lock();
        IMGRZ_ReInit();
        IMGRZ_SetScaleOpt(E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale((void *)(&rScaleParamV));           
        IMGRZ_Flush();
        IMGRZ_Wait();
        IMGRZ_Unlock();
    }
    return;
}


VOID MTMPLAYER_BoxWipeBL(IMG_VP_INFO_T rVpInfo)
{    
    RZ_VDO_SCL_PARAM_SET_T rScaleParamV;
    UINT32 u4I;
    
    for (u4I = SLIDE_SEG_FULLSIZE; u4I <= rVpInfo.u4Width; u4I += SLIDE_SEG_FULLSIZE)
    {
        rScaleParamV.u4IsRsIn = 1;        
        rScaleParamV.u4InMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[0];
        rScaleParamV.u4YSrcBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YSrcW = u4I;
        rScaleParamV.u4YSrcH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CSrcW = u4I >> 1;
        rScaleParamV.u4CSrcH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4YSrcHOffset = 0;
        rScaleParamV.u4YSrcVOffset = rVpInfo.u4Height - rScaleParamV.u4YSrcH;
        rScaleParamV.u4CSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[1];
        rScaleParamV.u4CSrcHOffset = 0;
        rScaleParamV.u4CSrcVOffset = rVpInfo.u4Height - rScaleParamV.u4YSrcH;
        rScaleParamV.u4IsRsOut = 1;
        rScaleParamV.u4OutMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4IsVdo2Osd = 0;     
        rScaleParamV.u4YTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[0];       
        rScaleParamV.u4YTgCM = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YTgBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YTgW = u4I;
        rScaleParamV.u4YTgH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[1];        
        rScaleParamV.u4CTgW = u4I >> 1;
        rScaleParamV.u4CTgH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;      
        rScaleParamV.u4YTgHOffset = 0;
        rScaleParamV.u4YTgVOffset = rVpInfo.u4Height - rScaleParamV.u4YTgH;
        rScaleParamV.u4SrcSwap = 0;    
        IMGRZ_Lock();
        IMGRZ_ReInit();
        IMGRZ_SetScaleOpt(E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale((void *)(&rScaleParamV));           
        IMGRZ_Flush();
        IMGRZ_Wait();
        IMGRZ_Unlock();
    }
    return;
}


VOID MTMPLAYER_BoxWipeBR(IMG_VP_INFO_T rVpInfo)
{    
    RZ_VDO_SCL_PARAM_SET_T rScaleParamV;
    UINT32 u4I;
    
    for (u4I = SLIDE_SEG_FULLSIZE; u4I <= rVpInfo.u4Width; u4I += SLIDE_SEG_FULLSIZE)
    {
        rScaleParamV.u4IsRsIn = 1;        
        rScaleParamV.u4InMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[0];
        rScaleParamV.u4YSrcBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YSrcW = u4I;
        rScaleParamV.u4YSrcH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CSrcW = u4I >> 1;
        rScaleParamV.u4CSrcH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4YSrcHOffset = rVpInfo.u4Width - u4I;
        rScaleParamV.u4YSrcVOffset = rVpInfo.u4Height - rScaleParamV.u4YSrcH;
        rScaleParamV.u4CSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[1];
        rScaleParamV.u4CSrcHOffset = (rVpInfo.u4Width - u4I) >> 1;
        rScaleParamV.u4CSrcVOffset = rVpInfo.u4Height - rScaleParamV.u4YSrcH;
        rScaleParamV.u4IsRsOut = 1;
        rScaleParamV.u4OutMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4IsVdo2Osd = 0;     
        rScaleParamV.u4YTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[0];       
        rScaleParamV.u4YTgCM = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YTgBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YTgW = u4I;
        rScaleParamV.u4YTgH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[1];        
        rScaleParamV.u4CTgW = u4I >> 1;
        rScaleParamV.u4CTgH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;      
        rScaleParamV.u4YTgHOffset = rVpInfo.u4Width - u4I;
        rScaleParamV.u4YTgVOffset = rVpInfo.u4Height - rScaleParamV.u4YTgH;
        rScaleParamV.u4SrcSwap = 0;    
        IMGRZ_Lock();
        IMGRZ_ReInit();
        IMGRZ_SetScaleOpt(E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale((void *)(&rScaleParamV));           
        IMGRZ_Flush();
        IMGRZ_Wait();
        IMGRZ_Unlock();
    }
    return;
}
#endif

/**horizontal bandoor wipe effect
*@param rVpInfo vdp parameters
*@param fgL2R, TRUE: close, FALSE: open
*@retval
*/
VOID MTMPLAYER_DoorWipeH(IMG_VP_INFO_T rVpInfo, BOOL fgClose)
{    
    RZ_VDO_SCL_PARAM_SET_T rScaleParamV;
    UINT32 u4Width;
    UINT32 u4I;

    u4Width = rVpInfo.u4Width >> 1;
    for (u4I = SLIDE_SEG_FULLSIZE; u4I <= u4Width; u4I += SLIDE_SEG_FULLSIZE)
    {
        rScaleParamV.u4IsRsIn = 1;        
        rScaleParamV.u4InMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[0];
        rScaleParamV.u4YSrcBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YSrcHOffset = (fgClose) ? u4I - SLIDE_SEG_FULLSIZE : u4Width - u4I;
        rScaleParamV.u4YSrcVOffset = 0;
        rScaleParamV.u4YSrcW = SLIDE_SEG_FULLSIZE;
        rScaleParamV.u4YSrcH = rVpInfo.u4Height;
        rScaleParamV.u4CSrcW = SLIDE_SEG_FULLSIZE >> 1;
        rScaleParamV.u4CSrcH = rVpInfo.u4Height;
        rScaleParamV.u4CSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[1];
        rScaleParamV.u4CSrcHOffset = (fgClose) ? (u4I - SLIDE_SEG_FULLSIZE) >> 1 : (u4Width - u4I) >> 1;
        rScaleParamV.u4CSrcVOffset = 0;
        rScaleParamV.u4IsRsOut = 1;
        rScaleParamV.u4OutMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4IsVdo2Osd = 0;     
        rScaleParamV.u4YTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[0];       
        rScaleParamV.u4YTgCM = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YTgBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YTgHOffset = (fgClose) ? u4I - SLIDE_SEG_FULLSIZE : u4Width - u4I;
        rScaleParamV.u4YTgVOffset = 0;
        rScaleParamV.u4YTgW = SLIDE_SEG_FULLSIZE;
        rScaleParamV.u4YTgH = rVpInfo.u4Height;
        rScaleParamV.u4CTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[1];        
        rScaleParamV.u4CTgW = SLIDE_SEG_FULLSIZE >> 1;
        rScaleParamV.u4CTgH = rVpInfo.u4Height;        
        rScaleParamV.u4SrcSwap = 0;    
        IMGRZ_Lock_Ex(E_FIRST_RESIZER);
        IMGRZ_ReInit_Ex(E_FIRST_RESIZER);
        IMGRZ_SetScaleOpt_Ex(E_FIRST_RESIZER, E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale_Ex(E_FIRST_RESIZER, (void *)(&rScaleParamV));           
        IMGRZ_Flush_Ex(E_FIRST_RESIZER);
        IMGRZ_Wait_Ex(E_FIRST_RESIZER);
        IMGRZ_Unlock_Ex(E_FIRST_RESIZER);

        rScaleParamV.u4YSrcHOffset = (fgClose) ? rVpInfo.u4Width - u4I : 
                                                 u4Width + u4I - SLIDE_SEG_FULLSIZE;
        rScaleParamV.u4CSrcHOffset = (fgClose) ? (rVpInfo.u4Width - u4I) >> 1 : 
                                                 (u4Width + u4I - SLIDE_SEG_FULLSIZE) >> 1;
        rScaleParamV.u4YTgHOffset = (fgClose) ? rVpInfo.u4Width - u4I : 
                                                 u4Width + u4I - SLIDE_SEG_FULLSIZE;
		IMGRZ_Lock_Ex(E_FIRST_RESIZER);
		IMGRZ_ReInit_Ex(E_FIRST_RESIZER);
		IMGRZ_SetScaleOpt_Ex(E_FIRST_RESIZER, E_RZ_INOUT_TYPE_VDOMD);
		IMGRZ_Scale_Ex(E_FIRST_RESIZER, (void *)(&rScaleParamV));			 
		IMGRZ_Flush_Ex(E_FIRST_RESIZER);
		IMGRZ_Wait_Ex(E_FIRST_RESIZER);
		IMGRZ_Unlock_Ex(E_FIRST_RESIZER);

        x_thread_delay(1);
    }
    return;
}


/**vertical bandoor wipe effect
*@param rVpInfo vdp parameters
*@param fgL2R, TRUE: close, FALSE: open
*@retval
*/
VOID MTMPLAYER_DoorWipeV(IMG_VP_INFO_T rVpInfo, BOOL fgClose)
{    
    RZ_VDO_SCL_PARAM_SET_T rScaleParamV;
    UINT32 u4Height;
    UINT32 u4I;

    u4Height = rVpInfo.u4Height >> 1;
    for (u4I = SLIDE_SEG_VHALFSIZE; u4I <= u4Height; u4I += SLIDE_SEG_VHALFSIZE)
    {
        rScaleParamV.u4IsRsIn = 1;        
        rScaleParamV.u4InMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[0];
        rScaleParamV.u4YSrcBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YSrcHOffset = 0;
        rScaleParamV.u4YSrcVOffset = (fgClose) ? u4I - SLIDE_SEG_VHALFSIZE : u4Height - u4I;
        rScaleParamV.u4YSrcW = rVpInfo.u4Width;
        rScaleParamV.u4YSrcH = SLIDE_SEG_VHALFSIZE;
        rScaleParamV.u4CSrcW = rVpInfo.u4Width >> 1;
        rScaleParamV.u4CSrcH = SLIDE_SEG_VHALFSIZE;
        rScaleParamV.u4CSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[1];
        rScaleParamV.u4CSrcHOffset = 0;
        rScaleParamV.u4CSrcVOffset = (fgClose) ? u4I - SLIDE_SEG_VHALFSIZE : u4Height - u4I;
        rScaleParamV.u4IsRsOut = 1;
        rScaleParamV.u4OutMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4IsVdo2Osd = 0;     
        rScaleParamV.u4YTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[0];       
        rScaleParamV.u4YTgCM = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YTgBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YTgHOffset = 0;
        rScaleParamV.u4YTgVOffset = (fgClose) ? u4I - SLIDE_SEG_VHALFSIZE : u4Height - u4I;
        rScaleParamV.u4YTgW = rVpInfo.u4Width;
        rScaleParamV.u4YTgH = SLIDE_SEG_VHALFSIZE;
        rScaleParamV.u4CTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[1];        
        rScaleParamV.u4CTgW = rVpInfo.u4Width >> 1;
        rScaleParamV.u4CTgH = SLIDE_SEG_VHALFSIZE;        
        rScaleParamV.u4SrcSwap = 0;    
        IMGRZ_Lock_Ex(E_FIRST_RESIZER);
        IMGRZ_ReInit_Ex(E_FIRST_RESIZER);
        IMGRZ_SetScaleOpt_Ex(E_FIRST_RESIZER, E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale_Ex(E_FIRST_RESIZER, (void *)(&rScaleParamV));           
        IMGRZ_Flush_Ex(E_FIRST_RESIZER);
        IMGRZ_Wait_Ex(E_FIRST_RESIZER);
        IMGRZ_Unlock_Ex(E_FIRST_RESIZER);


        rScaleParamV.u4YSrcVOffset = (fgClose) ? rVpInfo.u4Height - u4I : 
                                                 u4Height + u4I - SLIDE_SEG_VHALFSIZE;
        rScaleParamV.u4CSrcVOffset = (fgClose) ? rVpInfo.u4Height - u4I : 
                                                 u4Height + u4I - SLIDE_SEG_VHALFSIZE;
        rScaleParamV.u4YTgVOffset = (fgClose) ? rVpInfo.u4Height - u4I : 
                                                 u4Height + u4I - SLIDE_SEG_VHALFSIZE;
        IMGRZ_Lock_Ex(E_FIRST_RESIZER);
        IMGRZ_ReInit_Ex(E_FIRST_RESIZER);
        IMGRZ_SetScaleOpt_Ex(E_FIRST_RESIZER, E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale_Ex(E_FIRST_RESIZER, (void *)(&rScaleParamV));           
        IMGRZ_Flush_Ex(E_FIRST_RESIZER);
        IMGRZ_Wait_Ex(E_FIRST_RESIZER);
        IMGRZ_Unlock_Ex(E_FIRST_RESIZER);
        x_thread_delay(1);
    }
    return;
}

#if 0
VOID MTMPLAYER_DoorWipeVO(IMG_VP_INFO_T rVpInfo)
{    
    RZ_VDO_SCL_PARAM_SET_T rScaleParamV;
    UINT32 u4Height;
    UINT32 u4I;

    u4Height = rVpInfo.u4Height >> 1;
    for (u4I = SLIDE_SEG_VHALFSIZE; u4I <= u4Height; u4I += SLIDE_SEG_VHALFSIZE)
    {
        rScaleParamV.u4IsRsIn = 1;        
        rScaleParamV.u4InMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[0];
        rScaleParamV.u4YSrcBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YSrcHOffset = 0;
        rScaleParamV.u4YSrcVOffset = u4Height - u4I;
        rScaleParamV.u4YSrcW = rVpInfo.u4Width;
        rScaleParamV.u4YSrcH = SLIDE_SEG_VHALFSIZE;
        rScaleParamV.u4CSrcW = rVpInfo.u4Width >> 1;
        rScaleParamV.u4CSrcH = SLIDE_SEG_VHALFSIZE;
        rScaleParamV.u4CSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[1];
        rScaleParamV.u4CSrcHOffset = 0;
        rScaleParamV.u4CSrcVOffset = u4Height - u4I;
        rScaleParamV.u4IsRsOut = 1;
        rScaleParamV.u4OutMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4IsVdo2Osd = 0;     
        rScaleParamV.u4YTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[0];       
        rScaleParamV.u4YTgCM = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YTgBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YTgHOffset = 0;
        rScaleParamV.u4YTgVOffset = u4Height - u4I;
        rScaleParamV.u4YTgW = rVpInfo.u4Width;
        rScaleParamV.u4YTgH = SLIDE_SEG_VHALFSIZE;
        rScaleParamV.u4CTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[1];        
        rScaleParamV.u4CTgW = rVpInfo.u4Width >> 1;
        rScaleParamV.u4CTgH = SLIDE_SEG_VHALFSIZE;        
        rScaleParamV.u4SrcSwap = 0;    
        IMGRZ_Lock();
        IMGRZ_ReInit();
        IMGRZ_SetScaleOpt(E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale((void *)(&rScaleParamV));           
        IMGRZ_Flush();
        IMGRZ_Wait();
        IMGRZ_Unlock();

        rScaleParamV.u4YSrcVOffset = u4Height + u4I - SLIDE_SEG_VHALFSIZE;
        rScaleParamV.u4CSrcVOffset = u4Height + u4I - SLIDE_SEG_VHALFSIZE;
        rScaleParamV.u4YTgVOffset = u4Height + u4I - SLIDE_SEG_VHALFSIZE;
        IMGRZ_Lock();
        IMGRZ_ReInit();
        IMGRZ_SetScaleOpt(E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale((void *)(&rScaleParamV));           
        IMGRZ_Flush();
        IMGRZ_Wait();
        IMGRZ_Unlock();
    }
    return;
}
#endif

VOID MTMPLAYER_IrisWipe(IMG_VP_INFO_T rVpInfo)
{    
    RZ_VDO_SCL_PARAM_SET_T rScaleParamV;
    UINT32 u4Width, u4Height;
    UINT32 u4I, u4Half;

    u4Width = rVpInfo.u4Width >> 1;
    u4Height = rVpInfo.u4Height >> 1;
    for (u4I = SLIDE_SEG_FULLSIZE; u4I <= rVpInfo.u4Width; u4I += SLIDE_SEG_FULLSIZE)
    {
        u4Half = u4I >> 1;
        rScaleParamV.u4IsRsIn = 1;        
        rScaleParamV.u4InMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[0];
        rScaleParamV.u4YSrcBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YSrcHOffset = u4Width - u4Half;
        rScaleParamV.u4YSrcVOffset = (u4Height < u4Half) ?  0 : u4Height - u4Half;
        rScaleParamV.u4YSrcW = u4I;
        rScaleParamV.u4YSrcH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CSrcW = u4I >> 1;
        rScaleParamV.u4CSrcH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CSrcBase = (UINT32)rVpInfo.pu1BackFrameAddr[1];
        rScaleParamV.u4CSrcHOffset = (u4Width - u4Half) >> 1;
        rScaleParamV.u4CSrcVOffset = (u4Height < u4Half) ?  0 : u4Height - u4Half;
        rScaleParamV.u4IsRsOut = 1;
        rScaleParamV.u4OutMode = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4IsVdo2Osd = 0;     
        rScaleParamV.u4YTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[0];       
        rScaleParamV.u4YTgCM = E_RZ_VDO_OUTMD_422;
        rScaleParamV.u4YTgBufLen = D_RZ_ALIGN16(rVpInfo.u4Width);
        rScaleParamV.u4YTgHOffset = u4Width - u4Half;
        rScaleParamV.u4YTgVOffset = (u4Height < u4Half) ?  0 : u4Height - u4Half;
        rScaleParamV.u4YTgW = u4I;
        rScaleParamV.u4YTgH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;
        rScaleParamV.u4CTgBase = (UINT32)rVpInfo.pu1CurFrameAddr[1];        
        rScaleParamV.u4CTgW = u4I >> 1;
        rScaleParamV.u4CTgH = (u4I > rVpInfo.u4Height) ? rVpInfo.u4Height : u4I;        
        rScaleParamV.u4SrcSwap = 0;    
        IMGRZ_Lock_Ex(E_FIRST_RESIZER);
        IMGRZ_ReInit_Ex(E_FIRST_RESIZER);
        IMGRZ_SetScaleOpt_Ex(E_FIRST_RESIZER, E_RZ_INOUT_TYPE_VDOMD);
        IMGRZ_Scale_Ex(E_FIRST_RESIZER, (void *)(&rScaleParamV));           
        IMGRZ_Flush_Ex(E_FIRST_RESIZER);
        IMGRZ_Wait_Ex(E_FIRST_RESIZER);
        IMGRZ_Unlock_Ex(E_FIRST_RESIZER);
    }
    return;
}

