Lines Matching refs:dev_vcm
147 static unsigned int dw9800w_move_time_div(struct dw9800w_device *dev_vcm, in dw9800w_move_time_div() argument
150 struct i2c_client *client = dev_vcm->client; in dw9800w_move_time_div()
153 switch (dev_vcm->t_div) { in dw9800w_move_time_div()
175 __func__, dev_vcm->t_div); in dw9800w_move_time_div()
181 static unsigned int dw9800w_move_time(struct dw9800w_device *dev_vcm, in dw9800w_move_time() argument
184 struct i2c_client *client = dev_vcm->client; in dw9800w_move_time()
187 switch (dev_vcm->step_mode) { in dw9800w_move_time()
189 move_time_us = 252 + dev_vcm->t_src * 4; in dw9800w_move_time()
196 move_time_us = 6300 + dev_vcm->t_src * 100; in dw9800w_move_time()
197 move_time_us = dw9800w_move_time_div(dev_vcm, move_time_us); in dw9800w_move_time()
205 __func__, dev_vcm->step_mode); in dw9800w_move_time()
216 static int dw9800w_get_pos(struct dw9800w_device *dev_vcm, in dw9800w_get_pos() argument
219 struct i2c_client *client = dev_vcm->client; in dw9800w_get_pos()
227 if (abs_step <= dev_vcm->start_current) in dw9800w_get_pos()
229 else if ((abs_step > dev_vcm->start_current) && in dw9800w_get_pos()
230 (abs_step <= dev_vcm->rated_current)) in dw9800w_get_pos()
231 abs_step = (dev_vcm->rated_current - abs_step) / dev_vcm->step; in dw9800w_get_pos()
245 static int dw9800w_set_pos(struct dw9800w_device *dev_vcm, in dw9800w_set_pos() argument
250 struct i2c_client *client = dev_vcm->client; in dw9800w_set_pos()
254 position = dev_vcm->start_current; in dw9800w_set_pos()
256 position = dev_vcm->start_current + in dw9800w_set_pos()
257 (dev_vcm->step * (VCMDRV_MAX_LOG - dest_pos)); in dw9800w_set_pos()
262 dev_vcm->current_lens_pos = position; in dw9800w_set_pos()
263 dev_vcm->current_related_pos = dest_pos; in dw9800w_set_pos()
271 ret = dw9800w_write_reg(client, 0x03, 2, dev_vcm->current_lens_pos); in dw9800w_set_pos()
275 "%s: set reg val %d\n", __func__, dev_vcm->current_lens_pos); in dw9800w_set_pos()
285 struct dw9800w_device *dev_vcm = to_dw9800w_vcm(ctrl); in dw9800w_get_ctrl() local
288 return dw9800w_get_pos(dev_vcm, &ctrl->val); in dw9800w_get_ctrl()
295 struct dw9800w_device *dev_vcm = to_dw9800w_vcm(ctrl); in dw9800w_set_ctrl() local
296 struct i2c_client *client = dev_vcm->client; in dw9800w_set_ctrl()
314 move_pos = dev_vcm->current_related_pos - dest_pos; in dw9800w_set_ctrl()
318 ret = dw9800w_set_pos(dev_vcm, dest_pos); in dw9800w_set_ctrl()
319 if (dev_vcm->step_mode == LSC_MODE) in dw9800w_set_ctrl()
320 dev_vcm->move_us = ((dev_vcm->vcm_movefull_t * (uint32_t)move_pos) / in dw9800w_set_ctrl()
323 dev_vcm->move_us = dev_vcm->vcm_movefull_t; in dw9800w_set_ctrl()
327 dest_pos, dev_vcm->move_us); in dw9800w_set_ctrl()
329 dev_vcm->start_move_tv = ns_to_kernel_old_timeval(ktime_get_ns()); in dw9800w_set_ctrl()
330 mv_us = dev_vcm->start_move_tv.tv_usec + in dw9800w_set_ctrl()
331 dev_vcm->move_us; in dw9800w_set_ctrl()
333 dev_vcm->end_move_tv.tv_sec = in dw9800w_set_ctrl()
334 dev_vcm->start_move_tv.tv_sec + 1; in dw9800w_set_ctrl()
335 dev_vcm->end_move_tv.tv_usec = mv_us - 1000000; in dw9800w_set_ctrl()
337 dev_vcm->end_move_tv.tv_sec = in dw9800w_set_ctrl()
338 dev_vcm->start_move_tv.tv_sec; in dw9800w_set_ctrl()
339 dev_vcm->end_move_tv.tv_usec = mv_us; in dw9800w_set_ctrl()
376 static void dw9800w_update_vcm_cfg(struct dw9800w_device *dev_vcm) in dw9800w_update_vcm_cfg() argument
378 struct i2c_client *client = dev_vcm->client; in dw9800w_update_vcm_cfg()
381 if (dev_vcm->max_ma == 0) { in dw9800w_update_vcm_cfg()
386 cur_dist = dev_vcm->vcm_cfg.rated_ma - dev_vcm->vcm_cfg.start_ma; in dw9800w_update_vcm_cfg()
387 cur_dist = cur_dist * DW9800W_MAX_REG / dev_vcm->max_ma; in dw9800w_update_vcm_cfg()
388 dev_vcm->step = (cur_dist + (VCMDRV_MAX_LOG - 1)) / VCMDRV_MAX_LOG; in dw9800w_update_vcm_cfg()
389 dev_vcm->start_current = dev_vcm->vcm_cfg.start_ma * in dw9800w_update_vcm_cfg()
390 DW9800W_MAX_REG / dev_vcm->max_ma; in dw9800w_update_vcm_cfg()
391 dev_vcm->rated_current = dev_vcm->vcm_cfg.rated_ma * in dw9800w_update_vcm_cfg()
392 DW9800W_MAX_REG / dev_vcm->max_ma; in dw9800w_update_vcm_cfg()
393 dev_vcm->step_mode = dev_vcm->vcm_cfg.step_mode; in dw9800w_update_vcm_cfg()
397 dev_vcm->vcm_cfg.start_ma, in dw9800w_update_vcm_cfg()
398 dev_vcm->vcm_cfg.rated_ma, in dw9800w_update_vcm_cfg()
399 dev_vcm->vcm_cfg.step_mode, in dw9800w_update_vcm_cfg()
400 dev_vcm->max_ma); in dw9800w_update_vcm_cfg()
405 struct dw9800w_device *dev_vcm = sd_to_dw9800w_vcm(sd); in dw9800w_ioctl() local
406 struct i2c_client *client = dev_vcm->client; in dw9800w_ioctl()
414 vcm_tim->vcm_start_t.tv_sec = dev_vcm->start_move_tv.tv_sec; in dw9800w_ioctl()
416 dev_vcm->start_move_tv.tv_usec; in dw9800w_ioctl()
417 vcm_tim->vcm_end_t.tv_sec = dev_vcm->end_move_tv.tv_sec; in dw9800w_ioctl()
418 vcm_tim->vcm_end_t.tv_usec = dev_vcm->end_move_tv.tv_usec; in dw9800w_ioctl()
428 vcm_cfg->start_ma = dev_vcm->vcm_cfg.start_ma; in dw9800w_ioctl()
429 vcm_cfg->rated_ma = dev_vcm->vcm_cfg.rated_ma; in dw9800w_ioctl()
430 vcm_cfg->step_mode = dev_vcm->vcm_cfg.step_mode; in dw9800w_ioctl()
440 dev_vcm->vcm_cfg.start_ma = vcm_cfg->start_ma; in dw9800w_ioctl()
441 dev_vcm->vcm_cfg.rated_ma = vcm_cfg->rated_ma; in dw9800w_ioctl()
442 dev_vcm->vcm_cfg.step_mode = vcm_cfg->step_mode; in dw9800w_ioctl()
443 dw9800w_update_vcm_cfg(dev_vcm); in dw9800w_ioctl()
457 struct dw9800w_device *dev_vcm = sd_to_dw9800w_vcm(sd); in dw9800w_compat_ioctl32() local
458 struct i2c_client *client = dev_vcm->client; in dw9800w_compat_ioctl32()
524 static int dw9800w_init_controls(struct dw9800w_device *dev_vcm) in dw9800w_init_controls() argument
526 struct v4l2_ctrl_handler *hdl = &dev_vcm->ctrls_vcm; in dw9800w_init_controls()
535 dev_err(dev_vcm->sd.dev, "%s fail error: 0x%x\n", in dw9800w_init_controls()
537 dev_vcm->sd.ctrl_handler = hdl; in dw9800w_init_controls()
755 struct dw9800w_device *dev_vcm = i2c_get_clientdata(client); in dw9800w_init() local
769 if (dev_vcm->step_mode != DIRECT_MODE && in dw9800w_init()
770 dev_vcm->step_mode != LSC_MODE) in dw9800w_init()
775 switch (dev_vcm->step_mode) { in dw9800w_init()
780 mode_val |= dev_vcm->step_mode << 6; in dw9800w_init()
788 mode_val |= ((dev_vcm->t_div >> 2) & 0x01); in dw9800w_init()
789 algo_time = dev_vcm->t_div << 6 | dev_vcm->t_src; in dw9800w_init()
820 struct dw9800w_device *dev_vcm = i2c_get_clientdata(client); in dw9800w_vcm_resume() local
823 dw9800w_set_pos(dev_vcm, dev_vcm->current_related_pos); in dw9800w_vcm_resume()