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


#ifndef CONFIG_DEFAULT_H
#define CONFIG_DEFAULT_H


//----------------------------------------------------------------------------
// Initial dram settings
//----------------------------------------------------------------------------
#define DEFAULT_DRAM_TYPE                   DDR_III_x5
#define DEFAULT_DDR_CLOCK                   (1320000000)

#ifdef CC_SAKURA_CVT_SUPPORT
#define DEFAULT_DRAM_CFG_BY_GPIO            (1)
#endif

// Audio/0 > B2R/5 > VBI/3D/TVE/2 > SCPOS/7 > NR/PSCAN/4 > Test0/15 > OSD/OD/MMU/3 > MJC_IN/13 > MJC_OUT/14 > DEMUX/GCPU/1 > CPU/6 > VLD1/9 > VDEC_MC/8 > GFX/11 > VENC/12 > 3DGFX/10
#define DRAM_PRIORITY_LIST          ((UINT8*)"092641a3cbfde785")

#ifdef ANDROID
    #ifdef CC_FORCE_DRAM768M
        #ifdef CC_SUPPORT_MULTI_DRAM_COMBINATION
            #define TOTAL_MEM_SIZE                      (512 * 1024 * 1024) /* size of Channel A bank */
            #define DEFAULT_CHANNEL_A_SIZE              (512 * 1024 * 1024)
            #define DEFAULT_CHANNEL_B_SIZE              (256 * 1024 * 1024)
        #else /* CC_SUPPORT_MULTI_DRAM_COMBINATION */
            #define TOTAL_MEM_SIZE                      (768 * 1024 * 1024) /* size of Channel A bank */
        #endif /* CC_SUPPORT_MULTI_DRAM_COMBINATION */
    #elif defined (CC_FORCE_DRAM1G)
        #ifdef CC_SUPPORT_MULTI_DRAM_COMBINATION
            #define TOTAL_MEM_SIZE                      (512 * 1024 * 1024) /* size of Channel A bank */
            #define DEFAULT_CHANNEL_A_SIZE              (512 * 1024 * 1024)
            #define DEFAULT_CHANNEL_B_SIZE              (512 * 1024 * 1024)
        #else /* CC_SUPPORT_MULTI_DRAM_COMBINATION */
            #define TOTAL_MEM_SIZE                      (1024 * 1024 * 1024) /* size of Channel A bank */
        #endif /* CC_SUPPORT_MULTI_DRAM_COMBINATION */
    #else /* use all memory from 2 banks, 1GB + 1GB */
        #define TOTAL_MEM_SIZE                          (1024 * 1024 * 1024) /* size of Channel A bank */
        #define DEFAULT_CHANNEL_A_SIZE                  (1024 * 1024 * 1024)
        #define DEFAULT_CHANNEL_B_SIZE                  (1024 * 1024 * 1024)
    #endif
#else
    #ifdef CC_DRAM_256M
        #define TOTAL_MEM_SIZE                          (256 * 1024 * 1024)
    #else
        #define TOTAL_MEM_SIZE                          (1024 * 1024 * 1024)
    #endif
#endif
        #define TOTAL_CHB_MEM_SIZE                  (1024 * 1024 * 1024)

//----------------------------------------------------------------------------
// FBM setup
//----------------------------------------------------------------------------
#if 1
#define CC_CONFIG_OSD_CM_SIZE               (4) // 4:argb 8888 ;2:argb 4444
#define CC_CONFIG_OSD_BUF_MODE              (2) // 2:double  buffer ;1:sngle buffer
        
#ifndef CC_CONFIG_OSD_PLANE1_MAX_W
#define CC_CONFIG_OSD_PLANE1_MAX_W          (0)
#endif
#ifndef CC_CONFIG_OSD_PLANE1_MAX_H
#define CC_CONFIG_OSD_PLANE1_MAX_H          (0)
#endif
#define CC_CONFIG_OSD_PLANE1_MEM_SIZE       (((CC_CONFIG_OSD_PLANE1_MAX_W*     \
                                        CC_CONFIG_OSD_PLANE1_MAX_H*        \
                                        CC_CONFIG_OSD_CM_SIZE*             \
                                        CC_CONFIG_OSD_BUF_MODE)+0x1000)&(0xFFFFF000))
        
        // osd 3d buffer size
#if (defined(CC_CONFIG_OSD_SBS_PLANE1)||defined(CC_CONFIG_OSD_TB_PLANE1))
#define CC_CONFIG_OSD_3D_PLANE1_MEM_SIZE    (CC_CONFIG_OSD_PLANE1_MEM_SIZE)
#else
#define CC_CONFIG_OSD_3D_PLANE1_MEM_SIZE    (0)
#endif
        
        // osd decompress  buffer size
#ifdef CONFIG_OSD_PLANE1_COMPRESSION
#define CC_CONFIG_OSD_DEC_PLANE1_MEM_SIZE   (CC_CONFIG_OSD_PLANE1_MEM_SIZE)
#else
#define CC_CONFIG_OSD_DEC_PLANE1_MEM_SIZE   (0)
#endif
        
#ifndef CC_CONFIG_OSD_PLANE2_MAX_W
#define CC_CONFIG_OSD_PLANE2_MAX_W          (1920)
#endif
#ifndef CC_CONFIG_OSD_PLANE2_MAX_H
#define CC_CONFIG_OSD_PLANE2_MAX_H          (1080)
#endif
#define CC_CONFIG_OSD_PLANE2_MEM_SIZE       (((CC_CONFIG_OSD_PLANE2_MAX_W*     \
                                            CC_CONFIG_OSD_PLANE2_MAX_H*        \
                                            CC_CONFIG_OSD_CM_SIZE*             \
                                            CC_CONFIG_OSD_BUF_MODE)+0x1000)&(0xFFFFF000))
        
#if (defined(CC_CONFIG_OSD_SBS_PLANE2)||defined(CC_CONFIG_OSD_TB_PLANE2))
#define CC_CONFIG_OSD_3D_PLANE2_MEM_SIZE    (CC_CONFIG_OSD_PLANE2_MEM_SIZE)
#else
#define CC_CONFIG_OSD_3D_PLANE2_MEM_SIZE    (0)
#endif
        
#ifndef CONFIG_OSD_PLANE2_COMPRESSION
        //#define  CONFIG_OSD_PLANE2_COMPRESSION
#endif
        
        // osd decompress  buffer size
#ifdef CONFIG_OSD_PLANE2_COMPRESSION
#define CC_CONFIG_OSD_DEC_PLANE2_MEM_SIZE   (CC_CONFIG_OSD_PLANE2_MEM_SIZE)
#else
#define CC_CONFIG_OSD_DEC_PLANE2_MEM_SIZE   (0)
#endif
        
#ifndef CC_CONFIG_OSD_PLANE3_MAX_W
#define CC_CONFIG_OSD_PLANE3_MAX_W          (1920)
#endif
#ifndef CC_CONFIG_OSD_PLANE3_MAX_H
#define CC_CONFIG_OSD_PLANE3_MAX_H          (1080)
#endif
#define CC_CONFIG_OSD_PLANE3_MEM_SIZE       (((CC_CONFIG_OSD_PLANE3_MAX_W*     \
                                            CC_CONFIG_OSD_PLANE3_MAX_H*        \
                                            CC_CONFIG_OSD_CM_SIZE*             \
                                            CC_CONFIG_OSD_BUF_MODE)+0x1000)&(0xFFFFF000))
        
#if (defined(CC_CONFIG_OSD_SBS_PLANE3)||defined(CC_CONFIG_OSD_TB_PLANE3))
#define CC_CONFIG_OSD_3D_PLANE3_MEM_SIZE    (CC_CONFIG_OSD_PLANE3_MEM_SIZE)
#else
#define CC_CONFIG_OSD_3D_PLANE3_MEM_SIZE    (0)
#endif
        
        // osd decompress  buffer size
#ifndef CONFIG_OSD_PLANE3_COMPRESSION
        // #define  CONFIG_OSD_PLANE3_COMPRESSION
#endif
        
#ifdef CONFIG_OSD_PLANE3_COMPRESSION
#define CC_CONFIG_OSD_DEC_PLANE3_MEM_SIZE   (CC_CONFIG_OSD_PLANE3_MEM_SIZE)
#else
#define CC_CONFIG_OSD_DEC_PLANE3_MEM_SIZE   (0)
#endif
        
#ifndef CC_CONFIG_OSD_PLANE4_MAX_W
#define CC_CONFIG_OSD_PLANE4_MAX_W          (0)
#endif
#ifndef CC_CONFIG_OSD_PLANE4_MAX_H
#define CC_CONFIG_OSD_PLANE4_MAX_H          (0)
#endif
#define CC_CONFIG_OSD_PLANE4_MEM_SIZE       (((CC_CONFIG_OSD_PLANE4_MAX_W*     \
                                            CC_CONFIG_OSD_PLANE4_MAX_H*        \
                                            CC_CONFIG_OSD_CM_SIZE*             \
                                            CC_CONFIG_OSD_BUF_MODE)+0x1000)&(0xFFFFF000))
        
#if (defined(CC_CONFIG_OSD_SBS_PLANE4)||defined(CC_CONFIG_OSD_TB_PLANE4))
#define CC_CONFIG_OSD_3D_PLANE4_MEM_SIZE    (CC_CONFIG_OSD_PLANE4_MEM_SIZE)
#else
#define CC_CONFIG_OSD_3D_PLANE4_MEM_SIZE    (0)
#endif
        
        // osd decompress  buffer size
#ifdef CONFIG_OSD_PLANE4_COMPRESSION
#define CC_CONFIG_OSD_DEC_PLANE4_MEM_SIZE   (CC_CONFIG_OSD_PLANE4_MEM_SIZE)
#else
#define CC_CONFIG_OSD_DEC_PLANE4_MEM_SIZE   (0)
#endif
        
#ifndef CC_CONFIG_OSD_PLANE5_MAX_W
#define CC_CONFIG_OSD_PLANE5_MAX_W          (100)
#endif
#ifndef CC_CONFIG_OSD_PLANE5_MAX_H
#define CC_CONFIG_OSD_PLANE5_MAX_H          (100)
#endif
        
#define CC_CONFIG_OSD_PLANE5_MEM_SIZE       (((CC_CONFIG_OSD_PLANE5_MAX_W*     \
                                    CC_CONFIG_OSD_PLANE5_MAX_H*        \
                                    CC_CONFIG_OSD_CM_SIZE)+0x1000)&(0xFFFFF000))
        
        // osd 3d buffer size
#if (defined(CC_CONFIG_OSD_SBS_PLANE5)||defined(CC_CONFIG_OSD_TB_PLANE5))
#define CC_CONFIG_OSD_3D_PLANE5_MEM_SIZE    (CC_CONFIG_OSD_PLANE5_MEM_SIZE)
#else
#define CC_CONFIG_OSD_3D_PLANE5_MEM_SIZE    (0)
#endif
        
        // osd decompress  buffer size
#ifdef CONFIG_OSD_PLANE5_COMPRESSION
#define CC_CONFIG_OSD_DEC_PLANE5_MEM_SIZE   (CC_CONFIG_OSD_PLANE5_MEM_SIZE)
#else
#define CC_CONFIG_OSD_DEC_PLANE5_MEM_SIZE   (0)
#endif
        
#define CC_CONFIG_OSD_PLANE_BASIC_MEM_SIZE  (CC_CONFIG_OSD_PLANE1_MEM_SIZE+ \
                                        CC_CONFIG_OSD_PLANE2_MEM_SIZE+  \
                                        CC_CONFIG_OSD_PLANE3_MEM_SIZE+  \
                                        CC_CONFIG_OSD_PLANE4_MEM_SIZE+  \
                                        CC_CONFIG_OSD_PLANE5_MEM_SIZE)
        
#define CC_CONFIG_OSD_3D_PLANE_MEM_SIZE     (CC_CONFIG_OSD_3D_PLANE1_MEM_SIZE+  \
                                            CC_CONFIG_OSD_3D_PLANE2_MEM_SIZE+   \
                                            CC_CONFIG_OSD_3D_PLANE3_MEM_SIZE+   \
                                            CC_CONFIG_OSD_3D_PLANE4_MEM_SIZE+   \
                                            CC_CONFIG_OSD_3D_PLANE5_MEM_SIZE)
        
#define CC_CONFIG_OSD_DEC_PLANE_MEM_SIZE    (CC_CONFIG_OSD_DEC_PLANE1_MEM_SIZE+ \
                                            CC_CONFIG_OSD_DEC_PLANE2_MEM_SIZE+  \
                                            CC_CONFIG_OSD_DEC_PLANE3_MEM_SIZE+  \
                                            CC_CONFIG_OSD_DEC_PLANE4_MEM_SIZE+  \
                                            CC_CONFIG_OSD_DEC_PLANE5_MEM_SIZE)
        
#define CC_CONFIG_GFX_TEMP_MEM_SIZE         (CC_CONFIG_OSD_PLANE3_MAX_W*    \
                                            CC_CONFIG_OSD_PLANE3_MAX_H*     \
                                            CC_CONFIG_OSD_CM_SIZE)
        
#define DFB_SUM_MEM_SIZE                    (CC_CONFIG_OSD_PLANE_BASIC_MEM_SIZE+\
                                            CC_CONFIG_OSD_3D_PLANE_MEM_SIZE+    \
                                            CC_CONFIG_OSD_DEC_PLANE_MEM_SIZE+   \
                                            CC_CONFIG_GFX_TEMP_MEM_SIZE)
#endif                                                    

#ifdef CC_GFX_MMU
#define DIRECT_FB_MEM_SIZE                  ((DFB_SUM_MEM_SIZE+4*1024)&(0xFFFFF000)) 
#else
#define DIRECT_FB_MEM_SIZE                  (160 * 1024 * 1024)
#endif

#ifdef ANDROID
    // ANDROID need 8MB fb buffer

    #if defined(CC_TTX_SUBTITLE_IN_FBM) || defined(ANDROID_TWO_WORLDS)
        #ifdef OSD_RESOLUTION_1080p
            #define FB_MEM_SIZE                         (40 * 1024 * 1024)
            #define FB_MEM_SIZE_FHD_MODEL               (40 * 1024 * 1024)
        #else
            #define FB_MEM_SIZE                         (8 * 1024 * 1024)
        #endif
        #define GFX_FB_PARTITION_SIZE                   (0)
    #else
        #ifdef OSD_RESOLUTION_1080p
            #define FB_MEM_SIZE                         (28 * 1024 * 1024)
        #else
            #define FB_MEM_SIZE                         (20 * 1024 * 1024)
        #endif
	#define GFX_FB_PARTITION_SIZE               (12 * 1024 * 1024)
    #endif
#else


#define FB_MEM_SIZE                         (0 * 1024 * 1024)

#endif
#ifndef FBM_MEM_CFG_SIZE
#define FBM_MEM_CFG_SIZE                    (FBM_MEM_CFG_MT5890_3DTV_4K)
#endif /* FBM_MEM_CFG_SIZE */

#ifndef FBM_MEM_CHB_CFG_SIZE
#define FBM_MEM_CHB_CFG_SIZE                    (FBM_MEM_CFG_MT5890_3DTV_4K_CHB)
#endif /* FBM_MEM_CHB_CFG_SIZE */

#ifndef FBM_MEM_CHC_CFG_SIZE
#define FBM_MEM_CHC_CFG_SIZE                    (FBM_MEM_CFG_MT5890_3DTV_4K_CHC)
#endif /* FBM_MEM_CHC_CFG_SIZE */

#ifdef CC_TRUSTZONE_SUPPORT
#define TRUSTZONE_CODE_BASE                 (0x5000)

#if defined(CC_SVP_SUPPORT) && defined(CC_SUPPORT_4K2K)
        #define TRUSTZONE_MEM_SIZE                  ((8 * 1024 * 1024) + (40*1024*1024))
#else 
    #ifdef ANDROID
        #define TRUSTZONE_MEM_SIZE                  (18 * 1024 * 1024)
    #else
#define TRUSTZONE_MEM_SIZE                  (18 * 1024 * 1024)
    #endif
#endif

#else
#define TRUSTZONE_MEM_SIZE                  (0)
#endif

#if defined(CC_TRUSTZONE_IN_CHB)
#define TRUSTZONE_MEM_SIZE_CHA (0)
#else
#define TRUSTZONE_MEM_SIZE_CHA TRUSTZONE_MEM_SIZE
#endif

//----------------------------------------------------------------------------
// Kernel mem setup
//----------------------------------------------------------------------------

#ifdef CC_SUPPORT_MULTI_DRAM_COMBINATION
    #define DEFAULT_LINUX_KERNEL_MEM_SIZE       ((TOTAL_MEM_SIZE > (FBM_MEM_CFG_SIZE + DIRECT_FB_MEM_SIZE + FB_MEM_SIZE + TRUSTZONE_MEM_SIZE_CHA)) ?\
                                            (TOTAL_MEM_SIZE - FBM_MEM_CFG_SIZE - DIRECT_FB_MEM_SIZE - FB_MEM_SIZE - TRUSTZONE_MEM_SIZE_CHA) : (54 * 1024 * 1024))
#else
    #define LINUX_KERNEL_MEM_SIZE               ((TOTAL_MEM_SIZE > (FBM_MEM_CFG_SIZE + DIRECT_FB_MEM_SIZE + FB_MEM_SIZE + TRUSTZONE_MEM_SIZE_CHA)) ?\
                                            (TOTAL_MEM_SIZE - FBM_MEM_CFG_SIZE - DIRECT_FB_MEM_SIZE - FB_MEM_SIZE - TRUSTZONE_MEM_SIZE_CHA) : (54 * 1024 * 1024))
#endif                                                

#define DEFAULT_TARGET_COUNTRY              (COUNTRY_EU)  
//#define DEFAULT_TARGET_COUNTRY              (COUNTRY_CHD)
//----------------------------------------------------------------------------
// Default Panel setting
//----------------------------------------------------------------------------
#ifndef DEFAULT_PANEL_SELECT
#define DEFAULT_PANEL_SELECT                (PANEL_DEFAULT)
#endif
#define BACKLIGHT_GPIO                      (OPCTRL(4))
#define BACKLIGHT_ON_VAL                    (0)

#ifdef CC_COMBINE_4K_2K
#define PANELPOWER_GPIO_2K                  (OPCTRL(9))
#define PANELPOWER_GPIO_4K                  (0xFFFFFFFF)
#define PANELPOWER_ON_VAL                   (1)
#else
#ifdef CC_4K_MODEL
#define PANELPOWER_GPIO                     (0xFFFFFFFF)
#define PANELPOWER_ON_VAL                   (0)
#else
#define PANELPOWER_GPIO                     (OPCTRL(9))
#define PANELPOWER_ON_VAL                   (1)
#endif
#endif

// disable spread spectrum for vga output
#define SPREAD_SPECTRUM_PERMILLAGE          (0)

// pwm backlight adjustment setting
#define PANEL_BACKLIGHT_PWM_PORT            (1)

//3D Enable & LR GPIO
//#define EXT_3D_ENABLE_PORT                  (GPIO(52))
//#define EXT_3D_LR_PIN                      (PIN_GPIO53)
//#define EXT_3D_LR_PIN_FUNC                   (1)

#define PDWNC_POLARITY                      (0)
#define SYS_RESET_TIMER                     324000
//----------------------------------------------------------------------------
// Suspend power control GPIO Number, it must be PDWNC GPIO
//----------------------------------------------------------------------------
#define  SUSPEND_GPIO_NUMBER   0xffffffff
#define  SUSPEND_WOL_GPIO      271

//----------------------------------------------------------------------------
// Loader logo 
//----------------------------------------------------------------------------
//#ifdef CC_LOADER_LOGO_SUPPORT
#ifdef CC_UPGRADING_DYNAMIC_LOGO_SUPPORT
#define LOADER_LOGO_NUMBER                  (5)
#else
#define LOADER_LOGO_NUMBER                  (1)
#endif
#define LOADER_LOGO_H_FILE                  "Sony/maple_drv/sony_logo.h"
//#endif

//----------------------------------------------------------------------------
// Audio Customization
//----------------------------------------------------------------------------
#define AUDIO_INCLUDE_FILE                  "Sony/Mustang_aud.h"

#ifdef CC_COMBINE_4K_2K
#define AUDIO_Mute_Gpio_Num_2K               (GPIO(52))
#define AUDIO_Mute_Gpio_Num_4K              (GPIO(52))
#define AUDIO_Amp_Gpio_Num_4K           (OPCTRL(5))
//#define AUDIO_Amp_Gpio_Num_2K           (GPIO(67))
#else
#ifdef CC_4K_MODEL
#define AUDIO_Mute_Gpio_Num              (GPIO(52))
#define AUDIO_Amp_Gpio_Num               (OPCTRL(5))
#else
#define AUDIO_Mute_Gpio_Num                 (GPIO(52))
//#define AUDIO_Amp_Gpio_Num               (GPIO(67))
#endif
#endif//CC_COMBINE_4K_2K

#define AUDIO_HP_PLUG_IN_GPIO               (OPCTRL(6))
#define AUDIO_MUTE_GPIO_POLARITY            AUD_MUTE_GPIO_LOW_ENALBE
#define AUDIO_HP_PLUG_IN_POLARITY           (AUD_GPIO_HIGH_ENALBE)
#define AUDIO_AMP_GPIO_POLARITY         AUD_AMP_GPIO_HIGH_ENALBE
#define AUDIO_DIGITAL_AMP_RESET_GPIO        (GPIO(67)) //SD_CMD        
#define AUDIO_DIGITAL_AMP_RESET_GPIO_POLARITY  AUD_AMP_GPIO_HIGH_ENALBE 
#define AUDIO_SCART_Gpio_Num            (GPIO(51))
#define AUDIO_SCART_GPIO_POLARITY       AUD_GPIO_LOW_ENALBE


#define AUDIO_AL1AR1_PHASE_INVERSE           (TRUE)
#define AUDIO_AL2AR2_PHASE_INVERSE           (TRUE)
#define AUDIO_AL3AR3_PHASE_INVERSE           (TRUE)

#define AUDIO_INPUT_MUX_SEL_TABLE           (&_rMustangAudInputMuxTable)
#define AUDIO_IEC_WORD_LENGTH               (&_au1SakuraAudIecWordLength)
#define AUDIO_IEC_CATEGORY                  (&_au1SakuraEuAudIecCategory)
#define AUDIO_APROC_ENABLE                  (FALSE)
#define AUDIO_DOWNMIX_CHANNEL_POSITION      (DOWNMIX_CH_BEFORE_AVC)
#define AUDIO_HEAAC_MULTICHL_DDCO           (FALSE)
#define AUDIO_ADAC_USAGE                    (&_arSakuraAdacUsage)

#define AUD_FLASH_AQ_FILE              "Sony/sakura_aud_flash_aq.c" //CC_AUD_AQ_IN_DRVCUST

//----------------------------------------------------------------------------
// Other GPIO customization
#define DEFAULT_TUNER_RFAGC_SWITCH_GPIO     (272)
//#define DEFAULT_DEMOD_RESET_GPIO            (GPIO(65))

//----------------------------------------------------------------------------
#define FLAG_EXT_STATUS                     (0)

//----------------------------------------------------------------------------
// EEPROM customization
//----------------------------------------------------------------------------
#if (defined(REPLACE_EEPROM_WITH_EMMC)||defined(REPLACE_EEPROM_WITH_FLASH))
#define SYSTEM_EEPROM_SIZE                  (307200)
#else
#define SYSTEM_EEPROM_SIZE                  (4096)
#endif
//#define SYSTEM_EEPROM_WP_GPIO               (GPIO(46)) // OPCTRL9.
//#define SYSTEM_EEPROM_WP_ENABLE_POLARITY    (1)
#ifdef CC_EEP2EMMC_DUAL_BANK_SUPPORT
#define SYSTEM_EEPROM_INIT_HEADER_SIZE      (102400)
#define SYSTEM_EEPROM_HEADER_SIZE           (307200)
#endif

#ifndef DRVCUST_EEPROM_ANDROID_OTA_SIZE
#define DRVCUST_EEPROM_ANDROID_OTA_SIZE    ((UINT32)16)
#endif /* DRVCUST_EEPROM_ANDROID_OTA_SIZE */

#ifndef DRVCUST_EEPROM_ANDROID_OTA_OFFSET
#define DRVCUST_EEPROM_ANDROID_OTA_OFFSET    ((UINT32)(DRVCUST_EEPROM_HDCP2X_OFFSET-DRVCUST_EEPROM_ANDROID_OTA_SIZE))
#endif /* DRVCUST_EEPROM_ANDROID_OTA_OFFSET */
#include                                    "Sony/Sakura_eeprom_layout.h"

//----------------------------------------------------------------------------
// European CI (Common Interface) customization
//----------------------------------------------------------------------------
//#define CI_EXTERNAL_IC_INT_GPIO             (GPIO(84))  // Set:Interrupt Mode, UnSet:Polling Mode
#define CI_5V_OC_GPIO                       (GPIO(42))  
#define CI_5V_POWERON_GPIO                  (GPIO(48))
#define CI_5V_POWERON_POLARITY              (1)
#define CI_5V_OC_POLARITY                   (0)
#define CI_EXTERNAL_IC_DRIVING_CURRENT      (2)         // 2mA
#define CI_SYSTEM_CLOCK                     (72)        // 72 MHz
#define CI_TS_CLOCK                         (108)       // 108 MHz
#define CI_SPI_CLOCK                        (27)        // 72 MHz
//----------------------------------------------------------------------------
// USB Customization
//----------------------------------------------------------------------------
// "USBx_PORT_USING_LOADER & USBx_PORT_USING" related define is only for USB2.0 port
// 1. Loader, USB port using define (1)=used (0)=not used
#define USB0_PORT_USING_LOADER              (1)
#define USB1_PORT_USING_LOADER              (1)
#define USB2_PORT_USING_LOADER              (1)
#define USB3_PORT_USING_LOADER              (1)

// 2. Nuclues/Linux/Android System USB port using define (1)=used (0)=not used
#define USB0_PORT_USING                     (1)
#define USB1_PORT_USING                     (1) 
#define USB2_PORT_USING                     (1) 
#define USB3_PORT_USING                     (1)

// 3. USB +5V power switch Vbus GPIO control, if vbus not control by GPIO, mark off it.
#define USB0_VBUS_GPIO                      GPIO(45)    // GPIO51.
#define USB0_VBUS_GPIO_POLARITY		        (1)
#define USB1_VBUS_GPIO                      GPIO(43)    // GPIO43
#define USB1_VBUS_GPIO_POLARITY		        (1)
#define USB2_VBUS_GPIO                      GPIO(44)    // GPIO44
#define USB2_VBUS_GPIO_POLARITY		        (1)
//#define USB3_VBUS_GPIO                      OPCTRL(10)  // OPCTRL10.
//#define USB3_VBUS_GPIO_POLARITY		        (1)

// 4. USB power switch overcurrent GPIO control, if have not ic to control by GPIO, mark off it.
#define USB0_OC_GPIO                        GPIO(46)
#define USB0_OC_GPIO_POLARITY		        (0)
#define USB1_OC_GPIO                        GPIO(64)
#define USB1_OC_GPIO_POLARITY		        (0)
#define USB2_OC_GPIO                        ADIN(5)
#define USB2_OC_GPIO_POLARITY		        (0)
//#define USB3_OC_GPIO                        ADIN(5)     // ADIN 5.
//#define USB3_OC_GPIO_POLARITY		        (0)

// 5. Detect USB upgrade time, default is 0, but some device maybe can't detect when upgrade.
// If possible, set it to (300)ms when in customer's module.
#define USB_LOADER_WAIT_TIME                (1000)

//#define USB_DISABLE_SUSPEND_MODE /* Disable USB suspend, share 240 Mhz with H.264.*/
//----------------------------------------------------------------------------
// Button Customization
//----------------------------------------------------------------------------
#define FLAG_BUTTON_SUPPORT                 (1)
#define BUTTON_INCLUDE_FILE                 "Sony/maple_button.h"

#ifndef KEYPAD_POLLING_TIME
#define KEYPAD_POLLING_TIME         (20)
#endif
#ifndef KEYPAD_CHECK_TIME
#define KEYPAD_CHECK_TIME           (2)
#endif

#ifndef T8032UP_INCLUDE_FILE
#ifdef CC_MAPLE_IR_DRV
#define T8032UP_INCLUDE_FILE                "Sony/maple_drv/sakura_t8032fw.h"
#define T8032UP_OFFSET                      au1T8032FW
//#define T8032UP_SIZE                        26750//24576//16384
#define T8032UP_SIZE                     T8032FW_SIZE 
#else
#define T8032UP_INCLUDE_FILE                "mtk/mtk_t8032fw.h"
#define T8032UP_OFFSET                      au1T8032FW
#define T8032UP_SIZE                        24576//16384
#endif
#endif

//----------------------------------------------------------------------------
// MTK IR only setting
//----------------------------------------------------------------------------
//#define IR_INCLUDE_FILE                     "mtk/mtk_ir.h"
#ifdef CC_MAPLE_IR_DRV
#define IR_INCLUDE_FILE                     "Sony/maple_drv/sirc_ir.h"
#else
#define IR_INCLUDE_FILE                     "Sony/mtk_ir_SONY_IPTV.h"
#endif
#define IRRX_LED_BLINK_DURATION               (50)

#ifndef NPTV_SOURCE_TABLE
#define NPTV_SOURCE_TABLE                   "Sony/source_table_sony.c"
#endif

#define SCART1_FB_IN_SELECT                 SCART_FB_IN_SOY0
//----------------------------------------------------------------------------
// default HDMI GPIO control
//----------------------------------------------------------------------------
#ifndef HDMI_GPIO_CONF
#ifdef CC_HDMI_USE_DEMO_BOARD
#define HDMI_GPIO_CONF                      "mtk/hdmi_conf.c"
#else
#define HDMI_GPIO_CONF                      "Sony/hdmi_conf.c"
#endif
#endif

/*
 * default VGA table
*/
#ifndef VGA_INCLUDE_FILE
#define VGA_INCLUDE_FILE                    "mtk/mtk_vga.h"
#endif

#ifndef EDID_INCLUDE_FILE
#define EDID_INCLUDE_FILE                "Sony/sony_edid.h"
#endif


//----------------------------------------------------------------------------
// Tcon Customization
//----------------------------------------------------------------------------
// support LVDS and MLVDS both
#define PANEL_DISPLAY_TYPE_ALLOWED_MASK ((1<<PANEL_DISPLAY_TYPE_LVDS) | (1 << PANEL_DISPLAY_TYPE_MLVDS) | (1 << PANEL_DISPLAY_TYPE_EPI) | (1 << PANEL_DISPLAY_TYPE_VB1))

#ifndef TCON_CUST_FILE
#define TCON_CUST_FILE                      "mtk/Oryx_tcon_cust.c"
#endif
#define SUPPORT_LOCK_FROM_SRVAD 

//----------------------------------------------------------------------------
// BE configuration
//----------------------------------------------------------------------------
#ifdef CC_MAPLE_BE_LOADER_BOOT_FLOW
#ifndef BE_CTRL_INCLUDE_FILE
#define BE_CTRL_INCLUDE_FILE                    "Sony/maple_drv/maple_be_ctrl.h"
#endif
#endif

//----------------------------------------------------------------------------
// default PIN Setup
//----------------------------------------------------------------------------
#ifndef PINMUX_INCLUDE_FILE
#define PINMUX_INCLUDE_FILE                 "Sony/Sony_pin_setup.h"
#endif

//----------------------------------------------------------------------------
// SCART out configuration
//----------------------------------------------------------------------------
#ifndef TVE_INCLUDE_FILE
#define TVE_INCLUDE_FILE                    "mtk/mtk_tve.c"
#endif

//----------------------------------------------------------------------------
// DMX configuration
//----------------------------------------------------------------------------
#ifndef DMX_INCLUDE_FILE
#ifdef CC_ARIB
#define DMX_INCLUDE_FILE                    "Sony/mtk_arib_dmx.h"
#else
#define DMX_INCLUDE_FILE                    "mtk/mtk_dmx.h"
#endif
#endif

//----------------------------------------------------------------------------
// Loader configuration
//----------------------------------------------------------------------------
#if defined(LINUX_TURNKEY_SOLUTION) || defined(__KERNEL__)
//----------------------------------------------------------------------------
// Flash Partition configuration
#define MAX_UPGRADE_IMAGE_FILE_SIZE     ((UINT64)4*1024*1024*1024)
//----------------------------------------------------------------------------
#define NAND_INCLUDE_FILE                   "Sony/Sakura_flash_layout.h"
#define HDCP_NAND_FLASH_PART_ID (15)
#define HDCP2X_NAND_FLASH_PART_ID (25)

#endif //defined(LINUX_TURNKEY_SOLUTION) || defined(__KERNEL__)

#if defined(LINUX_TURNKEY_SOLUTION) || defined(__KERNEL__)
#ifdef CC_FBM_MAPPING_ONE_BY_ONE
#ifndef FBM_BOOT_MMAP_INCLUDE_FILE
#define FBM_BOOT_MMAP_INCLUDE_FILE           "mtk/mtk_fbm_mmap.h"
#endif
#endif
#endif

#ifdef CC_SAKURA_CUST_DRV
#define GPIO_INCLUDE_FILE                       "Sony/maple_drv/maple_gpio.h"
#define PDWNC_EXT_IMPL                          "Sony/maple_drv/maple_pdwnc.h"
#endif

/*
 * default quality table
*/
#ifndef QTYTBL_INCLUDE_FILE
//#define QTYTBL_INCLUDE_FILE               "mtk/QTY_DEFAULT/mtk_QtyTbl.h"
#endif

/*
 * default color parameter
*/
#ifndef COLOR_PARAM_INCLUDE_FILE
//#define COLOR_PARAM_INCLUDE_FILE          "mtk/PANEL_DEFAULT/color_param.h"
#endif

/*
 * dynamic backlight parameter
*/

//----------------------------------------------------------------------------
// D-interface Customization
//----------------------------------------------------------------------------
#ifdef CC_SAKURA_CUST_DRV
#ifndef DRV_CUSTOM_CUST_FILE
#define DRV_CUSTOM_CUST_FILE                    "Sony/maple_d_custom.c"
#endif

#ifndef DRV_CUSTOM_CUST_SPEC_SET
#define DRV_CUSTOM_CUST_SPEC_SET                d_maple_cust_spec_set
#endif

#ifndef DRV_CUSTOM_CUST_SPEC_GET
#define DRV_CUSTOM_CUST_SPEC_GET                d_maple_cust_spec_get
#endif
#endif

#ifdef CC_SAKURA_CUST_DRV
#ifndef CUSTOM_VIDEO_DRV_BODY_FILE
#define CUSTOM_VIDEO_DRV_BODY_FILE              "Sony/maple_video_drv.c"
#endif

#ifndef CUSTOM_BACKLIGHT_DRV_BODY_FILE
#define CUSTOM_BACKLIGHT_DRV_BODY_FILE          "Sony/maple_backlight_drv.c"
#endif
#endif

/*
 * default quality table
*/

#ifdef CC_MAPLE_CUST_DRV
#ifndef QTYTBL_INCLUDE_FILE
#define QTYTBL_INCLUDE_FILE               "Sony/QTY_drv_Sony_mt5830_linux//mtk_QtyTbl.h"
#endif
#endif


/*
 * default color parameter
*/

#ifdef CC_MAPLE_CUST_DRV
#ifndef COLOR_PARAM_INCLUDE_FILE
#define COLOR_PARAM_INCLUDE_FILE          "Sony/PANEL_DEFAULT/color_param.h"
#endif
#endif

#define SUPPORT_OD                          (0)

//For internal Demod use
#ifndef SIF_ENABLE_PDWNC_MASTER
#define SIF_ENABLE_PDWNC_MASTER      (1)
#endif

#ifndef SIF_ENABLE_PDWNC_MASTER1
#define SIF_ENABLE_PDWNC_MASTER1      (1)
#endif

#define SIF_ENABLE_SCL_STRETCH        (1)

//----------------------------------------------------------------------------
// SCART Pin8 Threshold Servo ADC Customization
//----------------------------------------------------------------------------
#ifndef SCART_PIN8_LOW_THRES
#define SCART_PIN8_LOW_THRES (11)
#endif

#ifndef SCART_PIN8_HI_THRES
#define SCART_PIN8_HI_THRES (31)
#endif

//----------------------------------------------------------------------------
// I2C Customization
//----------------------------------------------------------------------------
#ifndef DRV_CUST_FIXED_SIF_CLK_DIV
#define DRV_CUST_FIXED_SIF_CLK_DIV (0x48)
#endif

/* Flash Panel Table */
#ifdef CC_PANEL_FROM_FLASH
#ifndef LOAD_PANEL_FROM_FLASH_CUSTOM
#define LOAD_PANEL_FROM_FLASH_CUSTOM            CustomPanelLoadTableFromFlash
#define DUMP_PANEL_LIST_FROM_FLASH_CUSTOM       CustomDumpPanelListFromFlash
#define PANEL_VERSION_LENGTH                    16
#endif
#define PANEL_FLASH_HEADER_ADDRESS          (0)
#define PANEL_FLASH_HEADER_LENGTH           (32)
#define PANEL_FLASH_TABLE_SIZE              (636)//(180)
#define PANEL_FLASH_TABLE_BASE_PARTITION    (17)
#define PANEL_FLASH_TABLE_ADDRESS           (32)
#endif

#ifdef CC_MAPLE_CUST_DRV
#ifdef CC_MAPLE_LOADER_UPGRADE_VERSION_CTRL_FLOW
//#define USB_UPGRADE_FILE_NAME           ("upgrade_sony_fw_2015_1000_chd.pkg")
//#define USB_UPGRADE_FILE_NAME_PREFIX    ("upgrade_sony_fw_2015_")
//#define USB_UPGRADE_FILE_NAME_SUFFIX    (".pkg")
#endif
#define SDCARD_UPGRADE_SUPPORT_FLAG     (1)
#define SDCARD_UPGRADE_PART_OFFSET      (NAND_PART_OFFSET_40)
#endif
#ifdef CC_LDR_ATOMIC_MODE_SUPPORT
#ifndef LDR_ATOMIC_UPG_FILE_NAME
#define LDR_ATOMIC_UPG_FILE_NAME       ("factory_shipsetting.pkg")
#endif
#ifndef LDR_ATOMIC_UPG_FILE_NAME_PREFIX
#define LDR_ATOMIC_UPG_FILE_NAME_PREFIX    ("factory_shipsetting")
#endif
#ifndef LDR_ATOMIC_UPG_FILE_NAME_SUFFIX
#define LDR_ATOMIC_UPG_FILE_NAME_SUFFIX    (".pkg")
#endif
#endif

#define MODEL_4K2K_GPIO          (72)

#define WAKEUP_ON_BT_ENB_FUNC   CustomGetBTWakeupEnable
#define WAKEUP_ON_BT_GPIO       (210)
#define WAKEUP_ON_BT_POL          (0)

/*
 *  ENABLE WOW for WiFi
*/
#ifdef WIFI_WOWLAN_SUPPORT
#define WAKEUP_ON_WLAN_GPIO 	(218) // OPCTRL(18)
#define WAKEUP_ON_WLAN_POL 	(0)
#endif

#else /* CONFIG_DEFAULT_H */
#error "Cannot include multi-config files"
#endif /* CONFIG_DEFAULT_H */

