aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sonixj.c
diff options
context:
space:
mode:
authorJean-François Moine <moinejf@free.fr>2010-04-02 06:08:39 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:57:35 -0400
commitc26b12d0646e0f571389a0a990882af3732b26a8 (patch)
treef13892de9aa1ecdd0ad56f00df797b151ac939d2 /drivers/media/video/gspca/sonixj.c
parent73e4934c80338757dca46ffaa30a3443a31043fb (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/video/gspca/sonixj.c')
-rw-r--r--drivers/media/video/gspca/sonixj.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 0b74ea89ae04..d90c065a98ef 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -291,8 +291,7 @@ static const __u32 ctrl_dis[] = {
291 (1 << VFLIP_IDX) | 291 (1 << VFLIP_IDX) |
292 (1 << FREQ_IDX), 292 (1 << FREQ_IDX),
293 293
294[SENSOR_GC0307] = (1 << AUTOGAIN_IDX) | 294[SENSOR_GC0307] = (1 << INFRARED_IDX) |
295 (1 << INFRARED_IDX) |
296 (1 << VFLIP_IDX) | 295 (1 << VFLIP_IDX) |
297 (1 << FREQ_IDX), 296 (1 << FREQ_IDX),
298 297
@@ -642,12 +641,6 @@ static const u8 gc0307_sensor_param1[][8] = {
642/*param3*/ 641/*param3*/
643 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10}, 642 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
644 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10}, 643 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
645
646 {0xa0, 0x21, 0x68, 0x22, 0x00, 0x00, 0x00, 0x10},
647 {0xdd, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
648 {0xa0, 0x21, 0x03, 0x07, 0x00, 0x00, 0x00, 0x10},
649 {0xdd, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
650 {0xa0, 0x21, 0x04, 0x91, 0x00, 0x00, 0x00, 0x10},
651 {} 644 {}
652}; 645};
653 646
@@ -1815,6 +1808,18 @@ static u32 setexposure(struct gspca_dev *gspca_dev,
1815 struct sd *sd = (struct sd *) gspca_dev; 1808 struct sd *sd = (struct sd *) gspca_dev;
1816 1809
1817 switch (sd->sensor) { 1810 switch (sd->sensor) {
1811 case SENSOR_GC0307: {
1812 int a, b;
1813
1814 /* expo = 0..255 -> a = 19..43 */
1815 a = 19 + expo * 25 / 256;
1816 i2c_w1(gspca_dev, 0x68, a);
1817 a -= 12;
1818 b = a * a * 4; /* heuristic */
1819 i2c_w1(gspca_dev, 0x03, b >> 8);
1820 i2c_w1(gspca_dev, 0x04, b);
1821 break;
1822 }
1818 case SENSOR_HV7131R: { 1823 case SENSOR_HV7131R: {
1819 u8 Expodoit[] = 1824 u8 Expodoit[] =
1820 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 }; 1825 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
@@ -1925,6 +1930,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
1925 expo = sd->brightness >> 4; 1930 expo = sd->brightness >> 4;
1926 sd->exposure = setexposure(gspca_dev, expo); 1931 sd->exposure = setexposure(gspca_dev, expo);
1927 break; 1932 break;
1933 case SENSOR_GC0307:
1928 case SENSOR_MT9V111: 1934 case SENSOR_MT9V111:
1929 expo = sd->brightness >> 8; 1935 expo = sd->brightness >> 8;
1930 sd->exposure = setexposure(gspca_dev, expo); 1936 sd->exposure = setexposure(gspca_dev, expo);
@@ -2524,6 +2530,14 @@ static void do_autogain(struct gspca_dev *gspca_dev)
2524 if (delta < luma_mean - luma_delta || 2530 if (delta < luma_mean - luma_delta ||
2525 delta > luma_mean + luma_delta) { 2531 delta > luma_mean + luma_delta) {
2526 switch (sd->sensor) { 2532 switch (sd->sensor) {
2533 case SENSOR_GC0307:
2534 expotimes = sd->exposure;
2535 expotimes += (luma_mean - delta) >> 6;
2536 if (expotimes < 0)
2537 expotimes = 0;
2538 sd->exposure = setexposure(gspca_dev,
2539 (unsigned int) expotimes);
2540 break;
2527 case SENSOR_HV7131R: 2541 case SENSOR_HV7131R:
2528 expotimes = sd->exposure >> 8; 2542 expotimes = sd->exposure >> 8;
2529 expotimes += (luma_mean - delta) >> 4; 2543 expotimes += (luma_mean - delta) >> 4;