From patchwork Mon Jul 1 14:38:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20494 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 85B77BEFBE for ; Mon, 1 Jul 2024 14:41:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4318C62E17; Mon, 1 Jul 2024 16:41:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="N8mbrIJ7"; 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 5E6EA62E01 for ; Mon, 1 Jul 2024 16:41:39 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:89b2:f6c7:b29b:4e5c]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9B133289; Mon, 1 Jul 2024 16:41:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719844872; bh=9OfEPJgunPUuDfUjcEI6VFfSww4n4UtaKQheV72OlXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N8mbrIJ7RuHrKJWTkR1pTt5wNme1Pm8yFDyXloZ8QaXoGHu4hX4hk5EZaXNjZzIBr LzbH5o4KjKf0OqwjzyyTYgjZXBhwWYj+iY1lWJX+dgnX2w5GK2Y00A0NzR+/98oTTp JDS+M+ltukVwaIulmrYGynlXi2vq97aO1Ltseoao= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 1/5] ipa: libipa: Add black levels to camera sensor helper Date: Mon, 1 Jul 2024 16:38:24 +0200 Message-ID: <20240701144122.3418955-2-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701144122.3418955-1-stefan.klug@ideasonboard.com> References: <20240701144122.3418955-1-stefan.klug@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" For a proper tuning process we need to know the sensor black levels. In most cases these are fixed and not reported by the kernel driver. Store them inside the sensor helpers for later retrieval by the algorithms. Signed-off-by: Stefan Klug --- src/ipa/libipa/camera_sensor_helper.cpp | 18 ++++++++++++++++++ src/ipa/libipa/camera_sensor_helper.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp index 782ff9904e81..6d8850eb25a5 100644 --- a/src/ipa/libipa/camera_sensor_helper.cpp +++ b/src/ipa/libipa/camera_sensor_helper.cpp @@ -47,6 +47,21 @@ namespace ipa { * function. */ +/** + * \brief Fetch the black levels of the sensor + * + * This function returns the black levels of the sensor with respect to a 16bit + * pixel width in R, Gr, Gb, B order. If these are unknown an empty optional is + * returned. + * + * \return The black levels of the sensor + */ +std::optional +CameraSensorHelper::blackLevels() const +{ + return blackLevels_; +} + /** * \brief Compute gain code from the analogue gain absolute value * \param[in] gain The real gain to pass @@ -396,6 +411,7 @@ class CameraSensorHelperImx219 : public CameraSensorHelper public: CameraSensorHelperImx219() { + blackLevels_ = { 4096, 4096, 4096, 4096 }; gainType_ = AnalogueGainLinear; gainConstants_.linear = { 0, 256, -1, 256 }; } @@ -407,6 +423,7 @@ class CameraSensorHelperImx258 : public CameraSensorHelper public: CameraSensorHelperImx258() { + blackLevels_ = { 4096, 4096, 4096, 4096 }; gainType_ = AnalogueGainLinear; gainConstants_.linear = { 0, 512, -1, 512 }; } @@ -456,6 +473,7 @@ class CameraSensorHelperImx335 : public CameraSensorHelper public: CameraSensorHelperImx335() { + blackLevels_ = { 3200, 3200, 3200, 3200 }; gainType_ = AnalogueGainExponential; gainConstants_.exp = { 1.0, expGainDb(0.3) }; } diff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h index 0d99073bea82..f025727c06ee 100644 --- a/src/ipa/libipa/camera_sensor_helper.h +++ b/src/ipa/libipa/camera_sensor_helper.h @@ -9,7 +9,9 @@ #include +#include #include +#include #include #include @@ -22,9 +24,12 @@ namespace ipa { class CameraSensorHelper { public: + typedef std::array BlackLevels; + CameraSensorHelper() = default; virtual ~CameraSensorHelper() = default; + virtual std::optional blackLevels() const; virtual uint32_t gainCode(double gain) const; virtual double gain(uint32_t gainCode) const; @@ -51,6 +56,7 @@ protected: AnalogueGainExpConstants exp; }; + std::optional blackLevels_; AnalogueGainType gainType_; AnalogueGainConstants gainConstants_;