diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2011-06-07 05:34:41 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-27 16:53:19 -0400 |
commit | a1c894fba3c306a738576710ca35e70a32b74a6d (patch) | |
tree | b6338fd005e7d38a2f347f481f7e2d5c04a6f505 | |
parent | c76cd635726beb3e1c73bbc4dc87e0cda48ac006 (diff) |
[media] vivi: add autogain/gain support to test the autocluster functionality
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/vivi.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 3b9db8cbe41c..2f0a1b40dd29 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -163,6 +163,11 @@ struct vivi_dev { | |||
163 | struct v4l2_ctrl *contrast; | 163 | struct v4l2_ctrl *contrast; |
164 | struct v4l2_ctrl *saturation; | 164 | struct v4l2_ctrl *saturation; |
165 | struct v4l2_ctrl *hue; | 165 | struct v4l2_ctrl *hue; |
166 | struct { | ||
167 | /* autogain/gain cluster */ | ||
168 | struct v4l2_ctrl *autogain; | ||
169 | struct v4l2_ctrl *gain; | ||
170 | }; | ||
166 | struct v4l2_ctrl *volume; | 171 | struct v4l2_ctrl *volume; |
167 | struct v4l2_ctrl *button; | 172 | struct v4l2_ctrl *button; |
168 | struct v4l2_ctrl *boolean; | 173 | struct v4l2_ctrl *boolean; |
@@ -453,6 +458,7 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) | |||
453 | unsigned ms; | 458 | unsigned ms; |
454 | char str[100]; | 459 | char str[100]; |
455 | int h, line = 1; | 460 | int h, line = 1; |
461 | s32 gain; | ||
456 | 462 | ||
457 | if (!vbuf) | 463 | if (!vbuf) |
458 | return; | 464 | return; |
@@ -475,6 +481,7 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) | |||
475 | dev->width, dev->height, dev->input); | 481 | dev->width, dev->height, dev->input); |
476 | gen_text(dev, vbuf, line++ * 16, 16, str); | 482 | gen_text(dev, vbuf, line++ * 16, 16, str); |
477 | 483 | ||
484 | gain = v4l2_ctrl_g_ctrl(dev->gain); | ||
478 | mutex_lock(&dev->ctrl_handler.lock); | 485 | mutex_lock(&dev->ctrl_handler.lock); |
479 | snprintf(str, sizeof(str), " brightness %3d, contrast %3d, saturation %3d, hue %d ", | 486 | snprintf(str, sizeof(str), " brightness %3d, contrast %3d, saturation %3d, hue %d ", |
480 | dev->brightness->cur.val, | 487 | dev->brightness->cur.val, |
@@ -482,7 +489,8 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) | |||
482 | dev->saturation->cur.val, | 489 | dev->saturation->cur.val, |
483 | dev->hue->cur.val); | 490 | dev->hue->cur.val); |
484 | gen_text(dev, vbuf, line++ * 16, 16, str); | 491 | gen_text(dev, vbuf, line++ * 16, 16, str); |
485 | snprintf(str, sizeof(str), " volume %3d ", dev->volume->cur.val); | 492 | snprintf(str, sizeof(str), " autogain %d, gain %3d, volume %3d ", |
493 | dev->autogain->cur.val, gain, dev->volume->cur.val); | ||
486 | gen_text(dev, vbuf, line++ * 16, 16, str); | 494 | gen_text(dev, vbuf, line++ * 16, 16, str); |
487 | snprintf(str, sizeof(str), " int32 %d, int64 %lld ", | 495 | snprintf(str, sizeof(str), " int32 %d, int64 %lld ", |
488 | dev->int32->cur.val, | 496 | dev->int32->cur.val, |
@@ -978,6 +986,15 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) | |||
978 | 986 | ||
979 | /* --- controls ---------------------------------------------- */ | 987 | /* --- controls ---------------------------------------------- */ |
980 | 988 | ||
989 | static int vivi_g_volatile_ctrl(struct v4l2_ctrl *ctrl) | ||
990 | { | ||
991 | struct vivi_dev *dev = container_of(ctrl->handler, struct vivi_dev, ctrl_handler); | ||
992 | |||
993 | if (ctrl == dev->autogain) | ||
994 | dev->gain->val = jiffies & 0xff; | ||
995 | return 0; | ||
996 | } | ||
997 | |||
981 | static int vivi_s_ctrl(struct v4l2_ctrl *ctrl) | 998 | static int vivi_s_ctrl(struct v4l2_ctrl *ctrl) |
982 | { | 999 | { |
983 | struct vivi_dev *dev = container_of(ctrl->handler, struct vivi_dev, ctrl_handler); | 1000 | struct vivi_dev *dev = container_of(ctrl->handler, struct vivi_dev, ctrl_handler); |
@@ -1040,6 +1057,7 @@ static int vivi_mmap(struct file *file, struct vm_area_struct *vma) | |||
1040 | } | 1057 | } |
1041 | 1058 | ||
1042 | static const struct v4l2_ctrl_ops vivi_ctrl_ops = { | 1059 | static const struct v4l2_ctrl_ops vivi_ctrl_ops = { |
1060 | .g_volatile_ctrl = vivi_g_volatile_ctrl, | ||
1043 | .s_ctrl = vivi_s_ctrl, | 1061 | .s_ctrl = vivi_s_ctrl, |
1044 | }; | 1062 | }; |
1045 | 1063 | ||
@@ -1208,6 +1226,10 @@ static int __init vivi_create_instance(int inst) | |||
1208 | V4L2_CID_SATURATION, 0, 255, 1, 127); | 1226 | V4L2_CID_SATURATION, 0, 255, 1, 127); |
1209 | dev->hue = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops, | 1227 | dev->hue = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops, |
1210 | V4L2_CID_HUE, -128, 127, 1, 0); | 1228 | V4L2_CID_HUE, -128, 127, 1, 0); |
1229 | dev->autogain = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops, | ||
1230 | V4L2_CID_AUTOGAIN, 0, 1, 1, 1); | ||
1231 | dev->gain = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops, | ||
1232 | V4L2_CID_GAIN, 0, 255, 1, 100); | ||
1211 | dev->button = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_button, NULL); | 1233 | dev->button = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_button, NULL); |
1212 | dev->int32 = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_int32, NULL); | 1234 | dev->int32 = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_int32, NULL); |
1213 | dev->int64 = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_int64, NULL); | 1235 | dev->int64 = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_int64, NULL); |
@@ -1218,6 +1240,7 @@ static int __init vivi_create_instance(int inst) | |||
1218 | ret = hdl->error; | 1240 | ret = hdl->error; |
1219 | goto unreg_dev; | 1241 | goto unreg_dev; |
1220 | } | 1242 | } |
1243 | v4l2_ctrl_auto_cluster(2, &dev->autogain, 0, true); | ||
1221 | dev->v4l2_dev.ctrl_handler = hdl; | 1244 | dev->v4l2_dev.ctrl_handler = hdl; |
1222 | 1245 | ||
1223 | /* initialize locks */ | 1246 | /* initialize locks */ |