From patchwork Wed May 7 07:52:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 23343 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 92DEAC3226 for ; Wed, 7 May 2025 08:28:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BDBB668B30; Wed, 7 May 2025 10:28:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="gLOn5J1f"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1573268B2F for ; Wed, 7 May 2025 10:27:59 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-43ceeb85ab2so6124365e9.0 for ; Wed, 07 May 2025 01:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1746606478; x=1747211278; 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=fnaMAqT31Sn1HyYeUSz/LRhNsF9NQEXQj8bpQHhMNn0=; b=gLOn5J1fthRI2lpvsaWKenLBHcmUtBoLoMkAAp61xt95xnt45YVorb/M+5j6LJhmtO +HHPVZxtuJFPJQy+bYMFb4+SPGs9TGUSiRvpZu1n6aRhyNljXhGIssN4621hSodjikDF BuTQSYgMs2tlL+R3igOGPjD21XNQa/6qiwR/8mEYENGg6Q0E1D+iVVK5qpJOM8+NjFHz GZiOSVJlmhoFa/WUJoWkX6azDOMpYhVL6V6DW86ILWgvW7QNmcqy0xDzgXu3nkqPzXbE HB58mZiV2p2oBbT+xxWaavy9HMg5c7Vo8V5EKQ8ks8sV4HghCPBnMH/teaMh6Iv5UshQ qAWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746606478; x=1747211278; 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=fnaMAqT31Sn1HyYeUSz/LRhNsF9NQEXQj8bpQHhMNn0=; b=vUX/eXctppgSJdjFZYAFz8lipTcWhq8bXXXeHSpp2pGwbVFT1LOwyZjAxm7NuXmoAX T1LTiybAS+LZ87R91qPuO8VbEMH/N5Kbf5a7iQ42cqaAWtC8Koo2RBcHDoh2F6wC1Y8O pZJCxangL9KIeYjqy2ImM4G2n9WR03GuR6FVWRSXa+/0dvKIDp9j9fgCVOnA1vWErwCA 4ZAjbvH9Wq2OuZaIZu6LtPPCrVRc74UgtsQzbCQDFuuaD3wzCgBQnrDWKDPjpXyAn93V TGwplPcl+014PLMY8+TKAJfeGoYfA4uN0DDUEJtXzbtLz8PhtItLFglTnvpeP4KWE9W9 P5lg== X-Gm-Message-State: AOJu0Ywx54ZSM0Z5Y1xfChVEmFXJS+02UfiJGjIlf7HsmL0JHCcoRXVI 0IO0Ki9TRINwibwvoueBdzNu8nA8h+YsVPIKzEmj6qfVHw0mVo6j7UMr/WP3SfCnp1yAVWEi6TY L X-Gm-Gg: ASbGncuRC4qfcyCY3xKDrMyJBajVsq0Z6IBhTZmyefBJeIy/zTFuzEh2eYBWMgHF7mm w7ueyCgtbr5B3hZ7jLL4wgJU/ulfCC75dkGl8PZLQMULH2Cw929kVreHICR3S8QJj5ij5TidBt1 HiT02TqKYIv0ngmO2MVo69t1F51sirQW3lU8Nq6k4OrnNCN5tPRMA0gd2yWI4t5Uyelu7UmAlg1 D42veTj2C5QSpfvAFK8Wgtb9TPaAifLXDGa7D5hlraznlgNh4/pdyFInAthsOUbg0gksgc5i2Ny +S6QfwlyWFtWTvbNC+uwQ80cuGoIJ8Npv3VNdI3MQ67PVaXsnz4zOHYvW2MI X-Google-Smtp-Source: AGHT+IHi1q/l/kinKA98ZH8w+3vOHua7qQcRiDkumRVPaE0luc9b38F00rrDALa47ysEezWZQIyhRA== X-Received: by 2002:a05:600c:1c8c:b0:441:b397:e324 with SMTP id 5b1f17b1804b1-441d44ed543mr5482525e9.9.1746606478460; Wed, 07 May 2025 01:27:58 -0700 (PDT) Received: from NAUSH-P-DELL.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-441d440fff6sm22182575e9.25.2025.05.07.01.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 01:27:58 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [RFC PATCH 2/6] ipa: rpi: Replace dropFrameCount in the IPA -> PH interface Date: Wed, 7 May 2025 08:52:09 +0100 Message-ID: <20250507082753.2306743-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250507082753.2306743-1-naush@raspberrypi.com> References: <20250507082753.2306743-1-naush@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" Replace the dropFrameCount parameter returned from ipa::start() to the pipeline handler by startupFrameCount and invalidFrameCount. The former counts the number of frames required for AWB/AGC to converge, and the latter counts the number of invalid frames produced by the sensor when starting up. In the pipeline handler, use the sum of these 2 values to replicate the existing dropFrameCount behaviour. Signed-off-by: Naushir Patuck --- include/libcamera/ipa/raspberrypi.mojom | 3 ++- src/ipa/rpi/common/ipa_base.cpp | 14 ++++++++------ .../pipeline/rpi/common/pipeline_base.cpp | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index e30c70bde08b..12b083e9d04b 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -52,7 +52,8 @@ struct ConfigResult { struct StartResult { libcamera.ControlList controls; - int32 dropFrameCount; + int32 startupFrameCount; + int32 invalidFrameCount; }; struct PrepareParams { diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index e0a93daa9db2..c15f8a7bf71e 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -324,6 +324,7 @@ void IpaBase::start(const ControlList &controls, StartResult *result) * "mistrusted", which depends on whether this is a startup from cold, * or merely a mode switch in a running system. */ + unsigned int agcConvergenceFrames = 0, awbConvergenceFrames = 0; frameCount_ = 0; if (firstStart_) { dropFrameCount_ = helper_->hideFramesStartup(); @@ -336,7 +337,6 @@ void IpaBase::start(const ControlList &controls, StartResult *result) * (mistrustCount_) that they won't see. But if zero (i.e. * no convergence necessary), no frames need to be dropped. */ - unsigned int agcConvergenceFrames = 0; RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.getAlgorithm("agc")); if (agc) { @@ -345,7 +345,6 @@ void IpaBase::start(const ControlList &controls, StartResult *result) agcConvergenceFrames += mistrustCount_; } - unsigned int awbConvergenceFrames = 0; RPiController::AwbAlgorithm *awb = dynamic_cast( controller_.getAlgorithm("awb")); if (awb) { @@ -353,15 +352,18 @@ void IpaBase::start(const ControlList &controls, StartResult *result) if (awbConvergenceFrames) awbConvergenceFrames += mistrustCount_; } - - dropFrameCount_ = std::max({ dropFrameCount_, agcConvergenceFrames, awbConvergenceFrames }); - LOG(IPARPI, Debug) << "Drop " << dropFrameCount_ << " frames on startup"; } else { dropFrameCount_ = helper_->hideFramesModeSwitch(); mistrustCount_ = helper_->mistrustFramesModeSwitch(); } - result->dropFrameCount = dropFrameCount_; + result->startupFrameCount = std::max({ agcConvergenceFrames, awbConvergenceFrames }); + result->invalidFrameCount = dropFrameCount_; + + dropFrameCount_ = std::max({ dropFrameCount_, agcConvergenceFrames, awbConvergenceFrames }); + + LOG(IPARPI, Debug) << "Startup frames: " << result->startupFrameCount + << " Invalid frames: " << result->invalidFrameCount; firstStart_ = false; lastRunTimestamp_ = 0; diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 1f13e5230fae..5956485953a2 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -660,8 +660,8 @@ int PipelineHandlerBase::start(Camera *camera, const ControlList *controls) data->setSensorControls(result.controls); /* Configure the number of dropped frames required on startup. */ - data->dropFrameCount_ = data->config_.disableStartupFrameDrops - ? 0 : result.dropFrameCount; + data->dropFrameCount_ = data->config_.disableStartupFrameDrops ? + 0 : result.startupFrameCount + result.invalidFrameCount; for (auto const stream : data->streams_) stream->resetBuffers();