| Message ID | 20251114-exposure-limits-v3-0-b7c07feba026@ideasonboard.com |
|---|---|
| Headers | show
Return-Path: <libcamera-devel-bounces@lists.libcamera.org> 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 48A02C3241 for <parsemail@patchwork.libcamera.org>; Fri, 14 Nov 2025 14:17:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CD5EB60AA2; Fri, 14 Nov 2025 15:17:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Os/dYRoJ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 97915606E6 for <libcamera-devel@lists.libcamera.org>; Fri, 14 Nov 2025 15:17:17 +0100 (CET) Received: from [192.168.1.101] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 60258664; Fri, 14 Nov 2025 15:15:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1763129716; bh=8m+wntdMi41yAY12WJr2lymuQSVkTRfXUOaNIIQ/pgY=; h=From:Subject:Date:To:Cc:From; b=Os/dYRoJl0Yz0JEw4MHiRcHvSPMmOhQ/vH+PO1toBPS8jwseBDDf+vSmZoDXLVCdV 5DwT25P1lc/uX1X1hOMsDxT7sn1VBSSPiRhW7rkZiM1FEnI9UU9+Sa09OMqxBIw0JI VwJBiFFaSeb3uXjzjtYGRowROmZLog9t7BZQ0QVk= From: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Subject: [PATCH v3 00/19] libipa: agc: Calculate exposure limits Date: Fri, 14 Nov 2025 15:16:55 +0100 Message-Id: <20251114-exposure-limits-v3-0-b7c07feba026@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIANc5F2kC/3XNQQ6CMBCF4auQrq2hUwrVlfcwLko7yCRCSYsEQ 7i7hZWJuvxfMt8sLGIgjOycLSzgRJF8n0IeMmZb09+Rk0vNIAclclFxnAcfnwH5gzoaI1e20KC gQVVolq6GgA3Nu3i9pW4pjj689geT2Nb/1iR4zkvQ2jpdYiVOF3Joou9rb4I7Wt+xjZzggwH9z UBijK6VkUJLkPiDWdf1DYe/8o/8AAAA X-Change-ID: 20251017-exposure-limits-5c48252fe548 To: =?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>, Robert Mader <robert.mader@collabora.com>, libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>, Kieran Bingham <kieran.bingham@ideasonboard.com>, Laurent Pinchart <laurent.pinchart@ideasonboard.com> X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6916; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=8m+wntdMi41yAY12WJr2lymuQSVkTRfXUOaNIIQ/pgY=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpFznqH5VqjBHjuj49na25tTYxEBRHEpH9t5XnT pSBKQtYCxeJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaRc56gAKCRByNAaPFqFW PHAFEACe1n3QR3/e79KOaaLm4OQYXnlFQuiWNBjhn8Db3GWXPfBeCGlSgOTgxFONlLF6t0Ka3sr +V4V8m+T38BfjjUwEj17hVCQmIz5IJhzxE4n0US5+X9bUqP6HPF7ouloopnd12fRBTyU5lbvWlH arL16ez8IkKY1d/ivbgLryOSG5Fmz8ddaG6/Vd3caLHhQWD/c3SFYfxUH9j62KlWCPGX9x/pELs HpkUL5aPM27Mi6Bq6FTB8V7GOE+/8n1cAkrIdM67h3uJ0w/2qoAu+lv/N4DurIpz36ZGe8hmQ6U v35cdlsi/dJ6aAllKa8GzE8NVVw4IB7IqPb/g2taEaCpsGMqn8VYSmCzSQNkiCx1P5+Qz8vMrpI LoOXSNr4EACOoaNrGAD0Va6XlbmCkNuPo9NHJ0fPCWM43omn5nnU3sPT31rYiuMQwOj/E4OW1XI Tiji23JzCQEkHGFbbdBWJeWX53JAUOGNI5dLZ6eq7wjq1Snejm3g6mhbJZ1aicmLBqMRg4vq/nu 1i4nDQUFMv2TV007txdvWk+4JFbHu/ryG5BMBnFPN/BrZmYxb911oopRzud/8J1WTGsnRKWzBty oEw9SrDroXp9Nnna5FjPTS14TRjOMh0jE81uYdgsyCsvssqaIclrruGYuUlI0qGBlQA1vTWOm3z CnyVLgtFzjgX6/A== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: <libcamera-devel.lists.libcamera.org> List-Unsubscribe: <https://lists.libcamera.org/options/libcamera-devel>, <mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe> List-Archive: <https://lists.libcamera.org/pipermail/libcamera-devel/> List-Post: <mailto:libcamera-devel@lists.libcamera.org> List-Help: <mailto:libcamera-devel-request@lists.libcamera.org?subject=help> List-Subscribe: <https://lists.libcamera.org/listinfo/libcamera-devel>, <mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe> Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" <libcamera-devel-bounces@lists.libcamera.org> |
| Series |
|
| Related |
show
|
By definition, the exposure time that can be programmed on a sensor is limited by the frame duration and whenever the frame duration is updated, the exposure time limits should be updated as well. This is not the case for IPAs using the AgcMeanLuminance algorithm from libipa, where the exposure limits are computed at configure() time and never updated. This has two implications: 1) The AGC algorithms will always operate with an exposure time bound to the frame duration programmed at startup time 2) The Camera::controls() limits are not updated to reflect the new constraints This series addresses issue 1) by changing the AgcMeanLuminance class and the associated helpers to regulate the exposure time base on the currently programmed max frame duration using a sensor-specific margin that is now reported by the CameraHelper class. In order to get there, a few things worth describing on the design of the series. Along the whole series, I tried to separate "sensor" configuration data from run-time configuration data. The main target here is to facilitate the work Kieran is doing about centralizing the sensor configuration in the sensorHelper, so that each IPA doesn't have to populate and handle the sensor configuration data. For this reason I tried to: 1) Align all IPAS to use the same IPAContext.configuration.sensor layout where they populate the sensor configuration data at configure() time 2) Make the AgcMeanLuminance and ExposureModeHelper class use a similar type to: - Pass configuration data to AgcMeanLuminance::configure() - Store the configuration data separately from the run-time data in ExposureModeHelper I'm not thrilled by adding more types, one per each class, but hopefully this should make it easy to replace all of them by just using the camera sensor helper As the AgcMeanLuminance algorithm tries to push the exposure time up to the maximum allowed frame duration, initializing the algorithm with the sensor's maximum capabilities results in a very low frame rate, unless the user specifies a FrameDurationLimits range in which the algorithm should operate. To avoid slowing the frame rate down too much compute a "default" frame rate at algorithm configuration time, were the canonical 30, 15 and 10 FPS values are tested and selected in order of preference. I took the occasion to also rework the AgcMeanLuminance interface which now looks like: - AgcMeanLuminance::configure(sensorConfig, sensorHelper) - AgcMeanLuminance::setExposureLimits(fixedShutter, fixedGain, frameDuration) Once all IPAs have been moved to compute the exposure time from the frame duration, the exposure time can be removed from the sensor configuration data. Niklas suggested we should remove inspecting V4L2_CID_EXPOSURE completely. While I don't 100% agree this is any problem, I tried to do so, but the minExposureTime is effectivelly a sensor parameter and if the kernel offers an easy way to retrieve it I think we should use it. The last patch is not for inclusion as Mali support needs to be finalized upstream first, but shows how is it possible to handle frame duration limits and exposure with the new model (and I needed that patch for testing on Mali anyway). Tested with camshark on Mali-C55 and RkISP1 and with a test scripts that sets a longer frame duration (66 msecs) and by validating that the exposure time is increased to match the new limits on RkISP1. RkISP1Agc agc.cpp:644 Divided up exposure time, analogue gain, quantization gain and digital gain are 33251.27us, 10.6667, 1.00018 and 6.49639 61.545331 (47.58 fps) cam0-stream0 seq: 000050 bytesused: 2073600/1036800 kISP1Agc agc.cpp:644 Divided up exposure time, analogue gain, quantization gain and digital gain are 66578.16us, 10.6667, 1.00018 and 3.24451 61.566241 (47.82 fps) cam0-stream0 seq: 000051 bytesused: 2073600/1036800 Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> --- Changes in v3: - EDITME: describe what is new in this series revision. - EDITME: use bulletpoints and terse descriptions. - Link to v2: https://lore.kernel.org/r/20251028-exposure-limits-v2-0-a8b5a318323e@ideasonboard.com Changes in v2: - Rework of v1 that moves the exposure limits computation to the AgcMeanLuminance exposure helpers --- Jacopo Mondi (18): ipa: ipu3: Move CameraHelper to context ipa: rkisp1: Store FrameDurationLimits as sensor config ipa: mali: Move exposure limits to sensor config ipa: ipu3: Move exposure limits to sensor config ipa: camera_sensor_helper: Introduce maxShutterTime() ipa: camera_sensor_helper: Introduce minFrameDuration() ipa: libipa: agc: Remove unused accessors ipa: libipa: agc: Store sensor configuration parameters ipa: libipa: agc: Make Agc::configure() set limits ipa: libipa: agc: Pass the frame duration to configure() ipa: libipa: agc: Compute max shutter time with frame duration ipa: libipa: agc: Calculate exposure limits with frame duration ipa: libipa: agc: Rework setLimits() interface ipa: libipa: agc: Fold resetFrameCount() in configure() ipa: libipa: Remove maxExposureTime from sensor configuration ipa: rkisp1: agc: Calculate frame duration using cam helper ipa: libipa: agc: Initialize a sensible frame duration [DNI] ipa: mali: Handle FrameDurationLimits Kieran Bingham (1): ipa: mali-c55: Move CameraHelper to context src/ipa/ipu3/algorithms/agc.cpp | 29 +++---- src/ipa/ipu3/algorithms/agc.h | 4 - src/ipa/ipu3/ipa_context.cpp | 29 +++---- src/ipa/ipu3/ipa_context.h | 17 ++-- src/ipa/ipu3/ipu3.cpp | 37 ++++---- src/ipa/libipa/agc_mean_luminance.cpp | 127 ++++++++++++++++++++------- src/ipa/libipa/agc_mean_luminance.h | 27 ++++-- src/ipa/libipa/camera_sensor_helper.cpp | 113 ++++++++++++++++++++++++ src/ipa/libipa/camera_sensor_helper.h | 6 ++ src/ipa/libipa/exposure_mode_helper.cpp | 148 +++++++++++++++++++++----------- src/ipa/libipa/exposure_mode_helper.h | 36 +++++--- src/ipa/mali-c55/algorithms/agc.cpp | 73 +++++++++++++--- src/ipa/mali-c55/ipa_context.cpp | 6 ++ src/ipa/mali-c55/ipa_context.h | 21 ++++- src/ipa/mali-c55/mali-c55.cpp | 55 ++++++------ src/ipa/rkisp1/algorithms/agc.cpp | 92 +++++++++----------- src/ipa/rkisp1/ipa_context.cpp | 3 - src/ipa/rkisp1/ipa_context.h | 3 +- src/ipa/rkisp1/rkisp1.cpp | 45 ++++++---- 19 files changed, 598 insertions(+), 273 deletions(-) --- base-commit: 6d19c813b0a74770165e032e7f527c36b838e456 change-id: 20251017-exposure-limits-5c48252fe548 Best regards,