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_get_sync(&ov2685->client->dev); in ov2685_s_stream()
464 ret = __v4l2_ctrl_handler_setup(&ov2685->ctrl_handler); in ov2685_s_stream()
478 pm_runtime_put(&ov2685->client->dev); in ov2685_s_stream()
481 ov2685->streaming = on; in ov2685_s_stream()
484 mutex_unlock(&ov2685->mutex); in ov2685_s_stream()
492 struct ov2685 *ov2685 = to_ov2685(sd); in ov2685_open() local
495 mutex_lock(&ov2685->mutex); in ov2685_open()
501 mutex_unlock(&ov2685->mutex); in ov2685_open()
511 struct ov2685 *ov2685 = to_ov2685(sd); in ov2685_runtime_resume() local
513 return __ov2685_power_on(ov2685); in ov2685_runtime_resume()
520 struct ov2685 *ov2685 = to_ov2685(sd); in ov2685_runtime_suspend() local
522 __ov2685_power_off(ov2685); in ov2685_runtime_suspend()
534 struct ov2685 *ov2685 = container_of(ctrl->handler, in ov2685_set_ctrl() local
535 struct ov2685, ctrl_handler); in ov2685_set_ctrl()
536 struct i2c_client *client = ov2685->client; in ov2685_set_ctrl()
544 max_expo = ov2685->cur_mode->height + ctrl->val - 4; in ov2685_set_ctrl()
545 __v4l2_ctrl_modify_range(ov2685->exposure, in ov2685_set_ctrl()
546 ov2685->exposure->minimum, max_expo, in ov2685_set_ctrl()
547 ov2685->exposure->step, in ov2685_set_ctrl()
548 ov2685->exposure->default_value); in ov2685_set_ctrl()
557 ret = ov2685_write_reg(ov2685->client, OV2685_REG_EXPOSURE, in ov2685_set_ctrl()
561 ret = ov2685_write_reg(ov2685->client, OV2685_REG_GAIN, in ov2685_set_ctrl()
565 ret = ov2685_write_reg(ov2685->client, OV2685_REG_VTS, in ov2685_set_ctrl()
567 ctrl->val + ov2685->cur_mode->height); in ov2685_set_ctrl()
570 ret = ov2685_write_reg(ov2685->client, OV2685_REG_TEST_PATTERN, in ov2685_set_ctrl()
612 static int ov2685_initialize_controls(struct ov2685 *ov2685) in ov2685_initialize_controls() argument
621 handler = &ov2685->ctrl_handler; in ov2685_initialize_controls()
622 mode = ov2685->cur_mode; in ov2685_initialize_controls()
626 handler->lock = &ov2685->mutex; in ov2685_initialize_controls()
639 ov2685->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in ov2685_initialize_controls()
641 if (ov2685->hblank) in ov2685_initialize_controls()
642 ov2685->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov2685_initialize_controls()
644 ov2685->vblank = v4l2_ctrl_new_std(handler, &ov2685_ctrl_ops, in ov2685_initialize_controls()
650 ov2685->exposure = v4l2_ctrl_new_std(handler, &ov2685_ctrl_ops, in ov2685_initialize_controls()
655 ov2685->anal_gain = v4l2_ctrl_new_std(handler, &ov2685_ctrl_ops, in ov2685_initialize_controls()
660 ov2685->test_pattern = v4l2_ctrl_new_std_menu_items(handler, in ov2685_initialize_controls()
667 dev_err(&ov2685->client->dev, in ov2685_initialize_controls()
672 ov2685->subdev.ctrl_handler = handler; in ov2685_initialize_controls()
682 static int ov2685_check_sensor_id(struct ov2685 *ov2685, in ov2685_check_sensor_id() argument
685 struct device *dev = &ov2685->client->dev; in ov2685_check_sensor_id()
701 static int ov2685_configure_regulators(struct ov2685 *ov2685) in ov2685_configure_regulators() argument
706 ov2685->supplies[i].supply = ov2685_supply_names[i]; in ov2685_configure_regulators()
708 return devm_regulator_bulk_get(&ov2685->client->dev, in ov2685_configure_regulators()
710 ov2685->supplies); in ov2685_configure_regulators()
717 struct ov2685 *ov2685; in ov2685_probe() local
720 ov2685 = devm_kzalloc(dev, sizeof(*ov2685), GFP_KERNEL); in ov2685_probe()
721 if (!ov2685) in ov2685_probe()
724 ov2685->client = client; in ov2685_probe()
725 ov2685->cur_mode = &supported_modes[0]; in ov2685_probe()
727 ov2685->xvclk = devm_clk_get(dev, "xvclk"); in ov2685_probe()
728 if (IS_ERR(ov2685->xvclk)) { in ov2685_probe()
732 ret = clk_set_rate(ov2685->xvclk, OV2685_XVCLK_FREQ); in ov2685_probe()
737 if (clk_get_rate(ov2685->xvclk) != OV2685_XVCLK_FREQ) in ov2685_probe()
740 ov2685->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in ov2685_probe()
741 if (IS_ERR(ov2685->reset_gpio)) { in ov2685_probe()
746 ret = ov2685_configure_regulators(ov2685); in ov2685_probe()
752 mutex_init(&ov2685->mutex); in ov2685_probe()
753 v4l2_i2c_subdev_init(&ov2685->subdev, client, &ov2685_subdev_ops); in ov2685_probe()
754 ret = ov2685_initialize_controls(ov2685); in ov2685_probe()
758 ret = __ov2685_power_on(ov2685); in ov2685_probe()
762 ret = ov2685_check_sensor_id(ov2685, client); in ov2685_probe()
767 ov2685->subdev.internal_ops = &ov2685_internal_ops; in ov2685_probe()
768 ov2685->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in ov2685_probe()
771 ov2685->pad.flags = MEDIA_PAD_FL_SOURCE; in ov2685_probe()
772 ov2685->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR; in ov2685_probe()
773 ret = media_entity_pads_init(&ov2685->subdev.entity, 1, &ov2685->pad); in ov2685_probe()
778 ret = v4l2_async_register_subdev(&ov2685->subdev); in ov2685_probe()
792 media_entity_cleanup(&ov2685->subdev.entity); in ov2685_probe()
795 __ov2685_power_off(ov2685); in ov2685_probe()
797 v4l2_ctrl_handler_free(&ov2685->ctrl_handler); in ov2685_probe()
799 mutex_destroy(&ov2685->mutex); in ov2685_probe()
807 struct ov2685 *ov2685 = to_ov2685(sd); in ov2685_remove() local
813 v4l2_ctrl_handler_free(&ov2685->ctrl_handler); in ov2685_remove()
814 mutex_destroy(&ov2685->mutex); in ov2685_remove()
818 __ov2685_power_off(ov2685); in ov2685_remove()