diff options
author | Naren Bhat <nbhat@nvidia.com> | 2012-08-27 19:21:23 -0700 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-09-14 12:00:11 -0700 |
commit | 358ebef7134c4350dfcb65cabfb4644a40666a5b (patch) | |
tree | 365b54be308d413aa23a5c113f2e41658d5d6554 /drivers/media | |
parent | 3b848bc952cea5b6e657a4b8242a81279c0f0233 (diff) |
media:video:tegra Settletime consolidate, cleanup
Two instances of settle time consolidated into one. Actuator range
is removed. For focusers sh532u, ar0832 and ad5816.
Bug 1032214
Change-Id: Ieba1e587aa3518889c32ba3f346ed10e4490aa0a
Signed-off-by: Naren Bhat <nbhat@nvidia.com>
Reviewed-on: http://git-master/r/130828
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/tegra/ad5816.c | 1 | ||||
-rw-r--r-- | drivers/media/video/tegra/ar0832_main.c | 54 | ||||
-rw-r--r-- | drivers/media/video/tegra/sh532u.c | 54 |
3 files changed, 90 insertions, 19 deletions
diff --git a/drivers/media/video/tegra/ad5816.c b/drivers/media/video/tegra/ad5816.c index e5ec9545918c..5204b9a8d849 100644 --- a/drivers/media/video/tegra/ad5816.c +++ b/drivers/media/video/tegra/ad5816.c @@ -681,7 +681,6 @@ static void ad5816_get_focuser_capabilities(struct ad5816_info *info) info->nv_config.fnumber = info->nvc.fnumber; info->nv_config.max_aperture = info->nvc.fnumber; info->nv_config.range_ends_reversed = 0; - info->nv_config.settle_time = info->cap.settle_time; info->nv_config.pos_working_low = AF_POS_INVALID_VALUE; info->nv_config.pos_working_high = AF_POS_INVALID_VALUE; diff --git a/drivers/media/video/tegra/ar0832_main.c b/drivers/media/video/tegra/ar0832_main.c index 93457d8e5f92..89917afc371e 100644 --- a/drivers/media/video/tegra/ar0832_main.c +++ b/drivers/media/video/tegra/ar0832_main.c @@ -2071,8 +2071,51 @@ int ar0832_get_sensorid(struct ar0832_dev *dev, u16 *sensor_id) return ret; } +static long ar0832_set_focuser_capabilities(struct ar0832_dev *dev, + unsigned long arg) +{ + struct i2c_client *i2c_client = dev->i2c_client; + struct nv_focuser_config config; + + /* backup the current contents of dev->focuser_info->config for + * selective restore later on */ + memcpy(&config, &dev->focuser_info->config, + sizeof(struct nv_focuser_config)); + + if (copy_from_user(&dev->focuser_info->config, + (const void __user *)arg, + sizeof(struct nv_focuser_config))) { + dev_err(&i2c_client->dev, + "%s: copy_from_user() failed\n", __func__); + return -EFAULT; + } + + /* Now do selectively restore members that are overwriten */ + + /* Unconditionally restore actual low and high positions */ + dev->focuser_info->config.pos_actual_low = config.pos_actual_low; + dev->focuser_info->config.pos_actual_high = config.pos_actual_high; + + if (dev->focuser_info->config.pos_working_low == AF_POS_INVALID_VALUE) + dev->focuser_info->config.pos_working_low = + config.pos_working_low; + + if (dev->focuser_info->config.pos_working_high == AF_POS_INVALID_VALUE) + dev->focuser_info->config.pos_working_high = + config.pos_working_high; + + if (dev->focuser_info->config.focuser_set[0].settle_time == INT_MAX) + dev->focuser_info->config.focuser_set[0].settle_time = + config.focuser_set[0].settle_time; + + if (dev->focuser_info->config.slew_rate == INT_MAX) + dev->focuser_info->config.slew_rate = config.slew_rate; + + return 0; +} + static long ar0832_ioctl(struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { int err; struct ar0832_dev *dev = file->private_data; @@ -2189,12 +2232,9 @@ static long ar0832_ioctl(struct file *file, 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))) - { + if (ar0832_set_focuser_capabilities(dev, arg) != 0) { dev_err(&i2c_client->dev, - "%s: AR0832_FOCUSER_IOCTL_SET_CONFIG failed\n", __func__); + "%s: AR0832_IOCTL_SET_CONFIG failed\n", __func__); return -EFAULT; } dev_dbg(&i2c_client->dev, @@ -2480,7 +2520,7 @@ static int ar0832_probe(struct i2c_client *client, dev->i2c_client = client; /* focuser */ - dev->focuser_info->config.settle_time = SETTLE_TIME; + dev->focuser_info->config.focuser_set[0].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; diff --git a/drivers/media/video/tegra/sh532u.c b/drivers/media/video/tegra/sh532u.c index 86d85765c838..4cd02f4d6321 100644 --- a/drivers/media/video/tegra/sh532u.c +++ b/drivers/media/video/tegra/sh532u.c @@ -1367,12 +1367,11 @@ static void sh532u_get_focuser_capabilities(struct sh532u_info *info) info->config.max_aperture = info->nvc.fnumber; info->config.range_ends_reversed = (SH532U_POS_SIGN_CHANGER == -1) ? 1 : 0; - - info->config.settle_time = info->cap.settle_time; - /* * We do not use pos_working_low and pos_working_high - * in the kernel driver. + * in the kernel driver. It is OK to set them to invalid + * as the caller will reconstruct them from + * focuser_set[0].inf and focuser_set[0].macro */ info->config.pos_working_low = AF_POS_INVALID_VALUE; info->config.pos_working_high = AF_POS_INVALID_VALUE; @@ -1390,11 +1389,11 @@ static void sh532u_get_focuser_capabilities(struct sh532u_info *info) * Till we have these routines, we pass them up as part of the get call. */ info->config.num_focuser_sets = 1; - info->config.focuser_set[0].posture = 'S'; + info->config.focuser_set[0].posture = 's'; info->config.focuser_set[0].macro = info->cap.focus_macro; info->config.focuser_set[0].hyper = info->cap.focus_hyper; info->config.focuser_set[0].inf = info->cap.focus_infinity; - info->config.focuser_set[0].hysteresis = 0; + info->config.focuser_set[0].hysteresis = INT_MAX; info->config.focuser_set[0].settle_time = info->cap.settle_time; info->config.focuser_set[0].num_dist_pairs = 0; @@ -1408,6 +1407,13 @@ static void sh532u_get_focuser_capabilities(struct sh532u_info *info) static int sh532u_set_focuser_capabilities(struct sh532u_info *info, struct nvc_param *params) { + static struct nv_focuser_config config; + + /* backup the current contents of dev->focuser_info->config for + * selective restore later on */ + memcpy(&config, &info->config, + sizeof(struct nv_focuser_config)); + if (copy_from_user(&info->config, (const void __user *)params->p_value, params->sizeofvalue)) { dev_err(&info->i2c_client->dev, "%s Error: copy_from_user bytes %d\n", @@ -1415,12 +1421,38 @@ static int sh532u_set_focuser_capabilities(struct sh532u_info *info, return -EFAULT; } - /* info.config.focuser_set[0].posture, macro, hyper, infinity and - * hysterisis can remain there only. We need only settle_time & - * slew_rate for use here. - */ + /* Now do selectively restore members that are overwriten */ + + /* Unconditionally restore actual low and high positions */ + info->config.pos_actual_low = config.pos_actual_low; + info->config.pos_actual_high = config.pos_actual_high; + + if (info->config.pos_working_low == AF_POS_INVALID_VALUE) + info->config.pos_working_low = config.pos_working_low; + + if (info->config.pos_working_high == AF_POS_INVALID_VALUE) + info->config.pos_working_high = config.pos_working_high; + + if (info->config.slew_rate == INT_MAX) + info->config.slew_rate = config.slew_rate; + info->cap.slew_rate = info->config.slew_rate; + + if (info->config.focuser_set[0].settle_time == INT_MAX) + info->config.focuser_set[0].settle_time = + config.focuser_set[0].settle_time; info->cap.settle_time = info->config.focuser_set[0].settle_time; - info->config.slew_rate = info->config.slew_rate; + + if (info->config.focuser_set[0].macro == AF_POS_INVALID_VALUE) + info->config.focuser_set[0].macro = config.focuser_set[0].macro; + info->cap.focus_macro = info->config.focuser_set[0].macro; + + if (info->config.focuser_set[0].hyper == AF_POS_INVALID_VALUE) + info->config.focuser_set[0].hyper = config.focuser_set[0].hyper; + info->cap.focus_hyper = info->config.focuser_set[0].hyper; + + if (info->config.focuser_set[0].inf == AF_POS_INVALID_VALUE) + info->config.focuser_set[0].inf = config.focuser_set[0].inf; + info->cap.focus_infinity = info->config.focuser_set[0].inf; dev_dbg(&info->i2c_client->dev, "%s: copy_from_user bytes %d\n", __func__, params->sizeofvalue); |