feat(isp_ae): add isp auto exposure driver test

This commit is contained in:
gaoxu 2024-07-08 09:58:18 +08:00
parent 3c0fe579b6
commit cb6ecc470c

View File

@ -153,3 +153,94 @@ TEST_CASE("ISP CCM basic function", "[isp]")
TEST_ESP_OK(esp_isp_disable(isp_proc));
TEST_ESP_OK(esp_isp_del_processor(isp_proc));
}
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;
(void) edata;
(void) user_data;
// Do nothing
return false;
}
static bool test_isp_ae_default_on_continuous_done_cb(isp_ae_ctlr_t ae_ctlr, const esp_isp_ae_env_detector_evt_data_t *edata, void *user_data)
{
(void) ae_ctlr;
(void) edata;
(void) user_data;
// Do nothing
return false;
}
TEST_CASE("ISP AE driver basic function", "[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));
isp_ae_ctlr_t ae_ctlr = NULL;
/* Default parameters from helper macro */
esp_isp_ae_config_t ae_config = {
.ae_sample_point = ISP_AE_SAMPLE_POINT_AFTER_DEMOSAIC,
};
isp_ae_result_t ae_res = {};
/* Create the ae controller */
TEST_ESP_OK(esp_isp_new_ae_controller(isp_proc, &ae_config, &ae_ctlr));
/* Register AE callback */
esp_isp_ae_env_detector_evt_cbs_t ae_cb = {
.on_env_statistics_done = test_isp_ae_default_on_statistics_done_cb,
.on_env_change = test_isp_ae_default_on_continuous_done_cb,
};
TEST_ESP_OK(esp_isp_ae_env_detector_register_event_callbacks(ae_ctlr, &ae_cb, NULL));
/* Enabled the ae controller */
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_ESP_ERR(ESP_ERR_INVALID_STATE, esp_isp_ae_controller_get_oneshot_statistics(ae_ctlr, 0, &ae_res));
/* Stop continuous AE statistics */
TEST_ESP_OK(esp_isp_ae_controller_stop_continuous_statistics(ae_ctlr));
TEST_ESP_ERR(ESP_ERR_TIMEOUT, esp_isp_ae_controller_get_oneshot_statistics(ae_ctlr, 1, &ae_res));
/* Disable the ae controller */
TEST_ESP_OK(esp_isp_ae_controller_disable(ae_ctlr));
/* Delete the ae controller and free the resources */
TEST_ESP_OK(esp_isp_del_ae_controller(ae_ctlr));
TEST_ESP_OK(esp_isp_disable(isp_proc));
TEST_ESP_OK(esp_isp_del_processor(isp_proc));
}
TEST_CASE("ISP AE controller 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_ae_config_t ae_config = {
.ae_sample_point = ISP_AE_SAMPLE_POINT_AFTER_DEMOSAIC,
};
isp_ae_ctlr_t ae_ctrlr[SOC_ISP_AE_CTLR_NUMS + 1] = {};
for (int i = 0; i < SOC_ISP_AE_CTLR_NUMS; i++) {
TEST_ESP_OK(esp_isp_new_ae_controller(isp_proc, &ae_config, &ae_ctrlr[i]));
}
TEST_ASSERT(esp_isp_new_ae_controller(isp_proc, &ae_config, &ae_ctrlr[SOC_ISP_AE_CTLR_NUMS]) == ESP_ERR_NOT_FOUND);
for (int i = 0; i < SOC_ISP_AE_CTLR_NUMS; i++) {
TEST_ESP_OK(esp_isp_del_ae_controller(ae_ctrlr[i]));
}
TEST_ESP_OK(esp_isp_del_processor(isp_proc));
}