{"id":21567,"url":"https://patchwork.libcamera.org/api/1.1/patches/21567/?format=json","web_url":"https://patchwork.libcamera.org/patch/21567/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20241009191940.2359227-2-mzamazal@redhat.com>","date":"2024-10-09T19:19:33","name":"[v2,1/1] libcamera: software_isp: Get black level from the camera helper","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"26ece3464ebe6c69c9029e57e685c53fa5940277","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/1.1/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21567/mbox/","series":[{"id":4676,"url":"https://patchwork.libcamera.org/api/1.1/series/4676/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4676","date":"2024-10-09T19:19:32","name":"Get black level from the camera helper","version":2,"mbox":"https://patchwork.libcamera.org/series/4676/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21567/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21567/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 3B3B1C32E7\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Oct 2024 19:20:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D2AF963538;\n\tWed,  9 Oct 2024 21:20:03 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9539B65370\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Oct 2024 21:20:01 +0200 (CEST)","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-196-oNyXFfb1N8GO0pwgaIsRFw-1;\n\tWed, 09 Oct 2024 15:19:57 -0400","from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.40])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id EB94E195608C; Wed,  9 Oct 2024 19:19:55 +0000 (UTC)","from nuthatch.redhat.com (unknown [10.45.224.78])\n\tby mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 3555019560AA; Wed,  9 Oct 2024 19:19:53 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"X/5h6JC1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1728501600;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=xFgqmgXiQ2uxfSNe/6bf1R7upNHCqHmQkHwwgcjDrwA=;\n\tb=X/5h6JC1svKrmZei4O78JrQZursngKxS8Tg28awHjIPL/wyyR4TwsHoK2spFPrmI9ZGem0\n\tPkYsO9KbkkgyLkdUL7+6xekUMFbWp/mxNr9VLFMsx0eUm3mzBnku1v4267THVIGLrkLM/Z\n\tUjlN42cmp/9G3+84kbOhjPfhmu36wF0=","X-MC-Unique":"oNyXFfb1N8GO0pwgaIsRFw-1","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"[PATCH v2 1/1] libcamera: software_isp: Get black level from the\n\tcamera helper","Date":"Wed,  9 Oct 2024 21:19:33 +0200","Message-ID":"<20241009191940.2359227-2-mzamazal@redhat.com>","In-Reply-To":"<20241009191940.2359227-1-mzamazal@redhat.com>","References":"<20241009191940.2359227-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.40","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain; charset=\"US-ASCII\"; x-default=true","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The black level in software ISP is unconditionally guessed from the\nobtained frames.  CameraSensorHelper optionally provides the black level\nfrom camera specifications now.  Let's use the value if available.\n\nIf the black level is not available from the given CameraSensorHelper\ninstance, it's still determined on the fly.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/ipa/simple/algorithms/blc.cpp | 6 +++++-\n src/ipa/simple/ipa_context.h      | 4 ++++\n src/ipa/simple/soft_simple.cpp    | 3 +++\n 3 files changed, 12 insertions(+), 1 deletion(-)","diff":"diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp\nindex b9f2aaa6d..a7af2e12c 100644\n--- a/src/ipa/simple/algorithms/blc.cpp\n+++ b/src/ipa/simple/algorithms/blc.cpp\n@@ -24,7 +24,8 @@ BlackLevel::BlackLevel()\n int BlackLevel::configure(IPAContext &context,\n \t\t\t  [[maybe_unused]] const IPAConfigInfo &configInfo)\n {\n-\tcontext.activeState.blc.level = 255;\n+\tcontext.activeState.blc.level =\n+\t\tcontext.configuration.black.level.value_or(255);\n \treturn 0;\n }\n \n@@ -34,6 +35,9 @@ void BlackLevel::process(IPAContext &context,\n \t\t\t const SwIspStats *stats,\n \t\t\t [[maybe_unused]] ControlList &metadata)\n {\n+\tif (context.configuration.black.level.has_value())\n+\t\treturn;\n+\n \tif (frameContext.sensor.exposure == exposure_ &&\n \t    frameContext.sensor.gain == gain_) {\n \t\treturn;\ndiff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\nindex 3519f20f6..fd121eebe 100644\n--- a/src/ipa/simple/ipa_context.h\n+++ b/src/ipa/simple/ipa_context.h\n@@ -8,6 +8,7 @@\n #pragma once\n \n #include <array>\n+#include <optional>\n #include <stdint.h>\n \n #include <libipa/fc_queue.h>\n@@ -22,6 +23,9 @@ struct IPASessionConfiguration {\n \t\tint32_t exposureMin, exposureMax;\n \t\tdouble againMin, againMax, againMinStep;\n \t} agc;\n+\tstruct {\n+\t\tstd::optional<uint8_t> level;\n+\t} black;\n };\n \n struct IPAActiveState {\ndiff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\nindex b28c7039f..ad6334ff6 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -201,6 +201,9 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo)\n \t\t\t(context_.configuration.agc.againMax -\n \t\t\t context_.configuration.agc.againMin) /\n \t\t\t100.0;\n+\t\tif (camHelper_->blackLevel().has_value())\n+\t\t\tcontext_.configuration.black.level =\n+\t\t\t\tcamHelper_->blackLevel().value() / 256;\n \t} else {\n \t\t/*\n \t\t * The camera sensor gain (g) is usually not equal to the value written\n","prefixes":["v2","1/1"]}