feat(isp): fix potentiual AF/AE/AWB continuous and oneshot conflict and add test

This commit is contained in:
gaoxu
2024-08-02 16:52:35 +08:00
parent 3e974bd8a3
commit e3a717fd15
4 changed files with 182 additions and 112 deletions

View File

@@ -9,6 +9,10 @@
#include "driver/isp.h"
#include "soc/soc_caps.h"
/*---------------------------------------------------------------
ISP
---------------------------------------------------------------*/
TEST_CASE("ISP processor exhausted allocation", "[isp]")
{
esp_isp_processor_cfg_t isp_config = {
@@ -30,6 +34,75 @@ TEST_CASE("ISP processor exhausted allocation", "[isp]")
}
}
/*---------------------------------------------------------------
AF
---------------------------------------------------------------*/
static bool test_isp_af_default_on_statistics_done_cb(isp_af_ctlr_t af_ctlr, const esp_isp_af_env_detector_evt_data_t *edata, void *user_data)
{
(void) af_ctlr;
(void) edata;
(void) user_data;
// Do nothing
return false;
}
static bool test_isp_af_default_on_continuous_done_cb(isp_af_ctlr_t af_ctlr, const esp_isp_af_env_detector_evt_data_t *edata, void *user_data)
{
(void) af_ctlr;
(void) edata;
(void) user_data;
// Do nothing
return false;
}
TEST_CASE("ISP AF driver oneshot vs continuous test", "[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));
TEST_ESP_OK(esp_isp_enable(isp_proc));
esp_isp_af_config_t af_config = {
.edge_thresh = 128,
};
isp_af_ctlr_t af_ctlr = NULL;
isp_af_result_t af_res = {};
/* Create the af controller */
TEST_ESP_OK(esp_isp_new_af_controller(isp_proc, &af_config, &af_ctlr));
/* Register af callback */
esp_isp_af_env_detector_evt_cbs_t af_cb = {
.on_env_statistics_done = test_isp_af_default_on_statistics_done_cb,
.on_env_change = test_isp_af_default_on_continuous_done_cb,
};
TEST_ESP_OK(esp_isp_af_env_detector_register_event_callbacks(af_ctlr, &af_cb, NULL));
/* Enabled the af controller */
TEST_ESP_OK(esp_isp_af_controller_enable(af_ctlr));
/* Start continuous af statistics */
TEST_ESP_OK(esp_isp_af_controller_start_continuous_statistics(af_ctlr));
/* Test do oneshot mode when continuous mode start, should return error */
TEST_ESP_ERR(ESP_ERR_INVALID_STATE, esp_isp_af_controller_get_oneshot_statistics(af_ctlr, 0, &af_res));
/* Stop continuous af statistics */
TEST_ESP_OK(esp_isp_af_controller_stop_continuous_statistics(af_ctlr));
TEST_ESP_ERR(ESP_ERR_TIMEOUT, esp_isp_af_controller_get_oneshot_statistics(af_ctlr, 1, &af_res));
/* Disable the af controller */
TEST_ESP_OK(esp_isp_af_controller_disable(af_ctlr));
/* Delete the af controller and free the resources */
TEST_ESP_OK(esp_isp_del_af_controller(af_ctlr));
TEST_ESP_OK(esp_isp_disable(isp_proc));
TEST_ESP_OK(esp_isp_del_processor(isp_proc));
}
TEST_CASE("ISP AF controller exhausted allocation", "[isp]")
{
esp_isp_processor_cfg_t isp_config = {
@@ -57,6 +130,10 @@ TEST_CASE("ISP AF controller exhausted allocation", "[isp]")
TEST_ESP_OK(esp_isp_del_processor(isp_proc));
}
/*---------------------------------------------------------------
AWB
---------------------------------------------------------------*/
static bool test_isp_awb_default_on_statistics_done_cb(isp_awb_ctlr_t awb_ctlr, const esp_isp_awb_evt_data_t *edata, void *user_data)
{
(void) awb_ctlr;
@@ -66,7 +143,7 @@ static bool test_isp_awb_default_on_statistics_done_cb(isp_awb_ctlr_t awb_ctlr,
return false;
}
TEST_CASE("ISP AWB driver basic function", "[isp]")
TEST_CASE("ISP AWB driver oneshot vs continuous test", "[isp]")
{
esp_isp_processor_cfg_t isp_config = {
.clk_hz = 80 * 1000 * 1000,
@@ -154,6 +231,10 @@ TEST_CASE("ISP CCM basic function", "[isp]")
TEST_ESP_OK(esp_isp_del_processor(isp_proc));
}
/*---------------------------------------------------------------
AE
---------------------------------------------------------------*/
static bool test_isp_ae_default_on_statistics_done_cb(isp_ae_ctlr_t ae_ctlr, const esp_isp_ae_env_detector_evt_data_t *edata, void *user_data)
{
(void) ae_ctlr;
@@ -172,7 +253,7 @@ static bool test_isp_ae_default_on_continuous_done_cb(isp_ae_ctlr_t ae_ctlr, con
return false;
}
TEST_CASE("ISP AE driver basic function", "[isp]")
TEST_CASE("ISP AE driver oneshot vs continuous test", "[isp]")
{
esp_isp_processor_cfg_t isp_config = {
.clk_hz = 80 * 1000 * 1000,
@@ -202,6 +283,8 @@ TEST_CASE("ISP AE driver basic function", "[isp]")
TEST_ESP_OK(esp_isp_ae_controller_enable(ae_ctlr));
/* Start continuous AE statistics */
TEST_ESP_OK(esp_isp_ae_controller_start_continuous_statistics(ae_ctlr));
/* Test do oneshot mode when continuous mode start, should return error */
TEST_ESP_ERR(ESP_ERR_INVALID_STATE, esp_isp_ae_controller_get_oneshot_statistics(ae_ctlr, 0, &ae_res));
/* Stop continuous AE statistics */