media: video: tegra: ar0832: Add slew rate support
Naren Bhat [Mon, 20 Aug 2012 19:39:16 +0000 (12:39 -0700)]
Add slew rate support for AR0832 focuser.

bug 1028733

Change-Id: I4fd0245fad7f7c820fc30a7c4bfc970d52903da6
Signed-off-by: Naren Bhat <nbhat@nvidia.com>
Reviewed-on: http://git-master/r/124695
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
Reviewed-by: Frank Chen <frankc@nvidia.com>
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>

drivers/media/video/tegra/ar0832_main.c
include/media/nvc_focus.h

index ea8dfdd..b1f43da 100644 (file)
 #include <linux/regulator/consumer.h>
 #include <media/ar0832_main.h>
 
+
 #define POS_ACTUAL_LOW                 0
 #define POS_ACTUAL_HIGH                        255
 #define SETTLE_TIME                            100
-#define SLEW_RATE_DEFAULT              1
+#define AR0832_SLEW_RATE_DISABLED  0
+#define AR0832_SLEW_RATE_SLOWEST   7
 
 
 struct ar0832_sensor_info {
@@ -1930,13 +1932,26 @@ static int ar0832_focuser_set_config(struct ar0832_dev *dev)
        struct i2c_client *i2c_client = dev->i2c_client;
        struct ar0832_reg reg_vcm_ctrl, reg_vcm_step_time;
        int ret = 0;
-       u8 vcm_slew = 1;
+       u8 vcm_slew;
+       u16 vcm_control_data;
+       u16 vcm_step_time = 1024;
+
+       /* slew_rate of disabled (0) or default value (1) will disable    */
+       /* the slew rate in this case. Any value of 2 onwards will enable */
+       /* the slew rate to a different degree */
+       if (dev->focuser_info->config.slew_rate == SLEW_RATE_DISABLED ||
+          dev->focuser_info->config.slew_rate == SLEW_RATE_DEFAULT)
+               vcm_slew = AR0832_SLEW_RATE_DISABLED;
+       else
+               vcm_slew = dev->focuser_info->config.slew_rate - 1;
+
+       if (vcm_slew > AR0832_SLEW_RATE_SLOWEST)
+               vcm_slew = AR0832_SLEW_RATE_SLOWEST;
 
        /* bit15(0x80) means that VCM driver enable bit. */
        /* bit3(0x08) means that keep VCM(AF position) */
        /* while sensor is in soft standby mode during mode transitions. */
-       u16 vcm_control_data = (0x80 << 8 | (0x08 | (vcm_slew & 0x07)));
-       u16 vcm_step_time = 1024;
+       vcm_control_data = (0x80 << 8 | (0x08 | (vcm_slew & 0x07)));
 
        ar0832_get_focuser_vcm_control_regs(&reg_vcm_ctrl, vcm_control_data);
        ret = ar0832_write_reg16(dev->i2c_client, reg_vcm_ctrl.addr,
index e37d897..2c60db3 100644 (file)
 
 #define AF_POS_INVALID_VALUE INT_MAX
 
+/* These are the slew rate values coming down from the configuration */
+/* Disabled is the same as fastest. Default is the default */
+/* slew rate configuration in the focuser */
+#define SLEW_RATE_DISABLED             0
+#define SLEW_RATE_DEFAULT              1
+#define SLEW_RATE_SLOWEST              9
+
+
 enum nvc_focus_sts {
        NVC_FOCUS_STS_UNKNOWN           = 1,
        NVC_FOCUS_STS_NO_DEVICE,