void InitVideo()
{
    XAxiVdma_CfgInitialize(&vdma, XAxiVdma_LookupConfig(XPAR_AXI_VDMA_0_DEVICE_ID), XPAR_AXI_VDMA_0_BASEADDR);
    XAxiVdma_Reset(&vdma, XAXIVDMA_READ);
    while(XAxiVdma_ResetNotDone(&vdma, XAXIVDMA_READ));
    
    dmasetup.VertSizeInput = 480;
    dmasetup.HoriSizeInput = 640*4;
    dmasetup.FrameDelay = 0;
    dmasetup.EnableCircularBuf = 0;
    dmasetup.EnableSync = 0;
    dmasetup.PointNum = 0;
    dmasetup.EnableFrameCounter = 0;
    
    dmasetup.Stride = 2560;
    fptr = (unsigned char*)&frames;
    
    dmasetup.FixedFrameStoreAddr = 0;
    dmasetup.FrameStoreStartAddr[0] = (int)fptr;
    dmasetup.FrameStoreStartAddr[1] = (int)fptr+dmasetup.Stride*480;
    dmasetup.FrameStoreStartAddr[2] = (int)fptr+dmasetup.Stride*480*2;
    
    XAxiVdma_DmaConfig(&vdma, XAXIVDMA_READ, &dmasetup);
    XAxiVdma_DmaSetBufferAddr(&vdma, XAXIVDMA_READ, dmasetup.FrameStoreStartAddr);
    
    XAxiVdma_DmaStart(&vdma, XAXIVDMA_READ);
}
Пример #2
0
/**
*
* This function sets up the read channel
*
* @param	InstancePtr is the instance pointer to the DMA engine.
*
* @return	XST_SUCCESS if the setup is successful, XST_FAILURE otherwise.
*
* @note		None.
*
******************************************************************************/
static int ReadSetup(XAxiVdma *InstancePtr)
{
	xil_printf("\r\nRead setup...");
	int Index;
	u32 Addr;
	int Status;

	ReadCfg.VertSizeInput = FRAME_VERTICAL_LEN;
	ReadCfg.HoriSizeInput = FRAME_HORIZONTAL_LEN * sizeof(u32);

	ReadCfg.Stride = FRAME_HORIZONTAL_LEN * sizeof(u32);
	ReadCfg.FrameDelay = 0;  /* This example does not test frame delay */

	ReadCfg.EnableCircularBuf = 1;
	ReadCfg.EnableSync = 0;  /* No Gen-Lock */

	ReadCfg.PointNum = 0;    /* No Gen-Lock */
	ReadCfg.EnableFrameCounter = 0; /* Endless transfers */

	ReadCfg.FixedFrameStoreAddr = 0; /* We are not doing parking */

	Status = XAxiVdma_DmaConfig(InstancePtr, XAXIVDMA_READ, &ReadCfg);
	if (Status != XST_SUCCESS) {
		xil_printf(
		    "Read channel config failed %d\r\n", Status);

		return XST_FAILURE;
	}

	/* Initialize buffer addresses
	 *
	 * These addresses are physical addresses
	 */
	Addr = READ_ADDRESS_BASE;
	for(Index = 0; Index < NUMBER_OF_READ_FRAMES; Index++) {
		ReadCfg.FrameStoreStartAddr[Index] = Addr;

		Addr += FRAME_HORIZONTAL_LEN * FRAME_VERTICAL_LEN * sizeof(u32);
	}

	/* Set the buffer addresses for transfer in the DMA engine
	 * The buffer addresses are physical addresses
	 */
	Status = XAxiVdma_DmaSetBufferAddr(InstancePtr, XAXIVDMA_READ,
			ReadCfg.FrameStoreStartAddr);
	if (Status != XST_SUCCESS) {
		xil_printf(
		    "Read channel set buffer address failed %d\r\n", Status);

		return XST_FAILURE;
	}

	xil_printf("done");
	return XST_SUCCESS;
}
Пример #3
0
int     ReadSetup(XAxiVdma *InstancePtr, u32 BaseAddr, u32 PointNum,
          u32 EnableCircularBuf, u32 EnableSync, u32 HoriOffset, u32 VertOffset,
          u32 HoriSize, u32 VertSize, u32 HoriStride, u32 VertStride)
{
  int Index;
  int Status;
  int BlockOffset;

  XAxiVdma_DmaSetup ReadCfg;

  ReadCfg.VertSizeInput = VertSize;
  ReadCfg.HoriSizeInput = HoriSize * 2;           // Convert Pixels to Bytes

  ReadCfg.Stride = HoriStride * 2;                // Convert Pixels to Bytes
  ReadCfg.FrameDelay = 1;

  ReadCfg.EnableCircularBuf = EnableCircularBuf;
  ReadCfg.EnableSync = EnableSync;

  ReadCfg.PointNum = PointNum;
  ReadCfg.EnableFrameCounter = 0;

  ReadCfg.FixedFrameStoreAddr = 0;

  BlockOffset = (HoriStride * 2) * VertOffset;
  BlockOffset += (HoriOffset * 2);

  Status = XAxiVdma_DmaConfig(InstancePtr, XAXIVDMA_READ, &ReadCfg);
  if (Status != XST_SUCCESS) {
    return XST_FAILURE;
  }

  /* Initialize buffer addresses
   *
   * These addresses are physical addresses
   */
  for(Index = 0; Index < 3; Index++) {
    ReadCfg.FrameStoreStartAddr[Index] = BaseAddr + BlockOffset;

    BaseAddr += HoriStride * 2 * VertStride;
  }

  /* Set the buffer addresses for transfer in the DMA engine
   * The buffer addresses are physical addresses
   */
  Status = XAxiVdma_DmaSetBufferAddr(InstancePtr, XAXIVDMA_READ, ReadCfg.FrameStoreStartAddr);
  if (Status != XST_SUCCESS) {
    return XST_FAILURE;
  }

  return XST_SUCCESS;
}
Пример #4
0
/**
*
* This function sets up the write channel
*
* @param	InstancePtr is the instance pointer to the DMA engine.
*
* @return	XST_SUCCESS if the setup is successful, XST_FAILURE otherwise.
*
* @note		None.
*
******************************************************************************/
static int WriteSetup(XAxiVdma * InstancePtr)
{
	xil_printf("\r\nWrite setup...");
	int Index;
	u32 Addr;
	int Status;

	WriteCfg.VertSizeInput = FRAME_VERTICAL_LEN;
	WriteCfg.HoriSizeInput = FRAME_HORIZONTAL_LEN * sizeof(u32);

	WriteCfg.Stride = FRAME_HORIZONTAL_LEN * sizeof(u32);
	WriteCfg.FrameDelay = 0;  /* This example does not test frame delay */

	WriteCfg.EnableCircularBuf = 1;
	WriteCfg.EnableSync = 0;  /* No Gen-Lock */

	WriteCfg.PointNum = 0;    /* No Gen-Lock */
	WriteCfg.EnableFrameCounter = 0; /* Endless transfers */

	WriteCfg.FixedFrameStoreAddr = 0; /* We are not doing parking */

	Status = XAxiVdma_DmaConfig(InstancePtr, XAXIVDMA_WRITE, &WriteCfg);
	if (Status != XST_SUCCESS) {
		xil_printf(
		    "Write channel config failed %d\r\n", Status);

		return XST_FAILURE;
	}

	/* Initialize buffer addresses
	 *
	 * Use physical addresses
	 */

	Addr = WRITE_ADDRESS_BASE;
	for(Index = 0; Index < NUMBER_OF_WRITE_FRAMES; Index++) {
		WriteCfg.FrameStoreStartAddr[Index] = Addr;

		Addr += FRAME_HORIZONTAL_LEN * FRAME_VERTICAL_LEN * sizeof(u32);

	}


	/* Set the buffer addresses for transfer in the DMA engine
	 */
	Status = XAxiVdma_DmaSetBufferAddr(InstancePtr, XAXIVDMA_WRITE,
	        WriteCfg.FrameStoreStartAddr);
	if (Status != XST_SUCCESS) {
		xil_printf(
		    "Write channel set buffer address failed %d\r\n", Status);

		return XST_FAILURE;
	}

	/* Clear data buffer
	 */
	memset((void *)WriteFrameAddr, 0,
	    FRAME_HORIZONTAL_LEN * FRAME_VERTICAL_LEN * NUMBER_OF_WRITE_FRAMES);


	/* Initialise data buffer to blue */
	register int i;
	register u32 *vbufptr = (u32 *)READ_ADDRESS_BASE;
	for (i = 0; i < NUMBER_OF_READ_FRAMES * FRAME_HORIZONTAL_LEN * FRAME_VERTICAL_LEN ; i++) {
		vbufptr[i] = 0x0000FF;
	}

	/* Initialise data buffer with nice pattern */
//	register int i;
//	register u32 x;
//	register u32 y;
//	int frame_size = FRAME_HORIZONTAL_LEN * FRAME_VERTICAL_LEN;
//	register u32 *vbufptr = (u32 *)READ_ADDRESS_BASE;
//	for (i = 0; i < NUMBER_OF_READ_FRAMES ; i++) {
//		for (x = 0; x < FRAME_HORIZONTAL_LEN; x++) {
//			for (y = 0; y < FRAME_VERTICAL_LEN; y++) {
//				vbufptr[(i * frame_size) + y * FRAME_HORIZONTAL_LEN + x] = (x/5 * 0x000001) + (y/3 * 0x00FF00);
//			}
//		}
//	}

	xil_printf("done");
	return XST_SUCCESS;
}
void initVideo()
{
	init_platform(); // Necessary for all programs.
	int Status; // Keep track of success/failure of system function calls.
	// There are 3 steps to initializing the vdma driver and IP.
	// Step 1: lookup the memory structure that is used to access the vdma driver.
	XAxiVdma_Config * VideoDMAConfig = XAxiVdma_LookupConfig(
			XPAR_AXI_VDMA_0_DEVICE_ID);
	// Step 2: Initialize the memory structure and the hardware.
	if (XST_FAILURE == XAxiVdma_CfgInitialize(&videoDMAController,
			VideoDMAConfig, XPAR_AXI_VDMA_0_BASEADDR)) {
		xil_printf("VideoDMA Did not initialize.\r\n");
	}
	// Step 3: (optional) set the frame store number.
	if (XST_FAILURE == XAxiVdma_SetFrmStore(&videoDMAController, 2,
			XAXIVDMA_READ)) {
		xil_printf("Set Frame Store Failed.");
	}
	// Initialization is complete at this point.

	// Setup the frame counter. We want two read frames. We don't need any write frames but the
	// function generates an error if you set the write frame count to 0. We set it to 2
	// but ignore it because we don't need a write channel at all.
	XAxiVdma_FrameCounter myFrameConfig;
	myFrameConfig.ReadFrameCount = 2;
	myFrameConfig.ReadDelayTimerCount = 10;
	myFrameConfig.WriteFrameCount = 2;
	myFrameConfig.WriteDelayTimerCount = 10;
	Status = XAxiVdma_SetFrameCounter(&videoDMAController, &myFrameConfig);
	if (Status != XST_SUCCESS) {
		xil_printf("Set frame counter failed %d\r\n", Status);
		if (Status == XST_VDMA_MISMATCH_ERROR)
			xil_printf("DMA Mismatch Error\r\n");
	}
	// Now we tell the driver about the geometry of our frame buffer and a few other things.
	// Our image is 480 x 640.
	XAxiVdma_DmaSetup myFrameBuffer;

	myFrameBuffer.VertSizeInput = 480; // 480 vertical pixels.
	myFrameBuffer.HoriSizeInput = 640 * 4; // 640 horizontal (32-bit pixels).
	myFrameBuffer.Stride = 640 * 4; // Dont' worry about the rest of the values.
	myFrameBuffer.FrameDelay = 0;
	myFrameBuffer.EnableCircularBuf = 1;
	myFrameBuffer.EnableSync = 0;
	myFrameBuffer.PointNum = 0;
	myFrameBuffer.EnableFrameCounter = 0;
	myFrameBuffer.FixedFrameStoreAddr = 0;
	if (XST_FAILURE == XAxiVdma_DmaConfig(&videoDMAController, XAXIVDMA_READ,
			&myFrameBuffer)) {
		xil_printf("DMA Config Failed\r\n");
	}
	// We need to give the frame buffer pointers to the memory that it will use. This memory
	// is where you will write your video data. The vdma IP/driver then streams it to the HDMI
	// IP.
	myFrameBuffer.FrameStoreStartAddr[0] = FRAME_BUFFER_ADDR;
	myFrameBuffer.FrameStoreStartAddr[1] = FRAME_BUFFER_ADDR + 4*640*480;

	if (XST_FAILURE == XAxiVdma_DmaSetBufferAddr(&videoDMAController,
			XAXIVDMA_READ, myFrameBuffer.FrameStoreStartAddr)) {
		xil_printf("DMA Set Address Failed Failed\r\n");
	}
	// Print a sanity message if you get this far.
	xil_printf("Woohoo! I made it through initialization.\n\r");
	// Now, let's get ready to start displaying some stuff on the screen.
	// The variables framePointer and framePointer1 are just pointers to the base address
	// of frame 0 and frame 1.

	// This tells the HDMI controller the resolution of your display (there must be a better way to do this).
	XIo_Out32(XPAR_AXI_HDMI_0_BASEADDR, 640*480);

	// Start the DMA for the read channel only.
	if (XST_FAILURE == XAxiVdma_DmaStart(&videoDMAController, XAXIVDMA_READ)) {
		xil_printf("DMA START FAILED\r\n");
	}
	// We have two frames, let's park on frame 0. Use frameIndex to index them.
	// Note that you have to start the DMA process before parking on a frame.
	if (XST_FAILURE == XAxiVdma_StartParking(&videoDMAController, frameIndex,
			XAXIVDMA_READ)) {
		xil_printf("vdma parking failed\n\r");
	}
}