diff options
author | Jean-François Moine <moinejf@free.fr> | 2010-04-02 07:08:39 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-19 12:57:35 -0300 |
commit | c26b12d0646e0f571389a0a990882af3732b26a8 (patch) | |
tree | f13892de9aa1ecdd0ad56f00df797b151ac939d2 /drivers/media | |
parent | 73e4934c80338757dca46ffaa30a3443a31043fb (diff) |
V4L/DVB: gspca - sonixj: Add autogain for sensor gc0307
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/gspca/sonixj.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 0b74ea89ae0..d90c065a98e 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c @@ -291,8 +291,7 @@ static const __u32 ctrl_dis[] = { (1 << VFLIP_IDX) | (1 << FREQ_IDX), -[SENSOR_GC0307] = (1 << AUTOGAIN_IDX) | - (1 << INFRARED_IDX) | +[SENSOR_GC0307] = (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), @@ -642,12 +641,6 @@ static const u8 gc0307_sensor_param1[][8] = { /*param3*/ {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10}, {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10}, - - {0xa0, 0x21, 0x68, 0x22, 0x00, 0x00, 0x00, 0x10}, - {0xdd, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0xa0, 0x21, 0x03, 0x07, 0x00, 0x00, 0x00, 0x10}, - {0xdd, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0xa0, 0x21, 0x04, 0x91, 0x00, 0x00, 0x00, 0x10}, {} }; @@ -1815,6 +1808,18 @@ static u32 setexposure(struct gspca_dev *gspca_dev, struct sd *sd = (struct sd *) gspca_dev; switch (sd->sensor) { + case SENSOR_GC0307: { + int a, b; + + /* expo = 0..255 -> a = 19..43 */ + a = 19 + expo * 25 / 256; + i2c_w1(gspca_dev, 0x68, a); + a -= 12; + b = a * a * 4; /* heuristic */ + i2c_w1(gspca_dev, 0x03, b >> 8); + i2c_w1(gspca_dev, 0x04, b); + break; + } case SENSOR_HV7131R: { u8 Expodoit[] = { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 }; @@ -1925,6 +1930,7 @@ static void setbrightness(struct gspca_dev *gspca_dev) expo = sd->brightness >> 4; sd->exposure = setexposure(gspca_dev, expo); break; + case SENSOR_GC0307: case SENSOR_MT9V111: expo = sd->brightness >> 8; sd->exposure = setexposure(gspca_dev, expo); @@ -2524,6 +2530,14 @@ static void do_autogain(struct gspca_dev *gspca_dev) if (delta < luma_mean - luma_delta || delta > luma_mean + luma_delta) { switch (sd->sensor) { + case SENSOR_GC0307: + expotimes = sd->exposure; + expotimes += (luma_mean - delta) >> 6; + if (expotimes < 0) + expotimes = 0; + sd->exposure = setexposure(gspca_dev, + (unsigned int) expotimes); + break; case SENSOR_HV7131R: expotimes = sd->exposure >> 8; expotimes += (luma_mean - delta) >> 4; |