From patchwork Mon Nov 30 08:30:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 29109 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 D9B00C3304 for ; Mon, 30 Nov 2026 08:30:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5390A6AA3A; Mon, 30 Nov 2026 09:30:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fQJ4WRok"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B709B6AA37 for ; Mon, 30 Nov 2026 09:30:09 +0100 (CET) Received: from [127.0.1.1] (chfd-03-b2-v4wan-176392-cust229.vm15.cable.virginm.net [82.19.20.230]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 75309C31; Mon, 30 Nov 2026 09:27:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1796027252; bh=5WCLVWXOGzsD+vXHDoLmkcRk/9Esp2AgX9XQjqz28VM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fQJ4WRokoFQQSDe+X5s2rqAg/WzNMR3wGPpW3gR+6tO0AddbElL29YoWI/kn5SLtU f8bafH3/uoBtqK4v+jAMMK41+zFolf+6hJvrgMrImVIxuIq1d73IDUnFFYRNC/qG40 sKisOce6brUfSPxtvSHdHKSRQxTMpG1z6wRyJuZ8= From: Daniel Scally Date: Mon, 30 Nov 2026 08:30:00 +0000 Subject: [PATCH 1/2] libcamera: camera_manager: Allow other threads to create cameras MIME-Version: 1.0 Message-Id: <20261130-camera-thread-v1-1-bca905afbeef@ideasonboard.com> References: <20261130-camera-thread-v1-0-bca905afbeef@ideasonboard.com> In-Reply-To: <20261130-camera-thread-v1-0-bca905afbeef@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2339; i=dan.scally@ideasonboard.com; h=from:subject:message-id; bh=5WCLVWXOGzsD+vXHDoLmkcRk/9Esp2AgX9XQjqz28VM=; b=owEBbQKS/ZANAwAKAchJV3psRXUyAcsmYgBrDTQQauuCj478z3biORMAHn6BCoFT1G05eCWx9 7Na0+O0v0iJAjMEAAEKAB0WIQQqyuwyDnZdb+mxmm/ISVd6bEV1MgUCaw00EAAKCRDISVd6bEV1 MvH/EACk4lfbdxzbx0S81+RMuK40TVq6fQtIQ+pmnFKKR5qbjEBP40fmaPx41Vxr0Sq0N++YN22 K0/n+i6Ig7HQaNZZU6ysRfC91pRvgDOc8SxCgPr8224QdvCJ/i8QQdZWQUCkMegJ+dApl8SwWeL 2frl6Ei/zVA8nPQ0SwcFpNU5LkBMLc/MCA4z5bcbd8/toPr1Py/ct0tpAIwzDTUcrLOD5InFtis 5J6g/1IHRSCR41CW4Wx3ofkfNqX1Ya85avDS5G/tPftcmKqL6htUqeIzmAfkl28idogHumGcSi+ MvX4sk96j/m2LvCJ6sxO+0/0kCxmxHZUlKHCXslIHaXijECr1hAP8rEBOo1JCr7wtH5szotD2/c XiVFNfY5TVqpNSdt2/uorw3/woXmPR6A13ZabBK8kNGanRrr1is2RmvUXp4w53fmiaGOoDyHZtI DtRY0BdNNxYyYBk6t/V80sfznaZIUclTz1x5lqqfv77sXFIO5H5x6uZBaLCV3pT+RBi5amhqYuu Umj8MW+OZkHTbpmtGCXXMotCbikUsAYaCwWSz6eSo5N17NrOv3At6A/c9f9FqiEXVtu5N2cHyPM gYBSKbJPMblLQF0A+WAXsuNQZiGfrSVkqNARPuB2V73l/iQz7zs2vgS2yaeHf8W7ugzIVF1XCV4 dnKorPTOc9yQY7Q== X-Developer-Key: i=dan.scally@ideasonboard.com; a=openpgp; fpr=EEC699ACA1B7CB5D31330C0BBD501C2A3546CCF6 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 addCamera() and removeCamera() currently restrict the caller to the CameraManager thread. I can't see a compelling reason to keep that restriction; the addition / removal of the new Camera to the vector of Cameras is guarded by a mutex, and the notification of the change is performed by emitting a signal that will be handled by the program thread anyway. Removing the restriction makes it much easier to move PipelineHandlers to their own thread - drop it. Signed-off-by: Daniel Scally --- With the next patch, addCamera() will be called from the new thread for the PipelineHandler instead of the CameraManager's thread in PipelineHandler::registerCamera() via manager_->d()->addCamera(). It might be better to use invokeMethod? addCamera() doesn't create any objects that might then inherit the wrong thread so it didn't seem to be necessary, but I'm not totally sure so I thought I'd mention it. --- src/libcamera/camera_manager.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index 9c9073053710096f844670e8e1a5b70f2e4372bb..0f2189217c86e0ecc8673af0f5c7bf191eb2395d 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -198,13 +198,9 @@ void CameraManager::Private::cleanup() * * Device numbers from the SystemDevices property are used by the V4L2 * compatibility layer to map V4L2 device nodes to Camera instances. - * - * \context This function shall be called from the CameraManager thread. */ void CameraManager::Private::addCamera(std::shared_ptr camera) { - ASSERT(Thread::current() == this); - { MutexLocker locker(mutex_); @@ -236,13 +232,9 @@ void CameraManager::Private::addCamera(std::shared_ptr camera) * This function is called by pipeline handlers to unregister cameras from the * camera manager. Unregistered cameras won't be reported anymore by the * cameras() and get() calls, but references may still exist in applications. - * - * \context This function shall be called from the CameraManager thread. */ void CameraManager::Private::removeCamera(std::shared_ptr camera) { - ASSERT(Thread::current() == this); - { MutexLocker locker(mutex_);