Lines Matching +full:lens +full:- +full:focus
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2015--2017 Intel Corporation.
9 #include <media/v4l2-ctrls.h>
10 #include <media/v4l2-device.h>
11 #include <media/v4l2-event.h>
16 * This sets the minimum granularity for the focus positions.
17 * A value of 1 gives maximum accuracy for a desired focus position
21 * This acts as the minimum granularity of lens movement.
23 * uniformly adjusted for gradual lens movement, with desired
45 return container_of(ctrl->handler, struct dw9714_device, ctrls_vcm); in to_dw9714_vcm()
60 dev_err(&client->dev, "I2C write fail\n"); in dw9714_i2c_write()
61 return -EIO; in dw9714_i2c_write()
68 struct i2c_client *client = v4l2_get_subdevdata(&dw9714_dev->sd); in dw9714_t_focus_vcm()
70 dw9714_dev->current_val = val; in dw9714_t_focus_vcm()
79 if (ctrl->id == V4L2_CID_FOCUS_ABSOLUTE) in dw9714_set_ctrl()
80 return dw9714_t_focus_vcm(dev_vcm, ctrl->val); in dw9714_set_ctrl()
82 return -EINVAL; in dw9714_set_ctrl()
91 return pm_runtime_resume_and_get(sd->dev); in dw9714_open()
96 pm_runtime_put(sd->dev); in dw9714_close()
118 v4l2_async_unregister_subdev(&dw9714_dev->sd); in dw9714_subdev_cleanup()
119 v4l2_ctrl_handler_free(&dw9714_dev->ctrls_vcm); in dw9714_subdev_cleanup()
120 media_entity_cleanup(&dw9714_dev->sd.entity); in dw9714_subdev_cleanup()
125 struct v4l2_ctrl_handler *hdl = &dev_vcm->ctrls_vcm; in dw9714_init_controls()
133 if (hdl->error) in dw9714_init_controls()
134 dev_err(dev_vcm->sd.dev, "%s fail error: 0x%x\n", in dw9714_init_controls()
135 __func__, hdl->error); in dw9714_init_controls()
136 dev_vcm->sd.ctrl_handler = hdl; in dw9714_init_controls()
137 return hdl->error; in dw9714_init_controls()
145 dw9714_dev = devm_kzalloc(&client->dev, sizeof(*dw9714_dev), in dw9714_probe()
148 return -ENOMEM; in dw9714_probe()
150 dw9714_dev->vcc = devm_regulator_get(&client->dev, "vcc"); in dw9714_probe()
151 if (IS_ERR(dw9714_dev->vcc)) in dw9714_probe()
152 return PTR_ERR(dw9714_dev->vcc); in dw9714_probe()
154 rval = regulator_enable(dw9714_dev->vcc); in dw9714_probe()
156 dev_err(&client->dev, "failed to enable vcc: %d\n", rval); in dw9714_probe()
160 v4l2_i2c_subdev_init(&dw9714_dev->sd, client, &dw9714_ops); in dw9714_probe()
161 dw9714_dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | in dw9714_probe()
163 dw9714_dev->sd.internal_ops = &dw9714_int_ops; in dw9714_probe()
169 rval = media_entity_pads_init(&dw9714_dev->sd.entity, 0, NULL); in dw9714_probe()
173 dw9714_dev->sd.entity.function = MEDIA_ENT_F_LENS; in dw9714_probe()
175 rval = v4l2_async_register_subdev(&dw9714_dev->sd); in dw9714_probe()
179 pm_runtime_set_active(&client->dev); in dw9714_probe()
180 pm_runtime_enable(&client->dev); in dw9714_probe()
181 pm_runtime_idle(&client->dev); in dw9714_probe()
186 regulator_disable(dw9714_dev->vcc); in dw9714_probe()
187 v4l2_ctrl_handler_free(&dw9714_dev->ctrls_vcm); in dw9714_probe()
188 media_entity_cleanup(&dw9714_dev->sd.entity); in dw9714_probe()
199 pm_runtime_disable(&client->dev); in dw9714_remove()
200 if (!pm_runtime_status_suspended(&client->dev)) { in dw9714_remove()
201 ret = regulator_disable(dw9714_dev->vcc); in dw9714_remove()
203 dev_err(&client->dev, in dw9714_remove()
207 pm_runtime_set_suspended(&client->dev); in dw9714_remove()
213 * The lens position is gradually moved in units of DW9714_CTRL_STEPS,
223 if (pm_runtime_suspended(&client->dev)) in dw9714_vcm_suspend()
226 for (val = dw9714_dev->current_val & ~(DW9714_CTRL_STEPS - 1); in dw9714_vcm_suspend()
227 val >= 0; val -= DW9714_CTRL_STEPS) { in dw9714_vcm_suspend()
235 ret = regulator_disable(dw9714_dev->vcc); in dw9714_vcm_suspend()
245 * The lens position is gradually moved in units of DW9714_CTRL_STEPS,
255 if (pm_runtime_suspended(&client->dev)) in dw9714_vcm_resume()
258 ret = regulator_enable(dw9714_dev->vcc); in dw9714_vcm_resume()
265 for (val = dw9714_dev->current_val % DW9714_CTRL_STEPS; in dw9714_vcm_resume()
266 val < dw9714_dev->current_val + DW9714_CTRL_STEPS - 1; in dw9714_vcm_resume()