From patchwork Tue Jun 17 08:29:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 23587 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 E17DEBDE6B for ; Tue, 17 Jun 2025 08:30:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7C14F68DDC; Tue, 17 Jun 2025 10:30:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="CJNbhO5k"; dkim-atps=neutral Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8166968DC1 for ; Tue, 17 Jun 2025 10:30:04 +0200 (CEST) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3a365a6804eso3920855f8f.3 for ; Tue, 17 Jun 2025 01:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1750149004; x=1750753804; 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=zGffA9MI6iLQV7MMBALDScxf8HvhkdQ9UfVj+SjJCKA=; b=CJNbhO5kcS5Uazs80BPPNfBKSdWMYsGLguLqA0T3AMQpw6PI55cUlF7Ob0L/ZuKJaS wCqbMaIXj05kA3m58VSqHwV00AcYkymmYzdHr9PXBC7MnPJlLGyuWS0T2/8XOej0a5X3 Fe6swBYWSSkANHqZdb++/pwBa5K8fEH34b9jLFST/oWIqoZqPaUNO2HxiSWznVCcyqCV oobJJ+aUnBYsqzpn1F6alsJE31JE+s91SKBe9y/L1zF7WM/QA9dVZ65b8gNdkAA+dwXc PFegVx/oyBKxBDnkRiiZxZSlC8riTU+s5RFh8IX+WK3MeqOiW8pyEoFwxig7wB7Okb0l hdGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750149004; x=1750753804; 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=zGffA9MI6iLQV7MMBALDScxf8HvhkdQ9UfVj+SjJCKA=; b=dzPl0dqV1Kn0AaH0RJU3wr4YwAPDFQM/zX/gL4VrOecq+xlXwlxqMQLXv4ZKXjWKes H3/nM+4KlWxHmBfYd+NUpmPmtl+/rjfYmGhZepJ50TJlsdwtPPtfPAY6GuLOIKEP73Fl 7MjcChQilWhtsPO6Xx5Bx0mK97g/o2QFNvcUJd/xEOJowLv29LjGm6fVttYiInBjiSOE ht4bnPJ5F9RjVaVCB+cY7/bdz5jSNCpdIGNlHn9TKkCvDML5tRU2uAhCq3lGPjbhpj6T syhKLyKXHJ/IFMk1HGvbpRBZAWcqmJAH5nr8AANJIdr1jbxufvu14Bk0uuP5sHCxVHcn JUdA== X-Gm-Message-State: AOJu0Yy163CYqGYwAVb1yzFosAW56q5FjoVrZe6bnql6VWjVDj+c5O16 KgNeBf0D2t015xLx/T5L74mT9bO0ZjuKPSqIXr/cb4gcruKssmOhPJk/PFyHDZXWXZSy5jaMYKE iQ4u3 X-Gm-Gg: ASbGncsQ3y0X8gDEkoGqRYTPhVa3rnEDgVtAa9K2JQaHUIOjMuU9Dxl6IQ5zkpD+ey6 +dUDvAQ9YHB/7VQrlm6vFGu0aQYPTEqY6uUgg60Xt/tIihT1nfcsgNbo+eN+YOThaBNmfIL5gbh ug7Lj9L7keTfoSCgfkDenftwy+aShba1hLBVaVIuxE2HgxPWOc9PCWdS1Jb4mXcj2jVOu88c2ad FaP650norbdTC1oqLaEcG2Rizv7ofedw22YfFnVrsn6RGI/CYG/PtGMYCmAG/GGNt2dwAgUFdza CtYsv1rNyPOPCfQd0UIXzECaVW0LXB9Zfh1qZbj00K64F7zK5E03RpBLrwAGGgJQV41KpZnZXfu gwKmaBjN/22ph+GJ2hw== X-Google-Smtp-Source: AGHT+IF5mf3OfIarWoHXUuHBJcmJitTNaoeR9yUHmqRUMJR4A2HRENz/bccDV00mPU3EMlDj6VottA== X-Received: by 2002:a05:6000:2088:b0:3a5:67d5:a400 with SMTP id ffacd0b85a97d-3a5723a3650mr10718931f8f.33.1750149003712; Tue, 17 Jun 2025 01:30:03 -0700 (PDT) Received: from raspberrypi.pitowers.org ([2a00:1098:3142:1f:ffc9:aff6:7f7f:893b]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532e259108sm166062955e9.32.2025.06.17.01.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jun 2025 01:30:03 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [PATCH 4/7] ipa: rpi: Advance the delay context counter even when IPAs don't run Date: Tue, 17 Jun 2025 09:29:52 +0100 Message-Id: <20250617082956.5699-5-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250617082956.5699-1-david.plowman@raspberrypi.com> References: <20250617082956.5699-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The delay context counter must be advanced even when we decide not to run prepare/process. Otherwise, when we skip them at higher framerates, the current IPA context counter will catch up and overwrite the delay context. It's safe to advance the counter because the metadata is always copied forward a slot when we decide not to run the IPAs. Signed-off-by: David Plowman --- src/ipa/rpi/common/ipa_base.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 05699228..7af4ea5e 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -491,10 +491,11 @@ void IpaBase::prepareIsp(const PrepareParams ¶ms) void IpaBase::processStats(const ProcessParams ¶ms) { unsigned int ipaContext = params.ipaContext % rpiMetadata_.size(); + RPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext]; - if (processPending_ && frameCount_ >= mistrustCount_) { - RPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext]; + Duration offset(0s); + if (processPending_ && frameCount_ >= mistrustCount_) { auto it = buffers_.find(params.buffers.stats); if (it == buffers_.end()) { LOG(IPARPI, Error) << "Could not find stats buffer!"; @@ -510,7 +511,6 @@ void IpaBase::processStats(const ProcessParams ¶ms) controller_.process(statistics, &rpiMetadata); /* Send any sync algorithm outputs back to the pipeline handler */ - Duration offset(0s); struct SyncStatus syncStatus; if (rpiMetadata.get("sync.status", syncStatus) == 0) { if (minFrameDuration_ != maxFrameDuration_) @@ -522,14 +522,14 @@ void IpaBase::processStats(const ProcessParams ¶ms) if (syncStatus.timerKnown) libcameraMetadata_.set(controls::rpi::SyncTimer, syncStatus.timerValue); } + } - struct AgcStatus agcStatus; - if (rpiMetadata.get("agc.status", agcStatus) == 0) { - ControlList ctrls(sensorCtrls_); - applyAGC(&agcStatus, ctrls, offset); - setDelayedControls.emit(ctrls, ipaContext); - setCameraTimeoutValue(); - } + struct AgcStatus agcStatus; + if (rpiMetadata.get("agc.status", agcStatus) == 0) { + ControlList ctrls(sensorCtrls_); + applyAGC(&agcStatus, ctrls, offset); + setDelayedControls.emit(ctrls, ipaContext); + setCameraTimeoutValue(); } /*