From patchwork Mon Apr 29 19:17:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 1128 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D6A27600EC for ; Mon, 29 Apr 2019 21:17:46 +0200 (CEST) X-Halon-ID: 727d3f34-6ab3-11e9-8e2c-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from wyvern.station (unknown [37.182.44.227]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 727d3f34-6ab3-11e9-8e2c-005056917f90; Mon, 29 Apr 2019 21:17:43 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Apr 2019 21:17:18 +0200 Message-Id: <20190429191729.29697-1-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 00/11] libcamerea: Add support for exclusive access to cameras between processes 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: Mon, 29 Apr 2019 19:17:47 -0000 Hi, This series aims to solve mutably exclusive access to a camera between two or more processes by the use of lockf(). In the process of adding support for this the MediaDevice implementation is cleaned up a bit and stricter call patterns are enforced. At the same time a small load is taken of pipeline handler implementations. As a camera might share resources with other cameras from the same pipeline handler instance I have chosen to put the granularity of the lock at the media device level. When a camera is acquired by an applications all media devices the pipeline handler it belongs to have claimed are locked and becomes unavailable to other processes. Other process can still enumerate locked media devices and list all cameras they provide but they can't use any of the cameras who are backed by a locked media device. Patches 1/11 -- 7/11 deals with tidying up and adding more restrictions to the MediaDevices and how they handled inside pipeline handlers. While patches 8/11 -- 11/11 adds the new locking scheme which depends on the new stricter handling of media devices. Niklas Söderlund (11): libcamera: Always check return value of MediaDevice::acquire() libcamera: media_device: Open and close media device inside populate() libcamera: media_device: Only read device information in populate() libcamera: media_device: Handle media device fd in acquire() and release() test: media_device: Create a common MediaDeviceTest base class test: media_device: Add test for acquire() and release() libcamera: media_device: Make open() and close() private libcamera: media_device: Add functions to lock device for other processes libcamera: pipeline_handler: Keep track of MediaDevice libcamera: pipeline_handler: Add functions to lock a whole pipeline libcamera: camera: Lock the pipeline handler in acquire() src/libcamera/camera.cpp | 7 + src/libcamera/device_enumerator.cpp | 8 +- src/libcamera/include/media_device.h | 10 +- src/libcamera/include/pipeline_handler.h | 7 + src/libcamera/media_device.cpp | 238 +++++++++++------- src/libcamera/pipeline/ipu3/ipu3.cpp | 71 +----- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 57 ++--- src/libcamera/pipeline/uvcvideo.cpp | 23 +- src/libcamera/pipeline/vimc.cpp | 21 +- src/libcamera/pipeline_handler.cpp | 71 ++++++ test/media_device/media_device_basic.cpp | 41 +++ test/media_device/media_device_link_test.cpp | 76 ++---- test/media_device/media_device_print_test.cpp | 17 -- test/media_device/media_device_test.cpp | 41 +++ test/media_device/media_device_test.h | 35 +++ test/media_device/meson.build | 3 +- test/pipeline/ipu3/ipu3_pipeline_test.cpp | 5 - test/v4l2_device/v4l2_device_test.cpp | 4 - test/v4l2_subdevice/v4l2_subdevice_test.cpp | 17 +- 19 files changed, 420 insertions(+), 332 deletions(-) create mode 100644 test/media_device/media_device_basic.cpp create mode 100644 test/media_device/media_device_test.cpp create mode 100644 test/media_device/media_device_test.h