From patchwork Sun Oct 20 15:28:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Rudenko X-Patchwork-Id: 21707 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 1AF9AC3304 for ; Sun, 20 Oct 2024 15:28:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9ADDF65395; Sun, 20 Oct 2024 17:28:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OJlUgRxo"; dkim-atps=neutral Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E0D6F65379 for ; Sun, 20 Oct 2024 17:28:37 +0200 (CEST) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-539e4b7409fso3640841e87.0 for ; Sun, 20 Oct 2024 08:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729438117; x=1730042917; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fsdRqpztdFaGeJkanrNCe+tQNA7Ad8aazk7oOb+NI/U=; b=OJlUgRxoaRVPBFiTp5QAo22J2LptEVb5amdRSrmFxRdxzkCI+Vy4VVbxFw/Jxdm6Cj ST60YVecESkrNHpB0J98RJE5mTSc4PMrknRe+HFbi+hUHDwk1WcBknO4XVrXIjHwDvCz ufsLi0RDRCo/TJDHiyTYwaYGMaKeAmiHS4PLWpwtS0GORrpJq36hwOq+qbmwyRnXVxuN dyRG2snRkiME4T6XzQ7vTHFkx+68aKYgsyhzCOr+kS6A30mFDbM4RvyGIRkcgnOmyLSw 9whxY1DeHiVJE1fZYd+Hazg5/w9YgmglRrByPeLxv+h/jfCDrls+IUZgNFglSNsdqlYl VifA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729438117; x=1730042917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fsdRqpztdFaGeJkanrNCe+tQNA7Ad8aazk7oOb+NI/U=; b=itmeH3DNLvuaDs1iII7sxMw7n6j219wZLX0dPEuMPBxH5XzZmuLv4vu2iBOXdIZVvE YknvWpLVaE5idSXuMVBwbbhR7PA3rWkYiWjeesBKX/HdxfoOcVfHPhAFcNtTZZmPD0H3 cb7WBuIK8lmog0d2aas8CsXXE29UMOumKH/yDJzdACYdoC0CqM209Cidg54bJ+9gXK3S BuJ1omA0ECbBMzlxH42PEG9Y1kXSR6UdFyE4vV72a31ii5mMBkCcf+S5cwLFEJ7n+p9p jUZK1Gyg+aFVcG709EHcXjTpNoJ9G0Ih4b1HXGX0Afob0+emBIq5MqwcW8PYbGxD2LMV 5djA== X-Gm-Message-State: AOJu0YwEdUo6rSGM0TiwOHL2Jijg2gCAZrCJYzxdkf4SV5xK0+zO1ych L77gS3rVDt09Rr3vWO6QApbcjLCHNXTNOFqgxUs86VSHBLm1+DjVpU1Dlw== X-Google-Smtp-Source: AGHT+IHtoztCDMhr0JKj4r1ZDn3Yt9UjHA8s32jtwRaYYwiSv4EuEEYoYk80octrfa1swGcom6D7zw== X-Received: by 2002:a05:6512:12d3:b0:539:918c:5132 with SMTP id 2adb3069b0e04-53a0c620607mr4398070e87.0.1729438116608; Sun, 20 Oct 2024 08:28:36 -0700 (PDT) Received: from localhost.localdomain (static.40.223.216.95.clients.your-server.de. [95.216.223.40]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53a223efad4sm249040e87.67.2024.10.20.08.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:28:36 -0700 (PDT) From: Mikhail Rudenko To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Mikhail Rudenko Subject: [PATCH v2 1/4] ipa: rkisp1: agc: Use better defaults for analogue gain 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 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" At present, analogue gain in IPA context is initialized to the minimum sensor gain in configure(). Many sensors report minimum analogue gain of 0, which is by no means a sane default. Use a reasonable default of 1.0 instead. Also, set default exposure to maximum. In the common case when no gain stages are configured and no gain/exposure constraints are set, these defaults result in having right gain or exposure from the start, since AGC either sets 1.0 gain and steers exposure (lighter scenes), or sets max exposure and steers gain (darker scenes). Signed-off-by: Mikhail Rudenko --- src/ipa/rkisp1/algorithms/agc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 17d074d9..2b36d7aa 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -30,9 +30,12 @@ namespace libcamera { using namespace std::literals::chrono_literals; +using utils::Duration; namespace ipa::rkisp1::algorithms { +constexpr double defaultAnalogueGain = 1.0; + /** * \class Agc * \brief A mean-based auto-exposure algorithm @@ -164,9 +167,9 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData) int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) { /* Configure the default exposure and gain. */ - context.activeState.agc.automatic.gain = context.configuration.sensor.minAnalogueGain; + context.activeState.agc.automatic.gain = defaultAnalogueGain; context.activeState.agc.automatic.exposure = - 10ms / context.configuration.sensor.lineDuration; + context.configuration.sensor.maxShutterSpeed / context.configuration.sensor.lineDuration; context.activeState.agc.manual.gain = context.activeState.agc.automatic.gain; context.activeState.agc.manual.exposure = context.activeState.agc.automatic.exposure; context.activeState.agc.autoEnabled = !context.configuration.raw;