Skip to contentSkip to conversation

media: atomisp: Avoid picking too big sensor resolution

PATCH Superseded Hans de Goede 2 participants 3 messages Nov 6, 2024 – Nov 7, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: atomisp: Avoid picking too big sensor resolution

atomisp_try_fmt() is limiting the width of the requested resolution to 1920 before calling the sensor's try_fmt() method. But it is not limiting the height. In case of the old mode-list based t4ka3 driver which has a mode list of:

736x496
896x736
1936x1096
3280x2464

This results in 3280x2464 being selected when try_fmt is called with a requested resolution of 3280x2464, which is not supported because its width > 1920 .

Fix this by also limiting the height when in preview mode.

---
 drivers/staging/media/atomisp/pci/atomisp_cmd.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +7 -2
index 02ccf80e6559..10462c5db36f 100644
@@ -3784,9 +3784,14 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,
 			return -EINVAL;
 	}
 
-	/* The preview pipeline does not support width > 1920 */
-	if (asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW)
+	/*
+	 * The preview pipeline does not support width > 1920. Also limit height
+	 * to avoid sensor drivers still picking a too wide resolution.
+	 */
+	if (asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW) {
 		f->width = min_t(u32, f->width, 1920);
+		f->height = min_t(u32, f->height, 1440);
+	}
 
 	/*
 	 * atomisp_set_fmt() will set the sensor resolution to the requested
Signature · 1 line
2.47.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Hans de Goede

atomisp_try_fmt() is limiting the width of the requested resolution to 1920 before calling the sensor's try_fmt() method. But it is not limiting the height. In case of the old mode-list based t4ka3 driver which has a mode list of:

736x496
896x736
1936x1096
3280x2464

Quoted 5 lines

This results in 3280x2464 being selected when try_fmt is called with a requested resolution of 3280x2464, which is not supported because its width > 1920 .

Fix this by also limiting the height when in preview mode.

...

drivers/staging/media/atomisp/pci/atomisp_cmd.c int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, · line 3793

Quoted 7 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +6 -0
+	/*
+	 * The preview pipeline does not support width > 1920. Also limit height
+	 * to avoid sensor drivers still picking a too wide resolution.
+	 */
+	if (asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW) {
 		f->width = min_t(u32, f->width, 1920);
+		f->height = min_t(u32, f->height, 1440);

Perhaps umin() instead of min_t() in both cases?

Quoted 1 line
drivers/staging/media/atomisp/pci/atomisp_cmd.c +1 -0
+	}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 1 line · Andy Shevchenko

On Wed, Nov 06, 2024 at 10:55:09PM +0100, Hans de Goede wrote:

...

Quoted 4 lines

drivers/staging/media/atomisp/pci/atomisp_cmd.c int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, · line 3793

Quoted 2 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +1 -0
 		f->width = min_t(u32, f->width, 1920);
+		f->height = min_t(u32, f->height, 1440);

Perhaps umin() instead of min_t() in both cases?

...or min(..., 1920U); and similar for the second one.

Signature · 2 lines
With Best Regards,
Andy Shevchenko