aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Andr?n <erik.andren@gmail.com>2009-01-13 12:10:44 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 17:20:32 -0400
commit12e4ed7d5e4a3145cb342be91423e92a24257212 (patch)
tree6474350bc2b92e43f0ba0dd5e618a1308b815b82
parentb933d585baf6f6432ca5dd3f6d415ffa145e2c25 (diff)
V4L/DVB (11524): gspca - m5602-mt9m111: Add green balance 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_mt9m111.c60
-rw-r--r--drivers/media/video/gspca/m5602/m5602_mt9m111.h1
2 files changed, 57 insertions, 4 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.c b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
index 37a7fc82a53c..c1ff4770e3a6 100644
--- a/drivers/media/video/gspca/m5602/m5602_mt9m111.c
+++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
@@ -28,7 +28,8 @@ static int mt9m111_set_auto_white_balance(struct gspca_dev *gspca_dev,
28 __s32 val); 28 __s32 val);
29static int mt9m111_get_auto_white_balance(struct gspca_dev *gspca_dev, 29static int mt9m111_get_auto_white_balance(struct gspca_dev *gspca_dev,
30 __s32 *val); 30 __s32 *val);
31 31static int mt9m111_get_green_balance(struct gspca_dev *gspca_dev, __s32 *val);
32static int mt9m111_set_green_balance(struct gspca_dev *gspca_dev, __s32 val);
32 33
33static struct v4l2_pix_format mt9m111_modes[] = { 34static struct v4l2_pix_format mt9m111_modes[] = {
34 { 35 {
@@ -100,7 +101,23 @@ const static struct ctrl mt9m111_ctrls[] = {
100 }, 101 },
101 .set = mt9m111_set_auto_white_balance, 102 .set = mt9m111_set_auto_white_balance,
102 .get = mt9m111_get_auto_white_balance 103 .get = mt9m111_get_auto_white_balance
103 } 104 },
105#define GREEN_BALANCE_IDX 4
106 {
107 {
108 .id = M5602_V4L2_CID_GREEN_BALANCE,
109 .type = V4L2_CTRL_TYPE_INTEGER,
110 .name = "green balance",
111 .minimum = 0x00,
112 .maximum = 0x7ff,
113 .step = 0x1,
114 .default_value = MT9M111_GREEN_GAIN_DEFAULT,
115 .flags = V4L2_CTRL_FLAG_SLIDER
116 },
117 .set = mt9m111_set_green_balance,
118 .get = mt9m111_get_green_balance
119 },
120
104}; 121};
105 122
106static void mt9m111_dump_registers(struct sd *sd); 123static void mt9m111_dump_registers(struct sd *sd);
@@ -197,9 +214,12 @@ int mt9m111_init(struct sd *sd)
197 if (err < 0) 214 if (err < 0)
198 return err; 215 return err;
199 216
200 err = mt9m111_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]); 217 err = mt9m111_set_green_balance(&sd->gspca_dev,
218 sensor_settings[GREEN_BALANCE_IDX]);
219 if (err < 0)
220 return err;
201 221
202 return err; 222 return mt9m111_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]);
203} 223}
204 224
205void mt9m111_disconnect(struct sd *sd) 225void mt9m111_disconnect(struct sd *sd)
@@ -364,6 +384,38 @@ static int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val)
364 return err; 384 return err;
365} 385}
366 386
387static int mt9m111_set_green_balance(struct gspca_dev *gspca_dev, __s32 val)
388{
389 int err;
390 u8 data[2];
391 struct sd *sd = (struct sd *) gspca_dev;
392 s32 *sensor_settings = sd->sensor_priv;
393
394 sensor_settings[GREEN_BALANCE_IDX] = val;
395 data[0] = (val & 0xff);
396 data[1] = (val & 0xff00) >> 8;
397
398 PDEBUG(D_V4L2, "Set green balance %d", val);
399 err = m5602_write_sensor(sd, MT9M111_SC_GREEN_1_GAIN,
400 data, 2);
401 if (err < 0)
402 return err;
403
404 return m5602_write_sensor(sd, MT9M111_SC_GREEN_2_GAIN,
405 data, 2);
406}
407
408static int mt9m111_get_green_balance(struct gspca_dev *gspca_dev, __s32 *val)
409{
410 struct sd *sd = (struct sd *) gspca_dev;
411 s32 *sensor_settings = sd->sensor_priv;
412
413 *val = sensor_settings[GREEN_BALANCE_IDX];
414 PDEBUG(D_V4L2, "Read green balance %d", *val);
415 return 0;
416}
417
418
367static void mt9m111_dump_registers(struct sd *sd) 419static void mt9m111_dump_registers(struct sd *sd)
368{ 420{
369 u8 address, value[2] = {0x00, 0x00}; 421 u8 address, value[2] = {0x00, 0x00};
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.h b/drivers/media/video/gspca/m5602/m5602_mt9m111.h
index d0fe02ceabbf..2d39e12d6428 100644
--- a/drivers/media/video/gspca/m5602/m5602_mt9m111.h
+++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.h
@@ -93,6 +93,7 @@
93 93
94#define INITIAL_MAX_GAIN 64 94#define INITIAL_MAX_GAIN 64
95#define DEFAULT_GAIN 283 95#define DEFAULT_GAIN 283
96#define MT9M111_GREEN_GAIN_DEFAULT 0x20
96 97
97/*****************************************************************************/ 98/*****************************************************************************/
98 99