ov8830: HACK: allow driver to function even if AF detection fails
authorTuukka Toivonen <tuukka.toivonen@intel.com>
Mon, 16 Apr 2012 12:58:49 +0000 (15:58 +0300)
committerbuildbot <buildbot@intel.com>
Tue, 17 Apr 2012 17:32:39 +0000 (10:32 -0700)
BZ: 27473

With some hardware, gpio pins are not properly configured to supply
power to the lens driver chip and consequently the chip will not
respond to i2c commands. This caused the drv201 detection function
to fail and whole ov8830 driver to fail functioning at all, even
from driving the sensor.

This patch allows ov8830 driver to drive sensor even if the lens driver
chip detection fails by ignoring the error code returned by the drv201
detection function. In this case only the focus functionality is disabled.

Change-Id: I552f638d8b7f84017feee62858094bc6b8d0726f
Signed-off-by: Tuukka Toivonen <tuukka.toivonen@intel.com>
Reviewed-on: http://android.intel.com:8080/43578
Reviewed-by: Cohen, David A <david.a.cohen@intel.com>
Reviewed-by: Koski, Anttu <anttu.koski@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/ov8830.c
drivers/media/video/ov8830.h

index d514ea5..689de29 100644 (file)
@@ -1778,6 +1778,7 @@ static int drv201_power_up(struct v4l2_subdev *sd)
        }
 
        dev->focus = DRV201_MAX_FOCUS_POS;
+       dev->initialized = true;
 
        v4l2_info(client, "detected drv201\n");
        return 0;
@@ -1799,6 +1800,9 @@ static int drv201_t_focus_abs(struct v4l2_subdev *sd, s32 value)
        struct drv201_device *dev = to_drv201_device(sd);
        int r;
 
+       if (!dev->initialized)
+               return -ENODEV;
+
        value = clamp(value, 0, DRV201_MAX_FOCUS_POS);
        r = drv201_write16(sd, DRV201_VCM_CURRENT,
                           DRV201_MAX_FOCUS_POS - value);
@@ -2004,9 +2008,7 @@ static int ov8830_s_power(struct v4l2_subdev *sd, int on)
                ret = power_up(sd);
                if (ret)
                        return ret;
-               ret = drv201_power_up(sd);
-               if (ret)
-                       return ret;
+               drv201_power_up(sd);
 
                dev->power = 1;
                /* init motor initial position */
index 5a754b9..8561dc5 100644 (file)
@@ -50,6 +50,7 @@
 
 /* drv201 device structure */
 struct drv201_device {
+       bool initialized;               /* true if drv201 is detected */
        s32 focus;                      /* Current focus value */
        struct timespec focus_time;     /* Time when focus was last time set */
        __u8 buffer[4];                 /* Used for i2c transactions */