v4l2-compliance: add VIDIOC_SLICED_VBI_CAP compliance test.
authorHans Verkuil <hans.verkuil@cisco.com>
Tue, 28 Jun 2011 10:07:26 +0000 (12:07 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Tue, 28 Jun 2011 10:07:26 +0000 (12:07 +0200)
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/v4l2-compliance/v4l2-compliance.cpp
utils/v4l2-compliance/v4l2-compliance.h
utils/v4l2-compliance/v4l2-test-formats.cpp

index bde4047..f865a76 100644 (file)
@@ -574,6 +574,7 @@ int main(int argc, char **argv)
        printf("\ttest VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: %s\n", ok(testEnumFormats(&node)));
        printf("\ttest VIDIOC_G_FBUF: %s\n", ok(testFBuf(&node)));
        printf("\ttest VIDIOC_G_FMT: %s\n", ok(testFormats(&node)));
+       printf("\ttest VIDIOC_G_SLICED_VBI_CAP: %s\n", ok(testSlicedVBICap(&node)));
 
        /* TODO:
 
@@ -582,7 +583,6 @@ int main(int argc, char **argv)
           VIDIOC_S/TRY_FMT
           VIDIOC_G/S_PARM
           VIDIOC_G/S_JPEGCOMP
-          VIDIOC_SLICED_VBI_CAP
           VIDIOC_S_HW_FREQ_SEEK
           VIDIOC_SUBSCRIBE_EVENT/UNSUBSCRIBE_EVENT/DQEVENT
           VIDIOC_(TRY_)ENCODER_CMD
index 72aa203..6c8f607 100644 (file)
@@ -161,5 +161,6 @@ int testCustomTimings(struct node *node);
 int testEnumFormats(struct node *node);
 int testFBuf(struct node *node);
 int testFormats(struct node *node);
+int testSlicedVBICap(struct node *node);
 
 #endif
index 976a3c9..db9245c 100644 (file)
@@ -491,3 +491,49 @@ int testFormats(struct node *node)
                warn("Buffer type PRIVATE allowed!\n");
        return 0;
 }
+
+static int testSlicedVBICapType(struct node *node, enum v4l2_buf_type type)
+{
+       struct v4l2_sliced_vbi_cap cap;
+       bool sliced_type = (type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE ||
+                           type == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT);
+       __u32 service_set = 0;
+       int ret;
+
+       memset(&cap, 0xff, sizeof(cap));
+       memset(&cap.reserved, 0, sizeof(cap.reserved));
+       cap.type = type;
+       ret = doioctl(node, VIDIOC_G_SLICED_VBI_CAP, &cap);
+       fail_on_test(check_0(cap.reserved, sizeof(cap.reserved)));
+       fail_on_test(cap.type != type);
+       fail_on_test(ret && ret != EINVAL && sliced_type);
+       if (ret == EINVAL) {
+               fail_on_test(sliced_type && (node->caps & buftype2cap[type]));
+               if (node->caps & (V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_OUTPUT))
+                       return 0;
+               return -ENOSYS;
+       }
+       if (ret)
+               return fail("expected EINVAL, but got %d when getting sliced VBI caps buftype %d\n", ret, type);
+       fail_on_test(!(node->caps & buftype2cap[type]));
+
+       for (int f = 0; f < 2; f++)
+               for (int i = 0; i < 24; i++)
+                       service_set |= cap.service_lines[f][i];
+       fail_on_test(cap.service_set != service_set);
+       fail_on_test(cap.service_lines[0][0] || cap.service_lines[1][0]);
+       return 0;
+}
+
+int testSlicedVBICap(struct node *node)
+{
+       int ret;
+
+       ret = testSlicedVBICapType(node, V4L2_BUF_TYPE_SLICED_VBI_CAPTURE);
+       if (ret)
+               return ret;
+       ret = testSlicedVBICapType(node, V4L2_BUF_TYPE_SLICED_VBI_OUTPUT);
+       if (ret)
+               return ret;
+       return testSlicedVBICapType(node, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+}