V4L/DVB: gspca - zc3xx: Fix the gamma calculation from the contrast
authorJean-François Moine <moinejf@free.fr>
Sun, 25 Apr 2010 18:25:42 +0000 (15:25 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 19 May 2010 15:58:16 +0000 (12:58 -0300)
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/gspca/zc3xx.c

index 1bab5086badaad7f7e10ccb92323b1a51d29a249..d02aa5c8472ad81d5b92b6fb0d510f0a64ba1d9b 100644 (file)
@@ -6014,8 +6014,8 @@ static void setcontrast(struct gspca_dev *gspca_dev)
        int g, i, k, adj, gp;
        u8 gr[16];
        static const u8 delta_tb[16] =          /* delta for contrast */
-               {0x15, 0x0d, 0x0a, 0x09, 0x08, 0x08, 0x08, 0x08,
-                0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08};
+               {0x2c, 0x1a, 0x12, 0x0c, 0x0a, 0x06, 0x06, 0x06,
+                0x04, 0x06, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02};
        static const u8 gamma_tb[6][16] = {
                {0x00, 0x00, 0x03, 0x0d, 0x1b, 0x2e, 0x45, 0x5f,
                 0x79, 0x93, 0xab, 0xc1, 0xd4, 0xe5, 0xf3, 0xff},
@@ -6037,11 +6037,11 @@ static void setcontrast(struct gspca_dev *gspca_dev)
        adj = 0;
        gp = 0;
        for (i = 0; i < 16; i++) {
-               g = Tgamma[i] - delta_tb[i] * k / 128 - adj / 2;
+               g = Tgamma[i] - delta_tb[i] * k / 256 - adj / 2;
                if (g > 0xff)
                        g = 0xff;
-               else if (g <= 0)
-                       g = 1;
+               else if (g < 0)
+                       g = 0;
                reg_w(dev, g, 0x0120 + i);      /* gamma */
                if (k > 0)
                        adj--;