From: Yong He <yong.m...@intel.com>
Subject: [PATCH] MRST Tablet camera driver ver-0.954, fix 9495

Bug 9495 - OV5640 preview is not correct with camera driver 0.952

Solution,
add missing end mark of 5640 firmware load reg write list.
add 5640 i2c write fail retry, there should be NONE mismatch between reg 
written and immediate read back.
add exposure reset values and only switch from preview (smaller than 720P) to
snapshot (higher than 720P) need exposure restore.

Signed-off-by: Yong He <yong.m...@intel.com>
Index: linux-2.6.37/drivers/staging/mrstci/mrstov5640/ov5640.h
===================================================================
--- linux-2.6.37/drivers/staging/mrstci/mrstov5640/ov5640.h       (revision 119)
+++ linux-2.6.37/drivers/staging/mrstci/mrstov5640/ov5640.h    (working copy)
@@ -3984,6 +3984,9 @@
       {0x3027, 0x00},
       {0x3028, 0x00},
       {0x3029, 0xFF},
+
+       /* end mark of reg list */
+       {0xffff, 0xff},
};

Index: linux-2.6.37/drivers/staging/mrstci/mrstov5640/mrstov5640.c
===================================================================
--- linux-2.6.37/drivers/staging/mrstci/mrstov5640/mrstov5640.c        
(revision 119)
+++ linux-2.6.37/drivers/staging/mrstci/mrstov5640/mrstov5640.c     (working 
copy)
@@ -50,7 +50,7 @@
#include "ci_sensor_common.h"
#include "ov5640.h"
-#define DRIVER_VERSION "0.953"
+#define DRIVER_VERSION "0.954"
 #define GPIO_FLASH 45
static int ov5640_flash=0;
@@ -192,6 +192,7 @@
  */
 #define RESOLUTION_INDEX_VGA 6
+#define RESOLUTION_INDEX_720P 4
#define OV5640_FW_INITED 1
#define OV5640_FW_RESET 0
@@ -289,18 +290,28 @@
       return ret;
}
+#define OV5640_I2C_MAX_RETRY 3
static int ov5640_write_array(struct i2c_client *c, struct regval_list *vals)
{
       struct regval_list *p;
       u8 read_val = 0;
       int err_num = 0;
       int i = 0;
+       int retry;
       p = vals;
       while (p->reg_num != 0xffff) {
+                retry = OV5640_I2C_MAX_RETRY;
+__ov5640_reg_wr_retry:
                ov5640_write(c, p->reg_num, p->value);
                ov5640_read(c, p->reg_num, &read_val);
-                 if (read_val != p->value)
+                if (read_val != p->value) {
+                          if (retry-- > 0)
+                                   goto __ov5640_reg_wr_retry;
                          err_num++;
+                          dev_dbg(&c->adapter->dev,
+                                   "ov5640 wr reg err (0x%04x) <- (0x%02x) 
actual (0x%02x)\n",
+                                   p->reg_num, p->value, read_val);
+                }
                p++;
                i++;
       }
@@ -460,7 +471,7 @@
       return ret;
}
-#define OV5640_FW_LOAD_EXPECTED_MAX_MISMATCH 100
+#define OV5640_FW_LOAD_EXPECTED_MAX_MISMATCH 0
static int ov5640_af_init(struct i2c_client *c)
{
       int ret;
@@ -558,6 +569,10 @@
                spin_unlock_irqrestore(&ov5640_status.state_lock, flags);
       }
+       /* reset default exposure settings */
+       ov5640_status.preview.shutter16 = 0x200;
+       ov5640_status.preview.gain16 = 0x10;
+
       printk(KERN_INFO "PM: ov5640 standby called\n");
}
@@ -1118,11 +1133,15 @@
                          ret += ov5640_write_array(client, res_index->regs);
                          ov5640_restore_hw_status(client);
-                           ov5640_restore_gain(sd);
-                           ov5640_restore_expo(sd,
+                          /* only switch from preview (smaller than 720P) to
+                          * snapshot (higher than 720P) need exposure restore*/
+                          if (ov5640_status.current_res_i < 
RESOLUTION_INDEX_720P) {
+                                   ov5640_restore_expo(sd,
                                            previous_res_i, target_res_index);
-                           ov5640_set_b_filter(sd, target_res_index);
-                           ov5640_af_change_res(client);
+                                   ov5640_restore_gain(sd);
+                                   ov5640_set_b_filter(sd, target_res_index);
+                                   ov5640_af_change_res(client);
+                          }
                } else {
                          spin_unlock_irqrestore(
                                            &ov5640_status.state_lock, flags);

Best Regards,

Yong He
Software Engineer, PCSD SW Solutions,
Intel Asia-Pacific R&D Ltd.
Phone (+86) 21-61166334
Lab (+86) 21-61167881

Attachment: linux-2.6.37-camera-ov5640-ov9740-version-0.953_to_0.954.patch
Description: linux-2.6.37-camera-ov5640-ov9740-version-0.953_to_0.954.patch

_______________________________________________
MeeGo-kernel mailing list
MeeGo-kernel@lists.meego.com
http://lists.meego.com/listinfo/meego-kernel

Reply via email to