[libcamera-devel] [PATCH v4 00/22] libcamera: Introduce UniqueFD
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Nov 30 04:37:58 CET 2021
Hello,
This patch series is a continuation of Hiro's work on the ScopedFD class
([1]). The class is a std::unique_ptr<>-like wrapper around file
descriptors, which complements the existing shared-ownership
FileDescriptor.
Compared to v2, the main changes are a rename of ScopedFD to UniqueFD,
and to match that, of FileDescriptor to SharedFD, as well as a new unit
test.
Compared to v3, review comments have been take into account, and five
patches have been added:
- Patch 11/22 fixes an fd leak
- Patch 16/22 uses SharedFD in V4L2VideoDevice::open()
- Patch 20/22 improves SharedFD with comparison operators
- Patch 21/22 renames SharedFD::fd() to get() for consistency with
UniqueFD
- Patch 22/22 passes fds by rvalue reference to the UniqueFD constructor
and reset() function
As indicated in patch 22/22, if rvalue references are preferred, the
patch will be squashed with 04/22.
[1] https://patchwork.libcamera.org/project/libcamera/list/?series=2115
Hirokazu Honda (11):
libcamera: base: Introduce UniqueFD
libcamera: base: file_descriptor: Add constructor from UniqueFD
libcamera: event_dispatcher_poll: Manage fd by UniqueFD
libcamera: file: Manage fd by UniqueFD
libcamera: ipc_unixsocket: Use UniqueFD for a file descriptor
libcamera: process: Manage pipe fds by UniqueFD
libcamera: media_device: Manage fd by UniqueFD
libcamera: v4l2_device: Use UniqueFD for a file descriptor
libcamera: v4l2_videodevice: Use fd for a file descriptor
libcamera: pipeline: raspberrypi: DmaHeaps: Use UniqueFD for a file
descriptor
v4l2: v4l2_camera: Return int in getBufferFd()
Laurent Pinchart (11):
libcamera: Move compiler.h to base/
libcamera: Move file_descriptor.h to base/
libcamera: base: file_descriptor: Move inode() function to
frame_buffer.cpp
test: Add UniqueFD test
libcamera: base: file_descriptor: Return UniqueFD from dup()
libcamera: ipc_unixsocket: Fix file descriptor leak
libcamera: v4l2_videodevice: Pass SharedFD to open()
libcamera: base: Rename FileDescriptor to SharedFD
libcamera: base: shared_fd: Add comparison operators
libcamera: base: shared_fd: Rename fd() to get()
libcamera: base: unique_fd: Pass rvalue reference to constructor and
reset()
include/libcamera/{ => base}/compiler.h | 0
.../libcamera/base/event_dispatcher_poll.h | 3 +-
include/libcamera/base/file.h | 7 +-
include/libcamera/base/meson.build | 3 +
include/libcamera/base/shared_fd.h | 59 ++++
include/libcamera/base/unique_fd.h | 70 +++++
include/libcamera/file_descriptor.h | 49 ---
include/libcamera/framebuffer.h | 5 +-
include/libcamera/geometry.h | 2 +-
.../libcamera/internal/ipa_data_serializer.h | 40 +--
include/libcamera/internal/ipc_pipe.h | 9 +-
include/libcamera/internal/ipc_unixsocket.h | 7 +-
include/libcamera/internal/media_device.h | 3 +-
include/libcamera/internal/process.h | 4 +-
include/libcamera/internal/v4l2_device.h | 9 +-
include/libcamera/internal/v4l2_videodevice.h | 8 +-
include/libcamera/ipa/core.mojom | 6 +-
include/libcamera/ipa/raspberrypi.mojom | 2 +-
include/libcamera/meson.build | 2 -
src/android/camera_device.cpp | 2 +-
src/cam/drm.cpp | 4 +-
src/cam/image.cpp | 4 +-
src/gstreamer/gstlibcameraallocator.cpp | 2 +-
src/ipa/raspberrypi/raspberrypi.cpp | 6 +-
src/libcamera/base/event_dispatcher_poll.cpp | 11 +-
src/libcamera/base/file.cpp | 26 +-
src/libcamera/base/meson.build | 2 +
src/libcamera/base/shared_fd.cpp | 288 ++++++++++++++++++
src/libcamera/base/unique_fd.cpp | 129 ++++++++
src/libcamera/file_descriptor.cpp | 272 -----------------
src/libcamera/framebuffer.cpp | 36 ++-
src/libcamera/ipa_data_serializer.cpp | 100 +++---
src/libcamera/ipc_pipe.cpp | 6 +-
src/libcamera/ipc_pipe_unixsocket.cpp | 8 +-
src/libcamera/ipc_unixsocket.cpp | 43 +--
src/libcamera/mapped_framebuffer.cpp | 4 +-
src/libcamera/media_device.cpp | 36 +--
src/libcamera/meson.build | 1 -
.../pipeline/raspberrypi/dma_heaps.cpp | 41 +--
.../pipeline/raspberrypi/dma_heaps.h | 10 +-
.../pipeline/raspberrypi/raspberrypi.cpp | 13 +-
src/libcamera/process.cpp | 16 +-
src/libcamera/v4l2_device.cpp | 23 +-
src/libcamera/v4l2_videodevice.cpp | 65 ++--
src/v4l2/v4l2_camera.cpp | 6 +-
src/v4l2/v4l2_camera.h | 4 +-
src/v4l2/v4l2_camera_proxy.cpp | 6 +-
test/ipc/unixsocket.cpp | 14 +-
test/ipc/unixsocket_ipc.cpp | 8 +-
test/meson.build | 3 +-
.../ipa_data_serializer_test.cpp | 14 +-
test/{file-descriptor.cpp => shared-fd.cpp} | 86 +++---
test/unique-fd.cpp | 222 ++++++++++++++
.../module_ipa_proxy.cpp.tmpl | 2 +-
.../module_ipa_proxy.h.tmpl | 2 +-
.../module_ipa_proxy_worker.cpp.tmpl | 13 +-
.../libcamera_templates/proxy_functions.tmpl | 2 +-
.../libcamera_templates/serializer.tmpl | 22 +-
.../generators/mojom_libcamera_generator.py | 6 +-
59 files changed, 1154 insertions(+), 692 deletions(-)
rename include/libcamera/{ => base}/compiler.h (100%)
create mode 100644 include/libcamera/base/shared_fd.h
create mode 100644 include/libcamera/base/unique_fd.h
delete mode 100644 include/libcamera/file_descriptor.h
create mode 100644 src/libcamera/base/shared_fd.cpp
create mode 100644 src/libcamera/base/unique_fd.cpp
delete mode 100644 src/libcamera/file_descriptor.cpp
rename test/{file-descriptor.cpp => shared-fd.cpp} (65%)
create mode 100644 test/unique-fd.cpp
base-commit: 8178e01b36d767e05d7bbb9dd1f752f7ede0db3d
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list