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
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
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 drivers/media/i2c/dw9807-vcm.c | 7 ++++++-
16 1 file changed, 6 insertions(+), 1 deletion(-)
18 --- a/drivers/media/i2c/dw9807-vcm.c
19 +++ b/drivers/media/i2c/dw9807-vcm.c
20 @@ -62,6 +62,7 @@ struct dw9807_device {
22 struct regulator *vdd;
23 struct notifier_block notifier;
27 static inline struct dw9807_device *sd_to_dw9807_vcm(
28 @@ -176,6 +177,8 @@ static int dw9807_active(struct dw9807_d
32 + dw9807_dev->first = true;
34 return dw9807_ramp(client, dw9807_dev->idle_pos, dw9807_dev->current_val);
37 @@ -230,9 +233,11 @@ static int dw9807_set_ctrl(struct v4l2_c
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;
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);