From patchwork Fri Jun 6 10:55:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 23476 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 04090C31E9 for ; Fri, 6 Jun 2025 10:57:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9A76F68DC6; Fri, 6 Jun 2025 12:57:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="fXuU0BU3"; dkim-atps=neutral Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5934E68DBF for ; Fri, 6 Jun 2025 12:56:57 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-43f106a3591so1790395e9.3 for ; Fri, 06 Jun 2025 03:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1749207416; x=1749812216; 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=9YoGPuC/dIaxXZXl2DZZumzaSc1VCEyQJUBMyUKq20s=; b=fXuU0BU34b9bjPk6fBmKqjIUHTjRxJstf/AUHKhwyj4z/2YAgu0Psdz0y7oSqFw++y +4APilJXFF/3JWgt4MCKHHXh2a+n7tXQlKDctnOquGHsNl84rUzprvP5RZ61Yw/Hd1fw k7EZM0S7UnaDqY///rEl4YmzPZ6wltbp2Vot03BJyxX4u743IkVcdkvO4oj0Pvj/YO22 PzzQ+xn0zF8xIv/WvS83XNIYa4raxlTOMw1fhpc2ERZoFW69jA+MZLV9pMkkiXLeYDqh E5djwLRevIXrUWTUtstjyAgNbVOdB87UZAVbDHG1eR7q0hu6IMU/bK7VvTgoQYyn98R7 mN+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749207416; x=1749812216; 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=9YoGPuC/dIaxXZXl2DZZumzaSc1VCEyQJUBMyUKq20s=; b=SmpYQd2zbyKHCMdi03DYVAZfsxG7JLDRMp8g8DsvjqvS7g2sIM6dUtZsRypAPuJqm4 O9SgVqQ9aLKH/HlR71FiOwushsGqY4QMRmri/5WhLsK9AbgMBc6OsjIQWITOSBVF1rXn dK0AhLLraZmFmbmhbhz1sJSOXnvVUx0dlI9LfUAJk34rZaPiQea0eUvP+gJlwYsa6T1K 99gkNz1wyuCvkT7WJCkHMwKb4oDsHKOpZsgwzbNGGA9DjiYreTGOE/I1CL4pvxNBzVdp CMT0ndwTkG9/rkuzKBrR1kpSCHHr7WHUnudbu2zwaZQwU/xgQ+HV3whRUfugU8fef2GV HVNg== X-Gm-Message-State: AOJu0Yylm/oPqcgl6HmkXERoYhkx4oVvjE7stmkp2omcRzyNbJPRAlBD fApbD/wBAqRow3yYs38nCOstG3iLcgNUUFu8Je+SlSiGfLSOlMjtyjTXS2jfnXRGTUrYGLja5jl suVzB X-Gm-Gg: ASbGncu6Hu9sANwxwyr26KRzEWvf6QZwPvKKX2swyvTCOOF7SwmDzcqGs41eE8yBOfW aYttRBgmz9xR7ygaXFLRxrr7EVo0ZN0LZSuiKKaAdJtwXwV+VpjbNiTELmwrwj0nKlSb7XZpcvo p5z50gdQgW66HQHqdKVrZPmoCkdQrzpzUNpr7YuJ0+rgffPZhmJRfc3qmeysX2XWkV1luJCCiGJ s35GjJEhgdsrzJLtaRvB6TR470Th3LTIhwFUiKdAb61pcJmVuDbfV//j+5IuNFu2c6mURmFTYj6 twSk68V3p/8cE/caFpF0HuGXOWSMHHfOOgI+Ul9e2AKUmqcm/75l7WF+XPG8IlvJVQweTjh31zx l2R+sFsGwhKk= X-Google-Smtp-Source: AGHT+IEpXLfhuab/ICILNtr15MYjv+xfN20emM1EFQdW9A4464JlkWjthQhnrICZxTvte+MYWbwbwg== X-Received: by 2002:a05:600c:3f16:b0:442:7c40:fd81 with SMTP id 5b1f17b1804b1-4529abc8230mr7846405e9.5.1749207416442; Fri, 06 Jun 2025 03:56:56 -0700 (PDT) Received: from NAUSH-P-DELL.tail9c427.ts.net ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-452137277afsm20092455e9.30.2025.06.06.03.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jun 2025 03:56:55 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck , David Plowman , Jacopo Mondi Subject: [PATCH v3 2/6] ipa: rpi: Replace dropFrameCount in the IPA -> PH interface Date: Fri, 6 Jun 2025 11:55:20 +0100 Message-ID: <20250606105651.1624640-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250606105651.1624640-1-naush@raspberrypi.com> References: <20250606105651.1624640-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 Reviewed-by: Jacopo Mondi --- 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 e0f8b7e782f4..eee81e064e0d 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();