V4L/DVB (11411): gspca - m5602: Rework v4l ctrl handling in all sensors
authorErik Andr?n <erik.andren@gmail.com>
Tue, 30 Dec 2008 18:27:17 +0000 (15:27 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 7 Apr 2009 00:44:39 +0000 (21:44 -0300)
Previously, all sensors allocated a part of a large ctrl vector.
Define this vector separately for each sensor instead.

Signed-off-by: Erik Andrén <erik.andren@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
13 files changed:
drivers/media/video/gspca/m5602/Makefile
drivers/media/video/gspca/m5602/m5602_bridge.h
drivers/media/video/gspca/m5602/m5602_mt9m111.c
drivers/media/video/gspca/m5602/m5602_mt9m111.h
drivers/media/video/gspca/m5602/m5602_ov9650.c
drivers/media/video/gspca/m5602/m5602_ov9650.h
drivers/media/video/gspca/m5602/m5602_po1030.c
drivers/media/video/gspca/m5602/m5602_po1030.h
drivers/media/video/gspca/m5602/m5602_s5k4aa.c
drivers/media/video/gspca/m5602/m5602_s5k4aa.h
drivers/media/video/gspca/m5602/m5602_s5k83a.c
drivers/media/video/gspca/m5602/m5602_s5k83a.h
drivers/media/video/gspca/m5602/m5602_sensor.h

index 226ab4fc9d60bd71c7029d205a10e276a45d477b..9fa3644f4869971d73aa76337c625da57e8f5eb3 100644 (file)
@@ -7,5 +7,4 @@ gspca_m5602-objs := m5602_core.o \
                    m5602_s5k83a.o \
                    m5602_s5k4aa.o
 
-EXTRA_CFLAGS += -Idrivers/media/video/gspca
-
+EXTRA_CFLAGS += -Idrivers/media/video/gspca
\ No newline at end of file
index a3f3b7a0c7e75e59f8262751d9370d48cf0ccf79..9ff41006673b48c13cc808b419d9116f49a45a03 100644 (file)
@@ -116,7 +116,7 @@ struct sd {
        char *name;
 
        /* A pointer to the currently connected sensor */
-       struct m5602_sensor *sensor;
+       const struct m5602_sensor *sensor;
 
        struct sd_desc *desc;
 
index f3e9d8f0efe9d5a3c4dad5a0d1735158203844e8..69f8f6ce5811e76feacee62fef7edcf0fb5e3b07 100644 (file)
@@ -65,7 +65,7 @@ sensor_found:
        sd->gspca_dev.cam.cam_mode = mt9m111.modes;
        sd->gspca_dev.cam.nmodes = mt9m111.nmodes;
        sd->desc->ctrls = mt9m111.ctrls;
-       sd->desc->nctrls = mt9m111.nctrls;
+       sd->desc->nctrls = ARRAY_SIZE(mt9m111_ctrls);
        return 0;
 }
 
index e795ab7a36c92adf8c7baaadef3a087f63811b2b..23b8e4f57bbf6f655d96271a67b69eb2a2c22514 100644 (file)
@@ -94,18 +94,7 @@ int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
 int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
 int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val);
 
-static struct m5602_sensor mt9m111 = {
-       .name = "MT9M111",
-
-       .i2c_slave_id = 0xba,
-       .i2c_regW = 2,
-
-       .probe = mt9m111_probe,
-       .init = mt9m111_init,
-       .power_down = mt9m111_power_down,
-
-       .nctrls = 3,
-       .ctrls = {
+const static struct ctrl mt9m111_ctrls[] = {
        {
                {
                        .id             = V4L2_CID_VFLIP,
@@ -144,7 +133,17 @@ static struct m5602_sensor mt9m111 = {
                .set = mt9m111_set_gain,
                .get = mt9m111_get_gain
        }
-       },
+};
+
+static struct m5602_sensor mt9m111 = {
+       .name = "MT9M111",
+
+       .i2c_slave_id = 0xba,
+       .i2c_regW = 2,
+
+       .probe = mt9m111_probe,
+       .init = mt9m111_init,
+       .power_down = mt9m111_power_down,
 
        .nmodes = 1,
        .modes = {
index 6581479c0b301843971c86bbec2a3fa85b35f428..a9f6ff17ee9543beb9cc34da59c9eed45b6407c9 100644 (file)
@@ -113,7 +113,7 @@ sensor_found:
        sd->gspca_dev.cam.cam_mode = ov9650.modes;
        sd->gspca_dev.cam.nmodes = ov9650.nmodes;
        sd->desc->ctrls = ov9650.ctrls;
-       sd->desc->nctrls = ov9650.nctrls;
+       sd->desc->nctrls = ARRAY_SIZE(ov9650_ctrls);
        return 0;
 }
 
index fe69ddfcb0027c6baa56c6d083d7ed64d615d487..ebf7291332cc8d136bd38ae53672c0980dccda79 100644 (file)
@@ -156,18 +156,7 @@ int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val);
 int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val);
 int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val);
 
-static struct m5602_sensor ov9650 = {
-       .name = "OV9650",
-       .i2c_slave_id = 0x60,
-       .i2c_regW = 1,
-       .probe = ov9650_probe,
-       .init = ov9650_init,
-       .start = ov9650_start,
-       .stop = ov9650_stop,
-       .power_down = ov9650_power_down,
-
-       .nctrls = 8,
-       .ctrls = {
+static struct ctrl ov9650_ctrls[] = {
        {
                {
                        .id             = V4L2_CID_EXPOSURE,
@@ -267,7 +256,18 @@ static struct m5602_sensor ov9650 = {
                .set = ov9650_set_auto_gain,
                .get = ov9650_get_auto_gain
        }
-       },
+};
+
+static struct m5602_sensor ov9650 = {
+       .name = "OV9650",
+       .i2c_slave_id = 0x60,
+       .i2c_regW = 1,
+       .probe = ov9650_probe,
+       .init = ov9650_init,
+       .start = ov9650_start,
+       .stop = ov9650_stop,
+       .power_down = ov9650_power_down,
+       .ctrls = ov9650_ctrls,
 
        .nmodes = 4,
        .modes = {
@@ -444,19 +444,10 @@ static const unsigned char init_ov9650[][3] =
        /* Enable denoise, and white-pixel erase */
        {SENSOR, OV9650_COM22, 0x23},
 
-       /* Set the high bits of the exposure value */
-       {SENSOR, OV9650_AECH, ((EXPOSURE_DEFAULT & 0xff00) >> 8)},
-
        /* Enable VARIOPIXEL */
        {SENSOR, OV9650_COM3, OV9650_VARIOPIXEL},
        {SENSOR, OV9650_COM4, OV9650_QVGA_VARIOPIXEL},
 
-       /* Set the low bits of the exposure value */
-       {SENSOR, OV9650_COM1, (EXPOSURE_DEFAULT & 0xff)},
-       {SENSOR, OV9650_GAIN, GAIN_DEFAULT},
-       {SENSOR, OV9650_BLUE, BLUE_GAIN_DEFAULT},
-       {SENSOR, OV9650_RED, RED_GAIN_DEFAULT},
-
        /* Put the sensor in soft sleep mode */
        {SENSOR, OV9650_COM2, OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X},
 };
index d509330f5f518995e5b85bf358825a945dc543c2..7914dcc6e2a261b7032e979ac3cbe1f40e6ea68a 100644 (file)
@@ -62,7 +62,7 @@ sensor_found:
        sd->gspca_dev.cam.cam_mode = po1030.modes;
        sd->gspca_dev.cam.nmodes = po1030.nmodes;
        sd->desc->ctrls = po1030.ctrls;
-       sd->desc->nctrls = po1030.nctrls;
+       sd->desc->nctrls = ARRAY_SIZE(po1030_ctrls);
        return 0;
 }
 
index def39d5bcec6a4985bce5921610073a9c3572ca4..afd776a07f9d2e98a6f5ce2b62a6e9a53b00849a 100644 (file)
@@ -141,18 +141,7 @@ int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
 int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
 int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
 
-static struct m5602_sensor po1030 = {
-       .name = "PO1030",
-
-       .i2c_slave_id = 0xdc,
-       .i2c_regW = 1,
-
-       .probe = po1030_probe,
-       .init = po1030_init,
-       .power_down = po1030_power_down,
-
-       .nctrls = 6,
-       .ctrls = {
+static struct ctrl po1030_ctrls[] = {
        {
                {
                        .id             = V4L2_CID_GAIN,
@@ -230,7 +219,19 @@ static struct m5602_sensor po1030 = {
                .set = po1030_set_vflip,
                .get = po1030_get_vflip
        }
-       },
+};
+
+static struct m5602_sensor po1030 = {
+       .name = "PO1030",
+
+       .i2c_slave_id = 0xdc,
+       .i2c_regW = 1,
+
+       .probe = po1030_probe,
+       .init = po1030_init,
+       .power_down = po1030_power_down,
+
+       .ctrls = po1030_ctrls,
 
        .nmodes = 1,
        .modes = {
index 921d009e02c48a3b24e34c2e31a455f6c0532659..b7f1b045dca7dcb0e5898aba3c677aa798a70dab 100644 (file)
@@ -118,8 +118,7 @@ sensor_found:
        sd->gspca_dev.cam.cam_mode = s5k4aa.modes;
        sd->gspca_dev.cam.nmodes = s5k4aa.nmodes;
        sd->desc->ctrls = s5k4aa.ctrls;
-       sd->desc->nctrls = s5k4aa.nctrls;
-
+       sd->desc->nctrls = ARRAY_SIZE(s5k4aa_ctrls);
        return 0;
 }
 
index 0c08ccffc7ff253aa07f450e8f4390420510b2ea..33ba1621bc6922cab8397fff67f195d25bb96f63 100644 (file)
@@ -77,16 +77,7 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
 int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
 int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val);
 
-static struct m5602_sensor s5k4aa = {
-       .name = "S5K4AA",
-       .probe = s5k4aa_probe,
-       .init = s5k4aa_init,
-       .start = s5k4aa_start,
-       .power_down = s5k4aa_power_down,
-       .i2c_slave_id = 0x5a,
-       .i2c_regW = 2,
-       .nctrls = 4,
-       .ctrls = {
+static struct ctrl s5k4aa_ctrls[] = {
        {
                {
                        .id             = V4L2_CID_VFLIP,
@@ -140,7 +131,17 @@ static struct m5602_sensor s5k4aa = {
                .set = s5k4aa_set_exposure,
                .get = s5k4aa_get_exposure
        }
-       },
+};
+
+static struct m5602_sensor s5k4aa = {
+       .name = "S5K4AA",
+       .probe = s5k4aa_probe,
+       .init = s5k4aa_init,
+       .start = s5k4aa_start,
+       .power_down = s5k4aa_power_down,
+       .i2c_slave_id = 0x5a,
+       .i2c_regW = 2,
+       .ctrls = s5k4aa_ctrls,
 
        .nmodes = 1,
        .modes = {
index 5ce69d74dac97005668762631994dac34406f513..6880b31575c70a1bc3da45c0e66574573bac3e02 100644 (file)
@@ -66,7 +66,7 @@ sensor_found:
        sd->gspca_dev.cam.cam_mode = s5k83a.modes;
        sd->gspca_dev.cam.nmodes = s5k83a.nmodes;
        sd->desc->ctrls = s5k83a.ctrls;
-       sd->desc->nctrls = s5k83a.nctrls;
+       sd->desc->nctrls = ARRAY_SIZE(s5k83a_ctrls);
        return 0;
 }
 
index 40ed14165c2aa3df85332c968a56a94ff95d7d38..ed74d9734972cc12d038b25b6c7f3109c5bc3a63 100644 (file)
@@ -61,17 +61,7 @@ int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
 int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
 int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
 
-static struct m5602_sensor s5k83a = {
-       .name = "S5K83A",
-       .probe = s5k83a_probe,
-       .init = s5k83a_init,
-       .start = s5k83a_start,
-       .stop = s5k83a_stop,
-       .power_down = s5k83a_power_down,
-       .i2c_slave_id = 0x5a,
-       .i2c_regW = 2,
-       .nctrls = 5,
-       .ctrls = {
+static struct ctrl s5k83a_ctrls[] = {
        {
                {
                        .id = V4L2_CID_BRIGHTNESS,
@@ -136,8 +126,21 @@ static struct m5602_sensor s5k83a = {
                },
                .set = s5k83a_set_vflip,
                .get = s5k83a_get_vflip
-               }
-       },
+       }
+};
+
+
+static struct m5602_sensor s5k83a = {
+       .name = "S5K83A",
+       .probe = s5k83a_probe,
+       .init = s5k83a_init,
+       .start = s5k83a_start,
+       .stop = s5k83a_stop,
+       .power_down = s5k83a_power_down,
+       .i2c_slave_id = 0x5a,
+       .i2c_regW = 2,
+       .ctrls = s5k83a_ctrls,
+
        .nmodes = 1,
        .modes = {
        {
index 8eed4cc0b413c32077908fe7b1eb8b140d39ae5a..5867ee258918ba17cdcd7dcfb93b8061ce707d6a 100644 (file)
@@ -24,8 +24,6 @@
 #define M5602_DEFAULT_FRAME_WIDTH  640
 #define M5602_DEFAULT_FRAME_HEIGHT 480
 
-#define M5602_MAX_CTRLS                (V4L2_CID_LASTP1 - V4L2_CID_BASE + 10)
-
 /* Enumerates all supported sensors */
 enum sensors {
        OV9650_SENSOR   = 1,
@@ -67,8 +65,7 @@ struct m5602_sensor {
        /* Performs a power down sequence */
        int (*power_down)(struct sd *sd);
 
-       int nctrls;
-       struct ctrl ctrls[M5602_MAX_CTRLS];
+       const struct ctrl *ctrls;
 
        char nmodes;
        struct v4l2_pix_format modes[];