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.