diff options
author | Erik Andrén <erik.andren@gmail.com> | 2009-06-20 07:01:27 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:16:53 -0400 |
commit | f1f59fe60e38c4c56b8acba9690cd08d86d2ac0e (patch) | |
tree | 330be9016456d76354e0542732c8a72290b2ec95 /drivers/media/video/gspca/m5602 | |
parent | a94e2f2cb91678f106fb31e6fa58b7af451a42e9 (diff) |
V4L/DVB (12980): gspca - m5602-ov7660: Create auto white balance 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/m5602')
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_ov7660.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_ov7660.c b/drivers/media/video/gspca/m5602/m5602_ov7660.c index 9d0cf2ccd1fe..00f8365db1a1 100644 --- a/drivers/media/video/gspca/m5602/m5602_ov7660.c +++ b/drivers/media/video/gspca/m5602/m5602_ov7660.c | |||
@@ -24,6 +24,11 @@ static int ov7660_get_blue_gain(struct gspca_dev *gspca_dev, __s32 *val); | |||
24 | static int ov7660_set_blue_gain(struct gspca_dev *gspca_dev, __s32 val); | 24 | static int ov7660_set_blue_gain(struct gspca_dev *gspca_dev, __s32 val); |
25 | static int ov7660_get_red_gain(struct gspca_dev *gspca_dev, __s32 *val); | 25 | static int ov7660_get_red_gain(struct gspca_dev *gspca_dev, __s32 *val); |
26 | static int ov7660_set_red_gain(struct gspca_dev *gspca_dev, __s32 val); | 26 | static int ov7660_set_red_gain(struct gspca_dev *gspca_dev, __s32 val); |
27 | static int ov7660_get_auto_white_balance(struct gspca_dev *gspca_dev, | ||
28 | __s32 *val); | ||
29 | static int ov7660_set_auto_white_balance(struct gspca_dev *gspca_dev, | ||
30 | __s32 val); | ||
31 | |||
27 | 32 | ||
28 | const static struct ctrl ov7660_ctrls[] = { | 33 | const static struct ctrl ov7660_ctrls[] = { |
29 | #define GAIN_IDX 1 | 34 | #define GAIN_IDX 1 |
@@ -71,6 +76,21 @@ const static struct ctrl ov7660_ctrls[] = { | |||
71 | .set = ov7660_set_red_gain, | 76 | .set = ov7660_set_red_gain, |
72 | .get = ov7660_get_red_gain | 77 | .get = ov7660_get_red_gain |
73 | }, | 78 | }, |
79 | #define AUTO_WHITE_BALANCE_IDX 4 | ||
80 | { | ||
81 | { | ||
82 | .id = V4L2_CID_AUTO_WHITE_BALANCE, | ||
83 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
84 | .name = "auto white balance", | ||
85 | .minimum = 0, | ||
86 | .maximum = 1, | ||
87 | .step = 1, | ||
88 | .default_value = 1 | ||
89 | }, | ||
90 | .set = ov7660_set_auto_white_balance, | ||
91 | .get = ov7660_get_auto_white_balance | ||
92 | }, | ||
93 | |||
74 | }; | 94 | }; |
75 | 95 | ||
76 | static struct v4l2_pix_format ov7660_modes[] = { | 96 | static struct v4l2_pix_format ov7660_modes[] = { |
@@ -182,6 +202,9 @@ int ov7660_init(struct sd *sd) | |||
182 | if (err < 0) | 202 | if (err < 0) |
183 | return err; | 203 | return err; |
184 | 204 | ||
205 | err = ov7660_set_auto_white_balance(&sd->gspca_dev, | ||
206 | sensor_settings[AUTO_WHITE_BALANCE_IDX]); | ||
207 | |||
185 | return err; | 208 | return err; |
186 | } | 209 | } |
187 | 210 | ||
@@ -278,6 +301,37 @@ static int ov7660_set_red_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
278 | return err; | 301 | return err; |
279 | } | 302 | } |
280 | 303 | ||
304 | static int ov7660_get_auto_white_balance(struct gspca_dev *gspca_dev, | ||
305 | __s32 *val) | ||
306 | { | ||
307 | struct sd *sd = (struct sd *) gspca_dev; | ||
308 | s32 *sensor_settings = sd->sensor_priv; | ||
309 | |||
310 | *val = sensor_settings[AUTO_WHITE_BALANCE_IDX]; | ||
311 | return 0; | ||
312 | } | ||
313 | |||
314 | static int ov7660_set_auto_white_balance(struct gspca_dev *gspca_dev, | ||
315 | __s32 val) | ||
316 | { | ||
317 | int err; | ||
318 | u8 i2c_data; | ||
319 | struct sd *sd = (struct sd *) gspca_dev; | ||
320 | s32 *sensor_settings = sd->sensor_priv; | ||
321 | |||
322 | PDEBUG(D_V4L2, "Set auto white balance to %d", val); | ||
323 | |||
324 | sensor_settings[AUTO_WHITE_BALANCE_IDX] = val; | ||
325 | err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1); | ||
326 | if (err < 0) | ||
327 | return err; | ||
328 | |||
329 | i2c_data = ((i2c_data & 0xfd) | ((val & 0x01) << 1)); | ||
330 | err = m5602_write_sensor(sd, OV7660_COM8, &i2c_data, 1); | ||
331 | |||
332 | return err; | ||
333 | } | ||
334 | |||
281 | static void ov7660_dump_registers(struct sd *sd) | 335 | static void ov7660_dump_registers(struct sd *sd) |
282 | { | 336 | { |
283 | int address; | 337 | int address; |