public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Rivka Bukchin <rivkab300@gmail.com>
To: linux-media@vger.kernel.org
Cc: Rivka Bukchin <rivkab300@gmail.com>
Subject: [PATCH v2] v4l2-compliance: add tests for VIDIOC_S_FBUF/OVERLAY and selection flags
Date: Thu, 12 Mar 2026 10:18:01 +0200	[thread overview]
Message-ID: <20260312081801.14353-1-rivkab300@gmail.com> (raw)

Add compliance tests for VIDIOC_S_FBUF and VIDIOC_OVERLAY to verify
basic framebuffer and overlay handling.

Add tests for VIDIOC_S_SELECTION flag handling to ensure that valid
flags (V4L2_SEL_FLAG_GE and V4L2_SEL_FLAG_LE) are accepted and that
invalid flag combinations are rejected.

These tests extend the coverage of the format and selection ioctl
compliance checks.

Signed-off-by: Rivka Bukchin <rivkab300@gmail.com>
---
v2: Rebased on upstream v4l-utils tree

 utils/v4l2-compliance/v4l2-compliance.cpp   |  2 +
 utils/v4l2-compliance/v4l2-compliance.h     |  2 +
 utils/v4l2-compliance/v4l2-test-formats.cpp | 78 +++++++++++++++++++++
 3 files changed, 82 insertions(+)

diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index 4e5c9d00deb5..20d5f329d335 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -1464,6 +1464,8 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
 		printf("\ttest Cropping: %s\n", ok(testCropping(&node)));
 		printf("\ttest Composing: %s\n", ok(testComposing(&node)));
 		printf("\ttest Scaling: %s\n", ok(testScaling(&node)));
+		printf("\ttest Overlay: %s\n", ok(testOverlay(&node)));
+        printf("\ttest Selection Flags: %s\n", ok(testSelectionFlags(&node)));
 		printf("\n");
 
 		/* Codec ioctls */
diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h
index 4a7af5f5bce5..265cd08397fa 100644
--- a/utils/v4l2-compliance/v4l2-compliance.h
+++ b/utils/v4l2-compliance/v4l2-compliance.h
@@ -375,6 +375,8 @@ int testSlicedVBICap(struct node *node);
 int testCropping(struct node *node);
 int testComposing(struct node *node);
 int testScaling(struct node *node);
+int testOverlay(struct node *node);
+int testSelectionFlags(struct node *node);
 
 // Codec ioctl tests
 int testEncoder(struct node *node);
diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp
index 56b6614162cf..6c5743a3da47 100644
--- a/utils/v4l2-compliance/v4l2-test-formats.cpp
+++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
@@ -2048,3 +2048,81 @@ int testScaling(struct node *node)
 	}
 	return node->can_scale ? 0 : ENOTTY;
 }
+
+int testOverlay(struct node *node)
+{
+    struct v4l2_framebuffer fbuf;
+    int ret;
+
+    memset(&fbuf, 0xff, sizeof(fbuf));
+    fbuf.fmt.priv = 0;
+
+    ret = doioctl(node, VIDIOC_G_FBUF, &fbuf);
+    if (ret == ENOTTY)
+        return ret;
+    if (ret == EINVAL)
+        return ENOTTY;
+    fail_on_test(ret);
+
+    if (!(node->g_caps() & (V4L2_CAP_VIDEO_OVERLAY |
+                V4L2_CAP_VIDEO_OUTPUT_OVERLAY)))
+        return ENOTTY;
+
+    struct v4l2_framebuffer set_fbuf = fbuf;
+
+    ret = doioctl(node, VIDIOC_S_FBUF, &set_fbuf);
+    fail_on_test(ret && ret != ENOTTY && ret != EINVAL);
+
+    int enable = 1;
+
+    ret = doioctl(node, VIDIOC_OVERLAY, &enable);
+    fail_on_test(ret && ret != ENOTTY && ret != EINVAL);
+
+    enable = 0;
+
+    ret = doioctl(node, VIDIOC_OVERLAY, &enable);
+    fail_on_test(ret && ret != ENOTTY && ret != EINVAL);
+
+    return 0;
+}
+
+int testSelectionFlags(struct node *node)
+{
+    struct v4l2_selection sel = {
+        node->can_capture ?
+            V4L2_BUF_TYPE_VIDEO_CAPTURE :
+            V4L2_BUF_TYPE_VIDEO_OUTPUT,
+        V4L2_SEL_TGT_CROP
+    };
+    int ret;
+
+    memset(sel.reserved, 0xff, sizeof(sel.reserved));
+
+    ret = doioctl(node, VIDIOC_G_SELECTION, &sel);
+    if (ret == ENOTTY || ret == EINVAL || ret == ENODATA)
+        return ENOTTY;
+
+    fail_on_test(ret);
+    fail_on_test(check_0(sel.reserved, sizeof(sel.reserved)));
+
+    struct v4l2_selection s = sel;
+
+    s.flags = V4L2_SEL_FLAG_GE;
+    doioctl(node, VIDIOC_S_SELECTION, &s);
+
+    s = sel;
+    s.flags = V4L2_SEL_FLAG_LE;
+    doioctl(node, VIDIOC_S_SELECTION, &s);
+
+    s = sel;
+    s.flags = V4L2_SEL_FLAG_GE | V4L2_SEL_FLAG_LE;
+    doioctl(node, VIDIOC_S_SELECTION, &s);
+
+    s = sel;
+    s.flags = ~0;
+
+    ret = doioctl(node, VIDIOC_S_SELECTION, &s);
+    fail_on_test(ret == 0);
+
+    return 0;
+}
-- 
2.34.1


             reply	other threads:[~2026-03-12  8:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12  8:18 Rivka Bukchin [this message]
2026-03-17 12:24 ` [PATCH v2] v4l2-compliance: add tests for VIDIOC_S_FBUF/OVERLAY and selection flags Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260312081801.14353-1-rivkab300@gmail.com \
    --to=rivkab300@gmail.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox