v4l2-compliance: reworked the (c)v4l-helpers.h headers
authorHans Verkuil <hans.verkuil@cisco.com>
Sun, 20 Jul 2014 12:20:09 +0000 (14:20 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Sun, 20 Jul 2014 12:20:09 +0000 (14:20 +0200)
commit36799043d6e732d30143a5cd2991e514d6f9165b
tree6209451c0fc214d76eff102fbd25c001ab561693
parent06b44024b52a97752b57913068205dfdcabf7844
v4l2-compliance: reworked the (c)v4l-helpers.h headers

These headers were designed to easy coding for the V4L2 API, in particular
hiding the complexity relating to single and multiplanar formats.

These reworked headers resolve a number of design issues and they are now ready
to be used elsewhere.

As an example, the C++ code below works for single and multiplanar video capture and
output, vbi capture and output and sdr capture. By replacing V4L2_MEMORY_MMAP with
_USERPTR it will work with userptr streaming as well. But note that the code is
missing error handling, so a real application will need to do a bit more.

int main(int argc, char **argv)
{
cv4l_fd fd;
unsigned cnt = 0;

fd.open(argc >= 2 ? argv[1] : "/dev/video0");

cv4l_queue q(fd.g_type(), V4L2_MEMORY_MMAP);

q.reqbufs(&fd, 4);
q.obtain_bufs(&fd);
q.queue_all(&fd);
fd.streamon();

cv4l_buffer buf(q);

while (fd.dqbuf(buf) == 0) {
printf("seqnr: %u bytesused[0]: %u bytesused[1]: %u\n", buf.g_sequence(),
buf.g_bytesused(0), buf.g_bytesused(1));
fd.qbuf(buf);
if (cnt++ >= 60)
break;
}
q.free(&fd);
fd.close();
}

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/v4l2-compliance/cv4l-helpers.h
utils/v4l2-compliance/v4l-helpers.h
utils/v4l2-compliance/v4l2-compliance.cpp
utils/v4l2-compliance/v4l2-compliance.h
utils/v4l2-compliance/v4l2-test-buffers.cpp
utils/v4l2-compliance/v4l2-test-controls.cpp
utils/v4l2-compliance/v4l2-test-formats.cpp
utils/v4l2-compliance/v4l2-test-input-output.cpp
utils/v4l2-compliance/v4l2-test-io-config.cpp