mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix(isp): fixed awb subwindow always need to be set issue
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -74,46 +74,48 @@ static esp_err_t s_esp_isp_awb_config_hardware(isp_proc_handle_t isp_proc, const
|
||||
ESP_RETURN_ON_FALSE(isp_hal_awb_set_window_range(&isp_proc->hal, &awb_cfg->window),
|
||||
ESP_ERR_INVALID_ARG, TAG, "invalid window range");
|
||||
|
||||
bool subwindow_is_zero = awb_cfg->subwindow.top_left.x == 0 &&
|
||||
awb_cfg->subwindow.top_left.y == 0 &&
|
||||
awb_cfg->subwindow.btm_right.x == 0 &&
|
||||
awb_cfg->subwindow.btm_right.y == 0;
|
||||
// Subwindow feature is only supported on REV >= 3.0
|
||||
if (efuse_hal_chip_revision() < 300) {
|
||||
bool subwindow_is_zero = awb_cfg->subwindow.top_left.x == 0 &&
|
||||
awb_cfg->subwindow.top_left.y == 0 &&
|
||||
awb_cfg->subwindow.btm_right.x == 0 &&
|
||||
awb_cfg->subwindow.btm_right.y == 0;
|
||||
if (!subwindow_is_zero) {
|
||||
ESP_LOGW(TAG, "Subwindow feature is not supported on REV < 3.0, subwindow will not be configured");
|
||||
}
|
||||
} else {
|
||||
// Subwindow is just checked and configured on REV >= 3.0
|
||||
isp_window_t subwindow = awb_cfg->subwindow;
|
||||
ESP_RETURN_ON_FALSE(
|
||||
(subwindow.top_left.x >= awb_cfg->window.top_left.x) &&
|
||||
(subwindow.top_left.y >= awb_cfg->window.top_left.y) &&
|
||||
(subwindow.btm_right.x <= awb_cfg->window.btm_right.x) &&
|
||||
(subwindow.btm_right.y <= awb_cfg->window.btm_right.y),
|
||||
ESP_ERR_INVALID_ARG, TAG, "subwindow exceeds window range"
|
||||
);
|
||||
if (!subwindow_is_zero) {
|
||||
// Subwindow is just checked and configured on REV >= 3.0
|
||||
isp_window_t subwindow = awb_cfg->subwindow;
|
||||
ESP_RETURN_ON_FALSE(
|
||||
(subwindow.top_left.x >= awb_cfg->window.top_left.x) &&
|
||||
(subwindow.top_left.y >= awb_cfg->window.top_left.y) &&
|
||||
(subwindow.btm_right.x <= awb_cfg->window.btm_right.x) &&
|
||||
(subwindow.btm_right.y <= awb_cfg->window.btm_right.y),
|
||||
ESP_ERR_INVALID_ARG, TAG, "subwindow exceeds window range"
|
||||
);
|
||||
|
||||
if ((subwindow.btm_right.x - subwindow.top_left.x + 1) / ISP_AWB_WINDOW_X_NUM < 4 ||
|
||||
(subwindow.btm_right.y - subwindow.top_left.y + 1) / ISP_AWB_WINDOW_Y_NUM < 4) {
|
||||
ESP_LOGE(TAG, "subwindow block size is too small: width and height must be at least 4 (got %d x %d)",
|
||||
(subwindow.btm_right.x - subwindow.top_left.x + 1) / ISP_AWB_WINDOW_X_NUM,
|
||||
(subwindow.btm_right.y - subwindow.top_left.y + 1) / ISP_AWB_WINDOW_Y_NUM);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if ((subwindow.btm_right.x - subwindow.top_left.x + 1) / ISP_AWB_WINDOW_X_NUM < 4 ||
|
||||
(subwindow.btm_right.y - subwindow.top_left.y + 1) / ISP_AWB_WINDOW_Y_NUM < 4) {
|
||||
ESP_LOGE(TAG, "subwindow block size is too small: width and height must be at least 4 (got %d x %d)",
|
||||
(subwindow.btm_right.x - subwindow.top_left.x + 1) / ISP_AWB_WINDOW_X_NUM,
|
||||
(subwindow.btm_right.y - subwindow.top_left.y + 1) / ISP_AWB_WINDOW_Y_NUM);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
int size_x = subwindow.btm_right.x - subwindow.top_left.x + 1;
|
||||
int size_y = subwindow.btm_right.y - subwindow.top_left.y + 1;
|
||||
if ((size_x % ISP_AWB_WINDOW_X_NUM != 0) || (size_y % ISP_AWB_WINDOW_Y_NUM != 0)) {
|
||||
ESP_LOGW(TAG, "subwindow size (%d x %d) is not divisible by AWB subwindow blocks grid (%d x %d). \
|
||||
Resolution will be floored to the nearest divisible value.",
|
||||
size_x, size_y, ISP_AWB_WINDOW_X_NUM, ISP_AWB_WINDOW_Y_NUM);
|
||||
// floor to the nearest divisible value
|
||||
subwindow.btm_right.x -= size_x % ISP_AWB_WINDOW_X_NUM;
|
||||
subwindow.btm_right.y -= size_y % ISP_AWB_WINDOW_Y_NUM;
|
||||
int size_x = subwindow.btm_right.x - subwindow.top_left.x + 1;
|
||||
int size_y = subwindow.btm_right.y - subwindow.top_left.y + 1;
|
||||
if ((size_x % ISP_AWB_WINDOW_X_NUM != 0) || (size_y % ISP_AWB_WINDOW_Y_NUM != 0)) {
|
||||
ESP_LOGW(TAG, "subwindow size (%d x %d) is not divisible by AWB subwindow blocks grid (%d x %d). \
|
||||
Resolution will be floored to the nearest divisible value.",
|
||||
size_x, size_y, ISP_AWB_WINDOW_X_NUM, ISP_AWB_WINDOW_Y_NUM);
|
||||
// floor to the nearest divisible value
|
||||
subwindow.btm_right.x -= size_x % ISP_AWB_WINDOW_X_NUM;
|
||||
subwindow.btm_right.y -= size_y % ISP_AWB_WINDOW_Y_NUM;
|
||||
}
|
||||
ESP_RETURN_ON_FALSE(isp_hal_awb_set_subwindow_range(&isp_proc->hal, &subwindow),
|
||||
ESP_ERR_INVALID_ARG, TAG, "invalid subwindow range");
|
||||
}
|
||||
ESP_RETURN_ON_FALSE(isp_hal_awb_set_subwindow_range(&isp_proc->hal, &subwindow),
|
||||
ESP_ERR_INVALID_ARG, TAG, "invalid subwindow range");
|
||||
}
|
||||
|
||||
isp_u32_range_t lum_range = awb_cfg->white_patch.luminance;
|
||||
|
||||
Reference in New Issue
Block a user