Lines Matching +full:data +full:- +full:lanes

4  * SPDX-License-Identifier: Apache-2.0
18 #include <zephyr/drivers/video-controls.h>
97 #define ABS(a, b) (a > b ? a - b : b - a)
423 return -ENOTSUP; in ov5640_read_reg()
451 return -ENOTSUP; in ov5640_read_reg()
506 const struct ov5640_config *cfg = dev->config; in ov5640_set_frmival()
507 struct ov5640_data *drv_data = dev->data; in ov5640_set_frmival()
512 desired_frmrate = DIV_ROUND_CLOSEST(frmival->denominator, frmival->numerator); in ov5640_set_frmival()
516 if (ov5640_frame_rates[i] <= drv_data->cur_mode->max_frmrate && in ov5640_set_frmival()
525 {SC_PLL_CTRL1_REG, drv_data->cur_mode->mipi_frmrate_config[ind].pllCtrl1}, in ov5640_set_frmival()
526 {SC_PLL_CTRL2_REG, drv_data->cur_mode->mipi_frmrate_config[ind].pllCtrl2}, in ov5640_set_frmival()
529 ret = ov5640_write_multi_regs(&cfg->i2c, frmrate_params, ARRAY_SIZE(frmrate_params)); in ov5640_set_frmival()
530 ret |= ov5640_modify_reg(&cfg->i2c, SC_PLL_CTRL0_REG, 0x0f, MIPI_BIT_MODE); in ov5640_set_frmival()
531 ret |= ov5640_modify_reg(&cfg->i2c, SC_PLL_CTRL3_REG, 0x1f, in ov5640_set_frmival()
533 ret |= ov5640_modify_reg(&cfg->i2c, SYS_ROOT_DIV_REG, 0x3f, in ov5640_set_frmival()
543 drv_data->cur_frmrate = best_match; in ov5640_set_frmival()
544 drv_data->cur_pixrate = drv_data->cur_mode->mipi_frmrate_config[ind].pixelrate; in ov5640_set_frmival()
546 frmival->numerator = 1; in ov5640_set_frmival()
547 frmival->denominator = best_match; in ov5640_set_frmival()
555 struct ov5640_data *drv_data = dev->data; in ov5640_set_fmt()
556 const struct ov5640_config *cfg = dev->config; in ov5640_set_fmt()
561 if (fmt->pixelformat == fmts[i].pixelformat && fmt->width >= fmts[i].width_min && in ov5640_set_fmt()
562 fmt->width <= fmts[i].width_max && fmt->height >= fmts[i].height_min && in ov5640_set_fmt()
563 fmt->height <= fmts[i].height_max) { in ov5640_set_fmt()
570 return -ENOTSUP; in ov5640_set_fmt()
573 if (!memcmp(&drv_data->fmt, fmt, sizeof(drv_data->fmt))) { in ov5640_set_fmt()
577 drv_data->fmt = *fmt; in ov5640_set_fmt()
581 if (fmt->width == modes[i].width && fmt->height == modes[i].height) { in ov5640_set_fmt()
582 ret = ov5640_write_multi_regs(&cfg->i2c, modes[i].res_params, in ov5640_set_fmt()
591 drv_data->cur_mode = &modes[i]; in ov5640_set_fmt()
602 if (fmt->pixelformat == VIDEO_PIX_FMT_YUYV) { in ov5640_set_fmt()
607 ret = ov5640_write_multi_regs(&cfg->i2c, fmt_params, ARRAY_SIZE(fmt_params)); in ov5640_set_fmt()
614 def_frmival.denominator = drv_data->cur_mode->def_frmrate; in ov5640_set_fmt()
623 struct ov5640_data *drv_data = dev->data; in ov5640_get_fmt()
625 *fmt = drv_data->fmt; in ov5640_get_fmt()
633 caps->format_caps = fmts; in ov5640_get_caps()
639 const struct ov5640_config *cfg = dev->config; in ov5640_stream_start()
640 /* Power up MIPI PHY HS Tx & LP Rx in 2 data lanes mode */ in ov5640_stream_start()
641 int ret = ov5640_write_reg(&cfg->i2c, IO_MIPI_CTRL00_REG, 0x45); in ov5640_stream_start()
647 return ov5640_write_reg(&cfg->i2c, SYS_CTRL0_REG, SYS_CTRL0_SW_PWUP); in ov5640_stream_start()
652 const struct ov5640_config *cfg = dev->config; in ov5640_stream_stop()
654 int ret = ov5640_write_reg(&cfg->i2c, IO_MIPI_CTRL00_REG, 0x40); in ov5640_stream_stop()
660 return ov5640_write_reg(&cfg->i2c, SYS_CTRL0_REG, SYS_CTRL0_SW_PWDN); in ov5640_stream_stop()
678 const struct ov5640_config *cfg = dev->config; in ov5640_set_ctrl_test_pattern()
680 if (!IN_RANGE(value, 0, ARRAY_SIZE(test_pattern_val) - 1)) { in ov5640_set_ctrl_test_pattern()
681 return -EINVAL; in ov5640_set_ctrl_test_pattern()
684 return ov5640_write_reg(&cfg->i2c, PRE_ISP_TEST_SET1, test_pattern_val[value]); in ov5640_set_ctrl_test_pattern()
689 const struct ov5640_config *cfg = dev->config; in ov5640_set_ctrl_hue()
693 return -EINVAL; in ov5640_set_ctrl_hue()
697 int ret = ov5640_modify_reg(&cfg->i2c, SDE_CTRL0_REG, BIT(0), BIT(0)); in ov5640_set_ctrl_hue()
721 return ov5640_write_multi_regs(&cfg->i2c, hue_params, ARRAY_SIZE(hue_params)); in ov5640_set_ctrl_hue()
726 const struct ov5640_config *cfg = dev->config; in ov5640_set_ctrl_saturation()
729 return -EINVAL; in ov5640_set_ctrl_saturation()
733 int ret = ov5640_modify_reg(&cfg->i2c, SDE_CTRL8_REG, BIT(6) | BIT(0), BIT(6) | BIT(0)); in ov5640_set_ctrl_saturation()
739 return ov5640_write_multi_regs(&cfg->i2c, saturation_params, ARRAY_SIZE(saturation_params)); in ov5640_set_ctrl_saturation()
744 const struct ov5640_config *cfg = dev->config; in ov5640_set_ctrl_brightness()
746 if (!IN_RANGE(value, -UINT8_MAX, UINT8_MAX)) { in ov5640_set_ctrl_brightness()
747 return -EINVAL; in ov5640_set_ctrl_brightness()
752 int ret = ov5640_modify_reg(&cfg->i2c, SDE_CTRL0_REG, BIT(2), BIT(2)); in ov5640_set_ctrl_brightness()
758 return ov5640_write_multi_regs(&cfg->i2c, brightness_params, ARRAY_SIZE(brightness_params)); in ov5640_set_ctrl_brightness()
763 const struct ov5640_config *cfg = dev->config; in ov5640_set_ctrl_contrast()
766 return -EINVAL; in ov5640_set_ctrl_contrast()
769 int ret = ov5640_modify_reg(&cfg->i2c, SDE_CTRL0_REG, BIT(2), BIT(2)); in ov5640_set_ctrl_contrast()
775 return ov5640_write_reg(&cfg->i2c, SDE_CTRL6_REG, value & 0xff); in ov5640_set_ctrl_contrast()
780 const struct ov5640_config *cfg = dev->config; in ov5640_set_ctrl_gain()
783 return -EINVAL; in ov5640_set_ctrl_gain()
787 int ret = ov5640_modify_reg(&cfg->i2c, AEC_PK_MANUAL, BIT(1), BIT(0)); in ov5640_set_ctrl_gain()
796 return ov5640_write_multi_regs(&cfg->i2c, gain_params, ARRAY_SIZE(gain_params)); in ov5640_set_ctrl_gain()
798 return ov5640_write_reg(&cfg->i2c, AEC_PK_MANUAL, 0); in ov5640_set_ctrl_gain()
804 const struct ov5640_config *cfg = dev->config; in ov5640_set_ctrl_hflip()
806 return ov5640_modify_reg(&cfg->i2c, TIMING_TC_REG21_REG, BIT(2) | BIT(1), in ov5640_set_ctrl_hflip()
812 const struct ov5640_config *cfg = dev->config; in ov5640_set_ctrl_vflip()
814 return ov5640_modify_reg(&cfg->i2c, TIMING_TC_REG20_REG, BIT(2) | BIT(1), in ov5640_set_ctrl_vflip()
820 const struct ov5640_config *cfg = dev->config; in ov5640_set_ctrl_power_line_freq()
825 ret = ov5640_modify_reg(&cfg->i2c, HZ5060_CTRL01_REG, BIT(7), 0); in ov5640_set_ctrl_power_line_freq()
828 ret = ov5640_modify_reg(&cfg->i2c, HZ5060_CTRL00_REG, BIT(2), BIT(2)); in ov5640_set_ctrl_power_line_freq()
831 ret = ov5640_modify_reg(&cfg->i2c, HZ5060_CTRL00_REG, BIT(2), 0); in ov5640_set_ctrl_power_line_freq()
834 return -EINVAL; in ov5640_set_ctrl_power_line_freq()
841 return ov5640_modify_reg(&cfg->i2c, HZ5060_CTRL01_REG, BIT(7), BIT(7)); in ov5640_set_ctrl_power_line_freq()
866 return -ENOTSUP; in ov5640_set_ctrl()
872 struct ov5640_data *drv_data = dev->data; in ov5640_get_ctrl()
876 *((uint64_t *)value) = drv_data->cur_pixrate; in ov5640_get_ctrl()
880 return -ENOTSUP; in ov5640_get_ctrl()
887 struct ov5640_data *drv_data = dev->data; in ov5640_get_frmival()
889 frmival->numerator = 1; in ov5640_get_frmival()
890 frmival->denominator = drv_data->cur_frmrate; in ov5640_get_frmival()
901 if (fie->format->width == modes[i].width && in ov5640_enum_frmival()
902 fie->format->height == modes[i].height) { in ov5640_enum_frmival()
906 if (i == ARRAY_SIZE(modes) || fie->index >= ARRAY_SIZE(ov5640_frame_rates) || in ov5640_enum_frmival()
907 ov5640_frame_rates[fie->index] > modes[i].max_frmrate) { in ov5640_enum_frmival()
908 return -EINVAL; in ov5640_enum_frmival()
911 fie->type = VIDEO_FRMIVAL_TYPE_DISCRETE; in ov5640_enum_frmival()
912 fie->discrete.numerator = 1; in ov5640_enum_frmival()
913 fie->discrete.denominator = ov5640_frame_rates[fie->index]; in ov5640_enum_frmival()
933 const struct ov5640_config *cfg = dev->config; in ov5640_init()
938 if (!device_is_ready(cfg->i2c.bus)) { in ov5640_init()
940 return -ENODEV; in ov5640_init()
943 if (!gpio_is_ready_dt(&cfg->reset_gpio)) { in ov5640_init()
944 LOG_ERR("%s: device %s is not ready", dev->name, cfg->reset_gpio.port->name); in ov5640_init()
945 return -ENODEV; in ov5640_init()
948 if (!gpio_is_ready_dt(&cfg->powerdown_gpio)) { in ov5640_init()
949 LOG_ERR("%s: device %s is not ready", dev->name, cfg->powerdown_gpio.port->name); in ov5640_init()
950 return -ENODEV; in ov5640_init()
954 if (cfg->powerdown_gpio.port != NULL) { in ov5640_init()
955 ret = gpio_pin_configure_dt(&cfg->powerdown_gpio, GPIO_OUTPUT_ACTIVE); in ov5640_init()
961 if (cfg->reset_gpio.port != NULL) { in ov5640_init()
962 ret = gpio_pin_configure_dt(&cfg->reset_gpio, GPIO_OUTPUT_ACTIVE); in ov5640_init()
970 if (cfg->powerdown_gpio.port != NULL) { in ov5640_init()
971 gpio_pin_set_dt(&cfg->powerdown_gpio, 0); in ov5640_init()
976 if (cfg->reset_gpio.port != NULL) { in ov5640_init()
977 gpio_pin_set_dt(&cfg->reset_gpio, 0); in ov5640_init()
983 ret = ov5640_write_reg(&cfg->i2c, SYS_CTRL0_REG, SYS_CTRL0_SW_RST); in ov5640_init()
986 return -EIO; in ov5640_init()
992 ret = ov5640_write_multi_regs(&cfg->i2c, init_params, ARRAY_SIZE(init_params)); in ov5640_init()
995 return -EIO; in ov5640_init()
999 ret = ov5640_modify_reg(&cfg->i2c, 0x4814, 3U << 6, (uint8_t)(DEFAULT_MIPI_CHANNEL) << 6); in ov5640_init()
1002 return -EIO; in ov5640_init()
1006 ret = ov5640_read_reg(&cfg->i2c, CHIP_ID_REG, &chip_id, sizeof(chip_id)); in ov5640_init()
1009 return -ENODEV; in ov5640_init()
1014 return -ENODEV; in ov5640_init()
1025 return -EIO; in ov5640_init()