i.MX8MP Cached access to v4l2 buffers

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

i.MX8MP Cached access to v4l2 buffers

跳至解决方案
1,495 次查看
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

标签 (1)
标记 (3)
0 项奖励
回复
1 解答
1,422 次查看
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 项奖励
回复
2 回复数
1,423 次查看
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 项奖励
回复
1,461 次查看
jimmychan
NXP TechSupport
NXP TechSupport

userptr mode is not supported.

0 项奖励
回复