v4l2-compliance: restore the initial formats after testing S_FMT
authorHans Verkuil <hans.verkuil@cisco.com>
Mon, 17 Feb 2014 14:00:41 +0000 (15:00 +0100)
committerHans Verkuil <hans.verkuil@cisco.com>
Mon, 17 Feb 2014 15:46:12 +0000 (16:46 +0100)
The format you end up with after S_FMT has been run through its paces
is the smallest possible format. However, that's not what you want for
the streaming tests. So we restore the initial formats at the end of
the tests.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/v4l2-compliance/v4l2-test-formats.cpp

index 2f23ac5..4f68b2d 100644 (file)
@@ -749,6 +749,7 @@ int testSetFormats(struct node *node)
 {
        struct v4l2_clip clip, clip_set;
        struct v4l2_format fmt, fmt_set;
+       struct v4l2_format initial_fmts[V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE + 1];
        int type;
        int ret;
        
@@ -759,6 +760,7 @@ int testSetFormats(struct node *node)
                createInvalidFmt(fmt, clip, type);
                doioctl(node, VIDIOC_G_FMT, &fmt);
                
+               initial_fmts[type] = fmt;
                createInvalidFmt(fmt_set, clip_set, type);
                ret = doioctl(node, VIDIOC_S_FMT, &fmt_set);
                if (ret == EINVAL) {
@@ -846,6 +848,13 @@ int testSetFormats(struct node *node)
                }
        }
 
+       /* Restore initial format */
+       for (type = 0; type <= V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; type++) {
+               if (!(node->valid_buftypes & (1 << type)))
+                       continue;
+
+               doioctl(node, VIDIOC_S_FMT, &initial_fmts[type]);
+       }
        return 0;
 }