diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/libcamera/base/meson.build | 2 | ||||
-rw-r--r-- | include/libcamera/base/shared_fd.h (renamed from include/libcamera/base/file_descriptor.h) | 22 | ||||
-rw-r--r-- | include/libcamera/framebuffer.h | 4 | ||||
-rw-r--r-- | include/libcamera/internal/ipa_data_serializer.h | 40 | ||||
-rw-r--r-- | include/libcamera/internal/ipc_pipe.h | 8 | ||||
-rw-r--r-- | include/libcamera/internal/v4l2_videodevice.h | 2 | ||||
-rw-r--r-- | include/libcamera/ipa/core.mojom | 6 | ||||
-rw-r--r-- | include/libcamera/ipa/raspberrypi.mojom | 2 |
8 files changed, 43 insertions, 43 deletions
diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build index fce6eaa4..4410aba8 100644 --- a/include/libcamera/base/meson.build +++ b/include/libcamera/base/meson.build @@ -11,7 +11,6 @@ libcamera_base_headers = files([ 'event_dispatcher_poll.h', 'event_notifier.h', 'file.h', - 'file_descriptor.h', 'flags.h', 'log.h', 'message.h', @@ -19,6 +18,7 @@ libcamera_base_headers = files([ 'object.h', 'private.h', 'semaphore.h', + 'shared_fd.h', 'signal.h', 'span.h', 'thread.h', diff --git a/include/libcamera/base/file_descriptor.h b/include/libcamera/base/shared_fd.h index 12a43f95..a786885c 100644 --- a/include/libcamera/base/file_descriptor.h +++ b/include/libcamera/base/shared_fd.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * file_descriptor.h - File descriptor wrapper + * shared_fd.h - File descriptor wrapper with shared ownership */ #pragma once @@ -13,18 +13,18 @@ namespace libcamera { class UniqueFD; -class FileDescriptor final +class SharedFD final { public: - explicit FileDescriptor(const int &fd = -1); - explicit FileDescriptor(int &&fd); - explicit FileDescriptor(UniqueFD fd); - FileDescriptor(const FileDescriptor &other); - FileDescriptor(FileDescriptor &&other); - ~FileDescriptor(); - - FileDescriptor &operator=(const FileDescriptor &other); - FileDescriptor &operator=(FileDescriptor &&other); + explicit SharedFD(const int &fd = -1); + explicit SharedFD(int &&fd); + explicit SharedFD(UniqueFD fd); + SharedFD(const SharedFD &other); + SharedFD(SharedFD &&other); + ~SharedFD(); + + SharedFD &operator=(const SharedFD &other); + SharedFD &operator=(SharedFD &&other); bool isValid() const { return fd_ != nullptr; } int fd() const { return fd_ ? fd_->fd() : -1; } diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 2fbea9c5..357bbe18 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -13,7 +13,7 @@ #include <vector> #include <libcamera/base/class.h> -#include <libcamera/base/file_descriptor.h> +#include <libcamera/base/shared_fd.h> #include <libcamera/base/span.h> namespace libcamera { @@ -51,7 +51,7 @@ class FrameBuffer final : public Extensible public: struct Plane { static constexpr unsigned int kInvalidOffset = std::numeric_limits<unsigned int>::max(); - FileDescriptor fd; + SharedFD fd; unsigned int offset = kInvalidOffset; unsigned int length; }; diff --git a/include/libcamera/internal/ipa_data_serializer.h b/include/libcamera/internal/ipa_data_serializer.h index c2f602d5..a87449c9 100644 --- a/include/libcamera/internal/ipa_data_serializer.h +++ b/include/libcamera/internal/ipa_data_serializer.h @@ -66,7 +66,7 @@ template<typename T> class IPADataSerializer { public: - static std::tuple<std::vector<uint8_t>, std::vector<FileDescriptor>> + static std::tuple<std::vector<uint8_t>, std::vector<SharedFD>> serialize(const T &data, ControlSerializer *cs = nullptr); static T deserialize(const std::vector<uint8_t> &data, @@ -76,12 +76,12 @@ public: ControlSerializer *cs = nullptr); static T deserialize(const std::vector<uint8_t> &data, - const std::vector<FileDescriptor> &fds, + const std::vector<SharedFD> &fds, ControlSerializer *cs = nullptr); static T deserialize(std::vector<uint8_t>::const_iterator dataBegin, std::vector<uint8_t>::const_iterator dataEnd, - std::vector<FileDescriptor>::const_iterator fdsBegin, - std::vector<FileDescriptor>::const_iterator fdsEnd, + std::vector<SharedFD>::const_iterator fdsBegin, + std::vector<SharedFD>::const_iterator fdsEnd, ControlSerializer *cs = nullptr); }; @@ -104,11 +104,11 @@ template<typename V> class IPADataSerializer<std::vector<V>> { public: - static std::tuple<std::vector<uint8_t>, std::vector<FileDescriptor>> + static std::tuple<std::vector<uint8_t>, std::vector<SharedFD>> serialize(const std::vector<V> &data, ControlSerializer *cs = nullptr) { std::vector<uint8_t> dataVec; - std::vector<FileDescriptor> fdsVec; + std::vector<SharedFD> fdsVec; /* Serialize the length. */ uint32_t vecLen = data.size(); @@ -117,7 +117,7 @@ public: /* Serialize the members. */ for (auto const &it : data) { std::vector<uint8_t> dvec; - std::vector<FileDescriptor> fvec; + std::vector<SharedFD> fvec; std::tie(dvec, fvec) = IPADataSerializer<V>::serialize(it, cs); @@ -141,11 +141,11 @@ public: std::vector<uint8_t>::const_iterator dataEnd, ControlSerializer *cs = nullptr) { - std::vector<FileDescriptor> fds; + std::vector<SharedFD> fds; return deserialize(dataBegin, dataEnd, fds.cbegin(), fds.end(), cs); } - static std::vector<V> deserialize(std::vector<uint8_t> &data, std::vector<FileDescriptor> &fds, + static std::vector<V> deserialize(std::vector<uint8_t> &data, std::vector<SharedFD> &fds, ControlSerializer *cs = nullptr) { return deserialize(data.cbegin(), data.end(), fds.cbegin(), fds.end(), cs); @@ -153,15 +153,15 @@ public: static std::vector<V> deserialize(std::vector<uint8_t>::const_iterator dataBegin, std::vector<uint8_t>::const_iterator dataEnd, - std::vector<FileDescriptor>::const_iterator fdsBegin, - [[maybe_unused]] std::vector<FileDescriptor>::const_iterator fdsEnd, + std::vector<SharedFD>::const_iterator fdsBegin, + [[maybe_unused]] std::vector<SharedFD>::const_iterator fdsEnd, ControlSerializer *cs = nullptr) { uint32_t vecLen = readPOD<uint32_t>(dataBegin, 0, dataEnd); std::vector<V> ret(vecLen); std::vector<uint8_t>::const_iterator dataIter = dataBegin + 4; - std::vector<FileDescriptor>::const_iterator fdIter = fdsBegin; + std::vector<SharedFD>::const_iterator fdIter = fdsBegin; for (uint32_t i = 0; i < vecLen; i++) { uint32_t sizeofData = readPOD<uint32_t>(dataIter, 0, dataEnd); uint32_t sizeofFds = readPOD<uint32_t>(dataIter, 4, dataEnd); @@ -201,11 +201,11 @@ template<typename K, typename V> class IPADataSerializer<std::map<K, V>> { public: - static std::tuple<std::vector<uint8_t>, std::vector<FileDescriptor>> + static std::tuple<std::vector<uint8_t>, std::vector<SharedFD>> serialize(const std::map<K, V> &data, ControlSerializer *cs = nullptr) { std::vector<uint8_t> dataVec; - std::vector<FileDescriptor> fdsVec; + std::vector<SharedFD> fdsVec; /* Serialize the length. */ uint32_t mapLen = data.size(); @@ -214,7 +214,7 @@ public: /* Serialize the members. */ for (auto const &it : data) { std::vector<uint8_t> dvec; - std::vector<FileDescriptor> fvec; + std::vector<SharedFD> fvec; std::tie(dvec, fvec) = IPADataSerializer<K>::serialize(it.first, cs); @@ -247,11 +247,11 @@ public: std::vector<uint8_t>::const_iterator dataEnd, ControlSerializer *cs = nullptr) { - std::vector<FileDescriptor> fds; + std::vector<SharedFD> fds; return deserialize(dataBegin, dataEnd, fds.cbegin(), fds.end(), cs); } - static std::map<K, V> deserialize(std::vector<uint8_t> &data, std::vector<FileDescriptor> &fds, + static std::map<K, V> deserialize(std::vector<uint8_t> &data, std::vector<SharedFD> &fds, ControlSerializer *cs = nullptr) { return deserialize(data.cbegin(), data.end(), fds.cbegin(), fds.end(), cs); @@ -259,8 +259,8 @@ public: static std::map<K, V> deserialize(std::vector<uint8_t>::const_iterator dataBegin, std::vector<uint8_t>::const_iterator dataEnd, - std::vector<FileDescriptor>::const_iterator fdsBegin, - [[maybe_unused]] std::vector<FileDescriptor>::const_iterator fdsEnd, + std::vector<SharedFD>::const_iterator fdsBegin, + [[maybe_unused]] std::vector<SharedFD>::const_iterator fdsEnd, ControlSerializer *cs = nullptr) { std::map<K, V> ret; @@ -268,7 +268,7 @@ public: uint32_t mapLen = readPOD<uint32_t>(dataBegin, 0, dataEnd); std::vector<uint8_t>::const_iterator dataIter = dataBegin + 4; - std::vector<FileDescriptor>::const_iterator fdIter = fdsBegin; + std::vector<SharedFD>::const_iterator fdIter = fdsBegin; for (uint32_t i = 0; i < mapLen; i++) { uint32_t sizeofData = readPOD<uint32_t>(dataIter, 0, dataEnd); uint32_t sizeofFds = readPOD<uint32_t>(dataIter, 4, dataEnd); diff --git a/include/libcamera/internal/ipc_pipe.h b/include/libcamera/internal/ipc_pipe.h index 986f8d88..ab5dd67c 100644 --- a/include/libcamera/internal/ipc_pipe.h +++ b/include/libcamera/internal/ipc_pipe.h @@ -9,7 +9,7 @@ #include <vector> -#include <libcamera/base/file_descriptor.h> +#include <libcamera/base/shared_fd.h> #include <libcamera/base/signal.h> #include "libcamera/internal/ipc_unixsocket.h" @@ -33,17 +33,17 @@ public: Header &header() { return header_; } std::vector<uint8_t> &data() { return data_; } - std::vector<FileDescriptor> &fds() { return fds_; } + std::vector<SharedFD> &fds() { return fds_; } const Header &header() const { return header_; } const std::vector<uint8_t> &data() const { return data_; } - const std::vector<FileDescriptor> &fds() const { return fds_; } + const std::vector<SharedFD> &fds() const { return fds_; } private: Header header_; std::vector<uint8_t> data_; - std::vector<FileDescriptor> fds_; + std::vector<SharedFD> fds_; }; class IPCPipe diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index 9f556f99..5ba2b546 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -184,7 +184,7 @@ public: ~V4L2VideoDevice(); int open(); - int open(FileDescriptor handle, enum v4l2_buf_type type); + int open(SharedFD handle, enum v4l2_buf_type type); void close(); const char *driverName() const { return caps_.driver(); } diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom index f7eff0c7..74f3339e 100644 --- a/include/libcamera/ipa/core.mojom +++ b/include/libcamera/ipa/core.mojom @@ -32,7 +32,7 @@ module libcamera; * - This attribute instructs the build system that a (de)serializer is * available for the type and there's no need to generate one * - hasFd - struct fields or empty structs only - * - Designate that this field or empty struct contains a FileDescriptor + * - Designate that this field or empty struct contains a SharedFD * * Rules: * - If the type is defined in a libcamera C++ header *and* a (de)serializer is @@ -60,7 +60,7 @@ module libcamera; * - In mojom, reference the type as FrameBuffer.Plane and only as map/array * member * - [skipHeader] and [skipSerdes] only work here in core.mojom - * - If a field in a struct has a FileDescriptor, but is not explicitly + * - If a field in a struct has a SharedFD, but is not explicitly * defined so in mojom, then the field must be marked with the [hasFd] * attribute * @@ -71,7 +71,7 @@ module libcamera; */ [skipSerdes, skipHeader] struct ControlInfoMap {}; [skipSerdes, skipHeader] struct ControlList {}; -[skipSerdes, skipHeader] struct FileDescriptor {}; +[skipSerdes, skipHeader] struct SharedFD {}; [skipHeader] struct Point { int32 x; diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index e453d46c..acd3cafe 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -35,7 +35,7 @@ struct ISPConfig { struct IPAConfig { uint32 transform; - libcamera.FileDescriptor lsTableHandle; + libcamera.SharedFD lsTableHandle; }; struct StartConfig { |