{"id":19140,"url":"https://patchwork.libcamera.org/api/patches/19140/?format=json","web_url":"https://patchwork.libcamera.org/patch/19140/","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":"<20231013074841.16972-17-naush@raspberrypi.com>","date":"2023-10-13T07:48:37","name":"[libcamera-devel,v2,16/20] ipa: rpi: agc: Add an AGC stable region","commit_ref":null,"pull_url":null,"state":"accepted","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/19140/mbox/","series":[{"id":4049,"url":"https://patchwork.libcamera.org/api/series/4049/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4049","date":"2023-10-13T07:48:21","name":"Raspberry Pi: Preliminary PiSP support","version":2,"mbox":"https://patchwork.libcamera.org/series/4049/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19140/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19140/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 62E96C32B7\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Oct 2023 07:49:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 20A166299A;\n\tFri, 13 Oct 2023 09:49:08 +0200 (CEST)","from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 79CAE62988\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 09:48:58 +0200 (CEST)","by mail-wm1-x32b.google.com with SMTP id\n\t5b1f17b1804b1-40572aeb6d0so18693725e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 00:48:58 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tm16-20020a7bca50000000b003fee6e170f9sm1791890wml.45.2023.10.13.00.48.57\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 13 Oct 2023 00:48:57 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697183348;\n\tbh=x3O3orwN+9EoA2Rduqqnz09cvsygphT8R3W1P/h0/ZU=;\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:Cc:\n\tFrom;\n\tb=GPCikNrwodMncila1kIp+hVfF165nKrfdmhrQHPdq7h436/7qgSlqBna9jzwuTKBh\n\t5VJfgEVjgsllJ0+HtmQcczW16USRskHspA0alczR+o+zz+E62PVTAPg+tFlSgCVQ3o\n\t4U6r75zb3IJcu74ioc2FM1Ic0FppIerJbnybe3MaLMeVIbZV8Hrk2E9cxT3/LvifiJ\n\tCzFq1NnFtNdjKmed56aqfAiKyTBPAGbw87UsBYrGUEmI96yLfvfGDzKv3eNyxuLErZ\n\t+0XcQI2FKix5jVWK0EUKWXXpYBKMaqTz1LeqoGxW50yDUFh1LqlfBmEEoYz9W3XF5h\n\td/ehTyRkdwHAA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1697183338; x=1697788138;\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=77tYb2TD81ZwFQSZvXJvqN5v3/YGS+HcLZAwDU1MFVg=;\n\tb=kJSBq0l/cFwlCoZDQKnTHMS09zwEblrZ6LF7slzimfc6MIAKaKdevDy1WQOC5HE6SF\n\t6CtnT8V7Cl5U0wb0aGOhnwj5zjSxFQGh3LNBVBWKBOwRrBiAyXKs1y+KHa0ZEGSYr9ZF\n\tUTlkRTT+dhYu5hqbJKfoxRNxAwLbet/Q7jajbKwZYLTWIUqXzwsN+lhcpp8z+Awgc43A\n\t2C8dKcoxAvm7sZTp5ZsOpF81FhVNjpvWJHpJ9IUyFo0N2Y5NfmWw5JFSyT+jDuvVywjH\n\tJtzkQAcsHH+NN1/V16g0U51UBprgXL8d3PMAFkgl5aPRbUzvjLcQYOBIV9dR7Q1BFZDC\n\t5+EQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"kJSBq0l/\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1697183338; x=1697788138;\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=77tYb2TD81ZwFQSZvXJvqN5v3/YGS+HcLZAwDU1MFVg=;\n\tb=CRNuUp/ysT0XRZNqUGv9R1NOLVcQbVdUvKYflA/seR0E3f6oNn21JDTMUzQK75I1F9\n\tJvaRhsw9HVLY+DIjqNZZaf8ITxFgHNhKsCHSDm5o8ZMh1n+sDDv2BeF+bG1X2WxECNHo\n\tiIYVs+VnwcNi1fULCEKKujNisA/PTOSdPX/RYwPikUyFhzkdJpmEs8OWeX/g1IU6W44Q\n\thekZb43z6NH5MMu1yS+MWnjhbKDi/H/38Cyv/g1r91SQJ2oohdmbXLphHzBqtlCI+h+x\n\tBh2F5bRxlopmgJNdSosRpZPIYxNDJpRz9fs1f6t8mniOpoWY5zLw9ktDmoo8Wye6fJ+u\n\tQpSg==","X-Gm-Message-State":"AOJu0YwtZtgD0ERtpudVKZFFWokDfVyLWYBCjbqCATFoUgBDUOqDMbX/\n\tgX45MQat9G+lJhkdJzx6adSmFW+/rUJ9TGdnwIcvhw==","X-Google-Smtp-Source":"AGHT+IE/QKMlYyG5LD2nkfeMBWYjx1kWygV9u9wRapCuWWzQRvfguDY7+KJc4zfUb8I3hMy1mAn7aA==","X-Received":"by 2002:a1c:4c13:0:b0:406:7d74:a29b with SMTP id\n\tz19-20020a1c4c13000000b004067d74a29bmr22623694wmf.13.1697183337865; \n\tFri, 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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 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>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.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>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.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","v2","16/20"]}