From patchwork Fri Sep 18 07:59:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 28316 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 7800CC3292 for ; Fri, 18 Sep 2026 08:07:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E2E3D6870B; Fri, 18 Sep 2026 10:07:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="q8AdOMB9"; dkim-atps=neutral Received: from mail-wr2-x10.google.com (mail-wr2-x10.google.com [IPv6:2a00:1450:4864:30::10]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 28480686F7 for ; Fri, 18 Sep 2026 10:07:41 +0200 (CEST) Received: by mail-wr2-x10.google.com with SMTP id ffacd0b85a97d-4843178b1c8so62431f8f.0 for ; Fri, 18 Sep 2026 01:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1789718861; x=1790323661; 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:content-type; bh=v2RPFmD/SXTku6+ijEFzF9ylGtmdyCFFKZdl09UOI8Y=; b=q8AdOMB9Hw7MkJiHJdxUAufsrEG5ThENaEFuaVXuxkmV3594fOtKaviXa4L8YC7FmA KdfY0IG+HSOfmkPVvRVJ63Gv3zI83ASQQLnSVbJxj1hZCkH4g3+MXOwpKs42Aacw87Ac xQoU3PjAjUShT6YUc6zldY2A7g+TC1nC/1/TPHFy5nF6W/qsVoUFJPDc9wyiwl/26LAj AW3joX6uPHhI7yq8+6jos9vF02kse3nSEkKsZZVq0qyv7ngOXTev/com6X7kiIO857K7 cKFtueyNu8cDSgkGEEFhjDKU4DrZcvEH8vBkJ9t3IVQdh2+ojM2AjyIuHWU5ID8I4vMT 0h6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789718861; x=1790323661; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=v2RPFmD/SXTku6+ijEFzF9ylGtmdyCFFKZdl09UOI8Y=; b=vV0Y93fJFM2e0xTT167cZYGDKElnUOn2mfybUqPYXn0VmzhkIJhNBjQlZgopm5XUf5 pZAqwDpQPyvMPLjuAHcqtLsRvNEItnJHwYo5m+dXrVgisBf/vMTHAYKP1nKyhzCQ8rUa 7Qkd3epno82q8W8vghcYp0Ulx/h1qPuKvXPSc51TJ9iUsHBERmXabRyHQnWS5XMBkKhX BF/46OoPw6IzSEvOFaAwqUk5aIlBtdGBFDr/MFMbfYyT4osL6HQ2vNAEBDCX2xszfhxK S4Bepfioi+a+MFeOWaY2t2M1LKkUn5WpSyZT8ESD3Kfl/AGQWFhbEueF1BtJn/oLHXSY bUaQ== X-Gm-Message-State: AFuF++ngeVXfJVMTNbu7KneKFXPNk8L7sI6bjYpCE8kAzL/VMMASLfI0 WZJ6URi58xV0A+EGeYTXji00Mp38FsINm0astILKqlWph2ivDhxVzFIXtaSt1YKd7CK0HejvRdo mz7inrUE= X-Gm-Gg: AYBFou1tdExoJtG7IGp59jeS8UAwyAymADNKcvJTijh29TjbJ+/lIZTTxJJBA9wNxjm cdTNZNwmoP0JV9jnwbARxm1Ok80RWz/KKF2ifQOZx+jEK9M6yNLNvbslng0+H1DRwEnQuYOEqil E6+UR6QSPrrtUCQW5vwbG29Gc6ViSvsetln55kHRqWoWa/F2UHwnPH981aROVvpZiSnO/vhiXLj Fz14oF7UGDevO2b/SYeb88fGCyF8JTSOLWVmICqBtpKERIbh+F1OM9cIq7x14pgE6z9Ty9defTy nOEWL19iQ81qQvz/BxrSWWNOPyo/QhWtUACEKZNlM0o7qPwz5Tbs38P8FX6v5MzPd9YXByZpVE8 GaN+t/TpXhav/YuXcA6Xc1ZX5fmbxHWEPAOlRMDdXsPky5F3dbNI30p6/hWv2spWFMT5R6BcWjO jLiJsMSa4NeldEHNEYqpRHpyQznigkDaHhvE5OHmAbFyS2jFOuiO4SrHPQyAATYz1flWfeorUZJ GlmE4Uybg9EXvTS3INMuRLeYnSyE+XHEsp1iBz761ZATwbGp7V3KX2k3/cySHPMfKGRPD83V3u4 lsKUxV5bjYE9VLp2ItZsyAJNFHm4Wcj4vHmWQ/Gp1qjIMyAtBStBnbTqoYsd8EW6PIFtmGNQFo4 6zpEsEudjTNaJMasR/DrTlssokGuE7fGl62Q= X-Received: by 2002:a5d:5d02:0:b0:487:421:7c83 with SMTP id ffacd0b85a97d-4871f92df61mr1330745f8f.0.1789718860704; Fri, 18 Sep 2026 01:07:40 -0700 (PDT) Received: from naush-dell.pitowers.org ([2a00:1098:3142:1f:45e3:df8b:2b18:6253]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-487203f077fsm1742230f8f.26.2026.09.18.01.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 01:07:40 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [RFC PATCH v1 04/20] libcamera: device_enumerator: Add non-acquiring searchAll() Date: Fri, 18 Sep 2026 08:59:42 +0100 Message-ID: <20260918080734.1228227-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918080734.1228227-1-naush@raspberrypi.com> References: <20260918080734.1228227-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 searchAll() function that returns all media devices matching a DeviceMatch instead of the first match only. Unlike the acquire and advance behaviour used with search() in pipeline handler match() implementations, searchAll() allows callers to inspect every matching media device without acquiring any of them. This will be used by future commits for device enumeration. Signed-off-by: Naushir Patuck --- .../libcamera/internal/device_enumerator.h | 1 + src/libcamera/device_enumerator.cpp | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h index 5e1aec9924c5..14fd5750a0ab 100644 --- a/include/libcamera/internal/device_enumerator.h +++ b/include/libcamera/internal/device_enumerator.h @@ -45,6 +45,7 @@ public: virtual int enumerate() = 0; std::shared_ptr search(const DeviceMatch &dm); + std::vector> searchAll(const DeviceMatch &dm) const; Signal<> devicesAdded; diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index 0ce65e89a67f..6eaa52604a50 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -362,4 +362,35 @@ std::shared_ptr DeviceEnumerator::search(const DeviceMatch &dm) return nullptr; } +/** + * \brief Search available media devices for all pattern matches + * \param[in] dm Search pattern + * + * Search in the enumerated media devices that are not already in use for + * matches described in \a dm. Unlike search(), all matching media devices are + * returned instead of the first match only. The caller shall not use the + * returned devices for capture without acquiring them first. + * + * \return A vector of matching MediaDevice instances, empty if no match is + * found + */ +std::vector> DeviceEnumerator::searchAll(const DeviceMatch &dm) const +{ + std::vector> matches; + + for (const std::shared_ptr &media : devices_) { + if (media->busy()) + continue; + + if (dm.match(media.get())) { + LOG(DeviceEnumerator, Debug) + << "Successful match for media device \"" + << media->driver() << "\""; + matches.push_back(media); + } + } + + return matches; +} + } /* namespace libcamera */