coil               56 drivers/media/i2c/ad5820.c static int ad5820_write(struct ad5820_device *coil, u16 data)
coil               58 drivers/media/i2c/ad5820.c 	struct i2c_client *client = v4l2_get_subdevdata(&coil->subdev);
coil               86 drivers/media/i2c/ad5820.c static int ad5820_update_hw(struct ad5820_device *coil)
coil               90 drivers/media/i2c/ad5820.c 	status = RAMP_US_TO_CODE(coil->focus_ramp_time);
coil               91 drivers/media/i2c/ad5820.c 	status |= coil->focus_ramp_mode
coil               93 drivers/media/i2c/ad5820.c 	status |= coil->focus_absolute << AD5820_DAC_SHIFT;
coil               95 drivers/media/i2c/ad5820.c 	if (coil->standby)
coil               98 drivers/media/i2c/ad5820.c 	return ad5820_write(coil, status);
coil              104 drivers/media/i2c/ad5820.c static int ad5820_power_off(struct ad5820_device *coil, bool standby)
coil              113 drivers/media/i2c/ad5820.c 		coil->standby = true;
coil              114 drivers/media/i2c/ad5820.c 		ret = ad5820_update_hw(coil);
coil              117 drivers/media/i2c/ad5820.c 	ret2 = regulator_disable(coil->vana);
coil              123 drivers/media/i2c/ad5820.c static int ad5820_power_on(struct ad5820_device *coil, bool restore)
coil              127 drivers/media/i2c/ad5820.c 	ret = regulator_enable(coil->vana);
coil              133 drivers/media/i2c/ad5820.c 		coil->standby = false;
coil              134 drivers/media/i2c/ad5820.c 		ret = ad5820_update_hw(coil);
coil              141 drivers/media/i2c/ad5820.c 	coil->standby = true;
coil              142 drivers/media/i2c/ad5820.c 	regulator_disable(coil->vana);
coil              152 drivers/media/i2c/ad5820.c 	struct ad5820_device *coil =
coil              157 drivers/media/i2c/ad5820.c 		coil->focus_absolute = ctrl->val;
coil              158 drivers/media/i2c/ad5820.c 		return ad5820_update_hw(coil);
coil              169 drivers/media/i2c/ad5820.c static int ad5820_init_controls(struct ad5820_device *coil)
coil              171 drivers/media/i2c/ad5820.c 	v4l2_ctrl_handler_init(&coil->ctrls, 1);
coil              185 drivers/media/i2c/ad5820.c 	v4l2_ctrl_new_std(&coil->ctrls, &ad5820_ctrl_ops,
coil              188 drivers/media/i2c/ad5820.c 	if (coil->ctrls.error)
coil              189 drivers/media/i2c/ad5820.c 		return coil->ctrls.error;
coil              191 drivers/media/i2c/ad5820.c 	coil->focus_absolute = 0;
coil              192 drivers/media/i2c/ad5820.c 	coil->focus_ramp_time = 0;
coil              193 drivers/media/i2c/ad5820.c 	coil->focus_ramp_mode = 0;
coil              195 drivers/media/i2c/ad5820.c 	coil->subdev.ctrl_handler = &coil->ctrls;
coil              205 drivers/media/i2c/ad5820.c 	struct ad5820_device *coil = to_ad5820_device(subdev);
coil              207 drivers/media/i2c/ad5820.c 	return ad5820_init_controls(coil);
coil              213 drivers/media/i2c/ad5820.c 	struct ad5820_device *coil = to_ad5820_device(subdev);
coil              216 drivers/media/i2c/ad5820.c 	mutex_lock(&coil->power_lock);
coil              222 drivers/media/i2c/ad5820.c 	if (coil->power_count == !on) {
coil              223 drivers/media/i2c/ad5820.c 		ret = on ? ad5820_power_on(coil, true) :
coil              224 drivers/media/i2c/ad5820.c 			ad5820_power_off(coil, true);
coil              230 drivers/media/i2c/ad5820.c 	coil->power_count += on ? 1 : -1;
coil              231 drivers/media/i2c/ad5820.c 	WARN_ON(coil->power_count < 0);
coil              234 drivers/media/i2c/ad5820.c 	mutex_unlock(&coil->power_lock);
coil              269 drivers/media/i2c/ad5820.c 	struct ad5820_device *coil = to_ad5820_device(subdev);
coil              271 drivers/media/i2c/ad5820.c 	if (!coil->power_count)
coil              274 drivers/media/i2c/ad5820.c 	return ad5820_power_off(coil, false);
coil              281 drivers/media/i2c/ad5820.c 	struct ad5820_device *coil = to_ad5820_device(subdev);
coil              283 drivers/media/i2c/ad5820.c 	if (!coil->power_count)
coil              286 drivers/media/i2c/ad5820.c 	return ad5820_power_on(coil, true);
coil              292 drivers/media/i2c/ad5820.c 	struct ad5820_device *coil;
coil              295 drivers/media/i2c/ad5820.c 	coil = devm_kzalloc(&client->dev, sizeof(*coil), GFP_KERNEL);
coil              296 drivers/media/i2c/ad5820.c 	if (!coil)
coil              299 drivers/media/i2c/ad5820.c 	coil->vana = devm_regulator_get(&client->dev, "VANA");
coil              300 drivers/media/i2c/ad5820.c 	if (IS_ERR(coil->vana)) {
coil              301 drivers/media/i2c/ad5820.c 		ret = PTR_ERR(coil->vana);
coil              307 drivers/media/i2c/ad5820.c 	mutex_init(&coil->power_lock);
coil              309 drivers/media/i2c/ad5820.c 	v4l2_i2c_subdev_init(&coil->subdev, client, &ad5820_ops);
coil              310 drivers/media/i2c/ad5820.c 	coil->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
coil              311 drivers/media/i2c/ad5820.c 	coil->subdev.internal_ops = &ad5820_internal_ops;
coil              312 drivers/media/i2c/ad5820.c 	coil->subdev.entity.function = MEDIA_ENT_F_LENS;
coil              313 drivers/media/i2c/ad5820.c 	strscpy(coil->subdev.name, "ad5820 focus", sizeof(coil->subdev.name));
coil              315 drivers/media/i2c/ad5820.c 	ret = media_entity_pads_init(&coil->subdev.entity, 0, NULL);
coil              319 drivers/media/i2c/ad5820.c 	ret = v4l2_async_register_subdev(&coil->subdev);
coil              326 drivers/media/i2c/ad5820.c 	mutex_destroy(&coil->power_lock);
coil              328 drivers/media/i2c/ad5820.c 	media_entity_cleanup(&coil->subdev.entity);
coil              335 drivers/media/i2c/ad5820.c 	struct ad5820_device *coil = to_ad5820_device(subdev);
coil              337 drivers/media/i2c/ad5820.c 	v4l2_async_unregister_subdev(&coil->subdev);
coil              338 drivers/media/i2c/ad5820.c 	v4l2_ctrl_handler_free(&coil->ctrls);
coil              339 drivers/media/i2c/ad5820.c 	media_entity_cleanup(&coil->subdev.entity);
coil              340 drivers/media/i2c/ad5820.c 	mutex_destroy(&coil->power_lock);