Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelv...
[pandora-kernel.git] / drivers / media / video / mt9v011.c
index 72e55be..209ff97 100644 (file)
@@ -11,9 +11,8 @@
 #include <linux/delay.h>
 #include <asm/div64.h>
 #include <media/v4l2-device.h>
-#include "mt9v011.h"
-#include <media/v4l2-i2c-drv.h>
 #include <media/v4l2-chip-ident.h>
+#include "mt9v011.h"
 
 MODULE_DESCRIPTION("Micron mt9v011 sensor driver");
 MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
@@ -392,27 +391,25 @@ static int mt9v011_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
        return 0;
 }
 
-static int mt9v011_enum_fmt(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt)
+static int mt9v011_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
+                                       enum v4l2_mbus_pixelcode *code)
 {
-       if (fmt->index > 0)
+       if (index > 0)
                return -EINVAL;
 
-       fmt->flags = 0;
-       strcpy(fmt->description, "8 bpp Bayer GRGR..BGBG");
-       fmt->pixelformat = V4L2_PIX_FMT_SGRBG8;
-
+       *code = V4L2_MBUS_FMT_SGRBG8_1X8;
        return 0;
 }
 
-static int mt9v011_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
+static int mt9v011_try_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt)
 {
-       struct v4l2_pix_format *pix = &fmt->fmt.pix;
-
-       if (pix->pixelformat != V4L2_PIX_FMT_SGRBG8)
+       if (fmt->code != V4L2_MBUS_FMT_SGRBG8_1X8)
                return -EINVAL;
 
-       v4l_bound_align_image(&pix->width, 48, 639, 1,
-                             &pix->height, 32, 480, 1, 0);
+       v4l_bound_align_image(&fmt->width, 48, 639, 1,
+                             &fmt->height, 32, 480, 1, 0);
+       fmt->field = V4L2_FIELD_NONE;
+       fmt->colorspace = V4L2_COLORSPACE_SRGB;
 
        return 0;
 }
@@ -455,18 +452,17 @@ static int mt9v011_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
        return 0;
 }
 
-static int mt9v011_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
+static int mt9v011_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt)
 {
-       struct v4l2_pix_format *pix = &fmt->fmt.pix;
        struct mt9v011 *core = to_mt9v011(sd);
        int rc;
 
-       rc = mt9v011_try_fmt(sd, fmt);
+       rc = mt9v011_try_mbus_fmt(sd, fmt);
        if (rc < 0)
                return -EINVAL;
 
-       core->width = pix->width;
-       core->height = pix->height;
+       core->width = fmt->width;
+       core->height = fmt->height;
 
        set_res(sd);
 
@@ -549,9 +545,9 @@ static const struct v4l2_subdev_core_ops mt9v011_core_ops = {
 };
 
 static const struct v4l2_subdev_video_ops mt9v011_video_ops = {
-       .enum_fmt = mt9v011_enum_fmt,
-       .try_fmt = mt9v011_try_fmt,
-       .s_fmt = mt9v011_s_fmt,
+       .enum_mbus_fmt = mt9v011_enum_mbus_fmt,
+       .try_mbus_fmt = mt9v011_try_mbus_fmt,
+       .s_mbus_fmt = mt9v011_s_mbus_fmt,
        .g_parm = mt9v011_g_parm,
        .s_parm = mt9v011_s_parm,
 };
@@ -627,9 +623,25 @@ static const struct i2c_device_id mt9v011_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, mt9v011_id);
 
-static struct v4l2_i2c_driver_data v4l2_i2c_data = {
-       .name = "mt9v011",
-       .probe = mt9v011_probe,
-       .remove = mt9v011_remove,
-       .id_table = mt9v011_id,
+static struct i2c_driver mt9v011_driver = {
+       .driver = {
+               .owner  = THIS_MODULE,
+               .name   = "mt9v011",
+       },
+       .probe          = mt9v011_probe,
+       .remove         = mt9v011_remove,
+       .id_table       = mt9v011_id,
 };
+
+static __init int init_mt9v011(void)
+{
+       return i2c_add_driver(&mt9v011_driver);
+}
+
+static __exit void exit_mt9v011(void)
+{
+       i2c_del_driver(&mt9v011_driver);
+}
+
+module_init(init_mt9v011);
+module_exit(exit_mt9v011);