Skip to contentSkip to conversation

vimc: Add colors' order over test image

RFC PATCH In review Kaaira Gupta 4 participants 5 messages Jun 7, 2020 – Jun 8, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 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 text over the test image, representing the correct order of colors.

I have sent it as an RFC because we can add the text as an optional control, and maybe we can print some other useful information as well (like vivid does).

---
 drivers/media/test-drivers/vimc/Kconfig       | 2 ++
 drivers/media/test-drivers/vimc/vimc-core.c   | 9 +++++++++
 drivers/media/test-drivers/vimc/vimc-sensor.c | 8 ++++++++
 3 files changed, 19 insertions(+)
drivers/media/test-drivers/vimc/Kconfig +2 -0
index 4068a67585f9..da4b2ad6e40c 100644
@@ -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-core.c +9 -0
index 11210aaa2551..8142bfbcbd49 100644
@@ -5,10 +5,12 @@
  * Copyright (C) 2015-2017 Helen Koike <[email protected]>
  */
 
+#include <linux/font.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <media/media-device.h>
+#include <media/tpg/v4l2-tpg.h>
 #include <media/v4l2-device.h>
 
 #include "vimc-common.h"
@@ -265,7 +267,14 @@ static int vimc_probe(struct platform_device *pdev)
 {
 	struct vimc_device *vimc;
 	int ret;
+	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);
 	dev_dbg(&pdev->dev, "probe");
 
 	vimc = kzalloc(sizeof(*vimc), GFP_KERNEL);
drivers/media/test-drivers/vimc/vimc-sensor.c +8 -0
index a2f09ac9a360..4b13955c502a 100644
@@ -185,10 +185,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_calc_text_basep(&vsen->tpg, basep, 0, vsen->frame);
 	tpg_fill_plane_buffer(&vsen->tpg, 0, 0, vsen->frame);
+
+	snprintf(str, sizeof(str),
+		 "Order: white, yellow, cyan, green, magenta, red, blue, black");
+	tpg_gen_text(&vsen->tpg, basep, 1, 1, str);
+
 	return vsen->frame;
 }
 
Signature · 1 line
2.17.1
#1 lore raw

Hi,

Quoted 7 lines · Kaaira Gupta

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 text over the test image, representing the correct order of colors.

I have sent it as an RFC because we can add the text as an optional control, and maybe we can print some other useful information as well (like vivid does).

Yes, it seems like a good idea to add it as a control of the sensor.

Quoted 39 lines

---> drivers/media/test-drivers/vimc/Kconfig | 2 ++

  drivers/media/test-drivers/vimc/vimc-core.c   | 9 +++++++++
  drivers/media/test-drivers/vimc/vimc-sensor.c | 8 ++++++++
  3 files changed, 19 insertions(+)
drivers/media/test-drivers/vimc/Kconfig +2 -0
index 4068a67585f9..da4b2ad6e40c 100644
@@ -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-core.c +2 -0
index 11210aaa2551..8142bfbcbd49 100644
@@ -5,10 +5,12 @@
   * Copyright (C) 2015-2017 Helen Koike <[email protected]>
   */
 
+#include <linux/font.h>
  #include <linux/init.h>
  #include <linux/module.h>
  #include <linux/platform_device.h>
  #include <media/media-device.h>
+#include <media/tpg/v4l2-tpg.h>
  #include <media/v4l2-device.h>
 
  #include "vimc-common.h"
@@ -265,7 +267,14 @@ static int vimc_probe(struct platform_device *pdev)
  {

drivers/media/test-drivers/vimc/vimc-core.c static int vimc_probe(struct platform_device *pdev) · line 277

Quoted 10 lines
drivers/media/test-drivers/vimc/vimc-core.c +7 -0
  	struct vimc_device *vimc;
  	int ret;
+	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);

I think the code that set the format should move to the code that registers the sensor in vimc-sensor.c

Quoted 11 lines
drivers/media/test-drivers/vimc/vimc-core.c +0 -0
  	dev_dbg(&pdev->dev, "probe");
 
  	vimc = kzalloc(sizeof(*vimc), GFP_KERNEL);
drivers/media/test-drivers/vimc/vimc-sensor.c +0 -0
index a2f09ac9a360..4b13955c502a 100644
@@ -185,10 +185,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)
  {

drivers/media/test-drivers/vimc/vimc-sensor.c static const struct v4l2_subdev_pad_ops vimc_sen_pad_ops = { · line 197

Quoted 10 lines
drivers/media/test-drivers/vimc/vimc-sensor.c +6 -0
+	u8 *basep[TPG_MAX_PLANES][2];
+	char str[100];
  	struct vimc_sen_device *vsen = container_of(ved, struct vimc_sen_device,
  						    ved);
 
+	tpg_calc_text_basep(&vsen->tpg, basep, 0, vsen->frame);
  	tpg_fill_plane_buffer(&vsen->tpg, 0, 0, vsen->frame);
+
+	snprintf(str, sizeof(str),
+		 "Order: white, yellow, cyan, green, magenta, red, blue, black");

The colors are generated by the tpg, so I think it should be a feature of the tpg to print the colors.

For example, a function in v4l2-tpg-core.c that get the pattern as an argument and return this string, or maybe returns a const pointer to the array of colors, or something like that. Then maybe we can add a control in vivid for the same tpg feature.

Note also that the sensor has a control to change the pattern: vimc_sen_ctrl_test_pattern So the string depends on that pattern.

Thanks,
Dafna

Quoted 6 lines
drivers/media/test-drivers/vimc/vimc-sensor.c +2 -0
+	tpg_gen_text(&vsen->tpg, basep, 1, 1, str);
+
  	return vsen->frame;
  }
 
#2 lore raw
Quoted 82 lines · Dafna Hirschfeld

Hi,

Quoted 7 lines · Kaaira Gupta

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 text over the test image, representing the correct order of colors.

I have sent it as an RFC because we can add the text as an optional control, and maybe we can print some other useful information as well (like vivid does).

Yes, it seems like a good idea to add it as a control of the sensor.

Quoted 39 lines

---> drivers/media/test-drivers/vimc/Kconfig | 2 ++

  drivers/media/test-drivers/vimc/vimc-core.c   | 9 +++++++++
  drivers/media/test-drivers/vimc/vimc-sensor.c | 8 ++++++++
  3 files changed, 19 insertions(+)
drivers/media/test-drivers/vimc/Kconfig +2 -0
index 4068a67585f9..da4b2ad6e40c 100644
@@ -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-core.c +2 -0
index 11210aaa2551..8142bfbcbd49 100644
@@ -5,10 +5,12 @@
   * Copyright (C) 2015-2017 Helen Koike <[email protected]>
   */
 
+#include <linux/font.h>
  #include <linux/init.h>
  #include <linux/module.h>
  #include <linux/platform_device.h>
  #include <media/media-device.h>
+#include <media/tpg/v4l2-tpg.h>
  #include <media/v4l2-device.h>
 
  #include "vimc-common.h"
@@ -265,7 +267,14 @@ static int vimc_probe(struct platform_device *pdev)
  {

drivers/media/test-drivers/vimc/vimc-core.c static int vimc_probe(struct platform_device *pdev) · line 277

Quoted 10 lines
drivers/media/test-drivers/vimc/vimc-core.c +7 -0
  	struct vimc_device *vimc;
  	int ret;
+	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);

I think the code that set the format should move to the code that registers the sensor in vimc-sensor.c

Quoted 16 lines
drivers/media/test-drivers/vimc/vimc-core.c +0 -0
  	dev_dbg(&pdev->dev, "probe");
 
  	vimc = kzalloc(sizeof(*vimc), GFP_KERNEL);
drivers/media/test-drivers/vimc/vimc-sensor.c +2 -0
index a2f09ac9a360..4b13955c502a 100644
@@ -185,10 +185,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);
 
Quoted 6 lines

drivers/media/test-drivers/vimc/vimc-sensor.c static const struct v4l2_subdev_pad_ops vimc_sen_pad_ops = { · line 197

Quoted 5 lines
drivers/media/test-drivers/vimc/vimc-sensor.c +4 -0
+	tpg_calc_text_basep(&vsen->tpg, basep, 0, vsen->frame);
  	tpg_fill_plane_buffer(&vsen->tpg, 0, 0, vsen->frame);
+
+	snprintf(str, sizeof(str),
+		 "Order: white, yellow, cyan, green, magenta, red, blue, black");

The colors are generated by the tpg, so I think it should be a feature of the tpg to print the colors.

I agree. The tpg knows where each color is and based on the width and height it can print the text. A tpg_gen_pattern_text() function that does the work would be very nice.

It also doesn't make sense for all patterns, so this is really a nice feature to incorporate into the TPG itself and enable it via a vivid and vimc control.

Regards,

Hans

Quoted 18 lines

For example, a function in v4l2-tpg-core.c that get the pattern as an argument and return this string, or maybe returns a const pointer to the array of colors, or something like that. Then maybe we can add a control in vivid for the same tpg feature.

Note also that the sensor has a control to change the pattern: vimc_sen_ctrl_test_pattern So the string depends on that pattern.

Thanks,
Dafna

Quoted 6 lines
drivers/media/test-drivers/vimc/vimc-sensor.c +2 -0
+	tpg_gen_text(&vsen->tpg, basep, 1, 1, str);
+
  	return vsen->frame;
  }
 
#3 lore raw

Hello,

Quoted 87 lines · Hans Verkuil
Quoted 79 lines · Dafna Hirschfeld
Quoted 7 lines · Kaaira Gupta

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 text over the test image, representing the correct order of colors.

I have sent it as an RFC because we can add the text as an optional control, and maybe we can print some other useful information as well (like vivid does).

Yes, it seems like a good idea to add it as a control of the sensor.

Quoted 38 lines

---> drivers/media/test-drivers/vimc/Kconfig | 2 ++

  drivers/media/test-drivers/vimc/vimc-core.c   | 9 +++++++++
  drivers/media/test-drivers/vimc/vimc-sensor.c | 8 ++++++++
  3 files changed, 19 insertions(+)
drivers/media/test-drivers/vimc/Kconfig +2 -0
index 4068a67585f9..da4b2ad6e40c 100644
@@ -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-core.c +2 -0
index 11210aaa2551..8142bfbcbd49 100644
@@ -5,10 +5,12 @@
   * Copyright (C) 2015-2017 Helen Koike <[email protected]>
   */
 
+#include <linux/font.h>
  #include <linux/init.h>
  #include <linux/module.h>
  #include <linux/platform_device.h>
  #include <media/media-device.h>
+#include <media/tpg/v4l2-tpg.h>
  #include <media/v4l2-device.h>
 
  #include "vimc-common.h"
@@ -265,7 +267,14 @@ static int vimc_probe(struct platform_device *pdev)
  {

drivers/media/test-drivers/vimc/vimc-core.c static int vimc_probe(struct platform_device *pdev) · line 277

Quoted 10 lines
drivers/media/test-drivers/vimc/vimc-core.c +7 -0
  	struct vimc_device *vimc;
  	int ret;
+	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);

I think the code that set the format should move to the code that registers the sensor in vimc-sensor.c

Quoted 16 lines
drivers/media/test-drivers/vimc/vimc-core.c +0 -0
  	dev_dbg(&pdev->dev, "probe");
 
  	vimc = kzalloc(sizeof(*vimc), GFP_KERNEL);
drivers/media/test-drivers/vimc/vimc-sensor.c +2 -0
index a2f09ac9a360..4b13955c502a 100644
@@ -185,10 +185,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);
 
Quoted 6 lines

drivers/media/test-drivers/vimc/vimc-sensor.c static const struct v4l2_subdev_pad_ops vimc_sen_pad_ops = { · line 197

Quoted 5 lines
drivers/media/test-drivers/vimc/vimc-sensor.c +4 -0
+	tpg_calc_text_basep(&vsen->tpg, basep, 0, vsen->frame);
  	tpg_fill_plane_buffer(&vsen->tpg, 0, 0, vsen->frame);
+
+	snprintf(str, sizeof(str),
+		 "Order: white, yellow, cyan, green, magenta, red, blue, black");

The colors are generated by the tpg, so I think it should be a feature of the tpg to print the colors.

Quoted 3 lines

I agree. The tpg knows where each color is and based on the width and height it can print the text. A tpg_gen_pattern_text() function that does the work would be very nice.

Could we go one step further, and print the colour name on each colour bar ?

Quoted 15 lines

It also doesn't make sense for all patterns, so this is really a nice feature to incorporate into the TPG itself and enable it via a vivid and vimc control.

Quoted 12 lines

For example, a function in v4l2-tpg-core.c that get the pattern as an argument and return this string, or maybe returns a const pointer to the array of colors, or something like that. Then maybe we can add a control in vivid for the same tpg feature.

Note also that the sensor has a control to change the pattern: vimc_sen_ctrl_test_pattern So the string depends on that pattern.

Quoted 5 lines
drivers/media/test-drivers/vimc/vimc-sensor.c +2 -0
+	tpg_gen_text(&vsen->tpg, basep, 1, 1, str);
+
  	return vsen->frame;
  }
 
Signature · 3 lines
Regards,

Laurent Pinchart
#4 lore raw
Quoted 90 lines · Laurent Pinchart

Hello,

Quoted 87 lines · Hans Verkuil
Quoted 85 lines · Dafna Hirschfeld
Quoted 7 lines · Kaaira Gupta

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 text over the test image, representing the correct order of colors.

I have sent it as an RFC because we can add the text as an optional control, and maybe we can print some other useful information as well (like vivid does).

Yes, it seems like a good idea to add it as a control of the sensor.

Quoted 38 lines

---> drivers/media/test-drivers/vimc/Kconfig | 2 ++

  drivers/media/test-drivers/vimc/vimc-core.c   | 9 +++++++++
  drivers/media/test-drivers/vimc/vimc-sensor.c | 8 ++++++++
  3 files changed, 19 insertions(+)
drivers/media/test-drivers/vimc/Kconfig +2 -0
index 4068a67585f9..da4b2ad6e40c 100644
@@ -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-core.c +2 -0
index 11210aaa2551..8142bfbcbd49 100644
@@ -5,10 +5,12 @@
   * Copyright (C) 2015-2017 Helen Koike <[email protected]>
   */
 
+#include <linux/font.h>
  #include <linux/init.h>
  #include <linux/module.h>
  #include <linux/platform_device.h>
  #include <media/media-device.h>
+#include <media/tpg/v4l2-tpg.h>
  #include <media/v4l2-device.h>
 
  #include "vimc-common.h"
@@ -265,7 +267,14 @@ static int vimc_probe(struct platform_device *pdev)
  {

drivers/media/test-drivers/vimc/vimc-core.c static int vimc_probe(struct platform_device *pdev) · line 277

Quoted 10 lines
drivers/media/test-drivers/vimc/vimc-core.c +7 -0
  	struct vimc_device *vimc;
  	int ret;
+	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);

I think the code that set the format should move to the code that registers the sensor in vimc-sensor.c

Quoted 11 lines
drivers/media/test-drivers/vimc/vimc-core.c +0 -0
  	dev_dbg(&pdev->dev, "probe");
 
  	vimc = kzalloc(sizeof(*vimc), GFP_KERNEL);
drivers/media/test-drivers/vimc/vimc-sensor.c +0 -0
index a2f09ac9a360..4b13955c502a 100644
@@ -185,10 +185,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)
  {

drivers/media/test-drivers/vimc/vimc-sensor.c static const struct v4l2_subdev_pad_ops vimc_sen_pad_ops = { · line 197

Quoted 10 lines
drivers/media/test-drivers/vimc/vimc-sensor.c +6 -0
+	u8 *basep[TPG_MAX_PLANES][2];
+	char str[100];
  	struct vimc_sen_device *vsen = container_of(ved, struct vimc_sen_device,
  						    ved);
 
+	tpg_calc_text_basep(&vsen->tpg, basep, 0, vsen->frame);
  	tpg_fill_plane_buffer(&vsen->tpg, 0, 0, vsen->frame);
+
+	snprintf(str, sizeof(str),
+		 "Order: white, yellow, cyan, green, magenta, red, blue, black");

The colors are generated by the tpg, so I think it should be a feature of the tpg to print the colors.

Quoted 6 lines
Quoted 3 lines

I agree. The tpg knows where each color is and based on the width and height it can print the text. A tpg_gen_pattern_text() function that does the work would be very nice.

Could we go one step further, and print the colour name on each colour bar ?

I think we mean the same thing: tpg_gen_pattern_text() would write the name of the color on each color bar.

Regards,

Hans

Quoted 17 lines
Quoted 16 lines

It also doesn't make sense for all patterns, so this is really a nice feature to incorporate into the TPG itself and enable it via a vivid and vimc control.

Quoted 12 lines

For example, a function in v4l2-tpg-core.c that get the pattern as an argument and return this string, or maybe returns a const pointer to the array of colors, or something like that. Then maybe we can add a control in vivid for the same tpg feature.

Note also that the sensor has a control to change the pattern: vimc_sen_ctrl_test_pattern So the string depends on that pattern.

Quoted 5 lines
drivers/media/test-drivers/vimc/vimc-sensor.c +2 -0
+	tpg_gen_text(&vsen->tpg, basep, 1, 1, str);
+
  	return vsen->frame;
  }