{"id":19118,"url":"https://patchwork.libcamera.org/api/patches/19118/?format=json","web_url":"https://patchwork.libcamera.org/patch/19118/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20231006132000.23504-17-naush@raspberrypi.com>","date":"2023-10-06T13:19:56","name":"[libcamera-devel,16/20] ipa: rpi: agc: Add an AGC stable region","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"2b686d852c14481f4f623ca50e668ef800aba8f0","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19118/mbox/","series":[{"id":4047,"url":"https://patchwork.libcamera.org/api/series/4047/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4047","date":"2023-10-06T13:19:40","name":"Raspberry Pi: Preliminary PiSP support","version":1,"mbox":"https://patchwork.libcamera.org/series/4047/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19118/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19118/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 558BDC32BF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Oct 2023 13:20:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1ACCC62983;\n\tFri,  6 Oct 2023 15:20:20 +0200 (CEST)","from mail-wm1-x334.google.com (mail-wm1-x334.google.com\n\t[IPv6:2a00:1450:4864:20::334])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9A81062970\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Oct 2023 15:20:16 +0200 (CEST)","by mail-wm1-x334.google.com with SMTP id\n\t5b1f17b1804b1-40684f53d11so20303525e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 06 Oct 2023 06:20:16 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tm8-20020a056000180800b00321773bb933sm1639478wrh.77.2023.10.06.06.20.14\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 06 Oct 2023 06:20:15 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1696598420;\n\tbh=T75VGxIX4RUkLNCWmNWdLZdY1W9EPwWSCDSbp+dxzaw=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=HPmSjMyBRZXzXUy8dqjmkDfRvlSM7xjlhqK1+tBzylIQn9OXBBAQ7r65y3/YZ5Jn5\n\t1IYzWHMNMM5WSnb0wc6wn46DZuf1wj+zQlwY8Z4TrEIRxE0Z97E8A1AqEHP9KDXc2C\n\tGQ9u6Mqz1LhYwWz/aKD9Aeuo6f7cCFnLvzqdySfh1PZ5efofuJS8DorFVXy8PJuPpZ\n\t7X9f/Tz1mAaKmk4nf7KY2GFBh9o3CGhodiX/KATvUePKTg9+p0sMjV8Iqszzisef4p\n\ttPWeX1nOgNXVSPxUa2BI/BS1Hv72+3/yfKrCqpWY/NmfuGxrwvpSQhC/r47NOTZ9nR\n\tQbtwHqRD6UyIQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1696598416; x=1697203216;\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=dQ0brK8cAfxANWWPLZx06cfd1rpKrCG3c+CPadf4YdI=;\n\tb=OifkYwNyjECuE60AztcWThHmjz+V3ifrlIqD5kQI6lCJFCdbDGEzyPkLd2hAxsXNJy\n\tJxw8goGAVGRt37vdsEfPKPJlAOFd99Hgp3xFfasOrPSWUB/2PPEZFuFoCOwJZ32p9Sqs\n\tMQdtKRh0xL1SmVK4pSnVWjWv8yeJsNcL/CxzVHQwVpycPgZvGbK/DePFBr8m9zgXwSb6\n\t38FAGBEwRJPITq32dEPUEymjWblFd32QYxww/C1d8LXT0xYlcziLvkvgNarB3Y078uqD\n\tVa9aShcCbEJDerACiWGYOiQDBOELyIUbnaLvdbovOg3+HVZPpWY3QKMCAEGFXEIEJ/kZ\n\tvxhw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"OifkYwNy\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1696598416; x=1697203216;\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=dQ0brK8cAfxANWWPLZx06cfd1rpKrCG3c+CPadf4YdI=;\n\tb=lZRPSwtyo8NUWgjz0iiqSeTQMJC6zByXw2dVMVH6DC2F6+raBQQ32W+6H/qgWWlu21\n\t1VSXp9ATWJSqaM4tNPOnLVbjjfzbGx97OLczYWcmaSLiWTa8dv48HmNamJwiAqBKzUIK\n\tjWJ32ToqlWSOpv6mxcEaWiYIsKP9V8GuU3GEyUQ6TWyOErNPpXTr6BVzpRZXkW4SpfcY\n\tMmVDh3o9k3h025GgnbpeuISOJOSsPdKzwRzeAsrabVfJ01WZViuEFFhSpq0IVSG0GCub\n\tSLbNW5H4lkR6nhT0CqnZT2joJTVp/wtNFQwM6emceIovGGdyG1+M/q5kONpHF3m8Wa+y\n\tBAHQ==","X-Gm-Message-State":"AOJu0YztaXpBXq8Dn+AR+YTOw0Ca95rlnw/i+51WWt1VuFFONg/ruJWe\n\tR0IiMaTVQE+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\n\tn10-20020a5d484a000000b0031ffe07fddemr7895228wrs.12.1696598415999; \n\tFri, 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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 16/20] ipa: rpi: agc: Add an AGC stable\n\tregion","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: David Plowman <david.plowman@raspberrypi.com>\n\nAdd a small \"stable region\" parameter (defaulting to 2%) within which\nthe AGC will not adjust the exposure it requests. It allows\napplications to configure the AGC to avoid continual micro-adjustments\nof exposure values if they are somehow sensitive to it.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/rpi/controller/rpi/agc_channel.cpp | 7 +++++++\n src/ipa/rpi/controller/rpi/agc_channel.h   | 1 +\n 2 files changed, 8 insertions(+)","diff":"diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp\nindex 3957dbc3fa32..1e7eae06d425 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.cpp\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n@@ -251,6 +251,8 @@ int AgcConfig::read(const libcamera::YamlObject &params)\n \tdefaultExposureTime = params[\"default_exposure_time\"].get<double>(1000) * 1us;\n \tdefaultAnalogueGain = params[\"default_analogue_gain\"].get<double>(1.0);\n \n+\tstableRegion = params[\"stable_region\"].get<double>(0.02);\n+\n \treturn 0;\n }\n \n@@ -871,6 +873,8 @@ bool AgcChannel::applyDigitalGain(double gain, double targetY, bool channelBound\n void AgcChannel::filterExposure()\n {\n \tdouble speed = config_.speed;\n+\tdouble stableRegion = config_.stableRegion;\n+\n \t/*\n \t * AGC adapts instantly if both shutter and gain are directly specified\n \t * or we're in the startup phase.\n@@ -880,6 +884,9 @@ void AgcChannel::filterExposure()\n \t\tspeed = 1.0;\n \tif (!filtered_.totalExposure) {\n \t\tfiltered_.totalExposure = target_.totalExposure;\n+\t} else if (filtered_.totalExposure * (1.0 - stableRegion) < target_.totalExposure &&\n+\t\t   filtered_.totalExposure * (1.0 + stableRegion) > target_.totalExposure) {\n+\t\t/* Total exposure must change by more than this or we leave it alone. */\n \t} else {\n \t\t/*\n \t\t * If close to the result go faster, to save making so many\ndiff --git a/src/ipa/rpi/controller/rpi/agc_channel.h b/src/ipa/rpi/controller/rpi/agc_channel.h\nindex ae826fa8097f..c1808422498a 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.h\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.h\n@@ -75,6 +75,7 @@ struct AgcConfig {\n \tdouble baseEv;\n \tlibcamera::utils::Duration defaultExposureTime;\n \tdouble defaultAnalogueGain;\n+\tdouble stableRegion;\n };\n \n class AgcChannel\n","prefixes":["libcamera-devel","16/20"]}