XilinxProcessorIPLib/drivers/v_hdmitxss/examples/xhdmi_example/I2S/xhdmi_example.c
void RxStreamUpCallback(void *CallbackRef) {
	XV_HdmiRxSs *HdmiRxSsPtr = (XV_HdmiRxSs *)CallbackRef;
	xil_printf("RX stream is up\r\n");
#if(LOOPBACK_MODE_EN != 1 && XPAR_XV_HDMITXSS_NUM_INSTANCES > 0)
	u32 Status;
	u64 LineRate;
	XVphy_PllType RxPllType;
	XVidC_VideoStream *HdmiRxSsVidStreamPtr;
	XVidC_VideoStream *HdmiTxSsVidStreamPtr;

	HdmiRxSsVidStreamPtr = XV_HdmiRxSs_GetVideoStream(HdmiRxSsPtr);
	HdmiTxSsVidStreamPtr = XV_HdmiTxSs_GetVideoStream(&HdmiTxSs);

	/* Copy video parameters */
	*HdmiTxSsVidStreamPtr = *HdmiRxSsVidStreamPtr;
	XV_HdmiTxSs_SetVideoIDCode(&HdmiTxSs,
				XV_HdmiRxSs_GetVideoIDCode(HdmiRxSsPtr));
	XV_HdmiTxSs_SetVideoStreamType(&HdmiTxSs,
				XV_HdmiRxSs_GetVideoStreamType(HdmiRxSsPtr));

	RxPllType = XVphy_GetPllType(&Vphy,
				     0,
				     XVPHY_DIR_RX,
				     XVPHY_CHANNEL_ID_CH1);

	if (Vphy.Config.XcvrType != XVPHY_GT_TYPE_GTPE2) {
		if (!(RxPllType == XVPHY_PLL_TYPE_CPLL)) {
			LineRate = Vphy.Quads[0].Plls[XVPHY_CHANNEL_ID_CMN0 -
				XVPHY_CHANNEL_ID_CH1].LineRateHz;
		} else {
			LineRate = Vphy.Quads[0].Plls[0].LineRateHz;
		}
	} else { /* GTP */
		if (RxPllType == XVPHY_PLL_TYPE_PLL0) {
			LineRate = Vphy.Quads[0].Plls[XVPHY_CHANNEL_ID_CMN0 -
				XVPHY_CHANNEL_ID_CH1].LineRateHz;
		} else {
			LineRate = Vphy.Quads[0].Plls[XVPHY_CHANNEL_ID_CMN1 -
				XVPHY_CHANNEL_ID_CH1].LineRateHz;
		}
	}


	/* Check GT line rate
	 * For 4k60p the reference clock must be multiplied by four
	 */
	if ((LineRate / 1000000) > 3400) {
		/* TX reference clock */
		Vphy.HdmiTxRefClkHz = Vphy.HdmiRxRefClkHz * 4;
		XV_HdmiTxSs_SetTmdsClockRatio(&HdmiTxSs, 1);

		XV_HdmiTxSs_SetVideoStreamScramblingFlag(&HdmiTxSs, (TRUE));
	}

	/* Other resolutions */
	else {
		Vphy.HdmiTxRefClkHz = Vphy.HdmiRxRefClkHz;
		XV_HdmiTxSs_SetTmdsClockRatio(&HdmiTxSs, 0);

		XV_HdmiTxSs_SetVideoStreamScramblingFlag(&HdmiTxSs, (FALSE));
	}

	/* Set GT TX parameters */
	Status = XVphy_SetHdmiTxParam(&Vphy,
	                              0,
				      XVPHY_CHANNEL_ID_CHA,
				      HdmiTxSsVidStreamPtr->PixPerClk,
				      HdmiTxSsVidStreamPtr->ColorDepth,
				      HdmiTxSsVidStreamPtr->ColorFormatId);

	if (Status == XST_FAILURE) {
		return;
	}

	/* Disable the Colorbar */
	TxRestartColorbar = (FALSE);
	if (TxCableConnect) {
		/* Restart the TX if the TX Cable Connected */
		StartTxAfterRxFlag = (TRUE);

		/* Mute/Stop the HDMI RX SS Output
		 * Enable only when the downstream is ready
		 * (TPG & HDMI TX)
		 */
		XV_HdmiRxSs_VRST(HdmiRxSsPtr,TRUE);
	}

	/* Enable pass-through */
	IsPassThrough = (TRUE);

#else
	XVidC_ReportStreamInfo(&HdmiRxSsPtr->HdmiRxPtr->Stream.Video);

#endif

#ifdef USE_HDCP
	/* Call HDCP stream-up callback */
	XHdcp_StreamUpCallback(&HdcpRepeater);
#endif

#ifdef VIDEO_FRAME_CRC_EN
	/* Reset Video Frame CRC */
	XVidFrameCrc_Reset();
#endif

#ifdef XPAR_XI2SRX_NUM_INSTANCES
	rx_is_up = 1;
#endif
}
/*****************************************************************************/
/**
*
* This function is called when the RX stream is up.
*
* @param  None.
*
* @return None.
*
* @note   None.
*
******************************************************************************/
This function is called when the RX stream is up.
This function is called when the RX stream is up .
void RxStreamUpCallback(void *CallbackRef) {
	XV_HdmiRxSs *HdmiRxSsPtr = (XV_HdmiRxSs *)CallbackRef;
	xil_printf("RX stream is up\r\n");
#if(LOOPBACK_MODE_EN != 1 && XPAR_XV_HDMITXSS_NUM_INSTANCES > 0)
	u32 Status;
	u64 LineRate;
	XVphy_PllType RxPllType;
	XVidC_VideoStream *HdmiRxSsVidStreamPtr;
	XVidC_VideoStream *HdmiTxSsVidStreamPtr;
	HdmiRxSsVidStreamPtr = XV_HdmiRxSs_GetVideoStream(HdmiRxSsPtr);
	HdmiTxSsVidStreamPtr = XV_HdmiTxSs_GetVideoStream(&HdmiTxSs);
	*HdmiTxSsVidStreamPtr = *HdmiRxSsVidStreamPtr;
	XV_HdmiTxSs_SetVideoIDCode(&HdmiTxSs,
				XV_HdmiRxSs_GetVideoIDCode(HdmiRxSsPtr));
	XV_HdmiTxSs_SetVideoStreamType(&HdmiTxSs,
				XV_HdmiRxSs_GetVideoStreamType(HdmiRxSsPtr));
	RxPllType = XVphy_GetPllType(&Vphy,
				     0,
				     XVPHY_DIR_RX,
				     XVPHY_CHANNEL_ID_CH1);
	if (Vphy.Config.XcvrType != XVPHY_GT_TYPE_GTPE2) {
		if (!(RxPllType == XVPHY_PLL_TYPE_CPLL)) {
			LineRate = Vphy.Quads[0].Plls[XVPHY_CHANNEL_ID_CMN0 -
				XVPHY_CHANNEL_ID_CH1].LineRateHz;
		} else {
			LineRate = Vphy.Quads[0].Plls[0].LineRateHz;
		}
	} else { 
		if (RxPllType == XVPHY_PLL_TYPE_PLL0) {
			LineRate = Vphy.Quads[0].Plls[XVPHY_CHANNEL_ID_CMN0 -
				XVPHY_CHANNEL_ID_CH1].LineRateHz;
		} else {
			LineRate = Vphy.Quads[0].Plls[XVPHY_CHANNEL_ID_CMN1 -
				XVPHY_CHANNEL_ID_CH1].LineRateHz;
		}
	}
	if ((LineRate / 1000000) > 3400) {
		Vphy.HdmiTxRefClkHz = Vphy.HdmiRxRefClkHz * 4;
		XV_HdmiTxSs_SetTmdsClockRatio(&HdmiTxSs, 1);
		XV_HdmiTxSs_SetVideoStreamScramblingFlag(&HdmiTxSs, (TRUE));
	}
	else {
		Vphy.HdmiTxRefClkHz = Vphy.HdmiRxRefClkHz;
		XV_HdmiTxSs_SetTmdsClockRatio(&HdmiTxSs, 0);
		XV_HdmiTxSs_SetVideoStreamScramblingFlag(&HdmiTxSs, (FALSE));
	}
	Status = XVphy_SetHdmiTxParam(&Vphy,
	                              0,
				      XVPHY_CHANNEL_ID_CHA,
				      HdmiTxSsVidStreamPtr->PixPerClk,
				      HdmiTxSsVidStreamPtr->ColorDepth,
				      HdmiTxSsVidStreamPtr->ColorFormatId);
	if (Status == XST_FAILURE) {
		return;
	}
	TxRestartColorbar = (FALSE);
	if (TxCableConnect) {
		StartTxAfterRxFlag = (TRUE);
		XV_HdmiRxSs_VRST(HdmiRxSsPtr,TRUE);
	}
	IsPassThrough = (TRUE);
#else
	XVidC_ReportStreamInfo(&HdmiRxSsPtr->HdmiRxPtr->Stream.Video);
#endif
#ifdef USE_HDCP
	XHdcp_StreamUpCallback(&HdcpRepeater);
#endif
#ifdef VIDEO_FRAME_CRC_EN
	XVidFrameCrc_Reset();
#endif
#ifdef XPAR_XI2SRX_NUM_INSTANCES
	rx_is_up = 1;
#endif
}
void RxStreamUpCallback ( void * CallbackRef ) { XV_HdmiRxSs * HdmiRxSsPtr = ( XV_HdmiRxSs * ) CallbackRef ; xil_printf ( " \r \n " ) ; #if ( LOOPBACK_MODE_EN != 1 && XPAR_XV_HDMITXSS_NUM_INSTANCES > 0 ) u32 Status ; u64 LineRate ; XVphy_PllType RxPllType ; XVidC_VideoStream * HdmiRxSsVidStreamPtr ; XVidC_VideoStream * HdmiTxSsVidStreamPtr ; HdmiRxSsVidStreamPtr = XV_HdmiRxSs_GetVideoStream ( HdmiRxSsPtr ) ; HdmiTxSsVidStreamPtr = XV_HdmiTxSs_GetVideoStream ( & HdmiTxSs ) ; * HdmiTxSsVidStreamPtr = * HdmiRxSsVidStreamPtr ; XV_HdmiTxSs_SetVideoIDCode ( & HdmiTxSs , XV_HdmiRxSs_GetVideoIDCode ( HdmiRxSsPtr ) ) ; XV_HdmiTxSs_SetVideoStreamType ( & HdmiTxSs , XV_HdmiRxSs_GetVideoStreamType ( HdmiRxSsPtr ) ) ; RxPllType = XVphy_GetPllType ( & Vphy , 0 , XVPHY_DIR_RX , XVPHY_CHANNEL_ID_CH1 ) ; if ( Vphy . Config . XcvrType != XVPHY_GT_TYPE_GTPE2 ) { if ( ! ( RxPllType == XVPHY_PLL_TYPE_CPLL ) ) { LineRate = Vphy . Quads [ 0 ] . Plls [ XVPHY_CHANNEL_ID_CMN0 - XVPHY_CHANNEL_ID_CH1 ] . LineRateHz ; } else { LineRate = Vphy . Quads [ 0 ] . Plls [ 0 ] . LineRateHz ; } } else { if ( RxPllType == XVPHY_PLL_TYPE_PLL0 ) { LineRate = Vphy . Quads [ 0 ] . Plls [ XVPHY_CHANNEL_ID_CMN0 - XVPHY_CHANNEL_ID_CH1 ] . LineRateHz ; } else { LineRate = Vphy . Quads [ 0 ] . Plls [ XVPHY_CHANNEL_ID_CMN1 - XVPHY_CHANNEL_ID_CH1 ] . LineRateHz ; } } if ( ( LineRate / 1000000 ) > 3400 ) { Vphy . HdmiTxRefClkHz = Vphy . HdmiRxRefClkHz * 4 ; XV_HdmiTxSs_SetTmdsClockRatio ( & HdmiTxSs , 1 ) ; XV_HdmiTxSs_SetVideoStreamScramblingFlag ( & HdmiTxSs , ( TRUE ) ) ; } else { Vphy . HdmiTxRefClkHz = Vphy . HdmiRxRefClkHz ; XV_HdmiTxSs_SetTmdsClockRatio ( & HdmiTxSs , 0 ) ; XV_HdmiTxSs_SetVideoStreamScramblingFlag ( & HdmiTxSs , ( FALSE ) ) ; } Status = XVphy_SetHdmiTxParam ( & Vphy , 0 , XVPHY_CHANNEL_ID_CHA , HdmiTxSsVidStreamPtr -> PixPerClk , HdmiTxSsVidStreamPtr -> ColorDepth , HdmiTxSsVidStreamPtr -> ColorFormatId ) ; if ( Status == XST_FAILURE ) { return ; } TxRestartColorbar = ( FALSE ) ; if ( TxCableConnect ) { StartTxAfterRxFlag = ( TRUE ) ; XV_HdmiRxSs_VRST ( HdmiRxSsPtr , TRUE ) ; } IsPassThrough = ( TRUE ) ; #else XVidC_ReportStreamInfo ( & HdmiRxSsPtr -> HdmiRxPtr -> Stream . Video ) ; #endif #ifdef USE_HDCP XHdcp_StreamUpCallback ( & HdcpRepeater ) ; #endif #ifdef VIDEO_FRAME_CRC_EN XVidFrameCrc_Reset ( ) ; #endif #ifdef XPAR_XI2SRX_NUM_INSTANCES rx_is_up = 1 ; #endif }
This function is called when the RX stream is up.
This function is called when the RX stream is up .
/* Copy video parameters */ /* GTP */ /* Check GT line rate
	 * For 4k60p the reference clock must be multiplied by four
	 */ /* TX reference clock */ /* Other resolutions */ /* Set GT TX parameters */ /* Disable the Colorbar */ /* Restart the TX if the TX Cable Connected */ /* Mute/Stop the HDMI RX SS Output
		 * Enable only when the downstream is ready
		 * (TPG & HDMI TX)
		 */ /* Enable pass-through */ /* Call HDCP stream-up callback */ /* Reset Video Frame CRC */