-
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 'feature/support_isp_ccm' into 'master'
feat(isp_ccm): support isp color correction matrix Closes IDF-10080 See merge request espressif/esp-idf!31244
- Loading branch information
Showing
15 changed files
with
295 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ | |
#include "driver/isp_af.h" | ||
#include "driver/isp_awb.h" | ||
#include "driver/isp_bf.h" | ||
#include "driver/isp_ccm.h" |
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,70 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
#include "esp_err.h" | ||
#include "driver/isp_types.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Color Correction Matrix configurations | ||
* | ||
*/ | ||
typedef struct { | ||
float matrix[ISP_CCM_DIMENSION][ISP_CCM_DIMENSION]; /*!< The color correction matrix in float, range (-4.0, 4.0) */ | ||
bool saturation; /*!< Whether to use saturation when the float data in the matrix is out of the range, | ||
* For example, if one of the matrix data is 5.0, | ||
* When saturation is true, and final value will be limited to 4.0, and won't rise error | ||
* When saturation is false, `esp_isp_ccm_configure` will rise ESP_ERR_INVALID_ARG error | ||
*/ | ||
} esp_isp_ccm_config_t; | ||
|
||
/** | ||
* @brief ISP Color Correction Matrix (CCM) configuration | ||
* | ||
* @note This function is allowed to be called before or after `esp_isp_ccm_enable`, | ||
* but it only takes effect until `esp_isp_ccm_enable` is called | ||
* | ||
* @param[in] proc Processor handle | ||
* @param[in] ccm_cfg CCM configurations, set NULL to de-configure the ISP CCM | ||
* | ||
* @return | ||
* - ESP_OK On success | ||
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid | ||
*/ | ||
esp_err_t esp_isp_ccm_configure(isp_proc_handle_t proc, const esp_isp_ccm_config_t *ccm_cfg); | ||
|
||
/** | ||
* @brief Enable ISP CCM function | ||
* | ||
* @param[in] proc Processor handle | ||
* | ||
* @return | ||
* - ESP_OK On success | ||
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid. | ||
*/ | ||
esp_err_t esp_isp_ccm_enable(isp_proc_handle_t proc); | ||
|
||
/** | ||
* @brief Disable ISP CCM function | ||
* | ||
* @param[in] proc Processor handle | ||
* | ||
* @return | ||
* - ESP_OK On success | ||
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid. | ||
*/ | ||
esp_err_t esp_isp_ccm_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <esp_types.h> | ||
#include "esp_log.h" | ||
#include "esp_check.h" | ||
#include "freertos/FreeRTOS.h" | ||
#include "driver/isp_core.h" | ||
#include "driver/isp_ccm.h" | ||
#include "esp_private/isp_private.h" | ||
|
||
static const char *TAG = "ISP_CCM"; | ||
|
||
/*--------------------------------------------------------------- | ||
CCM | ||
---------------------------------------------------------------*/ | ||
esp_err_t esp_isp_ccm_configure(isp_proc_handle_t proc, const esp_isp_ccm_config_t *ccm_cfg) | ||
{ | ||
ESP_RETURN_ON_FALSE(proc && ccm_cfg, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); | ||
|
||
bool ret = true; | ||
portENTER_CRITICAL(&proc->spinlock); | ||
ret = isp_hal_ccm_set_matrix(&proc->hal, ccm_cfg->saturation, ccm_cfg->matrix); | ||
portEXIT_CRITICAL(&proc->spinlock); | ||
ESP_RETURN_ON_FALSE(ret, ESP_ERR_INVALID_ARG, TAG, "invalid argument: ccm matrix contain NaN or out of range"); | ||
|
||
return ESP_OK; | ||
} | ||
|
||
esp_err_t esp_isp_ccm_enable(isp_proc_handle_t proc) | ||
{ | ||
ESP_RETURN_ON_FALSE(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); | ||
|
||
portENTER_CRITICAL(&proc->spinlock); | ||
isp_ll_ccm_clk_enable(proc->hal.hw, true); | ||
isp_ll_ccm_enable(proc->hal.hw, true); | ||
portEXIT_CRITICAL(&proc->spinlock); | ||
|
||
return ESP_OK; | ||
} | ||
|
||
esp_err_t esp_isp_ccm_disable(isp_proc_handle_t proc) | ||
{ | ||
ESP_RETURN_ON_FALSE(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); | ||
|
||
portENTER_CRITICAL(&proc->spinlock); | ||
isp_ll_ccm_enable(proc->hal.hw, false); | ||
isp_ll_ccm_clk_enable(proc->hal.hw, false); | ||
portEXIT_CRITICAL(&proc->spinlock); | ||
|
||
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
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
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.