Lines Matching refs:ov2685

83 struct ov2685 {  struct
103 #define to_ov2685(sd) container_of(sd, struct ov2685, subdev) argument
334 struct ov2685 *ov2685 = to_ov2685(sd); in ov2685_set_fmt() local
338 ov2685_fill_fmt(ov2685->cur_mode, mbus_fmt); in ov2685_set_fmt()
347 struct ov2685 *ov2685 = to_ov2685(sd); in ov2685_get_fmt() local
350 ov2685_fill_fmt(ov2685->cur_mode, mbus_fmt); in ov2685_get_fmt()
392 static int __ov2685_power_on(struct ov2685 *ov2685) in __ov2685_power_on() argument
396 struct device *dev = &ov2685->client->dev; in __ov2685_power_on()
398 ret = clk_prepare_enable(ov2685->xvclk); in __ov2685_power_on()
404 gpiod_set_value_cansleep(ov2685->reset_gpio, 1); in __ov2685_power_on()
406 ret = regulator_bulk_enable(OV2685_NUM_SUPPLIES, ov2685->supplies); in __ov2685_power_on()
413 gpiod_set_value_cansleep(ov2685->reset_gpio, 0); in __ov2685_power_on()
421 ret = ov2685_write_array(ov2685->client, ov2685->cur_mode->reg_list); in __ov2685_power_on()
428 regulator_bulk_disable(OV2685_NUM_SUPPLIES, ov2685->supplies); in __ov2685_power_on()
430 clk_disable_unprepare(ov2685->xvclk); in __ov2685_power_on()
435 static void __ov2685_power_off(struct ov2685 *ov2685) in __ov2685_power_off() argument
441 clk_disable_unprepare(ov2685->xvclk); in __ov2685_power_off()
442 gpiod_set_value_cansleep(ov2685->reset_gpio, 1); in __ov2685_power_off()
443 regulator_bulk_disable(OV2685_NUM_SUPPLIES, ov2685->supplies); in __ov2685_power_off()
448 struct ov2685 *ov2685 = to_ov2685(sd); in ov2685_s_stream() local
449 struct i2c_client *client = ov2685->client; in ov2685_s_stream()
452 mutex_lock(&ov2685->mutex); in ov2685_s_stream()
455 if (on == ov2685->streaming) in ov2685_s_stream()
459 ret = pm_runtime_resume_and_get(&ov2685->client->dev); in ov2685_s_stream()
463 ret = __v4l2_ctrl_handler_setup(&ov2685->ctrl_handler); in ov2685_s_stream()
477 pm_runtime_put(&ov2685->client->dev); in ov2685_s_stream()
480 ov2685->streaming = on; in ov2685_s_stream()
483 mutex_unlock(&ov2685->mutex); in ov2685_s_stream()
491 struct ov2685 *ov2685 = to_ov2685(sd); in ov2685_open() local
494 mutex_lock(&ov2685->mutex); in ov2685_open()
500 mutex_unlock(&ov2685->mutex); in ov2685_open()
509 struct ov2685 *ov2685 = to_ov2685(sd); in ov2685_runtime_resume() local
511 return __ov2685_power_on(ov2685); in ov2685_runtime_resume()
517 struct ov2685 *ov2685 = to_ov2685(sd); in ov2685_runtime_suspend() local
519 __ov2685_power_off(ov2685); in ov2685_runtime_suspend()
531 struct ov2685 *ov2685 = container_of(ctrl->handler, in ov2685_set_ctrl() local
532 struct ov2685, ctrl_handler); in ov2685_set_ctrl()
533 struct i2c_client *client = ov2685->client; in ov2685_set_ctrl()
541 max_expo = ov2685->cur_mode->height + ctrl->val - 4; in ov2685_set_ctrl()
542 __v4l2_ctrl_modify_range(ov2685->exposure, in ov2685_set_ctrl()
543 ov2685->exposure->minimum, max_expo, in ov2685_set_ctrl()
544 ov2685->exposure->step, in ov2685_set_ctrl()
545 ov2685->exposure->default_value); in ov2685_set_ctrl()
554 ret = ov2685_write_reg(ov2685->client, OV2685_REG_EXPOSURE, in ov2685_set_ctrl()
558 ret = ov2685_write_reg(ov2685->client, OV2685_REG_GAIN, in ov2685_set_ctrl()
562 ret = ov2685_write_reg(ov2685->client, OV2685_REG_VTS, in ov2685_set_ctrl()
564 ctrl->val + ov2685->cur_mode->height); in ov2685_set_ctrl()
567 ret = ov2685_write_reg(ov2685->client, OV2685_REG_TEST_PATTERN, in ov2685_set_ctrl()
609 static int ov2685_initialize_controls(struct ov2685 *ov2685) in ov2685_initialize_controls() argument
618 handler = &ov2685->ctrl_handler; in ov2685_initialize_controls()
619 mode = ov2685->cur_mode; in ov2685_initialize_controls()
623 handler->lock = &ov2685->mutex; in ov2685_initialize_controls()
636 ov2685->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in ov2685_initialize_controls()
638 if (ov2685->hblank) in ov2685_initialize_controls()
639 ov2685->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov2685_initialize_controls()
641 ov2685->vblank = v4l2_ctrl_new_std(handler, &ov2685_ctrl_ops, in ov2685_initialize_controls()
647 ov2685->exposure = v4l2_ctrl_new_std(handler, &ov2685_ctrl_ops, in ov2685_initialize_controls()
652 ov2685->anal_gain = v4l2_ctrl_new_std(handler, &ov2685_ctrl_ops, in ov2685_initialize_controls()
657 ov2685->test_pattern = v4l2_ctrl_new_std_menu_items(handler, in ov2685_initialize_controls()
664 dev_err(&ov2685->client->dev, in ov2685_initialize_controls()
669 ov2685->subdev.ctrl_handler = handler; in ov2685_initialize_controls()
679 static int ov2685_check_sensor_id(struct ov2685 *ov2685, in ov2685_check_sensor_id() argument
682 struct device *dev = &ov2685->client->dev; in ov2685_check_sensor_id()
698 static int ov2685_configure_regulators(struct ov2685 *ov2685) in ov2685_configure_regulators() argument
703 ov2685->supplies[i].supply = ov2685_supply_names[i]; in ov2685_configure_regulators()
705 return devm_regulator_bulk_get(&ov2685->client->dev, in ov2685_configure_regulators()
707 ov2685->supplies); in ov2685_configure_regulators()
714 struct ov2685 *ov2685; in ov2685_probe() local
717 ov2685 = devm_kzalloc(dev, sizeof(*ov2685), GFP_KERNEL); in ov2685_probe()
718 if (!ov2685) in ov2685_probe()
721 ov2685->client = client; in ov2685_probe()
722 ov2685->cur_mode = &supported_modes[0]; in ov2685_probe()
724 ov2685->xvclk = devm_clk_get(dev, "xvclk"); in ov2685_probe()
725 if (IS_ERR(ov2685->xvclk)) { in ov2685_probe()
729 ret = clk_set_rate(ov2685->xvclk, OV2685_XVCLK_FREQ); in ov2685_probe()
734 if (clk_get_rate(ov2685->xvclk) != OV2685_XVCLK_FREQ) in ov2685_probe()
737 ov2685->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in ov2685_probe()
738 if (IS_ERR(ov2685->reset_gpio)) { in ov2685_probe()
743 ret = ov2685_configure_regulators(ov2685); in ov2685_probe()
749 mutex_init(&ov2685->mutex); in ov2685_probe()
750 v4l2_i2c_subdev_init(&ov2685->subdev, client, &ov2685_subdev_ops); in ov2685_probe()
751 ret = ov2685_initialize_controls(ov2685); in ov2685_probe()
755 ret = __ov2685_power_on(ov2685); in ov2685_probe()
759 ret = ov2685_check_sensor_id(ov2685, client); in ov2685_probe()
764 ov2685->subdev.internal_ops = &ov2685_internal_ops; in ov2685_probe()
765 ov2685->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in ov2685_probe()
768 ov2685->pad.flags = MEDIA_PAD_FL_SOURCE; in ov2685_probe()
769 ov2685->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR; in ov2685_probe()
770 ret = media_entity_pads_init(&ov2685->subdev.entity, 1, &ov2685->pad); in ov2685_probe()
775 ret = v4l2_async_register_subdev(&ov2685->subdev); in ov2685_probe()
789 media_entity_cleanup(&ov2685->subdev.entity); in ov2685_probe()
792 __ov2685_power_off(ov2685); in ov2685_probe()
794 v4l2_ctrl_handler_free(&ov2685->ctrl_handler); in ov2685_probe()
796 mutex_destroy(&ov2685->mutex); in ov2685_probe()
804 struct ov2685 *ov2685 = to_ov2685(sd); in ov2685_remove() local
810 v4l2_ctrl_handler_free(&ov2685->ctrl_handler); in ov2685_remove()
811 mutex_destroy(&ov2685->mutex); in ov2685_remove()
815 __ov2685_power_off(ov2685); in ov2685_remove()