mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] media: rcar-isp: ispcore: Fix inconsistent step sizes
@ 2026-09-29 13:30 Barnabás Pőcze
  2026-09-29 14:30 ` Niklas Söderlund
  0 siblings, 1 reply; 2+ messages in thread
From: Barnabás Pőcze @ 2026-09-29 13:30 UTC (permalink / raw)
  To: Niklas Söderlund, Mauro Carvalho Chehab, Geert Uytterhoeven,
	Magnus Damm
  Cc: Jacopo Mondi, Sakari Ailus, linux-media, linux-renesas-soc,
	linux-kernel, Barnabás Pőcze

`risp_io_{input,capture}_enum_framesizes()` sets the horizonal and vertical
step size to 2. However, `risp_io_{input,capture}_try_format()` passes 2
to `v4l_bound_align_image()`, which corresponds to a step size of 2^2 = 4.

So move these constants into macros to avoid the repetition, and with that,
use 4 as the step size everywhere.

Fixes: 2151350f60d1 ("media: rcar-isp: Add support for ISPCORE")
Signed-off-by: Barnabás Pőcze <barnabas.pocze+renesas@ideasonboard.com>
---
 .../media/platform/renesas/rcar-isp/core-io.c | 40 +++++++++++--------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/renesas/rcar-isp/core-io.c b/drivers/media/platform/renesas/rcar-isp/core-io.c
index 820af506f896c..b60b91f43d42d 100644
--- a/drivers/media/platform/renesas/rcar-isp/core-io.c
+++ b/drivers/media/platform/renesas/rcar-isp/core-io.c
@@ -15,6 +15,12 @@
 
 #include "risp-core.h"
 
+#define RISP_MIN_WIDTH 128
+#define RISP_MAX_WIDTH 5120
+#define RISP_MIN_HEIGHT 128
+#define RISP_MAX_HEIGHT 4096
+#define RISP_SIZE_ALIGNMENT 2 /* 2^2 = 4 */
+
 #define risp_io_err(d, fmt, arg...)         dev_err((d)->core->dev, fmt, ##arg)
 
 static struct risp_buffer *risp_io_vb2buf(struct vb2_v4l2_buffer *vb)
@@ -330,8 +336,9 @@ static void risp_io_input_try_format(struct rcar_isp_core_io *io,
 {
 	unsigned int bpp = 0;
 
-	v4l_bound_align_image(&pix->width, 128, 5120, 2,
-			      &pix->height, 128, 4096, 2, 0);
+	v4l_bound_align_image(&pix->width, RISP_MIN_WIDTH, RISP_MAX_WIDTH, RISP_SIZE_ALIGNMENT,
+			      &pix->height, RISP_MIN_HEIGHT, RISP_MAX_HEIGHT, RISP_SIZE_ALIGNMENT,
+			      0);
 
 	for (unsigned int i = 0; i < ARRAY_SIZE(risp_io_input_formats); i++) {
 		if (risp_io_input_formats[i].fourcc == pix->pixelformat) {
@@ -423,13 +430,13 @@ static int risp_io_input_enum_framesizes(struct file *file, void *fh,
 
 	fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
 
-	fsize->stepwise.min_width = 128;
-	fsize->stepwise.max_width = 5120;
-	fsize->stepwise.step_width = 2;
+	fsize->stepwise.min_width = RISP_MIN_WIDTH;
+	fsize->stepwise.max_width = RISP_MAX_WIDTH;
+	fsize->stepwise.step_width = 1u << RISP_SIZE_ALIGNMENT;
 
-	fsize->stepwise.min_height = 128;
-	fsize->stepwise.max_height = 4096;
-	fsize->stepwise.step_height = 2;
+	fsize->stepwise.min_height = RISP_MIN_HEIGHT;
+	fsize->stepwise.max_height = RISP_MAX_HEIGHT;
+	fsize->stepwise.step_height = 1u << RISP_SIZE_ALIGNMENT;
 
 	return 0;
 }
@@ -720,8 +727,9 @@ static const struct v4l2_pix_format_mplane risp_io_capture_default_format = {
 static void risp_io_capture_try_format(struct rcar_isp_core_io *io,
 				       struct v4l2_pix_format_mplane *pix)
 {
-	v4l_bound_align_image(&pix->width, 128, 5120, 2,
-			      &pix->height, 128, 4096, 2, 0);
+	v4l_bound_align_image(&pix->width, RISP_MIN_WIDTH, RISP_MAX_WIDTH, RISP_SIZE_ALIGNMENT,
+			      &pix->height, RISP_MIN_HEIGHT, RISP_MAX_HEIGHT, RISP_SIZE_ALIGNMENT,
+			      0);
 
 	pix->field = V4L2_FIELD_NONE;
 	pix->colorspace = V4L2_COLORSPACE_SRGB;
@@ -824,13 +832,13 @@ static int risp_io_capture_enum_framesizes(struct file *file, void *fh,
 
 	fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
 
-	fsize->stepwise.min_width = 128;
-	fsize->stepwise.max_width = 5120;
-	fsize->stepwise.step_width = 2;
+	fsize->stepwise.min_width = RISP_MIN_WIDTH;
+	fsize->stepwise.max_width = RISP_MAX_WIDTH;
+	fsize->stepwise.step_width = 1u << RISP_SIZE_ALIGNMENT;
 
-	fsize->stepwise.min_height = 128;
-	fsize->stepwise.max_height = 4096;
-	fsize->stepwise.step_height = 2;
+	fsize->stepwise.min_height = RISP_MIN_HEIGHT;
+	fsize->stepwise.max_height = RISP_MAX_HEIGHT;
+	fsize->stepwise.step_height = 1u << RISP_SIZE_ALIGNMENT;
 
 	return 0;
 }
-- 
2.55.0


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

* Re: [PATCH v1] media: rcar-isp: ispcore: Fix inconsistent step sizes
  2026-09-29 13:30 [PATCH v1] media: rcar-isp: ispcore: Fix inconsistent step sizes Barnabás Pőcze
@ 2026-09-29 14:30 ` Niklas Söderlund
  0 siblings, 0 replies; 2+ messages in thread
From: Niklas Söderlund @ 2026-09-29 14:30 UTC (permalink / raw)
  To: Barnabás Pőcze
  Cc: Mauro Carvalho Chehab, Geert Uytterhoeven, Magnus Damm,
	Jacopo Mondi, Sakari Ailus, linux-media, linux-renesas-soc,
	linux-kernel

Hi Barnabás,

Thanks for your work.

On 2026-09-29 15:30:21 +0200, Barnabás Pőcze wrote:
> `risp_io_{input,capture}_enum_framesizes()` sets the horizonal and vertical

nit: horizontal

> step size to 2. However, `risp_io_{input,capture}_try_format()` passes 2
> to `v4l_bound_align_image()`, which corresponds to a step size of 2^2 = 4.
> 
> So move these constants into macros to avoid the repetition, and with that,
> use 4 as the step size everywhere.
> 
> Fixes: 2151350f60d1 ("media: rcar-isp: Add support for ISPCORE")
> Signed-off-by: Barnabás Pőcze <barnabas.pocze+renesas@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  .../media/platform/renesas/rcar-isp/core-io.c | 40 +++++++++++--------
>  1 file changed, 24 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/media/platform/renesas/rcar-isp/core-io.c b/drivers/media/platform/renesas/rcar-isp/core-io.c
> index 820af506f896c..b60b91f43d42d 100644
> --- a/drivers/media/platform/renesas/rcar-isp/core-io.c
> +++ b/drivers/media/platform/renesas/rcar-isp/core-io.c
> @@ -15,6 +15,12 @@
>  
>  #include "risp-core.h"
>  
> +#define RISP_MIN_WIDTH 128
> +#define RISP_MAX_WIDTH 5120
> +#define RISP_MIN_HEIGHT 128
> +#define RISP_MAX_HEIGHT 4096
> +#define RISP_SIZE_ALIGNMENT 2 /* 2^2 = 4 */
> +
>  #define risp_io_err(d, fmt, arg...)         dev_err((d)->core->dev, fmt, ##arg)
>  
>  static struct risp_buffer *risp_io_vb2buf(struct vb2_v4l2_buffer *vb)
> @@ -330,8 +336,9 @@ static void risp_io_input_try_format(struct rcar_isp_core_io *io,
>  {
>  	unsigned int bpp = 0;
>  
> -	v4l_bound_align_image(&pix->width, 128, 5120, 2,
> -			      &pix->height, 128, 4096, 2, 0);
> +	v4l_bound_align_image(&pix->width, RISP_MIN_WIDTH, RISP_MAX_WIDTH, RISP_SIZE_ALIGNMENT,
> +			      &pix->height, RISP_MIN_HEIGHT, RISP_MAX_HEIGHT, RISP_SIZE_ALIGNMENT,
> +			      0);
>  
>  	for (unsigned int i = 0; i < ARRAY_SIZE(risp_io_input_formats); i++) {
>  		if (risp_io_input_formats[i].fourcc == pix->pixelformat) {
> @@ -423,13 +430,13 @@ static int risp_io_input_enum_framesizes(struct file *file, void *fh,
>  
>  	fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
>  
> -	fsize->stepwise.min_width = 128;
> -	fsize->stepwise.max_width = 5120;
> -	fsize->stepwise.step_width = 2;
> +	fsize->stepwise.min_width = RISP_MIN_WIDTH;
> +	fsize->stepwise.max_width = RISP_MAX_WIDTH;
> +	fsize->stepwise.step_width = 1u << RISP_SIZE_ALIGNMENT;
>  
> -	fsize->stepwise.min_height = 128;
> -	fsize->stepwise.max_height = 4096;
> -	fsize->stepwise.step_height = 2;
> +	fsize->stepwise.min_height = RISP_MIN_HEIGHT;
> +	fsize->stepwise.max_height = RISP_MAX_HEIGHT;
> +	fsize->stepwise.step_height = 1u << RISP_SIZE_ALIGNMENT;
>  
>  	return 0;
>  }
> @@ -720,8 +727,9 @@ static const struct v4l2_pix_format_mplane risp_io_capture_default_format = {
>  static void risp_io_capture_try_format(struct rcar_isp_core_io *io,
>  				       struct v4l2_pix_format_mplane *pix)
>  {
> -	v4l_bound_align_image(&pix->width, 128, 5120, 2,
> -			      &pix->height, 128, 4096, 2, 0);
> +	v4l_bound_align_image(&pix->width, RISP_MIN_WIDTH, RISP_MAX_WIDTH, RISP_SIZE_ALIGNMENT,
> +			      &pix->height, RISP_MIN_HEIGHT, RISP_MAX_HEIGHT, RISP_SIZE_ALIGNMENT,
> +			      0);
>  
>  	pix->field = V4L2_FIELD_NONE;
>  	pix->colorspace = V4L2_COLORSPACE_SRGB;
> @@ -824,13 +832,13 @@ static int risp_io_capture_enum_framesizes(struct file *file, void *fh,
>  
>  	fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
>  
> -	fsize->stepwise.min_width = 128;
> -	fsize->stepwise.max_width = 5120;
> -	fsize->stepwise.step_width = 2;
> +	fsize->stepwise.min_width = RISP_MIN_WIDTH;
> +	fsize->stepwise.max_width = RISP_MAX_WIDTH;
> +	fsize->stepwise.step_width = 1u << RISP_SIZE_ALIGNMENT;
>  
> -	fsize->stepwise.min_height = 128;
> -	fsize->stepwise.max_height = 4096;
> -	fsize->stepwise.step_height = 2;
> +	fsize->stepwise.min_height = RISP_MIN_HEIGHT;
> +	fsize->stepwise.max_height = RISP_MAX_HEIGHT;
> +	fsize->stepwise.step_height = 1u << RISP_SIZE_ALIGNMENT;
>  
>  	return 0;
>  }
> -- 
> 2.55.0
> 

-- 
Kind Regards,
Niklas Söderlund

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

end of thread, other threads:[~2026-09-29 14:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-29 13:30 [PATCH v1] media: rcar-isp: ispcore: Fix inconsistent step sizes Barnabás Pőcze
2026-09-29 14:30 ` Niklas Söderlund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®