summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/gspca/m5602/m5602_po1030.c
diff options
context:
space:
mode:
authorErik Andr?n <erik.andren@gmail.com>2009-01-08 07:53:50 +0100
committerErik Andr?n <erik.andren@gmail.com>2009-01-08 07:53:50 +0100
commit02837d3011a2f6ba4e2a02c6aee7f30f77d61693 (patch)
tree031acb58b4434fec68e126b6e83b3a0defa4159a /linux/drivers/media/video/gspca/m5602/m5602_po1030.c
parent81addebd5c8a4e038baef9281d335145168c15b1 (diff)
downloadmediapointer-dvb-s2-02837d3011a2f6ba4e2a02c6aee7f30f77d61693.tar.gz
mediapointer-dvb-s2-02837d3011a2f6ba4e2a02c6aee7f30f77d61693.tar.bz2
gspca - m5602-po1030: Add auto white balancing control
From: Erik Andr?n <erik.andren@gmail.com> Add a po1030 auto white balancing control that's disabled by default Priority: normal Signed-off-by: Erik Andr?n <erik.andren@gmail.com>
Diffstat (limited to 'linux/drivers/media/video/gspca/m5602/m5602_po1030.c')
-rw-r--r--linux/drivers/media/video/gspca/m5602/m5602_po1030.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/linux/drivers/media/video/gspca/m5602/m5602_po1030.c b/linux/drivers/media/video/gspca/m5602/m5602_po1030.c
index 7ec3fbffc..7eec6e8ca 100644
--- a/linux/drivers/media/video/gspca/m5602/m5602_po1030.c
+++ b/linux/drivers/media/video/gspca/m5602/m5602_po1030.c
@@ -119,6 +119,20 @@ const static struct ctrl po1030_ctrls[] = {
},
.set = po1030_set_vflip,
.get = po1030_get_vflip
+ },
+#define AUTO_WHITE_BALANCE_IDX 6
+ {
+ {
+ .id = V4L2_CID_AUTO_WHITE_BALANCE,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "auto white balance",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0,
+ },
+ .set = po1030_set_auto_white_balance,
+ .get = po1030_get_auto_white_balance
}
};
@@ -238,6 +252,14 @@ int po1030_init(struct sd *sd)
err = po1030_set_red_balance(&sd->gspca_dev,
sensor_settings[BLUE_BALANCE_IDX]);
+ if (err < 0)
+ return err;
+
+ err = po1030_set_auto_white_balance(&sd->gspca_dev,
+ sensor_settings[AUTO_WHITE_BALANCE_IDX]);
+ if (err < 0)
+ return err;
+
return err;
}
@@ -425,6 +447,35 @@ int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
return err;
}
+int po1030_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];
+ PDEBUG(D_V4L2, "Auto white balancing is %d", *val);
+
+ return 0;
+}
+
+int po1030_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+ u8 i2c_data;
+ int err;
+
+ sensor_settings[AUTO_WHITE_BALANCE_IDX] = val;
+
+ err = m5602_read_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1);
+ if (err < 0)
+ return err;
+
+ i2c_data = (i2c_data & 0xfe) | (val & 0x01);
+ err = m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1);
+ return err;
+}
+
void po1030_disconnect(struct sd *sd)
{
sd->sensor = NULL;