Lines Matching defs:ov9734
17 /* ov9734 only support 1-lane mipi output */
323 struct ov9734 {
345 static inline struct ov9734 *to_ov9734(struct v4l2_subdev *subdev)
347 return container_of(subdev, struct ov9734, sd);
368 static int ov9734_read_reg(struct ov9734 *ov9734, u16 reg, u16 len, u32 *val)
370 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
398 static int ov9734_write_reg(struct ov9734 *ov9734, u16 reg, u16 len, u32 val)
400 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
417 static int ov9734_write_reg_list(struct ov9734 *ov9734,
420 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
425 ret = ov9734_write_reg(ov9734, r_list->regs[i].address, 1,
438 static int ov9734_update_digital_gain(struct ov9734 *ov9734, u32 d_gain)
442 ret = ov9734_write_reg(ov9734, OV9734_REG_GROUP_ACCESS, 1,
447 ret = ov9734_write_reg(ov9734, OV9734_REG_MWB_R_GAIN, 2, d_gain);
451 ret = ov9734_write_reg(ov9734, OV9734_REG_MWB_G_GAIN, 2, d_gain);
455 ret = ov9734_write_reg(ov9734, OV9734_REG_MWB_B_GAIN, 2, d_gain);
459 ret = ov9734_write_reg(ov9734, OV9734_REG_GROUP_ACCESS, 1,
464 ret = ov9734_write_reg(ov9734, OV9734_REG_GROUP_ACCESS, 1,
469 static int ov9734_test_pattern(struct ov9734 *ov9734, u32 pattern)
475 return ov9734_write_reg(ov9734, OV9734_REG_TEST_PATTERN, 1, pattern);
480 struct ov9734 *ov9734 = container_of(ctrl->handler,
481 struct ov9734, ctrl_handler);
482 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
489 exposure_max = ov9734->cur_mode->height + ctrl->val -
491 __v4l2_ctrl_modify_range(ov9734->exposure,
492 ov9734->exposure->minimum,
493 exposure_max, ov9734->exposure->step,
503 ret = ov9734_write_reg(ov9734, OV9734_REG_ANALOG_GAIN,
508 ret = ov9734_update_digital_gain(ov9734, ctrl->val);
513 ret = ov9734_write_reg(ov9734, OV9734_REG_EXPOSURE,
518 ret = ov9734_write_reg(ov9734, OV9734_REG_VTS, 2,
519 ov9734->cur_mode->height + ctrl->val);
523 ret = ov9734_test_pattern(ov9734, ctrl->val);
540 static int ov9734_init_controls(struct ov9734 *ov9734)
548 ctrl_hdlr = &ov9734->ctrl_handler;
553 ctrl_hdlr->lock = &ov9734->mutex;
554 cur_mode = ov9734->cur_mode;
556 ov9734->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov9734_ctrl_ops,
560 if (ov9734->link_freq)
561 ov9734->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
564 ov9734->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov9734_ctrl_ops,
570 ov9734->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov9734_ctrl_ops,
575 ov9734->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov9734_ctrl_ops,
578 if (ov9734->hblank)
579 ov9734->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
587 exposure_max = ov9734->cur_mode->vts_def - OV9734_EXPOSURE_MAX_MARGIN;
588 ov9734->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov9734_ctrl_ops,
600 ov9734->sd.ctrl_handler = ctrl_hdlr;
614 static int ov9734_start_streaming(struct ov9734 *ov9734)
616 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
620 link_freq_index = ov9734->cur_mode->link_freq_index;
622 ret = ov9734_write_reg_list(ov9734, reg_list);
628 reg_list = &ov9734->cur_mode->reg_list;
629 ret = ov9734_write_reg_list(ov9734, reg_list);
635 ret = __v4l2_ctrl_handler_setup(ov9734->sd.ctrl_handler);
639 ret = ov9734_write_reg(ov9734, OV9734_REG_MODE_SELECT,
647 static void ov9734_stop_streaming(struct ov9734 *ov9734)
649 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
651 if (ov9734_write_reg(ov9734, OV9734_REG_MODE_SELECT,
658 struct ov9734 *ov9734 = to_ov9734(sd);
662 mutex_lock(&ov9734->mutex);
663 if (ov9734->streaming == enable) {
664 mutex_unlock(&ov9734->mutex);
671 mutex_unlock(&ov9734->mutex);
675 ret = ov9734_start_streaming(ov9734);
678 ov9734_stop_streaming(ov9734);
682 ov9734_stop_streaming(ov9734);
686 ov9734->streaming = enable;
687 mutex_unlock(&ov9734->mutex);
696 struct ov9734 *ov9734 = to_ov9734(sd);
698 mutex_lock(&ov9734->mutex);
699 if (ov9734->streaming)
700 ov9734_stop_streaming(ov9734);
702 mutex_unlock(&ov9734->mutex);
711 struct ov9734 *ov9734 = to_ov9734(sd);
714 mutex_lock(&ov9734->mutex);
715 if (!ov9734->streaming)
718 ret = ov9734_start_streaming(ov9734);
720 ov9734->streaming = false;
721 ov9734_stop_streaming(ov9734);
725 mutex_unlock(&ov9734->mutex);
733 struct ov9734 *ov9734 = to_ov9734(sd);
742 mutex_lock(&ov9734->mutex);
747 ov9734->cur_mode = mode;
748 __v4l2_ctrl_s_ctrl(ov9734->link_freq, mode->link_freq_index);
749 __v4l2_ctrl_s_ctrl_int64(ov9734->pixel_rate,
754 __v4l2_ctrl_modify_range(ov9734->vblank,
758 __v4l2_ctrl_s_ctrl(ov9734->vblank, vblank_def);
761 __v4l2_ctrl_modify_range(ov9734->hblank, h_blank, h_blank, 1,
765 mutex_unlock(&ov9734->mutex);
774 struct ov9734 *ov9734 = to_ov9734(sd);
776 mutex_lock(&ov9734->mutex);
778 fmt->format = *v4l2_subdev_get_try_format(&ov9734->sd,
782 ov9734_update_pad_format(ov9734->cur_mode, &fmt->format);
784 mutex_unlock(&ov9734->mutex);
821 struct ov9734 *ov9734 = to_ov9734(sd);
823 mutex_lock(&ov9734->mutex);
826 mutex_unlock(&ov9734->mutex);
855 static int ov9734_identify_module(struct ov9734 *ov9734)
857 struct i2c_client *client = v4l2_get_subdevdata(&ov9734->sd);
861 ret = ov9734_read_reg(ov9734, OV9734_REG_CHIP_ID, 2, &val);
936 struct ov9734 *ov9734 = to_ov9734(sd);
943 mutex_destroy(&ov9734->mutex);
948 struct ov9734 *ov9734;
958 ov9734 = devm_kzalloc(&client->dev, sizeof(*ov9734), GFP_KERNEL);
959 if (!ov9734)
962 v4l2_i2c_subdev_init(&ov9734->sd, client, &ov9734_subdev_ops);
963 ret = ov9734_identify_module(ov9734);
969 mutex_init(&ov9734->mutex);
970 ov9734->cur_mode = &supported_modes[0];
971 ret = ov9734_init_controls(ov9734);
977 ov9734->sd.internal_ops = &ov9734_internal_ops;
978 ov9734->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
979 ov9734->sd.entity.ops = &ov9734_subdev_entity_ops;
980 ov9734->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
981 ov9734->pad.flags = MEDIA_PAD_FL_SOURCE;
982 ret = media_entity_pads_init(&ov9734->sd.entity, 1, &ov9734->pad);
996 ret = v4l2_async_register_subdev_sensor(&ov9734->sd);
1008 media_entity_cleanup(&ov9734->sd.entity);
1011 v4l2_ctrl_handler_free(ov9734->sd.ctrl_handler);
1012 mutex_destroy(&ov9734->mutex);
1030 .name = "ov9734",