From patchwork Thu Jan 24 10:16:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 355 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 21AF060C78 for ; Thu, 24 Jan 2019 11:16:57 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 776F123A; Thu, 24 Jan 2019 11:16:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1548325016; bh=/2DeNMKzSiE1WCoJiV9h6bSZWGu1kxiAP+nNqD/JeFA=; h=From:To:Cc:Subject:Date:From; b=jX+YZJfKEI834nGWz1YOSsQzxCkQ//+9BsY4QHWX08JASGBZvWjkgGOtDnlh///ji 5stQ6NQaDT5b9CiqGuBUQSZf1o7Es+n2eePQXjBgikZy6zqm5SlD/P+s7zMiScMLP1 JLsiEI6qpBUADmtxM8TuC+3zHMuLE3sTjSc0zglc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Jan 2019 12:16:41 +0200 Message-Id: <20190124101651.9993-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 00/10] Hotplug support and object lifetime management X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2019 10:16:57 -0000 Hello everybody, This patch series implements hotplug support in libcamera, and handles all the lifetime management-related fallouts. The first two patches, 01/10 and 02/10, are simple cleanups. The real fun begins with pPatch 03/10 that stores a reference to the pipeline handler in the camera, turning PipelineHandler into shared pointers. Patch 04/10 turns MediaDevice into shared pointers as well, due to the need to support hot-unplug when references to the media device can still exist. This results in all three core objects related to hotplug, MediaDevice, PipelineHandler and Camera, being managed as shared pointers. The next four patches, 05/10 to 08/10, add disconnection support to MediaDevice, Camera, CameraManager and PipelineHandler through signals and slots. Patch 09/10 marks the media device used by the UVC pipeline handler as hot-pluggable, and patch 10/10 implements unplug detection in the udev enumerator for the last piece of the puzzle. While I hope the architecture is fine, I'm sure there will be lots of various issues that will be discussed, and I expect a few more versions of this series before merging it in the master branch. If the architecture is approved, I would however recommend already depending on this series as it addresses lots of lifetime management problems. Laurent Pinchart (7): libcamera: pipeline_handler: Store the camera manager pointer libcamera: pipeline_handler: Declare factory children classes as final libcamera: device_enumerator: Reference-count MediaDevice instances libcamera: media_device: Add disconnected signal libcamera: camera_manager: Add method to unregister a camera libcamera: pipeline: uvc: Mark the media device as hotpluggable libcamera: device_enumerator: Add hotplug support Niklas Söderlund (3): libcamera: camera: Associate cameras with their pipeline handler libcamera: camera: Add disconnection notification libcamera: pipeline_handler: Add camera disconnection support include/libcamera/camera.h | 15 ++- include/libcamera/camera_manager.h | 3 +- src/libcamera/camera.cpp | 47 +++++++- src/libcamera/camera_manager.cpp | 38 ++++-- src/libcamera/device_enumerator.cpp | 106 ++++++++++++++--- src/libcamera/include/device_enumerator.h | 10 +- src/libcamera/include/media_device.h | 4 + src/libcamera/include/pipeline_handler.h | 33 ++++-- src/libcamera/media_device.cpp | 10 ++ src/libcamera/pipeline/ipu3/ipu3.cpp | 32 +++-- src/libcamera/pipeline/uvcvideo.cpp | 20 ++-- src/libcamera/pipeline/vimc.cpp | 26 ++--- src/libcamera/pipeline_handler.cpp | 117 ++++++++++++++++++- test/media_device/media_device_link_test.cpp | 2 +- test/pipeline/ipu3/ipu3_pipeline_test.cpp | 2 +- 15 files changed, 372 insertions(+), 93 deletions(-)