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