From patchwork Fri Nov 15 07:46:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 21897 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 4DEB5C0F1B for ; Fri, 15 Nov 2024 07:46:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AA91A6586A; Fri, 15 Nov 2024 08:46:51 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="iLQRkE0F"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9E14B6584E for ; Fri, 15 Nov 2024 08:46:48 +0100 (CET) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 45FCC55; Fri, 15 Nov 2024 08:46:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731656793; bh=tb/oYz+8E680gPSRWmmqn5/zAMFkysuKilhimQHGIAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iLQRkE0Feocz8ljiKCHQM75Ag5YRipAbEldh6lOsVM1kHh/W4RJ2XQnQ1UPx+9o/l VQoR8Io7bIfDt5dsk1b3w0X++HlBVqCsT59ZyESJiJj7TozcmfqHIPNoPdpqiT8TWc MC/GYZx6abRfpqNOQ2mY54PTPq/xDHfce8M1rFx8= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH v3 1/6] ipa: libipa: Add colour helpers Date: Fri, 15 Nov 2024 07:46:23 +0000 Message-Id: <20241115074628.417215-2-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115074628.417215-1-dan.scally@ideasonboard.com> References: <20241115074628.417215-1-dan.scally@ideasonboard.com> 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" We start to have some functions relating to colour that are effectively identical crop up across the IPA modules. Add a file allowing those to be centralised within libipa so that a single implementation can be used in all of the IPAs. Signed-off-by: Daniel Scally Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Reviewed-by: Laurent Pinchart --- Changes in v3: - Named the file "colours.h" and "colours.cpp" instead of "helpers" - Made the rec601LuminanceFromRGB() arguments doubles Changes in v2: - Dropped the Q(m, n) format helpers until they're needed. - \return statements after long description - Switched rec601LuminanceFromRGB() to return a double src/ipa/libipa/colours.cpp | 77 ++++++++++++++++++++++++++++++++++++++ src/ipa/libipa/colours.h | 21 +++++++++++ src/ipa/libipa/meson.build | 2 + 3 files changed, 100 insertions(+) create mode 100644 src/ipa/libipa/colours.cpp create mode 100644 src/ipa/libipa/colours.h diff --git a/src/ipa/libipa/colours.cpp b/src/ipa/libipa/colours.cpp new file mode 100644 index 00000000..9fcb53b0 --- /dev/null +++ b/src/ipa/libipa/colours.cpp @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2024, Ideas on Board Oy + * + * libipa miscellaneous colour helpers + */ + +#include "colours.h" + +#include +#include + +namespace libcamera { + +namespace ipa { + +/** + * \file colours.h + * \brief Functions to reduce code duplication between IPA modules + */ + +/** + * \brief Estimate luminance from RGB values following ITU-R BT.601 + * \param[in] r The red value + * \param[in] g The green value + * \param[in] b The blue value + * + * This function estimates a luminance value from a triplet of Red, Green and + * Blue values, following the formula defined by ITU-R Recommendation BT.601-7 + * which can be found at https://www.itu.int/rec/R-REC-BT.601 + * + * \return The estimated luminance value + */ +double rec601LuminanceFromRGB(double r, double g, double b) +{ + return (r * .299) + (g * .587) + (b * .114); +} + +/** + * \brief Estimate correlated colour temperature from RGB color space input + * \param[in] red The input red value + * \param[in] green The input green value + * \param[in] blue The input blue value + * + * This function estimates the correlated color temperature RGB color space + * input. In physics and color science, the Planckian locus or black body locus + * is the path or locus that the color of an incandescent black body would take + * in a particular chromaticity space as the blackbody temperature changes. + * + * If a narrow range of color temperatures is considered (those encapsulating + * daylight being the most practical case) one can approximate the Planckian + * locus in order to calculate the CCT in terms of chromaticity coordinates. + * + * More detailed information can be found in: + * https://en.wikipedia.org/wiki/Color_temperature#Approximation + * + * \return The estimated color temperature + */ +uint32_t estimateCCT(double red, double green, double blue) +{ + /* Convert the RGB values to CIE tristimulus values (XYZ) */ + double X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue); + double Y = (-0.32466) * (red) + (1.57837) * (green) + (-0.73191) * (blue); + double Z = (-0.68202) * (red) + (0.77073) * (green) + (0.56332) * (blue); + + /* Calculate the normalized chromaticity values */ + double x = X / (X + Y + Z); + double y = Y / (X + Y + Z); + + /* Calculate CCT */ + double n = (x - 0.3320) / (0.1858 - y); + return 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33; +} + +} /* namespace ipa */ + +} /* namespace libcamera */ diff --git a/src/ipa/libipa/colours.h b/src/ipa/libipa/colours.h new file mode 100644 index 00000000..b42ed0ac --- /dev/null +++ b/src/ipa/libipa/colours.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2024, Ideas on Board Oy + * + * libipa miscellaneous colour helpers + */ + +#pragma once + +#include + +namespace libcamera { + +namespace ipa { + +double rec601LuminanceFromRGB(double r, double g, double b); +uint32_t estimateCCT(double red, double green, double blue); + +} /* namespace ipa */ + +} /* namespace libcamera */ diff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build index e78cbcd6..788d037a 100644 --- a/src/ipa/libipa/meson.build +++ b/src/ipa/libipa/meson.build @@ -4,6 +4,7 @@ libipa_headers = files([ 'agc_mean_luminance.h', 'algorithm.h', 'camera_sensor_helper.h', + 'colours.h', 'exposure_mode_helper.h', 'fc_queue.h', 'histogram.h', @@ -19,6 +20,7 @@ libipa_sources = files([ 'agc_mean_luminance.cpp', 'algorithm.cpp', 'camera_sensor_helper.cpp', + 'colours.cpp', 'exposure_mode_helper.cpp', 'fc_queue.cpp', 'histogram.cpp', From patchwork Fri Nov 15 07:46:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 21898 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 DA68AC3261 for ; Fri, 15 Nov 2024 07:46:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5CF7A65862; Fri, 15 Nov 2024 08:46:52 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Lw8nYR48"; 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 D08256585B for ; Fri, 15 Nov 2024 08:46:48 +0100 (CET) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8FF669CE; Fri, 15 Nov 2024 08:46:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731656793; bh=BWaOBbJjNQKmurhUT9SgNBHUiCHJRtyeVuFEj3PWKfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lw8nYR48z369MTZE4FheObjUWm7wsrk9m0+FM6msU3UgTqYsdFdF9SKuKJfNS/4iF dTg0p4aGFMoNXMEJ70jjD7RTX0fA6b+A2erHdLO9aUZfpvWhp9nChAJzwePVs3jQ3g Hjc440nn14XWF9ZAH1kZ2IIta2BkvP9VcTKyPNU4= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH v3 2/6] ipa: ipu3: Use centralised libipa helpers Date: Fri, 15 Nov 2024 07:46:24 +0000 Message-Id: <20241115074628.417215-3-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115074628.417215-1-dan.scally@ideasonboard.com> References: <20241115074628.417215-1-dan.scally@ideasonboard.com> 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" Use the centralised libipa helpers instead of open coding common functions. Signed-off-by: Daniel Scally Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Reviewed-by: Laurent Pinchart --- Changes in v3: - None Changes in v2: - Dropped the ipa:: prefix for function calls src/ipa/ipu3/algorithms/agc.cpp | 7 ++++--- src/ipa/ipu3/algorithms/awb.cpp | 32 ++------------------------------ src/ipa/ipu3/algorithms/awb.h | 1 - 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index c5f3d8f0..466b3fb3 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -17,6 +17,7 @@ #include +#include "libipa/colours.h" #include "libipa/histogram.h" /** @@ -185,9 +186,9 @@ double Agc::estimateLuminance(double gain) const blueSum += std::min(std::get<2>(rgbTriples_[i]) * gain, 255.0); } - double ySum = redSum * rGain_ * 0.299 - + greenSum * gGain_ * 0.587 - + blueSum * bGain_ * 0.114; + double ySum = rec601LuminanceFromRGB(redSum * rGain_, + greenSum * gGain_, + blueSum * bGain_); return ySum / (bdsGrid_.height * bdsGrid_.width) / 255; } diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp index 4d6e3994..c3c8b074 100644 --- a/src/ipa/ipu3/algorithms/awb.cpp +++ b/src/ipa/ipu3/algorithms/awb.cpp @@ -13,6 +13,8 @@ #include +#include "libipa/colours.h" + /** * \file awb.h */ @@ -301,36 +303,6 @@ void Awb::prepare(IPAContext &context, params->use.acc_ccm = 1; } -/** - * The function estimates the correlated color temperature using - * from RGB color space input. - * In physics and color science, the Planckian locus or black body locus is - * the path or locus that the color of an incandescent black body would take - * in a particular chromaticity space as the blackbody temperature changes. - * - * If a narrow range of color temperatures is considered (those encapsulating - * daylight being the most practical case) one can approximate the Planckian - * locus in order to calculate the CCT in terms of chromaticity coordinates. - * - * More detailed information can be found in: - * https://en.wikipedia.org/wiki/Color_temperature#Approximation - */ -uint32_t Awb::estimateCCT(double red, double green, double blue) -{ - /* Convert the RGB values to CIE tristimulus values (XYZ) */ - double X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue); - double Y = (-0.32466) * (red) + (1.57837) * (green) + (-0.73191) * (blue); - double Z = (-0.68202) * (red) + (0.77073) * (green) + (0.56332) * (blue); - - /* Calculate the normalized chromaticity values */ - double x = X / (X + Y + Z); - double y = Y / (X + Y + Z); - - /* Calculate CCT */ - double n = (x - 0.3320) / (0.1858 - y); - return 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33; -} - /* Generate an RGB vector with the average values for each zone */ void Awb::generateZones() { diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h index c0202823..a13c49ac 100644 --- a/src/ipa/ipu3/algorithms/awb.h +++ b/src/ipa/ipu3/algorithms/awb.h @@ -75,7 +75,6 @@ private: void generateAwbStats(const ipu3_uapi_stats_3a *stats); void clearAwbStats(); void awbGreyWorld(); - uint32_t estimateCCT(double red, double green, double blue); static constexpr uint16_t threshold(float value); static constexpr uint16_t gainValue(double gain); From patchwork Fri Nov 15 07:46:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 21899 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 C7CADC0F1B for ; Fri, 15 Nov 2024 07:46:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E9C2465869; Fri, 15 Nov 2024 08:46:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jzxLBMn2"; 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 0D1516585E for ; Fri, 15 Nov 2024 08:46:49 +0100 (CET) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DAA72FC5; Fri, 15 Nov 2024 08:46:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731656794; bh=pYUogIqwFlE9rtSCiMpCOv+mp+KdUEJQt/YLSUmQY2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jzxLBMn23Kl0C6VfveVtulnt42I0sE583H/az83MaIRKHwwuJtqjlPJnpXCPoPkkB K4qJji4BaGkPIaMjPXX8/UYR5dHxfRi/LooKmgRgmVbzmg3nlGHxAdjvT6xDXFjdmd KLdbtyPfdqQtUH9BPOhYFq2amvtt7Jf0PZO4k66Y= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally , Jacopo Mondi Subject: [PATCH v3 3/6] ipa: rkisp1: Use centralised libipa helpers Date: Fri, 15 Nov 2024 07:46:25 +0000 Message-Id: <20241115074628.417215-4-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115074628.417215-1-dan.scally@ideasonboard.com> References: <20241115074628.417215-1-dan.scally@ideasonboard.com> 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" Use the centralised libipa helpers instead of open-coding common functions. Reviewed-by: Jacopo Mondi Signed-off-by: Daniel Scally Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Reviewed-by: Laurent Pinchart --- Changes in v3: - None Changes in v2: - Dropped the ipa:: prefix for function calls src/ipa/rkisp1/algorithms/awb.cpp | 18 ++---------------- src/ipa/rkisp1/algorithms/awb.h | 2 -- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index b3c00bef..5c1d9511 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -16,6 +16,8 @@ #include +#include "libipa/colours.h" + /** * \file awb.h */ @@ -178,22 +180,6 @@ void Awb::prepare(IPAContext &context, const uint32_t frame, } } -uint32_t Awb::estimateCCT(double red, double green, double blue) -{ - /* Convert the RGB values to CIE tristimulus values (XYZ) */ - double X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue); - double Y = (-0.32466) * (red) + (1.57837) * (green) + (-0.73191) * (blue); - double Z = (-0.68202) * (red) + (0.77073) * (green) + (0.56332) * (blue); - - /* Calculate the normalized chromaticity values */ - double x = X / (X + Y + Z); - double y = Y / (X + Y + Z); - - /* Calculate CCT */ - double n = (x - 0.3320) / (0.1858 - y); - return 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33; -} - /** * \copydoc libcamera::ipa::Algorithm::process */ diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h index b3b2c0bb..6ac3a5c3 100644 --- a/src/ipa/rkisp1/algorithms/awb.h +++ b/src/ipa/rkisp1/algorithms/awb.h @@ -32,8 +32,6 @@ public: ControlList &metadata) override; private: - uint32_t estimateCCT(double red, double green, double blue); - bool rgbMode_; }; From patchwork Fri Nov 15 07:46:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 21900 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 6C929C32CE for ; Fri, 15 Nov 2024 07:46:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 51D0165873; Fri, 15 Nov 2024 08:46:55 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IIg0UbqG"; 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 1E29C6585F for ; Fri, 15 Nov 2024 08:46:49 +0100 (CET) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3BF8C1114; Fri, 15 Nov 2024 08:46:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731656794; bh=lcrlNkc6CH1nbUiNUpE3DSZJPddES9HIFWoJs45Fifk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IIg0UbqG41RmfD6k4zpsmay9OhQ+hdmNnJsPm9t+ecmSvMwDQN5Xvq20RVDJgWnKI YmyJc24ZESKwH8gpsqcVU1WqWeIvLMcIGlzTvgZ8Fx6FoG3hlXhG7MdRtug0FAvhbf YumQNOBW3NipJdpaVvhhgMR+sh6B8kiNmOMTTUDc= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH v3 4/6] ipa: rpi: Use centralised libipa helpers Date: Fri, 15 Nov 2024 07:46:26 +0000 Message-Id: <20241115074628.417215-5-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115074628.417215-1-dan.scally@ideasonboard.com> References: <20241115074628.417215-1-dan.scally@ideasonboard.com> 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" Use the centralised libipa helpers rather than open coding common functions. Signed-off-by: Daniel Scally Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Naushir Patuck --- Changes in v3: - None Changes in v2: - None. Jacopo; this isn't in the libcamera::ipa namespace. As an alternative to the prefix I could "using namespace libcamera::ipa" if that's better? src/ipa/rpi/controller/rpi/agc_channel.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp index c9df9b5b..8583f4f3 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.cpp +++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp @@ -12,6 +12,8 @@ #include +#include "libipa/colours.h" + #include "../awb_status.h" #include "../device_status.h" #include "../histogram.h" @@ -694,11 +696,11 @@ static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb, double ySum; /* Factor in the AWB correction if needed. */ if (stats->agcStatsPos == Statistics::AgcStatsPos::PreWb) { - ySum = rSum * awb.gainR * .299 + - gSum * awb.gainG * .587 + - bSum * awb.gainB * .114; + ySum = ipa::rec601LuminanceFromRGB(rSum * awb.gainR, + gSum * awb.gainG, + bSum * awb.gainB); } else - ySum = rSum * .299 + gSum * .587 + bSum * .114; + ySum = ipa::rec601LuminanceFromRGB(rSum, gSum, bSum); return ySum / pixelSum / (1 << 16); } From patchwork Fri Nov 15 07:46:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 21901 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 9D24FC330B for ; Fri, 15 Nov 2024 07:46:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EA7236586F; Fri, 15 Nov 2024 08:46:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XaD5flRd"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 43ECB65860 for ; Fri, 15 Nov 2024 08:46:49 +0100 (CET) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 855D7291; Fri, 15 Nov 2024 08:46:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731656794; bh=dBcOvZc7yO3j2flltzJyhsLe7qUtFxUMmu8yS4jIYMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XaD5flRd3olg+HdF6xdqqMAjnM9PW8NW7xY0M/33nqiYLHCN+yLlcaiV8ASmYI3U4 QEn+RyRMiJ+pLMLjyzMeHkb+ydCE/SncsumIdglgNPGt06z8l9RoA7AyR0bYlWSfOw edJUStt0XBMm7BCcrPu7n5j9rYGEgzKACYnn9VNc= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH v3 5/6] libcamera: camera_sensor_properties: Add sensor control delays Date: Fri, 15 Nov 2024 07:46:27 +0000 Message-Id: <20241115074628.417215-6-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115074628.417215-1-dan.scally@ideasonboard.com> References: <20241115074628.417215-1-dan.scally@ideasonboard.com> 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" Add properties covering the sensor control application delays to both the static CameraSensorProperties definitions. The values used are the defaults that're in use across the library, with deviations from that taken from Raspberry Pi's CamHelper class definitions. Signed-off-by: Daniel Scally --- Changes in v3: - Rebased on top of the CameraSensorFactory introduction - Some rephrasing - Defined the sensorDelays member as empty where Raspberry Pi didn't have any specific values. Check for the empty struct in getSensorDelays() and return the defaults from there with a warning. Changes in v2: - Rather than adding the delays to the properties ControlList, added a new function in CameraSensor that allows PipelineHandlers to retreive the delay values. include/libcamera/internal/camera_sensor.h | 2 + .../internal/camera_sensor_properties.h | 9 +++ src/libcamera/sensor/camera_sensor.cpp | 13 +++ src/libcamera/sensor/camera_sensor_legacy.cpp | 33 ++++++++ .../sensor/camera_sensor_properties.cpp | 79 +++++++++++++++++++ 5 files changed, 136 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 8aafd82e..a9b2d494 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -73,6 +73,8 @@ public: virtual const std::vector & testPatternModes() const = 0; virtual int setTestPatternMode(controls::draft::TestPatternModeEnum mode) = 0; + virtual void getSensorDelays(uint8_t &exposureDelay, uint8_t &gainDelay, + uint8_t &vblankDelay, uint8_t &hblankDelay) = 0; }; class CameraSensorFactoryBase diff --git a/include/libcamera/internal/camera_sensor_properties.h b/include/libcamera/internal/camera_sensor_properties.h index 480ac121..56d5c15d 100644 --- a/include/libcamera/internal/camera_sensor_properties.h +++ b/include/libcamera/internal/camera_sensor_properties.h @@ -10,6 +10,8 @@ #include #include +#include + #include #include @@ -20,6 +22,13 @@ struct CameraSensorProperties { Size unitCellSize; std::map testPatternModes; + + struct { + uint8_t exposureDelay; + uint8_t gainDelay; + uint8_t vblankDelay; + uint8_t hblankDelay; + } sensorDelays; }; } /* namespace libcamera */ diff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp index 54cf98b2..61420873 100644 --- a/src/libcamera/sensor/camera_sensor.cpp +++ b/src/libcamera/sensor/camera_sensor.cpp @@ -336,6 +336,19 @@ CameraSensor::~CameraSensor() = default; * pattern mode for every frame thus incurs no performance penalty. */ +/** + * \fn CameraSensor::getSensorDelays() + * \brief Fetch the sensor delay values + * \param[out] exposureDelay The exposure delay + * \param[out] gainDelay The analogue gain delay + * \param[out] vblankDelay The vblank delay + * \param[out] hblankDelay The hblank delay + * + * This function fills in sensor control delays for pipeline handlers to use to + * inform the DelayedControls. If no static properties are available it fills in + * some widely applicable default values. + */ + /** * \class CameraSensorFactoryBase * \brief Base class for camera sensor factories diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index a9b15c03..84972f02 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -95,6 +95,8 @@ public: const std::vector & testPatternModes() const override { return testPatternModes_; } int setTestPatternMode(controls::draft::TestPatternModeEnum mode) override; + void getSensorDelays(uint8_t &exposureDelay, uint8_t &gainDelay, + uint8_t &vblankDelay, uint8_t &hblankDelay) override; protected: std::string logPrefix() const override; @@ -482,6 +484,37 @@ void CameraSensorLegacy::initStaticProperties() initTestPatternModes(); } +void CameraSensorLegacy::getSensorDelays(uint8_t &exposureDelay, uint8_t &gainDelay, + uint8_t &vblankDelay, uint8_t &hblankDelay) +{ + + /* + * These defaults are applicable to many sensors, however more specific + * values can be added to the CameraSensorProperties for a sensor if + * required. + */ + if (!staticProps_ || + (!staticProps_->sensorDelays.exposureDelay && + !staticProps_->sensorDelays.gainDelay && + !staticProps_->sensorDelays.vblankDelay && + !staticProps_->sensorDelays.hblankDelay)) { + LOG(CameraSensor, Warning) + << "No sensor delays found in static properties. " + "Assuming unverified defaults."; + + exposureDelay = 2; + gainDelay = 1; + vblankDelay = 2; + hblankDelay = 2; + return; + } + + exposureDelay = staticProps_->sensorDelays.exposureDelay; + gainDelay = staticProps_->sensorDelays.gainDelay; + vblankDelay = staticProps_->sensorDelays.vblankDelay; + hblankDelay = staticProps_->sensorDelays.hblankDelay; +} + void CameraSensorLegacy::initTestPatternModes() { const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN); diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp index 6d4136d0..6dda7ba9 100644 --- a/src/libcamera/sensor/camera_sensor_properties.cpp +++ b/src/libcamera/sensor/camera_sensor_properties.cpp @@ -41,6 +41,13 @@ LOG_DEFINE_CATEGORY(CameraSensorProperties) * \brief Map that associates the TestPattern control value with the indexes of * the corresponding sensor test pattern modes as returned by * V4L2_CID_TEST_PATTERN. + * + * \var CameraSensorProperties::sensorDelays + * \brief Holds the delays, expressed in number of frames, between the time a + * control is applied to the sensor and the time it actually takes effect. + * Delays are recorded for the exposure time, analogue gain, vertical and + * horizontal blanking. These values may be defined as empty, in which case the + * CameraSensor derivative should provide default values. */ /** @@ -60,6 +67,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeColorBars, 2 }, { controls::draft::TestPatternModeColorBarsFadeToGray, 3 }, }, + .sensorDelays = { }, } }, { "ar0521", { .unitCellSize = { 2200, 2200 }, @@ -69,6 +77,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeColorBars, 2 }, { controls::draft::TestPatternModeColorBarsFadeToGray, 3 }, }, + .sensorDelays = { }, } }, { "hi846", { .unitCellSize = { 1120, 1120 }, @@ -87,6 +96,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * 9: "Resolution Pattern" */ }, + .sensorDelays = { }, } }, { "imx214", { .unitCellSize = { 1120, 1120 }, @@ -97,6 +107,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeColorBarsFadeToGray, 3 }, { controls::draft::TestPatternModePn9, 4 }, }, + .sensorDelays = { }, } }, { "imx219", { .unitCellSize = { 1120, 1120 }, @@ -107,6 +118,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeColorBarsFadeToGray, 3 }, { controls::draft::TestPatternModePn9, 4 }, }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "imx258", { .unitCellSize = { 1120, 1120 }, @@ -117,34 +134,62 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeColorBarsFadeToGray, 3 }, { controls::draft::TestPatternModePn9, 4 }, }, + .sensorDelays = { }, } }, { "imx283", { .unitCellSize = { 2400, 2400 }, .testPatternModes = {}, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 2, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "imx290", { .unitCellSize = { 2900, 2900 }, .testPatternModes = {}, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 2, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "imx296", { .unitCellSize = { 3450, 3450 }, .testPatternModes = {}, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 2, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "imx327", { .unitCellSize = { 2900, 2900 }, .testPatternModes = {}, + .sensorDelays = { }, } }, { "imx335", { .unitCellSize = { 2000, 2000 }, .testPatternModes = {}, + .sensorDelays = { }, } }, { "imx415", { .unitCellSize = { 1450, 1450 }, .testPatternModes = {}, + .sensorDelays = { }, } }, { "imx477", { .unitCellSize = { 1550, 1550 }, .testPatternModes = {}, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 2, + .vblankDelay = 3, + .hblankDelay = 3 + }, } }, { "imx519", { .unitCellSize = { 1220, 1220 }, @@ -157,6 +202,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * these two patterns do not comply with MIPI CCS v1.1 (Section 10.1). */ }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 2, + .vblankDelay = 3, + .hblankDelay = 3 + }, } }, { "imx708", { .unitCellSize = { 1400, 1400 }, @@ -167,6 +218,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeColorBarsFadeToGray, 3 }, { controls::draft::TestPatternModePn9, 4 }, }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 2, + .vblankDelay = 3, + .hblankDelay = 3 + }, } }, { "ov2685", { .unitCellSize = { 1750, 1750 }, @@ -181,6 +238,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * 5: "Color Square" */ }, + .sensorDelays = { }, } }, { "ov2740", { .unitCellSize = { 1400, 1400 }, @@ -188,6 +246,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeOff, 0 }, { controls::draft::TestPatternModeColorBars, 1}, }, + .sensorDelays = { }, } }, { "ov4689", { .unitCellSize = { 2000, 2000 }, @@ -201,6 +260,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * colorBarType2 and colorBarType3. */ }, + .sensorDelays = { }, } }, { "ov5640", { .unitCellSize = { 1400, 1400 }, @@ -208,10 +268,17 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeOff, 0 }, { controls::draft::TestPatternModeColorBars, 1 }, }, + .sensorDelays = { }, } }, { "ov5647", { .unitCellSize = { 1400, 1400 }, .testPatternModes = {}, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 2, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov5670", { .unitCellSize = { 1120, 1120 }, @@ -219,6 +286,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeOff, 0 }, { controls::draft::TestPatternModeColorBars, 1 }, }, + .sensorDelays = { }, } }, { "ov5675", { .unitCellSize = { 1120, 1120 }, @@ -226,6 +294,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeOff, 0 }, { controls::draft::TestPatternModeColorBars, 1 }, }, + .sensorDelays = { }, } }, { "ov5693", { .unitCellSize = { 1400, 1400 }, @@ -238,6 +307,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * Rolling Bar". */ }, + .sensorDelays = { }, } }, { "ov64a40", { .unitCellSize = { 1008, 1008 }, @@ -251,6 +321,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * 4: "Vertical Color Bar Type 4" */ }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 2, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov8858", { .unitCellSize = { 1120, 1120 }, @@ -264,6 +340,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * 4: "Vertical Color Bar Type 4" */ }, + .sensorDelays = { }, } }, { "ov8865", { .unitCellSize = { 1400, 1400 }, @@ -278,6 +355,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * 5: "Color squares with rolling bar" */ }, + .sensorDelays = { }, } }, { "ov13858", { .unitCellSize = { 1120, 1120 }, @@ -285,6 +363,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeOff, 0 }, { controls::draft::TestPatternModeColorBars, 1 }, }, + .sensorDelays = { }, } }, }; From patchwork Fri Nov 15 07:46:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 21902 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 59678C3261 for ; Fri, 15 Nov 2024 07:47:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EDB6A65876; Fri, 15 Nov 2024 08:46:59 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="uT746oyy"; 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 4F37065862 for ; Fri, 15 Nov 2024 08:46:49 +0100 (CET) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D4DC71340; Fri, 15 Nov 2024 08:46:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731656795; bh=6O0EmF3i/JczmfONoZ/puoVeIT0pZRhZUH7TZthvM28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uT746oyyG3Sv6pxyOxK+mJKQpHOrL0YaklEW9ymi8Lclzo3bXjvtTHU4m+RNpBblm QUOmBG6qFNJBXwNbKzfk8Z0I4wX/Ir9QZobb1KfuHyVmZUJAr5y3iEsz1/kPVRm+aE e4/ExMnAleBfIOkAcJDbDD+upDIv5qnUZ15YJHnI= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH v3 6/6] libcamera: pipelines: Draw control delays from CameraSensor properties Date: Fri, 15 Nov 2024 07:46:28 +0000 Message-Id: <20241115074628.417215-7-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115074628.417215-1-dan.scally@ideasonboard.com> References: <20241115074628.417215-1-dan.scally@ideasonboard.com> 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" Rather than hard coding default delays for control values in the pipeline handlers, pick up the ones defined in the CameraSensor properties. Signed-off-by: Daniel Scally --- Changes in v3: - Fixed some broken alignment Changes in v2: - Switched to use the new getSensorDelays() function src/libcamera/pipeline/ipu3/ipu3.cpp | 12 +++++------- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 13 ++++++------- src/libcamera/pipeline/simple/simple.cpp | 8 ++++++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 0069d5e2..4d6b86b5 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1077,14 +1077,12 @@ int PipelineHandlerIPU3::registerCameras() if (ret) continue; - /* - * \todo Read delay values from the sensor itself or from a - * a sensor database. For now use generic values taken from - * the Raspberry Pi and listed as 'generic values'. - */ + uint8_t exposureDelay, gainDelay, vblankDelay, hblankDelay; + cio2->sensor()->getSensorDelays(exposureDelay, gainDelay, + vblankDelay, hblankDelay); std::unordered_map params = { - { V4L2_CID_ANALOGUE_GAIN, { 1, false } }, - { V4L2_CID_EXPOSURE, { 2, false } }, + { V4L2_CID_ANALOGUE_GAIN, { gainDelay, false } }, + { V4L2_CID_EXPOSURE, { exposureDelay, false } }, }; data->delayedCtrls_ = diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 6c6d711f..42600908 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -1239,14 +1240,12 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) /* Initialize the camera properties. */ data->properties_ = data->sensor_->properties(); - /* - * \todo Read delay values from the sensor itself or from a - * a sensor database. For now use generic values taken from - * the Raspberry Pi and listed as generic values. - */ + uint8_t exposureDelay, gainDelay, vblankDelay, hblankDelay; + data->sensor_->getSensorDelays(exposureDelay, gainDelay, vblankDelay, + hblankDelay); std::unordered_map params = { - { V4L2_CID_ANALOGUE_GAIN, { 1, false } }, - { V4L2_CID_EXPOSURE, { 2, false } }, + { V4L2_CID_ANALOGUE_GAIN, { gainDelay, false } }, + { V4L2_CID_EXPOSURE, { exposureDelay, false } }, }; data->delayedCtrls_ = diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 41fdf84c..20f395fb 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -1290,9 +1291,12 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) if (outputCfgs.empty()) return 0; + uint8_t exposureDelay, gainDelay, vblankDelay, hblankDelay; + data->sensor_->getSensorDelays(exposureDelay, gainDelay, vblankDelay, + hblankDelay); std::unordered_map params = { - { V4L2_CID_ANALOGUE_GAIN, { 2, false } }, - { V4L2_CID_EXPOSURE, { 2, false } }, + { V4L2_CID_ANALOGUE_GAIN, { gainDelay, false } }, + { V4L2_CID_EXPOSURE, { exposureDelay, false } }, }; data->delayedCtrls_ = std::make_unique(data->sensor_->device(),