V4L/DVB (12977): gspca - m5602-ov7660: Create blue gain control
authorErik Andrén <erik.andren@gmail.com>
Wed, 17 Jun 2009 06:11:24 +0000 (03:11 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 19 Sep 2009 03:16:21 +0000 (00:16 -0300)
Hook up a blue gain v4l2 controller

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_ov7660.c
drivers/media/video/gspca/m5602/m5602_ov7660.h

index 7aafeb7cfa07992734fe3b9eaf52df193ae4a054..8125c5b6cfc0e5396ba21d216d901031b7735900 100644 (file)
@@ -20,6 +20,8 @@
 
 static int ov7660_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
 static int ov7660_set_gain(struct gspca_dev *gspca_dev, __s32 val);
+static int ov7660_get_blue_gain(struct gspca_dev *gspca_dev, __s32 *val);
+static int ov7660_set_blue_gain(struct gspca_dev *gspca_dev, __s32 val);
 
 const static struct ctrl ov7660_ctrls[] = {
 #define GAIN_IDX 1
@@ -37,6 +39,22 @@ const static struct ctrl ov7660_ctrls[] = {
                .set = ov7660_set_gain,
                .get = ov7660_get_gain
        },
+#define BLUE_BALANCE_IDX 2
+       {
+               {
+                       .id             = V4L2_CID_BLUE_BALANCE,
+                       .type           = V4L2_CTRL_TYPE_INTEGER,
+                       .name           = "blue balance",
+                       .minimum        = 0x00,
+                       .maximum        = 0x7f,
+                       .step           = 0x1,
+                       .default_value  = OV7660_DEFAULT_BLUE_GAIN,
+                       .flags          = V4L2_CTRL_FLAG_SLIDER
+               },
+               .set = ov7660_set_blue_gain,
+               .get = ov7660_get_blue_gain
+       },
+
 };
 
 static struct v4l2_pix_format ov7660_modes[] = {
@@ -194,6 +212,31 @@ static int ov7660_set_gain(struct gspca_dev *gspca_dev, __s32 val)
        return err;
 }
 
+static int ov7660_get_blue_gain(struct gspca_dev *gspca_dev, __s32 *val)
+{
+       struct sd *sd = (struct sd *) gspca_dev;
+       s32 *sensor_settings = sd->sensor_priv;
+
+       *val = sensor_settings[BLUE_BALANCE_IDX];
+       PDEBUG(D_V4L2, "Read blue balance %d", *val);
+       return 0;
+}
+
+static int ov7660_set_blue_gain(struct gspca_dev *gspca_dev, __s32 val)
+{
+       int err;
+       u8 i2c_data;
+       struct sd *sd = (struct sd *) gspca_dev;
+       s32 *sensor_settings = sd->sensor_priv;
+
+       PDEBUG(D_V4L2, "Setting blue balance to %d", val);
+
+       sensor_settings[BLUE_BALANCE_IDX] = val;
+
+       err = m5602_write_sensor(sd, OV7660_BLUE_GAIN, &i2c_data, 1);
+       return err;
+}
+
 static void ov7660_dump_registers(struct sd *sd)
 {
        int address;
index 3f2c169a93eac382dade45cf1fe94579c6300145..d2589d654a1924dfa2170773a93da31098566bd8 100644 (file)
 #define OV7660_RBIAS           0x2c
 #define OV7660_HREF            0x32
 #define OV7660_ADC             0x37
-#define OV7660_OFON            0x39
-#define OV7660_TSLB            0x3a
-#define OV7660_COM12           0x3c
-#define OV7660_COM13           0x3d
+#define OV7660_OFON            0x39
+#define OV7660_TSLB            0x3a
+#define OV7660_COM12           0x3c
+#define OV7660_COM13           0x3d
 #define OV7660_LCC1            0x62
 #define OV7660_LCC2            0x63
 #define OV7660_LCC3            0x64
 #define OV7660_LCC4            0x65
 #define OV7660_LCC5            0x66
-#define OV7660_HV              0x69
-#define OV7660_RSVDA1          0xa1
+#define OV7660_HV              0x69
+#define OV7660_RSVDA1          0xa1
 
 #define OV7660_DEFAULT_GAIN            0x0e
-#define OV7660_DEFAULT_RED_GAIN        0x80
+#define OV7660_DEFAULT_RED_GAIN                0x80
 #define OV7660_DEFAULT_BLUE_GAIN       0x80
 #define OV7660_DEFAULT_SATURATION      0x00
-#define OV7660_DEFAULT_EXPOSURE        0x20
+#define OV7660_DEFAULT_EXPOSURE                0x20
 
 /* Kernel module parameters */
 extern int force_sensor;
@@ -199,8 +199,6 @@ static const unsigned char init_ov7660[][4] =
 
        {SENSOR, OV7660_COM7, 0x80},
        {SENSOR, OV7660_CLKRC, 0x80},
-       {SENSOR, OV7660_BLUE_GAIN, 0x80},
-       {SENSOR, OV7660_RED_GAIN, 0x80},
        {SENSOR, OV7660_COM9, 0x4c},
        {SENSOR, OV7660_OFON, 0x43},
        {SENSOR, OV7660_COM12, 0x28},
@@ -264,8 +262,6 @@ static const unsigned char init_ov7660[][4] =
        {SENSOR, OV7660_OFON, 0x0c},
        {SENSOR, OV7660_COM2, 0x11},
        {SENSOR, OV7660_COM7, 0x05},
-       {SENSOR, OV7660_BLUE_GAIN, 0x80},
-       {SENSOR, OV7660_RED_GAIN, 0x80},
 
        {BRIDGE, M5602_XB_GPIO_DIR, 0x01},
        {BRIDGE, M5602_XB_GPIO_DAT, 0x04},