aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca
diff options
context:
space:
mode:
authorErik Andr?n <erik.andren@gmail.com>2009-01-09 12:03:27 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 17:20:27 -0400
commitb154044a020072c031c7175d2711adc2c6049e93 (patch)
tree837af3bc5627eb0cf455b5c175b49e1fa7be46cd /drivers/media/video/gspca
parent320aaab872474e4b1c3c3d9807dfe304a7850681 (diff)
V4L/DVB (11470): gspca - m5602-mt9m111: Implement an auto white balancing control
Signed-off-by: Erik Andr?n <erik.andren@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r--drivers/media/video/gspca/m5602/m5602_mt9m111.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.c b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
index a057b8d5d748..37a7fc82a53c 100644
--- a/drivers/media/video/gspca/m5602/m5602_mt9m111.c
+++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
@@ -24,6 +24,11 @@ static int mt9m111_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
24static int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val); 24static int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
25static int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val); 25static int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
26static int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val); 26static int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val);
27static int mt9m111_set_auto_white_balance(struct gspca_dev *gspca_dev,
28 __s32 val);
29static int mt9m111_get_auto_white_balance(struct gspca_dev *gspca_dev,
30 __s32 *val);
31
27 32
28static struct v4l2_pix_format mt9m111_modes[] = { 33static struct v4l2_pix_format mt9m111_modes[] = {
29 { 34 {
@@ -81,6 +86,20 @@ const static struct ctrl mt9m111_ctrls[] = {
81 }, 86 },
82 .set = mt9m111_set_gain, 87 .set = mt9m111_set_gain,
83 .get = mt9m111_get_gain 88 .get = mt9m111_get_gain
89 },
90#define AUTO_WHITE_BALANCE_IDX 3
91 {
92 {
93 .id = V4L2_CID_AUTO_WHITE_BALANCE,
94 .type = V4L2_CTRL_TYPE_BOOLEAN,
95 .name = "auto white balance",
96 .minimum = 0,
97 .maximum = 1,
98 .step = 1,
99 .default_value = 0,
100 },
101 .set = mt9m111_set_auto_white_balance,
102 .get = mt9m111_get_auto_white_balance
84 } 103 }
85}; 104};
86 105
@@ -273,6 +292,37 @@ static int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
273 return 0; 292 return 0;
274} 293}
275 294
295static int mt9m111_set_auto_white_balance(struct gspca_dev *gspca_dev,
296 __s32 val)
297{
298 struct sd *sd = (struct sd *) gspca_dev;
299 s32 *sensor_settings = sd->sensor_priv;
300 int err;
301 u8 data[2];
302
303 err = m5602_read_sensor(sd, MT9M111_CP_OPERATING_MODE_CTL, data, 2);
304 if (err < 0)
305 return err;
306
307 sensor_settings[AUTO_WHITE_BALANCE_IDX] = val & 0x01;
308 data[0] = ((data[0] & 0xfd) | ((val & 0x01) << 1));
309
310 err = m5602_write_sensor(sd, MT9M111_CP_OPERATING_MODE_CTL, data, 2);
311
312 PDEBUG(D_V4L2, "Set auto white balance %d", val);
313 return err;
314}
315
316static int mt9m111_get_auto_white_balance(struct gspca_dev *gspca_dev,
317 __s32 *val) {
318 struct sd *sd = (struct sd *) gspca_dev;
319 s32 *sensor_settings = sd->sensor_priv;
320
321 *val = sensor_settings[AUTO_WHITE_BALANCE_IDX];
322 PDEBUG(D_V4L2, "Read auto white balance %d", *val);
323 return 0;
324}
325
276static int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val) 326static int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val)
277{ 327{
278 int err, tmp; 328 int err, tmp;