/* 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$
 * $Date$
 * $RCSfile: fbm_pool_config.h,v $
 * $Revision$
 *
 *---------------------------------------------------------------------------*/

/** @file fbm_pool_if.h
 *  API of FBM (Frame Buffer Manager)
 *  Details of file fbm_pool_if.h.
 */

#ifndef FBM_POOL_IF_H
#define FBM_POOL_IF_H

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

#include "x_typedef.h"
#include "fbm_drvif.h"

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

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

#ifdef CC_MEM_TOOL
#define __KERNEL__
#endif

#ifdef __USERDRV__
#ifndef PAGE_SIZE
#define PAGE_SIZE	4096
#endif
#endif

#if defined(CC_MT5893) || defined(CC_MT5895)
#define FBM_PAGE_SIZE	0x10000 //mpu request address 64K align
#else
#define FBM_PAGE_SIZE	0x1000
#endif
//---------TNR---------- ???????
#if defined(CC_MT5893) || defined(CC_MT5895)
#define FBM_TNR_DEFINE_ADDR_ALIGMENT                  (0x8000 - 1)       // 32K
#elif 1
#define FBM_TNR_DEFINE_ADDR_ALIGMENT                  (0x2000 - 1)       // 8K
#endif
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_TNR_ADDR_ALIGMENT                   (((FBM_TNR_DEFINE_ADDR_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_TNR_DEFINE_ADDR_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_TNR_ADDR_ALIGMENT                   (32 - 1)
#endif
#define FBM_TNR_SIZE_ALIGMENT                  (0x4000 - 1)       // 8K

// -------- MDDI  --------

// MDDI Alignment
#if defined(CC_MT5893) || defined(CC_MT5895)
#define FBM_MDDI_ADDR_DEFINE_ALIGMENT                  (0x8000 - 1)       // 32K
#elif 1
#define FBM_MDDI_ADDR_DEFINE_ALIGMENT                  (0x2000 - 1)       // 8K
#endif
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MDDI_ADDR_ALIGMENT                   (((FBM_MDDI_ADDR_DEFINE_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_MDDI_ADDR_DEFINE_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_MDDI_ADDR_ALIGMENT                   (32 - 1)
#endif

#define FBM_MDDI_SIZE_ALIGMENT                  (0x4000 - 1)       // 8K

//Including RNR by multiply MV Flag by 3
#define FBM_MDDI_BI_FLAG_MV_SIZE(width, height)                     (((((((((width + 255) / 256) * 256) / 8 * height / 2) * 16 / 8) + 15) / 16) * 16) *3)
#define FBM_MDDI_BI_FLAG_LM_SIZE(width, height)                     ((((((((width + 255) / 256) * 256) / 8 * ((height / 2 + 3) / 4) * 4) * 16 / 8) + 15) / 16) * 16)

#define FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, height, yfld)          (((width + 255) / 256) * ((height / 2 * yfld + 7) / 8))
#define FBM_MDDI_BI_FLD_C422_MSB_SIZE(width, height, cfld)          (((width + 255) / 256) * ((height / 2 * cfld + 7) / 8))
#define FBM_MDDI_BI_FLD_C420_MSB_SIZE(width, height, cfld)          (((width + 255) / 256) * ((height / 2 * cfld / 2 + 7) / 8))

#if defined(CC_MT5398) || defined(CC_MT5399)||defined(CC_MT5890)||defined(CC_MT5891)|| defined(CC_MT5893)||defined(CC_MT5882)||defined(CC_MT5883)||defined(CC_MT5886) || defined(CC_MT5865)|| defined(CC_MT5863) || defined(CC_MT5895)
#define FBM_MDDI_BI_FLD_LUMA_LSB_SIZE(width, height, yfld)          (((width + 255) / 256) * ((height / 2 * yfld + 255) / 256 *8))
#define FBM_MDDI_BI_FLD_C422_LSB_SIZE(width, height, cfld)          (((width + 255) / 256) * ((height / 2 * cfld + 255) / 256 *8))
#define FBM_MDDI_BI_FLD_C420_LSB_SIZE(width, height, cfld)          (((width + 255) / 256) * ((height / 2 * cfld / 2 + 255) / 256 * 8))
#else
#define FBM_MDDI_BI_FLD_LUMA_LSB_SIZE(width, height, yfld)          (((width + 255) / 256) * ((height / 2 * yfld + 31) / 32))
#define FBM_MDDI_BI_FLD_C422_LSB_SIZE(width, height, cfld)          (((width + 255) / 256) * ((height / 2 * cfld + 31) / 32))
#define FBM_MDDI_BI_FLD_C420_LSB_SIZE(width, height, cfld)          (((width + 255) / 256) * ((height / 2 * cfld / 2 + 31) / 32))
#endif

//Main Progressive
#define FBM_MDDI_NR_10BIT_SIZE(width, height, fld)                  ((FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, (height)*2, fld)  \
                                                                    + FBM_MDDI_BI_FLD_LUMA_LSB_SIZE(width, (height)*2, fld)  \
                                                                    + FBM_MDDI_BI_FLD_C422_MSB_SIZE(width, (height)*2, fld)  \
                                                                    + FBM_MDDI_BI_FLD_C422_LSB_SIZE(width, (height)*2, fld)  \
                                                                    + 16) * 2048) 

#define FBM_MDDI_BI_NR_10BIT_SIZE(width, height, fld)               ( FBM_MDDI_NR_10BIT_SIZE(width, height, fld) \
                                                                    + FBM_MDDI_BI_FLAG_MV_SIZE(width, height*2))

#define FBM_MDDI_NR_8BIT_SIZE(width, height, fld)                   ((FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, (height)*2, fld)  \
                                                                    + FBM_MDDI_BI_FLD_C422_MSB_SIZE(width, (height)*2, fld)  \
                                                                    + 16) * 2048)

#define FBM_MDDI_BI_NR_8BIT_SIZE(width, height, fld)                ( FBM_MDDI_NR_8BIT_SIZE(width, height, fld)\
                                                                    + FBM_MDDI_BI_FLAG_MV_SIZE(width, height*2))


#define FBM_MDDI_NR_10BIT_420_SIZE(width, height, fld)              ((FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, (height)*2, fld)  \
                                                                    + FBM_MDDI_BI_FLD_LUMA_LSB_SIZE(width, (height)*2, fld)  \
                                                                    + FBM_MDDI_BI_FLD_C420_MSB_SIZE(width, (height)*2, fld)  \
                                                                    + FBM_MDDI_BI_FLD_C420_LSB_SIZE(width, (height)*2, fld)  \
                                                                    + 16) * 2048)


#define FBM_MDDI_BI_NR_10BIT_420_SIZE(width, height, fld)           (FBM_MDDI_NR_10BIT_420_SIZE(width, height, fld)\
                                                                    + FBM_MDDI_BI_FLAG_MV_SIZE(width, height*2))

#define FBM_MDDI_BI_NR_OFF_10BIT_420_SIZE(width, height, fld)       FBM_MDDI_NR_10BIT_420_SIZE(width, height, fld) 


#define FBM_MDDI_NR_8BIT_420_SIZE(width, height, fld)               ((FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, (height)*2, fld)  \
                                                                    + FBM_MDDI_BI_FLD_C420_MSB_SIZE(width, (height)*2, fld)  \
                                                                    + 16) * 2048)

#define FBM_MDDI_BI_NR_8BIT_420_SIZE(width, height, fld)            (FBM_MDDI_NR_8BIT_420_SIZE(width, height, fld)\
                                                                     + FBM_MDDI_BI_FLAG_MV_SIZE(width, height*2))
                                                                   
#define FBM_MDDI_BI_NR_OFF_8BIT_420_SIZE(width, height, fld)        FBM_MDDI_NR_8BIT_420_SIZE(width, height, fld)

#define FBM_MDDI_BI_NR_10BIT_444_SIZE(width, height, fld)           ((FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, (height)*2, fld)  \
                                                                    + FBM_MDDI_BI_FLD_LUMA_LSB_SIZE(width, (height)*2, fld)  \
                                                                    + (FBM_MDDI_BI_FLD_C422_MSB_SIZE(width, (height)*2, fld) * 2)  \
                                                                    + (FBM_MDDI_BI_FLD_C422_LSB_SIZE(width, (height)*2, fld) * 2)  \
                                                                    + 16) * 2048)

#define FBM_MDDI_BI_NR_8BIT_444_SIZE(width, height, fld)            ((FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, (height)*2, fld)  \
                                                                    + (FBM_MDDI_BI_FLD_C422_MSB_SIZE(width, (height)*2, fld) * 2)  \
                                                                    + 16) * 2048)

//Main Interlace
#define FBM_MDDI_8BIT_422_SIZE(width, height, yfld, cfld)           ((FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, height, yfld)  \
                                                                    + FBM_MDDI_BI_FLD_C422_MSB_SIZE(width, height, cfld) + 16) * 2048)

#define FBM_MDDI_BI_8BIT_422_SIZE(width, height, yfld, cfld)        ( FBM_MDDI_8BIT_422_SIZE(width, height, yfld, cfld)\
                                                                    + FBM_MDDI_BI_FLAG_MV_SIZE(width, height)\
                                                                    + FBM_MDDI_BI_FLAG_LM_SIZE(width, height))

#define FBM_MDDI_10BIT_422_SIZE(width, height, yfld, cfld)          ((FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, height, yfld)  \
                                                                    + FBM_MDDI_BI_FLD_LUMA_LSB_SIZE(width, height, yfld)  \
                                                                    + FBM_MDDI_BI_FLD_C422_MSB_SIZE(width, height, cfld)  \
                                                                    + FBM_MDDI_BI_FLD_C422_LSB_SIZE(width, height, cfld) + 16) * 2048)

#define FBM_MDDI_BI_10BIT_422_SIZE(width, height, yfld, cfld)       (FBM_MDDI_10BIT_422_SIZE(width, height, yfld, cfld)\
                                                                    + FBM_MDDI_BI_FLAG_MV_SIZE(width, height)\
                                                                    + FBM_MDDI_BI_FLAG_LM_SIZE(width, height))
                                                                    
#define FBM_MDDI_10BIT_420_SIZE(width, height, yfld, cfld)          ((FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, height, yfld)  \
                                                                    + FBM_MDDI_BI_FLD_LUMA_LSB_SIZE(width, height, yfld)  \
                                                                    + FBM_MDDI_BI_FLD_C420_MSB_SIZE(width, height, cfld)  \
                                                                    + FBM_MDDI_BI_FLD_C420_LSB_SIZE(width, height, cfld)  + 16) * 2048) 

#define FBM_MDDI_BI_10BIT_420_SIZE(width, height, yfld, cfld)       ( FBM_MDDI_10BIT_420_SIZE(width, height, yfld, cfld) \
                                                                    + FBM_MDDI_BI_FLAG_MV_SIZE(width, height)\
                                                                    + FBM_MDDI_BI_FLAG_LM_SIZE(width, height))

#define FBM_MDDI_8BIT_420_SIZE(width, height, yfld, cfld)           ((FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, height, yfld)  \
                                                                    + FBM_MDDI_BI_FLD_C420_MSB_SIZE(width, height, cfld) + 16) * 2048)

#define FBM_MDDI_BI_8BIT_420_SIZE(width, height, yfld, cfld)        ( FBM_MDDI_8BIT_420_SIZE(width, height, yfld, cfld) \
                                                                    + FBM_MDDI_BI_FLAG_MV_SIZE(width, height) \
                                                                    + FBM_MDDI_BI_FLAG_LM_SIZE(width, height))

// Sub Interlace
#define FBM_MDDI_SUB_BI_8BIT_422_SIZE(width, height, yfld, cfld)    ((FBM_MDDI_BI_FLD_LUMA_MSB_SIZE(width, height, yfld)  \
                                                                    + FBM_MDDI_BI_FLD_C422_MSB_SIZE(width, height, cfld)  \
                                                                    + 16) * 2048)

// -------- SCPOS --------

#define FBM_SCPOS_MSB_SIZE(width, height, fbNum)        (((width + 255) / 256) * ((height * fbNum + 7) / 8))
#define FBM_SCPOS_LSB_SIZE(width, height, fbNum)        (((width + 255) / 256) * ((height * fbNum + 255) / 256))
// 422/  8 bit/ 3 Frames
#define FBM_SCPOS_SIZE(width, height)           ((((((FBM_SCPOS_MSB_SIZE(width, height, 3)+7)/8)*8) * 2) + 8) * 2048)
// 422/ 10 bit/ 3 Frames
#define FBM_SCPOS_10BIT_SIZE(width, height)     ((((((FBM_SCPOS_MSB_SIZE(width, height, 3)+7)/8)*8) * 2) * 2048) + ((FBM_SCPOS_LSB_SIZE(width, height, 3) * 2) * 16384) + (8 * 2048)) 
// 422/  8 bit/ 2 Frames
#define FBM_SCPOS_2FB_SIZE(width, height)       ((((((FBM_SCPOS_MSB_SIZE(width, height, 2)+7)/8)*8) * 2) + 8) * 2048)
// 444/  8 bit/ 3 Frame
#define FBM_SCPOS_444_3FB_SIZE(width, height)   ((((((FBM_SCPOS_MSB_SIZE(width, height, 3)+7)/8)*8) * 3) + 12) * 2048)

#define FBM_SCPOS_8BIT_SIZE_FLIP(width, height, frame)           FBM_ALIGN_MASK( ((((((FBM_SCPOS_MSB_SIZE(width, height, frame)+7)/8)*8) * 2) + 8) * 2048), FBM_SCPOS_SIZE_ALIGMENT)
#define FBM_SCPOS_10BIT_SIZE_FLIP(width, height, frame)          FBM_ALIGN_MASK( ((((((FBM_SCPOS_MSB_SIZE(width, height, frame)+7)/8)*8) * 2) * 2048) + ((FBM_SCPOS_LSB_SIZE(width, height, frame) * 2) * 16384) + (8 * 2048)),   FBM_SCPOS_SIZE_ALIGMENT)
#define FBM_SCPOS_444_3FB_POOL_SIZE_FLIP(width, height, frame)   FBM_ALIGN_MASK( ((((((FBM_SCPOS_MSB_SIZE(width, height, frame)+7)/8)*8) * 3) + 12) * 2048), FBM_SCPOS_SIZE_ALIGMENT)
#define FBM_SCPOS_444_8BIT_POOL_SIZE_FLIP(width,height,frame)    FBM_ALIGN_MASK( ((((((FBM_SCPOS_MSB_SIZE(width, height, frame)+7)/8)*8) * 3) + 12) * 2048), FBM_SCPOS_SIZE_ALIGMENT)
#define FBM_SCPOS_444_10BIT_POOL_SIZE_FLIP(width,height,frame)   FBM_ALIGN_MASK( (((((((FBM_SCPOS_MSB_SIZE(width, height, frame)+7)/8)*8) * 3) + 12) * 2048) + ((FBM_SCPOS_LSB_SIZE(width, height, frame) * 3) * 16384) + (8 * 2048)), FBM_SCPOS_SIZE_ALIGMENT)

// SCPOS Pool Size Macro
#define FBM_SCPOS_POOL_SIZE(align, width, height)           FBM_ALIGN_MASK(FBM_SCPOS_SIZE(width, height), align)
#define FBM_SCPOS_10BIT_POOL_SIZE(align, width, height)     FBM_ALIGN_MASK(FBM_SCPOS_10BIT_SIZE(width, height), align)
#define FBM_SCPOS_2FB_POOL_SIZE(align, width, height)       FBM_ALIGN_MASK(FBM_SCPOS_2FB_SIZE(width, height), align)
#define FBM_SCPOS_444_3FB_POOL_SIZE(align, width, height)   FBM_ALIGN_MASK(FBM_SCPOS_444_3FB_SIZE(width, height), align)

// SCPOS Alignment
#define FBM_SCPOS_ADDR_DEFINE_ALIGMENT                 (0x20000 - 1)//128K  //(0x2000 - 1)       // 8K
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SCPOS_ADDR_ALIGMENT                   (((FBM_SCPOS_ADDR_DEFINE_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_SCPOS_ADDR_DEFINE_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_SCPOS_ADDR_ALIGMENT                   (32 - 1)
#endif
#define FBM_SCPOS_SIZE_ALIGMENT                 (0x20000 - 1)//128k  //(0x2000 - 1)

#define FBM_HDMI_SHM_ADDR_ALIGMENT                 (0x1000 - 1)
#ifdef CC_MT5895
#define FBM_HDMI_SHM_SIZE                          (0x4000)
#else
#define FBM_HDMI_SHM_SIZE                          (0x0)
#endif

#define FBM_SOUND_MODEL_ADDR_ALIGMENT                 (0x1000 - 1)
#define FBM_SOUND_MODEL_SIZE                          (0x19000)

// R2 buffer
#define FBM_MJC_R20_ADDR_ALIGMENT                     (0x1000 - 1)
#define FBM_MJC_R21_ADDR_ALIGMENT                     (0x1000 - 1)
#define FBM_LD_ADDR_ALIGMENT                          (0x1000 - 1)
#define FBM_3DLUT_ADDR_ALIGMENT                       (0x1000 - 1)
#define FBM_MJC_R20_SHM_ADDR_ALIGMENT                 (0x1000 - 1)

#define FBM_MJC_R20_SIZE                              (0x300000)
#define FBM_MJC_R21_SIZE                              (0x400000)
#define FBM_LD_SIZE                                   (0x400000)
#define FBM_3DLUT_SIZE                                (0x400000)
#define FBM_MJC_R20_SHM_SIZE                          (0x100000)

#define FBM_R2_TOTAL_SIZE                             (FBM_MJC_R20_SIZE+FBM_MJC_R21_SIZE+FBM_LD_SIZE+FBM_3DLUT_SIZE+FBM_MJC_R20_SHM_SIZE)

// -------- MJCALL -------- //for 3rd memc ip
// MJCALL Alignment
#define FBM_MJCALL_ADDR_ALIGMENT                     (0x1000 - 1)
#define FBM_MJCALL_SIZE_ALIGMENT                     (0x1000 - 1)

// -------- MJC --------
// MJC Alignment
#define FBM_MJC_ADDR_DEFINE_ALIGMENT                     (0x1000 - 1)     //((rpt444)? 63 : ((chanelA)? (0x1000 - 1) : (0x800 - 1))) // repeat mode 64byte,mjc mode chanel A 4k chanel B 2k
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MJC_ADDR_ALIGMENT                   (((FBM_MJC_ADDR_DEFINE_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_MJC_ADDR_DEFINE_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_MJC_ADDR_ALIGMENT                   (32 - 1)
#endif
#define FBM_MJC_SIZE_ALIGMENT                             63 // 64bytw

#define FBM_MJC_HEIGHT_BASE(height)                       (FBM_ALIGN_MASK(height, 7) >> 3)
#define FBM_MJC_HEIGHT_YC_BASE(rpt444, height, dramCfg)   ((dramCfg & (FBM_MJC_DRAM_OSMP_FPR | FBM_MJC_DRAM_3D_HPR))? (rpt444 ? (height >> 1) : FBM_ALIGN_MASK((height >> 1), 7)) : height)       
#define FBM_MJC_WIDTH_YC_BASE(width)                       FBM_ALIGN_MASK(width, 15)

#define FBM_MJC_YC_FLD_BASE(chanelA, y8c8)                (((y8c8)? 8 : 6) << (chanelA))                                            
#define FBM_MJC_YC_SIZE(chanelA, y8c8, rpt444, bufNum, width ,height, dramCfg)                                                                                                                                                    \
                                                         (bufNum * ((FBM_ALIGN_MASK(((FBM_ALIGN_MASK(FBM_MJC_WIDTH_YC_BASE(width), 63) >> 6) * FBM_MJC_HEIGHT_BASE(FBM_MJC_HEIGHT_YC_BASE(rpt444, height, dramCfg))),          \
                                                          (FBM_MJC_YC_FLD_BASE(chanelA, y8c8) - 1))) / FBM_MJC_YC_FLD_BASE(chanelA, y8c8)) << 2 << 7 << (chanelA))

#define FBM_FRC_FULLQMBNUM(width)                        ((FBM_MJC_WIDTH_YC_BASE(width) >> 4) >> 2)
#define FBM_FRC_FULLQMBMBNUM(width)                      ((FBM_MJC_WIDTH_YC_BASE(width) >> 4) % 4)
#define FBM_FRC_BIT_NUM(y8c8, rpt422)                    ((y8c8)? 0 : ((rpt422)?  2 : 3))
#define FBM_FRC_YC_SIZE(chanelA, y8c8, rpt444, rpt422, bufNum, width , height, dramCfg)                                                                                                                                           \
                                                        (bufNum * FBM_MJC_HEIGHT_YC_BASE(rpt444, height, dramCfg) * FBM_ALIGN_MASK(((FBM_FRC_FULLQMBNUM(width) * (((rpt422)? 8 : 12) + FBM_FRC_BIT_NUM(y8c8, rpt422))) +      \
                                                         (((FBM_FRC_FULLQMBMBNUM(width) != 0)? 1 : 0) * (((rpt422)? FBM_FRC_FULLQMBMBNUM(width) * 2 : FBM_FRC_FULLQMBMBNUM(width) * 3) + FBM_FRC_BIT_NUM(y8c8, rpt422)))), 3))                                        

#define FBM_MJC_OSD_SIZE(width ,height)                 (FBM_ALIGN_MASK((FBM_ALIGN_MASK(width, 7) >> 2), 63) * FBM_MJC_HEIGHT_BASE(height)) 
#define FBM_MJC_MV_SIZE(width ,height)                  (FBM_ALIGN_MASK((FBM_ALIGN_MASK(width, 7) >> 2), 63) * FBM_MJC_HEIGHT_BASE(height) * 5)
#define FBM_MJC_TBA_SIZE(width ,height)                 (FBM_ALIGN_MASK((FBM_ALIGN_MASK(width, 7) >> 3), 63) * FBM_MJC_HEIGHT_BASE(height))

#define FBM_MJC_MEMC_SIZE(rpt444, width ,height)        ((rpt444)? 0 : ((FBM_MJC_OSD_SIZE(width ,height) << 1) + (FBM_MJC_MV_SIZE(width ,height) << 1) + (FBM_MJC_TBA_SIZE(width ,height) << 1)))
#define FBM_MJC_POOL_SIZE(chanelA, y8c8, rpt444, rpt422, bufNum, width ,height, dramCfg)                                                                                                                                           \
                                                        ((((((rpt444)? FBM_FRC_YC_SIZE(chanelA, y8c8, rpt444, rpt422, bufNum, width, height, dramCfg) : FBM_MJC_YC_SIZE(chanelA, y8c8, rpt444, bufNum, width , height, dramCfg))\
                                                         << ((dramCfg & FBM_MJC_DRAM_OSMP_FPR)? 2 : ((dramCfg & (FBM_MJC_DRAM_3D_SG | FBM_MJC_DRAM_3D_HPR))? 1 : 0))) << 4) + FBM_MJC_MEMC_SIZE(rpt444, width ,height)) + 0x1000)

#define FBM_MJC_WIDTH                                   (1920)   
#define FBM_MJC_HEIGHT                                  (1080)  //if is l2r2 pdp(1920 * 2160) panel setting height = 2160 / 2 = 1080;

#define FBM_MJC_8BIT_422_CHB_POOL_SIZE                  FBM_MJC_POOL_SIZE(0, 1, 0, 0, 9, FBM_ALIGN_MASK(FBM_MJC_WIDTH, 15), FBM_ALIGN_MASK(FBM_MJC_HEIGHT, 7), FBM_MJC_DRAM_3D_CFG)   // Only  MJC_Y08_C08 case ;and 420 is same size as 422
#define FBM_MJC_8BIT_422_CHA_POOL_SIZE                  FBM_MJC_POOL_SIZE(1, 1, 0, 0, 9, FBM_ALIGN_MASK(FBM_MJC_WIDTH, 15), FBM_ALIGN_MASK(FBM_MJC_HEIGHT, 7), FBM_MJC_DRAM_3D_CFG)
#define FBM_MJC_10BIT_422_CHB_POOL_SIZE                 FBM_MJC_POOL_SIZE(0, 0, 0, 0, 9, FBM_ALIGN_MASK(FBM_MJC_WIDTH, 15), FBM_ALIGN_MASK(FBM_MJC_HEIGHT, 7), FBM_MJC_DRAM_3D_CFG)   // Not  MJC_Y08_C08 case ;and 420 is same size as 422
#define FBM_MJC_10BIT_422_CHA_POOL_SIZE                 FBM_MJC_POOL_SIZE(1, 0, 0, 0, 9, FBM_ALIGN_MASK(FBM_MJC_WIDTH, 15), FBM_ALIGN_MASK(FBM_MJC_HEIGHT, 7), FBM_MJC_DRAM_3D_CFG)
#define FBM_FRC_8BIT_444_CHA_POOL_SIZE                  FBM_MJC_POOL_SIZE(1, 1, 1, 0, 3, FBM_ALIGN_MASK(FBM_MJC_WIDTH, 15), FBM_ALIGN_MASK(FBM_MJC_HEIGHT, 7), FBM_MJC_DRAM_3D_CFG)
#define FBM_FRC_10BIT_444_CHA_POOL_SIZE                 FBM_MJC_POOL_SIZE(1, 0, 1, 0, 3, FBM_ALIGN_MASK(FBM_MJC_WIDTH, 15), FBM_ALIGN_MASK(FBM_MJC_HEIGHT, 7), FBM_MJC_DRAM_3D_CFG)
#define FBM_FRC_10BIT_444_CHB_POOL_SIZE                 FBM_MJC_POOL_SIZE(0, 0, 1, 0, 3, FBM_ALIGN_MASK(FBM_MJC_WIDTH, 15), FBM_ALIGN_MASK(FBM_MJC_HEIGHT, 7), FBM_MJC_DRAM_3D_CFG)
#define FBM_FRC_8BIT_422_CHA_POOL_SIZE                  FBM_MJC_POOL_SIZE(1, 1, 1, 1, 3, FBM_ALIGN_MASK(FBM_MJC_WIDTH, 15), FBM_ALIGN_MASK(FBM_MJC_HEIGHT, 7), FBM_MJC_DRAM_3D_CFG)
#define FBM_FRC_10BIT_422_CHA_POOL_SIZE                 FBM_MJC_POOL_SIZE(1, 0, 1, 1, 3, FBM_ALIGN_MASK(FBM_MJC_WIDTH, 15), FBM_ALIGN_MASK(FBM_MJC_HEIGHT, 7), FBM_MJC_DRAM_3D_CFG)
#define FBM_FRC_10BIT_422_CHB_POOL_SIZE                 FBM_MJC_POOL_SIZE(0, 0, 1, 1, 3, FBM_ALIGN_MASK(FBM_MJC_WIDTH, 15), FBM_ALIGN_MASK(FBM_MJC_HEIGHT, 7), FBM_MJC_DRAM_3D_CFG)

// -------- TDC --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_TDC_ADDR_ALIGMENT                   (FBM_PAGE_SIZE - 1)
#else
#define FBM_TDC_ADDR_ALIGMENT                   (2048 - 1)
#endif

#define FBM_TDC_SIZE_ALIGMENT                   (32 - 1)
#define FBM_TDC_SIZE                            0x2BFE90//0x2B4C10 // [10-bit] // 0x251ca0 [9-bit]
#define FBM_TDC_8BIT_SIZE                       0x251ca0
#define FBM_TDC_POOL_SIZE                       FBM_ALIGN_MASK((FBM_TDC_SIZE), FBM_TDC_SIZE_ALIGMENT)
#define FBM_TDC_8BIT_POOL_SIZE                  FBM_ALIGN_MASK((FBM_TDC_8BIT_SIZE), FBM_TDC_SIZE_ALIGMENT)

// -------- NR --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_NR_ADDR_ALIGMENT                    (FBM_PAGE_SIZE - 1)
#else
#define FBM_NR_ADDR_ALIGMENT                    31
#endif
#define FBM_NR_SIZE_ALIGMENT                    31

// -------- VBI --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_VBI_ADDR_ALIGMENT                   (FBM_PAGE_SIZE - 1)
#else
#define FBM_VBI_ADDR_ALIGMENT                   (16 - 1)
#endif
#define FBM_VBI_SIZE_ALIGMENT                   0
#define FBM_VBI_SIZE                            (0x17700 + 0xC00 + 0x10)  //=0x18310
#define FBM_VBI_POOL_SIZE                       FBM_ALIGN_MASK((FBM_VBI_SIZE), FBM_VBI_SIZE_ALIGMENT)

// -------- MPEG  --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MPEG_ADDR_ALIGMENT                  (((FBM_FMG_Y_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_FMG_Y_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_MPEG_ADDR_ALIGMENT                  FBM_FMG_Y_ALIGMENT
#endif
#define FBM_MPEG_POOL_PAD                       (1920 * 32)
#define FBM_MPEG_720P_POOL_PAD                  (1280 * 32)
#define FBM_MPEG_SD_POOL_PAD                    (720 * 32)

#define FBM_JPE_VDP_SIZE                        (0x1000000)
#define FBM_JPG_VDP_ADDR_ALIGMENT               (FBM_PAGE_SIZE - 1)
#define FBM_JPE_VDP_POOL_SIZE                   FBM_ALIGN_MASK((FBM_JPE_VDP_SIZE), FBM_JPG_VDP_ADDR_ALIGMENT)

// -------- DIVX  --------
#define FBM_DIVX_HD_SIZE                        (0x600000)
#define FBM_DIVX_SIZE_ALIGMENT                   0
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_DIVX_ADDR_ALIGMENT               (FBM_PAGE_SIZE - 1)
#else
#define FBM_DIVX_ADDR_ALIGMENT               (16 - 1)
#endif
#define FBM_DIVX_POOL_SIZE                   FBM_ALIGN_MASK((FBM_DIVX_HD_SIZE), FBM_DIVX_SIZE_ALIGMENT)

// -------- DSP.bin --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_DSP_BIN_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_DSP_BIN_ADDR_ALIGMENT                  (0x40- 1)
#endif
#define FBM_DSP_BIN_SIZE_ALIGMENT                  (0x40- 1)

// -------- DSP  --------
//#define FBM_DSP_ADDR_ALIGMENT                   (0x1000000-1) // (256 - 1)
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_DSP_ADDR_ALIGMENT                   (FBM_PAGE_SIZE - 1)
#else
#define FBM_DSP_ADDR_ALIGMENT                   (1024 - 1)
#endif
#define FBM_DSP_SIZE_ALIGMENT                   0

// new dual DSP case
#ifdef CC_AUD_ARM_RENDER
#define FBM_APROC_IO_BUFFER_SZ 0x24000*4
#define FBM_APROC_IO_NEW_RAW_BUFFER_SZ 0x24000*4
#else
#define FBM_APROC_IO_BUFFER_SZ 0
#define FBM_APROC_IO_NEW_RAW_BUFFER_SZ 0
#endif

#ifdef CC_AUD_DISABLE_2ND_DSP
#ifdef CC_MT5883
#define FBM_AUD_BASE                         (0x421C00+0x000000+0x19000+FBM_APROC_IO_BUFFER_SZ+FBM_APROC_IO_NEW_RAW_BUFFER_SZ)    // 4231 kB + 0KB + 576kB (DSP0+DSP1+Arpoc_io)+576kB
#else
#define FBM_AUD_BASE                         (0x421C00+0x000000+FBM_APROC_IO_BUFFER_SZ+FBM_APROC_IO_NEW_RAW_BUFFER_SZ) 
#endif
#ifdef CC_C4TV_SUPPORT
#define FBM_AUD_AFIFO_DSP0               0x90000     // 576 kb
#else
#define FBM_AUD_AFIFO_DSP0               0x48000     // 288 kb
#endif
#define FBM_AUD_AFIFO_DSP1               0x00000     // 039 kb
#ifdef __MODEL_slt__
#define FBM_AUD_AFIFO2_DSP0             0xf0000     // 960 kb
#define FBM_AUD_AFIFO2_DSP1             0x00000     // 960 kb
#else
#ifdef CC_AUD_DOLBY_SUPPORT_MS12
#define FBM_AUD_AFIFO2_DSP0             0x48000     // 288 kb
#else
#define FBM_AUD_AFIFO2_DSP0             0x48000     // 288 kb
#endif // CC_AUD_DOLBY_SUPPORT_MS12
#define FBM_AUD_AFIFO2_DSP1             0x00000     // 039 kb
#endif // __MODEL_slt__
#else
#define FBM_AUD_BASE                         (0x421C00+0x2A7000+FBM_APROC_IO_BUFFER_SZ+FBM_APROC_IO_NEW_RAW_BUFFER_SZ)    // 4231 kB + 2716KB + 576B (DSP0+DSP1+Arpoc_io)+576kB
#ifdef CC_C4TV_SUPPORT
#define FBM_AUD_AFIFO_DSP0               0x90000     // 576 kb
#else
#define FBM_AUD_AFIFO_DSP0               0x48000     // 288 kb
#endif
#define FBM_AUD_AFIFO_DSP1               0x09C00     // 039 kb
#ifdef __MODEL_slt__
#define FBM_AUD_AFIFO2_DSP0             0xf0000     // 960 kb
#define FBM_AUD_AFIFO2_DSP1             0xf0000     // 960 kb
#else
#ifdef CC_AUD_DOLBY_SUPPORT_MS12
#define FBM_AUD_AFIFO2_DSP0             0x48000     // 288 kb
#else
#define FBM_AUD_AFIFO2_DSP0             0x21C00     // 135 kb
#endif // CC_AUD_DOLBY_SUPPORT_MS12
#define FBM_AUD_AFIFO2_DSP1             0x09C00     // 039 kb
#endif
#endif // end CC_AUD_DISABLE_2ND_DSP
#ifdef CC_AUD_DOLBY_SUPPORT_MS12
#define FBM_AUD_AFIFO3_DSP0             0x40000     // 256 kb
#else
#define FBM_AUD_AFIFO3_DSP0             0x09C00     // 039 kb
#endif // CC_AUD_DOLBY_SUPPORT_MS12
#define FBM_AUD_AFIFO3_DSP1             0x00000     // 000 kb
#define FBM_AUD_AFIFO4_DSP0             0x42000     // 264 kb
#define FBM_AUD_AFIFO4_DSP1             0x00000     // 000 kb
#ifdef CC_AUD_HDMI_PARSER_2_0_SUPPORT
#define FBM_AUD_HDMI_PARSER                 0x60000     // 126 kb
#else
#define FBM_AUD_HDMI_PARSER                 0x0         // 0 kb
#endif
#if defined(CC_AUD_DDI) || defined(CC_AUD_SUPPORT_NEW_TUNNEL_MODE)
#define FBM_AUD_MIXSNDBUF                   0x60000//384k
#else
#define FBM_AUD_MIXSNDBUF                   0x58000     // 352 kb
#endif
#if defined(CC_AUD_ARM_SUPPORT)
 #if defined (CC_AUD_DISABLE_2ND_DSP) && defined (CC_AUD_ENLARGE_APROC_DRAM)
   #if defined (CC_AUD_DOLBY_SUPPORT_MS12B) || defined (CC_AUD_CPU_DEC)
#define FBM_AUD_APROC_WORKSPACE              (0x8EC000) // enlarge for MS12 libraries (~16MB total) //CPU decode need 0x842200
	 #else	 
     #ifdef CC_AUD_DOLBY_SUPPORT_MS12
#define FBM_AUD_APROC_WORKSPACE              (0x780000)    // 7.5MB, for MS12 libraries
   #else
#define FBM_AUD_APROC_WORKSPACE              (0x300000+0x2A3000)  // 3MB + 2.6MB(from 2nd DSP)
   #endif // CC_AUD_DOLBY_SUPPORT_MS12
   #endif // CC_AUD_DOLBY_SUPPORT_MS12B
 #else
   #if defined (CC_AUD_DOLBY_SUPPORT_MS12B) || defined (CC_AUD_CPU_DEC)
#define FBM_AUD_APROC_WORKSPACE              (0x8EC000) // enlarge for MS12 libraries (~16MB total) //CPU decode need 0x842200
	 #else
     #ifdef CC_AUD_DOLBY_SUPPORT_MS12
#define FBM_AUD_APROC_WORKSPACE              (0x780000)    // 7.5MB, for MS12 libraries
   #else
#define FBM_AUD_APROC_WORKSPACE              (0x300000+0x1F0000)    // 3MB + 1.5MB
   #endif // CC_AUD_DOLBY_SUPPORT_MS12
   #endif // CC_AUD_DOLBY_SUPPORT_MS12B
 #endif
#else
#define FBM_AUD_APROC_WORKSPACE              0x40000    // 256 kb
#endif // CC_AUD_ARM_SUPPORT
#define FBM_DSP_SIZE    (FBM_AUD_BASE+FBM_AUD_AFIFO_DSP0+FBM_AUD_AFIFO2_DSP0+FBM_AUD_AFIFO3_DSP0+  \
                        +FBM_AUD_AFIFO_DSP1+FBM_AUD_AFIFO2_DSP1+FBM_AUD_AFIFO3_DSP1+FBM_AUD_AFIFO4_DSP1+ \
                         FBM_AUD_AFIFO4_DSP0+FBM_AUD_HDMI_PARSER+FBM_AUD_MIXSNDBUF+ \
                         FBM_AUD_APROC_WORKSPACE)

#define FBM_DSP_POOL_SIZE                       FBM_ALIGN_MASK((FBM_DSP_SIZE), FBM_DSP_SIZE_ALIGMENT)


// -------- DMX  --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_DMX_ADDR_ALIGMENT                   (FBM_PAGE_SIZE - 1)
#else
#define FBM_DMX_ADDR_ALIGMENT                   (64 - 1)
#endif
#define FBM_DMX_SIZE_ALIGMENT                   (64 - 1)

// -------- W2D R2R  --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_W2D_R2R_ADDR_ALIGMENT                   (FBM_PAGE_SIZE - 1)
#else
#define FBM_W2D_R2R_ADDR_ALIGMENT                   (64 - 1)
#endif
#define FBM_W2D_R2R_SIZE_ALIGMENT                   (64 - 1)

#define FBM_GFX_ADDR_ALIGMENT                   (FBM_PAGE_SIZE - 1)
#define FBM_GFX_SIZE_ALIGMENT                   (64 - 1)

#define FBM_DMX_5381_FHD_SIZE                   0x280000
#define FBM_DMX_5371_SIZE                       0x180000
#define FBM_DMX_5380_16MB_SIZE                  0x100000
#define FBM_DMX_DVBT_SIZE                       0xC0000
#define FBM_DMX_POOL_SIZE                       FBM_ALIGN_MASK((FBM_DMX_SIZE), FBM_DMX_SIZE_ALIGMENT)


// -------- B2R  --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_B2R_ADDR_ALIGMENT                     (FBM_PAGE_SIZE - 1)
#else
#define FBM_B2R_ADDR_ALIGMENT                     (64 - 1)
#endif
#define FBM_B2R_SIZE_ALIGMENT                     0
#define FBM_B2R_POOL_SIZE(width, height, ns, bpp)   FBM_ALIGN_MASK(((((width * height) * bpp) + (FBM_B2R_ADDR_ALIGMENT + 1)) * ns), FBM_B2R_SIZE_ALIGMENT)
#define FBM_B2R_420_POOL_SIZE(width, height, ns)    FBM_ALIGN_MASK((((((width * height) * 3) / 2) + (FBM_B2R_ADDR_ALIGMENT + 1)) * ns), FBM_B2R_SIZE_ALIGMENT)

// -------- JPEG  --------
#if defined(__KERNEL__) || defined(__USERDRV__)
#define FBM_JPEG_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#define FBM_JPEG_SIZE_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_JPEG_ADDR_ALIGMENT                  (256 - 1)
#define FBM_JPEG_SIZE_ALIGMENT                  0
#endif

#ifdef CC_OSD_USE_FBM
#ifdef CC_53XX_JPG_ARGB4444
#define FBM_JPEG_POOL_SIZE                      (0xc00000)	//(1920*1080*4)
#define FBM_JPEG_POOL_SIZE_EXT                      (0xc00000)
#else
#ifdef __MODEL_slt__
#define FBM_JPEG_POOL_SIZE                      (0x1000000)
#define FBM_JPEG_POOL_SIZE_EXT                  (0x1000000)
#else
#if defined(CC_SUPPORT_PHOTO8K)||defined(CC_MT5895)
#define FBM_JPEG_POOL_SIZE                      (0xf00000)
#else
#define FBM_JPEG_POOL_SIZE                      (0x800000)	//(1920*1080*4)
#endif
#define FBM_JPEG_POOL_SIZE_EXT                  (0x800000)
#endif
#endif
#else
#define FBM_JPEG_POOL_SIZE                      (1920*1080*6)
#define FBM_JPEG_POOL_SIZE_EXT                  (1920*1080*6)
#endif

// -------- DRM --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_DRM_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_DRM_ADDR_ALIGMENT                  (32-1)
#endif
#define FBM_DRM_SIZE_ALIGMENT                  (32-1)


// -------- MUXER--------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MUXER_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_MUXER_ADDR_ALIGMENT                  (32-1)
#endif
#define FBM_MUXER_SIZE_ALIGMENT                  (32-1)

// -------- SUBTITLE--------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SUBTITLE_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SUBTITLE_ADDR_ALIGMENT                  (32-1)
#endif
#define FBM_SUBTITLE_SIZE_ALIGMENT                  (32-1)

// -------- secure_feeder--------
#define FBM_SECURE_FEEDER_DEFINE_ADDR_ALIGMENT               (0x8000 -1)
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SECURE_FEEDER_ADDR_ALIGMENT                  (((FBM_SECURE_FEEDER_DEFINE_ADDR_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_SECURE_FEEDER_DEFINE_ADDR_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_SECURE_FEEDER_ADDR_ALIGMENT                  (32-1)
#endif
#define FBM_SECURE_FEEDER_SIZE_ALIGMENT                  (32-1)


// -------- DMXPID --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_DMXPID_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_DMXPID_ADDR_ALIGMENT                  (64-1)
#endif
#define FBM_DMXPID_SIZE_ALIGMENT                  (64-1)
#define FBM_DMXPID_POOL_SIZE                      (FBM_DMX_PID_BUF)
#if defined(__KERNEL__) || defined(__USERDRV__)
#define FBM_PNG_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#define FBM_PNG_SIZE_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_PNG_ADDR_ALIGMENT                  (256 - 1)
#define FBM_PNG_SIZE_ALIGMENT                  0
#endif

// -------- PQ_PSCAN --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_PQ_PSCAN_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_PQ_PSCAN_ADDR_ALIGMENT                  (64-1)
#endif
#define FBM_PQ_PSCAN_SIZE_ALIGMENT                  (64-1)
#define FBM_PQ_PSCAN_POOL_SIZE                      (0x300000)

// -------- IMGRZ_3D_KR --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_IMGRZ_3D_KR_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_IMGRZ_3D_KR_ADDR_ALIGMENT                  (64-1)
#endif
#define FBM_IMGRZ_3D_KR_SIZE_ALIGMENT                  (64-1)
#define FBM_IMGRZ_3D_KR_POOL_SIZE                      (0x600000)

// -------- OSD  --------
#if defined(__KERNEL__) || defined(__USERDRV__)
#define FBM_OSD_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#define FBM_OSD_SIZE_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_OSD_ADDR_ALIGMENT                  (16 - 1)
#define FBM_OSD_SIZE_ALIGMENT                  0
#endif

#define FBM_OSD_POOL_SIZE(width, height, ns, bpp)   FBM_ALIGN_MASK(((((width * height) * bpp) + (FBM_OSD_ADDR_ALIGMENT + 1)) * ns), FBM_OSD_SIZE_ALIGMENT)

// -------- Feeder  --------
#if defined(__KERNEL__) || defined(__USERDRV__)
#define FBM_FEEDER_ADDR_DEFINE_ALIGMENT               (0x1000- 1)
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_FEEDER_ADDR_ALIGMENT                   (((FBM_FEEDER_ADDR_DEFINE_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_FEEDER_ADDR_DEFINE_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_FEEDER_ADDR_ALIGMENT                   (32 - 1)
#endif
#define FBM_FEEDER_SIZE_ALIGMENT               (0x1000- 1)
#else
#define FBM_FEEDER_ADDR_ALIGMENT               (16 - 1)
#define FBM_FEEDER_SIZE_ALIGMENT               0
#endif

#define FBM_FEEDER_4K_POOL_SIZE                FBM_ALIGN_MASK(0x800000, FBM_FEEDER_SIZE_ALIGMENT) //0x800000
#if defined(CC_MT5891)|| defined(CC_MT5893)||defined(CC_MT5886) || defined(CC_MT5895)
#define FBM_FEEDER_POOL_SIZE                   FBM_ALIGN_MASK(0x800000, FBM_FEEDER_SIZE_ALIGMENT)
#else
#define FBM_FEEDER_POOL_SIZE                   FBM_ALIGN_MASK(0x300000, FBM_FEEDER_SIZE_ALIGMENT)
#endif
#define FBM_FEEDER_MMP_POOL_SIZE               FBM_ALIGN_MASK(0x90000, FBM_FEEDER_SIZE_ALIGMENT)

#define FBM_TVE_ADDR_DEFINE_ALIGMENT                 (0x2000 - 1)
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_TVE_ADDR_ALIGMENT                   (((FBM_TVE_ADDR_DEFINE_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_TVE_ADDR_DEFINE_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_TVE_ADDR_ALIGMENT                   (32 - 1)
#endif
#define FBM_TVE_SIZE_ALIGMENT                 (0x2000 - 1)
#ifdef CC_FLIP_MIRROR_SUPPORT
#if defined(CC_MT5399)||defined(CC_MT5890)||defined(CC_MT5882)||defined(CC_MT5883)||defined(CC_MT5891)|| defined(CC_MT5893)||defined(CC_MT5886) || defined(CC_MT5863) || defined(CC_MT5895) //422 10bit 3 frame buffer
#define FBM_TVE_POOL_SIZE                      FBM_ALIGN_MASK(FBM_TVE_POOL_FBM_SIZE, FBM_TVE_SIZE_ALIGMENT)
#else
#define FBM_TVE_POOL_SIZE                      FBM_ALIGN_MASK(0x580000, FBM_TVE_SIZE_ALIGMENT)
#endif
#else
#if defined(CC_MT5399) ||defined(CC_MT5890)||defined(CC_MT5882)||defined(CC_MT5883)||defined(CC_MT5891)|| defined(CC_MT5893)||defined(CC_MT5886) || defined(CC_MT5863) || defined(CC_MT5895) //422 10bit 2 frame buffer
#define FBM_TVE_POOL_SIZE                      FBM_ALIGN_MASK(FBM_TVE_POOL_FBM_SIZE, FBM_TVE_SIZE_ALIGMENT)
#else
#define FBM_TVE_POOL_SIZE                      FBM_ALIGN_MASK(0x400000, FBM_TVE_SIZE_ALIGMENT)
#endif
#endif
// -------- PQ TOOL  --------
//#define FBM_PQ_TOOL_POOL_SIZE                    (0x800000)   // OD full dump need extra buffer 8MB
#ifdef CC_CDC_SUPPORT
#define FBM_PQ_TOOL_POOL_SIZE                      (0x1800000)    // OD partical dump (max: 1920*64)
#define FBM_PQ_TOOL_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#elif defined(CC_PQ_TOOL_8M)
#define FBM_PQ_TOOL_POOL_SIZE                    (0x800000)   //LG // OD full dump need extra buffer 8MB
#define FBM_PQ_TOOL_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_PQ_TOOL_POOL_SIZE                      (0x80000)    // OD partical dump (max: 1920*64)
#define FBM_PQ_TOOL_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif
#define FBM_PQ_TOOL_SIZE_ALIGMENT                  0

// -------- OD --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_OD_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_OD_ADDR_ALIGMENT                  (0x40- 1)
#endif
#define FBM_OD_SIZE_ALIGMENT                  (0x40- 1)
#define FBM_OD_POOL_SIZE                      (540*248*16)//(1920*1080)

// -------- VENC --------
#if defined(__KERNEL__) || defined(__USERDRV__)
#define FBM_VENC_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#define FBM_VENC_SIZE_ALIGMENT                  (FBM_PAGE_SIZE- 1)
#else
#define FBM_VENC_ADDR_ALIGMENT                  (2048- 1)
#define FBM_VENC_SIZE_ALIGMENT                  (2048- 1)
#endif

#if defined(CC_SUPPORT_VENC)
  #if (defined(CC_MT5399) ||defined(CC_MT5890)||defined(CC_MT5882)||defined(CC_MT5883)||defined(CC_MT5891) || defined(CC_MT5863))
    #if !defined(CC_VENC_RES_720P)
    #define FBM_VENC_POOL_SIZE                      (0x1F00000)
    #else
    #define FBM_VENC_POOL_SIZE                      (0xE00000)
    #endif
  #elif defined(CC_MT5886) || defined(CC_MT5893) || defined(CC_MT5895)
    #if !defined(CC_VENC_RES_720P)
    #define FBM_VENC_POOL_SIZE						(0x1700000)
    #else
    #define FBM_VENC_POOL_SIZE						(0xA00000)//(0xB00000)
    #endif
  #else
    #if !defined(CC_VENC_RES_720P)
    #define FBM_VENC_POOL_SIZE                      (0x1F00000)
    #else
    #define FBM_VENC_POOL_SIZE                      (0xE00000)
    #endif
  #endif
#else
  #define FBM_VENC_POOL_SIZE                      (0x0)
#endif
// -------- SWDMX --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SWDMX_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SWDMX_ADDR_ALIGMENT                  (16- 1)
#endif
#define FBM_SWDMX_SIZE_ALIGMENT                  (16- 1)
#define FBM_SWDMX_POOL_SIZE                      FBM_SWDMX_SIZE
// -------- VSS --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_VSS_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
//#define FBM_VSS_ADDR_ALIGMENT                  (16- 1)
//VSS always align 4k
#define FBM_VSS_ADDR_ALIGMENT                  (0x1000 - 1)
#endif
#define FBM_VSS_SIZE_ALIGMENT                  (16- 1)
#if defined(CC_MT5886)
#ifdef  CC_SUPPORT_VSS_422_MODE
#define FBM_VSS_POOL_SIZE                      (0x7F0000)
#else
#define FBM_VSS_POOL_SIZE                      (0xFD2000)
#endif
#else
#define FBM_VSS_POOL_SIZE                      (0xFD2000)
#endif

#if defined(CC_MT5886) || defined(CC_MT5893) || defined(CC_MT5895)//only for 5886/5893
#if !defined(CC_BYPASS_MJC)||defined(CC_FBM_DYNMJC)
#define FBM_POOL_MJC1_SIZE                      (0x1E00000) // 30M
#define FBM_POOL_MJC2_SIZE                      (0x1E00000) // 30M
#define FBM_POOL_MJC3_SIZE                      (0x1E00000) // 30M
#define FBM_POOL_MJC1_C_SIZE                    (0xEE0000+0x100000) // 14.83M
#define FBM_POOL_MJC2_C_SIZE                    (0xEE0000+0x100000) // 14.83M
#define FBM_POOL_MJC3_C_SIZE                    (0xEE0000+0x100000) // 14.83M
#define FBM_POOL_MJCMV_SIZE                     (0x70000) // 0.4M
// for capy
#define MEMC_FRAMES                             18 // 7
#define IPM_BUFFER_SIZE                         (4096*2160*MEMC_FRAMES*3/2)
#define IPM_MEDS_BUFFER_SIZE                    (((2048*1080*MEMC_FRAMES*3/4)+0x1f)&0xffffffe0) // 128bit alignment
#define X1_S1_MERGE_BUFFER_SIZE					(0x000918C3) 
#define X2_Y2_F2_S2_MERGE_BUFFER_SIZE           (0x005AF786)
#define LOGO_BUFFER_SIZE                        (0x0016BDE2)
#define HR_BUFFER_SIZE                          (0x002F7600)
#define HR23_BUFFER_SIZE                        (0x0017BB00)
#define DEFLICKER_BUFFER_SIZE                   (0x000BDD80)
#define OSDYS_BUFFER_SIZE                       (0x00048000)
#define MJC_DELAY_SIZE                          (0x022D0000)
#define FBM_MJCALL_SIZE                         (IPM_BUFFER_SIZE+IPM_MEDS_BUFFER_SIZE+X1_S1_MERGE_BUFFER_SIZE+X2_Y2_F2_S2_MERGE_BUFFER_SIZE+LOGO_BUFFER_SIZE+HR_BUFFER_SIZE+HR23_BUFFER_SIZE+DEFLICKER_BUFFER_SIZE+OSDYS_BUFFER_SIZE+MJC_DELAY_SIZE)
#define FBM_POOL_MJCALL_SIZE                    FBM_ALIGN_MASK((FBM_MJCALL_SIZE), FBM_MJCALL_SIZE_ALIGMENT)
#else
#define FBM_POOL_MJC1_SIZE                      (0x0) // 
#define FBM_POOL_MJC2_SIZE                      (0x0) // 
#define FBM_POOL_MJC3_SIZE                      (0x0) // 
#define FBM_POOL_MJC1_C_SIZE                    (0x0) // 
#define FBM_POOL_MJC2_C_SIZE                    (0x0) // 
#define FBM_POOL_MJC3_C_SIZE                    (0x0) // 
#define FBM_POOL_MJCMV_SIZE                     (0x0) //
#define FBM_POOL_MJCALL_SIZE                    (0x0) //
#define IPM_BUFFER_SIZE                         (0x0)
#define IPM_MEDS_BUFFER_SIZE                    (0x0)
#define X1_S1_MERGE_BUFFER_SIZE					(0x0) 
#define X2_Y2_F2_S2_MERGE_BUFFER_SIZE           (0x0)
#define LOGO_BUFFER_SIZE                        (0x0)
#define HR_BUFFER_SIZE                          (0x0)
#define HR23_BUFFER_SIZE                        (0x0)
#define DEFLICKER_BUFFER_SIZE                   (0x0)   
#define OSDYS_BUFFER_SIZE                       (0x0)
#define MJC_DELAY_SIZE                          (0x09500000)
#define FBM_MJCALL_SIZE                         (0x0) 
#endif
#endif


// -------- FACE DETECTION --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_FD_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_FD_ADDR_ALIGMENT                  (0x40- 1)
#endif
#define FBM_FD_SIZE_ALIGMENT                  (0x40- 1)

#if defined(CC_MT5895)
#define FBM_FD_POOL_SIZE                      (0xc00000)
#else
#define FBM_FD_POOL_SIZE                      (800*1024)
#endif

// -------- PVR  --------
#if defined(__KERNEL__) || defined(__USERDRV__)
#define FBM_PVR_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#define FBM_PVR_SIZE_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_PVR_ADDR_ALIGMENT                  (256 - 1)
#define FBM_PVR_SIZE_ALIGMENT                  (256 - 1)
#endif
#if defined(CC_DUAL_PVR_SUPPORT)
#define FBM_PVR_POOL_SIZE                      (0x600000*2)
#else
#define FBM_PVR_POOL_SIZE                      (0x380000)
#endif
// -------- PVR2  --------
#if defined(__KERNEL__) || defined(__USERDRV__)
#define FBM_PVR2_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#define FBM_PVR2_SIZE_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_PVR2_ADDR_ALIGMENT                  (256 - 1)
#define FBM_PVR2_SIZE_ALIGMENT                  (256 - 1)
#endif
#define FBM_PVR2_POOL_SIZE                      (3*1024*1024)

// -------- PQ_3DC --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_PQ_3DC_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_PQ_3DC_ADDR_ALIGMENT                  (64 - 1)
#endif
#define FBM_PQ_3DC_SIZE_ALIGMENT                  (64 - 1)
#define FBM_PQ_3DC_POOL_SIZE                      (0x80000)
// -------- EDB --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_EDB_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_EDB_ADDR_ALIGMENT                  (16- 1)
#endif
#define FBM_EDB_SIZE_ALIGMENT                  (16- 1)
#define FBM_EDB_POOL_SIZE                      FBM_EDB_SHARE_SIZE

// -------- SRS --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SRS_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SRS_ADDR_ALIGMENT                  (64 - 1)
#endif
#define FBM_SRS_POOL_SIZE                      (0x200000)

// -------- REMUX --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_REMUX_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_REMUX_ADDR_ALIGMENT                  (32 - 1)
#endif

// -------- hw demod --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_HW_DEMOD_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_HW_DEMOD_ADDR_ALIGMENT                  (16 - 1)
#endif

#define FBM_REMUX_POOL_SIZE                      (0x500000)

// -------- SEAMLESS1 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SEAML1_ADDR_ALIGMENT                  (((FBM_FMG_Y_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_FMG_Y_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_SEAML1_ADDR_ALIGMENT                  FBM_FMG_Y_ALIGMENT
#endif

// -------- SEAMLESS2 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SEAML2_ADDR_ALIGMENT                  (((FBM_FMG_Y_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_FMG_Y_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_SEAML2_ADDR_ALIGMENT                  FBM_FMG_Y_ALIGMENT
#endif

// -------- SEAMLESS3 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SEAML3_ADDR_ALIGMENT                  (((FBM_FMG_Y_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_FMG_Y_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_SEAML3_ADDR_ALIGMENT                  FBM_FMG_Y_ALIGMENT
#endif

// -------- SEAMLESS4 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SEAML4_ADDR_ALIGMENT                  (((FBM_FMG_Y_ALIGMENT) > (FBM_PAGE_SIZE - 1)) ? (FBM_FMG_Y_ALIGMENT) : (FBM_PAGE_SIZE - 1))
#else
#define FBM_SEAML4_ADDR_ALIGMENT                  FBM_FMG_Y_ALIGMENT
#endif

// -------- SLT_GFX --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SLT_GFX_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SLT_GFX_ADDR_ALIGMENT                  (4096 - 1)
#endif

// -------- CALIBRATION --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_CALIBRATION_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_CALIBRATION_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- VDEC LAX1 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_LAX1_ADDR_ALIGMENT             (FBM_PAGE_SIZE - 1)
#else
#define FBM_LAX1_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- VDEC LAX2 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_LAX2_ADDR_ALIGMENT             (0x0)//(FBM_PAGE_SIZE - 1)
#else
#define FBM_LAX2_ADDR_ALIGMENT             (0x0) //(FBM_PAGE_SIZE - 1)
#endif

// -------- VDEC LAX3 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_LAX3_ADDR_ALIGMENT             (FBM_PAGE_SIZE - 1)
#else
#define FBM_LAX3_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- VDEC LAX4 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_LAX4_ADDR_ALIGMENT             (0x0)//(FBM_PAGE_SIZE - 1)
#else
#define FBM_LAX4_ADDR_ALIGMENT             (0x0) //(FBM_PAGE_SIZE - 1)
#endif


// -------- NJC1 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MJC1_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_MJC1_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- NJC2 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MJC2_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_MJC2_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- NJC3 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MJC3_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_MJC3_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- MJC1_C --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MJC1_C_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_MJC1_C_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- MJC2_C --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MJC2_C_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_MJC2_C_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- MJC3_C --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MJC3_C_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_MJC3_C_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- MJCMV --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MJCMV_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_MJCMV_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- DYN_MPEG --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_DYN_MPEG_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_DYN_MPEG_ADDR_ALIGMENT                  (32 - 1)
#endif

// -------- DYN_MPEG2 --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_DYN_MPEG2_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_DYN_MPEG2_ADDR_ALIGMENT                  (32 - 1)
#endif

// -------- PAD --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_PAD_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_PAD_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif


// -------- RAMOOPS --------
#if defined(CC_RAMOOPS_SUPPORT)
#define FBM_RAMOOPS_ADDR_ALIGMENT                  0
#endif

// -------- MTDFB --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MTDFB_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_MTDFB_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- MTFB --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_MTFB_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_MTFB_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif

// -------- SHM_EWS --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SHMEWS_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SHMEWS_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif
#define FBM_SHMEWS_POOL_SIZE                      (0x6400) //25KB

// -------- SHM_TSRQUE --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SHMTSRQUE_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SHMTSRQUE_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif
#define FBM_SHMTSRQUE_POOL_SIZE                      (0x200000) //2MB

// -------- SHM_ISDBCC --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SHMISDBCC_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SHMISDBCC_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif
#define FBM_SHMISDBCC_POOL_SIZE                      (0x7D000) //500KB

// -------- SHM_SSMA --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SHMSSMA_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SHMSSMA_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif
#define FBM_SHMSSMA_POOL_SIZE                      (0x10000) //64KB

// -------- SHM_VBIF --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SHMVBIF_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SHMVBIF_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif
#define FBM_SHMVBIF_POOL_SIZE                      (0x1800) //6KB

// -------- SHM_ATV TIME SHIFT --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SHMATVTS_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SHMATVTS_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif
#define FBM_SHMATVTS_POOL_SIZE                      (0x100000) //1MB

// -------- SHM_MUXER --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SHMMUXER_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SHMMUXER_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif
#define FBM_SHMMUXER_POOL_SIZE                      (0x900000) //9MB


// -------- SHM_THUMBNAIL --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_THUMBNAIL_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_THUMBNAIL_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif
#define FBM_THUMBNAIL_POOL_SIZE                      (0x20000) //128K

// -------- SHM_SOUNDCLIP --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_SOUNDCLIP_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_SOUNDCLIP_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif
#define FBM_SOUNDCLIP_POOL_SIZE                      (0xB0000) //

// -------- DTCPIP --------
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#define FBM_DTCPIP_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#else
#define FBM_DTCPIP_ADDR_ALIGMENT                  (FBM_PAGE_SIZE - 1)
#endif
#define FBM_DTCPIP_POOL_SIZE                      (0x1900000) //25MB

#define FBM_ATSC30ALP_ADDR_ALIGMENT                     (FBM_PAGE_SIZE - 1)
#ifdef CC_FBM_SUPPORT_ATSC30
#define FBM_ATSC30ALP_SIZE                              (0x1400000) // 4*5M
#else
#define FBM_ATSC30ALP_SIZE                              (0x0)
#endif

#if defined( CC_SUPPORT_4K2K)||defined(CC_SUPPORT_HDMI_4K2K30)
#define FBM_EXTRA_FOR_4K2K_SCL_DRAM         (0x4000000) 
#endif

#ifdef CC_MEM_TOOL
#undef __KERNEL__
#endif

#endif    // FBM_POOL_IF_H
