UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Explorer
Explorer
1,036 Views
Registered: ‎04-18-2017

VDMA ring buffer is not in sequence

Hello,

 

I have a design with HDMI input and output with avent's fmc board. I have configured the VDMA like this:

vdma1.PNG

vdma2.PNG

 

The VDMA configuration is:

	xil_printf("VDMA 0 Initialization\r\n");
	XAxiVdma_Reset(pdemo->paxivdma0, XAXIVDMA_WRITE);
	XAxiVdma_Reset(pdemo->paxivdma0, XAXIVDMA_READ);
//	WriteSetup(pdemo->paxivdma0, 0x10000000, 0, 1, 1, 0, 0, pdemo->hdmii_width, pdemo->hdmii_height, 2048, 2048);
//	ReadSetup(pdemo->paxivdma0, 0x10000000, 0, 1, 1, 0, 0, pdemo->hdmio_width, pdemo->hdmio_height, 2048, 2048);
	WriteSetup(pdemo->paxivdma0, INPUT_BUFFER, 0, 1, 1, 0, 0, pdemo->hdmii_width, pdemo->hdmii_height, 2048, 2048);
	ReadSetup(pdemo->paxivdma0, OUTPUT_BUFFER, 0, 1, 1, 0, 0, pdemo->hdmio_width, pdemo->hdmio_height, 2048, 2048);
	StartTransfer(pdemo->paxivdma0);

	uint32_t frame_delay = (2 << 24);
	// Master / Input / Write
	XAxiVdma_WriteReg(XPAR_AXI_VDMA_0_BASEADDR, 0x30, 0x8B); // new
	XAxiVdma_WriteReg(XPAR_AXI_VDMA_0_BASEADDR, 0xAC, INPUT_BUFFER); // new
	XAxiVdma_WriteReg(XPAR_AXI_VDMA_0_BASEADDR, 0xA8, frame_delay + 1920*4); // new
    XAxiVdma_WriteReg(XPAR_AXI_VDMA_0_BASEADDR, 0xA4, 1920*4);
    XAxiVdma_WriteReg(XPAR_AXI_VDMA_0_BASEADDR, 0xA0, 1080);
    // Slave / Output / Read
    XAxiVdma_WriteReg(XPAR_AXI_VDMA_0_BASEADDR, 0x00, 0x8B);
    XAxiVdma_WriteReg(XPAR_AXI_VDMA_0_BASEADDR, 0x5C, OUTPUT_BUFFER);
    XAxiVdma_WriteReg(XPAR_AXI_VDMA_0_BASEADDR, 0x58, frame_delay + 1920*4);
    XAxiVdma_WriteReg(XPAR_AXI_VDMA_0_BASEADDR, 0x54, 1920*4);
    XAxiVdma_WriteReg(XPAR_AXI_VDMA_0_BASEADDR, 0x50, 1080);

And in the main, I have a while loop doing this:

		u32 park_ptr_reg = XAxiVdma_ReadReg(XPAR_AXI_VDMA_0_BASEADDR, XAXIVDMA_PARKPTR_OFFSET);
		u32 wr_ptr_new = (park_ptr_reg >> 24) & 0x1F;
		u32 rd_ptr_new = (park_ptr_reg >> 16) & 0x1F;


		if(wr_ptr_new != wr_ptr_old)
		{
			u32 in_ptr  = (wr_ptr_new == 0) ? (3) : (wr_ptr_new-1);
			wr_ptr_old = wr_ptr_new;
			//input_ptr  = (u32 *)INPUT_BUFFER  + frame_size * in_ptr;
			input_ptr  = (u32 *)INPUT_BUFFER  + frame_size * wr_ptr_new;
			output_ptr = (u32 *)OUTPUT_BUFFER + frame_size * rd_ptr_new;
			Passthrough(input_ptr, output_ptr);
			printf("wr_ptr_new: %d\n", wr_ptr_new);
		}

		if(rd_ptr_new != rd_ptr_old)
		{
			u32 out_ptr = (rd_ptr_new == 0) ? (3) : (rd_ptr_new-1);
			rd_ptr_old = rd_ptr_new;
			//output_ptr = (u32 *)OUTPUT_BUFFER + frame_size * out_ptr;
			output_ptr = (u32 *)OUTPUT_BUFFER + frame_size * rd_ptr_new;
			printf("rd_ptr_new: %d\n", rd_ptr_new);
		}

		Passthrough(input_ptr, output_ptr);   //Copies input to output

The problem is that the rd_ptr_new is not always in consecutive order or it is decreasing rather than increasing. Also, why is rd_ptr change twice and wr_ptr changes one?. Below is a the output of the printfs:

rd_ptr_new: 0

wr_ptr_new: 0

rd_ptr_new: 1
rd_ptr_new: 0

wr_ptr_new: 1

rd_ptr_new: 2
rd_ptr_new: 0

wr_ptr_new: 2

rd_ptr_new: 2

wr_ptr_new: 0

rd_ptr_new: 0
rd_ptr_new: 2

wr_ptr_new: 1

rd_ptr_new: 1

wr_ptr_new: 2

rd_ptr_new: 2
rd_ptr_new: 1

wr_ptr_new: 0

rd_ptr_new: 0

wr_ptr_new: 1

rd_ptr_new: 1
rd_ptr_new: 0

wr_ptr_new: 2

rd_ptr_new: 1

wr_ptr_new: 0

rd_ptr_new: 0
rd_ptr_new: 2

wr_ptr_new: 1

rd_ptr_new: 0

wr_ptr_new: 2

rd_ptr_new: 2
rd_ptr_new: 0

wr_ptr_new: 0

rd_ptr_new: 2
rd_ptr_new: 1

wr_ptr_new: 1

rd_ptr_new: 2

wr_ptr_new: 2

rd_ptr_new: 1
rd_ptr_new: 0

wr_ptr_new: 0

rd_ptr_new: 1

wr_ptr_new: 1

rd_ptr_new: 0
rd_ptr_new: 1

wr_ptr_new: 2

rd_ptr_new: 0

wr_ptr_new: 0

rd_ptr_new: 2
rd_ptr_new: 0

wr_ptr_new: 1

rd_ptr_new: 2

wr_ptr_new: 2

rd_ptr_new: 1
rd_ptr_new: 2

wr_ptr_new: 0

rd_ptr_new: 1

wr_ptr_new: 1

rd_ptr_new: 2
rd_ptr_new: 1

wr_ptr_new: 2

rd_ptr_new: 0
rd_ptr_new: 1

wr_ptr_new: 0

rd_ptr_new: 0

wr_ptr_new: 1

rd_ptr_new: 1
rd_ptr_new: 0

wr_ptr_new: 2

rd_ptr_new: 2

wr_ptr_new: 0

rd_ptr_new: 0
rd_ptr_new: 2

wr_ptr_new: 1

rd_ptr_new: 1

wr_ptr_new: 2

rd_ptr_new: 2
rd_ptr_new: 1

Thanks for the help.

Tags (1)
0 Kudos
10 Replies
Moderator
Moderator
974 Views
Registered: ‎11-09-2015

Re: VDMA ring buffer is not in sequence

Hi @aripod,

 

I will depends on what are the states of each action (read or write).

  • You will not read into a fame buffer you are writing into. So if you are writing in the next buffer, the rd buffer will stay in the same buffer (it will revert back)
  • Each time you finish reading a frame the read pointer will be incremented. But if it is not the latest frame available, you will revert back to the previous one

Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Explorer
Explorer
960 Views
Registered: ‎04-18-2017

Re: VDMA ring buffer is not in sequence

Hi @florentw,

 

What would make the read buffer not being available? That I am reading from it slow?

 

Thanks for the help.

0 Kudos
Moderator
Moderator
955 Views
Registered: ‎11-09-2015

Re: VDMA ring buffer is not in sequence

Hi @aripod,

 

If you are writing to a frame buffer or if the buffer is not the latest one, then you should not read in the frame buffer so "it will not be available for reading".

 

It might be that reading is too slow or too rapid


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Explorer
Explorer
948 Views
Registered: ‎04-18-2017

Re: VDMA ring buffer is not in sequence

Hi @florentw,

 

Do I need to configure something else or what I've shown is enough?

 

0 Kudos
Moderator
Moderator
939 Views
Registered: ‎11-09-2015

Re: VDMA ring buffer is not in sequence

HI @aripod,

 

Yes it seems correct


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Moderator
Moderator
894 Views
Registered: ‎11-09-2015

Re: VDMA ring buffer is not in sequence

Hi @aripod,

 

Do you have any updates on this?

 

If your question is answered or your issue is solved, please kindly mark the response which helped as solution (click on "Accept as solution" buton below the reply)

If this is not solved/answered, please reply in the topic giving more information on your current status.

Thanks and Regards,


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Explorer
Explorer
769 Views
Registered: ‎04-18-2017

Re: VDMA ring buffer is not in sequence

It does not seem to be correct as the issue still remains and I don't know how to debug this properly as the registers seem to be set how they should.

Thanks for the help.
0 Kudos
Moderator
Moderator
726 Views
Registered: ‎11-09-2015

Re: VDMA ring buffer is not in sequence

Hi @aripod,

 

What is the issue? You only described the pointer values, I do not think there is an issue with them.

Do you see any error on the output?

 

Regards,


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Explorer
Explorer
715 Views
Registered: ‎04-18-2017

Re: VDMA ring buffer is not in sequence

Hi @florentw,

 

There is an issue with the input. As the pointers do not go in order, you see the output image with a strange effect because it does not show frames consecutively. Therefore, you see an old frame after the what would be current one. I believe the reason is the pointers not being sequentially. To test it quickly, I changed from 3 to 2 so the next frame to show will be the other one that it is not currently used and then the output image looks smoother.

 

Shouldn't the pointers be consecutive so in some sort, the "follow" each other?

 

Thanks for the help. 

0 Kudos
Moderator
Moderator
566 Views
Registered: ‎11-09-2015

Re: VDMA ring buffer is not in sequence

HI @aripod,

 

For me it will really depends on how the frames are ready for writing reading.

 

I recommend you to use an example design using the VDMA as the xapp1285 and see what behaviour in it.

 

Regards,


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos