[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20231109202745.342387-1-paul.kocialkowski@bootlin.com>
Date: Thu, 9 Nov 2023 21:27:45 +0100
From: Paul Kocialkowski <paul.kocialkowski@...tlin.com>
To: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-staging@...ts.linux.dev
Cc: Mauro Carvalho Chehab <mchehab@...nel.org>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
Nicolas Dufresne <nicolas.dufresne@...labora.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Paul Kocialkowski <paul.kocialkowski@...tlin.com>
Subject: [PATCH v2] v4l2-compliance: codecs: Add stateless (TRY_)DECODER_CMD tests
Stateless codecs that support holding the capture buffer should implement the
(TRY_)DECODER_CMD ioctls for the flush command (and only this command).
Add a conditional to separate the stateless case from stateful one and move
the existing tests there.
Add new tests for the stateless case which ensure that the flush command is
supported and that the other stateful commands are not.
An existing check will already return early (without error) when the ioctls
are not implemented at all. Note that there is no easy way to check for the
capture buffer holding buffer flag since it requires setting up a coded format
in particular to be visible, which is far from trivial to implement here.
As a result we just carry out the tests when the ioctls are available.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@...tlin.com>
---
Changes since v1:
- Fixed typos.
utils/v4l2-compliance/v4l2-test-codecs.cpp | 111 ++++++++++++++-------
1 file changed, 75 insertions(+), 36 deletions(-)
diff --git a/utils/v4l2-compliance/v4l2-test-codecs.cpp b/utils/v4l2-compliance/v4l2-test-codecs.cpp
index df25a1ddc358..8c3527359813 100644
--- a/utils/v4l2-compliance/v4l2-test-codecs.cpp
+++ b/utils/v4l2-compliance/v4l2-test-codecs.cpp
@@ -99,6 +99,7 @@ int testDecoder(struct node *node)
{
struct v4l2_decoder_cmd cmd;
bool is_decoder = node->codec_mask & (STATEFUL_DECODER | JPEG_DECODER);
+ bool is_stateless = node->codec_mask & STATELESS_DECODER;
int ret;
fail_on_test((node->codec_mask & STATELESS_DECODER) && !node->has_media);
@@ -118,42 +119,80 @@ int testDecoder(struct node *node)
fail_on_test(ret == ENOTTY);
fail_on_test(ret != EINVAL);
- cmd.cmd = V4L2_DEC_CMD_STOP;
- cmd.flags = ~0;
- ret = doioctl(node, VIDIOC_TRY_DECODER_CMD, &cmd);
- fail_on_test(ret != 0);
- fail_on_test(cmd.flags & ~(V4L2_DEC_CMD_STOP_TO_BLACK | V4L2_DEC_CMD_STOP_IMMEDIATELY));
- fail_on_test(is_decoder && cmd.flags);
- ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);
- fail_on_test(ret != 0);
-
- cmd.cmd = V4L2_DEC_CMD_START;
- cmd.flags = ~0;
- ret = doioctl(node, VIDIOC_TRY_DECODER_CMD, &cmd);
- fail_on_test(ret);
- fail_on_test(cmd.flags & ~V4L2_DEC_CMD_START_MUTE_AUDIO);
- fail_on_test(is_decoder && cmd.flags);
-
- cmd.cmd = V4L2_DEC_CMD_START;
- cmd.flags = 0;
- cmd.start.speed = ~0;
- cmd.start.format = ~0U;
- ret = doioctl(node, VIDIOC_TRY_DECODER_CMD, &cmd);
- fail_on_test(ret);
- fail_on_test(cmd.start.format == ~0U);
- fail_on_test(cmd.start.speed == ~0);
- fail_on_test(is_decoder && cmd.start.format);
- fail_on_test(is_decoder && cmd.start.speed);
-
- cmd.cmd = V4L2_DEC_CMD_PAUSE;
- cmd.flags = 0;
- ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);
- fail_on_test(ret != EPERM && ret != EINVAL);
- fail_on_test(is_decoder && ret != EINVAL);
+ if (is_stateless) {
+ cmd.cmd = V4L2_DEC_CMD_FLUSH;
+ cmd.flags = 0;
+ ret = doioctl(node, VIDIOC_TRY_DECODER_CMD, &cmd);
+ fail_on_test(ret);
+ ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);
+ fail_on_test(ret);
+
+ cmd.cmd = V4L2_DEC_CMD_STOP;
+ cmd.flags = 0;
+ ret = doioctl(node, VIDIOC_TRY_DECODER_CMD, &cmd);
+ fail_on_test(!ret);
+ ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);
+ fail_on_test(!ret);
+
+ cmd.cmd = V4L2_DEC_CMD_START;
+ cmd.flags = 0;
+ ret = doioctl(node, VIDIOC_TRY_DECODER_CMD, &cmd);
+ fail_on_test(!ret);
+ ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);
+ fail_on_test(!ret);
+
+ cmd.cmd = V4L2_DEC_CMD_PAUSE;
+ cmd.flags = 0;
+ ret = doioctl(node, VIDIOC_TRY_DECODER_CMD, &cmd);
+ fail_on_test(!ret);
+ ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);
+ fail_on_test(!ret);
+
+ cmd.cmd = V4L2_DEC_CMD_RESUME;
+ cmd.flags = 0;
+ ret = doioctl(node, VIDIOC_TRY_DECODER_CMD, &cmd);
+ fail_on_test(!ret);
+ ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);
+ fail_on_test(!ret);
+ } else {
+ cmd.cmd = V4L2_DEC_CMD_STOP;
+ cmd.flags = ~0;
+ ret = doioctl(node, VIDIOC_TRY_DECODER_CMD, &cmd);
+ fail_on_test(ret);
+ fail_on_test(cmd.flags & ~(V4L2_DEC_CMD_STOP_TO_BLACK | V4L2_DEC_CMD_STOP_IMMEDIATELY));
+ fail_on_test(is_decoder && cmd.flags);
+ ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);
+ fail_on_test(ret);
+
+ cmd.cmd = V4L2_DEC_CMD_START;
+ cmd.flags = ~0;
+ ret = doioctl(node, VIDIOC_TRY_DECODER_CMD, &cmd);
+ fail_on_test(ret);
+ fail_on_test(cmd.flags & ~V4L2_DEC_CMD_START_MUTE_AUDIO);
+ fail_on_test(is_decoder && cmd.flags);
+
+ cmd.cmd = V4L2_DEC_CMD_START;
+ cmd.flags = 0;
+ cmd.start.speed = ~0;
+ cmd.start.format = ~0U;
+ ret = doioctl(node, VIDIOC_TRY_DECODER_CMD, &cmd);
+ fail_on_test(ret);
+ fail_on_test(cmd.start.format == ~0U);
+ fail_on_test(cmd.start.speed == ~0);
+ fail_on_test(is_decoder && cmd.start.format);
+ fail_on_test(is_decoder && cmd.start.speed);
+
+ cmd.cmd = V4L2_DEC_CMD_PAUSE;
+ cmd.flags = 0;
+ ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);
+ fail_on_test(ret != EPERM && ret != EINVAL);
+ fail_on_test(is_decoder && ret != EINVAL);
+
+ cmd.cmd = V4L2_DEC_CMD_RESUME;
+ ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);
+ fail_on_test(ret != EPERM && ret != EINVAL);
+ fail_on_test(is_decoder && ret != EINVAL);
+ }
- cmd.cmd = V4L2_DEC_CMD_RESUME;
- ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);
- fail_on_test(ret != EPERM && ret != EINVAL);
- fail_on_test(is_decoder && ret != EINVAL);
return 0;
}
--
2.42.1
Powered by blists - more mailing lists