public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/25] drivers: media: imx283 improvements
@ 2026-02-13 14:01 Kieran Bingham
  2026-02-13 14:01 ` [PATCH v2 01/25] media: i2c: imx283: Report correct V4L2_SEL_TGT_CROP Kieran Bingham
  2026-02-13 14:01 ` [PATCH v2 02/25] media: i2c: imx283: Fix handling of unsupported mbus codes Kieran Bingham
  0 siblings, 2 replies; 5+ messages in thread
From: Kieran Bingham @ 2026-02-13 14:01 UTC (permalink / raw)
  To: Umang Jain, Sakari Ailus, Mauro Carvalho Chehab, Hans Verkuil
  Cc: Jai Luthra, linux-media, linux-kernel, Kieran Bingham,
	Stefan Klug, stable

This now far more extensive series reposts some patches which provide
fixes to the users of the IMX283 camera sensor to resolve handling
exposure and blanking updates and the reporting of the cropping modes
configured.

The series then goes on to extensively extend the driver to move towards
a dedicated scan out structure allowing mode definitions to be greatly
simplified and factor out a lot of common definitions and duplication.

Vertical offset corrections are added which handle the correct
alignment of the output mode in the different binning combinations which
otherwise translate to an offset in the image capture which is
detectable when the camera is used as a measurement device.

To make use of this, the horizontal and vertical configuration is
refactored to make it clearer what calculations are being performed and
manage the vertical positioning based on the VOB and binning offsets
accordingly.

This then provides us with a mechanism to fix a separate issue that
occurs on the IMX283 where an 'extra black line' is inserted by the
sensor to resolve bayer re-ordering. This extra line is undesirable in
the output and so we account for this and remove it by instead
requesting *two* additional lines, and moving two lines back into the
VOB data type. The extra line is required to maintain bayer order, and
moving the lines prevents them from being added to the captured image.

Extra modes are added based on this new simplified mode configuration
structure to match the diagrams present in the sensor datasheet.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
Kieran Bingham (23):
      media: i2c: imx283: Move imx283_mode structure definition
      media: i2c: imx283: Move scan out data to single data structure
      media: i2c: imx283: Remove horizontal_ob
      media: i2c: imx283: Move vertical_ob to scan modes
      media: i2c: imx283: Factor out vertical cropping parameters
      media: i2c: imx283: Vertical offset corrections
      media: i2c: imx283: Define recommended area
      media: i2c: imx283: Move Horizontal configuration block
      media: i2c: imx283: Constrain scope of vertical calculations
      media: i2c: imx283: Simplify v_pos determination
      media: i2c: imx283: Move binning to scan modes
      media: i2c: imx283: Move minimum exposure handling to scan modes
      media: i2c: imx283: Simplify and clamp widcut calculation
      media: i2c: imx283: Account for clamp region coordinates
      media: i2c: imx283: Crop leading lines with user clamp
      media: i2c: imx283: Reduce vertical cutting
      media: i2c: imx283: Provide Native pixel array capture mode
      media: i2c: imx283: Provide a full active pixels mode
      media: i2c: imx283: Provide an effective pixel array mode
      media: i2c: imx283: Recalculate SHR on blanking changes
      media: i2c: imx283: Fix binned mode blanking timings
      media: i2c: imx283: Update exposure range on blanking changes
      media: i2c: imx283: Simplify VFLIP control setting

Stefan Klug (2):
      media: i2c: imx283: Report correct V4L2_SEL_TGT_CROP
      media: i2c: imx283: Fix handling of unsupported mbus codes

 drivers/media/i2c/imx283.c | 600 +++++++++++++++++++++++++++++----------------
 1 file changed, 393 insertions(+), 207 deletions(-)
---
base-commit: c824345288d11e269ce41b36c105715bc2286050
change-id: 20260212-mainline-imx283-v2-695ef290871f

Best regards,
-- 
--
Kieran


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

* [PATCH v2 01/25] media: i2c: imx283: Report correct V4L2_SEL_TGT_CROP
  2026-02-13 14:01 [PATCH v2 00/25] drivers: media: imx283 improvements Kieran Bingham
@ 2026-02-13 14:01 ` Kieran Bingham
  2026-02-16 14:39   ` Jai Luthra
  2026-02-13 14:01 ` [PATCH v2 02/25] media: i2c: imx283: Fix handling of unsupported mbus codes Kieran Bingham
  1 sibling, 1 reply; 5+ messages in thread
From: Kieran Bingham @ 2026-02-13 14:01 UTC (permalink / raw)
  To: Umang Jain, Sakari Ailus, Mauro Carvalho Chehab, Hans Verkuil
  Cc: Jai Luthra, linux-media, linux-kernel, Kieran Bingham,
	Stefan Klug, stable

From: Stefan Klug <stefan.klug@ideasonboard.com>

The target crop rectangle is initialized with the crop of the default
sensor mode. This is incorrect when a different sensor mode gets
selected. Fix that by updating the crop rectangle when changing the
sensor mode.

Cc: stable@vger.kernel.org # v6.10-rc1-70-gccb4eb4496fa
Fixes: ccb4eb4496fa ("media: i2c: Add imx283 camera sensor driver")
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 drivers/media/i2c/imx283.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
index 8ab63ad8f385..e5c04d259625 100644
--- a/drivers/media/i2c/imx283.c
+++ b/drivers/media/i2c/imx283.c
@@ -956,6 +956,7 @@ static int imx283_set_pad_format(struct v4l2_subdev *sd,
 				 struct v4l2_subdev_state *sd_state,
 				 struct v4l2_subdev_format *fmt)
 {
+	struct v4l2_rect *crop;
 	struct v4l2_mbus_framefmt *format;
 	const struct imx283_mode *mode;
 	struct imx283 *imx283 = to_imx283(sd);
@@ -982,6 +983,9 @@ static int imx283_set_pad_format(struct v4l2_subdev *sd,
 
 	*format = fmt->format;
 
+	crop = v4l2_subdev_state_get_crop(sd_state, IMAGE_PAD);
+	*crop = mode->crop;
+
 	return 0;
 }
 

-- 
2.52.0


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

* [PATCH v2 02/25] media: i2c: imx283: Fix handling of unsupported mbus codes
  2026-02-13 14:01 [PATCH v2 00/25] drivers: media: imx283 improvements Kieran Bingham
  2026-02-13 14:01 ` [PATCH v2 01/25] media: i2c: imx283: Report correct V4L2_SEL_TGT_CROP Kieran Bingham
@ 2026-02-13 14:01 ` Kieran Bingham
  2026-02-16 14:41   ` Jai Luthra
  1 sibling, 1 reply; 5+ messages in thread
From: Kieran Bingham @ 2026-02-13 14:01 UTC (permalink / raw)
  To: Umang Jain, Sakari Ailus, Mauro Carvalho Chehab, Hans Verkuil
  Cc: Jai Luthra, linux-media, linux-kernel, Kieran Bingham,
	Stefan Klug, stable

From: Stefan Klug <stefan.klug@ideasonboard.com>

When the code requested by imx283_set_pad_format() is not supported, a
kernel exception occurs due to dereferencing the mode variable which is
null. Fix that by correcting the code to a valid value before getting
the mode table.

While at it, remove the cases for the other unsupported codes in
get_mode_table.

Cc: stable@vger.kernel.org # v6.10-rc1-70-gccb4eb4496fa
Fixes: ccb4eb4496fa ("media: i2c: Add imx283 camera sensor driver")
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 drivers/media/i2c/imx283.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
index e5c04d259625..9a47cd0b181a 100644
--- a/drivers/media/i2c/imx283.c
+++ b/drivers/media/i2c/imx283.c
@@ -576,23 +576,31 @@ static inline struct imx283 *to_imx283(struct v4l2_subdev *sd)
 	return container_of_const(sd, struct imx283, sd);
 }
 
+static inline int get_format_code(unsigned int code)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(imx283_mbus_codes); i++)
+		if (imx283_mbus_codes[i] == code)
+			break;
+
+	if (i >= ARRAY_SIZE(imx283_mbus_codes))
+		i = 0;
+
+	return imx283_mbus_codes[i];
+}
+
 static inline void get_mode_table(unsigned int code,
 				  const struct imx283_mode **mode_list,
 				  unsigned int *num_modes)
 {
 	switch (code) {
 	case MEDIA_BUS_FMT_SRGGB12_1X12:
-	case MEDIA_BUS_FMT_SGRBG12_1X12:
-	case MEDIA_BUS_FMT_SGBRG12_1X12:
-	case MEDIA_BUS_FMT_SBGGR12_1X12:
 		*mode_list = supported_modes_12bit;
 		*num_modes = ARRAY_SIZE(supported_modes_12bit);
 		break;
 
 	case MEDIA_BUS_FMT_SRGGB10_1X10:
-	case MEDIA_BUS_FMT_SGRBG10_1X10:
-	case MEDIA_BUS_FMT_SGBRG10_1X10:
-	case MEDIA_BUS_FMT_SBGGR10_1X10:
 		*mode_list = supported_modes_10bit;
 		*num_modes = ARRAY_SIZE(supported_modes_10bit);
 		break;
@@ -963,6 +971,8 @@ static int imx283_set_pad_format(struct v4l2_subdev *sd,
 	const struct imx283_mode *mode_list;
 	unsigned int num_modes;
 
+	fmt->format.code = get_format_code(fmt->format.code);
+
 	get_mode_table(fmt->format.code, &mode_list, &num_modes);
 
 	mode = v4l2_find_nearest_size(mode_list, num_modes, width, height,
@@ -1361,8 +1371,6 @@ static int imx283_init_controls(struct imx283 *imx283)
 
 	imx283->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx283_ctrl_ops, V4L2_CID_VFLIP,
 					  0, 1, 1, 0);
-	if (imx283->vflip)
-		imx283->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
 
 	v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &imx283_ctrl_ops,
 				     V4L2_CID_TEST_PATTERN,

-- 
2.52.0


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

* Re: [PATCH v2 01/25] media: i2c: imx283: Report correct V4L2_SEL_TGT_CROP
  2026-02-13 14:01 ` [PATCH v2 01/25] media: i2c: imx283: Report correct V4L2_SEL_TGT_CROP Kieran Bingham
@ 2026-02-16 14:39   ` Jai Luthra
  0 siblings, 0 replies; 5+ messages in thread
From: Jai Luthra @ 2026-02-16 14:39 UTC (permalink / raw)
  To: Hans Verkuil, Kieran Bingham, Mauro Carvalho Chehab, Sakari Ailus,
	Umang Jain
  Cc: linux-media, linux-kernel, Kieran Bingham, Stefan Klug, stable

Quoting Kieran Bingham (2026-02-13 19:31:40)
> From: Stefan Klug <stefan.klug@ideasonboard.com>
> 
> The target crop rectangle is initialized with the crop of the default
> sensor mode. This is incorrect when a different sensor mode gets
> selected. Fix that by updating the crop rectangle when changing the
> sensor mode.
> 
> Cc: stable@vger.kernel.org # v6.10-rc1-70-gccb4eb4496fa
> Fixes: ccb4eb4496fa ("media: i2c: Add imx283 camera sensor driver")
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>

Reviewed-by: Jai Luthra <jai.luthra@ideasonboard.com> 

> ---
>  drivers/media/i2c/imx283.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
> index 8ab63ad8f385..e5c04d259625 100644
> --- a/drivers/media/i2c/imx283.c
> +++ b/drivers/media/i2c/imx283.c
> @@ -956,6 +956,7 @@ static int imx283_set_pad_format(struct v4l2_subdev *sd,
>                                  struct v4l2_subdev_state *sd_state,
>                                  struct v4l2_subdev_format *fmt)
>  {
> +       struct v4l2_rect *crop;
>         struct v4l2_mbus_framefmt *format;
>         const struct imx283_mode *mode;
>         struct imx283 *imx283 = to_imx283(sd);
> @@ -982,6 +983,9 @@ static int imx283_set_pad_format(struct v4l2_subdev *sd,
>  
>         *format = fmt->format;
>  
> +       crop = v4l2_subdev_state_get_crop(sd_state, IMAGE_PAD);
> +       *crop = mode->crop;
> +
>         return 0;
>  }
>  
> 
> -- 
> 2.52.0
>

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

* Re: [PATCH v2 02/25] media: i2c: imx283: Fix handling of unsupported mbus codes
  2026-02-13 14:01 ` [PATCH v2 02/25] media: i2c: imx283: Fix handling of unsupported mbus codes Kieran Bingham
@ 2026-02-16 14:41   ` Jai Luthra
  0 siblings, 0 replies; 5+ messages in thread
From: Jai Luthra @ 2026-02-16 14:41 UTC (permalink / raw)
  To: Hans Verkuil, Kieran Bingham, Mauro Carvalho Chehab, Sakari Ailus,
	Umang Jain
  Cc: linux-media, linux-kernel, Kieran Bingham, Stefan Klug, stable

Quoting Kieran Bingham (2026-02-13 19:31:41)
> From: Stefan Klug <stefan.klug@ideasonboard.com>
> 
> When the code requested by imx283_set_pad_format() is not supported, a
> kernel exception occurs due to dereferencing the mode variable which is
> null. Fix that by correcting the code to a valid value before getting
> the mode table.
> 
> While at it, remove the cases for the other unsupported codes in
> get_mode_table.
> 
> Cc: stable@vger.kernel.org # v6.10-rc1-70-gccb4eb4496fa
> Fixes: ccb4eb4496fa ("media: i2c: Add imx283 camera sensor driver")
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>

Reviewed-by: Jai Luthra <jai.luthra@ideasonboard.com> 

> ---
>  drivers/media/i2c/imx283.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
> index e5c04d259625..9a47cd0b181a 100644
> --- a/drivers/media/i2c/imx283.c
> +++ b/drivers/media/i2c/imx283.c
> @@ -576,23 +576,31 @@ static inline struct imx283 *to_imx283(struct v4l2_subdev *sd)
>         return container_of_const(sd, struct imx283, sd);
>  }
>  
> +static inline int get_format_code(unsigned int code)
> +{
> +       unsigned int i;
> +
> +       for (i = 0; i < ARRAY_SIZE(imx283_mbus_codes); i++)
> +               if (imx283_mbus_codes[i] == code)
> +                       break;
> +
> +       if (i >= ARRAY_SIZE(imx283_mbus_codes))
> +               i = 0;
> +
> +       return imx283_mbus_codes[i];
> +}
> +
>  static inline void get_mode_table(unsigned int code,
>                                   const struct imx283_mode **mode_list,
>                                   unsigned int *num_modes)
>  {
>         switch (code) {
>         case MEDIA_BUS_FMT_SRGGB12_1X12:
> -       case MEDIA_BUS_FMT_SGRBG12_1X12:
> -       case MEDIA_BUS_FMT_SGBRG12_1X12:
> -       case MEDIA_BUS_FMT_SBGGR12_1X12:
>                 *mode_list = supported_modes_12bit;
>                 *num_modes = ARRAY_SIZE(supported_modes_12bit);
>                 break;
>  
>         case MEDIA_BUS_FMT_SRGGB10_1X10:
> -       case MEDIA_BUS_FMT_SGRBG10_1X10:
> -       case MEDIA_BUS_FMT_SGBRG10_1X10:
> -       case MEDIA_BUS_FMT_SBGGR10_1X10:
>                 *mode_list = supported_modes_10bit;
>                 *num_modes = ARRAY_SIZE(supported_modes_10bit);
>                 break;
> @@ -963,6 +971,8 @@ static int imx283_set_pad_format(struct v4l2_subdev *sd,
>         const struct imx283_mode *mode_list;
>         unsigned int num_modes;
>  
> +       fmt->format.code = get_format_code(fmt->format.code);
> +
>         get_mode_table(fmt->format.code, &mode_list, &num_modes);
>  
>         mode = v4l2_find_nearest_size(mode_list, num_modes, width, height,
> @@ -1361,8 +1371,6 @@ static int imx283_init_controls(struct imx283 *imx283)
>  
>         imx283->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx283_ctrl_ops, V4L2_CID_VFLIP,
>                                           0, 1, 1, 0);
> -       if (imx283->vflip)
> -               imx283->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
>  
>         v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &imx283_ctrl_ops,
>                                      V4L2_CID_TEST_PATTERN,
> 
> -- 
> 2.52.0
>

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

end of thread, other threads:[~2026-02-16 14:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-13 14:01 [PATCH v2 00/25] drivers: media: imx283 improvements Kieran Bingham
2026-02-13 14:01 ` [PATCH v2 01/25] media: i2c: imx283: Report correct V4L2_SEL_TGT_CROP Kieran Bingham
2026-02-16 14:39   ` Jai Luthra
2026-02-13 14:01 ` [PATCH v2 02/25] media: i2c: imx283: Fix handling of unsupported mbus codes Kieran Bingham
2026-02-16 14:41   ` Jai Luthra

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