XilinxProcessorIPLib/drivers/dp14txss/examples/src/dats_dp14/menus.c
int XVidFrameCrc_Compare(u16 comp1, u16 comp2, u16 comp3,
		XVidC_VideoTimingMode TimingTable, user_config_struct user_config,
		u8 timeout, u8 LineRate, u8 LaneCount)
{
	u16 calc_comp1;
	u16 calc_comp2;
	u16 calc_comp3;

	u16 src_comp1;
	u16 src_comp2;
	u16 src_comp3;

	u16 snk_comp1;
	u16 snk_comp2;
	u16 snk_comp3;

	u16 crc_match;

	calc_comp1 = XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_G_R)
			& VIDEO_FRAME_CRC_R_Y_COMP_MASK;

	calc_comp2 = (XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_G_R)
			& VIDEO_FRAME_CRC_G_CR_COMP_MASK)
			>> VIDEO_FRAME_CRC_G_CR_COMP_SHIFT;

	calc_comp3 = XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_B)
			& VIDEO_FRAME_CRC_B_CB_COMP_MASK;

	//Reading twice for better stability
	calc_comp1 = XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_G_R)
			& VIDEO_FRAME_CRC_R_Y_COMP_MASK;

	calc_comp2 = (XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_G_R)
			& VIDEO_FRAME_CRC_G_CR_COMP_MASK)
			>> VIDEO_FRAME_CRC_G_CR_COMP_SHIFT;

	calc_comp3 = XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_B)
			& VIDEO_FRAME_CRC_B_CB_COMP_MASK;


	/*Y22 now had 3 components CRC*/
	//matching this to UCD400
//	if(user_config.user_format == TEST_YCBCR422_FORMAT)
//	{
//		src_comp1 = calc_comp1;
//		src_comp2 = calc_comp2;
//		src_comp3 = calc_comp3;
//
//		snk_comp1 = comp3;
//		snk_comp2 = comp1;
//		snk_comp3 = comp2;
//	}
//	else
//	{
		src_comp1 = calc_comp1;
		src_comp2 = calc_comp2;
		src_comp3 = calc_comp3;

		snk_comp1 = comp1;
		snk_comp2 = comp2;
		snk_comp3 = comp3;
//	}

	if((src_comp1==snk_comp1) && (src_comp2==snk_comp2) && (src_comp3==snk_comp3))
		crc_match = 1;
	else
		crc_match = 0;

	if( (crc_match==1) && (timeout==0))
	{
		xil_printf("VID_RESULT, PASSED, %s, %d, %d, %d, %d, %d, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, %d\r\n",
				TimingTable.Name, TimingTable.Timing.HActive, TimingTable.Timing.VActive,
				TimingTable.FrameRate, user_config.user_bpc, user_config.user_format,
				src_comp1,src_comp2,src_comp3, snk_comp1, snk_comp2,snk_comp3,LineRate,LaneCount);
		return (XST_SUCCESS);
	}
	else if((timeout==2))
	{
		xil_printf("VID_RESULT, SKIPPED, %s, %d, %d, %d, %d, %d, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, %d\r\n",
				TimingTable.Name, TimingTable.Timing.HActive, TimingTable.Timing.VActive,
				TimingTable.FrameRate, user_config.user_bpc, user_config.user_format,
				src_comp1,src_comp2,src_comp3, snk_comp1, snk_comp2,snk_comp3,LineRate,LaneCount);
		return (XST_FAILURE);
	}
	else
	{
		xil_printf("VID_RESULT, FAILED, %s, %d, %d, %d, %d, %d, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, %d\r\n",
				TimingTable.Name, TimingTable.Timing.HActive, TimingTable.Timing.VActive,
				TimingTable.FrameRate, user_config.user_bpc, user_config.user_format,
				src_comp1,src_comp2,src_comp3, snk_comp1, snk_comp2,snk_comp3,LineRate,LaneCount);
		return (XST_FAILURE);
	}

}
/*****************************************************************************/
/**
*
* This function compares CRC values of Video components
*
* @param	None.
*
* @return	None.
*
* @note		None.
*
******************************************************************************/
This function compares CRC values of Video components
This function compares CRC values of Video components
int XVidFrameCrc_Compare(u16 comp1, u16 comp2, u16 comp3,
		XVidC_VideoTimingMode TimingTable, user_config_struct user_config,
		u8 timeout, u8 LineRate, u8 LaneCount)
{
	u16 calc_comp1;
	u16 calc_comp2;
	u16 calc_comp3;
	u16 src_comp1;
	u16 src_comp2;
	u16 src_comp3;
	u16 snk_comp1;
	u16 snk_comp2;
	u16 snk_comp3;
	u16 crc_match;
	calc_comp1 = XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_G_R)
			& VIDEO_FRAME_CRC_R_Y_COMP_MASK;
	calc_comp2 = (XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_G_R)
			& VIDEO_FRAME_CRC_G_CR_COMP_MASK)
			>> VIDEO_FRAME_CRC_G_CR_COMP_SHIFT;
	calc_comp3 = XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_B)
			& VIDEO_FRAME_CRC_B_CB_COMP_MASK;
	calc_comp1 = XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_G_R)
			& VIDEO_FRAME_CRC_R_Y_COMP_MASK;
	calc_comp2 = (XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_G_R)
			& VIDEO_FRAME_CRC_G_CR_COMP_MASK)
			>> VIDEO_FRAME_CRC_G_CR_COMP_SHIFT;
	calc_comp3 = XVidFrameCrc_ReadReg(XPAR_VIDEO_FRAME_CRC_BASEADDR,
			VIDEO_FRAME_CRC_VALUE_B)
			& VIDEO_FRAME_CRC_B_CB_COMP_MASK;
		snk_comp1 = comp3;
		snk_comp2 = comp1;
		snk_comp3 = comp2;
	}
	else
		src_comp1 = calc_comp1;
		src_comp2 = calc_comp2;
		src_comp3 = calc_comp3;
		snk_comp1 = comp1;
		snk_comp2 = comp2;
		snk_comp3 = comp3;
	}
	if((src_comp1==snk_comp1) && (src_comp2==snk_comp2) && (src_comp3==snk_comp3))
		crc_match = 1;
	else
		crc_match = 0;
	if( (crc_match==1) && (timeout==0))
	{
		xil_printf("VID_RESULT, PASSED, %s, %d, %d, %d, %d, %d, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, %d\r\n",
				TimingTable.Name, TimingTable.Timing.HActive, TimingTable.Timing.VActive,
				TimingTable.FrameRate, user_config.user_bpc, user_config.user_format,
				src_comp1,src_comp2,src_comp3, snk_comp1, snk_comp2,snk_comp3,LineRate,LaneCount);
		return (XST_SUCCESS);
	}
	else if((timeout==2))
	{
		xil_printf("VID_RESULT, SKIPPED, %s, %d, %d, %d, %d, %d, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, %d\r\n",
				TimingTable.Name, TimingTable.Timing.HActive, TimingTable.Timing.VActive,
				TimingTable.FrameRate, user_config.user_bpc, user_config.user_format,
				src_comp1,src_comp2,src_comp3, snk_comp1, snk_comp2,snk_comp3,LineRate,LaneCount);
		return (XST_FAILURE);
	}
	else
	{
		xil_printf("VID_RESULT, FAILED, %s, %d, %d, %d, %d, %d, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, %d\r\n",
				TimingTable.Name, TimingTable.Timing.HActive, TimingTable.Timing.VActive,
				TimingTable.FrameRate, user_config.user_bpc, user_config.user_format,
				src_comp1,src_comp2,src_comp3, snk_comp1, snk_comp2,snk_comp3,LineRate,LaneCount);
		return (XST_FAILURE);
	}
}
int XVidFrameCrc_Compare ( u16 comp1 , u16 comp2 , u16 comp3 , XVidC_VideoTimingMode TimingTable , user_config_struct user_config , u8 timeout , u8 LineRate , u8 LaneCount ) { u16 calc_comp1 ; u16 calc_comp2 ; u16 calc_comp3 ; u16 src_comp1 ; u16 src_comp2 ; u16 src_comp3 ; u16 snk_comp1 ; u16 snk_comp2 ; u16 snk_comp3 ; u16 crc_match ; calc_comp1 = XVidFrameCrc_ReadReg ( XPAR_VIDEO_FRAME_CRC_BASEADDR , VIDEO_FRAME_CRC_VALUE_G_R ) & VIDEO_FRAME_CRC_R_Y_COMP_MASK ; calc_comp2 = ( XVidFrameCrc_ReadReg ( XPAR_VIDEO_FRAME_CRC_BASEADDR , VIDEO_FRAME_CRC_VALUE_G_R ) & VIDEO_FRAME_CRC_G_CR_COMP_MASK ) >> VIDEO_FRAME_CRC_G_CR_COMP_SHIFT ; calc_comp3 = XVidFrameCrc_ReadReg ( XPAR_VIDEO_FRAME_CRC_BASEADDR , VIDEO_FRAME_CRC_VALUE_B ) & VIDEO_FRAME_CRC_B_CB_COMP_MASK ; calc_comp1 = XVidFrameCrc_ReadReg ( XPAR_VIDEO_FRAME_CRC_BASEADDR , VIDEO_FRAME_CRC_VALUE_G_R ) & VIDEO_FRAME_CRC_R_Y_COMP_MASK ; calc_comp2 = ( XVidFrameCrc_ReadReg ( XPAR_VIDEO_FRAME_CRC_BASEADDR , VIDEO_FRAME_CRC_VALUE_G_R ) & VIDEO_FRAME_CRC_G_CR_COMP_MASK ) >> VIDEO_FRAME_CRC_G_CR_COMP_SHIFT ; calc_comp3 = XVidFrameCrc_ReadReg ( XPAR_VIDEO_FRAME_CRC_BASEADDR , VIDEO_FRAME_CRC_VALUE_B ) & VIDEO_FRAME_CRC_B_CB_COMP_MASK ; src_comp1 = calc_comp1 ; src_comp2 = calc_comp2 ; src_comp3 = calc_comp3 ; snk_comp1 = comp1 ; snk_comp2 = comp2 ; snk_comp3 = comp3 ; if ( ( src_comp1 == snk_comp1 ) && ( src_comp2 == snk_comp2 ) && ( src_comp3 == snk_comp3 ) ) crc_match = 1 ; else crc_match = 0 ; if ( ( crc_match == 1 ) && ( timeout == 0 ) ) { xil_printf ( " \r \n " , TimingTable . Name , TimingTable . Timing . HActive , TimingTable . Timing . VActive , TimingTable . FrameRate , user_config . user_bpc , user_config . user_format , src_comp1 , src_comp2 , src_comp3 , snk_comp1 , snk_comp2 , snk_comp3 , LineRate , LaneCount ) ; return ( XST_SUCCESS ) ; } else if ( ( timeout == 2 ) ) { xil_printf ( " \r \n " , TimingTable . Name , TimingTable . Timing . HActive , TimingTable . Timing . VActive , TimingTable . FrameRate , user_config . user_bpc , user_config . user_format , src_comp1 , src_comp2 , src_comp3 , snk_comp1 , snk_comp2 , snk_comp3 , LineRate , LaneCount ) ; return ( XST_FAILURE ) ; } else { xil_printf ( " \r \n " , TimingTable . Name , TimingTable . Timing . HActive , TimingTable . Timing . VActive , TimingTable . FrameRate , user_config . user_bpc , user_config . user_format , src_comp1 , src_comp2 , src_comp3 , snk_comp1 , snk_comp2 , snk_comp3 , LineRate , LaneCount ) ; return ( XST_FAILURE ) ; } }
This function compares CRC values of Video components
This function compares CRC values of Video components
//Reading twice for better stability /*Y22 now had 3 components CRC*/ //matching this to UCD400 //	if(user_config.user_format == TEST_YCBCR422_FORMAT) //	{ //		src_comp1 = calc_comp1; //		src_comp2 = calc_comp2; //		src_comp3 = calc_comp3; // //		snk_comp1 = comp3; //		snk_comp2 = comp1; //		snk_comp3 = comp2; //	} //	else //	{ //	}