video(1) supports reading frames from a webcam via mmap(). To inform the
V4L2 device about the number of desired buffers containing the frames to
be memory-mapped, a VIDIOC_REQBUFS ioctl call is used.

At the moment the v4l2_requestbuffers struct used for the VIDIOC_REQBUFS ioctl
is only partially initialized which leads to an invalid mmap for my webcam:

video: mmap: Invalid argument

With the following diff applied my camera works (only on EHCI ports with USB
3.0 disabled in BIOS but that is a different story).

OK?

Index: video.c
===================================================================
RCS file: /cvs/xenocara/app/video/video.c,v
retrieving revision 1.29
diff -u -p -r1.29 video.c
--- video.c     6 Nov 2019 05:46:51 -0000       1.29
+++ video.c     26 May 2020 09:14:39 -0000
@@ -1354,6 +1354,8 @@ mmap_init(struct video *vid)
 
        /* request buffers */
        rb.count = MMAP_NUM_BUFS;
+       rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+       rb.memory = V4L2_MEMORY_MMAP;
        r = ioctl(vid->dev.fd, VIDIOC_REQBUFS, &rb);
        if (r == -1) {
                warn("ioctl VIDIOC_REQBUFS");

Reply via email to