{"id":21625,"url":"https://patchwork.libcamera.org/api/patches/21625/?format=json","web_url":"https://patchwork.libcamera.org/patch/21625/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20241014191058.1812307-2-mzamazal@redhat.com>","date":"2024-10-14T19:10:57","name":"[v4,1/1] libcamera: software_isp: Get black level from the camera helper","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"22b2ead57600529908bf8e2a0a5b56db3b642c9a","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21625/mbox/","series":[{"id":4698,"url":"https://patchwork.libcamera.org/api/series/4698/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4698","date":"2024-10-14T19:10:56","name":"Get black level from the camera helper","version":4,"mbox":"https://patchwork.libcamera.org/series/4698/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21625/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21625/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 A2142C326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 14 Oct 2024 19:11:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4E5ED65383;\n\tMon, 14 Oct 2024 21:11:19 +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 988346537D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Oct 2024 21:11:17 +0200 (CEST)","from mx-prod-mc-04.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-522-QKFx7YBaO6WR9Wlta4ABJA-1;\n\tMon, 14 Oct 2024 15:11:08 -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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 0041E19560AD; Mon, 14 Oct 2024 19:11:07 +0000 (UTC)","from nuthatch.redhat.com (unknown [10.45.224.20])\n\tby mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id D278719560AA; Mon, 14 Oct 2024 19:11:04 +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=\"G55MKJ4G\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1728933076;\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=3hZJJLmYTWm1UwQqDZvSjDIm8JP9eB9aG7yKCReA0xc=;\n\tb=G55MKJ4GVsJM94AEhuUzdin4gMFVvZvVlBc6OmbXGbxaUWX+F/i0yBrmzNgL+t0mMlaN1I\n\t2170swU9NQkq1PnuoaRFl+xwouPGW44sHgdK76ITD7Cpod2CyGku0XOAAk/mZACGJC4gle\n\t/0y/AZ/7sgTwaELHeFQlSLZ7WWd0tPo=","X-MC-Unique":"QKFx7YBaO6WR9Wlta4ABJA-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>,\n\tRobert Mader <robert.mader@collabora.com>","Subject":"[PATCH v4 1/1] libcamera: software_isp: Get black level from the\n\tcamera helper","Date":"Mon, 14 Oct 2024 21:10:57 +0200","Message-ID":"<20241014191058.1812307-2-mzamazal@redhat.com>","In-Reply-To":"<20241014191058.1812307-1-mzamazal@redhat.com>","References":"<20241014191058.1812307-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>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nTested-by: Robert Mader <robert.mader@collabora.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    | 10 ++++++++++\n 3 files changed, 19 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..e96e65bd1 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -201,6 +201,16 @@ 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\t/*\n+\t\t\t * The black level from camHelper_ is a 16 bit value, software ISP\n+\t\t\t * works with 8 bit pixel values, both regardless of the actual\n+\t\t\t * sensor pixel width. Hence we obtain the pixel-based black value\n+\t\t\t * by dividing the value from the helper by 256.\n+\t\t\t */\n+\t\t\tcontext_.configuration.black.level =\n+\t\t\t\tcamHelper_->blackLevel().value() / 256;\n+\t\t}\n \t} else {\n \t\t/*\n \t\t * The camera sensor gain (g) is usually not equal to the value written\n","prefixes":["v4","1/1"]}