Lines Matching defs:ov02a10
102 struct ov02a10 {
129 static inline struct ov02a10 *to_ov02a10(struct v4l2_subdev *sd)
131 return container_of(sd, struct ov02a10, subdev);
272 static int ov02a10_write_array(struct ov02a10 *ov02a10,
275 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev);
301 struct ov02a10 *ov02a10 = to_ov02a10(sd);
306 mutex_lock(&ov02a10->mutex);
308 if (ov02a10->streaming && fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
314 mbus_fmt->code = ov02a10->fmt.code;
315 ov02a10_fill_fmt(ov02a10->cur_mode, mbus_fmt);
320 frame_fmt = &ov02a10->fmt;
325 mutex_unlock(&ov02a10->mutex);
333 struct ov02a10 *ov02a10 = to_ov02a10(sd);
336 mutex_lock(&ov02a10->mutex);
342 fmt->format = ov02a10->fmt;
343 mbus_fmt->code = ov02a10->fmt.code;
344 ov02a10_fill_fmt(ov02a10->cur_mode, mbus_fmt);
347 mutex_unlock(&ov02a10->mutex);
356 struct ov02a10 *ov02a10 = to_ov02a10(sd);
361 code->code = ov02a10->fmt.code;
381 static int ov02a10_check_sensor_id(struct ov02a10 *ov02a10)
383 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev);
406 struct ov02a10 *ov02a10 = to_ov02a10(sd);
409 gpiod_set_value_cansleep(ov02a10->rst_gpio, 1);
410 gpiod_set_value_cansleep(ov02a10->pd_gpio, 1);
412 ret = clk_prepare_enable(ov02a10->eclk);
419 ov02a10->supplies);
426 gpiod_set_value_cansleep(ov02a10->pd_gpio, 0);
429 gpiod_set_value_cansleep(ov02a10->rst_gpio, 0);
432 ret = ov02a10_check_sensor_id(ov02a10);
440 ov02a10->supplies);
442 clk_disable_unprepare(ov02a10->eclk);
451 struct ov02a10 *ov02a10 = to_ov02a10(sd);
453 gpiod_set_value_cansleep(ov02a10->rst_gpio, 1);
454 clk_disable_unprepare(ov02a10->eclk);
455 gpiod_set_value_cansleep(ov02a10->pd_gpio, 1);
457 ov02a10->supplies);
462 static int __ov02a10_start_stream(struct ov02a10 *ov02a10)
464 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev);
469 reg_list = &ov02a10->cur_mode->reg_list;
470 ret = ov02a10_write_array(ov02a10, reg_list);
475 ret = __v4l2_ctrl_handler_setup(ov02a10->subdev.ctrl_handler);
480 if (ov02a10->upside_down) {
494 if (ov02a10->mipi_clock_voltage != OV02A10_MIPI_TX_SPEED_DEFAULT) {
496 ov02a10->mipi_clock_voltage);
506 static int __ov02a10_stop_stream(struct ov02a10 *ov02a10)
508 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev);
532 struct ov02a10 *ov02a10 = to_ov02a10(sd);
533 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev);
536 mutex_lock(&ov02a10->mutex);
538 if (ov02a10->streaming == on) {
548 ret = __ov02a10_start_stream(ov02a10);
550 __ov02a10_stop_stream(ov02a10);
551 ov02a10->streaming = !on;
555 __ov02a10_stop_stream(ov02a10);
559 ov02a10->streaming = on;
560 mutex_unlock(&ov02a10->mutex);
567 mutex_unlock(&ov02a10->mutex);
576 static int ov02a10_set_exposure(struct ov02a10 *ov02a10, int val)
578 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev);
598 static int ov02a10_set_gain(struct ov02a10 *ov02a10, int val)
600 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev);
615 static int ov02a10_set_vblank(struct ov02a10 *ov02a10, int val)
617 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev);
618 u32 vts = val + ov02a10->cur_mode->height - OV02A10_BASE_LINES;
638 static int ov02a10_set_test_pattern(struct ov02a10 *ov02a10, int pattern)
640 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev);
663 struct ov02a10 *ov02a10 = container_of(ctrl->handler,
664 struct ov02a10, ctrl_handler);
665 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev);
672 max_expo = ov02a10->cur_mode->height + ctrl->val -
674 __v4l2_ctrl_modify_range(ov02a10->exposure,
675 ov02a10->exposure->minimum, max_expo,
676 ov02a10->exposure->step,
677 ov02a10->exposure->default_value);
686 ret = ov02a10_set_exposure(ov02a10, ctrl->val);
689 ret = ov02a10_set_gain(ov02a10, ctrl->val);
692 ret = ov02a10_set_vblank(ov02a10, ctrl->val);
695 ret = ov02a10_set_test_pattern(ov02a10, ctrl->val);
735 static int ov02a10_initialize_controls(struct ov02a10 *ov02a10)
737 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev);
747 handler = &ov02a10->ctrl_handler;
748 mode = ov02a10->cur_mode;
753 handler->lock = &ov02a10->mutex;
774 ov02a10->exposure = v4l2_ctrl_new_std(handler, &ov02a10_ctrl_ops,
797 ov02a10->subdev.ctrl_handler = handler;
807 static int ov02a10_check_hwcfg(struct device *dev, struct ov02a10 *ov02a10)
835 ov02a10->mipi_clock_voltage = clk_volt;
860 struct ov02a10 *ov02a10;
865 ov02a10 = devm_kzalloc(dev, sizeof(*ov02a10), GFP_KERNEL);
866 if (!ov02a10)
869 ret = ov02a10_check_hwcfg(dev, ov02a10);
874 v4l2_i2c_subdev_init(&ov02a10->subdev, client, &ov02a10_subdev_ops);
875 ov02a10->subdev.internal_ops = &ov02a10_internal_ops;
877 ov02a10->mipi_clock_voltage = OV02A10_MIPI_TX_SPEED_DEFAULT;
878 ov02a10->fmt.code = MEDIA_BUS_FMT_SBGGR10_1X10;
884 ov02a10->upside_down = true;
885 ov02a10->fmt.code = MEDIA_BUS_FMT_SRGGB10_1X10;
888 ov02a10->eclk = devm_clk_get(dev, "eclk");
889 if (IS_ERR(ov02a10->eclk))
890 return dev_err_probe(dev, PTR_ERR(ov02a10->eclk),
894 &ov02a10->eclk_freq);
899 ret = clk_set_rate(ov02a10->eclk, ov02a10->eclk_freq);
904 if (clk_get_rate(ov02a10->eclk) != OV02A10_ECLK_FREQ)
907 ov02a10->pd_gpio = devm_gpiod_get(dev, "powerdown", GPIOD_OUT_HIGH);
908 if (IS_ERR(ov02a10->pd_gpio))
909 return dev_err_probe(dev, PTR_ERR(ov02a10->pd_gpio),
912 ov02a10->rst_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
913 if (IS_ERR(ov02a10->rst_gpio))
914 return dev_err_probe(dev, PTR_ERR(ov02a10->rst_gpio),
918 ov02a10->supplies[i].supply = ov02a10_supply_names[i];
921 ov02a10->supplies);
925 mutex_init(&ov02a10->mutex);
928 ov02a10->cur_mode = &supported_modes[0];
930 ret = ov02a10_initialize_controls(ov02a10);
937 ov02a10->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
938 ov02a10->subdev.entity.ops = &ov02a10_subdev_entity_ops;
939 ov02a10->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
940 ov02a10->pad.flags = MEDIA_PAD_FL_SOURCE;
942 ret = media_entity_pads_init(&ov02a10->subdev.entity, 1, &ov02a10->pad);
957 ret = v4l2_async_register_subdev(&ov02a10->subdev);
971 media_entity_cleanup(&ov02a10->subdev.entity);
973 v4l2_ctrl_handler_free(ov02a10->subdev.ctrl_handler);
975 mutex_destroy(&ov02a10->mutex);
983 struct ov02a10 *ov02a10 = to_ov02a10(sd);
992 mutex_destroy(&ov02a10->mutex);
996 { .compatible = "ovti,ov02a10" },
1003 .name = "ov02a10",