From patchwork Thu Oct 31 16:07:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 21791 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 CA85EC3292 for ; Thu, 31 Oct 2024 16:08:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1819E653AD; Thu, 31 Oct 2024 17:08:20 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FWXXuDzH"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A0DBB6039B for ; Thu, 31 Oct 2024 17:08:12 +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 7465BE0D; Thu, 31 Oct 2024 17:08:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1730390888; bh=/FxZ1eFssi/jct/GeklGlD2CrAQhC5ZephJEYXf+Uuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FWXXuDzHvlnbozP5Yhti0zULpVYl7T1pDgIQIqp1Df6DOK5UUdwLnT9l9hqMcfxr0 oMozwc7bWDu0Ba+wa3s04A8OnJRsBoPFMpvc8Ey1w0OBX86tpTISmBCvbpFoLmI3R5 DF4jyIFfy4k1exEfxvmPWhiwsZ4WPp2n3V+Ry3Yw= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH 1/6] ipa: libipa: Add miscellaneous helpers Date: Thu, 31 Oct 2024 16:07:36 +0000 Message-Id: <20241031160741.253855-2-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031160741.253855-1-dan.scally@ideasonboard.com> References: <20241031160741.253855-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 functions 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 --- src/ipa/libipa/helpers.cpp | 103 +++++++++++++++++++++++++++++++++++++ src/ipa/libipa/helpers.h | 23 +++++++++ src/ipa/libipa/meson.build | 2 + 3 files changed, 128 insertions(+) create mode 100644 src/ipa/libipa/helpers.cpp create mode 100644 src/ipa/libipa/helpers.h diff --git a/src/ipa/libipa/helpers.cpp b/src/ipa/libipa/helpers.cpp new file mode 100644 index 00000000..cc0cd586 --- /dev/null +++ b/src/ipa/libipa/helpers.cpp @@ -0,0 +1,103 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2024, Ideas on Board Oy + * + * libipa miscellaneous helpers + */ + +#include "helpers.h" + +#include +#include + +namespace libcamera { + +namespace ipa { + +/** + * \file helpers.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 valye + * \return The estimated luminance 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 + */ +unsigned int rec601LuminanceFromRGB(unsigned int r, unsigned int g, unsigned int 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 + * \return The estimated color temperature + * + * 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 + */ +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; +} + +/** + * \brief Convert double to Q(m.n) format + * \param[in] value The value to convert + * \param[in] m The number of bits used to represent the integer part + * \param[in] n The number of bits used to represent the fraction part + * + * This function converts a double into an unsigned Q format, clamping at the + * largest possible value given m and n. + */ +unsigned int toQFormat(double value, unsigned int m, unsigned int n) +{ + double maxVal = (std::pow(2, m + n) - 1) / std::pow(2, n); + + return std::clamp(value, 0.0, maxVal) * std::pow(2, n); +} + +/** + * \brief Convert Q(m.n) formatted number to double + * \param[in] value The value to convert + * \param[in] n The number of bits used to represent the fraction part + * + * This function converts an unsigned Q formatted value into a double. + */ +double fromQFormat(unsigned int value, unsigned int n) +{ + return value / std::pow(2, n); +} + +} /* namespace ipa */ + +} /* namespace libcamera */ diff --git a/src/ipa/libipa/helpers.h b/src/ipa/libipa/helpers.h new file mode 100644 index 00000000..361b63bd --- /dev/null +++ b/src/ipa/libipa/helpers.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2024, Ideas on Board Oy + * + * libipa miscellaneous helpers + */ + +#pragma once + +#include + +namespace libcamera { + +namespace ipa { + +unsigned int rec601LuminanceFromRGB(unsigned int r, unsigned int g, unsigned int b); +uint32_t estimateCCT(double red, double green, double blue); +unsigned int toQFormat(double value, unsigned int m, unsigned int n); +double fromQFormat(unsigned int value, unsigned int n); + +} /* namespace ipa */ + +} /* namespace libcamera */ diff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build index e78cbcd6..ca4f3e28 100644 --- a/src/ipa/libipa/meson.build +++ b/src/ipa/libipa/meson.build @@ -6,6 +6,7 @@ libipa_headers = files([ 'camera_sensor_helper.h', 'exposure_mode_helper.h', 'fc_queue.h', + 'helpers.h', 'histogram.h', 'interpolator.h', 'lsc_polynomial.h', @@ -21,6 +22,7 @@ libipa_sources = files([ 'camera_sensor_helper.cpp', 'exposure_mode_helper.cpp', 'fc_queue.cpp', + 'helpers.cpp', 'histogram.cpp', 'interpolator.cpp', 'lsc_polynomial.cpp', From patchwork Thu Oct 31 16:07:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 21792 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 E08DCC31E9 for ; Thu, 31 Oct 2024 16:08:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 984A3653A1; Thu, 31 Oct 2024 17:08:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="dYYpYGKs"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D975C60360 for ; Thu, 31 Oct 2024 17:08:12 +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 C229FF50; Thu, 31 Oct 2024 17:08:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1730390888; bh=0EAcGBmDHe3rfOYu/c8xObanDTpwag/WZB3cflpU3N8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dYYpYGKspav+SeoiBHElFwiZlPpUeRQoINybt6nh6JEYGNeywwIOmEubdYQXeKkZB rav8DvKRFtobZut0oW8NXCFmBpCEtqDa4pfXb6JvtwBuDlAjFKkrS9F3ddWlkLVzB6 L7lQT3NxC5ayL745T56+Q8lxGAp0dS6ufkwzMQUM= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH 2/6] ipa: ipu3: Use centralised libipa helpers Date: Thu, 31 Oct 2024 16:07:37 +0000 Message-Id: <20241031160741.253855-3-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031160741.253855-1-dan.scally@ideasonboard.com> References: <20241031160741.253855-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 --- src/ipa/ipu3/algorithms/agc.cpp | 7 ++++--- src/ipa/ipu3/algorithms/awb.cpp | 34 +++------------------------------ src/ipa/ipu3/algorithms/awb.h | 1 - 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index c5f3d8f0..3eb73ef0 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -17,6 +17,7 @@ #include +#include "libipa/helpers.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 = ipa::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..0085edf4 100644 --- a/src/ipa/ipu3/algorithms/awb.cpp +++ b/src/ipa/ipu3/algorithms/awb.cpp @@ -13,6 +13,8 @@ #include +#include "libipa/helpers.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() { @@ -437,7 +409,7 @@ void Awb::awbGreyWorld() blueGain = sumBlue.G / (sumBlue.B + 1); /* Color temperature is not relevant in Grey world but still useful to estimate it :-) */ - asyncResults_.temperatureK = estimateCCT(sumRed.R, sumRed.G, sumBlue.B); + asyncResults_.temperatureK = ipa::estimateCCT(sumRed.R, sumRed.G, sumBlue.B); /* * Gain values are unsigned integer value ranging [0, 8) with 13 bit 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 Thu Oct 31 16:07:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 21793 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 9BDF7C330B for ; Thu, 31 Oct 2024 16:08:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5D0D6653B6; Thu, 31 Oct 2024 17:08:23 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wVr+K0+G"; 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 277BD653A1 for ; Thu, 31 Oct 2024 17:08:13 +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 1B3E21014; Thu, 31 Oct 2024 17:08:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1730390889; bh=f8uOKekUrzhwjcGWvj4o7L4uQ0ayFCkha2W3VJgG6Eg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wVr+K0+GU/7kpJfqHymZ1sc2rFhIWZpMcaryS4uHEPZF3+ZuisrSS8GY6y5LCYY6m 0IWJxHCDjQwSnLFK/+NdUUp91PuMQ7ynWm3S1PnaksQeKHAk6EatE8MjlKe/98TY+F KyL9BUuZL5DCtZp1wDHSr1EZovVESs9sNL3mIMME= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH 3/6] ipa: rkisp1: Use centralised libipa helpers Date: Thu, 31 Oct 2024 16:07:38 +0000 Message-Id: <20241031160741.253855-4-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031160741.253855-1-dan.scally@ideasonboard.com> References: <20241031160741.253855-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 --- src/ipa/rkisp1/algorithms/awb.cpp | 20 +++----------------- src/ipa/rkisp1/algorithms/awb.h | 2 -- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index b3c00bef..623c4eb2 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -16,6 +16,8 @@ #include +#include "libipa/helpers.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 */ @@ -279,7 +265,7 @@ void Awb::process(IPAContext &context, blueMean < kMeanMinThreshold) return; - activeState.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean); + activeState.awb.temperatureK = ipa::estimateCCT(redMean, greenMean, blueMean); /* Metadata shall contain the up to date measurement */ metadata.set(controls::ColourTemperature, activeState.awb.temperatureK); 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 Thu Oct 31 16:07:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 21794 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 C1486C330C for ; Thu, 31 Oct 2024 16:08:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 001BC653AE; Thu, 31 Oct 2024 17:08:24 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Hp3+a+lj"; 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 76A3B6039B for ; Thu, 31 Oct 2024 17:08:13 +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 67A389EC; Thu, 31 Oct 2024 17:08:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1730390889; bh=bIL2KgAsCqAOa2Ukgp1a7gZ0S/dFA59FTfmODvATBhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hp3+a+ljOMk7dkShvZKe4qrqXY0j9qxY561XOqILz0Qpnslgs4zaCtPqI4Karp2/y pCJ4BheCGMH3dfh9JFFBr0gaR7+hFI9Flv7/Z5tOGgWfZWI/P4KXLLb7kyDKwWdplv ns9gWwfGf3z14StP7WjuLJ1QZsyynPYIgrFNcypA= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH 4/6] ipa: rpi: Use centralised libipa helpers Date: Thu, 31 Oct 2024 16:07:39 +0000 Message-Id: <20241031160741.253855-5-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031160741.253855-1-dan.scally@ideasonboard.com> References: <20241031160741.253855-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 --- 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..0c8252a0 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/helpers.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 Thu Oct 31 16:07:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 21795 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 660D6C3292 for ; Thu, 31 Oct 2024 16:08:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 325A3653B8; Thu, 31 Oct 2024 17:08:26 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="CfbXoG84"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C88A2653A1 for ; Thu, 31 Oct 2024 17:08:13 +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 B1F25E0D; Thu, 31 Oct 2024 17:08:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1730390889; bh=qKy6v6XlBz3HiJ7DoKrtKJfauMB3/lVgACuzHKorkXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CfbXoG84FddfjmnjgkF6Y+gt6BdKOXbU+FDcMIYkNBCWjhk8CclAwduAVjT10NwQX pYJ0J7slwI6soEVzo3/ZjIN+jVGDL2BHNHy3/XNewIQ7/PFpYotLHN9LlxDjTN3uI/ STdgVev6TNTjdaCTwe/4mis9VTBv0jW9D59iith0= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH 5/6] libcamera: camera_sensor_properties: Add sensor control delays Date: Thu, 31 Oct 2024 16:07:40 +0000 Message-Id: <20241031160741.253855-6-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031160741.253855-1-dan.scally@ideasonboard.com> References: <20241031160741.253855-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 list of control values and 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. Initialise the properties from the static database during the same CameraSensor::initStaticProperties() function that currently handles the UnitCellSize. Signed-off-by: Daniel Scally --- If anyone has a suggestion for a graceful way to set default values without causing warnings due to -Wmissing-field-initializers I'm very interested... .../internal/camera_sensor_properties.h | 13 ++ src/libcamera/property_ids_core.yaml | 25 +++ src/libcamera/sensor/camera_sensor.cpp | 8 + .../sensor/camera_sensor_properties.cpp | 167 ++++++++++++++++++ 4 files changed, 213 insertions(+) diff --git a/include/libcamera/internal/camera_sensor_properties.h b/include/libcamera/internal/camera_sensor_properties.h index 480ac121..cd176b9e 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,17 @@ struct CameraSensorProperties { Size unitCellSize; std::map testPatternModes; + + /* + * These values are correct for many sensors. Other sensors will need to + * have the defaults overwritten in their CameraSensorProperties entry. + */ + struct { + uint8_t exposureDelay; + uint8_t gainDelay; + uint8_t vblankDelay; + uint8_t hblankDelay; + } sensorDelays; }; } /* namespace libcamera */ diff --git a/src/libcamera/property_ids_core.yaml b/src/libcamera/property_ids_core.yaml index 834454a4..a01c4014 100644 --- a/src/libcamera/property_ids_core.yaml +++ b/src/libcamera/property_ids_core.yaml @@ -701,4 +701,29 @@ controls: Different cameras may report identical devices. + - ExposureDelay: + type: uint8_t + description: | + The number of frames delay between an Exposure value being configured in + the sensor's registers and taking effect in the output data. + + - GainDelay: + type: uint8_t + description: | + The number of frames delay between a Gain value being configured in + the sensor's registers and taking effect in the output data. + + - VerticalBlankingDelay: + type: uint8_t + description: | + The number of frames delay between a Horizontal Blanking value being + configured in the sensor's registers and taking effect in the output + data. + + - HorizontalBlankingDelay: + type: uint8_t + description: | + The number of frames delay between a Vertical Blanking value being + configured in the sensor's registers and taking effect in the output + data. ... diff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp index 1b224f19..c9a3761e 100644 --- a/src/libcamera/sensor/camera_sensor.cpp +++ b/src/libcamera/sensor/camera_sensor.cpp @@ -387,6 +387,14 @@ void CameraSensor::initStaticProperties() /* Register the properties retrieved from the sensor database. */ properties_.set(properties::UnitCellSize, staticProps_->unitCellSize); + properties_.set(properties::ExposureDelay, + staticProps_->sensorDelays.exposureDelay); + properties_.set(properties::GainDelay, + staticProps_->sensorDelays.gainDelay); + properties_.set(properties::VerticalBlankingDelay, + staticProps_->sensorDelays.vblankDelay); + properties_.set(properties::HorizontalBlankingDelay, + staticProps_->sensorDelays.hblankDelay); initTestPatternModes(); } diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp index 6d4136d0..60d59f79 100644 --- a/src/libcamera/sensor/camera_sensor_properties.cpp +++ b/src/libcamera/sensor/camera_sensor_properties.cpp @@ -41,6 +41,11 @@ 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 struct holding the number of frames delay between a control value + * set and taking effect for each of exposure, gain, vertical blanking and + * horizontal blanking. */ /** @@ -60,6 +65,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeColorBars, 2 }, { controls::draft::TestPatternModeColorBarsFadeToGray, 3 }, }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ar0521", { .unitCellSize = { 2200, 2200 }, @@ -69,6 +80,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeColorBars, 2 }, { controls::draft::TestPatternModeColorBarsFadeToGray, 3 }, }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "hi846", { .unitCellSize = { 1120, 1120 }, @@ -87,6 +104,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * 9: "Resolution Pattern" */ }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "imx214", { .unitCellSize = { 1120, 1120 }, @@ -97,6 +120,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 + }, } }, { "imx219", { .unitCellSize = { 1120, 1120 }, @@ -107,6 +136,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 +152,82 @@ 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 + }, } }, { "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 = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "imx335", { .unitCellSize = { 2000, 2000 }, .testPatternModes = {}, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "imx415", { .unitCellSize = { 1450, 1450 }, .testPatternModes = {}, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "imx477", { .unitCellSize = { 1550, 1550 }, .testPatternModes = {}, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 2, + .vblankDelay = 3, + .hblankDelay = 3 + }, } }, { "imx519", { .unitCellSize = { 1220, 1220 }, @@ -157,6 +240,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 +256,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 +276,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * 5: "Color Square" */ }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov2740", { .unitCellSize = { 1400, 1400 }, @@ -188,6 +289,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeOff, 0 }, { controls::draft::TestPatternModeColorBars, 1}, }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov4689", { .unitCellSize = { 2000, 2000 }, @@ -201,6 +308,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * colorBarType2 and colorBarType3. */ }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov5640", { .unitCellSize = { 1400, 1400 }, @@ -208,10 +321,22 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeOff, 0 }, { controls::draft::TestPatternModeColorBars, 1 }, }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov5647", { .unitCellSize = { 1400, 1400 }, .testPatternModes = {}, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 2, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov5670", { .unitCellSize = { 1120, 1120 }, @@ -219,6 +344,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeOff, 0 }, { controls::draft::TestPatternModeColorBars, 1 }, }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov5675", { .unitCellSize = { 1120, 1120 }, @@ -226,6 +357,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeOff, 0 }, { controls::draft::TestPatternModeColorBars, 1 }, }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov5693", { .unitCellSize = { 1400, 1400 }, @@ -238,6 +375,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * Rolling Bar". */ }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov64a40", { .unitCellSize = { 1008, 1008 }, @@ -251,6 +394,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 +413,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * 4: "Vertical Color Bar Type 4" */ }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov8865", { .unitCellSize = { 1400, 1400 }, @@ -278,6 +433,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen * 5: "Color squares with rolling bar" */ }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, { "ov13858", { .unitCellSize = { 1120, 1120 }, @@ -285,6 +446,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { controls::draft::TestPatternModeOff, 0 }, { controls::draft::TestPatternModeColorBars, 1 }, }, + .sensorDelays = { + .exposureDelay = 2, + .gainDelay = 1, + .vblankDelay = 2, + .hblankDelay = 2 + }, } }, }; From patchwork Thu Oct 31 16:07:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 21796 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 2B622C330D for ; Thu, 31 Oct 2024 16:08:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C4E65653BB; Thu, 31 Oct 2024 17:08:26 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PGIxKy40"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 26E626039B for ; Thu, 31 Oct 2024 17:08:14 +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 0F84AF50; Thu, 31 Oct 2024 17:08:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1730390890; bh=LXXSy6kSZfGLfSaMmhAWEFpY8azs3ZYlwWXWhT2/uzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PGIxKy40ailYddioYjYd+nCKLuIYYQJw4DKXJwp08N6HNhBvp/USDJt8dzqW9YpsI jPfIEBHaCN6uhNBuurrBnLJER8ZY4ZSb8aitnxPcjcPCPzWi2adVmm9C0KR2YglID9 IAZTcqwIs1H/4xJSA4hOd2NBvf2u96ucAyuD+l4o= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH 6/6] libcamera: pipelines: Draw control delays from CameraSensor properties Date: Thu, 31 Oct 2024 16:07:41 +0000 Message-Id: <20241031160741.253855-7-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031160741.253855-1-dan.scally@ideasonboard.com> References: <20241031160741.253855-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 --- I note that the simple pipeline handler had a Gain delay of 2 rather than the standard 1...I don't think the difference from the norm is correct but thought I would highlight it in case I'm mistaken. src/libcamera/pipeline/ipu3/ipu3.cpp | 11 ++++------- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 12 +++++------- src/libcamera/pipeline/simple/simple.cpp | 7 +++++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 29d3c6c1..ff58ba28 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1077,14 +1077,11 @@ 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'. - */ + unsigned int gainDelay = data->properties_.get(properties::GainDelay).value(); + unsigned int exposureDelay = data->properties_.get(properties::ExposureDelay).value(); 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 c7b0b392..43e1315f 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 @@ -1240,14 +1241,11 @@ 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. - */ + unsigned int gainDelay = data->properties_.get(properties::GainDelay).value(); + unsigned int exposureDelay = data->properties_.get(properties::ExposureDelay).value(); 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 3ddce71d..20c97c37 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -1286,9 +1287,11 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) if (outputCfgs.empty()) return 0; + unsigned int gainDelay = data->properties_.get(properties::GainDelay).value(); + unsigned int exposureDelay = data->properties_.get(properties::ExposureDelay).value(); 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(),