{"id":969,"url":"https://patchwork.libcamera.org/api/covers/969/?format=json","web_url":"https://patchwork.libcamera.org/cover/969/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190414013506.10515-1-niklas.soderlund@ragnatech.se>","date":"2019-04-14T01:34:55","name":"[libcamera-devel,RFC,00/11] libcamerea: Add support for exclusive access to cameras between processes","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"mbox":"https://patchwork.libcamera.org/cover/969/mbox/","series":[{"id":249,"url":"https://patchwork.libcamera.org/api/series/249/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=249","date":"2019-04-14T01:34:55","name":"libcamerea: Add support for exclusive access to cameras between processes","version":1,"mbox":"https://patchwork.libcamera.org/series/249/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/969/comments/","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 30BB660DB4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 14 Apr 2019 03:35:14 +0200 (CEST)","from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 895d49aa-5e55-11e9-8e2c-005056917f90;\n\tSun, 14 Apr 2019 03:35:12 +0200 (CEST)"],"X-Halon-ID":"895d49aa-5e55-11e9-8e2c-005056917f90","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Sun, 14 Apr 2019 03:34:55 +0200","Message-Id":"<20190414013506.10515-1-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.21.0","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC 00/11] libcamerea: Add support for exclusive\n\taccess to cameras between processes","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sun, 14 Apr 2019 01:35:14 -0000"},"content":"Hi,\n\nThis RFC is a proposal on how to solve mutably exclusive access to a \ncamera between two or more processes by the use of lockf(). In the \nprocess of adding support for this the MediaDevice implementation is \ncleaned up a bit and stricter call patterns are enforced. At the same \ntime a small load is taken of pipeline handler implementations.\n\nAs a camera might share resources with other cameras from the same \npipeline handler instance I have chosen to put the granularity of the \nlock at the media device level. When a camera is acquired by an \napplications all media devices the pipeline handler it belongs to have \nclaimed are locked and becomes unavailable to other processes. Other \nprocess can still enumerate locked media devices and list all cameras \nthey provide but they can't use any of the cameras who are backed by a \nlocked media device.\n\nPatches 1/11 -- 8/11 deals with tidying up and adding more restrictions \nto the MediaDevices and how they handled inside pipeline handlers. While \npatches 9/11 -- 11/11 adds the new locking scheme which depends on the \nnew stricter handling of media devices.\n\nAs this is a RFC there are some limitations,\n- Documentation is missing for some of the new functions, but they are \n  pretty straight forward.\n- The new stricter MediaDevice call schema prevents \n  media_device_link_test to run properly as it now needs access to \n  private functions to operate. As it's outside the scope of this RFC to \n  solve testing of private functions I simply dropped it for now.\n- Some functions name are not as nice as they could be... I really hate \n  PipelineHandler::tryAcquire(), suggestions are welcome!\n\nAll comments welcome, including ones telling me I'm a moron! ;-)\n\nNiklas Söderlund (11):\n  libcamera: Always check return value of MediaDevice::acquire()\n  libcamera: media_device: Open and close media device inside populate()\n  libcamera: media_device: Only read device information in populate()\n  libcamera: media_device: Handle media device fd in acquire() and\n    release()\n  libcamera: media_device: Make open() and close() private\n  libcamera: pipeline_handler: Keep track of MediaDevice\n  [HACK] tests: disable media_device_link_test\n  libcamera: media_device: Restrict acquire() and release()\n  libcamera: media_device: Add functions to lock device for other\n    processes\n  libcamera: pipeline_handler: Add functions to lock a whole pipeline\n  libcamera: camera: Lock the pipeline handler in acquire()\n\n src/libcamera/camera.cpp                      |   7 +\n src/libcamera/device_enumerator.cpp           |   8 +-\n src/libcamera/include/media_device.h          |  16 +-\n src/libcamera/include/pipeline_handler.h      |   7 +\n src/libcamera/media_device.cpp                | 250 +++++++++---------\n src/libcamera/pipeline/ipu3/ipu3.cpp          |  47 +---\n src/libcamera/pipeline/uvcvideo.cpp           |  23 +-\n src/libcamera/pipeline/vimc.cpp               |  21 +-\n src/libcamera/pipeline_handler.cpp            |  40 +++\n test/media_device/media_device_link_test.cpp  |   9 +-\n test/media_device/media_device_print_test.cpp |  17 --\n test/media_device/meson.build                 |   1 -\n test/pipeline/ipu3/ipu3_pipeline_test.cpp     |   5 -\n test/v4l2_device/v4l2_device_test.cpp         |   4 -\n test/v4l2_subdevice/v4l2_subdevice_test.cpp   |  16 +-\n 15 files changed, 216 insertions(+), 255 deletions(-)"}