All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: imx219: fix test pattern ordering and add patterns
@ 2026-06-25 16:02 Tharit Tangkijwanichakul
  2026-06-26 10:04 ` Jai Luthra
  0 siblings, 1 reply; 3+ messages in thread
From: Tharit Tangkijwanichakul @ 2026-06-25 16:02 UTC (permalink / raw)
  To: Sakari Ailus, Dave Stevenson, Mauro Carvalho Chehab
  Cc: linux-media, linux-kernel, skhan, linux-kernel-mentees,
	Tharit Tangkijwanichakul

The test pattern menu currently maps 0 to color bars and 1 to a solid
color, whereas the imx219 datasheet specifies the reverse layout. fix
the ordering to align with the hardware specification.

Additionally, add 5 missing test patterns to complete the available
hardware test patterns.

The changes were validated on a raspberry pi 5 with an imx219 sensor
using v4l2-ctl and rpicam-still.

Signed-off-by: Tharit Tangkijwanichakul <tharitt97@gmail.com>
---
 drivers/media/i2c/imx219.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 223d3753c..8f0c04afd 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -110,11 +110,16 @@
 
 /* Test Pattern Control */
 #define IMX219_REG_TEST_PATTERN		CCI_REG16(0x0600)
-#define IMX219_TEST_PATTERN_DISABLE	0
-#define IMX219_TEST_PATTERN_SOLID_COLOR	1
-#define IMX219_TEST_PATTERN_COLOR_BARS	2
-#define IMX219_TEST_PATTERN_GREY_COLOR	3
-#define IMX219_TEST_PATTERN_PN9		4
+#define IMX219_TEST_PATTERN_DISABLE			0
+#define IMX219_TEST_PATTERN_SOLID_COLOR			1
+#define IMX219_TEST_PATTERN_COLOR_BARS			2
+#define IMX219_TEST_PATTERN_GREY_COLOR			3
+#define IMX219_TEST_PATTERN_PN9				4
+#define IMX219_TEST_PATTERN_16SPLIT_COLOR_BARS		5
+#define IMX219_TEST_PATTERN_16SPLIT_INV_COLOR_BARS	6
+#define IMX219_TEST_PATTERN_COLUMN_COUNTER		7
+#define IMX219_TEST_PATTERN_INV_COLUMN_COUNTER		8
+#define IMX219_TEST_PATTERN_PN31			9
 
 /* Test pattern colour components */
 #define IMX219_REG_TESTP_RED		CCI_REG16(0x0602)
@@ -235,18 +240,28 @@ static const s64 imx219_link_freq_4lane_menu[] = {
 
 static const char * const imx219_test_pattern_menu[] = {
 	"Disabled",
-	"Color Bars",
 	"Solid Color",
+	"Color Bars",
 	"Grey Color Bars",
-	"PN9"
+	"PN9",
+	"16 Split Color Bars",
+	"16 Split Inverted Color Bars",
+	"Column Counter",
+	"Inverted Column Counter",
+	"PN31"
 };
 
 static const int imx219_test_pattern_val[] = {
 	IMX219_TEST_PATTERN_DISABLE,
-	IMX219_TEST_PATTERN_COLOR_BARS,
 	IMX219_TEST_PATTERN_SOLID_COLOR,
+	IMX219_TEST_PATTERN_COLOR_BARS,
 	IMX219_TEST_PATTERN_GREY_COLOR,
 	IMX219_TEST_PATTERN_PN9,
+	IMX219_TEST_PATTERN_16SPLIT_COLOR_BARS,
+	IMX219_TEST_PATTERN_16SPLIT_INV_COLOR_BARS,
+	IMX219_TEST_PATTERN_COLUMN_COUNTER,
+	IMX219_TEST_PATTERN_INV_COLUMN_COUNTER,
+	IMX219_TEST_PATTERN_PN31
 };
 
 /* regulator supplies */

base-commit: 06cb687a5132fcffe624c0070576ab852ac6b568
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: imx219: fix test pattern ordering and add patterns
  2026-06-25 16:02 [PATCH] media: imx219: fix test pattern ordering and add patterns Tharit Tangkijwanichakul
@ 2026-06-26 10:04 ` Jai Luthra
  2026-06-26 12:38   ` Tharit Tangkijwanichakul
  0 siblings, 1 reply; 3+ messages in thread
From: Jai Luthra @ 2026-06-26 10:04 UTC (permalink / raw)
  To: Dave Stevenson, Mauro Carvalho Chehab, Sakari Ailus,
	Tharit Tangkijwanichakul
  Cc: linux-media, linux-kernel, skhan, linux-kernel-mentees,
	Tharit Tangkijwanichakul

Hi Tharit,

Thank you for the patch.

Quoting Tharit Tangkijwanichakul (2026-06-25 21:32:28)
> The test pattern menu currently maps 0 to color bars and 1 to a solid
> color, whereas the imx219 datasheet specifies the reverse layout. fix
> the ordering to align with the hardware specification.
> 

I'm not aware why the order was originally switched for the control menu.
Do you have a strong reason to switch this to the datasheet values?

I ask because this might break what userspace applications expect
(libcamera) and also automated capture tests (that compare md5sums of the
test pattern) in vendor board-farms.

Moreover, given this is a menu control with (correct) string descriptions
for what pattern will be selected, I don't see why the order should
strictly match the sensor register values except that it would be "nice".

Thanks,
    Jai

> Additionally, add 5 missing test patterns to complete the available
> hardware test patterns.
> 
> The changes were validated on a raspberry pi 5 with an imx219 sensor
> using v4l2-ctl and rpicam-still.
> 
> Signed-off-by: Tharit Tangkijwanichakul <tharitt97@gmail.com>
> ---
>  drivers/media/i2c/imx219.c | 31 +++++++++++++++++++++++--------
>  1 file changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
> index 223d3753c..8f0c04afd 100644
> --- a/drivers/media/i2c/imx219.c
> +++ b/drivers/media/i2c/imx219.c
> @@ -110,11 +110,16 @@
>  
>  /* Test Pattern Control */
>  #define IMX219_REG_TEST_PATTERN                CCI_REG16(0x0600)
> -#define IMX219_TEST_PATTERN_DISABLE    0
> -#define IMX219_TEST_PATTERN_SOLID_COLOR        1
> -#define IMX219_TEST_PATTERN_COLOR_BARS 2
> -#define IMX219_TEST_PATTERN_GREY_COLOR 3
> -#define IMX219_TEST_PATTERN_PN9                4
> +#define IMX219_TEST_PATTERN_DISABLE                    0
> +#define IMX219_TEST_PATTERN_SOLID_COLOR                        1
> +#define IMX219_TEST_PATTERN_COLOR_BARS                 2
> +#define IMX219_TEST_PATTERN_GREY_COLOR                 3
> +#define IMX219_TEST_PATTERN_PN9                                4
> +#define IMX219_TEST_PATTERN_16SPLIT_COLOR_BARS         5
> +#define IMX219_TEST_PATTERN_16SPLIT_INV_COLOR_BARS     6
> +#define IMX219_TEST_PATTERN_COLUMN_COUNTER             7
> +#define IMX219_TEST_PATTERN_INV_COLUMN_COUNTER         8
> +#define IMX219_TEST_PATTERN_PN31                       9
>  
>  /* Test pattern colour components */
>  #define IMX219_REG_TESTP_RED           CCI_REG16(0x0602)
> @@ -235,18 +240,28 @@ static const s64 imx219_link_freq_4lane_menu[] = {
>  
>  static const char * const imx219_test_pattern_menu[] = {
>         "Disabled",
> -       "Color Bars",
>         "Solid Color",
> +       "Color Bars",
>         "Grey Color Bars",
> -       "PN9"
> +       "PN9",
> +       "16 Split Color Bars",
> +       "16 Split Inverted Color Bars",
> +       "Column Counter",
> +       "Inverted Column Counter",
> +       "PN31"
>  };
>  
>  static const int imx219_test_pattern_val[] = {
>         IMX219_TEST_PATTERN_DISABLE,
> -       IMX219_TEST_PATTERN_COLOR_BARS,
>         IMX219_TEST_PATTERN_SOLID_COLOR,
> +       IMX219_TEST_PATTERN_COLOR_BARS,
>         IMX219_TEST_PATTERN_GREY_COLOR,
>         IMX219_TEST_PATTERN_PN9,
> +       IMX219_TEST_PATTERN_16SPLIT_COLOR_BARS,
> +       IMX219_TEST_PATTERN_16SPLIT_INV_COLOR_BARS,
> +       IMX219_TEST_PATTERN_COLUMN_COUNTER,
> +       IMX219_TEST_PATTERN_INV_COLUMN_COUNTER,
> +       IMX219_TEST_PATTERN_PN31
>  };
>  
>  /* regulator supplies */
> 
> base-commit: 06cb687a5132fcffe624c0070576ab852ac6b568
> -- 
> 2.53.0
> 
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: imx219: fix test pattern ordering and add patterns
  2026-06-26 10:04 ` Jai Luthra
@ 2026-06-26 12:38   ` Tharit Tangkijwanichakul
  0 siblings, 0 replies; 3+ messages in thread
From: Tharit Tangkijwanichakul @ 2026-06-26 12:38 UTC (permalink / raw)
  To: Jai Luthra
  Cc: Dave Stevenson, Mauro Carvalho Chehab, Sakari Ailus, linux-media,
	linux-kernel, skhan, linux-kernel-mentees

Hi Jai,

Thanks for the review

> Do you have a strong reason to switch this to the datasheet values?

I must say there is no strong reason. I'm totally new here and come from
the perspective of someone studying how to write a camera sensor driver.
The datasheet says that writing 0x1 to reg 0x0601 will set the mode to solid
color test pattern. So it is "natural" to expect that I should set
test_pattern=1 to do so via v4l2-ctl.

> I ask because this might break what userspace applications expect
> (libcamera) and also automated capture tests (that compare md5sums of the
> test pattern) in vendor board-farms.

This was totally oblivious to me when I made the change.
I agree with you on this point. Breaking userspace does not sound like
a good idea.

I'm open to making a v3 patch and only introduce new test patterns to
the driver.

Best,
Tharit

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-26 12:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-25 16:02 [PATCH] media: imx219: fix test pattern ordering and add patterns Tharit Tangkijwanichakul
2026-06-26 10:04 ` Jai Luthra
2026-06-26 12:38   ` Tharit Tangkijwanichakul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.