From fe840814f13636a757ba7a190fdcc93b73f25624 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 20 Feb 2014 13:17:05 +0100 Subject: [PATCH] v4l2-compliance: move streaming setup code to main source. The streaming setup code was partially in v4l2-compliance and partially in testMmap() where it really didn't belong. Move it all to v4l2-compliance.cpp. Also skip the streaming tests for mem2mem devices: these are not yet supported. Signed-off-by: Hans Verkuil --- utils/v4l2-compliance/v4l2-compliance.cpp | 82 +++++++++++++++++++---------- utils/v4l2-compliance/v4l2-test-buffers.cpp | 22 +------- 2 files changed, 55 insertions(+), 49 deletions(-) diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp index 6357313..2dbd4a5 100644 --- a/utils/v4l2-compliance/v4l2-compliance.cpp +++ b/utils/v4l2-compliance/v4l2-compliance.cpp @@ -399,6 +399,58 @@ static int testPrio(struct node *node, struct node *node2) return 0; } +static void streamingSetup(struct node *node) +{ + struct v4l2_input input; + + if (options[OptSetInput]) + doioctl(node, VIDIOC_S_INPUT, &select_input); + if (options[OptSetOutput]) + doioctl(node, VIDIOC_S_OUTPUT, &select_output); + if (options[OptSetFreq]) { + struct v4l2_frequency f = { 0 }; + unsigned freq_caps; + + if (node->caps & V4L2_CAP_MODULATOR) { + struct v4l2_modulator m = { 0 }; + + doioctl(node, VIDIOC_G_MODULATOR, &m); + freq_caps = m.capability; + f.type = V4L2_TUNER_RADIO; + } else { + struct v4l2_tuner t = { 0 }; + + doioctl(node, VIDIOC_G_TUNER, &t); + f.type = t.type; + freq_caps = t.capability; + } + if (freq_caps & V4L2_TUNER_CAP_LOW) + f.frequency = select_freq / 62.5; + else + f.frequency = select_freq / 62500; + doioctl(node, VIDIOC_S_FREQUENCY, &f); + } + + memset(&input, 0, sizeof(input)); + doioctl(node, VIDIOC_G_INPUT, &input.index); + doioctl(node, VIDIOC_ENUMINPUT, &input); + + if (input.capabilities & V4L2_IN_CAP_STD) { + v4l2_std_id std; + + doioctl(node, VIDIOC_QUERYSTD, &std); + if (std) + doioctl(node, VIDIOC_S_STD, &std); + } + + if (input.capabilities & V4L2_IN_CAP_DV_TIMINGS) { + struct v4l2_dv_timings t; + + if (doioctl(node, VIDIOC_QUERY_DV_TIMINGS, &t) == 0) + doioctl(node, VIDIOC_S_DV_TIMINGS, &t); + } +} + int main(int argc, char **argv) { int i; @@ -740,34 +792,8 @@ int main(int argc, char **argv) printf("Buffer ioctls:\n"); printf("\ttest VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: %s\n", ok(testReqBufs(&node))); printf("\ttest VIDIOC_EXPBUF: %s\n", ok(testExpBuf(&node))); - if (options[OptStreaming]) { - if (options[OptSetInput]) - doioctl(&node, VIDIOC_S_INPUT, &select_input); - if (options[OptSetOutput]) - doioctl(&node, VIDIOC_S_OUTPUT, &select_output); - if (options[OptSetFreq]) { - struct v4l2_frequency f = { 0 }; - unsigned freq_caps; - - if (node.caps & V4L2_CAP_MODULATOR) { - struct v4l2_modulator m = { 0 }; - - doioctl(&node, VIDIOC_G_MODULATOR, &m); - freq_caps = m.capability; - f.type = V4L2_TUNER_RADIO; - } else { - struct v4l2_tuner t = { 0 }; - - doioctl(&node, VIDIOC_G_TUNER, &t); - f.type = t.type; - freq_caps = t.capability; - } - if (freq_caps & V4L2_TUNER_CAP_LOW) - f.frequency = select_freq / 62.5; - else - f.frequency = select_freq / 62500; - doioctl(&node, VIDIOC_S_FREQUENCY, &f); - } + if (options[OptStreaming] && !node.is_m2m) { + streamingSetup(&node); printf("\ttest read/write: %s\n", ok(testReadWrite(&node))); // Reopen to clear the 'file I/O' mode of the filehandle, diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp index 5b524c7..70efd23 100644 --- a/utils/v4l2-compliance/v4l2-test-buffers.cpp +++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp @@ -547,33 +547,13 @@ int testMmap(struct node *node, unsigned frame_count) { struct v4l2_requestbuffers bufs; struct v4l2_create_buffers cbufs; - struct v4l2_input input; bool can_stream = node->caps & V4L2_CAP_STREAMING; bool have_createbufs = true; int ret; - + if (!(node->caps & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE))) return 0; - memset(&input, 0, sizeof(input)); - doioctl(node, VIDIOC_G_INPUT, &input.index); - doioctl(node, VIDIOC_ENUMINPUT, &input); - - if (input.capabilities & V4L2_IN_CAP_STD) { - v4l2_std_id std; - - doioctl(node, VIDIOC_QUERYSTD, &std); - if (std) - doioctl(node, VIDIOC_S_STD, &std); - } - - if (input.capabilities & V4L2_IN_CAP_DV_TIMINGS) { - struct v4l2_dv_timings t; - - if (doioctl(node, VIDIOC_QUERY_DV_TIMINGS, &t) == 0) - doioctl(node, VIDIOC_S_DV_TIMINGS, &t); - } - memset(&bufs, 0, sizeof(bufs)); bufs.type = (node->caps & V4L2_CAP_VIDEO_CAPTURE) ? V4L2_BUF_TYPE_VIDEO_CAPTURE : -- 2.7.4