XilinxProcessorIPLib/drivers/v_hdmiphy1/src/xhdmiphy1_hdmi.c
u64 XHdmiphy1_DruCalcCenterFreqHz(XHdmiphy1 *InstancePtr, u8 QuadId,
		XHdmiphy1_ChannelId ChId)
{
#if (XPAR_HDMIPHY1_0_TRANSCEIVER != XHDMIPHY1_GTYE5)
	XHdmiphy1_Channel *ChPtr;
	u64 DruRefClk;
#endif
	u64 ClkDetRefClk;
	u64 DataRate;
	u64 FDin;
	u64 FDruClk;

	ClkDetRefClk = XHdmiphy1_ClkDetGetRefClkFreqHz(InstancePtr,
                        XHDMIPHY1_DIR_RX);
#if (XPAR_HDMIPHY1_0_TRANSCEIVER != XHDMIPHY1_GTYE5)
	DruRefClk = XHdmiphy1_DruGetRefClkFreqHz(InstancePtr);

	/* Take the master channel (channel 1). */
	ChPtr = &InstancePtr->Quads[QuadId].Ch1;

	if ((ChId == XHDMIPHY1_CHANNEL_ID_CMN0) ||
			(ChId == XHDMIPHY1_CHANNEL_ID_CMN1)) {
		FDruClk = (DruRefClk * InstancePtr->Quads[QuadId].Plls[
			          XHDMIPHY1_CH2IDX(ChId)].PllParams.NFbDiv) /
			      (InstancePtr->Quads[QuadId].Plls[
			          XHDMIPHY1_CH2IDX(ChId)].PllParams.MRefClkDiv *
			          (ChPtr->RxOutDiv * 20));
	}
	else {
		FDruClk = (DruRefClk * ChPtr->PllParams.N1FbDiv *
			ChPtr->PllParams.N2FbDiv * 2) /
			(ChPtr->PllParams.MRefClkDiv * ChPtr->RxOutDiv * 20);
	}
#else
	/* Supress Warning */
	QuadId = QuadId;
	ChId = ChId;

	FDruClk = (u64) (XHDMIPHY1_HDMI_GTYE5_DRU_LRATE / 20);
#endif
	DataRate = 10 * ClkDetRefClk;
	FDin = DataRate * ((u64)1 << 32);

	/* Check for divide by zero. */
	if (FDin && FDruClk) {
		return (FDin / FDruClk);
	}
	return 0;
}
/*****************************************************************************/
/**
* This function calculates the center frequency value for the DRU.
*
* @param	InstancePtr is a pointer to the XHdmiphy1 GT core instance.
* @param	QuadId is the GT quad ID to operate on.
* @param	ChId is the channel ID to operate on.
*
* @return	The calculated DRU Center frequency value.
*
* @note		According to XAPP1240:
*			Center_f = fDIN * (2^32)/fdruclk
*		The DRU clock is derived from the measured reference clock and
*		the current QPLL settings.
*
******************************************************************************/
This function calculates the center frequency value for the DRU.
This function calculates the center frequency value for the DRU .
u64 XHdmiphy1_DruCalcCenterFreqHz(XHdmiphy1 *InstancePtr, u8 QuadId,
		XHdmiphy1_ChannelId ChId)
{
#if (XPAR_HDMIPHY1_0_TRANSCEIVER != XHDMIPHY1_GTYE5)
	XHdmiphy1_Channel *ChPtr;
	u64 DruRefClk;
#endif
	u64 ClkDetRefClk;
	u64 DataRate;
	u64 FDin;
	u64 FDruClk;
	ClkDetRefClk = XHdmiphy1_ClkDetGetRefClkFreqHz(InstancePtr,
                        XHDMIPHY1_DIR_RX);
#if (XPAR_HDMIPHY1_0_TRANSCEIVER != XHDMIPHY1_GTYE5)
	DruRefClk = XHdmiphy1_DruGetRefClkFreqHz(InstancePtr);
	ChPtr = &InstancePtr->Quads[QuadId].Ch1;
	if ((ChId == XHDMIPHY1_CHANNEL_ID_CMN0) ||
			(ChId == XHDMIPHY1_CHANNEL_ID_CMN1)) {
		FDruClk = (DruRefClk * InstancePtr->Quads[QuadId].Plls[
			          XHDMIPHY1_CH2IDX(ChId)].PllParams.NFbDiv) /
			      (InstancePtr->Quads[QuadId].Plls[
			          XHDMIPHY1_CH2IDX(ChId)].PllParams.MRefClkDiv *
			          (ChPtr->RxOutDiv * 20));
	}
	else {
		FDruClk = (DruRefClk * ChPtr->PllParams.N1FbDiv *
			ChPtr->PllParams.N2FbDiv * 2) /
			(ChPtr->PllParams.MRefClkDiv * ChPtr->RxOutDiv * 20);
	}
#else
	QuadId = QuadId;
	ChId = ChId;
	FDruClk = (u64) (XHDMIPHY1_HDMI_GTYE5_DRU_LRATE / 20);
#endif
	DataRate = 10 * ClkDetRefClk;
	FDin = DataRate * ((u64)1 << 32);
	if (FDin && FDruClk) {
		return (FDin / FDruClk);
	}
	return 0;
}
u64 XHdmiphy1_DruCalcCenterFreqHz ( XHdmiphy1 * InstancePtr , u8 QuadId , XHdmiphy1_ChannelId ChId ) { #if ( XPAR_HDMIPHY1_0_TRANSCEIVER != XHDMIPHY1_GTYE5 ) XHdmiphy1_Channel * ChPtr ; u64 DruRefClk ; #endif u64 ClkDetRefClk ; u64 DataRate ; u64 FDin ; u64 FDruClk ; ClkDetRefClk = XHdmiphy1_ClkDetGetRefClkFreqHz ( InstancePtr , XHDMIPHY1_DIR_RX ) ; #if ( XPAR_HDMIPHY1_0_TRANSCEIVER != XHDMIPHY1_GTYE5 ) DruRefClk = XHdmiphy1_DruGetRefClkFreqHz ( InstancePtr ) ; ChPtr = & InstancePtr -> Quads [ QuadId ] . Ch1 ; if ( ( ChId == XHDMIPHY1_CHANNEL_ID_CMN0 ) || ( ChId == XHDMIPHY1_CHANNEL_ID_CMN1 ) ) { FDruClk = ( DruRefClk * InstancePtr -> Quads [ QuadId ] . Plls [ XHDMIPHY1_CH2IDX ( ChId ) ] . PllParams . NFbDiv ) / ( InstancePtr -> Quads [ QuadId ] . Plls [ XHDMIPHY1_CH2IDX ( ChId ) ] . PllParams . MRefClkDiv * ( ChPtr -> RxOutDiv * 20 ) ) ; } else { FDruClk = ( DruRefClk * ChPtr -> PllParams . N1FbDiv * ChPtr -> PllParams . N2FbDiv * 2 ) / ( ChPtr -> PllParams . MRefClkDiv * ChPtr -> RxOutDiv * 20 ) ; } #else QuadId = QuadId ; ChId = ChId ; FDruClk = ( u64 ) ( XHDMIPHY1_HDMI_GTYE5_DRU_LRATE / 20 ) ; #endif DataRate = 10 * ClkDetRefClk ; FDin = DataRate * ( ( u64 ) 1 << 32 ) ; if ( FDin && FDruClk ) { return ( FDin / FDruClk ) ; } return 0 ; }
This function calculates the center frequency value for the DRU.
This function calculates the center frequency value for the DRU .
/* Take the master channel (channel 1). */ /* Supress Warning */ /* Check for divide by zero. */