/* 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 "eeprom_if.h"
#ifndef CC_VGA_EDID_DISABLE
CODE UINT8 VGA_EDID_TABLE[256] =
{
	0x00, 0xFF, 0xFF, 0xFF,  0xFF, 0xFF, 0xFF, 0x00,   0x36, 0x8B, 0x10, 0x00,  0x01, 0x01, 0x01, 0x01, 
	0x07, 0x14, 0x01, 0x03,  0x1F, 0x5D, 0x34, 0x78,   0xCA, 0x31, 0xC3, 0xA3,  0x55, 0x4A, 0x9B, 0x24, 
	0x10, 0x47, 0x4A, 0xAF,  0xCF, 0x00, 0x01, 0x01,   0x01, 0x01, 0x01, 0x01,  0x01, 0x01, 0x01, 0x01, 
	0x01, 0x01, 0x01, 0x01,  0x01, 0x01, 0x1A, 0x36,   0x80, 0xA0, 0x70, 0x38,  0x1F, 0x40, 0x30, 0x20, 
	0x35, 0x00, 0xA2, 0x0B,  0x32, 0x00, 0x00, 0x1A,   0x00, 0x00, 0x00, 0xFD,  0x00, 0x32, 0x55, 0x1F, 
	0x46, 0x0F, 0x00, 0x0A,  0x20, 0x20, 0x20, 0x20,   0x20, 0x20, 0x00, 0x00,  0x00, 0xFF, 0x00, 0x53, 
	0x4B, 0x46, 0x4A, 0x42,  0x4C, 0x30, 0x37, 0x30,   0x32, 0x30, 0x32, 0x39,  0x00, 0x00, 0x00, 0xFC, 
	0x00, 0x53, 0x56, 0x34,  0x32, 0x32, 0x58, 0x56,   0x54, 0x0A, 0x20, 0x20,  0x20, 0x20, 0x00, 0x5D, 
	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)
{
    UINT64 u8Offset;
    UINT8 idx = 0;
    //read form eeprom or flash to VGA_EDID_TABLE

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

    if((idx+1)*VGA_EDID_SIZE > VGA_EDID_STORAGE_SIZE)
    {
        u8Offset = 0;
    }
    else
    {
        u8Offset = idx*VGA_EDID_SIZE;
    }
    //Printf("read edid from eeprom\n");
#ifndef CC_DISABLE_VGA_EDID_FROM_EEP //wait for eeprom ready
    if(EEPVGAEDID_Read(u8Offset,  (UINT32) VGA_EDID_TABLE, VGA_EDID_SIZE ))
    {
        Printf("read eeprom edid fail\n");
    }
#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 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,  0x4B, 0x84, 0x10, 0x1F, 0x05, 0x13, 0x14, 0x01,  0x02, 0x11, 0x06, 0x15, 
	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, 0x00, 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
};	
UINT8 u1ProcessRawEdidData(UINT8 panelSize,UINT8 *pU1EdidRawData)
{
	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 = 0x30;
					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;
		default:
				{
					displaySizeByte1 = 0x6f;
					displaySizeByte2 = 0x3e;
					imageSizeByte1 = 0x53;
					imageSizeByte2 = 0x6f;
					imageSizeByte3 = 0x42;
				}
		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;
	pU1EdidRawData[pU1EdidRawData[0x101]] = imageSizeByte1;
	pU1EdidRawData[pU1EdidRawData[0x101]+1] = imageSizeByte2;
	pU1EdidRawData[pU1EdidRawData[0x101]+2] = imageSizeByte3;
	pU1EdidRawData[pU1EdidRawData[0x102]] = imageSizeByte1;
	pU1EdidRawData[pU1EdidRawData[0x102]+1] = imageSizeByte2;
	pU1EdidRawData[pU1EdidRawData[0x102]+2] = imageSizeByte3;
	pU1EdidRawData[pU1EdidRawData[0x103]] = imageSizeByte1;
	pU1EdidRawData[pU1EdidRawData[0x103]+1] = imageSizeByte2;
	pU1EdidRawData[pU1EdidRawData[0x103]+2] = imageSizeByte3;
	pU1EdidRawData[pU1EdidRawData[0x104]] = imageSizeByte1;
	pU1EdidRawData[pU1EdidRawData[0x104]+1] = imageSizeByte2;
	pU1EdidRawData[pU1EdidRawData[0x104]+2] = imageSizeByte3;
	
	pU1EdidRawData[pU1EdidRawData[0x100]] = pU1EdidRawData[0x110];
	pU1EdidRawData[pU1EdidRawData[0x100]+1] = pU1EdidRawData[0x111];
	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; 
}
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;
			UINT8 edidRawData[0x200];
			UINT8 *edidDataPointer = NULL;
			edidDataPointer = ((UINT8*)edidRawData + 0x10); //for jump header
			edidIndex = 0;	// need to change to INDEX API
			EEPHDMIEDID_Read(edidIndex*0x200,  (UINT32) edidRawData, 0x200);
			panelSize = 0x38;  // need to change to panelSizeApi;			
			u1ProcessRawEdidData(panelSize,edidDataPointer);
			for(i=0;i<=0xff;i++)
			{
				HDMIEDID_table[i] = edidDataPointer[i];
				if(i%16 == 0)
					Printf("\n");
				Printf("%x	",HDMIEDID_table[i]);
	
			}
			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
}
#endif

#endif // _EDID_CUSTOMIZATION_H_
