Lines Matching +full:lens +full:- +full:focus
1 // SPDX-License-Identifier: GPL-2.0
10 #include <media/v4l2-ctrls.h>
11 #include <media/v4l2-device.h>
15 * This sets the minimum granularity for the focus positions.
16 * A value of 1 gives maximum accuracy for a desired focus position
20 * This acts as the minimum granularity of lens movement.
22 * uniformly adjusted for gradual lens movement, with desired
47 struct v4l2_ctrl *focus; member
56 return container_of(ctrl->handler, struct ak7375_device, ctrls_vcm); in to_ak7375_vcm()
67 struct i2c_client *client = v4l2_get_subdevdata(&ak7375->sd); in ak7375_i2c_write()
72 return -EINVAL; in ak7375_i2c_write()
81 return -EIO; in ak7375_i2c_write()
90 if (ctrl->id == V4L2_CID_FOCUS_ABSOLUTE) in ak7375_set_ctrl()
92 ctrl->val << 4, 2); in ak7375_set_ctrl()
94 return -EINVAL; in ak7375_set_ctrl()
103 return pm_runtime_resume_and_get(sd->dev); in ak7375_open()
108 pm_runtime_put(sd->dev); in ak7375_close()
122 v4l2_async_unregister_subdev(&ak7375_dev->sd); in ak7375_subdev_cleanup()
123 v4l2_ctrl_handler_free(&ak7375_dev->ctrls_vcm); in ak7375_subdev_cleanup()
124 media_entity_cleanup(&ak7375_dev->sd.entity); in ak7375_subdev_cleanup()
129 struct v4l2_ctrl_handler *hdl = &dev_vcm->ctrls_vcm; in ak7375_init_controls()
134 dev_vcm->focus = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FOCUS_ABSOLUTE, in ak7375_init_controls()
137 if (hdl->error) in ak7375_init_controls()
138 dev_err(dev_vcm->sd.dev, "%s fail error: 0x%x\n", in ak7375_init_controls()
139 __func__, hdl->error); in ak7375_init_controls()
140 dev_vcm->sd.ctrl_handler = hdl; in ak7375_init_controls()
142 return hdl->error; in ak7375_init_controls()
151 ak7375_dev = devm_kzalloc(&client->dev, sizeof(*ak7375_dev), in ak7375_probe()
154 return -ENOMEM; in ak7375_probe()
157 ak7375_dev->supplies[i].supply = ak7375_supply_names[i]; in ak7375_probe()
159 ret = devm_regulator_bulk_get(&client->dev, in ak7375_probe()
161 ak7375_dev->supplies); in ak7375_probe()
163 dev_err_probe(&client->dev, ret, "Failed to get regulators\n"); in ak7375_probe()
167 v4l2_i2c_subdev_init(&ak7375_dev->sd, client, &ak7375_ops); in ak7375_probe()
168 ak7375_dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in ak7375_probe()
169 ak7375_dev->sd.internal_ops = &ak7375_int_ops; in ak7375_probe()
170 ak7375_dev->sd.entity.function = MEDIA_ENT_F_LENS; in ak7375_probe()
176 ret = media_entity_pads_init(&ak7375_dev->sd.entity, 0, NULL); in ak7375_probe()
180 ret = v4l2_async_register_subdev(&ak7375_dev->sd); in ak7375_probe()
184 pm_runtime_set_active(&client->dev); in ak7375_probe()
185 pm_runtime_enable(&client->dev); in ak7375_probe()
186 pm_runtime_idle(&client->dev); in ak7375_probe()
191 v4l2_ctrl_handler_free(&ak7375_dev->ctrls_vcm); in ak7375_probe()
192 media_entity_cleanup(&ak7375_dev->sd.entity); in ak7375_probe()
203 pm_runtime_disable(&client->dev); in ak7375_remove()
204 pm_runtime_set_suspended(&client->dev); in ak7375_remove()
209 * The lens position is gradually moved in units of AK7375_CTRL_STEPS,
218 if (!ak7375_dev->active) in ak7375_vcm_suspend()
221 for (val = ak7375_dev->focus->val & ~(AK7375_CTRL_STEPS - 1); in ak7375_vcm_suspend()
222 val >= 0; val -= AK7375_CTRL_STEPS) { in ak7375_vcm_suspend()
237 ak7375_dev->supplies); in ak7375_vcm_suspend()
241 ak7375_dev->active = false; in ak7375_vcm_suspend()
249 * The lens position is gradually moved in units of AK7375_CTRL_STEPS,
258 if (ak7375_dev->active) in ak7375_vcm_resume()
262 ak7375_dev->supplies); in ak7375_vcm_resume()
276 for (val = ak7375_dev->focus->val % AK7375_CTRL_STEPS; in ak7375_vcm_resume()
277 val <= ak7375_dev->focus->val; in ak7375_vcm_resume()
287 ak7375_dev->active = true; in ak7375_vcm_resume()
293 { .compatible = "asahi-kasei,ak7375" },