Lines Matching +full:enable +full:- +full:output +full:- +full:invert

4  * SPDX-License-Identifier: Apache-2.0
13 #include <zephyr/drivers/video-controls.h>
126 #define COM7_ZOOM_EN 0x04 /* Enable Zoom */
127 #define COM7_COLOR_BAR 0x02 /* Enable Color Bar Test */
131 #define COM8_BNDF_EN 0x20 /* Enable Banding filter */
143 #define CTRL1_AWB 0x08 /* Enable AWB */
170 { COM2, COM2_OUT_DRIVE_3x }, /* Output drive x2 */
174 { COM10, 0x00 }, /* Invert VSYNC */
370 * The sensor output image can be scaled with OUTW/OUTH
407 { 0x00, 0x04, 0x09, 0x00, 0x00 }, /* -2 */
408 { 0x00, 0x04, 0x09, 0x10, 0x00 }, /* -1 */
417 { 0x00, 0x04, 0x07, 0x20, 0x18, 0x34, 0x06 }, /* -2 */
418 { 0x00, 0x04, 0x07, 0x20, 0x1c, 0x2a, 0x06 }, /* -1 */
427 { 0x00, 0x02, 0x03, 0x28, 0x28 }, /* -2 */
428 { 0x00, 0x02, 0x03, 0x38, 0x38 }, /* -1 */
493 while (tries--) { in ov2640_write_reg()
502 return -1; in ov2640_write_reg()
516 while (tries--) { in ov2640_read_reg()
525 return -1; in ov2640_read_reg()
532 const struct ov2640_config *cfg = dev->config; in ov2640_write_all()
537 err = ov2640_write_reg(&cfg->i2c, regs[i].addr, regs[i].value); in ov2640_write_all()
549 const struct ov2640_config *cfg = dev->config; in ov2640_soft_reset()
552 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_SENSOR); in ov2640_soft_reset()
555 ret |= ov2640_write_reg(&cfg->i2c, COM7, COM7_SRST); in ov2640_soft_reset()
564 const struct ov2640_config *cfg = dev->config; in ov2640_set_level()
568 return -ENOTSUP; in ov2640_set_level()
572 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_DSP); in ov2640_set_level()
575 ret |= ov2640_write_reg(&cfg->i2c, regs[0][i], regs[level][i]); in ov2640_set_level()
588 if (ret == -ENOTSUP) { in ov2640_set_brightness()
602 if (ret == -ENOTSUP) { in ov2640_set_saturation()
616 if (ret == -ENOTSUP) { in ov2640_set_contrast()
627 const struct ov2640_config *cfg = dev->config; in ov2640_set_output_format()
630 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_DSP); in ov2640_set_output_format()
633 /* Enable JPEG compression */ in ov2640_set_output_format()
634 ret |= ov2640_write_reg(&cfg->i2c, IMAGE_MODE, IMAGE_MODE_JPEG_EN); in ov2640_set_output_format()
636 /* Disable JPEG compression and set output to RGB565 */ in ov2640_set_output_format()
637 ret |= ov2640_write_reg(&cfg->i2c, IMAGE_MODE, IMAGE_MODE_RGB565); in ov2640_set_output_format()
640 return -ENOTSUP; in ov2640_set_output_format()
650 const struct ov2640_config *cfg = dev->config; in ov2640_set_quality()
653 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_DSP); in ov2640_set_quality()
656 ret |= ov2640_write_reg(&cfg->i2c, QS, qs); in ov2640_set_quality()
661 static int ov2640_set_colorbar(const struct device *dev, uint8_t enable) in ov2640_set_colorbar() argument
664 const struct ov2640_config *cfg = dev->config; in ov2640_set_colorbar()
669 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_SENSOR); in ov2640_set_colorbar()
671 /* Update COM7 to enable/disable color bar test pattern */ in ov2640_set_colorbar()
672 reg = ov2640_read_reg(&cfg->i2c, COM7); in ov2640_set_colorbar()
674 if (enable) { in ov2640_set_colorbar()
680 ret |= ov2640_write_reg(&cfg->i2c, COM7, reg); in ov2640_set_colorbar()
685 static int ov2640_set_white_bal(const struct device *dev, int enable) in ov2640_set_white_bal() argument
688 const struct ov2640_config *cfg = dev->config; in ov2640_set_white_bal()
693 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_SENSOR); in ov2640_set_white_bal()
695 /* Update CTRL1 to enable/disable automatic white balance*/ in ov2640_set_white_bal()
696 reg = ov2640_read_reg(&cfg->i2c, CTRL1); in ov2640_set_white_bal()
698 if (enable) { in ov2640_set_white_bal()
704 ret |= ov2640_write_reg(&cfg->i2c, CTRL1, reg); in ov2640_set_white_bal()
709 static int ov2640_set_gain_ctrl(const struct device *dev, int enable) in ov2640_set_gain_ctrl() argument
712 const struct ov2640_config *cfg = dev->config; in ov2640_set_gain_ctrl()
717 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_SENSOR); in ov2640_set_gain_ctrl()
719 /* Update COM8 to enable/disable automatic gain control */ in ov2640_set_gain_ctrl()
720 reg = ov2640_read_reg(&cfg->i2c, COM8); in ov2640_set_gain_ctrl()
722 if (enable) { in ov2640_set_gain_ctrl()
728 ret |= ov2640_write_reg(&cfg->i2c, COM8, reg); in ov2640_set_gain_ctrl()
733 static int ov2640_set_exposure_ctrl(const struct device *dev, int enable) in ov2640_set_exposure_ctrl() argument
736 const struct ov2640_config *cfg = dev->config; in ov2640_set_exposure_ctrl()
741 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_SENSOR); in ov2640_set_exposure_ctrl()
743 /* Update COM8 to enable/disable automatic exposure control */ in ov2640_set_exposure_ctrl()
744 reg = ov2640_read_reg(&cfg->i2c, COM8); in ov2640_set_exposure_ctrl()
746 if (enable) { in ov2640_set_exposure_ctrl()
752 ret |= ov2640_write_reg(&cfg->i2c, COM8, reg); in ov2640_set_exposure_ctrl()
758 int enable) in ov2640_set_horizontal_mirror() argument
761 const struct ov2640_config *cfg = dev->config; in ov2640_set_horizontal_mirror()
766 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_SENSOR); in ov2640_set_horizontal_mirror()
768 /* Update REG04 to enable/disable horizontal mirror */ in ov2640_set_horizontal_mirror()
769 reg = ov2640_read_reg(&cfg->i2c, REG04); in ov2640_set_horizontal_mirror()
771 if (enable) { in ov2640_set_horizontal_mirror()
777 ret |= ov2640_write_reg(&cfg->i2c, REG04, reg); in ov2640_set_horizontal_mirror()
782 static int ov2640_set_vertical_flip(const struct device *dev, int enable) in ov2640_set_vertical_flip() argument
785 const struct ov2640_config *cfg = dev->config; in ov2640_set_vertical_flip()
790 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_SENSOR); in ov2640_set_vertical_flip()
792 /* Update REG04 to enable/disable vertical flip */ in ov2640_set_vertical_flip()
793 reg = ov2640_read_reg(&cfg->i2c, REG04); in ov2640_set_vertical_flip()
795 if (enable) { in ov2640_set_vertical_flip()
801 ret |= ov2640_write_reg(&cfg->i2c, REG04, reg); in ov2640_set_vertical_flip()
810 const struct ov2640_config *cfg = dev->config; in ov2640_set_resolution()
816 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_DSP); in ov2640_set_resolution()
817 ret |= ov2640_write_reg(&cfg->i2c, R_BYPASS, R_BYPASS_DSP_BYPAS); in ov2640_set_resolution()
819 /* Write output width */ in ov2640_set_resolution()
820 ret |= ov2640_write_reg(&cfg->i2c, ZMOW, (w >> 2) & 0xFF); /* OUTW[7:0] (real/4) */ in ov2640_set_resolution()
821 ret |= ov2640_write_reg(&cfg->i2c, ZMOH, (h >> 2) & 0xFF); /* OUTH[7:0] (real/4) */ in ov2640_set_resolution()
822 ret |= ov2640_write_reg(&cfg->i2c, ZMHH, ((h >> 8) & 0x04) | in ov2640_set_resolution()
826 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_SENSOR); in ov2640_set_resolution()
827 ret |= ov2640_write_reg(&cfg->i2c, CLKRC, cfg->clock_rate_control); in ov2640_set_resolution()
832 /* Enable DSP */ in ov2640_set_resolution()
833 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_DSP); in ov2640_set_resolution()
834 ret |= ov2640_write_reg(&cfg->i2c, R_BYPASS, R_BYPASS_DSP_EN); in ov2640_set_resolution()
844 const struct ov2640_config *cfg = dev->config; in ov2640_check_connection()
848 ret |= ov2640_write_reg(&cfg->i2c, BANK_SEL, BANK_SEL_SENSOR); in ov2640_check_connection()
849 reg_pid_val = ov2640_read_reg(&cfg->i2c, REG_PID); in ov2640_check_connection()
850 reg_ver_val = ov2640_read_reg(&cfg->i2c, REG_VER); in ov2640_check_connection()
854 return -ENODEV; in ov2640_check_connection()
863 struct ov2640_data *drv_data = dev->data; in ov2640_set_fmt()
869 if (fmt->pixelformat != VIDEO_PIX_FMT_RGB565 && fmt->pixelformat != VIDEO_PIX_FMT_JPEG) { in ov2640_set_fmt()
871 return -ENOTSUP; in ov2640_set_fmt()
874 width = fmt->width; in ov2640_set_fmt()
875 height = fmt->height; in ov2640_set_fmt()
877 if (!memcmp(&drv_data->fmt, fmt, sizeof(drv_data->fmt))) { in ov2640_set_fmt()
882 drv_data->fmt = *fmt; in ov2640_set_fmt()
884 /* Set output format */ in ov2640_set_fmt()
885 ret |= ov2640_set_output_format(dev, fmt->pixelformat); in ov2640_set_fmt()
890 fmts[i].pixelformat == fmt->pixelformat) { in ov2640_set_fmt()
892 ret |= ov2640_set_resolution(dev, fmt->width, fmt->height); in ov2640_set_fmt()
900 return -ENOTSUP; in ov2640_set_fmt()
906 struct ov2640_data *drv_data = dev->data; in ov2640_get_fmt()
908 *fmt = drv_data->fmt; in ov2640_get_fmt()
927 caps->format_caps = fmts; in ov2640_get_caps()
968 return -ENOTSUP; in ov2640_set_ctrl()
989 const struct ov2640_config *cfg = dev->config; in ov2640_init()
991 ret = gpio_pin_configure_dt(&cfg->reset_gpio, GPIO_OUTPUT_ACTIVE); in ov2640_init()
996 gpio_pin_set_dt(&cfg->reset_gpio, 0); in ov2640_init()
998 gpio_pin_set_dt(&cfg->reset_gpio, 1); in ov2640_init()
1021 return -EIO; in ov2640_init()
1042 const struct ov2640_config *cfg = dev->config; in ov2640_init_0()
1044 if (!device_is_ready(cfg->i2c.bus)) { in ov2640_init_0()
1046 return -ENODEV; in ov2640_init_0()
1050 if (!gpio_is_ready_dt(&cfg->reset_gpio)) { in ov2640_init_0()
1051 LOG_ERR("%s: device %s is not ready", dev->name, in ov2640_init_0()
1052 cfg->reset_gpio.port->name); in ov2640_init_0()
1053 return -ENODEV; in ov2640_init_0()
1060 if (i2c_configure(cfg->i2c.bus, i2c_cfg)) { in ov2640_init_0()