V4L/DVB (11526): gspca - m5602-mt9m111: Add red balance ctrl
authorErik Andr?n <erik.andren@gmail.com>
Tue, 13 Jan 2009 17:18:53 +0000 (14:18 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 16 Jun 2009 21:20:32 +0000 (18:20 -0300)
Signed-off-by: Erik Andr?n <erik.andren@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/gspca/m5602/m5602_mt9m111.c
drivers/media/video/gspca/m5602/m5602_mt9m111.h

index 8bdd29c7d8ffc465d71e8014886009dc67d3d619..95b6e95aa088fbe0d158b56c26af4e4787ef93b6 100644 (file)
@@ -32,6 +32,8 @@ static int mt9m111_get_green_balance(struct gspca_dev *gspca_dev, __s32 *val);
 static int mt9m111_set_green_balance(struct gspca_dev *gspca_dev, __s32 val);
 static int mt9m111_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val);
 static int mt9m111_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val);
+static int mt9m111_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val);
+static int mt9m111_set_red_balance(struct gspca_dev *gspca_dev, __s32 val);
 
 static struct v4l2_pix_format mt9m111_modes[] = {
        {
@@ -134,6 +136,21 @@ const static struct ctrl mt9m111_ctrls[] = {
                .set = mt9m111_set_blue_balance,
                .get = mt9m111_get_blue_balance
        },
+#define RED_BALANCE_IDX 5
+       {
+               {
+                       .id             = V4L2_CID_RED_BALANCE,
+                       .type           = V4L2_CTRL_TYPE_INTEGER,
+                       .name           = "red balance",
+                       .minimum        = 0x00,
+                       .maximum        = 0x7ff,
+                       .step           = 0x1,
+                       .default_value  = MT9M111_RED_GAIN_DEFAULT,
+                       .flags          = V4L2_CTRL_FLAG_SLIDER
+               },
+               .set = mt9m111_set_red_balance,
+               .get = mt9m111_get_red_balance
+       },
 };
 
 static void mt9m111_dump_registers(struct sd *sd);
@@ -240,6 +257,11 @@ int mt9m111_init(struct sd *sd)
        if (err < 0)
                return err;
 
+       err = mt9m111_set_red_balance(&sd->gspca_dev,
+                                       sensor_settings[RED_BALANCE_IDX]);
+       if (err < 0)
+               return err;
+
        return mt9m111_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]);
 }
 
@@ -462,6 +484,32 @@ static int mt9m111_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val)
        return 0;
 }
 
+static int mt9m111_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
+{
+       u8 data[2];
+       struct sd *sd = (struct sd *) gspca_dev;
+       s32 *sensor_settings = sd->sensor_priv;
+
+       sensor_settings[RED_BALANCE_IDX] = val;
+       data[0] = (val & 0xff);
+       data[1] = (val & 0xff00) >> 8;
+
+       PDEBUG(D_V4L2, "Set red balance %d", val);
+
+       return m5602_write_sensor(sd, MT9M111_SC_RED_GAIN,
+                                 data, 2);
+}
+
+static int mt9m111_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val)
+{
+       struct sd *sd = (struct sd *) gspca_dev;
+       s32 *sensor_settings = sd->sensor_priv;
+
+       *val = sensor_settings[RED_BALANCE_IDX];
+       PDEBUG(D_V4L2, "Read red balance %d", *val);
+       return 0;
+}
+
 static void mt9m111_dump_registers(struct sd *sd)
 {
        u8 address, value[2] = {0x00, 0x00};
index 57dcb56efef7701eca38119e0f56e512bfbb6883..217728a24da354ebcdfa19b206b3ae2b2e03b4ec 100644 (file)
@@ -95,6 +95,7 @@
 #define DEFAULT_GAIN                           283
 #define MT9M111_GREEN_GAIN_DEFAULT             0x20
 #define MT9M111_BLUE_GAIN_DEFAULT              0x20
+#define MT9M111_RED_GAIN_DEFAULT               0x20
 
 /*****************************************************************************/
 
This page took 0.032505 seconds and 5 git commands to generate.