[MPlayer-cvslog] r24573 - in trunk: DOCS/man/en/mplayer.1 cfg-common.h stream/stream_tv.c stream/tv.c stream/tv.h stream/tvi_v4l2.c

voroshil subversion at mplayerhq.hu
Tue Sep 18 18:28:40 CEST 2007


Author: voroshil
Date: Tue Sep 18 18:28:39 2007
New Revision: 24573

Log:
Implement setting gain control for video devices (usually webcams)
in v4l2 tv:// driver.


Modified:
   trunk/cfg-common.h
   trunk/stream/stream_tv.c
   trunk/stream/tv.c
   trunk/stream/tv.h
   trunk/stream/tvi_v4l2.c

Changes in other areas also in this revision:
Modified:
   trunk/DOCS/man/en/mplayer.1

Modified: trunk/cfg-common.h
==============================================================================
--- trunk/cfg-common.h	(original)
+++ trunk/cfg-common.h	Tue Sep 18 18:28:39 2007
@@ -436,6 +436,7 @@ m_option_t tvopts_conf[]={
 	{"contrast", &stream_tv_defaults.contrast, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
 	{"hue", &stream_tv_defaults.hue, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
 	{"saturation", &stream_tv_defaults.saturation, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
+	{"gain", &stream_tv_defaults.gain, CONF_TYPE_INT, CONF_RANGE, -1, 100, NULL},
 #if defined(HAVE_TV_V4L) || defined(HAVE_TV_V4L2)
 	{"amode", &stream_tv_defaults.amode, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
 	{"volume", &stream_tv_defaults.volume, CONF_TYPE_INT, CONF_RANGE, 0, 65535, NULL},

Modified: trunk/stream/stream_tv.c
==============================================================================
--- trunk/stream/stream_tv.c	(original)
+++ trunk/stream/stream_tv.c	Tue Sep 18 18:28:39 2007
@@ -72,6 +72,7 @@ tv_param_t stream_tv_defaults = {
     0,             //contrast
     0,             //hue
     0,             //saturation
+    -1,            //gain
     NULL,          //tdevice
     0,             //tformat
     100,           //tpage

Modified: trunk/stream/tv.c
==============================================================================
--- trunk/stream/tv.c	(original)
+++ trunk/stream/tv.c	Tue Sep 18 18:28:39 2007
@@ -759,6 +759,10 @@ no_audio:
     tv_set_color_options(tvh, TV_COLOR_SATURATION, tvh->tv_param->saturation);
     tv_set_color_options(tvh, TV_COLOR_CONTRAST, tvh->tv_param->contrast);
 
+    if(tvh->tv_param->gain!=-1)
+        if(funcs->control(tvh->priv,TVI_CONTROL_VID_SET_GAIN,&tvh->tv_param->gain)!=TVI_CONTROL_TRUE)
+            mp_msg(MSGT_TV,MSGL_WARN,"Unable to set gain control!\n");
+
     funcs->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);
 
     return demuxer;

Modified: trunk/stream/tv.h
==============================================================================
--- trunk/stream/tv.h	(original)
+++ trunk/stream/tv.h	Tue Sep 18 18:28:39 2007
@@ -47,6 +47,7 @@ typedef struct tv_param_s {
     int contrast;
     int hue;
     int saturation;
+    int gain;
     char *tdevice;  ///< teletext device
     int tformat;    ///< teletext display format
     int tpage;      ///< start teletext page
@@ -151,6 +152,8 @@ typedef struct {
 #define TVI_CONTROL_VID_SET_CONTRAST	0x11c
 #define TVI_CONTROL_VID_GET_PICTURE	0x11d
 #define TVI_CONTROL_VID_SET_PICTURE	0x11e
+#define TVI_CONTROL_VID_SET_GAIN	0x11f
+#define TVI_CONTROL_VID_GET_GAIN	0x120
 
 /* TUNER controls */
 #define TVI_CONTROL_TUN_GET_FREQ	0x201

Modified: trunk/stream/tvi_v4l2.c
==============================================================================
--- trunk/stream/tvi_v4l2.c	(original)
+++ trunk/stream/tvi_v4l2.c	Tue Sep 18 18:28:39 2007
@@ -478,7 +478,6 @@ static int set_mute(priv_t *priv, int va
 */
 static int set_control(priv_t *priv, struct v4l2_control *control, int val_signed) {
     struct v4l2_queryctrl        qctrl;
-
     qctrl.id = control->id;
     if (ioctl(priv->video_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
         mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query control failed: %s\n",
@@ -806,6 +805,40 @@ static int control(priv_t *priv, int cmd
             control.id = V4L2_CID_SATURATION;
             control.value = *(int *)arg;
             return set_control(priv, &control, 1);
+        case TVI_CONTROL_VID_GET_GAIN:
+        {
+
+            control.id = V4L2_CID_AUTOGAIN;
+            if(get_control(priv,&control,0)!=TVI_CONTROL_TRUE)
+                return TVI_CONTROL_FALSE;
+
+            if(control.value){ //Auto Gain control is enabled
+                *(int*)arg=0;
+                return TVI_CONTROL_TRUE;
+            }
+
+            //Manual Gain control
+            control.id = V4L2_CID_GAIN;
+            if(get_control(priv,&control,0)!=TVI_CONTROL_TRUE)
+                return TVI_CONTROL_FALSE;
+
+            *(int*)arg=control.value?control.value:1;
+
+            return TVI_CONTROL_TRUE;
+        }
+        case TVI_CONTROL_VID_SET_GAIN:
+        {
+            //value==0 means automatic gain control
+	    int value=*(int*)arg;
+
+            if (value < 0 || value>100)
+                return TVI_CONTROL_FALSE;
+
+            control.id=value?V4L2_CID_GAIN:V4L2_CID_AUTOGAIN;
+            control.value=value?value:1;
+
+            return set_control(priv,&control,0);
+        }
         case TVI_CONTROL_VID_GET_CONTRAST:
             control.id = V4L2_CID_CONTRAST;
             if (get_control(priv, &control, 1) == TVI_CONTROL_TRUE) {



More information about the MPlayer-cvslog mailing list