Lines Matching refs:dev_vcm
142 static unsigned int aw8601_move_time_div(struct aw8601_device *dev_vcm, in aw8601_move_time_div() argument
145 struct i2c_client *client = v4l2_get_subdevdata(&dev_vcm->sd); in aw8601_move_time_div()
148 switch (dev_vcm->t_div) { in aw8601_move_time_div()
170 __func__, dev_vcm->t_div); in aw8601_move_time_div()
176 static unsigned int aw8601_move_time(struct aw8601_device *dev_vcm, in aw8601_move_time() argument
179 struct i2c_client *client = v4l2_get_subdevdata(&dev_vcm->sd); in aw8601_move_time()
182 switch (dev_vcm->step_mode) { in aw8601_move_time()
184 move_time_us = 252 + dev_vcm->t_src * 4; in aw8601_move_time()
191 move_time_us = 6300 + dev_vcm->t_src * 100; in aw8601_move_time()
192 move_time_us = aw8601_move_time_div(dev_vcm, move_time_us); in aw8601_move_time()
200 __func__, dev_vcm->step_mode); in aw8601_move_time()
207 static int aw8601_get_pos(struct aw8601_device *dev_vcm, in aw8601_get_pos() argument
210 struct i2c_client *client = v4l2_get_subdevdata(&dev_vcm->sd); in aw8601_get_pos()
214 range = dev_vcm->rated_current - dev_vcm->start_current; in aw8601_get_pos()
219 if (abs_step <= dev_vcm->start_current) { in aw8601_get_pos()
220 abs_step = dev_vcm->max_logicalpos; in aw8601_get_pos()
221 } else if ((abs_step > dev_vcm->start_current) && in aw8601_get_pos()
222 (abs_step <= dev_vcm->rated_current)) { in aw8601_get_pos()
223 abs_step = (abs_step - dev_vcm->start_current) * dev_vcm->max_logicalpos / range; in aw8601_get_pos()
224 abs_step = dev_vcm->max_logicalpos - abs_step; in aw8601_get_pos()
239 static int aw8601_set_pos(struct aw8601_device *dev_vcm, in aw8601_set_pos() argument
244 struct i2c_client *client = v4l2_get_subdevdata(&dev_vcm->sd); in aw8601_set_pos()
248 range = dev_vcm->rated_current - dev_vcm->start_current; in aw8601_set_pos()
249 if (dest_pos >= dev_vcm->max_logicalpos) in aw8601_set_pos()
250 position = dev_vcm->start_current; in aw8601_set_pos()
252 position = dev_vcm->start_current + in aw8601_set_pos()
253 (range * (dev_vcm->max_logicalpos - dest_pos) / dev_vcm->max_logicalpos); in aw8601_set_pos()
258 dev_vcm->current_lens_pos = position; in aw8601_set_pos()
259 dev_vcm->current_related_pos = dest_pos; in aw8601_set_pos()
266 ret = aw8601_write_reg(client, 0x03, 2, dev_vcm->current_lens_pos); in aw8601_set_pos()
270 "%s: set reg val %d\n", __func__, dev_vcm->current_lens_pos); in aw8601_set_pos()
280 struct aw8601_device *dev_vcm = to_aw8601_vcm(ctrl); in aw8601_get_ctrl() local
283 return aw8601_get_pos(dev_vcm, &ctrl->val); in aw8601_get_ctrl()
290 struct aw8601_device *dev_vcm = to_aw8601_vcm(ctrl); in aw8601_set_ctrl() local
291 struct i2c_client *client = v4l2_get_subdevdata(&dev_vcm->sd); in aw8601_set_ctrl()
298 if (dest_pos > dev_vcm->max_logicalpos) { in aw8601_set_ctrl()
301 __func__, dest_pos, dev_vcm->max_logicalpos); in aw8601_set_ctrl()
305 move_pos = dev_vcm->current_related_pos - dest_pos; in aw8601_set_ctrl()
309 ret = aw8601_set_pos(dev_vcm, dest_pos); in aw8601_set_ctrl()
311 if (dev_vcm->step_mode == LSC_MODE) in aw8601_set_ctrl()
312 dev_vcm->move_us = ((dev_vcm->vcm_movefull_t * (uint32_t)move_pos) / in aw8601_set_ctrl()
313 dev_vcm->max_logicalpos); in aw8601_set_ctrl()
315 dev_vcm->move_us = dev_vcm->vcm_movefull_t; in aw8601_set_ctrl()
319 dest_pos, dev_vcm->move_us); in aw8601_set_ctrl()
321 dev_vcm->start_move_tv = ns_to_kernel_old_timeval(ktime_get_ns()); in aw8601_set_ctrl()
322 mv_us = dev_vcm->start_move_tv.tv_usec + in aw8601_set_ctrl()
323 dev_vcm->move_us; in aw8601_set_ctrl()
325 dev_vcm->end_move_tv.tv_sec = in aw8601_set_ctrl()
326 dev_vcm->start_move_tv.tv_sec + 1; in aw8601_set_ctrl()
327 dev_vcm->end_move_tv.tv_usec = mv_us - 1000000; in aw8601_set_ctrl()
329 dev_vcm->end_move_tv.tv_sec = in aw8601_set_ctrl()
330 dev_vcm->start_move_tv.tv_sec; in aw8601_set_ctrl()
331 dev_vcm->end_move_tv.tv_usec = mv_us; in aw8601_set_ctrl()
368 static void aw8601_update_vcm_cfg(struct aw8601_device *dev_vcm) in aw8601_update_vcm_cfg() argument
370 struct i2c_client *client = v4l2_get_subdevdata(&dev_vcm->sd); in aw8601_update_vcm_cfg()
372 if (dev_vcm->max_ma == 0) { in aw8601_update_vcm_cfg()
377 dev_vcm->start_current = dev_vcm->vcm_cfg.start_ma * in aw8601_update_vcm_cfg()
378 AW8601_MAX_REG / dev_vcm->max_ma; in aw8601_update_vcm_cfg()
379 dev_vcm->rated_current = dev_vcm->vcm_cfg.rated_ma * in aw8601_update_vcm_cfg()
380 AW8601_MAX_REG / dev_vcm->max_ma; in aw8601_update_vcm_cfg()
381 dev_vcm->step_mode = dev_vcm->vcm_cfg.step_mode; in aw8601_update_vcm_cfg()
385 dev_vcm->vcm_cfg.start_ma, in aw8601_update_vcm_cfg()
386 dev_vcm->vcm_cfg.rated_ma, in aw8601_update_vcm_cfg()
387 dev_vcm->vcm_cfg.step_mode, in aw8601_update_vcm_cfg()
388 dev_vcm->max_ma); in aw8601_update_vcm_cfg()
393 struct aw8601_device *dev_vcm = sd_to_aw8601_vcm(sd); in aw8601_ioctl() local
403 vcm_tim->vcm_start_t.tv_sec = dev_vcm->start_move_tv.tv_sec; in aw8601_ioctl()
405 dev_vcm->start_move_tv.tv_usec; in aw8601_ioctl()
406 vcm_tim->vcm_end_t.tv_sec = dev_vcm->end_move_tv.tv_sec; in aw8601_ioctl()
407 vcm_tim->vcm_end_t.tv_usec = dev_vcm->end_move_tv.tv_usec; in aw8601_ioctl()
417 vcm_cfg->start_ma = dev_vcm->vcm_cfg.start_ma; in aw8601_ioctl()
418 vcm_cfg->rated_ma = dev_vcm->vcm_cfg.rated_ma; in aw8601_ioctl()
419 vcm_cfg->step_mode = dev_vcm->vcm_cfg.step_mode; in aw8601_ioctl()
429 dev_vcm->vcm_cfg.start_ma = vcm_cfg->start_ma; in aw8601_ioctl()
430 dev_vcm->vcm_cfg.rated_ma = vcm_cfg->rated_ma; in aw8601_ioctl()
431 dev_vcm->vcm_cfg.step_mode = vcm_cfg->step_mode; in aw8601_ioctl()
432 aw8601_update_vcm_cfg(dev_vcm); in aw8601_ioctl()
437 dev_vcm->max_logicalpos = max_logicalpos; in aw8601_ioctl()
438 __v4l2_ctrl_modify_range(dev_vcm->focus, in aw8601_ioctl()
439 0, dev_vcm->max_logicalpos, 1, dev_vcm->max_logicalpos); in aw8601_ioctl()
529 static int aw8601_init_controls(struct aw8601_device *dev_vcm) in aw8601_init_controls() argument
531 struct v4l2_ctrl_handler *hdl = &dev_vcm->ctrls_vcm; in aw8601_init_controls()
536 dev_vcm->focus = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FOCUS_ABSOLUTE, in aw8601_init_controls()
537 0, dev_vcm->max_logicalpos, 1, 0); in aw8601_init_controls()
540 dev_err(dev_vcm->sd.dev, "%s fail error: 0x%x\n", in aw8601_init_controls()
542 dev_vcm->sd.ctrl_handler = hdl; in aw8601_init_controls()
699 struct aw8601_device *dev_vcm = sd_to_aw8601_vcm(sd); in aw8601_init() local
716 if (dev_vcm->step_mode != DIRECT_MODE && in aw8601_init()
717 dev_vcm->step_mode != LSC_MODE) in aw8601_init()
722 switch (dev_vcm->step_mode) { in aw8601_init()
727 mode_val |= dev_vcm->step_mode << 6; in aw8601_init()
735 mode_val |= ((dev_vcm->t_div >> 2) & 0x01); in aw8601_init()
736 algo_time = dev_vcm->t_div << 6 | dev_vcm->t_src; in aw8601_init()
760 struct aw8601_device *dev_vcm = sd_to_aw8601_vcm(sd); in aw8601_vcm_resume() local
763 aw8601_set_pos(dev_vcm, dev_vcm->current_related_pos); in aw8601_vcm_resume()