diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2014-07-17 17:31:23 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-07-17 17:44:38 +0200 |
commit | 0d5e8c4313c83dc2d60519a219d517a13ba8a432 (patch) | |
tree | 5a9f6581e1cc493f7dc624e51e7b65598a419005 /drivers/media/i2c/soc_camera/mt9t031.c | |
parent | [media] DocBook improvement for U8 and U16 control types (diff) | |
download | linux-0d5e8c4313c83dc2d60519a219d517a13ba8a432.tar.xz linux-0d5e8c4313c83dc2d60519a219d517a13ba8a432.zip |
[media] Fix 64-bit division fall-out from 64-bit control ranges
Commit 0ba2aeb6dab80920edd9cf5b93b1ea4d6913b8f3 increased the internal control ranges
to 64 bit, but that caused problems in drivers that use the minimum/maximum/step/default_value
control values in a division or modulus operations since not all architectures support
those natively.
Luckily, in almost all cases it is possible to just cast to 32 bits (the control value
is known to be 32 bits, so it is safe to cast). Only in v4l2-ctrls.c was it necessary to
use do_div in one function.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/i2c/soc_camera/mt9t031.c')
-rw-r--r-- | drivers/media/i2c/soc_camera/mt9t031.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c index ee7bb0ffcecb..f8358c4071a9 100644 --- a/drivers/media/i2c/soc_camera/mt9t031.c +++ b/drivers/media/i2c/soc_camera/mt9t031.c @@ -474,7 +474,7 @@ static int mt9t031_s_ctrl(struct v4l2_ctrl *ctrl) if (ctrl->val <= ctrl->default_value) { /* Pack it into 0..1 step 0.125, register values 0..8 */ unsigned long range = ctrl->default_value - ctrl->minimum; - data = ((ctrl->val - ctrl->minimum) * 8 + range / 2) / range; + data = ((ctrl->val - (s32)ctrl->minimum) * 8 + range / 2) / range; dev_dbg(&client->dev, "Setting gain %d\n", data); data = reg_write(client, MT9T031_GLOBAL_GAIN, data); @@ -485,7 +485,7 @@ static int mt9t031_s_ctrl(struct v4l2_ctrl *ctrl) /* We assume qctrl->maximum - qctrl->default_value - 1 > 0 */ unsigned long range = ctrl->maximum - ctrl->default_value - 1; /* calculated gain: map 65..127 to 9..1024 step 0.125 */ - unsigned long gain = ((ctrl->val - ctrl->default_value - 1) * + unsigned long gain = ((ctrl->val - (s32)ctrl->default_value - 1) * 1015 + range / 2) / range + 9; if (gain <= 32) /* calculated gain 9..32 -> 9..32 */ @@ -507,7 +507,7 @@ static int mt9t031_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_EXPOSURE_AUTO: if (ctrl->val == V4L2_EXPOSURE_MANUAL) { unsigned int range = exp->maximum - exp->minimum; - unsigned int shutter = ((exp->val - exp->minimum) * 1048 + + unsigned int shutter = ((exp->val - (s32)exp->minimum) * 1048 + range / 2) / range + 1; u32 old; |