aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-08-25 10:44:14 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-18 23:18:38 -0400
commita813d01f823259d1b27668c2149785515843a7eb (patch)
tree42c823775525880849338730e50aaba6f584fd45 /drivers
parent3418f165cc1cbcb30a8c017d7ebbc774710066bb (diff)
V4L/DVB (12512): ov772x: implement a band-stop filter support
The V4L2_CID_BAND_STOP_FILTER control is used to switch the "Banding Filter" on OV772x cameras on and off and to set the minimum AEC value in BDBASE register. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/ov772x.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c
index 119159773a68..4c550f91ca24 100644
--- a/drivers/media/video/ov772x.c
+++ b/drivers/media/video/ov772x.c
@@ -403,8 +403,9 @@ struct ov772x_priv {
403 const struct ov772x_color_format *fmt; 403 const struct ov772x_color_format *fmt;
404 const struct ov772x_win_size *win; 404 const struct ov772x_win_size *win;
405 int model; 405 int model;
406 unsigned int flag_vflip:1; 406 unsigned short flag_vflip:1;
407 unsigned int flag_hflip:1; 407 unsigned short flag_hflip:1;
408 unsigned short band_filter; /* 256 - BDBASE, 0 if (!COM8[5]) */
408}; 409};
409 410
410#define ENDMARKER { 0xff, 0xff } 411#define ENDMARKER { 0xff, 0xff }
@@ -569,6 +570,15 @@ static const struct v4l2_queryctrl ov772x_controls[] = {
569 .step = 1, 570 .step = 1,
570 .default_value = 0, 571 .default_value = 0,
571 }, 572 },
573 {
574 .id = V4L2_CID_BAND_STOP_FILTER,
575 .type = V4L2_CTRL_TYPE_INTEGER,
576 .name = "Band-stop filter",
577 .minimum = 0,
578 .maximum = 256,
579 .step = 1,
580 .default_value = 0,
581 },
572}; 582};
573 583
574 584
@@ -674,6 +684,9 @@ static int ov772x_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
674 case V4L2_CID_HFLIP: 684 case V4L2_CID_HFLIP:
675 ctrl->value = priv->flag_hflip; 685 ctrl->value = priv->flag_hflip;
676 break; 686 break;
687 case V4L2_CID_BAND_STOP_FILTER:
688 ctrl->value = priv->band_filter;
689 break;
677 } 690 }
678 return 0; 691 return 0;
679} 692}
@@ -700,6 +713,29 @@ static int ov772x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
700 val ^= HFLIP_IMG; 713 val ^= HFLIP_IMG;
701 ret = ov772x_mask_set(client, COM3, HFLIP_IMG, val); 714 ret = ov772x_mask_set(client, COM3, HFLIP_IMG, val);
702 break; 715 break;
716 case V4L2_CID_BAND_STOP_FILTER:
717 if ((unsigned)ctrl->value > 256)
718 ctrl->value = 256;
719 if (ctrl->value == priv->band_filter)
720 break;
721 if (!ctrl->value) {
722 /* Switch the filter off, it is on now */
723 ret = ov772x_mask_set(client, BDBASE, 0xff, 0xff);
724 if (!ret)
725 ret = ov772x_mask_set(client, COM8,
726 BNDF_ON_OFF, 0);
727 } else {
728 /* Switch the filter on, set AEC low limit */
729 val = 256 - ctrl->value;
730 ret = ov772x_mask_set(client, COM8,
731 BNDF_ON_OFF, BNDF_ON_OFF);
732 if (!ret)
733 ret = ov772x_mask_set(client, BDBASE,
734 0xff, val);
735 }
736 if (!ret)
737 priv->band_filter = ctrl->value;
738 break;
703 } 739 }
704 740
705 return ret; 741 return ret;
@@ -893,6 +929,18 @@ static int ov772x_set_params(struct i2c_client *client,
893 if (ret < 0) 929 if (ret < 0)
894 goto ov772x_set_fmt_error; 930 goto ov772x_set_fmt_error;
895 931
932 /*
933 * set COM8
934 */
935 if (priv->band_filter) {
936 ret = ov772x_mask_set(client, COM8, BNDF_ON_OFF, 1);
937 if (!ret)
938 ret = ov772x_mask_set(client, BDBASE,
939 0xff, 256 - priv->band_filter);
940 if (ret < 0)
941 goto ov772x_set_fmt_error;
942 }
943
896 return ret; 944 return ret;
897 945
898ov772x_set_fmt_error: 946ov772x_set_fmt_error: