feat(isp_color): support ISP color on P4
This commit is contained in:
@@ -30,6 +30,10 @@ if(CONFIG_SOC_ISP_SHARPEN_SUPPORTED)
|
||||
list(APPEND srcs "src/isp_sharpen.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_ISP_COLOR_SUPPORTED)
|
||||
list(APPEND srcs "src/isp_color.c")
|
||||
endif()
|
||||
|
||||
if(NOT ${target} STREQUAL "linux")
|
||||
list(APPEND requires esp_mm)
|
||||
endif()
|
||||
|
||||
@@ -21,3 +21,4 @@
|
||||
#include "driver/isp_gamma.h"
|
||||
#include "driver/isp_hist.h"
|
||||
#include "driver/isp_sharpen.h"
|
||||
#include "driver/isp_color.h"
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 color configurations
|
||||
*/
|
||||
typedef struct {
|
||||
isp_color_contrast_t color_contrast; /*!< The color contrast value, defines the contrast level of the image,
|
||||
* which controls the difference in luminance between the lightest and darkest parts of the image
|
||||
* Range 0 ~ 1, decimal value should be 0~127, default 1
|
||||
*/
|
||||
isp_color_saturation_t color_saturation; /*!< The color saturation value, controls the intensity of colors in the image,
|
||||
* affecting how vivid or muted the colors appear.
|
||||
* Range 0 ~ 1, decimal value should be 0~127, default 1
|
||||
*/
|
||||
uint32_t color_hue; /*!< The color hue value, based on the color wheel.
|
||||
* 0 degrees represents red, 120 degrees represents green, and 240 degrees represents blue. 360 degrees overlaps with 0 degrees
|
||||
* Range 0 ~ 360, default 0.
|
||||
*/
|
||||
int color_brightness; /*!< The color brightness value.
|
||||
* Range -128 ~ 127, default 0.
|
||||
* Negative range (-128 to -1): Decreases brightness, the smaller the value, the darker the image.
|
||||
* Zero (0): Maintains the original brightness, without adjusting the image's brightness.
|
||||
* Positive range (1 to 127): Increases brightness, the larger the value, the brighter the image.
|
||||
*/
|
||||
} esp_isp_color_config_t;
|
||||
|
||||
/**
|
||||
* @brief ISP Color configuration
|
||||
*
|
||||
* @note After calling this API, Color doesn't take into effect until `esp_isp_color_enable` is called
|
||||
* @note API is ISR available
|
||||
*
|
||||
* @param[in] proc Processor handle
|
||||
* @param[in] config Color configurations, set NULL to de-configure the ISP Color
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK On success
|
||||
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid
|
||||
*/
|
||||
esp_err_t esp_isp_color_configure(isp_proc_handle_t proc, const esp_isp_color_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Enable ISP color 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_color_enable(isp_proc_handle_t proc);
|
||||
|
||||
/**
|
||||
* @brief Disable ISP color 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_color_disable(isp_proc_handle_t proc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -72,6 +72,7 @@ typedef struct isp_processor_t {
|
||||
isp_fsm_t bf_fsm;
|
||||
isp_fsm_t demosaic_fsm;
|
||||
isp_fsm_t sharpen_fsm;
|
||||
isp_fsm_t color_fsm;
|
||||
esp_isp_evt_cbs_t cbs;
|
||||
void *user_data;
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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_color.h"
|
||||
#include "soc/isp_periph.h"
|
||||
#include "esp_private/isp_private.h"
|
||||
|
||||
static const char *TAG = "ISP_COLOR";
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Color
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
esp_err_t esp_isp_color_configure(isp_proc_handle_t proc, const esp_isp_color_config_t *config)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE_ISR(proc, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer");
|
||||
|
||||
if (config) {
|
||||
ESP_RETURN_ON_FALSE_ISR(((config->color_contrast.val <= ISP_LL_COLOR_CONTRAST_MAX) &&
|
||||
(config->color_saturation.val <= ISP_LL_COLOR_SATURATION_MAX) &&
|
||||
(config->color_hue <= ISP_LL_COLOR_HUE_MAX) &&
|
||||
(config->color_brightness >= ISP_LL_COLOR_BRIGNTNESS_MIN) &&
|
||||
(config->color_brightness <= ISP_LL_COLOR_BRIGNTNESS_MAX)), ESP_ERR_INVALID_ARG, TAG, "invalid color config");
|
||||
isp_hal_color_cfg_t color_hal_cfg = {
|
||||
.color_contrast = config->color_contrast,
|
||||
.color_saturation = config->color_saturation,
|
||||
.color_hue = config->color_hue,
|
||||
.color_brightness = config->color_brightness,
|
||||
};
|
||||
isp_hal_color_config(&(proc->hal), &color_hal_cfg);
|
||||
} else {
|
||||
isp_hal_color_config(&(proc->hal), NULL);
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_isp_color_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->color_fsm == ISP_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "color is enabled already");
|
||||
|
||||
isp_ll_color_clk_enable(proc->hal.hw, true);
|
||||
isp_ll_color_enable(proc->hal.hw, true);
|
||||
proc->color_fsm = ISP_FSM_ENABLE;
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_isp_color_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->color_fsm == ISP_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "color isn't enabled yet");
|
||||
|
||||
isp_ll_color_enable(proc->hal.hw, false);
|
||||
isp_ll_color_clk_enable(proc->hal.hw, false);
|
||||
proc->color_fsm = ISP_FSM_INIT;
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
Reference in New Issue
Block a user