diff options
author | Erik Andrén <erik.andren@gmail.com> | 2009-06-20 12:58:41 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:17:38 -0400 |
commit | 7c7ddf1638a45923ab053d1f7818c6d123148b4b (patch) | |
tree | 4c3987e1d91f734f8c3591d4b254e717ca425e23 /drivers/media/video/gspca | |
parent | 456ebe4e92063b92d2672da272bfc7ac70bd8bdd (diff) |
V4L/DVB (12983): gspca - m5602-ov7660: Add auto exposure ctrl
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_ov7660.c | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_ov7660.c b/drivers/media/video/gspca/m5602/m5602_ov7660.c index 855c058d5df3..80c64caac353 100644 --- a/drivers/media/video/gspca/m5602/m5602_ov7660.c +++ b/drivers/media/video/gspca/m5602/m5602_ov7660.c | |||
@@ -30,7 +30,8 @@ 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); | 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); | 32 | static int ov7660_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val); |
33 | 33 | static int ov7660_get_auto_exposure(struct gspca_dev *gspca_dev, __s32 *val); | |
34 | static int ov7660_set_auto_exposure(struct gspca_dev *gspca_dev, __s32 val); | ||
34 | 35 | ||
35 | const static struct ctrl ov7660_ctrls[] = { | 36 | const static struct ctrl ov7660_ctrls[] = { |
36 | #define GAIN_IDX 1 | 37 | #define GAIN_IDX 1 |
@@ -106,6 +107,20 @@ const static struct ctrl ov7660_ctrls[] = { | |||
106 | .set = ov7660_set_auto_gain, | 107 | .set = ov7660_set_auto_gain, |
107 | .get = ov7660_get_auto_gain | 108 | .get = ov7660_get_auto_gain |
108 | }, | 109 | }, |
110 | #define AUTO_EXPOSURE_IDX 6 | ||
111 | { | ||
112 | { | ||
113 | .id = V4L2_CID_EXPOSURE_AUTO, | ||
114 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
115 | .name = "auto exposure", | ||
116 | .minimum = 0, | ||
117 | .maximum = 1, | ||
118 | .step = 1, | ||
119 | .default_value = 1 | ||
120 | }, | ||
121 | .set = ov7660_set_auto_exposure, | ||
122 | .get = ov7660_get_auto_exposure | ||
123 | } | ||
109 | }; | 124 | }; |
110 | 125 | ||
111 | static struct v4l2_pix_format ov7660_modes[] = { | 126 | static struct v4l2_pix_format ov7660_modes[] = { |
@@ -227,6 +242,11 @@ int ov7660_init(struct sd *sd) | |||
227 | if (err < 0) | 242 | if (err < 0) |
228 | return err; | 243 | return err; |
229 | 244 | ||
245 | err = ov7660_set_auto_exposure(&sd->gspca_dev, | ||
246 | sensor_settings[AUTO_EXPOSURE_IDX]); | ||
247 | if (err < 0) | ||
248 | return err; | ||
249 | |||
230 | err = ov7660_set_blue_gain(&sd->gspca_dev, | 250 | err = ov7660_set_blue_gain(&sd->gspca_dev, |
231 | sensor_settings[BLUE_BALANCE_IDX]); | 251 | sensor_settings[BLUE_BALANCE_IDX]); |
232 | if (err < 0) | 252 | if (err < 0) |
@@ -391,6 +411,36 @@ static int ov7660_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
391 | return m5602_write_sensor(sd, OV7660_COM8, &i2c_data, 1); | 411 | return m5602_write_sensor(sd, OV7660_COM8, &i2c_data, 1); |
392 | } | 412 | } |
393 | 413 | ||
414 | static int ov7660_get_auto_exposure(struct gspca_dev *gspca_dev, __s32 *val) | ||
415 | { | ||
416 | struct sd *sd = (struct sd *) gspca_dev; | ||
417 | s32 *sensor_settings = sd->sensor_priv; | ||
418 | |||
419 | *val = sensor_settings[AUTO_EXPOSURE_IDX]; | ||
420 | PDEBUG(D_V4L2, "Read auto exposure control %d", *val); | ||
421 | return 0; | ||
422 | } | ||
423 | |||
424 | static int ov7660_set_auto_exposure(struct gspca_dev *gspca_dev, | ||
425 | __s32 val) | ||
426 | { | ||
427 | int err; | ||
428 | u8 i2c_data; | ||
429 | struct sd *sd = (struct sd *) gspca_dev; | ||
430 | s32 *sensor_settings = sd->sensor_priv; | ||
431 | |||
432 | PDEBUG(D_V4L2, "Set auto exposure control to %d", val); | ||
433 | |||
434 | sensor_settings[AUTO_EXPOSURE_IDX] = val; | ||
435 | err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1); | ||
436 | if (err < 0) | ||
437 | return err; | ||
438 | |||
439 | i2c_data = ((i2c_data & 0xfe) | ((val & 0x01) << 0)); | ||
440 | |||
441 | return m5602_write_sensor(sd, OV7660_COM8, &i2c_data, 1); | ||
442 | } | ||
443 | |||
394 | static void ov7660_dump_registers(struct sd *sd) | 444 | static void ov7660_dump_registers(struct sd *sd) |
395 | { | 445 | { |
396 | int address; | 446 | int address; |