From patchwork Thu Oct 28 11:15:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 14396 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 9D814BF415 for ; Thu, 28 Oct 2021 11:14:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9ABCE600C4; Thu, 28 Oct 2021 13:14:38 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A8DD7600BA for ; Thu, 28 Oct 2021 13:14:36 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 2653DFF804; Thu, 28 Oct 2021 11:14:35 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 13:15:10 +0200 Message-Id: <20211028111520.256612-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 00/10] libcamera: Introduce Fence support 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" Fences are a synchronization mechanism that allows to wait for events on a file descriptor with an optional timeout. So far the only user of synchronization fencs is the Android HAL, for which a dedicated class performs fences wait before queueing the Request to the Camera. This series move handling of fences to libcamera core to allow generic application to attach a synchronization fence to a FrameBuffer. Design principles in the series are: - Fences are passed and retrieved to/from FrameBuffer by their file-descriptor values - Fences are attacched to a FrameBuffer and their value is valid until the Request is queued to the Camera - When a Request completes the fence file descriptor value will read as -1 if the core has handled the fence correctly - If any error occourred waiting on the fence, the fence file descriptor is not closed and its value is available from the file descritpro To realize that an internal Fence class has been introduced and used by the FrameBuffer::Private and Request::Private classes. The pipeline handler receives a Request and handles valid fence in the Request's framebuffers. Once all Fences have been waited on, the Request is finally queued to the device. If any fence has expired or handling it has failed, the Request is cancelled and not queued to the device. Tested on ChromeOS by using CCA (which does not use fences), OpenCamera (which uses fences) and by several runs of CTS whose results are in the order of 2 to 3 failed tests Total Run time: 20m 17s 1/1 modules completed Total Tests : 231 PASSED : 228 FAILED : 3 With a few RecordingTest failures (expected) and some flukes in android.hardware.camera2.cts.SurfaceViewPreviewTest#testSurfaceSet and a capture timeout manifestin randomly in other tests which will be investigated. Thanks j Jacopo Mondi (9): libcamera: event_notifier: Add 'enable' constructor parameter libcamera: Introduce Fence class test: Add test for the Fence class libcamera: request: Add support for fences libcamera: framebuffer: Add synchronization Fence libcamera: pipeline_handler: Split request queueing libcamera: pipeline: Introduce stopDevice() libcamera: pipeline_handler: Handle fences android: Remove CameraWorker Laurent Pinchart (1): libcamera: request: Make Request class Extensible include/libcamera/base/event_notifier.h | 2 +- include/libcamera/framebuffer.h | 5 +- include/libcamera/internal/fence.h | 64 ++++++ include/libcamera/internal/framebuffer.h | 7 +- include/libcamera/internal/meson.build | 2 + include/libcamera/internal/pipeline_handler.h | 12 +- include/libcamera/internal/request.h | 55 ++++++ include/libcamera/request.h | 6 +- src/android/camera_device.cpp | 39 ++-- src/android/camera_device.h | 5 +- src/android/camera_request.cpp | 3 +- src/android/camera_request.h | 3 +- src/android/camera_worker.cpp | 129 ------------ src/android/camera_worker.h | 72 ------- src/android/meson.build | 1 - src/libcamera/base/event_notifier.cpp | 12 +- src/libcamera/fence.cpp | 185 ++++++++++++++++++ src/libcamera/framebuffer.cpp | 46 ++++- src/libcamera/meson.build | 1 + src/libcamera/pipeline/ipu3/ipu3.cpp | 4 +- .../pipeline/raspberrypi/raspberrypi.cpp | 4 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 +- src/libcamera/pipeline/simple/simple.cpp | 4 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 4 +- src/libcamera/pipeline/vimc/vimc.cpp | 4 +- src/libcamera/pipeline_handler.cpp | 141 ++++++++++++- src/libcamera/request.cpp | 137 ++++++++++++- test/fence.cpp | 148 ++++++++++++++ test/meson.build | 1 + 29 files changed, 824 insertions(+), 276 deletions(-) create mode 100644 include/libcamera/internal/fence.h create mode 100644 include/libcamera/internal/request.h delete mode 100644 src/android/camera_worker.cpp delete mode 100644 src/android/camera_worker.h create mode 100644 src/libcamera/fence.cpp create mode 100644 test/fence.cpp Reviewed-by: Kieran Bingham --- 2.33.1