-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/isp_demosaic' into 'master'
isp: demosaic Closes IDF-10519 See merge request espressif/esp-idf!33111
- Loading branch information
Showing
16 changed files
with
409 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include "esp_err.h" | ||
#include "driver/isp_types.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief ISP Demosaic configurations | ||
*/ | ||
typedef struct { | ||
isp_demosaic_grad_ratio_t grad_ratio; /**< Demosaic gradient ratio, | ||
- gradient_x * grad_ratio < gradient_y, use interpolation results in X direction | ||
- gradient_y * grad_ratio < gradient_x, use interpolation results in Y direction | ||
- else use the average results between X and Y | ||
*/ | ||
isp_demosaic_edge_padding_mode_t padding_mode; ///< Demosaic edge padding mode | ||
uint8_t padding_data; ///< Demosaic edge padding pixel data | ||
uint8_t padding_line_tail_valid_start_pixel; ///< Demosaic edge padding line tail valid start pixel, padding data will only be valid between the valid start pixel and the valid end pixel. Set both the start and end pixel to 0 to make all padding pixel valid | ||
uint8_t padding_line_tail_valid_end_pixel; ///< Demosaic edge padding line tail valid end pixel, padding data will only be valid between the valid start pixel and the valid end pixel. Set both the start and end pixel to 0 to make all padding pixel valid | ||
} esp_isp_demosaic_config_t; | ||
|
||
/** | ||
* @brief ISP Demosaic configuration | ||
* | ||
* @note After calling this API, Demosaic doesn't take into effect until `esp_isp_demosaic_enable` is called | ||
* | ||
* @param[in] proc Processor handle | ||
* @param[in] config Demosaic configurations, set NULL to de-configure the ISP Demosaic | ||
* | ||
* @return | ||
* - ESP_OK On success | ||
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid | ||
*/ | ||
esp_err_t esp_isp_demosaic_configure(isp_proc_handle_t proc, const esp_isp_demosaic_config_t *config); | ||
|
||
/** | ||
* @brief Enable ISP Demosaic function | ||
* | ||
* @param[in] proc Processor handle | ||
* | ||
* @return | ||
* - ESP_OK On success | ||
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid. | ||
* - ESP_ERR_INVALID_STATE Driver state is invalid. | ||
*/ | ||
esp_err_t esp_isp_demosaic_enable(isp_proc_handle_t proc); | ||
|
||
/** | ||
* @brief Disable ISP Demosaic function | ||
* | ||
* @param[in] proc Processor handle | ||
* | ||
* @return | ||
* - ESP_OK On success | ||
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid. | ||
* - ESP_ERR_INVALID_STATE Driver state is invalid. | ||
*/ | ||
esp_err_t esp_isp_demosaic_disable(isp_proc_handle_t proc); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <esp_types.h> | ||
#include <sys/lock.h> | ||
#include "sdkconfig.h" | ||
#include "esp_log.h" | ||
#include "esp_check.h" | ||
#include "freertos/FreeRTOS.h" | ||
#include "driver/isp_core.h" | ||
#include "driver/isp_demosaic.h" | ||
#include "soc/isp_periph.h" | ||
#include "esp_private/isp_private.h" | ||
|
||
static const char *TAG = "ISP_DEMOSAIC"; | ||
|
||
/*--------------------------------------------------------------- | ||
Demosaic | ||
---------------------------------------------------------------*/ | ||
esp_err_t esp_isp_demosaic_configure(isp_proc_handle_t proc, const esp_isp_demosaic_config_t *config) | ||
{ | ||
ESP_RETURN_ON_FALSE_ISR(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); | ||
|
||
if (config) { | ||
bool valid_padding_setting = (!config->padding_line_tail_valid_end_pixel && !config->padding_line_tail_valid_start_pixel) || (config->padding_line_tail_valid_end_pixel > config->padding_line_tail_valid_start_pixel); | ||
ESP_RETURN_ON_FALSE_ISR(valid_padding_setting, ESP_ERR_INVALID_ARG, TAG, "wrong padding line tail valid pixel setting"); | ||
|
||
isp_hal_demosaic_cfg_t demosaic_hal_cfg = { | ||
.grad_ratio = config->grad_ratio, | ||
.padding_mode = config->padding_mode, | ||
.padding_data = config->padding_data, | ||
.padding_line_tail_valid_start_pixel = config->padding_line_tail_valid_start_pixel, | ||
.padding_line_tail_valid_end_pixel = config->padding_line_tail_valid_end_pixel, | ||
}; | ||
isp_hal_demosaic_config(&(proc->hal), &demosaic_hal_cfg); | ||
} else { | ||
isp_hal_demosaic_config(&(proc->hal), NULL); | ||
} | ||
|
||
return ESP_OK; | ||
} | ||
|
||
esp_err_t esp_isp_demosaic_enable(isp_proc_handle_t proc) | ||
{ | ||
ESP_RETURN_ON_FALSE(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); | ||
ESP_RETURN_ON_FALSE(proc->demosaic_fsm == ISP_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "demosaic is enabled already"); | ||
|
||
isp_ll_demosaic_enable(proc->hal.hw, true); | ||
proc->demosaic_fsm = ISP_FSM_ENABLE; | ||
|
||
return ESP_OK; | ||
} | ||
|
||
esp_err_t esp_isp_demosaic_disable(isp_proc_handle_t proc) | ||
{ | ||
ESP_RETURN_ON_FALSE(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); | ||
ESP_RETURN_ON_FALSE(proc->demosaic_fsm == ISP_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "demosaic isn't enabled yet"); | ||
|
||
isp_ll_demosaic_enable(proc->hal.hw, false); | ||
proc->demosaic_fsm = ISP_FSM_INIT; | ||
|
||
return ESP_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.