Merge branch 'change/merge_isp_env_into_isp_af' into 'master'

(isp): merge isp env into isp af

See merge request espressif/esp-idf!29946
This commit is contained in:
Armando (Dou Yiwen)
2024-04-01 16:05:44 +08:00
8 changed files with 68 additions and 261 deletions

View File

@@ -102,6 +102,33 @@ typedef struct {
int interval; ///< Interval between environment detection, in frames int interval; ///< Interval between environment detection, in frames
} esp_isp_af_env_config_t; } esp_isp_af_env_config_t;
/**
* @brief Set ISP AF environment detector
*
* @param[in] af_ctrlr AF controller handle
* @param[in] env_config AF Env detector configuration
*
* @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_af_controller_set_env_detector(isp_af_ctrlr_t af_ctrlr, const esp_isp_af_env_config_t *env_config);
/**
* @brief Set ISP AF environment detector detecting threshold
*
* @param[in] af_ctrlr AF controller handle
* @param[in] definition_thresh Threshold for definition
* @param[in] luminance_thresh Threshold for luminance
*
* @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_af_controller_set_env_detector_threshold(isp_af_ctrlr_t af_ctrlr, int definition_thresh, int luminance_thresh);
/** /**
* @brief Event data structure * @brief Event data structure
*/ */
@@ -112,13 +139,13 @@ typedef struct {
/** /**
* @brief Prototype of ISP AF Env detector event callback * @brief Prototype of ISP AF Env detector event callback
* *
* @param[in] handle ISP Env detector handle * @param[in] handle ISP AF controller handle
* @param[in] edata ISP AF Env detector event data * @param[in] edata ISP AF Env detector event data
* @param[in] user_data User registered context, registered when in `esp_isp_af_env_detector_register_event_callbacks()` * @param[in] user_data User registered context, registered when in `esp_isp_af_env_detector_register_event_callbacks()`
* *
* @return Whether a high priority task is woken up by this function * @return Whether a high priority task is woken up by this function
*/ */
typedef bool (*esp_isp_af_env_detector_callback_t)(isp_af_env_detr_t detector, const esp_isp_af_env_detector_evt_data_t *edata, void *user_data); typedef bool (*esp_isp_af_env_detector_callback_t)(isp_af_ctrlr_t af_ctrlr, const esp_isp_af_env_detector_evt_data_t *edata, void *user_data);
/** /**
* @brief Group of ISP AF Env detector callbacks * @brief Group of ISP AF Env detector callbacks
@@ -131,71 +158,6 @@ typedef struct {
esp_isp_af_env_detector_callback_t on_env_change; ///< Event callback, invoked when environment change happens. esp_isp_af_env_detector_callback_t on_env_change; ///< Event callback, invoked when environment change happens.
} esp_isp_af_env_detector_evt_cbs_t; } esp_isp_af_env_detector_evt_cbs_t;
/**
* @brief New an ISP AF environment detector
*
* @param[in] af_ctrlr AF controller handle
* @param[in] config Pointer to AF env detector config. Refer to ``esp_isp_af_env_config_t``.
* @param[out] ret_hdl AF env detector handle
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid
* - ESP_ERR_INVALID_STATE Invalid state
* - ESP_ERR_NO_MEM If out of memory
*/
esp_err_t esp_isp_new_af_env_detector(isp_af_ctrlr_t af_ctrlr, const esp_isp_af_env_config_t *config, isp_af_env_detr_t *ret_hdl);
/**
* @brief Delete an ISP AF environment detector
*
* @param[in] af_env_detector AF env detector 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_del_af_env_detector(isp_af_env_detr_t af_env_detector);
/**
* @brief Enable an ISP AF environment detector
*
* @param[in] af_env_detector AF env detector 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_af_env_detector_enable(isp_af_env_detr_t af_env_detector);
/**
* @brief Disable an ISP AF environment detector
*
* @param[in] af_env_detector AF env detector 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_af_env_detector_disable(isp_af_env_detr_t af_env_detector);
/**
* @brief Set ISP AF environment detector detecting threshold
*
* @param[in] af_env_detector AF env detector handle
* @param[in] definition_thresh Threshold for definition
* @param[in] luminance_thresh Threshold for luminance
*
* @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_af_env_detector_set_threshold(isp_af_env_detr_t af_env_detector, int definition_thresh, int luminance_thresh);
/** /**
* @brief Register AF environment detector event callbacks * @brief Register AF environment detector event callbacks
* *
@@ -204,7 +166,7 @@ esp_err_t esp_isp_af_env_detector_set_threshold(isp_af_env_detr_t af_env_detecto
* @note When CONFIG_ISP_ISR_IRAM_SAFE is enabled, the callback itself and functions called by it should be placed in IRAM. * @note When CONFIG_ISP_ISR_IRAM_SAFE is enabled, the callback itself and functions called by it should be placed in IRAM.
* Involved variables (including `user_data`) should be in internal RAM as well. * Involved variables (including `user_data`) should be in internal RAM as well.
* *
* @param[in] af_env_detector AF env detector handle * @param[in] af_ctrlr AF controller handle
* @param[in] cbs Group of callback functions * @param[in] cbs Group of callback functions
* @param[in] user_data User data, which will be delivered to the callback functions directly * @param[in] user_data User data, which will be delivered to the callback functions directly
* *
@@ -213,7 +175,7 @@ esp_err_t esp_isp_af_env_detector_set_threshold(isp_af_env_detr_t af_env_detecto
* - ESP_ERR_INVALID_ARG: Invalid arguments * - ESP_ERR_INVALID_ARG: Invalid arguments
* - ESP_ERR_INVALID_STATE: Driver state is invalid, you shouldn't call this API at this moment * - ESP_ERR_INVALID_STATE: Driver state is invalid, you shouldn't call this API at this moment
*/ */
esp_err_t esp_isp_af_env_detector_register_event_callbacks(isp_af_env_detr_t af_env_detector, const esp_isp_af_env_detector_evt_cbs_t *cbs, void *user_data); esp_err_t esp_isp_af_env_detector_register_event_callbacks(isp_af_ctrlr_t af_ctrlr, const esp_isp_af_env_detector_evt_cbs_t *cbs, void *user_data);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -22,11 +22,6 @@ typedef struct isp_processor_t *isp_proc_handle_t;
*/ */
typedef struct isp_af_controller_t *isp_af_ctrlr_t; typedef struct isp_af_controller_t *isp_af_ctrlr_t;
/**
* @brief Type of ISP AF Env detector handle
*/
typedef struct isp_af_env_detector_t *isp_af_env_detr_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -164,109 +164,23 @@ esp_err_t esp_isp_af_controller_get_oneshot_result(isp_af_ctrlr_t af_ctlr, isp_a
/*--------------------------------------------- /*---------------------------------------------
AF Env Monitor AF Env Monitor
----------------------------------------------*/ ----------------------------------------------*/
static esp_err_t s_isp_claim_af_env_detector(isp_af_ctrlr_t af_ctlr, isp_af_env_detector_t *af_env_detector) esp_err_t esp_isp_af_controller_set_env_detector(isp_af_ctrlr_t af_ctrlr, const esp_isp_af_env_config_t *env_config)
{ {
assert(af_ctlr && af_env_detector); ESP_RETURN_ON_FALSE(af_ctrlr && env_config, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer");
ESP_RETURN_ON_FALSE(af_ctrlr->fsm == ISP_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "invalid fsm, should be called when in init state");
bool found = false; af_ctrlr->config.interval = env_config->interval;
portENTER_CRITICAL(&af_ctlr->spinlock);
for (int i = 0; i < SOC_ISP_AF_ENV_DETECTOR_NUMS; i++) {
found = !af_ctlr->af_env_detector[i];
if (found) {
af_ctlr->af_env_detector[i] = af_env_detector;
af_env_detector->id = i;
break; isp_ll_af_env_monitor_set_period(af_ctrlr->isp_proc->hal.hw, 0);
} isp_ll_clear_intr(af_ctrlr->isp_proc->hal.hw, ISP_LL_EVENT_AF_ENV);
}
portEXIT_CRITICAL(&af_ctlr->spinlock);
if (!found) {
return ESP_ERR_NOT_FOUND;
}
return ESP_OK;
}
static esp_err_t s_isp_declaim_af_env_detector(isp_af_env_detector_t *af_env_detector)
{
assert(af_env_detector && af_env_detector->af_ctlr);
portENTER_CRITICAL(&af_env_detector->af_ctlr->spinlock);
af_env_detector->af_ctlr->af_env_detector[af_env_detector->id] = NULL;
portEXIT_CRITICAL(&af_env_detector->af_ctlr->spinlock);
return ESP_OK; return ESP_OK;
} }
esp_err_t esp_isp_new_af_env_detector(isp_af_ctrlr_t af_ctlr, const esp_isp_af_env_config_t *config, isp_af_env_detr_t *ret_hdl) esp_err_t esp_isp_af_env_detector_register_event_callbacks(isp_af_ctrlr_t af_ctrlr, const esp_isp_af_env_detector_evt_cbs_t *cbs, void *user_data)
{ {
esp_err_t ret = ESP_FAIL; ESP_RETURN_ON_FALSE(af_ctrlr && cbs, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
ESP_RETURN_ON_FALSE(af_ctlr && config && ret_hdl, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); ESP_RETURN_ON_FALSE(af_ctrlr->fsm == ISP_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "detector isn't in the init state");
isp_af_env_detector_t *af_env_detector = heap_caps_calloc(1, sizeof(isp_af_env_detector_t), ISP_AF_MEM_ALLOC_CAPS);
ESP_RETURN_ON_FALSE(af_env_detector, ESP_ERR_NO_MEM, TAG, "no mem");
//claim an AF Env detector
ESP_GOTO_ON_ERROR(s_isp_claim_af_env_detector(af_ctlr, af_env_detector), err, TAG, "no available env detector");
af_env_detector->fsm = ISP_FSM_INIT;
af_env_detector->config.interval = config->interval;
af_env_detector->spinlock = (portMUX_TYPE)portMUX_INITIALIZER_UNLOCKED;
af_env_detector->af_ctlr = af_ctlr;
isp_ll_af_env_monitor_set_period(af_ctlr->isp_proc->hal.hw, 0);
isp_ll_clear_intr(af_ctlr->isp_proc->hal.hw, ISP_LL_EVENT_AF_ENV);
*ret_hdl = af_env_detector;
return ESP_OK;
err:
free(af_env_detector);
return ret;
}
esp_err_t esp_isp_del_af_env_detector(isp_af_env_detr_t af_env_detector)
{
ESP_RETURN_ON_FALSE(af_env_detector && af_env_detector->af_ctlr, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer");
ESP_RETURN_ON_ERROR(s_isp_declaim_af_env_detector(af_env_detector), TAG, "detector isn't in use");
ESP_RETURN_ON_FALSE(af_env_detector->fsm == ISP_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "detector isn't in init state");
free(af_env_detector);
return ESP_OK;
}
esp_err_t esp_isp_af_env_detector_enable(isp_af_env_detr_t af_env_detector)
{
ESP_RETURN_ON_FALSE(af_env_detector && af_env_detector->af_ctlr, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer");
ESP_RETURN_ON_FALSE(af_env_detector->fsm == ISP_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "detector isn't in init state");
//try use ratio mode
isp_ll_af_env_monitor_set_mode(af_env_detector->af_ctlr->isp_proc->hal.hw, ISP_LL_AF_ENV_MONITOR_MODE_ABS);
isp_ll_af_env_monitor_set_period(af_env_detector->af_ctlr->isp_proc->hal.hw, af_env_detector->config.interval);
isp_ll_enable_intr(af_env_detector->af_ctlr->isp_proc->hal.hw, ISP_LL_EVENT_AF_ENV, true);
af_env_detector->fsm = ISP_FSM_ENABLE;
return ESP_OK;
}
esp_err_t esp_isp_af_env_detector_disable(isp_af_env_detr_t af_env_detector)
{
ESP_RETURN_ON_FALSE(af_env_detector && af_env_detector->af_ctlr, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer");
ESP_RETURN_ON_FALSE(af_env_detector->fsm == ISP_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "detector isn't in enable state");
isp_ll_af_env_monitor_set_period(af_env_detector->af_ctlr->isp_proc->hal.hw, 0);
af_env_detector->fsm = ISP_FSM_INIT;
return ESP_OK;
}
esp_err_t esp_isp_af_env_detector_register_event_callbacks(isp_af_env_detr_t af_env_detector, const esp_isp_af_env_detector_evt_cbs_t *cbs, void *user_data)
{
ESP_RETURN_ON_FALSE(af_env_detector && cbs, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
ESP_RETURN_ON_FALSE(af_env_detector->fsm == ISP_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "detector isn't in the init state");
#if CONFIG_ISP_ISR_IRAM_SAFE #if CONFIG_ISP_ISR_IRAM_SAFE
if (cbs->on_env_change) { if (cbs->on_env_change) {
@@ -274,20 +188,20 @@ esp_err_t esp_isp_af_env_detector_register_event_callbacks(isp_af_env_detr_t af_
} }
#endif #endif
ESP_RETURN_ON_ERROR(esp_isp_register_isr(af_env_detector->af_ctlr->isp_proc, ISP_SUBMODULE_AF), TAG, "fail to register ISR"); ESP_RETURN_ON_ERROR(esp_isp_register_isr(af_ctrlr->isp_proc, ISP_SUBMODULE_AF), TAG, "fail to register ISR");
af_env_detector->cbs.on_env_change = cbs->on_env_change; af_ctrlr->cbs.on_env_change = cbs->on_env_change;
af_env_detector->user_data = user_data; af_ctrlr->user_data = user_data;
return ESP_OK; return ESP_OK;
} }
esp_err_t esp_isp_af_env_detector_set_threshold(isp_af_env_detr_t af_env_detector, int definition_thresh, int luminance_thresh) esp_err_t esp_isp_af_env_detector_set_threshold(isp_af_ctrlr_t af_ctrlr, int definition_thresh, int luminance_thresh)
{ {
ESP_RETURN_ON_FALSE_ISR(af_env_detector, ESP_ERR_INVALID_ARG, TAG, "invalid argument"); ESP_RETURN_ON_FALSE_ISR(af_ctrlr, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
ESP_RETURN_ON_FALSE_ISR(af_env_detector->fsm == ISP_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "detector isn't in enable state"); ESP_RETURN_ON_FALSE_ISR(af_ctrlr->fsm == ISP_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "detector isn't in enable state");
isp_ll_af_env_monitor_set_thresh(af_env_detector->af_ctlr->isp_proc->hal.hw, definition_thresh, luminance_thresh); isp_ll_af_env_monitor_set_thresh(af_ctrlr->isp_proc->hal.hw, definition_thresh, luminance_thresh);
return ESP_OK; return ESP_OK;
} }
@@ -295,12 +209,12 @@ esp_err_t esp_isp_af_env_detector_set_threshold(isp_af_env_detr_t af_env_detecto
/*--------------------------------------------------------------- /*---------------------------------------------------------------
INTR INTR
---------------------------------------------------------------*/ ---------------------------------------------------------------*/
static bool IRAM_ATTR s_af_env_isr(isp_af_env_detector_t *detector) static bool IRAM_ATTR s_af_env_isr(isp_af_ctrlr_t af_ctrlr)
{ {
bool need_yield = false; bool need_yield = false;
esp_isp_af_env_detector_evt_data_t edata = {}; esp_isp_af_env_detector_evt_data_t edata = {};
if (detector->cbs.on_env_change(detector, &edata, detector->user_data)) { if (af_ctrlr->cbs.on_env_change(af_ctrlr, &edata, af_ctrlr->user_data)) {
need_yield |= true; need_yield |= true;
} }
@@ -321,9 +235,9 @@ bool IRAM_ATTR esp_isp_af_isr(isp_proc_handle_t proc, uint32_t af_events)
* Now only one detector. * Now only one detector.
* Should decide a detector instance according to the hw event. * Should decide a detector instance according to the hw event.
*/ */
isp_af_env_detector_t *detector = proc->af_ctlr[0]->af_env_detector[0]; isp_af_ctrlr_t af_ctrlr = proc->af_ctlr[0];
need_yield |= s_af_env_isr(detector); need_yield |= s_af_env_isr(af_ctrlr);
} }
return need_yield; return need_yield;

View File

@@ -37,26 +37,17 @@ typedef enum {
ISP_SUBMODULE_AF, ISP_SUBMODULE_AF,
} isp_submodule_t; } isp_submodule_t;
typedef struct isp_af_env_detector_t isp_af_env_detector_t;
typedef struct isp_af_controller_t isp_af_controller_t; typedef struct isp_af_controller_t isp_af_controller_t;
typedef struct isp_processor_t isp_processor_t; typedef struct isp_processor_t isp_processor_t;
struct isp_af_env_detector_t { struct isp_af_controller_t {
int id; int id;
isp_fsm_t fsm; isp_fsm_t fsm;
esp_isp_af_env_config_t config;
portMUX_TYPE spinlock; portMUX_TYPE spinlock;
isp_processor_t *isp_proc;
esp_isp_af_env_config_t config;
esp_isp_af_env_detector_evt_cbs_t cbs; esp_isp_af_env_detector_evt_cbs_t cbs;
void *user_data; void *user_data;
isp_af_controller_t *af_ctlr;
};
struct isp_af_controller_t {
int id;
isp_fsm_t fsm;
portMUX_TYPE spinlock;
isp_processor_t *isp_proc;
isp_af_env_detector_t *af_env_detector[SOC_ISP_AF_ENV_DETECTOR_NUMS];
}; };
struct isp_processor_t { struct isp_processor_t {

View File

@@ -57,37 +57,3 @@ TEST_CASE("ISP AF controller exhausted allocation", "[isp]")
} }
TEST_ESP_OK(esp_isp_del_processor(isp_proc)); TEST_ESP_OK(esp_isp_del_processor(isp_proc));
} }
TEST_CASE("ISP AF env detector exhausted allocation", "[isp]")
{
esp_isp_processor_cfg_t isp_config = {
.clk_hz = 80 * 1000 * 1000,
.input_data_source = ISP_INPUT_DATA_SOURCE_CSI,
.input_data_color_type = ISP_COLOR_RAW8,
.output_data_color_type = ISP_COLOR_RGB565,
};
isp_proc_handle_t isp_proc = NULL;
TEST_ESP_OK(esp_isp_new_processor(&isp_config, &isp_proc));
esp_isp_af_config_t af_config = {
.edge_thresh = 128,
};
isp_af_ctrlr_t af_ctrlr = NULL;
TEST_ESP_OK(esp_isp_new_af_controller(isp_proc, &af_config, &af_ctrlr));
esp_isp_af_env_config_t env_config = {
.interval = 10,
};
isp_af_env_detr_t env_detector[SOC_ISP_AF_ENV_DETECTOR_NUMS + 1] = {};
for (int i = 0; i < SOC_ISP_AF_ENV_DETECTOR_NUMS; i++) {
TEST_ESP_OK(esp_isp_new_af_env_detector(af_ctrlr, &env_config, &env_detector[i]));
}
TEST_ASSERT(esp_isp_new_af_env_detector(af_ctrlr, &env_config, &env_detector[SOC_ISP_AF_ENV_DETECTOR_NUMS]) == ESP_ERR_NOT_FOUND);
for (int i = 0; i < SOC_ISP_AF_ENV_DETECTOR_NUMS; i++) {
TEST_ESP_OK(esp_isp_del_af_env_detector(env_detector[i]));
}
TEST_ESP_OK(esp_isp_del_af_controller(af_ctrlr));
TEST_ESP_OK(esp_isp_del_processor(isp_proc));
}

View File

@@ -711,10 +711,6 @@ config SOC_ISP_AF_CTLR_NUMS
int int
default 1 default 1
config SOC_ISP_AF_ENV_DETECTOR_NUMS
int
default 1
config SOC_ISP_AF_WINDOW_NUMS config SOC_ISP_AF_WINDOW_NUMS
int int
default 3 default 3

View File

@@ -297,7 +297,6 @@
/*-------------------------- ISP CAPS ----------------------------------------*/ /*-------------------------- ISP CAPS ----------------------------------------*/
#define SOC_ISP_NUMS 1U #define SOC_ISP_NUMS 1U
#define SOC_ISP_AF_CTLR_NUMS 1U #define SOC_ISP_AF_CTLR_NUMS 1U
#define SOC_ISP_AF_ENV_DETECTOR_NUMS 1U
#define SOC_ISP_AF_WINDOW_NUMS 3 #define SOC_ISP_AF_WINDOW_NUMS 3
#define SOC_ISP_SHARE_CSI_BRG 1 #define SOC_ISP_SHARE_CSI_BRG 1

View File

@@ -75,22 +75,6 @@ If the configurations in :cpp:type:`esp_isp_af_config_t` is specified, users can
You can use the created handle to do driver enable / disable the ISP AF driver and ISP AF Env module installation. You can use the created handle to do driver enable / disable the ISP AF driver and ISP AF Env module installation.
Install Image Signal Processor (ISP) Auto-Focus (AF) Environment Detector Driver
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ISP auto-focus (AF) driver requires the configuration that specified by :cpp:type:`esp_isp_af_env_config_t`.
If the configurations in :cpp:type:`esp_isp_af_env_config_t` is specified, users can call :cpp:func:`esp_isp_new_af_env_detector` to allocate and initialize an ISP AF processor. This function will return an ISP AF environment detector handle if it runs correctly. You can take following code as reference.
.. code:: c
esp_isp_af_env_config_t env_config = {
.interval = 10,
};
isp_af_env_detr_t env_detector = NULL;
ESP_ERROR_CHECK(esp_isp_new_af_env_detector(af_ctrlr, &env_config, &env_detector[i]));
Uninstall Image Signal Processor (ISP) Driver Uninstall Image Signal Processor (ISP) Driver
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -101,11 +85,6 @@ UnInstall Image Signal Processor (ISP) Auto-Focus (AF) Driver
If a previously installed ISP AF processor is no longer needed, it's recommended to recycle the resource by calling :cpp:func:`esp_isp_del_af_controller`, so that to release the underlying hardware. If a previously installed ISP AF processor is no longer needed, it's recommended to recycle the resource by calling :cpp:func:`esp_isp_del_af_controller`, so that to release the underlying hardware.
Uninstall Image Signal Processor (ISP) Environment Decetor Driver
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If a previously installed ISP AF processor is no longer needed, it's recommended to recycle the resource by calling :cpp:func:`esp_isp_del_af_env_detector`, so that to release the underlying hardware.
.. _isp-enable-disable: .. _isp-enable-disable:
@@ -130,15 +109,6 @@ Before doing ISP AF, you need to enable the ISP AF processor first, by calling :
Calling :cpp:func:`esp_isp_af_controller_disable` does the opposite, that is, put the driver back to the **init** state. Calling :cpp:func:`esp_isp_af_controller_disable` does the opposite, that is, put the driver back to the **init** state.
Image Signal Processor (ISP) Auto-Focus (AF) Environment Detector
-----------------------------------------------------------------
Before starting ISP environment detector, you need to enable the ISP AF environment detector first, by calling :cpp:func:`esp_isp_af_env_detector_enable`. This function:
* Switches the driver state from **init** to **enable**.
Calling :cpp:func:`esp_isp_af_env_detector_disable` does the opposite, that is, put the driver back to the **init** state.
.. _isp-af-get-oneshot-result: .. _isp-af-get-oneshot-result:
Get Auto-Focus (AF) Oneshot Result Get Auto-Focus (AF) Oneshot Result
@@ -156,6 +126,20 @@ Calling :cpp:func:`esp_isp_af_controller_get_oneshot_result` to get oneshot AF r
isp_af_result_t result = {}; isp_af_result_t result = {};
ESP_ERROR_CHECK(esp_isp_af_controller_get_oneshot_result(ctx->af_ctlr, &result)); ESP_ERROR_CHECK(esp_isp_af_controller_get_oneshot_result(ctx->af_ctlr, &result));
Set Auto-Focus (AF) Environment Detector
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Calling :cpp:func:`esp_isp_af_controller_set_env_detector` to set an ISP AF environment detector. You can take following code as reference.
.. code:: c
esp_isp_af_env_config_t env_config = {
.interval = 10,
};
isp_af_ctrlr_t af_ctrlr = NULL;
ESP_ERROR_CHECK(esp_isp_new_af_controller(isp_proc, &af_config, &af_ctrlr));
ESP_ERROR_CHECK(esp_isp_af_controller_set_env_detector(af_ctrlr, &env_config));
Set Auto-Focus (AF) Environment Detector Threshold Set Auto-Focus (AF) Environment Detector Threshold
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^