atomisp: lc898211: add temporary code for early development stage
authorDavid Cohen <david.a.cohen@intel.com>
Wed, 2 May 2012 14:51:47 +0000 (17:51 +0300)
committerbuildbot <buildbot@intel.com>
Mon, 7 May 2012 16:50:39 +0000 (09:50 -0700)
BZ: 27947

lc898211 driver is still in early development stage as 3A library tuning
doesn't work well yet. This patch adds debugging messages and 8-bit to
10-bit conversion for compatibility with current 3A library.

This patch must be reverted once 3A library support is implemented.

Change-Id: I5cff971e93f16842ef74962eb7c3e43bdbe15737
Signed-off-by: David Cohen <david.a.cohen@intel.com>
Reviewed-on: http://android.intel.com:8080/47098
Reviewed-by: Kruger, Jozef <jozef.kruger@intel.com>
Reviewed-by: Wang, Wen W <wen.w.wang@intel.com>
Reviewed-by: Samurov, Vitali <vitali.samurov@intel.com>
Reviewed-by: Koskinen, Ilkka <ilkka.koskinen@intel.com>
Tested-by: Koski, Anttu <anttu.koski@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/media/video/lc898211.c

index 888e69c..d380504 100644 (file)
 
 #include "lc898211.h"
 
+
+/*
+ * HACK: make driver to work with current 8-bit 3A while a correct 10-bit
+ * is coming. This is intended for test only. It does not guarantee accurate
+ * 3A work.
+ */
+#define LC898211_CONV_8_TO_10BIT
+
+/* Enable debug messages for development purpose */
+#define LC898211_DEBUG
+
 #define to_lc898211_dev(sd) container_of(sd, struct lc898211_dev, sd)
 
 static int
@@ -251,6 +262,18 @@ static int lc898211_t_focus_abs(struct v4l2_subdev *sd, s32 value)
                return ret;
        }
 
+#ifdef LC898211_DEBUG
+       {
+               s16 target;
+               lc898211_read_reg(client, LC898211_16BIT,
+                                 LC898211_REG16_STMVEND, &target);
+               target = be16_to_cpu(target);
+               target /= (1 << 6);
+
+               printk(KERN_INFO "%s: focus: cur:%d read:%d applied:%d\n",
+                      __func__, focus, value, target);
+       }
+#endif
        return 0;
 }
 
@@ -325,6 +348,18 @@ static int lc898211_t_focus_rel(struct v4l2_subdev *sd, s32 value)
        struct i2c_client *client = v4l2_get_subdevdata(sd);
        s16 focus;
        int ret;
+#ifdef LC898211_CONV_8_TO_10BIT
+       int rate = dev->af_tun.focus_abs_min - dev->af_tun.focus_abs_max;
+       s32 old_value = value;
+
+       rate /= 256;
+       value *= rate;
+       value <<= 1; /* Random hack to make 3A work better */
+#ifdef LC898211_DEBUG
+       printk(KERN_INFO "%s: rate:%d old_value:%d new_value:%d\n",
+              __func__, rate, old_value, value);
+#endif
+#endif
 
        ret = __lc898211_q_focus_abs(sd, &focus);
        if (ret < 0) {
@@ -337,6 +372,11 @@ static int lc898211_t_focus_rel(struct v4l2_subdev *sd, s32 value)
                focus >>= 6;
        }
 
+#ifdef LC898211_DEBUG
+       printk(KERN_INFO "%s: cur_focus:%d requesting:%d\n",
+              __func__, focus, focus + value);
+#endif
+
        return lc898211_t_focus_abs(sd, focus + value);
 }
 
@@ -410,6 +450,17 @@ static int lc898211_q_focus_abs(struct v4l2_subdev *sd, s32 *value)
        if (ret < 0)
                return ret;
 
+#ifdef LC898211_CONV_8_TO_10BIT
+       {
+               struct lc898211_dev *dev = to_lc898211_dev(sd);
+               int rate =  dev->af_tun.focus_abs_min -
+                           dev->af_tun.focus_abs_max;
+               rate = rate / 255;
+               focus -= dev->af_tun.focus_abs_max;
+               focus *= rate;
+       }
+#endif
+
        *value = focus;
 
        return 0;
@@ -925,6 +976,11 @@ static int lc898211_probe(struct i2c_client *client,
                goto err;
        }
 
+#ifdef LC898211_DEBUG
+       printk(KERN_INFO "%s: min %d max %d inf %d macro %d\n", __func__,
+              dev->af_tun.focus_abs_min, dev->af_tun.focus_abs_max,
+              dev->af_tun.inf_pos, dev->af_tun.mac_pos);
+#endif
        lc898211_power_down(&dev->sd);
 
        v4l2_info(client, "LC898211 actuator successfully initialized\n");