Lines Matching refs:ov01a10
277 struct ov01a10 { struct
295 static inline struct ov01a10 *to_ov01a10(struct v4l2_subdev *subdev) in to_ov01a10() argument
297 return container_of(subdev, struct ov01a10, sd); in to_ov01a10()
300 static int ov01a10_read_reg(struct ov01a10 *ov01a10, u16 reg, u16 len, u32 *val) in ov01a10_read_reg() argument
302 struct i2c_client *client = v4l2_get_subdevdata(&ov01a10->sd); in ov01a10_read_reg()
331 static int ov01a10_write_reg(struct ov01a10 *ov01a10, u16 reg, u16 len, u32 val) in ov01a10_write_reg() argument
333 struct i2c_client *client = v4l2_get_subdevdata(&ov01a10->sd); in ov01a10_write_reg()
350 static int ov01a10_write_reg_list(struct ov01a10 *ov01a10, in ov01a10_write_reg_list() argument
353 struct i2c_client *client = v4l2_get_subdevdata(&ov01a10->sd); in ov01a10_write_reg_list()
358 ret = ov01a10_write_reg(ov01a10, r_list->regs[i].address, 1, in ov01a10_write_reg_list()
371 static int ov01a10_update_digital_gain(struct ov01a10 *ov01a10, u32 d_gain) in ov01a10_update_digital_gain() argument
373 struct i2c_client *client = v4l2_get_subdevdata(&ov01a10->sd); in ov01a10_update_digital_gain()
377 ret = ov01a10_write_reg(ov01a10, OV01A10_REG_DIGITAL_GAIN_B, 3, real); in ov01a10_update_digital_gain()
383 ret = ov01a10_write_reg(ov01a10, OV01A10_REG_DIGITAL_GAIN_GB, 3, real); in ov01a10_update_digital_gain()
389 ret = ov01a10_write_reg(ov01a10, OV01A10_REG_DIGITAL_GAIN_GR, 3, real); in ov01a10_update_digital_gain()
395 ret = ov01a10_write_reg(ov01a10, OV01A10_REG_DIGITAL_GAIN_R, 3, real); in ov01a10_update_digital_gain()
402 static int ov01a10_test_pattern(struct ov01a10 *ov01a10, u32 pattern) in ov01a10_test_pattern() argument
409 return ov01a10_write_reg(ov01a10, OV01A10_REG_TEST_PATTERN, 1, pattern); in ov01a10_test_pattern()
413 static int ov01a10_set_hflip(struct ov01a10 *ov01a10, u32 hflip) in ov01a10_set_hflip() argument
419 ret = ov01a10_write_reg(ov01a10, OV01A10_REG_X_WIN, 1, offset); in ov01a10_set_hflip()
423 ret = ov01a10_read_reg(ov01a10, OV01A10_REG_FORMAT1, 1, &val); in ov01a10_set_hflip()
430 return ov01a10_write_reg(ov01a10, OV01A10_REG_FORMAT1, 1, val); in ov01a10_set_hflip()
433 static int ov01a10_set_vflip(struct ov01a10 *ov01a10, u32 vflip) in ov01a10_set_vflip() argument
439 ret = ov01a10_write_reg(ov01a10, OV01A10_REG_Y_WIN, 1, offset); in ov01a10_set_vflip()
443 ret = ov01a10_read_reg(ov01a10, OV01A10_REG_FORMAT1, 1, &val); in ov01a10_set_vflip()
450 return ov01a10_write_reg(ov01a10, OV01A10_REG_FORMAT1, 1, val); in ov01a10_set_vflip()
455 struct ov01a10 *ov01a10 = container_of(ctrl->handler, in ov01a10_set_ctrl() local
456 struct ov01a10, ctrl_handler); in ov01a10_set_ctrl()
457 struct i2c_client *client = v4l2_get_subdevdata(&ov01a10->sd); in ov01a10_set_ctrl()
462 exposure_max = ov01a10->cur_mode->height + ctrl->val - in ov01a10_set_ctrl()
464 __v4l2_ctrl_modify_range(ov01a10->exposure, in ov01a10_set_ctrl()
465 ov01a10->exposure->minimum, in ov01a10_set_ctrl()
466 exposure_max, ov01a10->exposure->step, in ov01a10_set_ctrl()
475 ret = ov01a10_write_reg(ov01a10, OV01A10_REG_ANALOG_GAIN, 2, in ov01a10_set_ctrl()
480 ret = ov01a10_update_digital_gain(ov01a10, ctrl->val); in ov01a10_set_ctrl()
484 ret = ov01a10_write_reg(ov01a10, OV01A10_REG_EXPOSURE, 2, in ov01a10_set_ctrl()
489 ret = ov01a10_write_reg(ov01a10, OV01A10_REG_VTS, 2, in ov01a10_set_ctrl()
490 ov01a10->cur_mode->height + ctrl->val); in ov01a10_set_ctrl()
494 ret = ov01a10_test_pattern(ov01a10, ctrl->val); in ov01a10_set_ctrl()
498 ov01a10_set_hflip(ov01a10, ctrl->val); in ov01a10_set_ctrl()
502 ov01a10_set_vflip(ov01a10, ctrl->val); in ov01a10_set_ctrl()
519 static int ov01a10_init_controls(struct ov01a10 *ov01a10) in ov01a10_init_controls() argument
521 struct i2c_client *client = v4l2_get_subdevdata(&ov01a10->sd); in ov01a10_init_controls()
534 ctrl_hdlr = &ov01a10->ctrl_handler; in ov01a10_init_controls()
539 cur_mode = ov01a10->cur_mode; in ov01a10_init_controls()
542 ov01a10->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, in ov01a10_init_controls()
547 if (ov01a10->link_freq) in ov01a10_init_controls()
548 ov01a10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov01a10_init_controls()
550 ov01a10->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov01a10_ctrl_ops, in ov01a10_init_controls()
557 ov01a10->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov01a10_ctrl_ops, in ov01a10_init_controls()
562 ov01a10->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov01a10_ctrl_ops, in ov01a10_init_controls()
565 if (ov01a10->hblank) in ov01a10_init_controls()
566 ov01a10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov01a10_init_controls()
576 ov01a10->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov01a10_ctrl_ops, in ov01a10_init_controls()
603 ov01a10->sd.ctrl_handler = ctrl_hdlr; in ov01a10_init_controls()
622 static int ov01a10_start_streaming(struct ov01a10 *ov01a10) in ov01a10_start_streaming() argument
624 struct i2c_client *client = v4l2_get_subdevdata(&ov01a10->sd); in ov01a10_start_streaming()
629 link_freq_index = ov01a10->cur_mode->link_freq_index; in ov01a10_start_streaming()
631 ret = ov01a10_write_reg_list(ov01a10, reg_list); in ov01a10_start_streaming()
637 reg_list = &ov01a10->cur_mode->reg_list; in ov01a10_start_streaming()
638 ret = ov01a10_write_reg_list(ov01a10, reg_list); in ov01a10_start_streaming()
644 ret = __v4l2_ctrl_handler_setup(ov01a10->sd.ctrl_handler); in ov01a10_start_streaming()
648 ret = ov01a10_write_reg(ov01a10, OV01A10_REG_MODE_SELECT, 1, in ov01a10_start_streaming()
656 static void ov01a10_stop_streaming(struct ov01a10 *ov01a10) in ov01a10_stop_streaming() argument
658 struct i2c_client *client = v4l2_get_subdevdata(&ov01a10->sd); in ov01a10_stop_streaming()
661 ret = ov01a10_write_reg(ov01a10, OV01A10_REG_MODE_SELECT, 1, in ov01a10_stop_streaming()
669 struct ov01a10 *ov01a10 = to_ov01a10(sd); in ov01a10_set_stream() local
675 if (ov01a10->streaming == enable) in ov01a10_set_stream()
683 ret = ov01a10_start_streaming(ov01a10); in ov01a10_set_stream()
692 ov01a10_stop_streaming(ov01a10); in ov01a10_set_stream()
695 ov01a10->streaming = enable; in ov01a10_set_stream()
706 struct ov01a10 *ov01a10 = to_ov01a10(sd); in ov01a10_suspend() local
710 if (ov01a10->streaming) in ov01a10_suspend()
711 ov01a10_stop_streaming(ov01a10); in ov01a10_suspend()
722 struct ov01a10 *ov01a10 = to_ov01a10(sd); in ov01a10_resume() local
727 if (!ov01a10->streaming) in ov01a10_resume()
730 ret = ov01a10_start_streaming(ov01a10); in ov01a10_resume()
732 ov01a10->streaming = false; in ov01a10_resume()
733 ov01a10_stop_streaming(ov01a10); in ov01a10_resume()
746 struct ov01a10 *ov01a10 = to_ov01a10(sd); in ov01a10_set_format() local
759 ov01a10->cur_mode = mode; in ov01a10_set_format()
760 __v4l2_ctrl_s_ctrl(ov01a10->link_freq, mode->link_freq_index); in ov01a10_set_format()
761 __v4l2_ctrl_s_ctrl_int64(ov01a10->pixel_rate, OV01A10_SCLK); in ov01a10_set_format()
764 __v4l2_ctrl_modify_range(ov01a10->vblank, in ov01a10_set_format()
768 __v4l2_ctrl_s_ctrl(ov01a10->vblank, vblank_def); in ov01a10_set_format()
770 __v4l2_ctrl_modify_range(ov01a10->hblank, h_blank, h_blank, 1, in ov01a10_set_format()
882 static int ov01a10_identify_module(struct ov01a10 *ov01a10) in ov01a10_identify_module() argument
884 struct i2c_client *client = v4l2_get_subdevdata(&ov01a10->sd); in ov01a10_identify_module()
888 ret = ov01a10_read_reg(ov01a10, OV01A10_REG_CHIP_ID, 3, &val); in ov01a10_identify_module()
916 struct ov01a10 *ov01a10; in ov01a10_probe() local
919 ov01a10 = devm_kzalloc(dev, sizeof(*ov01a10), GFP_KERNEL); in ov01a10_probe()
920 if (!ov01a10) in ov01a10_probe()
923 v4l2_i2c_subdev_init(&ov01a10->sd, client, &ov01a10_subdev_ops); in ov01a10_probe()
925 ret = ov01a10_identify_module(ov01a10); in ov01a10_probe()
930 ov01a10->cur_mode = &supported_modes[0]; in ov01a10_probe()
932 ret = ov01a10_init_controls(ov01a10); in ov01a10_probe()
938 ov01a10->sd.state_lock = ov01a10->ctrl_handler.lock; in ov01a10_probe()
939 ov01a10->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | in ov01a10_probe()
941 ov01a10->sd.entity.ops = &ov01a10_subdev_entity_ops; in ov01a10_probe()
942 ov01a10->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in ov01a10_probe()
943 ov01a10->pad.flags = MEDIA_PAD_FL_SOURCE; in ov01a10_probe()
945 ret = media_entity_pads_init(&ov01a10->sd.entity, 1, &ov01a10->pad); in ov01a10_probe()
951 ret = v4l2_subdev_init_finalize(&ov01a10->sd); in ov01a10_probe()
965 ret = v4l2_async_register_subdev_sensor(&ov01a10->sd); in ov01a10_probe()
978 media_entity_cleanup(&ov01a10->sd.entity); in ov01a10_probe()
981 v4l2_ctrl_handler_free(ov01a10->sd.ctrl_handler); in ov01a10_probe()