From patchwork Fri Oct 6 13:19:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19118 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 558BDC32BF for ; Fri, 6 Oct 2023 13:20:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1ACCC62983; Fri, 6 Oct 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1696598420; bh=T75VGxIX4RUkLNCWmNWdLZdY1W9EPwWSCDSbp+dxzaw=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=HPmSjMyBRZXzXUy8dqjmkDfRvlSM7xjlhqK1+tBzylIQn9OXBBAQ7r65y3/YZ5Jn5 1IYzWHMNMM5WSnb0wc6wn46DZuf1wj+zQlwY8Z4TrEIRxE0Z97E8A1AqEHP9KDXc2C GQ9u6Mqz1LhYwWz/aKD9Aeuo6f7cCFnLvzqdySfh1PZ5efofuJS8DorFVXy8PJuPpZ 7X9f/Tz1mAaKmk4nf7KY2GFBh9o3CGhodiX/KATvUePKTg9+p0sMjV8Iqszzisef4p tPWeX1nOgNXVSPxUa2BI/BS1Hv72+3/yfKrCqpWY/NmfuGxrwvpSQhC/r47NOTZ9nR QbtwHqRD6UyIQ== Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9A81062970 for ; Fri, 6 Oct 2023 15:20:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="OifkYwNy"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40684f53d11so20303525e9.1 for ; Fri, 06 Oct 2023 06:20:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1696598416; x=1697203216; 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=dQ0brK8cAfxANWWPLZx06cfd1rpKrCG3c+CPadf4YdI=; b=OifkYwNyjECuE60AztcWThHmjz+V3ifrlIqD5kQI6lCJFCdbDGEzyPkLd2hAxsXNJy Jxw8goGAVGRt37vdsEfPKPJlAOFd99Hgp3xFfasOrPSWUB/2PPEZFuFoCOwJZ32p9Sqs MQdtKRh0xL1SmVK4pSnVWjWv8yeJsNcL/CxzVHQwVpycPgZvGbK/DePFBr8m9zgXwSb6 38FAGBEwRJPITq32dEPUEymjWblFd32QYxww/C1d8LXT0xYlcziLvkvgNarB3Y078uqD Va9aShcCbEJDerACiWGYOiQDBOELyIUbnaLvdbovOg3+HVZPpWY3QKMCAEGFXEIEJ/kZ vxhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598416; x=1697203216; 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=dQ0brK8cAfxANWWPLZx06cfd1rpKrCG3c+CPadf4YdI=; b=lZRPSwtyo8NUWgjz0iiqSeTQMJC6zByXw2dVMVH6DC2F6+raBQQ32W+6H/qgWWlu21 1VSXp9ATWJSqaM4tNPOnLVbjjfzbGx97OLczYWcmaSLiWTa8dv48HmNamJwiAqBKzUIK jWJ32ToqlWSOpv6mxcEaWiYIsKP9V8GuU3GEyUQ6TWyOErNPpXTr6BVzpRZXkW4SpfcY MmVDh3o9k3h025GgnbpeuISOJOSsPdKzwRzeAsrabVfJ01WZViuEFFhSpq0IVSG0GCub SLbNW5H4lkR6nhT0CqnZT2joJTVp/wtNFQwM6emceIovGGdyG1+M/q5kONpHF3m8Wa+y BAHQ== X-Gm-Message-State: AOJu0YztaXpBXq8Dn+AR+YTOw0Ca95rlnw/i+51WWt1VuFFONg/ruJWe R0IiMaTVQE+VfVaZ2O98vIOcZii6sRU/h8F9Barzng== X-Google-Smtp-Source: AGHT+IGqQFf3Tzc64RqzgKNq6cCY2m8e+AZMv+S9v6qv7mAqp7FPBKphAx0/JEpGfIvcEOa+XqlrOw== X-Received: by 2002:a5d:484a:0:b0:31f:fe07:fdde with SMTP id n10-20020a5d484a000000b0031ffe07fddemr7895228wrs.12.1696598415999; Fri, 06 Oct 2023 06:20:15 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id m8-20020a056000180800b00321773bb933sm1639478wrh.77.2023.10.06.06.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:20:15 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 6 Oct 2023 14:19:56 +0100 Message-Id: <20231006132000.23504-17-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231006132000.23504-1-naush@raspberrypi.com> References: <20231006132000.23504-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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 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