v4l2-compliance: add tests for VIDIOC_G/S_JPEGCOMP.
authorHans Verkuil <hans.verkuil@cisco.com>
Sat, 28 Apr 2012 16:26:23 +0000 (18:26 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Sat, 28 Apr 2012 17:13:01 +0000 (19:13 +0200)
Since these ioctls are on their way out a warning is issued if they are
implemented.

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-controls.cpp

index 1b4a816..f6b8045 100644 (file)
@@ -592,6 +592,7 @@ int main(int argc, char **argv)
        printf("\ttest VIDIOC_G/S_CTRL: %s\n", ok(testSimpleControls(&node)));
        printf("\ttest VIDIOC_G/S/TRY_EXT_CTRLS: %s\n", ok(testExtendedControls(&node)));
        printf("\ttest VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: %s\n", ok(testControlEvents(&node)));
+       printf("\ttest VIDIOC_G/S_JPEGCOMP: %s\n", ok(testJpegComp(&node)));
        printf("\tStandard Controls: %d Private Controls: %d\n",
                        node.std_controls, node.priv_controls);
        printf("\n");
@@ -618,7 +619,6 @@ int main(int argc, char **argv)
           VIDIOC_S_FBUF/OVERLAY
           VIDIOC_S/TRY_FMT
           VIDIOC_G/S_PARM
-          VIDIOC_G/S_JPEGCOMP
           VIDIOC_(TRY_)ENCODER_CMD
           VIDIOC_G_ENC_INDEX
           VIDIOC_REQBUFS/QBUF/DQBUF/QUERYBUF
index 46cabb6..2aa11f3 100644 (file)
@@ -153,6 +153,7 @@ int testQueryControls(struct node *node);
 int testSimpleControls(struct node *node);
 int testExtendedControls(struct node *node);
 int testControlEvents(struct node *node);
+int testJpegComp(struct node *node);
 
 // I/O configuration ioctl tests
 int testStd(struct node *node);
index 7c7bdd3..50b7764 100644 (file)
@@ -717,3 +717,42 @@ int testControlEvents(struct node *node)
        }
        return 0;
 }
+
+int testJpegComp(struct node *node)
+{
+       struct v4l2_jpegcompression jc;
+       bool have_jpegcomp = false;
+       const unsigned all_markers =
+               V4L2_JPEG_MARKER_DHT | V4L2_JPEG_MARKER_DQT |
+               V4L2_JPEG_MARKER_DRI | V4L2_JPEG_MARKER_COM |
+               V4L2_JPEG_MARKER_APP;
+       int ret;
+       
+       memset(&jc, 0, sizeof(jc));
+       ret = doioctl(node, VIDIOC_G_JPEGCOMP, &jc);
+       if (ret != ENOTTY) {
+               warn("The VIDIOC_G_JPEGCOMP ioctl is deprecated!\n");
+               if (ret)
+                       return fail("VIDIOC_G_JPEGCOMP gave an error\n");
+               have_jpegcomp = true;
+               if (jc.COM_len < 0 || jc.COM_len > (int)sizeof(jc.COM_data))
+                       return fail("invalid COM_len value\n");
+               if (jc.APP_len < 0 || jc.APP_len > (int)sizeof(jc.APP_data))
+                       return fail("invalid APP_len value\n");
+               if (jc.quality < 0 || jc.quality > 100)
+                       warn("weird quality value: %d\n", jc.quality);
+               if (jc.APPn < 0 || jc.APPn > 15)
+                       return fail("invalid APPn value (%d)\n", jc.APPn);
+               if (jc.jpeg_markers & ~all_markers)
+                       return fail("invalid markers (%x)\n", jc.jpeg_markers);
+       }
+       ret = doioctl(node, VIDIOC_S_JPEGCOMP, &jc);
+       if (ret != ENOTTY) {
+               warn("The VIDIOC_S_JPEGCOMP ioctl is deprecated!\n");
+               if (ret && ret != EINVAL)
+                       return fail("VIDIOC_S_JPEGCOMP gave an error\n");
+               have_jpegcomp = true;
+       }
+
+       return have_jpegcomp ? ret : ENOTTY;
+}