From patchwork Wed Jun 25 08:41:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 23649 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 4E07BBDCBF for ; Wed, 25 Jun 2025 08:42:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D7BB568DEE; Wed, 25 Jun 2025 10:42:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="kawcPkvK"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 290D168DDB for ; Wed, 25 Jun 2025 10:42:16 +0200 (CEST) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3a4eb4dfd8eso937919f8f.2 for ; Wed, 25 Jun 2025 01:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1750840935; x=1751445735; 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=WKQHh9LbhltE62Muvas//gPdUkd0dcSgEm/ISD64DFE=; b=kawcPkvKk/HOyFyb8wCRMlit32bRBYupCgS3E7vEseUNTTzyqdwmqocSgkTQfttVKq EQYUt58xIYzsPZboSHscbJQlXPKqOSFq/1S+Vk5kRa1xQwU5b6DtWGBpem+mKCFtJ7j5 oSih7KaX4PoU7Wg0iel4HhFte36xynQ8ONNu/kVngrwM1PxyLN7lapYJtypAtcGQ4lRO fPUKIwH5TsVvubEu/wYgVKfzOm11N8Q2IP8siy9pubvgUi+x3dt/qdPsfGJR/VP9IE9h 8SJ/jBPgqc+OU1Li5GY/VhNFWq2VxtdfImxi6+biGZeusUoe9jJRHgEnOpEVcpQBLBQG J/ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750840935; x=1751445735; 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=WKQHh9LbhltE62Muvas//gPdUkd0dcSgEm/ISD64DFE=; b=FKb63drf3Gc73mg2hujRY7jB7BipqIfPEpn3Bp6qXtoNUzAv9K8oK26gd0GQ2ZGYc/ W8+QDAYFBf8yMxQlk+woIFp1bRzQRDmE3ufhXoUmn02UovUnbc/21cuZ5jUBmuKaR50k rZCSfFBW74souwwAfhv8zKNo+CqGyydbwboJ2ykrKkJo2xs561wz+hc062t1Gi70cGrV 9fFPHahdhD7fuD790Qo7K07MLeqNadY7hw/DElbQCi6qZKeB2yYBO5FewPMvwWQsiQib nV7+mwAACDGrdLQs0egxo49qkH1TQAnzD2uZ00hJRCwHXJ9T3gwQsPgG+p6qJcABK6SG 1b6A== X-Gm-Message-State: AOJu0Yyzhyr3F4tPuMXkIxRzDFvcWPLzqkDk1Ci4T1247GwmyFhIlPMu /R5W7fBcJMJw6I/V1mPZUHzGOwNSOON/GxPbfyxCrqB1TUA1/95gg6n63cBAyDHZ/QOx+QZ7MQY L5ygN X-Gm-Gg: ASbGncsF5RbH/eCVawqZUV4PRHfGa8wNqfa7Zj16CK3cGoRf5aAvq3asS5JoQcQiRU0 6APcE/RYYStO+whKtPoMT/iyeBqKPhVU5ZuO5L4wE0N8m0w0EeDjv61WpPNTte+9pMb9CqzdaNq iqcPNsHlRSFfNQAltF2exG94MyWbLHu+K7oCO5AmTZFBwqjli33w3xBAAXp/Bi6u1fQZjMeO5K1 x0qTdHdv/DJC8QyIbUjsGvIE7nYCuwnsCTRGnHFGIh+USwbW+T9msYQRA/kf0wa36Kbc+5i5u2l EQFpxYZhMb3QG27U+NDNSfkyH39Ha9zx5Z7FOcDVnMB/0Abuxj9tqnSp/dH9y7QquGpZDo4ZJhh WIQ+lrg== X-Google-Smtp-Source: AGHT+IFt4JLM6v4b9BmAIyMH3HyNlV3ANsbfzPJXRPKcETbQ5FytFrSnLpSGUe6QC4vq6Ozo9XlWfQ== X-Received: by 2002:a05:6000:2d09:b0:3a5:28f9:7175 with SMTP id ffacd0b85a97d-3a6ed63c8d5mr382019f8f.9.1750840935340; Wed, 25 Jun 2025 01:42:15 -0700 (PDT) Received: from NAUSH-P-DELL.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a6e80f296bsm3974297f8f.60.2025.06.25.01.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jun 2025 01:42:15 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: dave.stevenson@raspberrypi.com, Naushir Patuck Subject: [PATCH v1 1/3] pipeline: rpi: Fix for enumerating the media graphs Date: Wed, 25 Jun 2025 09:41:16 +0100 Message-ID: <20250625084212.858487-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250625084212.858487-1-naush@raspberrypi.com> References: <20250625084212.858487-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" When there are multiple entities between the sensor and CFE device (e.g. a seraliser and deserialiser or multiple mux devices), the media graph enumeration would work incorrectly and report that the frontend entity was not found. This is beause the found flag was stored locally in a boolean and got lost in the recursion. Fix this by explicitly tracking and returning the frontend found flag through the return value of enumerateVideoDevices(). This ensures the flag does not get lost through nested recursion. This flag can also be used to fail a camera registration if the frontend is not found. Signed-off-by: Naushir Patuck Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- .../pipeline/rpi/common/pipeline_base.cpp | 22 +++++++++++-------- .../pipeline/rpi/common/pipeline_base.h | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index e14d3b913aaa..eafe94427dbc 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -806,7 +806,8 @@ int PipelineHandlerBase::registerCamera(std::unique_ptr &camera * chain. There may be a cascade of devices in this chain! */ MediaLink *link = sensorEntity->getPadByIndex(0)->links()[0]; - data->enumerateVideoDevices(link, frontendName); + if (!data->enumerateVideoDevices(link, frontendName)) + return -EINVAL; ipa::RPi::InitResult result; if (data->loadIPA(&result)) { @@ -1018,16 +1019,20 @@ void CameraData::freeBuffers() * | Sensor2 | | Sensor3 | * +---------+ +---------+ */ -void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &frontend) +bool CameraData::enumerateVideoDevices(MediaLink *link, const std::string &frontend) { const MediaPad *sinkPad = link->sink(); const MediaEntity *entity = sinkPad->entity(); bool frontendFound = false; + /* Once we reach the Frontend entity, we are done. */ + if (link->sink()->entity()->name() == frontend) + return true; + /* We only deal with Video Mux and Bridge devices in cascade. */ if (entity->function() != MEDIA_ENT_F_VID_MUX && entity->function() != MEDIA_ENT_F_VID_IF_BRIDGE) - return; + return false; /* Find the source pad for this Video Mux or Bridge device. */ const MediaPad *sourcePad = nullptr; @@ -1039,7 +1044,7 @@ void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &front * and this branch in the cascade. */ if (sourcePad) - return; + return false; sourcePad = pad; } @@ -1056,12 +1061,9 @@ void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &front * other Video Mux and Bridge devices. */ for (MediaLink *l : sourcePad->links()) { - enumerateVideoDevices(l, frontend); - /* Once we reach the Frontend entity, we are done. */ - if (l->sink()->entity()->name() == frontend) { - frontendFound = true; + frontendFound = enumerateVideoDevices(l, frontend); + if (frontendFound) break; - } } /* This identifies the end of our entity enumeration recursion. */ @@ -1076,6 +1078,8 @@ void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &front bridgeDevices_.clear(); } } + + return frontendFound; } int CameraData::loadPipelineConfiguration() diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h index 4c5743e04f86..4bce4ec4f978 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.h +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h @@ -68,7 +68,7 @@ public: void freeBuffers(); virtual void platformFreeBuffers() = 0; - void enumerateVideoDevices(MediaLink *link, const std::string &frontend); + bool enumerateVideoDevices(MediaLink *link, const std::string &frontend); int loadPipelineConfiguration(); int loadIPA(ipa::RPi::InitResult *result);