Skip to content

Commit 8379cd7

Browse files
committed
Merge branch 'feature/isp_dvp_example_v5.4' into 'release/v5.4'
feat(dvp_isp_dsi_example): add new option to connect a DVP camera sensor (ov2640) through ISP_DVP (v5.4) See merge request espressif/esp-idf!35973
2 parents e456840 + 706b5b4 commit 8379cd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+657
-79
lines changed

components/esp_driver_cam/isp_dvp/src/esp_cam_ctlr_isp_dvp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,28 +495,28 @@ static esp_err_t s_isp_io_init(isp_dvp_controller_t *dvp_ctlr, const esp_cam_ctl
495495
.pull_up_en = true,
496496
};
497497

498-
if (ctlr_config->pclk_io) {
498+
if (ctlr_config->pclk_io >= 0) {
499499
gpio_conf.pin_bit_mask = 1ULL << ctlr_config->pclk_io;
500500
ESP_RETURN_ON_ERROR(gpio_config(&gpio_conf), TAG, "failed to configure pclk gpio");
501501
ESP_LOGD(TAG, "pclk_io: %d, dvp_pclk_sig: %"PRId32, ctlr_config->pclk_io, isp_hw_info.dvp_ctlr[dvp_ctlr->id].dvp_pclk_sig);
502502
esp_rom_gpio_connect_in_signal(ctlr_config->pclk_io, isp_hw_info.dvp_ctlr[dvp_ctlr->id].dvp_pclk_sig, false);
503503
}
504504

505-
if (ctlr_config->hsync_io) {
505+
if (ctlr_config->hsync_io >= 0) {
506506
gpio_conf.pin_bit_mask = 1ULL << ctlr_config->hsync_io;
507507
ESP_RETURN_ON_ERROR(gpio_config(&gpio_conf), TAG, "failed to configure hsync gpio");
508508
ESP_LOGD(TAG, "hsync_io: %d, dvp_hsync_sig: %"PRId32, ctlr_config->hsync_io, isp_hw_info.dvp_ctlr[dvp_ctlr->id].dvp_hsync_sig);
509509
esp_rom_gpio_connect_in_signal(ctlr_config->hsync_io, isp_hw_info.dvp_ctlr[dvp_ctlr->id].dvp_hsync_sig, false);
510510
}
511511

512-
if (ctlr_config->vsync_io) {
512+
if (ctlr_config->vsync_io >= 0) {
513513
gpio_conf.pin_bit_mask = 1ULL << ctlr_config->vsync_io;
514514
ESP_RETURN_ON_ERROR(gpio_config(&gpio_conf), TAG, "failed to configure vsync gpio");
515515
ESP_LOGD(TAG, "vsync_io: %d, dvp_vsync_sig: %"PRId32, ctlr_config->vsync_io, isp_hw_info.dvp_ctlr[dvp_ctlr->id].dvp_vsync_sig);
516516
esp_rom_gpio_connect_in_signal(ctlr_config->vsync_io, isp_hw_info.dvp_ctlr[dvp_ctlr->id].dvp_vsync_sig, false);
517517
}
518518

519-
if (ctlr_config->de_io) {
519+
if (ctlr_config->de_io >= 0) {
520520
gpio_conf.pin_bit_mask = 1ULL << ctlr_config->de_io;
521521
ESP_RETURN_ON_ERROR(gpio_config(&gpio_conf), TAG, "failed to configure de gpio");
522522
ESP_LOGD(TAG, "de_io: %d, dvp_de_sig: %"PRId32, ctlr_config->de_io, isp_hw_info.dvp_ctlr[dvp_ctlr->id].dvp_de_sig);

components/esp_driver_isp/src/isp_core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ esp_err_t esp_isp_new_processor(const esp_isp_processor_cfg_t *proc_config, isp_
145145
isp_ll_yuv_set_range(proc->hal.hw, proc_config->yuv_range);
146146
}
147147

148+
if (out_color_format.color_space == COLOR_SPACE_RGB && proc_config->input_data_source == ISP_INPUT_DATA_SOURCE_DVP) {
149+
isp_ll_color_enable(proc->hal.hw, true); // workaround for DIG-474
150+
}
151+
148152
proc->in_color_format = in_color_format;
149153
proc->out_color_format = out_color_format;
150154
proc->h_res = proc_config->h_res;

components/esp_driver_isp/src/isp_demosaic.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ esp_err_t esp_isp_demosaic_disable(isp_proc_handle_t proc)
5959
ESP_RETURN_ON_FALSE(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer");
6060
ESP_RETURN_ON_FALSE(proc->demosaic_fsm == ISP_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "demosaic isn't enabled yet");
6161

62-
isp_ll_demosaic_enable(proc->hal.hw, false);
62+
if (proc->out_color_format.color_space == (uint32_t)COLOR_SPACE_RAW) {
63+
// for other out_color_format, demosaic module is needed for rgb interpolation algorithm
64+
isp_ll_demosaic_enable(proc->hal.hw, false);
65+
}
6366
proc->demosaic_fsm = ISP_FSM_INIT;
6467

6568
return ESP_OK;

docs/en/api-reference/peripherals/camera_driver.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ This allows the interrupt to run while the cache is disabled, but comes at the c
212212
Application Examples
213213
--------------------
214214

215-
* :example:`peripherals/camera/camera_dsi` demonstrates how to use the ``esp_driver_cam`` component to capture signals from a camera sensor and display it on an ILI9881C LCD screen via a DSI interface.
215+
* :example:`peripherals/camera/mipi_isp_dsi` demonstrates how to use the ``esp_driver_cam`` component to capture signals from a MIPI CSI camera sensor via the ISP module and display it on a LCD screen via a DSI interface.
216+
* :example:`peripherals/camera/dvp_isp_dsi` demonstrates how to use the ``esp_driver_cam`` component to capture signals from a DVP camera sensor via the ISP module and display it on a LCD screen via a DSI interface.
216217

217218
API Reference
218219
-------------

docs/en/api-reference/peripherals/isp.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,10 @@ After calling :cpp:func:`esp_isp_color_configure`, you need to enable the ISP co
589589

590590
Calling :cpp:func:`esp_isp_color_disable` does the opposite, that is, put the driver back to the **init** state.
591591

592+
.. note::
593+
594+
When the ISP DVP peripheral is used with the output color format set to the RGB color space, :ref:`isp-color` is automatically enabled in the camera driver to ensure correct data output. The function :cpp:func:`esp_isp_color_disable` should never be called in this case, otherwise it may result in disarrayed camera data.
595+
592596
.. _isp-ccm-config:
593597

594598
Configure CCM

docs/zh_CN/api-reference/peripherals/camera_driver.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ IRAM 安全
212212
应用示例
213213
--------
214214

215-
* :example:`peripherals/camera/camera_dsi` 演示了如何使用 ``esp_driver_cam`` 组件从摄像头传感器捕获信号,并通过 DSI 接口将其显示在 ILI9881C LCD 屏幕上。
215+
* :example:`peripherals/camera/mipi_isp_dsi` 演示了如何使用 ``esp_driver_cam`` 组件从 MIPI CSI 摄像头传感器捕获信号,传入 ISP 模块,并通过 DSI 接口将其显示在 LCD 屏幕上。
216+
* :example:`peripherals/camera/dvp_isp_dsi` 演示了如何使用 ``esp_driver_cam`` 组件从 DVP 摄像头传感器捕获信号,传入 ISP 模块,并通过 DSI 接口将其显示在 LCD 屏幕上。
216217

217218
API 参考
218219
--------

examples/peripherals/.build-test-rules.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ examples/peripherals/analog_comparator:
3232
- esp_driver_gpio
3333
- esp_driver_ana_cmpr
3434

35-
examples/peripherals/camera/camera_dsi:
35+
examples/peripherals/camera/dvp_isp_dsi:
36+
disable:
37+
- if: SOC_ISP_DVP_SUPPORTED != 1 or SOC_MIPI_DSI_SUPPORTED != 1
38+
depends_components:
39+
- esp_lcd
40+
- esp_driver_cam
41+
42+
examples/peripherals/camera/mipi_isp_dsi:
3643
disable:
3744
- if: SOC_MIPI_CSI_SUPPORTED != 1 or SOC_MIPI_DSI_SUPPORTED != 1
3845
depends_components:

examples/peripherals/camera/camera_dsi/components/sensor_init/include/example_sensor_init.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/peripherals/camera/camera_dsi/main/idf_component.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
idf_component_register(SRCS "example_sensor_init.c"
22
INCLUDE_DIRS "include"
3+
REQUIRES esp_cam_sensor
34
)

examples/peripherals/camera/camera_dsi/components/sensor_init/example_sensor_init.c renamed to examples/peripherals/camera/common_components/sensor_init/example_sensor_init.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,32 @@
1313
#include "driver/i2c_master.h"
1414
#include "esp_sccb_intf.h"
1515
#include "esp_sccb_i2c.h"
16-
#include "esp_cam_sensor.h"
1716
#include "esp_cam_sensor_detect.h"
1817
#include "example_sensor_init.h"
1918
#include "example_sensor_init_config.h"
2019

2120
static const char *TAG = "sensor_init";
2221

23-
void example_sensor_init(int i2c_port, i2c_master_bus_handle_t *out_i2c_bus_handle)
22+
void example_sensor_init(example_sensor_config_t *sensor_config, i2c_master_bus_handle_t *out_i2c_bus_handle)
2423
{
2524
esp_err_t ret = ESP_FAIL;
2625

2726
//---------------I2C Init------------------//
2827
i2c_master_bus_config_t i2c_bus_conf = {
2928
.clk_source = I2C_CLK_SRC_DEFAULT,
30-
.sda_io_num = EXAMPLE_CAM_SCCB_SDA_IO,
31-
.scl_io_num = EXAMPLE_CAM_SCCB_SCL_IO,
32-
.i2c_port = i2c_port,
29+
.sda_io_num = sensor_config->i2c_sda_io_num,
30+
.scl_io_num = sensor_config->i2c_scl_io_num,
31+
.i2c_port = sensor_config->i2c_port_num,
3332
.flags.enable_internal_pullup = true,
3433
};
3534
i2c_master_bus_handle_t i2c_bus_handle = NULL;
3635
ESP_ERROR_CHECK(i2c_new_master_bus(&i2c_bus_conf, &i2c_bus_handle));
3736

3837
//---------------SCCB Init------------------//
39-
esp_sccb_io_handle_t sccb_io_handle = NULL;
4038
esp_cam_sensor_config_t cam_config = {
41-
.sccb_handle = sccb_io_handle,
4239
.reset_pin = -1,
4340
.pwdn_pin = -1,
4441
.xclk_pin = -1,
45-
.sensor_port = ESP_CAM_SENSOR_MIPI_CSI,
4642
};
4743

4844
esp_cam_sensor_device_t *cam = NULL;
@@ -54,9 +50,11 @@ void example_sensor_init(int i2c_port, i2c_master_bus_handle_t *out_i2c_bus_hand
5450
};
5551
ESP_ERROR_CHECK(sccb_new_i2c_io(i2c_bus_handle, &i2c_config, &cam_config.sccb_handle));
5652

53+
cam_config.sensor_port = p->port;
54+
5755
cam = (*(p->detect))(&cam_config);
5856
if (cam) {
59-
if (p->port != ESP_CAM_SENSOR_MIPI_CSI) {
57+
if (p->port != sensor_config->port) {
6058
ESP_LOGE(TAG, "detect a camera sensor with mismatched interface");
6159
return;
6260
}
@@ -79,8 +77,8 @@ void example_sensor_init(int i2c_port, i2c_master_bus_handle_t *out_i2c_bus_hand
7977

8078
esp_cam_sensor_format_t *cam_cur_fmt = NULL;
8179
for (int i = 0; i < cam_fmt_array.count; i++) {
82-
if (!strcmp(parray[i].name, EXAMPLE_CAM_FORMAT)) {
83-
cam_cur_fmt = (esp_cam_sensor_format_t *) & (parray[i].name);
80+
if (!strcmp(parray[i].name, sensor_config->format_name)) {
81+
cam_cur_fmt = (esp_cam_sensor_format_t *) & (parray[i]);
8482
}
8583
}
8684

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dependencies:
2-
espressif/esp_cam_sensor: "^0.5.1"
2+
espressif/esp_cam_sensor: "^0.6.1"
33
idf:
44
version: ">=5.3.0"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include "driver/i2c_master.h"
10+
#include "esp_cam_sensor.h"
11+
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
/**
17+
* @brief Configuration of SCCB interface and sensor
18+
*/
19+
typedef struct {
20+
int i2c_port_num; /* SCCB: i2c port */
21+
int i2c_sda_io_num; /* SCCB: i2c SDA IO number */
22+
int i2c_scl_io_num; /* SCCB: i2c SCL IO number */
23+
esp_cam_sensor_port_t port; /* Sensor: interface of the camera sensor */
24+
const char *format_name; /* Sensor: format to be set for the camera sensor */
25+
} example_sensor_config_t;
26+
27+
/**
28+
* @brief SCCB Interface and Sensor Init
29+
*
30+
* @param[in] sensor_config Camera sensor configuration
31+
* @param[out] out_i2c_bus_handle I2C bus handle
32+
*/
33+
void example_sensor_init(example_sensor_config_t *sensor_config, i2c_master_bus_handle_t *out_i2c_bus_handle);
34+
35+
#ifdef __cplusplus
36+
}
37+
#endif

examples/peripherals/camera/camera_dsi/main/example_config.h renamed to examples/peripherals/camera/common_components/sensor_init/include/example_sensor_init_config.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
extern "C" {
1111
#endif
1212

13-
#define EXAMPLE_RGB565_BITS_PER_PIXEL 16
14-
#define EXAMPLE_MIPI_IDI_CLOCK_RATE (50000000)
15-
#define EXAMPLE_MIPI_CSI_LANE_BITRATE_MBPS 200 //line_rate = pclk * 4
13+
#define EXAMPLE_CAM_SCCB_FREQ (100000)
1614

1715
#ifdef __cplusplus
1816
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The following lines of boilerplate have to be in your project's CMakeLists
2+
# in this exact order for cmake to work correctly
3+
cmake_minimum_required(VERSION 3.16)
4+
5+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
6+
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
7+
idf_build_set_property(MINIMAL_BUILD ON)
8+
project(dvp_isp_dsi)

0 commit comments

Comments
 (0)