[libcamera-devel] [PATCH 00/10] libcamera: Introduce Fence support
Jacopo Mondi
jacopo at jmondi.org
Thu Oct 28 13:15:10 CEST 2021
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
--
2.33.1
More information about the libcamera-devel
mailing list