aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/video/gspca/m5602
diff options
context:
space:
mode:
authorErik Andrén <erik.andren@gmail.com>2009-06-20 08:01:27 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-19 00:16:53 -0300
commitf1f59fe60e38c4c56b8acba9690cd08d86d2ac0e (patch)
tree330be9016456d76354e0542732c8a72290b2ec95 /drivers/media/video/gspca/m5602
parenta94e2f2cb91678f106fb31e6fa58b7af451a42e9 (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.c54
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 9d0cf2ccd1f..00f8365db1a 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);
static int ov7660_set_blue_gain(struct gspca_dev *gspca_dev, __s32 val);
static int ov7660_get_red_gain(struct gspca_dev *gspca_dev, __s32 *val);
static int ov7660_set_red_gain(struct gspca_dev *gspca_dev, __s32 val);
+static int ov7660_get_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 *val);
+static int ov7660_set_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 val);
+
const static struct ctrl ov7660_ctrls[] = {
#define GAIN_IDX 1
@@ -71,6 +76,21 @@ const static struct ctrl ov7660_ctrls[] = {
.set = ov7660_set_red_gain,
.get = ov7660_get_red_gain
},
+#define AUTO_WHITE_BALANCE_IDX 4
+ {
+ {
+ .id = V4L2_CID_AUTO_WHITE_BALANCE,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "auto white balance",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 1
+ },
+ .set = ov7660_set_auto_white_balance,
+ .get = ov7660_get_auto_white_balance
+ },
+
};
static struct v4l2_pix_format ov7660_modes[] = {
@@ -182,6 +202,9 @@ int ov7660_init(struct sd *sd)
if (err < 0)
return err;
+ err = ov7660_set_auto_white_balance(&sd->gspca_dev,
+ sensor_settings[AUTO_WHITE_BALANCE_IDX]);
+
return err;
}
@@ -278,6 +301,37 @@ static int ov7660_set_red_gain(struct gspca_dev *gspca_dev, __s32 val)
return err;
}
+static int ov7660_get_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[AUTO_WHITE_BALANCE_IDX];
+ return 0;
+}
+
+static int ov7660_set_auto_white_balance(struct gspca_dev *gspca_dev,
+ __s32 val)
+{
+ int err;
+ u8 i2c_data;
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ PDEBUG(D_V4L2, "Set auto white balance to %d", val);
+
+ sensor_settings[AUTO_WHITE_BALANCE_IDX] = val;
+ err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1);
+ if (err < 0)
+ return err;
+
+ i2c_data = ((i2c_data & 0xfd) | ((val & 0x01) << 1));
+ err = m5602_write_sensor(sd, OV7660_COM8, &i2c_data, 1);
+
+ return err;
+}
+
static void ov7660_dump_registers(struct sd *sd)
{
int address;