From patchwork Thu Oct 17 12:46:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Rudenko X-Patchwork-Id: 21651 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 CB0EFC32FC for ; Thu, 17 Oct 2024 12:46:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DC85265387; Thu, 17 Oct 2024 14:46:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PLtcRFdd"; dkim-atps=neutral Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B867A6353B for ; Thu, 17 Oct 2024 14:46:22 +0200 (CEST) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2fb4fa17044so10188681fa.3 for ; Thu, 17 Oct 2024 05:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729169181; x=1729773981; 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=gf//YmGItTJZqmMJGI0RLt5WZowlPXW4ukhDfXgr89M=; b=PLtcRFddVXzhQMbFRuOKLwt0OGFcJB9ZMMGP6pBncvVqGyKlXpBdgBuZ39vbnVzA7Z K16QQeT+Y4k+SrI3C7S6zhfnXdsyg2M5r8X8BjEYw+tpF67dGQaDJsEwALxcqZB7ZDFP oM7Df0mj4ysa8I6u4o+26oQSYawFgh1YQyXlaz5Oq3EwjCjg+osTLGe/j5S33nMIz/pQ dpQC1eQMQvw1v7exRAEIHPH+bAxMm28/AFmz7ISoEc9PDVw0Rha5jw2Ncyxs0m26wuwg I4hXr2rbQZvK8y00CyC8gf+NJRqnDQjx4c4mTf24b4p43AzHM8isCkfNodAyujrTRhJb sQGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729169181; x=1729773981; 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=gf//YmGItTJZqmMJGI0RLt5WZowlPXW4ukhDfXgr89M=; b=HXjTnTWI8x2dovHLwKJ7nxJvr/PtpzM9dwi8mkLZcRLfkv5dmhnrPU4sL4MwKLd26z Xm2VNY017Q1iCS7pmST7sEVv/7ew1X0lGoqdGMgCsk2c4XvkFetw2UOS6NvgcT7c6ouq FsGfwcKRtpkAdIKFDmFUIZNlM47m/aB3XCbig8PbS/7qflBVWAt1qzIzkSEvOQaPIEmw HiPoTvlzrWPvhyNWGrZl2SnqWHA+Vm7n08NZaRgoFS81tLC7osJPFRvj5SNObGNPnQdE 8WPnguZy8pUQYH8Wsz+l+/o3xSncUYTxAY9NRkvvbbuuGJh3jGvXxJBKj9whcUlztum0 9ATw== X-Gm-Message-State: AOJu0YyZOJhRWdSFxNb6RS1f97kkg4vgG9UB2sk9ow8QeCgHWnW0z19Q bjFklOHHKR/H3Dg2FDki7t8XS84qhGMDdzJUjV2kY/8aKJ4CNQdDA8mxJQ== X-Google-Smtp-Source: AGHT+IEOGj9OnSDq497BhqP4ufqC7mYZI70EH7SkQvVrdOsxkqjHbYpAyGpPjCqM6yrFAaO9J16ShA== X-Received: by 2002:a2e:bea7:0:b0:2fb:5ebe:ed40 with SMTP id 38308e7fff4ca-2fb5ebef039mr57788551fa.15.1729169181057; Thu, 17 Oct 2024 05:46:21 -0700 (PDT) Received: from localhost ([83.149.246.185]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fb5d0fb634sm7374221fa.11.2024.10.17.05.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 05:46:20 -0700 (PDT) From: Mikhail Rudenko To: libcamera-devel@lists.libcamera.org Cc: Mikhail Rudenko Subject: [PATCH 1/3] ipa: rkisp1: agc: Use better default value for analogue gain Date: Thu, 17 Oct 2024 15:46:11 +0300 Message-ID: <20241017124613.3853273-2-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241017124613.3853273-1-mike.rudenko@gmail.com> References: <20241017124613.3853273-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 move the default exposure to a named constant. Signed-off-by: Mikhail Rudenko --- src/ipa/rkisp1/algorithms/agc.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 17d074d9..339cddef 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -30,9 +30,13 @@ namespace libcamera { using namespace std::literals::chrono_literals; +using utils::Duration; namespace ipa::rkisp1::algorithms { +constexpr double defaultAnalogueGain = 1.0; +constexpr Duration defaultExposureTime = 10.0ms; + /** * \class Agc * \brief A mean-based auto-exposure algorithm @@ -164,9 +168,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; + defaultExposureTime / 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;