summaryrefslogtreecommitdiffstats
path: root/stream/tvi_v4l2.c
diff options
context:
space:
mode:
authorvoroshil <voroshil@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-09-18 16:28:39 +0000
committervoroshil <voroshil@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-09-18 16:28:39 +0000
commitfdb78c2bea9e2e3bb2b5e01c6c3564dadbf83aba (patch)
tree57cd668f17b6558892f2febd8a95b0fdc4afb53c /stream/tvi_v4l2.c
parent04586de1ddc3ddbb52165b97c2262b65c9e41813 (diff)
downloadmpv-fdb78c2bea9e2e3bb2b5e01c6c3564dadbf83aba.tar.bz2
mpv-fdb78c2bea9e2e3bb2b5e01c6c3564dadbf83aba.tar.xz
Implement setting gain control for video devices (usually webcams)
in v4l2 tv:// driver. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24573 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream/tvi_v4l2.c')
-rw-r--r--stream/tvi_v4l2.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c
index d0d58cbd38..e049d940dd 100644
--- a/stream/tvi_v4l2.c
+++ b/stream/tvi_v4l2.c
@@ -478,7 +478,6 @@ static int set_mute(priv_t *priv, int value)
*/
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, void *arg)
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) {