From patchwork Thu May 22 07:48:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 23417 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 6A660C31E9 for ; Thu, 22 May 2025 07:53:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1D89668D93; Thu, 22 May 2025 09:52:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="d0/+eHyb"; dkim-atps=neutral Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 43BF168D8E for ; Thu, 22 May 2025 09:52:49 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3a368259589so801171f8f.3 for ; Thu, 22 May 2025 00:52:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1747900368; x=1748505168; 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=5BhPQUO12kezx2EizAFy/txyAFMDEYzTcgAZJffzSAU=; b=d0/+eHyb7NYm4btTlpE0PDKnc6RLDFuQ/cSaq3JeZeiobkwY+OHNNO647+CktKvHxA 4lWV0SWEN/gGTdZD/vcW6KNYAYHNvTq/IP6+HjpDVrWnEPCu29mCncg08YS/vrsj89Ja gOPM0BnLe5TyXNz2tcS9MMzPfOOqB0+HlpEgIIYbrNbkPF13YyqkSKScYQZoaEAYWwJ4 FCruqQDZe4PKxP1K6NiXKUiZ4FIA7DzsAZFwP27St/ryQj+iMAybTRddYKc0DJLm8RtY Uixd1KIa5vz2mJwU6dcFHh+VWvbnBvqTJgjObE3LF5O3OgheZVJTZfOSTeoPpoJ0a0an u+7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747900368; x=1748505168; 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=5BhPQUO12kezx2EizAFy/txyAFMDEYzTcgAZJffzSAU=; b=HfY3y7UzAUuAQ5imlcJcSIYQwpuxxiQtuIVYnuy3IbopVxL2nn1+yruPxbS7S1fYNi hzaPn3cGY6Pbm+1Qw/XQio3Z0NXmVyM0GmFFaUmyue893uh+Aql0/pSqxLUDO29BkDYR F3fn0kLbum+bbH/jzHGtItRZSR7CDWwTwhR8NE1SYarbM1qTKiy1z5Zg2iFHp19SsBPn f8KR0bnZE0h3aOMdy/lNo4GRQv/eHMrl+CVPb91ROCvZhjvRsVLgZ3Lb09qdSU+5xjkT E1KenSFktWuPNH7wXQPOWiOotJm1RP8g3V5E2EC+B6QpCIKyer5bZgfoW2Cj7Pqb8v0S nmbQ== X-Gm-Message-State: AOJu0YyLQ4sbkcXXUiL5NXZroQ3skRylWVJUAkCrmq2rjSWhXbop+V6h AkoIUKx/Tc4kzaj3HmRTFUyll0zvix/fI/qu1YNFfVQIudA6ivi49XBiYD50e0XfTfXpblb9Vdg U9n4f X-Gm-Gg: ASbGncsJCRfcAi/8ZSlbMp5RE74jdT25ocAuZlRhkxJpLUmrfRNV2lAGe47YrQanqgk bGn4xHKn3yFgOE+L4WzHxf47S0+N5HvJ69nHY6uPQOIgzy8ffYkMLSsRI3Hdkeo2B3DXrMb06vh lO/R6xKLM+mJMmWmSxzmSTEHNkNBF2Zdt9bvAYCrYLp/aCxfLuDiFiSCz6N8LJ/MahXtw5YafO2 jmgq2UbrpnTDSjh1GpvOo+a+0rcUZN8zCjxZY50bHFFgNC1jwutb9VTC6o8Yrc0R0iSTSkkCqCZ edYcub1V/gAQjnhpMoOppP09kOLNno0RcGmXFxGkPd8aVjN2c4AZ3bRPmhRcNFGtHDwWwT0= X-Google-Smtp-Source: AGHT+IE7j5Gt+ezuR+wam29k5eGH3PX6+R4nD2usHMrtfU0D4LVqTd/c/7vGrQ5Uv9TSPNzP35xWhw== X-Received: by 2002:adf:f10e:0:b0:3a3:5c8e:2d8d with SMTP id ffacd0b85a97d-3a35c8e2da0mr7072466f8f.0.1747900368488; Thu, 22 May 2025 00:52:48 -0700 (PDT) Received: from NAUSH-P-DELL.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a3ca066eb7sm4191516f8f.2.2025.05.22.00.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 May 2025 00:52:48 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck , David Plowman Subject: [PATCH v2 2/6] ipa: rpi: Replace dropFrameCount in the IPA -> PH interface Date: Thu, 22 May 2025 08:48:18 +0100 Message-ID: <20250522075244.1198110-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250522075244.1198110-1-naush@raspberrypi.com> References: <20250522075244.1198110-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();