Lines Matching full:ov4689
3 * ov4689 driver
123 struct ov4689 { struct
142 #define to_ov4689(sd) container_of(sd, struct ov4689, subdev) argument
337 struct ov4689 *ov4689 = to_ov4689(sd); in ov4689_set_fmt() local
340 ov4689_fill_fmt(ov4689->cur_mode, mbus_fmt); in ov4689_set_fmt()
374 static int ov4689_enable_test_pattern(struct ov4689 *ov4689, u32 pattern) in ov4689_enable_test_pattern() argument
383 return cci_write(ov4689->regmap, OV4689_REG_TEST_PATTERN, in ov4689_enable_test_pattern()
415 static int ov4689_setup_timings(struct ov4689 *ov4689) in ov4689_setup_timings() argument
417 const struct ov4689_mode *mode = ov4689->cur_mode; in ov4689_setup_timings()
418 struct regmap *rm = ov4689->regmap; in ov4689_setup_timings()
437 static int ov4689_setup_blc_anchors(struct ov4689 *ov4689) in ov4689_setup_blc_anchors() argument
439 struct regmap *rm = ov4689->regmap; in ov4689_setup_blc_anchors()
452 struct ov4689 *ov4689 = to_ov4689(sd); in ov4689_s_stream() local
454 struct device *dev = ov4689->dev; in ov4689_s_stream()
457 sd_state = v4l2_subdev_lock_and_get_active_state(&ov4689->subdev); in ov4689_s_stream()
464 ret = cci_multi_reg_write(ov4689->regmap, in ov4689_s_stream()
465 ov4689->cur_mode->reg_list, in ov4689_s_stream()
466 ov4689->cur_mode->num_regs, in ov4689_s_stream()
473 ret = ov4689_setup_timings(ov4689); in ov4689_s_stream()
479 ret = ov4689_setup_blc_anchors(ov4689); in ov4689_s_stream()
485 ret = __v4l2_ctrl_handler_setup(&ov4689->ctrl_handler); in ov4689_s_stream()
491 ret = cci_write(ov4689->regmap, OV4689_REG_CTRL_MODE, in ov4689_s_stream()
498 cci_write(ov4689->regmap, OV4689_REG_CTRL_MODE, in ov4689_s_stream()
511 static inline u32 ov4689_cal_delay(struct ov4689 *ov4689, u32 cycles) in ov4689_cal_delay() argument
514 DIV_ROUND_UP(ov4689->clock_rate, 1000)); in ov4689_cal_delay()
520 struct ov4689 *ov4689 = to_ov4689(sd); in ov4689_power_on() local
524 ret = clk_prepare_enable(ov4689->xvclk); in ov4689_power_on()
530 gpiod_set_value_cansleep(ov4689->reset_gpio, 1); in ov4689_power_on()
533 ov4689->supplies); in ov4689_power_on()
539 gpiod_set_value_cansleep(ov4689->reset_gpio, 0); in ov4689_power_on()
541 gpiod_set_value_cansleep(ov4689->pwdn_gpio, 0); in ov4689_power_on()
544 delay_us = ov4689_cal_delay(ov4689, 8192); in ov4689_power_on()
550 clk_disable_unprepare(ov4689->xvclk); in ov4689_power_on()
558 struct ov4689 *ov4689 = to_ov4689(sd); in ov4689_power_off() local
560 gpiod_set_value_cansleep(ov4689->pwdn_gpio, 1); in ov4689_power_off()
561 clk_disable_unprepare(ov4689->xvclk); in ov4689_power_off()
562 gpiod_set_value_cansleep(ov4689->reset_gpio, 1); in ov4689_power_off()
564 ov4689->supplies); in ov4689_power_off()
608 static int ov4689_map_gain(struct ov4689 *ov4689, int logical_gain, int *result) in ov4689_map_gain() argument
620 dev_warn_ratelimited(ov4689->dev, in ov4689_map_gain()
635 struct ov4689 *ov4689 = in ov4689_set_ctrl() local
636 container_of(ctrl->handler, struct ov4689, ctrl_handler); in ov4689_set_ctrl()
637 struct regmap *regmap = ov4689->regmap; in ov4689_set_ctrl()
638 struct device *dev = ov4689->dev; in ov4689_set_ctrl()
647 max_expo = ov4689->cur_mode->height + ctrl->val - 4; in ov4689_set_ctrl()
648 __v4l2_ctrl_modify_range(ov4689->exposure, in ov4689_set_ctrl()
649 ov4689->exposure->minimum, max_expo, in ov4689_set_ctrl()
650 ov4689->exposure->step, in ov4689_set_ctrl()
651 ov4689->exposure->default_value); in ov4689_set_ctrl()
664 ret = ov4689_map_gain(ov4689, ctrl->val, &sensor_gain); in ov4689_set_ctrl()
669 ctrl->val + ov4689->cur_mode->height, &ret); in ov4689_set_ctrl()
672 ret = ov4689_enable_test_pattern(ov4689, ctrl->val); in ov4689_set_ctrl()
676 (ctrl->val + ov4689->cur_mode->width) / in ov4689_set_ctrl()
715 static int ov4689_initialize_controls(struct ov4689 *ov4689) in ov4689_initialize_controls() argument
717 struct i2c_client *client = v4l2_get_subdevdata(&ov4689->subdev); in ov4689_initialize_controls()
726 handler = &ov4689->ctrl_handler; in ov4689_initialize_controls()
727 mode = ov4689->cur_mode; in ov4689_initialize_controls()
752 ov4689->exposure = in ov4689_initialize_controls()
785 dev_err(ov4689->dev, "Failed to init controls(%d)\n", ret); in ov4689_initialize_controls()
798 ov4689->subdev.ctrl_handler = handler; in ov4689_initialize_controls()
808 static int ov4689_check_sensor_id(struct ov4689 *ov4689, in ov4689_check_sensor_id() argument
811 struct device *dev = ov4689->dev; in ov4689_check_sensor_id()
815 ret = cci_read(ov4689->regmap, OV4689_REG_CHIP_ID, &id, NULL); in ov4689_check_sensor_id()
832 static int ov4689_configure_regulators(struct ov4689 *ov4689) in ov4689_configure_regulators() argument
837 ov4689->supplies[i].supply = ov4689_supply_names[i]; in ov4689_configure_regulators()
839 return devm_regulator_bulk_get(ov4689->dev, in ov4689_configure_regulators()
841 ov4689->supplies); in ov4689_configure_regulators()
897 struct ov4689 *ov4689; in ov4689_probe() local
904 ov4689 = devm_kzalloc(dev, sizeof(*ov4689), GFP_KERNEL); in ov4689_probe()
905 if (!ov4689) in ov4689_probe()
908 ov4689->dev = dev; in ov4689_probe()
910 ov4689->cur_mode = &supported_modes[OV4689_MODE_2688_1520]; in ov4689_probe()
912 ov4689->xvclk = devm_clk_get_optional(dev, NULL); in ov4689_probe()
913 if (IS_ERR(ov4689->xvclk)) in ov4689_probe()
914 return dev_err_probe(dev, PTR_ERR(ov4689->xvclk), in ov4689_probe()
917 if (!ov4689->xvclk) { in ov4689_probe()
921 &ov4689->clock_rate); in ov4689_probe()
923 ov4689->clock_rate = clk_get_rate(ov4689->xvclk); in ov4689_probe()
926 if (ov4689->clock_rate != OV4689_XVCLK_FREQ) { in ov4689_probe()
929 ov4689->clock_rate, OV4689_XVCLK_FREQ); in ov4689_probe()
933 ov4689->regmap = devm_cci_regmap_init_i2c(client, 16); in ov4689_probe()
934 if (IS_ERR(ov4689->regmap)) { in ov4689_probe()
935 ret = PTR_ERR(ov4689->regmap); in ov4689_probe()
940 ov4689->reset_gpio = devm_gpiod_get_optional(dev, "reset", in ov4689_probe()
942 if (IS_ERR(ov4689->reset_gpio)) { in ov4689_probe()
944 return PTR_ERR(ov4689->reset_gpio); in ov4689_probe()
947 ov4689->pwdn_gpio = devm_gpiod_get_optional(dev, "pwdn", GPIOD_OUT_LOW); in ov4689_probe()
948 if (IS_ERR(ov4689->pwdn_gpio)) { in ov4689_probe()
950 return PTR_ERR(ov4689->pwdn_gpio); in ov4689_probe()
953 ret = ov4689_configure_regulators(ov4689); in ov4689_probe()
958 sd = &ov4689->subdev; in ov4689_probe()
962 ret = ov4689_initialize_controls(ov4689); in ov4689_probe()
972 ret = ov4689_check_sensor_id(ov4689, client); in ov4689_probe()
978 ov4689->pad.flags = MEDIA_PAD_FL_SOURCE; in ov4689_probe()
979 ret = media_entity_pads_init(&sd->entity, 1, &ov4689->pad); in ov4689_probe()
983 sd->state_lock = ov4689->ctrl_handler.lock; in ov4689_probe()
1016 v4l2_ctrl_handler_free(&ov4689->ctrl_handler); in ov4689_probe()
1024 struct ov4689 *ov4689 = to_ov4689(sd); in ov4689_remove() local
1029 v4l2_ctrl_handler_free(&ov4689->ctrl_handler); in ov4689_remove()
1038 { .compatible = "ovti,ov4689" },
1045 .name = "ov4689",
1055 MODULE_DESCRIPTION("OmniVision ov4689 sensor driver");