From patchwork Thu Aug 15 08:37:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 20941 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 EF16CBDB13 for ; Thu, 15 Aug 2024 08:37:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 96C63633C2; Thu, 15 Aug 2024 10:37:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="PZiGUAPg"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 55E35633BA for ; Thu, 15 Aug 2024 10:37:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723711054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nyn2Snq6YBwVI/hEQbIZO6YrFUlpfWFdksGEtOI7KFM=; b=PZiGUAPgSD3cMJKrlmYAqfXgLslvhJiZrPJFrB2M0YT5g+VdEY5IUrchiDRbI9PrGg+EZo iCe8lAKF+xYc8NXBT4WSv4O8MDfuLtHpNWyjJ+uTY4nqcCG3WrWMSl14+qPXOpvdRJfNkK pA0Z0V55EzHb5QENI0WVs2t4lC5ywAY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-88-Kl57wohAMguOSQDtgqepLg-1; Thu, 15 Aug 2024 04:37:32 -0400 X-MC-Unique: Kl57wohAMguOSQDtgqepLg-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 119C719560B1; Thu, 15 Aug 2024 08:37:32 +0000 (UTC) Received: from nuthatch.redhat.com (unknown [10.45.225.128]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5FE7A1955DC6; Thu, 15 Aug 2024 08:37:30 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Daniel Scally Subject: [PATCH 1/1] libcamera: software_isp: Get black level from the camera helper Date: Thu, 15 Aug 2024 10:37:16 +0200 Message-ID: <20240815083722.237229-2-mzamazal@redhat.com> In-Reply-To: <20240815083722.237229-1-mzamazal@redhat.com> References: <20240815083722.237229-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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" The black level in software ISP is unconditionally guessed from the obtained frames. CameraSensorHelper optionally provides the black level from camera specifications now. Let's use the value if available. The black level value initialization is moved from init to configure because this is where we get the other configuration (gains) from CameraSensorHelper in software ISP. If the black level is not available from the given CameraSensorHelper instance, it's still determined on the fly. Signed-off-by: Milan Zamazal --- src/ipa/simple/algorithms/blc.cpp | 10 +++++++--- src/ipa/simple/algorithms/blc.h | 3 ++- src/ipa/simple/ipa_context.h | 3 ++- src/ipa/simple/soft_simple.cpp | 3 +++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp index d01c2c14..5dc924bb 100644 --- a/src/ipa/simple/algorithms/blc.cpp +++ b/src/ipa/simple/algorithms/blc.cpp @@ -21,10 +21,11 @@ BlackLevel::BlackLevel() { } -int BlackLevel::init(IPAContext &context, - [[maybe_unused]] const YamlObject &tuningData) +int BlackLevel::configure(typename Module::Context &context, + [[maybe_unused]] const typename Module::Config &configInfo) { - context.activeState.black.level = 1.0; + context.activeState.black.level = + context.configuration.black.level.value_or(1.0); return 0; } @@ -34,6 +35,9 @@ void BlackLevel::process(IPAContext &context, const SwIspStats *stats, [[maybe_unused]] ControlList &metadata) { + if (context.configuration.black.level.has_value()) + return; + if (frameContext.sensor.exposure == exposure_ && frameContext.sensor.gain == gain_) { return; diff --git a/src/ipa/simple/algorithms/blc.h b/src/ipa/simple/algorithms/blc.h index 9b9daab1..586a23d2 100644 --- a/src/ipa/simple/algorithms/blc.h +++ b/src/ipa/simple/algorithms/blc.h @@ -24,7 +24,8 @@ public: BlackLevel(); ~BlackLevel() = default; - int init(IPAContext &context, const YamlObject &tuningData) + int configure(typename Module::Context &context, + const typename Module::Config &configInfo) override; void process(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h index 0e2096f8..08f965f4 100644 --- a/src/ipa/simple/ipa_context.h +++ b/src/ipa/simple/ipa_context.h @@ -8,6 +8,7 @@ #pragma once #include +#include #include @@ -24,7 +25,7 @@ struct IPASessionConfiguration { double againMin, againMax, againMinStep; } agc; struct { - double level; + std::optional level; } black; }; diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp index aef5f6e5..ac7a22b7 100644 --- a/src/ipa/simple/soft_simple.cpp +++ b/src/ipa/simple/soft_simple.cpp @@ -201,6 +201,9 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo) (context_.configuration.agc.againMax - context_.configuration.agc.againMin) / 100.0; + if (camHelper_->blackLevel().has_value()) + context_.configuration.black.level = + camHelper_->blackLevel().value() / 65536.0; } else { /* * The camera sensor gain (g) is usually not equal to the value written