/* 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: brianpc.huang $
 * $Date  $
 * $RCSfile: api_eep.h,v $
 * $Revision: #1 $
 *
 *---------------------------------------------------------------------------*/

/**
 * @EEPROM service function
 *
 * @author Kenny Huang
 */

#ifndef _API_EEP_H_
#define _API_EEP_H_

/**
 * read a UINT8 data from EEPROM shadow
 * If the address is valid, the return value is the data in the given address.
 * else the return value is always 0.
 *
 * @param wAddr EEPROM data address to be read
 * @return read data
 */
extern UINT8 bApiEepromReadByte(UINT16 wAddr);

/**
 * write a UINT8 data into EEPROM shadow
 * If not write shadow only, a write command will be added into command queue.
 *
 * @param wAddr EEPROM data address for writting data
 * @param bData data to be written
 * @return 0 or 1
 * @retval = 1 data is added into shadow and command is added into queue
 * @retval = 0 EEPROM write queue is full or the given address is invalid
 */
extern BOOL fgApiEepromWriteByte(UINT16 wAddr, UINT8 bData);

/**
 * read data from EEPROM shadow area in DRAM
 *
 * @param wPrm item ID that will be retrieved
 * @param pDst destination address
 * @param wLen number of bytes
 * @return NONE
 */
extern void vApiEepromDmaRead(UINT16 wPrm, void *pDst, UINT16 wLen);

/**
 * write data into EEPROM shadow area in DRAM
 *
 * @param wPrm item ID that will be written
 * @param pDst source address
 * @param wLen number of bytes
 * @return NONE
 */
extern void vApiEepromDmaWrite(UINT16 wPrm, void *pSrc, UINT16 wLen);

/**
 * Check EEPROM of NPTV valid or not
 *
 * @return TRUE or FALSE
 */
extern BOOL fgApiIsEepromMagicOK(void);
extern void  vApiEepromDefaultInit(void) ;


extern UINT8 _pbEepromMagic[4];

extern UINT16 wEEP_VIDEO_AUTO_COLOR_START;
//extern UINT16 wEEP_VIDEO_AUTO_COLOR_VGA_DONE;
//extern UINT16 wEEP_VIDEO_AUTO_COLOR_HDTV_DONE;
//extern UINT16 wEEP_VIDEO_AUTO_COLOR_DIFF_1;
extern UINT16 wEEP_ON_CHIP_AUTO_COLOR_GAIN_DONE;
extern UINT16 wEEP_ON_CHIP_AUTO_COLOR_OFFSET_ADDRESS_START;
#if 0
extern UINT16 wEEP_EXT_AUTO_COLOR_START;
extern UINT16 wEEP_VGA_CLOCK_START;
extern UINT16 wEEP_VGA_PHASE_START;
extern UINT16 wEEP_VGA_H_POSITION_START;
extern UINT16 wEEP_VGA_V_POSITION_START;
extern UINT16 wEEP_BYTE_TV_REGION;
extern UINT16 wEEP_CUSTOM_NAMED_CH_NUM;
extern UINT16 wEEP_CUSTOM_NAMED_CH;
extern UINT16 wEEP_CUSTOM_CH_NAME;
extern UINT16 wEEP_ADC_OFFSET_TV_CLAMP_DONE;
extern UINT16 wEEP_ADC_INPUT_OFFSET_TV_CH0_CLAMP;
extern UINT16 wEEP_ADC_OUTPUT_OFFSET_TV_CH0_CLAMP;
extern UINT16 wEEP_ADC_INPUT_OFFSET_TV_CH1_CLAMP;
extern UINT16 wEEP_ADC_OUTPUT_OFFSET_TV_CH1_CLAMP;
extern UINT16 wEEP_ADC_DFE_LEVEL_TV_DCLAMP;
extern UINT16 wEEP_ADC_OFFSET_CLAMP_BUT_LOW;
extern UINT16 wEEP_ADC_OFFSET_HDTV_CLAMP;
#endif



#endif //_API_EEP_H_
