Lines Matching refs:ov9734

17 /* ov9734 only support 1-lane mipi output */
323 struct ov9734 {
342 static inline struct ov9734 *to_ov9734(struct v4l2_subdev *subdev)
344 return container_of(subdev, struct ov9734, sd);
365 static int ov9734_read_reg(struct ov9734 *ov9734, u16 reg, u16 len, u32 *val)
367 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
395 static int ov9734_write_reg(struct ov9734 *ov9734, u16 reg, u16 len, u32 val)
397 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
414 static int ov9734_write_reg_list(struct ov9734 *ov9734,
417 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
422 ret = ov9734_write_reg(ov9734, r_list->regs[i].address, 1,
435 static int ov9734_update_digital_gain(struct ov9734 *ov9734, u32 d_gain)
439 ret = ov9734_write_reg(ov9734, OV9734_REG_GROUP_ACCESS, 1,
444 ret = ov9734_write_reg(ov9734, OV9734_REG_MWB_R_GAIN, 2, d_gain);
448 ret = ov9734_write_reg(ov9734, OV9734_REG_MWB_G_GAIN, 2, d_gain);
452 ret = ov9734_write_reg(ov9734, OV9734_REG_MWB_B_GAIN, 2, d_gain);
456 ret = ov9734_write_reg(ov9734, OV9734_REG_GROUP_ACCESS, 1,
461 ret = ov9734_write_reg(ov9734, OV9734_REG_GROUP_ACCESS, 1,
466 static int ov9734_test_pattern(struct ov9734 *ov9734, u32 pattern)
472 return ov9734_write_reg(ov9734, OV9734_REG_TEST_PATTERN, 1, pattern);
477 struct ov9734 *ov9734 = container_of(ctrl->handler,
478 struct ov9734, ctrl_handler);
479 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
486 exposure_max = ov9734->cur_mode->height + ctrl->val -
488 __v4l2_ctrl_modify_range(ov9734->exposure,
489 ov9734->exposure->minimum,
490 exposure_max, ov9734->exposure->step,
500 ret = ov9734_write_reg(ov9734, OV9734_REG_ANALOG_GAIN,
505 ret = ov9734_update_digital_gain(ov9734, ctrl->val);
510 ret = ov9734_write_reg(ov9734, OV9734_REG_EXPOSURE,
515 ret = ov9734_write_reg(ov9734, OV9734_REG_VTS, 2,
516 ov9734->cur_mode->height + ctrl->val);
520 ret = ov9734_test_pattern(ov9734, ctrl->val);
537 static int ov9734_init_controls(struct ov9734 *ov9734)
545 ctrl_hdlr = &ov9734->ctrl_handler;
550 ctrl_hdlr->lock = &ov9734->mutex;
551 cur_mode = ov9734->cur_mode;
553 ov9734->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov9734_ctrl_ops,
557 if (ov9734->link_freq)
558 ov9734->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
561 ov9734->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov9734_ctrl_ops,
567 ov9734->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov9734_ctrl_ops,
572 ov9734->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov9734_ctrl_ops,
575 if (ov9734->hblank)
576 ov9734->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
584 exposure_max = ov9734->cur_mode->vts_def - OV9734_EXPOSURE_MAX_MARGIN;
585 ov9734->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov9734_ctrl_ops,
597 ov9734->sd.ctrl_handler = ctrl_hdlr;
611 static int ov9734_start_streaming(struct ov9734 *ov9734)
613 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
617 link_freq_index = ov9734->cur_mode->link_freq_index;
619 ret = ov9734_write_reg_list(ov9734, reg_list);
625 reg_list = &ov9734->cur_mode->reg_list;
626 ret = ov9734_write_reg_list(ov9734, reg_list);
632 ret = __v4l2_ctrl_handler_setup(ov9734->sd.ctrl_handler);
636 ret = ov9734_write_reg(ov9734, OV9734_REG_MODE_SELECT,
644 static void ov9734_stop_streaming(struct ov9734 *ov9734)
646 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
648 if (ov9734_write_reg(ov9734, OV9734_REG_MODE_SELECT,
655 struct ov9734 *ov9734 = to_ov9734(sd);
659 mutex_lock(&ov9734->mutex);
664 mutex_unlock(&ov9734->mutex);
668 ret = ov9734_start_streaming(ov9734);
671 ov9734_stop_streaming(ov9734);
675 ov9734_stop_streaming(ov9734);
679 mutex_unlock(&ov9734->mutex);
688 struct ov9734 *ov9734 = to_ov9734(sd);
697 mutex_lock(&ov9734->mutex);
702 ov9734->cur_mode = mode;
703 __v4l2_ctrl_s_ctrl(ov9734->link_freq, mode->link_freq_index);
704 __v4l2_ctrl_s_ctrl_int64(ov9734->pixel_rate,
709 __v4l2_ctrl_modify_range(ov9734->vblank,
713 __v4l2_ctrl_s_ctrl(ov9734->vblank, vblank_def);
716 __v4l2_ctrl_modify_range(ov9734->hblank, h_blank, h_blank, 1,
720 mutex_unlock(&ov9734->mutex);
729 struct ov9734 *ov9734 = to_ov9734(sd);
731 mutex_lock(&ov9734->mutex);
736 ov9734_update_pad_format(ov9734->cur_mode, &fmt->format);
738 mutex_unlock(&ov9734->mutex);
775 struct ov9734 *ov9734 = to_ov9734(sd);
777 mutex_lock(&ov9734->mutex);
780 mutex_unlock(&ov9734->mutex);
809 static int ov9734_identify_module(struct ov9734 *ov9734)
811 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
815 ret = ov9734_read_reg(ov9734, OV9734_REG_CHIP_ID, 2, &val);
890 struct ov9734 *ov9734 = to_ov9734(sd);
897 mutex_destroy(&ov9734->mutex);
902 struct ov9734 *ov9734;
912 ov9734 = devm_kzalloc(&client->dev, sizeof(*ov9734), GFP_KERNEL);
913 if (!ov9734)
916 v4l2_i2c_subdev_init(&ov9734->sd, client, &ov9734_subdev_ops);
917 ret = ov9734_identify_module(ov9734);
923 mutex_init(&ov9734->mutex);
924 ov9734->cur_mode = &supported_modes[0];
925 ret = ov9734_init_controls(ov9734);
931 ov9734->sd.internal_ops = &ov9734_internal_ops;
932 ov9734->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
933 ov9734->sd.entity.ops = &ov9734_subdev_entity_ops;
934 ov9734->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
935 ov9734->pad.flags = MEDIA_PAD_FL_SOURCE;
936 ret = media_entity_pads_init(&ov9734->sd.entity, 1, &ov9734->pad);
950 ret = v4l2_async_register_subdev_sensor(&ov9734->sd);
962 media_entity_cleanup(&ov9734->sd.entity);
965 v4l2_ctrl_handler_free(ov9734->sd.ctrl_handler);
966 mutex_destroy(&ov9734->mutex);
980 .name = "ov9734",