Lines Matching refs:dev_vcm

149 static unsigned int dw9763_move_time_div(struct dw9763_device *dev_vcm,  in dw9763_move_time_div()  argument
152 struct i2c_client *client = dev_vcm->client; in dw9763_move_time_div()
155 switch (dev_vcm->t_div) { in dw9763_move_time_div()
175 dev_err(&client->dev, "%s: t_div parameter err %d\n", __func__, dev_vcm->t_div); in dw9763_move_time_div()
182 static unsigned int dw9763_move_time(struct dw9763_device *dev_vcm, in dw9763_move_time() argument
185 struct i2c_client *client = dev_vcm->client; in dw9763_move_time()
188 switch (dev_vcm->step_mode) { in dw9763_move_time()
194 move_time_us = 6300 + dev_vcm->t_src * 100; in dw9763_move_time()
195 move_time_us = dw9763_move_time_div(dev_vcm, move_time_us); in dw9763_move_time()
203 __func__, dev_vcm->step_mode); in dw9763_move_time()
214 static int dw9763_set_dac(struct dw9763_device *dev_vcm, in dw9763_set_dac() argument
217 struct i2c_client *client = v4l2_get_subdevdata(&dev_vcm->sd); in dw9763_set_dac()
241 static int dw9763_get_dac(struct dw9763_device *dev_vcm, unsigned int *cur_dac) in dw9763_get_dac() argument
243 struct i2c_client *client = v4l2_get_subdevdata(&dev_vcm->sd); in dw9763_get_dac()
262 static int dw9763_get_pos(struct dw9763_device *dev_vcm, in dw9763_get_pos() argument
265 struct i2c_client *client = dev_vcm->client; in dw9763_get_pos()
273 if (abs_step <= dev_vcm->start_current) in dw9763_get_pos()
275 else if ((abs_step > dev_vcm->start_current) && in dw9763_get_pos()
276 (abs_step <= dev_vcm->rated_current)) in dw9763_get_pos()
277 abs_step = (dev_vcm->rated_current - abs_step) / dev_vcm->step; in dw9763_get_pos()
291 static int dw9763_set_pos(struct dw9763_device *dev_vcm, in dw9763_set_pos() argument
296 struct i2c_client *client = dev_vcm->client; in dw9763_set_pos()
299 position = dev_vcm->start_current; in dw9763_set_pos()
301 position = dev_vcm->start_current + in dw9763_set_pos()
302 (dev_vcm->step * (VCMDRV_MAX_LOG - dest_pos)); in dw9763_set_pos()
307 dev_vcm->current_lens_pos = position; in dw9763_set_pos()
308 dev_vcm->current_related_pos = dest_pos; in dw9763_set_pos()
310 ret = dw9763_set_dac(dev_vcm, position); in dw9763_set_pos()
318 struct dw9763_device *dev_vcm = to_dw9763_vcm(ctrl); in dw9763_get_ctrl() local
321 return dw9763_get_pos(dev_vcm, &ctrl->val); in dw9763_get_ctrl()
328 struct dw9763_device *dev_vcm = to_dw9763_vcm(ctrl); in dw9763_set_ctrl() local
329 struct i2c_client *client = dev_vcm->client; in dw9763_set_ctrl()
346 ret = dw9763_set_pos(dev_vcm, dest_pos); in dw9763_set_ctrl()
348 dev_vcm->move_us = dev_vcm->vcm_movefull_t; in dw9763_set_ctrl()
352 dest_pos, dev_vcm->move_us); in dw9763_set_ctrl()
354 dev_vcm->start_move_tv = ns_to_kernel_old_timeval(ktime_get_ns()); in dw9763_set_ctrl()
355 mv_us = dev_vcm->start_move_tv.tv_usec + in dw9763_set_ctrl()
356 dev_vcm->move_us; in dw9763_set_ctrl()
358 dev_vcm->end_move_tv.tv_sec = in dw9763_set_ctrl()
359 dev_vcm->start_move_tv.tv_sec + 1; in dw9763_set_ctrl()
360 dev_vcm->end_move_tv.tv_usec = mv_us - 1000000; in dw9763_set_ctrl()
362 dev_vcm->end_move_tv.tv_sec = in dw9763_set_ctrl()
363 dev_vcm->start_move_tv.tv_sec; in dw9763_set_ctrl()
364 dev_vcm->end_move_tv.tv_usec = mv_us; in dw9763_set_ctrl()
401 static void dw9763_update_vcm_cfg(struct dw9763_device *dev_vcm) in dw9763_update_vcm_cfg() argument
403 struct i2c_client *client = dev_vcm->client; in dw9763_update_vcm_cfg()
406 if (dev_vcm->max_ma == 0) { in dw9763_update_vcm_cfg()
411 cur_dist = dev_vcm->vcm_cfg.rated_ma - dev_vcm->vcm_cfg.start_ma; in dw9763_update_vcm_cfg()
412 cur_dist = cur_dist * DW9763_MAX_REG / dev_vcm->max_ma; in dw9763_update_vcm_cfg()
413 dev_vcm->step = (cur_dist + (VCMDRV_MAX_LOG - 1)) / VCMDRV_MAX_LOG; in dw9763_update_vcm_cfg()
414 dev_vcm->start_current = dev_vcm->vcm_cfg.start_ma * in dw9763_update_vcm_cfg()
415 DW9763_MAX_REG / dev_vcm->max_ma; in dw9763_update_vcm_cfg()
416 dev_vcm->rated_current = dev_vcm->vcm_cfg.rated_ma * in dw9763_update_vcm_cfg()
417 DW9763_MAX_REG / dev_vcm->max_ma; in dw9763_update_vcm_cfg()
418 dev_vcm->step_mode = dev_vcm->vcm_cfg.step_mode; in dw9763_update_vcm_cfg()
422 dev_vcm->vcm_cfg.start_ma, in dw9763_update_vcm_cfg()
423 dev_vcm->vcm_cfg.rated_ma, in dw9763_update_vcm_cfg()
424 dev_vcm->vcm_cfg.step_mode, in dw9763_update_vcm_cfg()
425 dev_vcm->max_ma); in dw9763_update_vcm_cfg()
430 struct dw9763_device *dev_vcm = sd_to_dw9763_vcm(sd); in dw9763_ioctl() local
431 struct i2c_client *client = dev_vcm->client; in dw9763_ioctl()
439 vcm_tim->vcm_start_t.tv_sec = dev_vcm->start_move_tv.tv_sec; in dw9763_ioctl()
441 dev_vcm->start_move_tv.tv_usec; in dw9763_ioctl()
442 vcm_tim->vcm_end_t.tv_sec = dev_vcm->end_move_tv.tv_sec; in dw9763_ioctl()
443 vcm_tim->vcm_end_t.tv_usec = dev_vcm->end_move_tv.tv_usec; in dw9763_ioctl()
453 vcm_cfg->start_ma = dev_vcm->vcm_cfg.start_ma; in dw9763_ioctl()
454 vcm_cfg->rated_ma = dev_vcm->vcm_cfg.rated_ma; in dw9763_ioctl()
455 vcm_cfg->step_mode = dev_vcm->vcm_cfg.step_mode; in dw9763_ioctl()
465 dev_vcm->vcm_cfg.start_ma = vcm_cfg->start_ma; in dw9763_ioctl()
466 dev_vcm->vcm_cfg.rated_ma = vcm_cfg->rated_ma; in dw9763_ioctl()
467 dev_vcm->vcm_cfg.step_mode = vcm_cfg->step_mode; in dw9763_ioctl()
468 dw9763_update_vcm_cfg(dev_vcm); in dw9763_ioctl()
482 struct dw9763_device *dev_vcm = sd_to_dw9763_vcm(sd); in dw9763_compat_ioctl32() local
483 struct i2c_client *client = dev_vcm->client; in dw9763_compat_ioctl32()
549 static int dw9763_init_controls(struct dw9763_device *dev_vcm) in dw9763_init_controls() argument
551 struct v4l2_ctrl_handler *hdl = &dev_vcm->ctrls_vcm; in dw9763_init_controls()
560 dev_err(dev_vcm->sd.dev, "%s fail error: 0x%x\n", in dw9763_init_controls()
562 dev_vcm->sd.ctrl_handler = hdl; in dw9763_init_controls()
575 struct dw9763_device *dev_vcm = sd_to_dw9763_vcm(sd); in set_dacval() local
581 dw9763_set_dac(dev_vcm, val); in set_dacval()
591 struct dw9763_device *dev_vcm = sd_to_dw9763_vcm(sd); in get_dacval() local
594 dw9763_get_dac(dev_vcm, &dac); in get_dacval()
848 struct dw9763_device *dev_vcm = i2c_get_clientdata(client); in dw9763_init() local
862 if (dev_vcm->step_mode != DIRECT_MODE) in dw9763_init()
867 switch (dev_vcm->step_mode) { in dw9763_init()
873 mode_val |= dev_vcm->step_mode << 5; in dw9763_init()
879 mode_val |= (dev_vcm->t_div & 0x07); in dw9763_init()
880 algo_time = dev_vcm->t_src; in dw9763_init()
911 struct dw9763_device *dev_vcm = i2c_get_clientdata(client); in dw9763_vcm_resume() local
914 dw9763_set_pos(dev_vcm, dev_vcm->current_related_pos); in dw9763_vcm_resume()