]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
V4L/DVB (11458): gspca - m5602-po1030: Set all v4l2 controls at sensor init
authorErik Andr?n <erik.andren@gmail.com>
Wed, 7 Jan 2009 21:05:08 +0000 (18:05 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 16 Jun 2009 21:20:25 +0000 (18:20 -0300)
Previously many of the v4l2 ctrls were set to their initial values at resume from ram/disk. This patch enforces the values stored in the ctrl cache.

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

index 800b5f4cb0e47b454f681d4a87c5852bc972ad97..7ec3fbffc4be9d344cbffdb0f9a8dc6223d1d561 100644 (file)
@@ -127,7 +127,7 @@ static void po1030_dump_registers(struct sd *sd);
 int po1030_probe(struct sd *sd)
 {
        u8 prod_id = 0, ver_id = 0, i;
-       s32 *sensor_settings = sd->sensor_priv;
+       s32 *sensor_settings;
 
        if (force_sensor) {
                if (force_sensor == PO1030_SENSOR) {
@@ -177,11 +177,16 @@ sensor_found:
        for (i = 0; i < ARRAY_SIZE(po1030_ctrls); i++)
                sensor_settings[i] = po1030_ctrls[i].qctrl.default_value;
        sd->sensor_priv = sensor_settings;
+
+       if (dump_sensor)
+               po1030_dump_registers(sd);
+
        return 0;
 }
 
 int po1030_init(struct sd *sd)
 {
+       s32 *sensor_settings = sd->sensor_priv;
        int i, err = 0;
 
        /* Init the sensor */
@@ -206,10 +211,33 @@ int po1030_init(struct sd *sd)
                        return -EINVAL;
                }
        }
+       if (err < 0)
+               return err;
 
-       if (dump_sensor)
-               po1030_dump_registers(sd);
+       err = po1030_set_exposure(&sd->gspca_dev,
+                                  sensor_settings[EXPOSURE_IDX]);
+       if (err < 0)
+               return err;
+
+       err = po1030_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]);
+       if (err < 0)
+               return err;
+
+       err = po1030_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]);
+       if (err < 0)
+               return err;
+
+       err = po1030_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]);
+       if (err < 0)
+               return err;
+
+       err = po1030_set_red_balance(&sd->gspca_dev,
+                                     sensor_settings[RED_BALANCE_IDX]);
+       if (err < 0)
+               return err;
 
+       err = po1030_set_red_balance(&sd->gspca_dev,
+                                     sensor_settings[BLUE_BALANCE_IDX]);
        return err;
 }
 
index 3e9648794df206928f43a90ea9c14ce9588c0b2e..013be33d1b2077221d015515a32da758c2f7c442 100644 (file)
@@ -371,6 +371,7 @@ static const unsigned char init_po1030[][4] =
        {SENSOR, PO1030_GC6, 0xc0},
        {SENSOR, PO1030_GC7, 0xff},
        /*end of sequence 4*/
+
        /*sequence 5*/
        {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06},
        {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
@@ -396,31 +397,12 @@ static const unsigned char init_po1030[][4] =
        {BRIDGE, M5602_XB_SIG_INI, 0x00},
        /*end of sequence 5*/
        /*sequence 6*/
-       /* Changing 40 in f0 the image becomes green in bayer mode and red in
-        * rgb mode */
-       {SENSOR, PO1030_RED_GAIN, PO1030_RED_GAIN_DEFAULT},
-       /* in changing 40 in f0 the image becomes green in bayer mode and red in
-        * rgb mode */
-       {SENSOR, PO1030_BLUE_GAIN, PO1030_BLUE_GAIN_DEFAULT},
 
        /* with a very low lighted environment increase the exposure but
         * decrease the FPS (Frame Per Second) */
        {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
        {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
 
-       /* Controls high exposure more than SENSOR_LOW_EXPOSURE, use only in
-        * low lighted environment (f0 is more than ff ?)*/
-       {SENSOR, PO1030_INTEGLINES_H, ((PO1030_EXPOSURE_DEFAULT >> 2)
-               & 0xff)},
-
-       /* Controls middle exposure, use only in high lighted environment */
-       {SENSOR, PO1030_INTEGLINES_M, PO1030_EXPOSURE_DEFAULT & 0xff},
-
-       /* Controls clarity (not sure) */
-       {SENSOR, PO1030_INTEGLINES_L, 0x00},
-       /* Controls gain (the image is more lighted) */
-       {SENSOR, PO1030_GLOBALGAIN, PO1030_GLOBAL_GAIN_DEFAULT},
-
        /* Sets the width */
        {SENSOR, PO1030_FRAMEWIDTH_H, 0x02},
        {SENSOR, PO1030_FRAMEWIDTH_L, 0xef}