60c25d60232fad63035b4e411a3171af27962d35
[openwrt/staging/ldir.git] /
1 From a701a312ff709f0dcd6862be6e8fcc328379c4d1 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 3 Jan 2023 16:53:37 +0000
4 Subject: [PATCH] media: dw9807-vcm: Smooth the first user movement of
5 the lens
6
7 The power up/down sequence is already ramped. Extend this to
8 the first user movement as well, as this will generally avoid
9 the "tick" noises due to rapid movements and overshooting.
10 Subsequent movements are generally smaller and so don't cause
11 issues.
12
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
14 ---
15 drivers/media/i2c/dw9807-vcm.c | 7 ++++++-
16 1 file changed, 6 insertions(+), 1 deletion(-)
17
18 --- a/drivers/media/i2c/dw9807-vcm.c
19 +++ b/drivers/media/i2c/dw9807-vcm.c
20 @@ -62,6 +62,7 @@ struct dw9807_device {
21 u16 idle_pos;
22 struct regulator *vdd;
23 struct notifier_block notifier;
24 + bool first;
25 };
26
27 static inline struct dw9807_device *sd_to_dw9807_vcm(
28 @@ -176,6 +177,8 @@ static int dw9807_active(struct dw9807_d
29 return ret;
30 }
31
32 + dw9807_dev->first = true;
33 +
34 return dw9807_ramp(client, dw9807_dev->idle_pos, dw9807_dev->current_val);
35 }
36
37 @@ -230,9 +233,11 @@ static int dw9807_set_ctrl(struct v4l2_c
38
39 if (ctrl->id == V4L2_CID_FOCUS_ABSOLUTE) {
40 struct i2c_client *client = v4l2_get_subdevdata(&dev_vcm->sd);
41 + int start = (dev_vcm->first) ? dev_vcm->current_val : ctrl->val;
42
43 + dev_vcm->first = false;
44 dev_vcm->current_val = ctrl->val;
45 - return dw9807_ramp(client, ctrl->val, ctrl->val);
46 + return dw9807_ramp(client, start, ctrl->val);
47 }
48
49 return -EINVAL;