V4l2src0: Failed to allocate required memory

Dear community,

Apalis IMX8
Ixora Carrier
TDX Wayland with XWayland 5.3.0-devel-20210730092438+build.0 (dunfell)
Apalis-iMX8_Reference-Multimedia-Image

I am getting 2 bugs from v4l2 drivers.
One of it is about hardware acc. encode:
GST_DEBUG=3 gst-launch-1.0 v4l2src device=/dev/video4 io-mode=dmabuf ! 'video/x-raw, format=(string)UYVY, width=720, height=480, framerate=30/1, interlace-mode=interleaved' ! deinterlace fields=1 method=2 ! videoconvert ! v4l2h264enc output-io-mode=dmabuf-import ! filesink location=dmaTest1.mp4 sync=false

output:

Setting pipeline to PAUSED ...
0:00:00.110224177  1830 0xaaaaec82e2d0 WARN                    v4l2 gstv4l2object.c:2031:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from http://git.linuxtv.org/v4l-utils.git

0:00:00.110261551  1830 0xaaaaec82e2d0 WARN                    v4l2 gstv4l2object.c:2031:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from http://git.linuxtv.org/v4l-utils.git

0:00:00.110397924  1830 0xaaaaec82e2d0 WARN                    v4l2 gstv4l2object.c:4400:gst_v4l2_object_probe_caps:<v4l2h264enc0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Invalid argument
0:00:00.110666669  1830 0xaaaaec82e2d0 WARN                    v4l2 v4l2_calls.c:547:gst_v4l2_subscribe_event:<v4l2src0> Cannot subscribe V4L2_EVENT_SOURCE_CHANGE or V4L2_EVENT_EOS event for device '/dev/video4'.
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
0:00:00.125634762  1830 0xaaaaec84f320 WARN          v4l2bufferpool gstv4l2bufferpool.c:813:gst_v4l2_buffer_pool_start:<v4l2src0:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:00:00.125767135  1830 0xaaaaec84f320 ERROR          v4l2allocator gstv4l2allocator.c:943:gst_v4l2_allocator_alloc_dmabuf:<v4l2src0:pool:src:allocator> Failed to export DMABUF: Inappropriate ioctl for device
0:00:00.125797884  1830 0xaaaaec84f320 ERROR         v4l2bufferpool gstv4l2bufferpool.c:479:gst_v4l2_buffer_pool_alloc_buffer:<v4l2src0:pool:src> failed to allocate buffer
0:00:00.125824384  1830 0xaaaaec84f320 WARN              bufferpool gstbufferpool.c:305:do_alloc_buffer:<v4l2src0:pool:src> alloc function failed
0:00:00.125849508  1830 0xaaaaec84f320 WARN              bufferpool gstbufferpool.c:338:default_start:<v4l2src0:pool:src> failed to allocate buffer
0:00:00.125874133  1830 0xaaaaec84f320 ERROR         v4l2bufferpool gstv4l2bufferpool.c:921:gst_v4l2_buffer_pool_start:<v4l2src0:pool:src> allocate failed
0:00:00.125898007  1830 0xaaaaec84f320 ERROR             bufferpool gstbufferpool.c:559:gst_buffer_pool_set_active:<v4l2src0:pool:src> start failed
0:00:00.125932632  1830 0xaaaaec84f320 WARN                 v4l2src gstv4l2src.c:660:gst_v4l2src_decide_allocation:<v4l2src0> error: Failed to allocate required memory.
0:00:00.125960381  1830 0xaaaaec84f320 WARN                 v4l2src gstv4l2src.c:660:gst_v4l2src_decide_allocation:<v4l2src0> error: Buffer pool activation failed
0:00:00.126067129  1830 0xaaaaec84f320 WARN                 basesrc gstbasesrc.c:3292:gst_base_src_prepare_allocation:<v4l2src0> Subclass failed to decide allocation
0:00:00.126123128  1830 0xaaaaec84f320 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
0:00:00.126152877  1830 0xaaaaec84f320 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason not-negotiated (-4)
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Failed to allocate required memory.
Additional debug info:
../git/sys/v4l2/gstv4l2src.c(660): gst_v4l2src_decide_allocation (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Buffer pool activation failed

If i dont use io-mode=dmabuf and output-io-mode=dmabuf-import works fine.

Second problem i face is in the same debug output.
0:00:00.110224177 1830 0xaaaaec82e2d0 WARN v4l2 gstv4l2object.c:2031:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from http://git.linuxtv.org/v4l-utils.git

Every time i use v4l2 drivers from gstreamer or opencv it gives this warning.

As always, any help is highly appreciated.

Hi @Ugur_Ozdemir

Thanks for writing to the Toradex Community!

If i dont use io-mode=dmabuf and output-io-mode=dmabuf-import works fine.

Why do you need to use this flags?

Second problem i face is in the same debug output.

I see this is a warning, do you see any functional issue?

Best regards,
Jaski

1 Like

Hello @jaski.tx ,

According to this document below, i need to use this flag for using hardware accelerated h264 encoding.
i.MX8GStreamerUserGuide(1).pdf (778.8 KB)

If i dont use it, it encodes in CPU and there is a huge CPU usage and latency on encoding.

Hi @Ugur_Ozdemir

No, this is not true, you can use the hardware acceleration without the dma flags. The DMA just means that DMA memory is used. Could you try the encoding without these flags and check the CPU/Memory stats?

Best regards,
Jaski

1 Like

Hi, @jaski.tx ,

This is v4l2h264 encoding CPU load ( DVR-Software ). There are several gui operations in addition to encoding but it uses less than %1.

Doesnt io-mode=dmabuf and output-io-mode=dmabuf-import affect any CPU usage?

Thank you again @jaski.tx

Maybe it will affect since DVR Software will use DMA? Did you see any difference with the flags enabled? You need to test with lower resolution and framerate till you can run with without dma-memory errors?