Lines Matching defs:ov5675

70 #define to_ov5675(_sd)			container_of(_sd, struct ov5675, sd)
476 struct ov5675 {
516 static int ov5675_read_reg(struct ov5675 *ov5675, u16 reg, u16 len, u32 *val)
518 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd);
546 static int ov5675_write_reg(struct ov5675 *ov5675, u16 reg, u16 len, u32 val)
548 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd);
562 static int ov5675_write_reg_list(struct ov5675 *ov5675,
565 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd);
570 ret = ov5675_write_reg(ov5675, r_list->regs[i].address, 1,
583 static int ov5675_update_digital_gain(struct ov5675 *ov5675, u32 d_gain)
587 ret = ov5675_write_reg(ov5675, OV5675_REG_MWB_R_GAIN,
592 ret = ov5675_write_reg(ov5675, OV5675_REG_MWB_G_GAIN,
597 return ov5675_write_reg(ov5675, OV5675_REG_MWB_B_GAIN,
601 static int ov5675_test_pattern(struct ov5675 *ov5675, u32 pattern)
607 return ov5675_write_reg(ov5675, OV5675_REG_TEST_PATTERN,
615 static int ov5675_set_ctrl_hflip(struct ov5675 *ov5675, u32 ctrl_val)
620 ret = ov5675_read_reg(ov5675, OV5675_REG_FORMAT1,
625 return ov5675_write_reg(ov5675, OV5675_REG_FORMAT1,
630 static int ov5675_set_ctrl_vflip(struct ov5675 *ov5675, u8 ctrl_val)
635 ret = ov5675_read_reg(ov5675, OV5675_REG_FORMAT1,
640 ret = ov5675_write_reg(ov5675, OV5675_REG_FORMAT1,
647 ret = ov5675_read_reg(ov5675, OV5675_REG_FORMAT2,
653 return ov5675_write_reg(ov5675, OV5675_REG_FORMAT2,
660 struct ov5675 *ov5675 = container_of(ctrl->handler,
661 struct ov5675, ctrl_handler);
662 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd);
669 exposure_max = ov5675->cur_mode->height + ctrl->val -
671 __v4l2_ctrl_modify_range(ov5675->exposure,
672 ov5675->exposure->minimum,
673 exposure_max, ov5675->exposure->step,
683 ret = ov5675_write_reg(ov5675, OV5675_REG_ANALOG_GAIN,
688 ret = ov5675_update_digital_gain(ov5675, ctrl->val);
694 * for ov5675, the unit of exposure is differnt from other
699 ret = ov5675_write_reg(ov5675, OV5675_REG_EXPOSURE,
704 ret = ov5675_write_reg(ov5675, OV5675_REG_VTS,
706 ov5675->cur_mode->height + ctrl->val +
711 ret = ov5675_test_pattern(ov5675, ctrl->val);
715 ov5675_set_ctrl_hflip(ov5675, ctrl->val);
719 ov5675_set_ctrl_vflip(ov5675, ctrl->val);
736 static int ov5675_init_controls(struct ov5675 *ov5675)
742 ctrl_hdlr = &ov5675->ctrl_handler;
747 ctrl_hdlr->lock = &ov5675->mutex;
748 ov5675->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov5675_ctrl_ops,
752 if (ov5675->link_freq)
753 ov5675->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
755 ov5675->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov5675_ctrl_ops,
760 ov5675->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov5675_ctrl_ops,
762 ov5675->cur_mode->vts_min - ov5675->cur_mode->height,
763 OV5675_VTS_MAX - ov5675->cur_mode->height, 1,
764 ov5675->cur_mode->vts_def - ov5675->cur_mode->height);
765 h_blank = to_pixels_per_line(ov5675->cur_mode->hts,
766 ov5675->cur_mode->link_freq_index) - ov5675->cur_mode->width;
767 ov5675->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov5675_ctrl_ops,
770 if (ov5675->hblank)
771 ov5675->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
779 exposure_max = (ov5675->cur_mode->vts_def - OV5675_EXPOSURE_MAX_MARGIN);
780 ov5675->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov5675_ctrl_ops,
799 ov5675->sd.ctrl_handler = ctrl_hdlr;
813 static int ov5675_start_streaming(struct ov5675 *ov5675)
815 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd);
819 link_freq_index = ov5675->cur_mode->link_freq_index;
821 ret = ov5675_write_reg_list(ov5675, reg_list);
827 reg_list = &ov5675->cur_mode->reg_list;
828 ret = ov5675_write_reg_list(ov5675, reg_list);
834 ret = __v4l2_ctrl_handler_setup(ov5675->sd.ctrl_handler);
838 ret = ov5675_write_reg(ov5675, OV5675_REG_MODE_SELECT,
848 static void ov5675_stop_streaming(struct ov5675 *ov5675)
850 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd);
852 if (ov5675_write_reg(ov5675, OV5675_REG_MODE_SELECT,
859 struct ov5675 *ov5675 = to_ov5675(sd);
863 if (ov5675->streaming == enable)
866 mutex_lock(&ov5675->mutex);
871 mutex_unlock(&ov5675->mutex);
875 ret = ov5675_start_streaming(ov5675);
878 ov5675_stop_streaming(ov5675);
882 ov5675_stop_streaming(ov5675);
886 ov5675->streaming = enable;
887 mutex_unlock(&ov5675->mutex);
896 struct ov5675 *ov5675 = to_ov5675(sd);
898 mutex_lock(&ov5675->mutex);
899 if (ov5675->streaming)
900 ov5675_stop_streaming(ov5675);
902 mutex_unlock(&ov5675->mutex);
911 struct ov5675 *ov5675 = to_ov5675(sd);
914 mutex_lock(&ov5675->mutex);
915 if (ov5675->streaming) {
916 ret = ov5675_start_streaming(ov5675);
918 ov5675->streaming = false;
919 ov5675_stop_streaming(ov5675);
920 mutex_unlock(&ov5675->mutex);
925 mutex_unlock(&ov5675->mutex);
934 struct ov5675 *ov5675 = to_ov5675(sd);
943 mutex_lock(&ov5675->mutex);
948 ov5675->cur_mode = mode;
949 __v4l2_ctrl_s_ctrl(ov5675->link_freq, mode->link_freq_index);
950 __v4l2_ctrl_s_ctrl_int64(ov5675->pixel_rate,
955 __v4l2_ctrl_modify_range(ov5675->vblank,
959 __v4l2_ctrl_s_ctrl(ov5675->vblank, vblank_def);
962 __v4l2_ctrl_modify_range(ov5675->hblank, h_blank, h_blank, 1,
966 mutex_unlock(&ov5675->mutex);
975 struct ov5675 *ov5675 = to_ov5675(sd);
977 mutex_lock(&ov5675->mutex);
979 fmt->format = *v4l2_subdev_get_try_format(&ov5675->sd, cfg,
982 ov5675_update_pad_format(ov5675->cur_mode, &fmt->format);
984 mutex_unlock(&ov5675->mutex);
1021 struct ov5675 *ov5675 = to_ov5675(sd);
1023 mutex_lock(&ov5675->mutex);
1026 mutex_unlock(&ov5675->mutex);
1055 static int ov5675_identify_module(struct ov5675 *ov5675)
1057 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd);
1061 ret = ov5675_read_reg(ov5675, OV5675_REG_CHIP_ID,
1147 struct ov5675 *ov5675 = to_ov5675(sd);
1153 mutex_destroy(&ov5675->mutex);
1160 struct ov5675 *ov5675;
1170 ov5675 = devm_kzalloc(&client->dev, sizeof(*ov5675), GFP_KERNEL);
1171 if (!ov5675)
1174 v4l2_i2c_subdev_init(&ov5675->sd, client, &ov5675_subdev_ops);
1175 ret = ov5675_identify_module(ov5675);
1181 mutex_init(&ov5675->mutex);
1182 ov5675->cur_mode = &supported_modes[0];
1183 ret = ov5675_init_controls(ov5675);
1189 ov5675->sd.internal_ops = &ov5675_internal_ops;
1190 ov5675->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1191 ov5675->sd.entity.ops = &ov5675_subdev_entity_ops;
1192 ov5675->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
1193 ov5675->pad.flags = MEDIA_PAD_FL_SOURCE;
1194 ret = media_entity_pads_init(&ov5675->sd.entity, 1, &ov5675->pad);
1200 ret = v4l2_async_register_subdev_sensor_common(&ov5675->sd);
1218 media_entity_cleanup(&ov5675->sd.entity);
1221 v4l2_ctrl_handler_free(ov5675->sd.ctrl_handler);
1222 mutex_destroy(&ov5675->mutex);
1242 .name = "ov5675",