[{"id":37456,"web_url":"https://patchwork.libcamera.org/comment/37456/","msgid":"<85ikdkpaqt.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-01-02T10:30:50","subject":"Re: [PATCH] ipa: simple: agc: Make sure activeState.agc expo/again\n\tare always initialized","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi Hans,\n\nthank you for the patch.\n\nHans de Goede <johannes.goede@oss.qualcomm.com> writes:\n\n> If the first frame of a stream is bad, the IPA will not get called with\n> frame == 0, leaving activeState.agc expo/again uninitialized. This causes\n> the agc algorithm to set a very low gain and exposure on the next run\n> (where it will hit the if (!stats->valid) {} path) resulting in starting\n> with a black image.\n>\n> Fix this by using a valid flag instead of checking for frame == 0.\n>\n> The entire activeState gets cleared to 0 on configure() resetting the new\n> valid flag.\n>\n> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\n\n> ---\n>  src/ipa/simple/algorithms/agc.cpp | 5 +++--\n>  src/ipa/simple/ipa_context.h      | 1 +\n>  2 files changed, 4 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp\n> index 189de770..2f7e040c 100644\n> --- a/src/ipa/simple/algorithms/agc.cpp\n> +++ b/src/ipa/simple/algorithms/agc.cpp\n> @@ -100,7 +100,7 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou\n>  }\n>  \n>  void Agc::process(IPAContext &context,\n> -\t\t  const uint32_t frame,\n> +\t\t  [[maybe_unused]] const uint32_t frame,\n>  \t\t  IPAFrameContext &frameContext,\n>  \t\t  const SwIspStats *stats,\n>  \t\t  ControlList &metadata)\n> @@ -110,13 +110,14 @@ void Agc::process(IPAContext &context,\n>  \tmetadata.set(controls::ExposureTime, exposureTime.get<std::micro>());\n>  \tmetadata.set(controls::AnalogueGain, frameContext.sensor.gain);\n>  \n> -\tif (frame == 0) {\n> +\tif (!context.activeState.agc.valid) {\n>  \t\t/*\n>  \t\t * Init active-state from sensor values in case updateExposure()\n>  \t\t * does not run for the first frame.\n>  \t\t */\n>  \t\tcontext.activeState.agc.exposure = frameContext.sensor.exposure;\n>  \t\tcontext.activeState.agc.again = frameContext.sensor.gain;\n> +\t\tcontext.activeState.agc.valid = true;\n>  \t}\n>  \n>  \tif (!stats->valid) {\n> diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\n> index c3081e30..26b60fb6 100644\n> --- a/src/ipa/simple/ipa_context.h\n> +++ b/src/ipa/simple/ipa_context.h\n> @@ -40,6 +40,7 @@ struct IPAActiveState {\n>  \tstruct {\n>  \t\tint32_t exposure;\n>  \t\tdouble again;\n> +\t\tbool valid;\n>  \t} agc;\n>  \n>  \tstruct {","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 9F65BBDCC0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Jan 2026 10:30:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DAE8F61FB7;\n\tFri,  2 Jan 2026 11:30:57 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 489F46142F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Jan 2026 11:30:56 +0100 (CET)","from mail-wr1-f72.google.com (mail-wr1-f72.google.com\n\t[209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-455-IjKRBwigPbyOJ1Jyuxj-hw-1; Fri, 02 Jan 2026 05:30:53 -0500","by mail-wr1-f72.google.com with SMTP id\n\tffacd0b85a97d-430ffa9fccaso9338870f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 02 Jan 2026 02:30:53 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-4324eaa2beasm82776741f8f.33.2026.01.02.02.30.50\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 02 Jan 2026 02:30:51 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"YutT21Pu\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1767349855;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=Z3n4oKr7VlXpH2JdVQ0oDL4TX8+6awEtyLrfgihnjTk=;\n\tb=YutT21Pu6zZYEWPRUWMo3b3rTtf/bfoqFoy/mSIEEchxKtgUEV7MO6XGxJ2M1DHauO0S2E\n\t6VbTcSTw++J58i9a0j+EwAi6T5ELKSzjEO/Jw6E1JoU/0fdmxlLNubqb+05C6yAQKfFV1v\n\tuM6CIkseJX/buTVQYt9BCM7QDzYVRRM=","X-MC-Unique":"IjKRBwigPbyOJ1Jyuxj-hw-1","X-Mimecast-MFC-AGG-ID":"IjKRBwigPbyOJ1Jyuxj-hw_1767349853","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1767349852; x=1767954652;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject\n\t:date:message-id:reply-to;\n\tbh=Z3n4oKr7VlXpH2JdVQ0oDL4TX8+6awEtyLrfgihnjTk=;\n\tb=D/W2zbORc6Wbqn8AkxGtLm6Chz7JZX1KTlfHFOYgQwMIL18aFuoqfwNvpTSXMo1gM6\n\tXE0oA0f0UfNsHVWo1WK5T+5iv50s5aZpsdLZ90FyEyyMkPGXdDntqrQZjiDshq/vpEU3\n\tbvhEMiYFKaO/U+zH0oZQhuiuhcJJtwE8jAAiOiUaVOX6m+FFhHiGy7o/6WlBXkbyfdKM\n\tMAdW59si1FQ95fczcZz/NoVcD1llGavzVFxqwfzCSM+VSapO/C93ZoCzgxHVpyB15AND\n\tFNo2PLy2VQ9NmWzcAoRPCKTGqpqeyvySfzW7ESbfPHrOrsDo/FtBQe+i9n9muBmiYVyR\n\tRVQA==","X-Gm-Message-State":"AOJu0Yy9K/ifBsp26Ot/pxp3a+JF8sgc4xtHSkMTV79b6W4g0hzjx/se\n\tWNCm2Ya7A8E+TtWyshQDOxdla/wswbRWZ0L716r7j9rZImgEzMyKycS6fEocC3OjewzyVWKhxgm\n\tjj0UmnsINvQXoUhhJa2b5sdFjlM/J0AxtayyRzgTbU+MIU/k2Puh3jExKxvzS7fOG4b5wVzlHFu\n\tGmPdVA33VJH9wgYC8d2X6SNhd48WXWCx+wV8R9nca0ZHP+/CEShJDy+fjuSdk=","X-Gm-Gg":"AY/fxX6qghSbBBpVT1uavf+VsK+DLY0utCmU7nhPlZoY/+Uh6s0PyenTNMaKc+VuNxL\n\tsLFN7yAcyN/d+rDtQRU3mwAf3cdmaJsjeQ8EXHaiCUZHRD5/G6wjhwiOU/QwH638MZJSVDCo33d\n\tZAext4zlxnXtfHXP9GDs7Db2+CzWBo/XOlCL7gRDxWfySJyoCjSGpUfnGoUBzcNw+nCpMD8DZt1\n\tdtT6gcg6o+nYBYS0uw8l8qZjhQPT9zvQugaC1WWHs/JYBTqalkizGvntnqCp59bFdex49hdvXxJ\n\tPC7BqvtczMThuZKmQFO33mPDz44Bi+HQzP7P0s/riUjZLGgIKsQNVVytwGNhwMBjS9akiVN2NZC\n\ts0v3m4Txd+WHVL+ezfAlVL/i07MLeEQLirS5QhNH2S95R+e/RyUn0ExfS/PIzXOM=","X-Received":["by 2002:a05:6000:220b:b0:431:701:4a1a with SMTP id\n\tffacd0b85a97d-4324e4d0f68mr56630572f8f.26.1767349852252; \n\tFri, 02 Jan 2026 02:30:52 -0800 (PST)","by 2002:a05:6000:220b:b0:431:701:4a1a with SMTP id\n\tffacd0b85a97d-4324e4d0f68mr56630531f8f.26.1767349851787; \n\tFri, 02 Jan 2026 02:30:51 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IFRKWR0UBDxTGd5bVE3knCug2+/x1JX1ZS/Ch2dJ3h903ibVjOGngZB1DWjpDDyCvZVgUZWSQ==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Hans de Goede <johannes.goede@oss.qualcomm.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] ipa: simple: agc: Make sure activeState.agc expo/again\n\tare always initialized","In-Reply-To":"<20251220172703.321681-1-johannes.goede@oss.qualcomm.com> (Hans\n\tde Goede's message of \"Sat, 20 Dec 2025 18:27:03 +0100\")","References":"<20251220172703.321681-1-johannes.goede@oss.qualcomm.com>","Date":"Fri, 02 Jan 2026 11:30:50 +0100","Message-ID":"<85ikdkpaqt.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"ckZdNkiShHmSOmV1U4y8wD9EH2WfxgN1TFeN1I_ISDM_1767349853","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":37457,"web_url":"https://patchwork.libcamera.org/comment/37457/","msgid":"<85eco8pa8v.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-01-02T10:41:36","subject":"Re: [PATCH] ipa: simple: agc: Make sure activeState.agc expo/again\n\tare always initialized","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Milan Zamazal <mzamazal@redhat.com> writes:\n\n> Hi Hans,\n>\n> thank you for the patch.\n>\n> Hans de Goede <johannes.goede@oss.qualcomm.com> writes:\n>\n>> If the first frame of a stream is bad, the IPA will not get called with\n>> frame == 0, leaving activeState.agc expo/again uninitialized. This causes\n>> the agc algorithm to set a very low gain and exposure on the next run\n>> (where it will hit the if (!stats->valid) {} path) resulting in starting\n>> with a black image.\n>>\n>> Fix this by using a valid flag instead of checking for frame == 0.\n>>\n>> The entire activeState gets cleared to 0 on configure() resetting the new\n>> valid flag.\n>>\n>> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>\n\nI think it should fix\nhttps://gitlab.freedesktop.org/camera/libcamera/-/issues/298\n?\n\n> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>\n>\n>> ---\n>>  src/ipa/simple/algorithms/agc.cpp | 5 +++--\n>>  src/ipa/simple/ipa_context.h      | 1 +\n>>  2 files changed, 4 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp\n>> index 189de770..2f7e040c 100644\n>> --- a/src/ipa/simple/algorithms/agc.cpp\n>> +++ b/src/ipa/simple/algorithms/agc.cpp\n>> @@ -100,7 +100,7 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou\n>>  }\n>>  \n>>  void Agc::process(IPAContext &context,\n>> -\t\t  const uint32_t frame,\n>> +\t\t  [[maybe_unused]] const uint32_t frame,\n>>  \t\t  IPAFrameContext &frameContext,\n>>  \t\t  const SwIspStats *stats,\n>>  \t\t  ControlList &metadata)\n>> @@ -110,13 +110,14 @@ void Agc::process(IPAContext &context,\n>>  \tmetadata.set(controls::ExposureTime, exposureTime.get<std::micro>());\n>>  \tmetadata.set(controls::AnalogueGain, frameContext.sensor.gain);\n>>  \n>> -\tif (frame == 0) {\n>> +\tif (!context.activeState.agc.valid) {\n>>  \t\t/*\n>>  \t\t * Init active-state from sensor values in case updateExposure()\n>>  \t\t * does not run for the first frame.\n>>  \t\t */\n>>  \t\tcontext.activeState.agc.exposure = frameContext.sensor.exposure;\n>>  \t\tcontext.activeState.agc.again = frameContext.sensor.gain;\n>> +\t\tcontext.activeState.agc.valid = true;\n>>  \t}\n>>  \n>>  \tif (!stats->valid) {\n>> diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\n>> index c3081e30..26b60fb6 100644\n>> --- a/src/ipa/simple/ipa_context.h\n>> +++ b/src/ipa/simple/ipa_context.h\n>> @@ -40,6 +40,7 @@ struct IPAActiveState {\n>>  \tstruct {\n>>  \t\tint32_t exposure;\n>>  \t\tdouble again;\n>> +\t\tbool valid;\n>>  \t} agc;\n>>  \n>>  \tstruct {","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 EF02FBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Jan 2026 10:41:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 48E6561FA0;\n\tFri,  2 Jan 2026 11:41:45 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 62A466142F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Jan 2026 11:41:43 +0100 (CET)","from mail-wr1-f69.google.com (mail-wr1-f69.google.com\n\t[209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-140-BoaQIE2nMIu2wNV6xCFRFQ-1; Fri, 02 Jan 2026 05:41:40 -0500","by mail-wr1-f69.google.com with SMTP id\n\tffacd0b85a97d-430f5dcd4cdso6256396f8f.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 02 Jan 2026 02:41:40 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-4324eab2c4fsm84309648f8f.42.2026.01.02.02.41.37\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 02 Jan 2026 02:41:37 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"LcgG3yhx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1767350502;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=l61aVywq2bbL1bvkbj3yfhRiyutaROpy7iRUtXnsKiM=;\n\tb=LcgG3yhx41Xp2notkZasMqT6xl/x+uT8xpEOK6p6g1pC1g1FczNbqqe1h8QexCH54UGoEd\n\tg8peKzeFjBIv9aXUD6b+YDc/wgJ6VRxTzPAIazkxI32ZTdg/k9tjlgbUrcboNK8aRTPX92\n\t46BgTCu4l+w/7ug3PMMF/Lg6eu93EAc=","X-MC-Unique":"BoaQIE2nMIu2wNV6xCFRFQ-1","X-Mimecast-MFC-AGG-ID":"BoaQIE2nMIu2wNV6xCFRFQ_1767350499","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1767350499; x=1767955299;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject\n\t:date:message-id:reply-to;\n\tbh=l61aVywq2bbL1bvkbj3yfhRiyutaROpy7iRUtXnsKiM=;\n\tb=oOLtyiUXfT0BKq2vxwOKgaSVKvbWjyH8zqaSk1UK2vmeJfbWxmtXQI9QMBTNsX3RiV\n\tMT3X1DauF8MYxKWObWz/RUORAtgX8Q8mY+xeQTIWklsEdwZ+Kx+IqncB2coSBYz1GLs6\n\tOBMcW22Y4cMKzMKJPn8DyAsCr8bXhApEMfFulI/aU2LxS+dQbQGXVBvbJjB51oilEp3i\n\tq0VyMxZZ3f6TnhEmim8Q8UP9dTQt3zuStMisaCyyIw+nnn6DzshTkQEp1QLXnOG8kPL0\n\t9VeJw6NGFIbttLfQ/73IcGiLpqc5y9FIpYZeZMa+53B1vVr+GZZ/NBFN1Nj/xHQsp7qQ\n\tSTyg==","X-Gm-Message-State":"AOJu0YwX6mKCBRQRQhcZrMKrLR7xRZHoPmnf/cam8mVkdFtj3NPNVjgL\n\tcHHY5xpGH307mwOjTerUgKYhf8VnMELrxsNVE30U4PTREzORSQY8UC+64ykMjnsfG1RcOhrCoBl\n\t3RnSPf8VkpN2HaEUDIouI210y8aGNmqiR9jBL5AuxCzJnyZQnQBTlkDCU/o4EBvFyuOpRYidfN0\n\tD6TxrMs5dJLn7kQ0sY+b3V353/XorS/Upysx7EFsCaPa7Mup9Tpsu4yPLsGBA=","X-Gm-Gg":"AY/fxX7BIZStuapqTfLWJbptAd2uAAxQel56oKBRwGgw8AiqD3QqKycQWV8niToZ9S3\n\tebZezsfz5GprdWDMHyRrdR2Ds10SXJhUbBDgrSIZuvdr3sFsXxfrVV8jHyADyUltcMpHtT5IsbQ\n\tLK0AE1m0dfsjGVbgDpQtTGk7QFIE4/Skph/vIDhQPUp3rlPEABC/40Crz4p7OhzIDFLJ8XbBN/S\n\te8mmBHVFRxxwFxC6Xr+JFxPGZVH+h6silhsr9UwfeCf3nsmx7ALT0+SWXBxG/vbymQ7XrwnZpoo\n\tDhcigcj5nNiE4AVGjomguuIkltLwVwrkjYql9kilpIUVMeiofOROrX3fktHLPqaJNFk5cguXLSq\n\tdYFsp/ojH9fGT0af1am4xkHqRbLipWqNblqmUPWpxOo5LHXSrXmGbaP86RBnOIAI=","X-Received":["by 2002:a05:6000:2c02:b0:42b:3246:1681 with SMTP id\n\tffacd0b85a97d-4324e4c97d7mr52995618f8f.18.1767350498953; \n\tFri, 02 Jan 2026 02:41:38 -0800 (PST)","by 2002:a05:6000:2c02:b0:42b:3246:1681 with SMTP id\n\tffacd0b85a97d-4324e4c97d7mr52995589f8f.18.1767350498477; \n\tFri, 02 Jan 2026 02:41:38 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IFfN+Ng3jrFLQmh57gdAMwUALRbUPK6ZveONSJQIIwPHrFnfMdrE9nDaBmf4z7mwxxfDyFbqQ==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Hans de Goede <johannes.goede@oss.qualcomm.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] ipa: simple: agc: Make sure activeState.agc expo/again\n\tare always initialized","In-Reply-To":"<85ikdkpaqt.fsf@mzamazal-thinkpadp1gen7.tpbc.csb> (Milan\n\tZamazal's message of \"Fri, 02 Jan 2026 11:30:50 +0100\")","References":"<20251220172703.321681-1-johannes.goede@oss.qualcomm.com>\n\t<85ikdkpaqt.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","Date":"Fri, 02 Jan 2026 11:41:36 +0100","Message-ID":"<85eco8pa8v.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"3FOiA_k2aC3TwivAiakuZaG75iN9qWV1R2A0q8OecVk_1767350499","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":37459,"web_url":"https://patchwork.libcamera.org/comment/37459/","msgid":"<dbcd68c4-d93d-41f8-b9a1-f7ca62af2daa@oss.qualcomm.com>","date":"2026-01-03T12:10:32","subject":"Re: [PATCH] ipa: simple: agc: Make sure activeState.agc expo/again\n\tare always initialized","submitter":{"id":242,"url":"https://patchwork.libcamera.org/api/people/242/","name":"Hans de Goede","email":"johannes.goede@oss.qualcomm.com"},"content":"Hi,\n\nOn 2-Jan-26 11:41, Milan Zamazal wrote:\n> Milan Zamazal <mzamazal@redhat.com> writes:\n> \n>> Hi Hans,\n>>\n>> thank you for the patch.\n>>\n>> Hans de Goede <johannes.goede@oss.qualcomm.com> writes:\n>>\n>>> If the first frame of a stream is bad, the IPA will not get called with\n>>> frame == 0, leaving activeState.agc expo/again uninitialized. This causes\n>>> the agc algorithm to set a very low gain and exposure on the next run\n>>> (where it will hit the if (!stats->valid) {} path) resulting in starting\n>>> with a black image.\n>>>\n>>> Fix this by using a valid flag instead of checking for frame == 0.\n>>>\n>>> The entire activeState gets cleared to 0 on configure() resetting the new\n>>> valid flag.\n>>>\n>>> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>\n> \n> I think it should fix\n> https://gitlab.freedesktop.org/camera/libcamera/-/issues/298\n> ?\n\nYes it fixes that. I've already added the fix to the Fedora libcamera\npkgs and Fedora users with the same laptop as from that bug have\nconfirmed it fixes the oscilation.\n\nRegards,\n\nHans\n\n\n> \n>> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>\n>>\n>>> ---\n>>>  src/ipa/simple/algorithms/agc.cpp | 5 +++--\n>>>  src/ipa/simple/ipa_context.h      | 1 +\n>>>  2 files changed, 4 insertions(+), 2 deletions(-)\n>>>\n>>> diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp\n>>> index 189de770..2f7e040c 100644\n>>> --- a/src/ipa/simple/algorithms/agc.cpp\n>>> +++ b/src/ipa/simple/algorithms/agc.cpp\n>>> @@ -100,7 +100,7 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou\n>>>  }\n>>>  \n>>>  void Agc::process(IPAContext &context,\n>>> -\t\t  const uint32_t frame,\n>>> +\t\t  [[maybe_unused]] const uint32_t frame,\n>>>  \t\t  IPAFrameContext &frameContext,\n>>>  \t\t  const SwIspStats *stats,\n>>>  \t\t  ControlList &metadata)\n>>> @@ -110,13 +110,14 @@ void Agc::process(IPAContext &context,\n>>>  \tmetadata.set(controls::ExposureTime, exposureTime.get<std::micro>());\n>>>  \tmetadata.set(controls::AnalogueGain, frameContext.sensor.gain);\n>>>  \n>>> -\tif (frame == 0) {\n>>> +\tif (!context.activeState.agc.valid) {\n>>>  \t\t/*\n>>>  \t\t * Init active-state from sensor values in case updateExposure()\n>>>  \t\t * does not run for the first frame.\n>>>  \t\t */\n>>>  \t\tcontext.activeState.agc.exposure = frameContext.sensor.exposure;\n>>>  \t\tcontext.activeState.agc.again = frameContext.sensor.gain;\n>>> +\t\tcontext.activeState.agc.valid = true;\n>>>  \t}\n>>>  \n>>>  \tif (!stats->valid) {\n>>> diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\n>>> index c3081e30..26b60fb6 100644\n>>> --- a/src/ipa/simple/ipa_context.h\n>>> +++ b/src/ipa/simple/ipa_context.h\n>>> @@ -40,6 +40,7 @@ struct IPAActiveState {\n>>>  \tstruct {\n>>>  \t\tint32_t exposure;\n>>>  \t\tdouble again;\n>>> +\t\tbool valid;\n>>>  \t} agc;\n>>>  \n>>>  \tstruct {\n>","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 6E389BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  3 Jan 2026 12:10:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 97E9161FB9;\n\tSat,  3 Jan 2026 13:10:40 +0100 (CET)","from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com\n\t[205.220.168.131])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2A726606D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  3 Jan 2026 13:10:38 +0100 (CET)","from pps.filterd (m0279864.ppops.net [127.0.0.1])\n\tby mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n\t6038QpW4858731 for <libcamera-devel@lists.libcamera.org>;\n\tSat, 3 Jan 2026 12:10:37 GMT","from mail-qt1-f200.google.com (mail-qt1-f200.google.com\n\t[209.85.160.200])\n\tby mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bev9h8evt-1\n\t(version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 03 Jan 2026 12:10:37 +0000 (GMT)","by mail-qt1-f200.google.com with SMTP id\n\td75a77b69052e-4f4ab58098eso322406711cf.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 03 Jan 2026 04:10:36 -0800 (PST)","from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec?\n\t(2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl.\n\t[2001:1c00:c32:7800:5bfa:a036:83f0:f9ec])\n\tby smtp.gmail.com with ESMTPSA id\n\t4fb4d7f45d1cf-64b9105a9d8sm46469683a12.11.2026.01.03.04.10.33\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tSat, 03 Jan 2026 04:10:33 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=qualcomm.com header.i=@qualcomm.com\n\theader.b=\"axWCngnr\"; dkim=pass (2048-bit key;\n\tunprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n\theader.b=\"V+Ovg+hn\"; dkim-atps=neutral","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n\tcc:content-transfer-encoding:content-type:date:from:in-reply-to\n\t:message-id:mime-version:references:subject:to; s=qcppdkim1; bh=\n\txan3XNNawDXeaeqfu/aTVjQtYDLi/OdkI71F2Cgyw2U=; b=axWCngnrLaGI5sZN\n\tpQK5pUoPXHkTRBigRRStb2CJxu+5yjxYBtI2Bx5QVUteg0LW26lt4D6YFJ+8gcwh\n\tZAOY031ocaD8JD2MWYI2wOU82zAfVAOwODw6MoYxbV/Kpa/VAlJ6IN29pDxuEJsj\n\t5T4IZUyylU3u1EpBKPCh3CUHFrwwmqczk/OSczo+NUCQk/NHFqXMCY02icwyREXS\n\tI9FPQ63ZIyaaOnGPOPyGOvOCsTfTQ3VjxW9EZOd80MWJyCQJLah8ugN2wY1gpjeZ\n\t91AGmksGEkbtK+2wQYEJIbuV8lZfU5FJsNUAJY8NYZe/z0pvCwyYgBu3ACFinnQK\n\tl6rzuQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=oss.qualcomm.com; s=google; t=1767442236; x=1768047036;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:in-reply-to:content-language:references\n\t:cc:to:subject:from:user-agent:mime-version:date:message-id:from:to\n\t:cc:subject:date:message-id:reply-to;\n\tbh=xan3XNNawDXeaeqfu/aTVjQtYDLi/OdkI71F2Cgyw2U=;\n\tb=V+Ovg+hnMZFc3Nop3hTuibwVhZpt9D58Y8+pUMpaXhubqqMawvFJP/J97h+c7RExKx\n\tUr3By0nvlSdnyf81Lcp2pY+i2zYyD3sZPT0vJMIf7PMhpNMK+ZesA25AYES+h/G7PbbK\n\t7ehv4dhHvCtWrspoghG5cehKCSg3y+V65VBGQSV4ynhbzBEh2gQZ5nGGvgWZwnBW/cNo\n\t3ApEHXyvuOAnCtkNuap7UcNcWz9g+S+iD8tnk2GXgeFUnJYY2jK/4QhB97pQVWvfbpme\n\tBMKzqFDwPbTgnaVuThZ8O9zpFNML4oV4JnxUnjsRWilBbIdMamhX7pmzQbbmEATQe57W\n\tUGXA=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1767442236; x=1768047036;\n\th=content-transfer-encoding:in-reply-to:content-language:references\n\t:cc:to:subject:from:user-agent:mime-version:date:message-id:x-gm-gg\n\t:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n\tbh=xan3XNNawDXeaeqfu/aTVjQtYDLi/OdkI71F2Cgyw2U=;\n\tb=xMjTjE8Y9OrDw6bD2dOB+JnOoZT9USC9EpHRBC05FVHVFzl+F4lu6Xupze29ASu9W6\n\tf1UgcT7Rq/C+lN/hN2zaPOB0ht1ClO1OdyM7R9i2RHVjJAO5NwvY/uzfQjSn4FfS8wBP\n\t4Wq42voHljiXg9Dm+hvz8yfV3Y8tccJv/Pu2gFujEMH3XSOkc6LIhJL2ib5HjYnifrQs\n\tT8e3I98cPkA/I9FsW8kador2S2whTfaKDzHLmxkzdrSAc+HdQtftFT9T09J0E4LPCqqf\n\tkOUCvUK/cA9Ue7Pi7LnsIkoqInWhjLlVLlNJ/MG+TB9VJXJb+IPHAAi1oAAWgNj6SWP3\n\t7p7Q==","X-Gm-Message-State":"AOJu0YyCarfrBqP/K6W53xgNRJu65vYX83WYLD/uJ3/h3qWEJ7wN03JM\n\t2YorpyrF9NycGeAPQ2WyfgCxgiTFpPD3phcI9S2FDFlKjjhWgwmB7n6maWLK6DFDlzvPSubG03b\n\t/4nFtKSTaX8fcbOhy5OWCvyg9FwcIe2xxidOT774o610m5xEqEjZSPV/W3qehYTddl/rp88OQFq\n\tZp","X-Gm-Gg":"AY/fxX4svO+v/CnbRJiY4uAOUoA42wHobKngir876rMqX3JZ3EilgcLagPNq/WjVTGp\n\tJZLhywkwHT4Gx/33iRDTAPMSVkQm85WXGPmOpf765zqeY5Xun1oeHDfOzL7Kcgzp2b55bcr3hV4\n\txVzQ9G3LSJThLB7eUoWBPu9UUbdKT2cFCq3J/ADX6oSnanI5oUTl8NHzW64Z+vqbmn8VyxLKe8D\n\tsR4ieLdLRWDgdFBf56kzdzMPsrLGjoapy0BJm698J1by7PlmmsByy8snOSYt45Iwo5PfcizyNC4\n\thOV3mVJtj0pPYKSbi0mCX6lkHVk4F+Iv/OcAnlg8WMgIfSm/ELRN8aypepRGfxATopSLgG32+Mn\n\t+KCLY8ms/fSNiPmtGwVKx9TYK3wOH7qNVepW0mjG2teYrvmBj/UQ+kgQ1yMX8nV6sT3hzx08dCj\n\t+EkqeWm5p24vqleQzZsQcQUiMd+ABpq+s9Ye8SpE1U6iTYGZT8AEgYVa34LeyE5WTQ3DynJ7LMs\n\t0u8","X-Received":["by 2002:a05:622a:1146:b0:4ee:3e74:43d8 with SMTP id\n\td75a77b69052e-4f4abd752b8mr728805831cf.38.1767442236078; \n\tSat, 03 Jan 2026 04:10:36 -0800 (PST)","by 2002:a05:622a:1146:b0:4ee:3e74:43d8 with SMTP id\n\td75a77b69052e-4f4abd752b8mr728805651cf.38.1767442235584; \n\tSat, 03 Jan 2026 04:10:35 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IEsOD0bPNpcVQ3wKP26ewKhLmoErdqzMQaz4f3GpR5/nfCzcTbtkMi59rCpHkXCRk5ciGAhZQ==","Message-ID":"<dbcd68c4-d93d-41f8-b9a1-f7ca62af2daa@oss.qualcomm.com>","Date":"Sat, 3 Jan 2026 13:10:32 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","From":"Hans de Goede <johannes.goede@oss.qualcomm.com>","Subject":"Re: [PATCH] ipa: simple: agc: Make sure activeState.agc expo/again\n\tare always initialized","To":"Milan Zamazal <mzamazal@redhat.com>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20251220172703.321681-1-johannes.goede@oss.qualcomm.com>\n\t<85ikdkpaqt.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<85eco8pa8v.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","Content-Language":"en-US, nl","In-Reply-To":"<85eco8pa8v.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwMTAzMDExMCBTYWx0ZWRfX8Xg/8a2jnFhf\n\tAJvZKSHD3onC80DVOFPZBeywreAMpiY1dAA4QksCmf9qw9m4d7DyvTWpTVHhETjK5StqhIT6W0P\n\tw1tRR1jL3Qb8Vvne8KHwT0RRolPYmvvwc3f3gXR121hgFiGS2Zc6ChR+cdmVjSPT+uXSgb3tVzJ\n\tguWMPbg3GISynn6zuWbRIbA8Q4p+hrN0ezdanWkbBdVxH2tezzInu1ZRiLK6xfIsJnQGUiSHMH2\n\tPSNDeRnbh1112z5MbXFkxJ4/b9ADSsv5oOSQPa4i6bdMbmKLD1pE2OHFvcs2V2NdqKQm3JD42rg\n\t59ZharhpT7in2WvndF0yKEN59sb/ufmD4Swu0cZqQrqK6iNAICgHv1ajoYRgtbXpLp6H8IYvT89\n\tYVfWf+95s4rdzn+fC2aBthWnJnTPrvC7OMHwb2d4zsiFZXRCY9egcBjXPmOd+UZ3hRtROi5/HmD\n\tzpSV2SutLuu6lRHrrrg==","X-Proofpoint-GUID":"6bbiWkc_AxQcaZ6jKvqExdbdmHyBBKjt","X-Authority-Analysis":"v=2.4 cv=RrbI7SmK c=1 sm=1 tr=0 ts=6959073d cx=c_pps\n\ta=JbAStetqSzwMeJznSMzCyw==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10\n\ta=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22\n\ta=e5mUnYsNAAAA:8 a=20KFwNOVAAAA:8 a=EUspDBNiAAAA:8\n\ta=mMoOweznr5QaxQh6CTEA:9\n\ta=QEXdDO2ut3YA:10 a=uxP6HrT_eTzRwkO_Te1X:22 a=Vxmtnl_E_bksehYqCbjh:22","X-Proofpoint-ORIG-GUID":"6bbiWkc_AxQcaZ6jKvqExdbdmHyBBKjt","X-Proofpoint-Virus-Version":"vendor=baseguard\n\tengine=ICAP:2.0.293, Aquarius:18.0.1121, Hydra:6.1.9,\n\tFMLib:17.12.100.49\n\tdefinitions=2026-01-03_01,2025-12-31_01,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tphishscore=0 clxscore=1015 spamscore=0 impostorscore=0 malwarescore=0\n\tsuspectscore=0 adultscore=0 priorityscore=1501 bulkscore=0\n\tlowpriorityscore=0\n\tclassifier=typeunknown authscore=0 authtc= authcc= route=outbound\n\tadjust=0\n\treason=mlx scancount=1 engine=8.22.0-2512120000\n\tdefinitions=main-2601030110","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":37460,"web_url":"https://patchwork.libcamera.org/comment/37460/","msgid":"<176759826594.38244.2761482815098103264@ping.linuxembedded.co.uk>","date":"2026-01-05T07:31:05","subject":"Re: [PATCH] ipa: simple: agc: Make sure activeState.agc expo/again\n\tare always initialized","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Hans de Goede (2026-01-03 12:10:32)\n> Hi,\n> \n> On 2-Jan-26 11:41, Milan Zamazal wrote:\n> > Milan Zamazal <mzamazal@redhat.com> writes:\n> > \n> >> Hi Hans,\n> >>\n> >> thank you for the patch.\n> >>\n> >> Hans de Goede <johannes.goede@oss.qualcomm.com> writes:\n> >>\n> >>> If the first frame of a stream is bad, the IPA will not get called with\n> >>> frame == 0, leaving activeState.agc expo/again uninitialized. This causes\n> >>> the agc algorithm to set a very low gain and exposure on the next run\n> >>> (where it will hit the if (!stats->valid) {} path) resulting in starting\n> >>> with a black image.\n> >>>\n> >>> Fix this by using a valid flag instead of checking for frame == 0.\n> >>>\n> >>> The entire activeState gets cleared to 0 on configure() resetting the new\n> >>> valid flag.\n> >>>\n> >>> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>\n> > \n> > I think it should fix\n> > https://gitlab.freedesktop.org/camera/libcamera/-/issues/298\n> > ?\n> \n> Yes it fixes that. I've already added the fix to the Fedora libcamera\n> pkgs and Fedora users with the same laptop as from that bug have\n> confirmed it fixes the oscilation.\n\nLets add the tag then.\n\nCloses: https://gitlab.freedesktop.org/camera/libcamera/-/issues/298\n\nI don't know if patchwork will pick that up as a tag automatically\nthough.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> Regards,\n> \n> Hans\n> \n> \n> > \n> >> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>\n> >>\n> >>> ---\n> >>>  src/ipa/simple/algorithms/agc.cpp | 5 +++--\n> >>>  src/ipa/simple/ipa_context.h      | 1 +\n> >>>  2 files changed, 4 insertions(+), 2 deletions(-)\n> >>>\n> >>> diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp\n> >>> index 189de770..2f7e040c 100644\n> >>> --- a/src/ipa/simple/algorithms/agc.cpp\n> >>> +++ b/src/ipa/simple/algorithms/agc.cpp\n> >>> @@ -100,7 +100,7 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou\n> >>>  }\n> >>>  \n> >>>  void Agc::process(IPAContext &context,\n> >>> -             const uint32_t frame,\n> >>> +             [[maybe_unused]] const uint32_t frame,\n> >>>               IPAFrameContext &frameContext,\n> >>>               const SwIspStats *stats,\n> >>>               ControlList &metadata)\n> >>> @@ -110,13 +110,14 @@ void Agc::process(IPAContext &context,\n> >>>     metadata.set(controls::ExposureTime, exposureTime.get<std::micro>());\n> >>>     metadata.set(controls::AnalogueGain, frameContext.sensor.gain);\n> >>>  \n> >>> -   if (frame == 0) {\n> >>> +   if (!context.activeState.agc.valid) {\n> >>>             /*\n> >>>              * Init active-state from sensor values in case updateExposure()\n> >>>              * does not run for the first frame.\n> >>>              */\n> >>>             context.activeState.agc.exposure = frameContext.sensor.exposure;\n> >>>             context.activeState.agc.again = frameContext.sensor.gain;\n> >>> +           context.activeState.agc.valid = true;\n> >>>     }\n> >>>  \n> >>>     if (!stats->valid) {\n> >>> diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\n> >>> index c3081e30..26b60fb6 100644\n> >>> --- a/src/ipa/simple/ipa_context.h\n> >>> +++ b/src/ipa/simple/ipa_context.h\n> >>> @@ -40,6 +40,7 @@ struct IPAActiveState {\n> >>>     struct {\n> >>>             int32_t exposure;\n> >>>             double again;\n> >>> +           bool valid;\n> >>>     } agc;\n> >>>  \n> >>>     struct {\n> > \n>","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 A969ABDCC0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  5 Jan 2026 07:31:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A0D0961FB9;\n\tMon,  5 Jan 2026 08:31:10 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A726606D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  5 Jan 2026 08:31:08 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5E955591;\n\tMon,  5 Jan 2026 08:30:48 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"I9HQQUZZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1767598248;\n\tbh=l0q0YXjAsJ9Q0Qdoz38GyyKpZriBDn3ZhVzWRiuEuQo=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=I9HQQUZZuVshtY5AReXBzGQ1gopwtuy9TZqMC2XtCDoF39wpYyY7pGPO2QpTGRBEx\n\tYeQcNkfGhJuS0U0RlpmkXhZfIqM3HiI4Tov3ky9MPPAB/yAXvbqj97qpcItILMSU0T\n\tbU7Ag6sznkCUgjWdtkl1qMDW5xb3BZV4AdznkT70=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<dbcd68c4-d93d-41f8-b9a1-f7ca62af2daa@oss.qualcomm.com>","References":"<20251220172703.321681-1-johannes.goede@oss.qualcomm.com>\n\t<85ikdkpaqt.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<85eco8pa8v.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<dbcd68c4-d93d-41f8-b9a1-f7ca62af2daa@oss.qualcomm.com>","Subject":"Re: [PATCH] ipa: simple: agc: Make sure activeState.agc expo/again\n\tare always initialized","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"Hans de Goede <johannes.goede@oss.qualcomm.com>,\n\tMilan Zamazal <mzamazal@redhat.com>","Date":"Mon, 05 Jan 2026 07:31:05 +0000","Message-ID":"<176759826594.38244.2761482815098103264@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]