]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (11413): gspca - m5602-mt9m111: Separate mode vectors per sensor.
authorErik Andr?n <erik.andren@gmail.com>
Tue, 30 Dec 2008 19:48:42 +0000 (16:48 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 7 Apr 2009 00:44:40 +0000 (21:44 -0300)
By separating the supported for each sensor into a separate vector we can
eliminate the nmodes variable and instead calculate it at runtime.

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
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 69f8f6ce5811e76feacee62fef7edcf0fb5e3b07..5b57fb1eb4d0de7514dcfe5d4b915a20fd60173c 100644 (file)
 
 #include "m5602_mt9m111.h"
 
+static struct v4l2_pix_format mt9m111_modes[] = {
+       {
+               640,
+               480,
+               V4L2_PIX_FMT_SBGGR8,
+               V4L2_FIELD_NONE,
+               .sizeimage = 640 * 480,
+               .bytesperline = 640,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .priv = 0
+       }
+};
+
 static void mt9m111_dump_registers(struct sd *sd);
 
 int mt9m111_probe(struct sd *sd)
@@ -62,8 +75,8 @@ int mt9m111_probe(struct sd *sd)
        return -ENODEV;
 
 sensor_found:
-       sd->gspca_dev.cam.cam_mode = mt9m111.modes;
-       sd->gspca_dev.cam.nmodes = mt9m111.nmodes;
+       sd->gspca_dev.cam.cam_mode = mt9m111_modes;
+       sd->gspca_dev.cam.nmodes = ARRAY_SIZE(mt9m111_modes);
        sd->desc->ctrls = mt9m111.ctrls;
        sd->desc->nctrls = ARRAY_SIZE(mt9m111_ctrls);
        return 0;
index 23b8e4f57bbf6f655d96271a67b69eb2a2c22514..ff3809f28e41c9bc8abefb27b0783fe6ae21325b 100644 (file)
@@ -143,22 +143,7 @@ static struct m5602_sensor mt9m111 = {
 
        .probe = mt9m111_probe,
        .init = mt9m111_init,
-       .power_down = mt9m111_power_down,
-
-       .nmodes = 1,
-       .modes = {
-       {
-               M5602_DEFAULT_FRAME_WIDTH,
-               M5602_DEFAULT_FRAME_HEIGHT,
-               V4L2_PIX_FMT_SBGGR8,
-               V4L2_FIELD_NONE,
-               .sizeimage =
-                       M5602_DEFAULT_FRAME_WIDTH * M5602_DEFAULT_FRAME_HEIGHT,
-               .bytesperline = M5602_DEFAULT_FRAME_WIDTH,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-               .priv = 1
-       }
-       }
+       .power_down = mt9m111_power_down
 };
 
 static const unsigned char preinit_mt9m111[][4] =
index 4d3fc78bdf41585d6b94ea7e7fb3fc5d59bc8a0a..130a29c7c532d7fe8549b198b0ceb4c80df5a4fd 100644 (file)
@@ -68,6 +68,50 @@ static
        { }
 };
 
+static struct v4l2_pix_format ov9650_modes[] = {
+       {
+               176,
+               144,
+               V4L2_PIX_FMT_SBGGR8,
+               V4L2_FIELD_NONE,
+               .sizeimage =
+                       176 * 144,
+               .bytesperline = 176,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .priv = 0
+       }, {
+               320,
+               240,
+               V4L2_PIX_FMT_SBGGR8,
+               V4L2_FIELD_NONE,
+               .sizeimage =
+                       320 * 240,
+               .bytesperline = 320,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .priv = 0
+       }, {
+               352,
+               288,
+               V4L2_PIX_FMT_SBGGR8,
+               V4L2_FIELD_NONE,
+               .sizeimage =
+                       352 * 288,
+               .bytesperline = 352,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .priv = 0
+       }, {
+               640,
+               480,
+               V4L2_PIX_FMT_SBGGR8,
+               V4L2_FIELD_NONE,
+               .sizeimage =
+                       640 * 480,
+               .bytesperline = 640,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .priv = 0
+       }
+};
+
 static void ov9650_dump_registers(struct sd *sd);
 
 int ov9650_probe(struct sd *sd)
@@ -110,8 +154,11 @@ int ov9650_probe(struct sd *sd)
        return -ENODEV;
 
 sensor_found:
-       sd->gspca_dev.cam.cam_mode = ov9650.modes;
-       sd->gspca_dev.cam.nmodes = ov9650.nmodes;
+//     sd->gspca_dev.cam.cam_mode = ov9650.modes;
+//     sd->gspca_dev.cam.nmodes = ov9650.nmodes;
+       sd->gspca_dev.cam.cam_mode = ov9650_modes;
+       sd->gspca_dev.cam.nmodes = ARRAY_SIZE(ov9650_modes);
+
        sd->desc->ctrls = ov9650.ctrls;
        sd->desc->nctrls = ARRAY_SIZE(ov9650_ctrls);
        return 0;
index ebf7291332cc8d136bd38ae53672c0980dccda79..fb8fe56c4f102c3303d5fc2565fbee704b97087a 100644 (file)
@@ -267,52 +267,7 @@ static struct m5602_sensor ov9650 = {
        .start = ov9650_start,
        .stop = ov9650_stop,
        .power_down = ov9650_power_down,
-       .ctrls = ov9650_ctrls,
-
-       .nmodes = 4,
-       .modes = {
-       {
-               176,
-               144,
-               V4L2_PIX_FMT_SBGGR8,
-               V4L2_FIELD_NONE,
-               .sizeimage =
-                       176 * 144,
-               .bytesperline = 176,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-               .priv = 0
-       }, {
-               320,
-               240,
-               V4L2_PIX_FMT_SBGGR8,
-               V4L2_FIELD_NONE,
-               .sizeimage =
-                       320 * 240,
-               .bytesperline = 320,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-               .priv = 0
-       }, {
-               352,
-               288,
-               V4L2_PIX_FMT_SBGGR8,
-               V4L2_FIELD_NONE,
-               .sizeimage =
-                       352 * 288,
-               .bytesperline = 352,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-               .priv = 0
-       }, {
-               640,
-               480,
-               V4L2_PIX_FMT_SBGGR8,
-               V4L2_FIELD_NONE,
-               .sizeimage =
-                       640 * 480,
-               .bytesperline = 640,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-               .priv = 0
-       }
-       }
+       .ctrls = ov9650_ctrls
 };
 
 static const unsigned char preinit_ov9650[][3] =
index 7914dcc6e2a261b7032e979ac3cbe1f40e6ea68a..716b359e7a90660828fc1f57004fa9c668885ff1 100644 (file)
 
 #include "m5602_po1030.h"
 
+static struct v4l2_pix_format po1030_modes[] = {
+       {
+               640,
+               480,
+               V4L2_PIX_FMT_SBGGR8,
+               V4L2_FIELD_NONE,
+               .sizeimage = 640 * 480,
+               .bytesperline = 640,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .priv = 0
+       }
+};
+
 static void po1030_dump_registers(struct sd *sd);
 
 int po1030_probe(struct sd *sd)
@@ -59,8 +72,8 @@ int po1030_probe(struct sd *sd)
        return -ENODEV;
 
 sensor_found:
-       sd->gspca_dev.cam.cam_mode = po1030.modes;
-       sd->gspca_dev.cam.nmodes = po1030.nmodes;
+       sd->gspca_dev.cam.cam_mode = po1030_modes;
+       sd->gspca_dev.cam.nmodes = ARRAY_SIZE(po1030_modes);
        sd->desc->ctrls = po1030.ctrls;
        sd->desc->nctrls = ARRAY_SIZE(po1030_ctrls);
        return 0;
index afd776a07f9d2e98a6f5ce2b62a6e9a53b00849a..b28ab2e85a546ab8a9ff556746998b44384e1fa4 100644 (file)
@@ -232,21 +232,6 @@ static struct m5602_sensor po1030 = {
        .power_down = po1030_power_down,
 
        .ctrls = po1030_ctrls,
-
-       .nmodes = 1,
-       .modes = {
-       {
-               M5602_DEFAULT_FRAME_WIDTH,
-               M5602_DEFAULT_FRAME_HEIGHT,
-               V4L2_PIX_FMT_SBGGR8,
-               V4L2_FIELD_NONE,
-               .sizeimage =
-                       M5602_DEFAULT_FRAME_WIDTH * M5602_DEFAULT_FRAME_HEIGHT,
-               .bytesperline = M5602_DEFAULT_FRAME_WIDTH,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-               .priv = 1
-       }
-       }
 };
 
 static const unsigned char preinit_po1030[][3] =
index b7f1b045dca7dcb0e5898aba3c677aa798a70dab..40ef9ae764827ff1973f78591799ff75e3d520d8 100644 (file)
@@ -50,6 +50,20 @@ static
        { }
 };
 
+static struct v4l2_pix_format s5k4aa_modes[] = {
+       {
+               640,
+               480,
+               V4L2_PIX_FMT_SBGGR8,
+               V4L2_FIELD_NONE,
+               .sizeimage =
+                       640 * 480,
+               .bytesperline = 640,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .priv = 0
+       }
+};
+
 static void s5k4aa_dump_registers(struct sd *sd);
 
 int s5k4aa_probe(struct sd *sd)
@@ -115,8 +129,8 @@ int s5k4aa_probe(struct sd *sd)
                info("Detected a s5k4aa sensor");
 
 sensor_found:
-       sd->gspca_dev.cam.cam_mode = s5k4aa.modes;
-       sd->gspca_dev.cam.nmodes = s5k4aa.nmodes;
+       sd->gspca_dev.cam.cam_mode = s5k4aa_modes;
+       sd->gspca_dev.cam.nmodes = ARRAY_SIZE(s5k4aa_modes);
        sd->desc->ctrls = s5k4aa.ctrls;
        sd->desc->nctrls = ARRAY_SIZE(s5k4aa_ctrls);
        return 0;
index 33ba1621bc6922cab8397fff67f195d25bb96f63..0f0c6dff1eef215294144f16c76a4ec80c1e733e 100644 (file)
@@ -142,21 +142,6 @@ static struct m5602_sensor s5k4aa = {
        .i2c_slave_id = 0x5a,
        .i2c_regW = 2,
        .ctrls = s5k4aa_ctrls,
-
-       .nmodes = 1,
-       .modes = {
-       {
-               640,
-               480,
-               V4L2_PIX_FMT_SBGGR8,
-               V4L2_FIELD_NONE,
-               .sizeimage =
-                       640 * 480,
-               .bytesperline = 640,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-               .priv = 1
-       }
-       }
 };
 
 static const unsigned char preinit_s5k4aa[][4] =
index 6880b31575c70a1bc3da45c0e66574573bac3e02..fcc8c3752c75de2a5792413787833836ab4db6bc 100644 (file)
 
 #include "m5602_s5k83a.h"
 
+static struct v4l2_pix_format s5k83a_modes[] = {
+       {
+               640,
+               480,
+               V4L2_PIX_FMT_SBGGR8,
+               V4L2_FIELD_NONE,
+               .sizeimage =
+                       640 * 480,
+               .bytesperline = 640,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .priv = 0
+       }
+};
+
 static void s5k83a_dump_registers(struct sd *sd);
 
 int s5k83a_probe(struct sd *sd)
@@ -63,8 +77,8 @@ int s5k83a_probe(struct sd *sd)
                info("Detected a s5k83a sensor");
 
 sensor_found:
-       sd->gspca_dev.cam.cam_mode = s5k83a.modes;
-       sd->gspca_dev.cam.nmodes = s5k83a.nmodes;
+       sd->gspca_dev.cam.cam_mode = s5k83a_modes;
+       sd->gspca_dev.cam.nmodes = ARRAY_SIZE(s5k83a_modes);
        sd->desc->ctrls = s5k83a.ctrls;
        sd->desc->nctrls = ARRAY_SIZE(s5k83a_ctrls);
        return 0;
index ed74d9734972cc12d038b25b6c7f3109c5bc3a63..d56eb4c5ee312003fc9822c74ecb33835424f32e 100644 (file)
@@ -129,7 +129,6 @@ static struct ctrl s5k83a_ctrls[] = {
        }
 };
 
-
 static struct m5602_sensor s5k83a = {
        .name = "S5K83A",
        .probe = s5k83a_probe,
@@ -140,21 +139,6 @@ static struct m5602_sensor s5k83a = {
        .i2c_slave_id = 0x5a,
        .i2c_regW = 2,
        .ctrls = s5k83a_ctrls,
-
-       .nmodes = 1,
-       .modes = {
-       {
-               M5602_DEFAULT_FRAME_WIDTH,
-               M5602_DEFAULT_FRAME_HEIGHT,
-               V4L2_PIX_FMT_SBGGR8,
-               V4L2_FIELD_NONE,
-               .sizeimage =
-                       M5602_DEFAULT_FRAME_WIDTH * M5602_DEFAULT_FRAME_HEIGHT,
-               .bytesperline = M5602_DEFAULT_FRAME_WIDTH,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-               .priv = 1
-       }
-       }
 };
 
 static const unsigned char preinit_s5k83a[][4] =
index 5867ee258918ba17cdcd7dcfb93b8061ce707d6a..3fd92d370d0a788285c78abf88c49c061e8460d0 100644 (file)
@@ -66,9 +66,6 @@ struct m5602_sensor {
        int (*power_down)(struct sd *sd);
 
        const struct ctrl *ctrls;
-
-       char nmodes;
-       struct v4l2_pix_format modes[];
 };
 
 #endif