XilinxProcessorIPLib/drivers/dsitxss/examples/xdsitxss_video_test_example.c
u32 DsiTxSs_VideoTestExample(u32 DeviceId)
{
	u32 Status = XST_SUCCESS;
	XDsiTxSs_Config *ConfigPtr;
	s32 ii, jj;
	ULONG PixelIndex;
	ULONG ErrorCount = 0;
	u8 DataValue;
	XDsi_VideoTiming  Timing;

	/* Obtain the device configuration for the MIPI DSI TX Subsystem */
	ConfigPtr = XDsiTxSs_LookupConfig(DeviceId);
	if (!ConfigPtr) {
		return XST_FAILURE;
	}
	/* Copy the device configuration into the DsiTxSsInst's Config
	 * structure. */
	Status = XDsiTxSs_CfgInitialize(&DsiTxSsInst, ConfigPtr,
					ConfigPtr->BaseAddr);
	if (Status != XST_SUCCESS) {
		xil_printf("MIPI DSI TX SS config initialization failed.\n\r");
		return XST_FAILURE;
	}

	/* Run the self test. */
	Status = XDsiTxSs_SelfTest(&DsiTxSsInst);
	memset((void *)XPAR_BRAM_1_BASEADDR, 0x99,
	(XPAR_BRAM_1_HIGHADDR - XPAR_BRAM_1_BASEADDR));
	memset((void *)XPAR_BRAM_0_BASEADDR, 0x00,
	(XPAR_BRAM_0_HIGHADDR - XPAR_BRAM_0_BASEADDR));

	/*
	 * Fill the buffer with the data value
	 */
	PixelIndex = 0;
	DataValue  = 1;
	for ( ii = 0; ii < VERTICAL_RESOLUTION; ii++ ) {
		for ( jj = 0; jj < HORIZONTAL_RESOLUTION; jj++ ) {
		SrcBuffer[ PixelIndex + 0 ] = (u8) DataValue;
		SrcBuffer[ PixelIndex + 1 ] = (u8) DataValue + 1;
		SrcBuffer[ PixelIndex + 2 ] = (u8) DataValue + 2;
		DataValue += NO_BYTES_PER_PIXEL;
		PixelIndex += NO_BYTES_PER_PIXEL;
		    if(DataValue >= 0xF) {
			DataValue += 1;
		    }
		}
	}

	/* Reset the VMDA */
	ResetVDMA();

	SetupVdmaCR(VDMA_MM2S,FRAME_COUNTER);
	SetupVdmaCR(VDMA_S2MM,FRAME_COUNTER);

	ConfigureChannel(VDMA_MM2S);
	ConfigureChannel(VDMA_S2MM);

	StartChannel(VDMA_S2MM, VERTICAL_RESOLUTION);
	StartChannel(VDMA_MM2S, VERTICAL_RESOLUTION);

	/* Reset the DSI device */
	XDsiTxSs_Reset(&DsiTxSsInst);

	/* Set the Video Peripheral timing parameters */
	Timing.HActive		= HACT_VALUE;
	Timing.HBackPorch	= HBP_VALUE;
	Timing.HFrontPorch	= HFP_VALUE;
	Timing.HSyncWidth	= HSA_VALUE;
	Timing.VActive		= VACT_VALUE;
	Timing.VBackPorch	= VBP_VALUE;
	Timing.VFrontPorch	= VFP_VALUE;
	Timing.VSyncWidth	= VSA_VALUE;
	Timing.BLLPBurst	= BLLP_BURST_VALUE;

	XDsiTxSs_SetCustomVideoInterfaceTiming(&DsiTxSsInst,
			XDSI_VM_NON_BURST_SYNC_EVENT, &Timing);

	/* Enable DSI core */
	XDsiTxSs_Activate(&DsiTxSsInst, XDSITXSS_ENABLE);

	/* Wait for S2MM transfer completion */
	Status = WaitForCompletion(VDMA_S2MM, (u32*)VDMA_BASEADDR);
	if (Status != S2MM_HALT_SUCCESS) {
		 xil_printf("S2MM channel has not halted\r\n");
		 return XST_FAILURE;
	} else {
		Status = XST_SUCCESS;
	}
	/* Wait for MM2SS transfer completion */
	Status = WaitForCompletion(VDMA_MM2S, (u32*)VDMA_BASEADDR);
	if (Status != MM2S_HALT_SUCCESS) {
		xil_printf("MM2S channel has not halted\r\n");
		return XST_FAILURE;
	} else {
		Status = XST_SUCCESS;
	}
	/* Compare source and destination buffers */
	PixelIndex = 0;
	ErrorCount = 0;
	for ( ii = 0; ii < VERTICAL_RESOLUTION; ii++ ) {
	    for ( jj = 0; jj < HORIZONTAL_RESOLUTION; jj++) {
		if((SrcBuffer[ PixelIndex + 0 ] == DstBuffer[ PixelIndex + 0 ])
		&& (SrcBuffer[ PixelIndex + 1 ] == DstBuffer[ PixelIndex + 2 ])
		&& (SrcBuffer[ PixelIndex + 2 ] == DstBuffer[ PixelIndex + 1 ]))
		{
			PixelIndex = PixelIndex + 3;
		}
		else {
			ErrorCount++;
			break;
		}
	    }
	    if(ErrorCount > 0) {
		break;
	    }
	}
	if(ErrorCount > 0) {
		xil_printf("Source pattern does not match with "
		"destination pattern ... \r\n");
		return XST_FAILURE;
	}
	xil_printf("Source pattern match with destination pattern ... \r\n");
	return Status;
}
/*****************************************************************************/
/**
*
* This function is the main entry point for the video test example using the
* XDsiTxSs driver.
*
* @param	DeviceId is the unique device ID of the MIPI DSI RX
*			Subsystem core.
*
* @return
*		- XST_FAILURE if any of MIPI DSI RX Subsystem sub-core self
*		test failed.
*		- XST_SUCCESS, if all of MIPI DSI RX Subsystem sub-core self
*		test passed.
*
* @note		None.
*
******************************************************************************/
This function is the main entry point for the video test example using the
XDsiTxSs driver.
This function is the main entry point for the video test example using the XDsiTxSs driver .
u32 DsiTxSs_VideoTestExample(u32 DeviceId)
{
	u32 Status = XST_SUCCESS;
	XDsiTxSs_Config *ConfigPtr;
	s32 ii, jj;
	ULONG PixelIndex;
	ULONG ErrorCount = 0;
	u8 DataValue;
	XDsi_VideoTiming  Timing;
	ConfigPtr = XDsiTxSs_LookupConfig(DeviceId);
	if (!ConfigPtr) {
		return XST_FAILURE;
	}
	Status = XDsiTxSs_CfgInitialize(&DsiTxSsInst, ConfigPtr,
					ConfigPtr->BaseAddr);
	if (Status != XST_SUCCESS) {
		xil_printf("MIPI DSI TX SS config initialization failed.\n\r");
		return XST_FAILURE;
	}
	Status = XDsiTxSs_SelfTest(&DsiTxSsInst);
	memset((void *)XPAR_BRAM_1_BASEADDR, 0x99,
	(XPAR_BRAM_1_HIGHADDR - XPAR_BRAM_1_BASEADDR));
	memset((void *)XPAR_BRAM_0_BASEADDR, 0x00,
	(XPAR_BRAM_0_HIGHADDR - XPAR_BRAM_0_BASEADDR));
	PixelIndex = 0;
	DataValue  = 1;
	for ( ii = 0; ii < VERTICAL_RESOLUTION; ii++ ) {
		for ( jj = 0; jj < HORIZONTAL_RESOLUTION; jj++ ) {
		SrcBuffer[ PixelIndex + 0 ] = (u8) DataValue;
		SrcBuffer[ PixelIndex + 1 ] = (u8) DataValue + 1;
		SrcBuffer[ PixelIndex + 2 ] = (u8) DataValue + 2;
		DataValue += NO_BYTES_PER_PIXEL;
		PixelIndex += NO_BYTES_PER_PIXEL;
		    if(DataValue >= 0xF) {
			DataValue += 1;
		    }
		}
	}
	ResetVDMA();
	SetupVdmaCR(VDMA_MM2S,FRAME_COUNTER);
	SetupVdmaCR(VDMA_S2MM,FRAME_COUNTER);
	ConfigureChannel(VDMA_MM2S);
	ConfigureChannel(VDMA_S2MM);
	StartChannel(VDMA_S2MM, VERTICAL_RESOLUTION);
	StartChannel(VDMA_MM2S, VERTICAL_RESOLUTION);
	XDsiTxSs_Reset(&DsiTxSsInst);
	Timing.HActive		= HACT_VALUE;
	Timing.HBackPorch	= HBP_VALUE;
	Timing.HFrontPorch	= HFP_VALUE;
	Timing.HSyncWidth	= HSA_VALUE;
	Timing.VActive		= VACT_VALUE;
	Timing.VBackPorch	= VBP_VALUE;
	Timing.VFrontPorch	= VFP_VALUE;
	Timing.VSyncWidth	= VSA_VALUE;
	Timing.BLLPBurst	= BLLP_BURST_VALUE;
	XDsiTxSs_SetCustomVideoInterfaceTiming(&DsiTxSsInst,
			XDSI_VM_NON_BURST_SYNC_EVENT, &Timing);
	XDsiTxSs_Activate(&DsiTxSsInst, XDSITXSS_ENABLE);
	Status = WaitForCompletion(VDMA_S2MM, (u32*)VDMA_BASEADDR);
	if (Status != S2MM_HALT_SUCCESS) {
		 xil_printf("S2MM channel has not halted\r\n");
		 return XST_FAILURE;
	} else {
		Status = XST_SUCCESS;
	}
	Status = WaitForCompletion(VDMA_MM2S, (u32*)VDMA_BASEADDR);
	if (Status != MM2S_HALT_SUCCESS) {
		xil_printf("MM2S channel has not halted\r\n");
		return XST_FAILURE;
	} else {
		Status = XST_SUCCESS;
	}
	PixelIndex = 0;
	ErrorCount = 0;
	for ( ii = 0; ii < VERTICAL_RESOLUTION; ii++ ) {
	    for ( jj = 0; jj < HORIZONTAL_RESOLUTION; jj++) {
		if((SrcBuffer[ PixelIndex + 0 ] == DstBuffer[ PixelIndex + 0 ])
		&& (SrcBuffer[ PixelIndex + 1 ] == DstBuffer[ PixelIndex + 2 ])
		&& (SrcBuffer[ PixelIndex + 2 ] == DstBuffer[ PixelIndex + 1 ]))
		{
			PixelIndex = PixelIndex + 3;
		}
		else {
			ErrorCount++;
			break;
		}
	    }
	    if(ErrorCount > 0) {
		break;
	    }
	}
	if(ErrorCount > 0) {
		xil_printf("Source pattern does not match with "
		"destination pattern ... \r\n");
		return XST_FAILURE;
	}
	xil_printf("Source pattern match with destination pattern ... \r\n");
	return Status;
}
u32 DsiTxSs_VideoTestExample ( u32 DeviceId ) { u32 Status = XST_SUCCESS ; XDsiTxSs_Config * ConfigPtr ; s32 ii , jj ; ULONG PixelIndex ; ULONG ErrorCount = 0 ; u8 DataValue ; XDsi_VideoTiming Timing ; ConfigPtr = XDsiTxSs_LookupConfig ( DeviceId ) ; if ( ! ConfigPtr ) { return XST_FAILURE ; } Status = XDsiTxSs_CfgInitialize ( & DsiTxSsInst , ConfigPtr , ConfigPtr -> BaseAddr ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \n \r " ) ; return XST_FAILURE ; } Status = XDsiTxSs_SelfTest ( & DsiTxSsInst ) ; memset ( ( void * ) XPAR_BRAM_1_BASEADDR , 0x99 , ( XPAR_BRAM_1_HIGHADDR - XPAR_BRAM_1_BASEADDR ) ) ; memset ( ( void * ) XPAR_BRAM_0_BASEADDR , 0x00 , ( XPAR_BRAM_0_HIGHADDR - XPAR_BRAM_0_BASEADDR ) ) ; PixelIndex = 0 ; DataValue = 1 ; for ( ii = 0 ; ii < VERTICAL_RESOLUTION ; ii ++ ) { for ( jj = 0 ; jj < HORIZONTAL_RESOLUTION ; jj ++ ) { SrcBuffer [ PixelIndex + 0 ] = ( u8 ) DataValue ; SrcBuffer [ PixelIndex + 1 ] = ( u8 ) DataValue + 1 ; SrcBuffer [ PixelIndex + 2 ] = ( u8 ) DataValue + 2 ; DataValue += NO_BYTES_PER_PIXEL ; PixelIndex += NO_BYTES_PER_PIXEL ; if ( DataValue >= 0xF ) { DataValue += 1 ; } } } ResetVDMA ( ) ; SetupVdmaCR ( VDMA_MM2S , FRAME_COUNTER ) ; SetupVdmaCR ( VDMA_S2MM , FRAME_COUNTER ) ; ConfigureChannel ( VDMA_MM2S ) ; ConfigureChannel ( VDMA_S2MM ) ; StartChannel ( VDMA_S2MM , VERTICAL_RESOLUTION ) ; StartChannel ( VDMA_MM2S , VERTICAL_RESOLUTION ) ; XDsiTxSs_Reset ( & DsiTxSsInst ) ; Timing . HActive = HACT_VALUE ; Timing . HBackPorch = HBP_VALUE ; Timing . HFrontPorch = HFP_VALUE ; Timing . HSyncWidth = HSA_VALUE ; Timing . VActive = VACT_VALUE ; Timing . VBackPorch = VBP_VALUE ; Timing . VFrontPorch = VFP_VALUE ; Timing . VSyncWidth = VSA_VALUE ; Timing . BLLPBurst = BLLP_BURST_VALUE ; XDsiTxSs_SetCustomVideoInterfaceTiming ( & DsiTxSsInst , XDSI_VM_NON_BURST_SYNC_EVENT , & Timing ) ; XDsiTxSs_Activate ( & DsiTxSsInst , XDSITXSS_ENABLE ) ; Status = WaitForCompletion ( VDMA_S2MM , ( u32 * ) VDMA_BASEADDR ) ; if ( Status != S2MM_HALT_SUCCESS ) { xil_printf ( " \r \n " ) ; return XST_FAILURE ; } else { Status = XST_SUCCESS ; } Status = WaitForCompletion ( VDMA_MM2S , ( u32 * ) VDMA_BASEADDR ) ; if ( Status != MM2S_HALT_SUCCESS ) { xil_printf ( " \r \n " ) ; return XST_FAILURE ; } else { Status = XST_SUCCESS ; } PixelIndex = 0 ; ErrorCount = 0 ; for ( ii = 0 ; ii < VERTICAL_RESOLUTION ; ii ++ ) { for ( jj = 0 ; jj < HORIZONTAL_RESOLUTION ; jj ++ ) { if ( ( SrcBuffer [ PixelIndex + 0 ] == DstBuffer [ PixelIndex + 0 ] ) && ( SrcBuffer [ PixelIndex + 1 ] == DstBuffer [ PixelIndex + 2 ] ) && ( SrcBuffer [ PixelIndex + 2 ] == DstBuffer [ PixelIndex + 1 ] ) ) { PixelIndex = PixelIndex + 3 ; } else { ErrorCount ++ ; break ; } } if ( ErrorCount > 0 ) { break ; } } if ( ErrorCount > 0 ) { xil_printf ( " " " \r \n " ) ; return XST_FAILURE ; } xil_printf ( " \r \n " ) ; return Status ; }
This function is the main entry point for the video test example using the
XDsiTxSs driver.
This function is the main entry point for the video test example using the XDsiTxSs driver .
/* Obtain the device configuration for the MIPI DSI TX Subsystem */ /* Copy the device configuration into the DsiTxSsInst's Config
	 * structure. */ /* Run the self test. */ /*
	 * Fill the buffer with the data value
	 */ /* Reset the VMDA */ /* Reset the DSI device */ /* Set the Video Peripheral timing parameters */ /* Enable DSI core */ /* Wait for S2MM transfer completion */ /* Wait for MM2SS transfer completion */ /* Compare source and destination buffers */