V4L/DVB (8318): OV7670: don't reject unsupported settings
[pandora-kernel.git] / drivers / media / video / ov7670.c
index f8f21dd..5e0d4e2 100644 (file)
@@ -12,7 +12,6 @@
  */
 #include <linux/init.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/videodev.h>
@@ -407,8 +406,10 @@ static int ov7670_read(struct i2c_client *c, unsigned char reg,
        int ret;
 
        ret = i2c_smbus_read_byte_data(c, reg);
-       if (ret >= 0)
+       if (ret >= 0) {
                *value = (unsigned char) ret;
+               ret = 0;
+       }
        return ret;
 }
 
@@ -416,7 +417,10 @@ static int ov7670_read(struct i2c_client *c, unsigned char reg,
 static int ov7670_write(struct i2c_client *c, unsigned char reg,
                unsigned char value)
 {
-       return i2c_smbus_write_byte_data(c, reg, value);
+       int ret = i2c_smbus_write_byte_data(c, reg, value);
+       if (reg == REG_COM7 && (value & COM7_RESET))
+               msleep(2);  /* Wait for reset to run */
+       return ret;
 }
 
 
@@ -678,17 +682,17 @@ static int ov7670_try_fmt(struct i2c_client *c, struct v4l2_format *fmt,
        for (index = 0; index < N_OV7670_FMTS; index++)
                if (ov7670_formats[index].pixelformat == pix->pixelformat)
                        break;
-       if (index >= N_OV7670_FMTS)
-               return -EINVAL;
+       if (index >= N_OV7670_FMTS) {
+               /* default to first format */
+               index = 0;
+               pix->pixelformat = ov7670_formats[0].pixelformat;
+       }
        if (ret_fmt != NULL)
                *ret_fmt = ov7670_formats + index;
        /*
         * Fields: the OV devices claim to be progressive.
         */
-       if (pix->field == V4L2_FIELD_ANY)
-               pix->field = V4L2_FIELD_NONE;
-       else if (pix->field != V4L2_FIELD_NONE)
-               return -EINVAL;
+       pix->field = V4L2_FIELD_NONE;
        /*
         * Round requested image size down to the nearest
         * we support, but not below the smallest.