Hdmi cannot output continuously on pynq-z2

hi ! I rebuild the base overlay and remove the block that I don’t need by following the tutorial below: Tutorial: Rebuilding the PYNQ base overlay (PYNQ v2.6)

What I want to do is to use HDMI in to read input frame and then transfer the input frame to the FIFO in PL side and then send back to PS by DMA, and then HDMI out will display the image on the monitor. Everything is fine when I only run one image. When I process multiple frames, the HDMI out will display mostly black on my monitor and then the final frame will display on the monitor.

Below is my block diagram:

the code I run on jupyter notebook:



Did I setup wrong or there something I should be careful?

1 Like

Can you try with commenting out frame.freebuffer() or adding another one after hdmi_out.writeframe(frame). It might work.

Hi ! thanks for your reply. I have tried both method, but the problem still the same. Do you have any suggestion else?

have you tried activating the DMA wait function? I can see those are commented out.

There are a couple of things to have a look at.

First, be careful when assigning array objects - doing input_buffer = frame doesn’t copy the data from frame to input_buffer instead it just changes the input_buffer reference to be that of frame thus losing handle to the input_buffer you allocated before the loop. If you want to copy the data from one buffer to another you should use input_buffer[:] = frame.

That shouldn’t be necessary in this case though. You should be able to operate on the input and output frames directly - something like:

in_frame = hdmi_in.readframe()
out_frame = hdmi_out.newframe()
dma_send.sendchannel.transfer(in_frame)
dma_recv.recvchannel.transfer(out_frame)
dma_send.sendchannel.wait()
dma_recv.recvchannel.wait()
hdmi_out.writeframe(out_frame)

You might be able to get a bit of a performance boost if you explicitly interleave the processing with the HDMI read and write commands but I don’t think it will make that much difference.

If you are running at 1080p60 you might want to check at a lower resolution/frame rate. The DDR bandwidth of the board is somewhat limited and you can start running into bottlenecks with two many video streams running.

One final note is that (at least with PYNQ >= 2.5) you shouldn’t need to worry about freebuffer. Buffers will get freed automatically when they go out of scope.

Peter

4 Likes

If you want to optimize bandwidth on the design you might consider moving the DMA engines to HP2 and HP3 and not using HP1. The reason is that HP0 and HP1 share a port on the system DDR controller, likewise HP2 and HP3. As the video block is using the same bandwidth as the two DMA engines this would help balance the load.

Peter

2 Likes

Hi ! Thanks for your reply! I have tried activating the DMA wait function, but it seems to only slow down the frame rate.

Hi ! Thanks to reply me these useful information! After I moved the DMA engines to HP2 and HP3, I can successfully output hdmi continuously. The fps is around 10. Are there any chance to enhance the speed?

You could try setting

hdmi_out.cacheable_frames = False
hdmi_in.cacheable_frames = False

between .configure and .start as shown in cell 7 of the HDMI notebook

Peter

1 Like

OK ! Thanks for your help!

您好 想請問能分享完整正確版的Jupiter notebook code嗎?最近在自學pynq板子要做學校專題,剛好參考到你的block design內容,想多瞭解是如何運作的