diff --git a/components/esp_driver_isp/include/driver/isp_af.h b/components/esp_driver_isp/include/driver/isp_af.h index 9058ea7445..d3d9522d79 100644 --- a/components/esp_driver_isp/include/driver/isp_af.h +++ b/components/esp_driver_isp/include/driver/isp_af.h @@ -19,7 +19,7 @@ extern "C" { * @brief AF controller config */ typedef struct { - isp_af_window_t window[ISP_AF_WINDOW_NUM]; ///< The sampling windows of AF + isp_window_t window[ISP_AF_WINDOW_NUM]; ///< The sampling windows of AF int edge_thresh; ///< Edge threshold, definition higher than this value will be counted as a valid pixel for calculating AF result int intr_priority; ///< The interrupt priority, range 0~7, if set to 0, the driver will try to allocate an interrupt with a relative low priority (1,2,3) otherwise the larger the higher, 7 is NMI } esp_isp_af_config_t; diff --git a/components/esp_driver_isp/src/isp_af.c b/components/esp_driver_isp/src/isp_af.c index 02f289a441..dd7ad8d4f3 100644 --- a/components/esp_driver_isp/src/isp_af.c +++ b/components/esp_driver_isp/src/isp_af.c @@ -88,17 +88,17 @@ esp_err_t esp_isp_new_af_controller(isp_proc_handle_t isp_proc, const esp_isp_af ESP_RETURN_ON_FALSE(demosaic_en && rgb2yuv_en, ESP_ERR_INVALID_STATE, TAG, "RGB2YUV not enabled, please update the output_data_color_type"); for (int i = 0; i < SOC_ISP_AF_WINDOW_NUMS; i++) { - ESP_LOGV(TAG, "af_config->window[%d].top_left_x: %"PRId32, i, af_config->window[i].top_left_x); - ESP_LOGV(TAG, "af_config->window[%d].bottom_right_x: %"PRId32, i, af_config->window[i].bottom_right_x); - ESP_LOGV(TAG, "af_config->window[%d].bottom_right_y: %"PRId32, i, af_config->window[i].bottom_right_y); - ESP_LOGV(TAG, "af_config->window[%d].top_left_y: %"PRId32, i, af_config->window[i].top_left_y); + ESP_LOGV(TAG, "af_config->window[%d].top_left.x: %"PRId32, i, af_config->window[i].top_left.x); + ESP_LOGV(TAG, "af_config->window[%d].btm_right.x: %"PRId32, i, af_config->window[i].btm_right.x); + ESP_LOGV(TAG, "af_config->window[%d].btm_right.y: %"PRId32, i, af_config->window[i].btm_right.y); + ESP_LOGV(TAG, "af_config->window[%d].top_left.y: %"PRId32, i, af_config->window[i].top_left.y); - ESP_RETURN_ON_FALSE(((af_config->window[i].top_left_x < ISP_LL_AF_WINDOW_MAX_RANGE) && - (af_config->window[i].bottom_right_x >= af_config->window[i].top_left_x) && - (af_config->window[i].bottom_right_x < ISP_LL_AF_WINDOW_MAX_RANGE) && - (af_config->window[i].top_left_y < ISP_LL_AF_WINDOW_MAX_RANGE) && - (af_config->window[i].bottom_right_y >= af_config->window[i].top_left_y) && - (af_config->window[i].bottom_right_y < ISP_LL_AF_WINDOW_MAX_RANGE)), ESP_ERR_INVALID_ARG, TAG, "invalid window"); + ESP_RETURN_ON_FALSE(((af_config->window[i].top_left.x < ISP_LL_AF_WINDOW_MAX_RANGE) && + (af_config->window[i].btm_right.x >= af_config->window[i].top_left.x) && + (af_config->window[i].btm_right.x < ISP_LL_AF_WINDOW_MAX_RANGE) && + (af_config->window[i].top_left.y < ISP_LL_AF_WINDOW_MAX_RANGE) && + (af_config->window[i].btm_right.y >= af_config->window[i].top_left.y) && + (af_config->window[i].btm_right.y < ISP_LL_AF_WINDOW_MAX_RANGE)), ESP_ERR_INVALID_ARG, TAG, "invalid window"); } ESP_RETURN_ON_FALSE(af_config->edge_thresh > 0, ESP_ERR_INVALID_ARG, TAG, "edge threshold should be larger than 0"); diff --git a/components/hal/include/hal/isp_hal.h b/components/hal/include/hal/isp_hal.h index 9aacd179d8..c239fa4318 100644 --- a/components/hal/include/hal/isp_hal.h +++ b/components/hal/include/hal/isp_hal.h @@ -62,7 +62,7 @@ void isp_hal_init(isp_hal_context_t *hal, int isp_id); * @param[in] window_id Window ID * @param[in] window Window info, see `isp_af_window_t` */ -void isp_hal_af_window_config(const isp_hal_context_t *hal, int window_id, const isp_af_window_t *window); +void isp_hal_af_window_config(const isp_hal_context_t *hal, int window_id, const isp_window_t *window); /*--------------------------------------------------------------- INTR diff --git a/components/hal/include/hal/isp_types.h b/components/hal/include/hal/isp_types.h index baa74ea90d..2d02ae3cd8 100644 --- a/components/hal/include/hal/isp_types.h +++ b/components/hal/include/hal/isp_types.h @@ -23,6 +23,24 @@ typedef soc_periph_isp_clk_src_t isp_clk_src_t; ///< Clock source type of typedef int isp_clk_src_t; ///< Default type #endif +/** + * @brief ISP coordinate type + * + */ +typedef struct { + uint32_t x; ///< X coordinate of the point + uint32_t y; ///< Y coordinate of the point +} isp_coordinate_t; + +/** + * @brief ISP window type + * + */ +typedef struct { + isp_coordinate_t top_left; ///< The top left point coordinate + isp_coordinate_t btm_right; ///< The bottom right point coordinate +} isp_window_t; + /** * @brief ISP Input Source */ @@ -63,16 +81,6 @@ typedef enum { #define ISP_AF_WINDOW_NUM 0 #endif -/** - * @brief ISP AF window - */ -typedef struct { - uint32_t top_left_x; ///< Top left x axis value - uint32_t top_left_y; ///< Top left y axis value - uint32_t bottom_right_x; ///< Bottom right x axis value - uint32_t bottom_right_y; ///< Bottom right y axis value -} isp_af_window_t; - /** * @brief ISP AF result */ diff --git a/components/hal/isp_hal.c b/components/hal/isp_hal.c index 3bb3890693..16b496a3af 100644 --- a/components/hal/isp_hal.c +++ b/components/hal/isp_hal.c @@ -27,9 +27,9 @@ void isp_hal_init(isp_hal_context_t *hal, int isp_id) /*--------------------------------------------------------------- AF ---------------------------------------------------------------*/ -void isp_hal_af_window_config(const isp_hal_context_t *hal, int window_id, const isp_af_window_t *window) +void isp_hal_af_window_config(const isp_hal_context_t *hal, int window_id, const isp_window_t *window) { - isp_ll_af_set_window_range(hal->hw, window_id, window->top_left_x, window->top_left_y, window->bottom_right_x, window->bottom_right_y); + isp_ll_af_set_window_range(hal->hw, window_id, window->top_left.x, window->top_left.y, window->btm_right.x, window->btm_right.y); } /*--------------------------------------------------------------- diff --git a/examples/peripherals/isp/auto_focus/main/isp_af_dsi_main.c b/examples/peripherals/isp/auto_focus/main/isp_af_dsi_main.c index 0d8be2f9bb..d8f84c2b0c 100644 --- a/examples/peripherals/isp/auto_focus/main/isp_af_dsi_main.c +++ b/examples/peripherals/isp/auto_focus/main/isp_af_dsi_main.c @@ -99,22 +99,34 @@ static void af_task(void *arg) esp_isp_af_config_t af_config = { .window = { [0] = { - .top_left_x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) - 100, - .bottom_right_x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) + 99, - .top_left_y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) - 100, - .bottom_right_y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) + 99, + .top_left = { + .x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) - 100, + .y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) - 100, + }, + .btm_right = { + .x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) + 99, + .y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) + 99, + }, }, [1] = { - .top_left_x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) - 100, - .bottom_right_x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) + 99, - .top_left_y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) - 100, - .bottom_right_y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) + 99, + .top_left = { + .x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) - 100, + .y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) - 100, + }, + .btm_right = { + .x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) + 99, + .y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) + 99, + }, }, [2] = { - .top_left_x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) - 100, - .bottom_right_x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) + 99, - .top_left_y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) - 100, - .bottom_right_y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) + 99, + .top_left = { + .x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) - 100, + .y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) - 100, + }, + .btm_right = { + .x = (CONFIG_EXAMPLE_MIPI_CSI_DISP_HRES / 2) + 99, + .y = (CONFIG_EXAMPLE_MIPI_CSI_DISP_VRES / 2) + 99, + }, }, }, .edge_thresh = 128,