Norris Lin
Published © GPL3+

PYNQ-Z2 HDMI Usage - 4: Video Processing Seamless Switch

This post adds a toggle for the Sobel filter, ensuring the screen remains stable with no blackout.

IntermediateFull instructions provided2 hours337

Things used in this project

Story

Read more

Schematics

Seamless Switch Block Diagram

Code

sobel_filter_switch.c

C/C++
/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc.  All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/

/*
 * helloworld.c: simple test application
 *
 * This application configures UART 16550 to baud rate 9600.
 * PS7 UART (Zynq) is not initialized by this application, since
 * bootrom/bsp configures it to baud rate 115200
 *
 * ------------------------------------------------
 * | UART TYPE   BAUD RATE                        |
 * ------------------------------------------------
 *   uartns550   9600
 *   uartlite    Configurable only in HW design
 *   ps7_uart    115200 (configured by bootrom/bsp)
 */

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"


#include "xgpio.h"

#include "xhls_sobel_axi_stream_top.h"


XHls_sobel_axi_stream_top example_ptr;

XGpio input;
XGpio FIFO_Reset;

#define width   1920
#define height  1080


void ResetVDMA()
{

	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x00, 0x00000004);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x30, 0x00000004);

	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0x00, 0x00000004);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0x30, 0x00000004);

}

void RunVDMAwithRegister(){

/////////////////////////// VDMA 0 /////////////////////////
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x30, 0x8B);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xAC, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0x0000000);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xB0, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0x2000000);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xB4, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0x4000000);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xA8, width*3);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xA4, width*3);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xA0, height);


	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x00, 0x8B);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x5C, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0x0000000);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x60, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0x2000000);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x64, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0x4000000);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x58, width*3);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x54, width*3);
	Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x50, height);
/////////////////////////////////////////////////////////////////////////////
/////////////////////////// VDMA 1 /////////////////////////
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0x30, 0x8B);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0xAC, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0x6000000);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0xB0, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0x8000000);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0xB4, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0xA000000);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0xA8, width*3);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0xA4, width*3);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0xA0, height);


	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0x00, 0x8B);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0x5C, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0x6000000);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0x60, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0x8000000);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0x64, XPAR_PS7_DDR_0_S_AXI_BASEADDR + 0xA000000);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0x58, width*3);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0x54, width*3);
	Xil_Out32(XPAR_AXI_VDMA_1_BASEADDR + 0x50, height);
/////////////////////////////////////////////////////////////////////////////
}


int main()
{
    init_platform();
    int Status;

    XGpio_Initialize(&input, XPAR_AXI_GPIO_0_DEVICE_ID);
    XGpio_Initialize(&FIFO_Reset, XPAR_AXI_GPIO_1_DEVICE_ID);

    XGpio_DiscreteWrite(&FIFO_Reset, 1, 0);
	usleep(10000);
	XGpio_DiscreteWrite(&FIFO_Reset, 1, 1);

    ResetVDMA();



	// Initialize module
	Status = XHls_sobel_axi_stream_top_Initialize(&example_ptr, XPAR_HLS_SOBEL_AXI_STREAM_0_DEVICE_ID);
	if (Status != XST_SUCCESS) {
		xil_printf("Example Initialization Failed\r\n");
		return XST_FAILURE;
	}

	XHls_sobel_axi_stream_top_Set_rows(&example_ptr, height);
	XHls_sobel_axi_stream_top_Set_cols(&example_ptr, width);




	RunVDMAwithRegister();


	for(;;){


		XHls_sobel_axi_stream_top_Start(&example_ptr);
		XHls_sobel_axi_stream_top_EnableAutoRestart(&example_ptr);

		XGpio_DiscreteWrite(&input, 2, XGpio_DiscreteRead(&input, 1));



	}


    print("Successfully ran application");
    cleanup_platform();
    return 0;
}

Credits

Norris Lin
6 projects • 4 followers
An R&D professional passionate about FPGA development, skilled in system and IP integration.
Contact

Comments

Please log in or sign up to comment.