summaryrefslogtreecommitdiff
path: root/linux/drivers/media
diff options
context:
space:
mode:
authorErik Andr?n <erik.andren@gmail.com>2009-01-14 07:37:03 +0100
committerErik Andr?n <erik.andren@gmail.com>2009-01-14 07:37:03 +0100
commit5432c866197d81e8af8579d9865ba47d770d44bc (patch)
tree733be9abc843008e37562d19f7e56dda1844df91 /linux/drivers/media
parent81dcc91ec72ff9b0b3464d46ab0965f53e4499e7 (diff)
downloadmediapointer-dvb-s2-5432c866197d81e8af8579d9865ba47d770d44bc.tar.gz
mediapointer-dvb-s2-5432c866197d81e8af8579d9865ba47d770d44bc.tar.bz2
gspca - m5602-s5k4aa: Add brightness v4l2 ctrl
From: Erik Andr?n <erik.andren@gmail.com> Priority: normal Signed-off-by: Erik Andr?n <erik.andren@gmail.com>
Diffstat (limited to 'linux/drivers/media')
-rw-r--r--linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.c54
-rw-r--r--linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.h8
2 files changed, 56 insertions, 6 deletions
diff --git a/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
index b21f2e0b4..06da4b3ed 100644
--- a/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
+++ b/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
@@ -28,6 +28,8 @@ static int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val);
static int s5k4aa_get_noise(struct gspca_dev *gspca_dev, __s32 *val);
static int s5k4aa_set_noise(struct gspca_dev *gspca_dev, __s32 val);
+static int s5k4aa_get_brightness(struct gspca_dev *gspca_dev, __s32 *val);
+static int s5k4aa_set_brightness(struct gspca_dev *gspca_dev, __s32 val);
static
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
@@ -115,7 +117,7 @@ const static struct ctrl s5k4aa_ctrls[] = {
.minimum = 0,
.maximum = 127,
.step = 1,
- .default_value = DEFAULT_GAIN_2,
+ .default_value = S5K4AA_DEFAULT_GAIN,
.flags = V4L2_CTRL_FLAG_SLIDER
},
.set = s5k4aa_set_gain,
@@ -150,6 +152,21 @@ const static struct ctrl s5k4aa_ctrls[] = {
.set = s5k4aa_set_noise,
.get = s5k4aa_get_noise
},
+#define BRIGHTNESS_IDX 5
+ {
+ {
+ .id = V4L2_CID_BRIGHTNESS,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Brightness",
+ .minimum = 0,
+ .maximum = 0x1f,
+ .step = 1,
+ .default_value = S5K4AA_DEFAULT_BRIGHTNESS,
+ },
+ .set = s5k4aa_set_brightness,
+ .get = s5k4aa_get_brightness
+ },
+
};
static void s5k4aa_dump_registers(struct sd *sd);
@@ -322,6 +339,11 @@ int s5k4aa_init(struct sd *sd)
if (err < 0)
return err;
+ err = s5k4aa_set_brightness(&sd->gspca_dev,
+ sensor_settings[BRIGHTNESS_IDX]);
+ if (err < 0)
+ return err;
+
err = s5k4aa_set_noise(&sd->gspca_dev, sensor_settings[NOISE_SUPP_IDX]);
if (err < 0)
return err;
@@ -510,11 +532,39 @@ static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val)
return err;
data = val & 0xff;
- err = m5602_write_sensor(sd, S5K4AA_GAIN_2, &data, 1);
+ err = m5602_write_sensor(sd, S5K4AA_GAIN, &data, 1);
return err;
}
+static int s5k4aa_get_brightness(struct gspca_dev *gspca_dev, __s32 *val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+
+ *val = sensor_settings[BRIGHTNESS_IDX];
+ PDEBUG(D_V4L2, "Read brightness %d", *val);
+ return 0;
+}
+
+static int s5k4aa_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
+{
+ struct sd *sd = (struct sd *) gspca_dev;
+ s32 *sensor_settings = sd->sensor_priv;
+ u8 data = S5K4AA_PAGE_MAP_2;
+ int err;
+
+ sensor_settings[BRIGHTNESS_IDX] = val;
+
+ PDEBUG(D_V4L2, "Set brightness to %d", val);
+ err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
+ if (err < 0)
+ return err;
+
+ data = val & 0xff;
+ return m5602_write_sensor(sd, S5K4AA_BRIGHTNESS, &data, 1);
+}
+
static int s5k4aa_get_noise(struct gspca_dev *gspca_dev, __s32 *val)
{
struct sd *sd = (struct sd *) gspca_dev;
diff --git a/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.h b/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
index 8299f216c..2349174ad 100644
--- a/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
+++ b/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
@@ -47,8 +47,8 @@
#define S5K4AA_H_BLANK_LO__ 0x1e
#define S5K4AA_EXPOSURE_HI 0x17
#define S5K4AA_EXPOSURE_LO 0x18
-#define S5K4AA_GAIN_1 0x1f /* (digital?) gain : 5 bits */
-#define S5K4AA_GAIN_2 0x20 /* (analogue?) gain : 7 bits */
+#define S5K4AA_BRIGHTNESS 0x1f /* (digital?) gain : 5 bits */
+#define S5K4AA_GAIN 0x20 /* (analogue?) gain : 7 bits */
#define S5K4AA_NOISE_SUPP 0x37
#define S5K4AA_RM_ROW_SKIP_4X 0x08
@@ -58,7 +58,8 @@
#define S5K4AA_RM_H_FLIP 0x40
#define S5K4AA_RM_V_FLIP 0x80
-#define DEFAULT_GAIN_2 0x5f
+#define S5K4AA_DEFAULT_GAIN 0x5f
+#define S5K4AA_DEFAULT_BRIGHTNESS 0x10
/*****************************************************************************/
@@ -303,7 +304,6 @@ static const unsigned char VGA_s5k4aa[][4] =
{SENSOR, 0x12, 0xc3, 0x00},
{SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00},
{SENSOR, 0x02, 0x0e, 0x00},
- {SENSOR, S5K4AA_GAIN_1, 0x10, 0x00},
};
#endif