Lines Matching +full:dovdd +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0
17 #include <media/media-entity.h>
18 #include <media/v4l2-async.h>
19 #include <media/v4l2-ctrls.h>
20 #include <media/v4l2-subdev.h>
63 "dovdd", /* Digital I/O power */
254 return -EINVAL; in ov2685_write_reg()
262 val_i = 4 - len; in ov2685_write_reg()
268 return -EIO; in ov2685_write_reg()
297 return -EINVAL; in ov2685_read_reg()
301 msgs[0].addr = client->addr; in ov2685_read_reg()
307 msgs[1].addr = client->addr; in ov2685_read_reg()
310 msgs[1].buf = &data_be_p[4 - len]; in ov2685_read_reg()
312 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); in ov2685_read_reg()
314 return -EIO; in ov2685_read_reg()
324 fmt->code = MEDIA_BUS_FMT_SBGGR10_1X10; in ov2685_fill_fmt()
325 fmt->width = mode->width; in ov2685_fill_fmt()
326 fmt->height = mode->height; in ov2685_fill_fmt()
327 fmt->field = V4L2_FIELD_NONE; in ov2685_fill_fmt()
335 struct v4l2_mbus_framefmt *mbus_fmt = &fmt->format; in ov2685_set_fmt()
338 ov2685_fill_fmt(ov2685->cur_mode, mbus_fmt); in ov2685_set_fmt()
348 struct v4l2_mbus_framefmt *mbus_fmt = &fmt->format; in ov2685_get_fmt()
350 ov2685_fill_fmt(ov2685->cur_mode, mbus_fmt); in ov2685_get_fmt()
359 if (code->index >= ARRAY_SIZE(supported_modes)) in ov2685_enum_mbus_code()
360 return -EINVAL; in ov2685_enum_mbus_code()
362 code->code = MEDIA_BUS_FMT_SBGGR10_1X10; in ov2685_enum_mbus_code()
371 int index = fse->index; in ov2685_enum_frame_sizes()
374 return -EINVAL; in ov2685_enum_frame_sizes()
376 fse->code = MEDIA_BUS_FMT_SBGGR10_1X10; in ov2685_enum_frame_sizes()
378 fse->min_width = supported_modes[index].width; in ov2685_enum_frame_sizes()
379 fse->max_width = supported_modes[index].width; in ov2685_enum_frame_sizes()
380 fse->max_height = supported_modes[index].height; in ov2685_enum_frame_sizes()
381 fse->min_height = supported_modes[index].height; in ov2685_enum_frame_sizes()
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()
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()
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()
461 pm_runtime_put_noidle(&client->dev); in ov2685_s_stream()
464 ret = __v4l2_ctrl_handler_setup(&ov2685->ctrl_handler); in ov2685_s_stream()
466 pm_runtime_put(&client->dev); in ov2685_s_stream()
472 pm_runtime_put(&client->dev); 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()
495 mutex_lock(&ov2685->mutex); in ov2685_open()
497 try_fmt = v4l2_subdev_get_try_format(sd, fh->pad, 0); in ov2685_open()
501 mutex_unlock(&ov2685->mutex); in ov2685_open()
534 struct ov2685 *ov2685 = container_of(ctrl->handler, in ov2685_set_ctrl()
536 struct i2c_client *client = ov2685->client; in ov2685_set_ctrl()
541 switch (ctrl->id) { 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()
552 if (!pm_runtime_get_if_in_use(&client->dev)) in ov2685_set_ctrl()
555 switch (ctrl->id) { in ov2685_set_ctrl()
557 ret = ov2685_write_reg(ov2685->client, OV2685_REG_EXPOSURE, in ov2685_set_ctrl()
558 OV2685_REG_VALUE_24BIT, ctrl->val << 4); in ov2685_set_ctrl()
561 ret = ov2685_write_reg(ov2685->client, OV2685_REG_GAIN, in ov2685_set_ctrl()
562 OV2685_REG_VALUE_16BIT, ctrl->val); 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()
572 ov2685_test_pattern_val[ctrl->val]); in ov2685_set_ctrl()
575 dev_warn(&client->dev, "%s Unhandled id:0x%x, val:0x%x\n", in ov2685_set_ctrl()
576 __func__, ctrl->id, ctrl->val); in ov2685_set_ctrl()
577 ret = -EINVAL; in ov2685_set_ctrl()
581 pm_runtime_put(&client->dev); in ov2685_set_ctrl()
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()
631 ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov2685_initialize_controls()
638 h_blank = mode->hts_def - mode->width; 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()
645 V4L2_CID_VBLANK, mode->vts_def - mode->height, in ov2685_initialize_controls()
646 OV2685_VTS_MAX - mode->height, 1, in ov2685_initialize_controls()
647 mode->vts_def - mode->height); in ov2685_initialize_controls()
649 exposure_max = mode->vts_def - 4; in ov2685_initialize_controls()
650 ov2685->exposure = v4l2_ctrl_new_std(handler, &ov2685_ctrl_ops, in ov2685_initialize_controls()
653 mode->exp_def); 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()
662 ARRAY_SIZE(ov2685_test_pattern_menu) - 1, in ov2685_initialize_controls()
665 if (handler->error) { in ov2685_initialize_controls()
666 ret = handler->error; in ov2685_initialize_controls()
667 dev_err(&ov2685->client->dev, in ov2685_initialize_controls()
672 ov2685->subdev.ctrl_handler = handler; in ov2685_initialize_controls()
685 struct device *dev = &ov2685->client->dev; in ov2685_check_sensor_id()
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()
716 struct device *dev = &client->dev; in ov2685_probe()
722 return -ENOMEM; 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()
730 return -EINVAL; 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()
742 dev_err(dev, "Failed to get reset-gpios\n"); in ov2685_probe()
743 return -EINVAL; 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()
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()
797 v4l2_ctrl_handler_free(&ov2685->ctrl_handler); in ov2685_probe()
799 mutex_destroy(&ov2685->mutex); in ov2685_probe()
811 media_entity_cleanup(&sd->entity); in ov2685_remove()
813 v4l2_ctrl_handler_free(&ov2685->ctrl_handler); in ov2685_remove()
814 mutex_destroy(&ov2685->mutex); in ov2685_remove()
816 pm_runtime_disable(&client->dev); in ov2685_remove()
817 if (!pm_runtime_status_suspended(&client->dev)) in ov2685_remove()
819 pm_runtime_set_suspended(&client->dev); in ov2685_remove()