changeset 28940:7406e7f30d4e

Add TVI_CONTROL_VID_SET_WIDTH_HEIGHT to set width and height together for v4l2, otherwise some drivers will always stay stuck in the lowest resolution.
author reimar
date Mon, 16 Mar 2009 17:12:29 +0000
parents cbf56e4c9662
children a038ab949e7e
files stream/tv.c stream/tv.h stream/tvi_v4l2.c
diffstat 3 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/stream/tv.c	Mon Mar 16 14:25:03 2009 +0000
+++ b/stream/tv.c	Mon Mar 16 17:12:29 2009 +0000
@@ -439,6 +439,12 @@
 #endif
 
     /* limits on w&h are norm-dependent -- JM */
+    if (tvh->tv_param->width != -1 && tvh->tv_param->height != -1) {
+        // first tell the driver both width and height, some drivers do not support setting them independently.
+        int dim[2];
+        dim[0] = tvh->tv_param->width; dim[1] = tvh->tv_param->height;
+        funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH_HEIGHT, dim);
+    }
     /* set width */
     if (tvh->tv_param->width != -1)
     {
--- a/stream/tv.h	Mon Mar 16 14:25:03 2009 +0000
+++ b/stream/tv.h	Mon Mar 16 17:12:29 2009 +0000
@@ -175,6 +175,7 @@
 #define TVI_CONTROL_VID_SET_PICTURE	0x11e
 #define TVI_CONTROL_VID_SET_GAIN	0x11f
 #define TVI_CONTROL_VID_GET_GAIN	0x120
+#define TVI_CONTROL_VID_SET_WIDTH_HEIGHT	0x121
 
 /* TUNER controls */
 #define TVI_CONTROL_TUN_GET_FREQ	0x201
--- a/stream/tvi_v4l2.c	Mon Mar 16 14:25:03 2009 +0000
+++ b/stream/tvi_v4l2.c	Mon Mar 16 17:12:29 2009 +0000
@@ -780,6 +780,14 @@
         return TVI_CONTROL_TRUE;
     case TVI_CONTROL_VID_CHK_WIDTH:
         return TVI_CONTROL_TRUE;
+    case TVI_CONTROL_VID_SET_WIDTH_HEIGHT:
+        if (getfmt(priv) < 0) return TVI_CONTROL_FALSE;
+        priv->format.fmt.pix.width = ((int *)arg)[0];
+        priv->format.fmt.pix.height = ((int *)arg)[1];
+        priv->format.fmt.pix.field = V4L2_FIELD_ANY;
+        if (ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0)
+            return TVI_CONTROL_FALSE;
+        return TVI_CONTROL_TRUE;
     case TVI_CONTROL_VID_SET_WIDTH:
         if (getfmt(priv) < 0) return TVI_CONTROL_FALSE;
         priv->format.fmt.pix.width = *(int *)arg;