From patchwork Mon May 19 09:20:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 23387 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 0DE47BD78E for ; Mon, 19 May 2025 09:23:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3C95768D7D; Mon, 19 May 2025 11:22:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="UY41eqT0"; dkim-atps=neutral Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DA40968B66 for ; Mon, 19 May 2025 11:22:52 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3a362e099cfso400356f8f.2 for ; Mon, 19 May 2025 02:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1747646572; x=1748251372; 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=UY41eqT0smcRWRSd3LFzmd89npTGGMe6Q1NjR5O62G9oYKYpP1zEv+HCDNM3pMKMbg 5YnB/uGy/bZQcCx7TkD97Yz3CJjID6+/hpe65VXDeZ0bMA50y3NknEwoqw01UFKZ13fb PWim7kuzem5yU8vHpBY2l2KOsu3bWwUWSmiTPpqcymSH3UFVtAGjacwulIt5GpAwx3qV YWaIQ0qc+APajzuGWnI5VP6x0LTOIpbREAKa3ZtHzEVV9s+PPhkQLyh016+kP6HlYAjW F8cVZTZQTycukYdL93f7q6Lj8UVJ9+Tx6So9WObrh98EP+0zor1PHIdiQDyCbx/5K2cz qrLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747646572; x=1748251372; 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=gCI2DPXGepkiOexk4drZeA+0/TbZ+IWY9gJT9uHHPYdI7M0PpfTyXxxys0fePogj05 eR0iYesnubYAQm2lDg30BsSeGSfP2eM71R4xVjKQR0ibGf2mzAF+4EH7OyHF6uzMeIVE HDKjkW/lX2kpY9UF2W3ykPr3MYWM+JokHw3hPvKrFs+MjfODL77chSKQEGHrqWzNqLL9 5Vn2DRXALYykMcrZaRZCeEUGG7P251KVX4sc73jslFy1VgIzIDyVbcGnpg6JKouh6jhS F1YPkNL+dG1lvQJdPZURTg2kZeEFnitPsjEwoXbpzeC3Smx16qI4E47VbMbN4HdkIPtS fsCQ== X-Gm-Message-State: AOJu0YzFsivEAE6mly7lpYsn24/CqSU9lrg1fh2dWOipwg1bBB1UowbP vXV+S6YgV9KCTajnEOrbOPlDigKxOjb4n3C0cYXLMwf3j7P8rWPrd/hBOT7pjx8AJXkKeNCQH/y Hcpum X-Gm-Gg: ASbGncsVReOcYAiBfqckBRCMkE1XnhOw+8wu1WNWwOffuuaU6ywKR7vHxwkPLzz8vOw f+evlifehzd0ya0IUFowx9RwtpSDxIkiCHzl7foOHV8Z//lsh17d0T30vBe5U54KVtXuzCHK1Ba LCGm+anPLC8hTQqTpwD9Gytek2gULOI8ZOxV60sDKjUZO3xBn2KyVEcYHx7HLIIQyOjUC0IEd4d CGuqbe3qAA9pZRExiTbq9tP7H/lP0LgEByOtnYw/8nfHzp6fYKTTo6tYVy+DteV4R9QVblO47r8 TcrzHHHnwRvFrGF/+RkCwu35olSsF/xJrhWkVBfck85p8DeVWKqkQwjvIdrt7mIHPTerLOw= X-Google-Smtp-Source: AGHT+IFNSWXSO7SVzY8UXBRz30mcxBjKr8b4W3bugqa6AxWLA4JYnt75K+Ag4HRSzYyHwvF+C9qkqQ== X-Received: by 2002:a5d:64c5:0:b0:3a3:6964:57c8 with SMTP id ffacd0b85a97d-3a369645a0fmr2005956f8f.5.1747646572107; Mon, 19 May 2025 02:22:52 -0700 (PDT) Received: from NAUSH-P-DELL.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a366e08747sm8645961f8f.95.2025.05.19.02.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 02:22:51 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v1 2/6] ipa: rpi: Replace dropFrameCount in the IPA -> PH interface Date: Mon, 19 May 2025 10:20:50 +0100 Message-ID: <20250519092245.269048-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250519092245.269048-1-naush@raspberrypi.com> References: <20250519092245.269048-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 Reviewed-by: David Plowman --- 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();