XilinxProcessorIPLib/drivers/v_hdmitxss1/examples/hdcp_key_utility/video_fmc.c
int Vfmc_HdmiInit(u16 GpioDeviceId, void *IicPtr)
{
	int Status;
	u8 Buffer[2];
	int ByteCount;
#if defined (XPS_BOARD_ZCU102) || \
	defined (XPS_BOARD_ZCU104) || \
	defined (XPS_BOARD_ZCU106)
	XIicPs *Iic_Ptr = IicPtr;
#else
	XIic *Iic_Ptr = IicPtr;
#endif

	/* Initialize GPIO for VFMC */
	Gpio_Vfmc_ConfigPtr =
		XGpio_LookupConfig(GpioDeviceId);

	if(Gpio_Vfmc_ConfigPtr == NULL) {
		Gpio_Vfmc.IsReady = 0;
		return (XST_DEVICE_NOT_FOUND);
	}

	Status = XGpio_CfgInitialize(&Gpio_Vfmc,
								 Gpio_Vfmc_ConfigPtr,
								 Gpio_Vfmc_ConfigPtr->BaseAddress);
	if(Status != XST_SUCCESS) {
		xil_printf("ERR:: GPIO for VFMC ");
		xil_printf("Initialization failed %d\r\n", Status);
		return(XST_FAILURE);
	}

	Vfmc_I2cMuxSelect(IicPtr);

	/* Configure VFMC IO Expander 0:
	 * Disable Si5344
	 * Set primary clock source for LMK03318 to IOCLKp(0)
	 * Set secondary clock source for LMK03318 to IOCLKp(1)
	 * Disable LMK61E2*/
	Buffer[0] = 0x52;
	ByteCount = Vfmc_I2cSend(IicPtr, VFMC_I2C_IOEXP_0_ADDR,
			(u8*)Buffer, 1, I2C_STOP);
	if (ByteCount != 1) {
		xil_printf("Failed to set the I2C IO Expander.\r\n");
		return XST_FAILURE;
	}

	/* Configure VFMC IO Expander 1:
	 * Enable LMK03318 -> In a power-down state the I2C bus becomes unusable.
	 * Select LMK03318 clock as source for FMC_GT_CLKp(0)
	 * Select IDT8T49N241 clock as source for FMC_GT_CLKp(1)
	 * Enable IDT8T49N241 */
	Buffer[0] = 0x1A;
	ByteCount = Vfmc_I2cSend(IicPtr, VFMC_I2C_IOEXP_1_ADDR,
			(u8*)Buffer, 1, I2C_STOP);
	if (ByteCount != 1) {
		xil_printf("Failed to set the I2C IO Expander.\r\n");
		return XST_FAILURE;
	}

	/* Configure HDMI2.0 Mezz in Slot 1 IO Expander 1:
	 * Enable DP159 Output
	 * Select GT3 as TMDS Clk source */
	/* Note : for HDMI4K FMC:
	 * Buffer[0] = 0x05;
	 * ByteCount = XIic_Send(BaseAddr, 0x22,
	 *		(u8*)Buffer, 1, XIIC_STOP);
	 * if (ByteCount != 1) {
	 *	xil_printf("Failed to set the I2C IO Expander.\r\n");
	 *	return XST_FAILURE;
	 * }
	 */

	Status |= IDT_8T49N24x_Init(Iic_Ptr, VFMC_I2C_IDT8N49_ADDR);
	Status |= IDT_8T49N24x_GpioLolEnable(Iic_Ptr,
					VFMC_I2C_IDT8N49_ADDR);
	if (Status != XST_SUCCESS) {
		xil_printf("Failed to initialize IDT 8T49N241.\r\n");
		return XST_FAILURE;
	}

	Status = TI_LMK03318_Init(Iic_Ptr, VFMC_I2C_LMK03318_ADDR);
	if (Status != XST_SUCCESS) {
		xil_printf("Failed to initialize TI LMK03318.\r\n");
		return XST_FAILURE;
	}

	/* Used for the RX GT ref clock */
	Status = TI_LMK03318_EnableBypass(Iic_Ptr,
					VFMC_I2C_LMK03318_ADDR, 0, 4);
	if (Status != XST_SUCCESS) {
		xil_printf("Failed to enable bypass for port 4.\r\n");
		return XST_FAILURE;
	}

	/* Used for the TX GT ref clock */
	Status = TI_LMK03318_EnableBypass(Iic_Ptr,
					VFMC_I2C_LMK03318_ADDR, 0, 6);
	if (Status != XST_SUCCESS) {
		xil_printf("Failed to enable bypass for port 6.\r\n");
		return XST_FAILURE;
	}

	/* TX Mezzanine Init Done */
	Vfmc_Gpio_Led_On(VFMC_GPIO_TX_LED0, TRUE);

	/* RX Mezzanine Init Done */
	Vfmc_Gpio_Led_On(VFMC_GPIO_RX_LED0, TRUE);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function initializes the Video FMC clock generator and clock MUXs
* for HDMI operation
*
* @param  None.
*
* @return None.
*
* @note   None.
*
******************************************************************************/
This function initializes the Video FMC clock generator and clock MUXs
for HDMI operation
This function initializes the Video FMC clock generator and clock MUXs for HDMI operation
int Vfmc_HdmiInit(u16 GpioDeviceId, void *IicPtr)
{
	int Status;
	u8 Buffer[2];
	int ByteCount;
#if defined (XPS_BOARD_ZCU102) || \
	defined (XPS_BOARD_ZCU104) || \
	defined (XPS_BOARD_ZCU106)
	XIicPs *Iic_Ptr = IicPtr;
#else
	XIic *Iic_Ptr = IicPtr;
#endif
	Gpio_Vfmc_ConfigPtr =
		XGpio_LookupConfig(GpioDeviceId);
	if(Gpio_Vfmc_ConfigPtr == NULL) {
		Gpio_Vfmc.IsReady = 0;
		return (XST_DEVICE_NOT_FOUND);
	}
	Status = XGpio_CfgInitialize(&Gpio_Vfmc,
								 Gpio_Vfmc_ConfigPtr,
								 Gpio_Vfmc_ConfigPtr->BaseAddress);
	if(Status != XST_SUCCESS) {
		xil_printf("ERR:: GPIO for VFMC ");
		xil_printf("Initialization failed %d\r\n", Status);
		return(XST_FAILURE);
	}
	Vfmc_I2cMuxSelect(IicPtr);
	Buffer[0] = 0x52;
	ByteCount = Vfmc_I2cSend(IicPtr, VFMC_I2C_IOEXP_0_ADDR,
			(u8*)Buffer, 1, I2C_STOP);
	if (ByteCount != 1) {
		xil_printf("Failed to set the I2C IO Expander.\r\n");
		return XST_FAILURE;
	}
	Buffer[0] = 0x1A;
	ByteCount = Vfmc_I2cSend(IicPtr, VFMC_I2C_IOEXP_1_ADDR,
			(u8*)Buffer, 1, I2C_STOP);
	if (ByteCount != 1) {
		xil_printf("Failed to set the I2C IO Expander.\r\n");
		return XST_FAILURE;
	}
	Status |= IDT_8T49N24x_Init(Iic_Ptr, VFMC_I2C_IDT8N49_ADDR);
	Status |= IDT_8T49N24x_GpioLolEnable(Iic_Ptr,
					VFMC_I2C_IDT8N49_ADDR);
	if (Status != XST_SUCCESS) {
		xil_printf("Failed to initialize IDT 8T49N241.\r\n");
		return XST_FAILURE;
	}
	Status = TI_LMK03318_Init(Iic_Ptr, VFMC_I2C_LMK03318_ADDR);
	if (Status != XST_SUCCESS) {
		xil_printf("Failed to initialize TI LMK03318.\r\n");
		return XST_FAILURE;
	}
	Status = TI_LMK03318_EnableBypass(Iic_Ptr,
					VFMC_I2C_LMK03318_ADDR, 0, 4);
	if (Status != XST_SUCCESS) {
		xil_printf("Failed to enable bypass for port 4.\r\n");
		return XST_FAILURE;
	}
	Status = TI_LMK03318_EnableBypass(Iic_Ptr,
					VFMC_I2C_LMK03318_ADDR, 0, 6);
	if (Status != XST_SUCCESS) {
		xil_printf("Failed to enable bypass for port 6.\r\n");
		return XST_FAILURE;
	}
	Vfmc_Gpio_Led_On(VFMC_GPIO_TX_LED0, TRUE);
	Vfmc_Gpio_Led_On(VFMC_GPIO_RX_LED0, TRUE);
	return XST_SUCCESS;
}
int Vfmc_HdmiInit ( u16 GpioDeviceId , void * IicPtr ) { int Status ; u8 Buffer [ 2 ] ; int ByteCount ; #if defined ( XPS_BOARD_ZCU102 ) || defined ( XPS_BOARD_ZCU104 ) || defined ( XPS_BOARD_ZCU106 ) XIicPs * Iic_Ptr = IicPtr ; #else XIic * Iic_Ptr = IicPtr ; #endif Gpio_Vfmc_ConfigPtr = XGpio_LookupConfig ( GpioDeviceId ) ; if ( Gpio_Vfmc_ConfigPtr == NULL ) { Gpio_Vfmc . IsReady = 0 ; return ( XST_DEVICE_NOT_FOUND ) ; } Status = XGpio_CfgInitialize ( & Gpio_Vfmc , Gpio_Vfmc_ConfigPtr , Gpio_Vfmc_ConfigPtr -> BaseAddress ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " " ) ; xil_printf ( " \r \n " , Status ) ; return ( XST_FAILURE ) ; } Vfmc_I2cMuxSelect ( IicPtr ) ; Buffer [ 0 ] = 0x52 ; ByteCount = Vfmc_I2cSend ( IicPtr , VFMC_I2C_IOEXP_0_ADDR , ( u8 * ) Buffer , 1 , I2C_STOP ) ; if ( ByteCount != 1 ) { xil_printf ( " \r \n " ) ; return XST_FAILURE ; } Buffer [ 0 ] = 0x1A ; ByteCount = Vfmc_I2cSend ( IicPtr , VFMC_I2C_IOEXP_1_ADDR , ( u8 * ) Buffer , 1 , I2C_STOP ) ; if ( ByteCount != 1 ) { xil_printf ( " \r \n " ) ; return XST_FAILURE ; } Status |= IDT_8T49N24x_Init ( Iic_Ptr , VFMC_I2C_IDT8N49_ADDR ) ; Status |= IDT_8T49N24x_GpioLolEnable ( Iic_Ptr , VFMC_I2C_IDT8N49_ADDR ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " ) ; return XST_FAILURE ; } Status = TI_LMK03318_Init ( Iic_Ptr , VFMC_I2C_LMK03318_ADDR ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " ) ; return XST_FAILURE ; } Status = TI_LMK03318_EnableBypass ( Iic_Ptr , VFMC_I2C_LMK03318_ADDR , 0 , 4 ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " ) ; return XST_FAILURE ; } Status = TI_LMK03318_EnableBypass ( Iic_Ptr , VFMC_I2C_LMK03318_ADDR , 0 , 6 ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " ) ; return XST_FAILURE ; } Vfmc_Gpio_Led_On ( VFMC_GPIO_TX_LED0 , TRUE ) ; Vfmc_Gpio_Led_On ( VFMC_GPIO_RX_LED0 , TRUE ) ; return XST_SUCCESS ; }
This function initializes the Video FMC clock generator and clock MUXs
for HDMI operation
This function initializes the Video FMC clock generator and clock MUXs for HDMI operation
/* Initialize GPIO for VFMC */ /* Configure VFMC IO Expander 0:
	 * Disable Si5344
	 * Set primary clock source for LMK03318 to IOCLKp(0)
	 * Set secondary clock source for LMK03318 to IOCLKp(1)
	 * Disable LMK61E2*/ /* Configure VFMC IO Expander 1:
	 * Enable LMK03318 -> In a power-down state the I2C bus becomes unusable.
	 * Select LMK03318 clock as source for FMC_GT_CLKp(0)
	 * Select IDT8T49N241 clock as source for FMC_GT_CLKp(1)
	 * Enable IDT8T49N241 */ /* Configure HDMI2.0 Mezz in Slot 1 IO Expander 1:
	 * Enable DP159 Output
	 * Select GT3 as TMDS Clk source */ /* Note : for HDMI4K FMC:
	 * Buffer[0] = 0x05;
	 * ByteCount = XIic_Send(BaseAddr, 0x22,
	 *		(u8*)Buffer, 1, XIIC_STOP);
	 * if (ByteCount != 1) {
	 *	xil_printf("Failed to set the I2C IO Expander.\r\n");
	 *	return XST_FAILURE;
	 * }
	 */ /* Used for the RX GT ref clock */ /* Used for the TX GT ref clock */ /* TX Mezzanine Init Done */ /* RX Mezzanine Init Done */