From 3ee04883eecb0deda80f39c7c0ade2311f5d3d19 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 18 Dec 2024 15:30:24 -0500 Subject: [PATCH] v4l2: object: Adjust DMABuf negotiation base on io-mode If the io-mode is forced by user to MMAP, USERPTR or RW, don't try and negotiated DMABuf caps feature. This would otherwise fail later. Part-of: --- .../gst-plugins-good/sys/v4l2/gstv4l2object.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c index 4730df42ba..c8d82e5222 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c @@ -5190,6 +5190,7 @@ gst_v4l2_object_probe_caps (GstV4l2Object * v4l2object, GstCaps * filter) GSList *walk; GSList *formats; guint32 fourcc = 0; + gboolean enable_dmabuf = FALSE; if (v4l2object->fmtdesc) fourcc = GST_V4L2_PIXELFORMAT (v4l2object); @@ -5197,6 +5198,17 @@ gst_v4l2_object_probe_caps (GstV4l2Object * v4l2object, GstCaps * filter) gst_v4l2_object_clear_format_list (v4l2object); formats = gst_v4l2_object_get_format_list (v4l2object); + switch (v4l2object->req_mode) { + case GST_V4L2_IO_AUTO: + case GST_V4L2_IO_DMABUF: + case GST_V4L2_IO_DMABUF_IMPORT: + enable_dmabuf = TRUE; + break; + default: + break; + } + + /* Recover the fmtdesc, it may no longer exist, in which case it will be set * to null */ if (fourcc) @@ -5250,7 +5262,7 @@ gst_v4l2_object_probe_caps (GstV4l2Object * v4l2object, GstCaps * filter) sysmem_tmpl = gst_v4l2_object_v4l2fourcc_to_bare_struct (format->pixelformat, - &dmabuf_tmpl); + enable_dmabuf ? &dmabuf_tmpl : NULL); if (!sysmem_tmpl && !dmabuf_tmpl) { GST_DEBUG_OBJECT (v4l2object->dbg_obj, -- 2.34.1