[PATCH] tvtime: support drivers that always select a pixfmt in S_FMT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Drivers can either reject an unsupported pixelformat in VIDIOC_S_FMT,
or replace it with a supported one. Either option is allowed.

tvtime assumes that it is rejected, but instead it should check if it
chose something else, and then retry with UYVY.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
---
diff --git a/src/videoinput.c b/src/videoinput.c
index 5c147c8..12763dd 100644
--- a/src/videoinput.c
+++ b/src/videoinput.c
@@ -516,13 +516,19 @@ retry:
     memset( &(imgformat.fmt.pix), 0, sizeof( struct v4l2_pix_format ) );
     imgformat.fmt.pix.width = capwidth;
     imgformat.fmt.pix.height = vidin->height;
-    imgformat.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
     imgformat.fmt.pix.field = V4L2_FIELD_INTERLACED;
+    imgformat.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;

-    if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 ) {
+    if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 ||
+        imgformat.fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV ) {
 	/* Try for UYVY instead. */
+	memset( &(imgformat.fmt.pix), 0, sizeof( struct v4l2_pix_format ) );
+	imgformat.fmt.pix.width = capwidth;
+	imgformat.fmt.pix.height = vidin->height;
+	imgformat.fmt.pix.field = V4L2_FIELD_INTERLACED;
 	imgformat.fmt.pix.pixelformat = V4L2_PIX_FMT_UYVY;
-	if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 ) {
+	if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 ||
+	    imgformat.fmt.pix.pixelformat != V4L2_PIX_FMT_UYVY ) {

 	    fprintf( stderr, "\n"
      "    Your capture card driver: %s\n"



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux