Lines Matching full:dw9768
15 #define DW9768_NAME "dw9768"
31 * DW9768 requires waiting time of Topr after PD reset takes place.
39 * DW9768 separates two registers to control the VCM position.
78 * DW9768 requires waiting time (delay time) of t_OPR after power-up,
100 /* dw9768 device structure */
101 struct dw9768 { struct
113 static inline struct dw9768 *sd_to_dw9768(struct v4l2_subdev *subdev) in sd_to_dw9768() argument
115 return container_of(subdev, struct dw9768, sd); in sd_to_dw9768()
202 static int dw9768_mod_reg(struct dw9768 *dw9768, u8 reg, u8 mask, u8 val) in dw9768_mod_reg() argument
204 struct i2c_client *client = v4l2_get_subdevdata(&dw9768->sd); in dw9768_mod_reg()
216 static int dw9768_set_dac(struct dw9768 *dw9768, u16 val) in dw9768_set_dac() argument
218 struct i2c_client *client = v4l2_get_subdevdata(&dw9768->sd); in dw9768_set_dac()
224 static int dw9768_init(struct dw9768 *dw9768) in dw9768_init() argument
226 struct i2c_client *client = v4l2_get_subdevdata(&dw9768->sd); in dw9768_init()
248 ret = dw9768_mod_reg(dw9768, DW9768_AAC_PRESC_REG, in dw9768_init()
250 dw9768->aac_mode << 5); in dw9768_init()
255 if (dw9768->clock_presc != DW9768_CLOCK_PRE_SCALE_DEFAULT) { in dw9768_init()
256 ret = dw9768_mod_reg(dw9768, DW9768_AAC_PRESC_REG, in dw9768_init()
258 dw9768->clock_presc); in dw9768_init()
264 if (dw9768->aac_timing != DW9768_AAC_TIME_DEFAULT) { in dw9768_init()
266 dw9768->aac_timing); in dw9768_init()
271 for (val = dw9768->focus->val % DW9768_MOVE_STEPS; in dw9768_init()
272 val <= dw9768->focus->val; in dw9768_init()
274 ret = dw9768_set_dac(dw9768, val); in dw9768_init()
279 usleep_range(dw9768->move_delay_us, in dw9768_init()
280 dw9768->move_delay_us + 1000); in dw9768_init()
286 static int dw9768_release(struct dw9768 *dw9768) in dw9768_release() argument
288 struct i2c_client *client = v4l2_get_subdevdata(&dw9768->sd); in dw9768_release()
291 val = round_down(dw9768->focus->val, DW9768_MOVE_STEPS); in dw9768_release()
293 ret = dw9768_set_dac(dw9768, val); in dw9768_release()
298 usleep_range(dw9768->move_delay_us, in dw9768_release()
299 dw9768->move_delay_us + 1000); in dw9768_release()
320 struct dw9768 *dw9768 = sd_to_dw9768(sd); in dw9768_runtime_suspend() local
322 dw9768_release(dw9768); in dw9768_runtime_suspend()
324 dw9768->supplies); in dw9768_runtime_suspend()
333 struct dw9768 *dw9768 = sd_to_dw9768(sd); in dw9768_runtime_resume() local
337 dw9768->supplies); in dw9768_runtime_resume()
349 ret = dw9768_init(dw9768); in dw9768_runtime_resume()
357 dw9768->supplies); in dw9768_runtime_resume()
364 struct dw9768 *dw9768 = container_of(ctrl->handler, in dw9768_set_ctrl() local
365 struct dw9768, ctrls); in dw9768_set_ctrl()
368 return dw9768_set_dac(dw9768, ctrl->val); in dw9768_set_ctrl()
404 static int dw9768_init_controls(struct dw9768 *dw9768) in dw9768_init_controls() argument
406 struct v4l2_ctrl_handler *hdl = &dw9768->ctrls; in dw9768_init_controls()
411 dw9768->focus = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FOCUS_ABSOLUTE, 0, in dw9768_init_controls()
418 dw9768->sd.ctrl_handler = hdl; in dw9768_init_controls()
426 struct dw9768 *dw9768; in dw9768_probe() local
430 dw9768 = devm_kzalloc(dev, sizeof(*dw9768), GFP_KERNEL); in dw9768_probe()
431 if (!dw9768) in dw9768_probe()
435 v4l2_i2c_subdev_init(&dw9768->sd, client, &dw9768_ops); in dw9768_probe()
437 dw9768->aac_mode = DW9768_AAC_MODE_DEFAULT; in dw9768_probe()
438 dw9768->aac_timing = DW9768_AAC_TIME_DEFAULT; in dw9768_probe()
439 dw9768->clock_presc = DW9768_CLOCK_PRE_SCALE_DEFAULT; in dw9768_probe()
443 &dw9768->aac_mode); in dw9768_probe()
447 &dw9768->clock_presc); in dw9768_probe()
451 &dw9768->aac_timing); in dw9768_probe()
453 dw9768->move_delay_us = dw9768_cal_move_delay(dw9768->aac_mode, in dw9768_probe()
454 dw9768->clock_presc, in dw9768_probe()
455 dw9768->aac_timing); in dw9768_probe()
458 dw9768->supplies[i].supply = dw9768_supply_names[i]; in dw9768_probe()
461 dw9768->supplies); in dw9768_probe()
468 ret = dw9768_init_controls(dw9768); in dw9768_probe()
473 dw9768->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in dw9768_probe()
474 dw9768->sd.internal_ops = &dw9768_int_ops; in dw9768_probe()
476 ret = media_entity_pads_init(&dw9768->sd.entity, 0, NULL); in dw9768_probe()
480 dw9768->sd.entity.function = MEDIA_ENT_F_LENS; in dw9768_probe()
491 ret = v4l2_async_register_subdev(&dw9768->sd); in dw9768_probe()
505 media_entity_cleanup(&dw9768->sd.entity); in dw9768_probe()
507 v4l2_ctrl_handler_free(&dw9768->ctrls); in dw9768_probe()
515 struct dw9768 *dw9768 = sd_to_dw9768(sd); in dw9768_remove() local
517 v4l2_async_unregister_subdev(&dw9768->sd); in dw9768_remove()
518 v4l2_ctrl_handler_free(&dw9768->ctrls); in dw9768_remove()
519 media_entity_cleanup(&dw9768->sd.entity); in dw9768_remove()
529 { .compatible = "dongwoon,dw9768" },
553 MODULE_DESCRIPTION("DW9768 VCM driver");