From patchwork Fri Dec 6 10:13:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22192 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CF7CFBF415 for ; Fri, 6 Dec 2024 10:13:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9C49E66127; Fri, 6 Dec 2024 11:13:50 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MXtMoEIl"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2266D618B2 for ; Fri, 6 Dec 2024 11:13:49 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:3543:aebe:e043:ef86]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8D2BA74C; Fri, 6 Dec 2024 11:13:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733479999; bh=eaFLC0KhTlzndRfLm1UyB2GHt6kkR/7neELI7By3TaM=; h=From:To:Cc:Subject:Date:From; b=MXtMoEIlTY1fgWsucb5PUV86E/72qQSRMh7cYQaJ2xzmm9paR0pLNr0yiYu8rfiSo F/VlFcPrtHp+rtp9Ogu/Fru2Sbi2C8VzN9PK9h42AA2ojbuRn7reqRVSl6Xsb5a5iu EJ17kFzzN5i5pMFcMvDCG6tZpBLkcyZ6QH9w6tqQ= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v3 00/17] rkisp1: Fix aspect ratio and ScalerCrop Date: Fri, 6 Dec 2024 11:13:22 +0100 Message-ID: <20241206101344.767170-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi all, This series contains fixes for a few issues on the imx8mp that I'd like to get in before the next release. Version 3 is a major extension which is described in the last paragraph. Patch 1 is a drive by fix Patch 2 Fixes the aspect ratio on the imx8mp. There is code to keep the aspect ratio in the rkisp1 pipeline that adjust the input crop on the resizer stage. On the imx8mp however the resizer hardware is missing that functionality and cropping needs to be done on the ISP output. Patch 2 implements that. Patches 3-8 fix the ScalerCrop control. The existing implementation implements ScalerCrop in dewarper coordinates (After scaling down). This is incorrect as ScalerCrop is specified to be in sensor coordinates. To fix that, patches 3-6 do preparatory changes and patch 6 implements the correct ScalerCrop control. Patch 8 adds ScalerMaximumCrop for completeness sake. Note that this solution while being correct on the numbers is still not ideal, because the aspect ratio preserving crop on the ISP output is still applied unconditionally. That will get fixed in an upcoming series, where the full sensor size get's passed to the dewarper and all cropping/scaling gets handled there. Patches 9-17 were added after version 2 because it got clear that the current master is completely missing the dewarper size validation and that requires fixing. So patches 9-15 do the necessary plumbing and implementation of the validation. Thanks Jacopo for helping with that. Patches 16-17 fixe another bug found during that work where the sensor might get configured to a size not supported by the isp. Best regards, Stefan Changes in v3: - Fixes from review (see individual changelogs) - Added pipeline validation for the dewarper - Fixed bug where sensor might be configured to a format incompatible with the isp Changes in v2: - Some smaller fixes from review (see individual changelogs) - Added [PATCH v2 6/8] libcamera: converter_v4l2_m2m: Improve crop bounds support to be able to provide sane default values for ScalerCrop before configure() Jacopo Mondi (2): libcamera: converter: Add functions to adjust config libcamera: stream: Add operator<<(StreamConfiguration) Stefan Klug (15): libcamera: rkisp1: Fix scope of dewarper stop() exit action libcamera: rkisp1: Keep aspect ratio on imx8mp libcamera: geometry: Add Rectangle::transformedBetween() pipeline: rkisp1: Split inputCrop and outputCrop pipeline: rkisp1: Reorder sensorInfo collection code libcamera: converter_v4l2_m2m: Improve crop bounds support pipeline: rkisp1: Fix ScalerCrop to be in sensor coordinates pipeline: rkisp1: Add ScalerMaximumCrop property libcamera: rkisp1: Refactor path validation libcamera: rkisp1: Enable the dewarper unconditionally camera: Add a const version of the pipe() function libcamera: rkisp1: make RkISP1CameraConfiguration a friend of the pipeline handler pipeline: rkisp1: Fix config validation when dewarper is used libcamera: camera_sensor: Add parameter to limit returned sensor size libcamera: pipeline: rkisp1: Limit sensor size to max resolution include/libcamera/geometry.h | 3 + include/libcamera/internal/camera.h | 1 + include/libcamera/internal/camera_sensor.h | 2 +- include/libcamera/internal/converter.h | 17 ++ .../internal/converter/converter_v4l2_m2m.h | 12 + include/libcamera/stream.h | 2 + src/libcamera/camera.cpp | 5 + src/libcamera/converter.cpp | 46 +++ .../converter/converter_v4l2_m2m.cpp | 282 ++++++++++++++---- src/libcamera/geometry.cpp | 49 +++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 182 ++++++++--- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 13 +- src/libcamera/pipeline/rkisp1/rkisp1_path.h | 1 + src/libcamera/sensor/camera_sensor.cpp | 3 + src/libcamera/sensor/camera_sensor_legacy.cpp | 9 +- src/libcamera/stream.cpp | 13 + test/geometry.cpp | 11 + 17 files changed, 543 insertions(+), 108 deletions(-)