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


/*****************************************************************************
 *
 * Filename:
 * ---------
 *   $Workfile: mtk_edid.h
 *
 * Project:
 * --------
 *   MT5365
 *
 * Description:
 * ------------
 *   Edid customization
 *   
 * Author:
 * -------
 *   
 *
 * Unauthorized use, practice, perform, copy, distribution, reproduction,
 * or disclosure of this information in whole or in part is prohibited.
 *-----------------------------------------------------------------------------
 *
 * $Author: dtvbm11 $
 * $Date: 2015/11/10 $
 * $RCSfile: mtk_vga.h,v $
 * $Revision: #1 $
 *
 *---------------------------------------------------------------------------*/
#ifndef _EDID_CUSTOMIZATION_H_
#define _EDID_CUSTOMIZATION_H_
#include "msdc_if.h"
#include "eeprom_if.h"
#include "panel_cust.h"
#ifndef CC_VGA_EDID_DISABLE
CODE UINT8 VGA_EDID_TABLE[256] =
{
	0x00, 0xFF, 0xFF, 0xFF,  0xFF, 0xFF, 0xFF, 0x00,   0x4D, 0xD9, 0x02, 0xB0,  0x01, 0x01, 0x01, 0x01, 
	0x0C, 0x16, 0x01, 0x03,  0x08, 0xA0, 0x5A, 0x78,   0x0A, 0x0D, 0xC9, 0xA0,  0x57, 0x47, 0x98, 0x27, 
	0x12, 0x48, 0x4C, 0x21,  0x08, 0x00, 0x81, 0xC0,   0x81, 0x80, 0x01, 0x01,  0x01, 0x01, 0x01, 0x01, 
	0x01, 0x01, 0x01, 0x01,  0x01, 0x01, 0x02, 0x3A,   0x80, 0x18, 0x71, 0x38,  0x2D, 0x40, 0x58, 0x2C, 
	0x45, 0x00, 0x40, 0x84,  0x63, 0x00, 0x00, 0x1E,   0x66, 0x21, 0x50, 0xB0,  0x51, 0x00, 0x1B, 0x30, 
	0x40, 0x70, 0x36, 0x00,  0x40, 0x84, 0x63, 0x00,   0x00, 0x1E, 0x00, 0x00,  0x00, 0xFD, 0x00, 0x39, 
	0x3F, 0x1E, 0x50, 0x0F,  0x00, 0x0A, 0x20, 0x20,   0x20, 0x20, 0x20, 0x20,  0x00, 0x00, 0x00, 0xFC, 
	0x00, 0x53, 0x4F, 0x4E,  0x59, 0x20, 0x54, 0x56,   0x0A, 0x20, 0x20, 0x20,  0x20, 0x20, 0x00, 0xD5,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00
};

CODE UINT8 VGA_WXGA_EDID_TABLE[256] =
{
	0x00, 0xFF, 0xFF, 0xFF,  0xFF, 0xFF, 0xFF, 0x00,   0x4D, 0xD9, 0x02, 0xB0,  0x01, 0x01, 0x01, 0x01, 
	0x0C, 0x16, 0x01, 0x03,  0x08, 0xA0, 0x5A, 0x78,   0x0A, 0x0D, 0xC9, 0xA0,  0x57, 0x47, 0x98, 0x27, 	
	0x12, 0x48, 0x4C, 0x21,  0x08, 0x00, 0x81, 0xC0,   0x81, 0x80, 0x01, 0x01,  0x01, 0x01, 0x01, 0x01, 
	0x01, 0x01, 0x01, 0x01,  0x01, 0x01, 0x02, 0x3A,   0x80, 0x18, 0x71, 0x38,  0x2D, 0x40, 0x58, 0x2C, 
	0x45, 0x00, 0x40, 0x84,  0x63, 0x00, 0x00, 0x1E,   0x66, 0x21, 0x50, 0xB0,  0x51, 0x00, 0x1B, 0x30, 
	0x40, 0x70, 0x36, 0x00,  0x40, 0x84, 0x63, 0x00,   0x00, 0x1E, 0x00, 0x00,  0x00, 0xFD, 0x00, 0x39, 
	0x3F, 0x1E, 0x50, 0x0F,  0x00, 0x0A, 0x20, 0x20,   0x20, 0x20, 0x20, 0x20,  0x00, 0x00, 0x00, 0xFC, 
	0x00, 0x53, 0x4F, 0x4E,  0x59, 0x20, 0x54, 0x56,   0x0A, 0x20, 0x20, 0x20,  0x20, 0x20, 0x00, 0xD5,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00
};	

void vDrvLoadVgaEdid2Table(void)
{
    UINT32 EdidIdx;
#ifdef CC_PANEL_FROM_FLASH	
    EdidIdx=FlashPanel_GetVgaEdidTblIdx();
	if(EdidIdx==0)
		{
		//Default is FHD EDID
		}
		else
		{
		x_memcpy(VGA_EDID_TABLE, VGA_WXGA_EDID_TABLE, 256);
		}
#else
	   //USE deautlt Default VGA_EDID_TABLE
#endif
}
#endif

#ifndef CC_HDMI_EDID_DISABLE
/*
All value of Port 0 is in HDMIEDID_CEC_192k_DeepColor12B_P0
Arrangement of HDMICEC_SETTING is
Port2 CEC physical address
Port3 CEC physical address
Port4 CEC physical address
*/
UINT8 HDMICEC_SETTING[3]=
{
	0x20, // Port2 CEC physical address
	0x30, // Port2 CEC physical address
	0x40, // Port2 CEC physical address
};
UINT8 HDMIBOSTONEDID_table[1024];
UINT8 HDMIEDID_table[256] =
{
    0x00, 0xFF, 0xFF, 0xFF,  0xFF, 0xFF, 0xFF, 0x00, 0x36, 0x8B, 0x01, 0x00,  0x01, 0x01, 0x01, 0x01,
    0x01, 0x0F, 0x01, 0x03,  0x80, 0x3C, 0x22, 0x78, 0x0A, 0x0D, 0xC9, 0xA0,  0x57, 0x47, 0x98, 0x27,
    0x12, 0x48, 0x4C, 0xBF,  0xEF, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,  0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01,  0x01, 0x01, 0x01, 0x1D, 0x00, 0x72, 0x51, 0xD0,  0x1E, 0x20, 0x6E, 0x28,
    0x55, 0x00, 0xC4, 0x8E,  0x21, 0x00, 0x00, 0x1E, 0x01, 0x1D, 0x80, 0x18,  0x71, 0x1C, 0x16, 0x20,
    0x58, 0x2C, 0x25, 0x00,  0xC4, 0x8E, 0x21, 0x00, 0x00, 0x9E, 0x00, 0x00,  0x00, 0xFC, 0x00, 0x4D,
    0x54, 0x4B, 0x20, 0x4C,  0x43, 0x44, 0x54, 0x56, 0x0A, 0x20, 0x20, 0x20,  0x00, 0x00, 0x00, 0xFD,
    0x00, 0x31, 0x4C, 0x0F,  0x50, 0x0E, 0x00, 0x0A, 0x20, 0x20, 0x20, 0x20,  0x20, 0x20, 0x01, 0x56,
    0x02, 0x03, 0x23, 0x74,  0x4B, 0x84, 0x10, 0x1F, 0x05, 0x13, 0x14, 0x01,  0x02, 0x11, 0x06, 0x15,
    0x26, 0x09, 0x7F, 0x03,  0x11, 0x7F, 0x18, 0x83, 0x01, 0x00, 0x00, 0x67,  0x03, 0x0C, 0x00, 0x10,
    0x00, 0xB8, 0x2D, 0x01,  0x1D, 0x00, 0xBC, 0x52, 0xD0, 0x1E, 0x20, 0xB8,  0x28, 0x55, 0x40, 0xC4,
    0x8E, 0x21, 0x00, 0x00,  0x1E, 0x01, 0x1D, 0x80, 0xD0, 0x72, 0x1C, 0x16,  0x20, 0x10, 0x2C, 0x25,
    0x80, 0xC4, 0x8E, 0x21,  0x00, 0x00, 0x9E, 0x8C, 0x0A, 0xD0, 0x8A, 0x20,  0xE0, 0x2D, 0x10, 0x10,
    0x3E, 0x96, 0x00, 0x13,  0x8E, 0x21, 0x00, 0x00, 0x18, 0x8C, 0x0A, 0xD0,  0x90, 0x20, 0x40, 0x31,
    0x20, 0x0C, 0x40, 0x55,  0x00, 0x13, 0x8E, 0x21, 0x00, 0x00, 0x18, 0x00,  0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x52
	
};

UINT8 HDMIEDID_CEC_192k_DeepColor12B_P0[256] =
{
    0x00, 0xFF, 0xFF, 0xFF,  0xFF, 0xFF, 0xFF, 0x00,   0x36, 0x8B, 0x01, 0x00,  0x01, 0x01, 0x01, 0x01,
    0x01, 0x0F, 0x01, 0x03,  0x80, 0x3C, 0x22, 0x78,   0x0A, 0x0D, 0xC9, 0xA0,  0x57, 0x47, 0x98, 0x27,
    0x12, 0x48, 0x4C, 0xBF,  0xEF, 0x00, 0x01, 0x01,   0x01, 0x01, 0x01, 0x01,  0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01,  0x01, 0x01, 0x01, 0x1D,   0x00, 0x72, 0x51, 0xD0,  0x1E, 0x20, 0x6E, 0x28,
    0x55, 0x00, 0xC4, 0x8E,  0x21, 0x00, 0x00, 0x1E,   0x01, 0x1D, 0x80, 0x18,  0x71, 0x1C, 0x16, 0x20,
    0x58, 0x2C, 0x25, 0x00,  0xC4, 0x8E, 0x21, 0x00,   0x00, 0x9E, 0x00, 0x00,  0x00, 0xFC, 0x00, 0x4D,
    0x54, 0x4B, 0x20, 0x4C,  0x43, 0x44, 0x54, 0x56,   0x0A, 0x20, 0x20, 0x20,  0x00, 0x00, 0x00, 0xFD,
    0x00, 0x31, 0x4C, 0x0F,  0x50, 0x0E, 0x00, 0x0A,   0x20, 0x20, 0x20, 0x20,  0x20, 0x20, 0x01, 0x56,
    0x02, 0x03, 0x23, 0x74,  0x4B, 0x84, 0x10, 0x1F,   0x05, 0x13, 0x14, 0x01,  0x02, 0x11, 0x06, 0x15,
    0x26, 0x09, 0x7F, 0x03,  0x11, 0x7F, 0x18, 0x83,   0x01, 0x00, 0x00, 0x67,  0x03, 0x0C, 0x00, 0x10,
    0x00, 0xB8, 0x2D, 0x01,  0x1D, 0x00, 0xBC, 0x52,   0xD0, 0x1E, 0x20, 0xB8,  0x28, 0x55, 0x40, 0xC4,
    0x8E, 0x21, 0x00, 0x00,  0x1E, 0x01, 0x1D, 0x80,   0xD0, 0x72, 0x1C, 0x16,  0x20, 0x10, 0x2C, 0x25,
    0x80, 0xC4, 0x8E, 0x21,  0x00, 0x00, 0x9E, 0x8C,   0x0A, 0xD0, 0x8A, 0x20,  0xE0, 0x2D, 0x10, 0x10,
    0x3E, 0x96, 0x00, 0x13,  0x8E, 0x21, 0x00, 0x00,   0x18, 0x8C, 0x0A, 0xD0,  0x90, 0x20, 0x40, 0x31,
    0x20, 0x0C, 0x40, 0x55,  0x00, 0x13, 0x8E, 0x21,   0x00, 0x00, 0x18, 0x00,  0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x52
};
UINT8 HDMIEDID_3D_CEC_192k_DeepColor12B_P0[256] =
{
	0x00, 0xFF, 0xFF, 0xFF,  0xFF, 0xFF, 0xFF, 0x00, 0x36, 0x8B, 0x01, 0x00,  0x01, 0x01, 0x01, 0x01, 
	0x01, 0x0F, 0x01, 0x03,  0x80, 0x3C, 0x22, 0x78, 0x0A, 0x0D, 0xC9, 0xA0,  0x57, 0x47, 0x98, 0x27, 
	0x12, 0x48, 0x4C, 0xBF,  0xEF, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,  0x01, 0x01, 0x01, 0x01, 
	0x01, 0x01, 0x01, 0x01,  0x01, 0x01, 0x01, 0x1D, 0x00, 0x72, 0x51, 0xD0,  0x1E, 0x20, 0x6E, 0x28, 
	0x55, 0x00, 0xC4, 0x8E,  0x21, 0x00, 0x00, 0x1E, 0x01, 0x1D, 0x80, 0x18,  0x71, 0x1C, 0x16, 0x20, 
	0x58, 0x2C, 0x25, 0x00,  0xC4, 0x8E, 0x21, 0x00, 0x00, 0x9E, 0x00, 0x00,  0x00, 0xFC, 0x00, 0x4D, 
	0x54, 0x4B, 0x20, 0x4C,  0x43, 0x44, 0x54, 0x56, 0x0A, 0x20, 0x20, 0x20,  0x00, 0x00, 0x00, 0xFD, 
	0x00, 0x31, 0x4C, 0x0F,  0x50, 0x0E, 0x00, 0x0A, 0x20, 0x20, 0x20, 0x20,  0x20, 0x20, 0x01, 0x56, 
	0x02, 0x03, 0x26, 0x74,  0x4C, 0x84, 0x10, 0x1F, 0x05, 0x13, 0x14, 0x01,  0x02, 0x11, 0x06, 0x15, 0x20,
	0x26, 0x09, 0x7F, 0x03,  0x11, 0x7F, 0x18, 0x83, 0x01, 0x00, 0x00, 0x6A,  0x03, 0x0C, 0x00, 0x10, 
	0x00, 0xF8, 0x2D, 0x2F,  0x80, 0x00, 0x01, 0x1D, 0x00, 0xBC, 0x52, 0xD0,  0x1E, 0x20, 0xB8, 0x28, 
	0x55, 0x40, 0xC4, 0x8E,  0x21, 0x00, 0x00, 0x1E, 0x01, 0x1D, 0x80, 0xD0,  0x72, 0x1C, 0x16, 0x20, 
	0x10, 0x2C, 0x25, 0x80,  0xC4, 0x8E, 0x21, 0x00, 0x00, 0x9E, 0x8C, 0x0A,  0xD0, 0x8A, 0x20, 0xE0, 
	0x2D, 0x10, 0x10, 0x3E,  0x96, 0x00, 0x13, 0x8E, 0x21, 0x00, 0x00, 0x18,  0x8C, 0x0A, 0xD0, 0x90, 
	0x20, 0x40, 0x31, 0x20,  0x0C, 0x40, 0x55, 0x00, 0x13, 0x8E, 0x21, 0x00,  0x00, 0x18, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x3C//, 0x5D
};
UINT8 HDMIEDID_4K2K_P0[256] =
{
	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x4d, 0xd9, 0xf3, 0xb4, 0x01, 0x01, 0x01, 0x01,
	0x31, 0x15, 0x01, 0x03, 0x80, 0xe0, 0x77, 0x78, 0x0a, 0x99, 0x55, 0xae, 0x51, 0x49, 0xb2, 0x24,
	0x0d, 0x50, 0x54, 0xa1, 0x08, 0x00, 0x90, 0x40, 0x81, 0x80, 0x81, 0x40, 0x01, 0x01, 0x01, 0x01,
	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38, 0x2d, 0x40, 0x58, 0x2c,
	0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x0e, 0x1f, 0x00, 0x80, 0x51, 0x00, 0x1e, 0x30,
	0x40, 0x80, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x17,
	0x40, 0x0f, 0x44, 0x0f, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
	0x00, 0x56, 0x50, 0x4c, 0x2d, 0x56, 0x57, 0x31, 0x30, 0x30, 0x30, 0x45, 0x53, 0x0a, 0x01, 0xb4,
	0x02, 0x03, 0x33, 0xf0, 0x4c, 0x10, 0x1f, 0x20, 0x05, 0x14, 0x04, 0x13, 0x03, 0x12, 0x07, 0x16,
	0x01, 0x26, 0x09, 0x7f, 0x03, 0x11, 0x7f, 0x18, 0x7a, 0x03, 0x0c, 0x00, 0x10, 0x00, 0xb8, 0x3c,
	0xe0, 0x1c, 0xff, 0x1c, 0xff, 0xc8, 0x88, 0x01, 0x02, 0x03, 0x00, 0x01, 0x40, 0x00, 0x63, 0x38, 
	0x10, 0x48, 0x10, 0x02, 0x3a, 0x80, 0xd0, 0x72, 0x38, 0x2d, 0x40, 0x10, 0x2c, 0x45, 0x80, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x1e, 0x01, 0x1d, 0x80, 0x18, 0x71, 0x1c, 0x16, 0x20, 0x58, 0x2c, 0x25,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, 0x8c, 0x0a, 0xd0, 0x8a, 0x20, 0xe0, 0x2d, 0x10, 0x10,
	0x3e, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x8c, 0x0a, 0xd0, 0x90, 0x20, 0x40, 0x31,
	0x20, 0x0c, 0x40, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x39
};
#ifdef CC_COMBINE_4K_2K
UINT8 u1ProcessRawEdidData(UINT8 panelSize,UINT8 *pU1EdidRawData,UINT8 hdmiPort)
{
	UINT8 displaySizeByte1,displaySizeByte2;
	UINT8 oldDisplaySizeByte1,oldDisplaySizeByte2;
	UINT8 imageSizeByte1,imageSizeByte2,imageSizeByte3;
	UINT8 oldImageSizeByte1,oldImageSizeByte2,oldImageSizeByte3;
	UINT8 oldBlock1CheckSum,oldBlock2CheckSum;
	UINT8 oldPhysicalAddrByte1,oldPhysicalAddrByte2;
	UINT8 i,tempSum;
	switch(panelSize)
	{
		case 0x13:
				{
					displaySizeByte1 = 0x2a;
					displaySizeByte2 = 0x18;
					imageSizeByte1 = 0xa5;
					imageSizeByte2 = 0xed;
					imageSizeByte3 = 0x10;
				}
		break;
		case 0x16:
				{
					displaySizeByte1 = 0x31;
					displaySizeByte2 = 0x1b;
					imageSizeByte1 = 0xe7;
					imageSizeByte2 = 0x12;
					imageSizeByte3 = 0x11;
				}
		break;
		case 0x18:
				{
					displaySizeByte1 = 0x35;
					displaySizeByte2 = 0x1e;
					imageSizeByte1 = 0x13;
					imageSizeByte2 = 0x2b;
					imageSizeByte3 = 0x21;
				}
		break;
		case 0x1a:
				{
					displaySizeByte1 = 0x3a;
					displaySizeByte2 = 0x20;
					imageSizeByte1 = 0x40;
					imageSizeByte2 = 0x44;
					imageSizeByte3 = 0x21;
				}
		break;
		case 0x20:
				{
					displaySizeByte1 = 0x47;
					displaySizeByte2 = 0x28;
					imageSizeByte1 = 0xc4;
					imageSizeByte2 = 0x8e;
					imageSizeByte3 = 0x21;
				}
		break;
		case 0x25:
				{
					displaySizeByte1 = 0x52;
					displaySizeByte2 = 0x2e;
					imageSizeByte1 = 0x33;
					imageSizeByte2 = 0xcd;
					imageSizeByte3 = 0x31;
				}
		break;
		case 0x28:
				{
					displaySizeByte1 = 0x59;
					displaySizeByte2 = 0x32;
					imageSizeByte1 = 0x76;
					imageSizeByte2 = 0xf2;
					imageSizeByte3 = 0x31;
				}
		break;
		case 0x2a:
				{
					displaySizeByte1 = 0x5d;
					displaySizeByte2 = 0x34;
					imageSizeByte1 = 0xa2;
					imageSizeByte2 = 0x0b;
					imageSizeByte3 = 0x32;
				}
		break;
		case 0x2e:
				{
					displaySizeByte1 = 0x66;
					displaySizeByte2 = 0x39;
					imageSizeByte1 = 0xfa;
					imageSizeByte2 = 0x3d;
					imageSizeByte3 = 0x32;
				}
		break;
		case 0x2f:
				{
					displaySizeByte1 = 0x68;
					displaySizeByte2 = 0x3b;
					imageSizeByte1 = 0x10;
					imageSizeByte2 = 0x49;
					imageSizeByte3 = 0x42;
				}
		break;
		case 0x32:
				{
					displaySizeByte1 = 0x6f;
					displaySizeByte2 = 0x3e;
					imageSizeByte1 = 0x53;
					imageSizeByte2 = 0x6f;
					imageSizeByte3 = 0x42;
				}
		break;
		case 0x34:
				{
					displaySizeByte1 = 0x73;
					displaySizeByte2 = 0x41;
					imageSizeByte1 = 0x7f;
					imageSizeByte2 = 0x88;
					imageSizeByte3 = 0x42;
				}
		break;
		case 0x37:
				{
					displaySizeByte1 = 0x7a;
					displaySizeByte2 = 0x44;
					imageSizeByte1 = 0xc2;
					imageSizeByte2 = 0xad;
					imageSizeByte3 = 0x42;
				}
		break;
		case 0x3c:
				{
					displaySizeByte1 = 0x85;
					displaySizeByte2 = 0x4b;
					imageSizeByte1 = 0x30;
					imageSizeByte2 = 0xeb;
					imageSizeByte3 = 0x52;
				}
		break;
		case 0x41:
				{
					displaySizeByte1 = 0x90;
					displaySizeByte2 = 0x51;
					imageSizeByte1 = 0x9f;
					imageSizeByte2 = 0x29;
					imageSizeByte3 = 0x53;
				}
		break;
		case 0x44:
				{
					displaySizeByte1 = 0x97;
					displaySizeByte2 = 0x55;
					imageSizeByte1 = 0xe1;
					imageSizeByte2 = 0x4f;
					imageSizeByte3 = 0x53;
				}
		break;
		case 0x48:
				{
					displaySizeByte1 = 0x9f;
					displaySizeByte2 = 0x5a;
					imageSizeByte1 = 0x3a;
					imageSizeByte2 = 0x81;
					imageSizeByte3 = 0x63;
				}
		break;
		case 0x4b:
				{
					displaySizeByte1 = 0xa6;
					displaySizeByte2 = 0x5d;
					imageSizeByte1 = 0x7c;
					imageSizeByte2 = 0xa6;
					imageSizeByte3 = 0x63;
				}
		break;
		case 0x54:
				{
					displaySizeByte1 = 0xba;
					displaySizeByte2 = 0x69;
					imageSizeByte1 = 0x44;
					imageSizeByte2 = 0x16;
					imageSizeByte3 = 0x74;
				}
		break;
		case 0x38:
				{
					displaySizeByte1 = 0x7c;
					displaySizeByte2 = 0x46;
					imageSizeByte1 = 0xd8;
					imageSizeByte2 = 0xb9;
					imageSizeByte3 = 0x42;
				}
		break;
		case 0x46:
				{
					displaySizeByte1 = 0x9b;
					displaySizeByte2 = 0x57;
					imageSizeByte1 = 0x0e;
					imageSizeByte2 = 0x68;
					imageSizeByte3 = 0x63;
				}
		break;
		case 0x4d:
				{
					displaySizeByte1 = 0xaa;
					displaySizeByte2 = 0x60;
					imageSizeByte1 = 0xa9;
					imageSizeByte2 = 0xbf;
					imageSizeByte3 = 0x63;
				}
		break;
		case 0x2b:
				{
					displaySizeByte1 = 0x5f;
					displaySizeByte2 = 0x36;
					imageSizeByte1 = 0xb8;
					imageSizeByte2 = 0x17;
					imageSizeByte3 = 0x32;
				}
		break;
		case 0x30:
				{
					displaySizeByte1 = 0x6a;
					displaySizeByte2 = 0x3c;
					imageSizeByte1 = 0x27;
					imageSizeByte2 = 0x56;
					imageSizeByte3 = 0x42;
				}
		break;
		case 0x31:
				{
					displaySizeByte1 = 0x6c;
					displaySizeByte2 = 0x3d;
					imageSizeByte1 = 0x3d;
					imageSizeByte2 = 0x62;
					imageSizeByte3 = 0x42;
				}
		break;
		case 0x55:
				{
					displaySizeByte1 = 0xbc;
					displaySizeByte2 = 0x6a;
					imageSizeByte1 = 0x5a;
					imageSizeByte2 = 0x22;
					imageSizeByte3 = 0x74;
				}
		break;
		default:
				{
					UINT32 i4DisplaySizeHTemp = ((UINT32)(16 * panelSize * 2540 * 1000) / 183576);
					UINT32 i4DisplaySizeVTemp = ((UINT32)(9 * panelSize * 2540 * 1000)/ 183576); 

					UINT32 i4DisplaySizeH = (i4DisplaySizeHTemp + 5)/10;
					UINT32 i4DisplaySizeV = (i4DisplaySizeVTemp + 5)/10;
					
					displaySizeByte1 = (i4DisplaySizeHTemp +50)/100;
					displaySizeByte2 = (i4DisplaySizeVTemp +50)/100;

					imageSizeByte1 = (UINT8)i4DisplaySizeH;
					imageSizeByte2 = (UINT8)i4DisplaySizeV;
					imageSizeByte3 = (((i4DisplaySizeH>>8)&0x0f)<<4) |((i4DisplaySizeV>>8)&0x0f);
				}
		break;
	}
	Printf("displaySizeByte1 = %x\n",displaySizeByte1);
	Printf("displaySizeByte2 = %x\n",displaySizeByte2);
	Printf("imageSizeByte1 = %x\n",imageSizeByte1);
	Printf("imageSizeByte2 = %x\n",imageSizeByte2);
	Printf("imageSizeByte3 = %x\n",imageSizeByte3);
	oldDisplaySizeByte1 = pU1EdidRawData[0x15];
	oldDisplaySizeByte2 = pU1EdidRawData[0x16];
	oldImageSizeByte1 = pU1EdidRawData[pU1EdidRawData[0x101]];
	oldImageSizeByte2 = pU1EdidRawData[pU1EdidRawData[0x101]+1];
	oldImageSizeByte3 = pU1EdidRawData[pU1EdidRawData[0x101]+2];
	oldBlock1CheckSum = pU1EdidRawData[0x7f];
	oldBlock2CheckSum = pU1EdidRawData[0xff];
	oldPhysicalAddrByte1 = pU1EdidRawData[pU1EdidRawData[0x100]];
	oldPhysicalAddrByte2 = pU1EdidRawData[pU1EdidRawData[0x100]+1];
	
	pU1EdidRawData[0x15] = displaySizeByte1;
	pU1EdidRawData[0x16] = displaySizeByte2;
	for(i=1;i<=0xf;i++)
	{
		if(pU1EdidRawData[0x100+i]!=0xff)
		{
			pU1EdidRawData[pU1EdidRawData[0x100+i]] = imageSizeByte1;
			pU1EdidRawData[pU1EdidRawData[0x100+i]+1] = imageSizeByte2;
			pU1EdidRawData[pU1EdidRawData[0x100+i]+2] = imageSizeByte3;
		}
	}
	pU1EdidRawData[pU1EdidRawData[0x100]] = pU1EdidRawData[0x110 + (hdmiPort-1) * 2];
	pU1EdidRawData[pU1EdidRawData[0x100]+1] = pU1EdidRawData[0x111 + (hdmiPort-1) * 2];
	tempSum = 0;
	for(i=0;i<=0x7e;i++)
	{
		tempSum += pU1EdidRawData[i];
	}
	pU1EdidRawData[0x7f] = 0x100 - tempSum; 
	tempSum = 0;
	for(i=0x80;i<=0xfe;i++)
	{
		tempSum += pU1EdidRawData[i];
	}
	pU1EdidRawData[0xff] = 0x100 - tempSum; 
	return 1;
}
#endif
UINT8 ptiPanelLess = 0;
UINT8 pti3D = 0;
UINT8 ptiColorSpace = 0;

UINT8 mviDestination = 0;
UINT8 mviChassiType = 2;
UINT8 mviNo3D = 0;

#define PANEL_LESS (ptiPanelLess==0)
#define WITH_PANEL (ptiPanelLess==1)
#define TD_TYPE_NO_3D (pti3D == 0)
#define TD_ACTIVE_3D (pti3D == 1)
#define TD_PASSIVE_3D (pti3D == 2)
#define TD_RESERVED (pti3D == 3)
#define COLORSPACE_NORMAL (ptiColorSpace == 0)
#define COLORSPACE_WCG_1 (ptiColorSpace == 1)
#define COLORSPACE_WCG_2 (ptiColorSpace == 2)
#define COLORSPACE_WCG_3 (ptiColorSpace == 3)

#define DESTINATION_JP (mviDestination == 0xf)
#define CHASSITYPE_QFHD ((mviChassiType == 0x2) ||(mviChassiType == 0x3))
#define CHASSITYPE_FHD  ((mviChassiType == 0x0) ||(mviChassiType == 0x1))
#define MVI_NO3D_3D2D (mviNo3D == 0)
#define MVI_NO3D_NO3D (mviNo3D == 1)
UINT8 u1EdidFlowInLoader(void)
{
	UINT8 localEdid[0x10] = {0};
	UINT8 edidFormat = 1;
	EEPHDMIEDID_Read(0,  (UINT32) localEdid, 0x10);
	if((localEdid[0] == 0x4d) &&(localEdid[1] == 0xd9))
	{
		//format 1, do nothing
		edidFormat = 1;
	}
	else
	{
		if((localEdid[0] == 0x46) &&(localEdid[1] == 0x4d)&&(localEdid[2] == 0x54))
		{
			edidFormat = localEdid[3];
		}
		else
		{
			edidFormat = 1;
		}
	}
	//return (edidFormat == 1)?1:0;
	if(edidFormat == 1)
	{
		return 1;
	}
	else if(edidFormat == 2)
	{
#ifdef CC_COMBINE_4K_2K	
		UINT32 u4SonyModelType = 0;
		if (DRVCUST_InitQuery(eGet2KModelSupport, &u4SonyModelType) == 0)
		{
			if((u4SonyModelType&0x01)==0x00)
			{
				//2k model
				return 1;
			}
			else
			{
				//4k model
				return 0;
			}
		}
#endif
		return 1;
	}
	else if(edidFormat>=3)
	{
		return 0;
	}

    return 0;
}
#if 0 
UINT32 u4EdidSelectIndex(void)
{
	if(PANEL_LESS&&CHASSITYPE_QFHD&&DESTINATION_JP)
	{
		return 0x0396;
	}
	if(PANEL_LESS&&CHASSITYPE_QFHD&&!DESTINATION_JP)
	{
		return 0x0394;
	}
	if(PANEL_LESS&&!CHASSITYPE_QFHD&&DESTINATION_JP)
	{
		return 0x039f;
	}
	if(PANEL_LESS&&!CHASSITYPE_QFHD&&!DESTINATION_JP)
	{
		return 0x039d;
	}
	if(WITH_PANEL&&CHASSITYPE_QFHD&&!COLORSPACE_NORMAL&&MVI_NO3D_3D2D&&\
		!TD_TYPE_NO_3D&&DESTINATION_JP)
	{
		return 0x0396;
	}
	if(WITH_PANEL&&CHASSITYPE_QFHD&&!COLORSPACE_NORMAL&&MVI_NO3D_3D2D&&\
		!TD_TYPE_NO_3D&&!DESTINATION_JP)
	{
		return 0x0394;
	}
	if(WITH_PANEL&&CHASSITYPE_FHD&&!COLORSPACE_NORMAL&&DESTINATION_JP)
	{
		return 0x039c;
	}
	if(WITH_PANEL&&CHASSITYPE_FHD&&!COLORSPACE_NORMAL&&!DESTINATION_JP)
	{
		return 0x039a;
	}
	if(WITH_PANEL&&CHASSITYPE_FHD&&COLORSPACE_NORMAL&&MVI_NO3D_3D2D\
		&&!TD_TYPE_NO_3D&&DESTINATION_JP)
	{
		return 0x039f;
	}
	if(WITH_PANEL&&CHASSITYPE_FHD&&COLORSPACE_NORMAL&&MVI_NO3D_3D2D\
		&&!TD_TYPE_NO_3D&&!DESTINATION_JP)
	{
		return 0x039d;
	}
	if(WITH_PANEL&&CHASSITYPE_FHD&&COLORSPACE_NORMAL&&MVI_NO3D_NO3D\
		&&!DESTINATION_JP)
	{
		return 0x03a2;
	}
	if(WITH_PANEL&&CHASSITYPE_FHD&&COLORSPACE_NORMAL&&MVI_NO3D_NO3D\
		&&!DESTINATION_JP)
	{
		return 0x03a0;
	}
	return 0;
}
#else
UINT32 u4EdidSelectIndex(void)
{
	if(PANEL_LESS)
	{
		if(CHASSITYPE_QFHD)
		{
			if(DESTINATION_JP)
			{
				return 0x0396;
			}
			else
			{
				return 0x0394;
			}
		}
		else
		{
			if(DESTINATION_JP)
			{
				return 0x039f;
			}
			else
			{
				return 0x039d;
			}

		}
	}
	else if(WITH_PANEL)
	{
		if(CHASSITYPE_QFHD)
		{
			if(!COLORSPACE_NORMAL)
			{
				if(MVI_NO3D_3D2D)
				{
					if(!TD_TYPE_NO_3D)
					{
						if(DESTINATION_JP)
						{
							return 0x0396;
						}
						else
						{
							return 0x0394;
						}
					}
					else
					{
						if(DESTINATION_JP)
						{
							return 0x0399;
						}
						else
						{
							return 0x0397;
						}
					}
				}
				else
				{
					if(DESTINATION_JP)
					{
						return 0x0399;
					}
					else
					{
						return 0x0397;
					}
				}
			}
			else
			{
				if(MVI_NO3D_3D2D)
				{
					if(!TD_TYPE_NO_3D)
					{
						if(DESTINATION_JP)
						{
							return 0x03d4;
						}
						else
						{
							return 0x03d2;
						}

					}
					else
					{
						if(DESTINATION_JP)
						{
							return 0x03c3;
						}
						else
						{
							return 0x03c4;
						}					
					}
				}
				else
				{
					if(DESTINATION_JP)
					{
						return 0x03c3;
					}
					else
					{
						return 0x03c4;
					}
				}
			}
		}
		else
		{
			if(!COLORSPACE_NORMAL)
			{
				if(DESTINATION_JP)
				{
					return 0x039c;
				}
				else
				{
					return 0x039a;
				}
			}
			else
			{
				if(MVI_NO3D_3D2D)
				{
					if(!TD_TYPE_NO_3D)
					{
						if(DESTINATION_JP)
						{
							return 0x039f;
						}
						else
						{
							return 0x039d;
						}
					}
					else
					{
						if(DESTINATION_JP)	// add Oct11:from here 
						{
							return 0x03a2;
						}
						else
						{
							return 0x03a0;
						}					// add Oct11: to here
					}
				}
				else
				{
					if(DESTINATION_JP)
					{
						return 0x03a2;
					}
					else
					{
						return 0x03a0;
					}
				}
			}
		}
	}
	else
	{
		return 0;
	}
}
#endif
#ifdef CC_PANEL_FROM_FLASH
extern UINT32 FlashPanel_GetControlWord3(void);
extern UINT32 FlashPanel_GetInchSize(void);
#endif
#if defined(CC_SAKURA_CUST_DRV)
void readEmmcBostonEdidData(UINT8 data[256],UINT8 port)
{
	UINT32 partId = 0;
	UINT32 offsetOfBostonEdid = 0x10 + 0x5000 + (port-1)*256;
	partId = (INT32) DRVCUST_InitGet(eHDMIBOSTONFWPartId);
#ifdef CC_MTK_LOADER
	#ifndef CC_UBOOT
			Loader_ReadMsdc(partId, offsetOfBostonEdid, data, 0x100);
	#endif
#else	
	{
		UINT64 u8Offset = 0;
		u8Offset = offsetOfBostonEdid |(((UINT64)(UINT32)partId) << 32);
		MSDCPART_Read(u8Offset,(UINT32)data, 0x100);	
	}
#endif

}
void writeEmmcBostonEdidData(UINT8 data[256],UINT8 port)
{
	UINT32 partId = 0;
	UINT32 offsetOfBostonEdid = 0x10 + 0x5000 + (port-1)*256;
	partId = (INT32) DRVCUST_InitGet(eHDMIBOSTONFWPartId);
	#ifdef CC_MTK_LOADER
		#ifndef CC_UBOOT
			Loader_WriteMsdc(partId, offsetOfBostonEdid, data, 0x100);
		#endif
	#else	
		{
			UINT64 u8Offset = 0;
			u8Offset = offsetOfBostonEdid |(((UINT64)(UINT32)partId) << 32);
			MSDCPART_Write(u8Offset, (UINT32)data, 0x100);			
		}
	#endif
}
void readEmmcBostonData(UINT8 *data,UINT32 dataOffset,UINT32 length)
{
	UINT32 partId = 0;
	partId = (INT32) DRVCUST_InitGet(eHDMIBOSTONFWPartId);
#ifdef CC_MTK_LOADER
	#ifndef CC_UBOOT
			Loader_ReadMsdc(partId, dataOffset, data, length);
	#endif
#else		
	{
		UINT64 u8Offset = 0;
		u8Offset = dataOffset |(((UINT64)(UINT32)partId) << 32);
		MSDCPART_Read(u8Offset, (UINT32)data, length);		
	}
#endif
}
void writeEmmcBostonData(UINT8 *data,UINT32 dataOffset,UINT32 length)
{
	UINT32 partId = 0;
	partId = (INT32) DRVCUST_InitGet(eHDMIBOSTONFWPartId);
	#ifdef CC_MTK_LOADER
		#ifndef CC_UBOOT
			Loader_WriteMsdc(partId, dataOffset, data, length);
		#endif
	#else	
	{
			UINT64 u8Offset = 0;
			u8Offset = dataOffset |(((UINT64)(UINT32)partId) << 32);
			MSDCPART_Write(u8Offset, (UINT32)data, length);		
	}
	#endif
}
void setEmmcEdidRequest(void)
{
	UINT8 edidRequest =1;
	writeEmmcBostonData(&edidRequest,15,1);
}
void clearEmmcEdidRequest(void)
{
	UINT8 edidRequest = 0;
	writeEmmcBostonData(&edidRequest,15,1);
}
UINT8 IsEdidOfBostonAndIcSame(UINT8 boston[256],UINT8 hostIC[256])
{
	UINT32 i;
	for(i=0;i<256;i++)
	{
		if(boston[i]!=hostIC[i])
		{
			return 0;
		}
	}
	return 1;
}
void replaceEdidOfBoston(UINT8 data[256],UINT8 physicalAddr,UINT8 port2Addr,UINT8 port3Addr,UINT8 port4Addr)
{
	UINT8 checkSum;
	writeEmmcBostonEdidData(data,1);
	checkSum = data[physicalAddr] + data[255];
	data[physicalAddr] = port2Addr;
	data[255] = (checkSum>=port2Addr)?(checkSum - port2Addr):(checkSum + 0x100- port2Addr);	
	writeEmmcBostonEdidData(data,2);
	data[physicalAddr] = port3Addr;
	data[255] = (checkSum>=port3Addr)?(checkSum - port3Addr):(checkSum + 0x100- port3Addr);
	writeEmmcBostonEdidData(data,3);
	data[physicalAddr] = port4Addr;
	data[255] = (checkSum>=port4Addr)?(checkSum - port4Addr):(checkSum + 0x100- port4Addr);
	writeEmmcBostonEdidData(data,4);
}
void edidOfBostonCheck(UINT8 hostIc[256],UINT8 physicalAddr,UINT8 port2Addr,UINT8 port3Addr,UINT8 port4Addr)
{
	UINT8 boston[256];
	readEmmcBostonEdidData(boston,1);
	if(	IsEdidOfBostonAndIcSame(boston,hostIc)==0)
	{
		replaceEdidOfBoston(hostIc,physicalAddr,port2Addr,port3Addr,port4Addr);
		setEmmcEdidRequest();
	}
}
void edidOfBostonCheck4port(UINT8 *host1024ByteEdid)
{
	UINT32 i,j;
	UINT8 boston[256];
	for(i=1;i<=4;i++)
	{
		readEmmcBostonEdidData(boston,i);
		if(	IsEdidOfBostonAndIcSame(boston,&host1024ByteEdid[(i-1)*256])==0)
		{
			writeEmmcBostonEdidData(&host1024ByteEdid[(i-1)*256],i);
			for(j=0;j<256;j++)
			{
				//printf("%x , ", host1024ByteEdid[(i-1)*256 + j]);
				if(j%16 == 0)
				{
					//printf("\n");
				}
			}
			setEmmcEdidRequest();
		}
	}
}
#endif
UINT32 u4EdidSecondIDCheck(UINT32 mainId,UINT8 fgHFVSDB)
{
	UINT32 secondId = mainId;
	if(fgHFVSDB)
	{
		switch(mainId)
		{
			case 0x0394:
				secondId = 0x03c8;
				break;
			case 0x0396:
				secondId = 0x03c7;
				break;
			case 0x03d2:
				secondId = 0x03d3;
				break;
			case 0x03d4:
				secondId = 0x03d5;
				break;				
			case 0x0397:
				secondId = 0x03ca;
				break;
			case 0x0399:
				secondId = 0x03c9;
				break;
			case 0x03c4:
				secondId = 0x03c6;
				break;
			case 0x03c3:
				secondId = 0x03c5;
				break;	
			default:
				break;
		}
	}
	return secondId;
}
#define HDMI_MAX_EDID_INDEX 64
void vDrvLoadHdmiEdid2Table(void)
{
#ifndef CC_FPGA
    UINT64 u8Offset;
    UINT8 idx = 0;
    //read form eeprom or flash to VGA_EDID_TABLE

#ifdef CC_MULTI_EDID
    UINT32 u4EdidOffset;
    if(DRVCUST_InitQuery(eEdidHdmiIndexOffset, &u4EdidOffset) == 0)
    {
        EEPROM_Read((UINT64)u4EdidOffset, (UINT32)&idx, 1);
    }
#endif

    if((idx+1)*HDMI_EDID_SIZE > HDMI_EDID_STORAGE_SIZE)
    {
        u8Offset = 0;
    }
    else
    {
        u8Offset = idx*HDMI_EDID_SIZE;
    }
#ifdef CC_COMBINE_4K_2K
		{
			UINT32 i;
			UINT8 panelSize;
			UINT8 edidIndex;
			UINT32 mainEdidVersion;
			UINT32 secondEdidVersion;
			//UINT8 edidFormat = 1;
#ifdef CC_PANEL_FROM_FLASH
			UINT32 ptiInfo;
#endif
			UINT8 edidRawData[0x200];
			UINT8 edidHFVSDBinfo = 0;
			UINT8 *edidDataPointer = NULL;
			UINT8 localEdid[10] = {0};			
			UINT8 edidReadOffset = 0;
			UINT8 hdmiPortEdidProcess = 1;
			
			EEPHDMIEDID_Read(0,  (UINT32) localEdid, 0x10);
			EEPROM_Read(0x38e,(UINT32)(&edidHFVSDBinfo),0x1);
			if((localEdid[0] == 0x4d) &&(localEdid[1] == 0xd9))
			{
				edidReadOffset = 0;
			}
			else
			{
				edidReadOffset = 0x10;
			}
			EEPROM_Read(0x10010,(UINT32)&mviChassiType,1);
			EEPROM_Read(0x10200,(UINT32)&mviDestination,1);
			EEPROM_Read(0x10206,(UINT32)&mviNo3D,1);
#ifdef CC_PANEL_FROM_FLASH
			ptiInfo = FlashPanel_GetControlWord3();
			ptiPanelLess = ((ptiInfo>>31) & (0x1));
			pti3D = (ptiInfo & (0x0c000000))>>26;	// modify at Oct11; from "(0x70000000))>>28"
			ptiColorSpace = (ptiInfo & 0x3);
			Printf("ptiInfo= %x\n",ptiInfo);
			Printf("ptiPanelLess= %x\n",ptiPanelLess);
			Printf("pti3D= %x\n",pti3D);
			Printf("ptiColorSpace= %x\n",ptiColorSpace);	
			Printf("edidHFVSDBinfo= %x\n",edidHFVSDBinfo);
#endif
			Printf("mviChassiType= %x\n",mviChassiType);
			Printf("mviDestination= %x\n",mviDestination);
			Printf("mviNo3D= %x\n",mviNo3D);
			mainEdidVersion = u4EdidSelectIndex();
			Printf("mainEdidVersion= %x\n",mainEdidVersion);			
			if(mainEdidVersion == 0)
			{
				Printf("can not select valid edid\n");
				mainEdidVersion = 0x0394;
			}
			{
				UINT32 u4SonyModelType = 0;
				if (DRVCUST_InitQuery(eGet2KModelSupport, &u4SonyModelType) == 0)
				{
					if((u4SonyModelType&0x01)==0x00)
					{
						//2k model
						hdmiPortEdidProcess = 1;
						//return 1;
						
					}
					else
					{
						//4k model
						hdmiPortEdidProcess = 4;
						//return 0;
					}
				}
			}
	
	Printf("HDMI_MAX_EDID_INDEX is %d>>>>>>>>>>>>>>>>>>>>\n",HDMI_MAX_EDID_INDEX);
	for(i=0;i<hdmiPortEdidProcess;i++)
	{
		secondEdidVersion = u4EdidSecondIDCheck(mainEdidVersion,(edidHFVSDBinfo&(1<<i)));
		edidDataPointer = ((UINT8*)edidRawData + 0x10); //for jump header
		for(edidIndex = 0;edidIndex < HDMI_MAX_EDID_INDEX; edidIndex++)
		{
			EEPHDMIEDID_Read(edidReadOffset + edidIndex*0x200,  (UINT32) edidRawData, 0x200);
			if((edidRawData[2] == ((secondEdidVersion & 0xff00)>>8))&&(edidRawData[3] == (secondEdidVersion & 0xff)))
			{

				Printf("find valid edid, break to process edid......,Index %d:0x%02x 0x%02x\n",edidIndex,edidRawData[2],edidRawData[3]);
				break;
			}
		}
		if(edidIndex==HDMI_MAX_EDID_INDEX)
		{
			Printf("invalid edid,select default edid to process......\n");
			EEPHDMIEDID_Read(edidReadOffset + 0*0x200,  (UINT32) edidRawData, 0x200);
		}
#ifdef CC_PANEL_FROM_FLASH
		panelSize = FlashPanel_GetInchSize();  // need to change to panelSizeApi;		
#else
		panelSize = 0x38;		
#endif
		u1ProcessRawEdidData(panelSize,edidDataPointer,i+1);
		{
			UINT32 j = 0;
			for(j=0;j<=0xff;j++)
			{
				HDMIBOSTONEDID_table[i*256+j]=edidDataPointer[j];
				
				//if(j%16 == 0)
				//	Printf("\n");
				//Printf("%x	",edidDataPointer[j]);
			}
		}
	}
//
#if defined(CC_SAKURA_CUST_DRV)
#ifdef CC_SUPPORT_BOSTON_SWITCH
		//edidOfBostonCheck(HDMIEDID_table,u1PAOffset,HDMI2_CEC_PHY_ADR,HDMI3_CEC_PHY_ADR,HDMI4_CEC_PHY_ADR);
	edidOfBostonCheck4port(HDMIBOSTONEDID_table);
#endif
#endif

	for(i=0;i<=0xff;i++)
	{
		HDMIEDID_table[i] = edidDataPointer[i];
		if(i%16 == 0)
			Printf("\n");
		Printf("%x	",HDMIEDID_table[i]);

	}
	Printf("secondEdidVersion edidVersion =%d \n",secondEdidVersion);


	HDMICEC_SETTING[0] = edidDataPointer[0x112];
	HDMICEC_SETTING[1] = edidDataPointer[0x114];
			HDMICEC_SETTING[2] = edidDataPointer[0x116];
			
			Printf("\nphysical addr port2:%x	\n",HDMICEC_SETTING[0]);
			
			Printf("physical addr port3:%x	\n",HDMICEC_SETTING[1]);

			Printf("physical addr port4:%x	\n",HDMICEC_SETTING[2]);
		}

#else
    //read form eeprom or flash to HDMIEDID_CEC_192k_DeepColor12B_P0
    if (EEPHDMIEDID_Read(u8Offset,  (UINT32) HDMIEDID_table, HDMI_EDID_SIZE ))
    {
        Printf("read eeprom edid fail\n");
    }
#endif
#endif
}
#ifdef CC_COMBINE_4K_2K
#ifdef CC_PANEL_FROM_FLASH
UINT32 u4EdidVersion(void)
{	
	UINT32 ptiInfo;
	UINT32 edidVersion;
	EEPROM_Read(0x10010,(UINT32)&mviChassiType,1);
	EEPROM_Read(0x10200,(UINT32)&mviDestination,1);
	EEPROM_Read(0x10206,(UINT32)&mviNo3D,1);
	ptiInfo = FlashPanel_GetControlWord3();
	ptiPanelLess = ((ptiInfo>>31) & (0x1));
	pti3D = (ptiInfo & (0x0c000000))>>26;
	ptiColorSpace = (ptiInfo & 0x3);	
	edidVersion = u4EdidSelectIndex();
	return edidVersion;
}
UINT32 u4GetEdidRawData(UINT8 *edidData)
{	
	UINT8 edidRawData[0x200];
	UINT8 *edidDataPointer = NULL;
	UINT8 edidIndex;
	UINT32 i;
	UINT32 edidVersion = u4EdidVersion();
	edidDataPointer = ((UINT8*)edidRawData + 0x10); //for jump header
	for(edidIndex = 0;edidIndex < 20; edidIndex++)
	{
		EEPHDMIEDID_Read(edidIndex*0x200,  (UINT32) edidRawData, 0x200);
		if((edidRawData[2] == ((edidVersion & 0xff00)>>8))&&(edidRawData[3] == (edidVersion & 0xff)))
		{	
			Printf("find valid edid, break to process edid......\n");
			break;
		}
	}
	if(edidIndex==20)
	{
		Printf("invalid edid,select default edid to process......\n");
		EEPHDMIEDID_Read(0*0x200,  (UINT32) edidRawData, 0x200);
		return 1;
	}
	for(i=0;i<0x200;i++)
	{
		edidData[i] = edidRawData[i];
	}
	return 0;
}
#endif
#endif
#endif

#endif // _EDID_CUSTOMIZATION_H_
