Lines Matching refs:ov13b

660 static int ov13b10_read_reg(struct ov13b10 *ov13b,  in ov13b10_read_reg()  argument
663 struct i2c_client *client = v4l2_get_subdevdata(&ov13b->sd); in ov13b10_read_reg()
696 static int ov13b10_write_reg(struct ov13b10 *ov13b, in ov13b10_write_reg() argument
699 struct i2c_client *client = v4l2_get_subdevdata(&ov13b->sd); in ov13b10_write_reg()
725 static int ov13b10_write_regs(struct ov13b10 *ov13b, in ov13b10_write_regs() argument
728 struct i2c_client *client = v4l2_get_subdevdata(&ov13b->sd); in ov13b10_write_regs()
733 ret = ov13b10_write_reg(ov13b, regs[i].address, 1, in ov13b10_write_regs()
747 static int ov13b10_write_reg_list(struct ov13b10 *ov13b, in ov13b10_write_reg_list() argument
750 return ov13b10_write_regs(ov13b, r_list->regs, r_list->num_of_regs); in ov13b10_write_reg_list()
757 struct ov13b10 *ov13b = to_ov13b10(sd); in ov13b10_open() local
761 mutex_lock(&ov13b->mutex); in ov13b10_open()
770 mutex_unlock(&ov13b->mutex); in ov13b10_open()
775 static int ov13b10_update_digital_gain(struct ov13b10 *ov13b, u32 d_gain) in ov13b10_update_digital_gain() argument
785 ret = ov13b10_write_reg(ov13b, OV13B10_REG_DGTL_GAIN_L, in ov13b10_update_digital_gain()
791 ret = ov13b10_write_reg(ov13b, OV13B10_REG_DGTL_GAIN_M, in ov13b10_update_digital_gain()
797 ret = ov13b10_write_reg(ov13b, OV13B10_REG_DGTL_GAIN_H, in ov13b10_update_digital_gain()
803 static int ov13b10_enable_test_pattern(struct ov13b10 *ov13b, u32 pattern) in ov13b10_enable_test_pattern() argument
808 ret = ov13b10_read_reg(ov13b, OV13B10_REG_TEST_PATTERN, in ov13b10_enable_test_pattern()
821 return ov13b10_write_reg(ov13b, OV13B10_REG_TEST_PATTERN, in ov13b10_enable_test_pattern()
825 static int ov13b10_set_ctrl_hflip(struct ov13b10 *ov13b, u32 ctrl_val) in ov13b10_set_ctrl_hflip() argument
830 ret = ov13b10_read_reg(ov13b, OV13B10_REG_FORMAT1, in ov13b10_set_ctrl_hflip()
835 ret = ov13b10_write_reg(ov13b, OV13B10_REG_FORMAT1, in ov13b10_set_ctrl_hflip()
842 ret = ov13b10_read_reg(ov13b, OV13B10_REG_H_WIN_OFFSET, in ov13b10_set_ctrl_hflip()
851 return ov13b10_write_reg(ov13b, OV13B10_REG_H_WIN_OFFSET, in ov13b10_set_ctrl_hflip()
856 static int ov13b10_set_ctrl_vflip(struct ov13b10 *ov13b, u32 ctrl_val) in ov13b10_set_ctrl_vflip() argument
861 ret = ov13b10_read_reg(ov13b, OV13B10_REG_FORMAT1, in ov13b10_set_ctrl_vflip()
866 ret = ov13b10_write_reg(ov13b, OV13B10_REG_FORMAT1, in ov13b10_set_ctrl_vflip()
873 ret = ov13b10_read_reg(ov13b, OV13B10_REG_V_WIN_OFFSET, in ov13b10_set_ctrl_vflip()
882 return ov13b10_write_reg(ov13b, OV13B10_REG_V_WIN_OFFSET, in ov13b10_set_ctrl_vflip()
889 struct ov13b10 *ov13b = container_of(ctrl->handler, in ov13b10_set_ctrl() local
891 struct i2c_client *client = v4l2_get_subdevdata(&ov13b->sd); in ov13b10_set_ctrl()
899 max = ov13b->cur_mode->height + ctrl->val - 8; in ov13b10_set_ctrl()
900 __v4l2_ctrl_modify_range(ov13b->exposure, in ov13b10_set_ctrl()
901 ov13b->exposure->minimum, in ov13b10_set_ctrl()
902 max, ov13b->exposure->step, max); in ov13b10_set_ctrl()
916 ret = ov13b10_write_reg(ov13b, OV13B10_REG_ANALOG_GAIN, in ov13b10_set_ctrl()
921 ret = ov13b10_update_digital_gain(ov13b, ctrl->val); in ov13b10_set_ctrl()
924 ret = ov13b10_write_reg(ov13b, OV13B10_REG_EXPOSURE, in ov13b10_set_ctrl()
929 ret = ov13b10_write_reg(ov13b, OV13B10_REG_VTS, in ov13b10_set_ctrl()
931 ov13b->cur_mode->height in ov13b10_set_ctrl()
935 ret = ov13b10_enable_test_pattern(ov13b, ctrl->val); in ov13b10_set_ctrl()
938 ov13b10_set_ctrl_hflip(ov13b, ctrl->val); in ov13b10_set_ctrl()
941 ov13b10_set_ctrl_vflip(ov13b, ctrl->val); in ov13b10_set_ctrl()
999 static int ov13b10_do_get_pad_format(struct ov13b10 *ov13b, in ov13b10_do_get_pad_format() argument
1009 ov13b10_update_pad_format(ov13b->cur_mode, fmt); in ov13b10_do_get_pad_format()
1019 struct ov13b10 *ov13b = to_ov13b10(sd); in ov13b10_get_pad_format() local
1022 mutex_lock(&ov13b->mutex); in ov13b10_get_pad_format()
1023 ret = ov13b10_do_get_pad_format(ov13b, sd_state, fmt); in ov13b10_get_pad_format()
1024 mutex_unlock(&ov13b->mutex); in ov13b10_get_pad_format()
1034 struct ov13b10 *ov13b = to_ov13b10(sd); in ov13b10_set_pad_format() local
1043 mutex_lock(&ov13b->mutex); in ov13b10_set_pad_format()
1058 ov13b->cur_mode = mode; in ov13b10_set_pad_format()
1059 __v4l2_ctrl_s_ctrl(ov13b->link_freq, mode->link_freq_index); in ov13b10_set_pad_format()
1062 __v4l2_ctrl_s_ctrl_int64(ov13b->pixel_rate, pixel_rate); in ov13b10_set_pad_format()
1065 vblank_def = ov13b->cur_mode->vts_def - in ov13b10_set_pad_format()
1066 ov13b->cur_mode->height; in ov13b10_set_pad_format()
1067 vblank_min = ov13b->cur_mode->vts_min - in ov13b10_set_pad_format()
1068 ov13b->cur_mode->height; in ov13b10_set_pad_format()
1069 __v4l2_ctrl_modify_range(ov13b->vblank, vblank_min, in ov13b10_set_pad_format()
1071 - ov13b->cur_mode->height, in ov13b10_set_pad_format()
1074 __v4l2_ctrl_s_ctrl(ov13b->vblank, vblank_def); in ov13b10_set_pad_format()
1077 - ov13b->cur_mode->width; in ov13b10_set_pad_format()
1078 __v4l2_ctrl_modify_range(ov13b->hblank, h_blank, in ov13b10_set_pad_format()
1082 mutex_unlock(&ov13b->mutex); in ov13b10_set_pad_format()
1088 static int ov13b10_identify_module(struct ov13b10 *ov13b) in ov13b10_identify_module() argument
1090 struct i2c_client *client = v4l2_get_subdevdata(&ov13b->sd); in ov13b10_identify_module()
1094 if (ov13b->identified) in ov13b10_identify_module()
1097 ret = ov13b10_read_reg(ov13b, OV13B10_REG_CHIP_ID, in ov13b10_identify_module()
1108 ov13b->identified = true; in ov13b10_identify_module()
1156 static int ov13b10_start_streaming(struct ov13b10 *ov13b) in ov13b10_start_streaming() argument
1158 struct i2c_client *client = v4l2_get_subdevdata(&ov13b->sd); in ov13b10_start_streaming()
1162 ret = ov13b10_identify_module(ov13b); in ov13b10_start_streaming()
1167 ret = ov13b10_write_reg(ov13b, OV13B10_REG_SOFTWARE_RST, in ov13b10_start_streaming()
1175 link_freq_index = ov13b->cur_mode->link_freq_index; in ov13b10_start_streaming()
1177 ret = ov13b10_write_reg_list(ov13b, reg_list); in ov13b10_start_streaming()
1184 reg_list = &ov13b->cur_mode->reg_list; in ov13b10_start_streaming()
1185 ret = ov13b10_write_reg_list(ov13b, reg_list); in ov13b10_start_streaming()
1192 ret = __v4l2_ctrl_handler_setup(ov13b->sd.ctrl_handler); in ov13b10_start_streaming()
1196 return ov13b10_write_reg(ov13b, OV13B10_REG_MODE_SELECT, in ov13b10_start_streaming()
1202 static int ov13b10_stop_streaming(struct ov13b10 *ov13b) in ov13b10_stop_streaming() argument
1204 return ov13b10_write_reg(ov13b, OV13B10_REG_MODE_SELECT, in ov13b10_stop_streaming()
1210 struct ov13b10 *ov13b = to_ov13b10(sd); in ov13b10_set_stream() local
1214 mutex_lock(&ov13b->mutex); in ov13b10_set_stream()
1225 ret = ov13b10_start_streaming(ov13b); in ov13b10_set_stream()
1229 ov13b10_stop_streaming(ov13b); in ov13b10_set_stream()
1233 mutex_unlock(&ov13b->mutex); in ov13b10_set_stream()
1240 mutex_unlock(&ov13b->mutex); in ov13b10_set_stream()
1282 static int ov13b10_init_controls(struct ov13b10 *ov13b) in ov13b10_init_controls() argument
1284 struct i2c_client *client = v4l2_get_subdevdata(&ov13b->sd); in ov13b10_init_controls()
1297 ctrl_hdlr = &ov13b->ctrl_handler; in ov13b10_init_controls()
1302 mutex_init(&ov13b->mutex); in ov13b10_init_controls()
1303 ctrl_hdlr->lock = &ov13b->mutex; in ov13b10_init_controls()
1305 ov13b->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, in ov13b10_init_controls()
1311 if (ov13b->link_freq) in ov13b10_init_controls()
1312 ov13b->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov13b10_init_controls()
1317 ov13b->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov13b10_ctrl_ops, in ov13b10_init_controls()
1322 mode = ov13b->cur_mode; in ov13b10_init_controls()
1325 ov13b->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov13b10_ctrl_ops, in ov13b10_init_controls()
1333 ov13b->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov13b10_ctrl_ops, in ov13b10_init_controls()
1336 if (ov13b->hblank) in ov13b10_init_controls()
1337 ov13b->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov13b10_init_controls()
1340 ov13b->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov13b10_ctrl_ops, in ov13b10_init_controls()
1381 ov13b->sd.ctrl_handler = ctrl_hdlr; in ov13b10_init_controls()
1387 mutex_destroy(&ov13b->mutex); in ov13b10_init_controls()
1392 static void ov13b10_free_controls(struct ov13b10 *ov13b) in ov13b10_free_controls() argument
1394 v4l2_ctrl_handler_free(ov13b->sd.ctrl_handler); in ov13b10_free_controls()
1395 mutex_destroy(&ov13b->mutex); in ov13b10_free_controls()
1401 struct ov13b10 *ov13b = to_ov13b10(sd); in ov13b10_get_pm_resources() local
1404 ov13b->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in ov13b10_get_pm_resources()
1405 if (IS_ERR(ov13b->reset)) in ov13b10_get_pm_resources()
1406 return dev_err_probe(dev, PTR_ERR(ov13b->reset), in ov13b10_get_pm_resources()
1409 ov13b->img_clk = devm_clk_get_optional(dev, NULL); in ov13b10_get_pm_resources()
1410 if (IS_ERR(ov13b->img_clk)) in ov13b10_get_pm_resources()
1411 return dev_err_probe(dev, PTR_ERR(ov13b->img_clk), in ov13b10_get_pm_resources()
1414 ov13b->avdd = devm_regulator_get_optional(dev, "avdd"); in ov13b10_get_pm_resources()
1415 if (IS_ERR(ov13b->avdd)) { in ov13b10_get_pm_resources()
1416 ret = PTR_ERR(ov13b->avdd); in ov13b10_get_pm_resources()
1417 ov13b->avdd = NULL; in ov13b10_get_pm_resources()
1498 struct ov13b10 *ov13b; in ov13b10_probe() local
1509 ov13b = devm_kzalloc(&client->dev, sizeof(*ov13b), GFP_KERNEL); in ov13b10_probe()
1510 if (!ov13b) in ov13b10_probe()
1514 v4l2_i2c_subdev_init(&ov13b->sd, client, &ov13b10_subdev_ops); in ov13b10_probe()
1529 ret = ov13b10_identify_module(ov13b); in ov13b10_probe()
1537 ov13b->cur_mode = &supported_modes[0]; in ov13b10_probe()
1539 ret = ov13b10_init_controls(ov13b); in ov13b10_probe()
1544 ov13b->sd.internal_ops = &ov13b10_internal_ops; in ov13b10_probe()
1545 ov13b->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in ov13b10_probe()
1546 ov13b->sd.entity.ops = &ov13b10_subdev_entity_ops; in ov13b10_probe()
1547 ov13b->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in ov13b10_probe()
1550 ov13b->pad.flags = MEDIA_PAD_FL_SOURCE; in ov13b10_probe()
1551 ret = media_entity_pads_init(&ov13b->sd.entity, 1, &ov13b->pad); in ov13b10_probe()
1568 ret = v4l2_async_register_subdev_sensor(&ov13b->sd); in ov13b10_probe()
1578 media_entity_cleanup(&ov13b->sd.entity); in ov13b10_probe()
1581 ov13b10_free_controls(ov13b); in ov13b10_probe()
1593 struct ov13b10 *ov13b = to_ov13b10(sd); in ov13b10_remove() local
1597 ov13b10_free_controls(ov13b); in ov13b10_remove()