media: video: tegra: ar0832: Make focuser range, slew rate tunable
Naren Bhat [Thu, 17 May 2012 01:49:21 +0000 (18:49 -0700)]
The range parameters & slew rate from the blocks-camera are being passed
down to ODM and then to kernel. Generic structure added for sharing
the data between ODM and kernel instead of specific structure.

Bug 954874

Change-Id: I84656e36a5a2721c007de78aa5c20f5dfeb00361
Signed-off-by: Naren Bhat <nbhat@nvidia.com>
Reviewed-on: http://git-master/r/102077
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jon Mayo <jmayo@nvidia.com>

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

index c415f65..0032908 100644 (file)
 
 #include <media/ar0832_main.h>
 
-#define POS_LOW  0
-#define POS_HIGH 1000
-#define SETTLETIME_MS 100
+#define POS_ACTUAL_LOW                 0
+#define POS_ACTUAL_HIGH                        255
+#define SETTLE_TIME                            100
+#define SLEW_RATE_DEFAULT              1
+
 
 struct ar0832_sensor_info {
        int mode;
@@ -35,7 +37,7 @@ struct ar0832_sensor_info {
 };
 
 struct ar0832_focuser_info {
-       struct ar0832_focuser_config config;
+       struct nv_focuser_config config;
        int focuser_init_flag;
        u16 last_position;
 };
@@ -2162,7 +2164,8 @@ static long ar0832_ioctl(struct file *file,
                        "%s AR0832_FOCUSER_IOCTL_GET_CONFIG\n", __func__);
                if (copy_to_user((void __user *) arg,
                                 &dev->focuser_info->config,
-                                sizeof(dev->focuser_info->config))) {
+                                sizeof(struct nv_focuser_config)))
+        {
                        dev_err(&i2c_client->dev,
                                "%s: AR0832_FOCUSER_IOCTL_GET_CONFIG failed\n",
                                __func__);
@@ -2170,6 +2173,25 @@ static long ar0832_ioctl(struct file *file,
                }
                return 0;
 
+       case AR0832_FOCUSER_IOCTL_SET_CONFIG:
+               dev_info(&i2c_client->dev,
+                               "%s AR0832_FOCUSER_IOCTL_SET_CONFIG\n", __func__);
+               if (copy_from_user(&dev->focuser_info->config,
+                       (const void __user *)arg,
+                       sizeof(struct nv_focuser_config)))
+               {
+                       dev_err(&i2c_client->dev,
+                                       "%s: AR0832_FOCUSER_IOCTL_SET_CONFIG failed\n", __func__);
+                       return -EFAULT;
+               }
+               dev_dbg(&i2c_client->dev,
+                       "%s AR0832_FOCUSER_IOCTL_SET_CONFIG sucess "
+                       "slew_rate %i, pos_working_high %i, pos_working_low %i\n",
+                       __func__, dev->focuser_info->config.slew_rate,
+                       dev->focuser_info->config.pos_working_low,
+                       dev->focuser_info->config.pos_working_high);
+               return 0;
+
        case AR0832_FOCUSER_IOCTL_SET_POSITION:
                dev_dbg(&i2c_client->dev,
                        "%s AR0832_FOCUSER_IOCTL_SET_POSITION\n", __func__);
@@ -2445,9 +2467,12 @@ static int ar0832_probe(struct i2c_client *client,
        dev->i2c_client = client;
 
        /* focuser */
-       dev->focuser_info->config.settle_time = SETTLETIME_MS;
-       dev->focuser_info->config.pos_low = POS_LOW;
-       dev->focuser_info->config.pos_high = POS_HIGH;
+       dev->focuser_info->config.settle_time = SETTLE_TIME;
+       dev->focuser_info->config.slew_rate = SLEW_RATE_DEFAULT;
+       dev->focuser_info->config.pos_actual_low = POS_ACTUAL_LOW;
+       dev->focuser_info->config.pos_actual_high = POS_ACTUAL_HIGH;
+       dev->focuser_info->config.pos_working_low = POS_ACTUAL_LOW;
+       dev->focuser_info->config.pos_working_high = POS_ACTUAL_HIGH;
 
        snprintf(dev->dname, sizeof(dev->dname), "%s-%s",
                id->name, dev->pdata->id);
index f5e3713..fe46c22 100644 (file)
@@ -12,6 +12,7 @@
 #define __AR0832_MAIN_H__
 
 #include <linux/ioctl.h> /* For IOCTL macros */
+#include <media/nvc_focus.h>
 
 #define AR0832_IOCTL_SET_MODE                  _IOW('o', 0x01, struct ar0832_mode)
 #define AR0832_IOCTL_SET_FRAME_LENGTH          _IOW('o', 0x02, __u32)
 #define AR0832_IOCTL_SET_POWER_ON              _IOW('o', 0x08, struct ar0832_mode)
 #define AR0832_IOCTL_SET_SENSOR_REGION         _IOW('o', 0x09, struct ar0832_stereo_region)
 
-#define AR0832_FOCUSER_IOCTL_GET_CONFIG                _IOR('o', 0x10, struct ar0832_focuser_config)
+#define AR0832_FOCUSER_IOCTL_GET_CONFIG                _IOR('o', 0x10, struct nv_focuser_config)
 #define AR0832_FOCUSER_IOCTL_SET_POSITION      _IOW('o', 0x11, __u32)
 
 #define AR0832_IOCTL_GET_SENSOR_ID             _IOR('o', 0x12, __u16)
+#define AR0832_FOCUSER_IOCTL_SET_CONFIG                _IOW('o', 0x13, struct nv_focuser_config)
 
 #define AR0832_SENSOR_ID_8141                  0x1006
 #define AR0832_SENSOR_ID_8140                  0x3006
@@ -85,15 +87,6 @@ struct ar0832_stereo_region {
        struct ar0832_point image_end;
 };
 
-struct ar0832_focuser_config {
-       __u32 settle_time;
-       __u32 actuator_range;
-       __u32 pos_low;
-       __u32 pos_high;
-       __u32 focal_length;
-       __u32 fnumber;
-       __u32 max_aperture;
-};
 
 #ifdef __KERNEL__
 struct ar0832_platform_data {
index bed9df1..c6ff1fa 100644 (file)
@@ -59,5 +59,43 @@ struct nvc_focus_cap {
        __u32 focus_infinity;
 } __packed;
 
+
+#define NV_FOCUSER_SET_MAX              10
+#define NV_FOCUSER_SET_DISTANCE_PAIR    16
+
+struct nv_focuser_set_dist_pairs {
+       __s32 fdn;
+       __s32 distance;
+};
+
+struct nv_focuser_set {
+       __s32 posture;
+       __s32 macro;
+       __s32 hyper;
+       __s32 inf;
+       __s32 hysteresis;
+       __u32 settle_time;
+       __s32 macro_offset;
+       __s32 inf_offset;
+       __u32 num_dist_pairs;
+       struct nv_focuser_set_dist_pairs dist_pair[NV_FOCUSER_SET_DISTANCE_PAIR];
+};
+
+struct nv_focuser_config {
+       __u32 focal_length;
+       __u32 fnumber;
+       __u32 max_aperture;
+       __u32 actuator_range;
+       __u32 settle_time;
+       __s32 pos_working_low;
+       __s32 pos_working_high;
+       __s32 pos_actual_low;
+       __s32 pos_actual_high;
+       __u32 slew_rate;
+       __u32 circle_of_confusion;
+       struct nv_focuser_set focuser_set[NV_FOCUSER_SET_MAX];
+};
+
+
 #endif /* __NVC_FOCUS_H__ */