i.MX8MP Cached access to v4l2 buffers

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX8MP Cached access to v4l2 buffers

Jump to solution
1,835 Views
mfoerst
Contributor II

Hi all,

I'm capturing images from a MIPI camera on the i.MX8MP using a GStreamer pipeline. My camera driver uses the ISI and not the ISP.

I use a v4l2src element to grab the images followed by a custom element that does some image transformation:

 

gst-launch-1.0 v4l2src device=/dev/video1 io-mode=mmap ! mytransformelement ! ...

 

For testing, the custom GStreamer element just maps the buffer that it receives, reads a subset of the pixel values and writes them to an output buffer.

Now I am facing the problem that the performance is poor. Precisely, the read accesses to the buffer that I receive from v4l2src is very slow s.t. it takes ~500ms to just read the single pixels of a 12MP grayscale image without any further processing. The memory access pattern does not influence this result.

I did some experiments / research and figured out that this behavior is caused by the fact that the CPU access to the DMA-buffer that comes from the camera is not cached (as stated here).

If I do a copy of the buffer using memcpy(), the read operations are cached and are much faster. However, the memcpy itself takes ~200ms s.t. this is not an option.

I already tried to use different io-mode=dmabuf instead of mmap with the same results. Using userptr mode seems to be not supported on the i.MX8.

My questions are:

  • Why are the read accesses to the v4l2-buffer not cached?
  • Is there a way to change the memory allocation / mapping to allow cached access to the buffer?
  • Is the v4l2 buffer mode userptr really not supported on the i.MX8MP?

 

Thank you for your help

Labels (1)
0 Kudos
Reply
1 Solution
1,762 Views
mfoerst
Contributor II

I solved the problem by backporting this Linux Kernel commit to the kernel on the i.MX8MP. It uses the non-contiguous memory API and allows the v4l2 buffers to be cached.

By doing so, I get the expected performance when reading the frame buffers from the cameras.

View solution in original post

0 Kudos
Reply
2 Replies
1,763 Views
mfoerst
Contributor II

I solved the problem by backporting this Linux Kernel commit to the kernel on the i.MX8MP. It uses the non-contiguous memory API and allows the v4l2 buffers to be cached.

By doing so, I get the expected performance when reading the frame buffers from the cameras.

0 Kudos
Reply
1,801 Views
jimmychan
NXP TechSupport
NXP TechSupport

userptr mode is not supported.

0 Kudos
Reply