vimc: Add colors' order over test image
Subsystems (2)
PATCH 1/1 vimc: Add colors' order over test image
Currently there is no method to know if the test image generated by vimc is correct (except for comparing it with a known 'correct' image). Add a function which returns the correct order of the colors in test pattern. And hence, add that text over the test image.
Add a null check in tpg_gen_text() for patterns for which color order does not exist/make sense to print.
Make a separate control for the same in vimc to make displaying the text optional.
--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 24 ++++++++++++- drivers/media/test-drivers/vimc/Kconfig | 2 ++ drivers/media/test-drivers/vimc/vimc-common.h | 1 + drivers/media/test-drivers/vimc/vimc-sensor.c | 34 +++++++++++++++++++ include/media/tpg/v4l2-tpg.h | 1 + 5 files changed, 61 insertions(+), 1 deletion(-)
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +23 -1
@@ -1962,7 +1962,7 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2],unsigned len =strlen (text);unsigned p; -if (font8x16 ==NULL || basep ==NULL ) +if (font8x16 ==NULL || basep ==NULL || text ==NULL )return ;/* Checks if it is possible to show string */
@@ -2006,6 +2006,28 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], }EXPORT_SYMBOL_GPL (tpg_gen_text); +const char *tpg_g_color_order (const struct tpg_data *tpg) +{ +switch (tpg->pattern) { +case (TPG_PAT_75_COLORBAR ||TPG_PAT_100_COLORBAR ||TPG_PAT_CSC_COLORBAR ): +return "Left to right: white, yellow, cyan, green, magenta, red, blue, black" ; +case TPG_PAT_100_HCOLORBAR : +return "Top to bottom: white, yellow, cyan, green, magenta, red, blue, black" ; +case TPG_PAT_BLACK : +return "Black" ; +case TPG_PAT_WHITE : +return "White" ; +case TPG_PAT_RED : +return "Red" ; +case TPG_PAT_GREEN : +return "Green" ; +case TPG_PAT_BLUE : +return "Blue" ; +default : +return ; + } +} +void tpg_update_mv_step (struct tpg_data *tpg) {int factor = tpg->mv_hor_mode >TPG_MOVE_NONE ?-1 :1 ;
drivers/media/test-drivers/vimc/Kconfig +2 -0
@@ -2,6 +2,8 @@ config VIDEO_VIMC tristate "Virtual Media Controller Driver (VIMC)" depends on VIDEO_DEV && VIDEO_V4L2 + select FONT_SUPPORT + select FONT_8x16 select MEDIA_CONTROLLER select VIDEO_V4L2_SUBDEV_API select VIDEOBUF2_VMALLOC
drivers/media/test-drivers/vimc/vimc-common.h +1 -0
@@ -20,6 +20,7 @@#define VIMC_CID_VIMC_CLASS (0x00f00000 | 1)#define VIMC_CID_TEST_PATTERN (VIMC_CID_VIMC_BASE + 0)#define VIMC_CID_MEAN_WIN_SIZE (VIMC_CID_VIMC_BASE + 1) +#define VIMC_TEST_PATTERN_ORDER (VIMC_CID_VIMC_BASE + 2)#define VIMC_FRAME_MAX_WIDTH 4096#define VIMC_FRAME_MAX_HEIGHT 2160
drivers/media/test-drivers/vimc/vimc-sensor.c +34 -0
@@ -5,6 +5,7 @@* Copyright (C) 2015-2017 Helen Koike <[email protected]> */ +#include <linux/font.h> #include <linux/v4l2-mediabus.h> #include <linux/vmalloc.h> #include <media/v4l2-ctrls.h>
@@ -19,6 +20,7 @@ struct vimc_sen_device {struct v4l2_subdev sd;struct tpg_data tpg;u8 *frame; +bool showOrder;/* The active format */ struct v4l2_mbus_framefmt mbus_format;struct v4l2_ctrl_handler hdl;
@@ -185,10 +187,18 @@ static const struct v4l2_subdev_pad_ops vimc_sen_pad_ops = {static void *vimc_sen_process_frame (struct vimc_ent_device *ved,const void *sink_frame) { +u8 *basep[TPG_MAX_PLANES ][2 ]; +char str[100 ]; struct vimc_sen_device *vsen = container_of(ved, struct vimc_sen_device, ved);tpg_fill_plane_buffer (&vsen->tpg,0 ,0 , vsen->frame); +if (vsen->showOrder ==1 ) { +tpg_calc_text_basep (&vsen->tpg, basep,0 , vsen->frame); +snprintf (str,sizeof (str),tpg_g_color_order (&vsen->tpg)); +tpg_gen_text (&vsen->tpg, basep,1 ,1 , str); + } +return vsen->frame; }
@@ -200,6 +210,14 @@ static int vimc_sen_s_stream(struct v4l2_subdev *sd, int enable)if (enable) {const struct vimc_pix_map *vpix;unsigned int frame_size; +const struct font_desc *font =find_font ("VGA8x16" ); + +if (font ==NULL ) { +pr_err ("vimc: could not find font\n" ); +return -ENODEV ; + } + +tpg_set_font (font->data);/* Calculate the frame size */ vpix =vimc_pix_map_by_code (vsen->mbus_format.code);
@@ -269,6 +287,9 @@ static int vimc_sen_s_ctrl(struct v4l2_ctrl *ctrl)case V4L2_CID_SATURATION :tpg_s_saturation (&vsen->tpg, ctrl->val);break ; +case VIMC_TEST_PATTERN_ORDER : + vsen->showOrder = ctrl->val; +break ;default :return -EINVAL ; }
@@ -307,6 +328,17 @@ static const struct v4l2_ctrl_config vimc_sen_ctrl_test_pattern = { .qmenu = tpg_pattern_strings, }; +static const struct v4l2_ctrl_config vimc_sen_ctrl_order = { + .ops = &vimc_sen_ctrl_ops, + .id =VIMC_TEST_PATTERN_ORDER , + .name ="Show Order" , + .type =V4L2_CTRL_TYPE_BOOLEAN , + .min =0 , + .max =1 , + .step =1 , + .def =1 , +}; +static struct vimc_ent_device *vimc_sen_add (struct vimc_device *vimc,const char *vcfg_name) {
@@ -323,6 +355,7 @@ static struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,v4l2_ctrl_new_custom (&vsen->hdl, &vimc_sen_ctrl_class,NULL );v4l2_ctrl_new_custom (&vsen->hdl, &vimc_sen_ctrl_test_pattern,NULL ); +v4l2_ctrl_new_custom (&vsen->hdl, &vimc_sen_ctrl_order,NULL );v4l2_ctrl_new_std (&vsen->hdl, &vimc_sen_ctrl_ops,V4L2_CID_VFLIP ,0 ,1 ,1 ,0 ); v4l2_ctrl_new_std(&vsen->hdl, &vimc_sen_ctrl_ops,
@@ -362,6 +395,7 @@ static struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,/* Initialize the frame format */ vsen->mbus_format = fmt_default; + vsen->showOrder = vimc_sen_ctrl_order.def;return &vsen->ved;
include/media/tpg/v4l2-tpg.h +1 -0
@@ -252,6 +252,7 @@ void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std,bool tpg_s_fourcc (struct tpg_data *tpg,u32 fourcc);void tpg_s_crop_compose (struct tpg_data *tpg,const struct v4l2_rect *crop,const struct v4l2_rect *compose); +const char *tpg_g_color_order (const struct tpg_data *tpg);static inline void tpg_s_pattern (struct tpg_data *tpg,enum tpg_pattern pattern) {
Signature · 1 line
2.17.1
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Kaaira,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on next-20200612]
[cannot apply to v5.7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Kaaira-Gupta/vimc-Add-colors-order-over-test-image/20200613-015755 base: git://linuxtv.org/media_tree.git master config: riscv-allyesconfig (attached as .config) compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=riscv
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>, old ones prefixed by <<):
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c: In function 'tpg_g_color_order':
>> drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2027:3: warning: 'return' with no value, in function returning non-void [-Wreturn-type]
2027 | return;
| ^~~~~~drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2009:13: note: declared here 2009 | const char *tpg_g_color_order(const struct tpg_data *tpg)
| ^~~~~~~~~~~~~~~~~
vim +/return +2027 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
2008
2009 const char *tpg_g_color_order(const struct tpg_data *tpg)
2010 {
2011 switch (tpg->pattern) {
2012 case (TPG_PAT_75_COLORBAR || TPG_PAT_100_COLORBAR || TPG_PAT_CSC_COLORBAR):
2013 return "Left to right: white, yellow, cyan, green, magenta, red, blue, black";
2014 case TPG_PAT_100_HCOLORBAR:
2015 return "Top to bottom: white, yellow, cyan, green, magenta, red, blue, black";
2016 case TPG_PAT_BLACK:
2017 return "Black";
2018 case TPG_PAT_WHITE:
2019 return "White";
2020 case TPG_PAT_RED:
2021 return "Red";
2022 case TPG_PAT_GREEN:
2023 return "Green";
2024 case TPG_PAT_BLUE:
2025 return "Blue";
2026 default:
> 2027 return;
2028 }
2029 }
2030
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Kaaira,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on next-20200612]
[cannot apply to v5.7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Kaaira-Gupta/vimc-Add-colors-order-over-test-image/20200613-015755 base: git://linuxtv.org/media_tree.git master config: x86_64-allyesconfig (attached as .config) compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 3b43f006294971b8049d4807110032169780e5b8)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>, old ones prefixed by <<):
>> drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2012:52: warning: converting the enum constant to a boolean [-Wint-in-bool-context] case (TPG_PAT_75_COLORBAR || TPG_PAT_100_COLORBAR || TPG_PAT_CSC_COLORBAR): ^ >> drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2027:3: error: non-void function 'tpg_g_color_order' should return a value [-Wreturn-type]
return;
^
1 warning and 1 error generated.
vim +/tpg_g_color_order +2027 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
2008
2009 const char *tpg_g_color_order(const struct tpg_data *tpg)
2010 {
2011 switch (tpg->pattern) {
> 2012 case (TPG_PAT_75_COLORBAR || TPG_PAT_100_COLORBAR || TPG_PAT_CSC_COLORBAR): 2013 return "Left to right: white, yellow, cyan, green, magenta, red, blue, black"; 2014 case TPG_PAT_100_HCOLORBAR: 2015 return "Top to bottom: white, yellow, cyan, green, magenta, red, blue, black"; 2016 case TPG_PAT_BLACK: 2017 return "Black"; 2018 case TPG_PAT_WHITE: 2019 return "White"; 2020 case TPG_PAT_RED: 2021 return "Red"; 2022 case TPG_PAT_GREEN: 2023 return "Green"; 2024 case TPG_PAT_BLUE: 2025 return "Blue"; 2026 default: > 2027 return;
2028 }
2029 }
2030
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org