From ebd736240eca90030866c5feeed33f8f73cb7967 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 15 Sep 2021 12:06:31 +0900 Subject: [PATCH] drivers/video: Replace error output macro to verr Add video debug macros verr/vwarn/vinfo, and replace error output macro to verr. --- Kconfig | 32 +++++++++++++++++++ drivers/video/isx012.c | 70 ++++++++++++++++-------------------------- drivers/video/video.c | 27 +++------------- include/debug.h | 18 +++++++++++ 4 files changed, 80 insertions(+), 67 deletions(-) diff --git a/Kconfig b/Kconfig index 2401cf3453..3441d5dcc5 100644 --- a/Kconfig +++ b/Kconfig @@ -1774,6 +1774,38 @@ config DEBUG_MOTOR_INFO Enable motor informational output to SYSLOG. endif # DEBUG_MOTOR + +config DEBUG_VIDEO + bool "Video Debug Features" + default n + depends on DRIVERS_VIDEO + ---help--- + Enable video debug features. + +if DEBUG_VIDEO + +config DEBUG_VIDEO_ERROR + bool "Video Error Output" + default n + depends on DEBUG_ERROR + ---help--- + Enable video error output to SYSLOG. + +config DEBUG_VIDEO_WARN + bool "Video Warnings Output" + default n + depends on DEBUG_WARN + ---help--- + Enable video warning output to SYSLOG. + +config DEBUG_VIDEO_INFO + bool "Video Informational Output" + default n + depends on DEBUG_INFO + ---help--- + Enable video informational output to SYSLOG. + +endif # DEBUG_VIDEO endif # DEBUG_FEATURES config ARCH_HAVE_STACKCHECK diff --git a/drivers/video/isx012.c b/drivers/video/isx012.c index 62630e6889..2d9981384d 100644 --- a/drivers/video/isx012.c +++ b/drivers/video/isx012.c @@ -135,24 +135,6 @@ #define ISX012_ELEMS_3APARAM (3) -#ifdef CONFIG_DEBUG_IMAGER_ERROR -#define imagererr(format, ...) _err(format, ##__VA_ARGS__) -#else -#define imagererr(x...) -#endif - -#ifdef CONFIG_DEBUG_IMAGER_WARN -#define imagerwarn(format, ...) _warn(format, ##__VA_ARGS__) -#else -#define imagerwarn(x...) -#endif - -#ifdef CONFIG_DEBUG_IMAGER_INFO -#define imagerinfo(format, ...) _info(format, ##__VA_ARGS__) -#else -#define imagerinfo(x...) -#endif - #define VALIDATE_VALUE(val, min, max, step) (((val >= min) && \ (val <= max) && \ (((val - min) % step) == 0) ? \ @@ -667,7 +649,7 @@ static uint16_t isx012_getreg(isx012_dev_t *priv, ret = i2c_write(priv->i2c, &config, (uint8_t *)buffer, 2); if (ret < 0) { - imagererr("i2c_write failed: %d\n", ret); + verr("i2c_write failed: %d\n", ret); return 0; } @@ -676,7 +658,7 @@ static uint16_t isx012_getreg(isx012_dev_t *priv, ret = i2c_read(priv->i2c, &config, (uint8_t *)buffer, regsize); if (ret < 0) { - imagererr("i2c_read failed: %d\n", ret); + verr("i2c_read failed: %d\n", ret); return 0; } @@ -711,7 +693,7 @@ static int isx012_putreg(isx012_dev_t *priv, (uint8_t *)buffer, regsize + 2); if (ret < 0) { - imagererr("i2c_write failed: %d\n", ret); + verr("i2c_write failed: %d\n", ret); } return ret; @@ -730,7 +712,7 @@ static int isx012_putreglist(isx012_dev_t *priv, entry->regval, entry->regsize); if (ret < 0) { - imagererr("isx012_putreg failed: %d\n", ret); + verr("isx012_putreg failed: %d\n", ret); return ret; } } @@ -1185,7 +1167,7 @@ int init_isx012(FAR struct isx012_dev_s *priv) ret = isx012_chipid(priv); if (ret < 0) { - imagererr("isx012_chipid failed: %d\n", ret); + verr("isx012_chipid failed: %d\n", ret); board_isx012_set_reset(); return ret; } @@ -1197,7 +1179,7 @@ int init_isx012(FAR struct isx012_dev_s *priv) DEVICE_STATE_WAIT_TIME, DEVICE_STATE_TIMEOUT); if (ret != OK) { - imagererr("OM_CHANGED_STS(PreSleep) is Not occurred: %d\n", ret); + verr("OM_CHANGED_STS(PreSleep) is Not occurred: %d\n", ret); return ret; } @@ -1211,7 +1193,7 @@ int init_isx012(FAR struct isx012_dev_s *priv) ret = isx012_putreglist(priv, g_isx012_presleep, ISX012_PRESLEEP_NENTRIES); if (ret != OK) { - imagererr("isx012_putreglist(INCK_SET) failed: %d\n", ret); + verr("isx012_putreglist(INCK_SET) failed: %d\n", ret); return ret; } @@ -1221,7 +1203,7 @@ int init_isx012(FAR struct isx012_dev_s *priv) DEVICE_STATE_WAIT_TIME, DEVICE_STATE_TIMEOUT); if (ret != OK) { - imagererr("OM_CHANGED_STS(Sleep) is Not occurred: %d\n", ret); + verr("OM_CHANGED_STS(Sleep) is Not occurred: %d\n", ret); return ret; } #endif @@ -1234,7 +1216,7 @@ int init_isx012(FAR struct isx012_dev_s *priv) ret = isx012_putreglist(priv, g_isx012_def_init, ISX012_RESET_NENTRIES); if (ret < 0) { - imagererr("isx012_putreglist failed: %d\n", ret); + verr("isx012_putreglist failed: %d\n", ret); board_isx012_set_reset(); return ret; } @@ -1244,7 +1226,7 @@ int init_isx012(FAR struct isx012_dev_s *priv) ret = isx012_set_shd(priv); if (ret < 0) { - imagererr("isx012_set_shd failed: %d\n", ret); + verr("isx012_set_shd failed: %d\n", ret); board_isx012_set_reset(); return ret; } @@ -1260,14 +1242,14 @@ static int isx012_init(void) ret = board_isx012_power_on(); if (ret < 0) { - imagererr("Failed to power on %d\n", ret); + verr("Failed to power on %d\n", ret); return ret; } ret = init_isx012(priv); if (ret < 0) { - imagererr("Failed to init_isx012 %d\n", ret); + verr("Failed to init_isx012 %d\n", ret); board_isx012_set_reset(); board_isx012_power_off(); return ret; @@ -1292,7 +1274,7 @@ static int isx012_uninit(void) ret = board_isx012_power_off(); if (ret < 0) { - imagererr("Failed to power off %d\n", ret); + verr("Failed to power off %d\n", ret); return ret; } @@ -2703,7 +2685,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) ret = isx012_putreg(priv, SHD_EN, 0x50, 1); if (ret < 0) { - imagererr("isx012_putreg(disable CXC/SHD) failed: %d\n", ret); + verr("isx012_putreg(disable CXC/SHD) failed: %d\n", ret); return ret; } @@ -2712,7 +2694,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) ret = isx012_putreg(priv, CXC_VALID, 0x8282, 2); if (ret < 0) { - imagererr("isx012_putreg(CXC_VALID) failed: %d\n", ret); + verr("isx012_putreg(CXC_VALID) failed: %d\n", ret); return ret; } @@ -2728,7 +2710,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) 1); if (ret < 0) { - imagererr("isx012_putreg(CXC R Gb) failed: %d\n", ret); + verr("isx012_putreg(CXC R Gb) failed: %d\n", ret); return ret; } } @@ -2746,7 +2728,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) 1); if (ret < 0) { - imagererr("isx012_putreg(CXC G Rb) failed: %d\n", ret); + verr("isx012_putreg(CXC G Rb) failed: %d\n", ret); return ret; } } @@ -2757,7 +2739,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) ret = isx012_putreg(priv, SHD_VALID, 0x9191, 2); if (ret < 0) { - imagererr("isx012_putreg(SHD_VALID) failed: %d\n", ret); + verr("isx012_putreg(SHD_VALID) failed: %d\n", ret); return ret; } @@ -2773,7 +2755,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) 1); if (ret < 0) { - imagererr("isx012_putreg(SHD R Gb) failed: %d\n", ret); + verr("isx012_putreg(SHD R Gb) failed: %d\n", ret); return ret; } } @@ -2791,7 +2773,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) 1); if (ret < 0) { - imagererr("isx012_putreg(SHD G Rb) failed: %d\n", ret); + verr("isx012_putreg(SHD G Rb) failed: %d\n", ret); return ret; } } @@ -2809,7 +2791,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) 1); if (ret < 0) { - imagererr("isx012_putreg(SHD R1) failed: %d\n", ret); + verr("isx012_putreg(SHD R1) failed: %d\n", ret); return ret; } } @@ -2827,7 +2809,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) 1); if (ret < 0) { - imagererr("isx012_putreg(SHD R2) failed: %d\n", ret); + verr("isx012_putreg(SHD R2) failed: %d\n", ret); return ret; } } @@ -2845,7 +2827,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) 1); if (ret < 0) { - imagererr("isx012_putreg(SHD B2) failed: %d\n", ret); + verr("isx012_putreg(SHD B2) failed: %d\n", ret); return ret; } } @@ -2857,7 +2839,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) ISX012_SHD_THRESHOLDS_NENTRIES); if (ret < 0) { - imagererr("isx012_putreglist failed(SHD thresholds): %d\n", ret); + verr("isx012_putreglist failed(SHD thresholds): %d\n", ret); board_isx012_set_reset(); return ret; } @@ -2867,7 +2849,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) ret = isx012_putreglist(priv, g_isx012_shd_wb, ISX012_SHD_WB_NENTRIES); if (ret < 0) { - imagererr("isx012_putreglist(SHD white balance) failed: %d\n", ret); + verr("isx012_putreglist(SHD white balance) failed: %d\n", ret); board_isx012_set_reset(); return ret; } @@ -2877,7 +2859,7 @@ static int isx012_set_shd(FAR isx012_dev_t *priv) ret = isx012_putreg(priv, SHD_EN, 0x57, 1); if (ret < 0) { - imagererr("isx012_putreg(enable CXC/SHD) failed: %d\n", ret); + verr("isx012_putreg(enable CXC/SHD) failed: %d\n", ret); return ret; } diff --git a/drivers/video/video.c b/drivers/video/video.c index 6b9c1e92d1..e5bb203d0a 100644 --- a/drivers/video/video.c +++ b/drivers/video/video.c @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -55,26 +56,6 @@ #define VIDEO_REMAINING_CAPNUM_INFINITY (-1) -/* Debug option */ - -#ifdef CONFIG_DEBUG_VIDEO_ERROR -#define videoerr(format, ...) _err(format, ##__VA_ARGS__) -#else -#define videoerr(x...) -#endif - -#ifdef CONFIG_DEBUG_VIDEO_WARN -#define videowarn(format, ...) _warn(format, ##__VA_ARGS__) -#else -#define videowarn(x...) -#endif - -#ifdef CONFIG_DEBUG_VIDEO_INFO -#define videoinfo(format, ...) _info(format, ##__VA_ARGS__) -#else -#define videoinfo(x...) -#endif - #define VIDEO_SCENE_MAX (sizeof(g_video_scene_parameter) / \ sizeof(video_scene_params_t)) @@ -2795,7 +2776,7 @@ static int video_ioctl(FAR struct file *filep, int cmd, unsigned long arg) break; default: - videoerr("Unrecognized cmd: %d\n", cmd); + verr("Unrecognized cmd: %d\n", cmd); ret = - ENOTTY; break; } @@ -2830,7 +2811,7 @@ static FAR void *video_register(FAR const char *devpath) priv = (FAR video_mng_t *)kmm_malloc(sizeof(video_mng_t)); if (!priv) { - videoerr("Failed to allocate instance\n"); + verr("Failed to allocate instance\n"); return NULL; } @@ -2857,7 +2838,7 @@ static FAR void *video_register(FAR const char *devpath) ret = register_driver(priv->devpath, &g_video_fops, 0666, priv); if (ret < 0) { - videoerr("Failed to register driver: %d\n", ret); + verr("Failed to register driver: %d\n", ret); kmm_free(priv->devpath); kmm_free(priv); return NULL; diff --git a/include/debug.h b/include/debug.h index a869897390..995020b07b 100644 --- a/include/debug.h +++ b/include/debug.h @@ -754,6 +754,24 @@ # define mtrinfo _none #endif +#ifdef CONFIG_DEBUG_VIDEO_ERROR +# define verr _err +#else +# define verr _none +#endif + +#ifdef CONFIG_DEBUG_VIDEO_WARN +# define vwarn _warn +#else +# define vwarn _none +#endif + +#ifdef CONFIG_DEBUG_VIDEO_INFO +# define vinfo _info +#else +# define vinfo _none +#endif + /* Buffer dumping macros do not depend on varargs */ #ifdef CONFIG_DEBUG_ERROR