Hi,
this is the v4l-test 0.9 for LTP patch.
Changes: Test cases added for VIDIOC_S_CROP. Test steps added for VIDIOC_S_CTRL.
Best regards,
Márton Németh
---
v4l-test home page: http://v4l-test.sourceforge.net/
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/doc/index.html ltp/testcases/kernel/device-drivers/v4l/user_space/doc/index.html
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/doc/index.html 2009-02-23 12:22:27.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/doc/index.html 2009-03-14 10:49:47.000000000 +0100
@@ -214,7 +214,7 @@ implemented test cases.</p>
</tr>
<tr>
<td>ioctl <a href="spec/r9994.htm">VIDIOC_S_CROP</a></td>
- <td>no</td>
+ <td>yes, only when STREAM_OFF</td>
<td>Opt.</td>
</tr>
<tr>
@@ -503,13 +503,18 @@ The following documents and articles are
<a href="http://lwn.net/Articles/203924/">The Video4Linux2 API series</a> at
<a href="http://lwn.net/">lwn.net</a>
</li>
+ <li><a href="http://people.atrpms.net/~hdegoede/libv4l.spec">libv4l</a>
+ <a href="http://people.atrpms.net/~hdegoede/libv4l-0.5.8.tar.gz">0.5.8</a>
+ </li>
+ <li>Simple V4L2 video viewer: <a href="http://moinejf.free.fr/svv.c">svv.c</a>
+ </li>
</ul>
<h2><a name="feedback">Feedbacks</a></h2>
<p>Any feedbacks, comments, ideas, etc. are welcome at the author's email address.</p>
<hr style="width: 100%; height: 2px;">
<p>Last changed:
-Sun Feb 22 16:53:17 CET 2009
+Sat Mar 14 10:49:43 2009
</p>
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/README ltp/testcases/kernel/device-drivers/v4l/user_space/README
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/README 2009-02-23 12:22:27.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/README 2009-03-14 09:36:45.000000000 +0100
@@ -4,6 +4,8 @@
Release History
---------------
+14 Mar 2009 0.9 Test cases added for VIDIOC_S_CROP;
+ Test steps added for VIDIOC_S_CTRL
22 Feb 2009 0.8 Test cases added for VIDIOC_G_CROP, VIDIOC_G_CTRL and VIDIOC_S_CTRL
9 Feb 2009 0.7 Test cases added for VIDIOC_G_AUDIO, VIDIOC_G_AUDOUT,
VIDIOC_S_AUDIO and VIDIOC_G_CROP;
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROP.c ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROP.c
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROP.c 2009-02-23 12:22:27.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROP.c 2009-03-08 11:33:36.000000000 +0100
@@ -1,6 +1,7 @@
/*
* v4l-test: Test environment for Video For Linux Two API
*
+ * 7 Mar 2009 0.3 Test cases added for VIDIOC_S_CROP
* 13 Feb 2009 0.2 Test cases added for VIDIOC_G_CROP
* 7 Feb 2009 0.1 First release
*
@@ -136,3 +137,715 @@ void test_VIDIOC_G_CROP_NULL() {
}
}
+
+void do_set_crop(enum v4l2_buf_type type) {
+ int ret_orig, errno_orig;
+ int ret_set, errno_set;
+ int ret_new, errno_new;
+ int ret_cap, errno_cap;
+ struct v4l2_crop crop_orig;
+ struct v4l2_crop crop;
+ struct v4l2_crop crop_new;
+ struct v4l2_cropcap cropcap;
+ __s32 i;
+
+ memset(&crop_orig, 0, sizeof(crop_orig));
+ crop_orig.type = type;
+ ret_orig = ioctl(get_video_fd(), VIDIOC_G_CROP, &crop_orig);
+ errno_orig = errno;
+ dprintf("\t%s:%u: VIDIOC_G_CROP, ret_orig=%i, errno_orig=%i, "
+ "crop_orig = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_orig, errno_orig,
+ crop_orig.type,
+ crop_orig.c.left,
+ crop_orig.c.top,
+ crop_orig.c.width,
+ crop_orig.c.height
+ );
+
+ memset(&cropcap, 0, sizeof(cropcap));
+ cropcap.type = type;
+ ret_cap = ioctl(get_video_fd(), VIDIOC_CROPCAP, &cropcap);
+ errno_cap = errno;
+
+ dprintf("\t%s:%u: VIDIOC_CROPCAP, ret_cap=%i, errno_cap=%i, cropcap = { .type = %i, "
+ ".bounds = { .left = %i, .top = %i, .width = %i, .height = %i }, "
+ ".defrect = { .left = %i, .top = %i, .width = %i, .height = %i }, "
+ ".pixelaspect = { .numerator = %u, .denominator = %u } "
+ "}\n",
+ __FILE__, __LINE__,
+ ret_cap, errno_cap,
+ cropcap.type,
+
+ cropcap.bounds.left,
+ cropcap.bounds.top,
+ cropcap.bounds.width,
+ cropcap.bounds.height,
+
+ cropcap.defrect.left,
+ cropcap.defrect.top,
+ cropcap.defrect.width,
+ cropcap.defrect.height,
+
+ cropcap.pixelaspect.numerator,
+ cropcap.pixelaspect.denominator
+ );
+
+ memset(&crop, 0xff, sizeof(crop));
+ crop.type = type;
+ crop.c = cropcap.bounds;
+ ret_set = ioctl(get_video_fd(), VIDIOC_S_CROP, &crop);
+ errno_set = errno;
+ dprintf("\t%s:%u: VIDIOC_S_CROP, ret_set=%i, errno_set=%i, "
+ "crop = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_set, errno_set,
+ crop.type,
+ crop.c.left,
+ crop.c.top,
+ crop.c.width,
+ crop.c.height
+ );
+
+ memset(&crop_new, 0, sizeof(crop_new));
+ crop_new.type = type;
+ ret_new = ioctl(get_video_fd(), VIDIOC_G_CROP, &crop_new);
+ errno_new = errno;
+ dprintf("\t%s:%u: VIDIOC_G_CROP, ret_new=%i, errno_new=%i, "
+ "crop_new = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_new, errno_new,
+ crop_new.type,
+ crop_new.c.left,
+ crop_new.c.top,
+ crop_new.c.width,
+ crop_new.c.height
+ );
+
+ if (ret_cap == 0) {
+ CU_ASSERT_EQUAL(ret_cap, 0);
+ CU_ASSERT_EQUAL(ret_set, 0);
+ CU_ASSERT_EQUAL(ret_new, 0);
+
+
+ if (ret_cap == 0 && ret_new == 0) {
+
+ /* | left x */
+ /* ----+----+--------------------------------------> */
+ /* | : */
+ /* top + +------ cropcap.bounds -------+ ^ */
+ /* | | | | */
+ /* | | +------- crop_new --------+ | | */
+ /* | | | | | | */
+ /* | | | | | | */
+ /* | | | | | | height */
+ /* | | +-------------------------+ | | */
+ /* | | | | */
+ /* | | | | */
+ /* | +-----------------------------+ v */
+ /* | : : */
+ /* | <---------- width ------------> */
+ /* | */
+ /* v y */
+
+ CU_ASSERT(cropcap.bounds.left <= crop_new.c.left);
+ CU_ASSERT(cropcap.bounds.top <= crop_new.c.top);
+
+ CU_ASSERT(crop_new.c.left+crop_new.c.width <= cropcap.bounds.left+cropcap.bounds.width);
+ CU_ASSERT(crop_new.c.top+crop_new.c.height <= cropcap.bounds.top+cropcap.bounds.height);
+ }
+
+ } else {
+ CU_ASSERT_EQUAL(ret_cap, -1);
+ CU_ASSERT_EQUAL(errno_cap, EINVAL);
+ CU_ASSERT_EQUAL(ret_set, -1);
+ CU_ASSERT_EQUAL(errno_set, EINVAL);
+ CU_ASSERT_EQUAL(ret_new, -1);
+ CU_ASSERT_EQUAL(errno_new, EINVAL);
+
+ }
+
+ memset(&crop, 0xff, sizeof(crop));
+ crop.type = type;
+ crop.c = cropcap.defrect;
+ ret_set = ioctl(get_video_fd(), VIDIOC_S_CROP, &crop);
+ errno_set = errno;
+ dprintf("\t%s:%u: VIDIOC_S_CROP, ret_set=%i, errno_set=%i, "
+ "crop = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_set, errno_set,
+ crop.type,
+ crop.c.left,
+ crop.c.top,
+ crop.c.width,
+ crop.c.height
+ );
+
+ memset(&crop_new, 0, sizeof(crop_new));
+ crop_new.type = type;
+ ret_new = ioctl(get_video_fd(), VIDIOC_G_CROP, &crop_new);
+ errno_new = errno;
+ dprintf("\t%s:%u: VIDIOC_G_CROP, ret_new=%i, errno_new=%i, "
+ "crop_new = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_new, errno_new,
+ crop_new.type,
+ crop_new.c.left,
+ crop_new.c.top,
+ crop_new.c.width,
+ crop_new.c.height
+ );
+
+ if (ret_cap == 0) {
+ CU_ASSERT_EQUAL(ret_cap, 0);
+ CU_ASSERT_EQUAL(ret_set, 0);
+ CU_ASSERT_EQUAL(ret_new, 0);
+
+ if (ret_cap == 0 && ret_new == 0) {
+
+ /* | left x */
+ /* ----+----+--------------------------------------> */
+ /* | : */
+ /* top + +------ cropcap.defrect ------+ ^ */
+ /* | | | | */
+ /* | | +------- crop_new --------+ | | */
+ /* | | | | | | */
+ /* | | | | | | */
+ /* | | | | | | height */
+ /* | | +-------------------------+ | | */
+ /* | | | | */
+ /* | | | | */
+ /* | +-----------------------------+ v */
+ /* | : : */
+ /* | <---------- width ------------> */
+ /* | */
+ /* v y */
+
+ CU_ASSERT(cropcap.defrect.left <= crop_new.c.left);
+ CU_ASSERT(cropcap.defrect.top <= crop_new.c.top);
+
+ CU_ASSERT(crop_new.c.left+crop_new.c.width <= cropcap.defrect.left+cropcap.defrect.width);
+ CU_ASSERT(crop_new.c.top+crop_new.c.height <= cropcap.defrect.top+cropcap.defrect.height);
+ }
+
+ } else {
+ CU_ASSERT_EQUAL(ret_cap, -1);
+ CU_ASSERT_EQUAL(errno_cap, EINVAL);
+ CU_ASSERT_EQUAL(ret_set, -1);
+ CU_ASSERT_EQUAL(errno_set, EINVAL);
+ CU_ASSERT_EQUAL(ret_new, -1);
+ CU_ASSERT_EQUAL(errno_new, EINVAL);
+
+ }
+
+ /* | left x */
+ /* ----+----+--------------------------------------> */
+ /* | : */
+ /* top + +-------- crop.c -------------+ ^ */
+ /* | | : | | */
+ /* | | : | | */
+ /* | | : | | */
+ /* | | :<----| | */
+ /* | | : | | height */
+ /* | | : | | */
+ /* | | : | | */
+ /* | | : | | */
+ /* | +-----------------------------+ v */
+ /* | : : */
+ /* | <---------- width ------------> */
+ /* | */
+ /* v y */
+ for (i=0; i<cropcap.bounds.width; i++) {
+ memset(&crop, 0xff, sizeof(crop));
+ crop.type = type;
+ crop.c.left = cropcap.bounds.left;
+ crop.c.top = cropcap.bounds.top;
+ crop.c.width = cropcap.bounds.width-i;
+ crop.c.height = cropcap.bounds.height;
+ ret_set = ioctl(get_video_fd(), VIDIOC_S_CROP, &crop);
+ errno_set = errno;
+ dprintf("\t%s:%u: VIDIOC_S_CROP, ret_set=%i, errno_set=%i, "
+ "crop = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_set, errno_set,
+ crop.type,
+ crop.c.left,
+ crop.c.top,
+ crop.c.width,
+ crop.c.height
+ );
+
+ memset(&crop_new, 0, sizeof(crop_new));
+ crop_new.type = type;
+ ret_new = ioctl(get_video_fd(), VIDIOC_G_CROP, &crop_new);
+ errno_new = errno;
+ dprintf("\t%s:%u: VIDIOC_G_CROP, ret_new=%i, errno_new=%i, "
+ "crop_new = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_new, errno_new,
+ crop_new.type,
+ crop_new.c.left,
+ crop_new.c.top,
+ crop_new.c.width,
+ crop_new.c.height
+ );
+
+ if (ret_cap == 0) {
+ CU_ASSERT_EQUAL(ret_cap, 0);
+ CU_ASSERT_EQUAL(ret_set, 0);
+ CU_ASSERT_EQUAL(ret_new, 0);
+
+ if (ret_cap == 0 && ret_new == 0) {
+
+ CU_ASSERT(cropcap.defrect.left <= crop_new.c.left);
+ CU_ASSERT(cropcap.defrect.top <= crop_new.c.top);
+
+ CU_ASSERT(crop_new.c.left+crop_new.c.width <= cropcap.defrect.left+cropcap.defrect.width);
+ CU_ASSERT(crop_new.c.top+crop_new.c.height <= cropcap.defrect.top+cropcap.defrect.height);
+ }
+
+ } else {
+ CU_ASSERT_EQUAL(ret_cap, -1);
+ CU_ASSERT_EQUAL(errno_cap, EINVAL);
+ CU_ASSERT_EQUAL(ret_set, -1);
+ CU_ASSERT_EQUAL(errno_set, EINVAL);
+ CU_ASSERT_EQUAL(ret_new, -1);
+ CU_ASSERT_EQUAL(errno_new, EINVAL);
+ }
+ }
+
+ /* | left x */
+ /* ----+----+--------------------------------------> */
+ /* | : */
+ /* top + +---------- crop.c -----------+ ^ */
+ /* | | | | */
+ /* | | | | */
+ /* | | | | */
+ /* | | | | */
+ /* | |.............................| | height */
+ /* | | ^ | | */
+ /* | | | | | */
+ /* | | | | | */
+ /* | +-----------------------------+ v */
+ /* | : : */
+ /* | <---------- width ------------> */
+ /* | */
+ /* v y */
+ for (i=0; i<cropcap.bounds.height; i++) {
+ memset(&crop, 0xff, sizeof(crop));
+ crop.type = type;
+ crop.c.left = cropcap.bounds.left;
+ crop.c.top = cropcap.bounds.top;
+ crop.c.width = cropcap.bounds.width;
+ crop.c.height = cropcap.bounds.height-i;
+ ret_set = ioctl(get_video_fd(), VIDIOC_S_CROP, &crop);
+ errno_set = errno;
+ dprintf("\t%s:%u: VIDIOC_S_CROP, ret_set=%i, errno_set=%i, "
+ "crop = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_set, errno_set,
+ crop.type,
+ crop.c.left,
+ crop.c.top,
+ crop.c.width,
+ crop.c.height
+ );
+
+ memset(&crop_new, 0, sizeof(crop_new));
+ crop_new.type = type;
+ ret_new = ioctl(get_video_fd(), VIDIOC_G_CROP, &crop_new);
+ errno_new = errno;
+ dprintf("\t%s:%u: VIDIOC_G_CROP, ret_new=%i, errno_new=%i, "
+ "crop_new = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_new, errno_new,
+ crop_new.type,
+ crop_new.c.left,
+ crop_new.c.top,
+ crop_new.c.width,
+ crop_new.c.height
+ );
+
+ if (ret_cap == 0) {
+ CU_ASSERT_EQUAL(ret_cap, 0);
+ CU_ASSERT_EQUAL(ret_set, 0);
+ CU_ASSERT_EQUAL(ret_new, 0);
+
+ if (ret_cap == 0 && ret_new == 0) {
+
+ CU_ASSERT(cropcap.defrect.left <= crop_new.c.left);
+ CU_ASSERT(cropcap.defrect.top <= crop_new.c.top);
+
+ CU_ASSERT(crop_new.c.left+crop_new.c.width <= cropcap.defrect.left+cropcap.defrect.width);
+ CU_ASSERT(crop_new.c.top+crop_new.c.height <= cropcap.defrect.top+cropcap.defrect.height);
+ }
+
+ } else {
+ CU_ASSERT_EQUAL(ret_cap, -1);
+ CU_ASSERT_EQUAL(errno_cap, EINVAL);
+ CU_ASSERT_EQUAL(ret_set, -1);
+ CU_ASSERT_EQUAL(errno_set, EINVAL);
+ CU_ASSERT_EQUAL(ret_new, -1);
+ CU_ASSERT_EQUAL(errno_new, EINVAL);
+ }
+ }
+
+ /* | left x */
+ /* ----+----+--------------------------------------> */
+ /* | : */
+ /* top + +---------- crop.c -----------+ ^ */
+ /* | | : | | */
+ /* | | : | | */
+ /* | | : | | */
+ /* | |--->: | | */
+ /* | | : | | height */
+ /* | | : | | */
+ /* | | : | | */
+ /* | | : | | */
+ /* | +-----------------------------+ v */
+ /* | : : */
+ /* | <---------- width ------------> */
+ /* | */
+ /* v y */
+ for (i=0; i<cropcap.bounds.width; i++) {
+ memset(&crop, 0xff, sizeof(crop));
+ crop.type = type;
+ crop.c.left = cropcap.bounds.left+i;
+ crop.c.top = cropcap.bounds.top;
+ crop.c.width = cropcap.bounds.width-i;
+ crop.c.height = cropcap.bounds.height;
+ ret_set = ioctl(get_video_fd(), VIDIOC_S_CROP, &crop);
+ errno_set = errno;
+ dprintf("\t%s:%u: VIDIOC_S_CROP, ret_set=%i, errno_set=%i, "
+ "crop = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_set, errno_set,
+ crop.type,
+ crop.c.left,
+ crop.c.top,
+ crop.c.width,
+ crop.c.height
+ );
+
+ memset(&crop_new, 0, sizeof(crop_new));
+ crop_new.type = type;
+ ret_new = ioctl(get_video_fd(), VIDIOC_G_CROP, &crop_new);
+ errno_new = errno;
+ dprintf("\t%s:%u: VIDIOC_G_CROP, ret_new=%i, errno_new=%i, "
+ "crop_new = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_new, errno_new,
+ crop_new.type,
+ crop_new.c.left,
+ crop_new.c.top,
+ crop_new.c.width,
+ crop_new.c.height
+ );
+
+ if (ret_cap == 0) {
+ CU_ASSERT_EQUAL(ret_cap, 0);
+ CU_ASSERT_EQUAL(ret_set, 0);
+ CU_ASSERT_EQUAL(ret_new, 0);
+
+ if (ret_cap == 0 && ret_new == 0) {
+
+ CU_ASSERT(cropcap.defrect.left <= crop_new.c.left);
+ CU_ASSERT(cropcap.defrect.top <= crop_new.c.top);
+
+ CU_ASSERT(crop_new.c.left+crop_new.c.width <= cropcap.defrect.left+cropcap.defrect.width);
+ CU_ASSERT(crop_new.c.top+crop_new.c.height <= cropcap.defrect.top+cropcap.defrect.height);
+ }
+
+ } else {
+ CU_ASSERT_EQUAL(ret_cap, -1);
+ CU_ASSERT_EQUAL(errno_cap, EINVAL);
+ CU_ASSERT_EQUAL(ret_set, -1);
+ CU_ASSERT_EQUAL(errno_set, EINVAL);
+ CU_ASSERT_EQUAL(ret_new, -1);
+ CU_ASSERT_EQUAL(errno_new, EINVAL);
+ }
+ }
+
+
+ /* | left x */
+ /* ----+----+--------------------------------------> */
+ /* | : */
+ /* top + +---------- crop.c -----------+ ^ */
+ /* | | | | | */
+ /* | | | | | */
+ /* | | v | | */
+ /* | |.............................| | */
+ /* | | | | height */
+ /* | | | | */
+ /* | | | | */
+ /* | | | | */
+ /* | +-----------------------------+ v */
+ /* | : : */
+ /* | <---------- width ------------> */
+ /* | */
+ /* v y */
+ for (i=0; i<cropcap.bounds.height; i++) {
+ memset(&crop, 0xff, sizeof(crop));
+ crop.type = type;
+ crop.c.left = cropcap.bounds.left;
+ crop.c.top = cropcap.bounds.top+i;
+ crop.c.width = cropcap.bounds.width;
+ crop.c.height = cropcap.bounds.height-i;
+ ret_set = ioctl(get_video_fd(), VIDIOC_S_CROP, &crop);
+ errno_set = errno;
+ dprintf("\t%s:%u: VIDIOC_S_CROP, ret_set=%i, errno_set=%i, "
+ "crop = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_set, errno_set,
+ crop.type,
+ crop.c.left,
+ crop.c.top,
+ crop.c.width,
+ crop.c.height
+ );
+
+ memset(&crop_new, 0, sizeof(crop_new));
+ crop_new.type = type;
+ ret_new = ioctl(get_video_fd(), VIDIOC_G_CROP, &crop_new);
+ errno_new = errno;
+ dprintf("\t%s:%u: VIDIOC_G_CROP, ret_new=%i, errno_new=%i, "
+ "crop_new = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_new, errno_new,
+ crop_new.type,
+ crop_new.c.left,
+ crop_new.c.top,
+ crop_new.c.width,
+ crop_new.c.height
+ );
+
+ if (ret_cap == 0) {
+ CU_ASSERT_EQUAL(ret_cap, 0);
+ CU_ASSERT_EQUAL(ret_set, 0);
+ CU_ASSERT_EQUAL(ret_new, 0);
+
+ if (ret_cap == 0 && ret_new == 0) {
+
+ CU_ASSERT(cropcap.defrect.left <= crop_new.c.left);
+ CU_ASSERT(cropcap.defrect.top <= crop_new.c.top);
+
+ CU_ASSERT(crop_new.c.left+crop_new.c.width <= cropcap.defrect.left+cropcap.defrect.width);
+ CU_ASSERT(crop_new.c.top+crop_new.c.height <= cropcap.defrect.top+cropcap.defrect.height);
+ }
+
+ } else {
+ CU_ASSERT_EQUAL(ret_cap, -1);
+ CU_ASSERT_EQUAL(errno_cap, EINVAL);
+ CU_ASSERT_EQUAL(ret_set, -1);
+ CU_ASSERT_EQUAL(errno_set, EINVAL);
+ CU_ASSERT_EQUAL(ret_new, -1);
+ CU_ASSERT_EQUAL(errno_new, EINVAL);
+ }
+ }
+
+ if (ret_orig == 0) {
+ /* it shall be possible to restore the original settings */
+ ret_set = ioctl(get_video_fd(), VIDIOC_S_CROP, &crop_orig);
+ errno_set = errno;
+ dprintf("\t%s:%u: VIDIOC_S_CROP, ret_set=%i, errno_set=%i\n",
+ __FILE__, __LINE__, ret_set, errno_set);
+ CU_ASSERT_EQUAL(ret_set, 0);
+ }
+}
+
+void test_VIDIOC_S_CROP() {
+
+ do_set_crop(V4L2_BUF_TYPE_VIDEO_CAPTURE);
+ do_set_crop(V4L2_BUF_TYPE_VIDEO_OUTPUT);
+ do_set_crop(V4L2_BUF_TYPE_VIDEO_OVERLAY);
+ do_set_crop(V4L2_BUF_TYPE_PRIVATE);
+
+}
+
+void do_set_crop_invalid(enum v4l2_buf_type type) {
+ int ret_set, errno_set;
+ int ret_new, errno_new;
+ int ret_cap, errno_cap;
+ struct v4l2_crop crop;
+ struct v4l2_crop crop_new;
+ struct v4l2_cropcap cropcap;
+
+ memset(&cropcap, 0, sizeof(cropcap));
+ cropcap.type = type;
+ ret_cap = ioctl(get_video_fd(), VIDIOC_CROPCAP, &cropcap);
+ errno_cap = errno;
+
+ dprintf("\t%s:%u: VIDIOC_CROPCAP, ret_cap=%i, errno_cap=%i, cropcap = { .type = %i, "
+ ".bounds = { .left = %i, .top = %i, .width = %i, .height = %i }, "
+ ".defrect = { .left = %i, .top = %i, .width = %i, .height = %i }, "
+ ".pixelaspect = { .numerator = %u, .denominator = %u } "
+ "}\n",
+ __FILE__, __LINE__,
+ ret_cap, errno_cap,
+ cropcap.type,
+
+ cropcap.bounds.left,
+ cropcap.bounds.top,
+ cropcap.bounds.width,
+ cropcap.bounds.height,
+
+ cropcap.defrect.left,
+ cropcap.defrect.top,
+ cropcap.defrect.width,
+ cropcap.defrect.height,
+
+ cropcap.pixelaspect.numerator,
+ cropcap.pixelaspect.denominator
+ );
+
+ memset(&crop, 0xff, sizeof(crop));
+ crop.type = type;
+ crop.c = cropcap.bounds;
+ ret_set = ioctl(get_video_fd(), VIDIOC_S_CROP, &crop);
+ errno_set = errno;
+ dprintf("\t%s:%u: VIDIOC_S_CROP, ret_set=%i, errno_set=%i, "
+ "crop = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_set, errno_set,
+ crop.type,
+ crop.c.left,
+ crop.c.top,
+ crop.c.width,
+ crop.c.height
+ );
+
+ memset(&crop_new, 0, sizeof(crop_new));
+ crop_new.type = type;
+ ret_new = ioctl(get_video_fd(), VIDIOC_G_CROP, &crop_new);
+ errno_new = errno;
+ dprintf("\t%s:%u: VIDIOC_G_CROP, ret_new=%i, errno_new=%i, "
+ "crop_new = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_new, errno_new,
+ crop_new.type,
+ crop_new.c.left,
+ crop_new.c.top,
+ crop_new.c.width,
+ crop_new.c.height
+ );
+
+ CU_ASSERT_EQUAL(ret_cap, -1);
+ CU_ASSERT_EQUAL(errno_cap, EINVAL);
+ CU_ASSERT_EQUAL(ret_set, -1);
+ CU_ASSERT_EQUAL(errno_set, EINVAL);
+ CU_ASSERT_EQUAL(ret_new, -1);
+ CU_ASSERT_EQUAL(errno_new, EINVAL);
+
+}
+
+void test_VIDIOC_S_CROP_invalid() {
+ do_set_crop_invalid(0);
+ do_set_crop_invalid(V4L2_BUF_TYPE_VBI_CAPTURE);
+ do_set_crop_invalid(V4L2_BUF_TYPE_VBI_OUTPUT);
+ do_set_crop_invalid(V4L2_BUF_TYPE_SLICED_VBI_CAPTURE);
+ do_set_crop_invalid(V4L2_BUF_TYPE_SLICED_VBI_OUTPUT);
+ do_set_crop_invalid(V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY);
+ do_set_crop_invalid(V4L2_BUF_TYPE_PRIVATE);
+ do_set_crop_invalid(S32_MAX);
+ do_set_crop_invalid( ((__u32)S32_MAX)+1 );
+ do_set_crop_invalid(U32_MAX);
+}
+
+void do_set_crop_null(enum v4l2_buf_type type) {
+ int ret_orig, errno_orig;
+ int ret_set, errno_set;
+ int ret_cap, errno_cap;
+ int ret_null, errno_null;
+ struct v4l2_crop crop;
+ struct v4l2_crop crop_orig;
+ struct v4l2_cropcap cropcap;
+
+ memset(&crop_orig, 0, sizeof(crop_orig));
+ crop_orig.type = type;
+ ret_orig = ioctl(get_video_fd(), VIDIOC_G_CROP, &crop_orig);
+ errno_orig = errno;
+ dprintf("\t%s:%u: VIDIOC_G_CROP, ret_orig=%i, errno_orig=%i, "
+ "crop_orig = { .type=%i, .c={ .left=%i, .top=%i, .width=%i, .height=%i }}\n",
+ __FILE__, __LINE__,
+ ret_orig, errno_orig,
+ crop_orig.type,
+ crop_orig.c.left,
+ crop_orig.c.top,
+ crop_orig.c.width,
+ crop_orig.c.height
+ );
+
+ memset(&cropcap, 0, sizeof(cropcap));
+ cropcap.type = type;
+ ret_cap = ioctl(get_video_fd(), VIDIOC_CROPCAP, &cropcap);
+ errno_cap = errno;
+
+ dprintf("\t%s:%u: VIDIOC_CROPCAP, ret_cap=%i, errno_cap=%i, cropcap = { .type = %i, "
+ ".bounds = { .left = %i, .top = %i, .width = %i, .height = %i }, "
+ ".defrect = { .left = %i, .top = %i, .width = %i, .height = %i }, "
+ ".pixelaspect = { .numerator = %u, .denominator = %u } "
+ "}\n",
+ __FILE__, __LINE__,
+ ret_cap, errno_cap,
+ cropcap.type,
+
+ cropcap.bounds.left,
+ cropcap.bounds.top,
+ cropcap.bounds.width,
+ cropcap.bounds.height,
+
+ cropcap.defrect.left,
+ cropcap.defrect.top,
+ cropcap.defrect.width,
+ cropcap.defrect.height,
+
+ cropcap.pixelaspect.numerator,
+ cropcap.pixelaspect.denominator
+ );
+
+ memset(&crop, 0, sizeof(crop));
+ crop.type = type;
+ crop.c = cropcap.bounds;
+ ret_set = ioctl(get_video_fd(), VIDIOC_S_CROP, &crop);
+ errno_set = errno;
+ dprintf("\t%s:%u: VIDIOC_S_CROP, ret_set=%i, errno_set=%i\n",
+ __FILE__, __LINE__, ret_set, errno_set);
+
+ ret_null = ioctl(get_video_fd(), VIDIOC_S_CROP, NULL);
+ errno_null = errno;
+ dprintf("\t%s:%u: VIDIOC_S_CROP, ret_null=%i, errno_null=%i\n",
+ __FILE__, __LINE__, ret_null, errno_null);
+
+ if (ret_set == 0) {
+ CU_ASSERT_EQUAL(ret_set, 0);
+ CU_ASSERT_EQUAL(ret_null, -1);
+ CU_ASSERT_EQUAL(errno_null, EFAULT);
+
+ } else {
+ CU_ASSERT_EQUAL(ret_set, -1);
+ CU_ASSERT_EQUAL(errno_set, EINVAL);
+ CU_ASSERT_EQUAL(ret_null, -1);
+ CU_ASSERT_EQUAL(errno_null, EINVAL);
+
+ }
+
+ if (ret_orig == 0) {
+ /* it shall be possible to restore the original settings */
+ ret_set = ioctl(get_video_fd(), VIDIOC_S_CROP, &crop_orig);
+ errno_set = errno;
+ dprintf("\t%s:%u: VIDIOC_S_CROP, ret_set=%i, errno_set=%i\n",
+ __FILE__, __LINE__, ret_set, errno_set);
+ CU_ASSERT_EQUAL(ret_set, 0);
+ }
+
+}
+
+void test_VIDIOC_S_CROP_NULL() {
+
+ do_set_crop_null(V4L2_BUF_TYPE_VIDEO_CAPTURE);
+ do_set_crop_null(V4L2_BUF_TYPE_VIDEO_OUTPUT);
+ do_set_crop_null(V4L2_BUF_TYPE_VIDEO_OVERLAY);
+ do_set_crop_null(V4L2_BUF_TYPE_PRIVATE);
+
+}
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROPCAP.c ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROPCAP.c
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROPCAP.c 2009-02-16 06:13:54.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROPCAP.c 2009-03-07 21:22:59.000000000 +0100
@@ -1,6 +1,7 @@
/*
* v4l-test: Test environment for Video For Linux Two API
*
+ * 7 Mar 2009 0.4 Typo corrected
* 9 Feb 2009 0.3 Modify test_VIDIOC_CROPCAP_enum_INPUT() to support drivers
* without any inputs
* 3 Feb 2009 0.2 Typo fixed
@@ -54,7 +55,7 @@ static void do_ioctl_VIDIOC_CROPCAP(enum
/* | | +------- defrect ---------+ | | */
/* | | | | | | */
/* | | | | | | */
- /* | | | | | | heigth */
+ /* | | | | | | height */
/* | | +-------------------------+ | | */
/* | | | | */
/* | | | | */
@@ -85,8 +86,8 @@ static void do_ioctl_VIDIOC_CROPCAP(enum
CU_ASSERT_NOT_EQUAL(cropcap.pixelaspect.denominator, 0);
dprintf("\tcropcap = { .type = %i, "
- ".bounds = { .left = %i, .top = %i, .width = %i, .heigth = %i }, "
- ".defrect = { .left = %i, .top = %i, .width = %i, .heigth = %i }, "
+ ".bounds = { .left = %i, .top = %i, .width = %i, .height = %i }, "
+ ".defrect = { .left = %i, .top = %i, .width = %i, .height = %i }, "
".pixelaspect = { .numerator = %u, .denominator = %u } "
"}\n",
cropcap.type,
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROP.h ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROP.h
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROP.h 2009-02-23 12:22:27.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CROP.h 2009-03-07 21:49:01.000000000 +0100
@@ -1,6 +1,7 @@
/*
* v4l-test: Test environment for Video For Linux Two API
*
+ * 7 Mar 2009 0.3 Test cases added for VIDIOC_S_CROP
* 13 Feb 2009 0.2 Test cases added for VIDIOC_G_CROP
* 7 Feb 2009 0.1 First release
*
@@ -11,3 +12,6 @@
void test_VIDIOC_G_CROP(void);
void test_VIDIOC_G_CROP_invalid(void);
void test_VIDIOC_G_CROP_NULL(void);
+void test_VIDIOC_S_CROP(void);
+void test_VIDIOC_S_CROP_invalid(void);
+void test_VIDIOC_S_CROP_NULL(void);
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CTRL.c ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CTRL.c
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CTRL.c 2009-02-26 13:14:52.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_CTRL.c 2009-03-14 09:32:02.000000000 +0100
@@ -1,6 +1,9 @@
/*
* v4l-test: Test environment for Video For Linux Two API
*
+ * 14 Mar 2009 0.4 Added test steps for S16_MIN, S16_MAX, U16_MIN and U16_MAX
+ * 6 Mar 2009 0.3 Check whether the newly set value is converted to the
+ * closest valid value when setting out of bounds value
* 22 Feb 2009 0.2 Added test cases for VIDIOC_S_CTRL
* 19 Feb 2009 0.1 First release
*
@@ -241,11 +244,11 @@ int do_set_control(__u32 id) {
* S32_MIN <= queryctrl.minimum-queryctrl.step and
* queryctrl.maximum+queryctrl.step <= S32_MAX
*/
-
+
/*
* If we try to set the new control value to "value" then the possible results can be
* "x" and "x-step". These two values can be expressed with the range
- * (value-step, value+step) where the ranges are not included.
+ * (value-step, value+step) where the ranges are not included.
*
* value-step value value+step
* | | |
@@ -449,6 +452,72 @@ int do_set_control(__u32 id) {
return ret1;
}
+static void do_set_control_value(__u32 id, __s32 value, struct v4l2_queryctrl *queryctrl);
+static void do_set_control_value(__u32 id, __s32 value, struct v4l2_queryctrl *queryctrl) {
+ int ret_set, errno_set;
+ int ret_get, errno_get;
+ struct v4l2_control control;
+ struct v4l2_control control_new;
+
+ memset(&control, 0xff, sizeof(control));
+ control.id = id;
+ control.value = value;
+ ret_set = ioctl(get_video_fd(), VIDIOC_S_CTRL, &control);
+ errno_set = errno;
+
+ dprintf("\t%s:%u: VIDIOC_S_CTRL, id=%u (V4L2_CID_BASE+%i), value=%i, ret_set=%i, errno_set=%i\n",
+ __FILE__, __LINE__, id, id-V4L2_CID_BASE, value, ret_set, errno_set);
+
+ /* The driver can decide if it returns ERANGE or
+ * accepts the value and converts it to
+ * the nearest limit
+ */
+ if (ret_set == -1) {
+ CU_ASSERT_EQUAL(ret_set, -1);
+ if (!(queryctrl->flags & V4L2_CTRL_FLAG_DISABLED) &&
+ !(queryctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) {
+ CU_ASSERT_EQUAL(errno_set, ERANGE);
+ } else {
+ CU_ASSERT_EQUAL(errno_set, EINVAL);
+ }
+
+ /* check whether the new value is not out of bounds */
+ memset(&control_new, 0, sizeof(control_new));
+ control_new.id = id;
+ ret_get = ioctl(get_video_fd(), VIDIOC_G_CTRL, &control_new);
+ errno_get = errno;
+
+ dprintf("\t%s:%u: VIDIOC_G_CTRL, id=%u (V4L2_CID_BASE+%i), ret_get=%i, errno_get=%i, control_new.value=%i\n",
+ __FILE__, __LINE__, id, id-V4L2_CID_BASE, ret_get, errno_get, control_new.value);
+
+ CU_ASSERT_EQUAL(ret_get, 0);
+ if (ret_get == 0) {
+ CU_ASSERT(queryctrl->minimum <= control_new.value);
+ CU_ASSERT(control_new.value <= queryctrl->maximum);
+ }
+
+ } else {
+ CU_ASSERT_EQUAL(ret_set, 0);
+
+ /* check whether the new value is not out of bounds */
+ memset(&control_new, 0, sizeof(control_new));
+ control_new.id = id;
+ ret_get = ioctl(get_video_fd(), VIDIOC_G_CTRL, &control_new);
+ errno_get = errno;
+
+ dprintf("\t%s:%u: VIDIOC_G_CTRL, id=%u (V4L2_CID_BASE+%i), ret_get=%i, errno_get=%i, control_new.value=%i\n",
+ __FILE__, __LINE__, id, id-V4L2_CID_BASE, ret_get, errno_get, control_new.value);
+
+ CU_ASSERT_EQUAL(ret_get, 0);
+ if (ret_get == 0) {
+ CU_ASSERT(queryctrl->minimum <= control_new.value);
+ CU_ASSERT(control_new.value <= queryctrl->maximum);
+ CU_ASSERT_EQUAL(control_new.value, queryctrl->minimum);
+ }
+ }
+}
+
+
int do_set_control_invalid(__u32 id) {
int ret1, errno1;
int ret_set, errno_set;
@@ -508,223 +577,37 @@ int do_set_control_invalid(__u32 id) {
case V4L2_CTRL_TYPE_BOOLEAN:
case V4L2_CTRL_TYPE_MENU:
if (S32_MIN < queryctrl.minimum) {
-
- value = S32_MIN;
- memset(&control, 0xff, sizeof(control));
- control.id = id;
- control.value = value;
- ret_set = ioctl(get_video_fd(), VIDIOC_S_CTRL, &control);
- errno_set = errno;
-
- dprintf("\t%s:%u: VIDIOC_S_CTRL, id=%u (V4L2_CID_BASE+%i), value=%i, ret_set=%i, errno_set=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, value, ret_set, errno_set);
-
- /* The driver can decide if it returns ERANGE or
- * accepts the value and converts it to
- * the nearest limit
- */
- if (ret_set == -1) {
- CU_ASSERT_EQUAL(ret_set, -1);
- if (!(queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) &&
- !(queryctrl.flags & V4L2_CTRL_FLAG_READ_ONLY)) {
- CU_ASSERT_EQUAL(errno_set, ERANGE);
- } else {
- CU_ASSERT_EQUAL(errno_set, EINVAL);
- }
-
- /* check whether the new value is not out of bounds */
- memset(&control_new, 0, sizeof(control_new));
- control_new.id = id;
- ret_get = ioctl(get_video_fd(), VIDIOC_G_CTRL, &control_new);
- errno_get = errno;
-
- dprintf("\t%s:%u: VIDIOC_G_CTRL, id=%u (V4L2_CID_BASE+%i), ret_get=%i, errno_get=%i, control_new.value=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, ret_get, errno_get, control_new.value);
-
- CU_ASSERT_EQUAL(ret_get, 0);
- if (ret_get == 0) {
- CU_ASSERT(queryctrl.minimum <= control_new.value);
- CU_ASSERT(control_new.value <= queryctrl.maximum);
- }
-
- } else {
- CU_ASSERT_EQUAL(ret_set, 0);
-
- /* check whether the new value is not out of bounds */
- memset(&control_new, 0, sizeof(control_new));
- control_new.id = id;
- ret_get = ioctl(get_video_fd(), VIDIOC_G_CTRL, &control_new);
- errno_get = errno;
-
- dprintf("\t%s:%u: VIDIOC_G_CTRL, id=%u (V4L2_CID_BASE+%i), ret_get=%i, errno_get=%i, control_new.value=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, ret_get, errno_get, control_new.value);
-
- CU_ASSERT_EQUAL(ret_get, 0);
- if (ret_get == 0) {
- CU_ASSERT(queryctrl.minimum <= control_new.value);
- CU_ASSERT(control_new.value <= queryctrl.maximum);
- }
- }
+ do_set_control_value(id, S32_MIN, &queryctrl);
}
if (S32_MIN < queryctrl.minimum) {
-
- value = queryctrl.minimum-1;
- memset(&control, 0xff, sizeof(control));
- control.id = id;
- control.value = value;
- ret_set = ioctl(get_video_fd(), VIDIOC_S_CTRL, &control);
- errno_set = errno;
-
- dprintf("\t%s:%u: VIDIOC_S_CTRL, id=%u (V4L2_CID_BASE+%i), value=%i, ret_set=%i, errno_set=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, value, ret_set, errno_set);
+ do_set_control_value(id, queryctrl.minimum-1, &queryctrl);
+ }
- if (ret_set == -1) {
- CU_ASSERT_EQUAL(ret_set, -1);
- CU_ASSERT_EQUAL(errno_set, ERANGE);
+ if (S16_MIN < queryctrl.minimum) {
+ do_set_control_value(id, S16_MIN, &queryctrl);
+ }
- /* check whether the new value is not out of bounds */
- memset(&control_new, 0, sizeof(control_new));
- control_new.id = id;
- ret_get = ioctl(get_video_fd(), VIDIOC_G_CTRL, &control_new);
- errno_get = errno;
-
- dprintf("\t%s:%u: VIDIOC_G_CTRL, id=%u (V4L2_CID_BASE+%i), ret_get=%i, errno_get=%i, control_new.value=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, ret_get, errno_get, control_new.value);
-
- CU_ASSERT_EQUAL(ret_get, 0);
- if (ret_get == 0) {
- CU_ASSERT(queryctrl.minimum <= control_new.value);
- CU_ASSERT(control_new.value <= queryctrl.maximum);
- }
+ if (U16_MIN < queryctrl.minimum) {
+ do_set_control_value(id, U16_MIN, &queryctrl);
+ }
- } else {
- CU_ASSERT_EQUAL(ret_set, 0);
+ if (queryctrl.maximum < S16_MAX) {
+ do_set_control_value(id, S16_MAX, &queryctrl);
+ }
- /* check whether the new value is not out of bounds */
- memset(&control_new, 0, sizeof(control_new));
- control_new.id = id;
- ret_get = ioctl(get_video_fd(), VIDIOC_G_CTRL, &control_new);
- errno_get = errno;
-
- dprintf("\t%s:%u: VIDIOC_G_CTRL, id=%u (V4L2_CID_BASE+%i), ret_get=%i, errno_get=%i, control_new.value=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, ret_get, errno_get, control_new.value);
-
- CU_ASSERT_EQUAL(ret_get, 0);
- if (ret_get == 0) {
- CU_ASSERT(queryctrl.minimum <= control_new.value);
- CU_ASSERT(control_new.value <= queryctrl.maximum);
- }
- }
+ if (queryctrl.maximum < (__s32)U16_MAX) {
+ do_set_control_value(id, (__s32)U16_MAX, &queryctrl);
}
if (queryctrl.maximum < S32_MAX) {
-
- value = queryctrl.maximum+1;
- memset(&control, 0xff, sizeof(control));
- control.id = id;
- control.value = value;
- ret_set = ioctl(get_video_fd(), VIDIOC_S_CTRL, &control);
- errno_set = errno;
-
- dprintf("\t%s:%u: VIDIOC_S_CTRL, id=%u (V4L2_CID_BASE+%i), value=%i, ret_set=%i, errno_set=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, value, ret_set, errno_set);
-
- /* The driver can decide if it returns ERANGE or
- * accepts the value and converts it to
- * the nearest limit
- */
- if (ret_set == -1) {
- CU_ASSERT_EQUAL(ret_set, -1);
- CU_ASSERT_EQUAL(errno_set, ERANGE);
-
- /* check whether the new value is not out of bounds */
- memset(&control_new, 0, sizeof(control_new));
- control_new.id = id;
- ret_get = ioctl(get_video_fd(), VIDIOC_G_CTRL, &control_new);
- errno_get = errno;
-
- dprintf("\t%s:%u: VIDIOC_G_CTRL, id=%u (V4L2_CID_BASE+%i), ret_get=%i, errno_get=%i, control_new.value=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, ret_get, errno_get, control_new.value);
-
- CU_ASSERT_EQUAL(ret_get, 0);
- if (ret_get == 0) {
- CU_ASSERT(queryctrl.minimum <= control_new.value);
- CU_ASSERT(control_new.value <= queryctrl.maximum);
- }
-
- } else {
- CU_ASSERT_EQUAL(ret_set, 0);
-
- /* check whether the new value is not out of bounds */
- memset(&control_new, 0, sizeof(control_new));
- control_new.id = id;
- ret_get = ioctl(get_video_fd(), VIDIOC_G_CTRL, &control_new);
- errno_get = errno;
-
- dprintf("\t%s:%u: VIDIOC_G_CTRL, id=%u (V4L2_CID_BASE+%i), ret_get=%i, errno_get=%i, control_new.value=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, ret_get, errno_get, control_new.value);
-
- CU_ASSERT_EQUAL(ret_get, 0);
- if (ret_get == 0) {
- CU_ASSERT(queryctrl.minimum <= control_new.value);
- CU_ASSERT(control_new.value <= queryctrl.maximum);
- }
- }
+ do_set_control_value(id, queryctrl.maximum+1, &queryctrl);
}
if (queryctrl.maximum < S32_MAX) {
-
- value = S32_MAX;
- memset(&control, 0xff, sizeof(control));
- control.id = id;
- control.value = value;
- ret_set = ioctl(get_video_fd(), VIDIOC_S_CTRL, &control);
- errno_set = errno;
-
- dprintf("\t%s:%u: VIDIOC_S_CTRL, id=%u (V4L2_CID_BASE+%i), value=%i, ret_set=%i, errno_set=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, value, ret_set, errno_set);
-
- if (ret_set == -1) {
- CU_ASSERT_EQUAL(ret_set, -1);
- CU_ASSERT_EQUAL(errno_set, ERANGE);
-
- /* check whether the new value is not out of bounds */
- memset(&control_new, 0, sizeof(control_new));
- control_new.id = id;
- ret_get = ioctl(get_video_fd(), VIDIOC_G_CTRL, &control_new);
- errno_get = errno;
-
- dprintf("\t%s:%u: VIDIOC_G_CTRL, id=%u (V4L2_CID_BASE+%i), ret_get=%i, errno_get=%i, control_new.value=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, ret_get, errno_get, control_new.value);
-
- CU_ASSERT_EQUAL(ret_get, 0);
- if (ret_get == 0) {
- CU_ASSERT(queryctrl.minimum <= control_new.value);
- CU_ASSERT(control_new.value <= queryctrl.maximum);
- }
-
- } else {
- CU_ASSERT_EQUAL(ret_set, 0);
-
- /* check whether the new value is not out of bounds */
- memset(&control_new, 0, sizeof(control_new));
- control_new.id = id;
- ret_get = ioctl(get_video_fd(), VIDIOC_G_CTRL, &control_new);
- errno_get = errno;
-
- dprintf("\t%s:%u: VIDIOC_G_CTRL, id=%u (V4L2_CID_BASE+%i), ret_get=%i, errno_get=%i, control_new.value=%i\n",
- __FILE__, __LINE__, id, id-V4L2_CID_BASE, ret_get, errno_get, control_new.value);
-
- CU_ASSERT_EQUAL(ret_get, 0);
- if (ret_get == 0) {
- CU_ASSERT(queryctrl.minimum <= control_new.value);
- CU_ASSERT(control_new.value <= queryctrl.maximum);
- }
- }
+ do_set_control_value(id, S32_MAX, &queryctrl);
}
-
break;
case V4L2_CTRL_TYPE_BUTTON:
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUM_FMT.c ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUM_FMT.c
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUM_FMT.c 2009-02-26 13:02:10.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUM_FMT.c 2009-01-04 12:45:22.000000000 +0100
@@ -174,7 +174,7 @@ void test_VIDIOC_ENUM_FMT_invalid_type()
struct v4l2_fmtdesc format2;
int i;
- /* In this test case the .index is valid (0) and only the .type
+ /* In this test case the .index is valid (0) and only the .type
* is invalid. The .type filed is an enum which is stored in an 'int'.
*/
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUMSTD.c ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUMSTD.c
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUMSTD.c 2009-02-26 13:02:10.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUMSTD.c 2009-01-18 17:23:15.000000000 +0100
@@ -13,7 +13,7 @@
/* TODO: from V4L2 Spec:
* "Drivers may enumerate a different set of standards after switching the video input or output."
- *
+ *
*/
#include <stdio.h>
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_QUERYCTRL.c ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_QUERYCTRL.c
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_QUERYCTRL.c 2009-02-26 13:14:52.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_QUERYCTRL.c 2009-01-04 13:29:37.000000000 +0100
@@ -6,7 +6,7 @@
* Written by Márton Németh <[email protected]>
* Released under GPL
*/
-
+
/*
* Note: V4L2_CID_LASTP1 != V4L2_CID_BASE_LASTP1
*/
@@ -123,7 +123,7 @@ void test_VIDIOC_QUERYCTRL() {
/* These parameters are defined as n/a by V4L2, so
* they should be filled with zeros, the same like
* the reserved fields.
- */
+ */
CU_ASSERT_EQUAL(queryctrl.minimum, 0);
CU_ASSERT_EQUAL(queryctrl.maximum, 0);
CU_ASSERT_EQUAL(queryctrl.step, 0);
@@ -305,7 +305,7 @@ void test_VIDIOC_QUERYCTRL_flag_NEXT_CTR
CU_ASSERT_EQUAL(memcmp(&queryctrl, &controls[queryctrl.id-V4L2_CID_BASE], sizeof(queryctrl)), 0);
}
- /* "The VIDIOC_QUERYCTRL ioctl will return the first
+ /* "The VIDIOC_QUERYCTRL ioctl will return the first
* control with a higher ID than the specified one."
*/
CU_ASSERT(i < queryctrl.id);
@@ -346,12 +346,12 @@ void test_VIDIOC_QUERYCTRL_flag_NEXT_CTR
CU_ASSERT_EQUAL(errno, EINVAL);
}
- /* Check whether the same controls are reported if using
+ /* Check whether the same controls are reported if using
* V4L2_CTRL_FLAG_NEXT_CTRL and without using it.
* This also checks if one control is not reported twice.
*/
CU_ASSERT_EQUAL(memcmp(count_controls1, count_controls2, sizeof(count_controls1)), 0);
-
+
dprintf1("count_controls1 = { ");
for (i=0; i<sizeof(count_controls1)/sizeof(*count_controls1); i++) {
dprintf("%i ", count_controls1[i]);
@@ -363,7 +363,7 @@ void test_VIDIOC_QUERYCTRL_flag_NEXT_CTR
dprintf("%i ", count_controls2[i]);
}
dprintf1("}\n");
-
+
} else {
dprintf1("V4L2_CTRL_FLAG_NEXT_CTRL is not supported or no control is available\n");
/* The flag V4L2_CTRL_FLAG_NEXT_CTRL is not supported
@@ -440,7 +440,7 @@ void test_VIDIOC_QUERYCTRL_private() {
/* These parameters are defined as n/a by V4L2, so
* they should be filled with zeros, the same like
* the reserved fields.
- */
+ */
CU_ASSERT_EQUAL(queryctrl.minimum, 0);
CU_ASSERT_EQUAL(queryctrl.maximum, 0);
CU_ASSERT_EQUAL(queryctrl.step, 0);
@@ -523,7 +523,7 @@ void test_VIDIOC_QUERYCTRL_private_last_
memset(&queryctrl, 0xff, sizeof(queryctrl));
queryctrl.id = i;
ret = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, &queryctrl);
-
+
i++;
} while (ret == 0);
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/v4l2_test.c ltp/testcases/kernel/device-drivers/v4l/user_space/v4l2_test.c
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/v4l2_test.c 2009-02-23 12:22:27.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/v4l2_test.c 2009-03-07 21:48:51.000000000 +0100
@@ -1,6 +1,7 @@
/*
* v4l-test: Test environment for Video For Linux Two API
*
+ * 7 Mar 2009 0.13 Test cases added for VIDIOC_S_CROP
* 22 Feb 2009 0.12 Test cases added for VIDIOC_S_CTRL
* 19 Feb 2009 0.11 Test cases added for VIDIOC_G_CTRL
* 7 Feb 2009 0.10 Test cases added for VIDIOC_G_AUDIO, VIDIOC_G_AUDOUT,
@@ -203,6 +204,11 @@ static CU_TestInfo suite_get_set_try[] =
{ "VIDIOC_G_CROP", test_VIDIOC_G_CROP },
{ "VIDIOC_G_CROP with invalid type", test_VIDIOC_G_CROP_invalid },
{ "VIDIOC_G_CROP with NULL parameter", test_VIDIOC_G_CROP_NULL },
+
+ { "VIDIOC_S_CROP", test_VIDIOC_S_CROP },
+ { "VIDIOC_S_CROP with invalid type", test_VIDIOC_S_CROP_invalid},
+ { "VIDIOC_S_CROP with NULL parameter", test_VIDIOC_S_CROP_NULL },
+
#endif
{ "VIDIOC_G_CTRL", test_VIDIOC_G_CTRL },
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/video_limits.h ltp/testcases/kernel/device-drivers/v4l/user_space/video_limits.h
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/video_limits.h 2009-02-23 12:22:27.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/video_limits.h 2009-03-12 08:24:12.000000000 +0100
@@ -1,6 +1,7 @@
/*
* v4l-test: Test environment for Video For Linux Two API
*
+ * 12 Mar 2009 0.4 S16_MIN, S16_MAX, U16_MIN and U16_MAX added
* 22 Feb 2009 0.3 S32_MIN and U32_MIN added
* 1 Jan 2009 0.2 SINT_MAX and SINT_MIN added
* 18 Dec 2008 0.1 First release
@@ -17,5 +18,11 @@
#define U32_MIN 0
#define U32_MAX 0xFFFFFFFFU
+#define S16_MIN -32768
+#define S16_MAX 32767
+
+#define U16_MIN 0
+#define U16_MAX 0xFFFFU
+
#define SINT_MIN INT_MIN
#define SINT_MAX INT_MAX
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list