summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Klug <stefan.klug@ideasonboard.com>2024-12-16 16:40:42 +0100
committerStefan Klug <stefan.klug@ideasonboard.com>2024-12-17 10:31:44 +0100
commitdb9b6f8e2302842e0bb153f0c9600444a21ef670 (patch)
treeb12f85f7c31106232af344f95ddaad4d0723ab4f /src
parent479e8c851c4adc354472af1cd70abda802f9da2e (diff)
pipeline: rkisp1: Keep aspect ratio on imx8mp
In the current code, the input stage of the image resizer is used to apply a crop to keep the aspect ratio in cases where the requested output aspect ratio differs from the one of the selected sensor mode. On the imx8mp the resizer hardware is not capable of cropping (for reference see also rkisp1-resizer.c:rkisp1_rsz_set_sink_crop() in the linux kernel v6.10). Therefore apply the necessary cropping on the output of the ISP (on the image stabilization block). The cropping code on the image resizer doesn't need modifications as the requested crop gets ignored by the kernel. While at it, remove a todo comment that is no longer needed. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1.cpp13
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1_path.cpp13
2 files changed, 21 insertions, 5 deletions
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 8b92fdeb..698fe9ff 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -812,6 +812,19 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
if (!isRaw_)
format.code = MEDIA_BUS_FMT_YUYV8_2X8;
+ /*
+ * On devices without DUAL_CROP (like the imx8mp) cropping needs to be
+ * done on the ISP/IS output.
+ */
+ if (media_->hwRevision() == RKISP1_V_IMX8MP) {
+ /* imx8mp has only a single path. */
+ const auto &cfg = config->at(0);
+ Size ispCrop = format.size.boundedToAspectRatio(cfg.size)
+ .alignedUpTo(2, 2);
+ rect = ispCrop.centeredTo(Rectangle(format.size).center());
+ format.size = ispCrop;
+ }
+
LOG(RkISP1, Debug)
<< "Configuring ISP output pad with " << format
<< " crop " << rect;
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
index 236d05af..eee5b09e 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
@@ -417,11 +417,14 @@ int RkISP1Path::configure(const StreamConfiguration &config,
/*
* Crop on the resizer input to maintain FOV before downscaling.
*
- * \todo The alignment to a multiple of 2 pixels is required but may
- * change the aspect ratio very slightly. A more advanced algorithm to
- * compute the resizer input crop rectangle is needed, and it should
- * also take into account the need to crop away the edge pixels affected
- * by the ISP processing blocks.
+ * Note that this does not apply to devices without DUAL_CROP support
+ * (like imx8mp) , where the cropping needs to be done on the
+ * ImageStabilizer block on the ISP source pad and therefore is
+ * configured before this stage. For simplicity we still set the crop.
+ * This gets ignored by the kernel driver because the hardware is
+ * missing the capability.
+ *
+ * Alignment to a multiple of 2 pixels is required by the resizer.
*/
Size ispCrop = inputFormat.size.boundedToAspectRatio(config.size)
.alignedUpTo(2, 2);