V4L/DVB (8828): gspca: Set the clock at the end of initialization in sonixj.
[safe/jmp/linux-2.6] / drivers / media / video / mt9m001.c
index acb5454..554d229 100644 (file)
 #include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/log2.h>
+#include <linux/gpio.h>
 
 #include <media/v4l2-common.h>
 #include <media/v4l2-chip-ident.h>
 #include <media/soc_camera.h>
 
-#ifdef CONFIG_MT9M001_PCA9536_SWITCH
-#include <asm/gpio.h>
-#endif
-
 /* mt9m001 i2c address 0x5d
  * The platform has to define i2c_board_info
  * and call i2c_register_board_info() */
@@ -123,7 +120,7 @@ static int mt9m001_init(struct soc_camera_device *icd)
        int ret;
 
        /* Disable chip, synchronous option update */
-       dev_dbg(icd->vdev->dev, "%s\n", __FUNCTION__);
+       dev_dbg(icd->vdev->parent, "%s\n", __func__);
 
        ret = reg_write(icd, MT9M001_RESET, 1);
        if (ret >= 0)
@@ -372,7 +369,7 @@ static int mt9m001_set_register(struct soc_camera_device *icd,
 }
 #endif
 
-const struct v4l2_queryctrl mt9m001_controls[] = {
+static const struct v4l2_queryctrl mt9m001_controls[] = {
        {
                .id             = V4L2_CID_VFLIP,
                .type           = V4L2_CTRL_TYPE_BOOLEAN,
@@ -410,11 +407,15 @@ const struct v4l2_queryctrl mt9m001_controls[] = {
        }
 };
 
-static int mt9m001_get_control(struct soc_camera_device *icd, struct v4l2_control *ctrl);
-static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_control *ctrl);
+static int mt9m001_video_probe(struct soc_camera_device *);
+static void mt9m001_video_remove(struct soc_camera_device *);
+static int mt9m001_get_control(struct soc_camera_device *, struct v4l2_control *);
+static int mt9m001_set_control(struct soc_camera_device *, struct v4l2_control *);
 
 static struct soc_camera_ops mt9m001_ops = {
        .owner                  = THIS_MODULE,
+       .probe                  = mt9m001_video_probe,
+       .remove                 = mt9m001_video_remove,
        .init                   = mt9m001_init,
        .release                = mt9m001_release,
        .start_capture          = mt9m001_start_capture,
@@ -423,8 +424,6 @@ static struct soc_camera_ops mt9m001_ops = {
        .try_fmt_cap            = mt9m001_try_fmt_cap,
        .set_bus_param          = mt9m001_set_bus_param,
        .query_bus_param        = mt9m001_query_bus_param,
-       .formats                = NULL, /* Filled in later depending on the */
-       .num_formats            = 0,    /* camera type and data widths */
        .controls               = mt9m001_controls,
        .num_controls           = ARRAY_SIZE(mt9m001_controls),
        .get_control            = mt9m001_get_control,
@@ -573,19 +572,19 @@ static int mt9m001_video_probe(struct soc_camera_device *icd)
        case 0x8411:
        case 0x8421:
                mt9m001->model = V4L2_IDENT_MT9M001C12ST;
-               mt9m001_ops.formats = mt9m001_colour_formats;
+               icd->formats = mt9m001_colour_formats;
                if (mt9m001->client->dev.platform_data)
-                       mt9m001_ops.num_formats = ARRAY_SIZE(mt9m001_colour_formats);
+                       icd->num_formats = ARRAY_SIZE(mt9m001_colour_formats);
                else
-                       mt9m001_ops.num_formats = 1;
+                       icd->num_formats = 1;
                break;
        case 0x8431:
                mt9m001->model = V4L2_IDENT_MT9M001C12STM;
-               mt9m001_ops.formats = mt9m001_monochrome_formats;
+               icd->formats = mt9m001_monochrome_formats;
                if (mt9m001->client->dev.platform_data)
-                       mt9m001_ops.num_formats = ARRAY_SIZE(mt9m001_monochrome_formats);
+                       icd->num_formats = ARRAY_SIZE(mt9m001_monochrome_formats);
                else
-                       mt9m001_ops.num_formats = 1;
+                       icd->num_formats = 1;
                break;
        default:
                ret = -ENODEV;
@@ -618,7 +617,8 @@ static void mt9m001_video_remove(struct soc_camera_device *icd)
        soc_camera_video_stop(&mt9m001->icd);
 }
 
-static int mt9m001_probe(struct i2c_client *client)
+static int mt9m001_probe(struct i2c_client *client,
+                        const struct i2c_device_id *did)
 {
        struct mt9m001 *mt9m001;
        struct soc_camera_device *icd;
@@ -646,8 +646,6 @@ static int mt9m001_probe(struct i2c_client *client)
 
        /* Second stage probe - when a capture adapter is there */
        icd = &mt9m001->icd;
-       icd->probe      = mt9m001_video_probe;
-       icd->remove     = mt9m001_video_remove;
        icd->ops        = &mt9m001_ops;
        icd->control    = &client->dev;
        icd->x_min      = 20;
@@ -696,12 +694,19 @@ static int mt9m001_remove(struct i2c_client *client)
        return 0;
 }
 
+static const struct i2c_device_id mt9m001_id[] = {
+       { "mt9m001", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, mt9m001_id);
+
 static struct i2c_driver mt9m001_i2c_driver = {
        .driver = {
                .name = "mt9m001",
        },
        .probe          = mt9m001_probe,
        .remove         = mt9m001_remove,
+       .id_table       = mt9m001_id,
 };
 
 static int __init mt9m001_mod_init(void)