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); From patchwork Wed Jun 25 08:41:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 23650 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 0CBDCBDCBF for ; Wed, 25 Jun 2025 08:42:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 45C6068DF0; Wed, 25 Jun 2025 10:42:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="n3iNIdCI"; dkim-atps=neutral Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D294468DE6 for ; Wed, 25 Jun 2025 10:42:16 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3a4e57d018cso871078f8f.1 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=1750840936; x=1751445736; 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=h4YFCnw/Vnf4bWX7DPoVXHfCEVt0AT65TY4/SmZkWNM=; b=n3iNIdCIiDltzbx3SqgNRfWUtCBgKU7LCUj3Mc+Va0MfuxMqzsMqlos4OLbIoqJRt+ AoOkildZXi/EvvJn1DsKmR+EnglR3XsYVVsQpDIS/PRHZtCBRGikRyUnjbWbzga7ywG7 VQ45WBDRwSgLIpPnw5eY/yuTtJK9c+bTdPuKWWnzryQrg04CblzuXp0MYA7ea2A2qbG1 uRpg/CWR+Jc1HwQMqeAKgrWaBtC94i4RcqaZX5UBGmwPMm6owOXdndLLr8vLosscXfVh cpjJRBTEQtOxlC6WTMe3h2jo2EXGPRUn09Q/qDpNlJ16l9+R3w/a11/4HJfzTA9aSAv5 lktw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750840936; x=1751445736; 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=h4YFCnw/Vnf4bWX7DPoVXHfCEVt0AT65TY4/SmZkWNM=; b=oRyhTo8m87hnbCiAUeuw4gLs2g/C/eW3b0zrox84DbyEGm8BuR7VXQAVnENOXyfBD5 vQI0uPkvzSAS8r6bP+s0bRE3Kzq0/rQvM0c48TOLROoMDitjxxCdCDeW1WI8n1Fb4D2e sWpDljFQjdDebu14GzYW+w3u6S6qmKnRXmpwe+uF4POLQCFvbkcn5EdYMf7cOjyrcT2H SbDeC7+9PSHQksCObXnXO0EHIDC5thv6ncrbah2vKRwiZc+LOSkp47tj1nRoSV/dUNGt ZQAcSXt8thwr+Ri34w8lO+jom8ab+skOjWHd3jp3ZE6BOU3tqR4jMAWhVwfqGDrUOlmO crDg== X-Gm-Message-State: AOJu0YyzFmo6ItGVJO+lnm6NcuftvRYvVWfzAxs3plYBHTSoDV8SZ0mr rT4fohvWKp+Pwu6CyS7I+Dehqx7NBqoXUJDbkkDJVlAsm1W9xosUfXYgEvETgEw3zS3rU91P/vw RVjMe X-Gm-Gg: ASbGnct0i8yWaC7qgk/FpRKrO219jcqrjsQ7vrTMpNWSUxqXZ/M3sDB9Swc8idvpwlo 9FhEZb7t4o6WZj1zGp6ZhsorNheXKpi76kKI/zKmRCrveZow9XNjZR0U0L8bCF8i6OSZHFZUqQ1 WRdJGFs7UPvKonZ7lxBFqqvZ9Xo8sr1nK33+SLJowYURPUHjl5v9hLo5i1Uf5hVxyV6J4Bc4aZx b4GkHeXoA33eIXKq93hk/fArYkm/0nDAJkGc2cbVZlF+xAkHKdoqSNL07DauXpXwPkcJpvwgJ21 ghiFY7LyJV3mVyR8PVJXb4lSDofXoBeIldYp/yu3vQq+UWmK9L3+jtWZ4xORjM1py9FihaEWIY+ vgS93mg== X-Google-Smtp-Source: AGHT+IG3a15v2N/CJJHDO/EMVpA7vyosQYRr+19nnug/2K1ZW8ZG8kivIZTBK+x8wfa+yA5PeX+AIw== X-Received: by 2002:a05:600c:c059:20b0:453:59b5:25cc with SMTP id 5b1f17b1804b1-45381b15784mr3824225e9.7.1750840935963; 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.15 (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 2/3] pipeline: rpi: Move media device configuration into its own function Date: Wed, 25 Jun 2025 09:41:17 +0100 Message-ID: <20250625084212.858487-3-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" Add a new function configureMediaDevices() used to configure the media links and pads for all known bridge/mux entities in the media graph. No functional change, this simply moves existing code into a new function in prepartion for further changes in a subsequent commit. Signed-off-by: Naushir Patuck Reviewed-by: Umang Jain --- .../pipeline/rpi/common/pipeline_base.cpp | 84 ++++++++++--------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index eafe94427dbc..219bd81cc63a 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -85,6 +85,51 @@ std::optional findValidColorSpace(const ColorSpace &colourSpace) return std::nullopt; } +int configureMediaDevices(std::vector, MediaLink *>> &bridgeDevices, + V4L2SubdeviceFormat *sensorFormat) +{ + int ret = 0; + + /* Setup the Video Mux/Bridge entities. */ + for (auto &[device, link] : bridgeDevices) { + /* + * Start by disabling all the sink pad links on the devices in the + * cascade, with the exception of the link connecting the device. + */ + for (const MediaPad *p : device->entity()->pads()) { + if (!(p->flags() & MEDIA_PAD_FL_SINK)) + continue; + + for (MediaLink *l : p->links()) { + if (l != link) + l->setEnabled(false); + } + } + + /* + * Next, enable the entity -> entity links, and setup the pad format. + * + * \todo Some bridge devices may chainge the media bus code, so we + * ought to read the source pad format and propagate it to the sink pad. + */ + link->setEnabled(true); + const MediaPad *sinkPad = link->sink(); + ret = device->setFormat(sinkPad->index(), sensorFormat); + if (ret) { + LOG(RPI, Error) << "Failed to set format on " << device->entity()->name() + << " pad " << sinkPad->index() + << " with format " << *sensorFormat + << ": " << ret; + return ret; + } + + LOG(RPI, Debug) << "Configured media link on device " << device->entity()->name() + << " on pad " << sinkPad->index(); + } + + return ret; +} + } /* namespace */ /* @@ -589,44 +634,7 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config) data->controlInfo_ = ControlInfoMap(std::move(ctrlMap), result.controlInfo.idmap()); - /* Setup the Video Mux/Bridge entities. */ - for (auto &[device, link] : data->bridgeDevices_) { - /* - * Start by disabling all the sink pad links on the devices in the - * cascade, with the exception of the link connecting the device. - */ - for (const MediaPad *p : device->entity()->pads()) { - if (!(p->flags() & MEDIA_PAD_FL_SINK)) - continue; - - for (MediaLink *l : p->links()) { - if (l != link) - l->setEnabled(false); - } - } - - /* - * Next, enable the entity -> entity links, and setup the pad format. - * - * \todo Some bridge devices may chainge the media bus code, so we - * ought to read the source pad format and propagate it to the sink pad. - */ - link->setEnabled(true); - const MediaPad *sinkPad = link->sink(); - ret = device->setFormat(sinkPad->index(), sensorFormat); - if (ret) { - LOG(RPI, Error) << "Failed to set format on " << device->entity()->name() - << " pad " << sinkPad->index() - << " with format " << *sensorFormat - << ": " << ret; - return ret; - } - - LOG(RPI, Debug) << "Configured media link on device " << device->entity()->name() - << " on pad " << sinkPad->index(); - } - - return 0; + return configureMediaDevices(data->bridgeDevices_, sensorFormat); } int PipelineHandlerBase::exportFrameBuffers([[maybe_unused]] Camera *camera, libcamera::Stream *stream, From patchwork Wed Jun 25 08:41: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: 23651 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 D67F9BDCBF for ; Wed, 25 Jun 2025 08:42:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 37FE268DF3; Wed, 25 Jun 2025 10:42:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ngSI95bk"; dkim-atps=neutral Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3759B68DEC for ; Wed, 25 Jun 2025 10:42:17 +0200 (CEST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4531898b208so2438045e9.3 for ; Wed, 25 Jun 2025 01:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1750840936; x=1751445736; 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=lrSqQB4Cti6BoBr67+f3uwE0CYQ6ivP0q/pERTPPsCU=; b=ngSI95bksc6jNXmGKjKkPj0folxUZUyRsg659iZWtkKFv+Als7WslqpfRaP2qemy/v 15QhT2jL6+IENC4Wb4OPc3rk1BoaqMz1jfYmljwJanqzxMwy0to+Y/veQf3w93cMXD8w jsNWtUE/Q4JWDng2KthU93emSfa4tA1E4/4SPRAzjmgl34nN4ndNfl85gl9duZa2fwUh FkHUOKKeiX1kIqbilDcmTtp1JTroPR5xUIJZDs62UxIEAs5S+ckQ2fMbbZ9BrUHAeOX8 GOPgG2fGIQ2ejf4fn+C3OiqbWaNpJy+ouQ7ZlnOpNchk0fym+v/7dvBhJswnyUEjjWMm R8Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750840936; x=1751445736; 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=lrSqQB4Cti6BoBr67+f3uwE0CYQ6ivP0q/pERTPPsCU=; b=Wdw4cJ0vp6zobGCqFBfDqsq57tq/vob1VKCfXxTGuDS7z1taEdlQfjVOOe7FkgYelx JBs1SdYTPNhTnnf1Iw6f8qz8ne9DKhuFFN96qN8F9NI0Y9pXdGMEeZZQxo0YU1pxHNJz F/vKHvc80IU1dYsBk65pv63/V3kadm7iGZyFfeJfj8rZdi7f4yzQl1fArokTOeQ3EOv7 kc+peI2n4/4AYXvqe3tX8UX48BxTYFQvEhXsrp8aG8kb9MH8ZNzsnDaXvmRV8jL2eIGi JleNX5RGLt5vaMQ0S3Xllh+RozyD2mbq51r7EBWy6/9SXbzyPiiJjo30zr/CDBhoA4f9 1krA== X-Gm-Message-State: AOJu0YzUvdcVBQcwGstPgR1YSiKzmEX10vGJRDWrnEKpXwE4uPpetjZ8 f71/f1chs07RGXhV+YE87Q2bLTbpL9rd/V06P1m8Hkoj1oABsBInpSpA7SV2+bGXJ1BUwRxUuCE e48T5 X-Gm-Gg: ASbGncuFM9Fx7MDhZEOJrTh4raYP1B6weapc2bMuHkmQGCTvti1e5GL9I3dh6t4gES0 JO0hTWJGW0c+LLW5vh12wLjzphpgdLgziHsW8B1QH1m1kTTZ41u2qEBskr2Aav4Y7qqibcqkrwY c3lGh0sr7H+BDgydBT2+mc5TdGqbeIu76jhNpC7NTZvz3JxUlI596jC80PfhvUHV/CRhjtwYys2 IpXnc4Ec66PHLcl9X2YNL22V9kCPz4bj6Om2KKK+PaplvFQCc0Ob3fOwAu5UQIQSCVgsT8WsASf RUeQZBwQTPNjpEzzLlUkbEAQIkU8ivshIvZ+/UPX58zDLRSxNbF+UoelzqviWRZl3QkmzPInSk0 SVjBiVg== X-Google-Smtp-Source: AGHT+IHxGmyHPWOFDF/VJMnixzGvilTVRVwdPc55oZL7CmsE2MpyjTYmQHhV7P5A+qE+349zLk8okQ== X-Received: by 2002:a05:600c:3b22:b0:43e:94fa:4aef with SMTP id 5b1f17b1804b1-45381af75f0mr7762705e9.8.1750840936492; Wed, 25 Jun 2025 01:42:16 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jun 2025 01:42:16 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: dave.stevenson@raspberrypi.com, Naushir Patuck Subject: [PATCH v1 3/3] pipeline: rpi: Set a default route for entities where applicable Date: Wed, 25 Jun 2025 09:41:18 +0100 Message-ID: <20250625084212.858487-4-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" If an entity advertises streams support, and no routes are active, set a default active route for Stream 0:[pad 0 -> pad 1]. This allows serialiser/deserialiser devices to run without user setup in the default case. Signed-off-by: Naushir Patuck --- .../pipeline/rpi/common/pipeline_base.cpp | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 219bd81cc63a..eafbf702ed0b 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -107,7 +107,38 @@ int configureMediaDevices(std::vector, } /* - * Next, enable the entity -> entity links, and setup the pad format. + * Next, setup the stream routing if needed. By default this + * sets up Stream 0:[pad 0 -> pad 1] route. Anything more + * complicated must currently be setup and activated externally. + * + * If we find any active routes, we don't change anything. + */ + if (device->caps().hasStreams()) { + V4L2Subdevice::Routing routing; + + ret = device->getRouting(&routing); + if (ret) + return ret; + + /* If we find an active route, don't do anything more. */ + for (auto const &r : routing) { + if (r.flags & V4L2_SUBDEV_ROUTE_FL_ACTIVE) + return 0; + } + + /* + * Set up a default Stream 0:[pad 0 -> pad 1] route if nothing + * has already been set. + */ + routing = { { V4L2Subdevice::Stream{ 0, 0 }, + V4L2Subdevice::Stream{ 1, 0 }, + V4L2_SUBDEV_ROUTE_FL_ACTIVE } }; + + ret = device->setRouting(&routing); + } + + /* + * Finally, enable the entity -> entity links, and setup the pad format. * * \todo Some bridge devices may chainge the media bus code, so we * ought to read the source pad format and propagate it to the sink pad.