Lines Matching defs:ov2740

318 struct ov2740 {
340 static inline struct ov2740 *to_ov2740(struct v4l2_subdev *subdev)
342 return container_of(subdev, struct ov2740, sd);
363 static int ov2740_read_reg(struct ov2740 *ov2740, u16 reg, u16 len, u32 *val)
365 struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd);
393 static int ov2740_write_reg(struct ov2740 *ov2740, u16 reg, u16 len, u32 val)
395 struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd);
412 static int ov2740_write_reg_list(struct ov2740 *ov2740,
415 struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd);
420 ret = ov2740_write_reg(ov2740, r_list->regs[i].address, 1,
433 static int ov2740_update_digital_gain(struct ov2740 *ov2740, u32 d_gain)
437 ret = ov2740_write_reg(ov2740, OV2740_REG_MWB_R_GAIN, 2, d_gain);
441 ret = ov2740_write_reg(ov2740, OV2740_REG_MWB_G_GAIN, 2, d_gain);
445 return ov2740_write_reg(ov2740, OV2740_REG_MWB_B_GAIN, 2, d_gain);
448 static int ov2740_test_pattern(struct ov2740 *ov2740, u32 pattern)
454 return ov2740_write_reg(ov2740, OV2740_REG_TEST_PATTERN, 1, pattern);
459 struct ov2740 *ov2740 = container_of(ctrl->handler,
460 struct ov2740, ctrl_handler);
461 struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd);
468 exposure_max = ov2740->cur_mode->height + ctrl->val -
470 __v4l2_ctrl_modify_range(ov2740->exposure,
471 ov2740->exposure->minimum,
472 exposure_max, ov2740->exposure->step,
482 ret = ov2740_write_reg(ov2740, OV2740_REG_ANALOG_GAIN, 2,
487 ret = ov2740_update_digital_gain(ov2740, ctrl->val);
492 ret = ov2740_write_reg(ov2740, OV2740_REG_EXPOSURE, 3,
497 ret = ov2740_write_reg(ov2740, OV2740_REG_VTS, 2,
498 ov2740->cur_mode->height + ctrl->val);
502 ret = ov2740_test_pattern(ov2740, ctrl->val);
519 static int ov2740_init_controls(struct ov2740 *ov2740)
528 ctrl_hdlr = &ov2740->ctrl_handler;
533 ctrl_hdlr->lock = &ov2740->mutex;
534 cur_mode = ov2740->cur_mode;
537 ov2740->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov2740_ctrl_ops,
541 if (ov2740->link_freq)
542 ov2740->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
545 ov2740->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops,
552 ov2740->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops,
558 ov2740->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops,
561 if (ov2740->hblank)
562 ov2740->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
571 ov2740->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops,
585 ov2740->sd.ctrl_handler = ctrl_hdlr;
599 static int ov2740_start_streaming(struct ov2740 *ov2740)
601 struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd);
606 link_freq_index = ov2740->cur_mode->link_freq_index;
608 ret = ov2740_write_reg_list(ov2740, reg_list);
614 reg_list = &ov2740->cur_mode->reg_list;
615 ret = ov2740_write_reg_list(ov2740, reg_list);
621 ret = __v4l2_ctrl_handler_setup(ov2740->sd.ctrl_handler);
625 ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1,
633 static void ov2740_stop_streaming(struct ov2740 *ov2740)
635 struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd);
637 if (ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1,
644 struct ov2740 *ov2740 = to_ov2740(sd);
648 if (ov2740->streaming == enable)
651 mutex_lock(&ov2740->mutex);
656 mutex_unlock(&ov2740->mutex);
660 ret = ov2740_start_streaming(ov2740);
663 ov2740_stop_streaming(ov2740);
667 ov2740_stop_streaming(ov2740);
671 ov2740->streaming = enable;
672 mutex_unlock(&ov2740->mutex);
681 struct ov2740 *ov2740 = to_ov2740(sd);
683 mutex_lock(&ov2740->mutex);
684 if (ov2740->streaming)
685 ov2740_stop_streaming(ov2740);
687 mutex_unlock(&ov2740->mutex);
696 struct ov2740 *ov2740 = to_ov2740(sd);
699 mutex_lock(&ov2740->mutex);
700 if (!ov2740->streaming)
703 ret = ov2740_start_streaming(ov2740);
705 ov2740->streaming = false;
706 ov2740_stop_streaming(ov2740);
710 mutex_unlock(&ov2740->mutex);
718 struct ov2740 *ov2740 = to_ov2740(sd);
727 mutex_lock(&ov2740->mutex);
732 ov2740->cur_mode = mode;
733 __v4l2_ctrl_s_ctrl(ov2740->link_freq, mode->link_freq_index);
734 __v4l2_ctrl_s_ctrl_int64(ov2740->pixel_rate,
739 __v4l2_ctrl_modify_range(ov2740->vblank,
743 __v4l2_ctrl_s_ctrl(ov2740->vblank, vblank_def);
746 __v4l2_ctrl_modify_range(ov2740->hblank, h_blank, h_blank, 1,
749 mutex_unlock(&ov2740->mutex);
758 struct ov2740 *ov2740 = to_ov2740(sd);
760 mutex_lock(&ov2740->mutex);
762 fmt->format = *v4l2_subdev_get_try_format(&ov2740->sd, cfg,
765 ov2740_update_pad_format(ov2740->cur_mode, &fmt->format);
767 mutex_unlock(&ov2740->mutex);
804 struct ov2740 *ov2740 = to_ov2740(sd);
806 mutex_lock(&ov2740->mutex);
809 mutex_unlock(&ov2740->mutex);
838 static int ov2740_identify_module(struct ov2740 *ov2740)
840 struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd);
844 ret = ov2740_read_reg(ov2740, OV2740_REG_CHIP_ID, 3, &val);
926 struct ov2740 *ov2740 = to_ov2740(sd);
932 mutex_destroy(&ov2740->mutex);
939 struct ov2740 *ov2740 = to_ov2740(i2c_get_clientdata(client));
944 ret = ov2740_read_reg(ov2740, OV2740_REG_ISP_CTRL00, 1, &isp_ctrl00);
949 ret = ov2740_read_reg(ov2740, OV2740_REG_ISP_CTRL01, 1, &isp_ctrl01);
956 ret = ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL00, 1,
964 ret = ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL01, 1,
971 ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1,
991 ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1,
993 ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL01, 1, isp_ctrl01);
994 ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL00, 1, isp_ctrl00);
1063 struct ov2740 *ov2740;
1073 ov2740 = devm_kzalloc(&client->dev, sizeof(*ov2740), GFP_KERNEL);
1074 if (!ov2740)
1077 v4l2_i2c_subdev_init(&ov2740->sd, client, &ov2740_subdev_ops);
1078 ret = ov2740_identify_module(ov2740);
1084 mutex_init(&ov2740->mutex);
1085 ov2740->cur_mode = &supported_modes[0];
1086 ret = ov2740_init_controls(ov2740);
1092 ov2740->sd.internal_ops = &ov2740_internal_ops;
1093 ov2740->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1094 ov2740->sd.entity.ops = &ov2740_subdev_entity_ops;
1095 ov2740->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
1096 ov2740->pad.flags = MEDIA_PAD_FL_SOURCE;
1097 ret = media_entity_pads_init(&ov2740->sd.entity, 1, &ov2740->pad);
1103 ret = v4l2_async_register_subdev_sensor_common(&ov2740->sd);
1125 media_entity_cleanup(&ov2740->sd.entity);
1128 v4l2_ctrl_handler_free(ov2740->sd.ctrl_handler);
1129 mutex_destroy(&ov2740->mutex);
1147 .name = "ov2740",