Lines Matching refs:og01a1b

73 #define to_og01a1b(_sd)			container_of(_sd, struct og01a1b, sd)
423 struct og01a1b { struct
466 static int og01a1b_read_reg(struct og01a1b *og01a1b, u16 reg, u16 len, u32 *val) in og01a1b_read_reg() argument
468 struct i2c_client *client = v4l2_get_subdevdata(&og01a1b->sd); in og01a1b_read_reg()
496 static int og01a1b_write_reg(struct og01a1b *og01a1b, u16 reg, u16 len, u32 val) in og01a1b_write_reg() argument
498 struct i2c_client *client = v4l2_get_subdevdata(&og01a1b->sd); in og01a1b_write_reg()
512 static int og01a1b_write_reg_list(struct og01a1b *og01a1b, in og01a1b_write_reg_list() argument
515 struct i2c_client *client = v4l2_get_subdevdata(&og01a1b->sd); in og01a1b_write_reg_list()
520 ret = og01a1b_write_reg(og01a1b, r_list->regs[i].address, 1, in og01a1b_write_reg_list()
533 static int og01a1b_test_pattern(struct og01a1b *og01a1b, u32 pattern) in og01a1b_test_pattern() argument
539 return og01a1b_write_reg(og01a1b, OG01A1B_REG_TEST_PATTERN, in og01a1b_test_pattern()
545 struct og01a1b *og01a1b = container_of(ctrl->handler, in og01a1b_set_ctrl() local
546 struct og01a1b, ctrl_handler); in og01a1b_set_ctrl()
547 struct i2c_client *client = v4l2_get_subdevdata(&og01a1b->sd); in og01a1b_set_ctrl()
554 exposure_max = og01a1b->cur_mode->height + ctrl->val - in og01a1b_set_ctrl()
556 __v4l2_ctrl_modify_range(og01a1b->exposure, in og01a1b_set_ctrl()
557 og01a1b->exposure->minimum, in og01a1b_set_ctrl()
558 exposure_max, og01a1b->exposure->step, in og01a1b_set_ctrl()
568 ret = og01a1b_write_reg(og01a1b, OG01A1B_REG_ANALOG_GAIN, in og01a1b_set_ctrl()
574 ret = og01a1b_write_reg(og01a1b, OG01A1B_REG_DIG_GAIN, in og01a1b_set_ctrl()
580 ret = og01a1b_write_reg(og01a1b, OG01A1B_REG_EXPOSURE, in og01a1b_set_ctrl()
585 ret = og01a1b_write_reg(og01a1b, OG01A1B_REG_VTS, in og01a1b_set_ctrl()
587 og01a1b->cur_mode->height + ctrl->val); in og01a1b_set_ctrl()
591 ret = og01a1b_test_pattern(og01a1b, ctrl->val); in og01a1b_set_ctrl()
608 static int og01a1b_init_controls(struct og01a1b *og01a1b) in og01a1b_init_controls() argument
614 ctrl_hdlr = &og01a1b->ctrl_handler; in og01a1b_init_controls()
619 ctrl_hdlr->lock = &og01a1b->mutex; in og01a1b_init_controls()
620 og01a1b->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, in og01a1b_init_controls()
626 if (og01a1b->link_freq) in og01a1b_init_controls()
627 og01a1b->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; in og01a1b_init_controls()
629 og01a1b->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &og01a1b_ctrl_ops, in og01a1b_init_controls()
636 og01a1b->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &og01a1b_ctrl_ops, in og01a1b_init_controls()
638 og01a1b->cur_mode->vts_min - in og01a1b_init_controls()
639 og01a1b->cur_mode->height, in og01a1b_init_controls()
641 og01a1b->cur_mode->height, 1, in og01a1b_init_controls()
642 og01a1b->cur_mode->vts_def - in og01a1b_init_controls()
643 og01a1b->cur_mode->height); in og01a1b_init_controls()
644 h_blank = to_pixels_per_line(og01a1b->cur_mode->hts, in og01a1b_init_controls()
645 og01a1b->cur_mode->link_freq_index) - in og01a1b_init_controls()
646 og01a1b->cur_mode->width; in og01a1b_init_controls()
647 og01a1b->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &og01a1b_ctrl_ops, in og01a1b_init_controls()
650 if (og01a1b->hblank) in og01a1b_init_controls()
651 og01a1b->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in og01a1b_init_controls()
659 exposure_max = (og01a1b->cur_mode->vts_def - in og01a1b_init_controls()
661 og01a1b->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &og01a1b_ctrl_ops, in og01a1b_init_controls()
675 og01a1b->sd.ctrl_handler = ctrl_hdlr; in og01a1b_init_controls()
689 static int og01a1b_start_streaming(struct og01a1b *og01a1b) in og01a1b_start_streaming() argument
691 struct i2c_client *client = v4l2_get_subdevdata(&og01a1b->sd); in og01a1b_start_streaming()
695 link_freq_index = og01a1b->cur_mode->link_freq_index; in og01a1b_start_streaming()
698 ret = og01a1b_write_reg_list(og01a1b, reg_list); in og01a1b_start_streaming()
704 reg_list = &og01a1b->cur_mode->reg_list; in og01a1b_start_streaming()
705 ret = og01a1b_write_reg_list(og01a1b, reg_list); in og01a1b_start_streaming()
711 ret = __v4l2_ctrl_handler_setup(og01a1b->sd.ctrl_handler); in og01a1b_start_streaming()
715 ret = og01a1b_write_reg(og01a1b, OG01A1B_REG_MODE_SELECT, in og01a1b_start_streaming()
726 static void og01a1b_stop_streaming(struct og01a1b *og01a1b) in og01a1b_stop_streaming() argument
728 struct i2c_client *client = v4l2_get_subdevdata(&og01a1b->sd); in og01a1b_stop_streaming()
730 if (og01a1b_write_reg(og01a1b, OG01A1B_REG_MODE_SELECT, in og01a1b_stop_streaming()
737 struct og01a1b *og01a1b = to_og01a1b(sd); in og01a1b_set_stream() local
741 mutex_lock(&og01a1b->mutex); in og01a1b_set_stream()
745 mutex_unlock(&og01a1b->mutex); in og01a1b_set_stream()
749 ret = og01a1b_start_streaming(og01a1b); in og01a1b_set_stream()
752 og01a1b_stop_streaming(og01a1b); in og01a1b_set_stream()
756 og01a1b_stop_streaming(og01a1b); in og01a1b_set_stream()
760 mutex_unlock(&og01a1b->mutex); in og01a1b_set_stream()
769 struct og01a1b *og01a1b = to_og01a1b(sd); in og01a1b_set_format() local
778 mutex_lock(&og01a1b->mutex); in og01a1b_set_format()
783 og01a1b->cur_mode = mode; in og01a1b_set_format()
784 __v4l2_ctrl_s_ctrl(og01a1b->link_freq, mode->link_freq_index); in og01a1b_set_format()
785 __v4l2_ctrl_s_ctrl_int64(og01a1b->pixel_rate, in og01a1b_set_format()
790 __v4l2_ctrl_modify_range(og01a1b->vblank, in og01a1b_set_format()
794 __v4l2_ctrl_s_ctrl(og01a1b->vblank, vblank_def); in og01a1b_set_format()
797 __v4l2_ctrl_modify_range(og01a1b->hblank, h_blank, h_blank, 1, in og01a1b_set_format()
801 mutex_unlock(&og01a1b->mutex); in og01a1b_set_format()
810 struct og01a1b *og01a1b = to_og01a1b(sd); in og01a1b_get_format() local
812 mutex_lock(&og01a1b->mutex); in og01a1b_get_format()
817 og01a1b_update_pad_format(og01a1b->cur_mode, &fmt->format); in og01a1b_get_format()
819 mutex_unlock(&og01a1b->mutex); in og01a1b_get_format()
856 struct og01a1b *og01a1b = to_og01a1b(sd); in og01a1b_open() local
858 mutex_lock(&og01a1b->mutex); in og01a1b_open()
861 mutex_unlock(&og01a1b->mutex); in og01a1b_open()
890 static int og01a1b_identify_module(struct og01a1b *og01a1b) in og01a1b_identify_module() argument
892 struct i2c_client *client = v4l2_get_subdevdata(&og01a1b->sd); in og01a1b_identify_module()
896 ret = og01a1b_read_reg(og01a1b, OG01A1B_REG_CHIP_ID, in og01a1b_identify_module()
910 static int og01a1b_check_hwcfg(struct og01a1b *og01a1b) in og01a1b_check_hwcfg() argument
912 struct i2c_client *client = v4l2_get_subdevdata(&og01a1b->sd); in og01a1b_check_hwcfg()
928 if (!og01a1b->xvclk) { in og01a1b_check_hwcfg()
933 mclk = clk_get_rate(og01a1b->xvclk); in og01a1b_check_hwcfg()
989 struct og01a1b *og01a1b = to_og01a1b(sd); in og01a1b_power_on() local
992 if (og01a1b->avdd) { in og01a1b_power_on()
993 ret = regulator_enable(og01a1b->avdd); in og01a1b_power_on()
998 if (og01a1b->dovdd) { in og01a1b_power_on()
999 ret = regulator_enable(og01a1b->dovdd); in og01a1b_power_on()
1004 if (og01a1b->dvdd) { in og01a1b_power_on()
1005 ret = regulator_enable(og01a1b->dvdd); in og01a1b_power_on()
1010 ret = clk_prepare_enable(og01a1b->xvclk); in og01a1b_power_on()
1014 gpiod_set_value_cansleep(og01a1b->reset_gpio, 0); in og01a1b_power_on()
1016 if (og01a1b->reset_gpio) in og01a1b_power_on()
1018 else if (og01a1b->xvclk) in og01a1b_power_on()
1024 if (og01a1b->dvdd) in og01a1b_power_on()
1025 regulator_disable(og01a1b->dvdd); in og01a1b_power_on()
1027 if (og01a1b->dovdd) in og01a1b_power_on()
1028 regulator_disable(og01a1b->dovdd); in og01a1b_power_on()
1030 if (og01a1b->avdd) in og01a1b_power_on()
1031 regulator_disable(og01a1b->avdd); in og01a1b_power_on()
1040 struct og01a1b *og01a1b = to_og01a1b(sd); in og01a1b_power_off() local
1042 if (og01a1b->xvclk) in og01a1b_power_off()
1045 clk_disable_unprepare(og01a1b->xvclk); in og01a1b_power_off()
1047 gpiod_set_value_cansleep(og01a1b->reset_gpio, 1); in og01a1b_power_off()
1049 if (og01a1b->dvdd) in og01a1b_power_off()
1050 regulator_disable(og01a1b->dvdd); in og01a1b_power_off()
1052 if (og01a1b->dovdd) in og01a1b_power_off()
1053 regulator_disable(og01a1b->dovdd); in og01a1b_power_off()
1055 if (og01a1b->avdd) in og01a1b_power_off()
1056 regulator_disable(og01a1b->avdd); in og01a1b_power_off()
1064 struct og01a1b *og01a1b = to_og01a1b(sd); in og01a1b_remove() local
1070 mutex_destroy(&og01a1b->mutex); in og01a1b_remove()
1075 struct og01a1b *og01a1b; in og01a1b_probe() local
1078 og01a1b = devm_kzalloc(&client->dev, sizeof(*og01a1b), GFP_KERNEL); in og01a1b_probe()
1079 if (!og01a1b) in og01a1b_probe()
1082 v4l2_i2c_subdev_init(&og01a1b->sd, client, &og01a1b_subdev_ops); in og01a1b_probe()
1084 og01a1b->xvclk = devm_clk_get_optional(&client->dev, NULL); in og01a1b_probe()
1085 if (IS_ERR(og01a1b->xvclk)) { in og01a1b_probe()
1086 ret = PTR_ERR(og01a1b->xvclk); in og01a1b_probe()
1091 ret = og01a1b_check_hwcfg(og01a1b); in og01a1b_probe()
1098 og01a1b->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", in og01a1b_probe()
1100 if (IS_ERR(og01a1b->reset_gpio)) { in og01a1b_probe()
1102 return PTR_ERR(og01a1b->reset_gpio); in og01a1b_probe()
1105 og01a1b->avdd = devm_regulator_get_optional(&client->dev, "avdd"); in og01a1b_probe()
1106 if (IS_ERR(og01a1b->avdd)) { in og01a1b_probe()
1107 ret = PTR_ERR(og01a1b->avdd); in og01a1b_probe()
1114 og01a1b->avdd = NULL; in og01a1b_probe()
1117 og01a1b->dovdd = devm_regulator_get_optional(&client->dev, "dovdd"); in og01a1b_probe()
1118 if (IS_ERR(og01a1b->dovdd)) { in og01a1b_probe()
1119 ret = PTR_ERR(og01a1b->dovdd); in og01a1b_probe()
1126 og01a1b->dovdd = NULL; in og01a1b_probe()
1129 og01a1b->dvdd = devm_regulator_get_optional(&client->dev, "dvdd"); in og01a1b_probe()
1130 if (IS_ERR(og01a1b->dvdd)) { in og01a1b_probe()
1131 ret = PTR_ERR(og01a1b->dvdd); in og01a1b_probe()
1138 og01a1b->dvdd = NULL; in og01a1b_probe()
1146 ret = og01a1b_identify_module(og01a1b); in og01a1b_probe()
1152 mutex_init(&og01a1b->mutex); in og01a1b_probe()
1153 og01a1b->cur_mode = &supported_modes[0]; in og01a1b_probe()
1154 ret = og01a1b_init_controls(og01a1b); in og01a1b_probe()
1160 og01a1b->sd.internal_ops = &og01a1b_internal_ops; in og01a1b_probe()
1161 og01a1b->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in og01a1b_probe()
1162 og01a1b->sd.entity.ops = &og01a1b_subdev_entity_ops; in og01a1b_probe()
1163 og01a1b->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in og01a1b_probe()
1164 og01a1b->pad.flags = MEDIA_PAD_FL_SOURCE; in og01a1b_probe()
1165 ret = media_entity_pads_init(&og01a1b->sd.entity, 1, &og01a1b->pad); in og01a1b_probe()
1171 ret = v4l2_async_register_subdev_sensor(&og01a1b->sd); in og01a1b_probe()
1186 media_entity_cleanup(&og01a1b->sd.entity); in og01a1b_probe()
1189 v4l2_ctrl_handler_free(og01a1b->sd.ctrl_handler); in og01a1b_probe()
1190 mutex_destroy(&og01a1b->mutex); in og01a1b_probe()