From 14b3f5d12dd2c5a6097986efc4414feedb57fd07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20B=C3=A9rub=C3=A9?= Date: Mon, 3 Jun 2024 13:23:29 -0400 Subject: [PATCH] Introduce anti-flicking parameter on Ingenic for now --- src/app_config.c | 2 ++ src/app_config.h | 1 + src/hal/inge/t31_hal.c | 13 ++++++++++--- src/video.c | 4 ++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/app_config.c b/src/app_config.c index 9271ec5..0c37e85 100644 --- a/src/app_config.c +++ b/src/app_config.c @@ -32,6 +32,7 @@ enum ConfigError parse_app_config(void) { app_config.mirror = false; app_config.flip = false; + app_config.antiflicker = 0; app_config.night_mode_enable = false; app_config.ir_sensor_pin = 999; @@ -123,6 +124,7 @@ enum ConfigError parse_app_config(void) { err = parse_bool(&ini, "isp", "flip", &app_config.flip); if (err != CONFIG_OK) goto RET_ERR; + parse_int(&ini, "isp", "antiflicker", -1, 60, &app_config.antiflicker); err = parse_bool(&ini, "rtsp", "enable", &app_config.rtsp_enable); if (err != CONFIG_OK) diff --git a/src/app_config.h b/src/app_config.h index 72f9c6e..1b6a71e 100644 --- a/src/app_config.h +++ b/src/app_config.h @@ -55,6 +55,7 @@ struct AppConfig { // [isp] bool mirror; bool flip; + int antiflicker; // [night_mode] bool night_mode_enable; diff --git a/src/hal/inge/t31_hal.c b/src/hal/inge/t31_hal.c index 09eaa10..d2cb093 100644 --- a/src/hal/inge/t31_hal.c +++ b/src/hal/inge/t31_hal.c @@ -163,7 +163,7 @@ int t31_config_load(char *path) return t31_isp.fnLoadConfig(path); } -int t31_pipeline_create(char mirror, char flip, char framerate) +int t31_pipeline_create(char mirror, char flip, char antiflicker, char framerate) { int ret; @@ -193,8 +193,15 @@ int t31_pipeline_create(char mirror, char flip, char framerate) return ret; if (ret = t31_isp.fnSetRunningMode(0)) return ret; - if (ret = t31_isp.fnSetAntiFlicker(T31_ISP_FLICK_60HZ)) - return ret; + { + t31_isp_flick mode = T31_ISP_FLICK_OFF; + if (antiflicker >= 60) + mode = T31_ISP_FLICK_60HZ; + else if (antiflicker >= 50) + mode = T31_ISP_FLICK_50HZ; + if (ret = t31_isp.fnSetAntiFlicker(mode)) + return ret; + } if (ret = t31_isp.fnSetFlip((mirror ? 1 : 0) | (flip ? 2 : 0))) return ret; if (ret = t31_isp.fnSetFramerate(framerate, 1)) diff --git a/src/video.c b/src/video.c index ba3b6d4..abc01ff 100644 --- a/src/video.c +++ b/src/video.c @@ -205,8 +205,8 @@ int start_sdk() { height, framerate); break; case HAL_PLATFORM_I6F: ret = i6f_pipeline_create(0, width, height, framerate); break; - case HAL_PLATFORM_T31: ret = t31_pipeline_create( - app_config.mirror, app_config.flip, framerate); break; + case HAL_PLATFORM_T31: ret = t31_pipeline_create(app_config.mirror, + app_config.flip, app_config.antiflicker, framerate); break; case HAL_PLATFORM_V3: ret = v3_pipeline_create(); break; case HAL_PLATFORM_V4: ret = v4_pipeline_create(); break; }