XilinxProcessorIPLib/drivers/v_hdmitxss1/examples/xhdmi_example/idt_8t49n24x.c
static int IDT_8T49N24x_GetIntDivTable(int FOut, int *DivTable, u8 Bypass)
{
	int NS1_Options[4] = {1,4,5,6};
	int index;
	int NS2Min = 1;
	int NS2Max = 1;
	
	int NS2Temp;
	int OutDivTemp;
	u32 VCOTemp;
	int OutDivMin;
	int OutDivMax;

	/* ceil(IDT_8T49N24X_FVCO_MIN/FOut) */
	OutDivMin = (IDT_8T49N24X_FVCO_MIN/FOut) +
					(((IDT_8T49N24X_FVCO_MIN % FOut)==0) ? 0 : 1);
	/* (int)floor(IDT_8T49N24X_FVCO_MAX/FOut) */
	OutDivMax = (IDT_8T49N24X_FVCO_MAX/FOut);

	int Count = 0;
	int *DivTablePtr = DivTable;
	
	if (Bypass == TRUE) {
		index = 0;
	}
	else {
		index = 1;
	}
	
	for (int i = index; i < (sizeof(NS1_Options)/sizeof(int)); i++) {
		/* This is for the case where we want to bypass NS2 */
		if ((NS1_Options[i] == OutDivMin) || (NS1_Options[i] == OutDivMax)) {
			NS2Min = 0;
			NS2Max = 0;
		}
	}
	
	/* if this test passes, then we know we're not in the bypass case */
	if (NS2Min == 1) {
		/* The last element in the list */
		/* (int)ceil(OutDivMin / NS1_Options[3] / 2) */
		NS2Min = (OutDivMin / NS1_Options[3] / 2) +
				((((OutDivMin / NS1_Options[3]) % 2)==0) ? 0 : 1);
		/* floor(OutDivMax / NS1_Options[index] / 2) */
		NS2Max = (OutDivMax / NS1_Options[index] / 2);
		if (NS2Max == 0)
			/* because we're rounding-down for the max, we may end-up with
			   it being 0, in which case we need to make it 1 */
			NS2Max = 1; 
	}
	 
	NS2Temp = NS2Min;
	
	while (NS2Temp <= NS2Max) {
		for (int i = index; i < (sizeof(NS1_Options)/sizeof(int)); i++) {
			if (NS2Temp == 0) {
				OutDivTemp = NS1_Options[i];
			}
			else {
				OutDivTemp = NS1_Options[i] * NS2Temp * 2;
			}
			
			VCOTemp = FOut * OutDivTemp;
			
			if ((VCOTemp <= IDT_8T49N24X_FVCO_MAX) &&
			    (VCOTemp >= IDT_8T49N24X_FVCO_MIN)) {
				*DivTablePtr = OutDivTemp;
				Count++;
				DivTablePtr++;
			}
		}
		NS2Temp++;
	}
	
	return Count;
}
/* Get valid Integer output divider values */
Get valid Integer output divider values
Get valid Integer output divider values
static int IDT_8T49N24x_GetIntDivTable(int FOut, int *DivTable, u8 Bypass)
{
	int NS1_Options[4] = {1,4,5,6};
	int index;
	int NS2Min = 1;
	int NS2Max = 1;
	int NS2Temp;
	int OutDivTemp;
	u32 VCOTemp;
	int OutDivMin;
	int OutDivMax;
	OutDivMin = (IDT_8T49N24X_FVCO_MIN/FOut) +
					(((IDT_8T49N24X_FVCO_MIN % FOut)==0) ? 0 : 1);
	OutDivMax = (IDT_8T49N24X_FVCO_MAX/FOut);
	int Count = 0;
	int *DivTablePtr = DivTable;
	if (Bypass == TRUE) {
		index = 0;
	}
	else {
		index = 1;
	}
	for (int i = index; i < (sizeof(NS1_Options)/sizeof(int)); i++) {
		if ((NS1_Options[i] == OutDivMin) || (NS1_Options[i] == OutDivMax)) {
			NS2Min = 0;
			NS2Max = 0;
		}
	}
	if (NS2Min == 1) {
		NS2Min = (OutDivMin / NS1_Options[3] / 2) +
				((((OutDivMin / NS1_Options[3]) % 2)==0) ? 0 : 1);
		NS2Max = (OutDivMax / NS1_Options[index] / 2);
		if (NS2Max == 0)
			NS2Max = 1; 
	}
	NS2Temp = NS2Min;
	while (NS2Temp <= NS2Max) {
		for (int i = index; i < (sizeof(NS1_Options)/sizeof(int)); i++) {
			if (NS2Temp == 0) {
				OutDivTemp = NS1_Options[i];
			}
			else {
				OutDivTemp = NS1_Options[i] * NS2Temp * 2;
			}
			VCOTemp = FOut * OutDivTemp;
			if ((VCOTemp <= IDT_8T49N24X_FVCO_MAX) &&
			    (VCOTemp >= IDT_8T49N24X_FVCO_MIN)) {
				*DivTablePtr = OutDivTemp;
				Count++;
				DivTablePtr++;
			}
		}
		NS2Temp++;
	}
	return Count;
}
static int IDT_8T49N24x_GetIntDivTable ( int FOut , int * DivTable , u8 Bypass ) { int NS1_Options [ 4 ] = { 1 , 4 , 5 , 6 } ; int index ; int NS2Min = 1 ; int NS2Max = 1 ; int NS2Temp ; int OutDivTemp ; u32 VCOTemp ; int OutDivMin ; int OutDivMax ; OutDivMin = ( IDT_8T49N24X_FVCO_MIN / FOut ) + ( ( ( IDT_8T49N24X_FVCO_MIN % FOut ) == 0 ) ? 0 : 1 ) ; OutDivMax = ( IDT_8T49N24X_FVCO_MAX / FOut ) ; int Count = 0 ; int * DivTablePtr = DivTable ; if ( Bypass == TRUE ) { index = 0 ; } else { index = 1 ; } for ( int i = index ; i < ( sizeof ( NS1_Options ) / sizeof ( int ) ) ; i ++ ) { if ( ( NS1_Options [ i ] == OutDivMin ) || ( NS1_Options [ i ] == OutDivMax ) ) { NS2Min = 0 ; NS2Max = 0 ; } } if ( NS2Min == 1 ) { NS2Min = ( OutDivMin / NS1_Options [ 3 ] / 2 ) + ( ( ( ( OutDivMin / NS1_Options [ 3 ] ) % 2 ) == 0 ) ? 0 : 1 ) ; NS2Max = ( OutDivMax / NS1_Options [ index ] / 2 ) ; if ( NS2Max == 0 ) NS2Max = 1 ; } NS2Temp = NS2Min ; while ( NS2Temp <= NS2Max ) { for ( int i = index ; i < ( sizeof ( NS1_Options ) / sizeof ( int ) ) ; i ++ ) { if ( NS2Temp == 0 ) { OutDivTemp = NS1_Options [ i ] ; } else { OutDivTemp = NS1_Options [ i ] * NS2Temp * 2 ; } VCOTemp = FOut * OutDivTemp ; if ( ( VCOTemp <= IDT_8T49N24X_FVCO_MAX ) && ( VCOTemp >= IDT_8T49N24X_FVCO_MIN ) ) { * DivTablePtr = OutDivTemp ; Count ++ ; DivTablePtr ++ ; } } NS2Temp ++ ; } return Count ; }
Get valid Integer output divider values
Get valid Integer output divider values
/* ceil(IDT_8T49N24X_FVCO_MIN/FOut) */ /* (int)floor(IDT_8T49N24X_FVCO_MAX/FOut) */ /* This is for the case where we want to bypass NS2 */ /* if this test passes, then we know we're not in the bypass case */ /* The last element in the list */ /* (int)ceil(OutDivMin / NS1_Options[3] / 2) */ /* floor(OutDivMax / NS1_Options[index] / 2) */ /* because we're rounding-down for the max, we may end-up with
			   it being 0, in which case we need to make it 1 */