From patchwork Fri Oct 13 07:48:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19140 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 62E96C32B7 for ; Fri, 13 Oct 2023 07:49:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 20A166299A; Fri, 13 Oct 2023 09:49:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697183348; bh=x3O3orwN+9EoA2Rduqqnz09cvsygphT8R3W1P/h0/ZU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=GPCikNrwodMncila1kIp+hVfF165nKrfdmhrQHPdq7h436/7qgSlqBna9jzwuTKBh 5VJfgEVjgsllJ0+HtmQcczW16USRskHspA0alczR+o+zz+E62PVTAPg+tFlSgCVQ3o 4U6r75zb3IJcu74ioc2FM1Ic0FppIerJbnybe3MaLMeVIbZV8Hrk2E9cxT3/LvifiJ CzFq1NnFtNdjKmed56aqfAiKyTBPAGbw87UsBYrGUEmI96yLfvfGDzKv3eNyxuLErZ +0XcQI2FKix5jVWK0EUKWXXpYBKMaqTz1LeqoGxW50yDUFh1LqlfBmEEoYz9W3XF5h d/ehTyRkdwHAA== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 79CAE62988 for ; Fri, 13 Oct 2023 09:48:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="kJSBq0l/"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40572aeb6d0so18693725e9.1 for ; Fri, 13 Oct 2023 00:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1697183338; x=1697788138; 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=77tYb2TD81ZwFQSZvXJvqN5v3/YGS+HcLZAwDU1MFVg=; b=kJSBq0l/cFwlCoZDQKnTHMS09zwEblrZ6LF7slzimfc6MIAKaKdevDy1WQOC5HE6SF 6CtnT8V7Cl5U0wb0aGOhnwj5zjSxFQGh3LNBVBWKBOwRrBiAyXKs1y+KHa0ZEGSYr9ZF UTlkRTT+dhYu5hqbJKfoxRNxAwLbet/Q7jajbKwZYLTWIUqXzwsN+lhcpp8z+Awgc43A 2C8dKcoxAvm7sZTp5ZsOpF81FhVNjpvWJHpJ9IUyFo0N2Y5NfmWw5JFSyT+jDuvVywjH JtzkQAcsHH+NN1/V16g0U51UBprgXL8d3PMAFkgl5aPRbUzvjLcQYOBIV9dR7Q1BFZDC 5+EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697183338; x=1697788138; 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=77tYb2TD81ZwFQSZvXJvqN5v3/YGS+HcLZAwDU1MFVg=; b=CRNuUp/ysT0XRZNqUGv9R1NOLVcQbVdUvKYflA/seR0E3f6oNn21JDTMUzQK75I1F9 JvaRhsw9HVLY+DIjqNZZaf8ITxFgHNhKsCHSDm5o8ZMh1n+sDDv2BeF+bG1X2WxECNHo iIYVs+VnwcNi1fULCEKKujNisA/PTOSdPX/RYwPikUyFhzkdJpmEs8OWeX/g1IU6W44Q hekZb43z6NH5MMu1yS+MWnjhbKDi/H/38Cyv/g1r91SQJ2oohdmbXLphHzBqtlCI+h+x Bh2F5bRxlopmgJNdSosRpZPIYxNDJpRz9fs1f6t8mniOpoWY5zLw9ktDmoo8Wye6fJ+u QpSg== X-Gm-Message-State: AOJu0YwtZtgD0ERtpudVKZFFWokDfVyLWYBCjbqCATFoUgBDUOqDMbX/ gX45MQat9G+lJhkdJzx6adSmFW+/rUJ9TGdnwIcvhw== X-Google-Smtp-Source: AGHT+IE/QKMlYyG5LD2nkfeMBWYjx1kWygV9u9wRapCuWWzQRvfguDY7+KJc4zfUb8I3hMy1mAn7aA== X-Received: by 2002:a1c:4c13:0:b0:406:7d74:a29b with SMTP id z19-20020a1c4c13000000b004067d74a29bmr22623694wmf.13.1697183337865; Fri, 13 Oct 2023 00:48:57 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id m16-20020a7bca50000000b003fee6e170f9sm1791890wml.45.2023.10.13.00.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 00:48:57 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 13 Oct 2023 08:48:37 +0100 Message-Id: <20231013074841.16972-17-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013074841.16972-1-naush@raspberrypi.com> References: <20231013074841.16972-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 16/20] ipa: rpi: agc: Add an AGC stable region 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: David Plowman Add a small "stable region" parameter (defaulting to 2%) within which the AGC will not adjust the exposure it requests. It allows applications to configure the AGC to avoid continual micro-adjustments of exposure values if they are somehow sensitive to it. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- src/ipa/rpi/controller/rpi/agc_channel.cpp | 7 +++++++ src/ipa/rpi/controller/rpi/agc_channel.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp index 3957dbc3fa32..1e7eae06d425 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.cpp +++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp @@ -251,6 +251,8 @@ int AgcConfig::read(const libcamera::YamlObject ¶ms) defaultExposureTime = params["default_exposure_time"].get(1000) * 1us; defaultAnalogueGain = params["default_analogue_gain"].get(1.0); + stableRegion = params["stable_region"].get(0.02); + return 0; } @@ -871,6 +873,8 @@ bool AgcChannel::applyDigitalGain(double gain, double targetY, bool channelBound void AgcChannel::filterExposure() { double speed = config_.speed; + double stableRegion = config_.stableRegion; + /* * AGC adapts instantly if both shutter and gain are directly specified * or we're in the startup phase. @@ -880,6 +884,9 @@ void AgcChannel::filterExposure() speed = 1.0; if (!filtered_.totalExposure) { filtered_.totalExposure = target_.totalExposure; + } else if (filtered_.totalExposure * (1.0 - stableRegion) < target_.totalExposure && + filtered_.totalExposure * (1.0 + stableRegion) > target_.totalExposure) { + /* Total exposure must change by more than this or we leave it alone. */ } else { /* * If close to the result go faster, to save making so many diff --git a/src/ipa/rpi/controller/rpi/agc_channel.h b/src/ipa/rpi/controller/rpi/agc_channel.h index ae826fa8097f..c1808422498a 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.h +++ b/src/ipa/rpi/controller/rpi/agc_channel.h @@ -75,6 +75,7 @@ struct AgcConfig { double baseEv; libcamera::utils::Duration defaultExposureTime; double defaultAnalogueGain; + double stableRegion; }; class AgcChannel