diff mbox series

[v2,09/18] media: i2c: imx219: Infer binning settings from format and crop

Message ID 20230821223001.28480-10-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series media: i2c: imx219: Miscellaneous cleanups and improvements | expand

Commit Message

Laurent Pinchart Aug. 21, 2023, 10:29 p.m. UTC
Compare the format and crop rectangle dimensions to infer binning
settings, instead of storing the binning mode in the imx219_mode
structure. This removes duplicate information from the mode.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/i2c/imx219.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

Comments

Jacopo Mondi Aug. 28, 2023, 1:39 p.m. UTC | #1
Hi Laurent

On Tue, Aug 22, 2023 at 01:29:52AM +0300, Laurent Pinchart wrote:
> Compare the format and crop rectangle dimensions to infer binning
> settings, instead of storing the binning mode in the imx219_mode
> structure. This removes duplicate information from the mode.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

> ---
>  drivers/media/i2c/imx219.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
> index 1205986ce47e..0c26cbfe58f3 100644
> --- a/drivers/media/i2c/imx219.c
> +++ b/drivers/media/i2c/imx219.c
> @@ -161,9 +161,6 @@ struct imx219_mode {
>
>  	/* V-timing */
>  	unsigned int vts_def;
> -
> -	/* 2x2 binning is used */
> -	bool binning;
>  };
>
>  static const struct cci_reg_sequence imx219_common_regs[] = {
> @@ -306,7 +303,6 @@ static const struct imx219_mode supported_modes[] = {
>  			.height = 2464
>  		},
>  		.vts_def = IMX219_VTS_15FPS,
> -		.binning = false,
>  	},
>  	{
>  		/* 1080P 30fps cropped */
> @@ -319,7 +315,6 @@ static const struct imx219_mode supported_modes[] = {
>  			.height = 1080
>  		},
>  		.vts_def = IMX219_VTS_30FPS_1080P,
> -		.binning = false,
>  	},
>  	{
>  		/* 2x2 binned 30fps mode */
> @@ -332,7 +327,6 @@ static const struct imx219_mode supported_modes[] = {
>  			.height = 2464
>  		},
>  		.vts_def = IMX219_VTS_30FPS_BINNED,
> -		.binning = true,
>  	},
>  	{
>  		/* 640x480 30fps mode */
> @@ -345,7 +339,6 @@ static const struct imx219_mode supported_modes[] = {
>  			.height = 960
>  		},
>  		.vts_def = IMX219_VTS_30FPS_640x480,
> -		.binning = true,
>  	},
>  };
>
> @@ -648,7 +641,7 @@ static int imx219_set_framefmt(struct imx219 *imx219,
>  	cci_write(imx219->regmap, IMX219_REG_Y_ADD_END_A,
>  		  crop->top - IMX219_PIXEL_ARRAY_TOP + crop->height - 1, &ret);
>
> -	if (!imx219->mode->binning)
> +	if (format->width == crop->width && format->height == crop->height)
>  		bin_mode = IMX219_BINNING_NONE;
>  	else if (bpp == 8)
>  		bin_mode = IMX219_BINNING_2X2_ANALOG;
> --
> Regards,
>
> Laurent Pinchart
>
Dave Stevenson Aug. 29, 2023, 9:55 a.m. UTC | #2
Hi Laurent

Sorry for the delay in reviewing these ones - I got lost in the subdev
state stuff and the magic associated with "which" changing the state
passed in.

On Mon, 21 Aug 2023 at 23:30, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Compare the format and crop rectangle dimensions to infer binning
> settings, instead of storing the binning mode in the imx219_mode
> structure. This removes duplicate information from the mode.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

> ---
>  drivers/media/i2c/imx219.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
> index 1205986ce47e..0c26cbfe58f3 100644
> --- a/drivers/media/i2c/imx219.c
> +++ b/drivers/media/i2c/imx219.c
> @@ -161,9 +161,6 @@ struct imx219_mode {
>
>         /* V-timing */
>         unsigned int vts_def;
> -
> -       /* 2x2 binning is used */
> -       bool binning;
>  };
>
>  static const struct cci_reg_sequence imx219_common_regs[] = {
> @@ -306,7 +303,6 @@ static const struct imx219_mode supported_modes[] = {
>                         .height = 2464
>                 },
>                 .vts_def = IMX219_VTS_15FPS,
> -               .binning = false,
>         },
>         {
>                 /* 1080P 30fps cropped */
> @@ -319,7 +315,6 @@ static const struct imx219_mode supported_modes[] = {
>                         .height = 1080
>                 },
>                 .vts_def = IMX219_VTS_30FPS_1080P,
> -               .binning = false,
>         },
>         {
>                 /* 2x2 binned 30fps mode */
> @@ -332,7 +327,6 @@ static const struct imx219_mode supported_modes[] = {
>                         .height = 2464
>                 },
>                 .vts_def = IMX219_VTS_30FPS_BINNED,
> -               .binning = true,
>         },
>         {
>                 /* 640x480 30fps mode */
> @@ -345,7 +339,6 @@ static const struct imx219_mode supported_modes[] = {
>                         .height = 960
>                 },
>                 .vts_def = IMX219_VTS_30FPS_640x480,
> -               .binning = true,
>         },
>  };
>
> @@ -648,7 +641,7 @@ static int imx219_set_framefmt(struct imx219 *imx219,
>         cci_write(imx219->regmap, IMX219_REG_Y_ADD_END_A,
>                   crop->top - IMX219_PIXEL_ARRAY_TOP + crop->height - 1, &ret);
>
> -       if (!imx219->mode->binning)
> +       if (format->width == crop->width && format->height == crop->height)
>                 bin_mode = IMX219_BINNING_NONE;
>         else if (bpp == 8)
>                 bin_mode = IMX219_BINNING_2X2_ANALOG;
> --
> Regards,
>
> Laurent Pinchart
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 1205986ce47e..0c26cbfe58f3 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -161,9 +161,6 @@  struct imx219_mode {
 
 	/* V-timing */
 	unsigned int vts_def;
-
-	/* 2x2 binning is used */
-	bool binning;
 };
 
 static const struct cci_reg_sequence imx219_common_regs[] = {
@@ -306,7 +303,6 @@  static const struct imx219_mode supported_modes[] = {
 			.height = 2464
 		},
 		.vts_def = IMX219_VTS_15FPS,
-		.binning = false,
 	},
 	{
 		/* 1080P 30fps cropped */
@@ -319,7 +315,6 @@  static const struct imx219_mode supported_modes[] = {
 			.height = 1080
 		},
 		.vts_def = IMX219_VTS_30FPS_1080P,
-		.binning = false,
 	},
 	{
 		/* 2x2 binned 30fps mode */
@@ -332,7 +327,6 @@  static const struct imx219_mode supported_modes[] = {
 			.height = 2464
 		},
 		.vts_def = IMX219_VTS_30FPS_BINNED,
-		.binning = true,
 	},
 	{
 		/* 640x480 30fps mode */
@@ -345,7 +339,6 @@  static const struct imx219_mode supported_modes[] = {
 			.height = 960
 		},
 		.vts_def = IMX219_VTS_30FPS_640x480,
-		.binning = true,
 	},
 };
 
@@ -648,7 +641,7 @@  static int imx219_set_framefmt(struct imx219 *imx219,
 	cci_write(imx219->regmap, IMX219_REG_Y_ADD_END_A,
 		  crop->top - IMX219_PIXEL_ARRAY_TOP + crop->height - 1, &ret);
 
-	if (!imx219->mode->binning)
+	if (format->width == crop->width && format->height == crop->height)
 		bin_mode = IMX219_BINNING_NONE;
 	else if (bpp == 8)
 		bin_mode = IMX219_BINNING_2X2_ANALOG;