From 8ac8ecb1e12f18891369bb26693bc3a0a7d6ff94 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Mon, 15 Nov 2021 19:01:56 +0100 Subject: libcamera: fence: Introduce Fence Introduce a Fence class which models a synchronization primitive that allows to notify the availability of a resource. The Fence is modeled as a wrapper of a UniqueFD instance where read events are used to signal the Fence. The class can be later extended to support additional signalling mechanisms. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/fence.h | 31 +++++++++++++++++++++++++++++++ include/libcamera/meson.build | 1 + 2 files changed, 32 insertions(+) create mode 100644 include/libcamera/fence.h (limited to 'include') diff --git a/include/libcamera/fence.h b/include/libcamera/fence.h new file mode 100644 index 00000000..c0c916c2 --- /dev/null +++ b/include/libcamera/fence.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Google Inc. + * + * internal/fence.h - Synchronization fence + */ + +#pragma once + +#include +#include + +namespace libcamera { + +class Fence +{ +public: + Fence(UniqueFD fd); + + bool isValid() const { return fd_.isValid(); } + const UniqueFD &fd() const { return fd_; } + + UniqueFD release() { return std::move(fd_); } + +private: + LIBCAMERA_DISABLE_COPY_AND_MOVE(Fence) + + UniqueFD fd_; +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 5f42977c..8c2cae00 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -6,6 +6,7 @@ libcamera_public_headers = files([ 'camera.h', 'camera_manager.h', 'controls.h', + 'fence.h', 'framebuffer.h', 'framebuffer_allocator.h', 'geometry.h', -- cgit v1.2.1