aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mt9m111.c
diff options
context:
space:
mode:
authorRobert Jarzmik <robert.jarzmik@free.fr>2008-12-18 09:29:05 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:40:18 -0500
commit39bf372f606448de2df93a90f40efc613cb5c909 (patch)
treedea2dc72b87cfe5cfa26199364da5c1941b085d5 /drivers/media/video/mt9m111.c
parentbd73b36f0c41b0c02ef4b10a307db1c43537e006 (diff)
V4L/DVB (10073): mt9m111: Add automatic white balance control
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mt9m111.c')
-rw-r--r--drivers/media/video/mt9m111.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c
index b0e6046ea967..2ab1e0f4925d 100644
--- a/drivers/media/video/mt9m111.c
+++ b/drivers/media/video/mt9m111.c
@@ -90,7 +90,7 @@
90#define MT9M111_OUTPUT_FORMAT_CTRL2_B 0x19b 90#define MT9M111_OUTPUT_FORMAT_CTRL2_B 0x19b
91 91
92#define MT9M111_OPMODE_AUTOEXPO_EN (1 << 14) 92#define MT9M111_OPMODE_AUTOEXPO_EN (1 << 14)
93 93#define MT9M111_OPMODE_AUTOWHITEBAL_EN (1 << 1)
94 94
95#define MT9M111_OUTFMT_PROCESSED_BAYER (1 << 14) 95#define MT9M111_OUTFMT_PROCESSED_BAYER (1 << 14)
96#define MT9M111_OUTFMT_BYPASS_IFP (1 << 10) 96#define MT9M111_OUTFMT_BYPASS_IFP (1 << 10)
@@ -163,6 +163,7 @@ struct mt9m111 {
163 unsigned int swap_rgb_red_blue:1; 163 unsigned int swap_rgb_red_blue:1;
164 unsigned int swap_yuv_y_chromas:1; 164 unsigned int swap_yuv_y_chromas:1;
165 unsigned int swap_yuv_cb_cr:1; 165 unsigned int swap_yuv_cb_cr:1;
166 unsigned int autowhitebalance:1;
166}; 167};
167 168
168static int reg_page_map_set(struct i2c_client *client, const u16 reg) 169static int reg_page_map_set(struct i2c_client *client, const u16 reg)
@@ -702,6 +703,23 @@ static int mt9m111_set_autoexposure(struct soc_camera_device *icd, int on)
702 703
703 return ret; 704 return ret;
704} 705}
706
707static int mt9m111_set_autowhitebalance(struct soc_camera_device *icd, int on)
708{
709 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
710 int ret;
711
712 if (on)
713 ret = reg_set(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOWHITEBAL_EN);
714 else
715 ret = reg_clear(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOWHITEBAL_EN);
716
717 if (!ret)
718 mt9m111->autowhitebalance = on;
719
720 return ret;
721}
722
705static int mt9m111_get_control(struct soc_camera_device *icd, 723static int mt9m111_get_control(struct soc_camera_device *icd,
706 struct v4l2_control *ctrl) 724 struct v4l2_control *ctrl)
707{ 725{
@@ -738,6 +756,9 @@ static int mt9m111_get_control(struct soc_camera_device *icd,
738 case V4L2_CID_EXPOSURE_AUTO: 756 case V4L2_CID_EXPOSURE_AUTO:
739 ctrl->value = mt9m111->autoexposure; 757 ctrl->value = mt9m111->autoexposure;
740 break; 758 break;
759 case V4L2_CID_AUTO_WHITE_BALANCE:
760 ctrl->value = mt9m111->autowhitebalance;
761 break;
741 } 762 }
742 return 0; 763 return 0;
743} 764}
@@ -771,6 +792,9 @@ static int mt9m111_set_control(struct soc_camera_device *icd,
771 case V4L2_CID_EXPOSURE_AUTO: 792 case V4L2_CID_EXPOSURE_AUTO:
772 ret = mt9m111_set_autoexposure(icd, ctrl->value); 793 ret = mt9m111_set_autoexposure(icd, ctrl->value);
773 break; 794 break;
795 case V4L2_CID_AUTO_WHITE_BALANCE:
796 ret = mt9m111_set_autowhitebalance(icd, ctrl->value);
797 break;
774 default: 798 default:
775 ret = -EINVAL; 799 ret = -EINVAL;
776 } 800 }
@@ -789,6 +813,7 @@ static int mt9m111_restore_state(struct soc_camera_device *icd)
789 mt9m111_set_flip(icd, mt9m111->vflip, MT9M111_RMB_MIRROR_ROWS); 813 mt9m111_set_flip(icd, mt9m111->vflip, MT9M111_RMB_MIRROR_ROWS);
790 mt9m111_set_global_gain(icd, icd->gain); 814 mt9m111_set_global_gain(icd, icd->gain);
791 mt9m111_set_autoexposure(icd, mt9m111->autoexposure); 815 mt9m111_set_autoexposure(icd, mt9m111->autoexposure);
816 mt9m111_set_autowhitebalance(icd, mt9m111->autowhitebalance);
792 return 0; 817 return 0;
793} 818}
794 819
@@ -883,6 +908,7 @@ static int mt9m111_video_probe(struct soc_camera_device *icd)
883 goto eisis; 908 goto eisis;
884 909
885 mt9m111->autoexposure = 1; 910 mt9m111->autoexposure = 1;
911 mt9m111->autowhitebalance = 1;
886 912
887 mt9m111->swap_rgb_even_odd = 1; 913 mt9m111->swap_rgb_even_odd = 1;
888 mt9m111->swap_rgb_red_blue = 1; 914 mt9m111->swap_rgb_red_blue = 1;