/**
 * @file hv_cal_ktx.h
 * @brief Header file of cal ktx module.
 * 
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * 
 * @endverbatim
 *
 * @author HiView SoC Software Team
 * @version 0.0.1
 * @date 2022-09-03
 */

#ifndef _HV_CAL_KTX_H_
#define _HV_CAL_KTX_H_
#include "hv_comm_DataType.h"
#include "hv_cal_KtxCommon.h"
#include "hv_comm_Define.h"

/* KTX attribute */

#define KTX_SOURCE_NUM              (1)
#define KTX_FLIP_ENABLE             (0)
#define TX_PPC                      (1)            /* 获取芯片设计的PPC */
#define TX_IN_PRE_DE_BEFORE_KTX     (5)
#define KTX_GATE_NUM                (1)
#define TX_GRP_00_DCLK_SEL          (0)            /* 规避插红屏闪三条黑线的问题 */



/**
 * @brief 
 * @return 0: 10bits; 1: 8bits; 2: 6bits
 */
UCHAR8 Hv_Cal_Ktx_GetOutDataMode(VOID);

/**
 * @brief 获取芯片设计的PLL Vco Range
 */
VOID Hv_Cal_Ktx_GetTxPLLVcoRange(UINT32 *puiMax, UINT32 *puiMin);

/**
 * @brief The function write register COMBOTX_PHY.
 * @param[in] stHvKtxCombotxPhyMux CombotxPhy param.
 */
VOID Hv_Cal_Ktx_ComboTxPhyMuxSel(UCHAR8 ucPhyIdx, const PanelParam *pstPanelParam);

/**
 * @brief The function write registera about E1 - KTX_POST_TOP.
 * @param[in] pstKtxTostTopParam KTX_POST_TOP_00 param.
 */
VOID Hv_Cal_Ktx_SetPostTopParam(HvKtxPostTopCfgParam *pstKtxTostTopParam);

/**
 * @brief The function write registera about F0 - COMBOTX_PHY_0.
 * @param[in] idx pll indx.
 * @param[in] pstKtxPllParam COMBOTX_PHY_0 param.
 */
VOID Hv_Cal_Ktx_SetPllParam(UINT32 idx, HvKtxPllCfgParam *pstKtxPllParam);

/**
 * @brief The function write registera about E0 - PIF_TX_TOP.
 * @param[in] pstKtxPIFParam PIF_TX_TOP param.
 */
VOID Hv_Cal_Ktx_SetPifParam(HvKtxPIFCfgParam *pstKtxPIFParam);

/**
 * @brief Phy enable.
 * @param[in] bPhy Phy num.
 */
VOID HV_Cal_Ktx_ComboTxPhyEn(UCHAR8 ucPhy, BOOL bEn);

/**
 * @brief Get phy afifo flag.
 */
BOOL Hv_Cal_Ktx_GetTxPhyAfifoFlag(VOID);

/**
 * @brief phy afifo flag clear.
 */
VOID Hv_Cal_Ktx_TxPhyAfifoFlagClear(VOID);

/**
 * @brief Get ktx post fifo flag.
 */
BOOL Hv_Cal_Ktx_GetKtxPostFifoFlag(VOID);

/**
 * @brief ktx post fifo flag clear.
 */
VOID Hv_Cal_Ktx_KtxPostFifoFlagClear(VOID);

/**
 * @brief Get ktx pif afifo flag.
 */
BOOL Hv_Cal_Ktx_GetKtxPifAfifoFlag(VOID);

/**
 * @brief ktx pif afifo flag Clear.
 */
VOID Hv_Cal_Ktx_KtxPifAfifoFlagClear(VOID);

/**
 * @brief Pif Start.
 */
VOID Hv_Cal_Ktx_PifStart(BOOL bStart);

/**
 * @brief Pif reset.
 */
VOID Hv_Cal_Ktx_PifRst(BOOL bRst);

/**
 * @brief tx mac reset, vbo and edp.
 */
VOID Hv_Cal_Ktx_TxMacRst(BOOL bRst);

/**
 * @brief KTX fix settings.
 */
VOID Hv_Cal_Ktx_BasicInit(const PanelParam *pstPanelParam);

/**
 * @brief KTX Pll Reset.
 */
VOID Hv_Cal_Ktx_PllReset(BOOL bRst);

/**
 * @brief KTX Pll enable.
 */
VOID Hv_Cal_Ktx_PllEn(BOOL bEn);

/**
 * @brief txphy_rd_clk_en enable.
 * @param[in] usEn enable num.
 */
VOID Hv_Cal_Ktx_TxPhyRdClkEn(USHORT16 usEn);

/**
 * @brief txphy_rd_clk_en enable.
 * @param[in] bEn enable.
 */
VOID Hv_Cal_Ktx_PifPreClkEn(BOOL bEn);

/**
 * @brief pif_lane_clk_en enable.
 * @param[in] usEn enable lane num.
 */
VOID Hv_Cal_Ktx_PifLaneClkEn(BOOL bEn);

/**
 * @brief Get KTX Pll Lock Status.
 * @return 0: unlock 1:lock.
 */
UCHAR8 Hv_Cal_Ktx_PllLockStatus(VOID);

/**
 * @brief 设置Panel 12V 电源.
 * @param[in] ucEn Panel power.
 */
VOID Hv_Cal_Ktx_SetPanelPowerOn(UCHAR8 ucEn);

/**
 * @brief 设置背光板5V 电源
 * @param[in] ucEn backlight power.
 */
VOID Hv_Cal_Ktx_SetBacklightPower(UCHAR8 ucEn);

/**
 * @brief show ktx pattern
 * @param[in] ucPatternMode different pattern color.
 */
Status Hv_Cal_Ktx_SetKtxPatt(UCHAR8 ucKtxPattSwitch, UCHAR8 ucPatternMode);

/**
 * @brief open ktx post cursor
 */
VOID Hv_Cal_Ktx_SetTxPostCursroParam(UINT32 uiHpost, UINT32 uiVpost,UINT32 uiR, UINT32 uiG, UINT32 uiB);

/**
 * @brief 保存panel状态到寄存器
 */
VOID Hv_Cal_Ktx_SetPanelState(USHORT16 usState);

/**
 * @brief 保存power状态到寄存器
 */
VOID Hv_Cal_Ktx_SetPowerState(USHORT16 usState);

/**
 * @brief 保存开机原因到寄存器
 */
VOID Hv_Cal_Ktx_SetPowerOnReason(USHORT16 usReason);
#endif
