From patchwork Fri Sep 18 07:59:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 28319 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 014C7C3358 for ; Fri, 18 Sep 2026 08:07:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 013736872E; Fri, 18 Sep 2026 10:07:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="gEgODjnf"; dkim-atps=neutral Received: from mail-wr2-x0f.google.com (mail-wr2-x0f.google.com [IPv6:2a00:1450:4864:30::f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3EC3B68721 for ; Fri, 18 Sep 2026 10:07:46 +0200 (CEST) Received: by mail-wr2-x0f.google.com with SMTP id ffacd0b85a97d-482e1b429f7so64340f8f.2 for ; Fri, 18 Sep 2026 01:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1789718866; x=1790323666; 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=axggi41KQRiaLtC5fkpnui7rDk7gH9OBcWZpESWdAZM=; b=gEgODjnfT2qRPK/kiPHLg2J8eQ7SzXuzVPrloNNsj6oCS8X/lqY0UPoHlwDY5ZJPkR 0HdKCoZE2ZV31ne8u5kLlFw+pGGjbSDzjwpQvY5DrYi2tGCGV6nMjfG+GKqvi/Hu54bC 1+lLqdZvnRG4+5wWzwmYzSBrtExGCwT5PreXT7DNbxc494Fvt4cxfMwlewSdSQhRUR32 kPG6WG69DV3piIlYCIHUM5AGp5KYlY94IuWMkmQQSg+0M01R6goLyo0gA4UY0jlre4Bb HRsB+BS+N46KQKF3rzlMnWn3CWJC1kfFpVh2Lv7t0dx/abxdnTWSahrL1fmacm9ioQEj 5eMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789718866; x=1790323666; 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=axggi41KQRiaLtC5fkpnui7rDk7gH9OBcWZpESWdAZM=; b=Tsn3eAYEhgz45LEqzMNpwAECdwN8nQHRA8WrNYmTpvx3xvjxOhMKPTlAto3/tlelfU yncSySsIKlHp9rlPucql1+wEL6NYsoXKNjMy05MhnhUFW6jZ8vJkchbmepvsU0SPKgWd m2ByFbX/CJxWpiG+226mQvpkR8C/TDPxoJufrEMmD5biUonpU+bydmqiWGOq5BYuLym2 i2JaLyUBSGp7qOybQSxt5MPPvLuQVpeBQaCxEwLjQtJbgxLLuJ+dwMNnf7rOGBXU2W5M 3wUtXqoUmU+IiF4Rzsl6Wwl7t5XjqucKzdeaKg73fhlOHqRHbsc3JUIjJ9lBBSevsO3s 9jiw== X-Gm-Message-State: AFuF++kzlY5bSW3bsBST0Kc+ejA9/q/ehdLNBpSwpjc/sp+7plHQH45R 8boy+x5M85OQgg1t5jCtEdvWzjYiQFgZ0+ey5lFcWsafgzn/fnLQAjoL2EfkWj2kS4Rl0zKNMW+ OI5OQilg= X-Gm-Gg: AYBFou1Sr2EH94b/ix1S1KNjSLjkgoV8doNuEAvMMigIm5yGByIy2OPJwUGbK/zNS3P Hw2r+O06mxb8bBTBuSdHNQfgtpfF2H8GmZzAeH5ScbTq18bUAMrJUAaC4oE8+LVDplW5UpXq0Ko SEbGc9CsMfT46LDy3jg7OKBsaW05Rk6WWEbCX0sQQLgrUqIYYl2+cLICKsc3vwGPO1BM5NEgLni tbFp/tP6zykKN3XPTkDiO0c9OoE5DzeZlZXkdGLtan6MsMZX3nQanObNOS6WqavTA+wvma8T8wO c3Zdvn09w03RPybvxuKhcRMlAHAU+dxp2rr7C/QTR6vwQibZVkryF9QlxHPp2tamZY67uU2/Qot G9SJJlASZnvhpoy+7QKLYOyn9cvVKI1ZGID1O5a1ZAUU5PhKoVG5qxH84detLqLJUD7KwLWLHqh V9Ak0bAKTy369uz3Or89wNfi23fbUvkuLYc3MlttgIBQR0t89ydUi985CYwf8UeOwkFZ51ZUhbL MhJH560pYwpH+o+CmBXll+QTHs12IQo8MdYqsV0SHJy6TflmdspkZkon87bUdnstmO7WafmdpwL h5vh5PjelY4sqZSPVV6Z0PesLDblHr6dsWFPfkVAhGM48fGdXSdVse57zyCA1odWTuhZ99l8vBL fDhpPU3GRXM0wcFFF5EmA725wjsjUZoYZwyM= X-Received: by 2002:a05:6000:41f9:b0:487:a9f:4fa2 with SMTP id ffacd0b85a97d-4871fa282e5mr1168584f8f.1.1789718865499; Fri, 18 Sep 2026 01:07:45 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 01:07:45 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [RFC PATCH v1 07/20] libcamera: pipeline_handler: Allow acquiring a specific media device Date: Fri, 18 Sep 2026 08:59:45 +0100 Message-ID: <20260918080734.1228227-8-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 an acquireMediaDevice() overload that acquires a given MediaDevice instance rather than the existing search mechanism. Camera creation through a descriptor already knows exactly which media devices the camera needs, so this is a simpler shortcut. This will be used in future commits to acquire a camera through the enumeration API. Signed-off-by: Naushir Patuck --- include/libcamera/internal/pipeline_handler.h | 1 + src/libcamera/pipeline_handler.cpp | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index c22c69e70fae..1f82ff998514 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -46,6 +46,7 @@ public: virtual int createCamera(const CameraDescriptor *descriptor); std::shared_ptr acquireMediaDevice(DeviceEnumerator *enumerator, const DeviceMatch &dm); + bool acquireMediaDevice(std::shared_ptr media); bool usesMediaDevice(const MediaDevice *media) const; bool acquire(Camera *camera); diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 30079fa9f665..6023d028f40b 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -204,6 +204,29 @@ PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator, return media; } +/** + * \brief Acquire a specific MediaDevice + * \param[in] media The media device to acquire + * + * Acquire the media device \a media for this pipeline handler instance. As with + * the search variant, the caller shall not release the device explicitly, it + * will be automatically released when the pipeline handler is destroyed. + * + * \context This function shall be called from the CameraManager thread. + * + * \return True if the media device was acquired, or false if it was already + * in use + */ +bool PipelineHandler::acquireMediaDevice(std::shared_ptr media) +{ + if (!media->acquire()) + return false; + + mediaDevices_.push_back(std::move(media)); + + return true; +} + /** * \brief Check if this pipeline handler instance uses a media device * \param[in] media The media device to check for