From f50ace41a0d05bea2f5f1a5c7d769b22b956bd94 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Tue, 29 Nov 2016 12:08:13 +0100 Subject: v4l2-jpeg-codec-test: V4L2 capabilities testing fix Use device caps and test only for V4L2_CAP_VIDEO_M2M when available to avoid errors with recent kernels. Signed-off-by: Sylwester Nawrocki --- v4l2-jpeg-codec-test/test-jpeg.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'v4l2-jpeg-codec-test') diff --git a/v4l2-jpeg-codec-test/test-jpeg.c b/v4l2-jpeg-codec-test/test-jpeg.c index 2e17057..f723bf4 100644 --- a/v4l2-jpeg-codec-test/test-jpeg.c +++ b/v4l2-jpeg-codec-test/test-jpeg.c @@ -32,6 +32,10 @@ #include #include +#ifndef V4L2_CAP_VIDEO_M2M +#define V4L2_CAP_VIDEO_M2M 0x00008000 +#endif + #include #define VIDEO_DEV_NAME "/dev/video" @@ -410,13 +414,24 @@ int main(int argc, char *argv[]) ret = ioctl(vid_fd, VIDIOC_QUERYCAP, &cap); perror_exit(ret != 0, "ioctl"); - if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { - fprintf(stderr, "Device does not support capture\n"); - exit(EXIT_FAILURE); - } - if (!(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT)) { - fprintf(stderr, "Device does not support output\n"); - exit(EXIT_FAILURE); + + if (cap.device_caps | V4L2_CAP_DEVICE_CAPS) { + if (!(cap.device_caps & V4L2_CAP_VIDEO_M2M)) { + fprintf(stderr, "Device %s does not support mem-to-mem (%#x)\n", + video_node_name, cap.device_caps); + exit(EXIT_FAILURE); + } + } else { + if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { + fprintf(stderr, "Device %s does not support capture (%#x)\n", + video_node_name, cap.capabilities); + exit(EXIT_FAILURE); + } + if (!(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT)) { + fprintf(stderr, "Device %s does not support output (%#x)\n", + video_node_name, cap.capabilities); + exit(EXIT_FAILURE); + } } /* set input format */ -- cgit v1.2.3