Lines Matching refs:ov5675
70 #define to_ov5675(_sd) container_of(_sd, struct ov5675, sd)
476 struct ov5675 { struct
516 static int ov5675_read_reg(struct ov5675 *ov5675, u16 reg, u16 len, u32 *val) in ov5675_read_reg() argument
518 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd); in ov5675_read_reg()
546 static int ov5675_write_reg(struct ov5675 *ov5675, u16 reg, u16 len, u32 val) in ov5675_write_reg() argument
548 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd); in ov5675_write_reg()
562 static int ov5675_write_reg_list(struct ov5675 *ov5675, in ov5675_write_reg_list() argument
565 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd); in ov5675_write_reg_list()
570 ret = ov5675_write_reg(ov5675, r_list->regs[i].address, 1, in ov5675_write_reg_list()
583 static int ov5675_update_digital_gain(struct ov5675 *ov5675, u32 d_gain) in ov5675_update_digital_gain() argument
587 ret = ov5675_write_reg(ov5675, OV5675_REG_MWB_R_GAIN, in ov5675_update_digital_gain()
592 ret = ov5675_write_reg(ov5675, OV5675_REG_MWB_G_GAIN, in ov5675_update_digital_gain()
597 return ov5675_write_reg(ov5675, OV5675_REG_MWB_B_GAIN, in ov5675_update_digital_gain()
601 static int ov5675_test_pattern(struct ov5675 *ov5675, u32 pattern) in ov5675_test_pattern() argument
607 return ov5675_write_reg(ov5675, OV5675_REG_TEST_PATTERN, in ov5675_test_pattern()
615 static int ov5675_set_ctrl_hflip(struct ov5675 *ov5675, u32 ctrl_val) in ov5675_set_ctrl_hflip() argument
620 ret = ov5675_read_reg(ov5675, OV5675_REG_FORMAT1, in ov5675_set_ctrl_hflip()
625 return ov5675_write_reg(ov5675, OV5675_REG_FORMAT1, in ov5675_set_ctrl_hflip()
630 static int ov5675_set_ctrl_vflip(struct ov5675 *ov5675, u8 ctrl_val) in ov5675_set_ctrl_vflip() argument
635 ret = ov5675_read_reg(ov5675, OV5675_REG_FORMAT1, in ov5675_set_ctrl_vflip()
640 ret = ov5675_write_reg(ov5675, OV5675_REG_FORMAT1, in ov5675_set_ctrl_vflip()
647 ret = ov5675_read_reg(ov5675, OV5675_REG_FORMAT2, in ov5675_set_ctrl_vflip()
653 return ov5675_write_reg(ov5675, OV5675_REG_FORMAT2, in ov5675_set_ctrl_vflip()
660 struct ov5675 *ov5675 = container_of(ctrl->handler, in ov5675_set_ctrl() local
661 struct ov5675, ctrl_handler); in ov5675_set_ctrl()
662 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd); in ov5675_set_ctrl()
669 exposure_max = ov5675->cur_mode->height + ctrl->val - in ov5675_set_ctrl()
671 __v4l2_ctrl_modify_range(ov5675->exposure, in ov5675_set_ctrl()
672 ov5675->exposure->minimum, in ov5675_set_ctrl()
673 exposure_max, ov5675->exposure->step, in ov5675_set_ctrl()
683 ret = ov5675_write_reg(ov5675, OV5675_REG_ANALOG_GAIN, in ov5675_set_ctrl()
688 ret = ov5675_update_digital_gain(ov5675, ctrl->val); in ov5675_set_ctrl()
699 ret = ov5675_write_reg(ov5675, OV5675_REG_EXPOSURE, in ov5675_set_ctrl()
704 ret = ov5675_write_reg(ov5675, OV5675_REG_VTS, in ov5675_set_ctrl()
706 ov5675->cur_mode->height + ctrl->val + in ov5675_set_ctrl()
711 ret = ov5675_test_pattern(ov5675, ctrl->val); in ov5675_set_ctrl()
715 ov5675_set_ctrl_hflip(ov5675, ctrl->val); in ov5675_set_ctrl()
719 ov5675_set_ctrl_vflip(ov5675, ctrl->val); in ov5675_set_ctrl()
736 static int ov5675_init_controls(struct ov5675 *ov5675) in ov5675_init_controls() argument
742 ctrl_hdlr = &ov5675->ctrl_handler; in ov5675_init_controls()
747 ctrl_hdlr->lock = &ov5675->mutex; in ov5675_init_controls()
748 ov5675->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov5675_ctrl_ops, in ov5675_init_controls()
752 if (ov5675->link_freq) in ov5675_init_controls()
753 ov5675->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov5675_init_controls()
755 ov5675->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov5675_ctrl_ops, in ov5675_init_controls()
760 ov5675->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov5675_ctrl_ops, in ov5675_init_controls()
762 ov5675->cur_mode->vts_min - ov5675->cur_mode->height, in ov5675_init_controls()
763 OV5675_VTS_MAX - ov5675->cur_mode->height, 1, in ov5675_init_controls()
764 ov5675->cur_mode->vts_def - ov5675->cur_mode->height); in ov5675_init_controls()
765 h_blank = to_pixels_per_line(ov5675->cur_mode->hts, in ov5675_init_controls()
766 ov5675->cur_mode->link_freq_index) - ov5675->cur_mode->width; in ov5675_init_controls()
767 ov5675->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov5675_ctrl_ops, in ov5675_init_controls()
770 if (ov5675->hblank) in ov5675_init_controls()
771 ov5675->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov5675_init_controls()
779 exposure_max = (ov5675->cur_mode->vts_def - OV5675_EXPOSURE_MAX_MARGIN); in ov5675_init_controls()
780 ov5675->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov5675_ctrl_ops, in ov5675_init_controls()
797 ov5675->sd.ctrl_handler = ctrl_hdlr; in ov5675_init_controls()
811 static int ov5675_start_streaming(struct ov5675 *ov5675) in ov5675_start_streaming() argument
813 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd); in ov5675_start_streaming()
817 link_freq_index = ov5675->cur_mode->link_freq_index; in ov5675_start_streaming()
819 ret = ov5675_write_reg_list(ov5675, reg_list); in ov5675_start_streaming()
825 reg_list = &ov5675->cur_mode->reg_list; in ov5675_start_streaming()
826 ret = ov5675_write_reg_list(ov5675, reg_list); in ov5675_start_streaming()
832 ret = __v4l2_ctrl_handler_setup(ov5675->sd.ctrl_handler); in ov5675_start_streaming()
836 ret = ov5675_write_reg(ov5675, OV5675_REG_MODE_SELECT, in ov5675_start_streaming()
846 static void ov5675_stop_streaming(struct ov5675 *ov5675) in ov5675_stop_streaming() argument
848 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd); in ov5675_stop_streaming()
850 if (ov5675_write_reg(ov5675, OV5675_REG_MODE_SELECT, in ov5675_stop_streaming()
857 struct ov5675 *ov5675 = to_ov5675(sd); in ov5675_set_stream() local
861 if (ov5675->streaming == enable) in ov5675_set_stream()
864 mutex_lock(&ov5675->mutex); in ov5675_set_stream()
869 mutex_unlock(&ov5675->mutex); in ov5675_set_stream()
873 ret = ov5675_start_streaming(ov5675); in ov5675_set_stream()
876 ov5675_stop_streaming(ov5675); in ov5675_set_stream()
880 ov5675_stop_streaming(ov5675); in ov5675_set_stream()
884 ov5675->streaming = enable; in ov5675_set_stream()
885 mutex_unlock(&ov5675->mutex); in ov5675_set_stream()
894 struct ov5675 *ov5675 = to_ov5675(sd); in ov5675_suspend() local
896 mutex_lock(&ov5675->mutex); in ov5675_suspend()
897 if (ov5675->streaming) in ov5675_suspend()
898 ov5675_stop_streaming(ov5675); in ov5675_suspend()
900 mutex_unlock(&ov5675->mutex); in ov5675_suspend()
909 struct ov5675 *ov5675 = to_ov5675(sd); in ov5675_resume() local
912 mutex_lock(&ov5675->mutex); in ov5675_resume()
913 if (ov5675->streaming) { in ov5675_resume()
914 ret = ov5675_start_streaming(ov5675); in ov5675_resume()
916 ov5675->streaming = false; in ov5675_resume()
917 ov5675_stop_streaming(ov5675); in ov5675_resume()
918 mutex_unlock(&ov5675->mutex); in ov5675_resume()
923 mutex_unlock(&ov5675->mutex); in ov5675_resume()
932 struct ov5675 *ov5675 = to_ov5675(sd); in ov5675_set_format() local
941 mutex_lock(&ov5675->mutex); in ov5675_set_format()
946 ov5675->cur_mode = mode; in ov5675_set_format()
947 __v4l2_ctrl_s_ctrl(ov5675->link_freq, mode->link_freq_index); in ov5675_set_format()
948 __v4l2_ctrl_s_ctrl_int64(ov5675->pixel_rate, in ov5675_set_format()
953 __v4l2_ctrl_modify_range(ov5675->vblank, in ov5675_set_format()
957 __v4l2_ctrl_s_ctrl(ov5675->vblank, vblank_def); in ov5675_set_format()
960 __v4l2_ctrl_modify_range(ov5675->hblank, h_blank, h_blank, 1, in ov5675_set_format()
964 mutex_unlock(&ov5675->mutex); in ov5675_set_format()
973 struct ov5675 *ov5675 = to_ov5675(sd); in ov5675_get_format() local
975 mutex_lock(&ov5675->mutex); in ov5675_get_format()
977 fmt->format = *v4l2_subdev_get_try_format(&ov5675->sd, cfg, in ov5675_get_format()
980 ov5675_update_pad_format(ov5675->cur_mode, &fmt->format); in ov5675_get_format()
982 mutex_unlock(&ov5675->mutex); in ov5675_get_format()
1019 struct ov5675 *ov5675 = to_ov5675(sd); in ov5675_open() local
1021 mutex_lock(&ov5675->mutex); in ov5675_open()
1024 mutex_unlock(&ov5675->mutex); in ov5675_open()
1053 static int ov5675_identify_module(struct ov5675 *ov5675) in ov5675_identify_module() argument
1055 struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd); in ov5675_identify_module()
1059 ret = ov5675_read_reg(ov5675, OV5675_REG_CHIP_ID, in ov5675_identify_module()
1145 struct ov5675 *ov5675 = to_ov5675(sd); in ov5675_remove() local
1151 mutex_destroy(&ov5675->mutex); in ov5675_remove()
1158 struct ov5675 *ov5675; in ov5675_probe() local
1168 ov5675 = devm_kzalloc(&client->dev, sizeof(*ov5675), GFP_KERNEL); in ov5675_probe()
1169 if (!ov5675) in ov5675_probe()
1172 v4l2_i2c_subdev_init(&ov5675->sd, client, &ov5675_subdev_ops); in ov5675_probe()
1173 ret = ov5675_identify_module(ov5675); in ov5675_probe()
1179 mutex_init(&ov5675->mutex); in ov5675_probe()
1180 ov5675->cur_mode = &supported_modes[0]; in ov5675_probe()
1181 ret = ov5675_init_controls(ov5675); in ov5675_probe()
1187 ov5675->sd.internal_ops = &ov5675_internal_ops; in ov5675_probe()
1188 ov5675->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in ov5675_probe()
1189 ov5675->sd.entity.ops = &ov5675_subdev_entity_ops; in ov5675_probe()
1190 ov5675->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in ov5675_probe()
1191 ov5675->pad.flags = MEDIA_PAD_FL_SOURCE; in ov5675_probe()
1192 ret = media_entity_pads_init(&ov5675->sd.entity, 1, &ov5675->pad); in ov5675_probe()
1198 ret = v4l2_async_register_subdev_sensor_common(&ov5675->sd); in ov5675_probe()
1216 media_entity_cleanup(&ov5675->sd.entity); in ov5675_probe()
1219 v4l2_ctrl_handler_free(ov5675->sd.ctrl_handler); in ov5675_probe()
1220 mutex_destroy(&ov5675->mutex); in ov5675_probe()