Lines Matching full:ov02a10

102 struct ov02a10 {  struct
129 static inline struct ov02a10 *to_ov02a10(struct v4l2_subdev *sd) in to_ov02a10() argument
131 return container_of(sd, struct ov02a10, subdev); in to_ov02a10()
272 static int ov02a10_write_array(struct ov02a10 *ov02a10, in ov02a10_write_array() argument
275 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); in ov02a10_write_array()
301 struct ov02a10 *ov02a10 = to_ov02a10(sd); in ov02a10_set_fmt() local
306 mutex_lock(&ov02a10->mutex); in ov02a10_set_fmt()
308 if (ov02a10->streaming && fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { in ov02a10_set_fmt()
314 mbus_fmt->code = ov02a10->fmt.code; in ov02a10_set_fmt()
315 ov02a10_fill_fmt(ov02a10->cur_mode, mbus_fmt); in ov02a10_set_fmt()
320 frame_fmt = &ov02a10->fmt; in ov02a10_set_fmt()
325 mutex_unlock(&ov02a10->mutex); in ov02a10_set_fmt()
333 struct ov02a10 *ov02a10 = to_ov02a10(sd); in ov02a10_get_fmt() local
336 mutex_lock(&ov02a10->mutex); in ov02a10_get_fmt()
342 fmt->format = ov02a10->fmt; in ov02a10_get_fmt()
343 mbus_fmt->code = ov02a10->fmt.code; in ov02a10_get_fmt()
344 ov02a10_fill_fmt(ov02a10->cur_mode, mbus_fmt); in ov02a10_get_fmt()
347 mutex_unlock(&ov02a10->mutex); in ov02a10_get_fmt()
356 struct ov02a10 *ov02a10 = to_ov02a10(sd); in ov02a10_enum_mbus_code() local
361 code->code = ov02a10->fmt.code; in ov02a10_enum_mbus_code()
381 static int ov02a10_check_sensor_id(struct ov02a10 *ov02a10) in ov02a10_check_sensor_id() argument
383 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); in ov02a10_check_sensor_id()
406 struct ov02a10 *ov02a10 = to_ov02a10(sd); in ov02a10_power_on() local
409 gpiod_set_value_cansleep(ov02a10->rst_gpio, 1); in ov02a10_power_on()
410 gpiod_set_value_cansleep(ov02a10->pd_gpio, 1); in ov02a10_power_on()
412 ret = clk_prepare_enable(ov02a10->eclk); in ov02a10_power_on()
419 ov02a10->supplies); in ov02a10_power_on()
426 gpiod_set_value_cansleep(ov02a10->pd_gpio, 0); in ov02a10_power_on()
429 gpiod_set_value_cansleep(ov02a10->rst_gpio, 0); in ov02a10_power_on()
432 ret = ov02a10_check_sensor_id(ov02a10); in ov02a10_power_on()
440 ov02a10->supplies); in ov02a10_power_on()
442 clk_disable_unprepare(ov02a10->eclk); in ov02a10_power_on()
451 struct ov02a10 *ov02a10 = to_ov02a10(sd); in ov02a10_power_off() local
453 gpiod_set_value_cansleep(ov02a10->rst_gpio, 1); in ov02a10_power_off()
454 clk_disable_unprepare(ov02a10->eclk); in ov02a10_power_off()
455 gpiod_set_value_cansleep(ov02a10->pd_gpio, 1); in ov02a10_power_off()
457 ov02a10->supplies); in ov02a10_power_off()
462 static int __ov02a10_start_stream(struct ov02a10 *ov02a10) in __ov02a10_start_stream() argument
464 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); in __ov02a10_start_stream()
469 reg_list = &ov02a10->cur_mode->reg_list; in __ov02a10_start_stream()
470 ret = ov02a10_write_array(ov02a10, reg_list); in __ov02a10_start_stream()
475 ret = __v4l2_ctrl_handler_setup(ov02a10->subdev.ctrl_handler); in __ov02a10_start_stream()
480 if (ov02a10->upside_down) { in __ov02a10_start_stream()
494 if (ov02a10->mipi_clock_voltage != OV02A10_MIPI_TX_SPEED_DEFAULT) { in __ov02a10_start_stream()
496 ov02a10->mipi_clock_voltage); in __ov02a10_start_stream()
506 static int __ov02a10_stop_stream(struct ov02a10 *ov02a10) in __ov02a10_stop_stream() argument
508 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); in __ov02a10_stop_stream()
532 struct ov02a10 *ov02a10 = to_ov02a10(sd); in ov02a10_s_stream() local
533 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); in ov02a10_s_stream()
536 mutex_lock(&ov02a10->mutex); in ov02a10_s_stream()
538 if (ov02a10->streaming == on) { in ov02a10_s_stream()
548 ret = __ov02a10_start_stream(ov02a10); in ov02a10_s_stream()
550 __ov02a10_stop_stream(ov02a10); in ov02a10_s_stream()
551 ov02a10->streaming = !on; in ov02a10_s_stream()
555 __ov02a10_stop_stream(ov02a10); in ov02a10_s_stream()
559 ov02a10->streaming = on; in ov02a10_s_stream()
560 mutex_unlock(&ov02a10->mutex); in ov02a10_s_stream()
567 mutex_unlock(&ov02a10->mutex); in ov02a10_s_stream()
578 static int ov02a10_set_exposure(struct ov02a10 *ov02a10, int val) in ov02a10_set_exposure() argument
580 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); in ov02a10_set_exposure()
600 static int ov02a10_set_gain(struct ov02a10 *ov02a10, int val) in ov02a10_set_gain() argument
602 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); in ov02a10_set_gain()
617 static int ov02a10_set_vblank(struct ov02a10 *ov02a10, int val) in ov02a10_set_vblank() argument
619 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); in ov02a10_set_vblank()
620 u32 vts = val + ov02a10->cur_mode->height - OV02A10_BASE_LINES; in ov02a10_set_vblank()
640 static int ov02a10_set_test_pattern(struct ov02a10 *ov02a10, int pattern) in ov02a10_set_test_pattern() argument
642 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); in ov02a10_set_test_pattern()
665 struct ov02a10 *ov02a10 = container_of(ctrl->handler, in ov02a10_set_ctrl() local
666 struct ov02a10, ctrl_handler); in ov02a10_set_ctrl()
667 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); in ov02a10_set_ctrl()
674 max_expo = ov02a10->cur_mode->height + ctrl->val - in ov02a10_set_ctrl()
676 __v4l2_ctrl_modify_range(ov02a10->exposure, in ov02a10_set_ctrl()
677 ov02a10->exposure->minimum, max_expo, in ov02a10_set_ctrl()
678 ov02a10->exposure->step, in ov02a10_set_ctrl()
679 ov02a10->exposure->default_value); in ov02a10_set_ctrl()
688 ret = ov02a10_set_exposure(ov02a10, ctrl->val); in ov02a10_set_ctrl()
691 ret = ov02a10_set_gain(ov02a10, ctrl->val); in ov02a10_set_ctrl()
694 ret = ov02a10_set_vblank(ov02a10, ctrl->val); in ov02a10_set_ctrl()
697 ret = ov02a10_set_test_pattern(ov02a10, ctrl->val); in ov02a10_set_ctrl()
734 static int ov02a10_initialize_controls(struct ov02a10 *ov02a10) in ov02a10_initialize_controls() argument
736 struct i2c_client *client = v4l2_get_subdevdata(&ov02a10->subdev); in ov02a10_initialize_controls()
746 handler = &ov02a10->ctrl_handler; in ov02a10_initialize_controls()
747 mode = ov02a10->cur_mode; in ov02a10_initialize_controls()
752 handler->lock = &ov02a10->mutex; in ov02a10_initialize_controls()
773 ov02a10->exposure = v4l2_ctrl_new_std(handler, &ov02a10_ctrl_ops, in ov02a10_initialize_controls()
796 ov02a10->subdev.ctrl_handler = handler; in ov02a10_initialize_controls()
806 static int ov02a10_check_hwcfg(struct device *dev, struct ov02a10 *ov02a10) in ov02a10_check_hwcfg() argument
834 ov02a10->mipi_clock_voltage = clk_volt; in ov02a10_check_hwcfg()
859 struct ov02a10 *ov02a10; in ov02a10_probe() local
864 ov02a10 = devm_kzalloc(dev, sizeof(*ov02a10), GFP_KERNEL); in ov02a10_probe()
865 if (!ov02a10) in ov02a10_probe()
868 ret = ov02a10_check_hwcfg(dev, ov02a10); in ov02a10_probe()
873 v4l2_i2c_subdev_init(&ov02a10->subdev, client, &ov02a10_subdev_ops); in ov02a10_probe()
875 ov02a10->mipi_clock_voltage = OV02A10_MIPI_TX_SPEED_DEFAULT; in ov02a10_probe()
876 ov02a10->fmt.code = MEDIA_BUS_FMT_SBGGR10_1X10; in ov02a10_probe()
882 ov02a10->upside_down = true; in ov02a10_probe()
883 ov02a10->fmt.code = MEDIA_BUS_FMT_SRGGB10_1X10; in ov02a10_probe()
886 ov02a10->eclk = devm_clk_get(dev, "eclk"); in ov02a10_probe()
887 if (IS_ERR(ov02a10->eclk)) in ov02a10_probe()
888 return dev_err_probe(dev, PTR_ERR(ov02a10->eclk), in ov02a10_probe()
892 &ov02a10->eclk_freq); in ov02a10_probe()
897 ret = clk_set_rate(ov02a10->eclk, ov02a10->eclk_freq); in ov02a10_probe()
902 if (clk_get_rate(ov02a10->eclk) != OV02A10_ECLK_FREQ) in ov02a10_probe()
905 ov02a10->pd_gpio = devm_gpiod_get(dev, "powerdown", GPIOD_OUT_HIGH); in ov02a10_probe()
906 if (IS_ERR(ov02a10->pd_gpio)) in ov02a10_probe()
907 return dev_err_probe(dev, PTR_ERR(ov02a10->pd_gpio), in ov02a10_probe()
910 ov02a10->rst_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in ov02a10_probe()
911 if (IS_ERR(ov02a10->rst_gpio)) in ov02a10_probe()
912 return dev_err_probe(dev, PTR_ERR(ov02a10->rst_gpio), in ov02a10_probe()
916 ov02a10->supplies[i].supply = ov02a10_supply_names[i]; in ov02a10_probe()
919 ov02a10->supplies); in ov02a10_probe()
923 mutex_init(&ov02a10->mutex); in ov02a10_probe()
926 ov02a10->cur_mode = &supported_modes[0]; in ov02a10_probe()
928 ret = ov02a10_initialize_controls(ov02a10); in ov02a10_probe()
935 ov02a10->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in ov02a10_probe()
936 ov02a10->subdev.entity.ops = &ov02a10_subdev_entity_ops; in ov02a10_probe()
937 ov02a10->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR; in ov02a10_probe()
938 ov02a10->pad.flags = MEDIA_PAD_FL_SOURCE; in ov02a10_probe()
940 ret = media_entity_pads_init(&ov02a10->subdev.entity, 1, &ov02a10->pad); in ov02a10_probe()
955 ret = v4l2_async_register_subdev(&ov02a10->subdev); in ov02a10_probe()
969 media_entity_cleanup(&ov02a10->subdev.entity); in ov02a10_probe()
971 v4l2_ctrl_handler_free(ov02a10->subdev.ctrl_handler); in ov02a10_probe()
973 mutex_destroy(&ov02a10->mutex); in ov02a10_probe()
981 struct ov02a10 *ov02a10 = to_ov02a10(sd); in ov02a10_remove() local
990 mutex_destroy(&ov02a10->mutex); in ov02a10_remove()
994 { .compatible = "ovti,ov02a10" },
1001 .name = "ov02a10",
1011 MODULE_DESCRIPTION("OmniVision OV02A10 sensor driver");