#include "drv_sil_if.h"
#include "hdmi_mhl_if_sii1292.h"
#include "drv_hdmi.h"
extern void fgSiiVbusCntrl(UINT8 ctrl);
extern void NTF_CBUS_Disconnected(void);
extern void NTF_CBUS_Connected(void);
extern void u1ClearMHLDeviceAdapterID(VOID);
UINT8 u1fgSilCbusStatus = SIL_CBUS_DISCONECTED;
void vHDMIMHL_Init(void)
{
    fgSil_Init();
}


void vMhl_MainLoop(void)
{
	vSil_MainLoop();
}

void vfgSiI_MhlSetState(BOOL port, BOOL chargeCapa)
{
	fgSil_Set_MHL2_State(port,chargeCapa);
}
#ifdef CECNFY5VSTATUS
extern void _Cec_Notify5VStatus(UINT8 u1Port, UINT8 u15vStatus);
#endif
void fgSil_NTF_CBUS_Connected(void)
{
	u1fgSilCbusStatus = SIL_CBUS_CONNECTED;
#ifdef CECNFY5VSTATUS
		_Cec_Notify5VStatus(3,1);//MHL SOURCE 
#endif
	NTF_CBUS_Connected();
}
extern void vSetHdmiUnplug(E_HDMI_SWITCH_NUM ePort);
void fgSil_NTF_CBUS_Disconnected(void)
{
	u1fgSilCbusStatus = SIL_CBUS_DISCONECTED;
#ifdef CECNFY5VSTATUS
	_Cec_Notify5VStatus(3,0);//MHL SOURCE 
#endif
	NTF_CBUS_Disconnected();
	u1ClearMHLDeviceAdapterID();
	vSetHdmiUnplug(3);// force mode change down.
}

BOOL fgSil_NTF_CBUS_STATUS(void)
{
	if(u1fgSilCbusStatus == SIL_CBUS_CONNECTED)
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
void fgSil_NTF_3D_Communicated(void)
{
	
}

void fgSil_NTF_VBUS_High(void)
{
	fgSiiVbusCntrl(1);
}
void fgSil_NTF_VBUS_Low(void)
{
	
	fgSiiVbusCntrl(0);
}

extern BOOL Sif_WriteBytes(UINT8 DeviceID,UINT8 Offset,UINT8 *pData,UINT8 ByteCount);
extern BOOL Sif_ReadBytes(UINT8 DeviceID, UINT8 Offset, UINT8 *pData, UINT8 ByteCount);
extern void Delay1ms(UINT32 ms);
extern void Delay1us(UINT32 us);

BOOL fgSil_Sif_WriteBytes(UINT8 DeviceID, UINT8 Offset, UINT8 *pData, UINT8 ByteCount)
{
	return Sif_WriteBytes(DeviceID,Offset,pData,ByteCount);

}

BOOL fgSil_Sif_ReadBytes(UINT8 DeviceID, UINT8 Offset, UINT8 *pData, UINT8 ByteCount)
{
	return Sif_ReadBytes(DeviceID,Offset,pData,ByteCount);
}

void SendRcpKey(UINT8 key)
{
	fgSil_RcpKeys(key);
}

void vSil_Delay1ms(UINT32 ms)   // Delay in millisecond
{
	Delay1ms(ms);
}
void vSil_Delay1us(UINT32 us)   // Delay in microsecond
{
	Delay1us(us);
}

extern bool_t mhl_con;
BOOL IsMhlCableConnected(void)
{
	if(mhl_con)
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}



