{"id":21707,"url":"https://patchwork.libcamera.org/api/1.1/patches/21707/?format=json","web_url":"https://patchwork.libcamera.org/patch/21707/","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":"<20241020152821.240726-2-mike.rudenko@gmail.com>","date":"2024-10-20T15:28:18","name":"[v2,1/4] ipa: rkisp1: agc: Use better defaults for analogue gain and exposure","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"1bc4916b6b48505d1291f05aae270e70b8ce2190","submitter":{"id":146,"url":"https://patchwork.libcamera.org/api/1.1/people/146/?format=json","name":"Mikhail Rudenko","email":"mike.rudenko@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21707/mbox/","series":[{"id":4728,"url":"https://patchwork.libcamera.org/api/1.1/series/4728/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4728","date":"2024-10-20T15:28:17","name":"Reduce rkisp1 flicker on first start","version":2,"mbox":"https://patchwork.libcamera.org/series/4728/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21707/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21707/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 1AF9AC3304\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 20 Oct 2024 15:28:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9ADDF65395;\n\tSun, 20 Oct 2024 17:28:45 +0200 (CEST)","from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com\n\t[IPv6:2a00:1450:4864:20::12e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E0D6F65379\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 20 Oct 2024 17:28:37 +0200 (CEST)","by mail-lf1-x12e.google.com with SMTP id\n\t2adb3069b0e04-539e4b7409fso3640841e87.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 20 Oct 2024 08:28:37 -0700 (PDT)","from localhost.localdomain\n\t(static.40.223.216.95.clients.your-server.de. [95.216.223.40])\n\tby smtp.gmail.com with ESMTPSA id\n\t2adb3069b0e04-53a223efad4sm249040e87.67.2024.10.20.08.28.35\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 20 Oct 2024 08:28:36 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"OJlUgRxo\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20230601; t=1729438117; x=1730042917;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=fsdRqpztdFaGeJkanrNCe+tQNA7Ad8aazk7oOb+NI/U=;\n\tb=OJlUgRxoaRVPBFiTp5QAo22J2LptEVb5amdRSrmFxRdxzkCI+Vy4VVbxFw/Jxdm6Cj\n\tST60YVecESkrNHpB0J98RJE5mTSc4PMrknRe+HFbi+hUHDwk1WcBknO4XVrXIjHwDvCz\n\tufsLi0RDRCo/TJDHiyTYwaYGMaKeAmiHS4PLWpwtS0GORrpJq36hwOq+qbmwyRnXVxuN\n\tdyRG2snRkiME4T6XzQ7vTHFkx+68aKYgsyhzCOr+kS6A30mFDbM4RvyGIRkcgnOmyLSw\n\t9whxY1DeHiVJE1fZYd+Hazg5/w9YgmglRrByPeLxv+h/jfCDrls+IUZgNFglSNsdqlYl\n\tVifA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1729438117; x=1730042917;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=fsdRqpztdFaGeJkanrNCe+tQNA7Ad8aazk7oOb+NI/U=;\n\tb=itmeH3DNLvuaDs1iII7sxMw7n6j219wZLX0dPEuMPBxH5XzZmuLv4vu2iBOXdIZVvE\n\tYknvWpLVaE5idSXuMVBwbbhR7PA3rWkYiWjeesBKX/HdxfoOcVfHPhAFcNtTZZmPD0H3\n\tcb7WBuIK8lmog0d2aas8CsXXE29UMOumKH/yDJzdACYdoC0CqM209Cidg54bJ+9gXK3S\n\tBuJ1omA0ECbBMzlxH42PEG9Y1kXSR6UdFyE4vV72a31ii5mMBkCcf+S5cwLFEJ7n+p9p\n\tjUZK1Gyg+aFVcG709EHcXjTpNoJ9G0Ih4b1HXGX0Afob0+emBIq5MqwcW8PYbGxD2LMV\n\t5djA==","X-Gm-Message-State":"AOJu0YwEdUo6rSGM0TiwOHL2Jijg2gCAZrCJYzxdkf4SV5xK0+zO1ych\n\tL77gS3rVDt09Rr3vWO6QApbcjLCHNXTNOFqgxUs86VSHBLm1+DjVpU1Dlw==","X-Google-Smtp-Source":"AGHT+IHtoztCDMhr0JKj4r1ZDn3Yt9UjHA8s32jtwRaYYwiSv4EuEEYoYk80octrfa1swGcom6D7zw==","X-Received":"by 2002:a05:6512:12d3:b0:539:918c:5132 with SMTP id\n\t2adb3069b0e04-53a0c620607mr4398070e87.0.1729438116608; \n\tSun, 20 Oct 2024 08:28:36 -0700 (PDT)","From":"Mikhail Rudenko <mike.rudenko@gmail.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tMikhail Rudenko <mike.rudenko@gmail.com>","Subject":"[PATCH v2 1/4] ipa: rkisp1: agc: Use better defaults for analogue\n\tgain and exposure","Date":"Sun, 20 Oct 2024 18:28:18 +0300","Message-ID":"<20241020152821.240726-2-mike.rudenko@gmail.com>","X-Mailer":"git-send-email 2.46.0","In-Reply-To":"<20241020152821.240726-1-mike.rudenko@gmail.com>","References":"<20241020152821.240726-1-mike.rudenko@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"At present, analogue gain in IPA context is initialized to the minimum\nsensor gain in configure(). Many sensors report minimum analogue gain\nof 0, which is by no means a sane default. Use a reasonable default of\n1.0 instead. Also, set default exposure to maximum. In the common case\nwhen no gain stages are configured and no gain/exposure constraints\nare set, these defaults result in having right gain or exposure from\nthe start, since AGC either sets 1.0 gain and steers exposure (lighter\nscenes), or sets max exposure and steers gain (darker scenes).\n\nSigned-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>\n---\n src/ipa/rkisp1/algorithms/agc.cpp | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 17d074d9..2b36d7aa 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -30,9 +30,12 @@\n namespace libcamera {\n \n using namespace std::literals::chrono_literals;\n+using utils::Duration;\n \n namespace ipa::rkisp1::algorithms {\n \n+constexpr double defaultAnalogueGain = 1.0;\n+\n /**\n  * \\class Agc\n  * \\brief A mean-based auto-exposure algorithm\n@@ -164,9 +167,9 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData)\n int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n {\n \t/* Configure the default exposure and gain. */\n-\tcontext.activeState.agc.automatic.gain = context.configuration.sensor.minAnalogueGain;\n+\tcontext.activeState.agc.automatic.gain = defaultAnalogueGain;\n \tcontext.activeState.agc.automatic.exposure =\n-\t\t10ms / context.configuration.sensor.lineDuration;\n+\t\tcontext.configuration.sensor.maxShutterSpeed / context.configuration.sensor.lineDuration;\n \tcontext.activeState.agc.manual.gain = context.activeState.agc.automatic.gain;\n \tcontext.activeState.agc.manual.exposure = context.activeState.agc.automatic.exposure;\n \tcontext.activeState.agc.autoEnabled = !context.configuration.raw;\n","prefixes":["v2","1/4"]}