diff options
author | Erik Andrén <erik.andren@gmail.com> | 2009-06-20 08:29:00 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:17:28 -0400 |
commit | 456ebe4e92063b92d2672da272bfc7ac70bd8bdd (patch) | |
tree | edc055d292ed06c123677d033cc5015f10889fa4 | |
parent | 36e64d5cec0a210d87e8e8c02566a1cbe24c00f3 (diff) |
V4L/DVB (12982): gspca - m5602-ov7660: Add auto gain ctrl
Signed-off-by: Erik Andrén <erik.andren@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_ov7660.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_ov7660.c b/drivers/media/video/gspca/m5602/m5602_ov7660.c index 7d2af089ee99..855c058d5df3 100644 --- a/drivers/media/video/gspca/m5602/m5602_ov7660.c +++ b/drivers/media/video/gspca/m5602/m5602_ov7660.c | |||
@@ -28,6 +28,8 @@ static int ov7660_get_auto_white_balance(struct gspca_dev *gspca_dev, | |||
28 | __s32 *val); | 28 | __s32 *val); |
29 | static int ov7660_set_auto_white_balance(struct gspca_dev *gspca_dev, | 29 | static int ov7660_set_auto_white_balance(struct gspca_dev *gspca_dev, |
30 | __s32 val); | 30 | __s32 val); |
31 | static int ov7660_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val); | ||
32 | static int ov7660_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val); | ||
31 | 33 | ||
32 | 34 | ||
33 | const static struct ctrl ov7660_ctrls[] = { | 35 | const static struct ctrl ov7660_ctrls[] = { |
@@ -90,7 +92,20 @@ const static struct ctrl ov7660_ctrls[] = { | |||
90 | .set = ov7660_set_auto_white_balance, | 92 | .set = ov7660_set_auto_white_balance, |
91 | .get = ov7660_get_auto_white_balance | 93 | .get = ov7660_get_auto_white_balance |
92 | }, | 94 | }, |
93 | 95 | #define AUTO_GAIN_CTRL_IDX 5 | |
96 | { | ||
97 | { | ||
98 | .id = V4L2_CID_AUTOGAIN, | ||
99 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
100 | .name = "auto gain control", | ||
101 | .minimum = 0, | ||
102 | .maximum = 1, | ||
103 | .step = 1, | ||
104 | .default_value = 1 | ||
105 | }, | ||
106 | .set = ov7660_set_auto_gain, | ||
107 | .get = ov7660_get_auto_gain | ||
108 | }, | ||
94 | }; | 109 | }; |
95 | 110 | ||
96 | static struct v4l2_pix_format ov7660_modes[] = { | 111 | static struct v4l2_pix_format ov7660_modes[] = { |
@@ -207,6 +222,11 @@ int ov7660_init(struct sd *sd) | |||
207 | if (err < 0) | 222 | if (err < 0) |
208 | return err; | 223 | return err; |
209 | 224 | ||
225 | err = ov7660_set_auto_gain(&sd->gspca_dev, | ||
226 | sensor_settings[AUTO_GAIN_CTRL_IDX]); | ||
227 | if (err < 0) | ||
228 | return err; | ||
229 | |||
210 | err = ov7660_set_blue_gain(&sd->gspca_dev, | 230 | err = ov7660_set_blue_gain(&sd->gspca_dev, |
211 | sensor_settings[BLUE_BALANCE_IDX]); | 231 | sensor_settings[BLUE_BALANCE_IDX]); |
212 | if (err < 0) | 232 | if (err < 0) |
@@ -342,6 +362,35 @@ static int ov7660_set_auto_white_balance(struct gspca_dev *gspca_dev, | |||
342 | return err; | 362 | return err; |
343 | } | 363 | } |
344 | 364 | ||
365 | static int ov7660_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val) | ||
366 | { | ||
367 | struct sd *sd = (struct sd *) gspca_dev; | ||
368 | s32 *sensor_settings = sd->sensor_priv; | ||
369 | |||
370 | *val = sensor_settings[AUTO_GAIN_CTRL_IDX]; | ||
371 | PDEBUG(D_V4L2, "Read auto gain control %d", *val); | ||
372 | return 0; | ||
373 | } | ||
374 | |||
375 | static int ov7660_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val) | ||
376 | { | ||
377 | int err; | ||
378 | u8 i2c_data; | ||
379 | struct sd *sd = (struct sd *) gspca_dev; | ||
380 | s32 *sensor_settings = sd->sensor_priv; | ||
381 | |||
382 | PDEBUG(D_V4L2, "Set auto gain control to %d", val); | ||
383 | |||
384 | sensor_settings[AUTO_GAIN_CTRL_IDX] = val; | ||
385 | err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1); | ||
386 | if (err < 0) | ||
387 | return err; | ||
388 | |||
389 | i2c_data = ((i2c_data & 0xfb) | ((val & 0x01) << 2)); | ||
390 | |||
391 | return m5602_write_sensor(sd, OV7660_COM8, &i2c_data, 1); | ||
392 | } | ||
393 | |||
345 | static void ov7660_dump_registers(struct sd *sd) | 394 | static void ov7660_dump_registers(struct sd *sd) |
346 | { | 395 | { |
347 | int address; | 396 | int address; |