From patchwork Wed Aug 27 09:07:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 24238 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 A3584BD87C for ; Wed, 27 Aug 2025 09:07:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3F6B9692EE; Wed, 27 Aug 2025 11:07:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="JncETe+o"; 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 C85CA613C0 for ; Wed, 27 Aug 2025 11:07:44 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3c73d3ebff0so293571f8f.1 for ; Wed, 27 Aug 2025 02:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1756285664; x=1756890464; 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=KWoEiVaKZRbolQ7JZ2mn3Ccm5Fq8zD+7dRFyWs6vnD4=; b=JncETe+ouofaKkULrRNzvqJQ7/q//a3pEj2LTYAIrFhE6QNR/+20abOzvoFVExAoGn qwuguPC1ar0TXyI9gDtkUtLuFomQQmPFvgDvQMt4AZShi3WI5zNQw+6j22st1rhU2yI7 bKjiND0FMhdESmovNLQTcRsMtj5IxHjIBiqnjlpigO3FTvjAN7hEKNTipTSzc2mBQXhg fv0bYGc3ul7C3u7bTBNRAwsnKWxH2M27/voH199HGCjkI11w8b9EiZbwW6FO8ERnCweB tIxOcbWq81DKDm5MRjw3uj4h7+ro8glzhkedi32I3b6ZgEU6TiI7tIZt+3tbaVC5MBwJ ixzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756285664; x=1756890464; 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=KWoEiVaKZRbolQ7JZ2mn3Ccm5Fq8zD+7dRFyWs6vnD4=; b=anUoNaU2jI4iI/U114Ha9o0KFEDm55266GmxTCxnVrICbuffmzPS0HTlpAoZO/lFZq 6ufyi3lBYIf51x4MoN5/wi8mTv43m41tCYTY8cV6rN8PKWeSb8SCKGmqykGmP2knHVb9 gy2a34ENNvdBcMo5NPSWYvETj/Sv9t6IoaaF3zhWGw4EsnAswjOSihFx4HQxdDZ697Q9 phQxqCwi5D5RvqdQAvC3w5jlfgWOv0JZZCIGLun4f4NBeH5B0CxV2LOD+viwgh7vDhEf jx4mVR82EdQe87Sp3MrctEwmq+/eVTz1q5e1jNQsC++B7O4oC1ZauTQ4cQ6reFCBBFwo ZyLg== X-Gm-Message-State: AOJu0Yyyl9Kv5oXlutEwtcy5Ucg+jrHRnVZSK057BOeDzSAXWUIdy0a5 Z3vflALWEyy4Jp8F6nHE/xk8Qeen35onbxqvxcilquM0JLfSEAlM6ZY5puZUrIj6NP4NhmYYDN0 amwSt X-Gm-Gg: ASbGnct4rTqhadkyhq288ZCJgJlB16w2LbWOwPSMYvpj+I/ZygOa29Xwm8it4sINKR+ Ldupxj3Qfez89Jj0+Rct+i0quW5PY7IlxxJ0RKdus31JrbdMAGSjAun39mU7JaHt8leUge06HbV ec185D4qG++GNKce+oxkYW5u0MRnAOO87GBfST46A/oEnGIxEYn7oJk63C+3CWwxbuebpU9VXJg uj/ZoYcsKI69gIyRykask4m8RHod2/LITWVq1yktiI+1UFSS4WkMBhX3kFvNPLe6lqBSUcKRpsM g4UunnoDhFVkKmWkL+8E09Hf5zKhnjoCSnoAEQrMBEUIB2qTWAnAFmvqTVMASERsFpaULFXb4tm jRmI5uEIoiCg2Mi9Q/ypWgRsCylKd2P/koYmY69QbUiZCP1/UkY1bUVVMrkuJke5bTiq30HABI6 Ewr7qySKOl07MmlJanomq1TDDRcJCbmJHSCLGFzIU= X-Google-Smtp-Source: AGHT+IFifNTZFgU4+DBCq+DKwm76bd4pDL7riH7TdCNJsx1AB+bE11Wwa0/eRmX1k/hRHoLeOj3CWQ== X-Received: by 2002:a5d:5d10:0:b0:3c5:8300:978d with SMTP id ffacd0b85a97d-3cbb15ca07fmr3725265f8f.22.1756285663781; Wed, 27 Aug 2025 02:07:43 -0700 (PDT) Received: from raspberrypi.pitowers.org ([2a00:1098:3142:1f:ffc9:aff6:7f7f:893b]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f30fe02sm21498675e9.18.2025.08.27.02.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Aug 2025 02:07:43 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [RFC PATCH 01/12] libcamera: Infrastructure to ask for "memory" cameras Date: Wed, 27 Aug 2025 10:07:28 +0100 Message-Id: <20250827090739.86955-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250827090739.86955-1-david.plowman@raspberrypi.com> References: <20250827090739.86955-1-david.plowman@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" Signed-off-by: David Plowman --- include/libcamera/camera_manager.h | 4 ++ include/libcamera/internal/camera_manager.h | 5 +++ include/libcamera/internal/pipeline_handler.h | 8 ++++ src/libcamera/camera_manager.cpp | 40 +++++++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index 27835500..436db409 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -20,6 +21,7 @@ namespace libcamera { class Camera; +class PipelineHandler; class CameraManager : public Object, public Extensible { @@ -33,6 +35,8 @@ public: std::vector> cameras() const; std::shared_ptr get(std::string_view id); + std::vector memoryCameras() const; + std::shared_ptr getMemoryCamera(std::string_view id, std::string_view settings); static const std::string &version() { return version_; } diff --git a/include/libcamera/internal/camera_manager.h b/include/libcamera/internal/camera_manager.h index 0150ca61..a490cb25 100644 --- a/include/libcamera/internal/camera_manager.h +++ b/include/libcamera/internal/camera_manager.h @@ -49,6 +49,9 @@ private: void pipelineFactoryMatch(const PipelineHandlerFactoryBase *factory); void cleanup() LIBCAMERA_TSA_EXCLUDES(mutex_); + std::shared_ptr getMemoryCamera(const PipelineHandlerFactoryBase *factory, + std::string_view settings); + /* * This mutex protects * @@ -64,6 +67,8 @@ private: std::unique_ptr enumerator_; + std::vector memoryCameras_; + std::unique_ptr ipaManager_; ProcessManager processManager_; }; diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index e89d6a33..0210d48b 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -70,6 +70,14 @@ public: CameraManager *cameraManager() const { return manager_; } + virtual bool supportsMemoryCamera() { return false; } + + virtual std::shared_ptr createMemoryCamera([[maybe_unused]] DeviceEnumerator *enumerator, + [[maybe_unused]] std::string_view settings) + { + return nullptr; + } + protected: void registerCamera(std::shared_ptr camera); void hotplugMediaDevice(MediaDevice *media); diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index f81794bf..580c31bf 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -152,6 +152,13 @@ void CameraManager::Private::pipelineFactoryMatch(const PipelineHandlerFactoryBa { CameraManager *const o = LIBCAMERA_O_PTR(); + /* First check for any memory-to-memory camera pipelines. */ + { + std::shared_ptr pipe = factory->create(o); + if (pipe->supportsMemoryCamera()) + memoryCameras_.push_back(std::string(pipe->name())); + } + /* Provide as many matching pipelines as possible. */ while (1) { std::shared_ptr pipe = factory->create(o); @@ -164,6 +171,19 @@ void CameraManager::Private::pipelineFactoryMatch(const PipelineHandlerFactoryBa } } +std::shared_ptr CameraManager::Private::getMemoryCamera(const PipelineHandlerFactoryBase *factory, + std::string_view settings) +{ + CameraManager *const o = LIBCAMERA_O_PTR(); + + std::shared_ptr pipe = factory->create(o); + + pipe->moveToThread(this); + + return pipe->invokeMethod(&PipelineHandler::createMemoryCamera, + ConnectionTypeBlocking, enumerator_.get(), settings); +} + void CameraManager::Private::cleanup() { enumerator_->devicesAdded.disconnect(this); @@ -399,6 +419,26 @@ std::shared_ptr CameraManager::get(std::string_view id) return nullptr; } +std::vector CameraManager::memoryCameras() const +{ + return _d()->memoryCameras_; +} + +std::shared_ptr CameraManager::getMemoryCamera(std::string_view id, + std::string_view settings) +{ + for (const auto &name : _d()->memoryCameras_) { + if (name == id) { + const PipelineHandlerFactoryBase *factory; + factory = PipelineHandlerFactoryBase::getFactoryByName(name); + + return _d()->getMemoryCamera(factory, settings); + } + } + + return nullptr; +} + /** * \var CameraManager::cameraAdded * \brief Notify of a new camera added to the system