[MPlayer-dev-eng] [PATCH] Fix V4L2 buffer operations and tunerhandling

Laurent Pinchart laurent.pinchart at skynet.be
Wed Dec 6 13:23:31 CET 2006


> >>>this patch fixes problems with video acquisition through the V4L2 API.
> >>>Two separate issues are addressed, which prevented MPlayer from working
> >>>with UVC
> >>>(USB Video Class) devices.
> >>>
> >>>- Many V4L2 devices (mostly webcams) have no tuner. For those devices
> >>> the concept of norm just doesn't apply. VIDIOC_G_STD should not be
> >>> called for those tuner-less devices.
> >>>
> >>>- The buffer management (using VIDIOC_QBUF, VIDIOC_DQBUF and
> >>>VIDIOC_REQBUFS)
> >>>code doesn't set the buffer memory type to V4L2_MEMORY_MMAP. While many
> >>>drivers fails to check the parameter, it is nonetheless mandatory to set
> >>>it
> >>>to the correct value.
> >>
> >>The patch looks good to me but please resend without the cosmetic
> >> changes. All of the patch isn't needed.
> >
> >Cosmetic changes have been removed, as well as the VIDIOC_G_STD changes.
> > I'm working on a better fix for the last one (division by zero when
> > VIDIOC_G_STD fails come to mind).
> >
> >Please apply the buffer management patch. The VIDIOC_G_STD issue only
> > affects mencoder, so this patch is useful on its own for mplayer.
> >
> >------------------------------------------------------------------------
> >
> >--- stream/tvi_v4l2.c	2006-12-06 10:12:01.000000000 +0100
> >+++ stream/tvi_v4l2.c	2006-12-06 10:13:30.000000000 +0100
> >@@ -875,7 +875,8 @@
> >
> > 	/* unqueue all remaining buffers */
> > 	memset(&buf,0,sizeof(buf));
> >-	buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> >+	buf.type   = V4L2_BUF_TYPE_VIDEO_CAPTURE;
>
> cosmetics
>
> >+	buf.memory = V4L2_MEMORY_MMAP;
> > 	while (!ioctl(priv->video_fd, VIDIOC_DQBUF, &buf));
> >     }
> >
> >@@ -1250,7 +1251,7 @@
> > 	request.count = BUFFER_COUNT;
> >     }
> >
> >-    request.type  = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> >+    request.type   = V4L2_BUF_TYPE_VIDEO_CAPTURE;
>
> cosmetics
>
> >     request.memory = V4L2_MEMORY_MMAP;
> >     if (ioctl(priv->video_fd, VIDIOC_REQBUFS, &request) < 0) {
> > 	mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl request buffers failed: %s\n",
> >@@ -1290,6 +1291,7 @@
> > 	/* count up to make sure this is correct everytime */
> > 	priv->mapcount++;
> >
> >+	priv->map[i].buf.memory = V4L2_MEMORY_MMAP;
> > 	if (ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) {
> > 	    mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl queue buffer failed: %s\n",
> > 		   info.short_name, strerror(errno));
> >@@ -1394,7 +1396,8 @@
> > 	}
> >
> > 	memset(&buf,0,sizeof(buf));
> >-	buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> >+	buf.type   = V4L2_BUF_TYPE_VIDEO_CAPTURE;
>
> cosmetics

This one should do.

Laurent Pinchart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tvi_v4l2.buffer.patch
Type: text/x-diff
Size: 1607 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20061206/b94ce2cd/attachment.patch>


More information about the MPlayer-dev-eng mailing list