V4L/DVB (9687): gspca: Split brightness and red and blue balance in spca501.
authorHans de Goede <hdegoede@redhat.com>
Mon, 17 Nov 2008 18:03:03 +0000 (15:03 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 29 Dec 2008 19:53:38 +0000 (17:53 -0200)
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/gspca/spca501.c

index b4a3c3cb42e139972b3398235a4fb5f2c775a5cd..9318de9aaf850bcf2fe09c33906dbeeadc6a8f94 100644 (file)
@@ -34,6 +34,8 @@ struct sd {
        unsigned short contrast;
        __u8 brightness;
        __u8 colors;
+       __u8 blue_balance;
+       __u8 red_balance;
 
        char subtype;
 #define Arowana300KCMOSCamera 0
@@ -52,6 +54,10 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
 static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
+static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
+static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
+static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
+static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
 
 static struct ctrl sd_ctrls[] = {
 #define MY_BRIGHTNESS 0
@@ -63,7 +69,7 @@ static struct ctrl sd_ctrls[] = {
                .minimum = 0,
                .maximum = 127,
                .step    = 1,
-               .default_value = 63,
+               .default_value = 0,
            },
            .set = sd_setbrightness,
            .get = sd_getbrightness,
@@ -75,9 +81,9 @@ static struct ctrl sd_ctrls[] = {
                .type    = V4L2_CTRL_TYPE_INTEGER,
                .name    = "Contrast",
                .minimum = 0,
-               .maximum = 0xffff,
+               .maximum = 64725,
                .step    = 1,
-               .default_value = 0xaa00,
+               .default_value = 64725,
            },
            .set = sd_setcontrast,
            .get = sd_getcontrast,
@@ -91,11 +97,39 @@ static struct ctrl sd_ctrls[] = {
                .minimum = 0,
                .maximum = 63,
                .step    = 1,
-               .default_value = 31,
+               .default_value = 20,
            },
            .set = sd_setcolors,
            .get = sd_getcolors,
        },
+#define MY_BLUE_BALANCE 3
+       {
+           {
+               .id      = V4L2_CID_BLUE_BALANCE,
+               .type    = V4L2_CTRL_TYPE_INTEGER,
+               .name    = "Blue Balance",
+               .minimum = 0,
+               .maximum = 127,
+               .step    = 1,
+               .default_value = 0,
+           },
+           .set = sd_setblue_balance,
+           .get = sd_getblue_balance,
+       },
+#define MY_RED_BALANCE 4
+       {
+           {
+               .id      = V4L2_CID_RED_BALANCE,
+               .type    = V4L2_CTRL_TYPE_INTEGER,
+               .name    = "Red Balance",
+               .minimum = 0,
+               .maximum = 127,
+               .step    = 1,
+               .default_value = 0,
+           },
+           .set = sd_setred_balance,
+           .get = sd_getred_balance,
+       },
 };
 
 static struct v4l2_pix_format vga_mode[] = {
@@ -1846,9 +1880,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
 
-       reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x11, sd->brightness);
        reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x12, sd->brightness);
-       reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x13, sd->brightness);
 }
 
 static void getbrightness(struct gspca_dev *gspca_dev)
@@ -1880,6 +1912,20 @@ static void getcolors(struct gspca_dev *gspca_dev)
 {
 }
 
+static void setblue_balance(struct gspca_dev *gspca_dev)
+{
+       struct sd *sd = (struct sd *) gspca_dev;
+
+       reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x11, sd->blue_balance);
+}
+
+static void setred_balance(struct gspca_dev *gspca_dev)
+{
+       struct sd *sd = (struct sd *) gspca_dev;
+
+       reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x13, sd->red_balance);
+}
+
 /* this function is called at probe time */
 static int sd_config(struct gspca_dev *gspca_dev,
                        const struct usb_device_id *id)
@@ -2081,6 +2127,42 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
        return 0;
 }
 
+static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
+{
+       struct sd *sd = (struct sd *) gspca_dev;
+
+       sd->blue_balance = val;
+       if (gspca_dev->streaming)
+               setblue_balance(gspca_dev);
+       return 0;
+}
+
+static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
+{
+       struct sd *sd = (struct sd *) gspca_dev;
+
+       *val = sd->blue_balance;
+       return 0;
+}
+
+static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
+{
+       struct sd *sd = (struct sd *) gspca_dev;
+
+       sd->red_balance = val;
+       if (gspca_dev->streaming)
+               setred_balance(gspca_dev);
+       return 0;
+}
+
+static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
+{
+       struct sd *sd = (struct sd *) gspca_dev;
+
+       *val = sd->red_balance;
+       return 0;
+}
+
 /* sub-driver description */
 static const struct sd_desc sd_desc = {
        .name = MODULE_NAME,