/**
 * @file drv_hdmi.h
 * @brief HDMI RX driver layer interface.
 * @verbatim
 * ==============================================================================
 *                        ##### How to use this driver #####
 * ==============================================================================
 * (+) Use Hv_HDMIRx_DataInit(...) to Init the HDMI RX Data.
 * (+) Use Hv_HDMIRx_GetCableConnect(...) to Get the Cable Connection status.
 * (+) Use Hv_HDMIRx_RegisterIntCallBack(...) to register the Interrupt Call Back function. 
 * @endverbatim
 *
 * @author HiView SoC Software Team
 * @version 0.0.1
 * @date 2022-08-22
 */

#ifndef __HV_DRV_HDMIRX_H__
#define __HV_DRV_HDMIRX_H__

#include "hv_cal_HdmiRx.h"
#include "hv_cal_HdmiInc.h"

/**
 * @brief Initialize the hdmi parameter for the indicated port.
 * @param[in] Port Number used for the HDMI RX.
 * @return VOID without return.
 */
VOID Hv_Drv_HdmiRx_CecInit(UCHAR8 ucPortIndex);

/**
 * @brief HPD Control with switch.
 * @param[in] Port Index of HDMI and the HPD switch.
 * @return 0: Success or 1: Fail.
 */
Status Hv_Drv_HdmiRx_HPDCtrol(UCHAR8 ucPortIndex, BOOL bSwitch);

/**
 * @brief Initialize the hdmi parameter for the indicated port.
 * @param[in] Port Index used for the HDMI RX.
 * @return Status with 0: Success, 1: Failure.
 */
Status Hv_Drv_HdmiRx_PortInit(UCHAR8 ucPortIndex);

/**
 * @brief Get HDMI Rx AVI info.
 * @param[in] Port Index of HDMI.
 * @return Status of the function and the color parameters.
 */
Status Hv_Drv_HdmiRx_GetAVIPara(UCHAR8 ucPortIndex, VideoColorParam *pstVideoAVIPara, VideoTimingParam *pstTimingPara);

/**
 * @brief Get HDMI Rx Timing parameters.
 * @param[in] Port Index of HDMI
 * @return Status of the function and the information of the RX timing.
 */
Status Hv_Drv_HdmiRx_GetTimingPara(UCHAR8 ucPortIndex, VideoTimingParam *pstTimingPara);

/**
 * @brief frl rate change indicate frl or tmds
 * @param[in] ucPortIndex used for the HDMI RX.
 * @return FRL Rate 0: TMDS, Others: FRL.
 */
UCHAR8  Hv_Drv_HdmiFRLRateChange(UCHAR8 ucPortIndex);

/**
 * @brief frl training is in
 * @param[in] ucPortIndex used for the HDMI RX.
 * @return Status with 0: Success, 1: Failure.
 */
Status  Hv_Drv_HdmiFRLTraningIn(UCHAR8 ucPortIndex);

/**
 * @brief frl training is error
 * @param[in] ucPortIndex used for the HDMI RX.
 * @return Status with 0: Success, 1: Failure.
 */
Status  Hv_Drv_HdmiFRLTraningError(UCHAR8 ucPortIndex);

/**
 * @brief frl training is done
 * @param[in] ucPortIndex used for the HDMI RX.
 * @return Status with 0: Success, 1: Failure.
 */
Status  Hv_Drv_HdmiFRLTraningDone(UCHAR8 ucPortIndex);

/**
 * @brief cec recv data
 * @param[in] ucPortIndex used for the HDMI RX.
 * @return Status with 0: Success, 1: Failure.
 */
Status Hv_Drv_HdmiRx_CecRecvData(UCHAR8 ucPortIndex);

/**
 * @brief Action for the HDMI Enter the Standby.
 * @param[in] Port Index of HDMI.
 * @param[in] Status of Enter or Leave the standby.
 * @return Status of this Function.
 */
Status Hv_Drv_HdmiRx_EnterStandby(UCHAR8 ucPortIndex, BOOL bEnterStandby);

/**
 * @brief Send the DDC Message for DDCCI.
 * @param[in] Port Index of HDMI.
 * @param[in] Data and Length for the DDC to send.
 * @return Status of this Function.
 */
Status Hv_Drv_HdmiRx_DdcSend(UCHAR8 ucPortIndex, UCHAR8 *data, UINT32 len);

/**
 * @brief Get the DDC Message for DDCCI.
 * @param[in] Port Index of HDMI.
 * @param[Out] Data for the DDC received.
 * @return length of the DDC data received.
 */
UCHAR8 Hv_Drv_HdmiRx_DdcRecv(UCHAR8 ucPortIndex, UCHAR8 *ucBuf);

/**
 * @brief hdmi ratio change need change phy para
 * @param[in] ucPortIndex used for the HDMI RX.
 * @return Status with 0: Success, 1: Failure.
 */
HdmiRxGearMode Hv_Drv_HdmiRx_GetRatioType(UCHAR8 ucPortIndex, HdmiRxGearMode emGearModeCfg);

/**
 * @brief hdmi read request change need init reg
 * @param[in] ucPortIndex used for the HDMI RX.
 * @return Status with 0: Success, 1: Failure.
 */
Status  Hv_Drv_HdmiRRChange(UCHAR8 ucPortIndex);

/**
 * @brief Open or Closed the packet error interrupt.
 * @param[in] Port Index of HDMI.
 * @return Status of the function.
 */
Status Hv_Drv_HdmiRx_SetPacketErrorInt(UCHAR8 ucPortIndex, BOOL bSwitch);

/**
 * @brief Send DDCCI Message.
 * @param[in] Port Index of HDMI and Data want to send.
 * @return Status of the function.
 */
Status Hv_Drv_HdmiRxDDCSend(UCHAR8 ucPortIndex, UCHAR8 *data, UCHAR8 len);

/**
 * @brief Print the Interrupt Message.
 * @param[in] Port Index of HDMI and Data want to send.
 * @return Status of the function.
 */
UINT32 Hv_Drv_HdmiRx_InterruptEnPrint(UCHAR8 ucPortIndex, UCHAR8 ucIntr);

/**
 * @brief Reset SCDC with the 5V Change.
 * @param[in] ucPortIndex Port Index of HDMI.
 * @return : None.
 */
VOID HV_Drv_HdmirRx_ResetScdcWith5V(UCHAR8 ucPortIndex);

/**
 * @brief Initialize the hdmi EDID configuration, check if need to close the Register EDID.
 * @param[in] Port Number used for the HDMI RX.
 * @return VOID without return.
 */
Status Hv_Drv_HdmiRx_InitEdidConf(UCHAR8 ucPortIndex);

/**
 * @brief Reset The TMDS Pre of Bus and Sw.
 * @param[in] Port Number used for the HDMI RX.
 * @return Status of the function.
 */
Status Hv_Drv_HdmiRx_TmdsPreReset(UCHAR8 ucPortIndex);

/**
 * @brief check and restore audio fifo
 * @param[in] Port Number used for the HDMI RX.
 */
VOID Hv_Drv_HdmiRx_AudioCheck(UCHAR8 ucPortId);

/**
 * @brief reload color depth reg
 * @param[in] Port Number used for the HDMI RX.
 */
VOID Hv_Drv_HdmiRx_ReloadColorDepth(UCHAR8 ucPortIndex);

/**
 * @brief Get the Mata Date for the VRR with EMP(0x7F) Packet.
 * @param[in] Port Index of HDMI.
 * @return VRR parameters on EMP.
 */
Status Hv_Drv_HdmiRx_GetMDVrrPara(UCHAR8 ucPortIndex, VRRInfoParam* pstVrrMdPara);

/**
 * @brief Get HDMI Rx audio info.
 * @param[in] Port Index of HDMI
 * @return Status of the function.
 */
Status Hv_Drv_HdmiRx_GetAudioPara(UCHAR8 ucPortIndex, AudioPara *pstAudioPara);

/**
 * @brief Get HDR data.
 * @param[in] Port Index of HDMI
 * @return Parameters of HDR send from Source.
 */
Status Hv_Drv_HdmiRx_GetHDRPara(UCHAR8 ucPortIndex, HDRParam *pstHDRPara);

/**
 * @brief Parse the SPD of AMD.
 * @param[in] Port Index of HDMI
 * @return HV_SUCCESS or FAILSE.
 * @return VRR value from the SPD.
 */
Status Hv_Drv_HdmiRx_GetAMDVendSpecInfoPara(UCHAR8 ucPortIndex, VRRInfoParam *pstVendSpecInfoPara);

/**
 * @brief HDMI Rx Phy Gear Mode Robust checking.
 * @param[in] Port Index of HDMI and gear mode.
 * @return HV_TRUE for Ratio mode and HV_TRUE for Normal.
 */
BOOL Hv_Drv_HdmiRX_RobustCheckRatioMode(UCHAR8 ucPortIndex);

/**
 * @brief Detect HDMI Rx aln lock.
 * @param[in] Port Index of HDMI.
 * @param[in] Clock Lane Swap ID.
 * @return HV_TRUE of HV_FALSE.
 */
BOOL Hv_Drv_HdmiRx_IsClockStable(UCHAR8 ucPortIndex);

/**
 * @brief Set the EQ with Confgiure Date.
 * @param[in] ucPortIndex Port Index of HDMI.
 * @param[in] pusSwEqValue The 3Lane Eq Value to be configured 
 * @return Status of the function.
 */
Status Hv_Drv_HdmiRx_SetSwEqValue(UCHAR8 ucPortIndex, const USHORT16 *pusSwEqValue);

/**
 * @brief Get the Packet Error Value.
 * @param[in] Port Index of HDMI.
 * @return Number of the CED Value.
 */
Status Hv_Drv_HdmiRx_GetLaneCEDValue(UCHAR8 ucPortIndex, HdmiRxLaneCED *pstLaneCedValue);

/**
 * @brief Detect HDMI Timing Statble.
 * @param[in] Port Index of HDMI
 * @return HV_TRUE of HV_FALSE.
 */
BOOL Hv_Drv_HdmiRx_IsTimingStable(UCHAR8 ucPortIndex);

/**
 * @brief Action for the Cable plug in or out.
 * @param[in] Port Index of HDMI and the cable status.
 * @return Status of the function.
 */
Status Hv_Drv_HdmiRx_CableConnectAction(UCHAR8 ucPortIndex, BOOL bCableSta);

/**
 * @brief HDMI Rx Phy Gear Mode change.
 * @param[in] Port Index of HDMI and gear mode.
 * @return VOID.
 */
VOID Hv_Drv_HdmiRX_SwitchPhyGearMode(UCHAR8 ucPortIndex, HdmiRxGearMode ucGrearMode);

/**
 * @brief If the PHY is fast locked.
 * @param[in] Port Number used for the HDMI RX.
 * @return TRUE is Loced False is unlocked.
 */
BOOL Hv_Drv_HdmiRX_IsPhyFastLocked(UCHAR8 ucPortIndex);

/**
 * @brief If the PHY TMDS Clock Is OverFlow.
 * @param[in] Port Number used for the HDMI RX.
 * @return TRUE is OverFlow False is not OverFlow.
 */
BOOL Hv_Drv_HdmiRX_IsTMDSClockOverFlow(UCHAR8 ucPortIndex);

Status Hv_Drv_HdmiRx_Hdcp1XInitForAuth(UCHAR8 ucPortIndex);

BOOL Hv_Drv_HdmiRx_CheckTmdsClockAbnormal(UCHAR8 ucPortIndex);

BOOL Hv_Drv_HdmiRx_GetCableStatus(UCHAR8 ucPortIndex);

#endif


