aboutsummaryrefslogtreecommitdiffstats
path: root/utils/v4l2-compliance/v4l2-test-codecs.cpp
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-08-21 16:17:34 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2012-08-21 16:38:15 +0200
commit574f9328842eaa1b1e767ce9a1abd8cd869e783c (patch)
tree29a8c61345f40e7baac0ba7889c0a6fa3d1ba0d0 /utils/v4l2-compliance/v4l2-test-codecs.cpp
parenta449cdde3902997d8fb043ff9d53a36a571a0936 (diff)
v4l2-compliance: add tests for VIDIOC_(TRY_)ENCODER_CMD.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Diffstat (limited to 'utils/v4l2-compliance/v4l2-test-codecs.cpp')
-rw-r--r--utils/v4l2-compliance/v4l2-test-codecs.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/utils/v4l2-compliance/v4l2-test-codecs.cpp b/utils/v4l2-compliance/v4l2-test-codecs.cpp
new file mode 100644
index 00000000..60f861a2
--- /dev/null
+++ b/utils/v4l2-compliance/v4l2-test-codecs.cpp
@@ -0,0 +1,62 @@
+/*
+ V4L2 API codec ioctl tests.
+
+ Copyright (C) 2012 Hans Verkuil <hans.verkuil@cisco.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <assert.h>
+#include "v4l2-compliance.h"
+
+int testEncoder(struct node *node)
+{
+ struct v4l2_encoder_cmd cmd;
+ int ret;
+
+ memset(&cmd, 0xff, sizeof(cmd));
+ memset(&cmd.raw, 0, sizeof(cmd.raw));
+ ret = doioctl(node, VIDIOC_ENCODER_CMD, &cmd);
+ if (ret == ENOTTY)
+ return ret;
+ fail_on_test(ret != EINVAL);
+ ret = doioctl(node, VIDIOC_TRY_ENCODER_CMD, &cmd);
+ fail_on_test(ret == ENOTTY);
+ fail_on_test(ret != EINVAL);
+ cmd.cmd = V4L2_ENC_CMD_STOP;
+ cmd.flags = 0;
+ ret = doioctl(node, VIDIOC_TRY_ENCODER_CMD, &cmd);
+ fail_on_test(ret != 0);
+ ret = doioctl(node, VIDIOC_ENCODER_CMD, &cmd);
+ fail_on_test(ret != 0);
+ cmd.cmd = V4L2_ENC_CMD_PAUSE;
+ ret = doioctl(node, VIDIOC_ENCODER_CMD, &cmd);
+ fail_on_test(ret != EPERM && ret != EINVAL);
+ cmd.cmd = V4L2_ENC_CMD_RESUME;
+ ret = doioctl(node, VIDIOC_ENCODER_CMD, &cmd);
+ fail_on_test(ret != EPERM && ret != EINVAL);
+ return 0;
+}

Privacy Policy