From 93e72b695e477ac1efc22a0bdddb177199cf2fb9 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 12 May 2020 00:58:34 +0300 Subject: libcamera: Move internal headers to include/libcamera/internal/ The libcamera internal headers are located in src/libcamera/include/. The directory is added to the compiler headers search path with a meson include_directories() directive, and internal headers are included with (e.g. for the internal semaphore.h header) #include "semaphore.h" All was well, until libcxx decided to implement the C++20 synchronization library. The __threading_support header gained a #include to include the pthread's semaphore support. As include_directories() adds src/libcamera/include/ to the compiler search path with -I, the internal semaphore.h is included instead of the pthread version. Needless to say, the compiler isn't happy. Three options have been considered to fix this issue: - Use -iquote instead of -I. The -iquote option instructs gcc to only consider the header search path for headers included with the "" version. Meson unfortunately doesn't support this option. - Rename the internal semaphore.h header. This was deemed to be the beginning of a long whack-a-mole game, where namespace clashes with system libraries would appear over time (possibly dependent on particular system configurations) and would need to be constantly fixed. - Move the internal headers to another directory to create a unique namespace through path components. This causes lots of churn in all the existing source files through the all project. The first option would be best, but isn't available to us due to missing support in meson. Even if -iquote support was added, we would need to fix the problem before a new version of meson containing the required support would be released. The third option is thus the only practical solution available. Bite the bullet, and do it, moving headers to include/libcamera/internal/. Signed-off-by: Laurent Pinchart Acked-by: Jacopo Mondi --- Documentation/Doxyfile.in | 6 +- include/libcamera/internal/byte_stream_buffer.h | 89 +++++++ include/libcamera/internal/camera_controls.h | 30 +++ include/libcamera/internal/camera_sensor.h | 88 +++++++ include/libcamera/internal/control_serializer.h | 55 ++++ include/libcamera/internal/control_validator.h | 27 ++ include/libcamera/internal/device_enumerator.h | 57 +++++ .../libcamera/internal/device_enumerator_sysfs.h | 32 +++ .../libcamera/internal/device_enumerator_udev.h | 75 ++++++ include/libcamera/internal/event_dispatcher_poll.h | 58 +++++ include/libcamera/internal/file.h | 71 ++++++ include/libcamera/internal/formats.h | 58 +++++ include/libcamera/internal/ipa_context_wrapper.h | 50 ++++ include/libcamera/internal/ipa_manager.h | 51 ++++ include/libcamera/internal/ipa_module.h | 61 +++++ include/libcamera/internal/ipa_proxy.h | 70 ++++++ include/libcamera/internal/ipc_unixsocket.h | 59 +++++ include/libcamera/internal/log.h | 130 ++++++++++ include/libcamera/internal/media_device.h | 94 +++++++ include/libcamera/internal/media_object.h | 124 +++++++++ include/libcamera/internal/meson.build | 35 +++ include/libcamera/internal/message.h | 70 ++++++ include/libcamera/internal/pipeline_handler.h | 151 +++++++++++ include/libcamera/internal/process.h | 55 ++++ include/libcamera/internal/pub_key.h | 38 +++ include/libcamera/internal/semaphore.h | 34 +++ include/libcamera/internal/thread.h | 77 ++++++ include/libcamera/internal/utils.h | 197 +++++++++++++++ include/libcamera/internal/v4l2_controls.h | 31 +++ include/libcamera/internal/v4l2_device.h | 60 +++++ include/libcamera/internal/v4l2_pixelformat.h | 49 ++++ include/libcamera/internal/v4l2_subdevice.h | 77 ++++++ include/libcamera/internal/v4l2_videodevice.h | 277 +++++++++++++++++++++ include/libcamera/meson.build | 2 + src/android/camera3_hal.cpp | 3 +- src/android/camera_device.cpp | 4 +- src/android/camera_device.h | 2 +- src/android/camera_hal_manager.cpp | 2 +- src/android/camera_metadata.cpp | 2 +- src/ipa/libipa/ipa_interface_wrapper.cpp | 4 +- src/ipa/libipa/ipa_interface_wrapper.h | 2 +- src/ipa/meson.build | 1 - src/ipa/raspberrypi/cam_helper.cpp | 4 +- src/ipa/raspberrypi/cam_helper.hpp | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 8 +- src/ipa/rkisp1/rkisp1.cpp | 4 +- src/ipa/vimc/vimc.cpp | 4 +- src/libcamera/bound_method.cpp | 6 +- src/libcamera/buffer.cpp | 2 +- src/libcamera/byte_stream_buffer.cpp | 4 +- src/libcamera/camera.cpp | 6 +- src/libcamera/camera_controls.cpp | 2 +- src/libcamera/camera_manager.cpp | 12 +- src/libcamera/camera_sensor.cpp | 8 +- src/libcamera/control_serializer.cpp | 6 +- src/libcamera/control_validator.cpp | 2 +- src/libcamera/controls.cpp | 6 +- src/libcamera/device_enumerator.cpp | 10 +- src/libcamera/device_enumerator_sysfs.cpp | 6 +- src/libcamera/device_enumerator_udev.cpp | 6 +- src/libcamera/event_dispatcher.cpp | 2 +- src/libcamera/event_dispatcher_poll.cpp | 8 +- src/libcamera/event_notifier.cpp | 4 +- src/libcamera/file.cpp | 4 +- src/libcamera/file_descriptor.cpp | 2 +- src/libcamera/formats.cpp | 4 +- src/libcamera/framebuffer_allocator.cpp | 4 +- src/libcamera/include/byte_stream_buffer.h | 89 ------- src/libcamera/include/camera_controls.h | 30 --- src/libcamera/include/camera_sensor.h | 88 ------- src/libcamera/include/control_serializer.h | 55 ---- src/libcamera/include/control_validator.h | 27 -- src/libcamera/include/device_enumerator.h | 57 ----- src/libcamera/include/device_enumerator_sysfs.h | 32 --- src/libcamera/include/device_enumerator_udev.h | 75 ------ src/libcamera/include/event_dispatcher_poll.h | 58 ----- src/libcamera/include/file.h | 71 ------ src/libcamera/include/formats.h | 58 ----- src/libcamera/include/ipa_context_wrapper.h | 50 ---- src/libcamera/include/ipa_manager.h | 51 ---- src/libcamera/include/ipa_module.h | 61 ----- src/libcamera/include/ipa_proxy.h | 70 ------ src/libcamera/include/ipc_unixsocket.h | 59 ----- src/libcamera/include/log.h | 130 ---------- src/libcamera/include/media_device.h | 94 ------- src/libcamera/include/media_object.h | 124 --------- src/libcamera/include/meson.build | 35 --- src/libcamera/include/message.h | 70 ------ src/libcamera/include/pipeline_handler.h | 151 ----------- src/libcamera/include/process.h | 55 ---- src/libcamera/include/pub_key.h | 38 --- src/libcamera/include/semaphore.h | 34 --- src/libcamera/include/thread.h | 77 ------ src/libcamera/include/utils.h | 197 --------------- src/libcamera/include/v4l2_controls.h | 31 --- src/libcamera/include/v4l2_device.h | 60 ----- src/libcamera/include/v4l2_pixelformat.h | 49 ---- src/libcamera/include/v4l2_subdevice.h | 77 ------ src/libcamera/include/v4l2_videodevice.h | 277 --------------------- src/libcamera/ipa_context_wrapper.cpp | 8 +- src/libcamera/ipa_manager.cpp | 14 +- src/libcamera/ipa_module.cpp | 10 +- src/libcamera/ipa_proxy.cpp | 8 +- src/libcamera/ipa_pub_key.cpp.in | 2 +- src/libcamera/ipc_unixsocket.cpp | 4 +- src/libcamera/log.cpp | 6 +- src/libcamera/media_device.cpp | 4 +- src/libcamera/media_object.cpp | 6 +- src/libcamera/meson.build | 5 - src/libcamera/message.cpp | 4 +- src/libcamera/object.cpp | 10 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 18 +- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 17 +- .../pipeline/raspberrypi/staggered_ctrl.cpp | 6 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 19 +- src/libcamera/pipeline/rkisp1/timeline.cpp | 2 +- src/libcamera/pipeline/rkisp1/timeline.h | 2 +- src/libcamera/pipeline/simple/converter.cpp | 6 +- src/libcamera/pipeline/simple/simple.cpp | 14 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 14 +- src/libcamera/pipeline/vimc/vimc.cpp | 20 +- src/libcamera/pipeline_handler.cpp | 10 +- src/libcamera/process.cpp | 6 +- src/libcamera/proxy/ipa_proxy_linux.cpp | 10 +- src/libcamera/proxy/ipa_proxy_thread.cpp | 10 +- .../proxy/worker/ipa_proxy_linux_worker.cpp | 8 +- src/libcamera/proxy/worker/meson.build | 1 - src/libcamera/pub_key.cpp | 2 +- src/libcamera/request.cpp | 4 +- src/libcamera/semaphore.cpp | 4 +- src/libcamera/signal.cpp | 2 +- src/libcamera/stream.cpp | 4 +- src/libcamera/thread.cpp | 8 +- src/libcamera/timer.cpp | 8 +- src/libcamera/utils.cpp | 2 +- src/libcamera/v4l2_controls.cpp | 2 +- src/libcamera/v4l2_device.cpp | 8 +- src/libcamera/v4l2_pixelformat.cpp | 6 +- src/libcamera/v4l2_subdevice.cpp | 10 +- src/libcamera/v4l2_videodevice.cpp | 10 +- src/v4l2/meson.build | 1 - src/v4l2/v4l2_camera.cpp | 2 +- src/v4l2/v4l2_camera.h | 2 +- src/v4l2/v4l2_camera_proxy.cpp | 5 +- src/v4l2/v4l2_compat_manager.cpp | 2 +- test/byte-stream-buffer.cpp | 3 +- test/camera-sensor.cpp | 10 +- test/camera/buffer_import.cpp | 6 +- test/controls/control_info_map.cpp | 2 +- test/controls/control_list.cpp | 2 +- test/event-dispatcher.cpp | 3 +- test/event-thread.cpp | 3 +- test/event.cpp | 3 +- test/file-descriptor.cpp | 3 +- test/file.cpp | 3 +- test/ipa/ipa_interface_test.cpp | 11 +- test/ipa/ipa_module_test.cpp | 2 +- test/ipa/ipa_wrappers_test.cpp | 10 +- test/ipc/unixsocket.cpp | 7 +- test/libtest/buffer_source.cpp | 2 +- test/libtest/buffer_source.h | 4 +- test/libtest/meson.build | 1 - test/log/log_api.cpp | 3 +- test/log/log_process.cpp | 9 +- test/media_device/media_device_print_test.cpp | 2 +- test/media_device/media_device_test.h | 4 +- test/message.cpp | 5 +- test/object-invoke.cpp | 3 +- test/object.cpp | 4 +- test/pipeline/ipu3/ipu3_pipeline_test.cpp | 7 +- test/pipeline/rkisp1/rkisp1_pipeline_test.cpp | 7 +- test/process/process_test.cpp | 7 +- test/serialization/control_serialization.cpp | 5 +- test/signal-threads.cpp | 7 +- test/threads.cpp | 3 +- test/timer-thread.cpp | 3 +- test/timer.cpp | 3 +- test/utils.cpp | 3 +- test/v4l2_subdevice/list_formats.cpp | 3 +- test/v4l2_subdevice/test_formats.cpp | 3 +- test/v4l2_subdevice/v4l2_subdevice_test.cpp | 7 +- test/v4l2_subdevice/v4l2_subdevice_test.h | 7 +- test/v4l2_videodevice/buffer_sharing.cpp | 3 +- test/v4l2_videodevice/capture_async.cpp | 3 +- test/v4l2_videodevice/controls.cpp | 2 +- test/v4l2_videodevice/formats.cpp | 4 +- test/v4l2_videodevice/v4l2_m2mdevice.cpp | 8 +- test/v4l2_videodevice/v4l2_videodevice_test.cpp | 6 +- test/v4l2_videodevice/v4l2_videodevice_test.h | 12 +- 189 files changed, 2786 insertions(+), 2762 deletions(-) create mode 100644 include/libcamera/internal/byte_stream_buffer.h create mode 100644 include/libcamera/internal/camera_controls.h create mode 100644 include/libcamera/internal/camera_sensor.h create mode 100644 include/libcamera/internal/control_serializer.h create mode 100644 include/libcamera/internal/control_validator.h create mode 100644 include/libcamera/internal/device_enumerator.h create mode 100644 include/libcamera/internal/device_enumerator_sysfs.h create mode 100644 include/libcamera/internal/device_enumerator_udev.h create mode 100644 include/libcamera/internal/event_dispatcher_poll.h create mode 100644 include/libcamera/internal/file.h create mode 100644 include/libcamera/internal/formats.h create mode 100644 include/libcamera/internal/ipa_context_wrapper.h create mode 100644 include/libcamera/internal/ipa_manager.h create mode 100644 include/libcamera/internal/ipa_module.h create mode 100644 include/libcamera/internal/ipa_proxy.h create mode 100644 include/libcamera/internal/ipc_unixsocket.h create mode 100644 include/libcamera/internal/log.h create mode 100644 include/libcamera/internal/media_device.h create mode 100644 include/libcamera/internal/media_object.h create mode 100644 include/libcamera/internal/meson.build create mode 100644 include/libcamera/internal/message.h create mode 100644 include/libcamera/internal/pipeline_handler.h create mode 100644 include/libcamera/internal/process.h create mode 100644 include/libcamera/internal/pub_key.h create mode 100644 include/libcamera/internal/semaphore.h create mode 100644 include/libcamera/internal/thread.h create mode 100644 include/libcamera/internal/utils.h create mode 100644 include/libcamera/internal/v4l2_controls.h create mode 100644 include/libcamera/internal/v4l2_device.h create mode 100644 include/libcamera/internal/v4l2_pixelformat.h create mode 100644 include/libcamera/internal/v4l2_subdevice.h create mode 100644 include/libcamera/internal/v4l2_videodevice.h delete mode 100644 src/libcamera/include/byte_stream_buffer.h delete mode 100644 src/libcamera/include/camera_controls.h delete mode 100644 src/libcamera/include/camera_sensor.h delete mode 100644 src/libcamera/include/control_serializer.h delete mode 100644 src/libcamera/include/control_validator.h delete mode 100644 src/libcamera/include/device_enumerator.h delete mode 100644 src/libcamera/include/device_enumerator_sysfs.h delete mode 100644 src/libcamera/include/device_enumerator_udev.h delete mode 100644 src/libcamera/include/event_dispatcher_poll.h delete mode 100644 src/libcamera/include/file.h delete mode 100644 src/libcamera/include/formats.h delete mode 100644 src/libcamera/include/ipa_context_wrapper.h delete mode 100644 src/libcamera/include/ipa_manager.h delete mode 100644 src/libcamera/include/ipa_module.h delete mode 100644 src/libcamera/include/ipa_proxy.h delete mode 100644 src/libcamera/include/ipc_unixsocket.h delete mode 100644 src/libcamera/include/log.h delete mode 100644 src/libcamera/include/media_device.h delete mode 100644 src/libcamera/include/media_object.h delete mode 100644 src/libcamera/include/meson.build delete mode 100644 src/libcamera/include/message.h delete mode 100644 src/libcamera/include/pipeline_handler.h delete mode 100644 src/libcamera/include/process.h delete mode 100644 src/libcamera/include/pub_key.h delete mode 100644 src/libcamera/include/semaphore.h delete mode 100644 src/libcamera/include/thread.h delete mode 100644 src/libcamera/include/utils.h delete mode 100644 src/libcamera/include/v4l2_controls.h delete mode 100644 src/libcamera/include/v4l2_device.h delete mode 100644 src/libcamera/include/v4l2_pixelformat.h delete mode 100644 src/libcamera/include/v4l2_subdevice.h delete mode 100644 src/libcamera/include/v4l2_videodevice.h diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in index 86bcc4d0..c3fe5f66 100644 --- a/Documentation/Doxyfile.in +++ b/Documentation/Doxyfile.in @@ -842,10 +842,10 @@ RECURSIVE = YES # run. EXCLUDE = @TOP_SRCDIR@/include/libcamera/span.h \ + @TOP_SRCDIR@/include/libcamera/internal/device_enumerator_sysfs.h \ + @TOP_SRCDIR@/include/libcamera/internal/device_enumerator_udev.h \ @TOP_SRCDIR@/src/libcamera/device_enumerator_sysfs.cpp \ @TOP_SRCDIR@/src/libcamera/device_enumerator_udev.cpp \ - @TOP_SRCDIR@/src/libcamera/include/device_enumerator_sysfs.h \ - @TOP_SRCDIR@/src/libcamera/include/device_enumerator_udev.h \ @TOP_SRCDIR@/src/libcamera/pipeline/ \ @TOP_SRCDIR@/src/libcamera/proxy/ @@ -2053,7 +2053,7 @@ SEARCH_INCLUDES = YES # preprocessor. # This tag requires that the tag SEARCH_INCLUDES is set to YES. -INCLUDE_PATH = "@TOP_SRCDIR@/include/libcamera" "@TOP_SRCDIR@/src/libcamera/include" +INCLUDE_PATH = "@TOP_SRCDIR@/include/libcamera" # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the diff --git a/include/libcamera/internal/byte_stream_buffer.h b/include/libcamera/internal/byte_stream_buffer.h new file mode 100644 index 00000000..b3aaa8b9 --- /dev/null +++ b/include/libcamera/internal/byte_stream_buffer.h @@ -0,0 +1,89 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * byte_stream_buffer.h - Byte stream buffer + */ +#ifndef __LIBCAMERA_BYTE_STREAM_BUFFER_H__ +#define __LIBCAMERA_BYTE_STREAM_BUFFER_H__ + +#include +#include +#include + +#include + +namespace libcamera { + +class ByteStreamBuffer +{ +public: + ByteStreamBuffer(const uint8_t *base, size_t size); + ByteStreamBuffer(uint8_t *base, size_t size); + ByteStreamBuffer(ByteStreamBuffer &&other); + ByteStreamBuffer &operator=(ByteStreamBuffer &&other); + + const uint8_t *base() const { return base_; } + uint32_t offset() const { return (write_ ? write_ : read_) - base_; } + size_t size() const { return size_; } + bool overflow() const { return overflow_; } + + ByteStreamBuffer carveOut(size_t size); + int skip(size_t size); + + template + int read(T *t) + { + return read(reinterpret_cast(t), sizeof(*t)); + } + + template + int read(const Span &data) + { + return read(reinterpret_cast(data.data()), + data.size_bytes()); + } + + template + const std::remove_reference_t *read(size_t count = 1) + { + using return_type = const std::remove_reference_t *; + return reinterpret_cast(read(sizeof(T), count)); + } + + template + int write(const T *t) + { + return write(reinterpret_cast(t), sizeof(*t)); + } + + template + int write(const Span &data) + { + return write(reinterpret_cast(data.data()), + data.size_bytes()); + } + +private: + ByteStreamBuffer(const ByteStreamBuffer &other) = delete; + ByteStreamBuffer &operator=(const ByteStreamBuffer &other) = delete; + + void setOverflow(); + + int read(uint8_t *data, size_t size); + const uint8_t *read(size_t size, size_t count); + int write(const uint8_t *data, size_t size); + + ByteStreamBuffer *parent_; + + const uint8_t *base_; + size_t size_; + bool overflow_; + + const uint8_t *read_; + uint8_t *write_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_BYTE_STREAM_BUFFER_H__ */ diff --git a/include/libcamera/internal/camera_controls.h b/include/libcamera/internal/camera_controls.h new file mode 100644 index 00000000..dc8b3ba8 --- /dev/null +++ b/include/libcamera/internal/camera_controls.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * camera_controls.h - Camera controls + */ +#ifndef __LIBCAMERA_CAMERA_CONTROLS_H__ +#define __LIBCAMERA_CAMERA_CONTROLS_H__ + +#include "libcamera/internal/control_validator.h" + +namespace libcamera { + +class Camera; + +class CameraControlValidator final : public ControlValidator +{ +public: + CameraControlValidator(Camera *camera); + + const std::string &name() const override; + bool validate(unsigned int id) const override; + +private: + Camera *camera_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_CAMERA_CONTROLS_H__ */ diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h new file mode 100644 index 00000000..d79bd9ce --- /dev/null +++ b/include/libcamera/internal/camera_sensor.h @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * camera_sensor.h - A camera sensor + */ +#ifndef __LIBCAMERA_CAMERA_SENSOR_H__ +#define __LIBCAMERA_CAMERA_SENSOR_H__ + +#include +#include +#include + +#include +#include + +#include "libcamera/internal/formats.h" +#include "libcamera/internal/log.h" + +namespace libcamera { + +class MediaEntity; +class V4L2Subdevice; + +struct V4L2SubdeviceFormat; + +struct CameraSensorInfo { + std::string model; + + uint32_t bitsPerPixel; + + Size activeAreaSize; + Rectangle analogCrop; + Size outputSize; + + uint64_t pixelRate; + uint32_t lineLength; +}; + +class CameraSensor : protected Loggable +{ +public: + explicit CameraSensor(const MediaEntity *entity); + ~CameraSensor(); + + CameraSensor(const CameraSensor &) = delete; + CameraSensor &operator=(const CameraSensor &) = delete; + + int init(); + + const std::string &model() const { return model_; } + const MediaEntity *entity() const { return entity_; } + const std::vector &mbusCodes() const { return mbusCodes_; } + const std::vector &sizes() const { return sizes_; } + const Size &resolution() const { return resolution_; } + + V4L2SubdeviceFormat getFormat(const std::vector &mbusCodes, + const Size &size) const; + int setFormat(V4L2SubdeviceFormat *format); + + const ControlInfoMap &controls() const; + ControlList getControls(const std::vector &ids); + int setControls(ControlList *ctrls); + + const ControlList &properties() const { return properties_; } + int sensorInfo(CameraSensorInfo *info) const; + +protected: + std::string logPrefix() const; + +private: + const MediaEntity *entity_; + std::unique_ptr subdev_; + unsigned int pad_; + + std::string model_; + + ImageFormats formats_; + Size resolution_; + std::vector mbusCodes_; + std::vector sizes_; + + ControlList properties_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_CAMERA_SENSOR_H__ */ diff --git a/include/libcamera/internal/control_serializer.h b/include/libcamera/internal/control_serializer.h new file mode 100644 index 00000000..99bacd92 --- /dev/null +++ b/include/libcamera/internal/control_serializer.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * control_serializer.h - Control (de)serializer + */ +#ifndef __LIBCAMERA_CONTROL_SERIALIZER_H__ +#define __LIBCAMERA_CONTROL_SERIALIZER_H__ + +#include +#include +#include + +#include + +namespace libcamera { + +class ByteStreamBuffer; + +class ControlSerializer +{ +public: + ControlSerializer(); + + void reset(); + + static size_t binarySize(const ControlInfoMap &infoMap); + static size_t binarySize(const ControlList &list); + + int serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer); + int serialize(const ControlList &list, ByteStreamBuffer &buffer); + + template + T deserialize(ByteStreamBuffer &buffer); + +private: + static size_t binarySize(const ControlValue &value); + static size_t binarySize(const ControlInfo &info); + + static void store(const ControlValue &value, ByteStreamBuffer &buffer); + static void store(const ControlInfo &info, ByteStreamBuffer &buffer); + + ControlValue loadControlValue(ControlType type, ByteStreamBuffer &buffer, + bool isArray = false, unsigned int count = 1); + ControlInfo loadControlInfo(ControlType type, ByteStreamBuffer &buffer); + + unsigned int serial_; + std::vector> controlIds_; + std::map infoMaps_; + std::map infoMapHandles_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_CONTROL_SERIALIZER_H__ */ diff --git a/include/libcamera/internal/control_validator.h b/include/libcamera/internal/control_validator.h new file mode 100644 index 00000000..f1c9110b --- /dev/null +++ b/include/libcamera/internal/control_validator.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * control_validator.h - Control validator + */ +#ifndef __LIBCAMERA_CONTROL_VALIDATOR_H__ +#define __LIBCAMERA_CONTROL_VALIDATOR_H__ + +#include + +namespace libcamera { + +class ControlId; + +class ControlValidator +{ +public: + virtual ~ControlValidator() {} + + virtual const std::string &name() const = 0; + virtual bool validate(unsigned int id) const = 0; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_CONTROL_VALIDATOR_H__ */ diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h new file mode 100644 index 00000000..433e357a --- /dev/null +++ b/include/libcamera/internal/device_enumerator.h @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2018, Google Inc. + * + * device_enumerator.h - API to enumerate and find media devices + */ +#ifndef __LIBCAMERA_DEVICE_ENUMERATOR_H__ +#define __LIBCAMERA_DEVICE_ENUMERATOR_H__ + +#include +#include +#include + +#include + +namespace libcamera { + +class MediaDevice; + +class DeviceMatch +{ +public: + DeviceMatch(const std::string &driver); + + void add(const std::string &entity); + + bool match(const MediaDevice *device) const; + +private: + std::string driver_; + std::vector entities_; +}; + +class DeviceEnumerator +{ +public: + static std::unique_ptr create(); + + virtual ~DeviceEnumerator(); + + virtual int init() = 0; + virtual int enumerate() = 0; + + std::shared_ptr search(const DeviceMatch &dm); + +protected: + std::unique_ptr createDevice(const std::string &deviceNode); + void addDevice(std::unique_ptr &&media); + void removeDevice(const std::string &deviceNode); + +private: + std::vector> devices_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_DEVICE_ENUMERATOR_H__ */ diff --git a/include/libcamera/internal/device_enumerator_sysfs.h b/include/libcamera/internal/device_enumerator_sysfs.h new file mode 100644 index 00000000..a63e737a --- /dev/null +++ b/include/libcamera/internal/device_enumerator_sysfs.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * device_enumerator_sysfs.h - sysfs-based device enumerator + */ +#ifndef __LIBCAMERA_DEVICE_ENUMERATOR_SYSFS_H__ +#define __LIBCAMERA_DEVICE_ENUMERATOR_SYSFS_H__ + +#include +#include + +#include "libcamera/internal/device_enumerator.h" + +class MediaDevice; + +namespace libcamera { + +class DeviceEnumeratorSysfs final : public DeviceEnumerator +{ +public: + int init(); + int enumerate(); + +private: + int populateMediaDevice(MediaDevice *media); + std::string lookupDeviceNode(int major, int minor); +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_DEVICE_ENUMERATOR_SYSFS_H__ */ diff --git a/include/libcamera/internal/device_enumerator_udev.h b/include/libcamera/internal/device_enumerator_udev.h new file mode 100644 index 00000000..fdaa2096 --- /dev/null +++ b/include/libcamera/internal/device_enumerator_udev.h @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2018-2019, Google Inc. + * + * device_enumerator_udev.h - udev-based device enumerator + */ +#ifndef __LIBCAMERA_DEVICE_ENUMERATOR_UDEV_H__ +#define __LIBCAMERA_DEVICE_ENUMERATOR_UDEV_H__ + +#include +#include +#include +#include +#include +#include + +#include "libcamera/internal/device_enumerator.h" + +struct udev; +struct udev_device; +struct udev_monitor; + +namespace libcamera { + +class EventNotifier; +class MediaDevice; +class MediaEntity; + +class DeviceEnumeratorUdev : public DeviceEnumerator +{ +public: + DeviceEnumeratorUdev(); + ~DeviceEnumeratorUdev(); + + int init() final; + int enumerate() final; + +private: + struct udev *udev_; + struct udev_monitor *monitor_; + EventNotifier *notifier_; + + using DependencyMap = std::map>; + + struct MediaDeviceDeps { + MediaDeviceDeps(std::unique_ptr &&media, + DependencyMap &&deps) + : media_(std::move(media)), deps_(std::move(deps)) + { + } + + bool operator==(const MediaDeviceDeps &other) const + { + return media_ == other.media_; + } + + std::unique_ptr media_; + DependencyMap deps_; + }; + + std::set orphans_; + std::list pending_; + std::map devMap_; + + int addUdevDevice(struct udev_device *dev); + int populateMediaDevice(MediaDevice *media, DependencyMap *deps); + std::string lookupDeviceNode(dev_t devnum); + + int addV4L2Device(dev_t devnum); + void udevNotify(EventNotifier *notifier); +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_DEVICE_ENUMERATOR_UDEV_H__ */ diff --git a/include/libcamera/internal/event_dispatcher_poll.h b/include/libcamera/internal/event_dispatcher_poll.h new file mode 100644 index 00000000..1f073861 --- /dev/null +++ b/include/libcamera/internal/event_dispatcher_poll.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * event_dispatcher_poll.h - Poll-based event dispatcher + */ +#ifndef __LIBCAMERA_EVENT_DISPATCHER_POLL_H__ +#define __LIBCAMERA_EVENT_DISPATCHER_POLL_H__ + +#include +#include +#include + +#include + +struct pollfd; + +namespace libcamera { + +class EventNotifier; +class Timer; + +class EventDispatcherPoll final : public EventDispatcher +{ +public: + EventDispatcherPoll(); + ~EventDispatcherPoll(); + + void registerEventNotifier(EventNotifier *notifier); + void unregisterEventNotifier(EventNotifier *notifier); + + void registerTimer(Timer *timer); + void unregisterTimer(Timer *timer); + + void processEvents(); + void interrupt(); + +private: + struct EventNotifierSetPoll { + short events() const; + EventNotifier *notifiers[3]; + }; + + std::map notifiers_; + std::list timers_; + int eventfd_; + + bool processingEvents_; + + int poll(std::vector *pollfds); + void processInterrupt(const struct pollfd &pfd); + void processNotifiers(const std::vector &pollfds); + void processTimers(); +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_EVENT_DISPATCHER_POLL_H__ */ diff --git a/include/libcamera/internal/file.h b/include/libcamera/internal/file.h new file mode 100644 index 00000000..f020f2cc --- /dev/null +++ b/include/libcamera/internal/file.h @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2020, Google Inc. + * + * file.h - File I/O operations + */ +#ifndef __LIBCAMERA_FILE_H__ +#define __LIBCAMERA_FILE_H__ + +#include +#include +#include + +#include + +namespace libcamera { + +class File +{ +public: + enum MapFlag { + MapNoOption = 0, + MapPrivate = (1 << 0), + }; + + enum OpenMode { + NotOpen = 0, + ReadOnly = (1 << 0), + WriteOnly = (1 << 1), + ReadWrite = ReadOnly | WriteOnly, + }; + + File(const std::string &name); + File(); + ~File(); + + File(const File &) = delete; + File &operator=(const File &) = delete; + + const std::string &fileName() const { return name_; } + void setFileName(const std::string &name); + bool exists() const; + + bool open(OpenMode mode); + bool isOpen() const { return fd_ != -1; } + OpenMode openMode() const { return mode_; } + void close(); + + int error() const { return error_; } + ssize_t size() const; + + Span map(off_t offset = 0, ssize_t size = -1, + MapFlag flags = MapNoOption); + bool unmap(uint8_t *addr); + + static bool exists(const std::string &name); + +private: + void unmapAll(); + + std::string name_; + int fd_; + OpenMode mode_; + + int error_; + std::map maps_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_FILE_H__ */ diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h new file mode 100644 index 00000000..4092a93e --- /dev/null +++ b/include/libcamera/internal/formats.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * formats.h - libcamera image formats + */ + +#ifndef __LIBCAMERA_FORMATS_H__ +#define __LIBCAMERA_FORMATS_H__ + +#include +#include + +#include +#include + +#include "libcamera/internal/v4l2_pixelformat.h" + +namespace libcamera { + +class ImageFormats +{ +public: + int addFormat(unsigned int format, const std::vector &sizes); + + bool isEmpty() const; + std::vector formats() const; + const std::vector &sizes(unsigned int format) const; + const std::map> &data() const; + +private: + std::map> data_; +}; + +class PixelFormatInfo +{ +public: + enum ColourEncoding { + ColourEncodingRGB, + ColourEncodingYUV, + ColourEncodingRAW, + }; + + bool isValid() const { return format.isValid(); } + + static const PixelFormatInfo &info(const PixelFormat &format); + + /* \todo Add support for non-contiguous memory planes */ + PixelFormat format; + V4L2PixelFormat v4l2Format; + unsigned int bitsPerPixel; + enum ColourEncoding colourEncoding; + bool packed; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_FORMATS_H__ */ diff --git a/include/libcamera/internal/ipa_context_wrapper.h b/include/libcamera/internal/ipa_context_wrapper.h new file mode 100644 index 00000000..a717d406 --- /dev/null +++ b/include/libcamera/internal/ipa_context_wrapper.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_context_wrapper.h - Image Processing Algorithm context wrapper + */ +#ifndef __LIBCAMERA_IPA_CONTEXT_WRAPPER_H__ +#define __LIBCAMERA_IPA_CONTEXT_WRAPPER_H__ + +#include + +#include "libcamera/internal/control_serializer.h" + +namespace libcamera { + +class IPAContextWrapper final : public IPAInterface +{ +public: + IPAContextWrapper(struct ipa_context *context); + ~IPAContextWrapper(); + + int init(const IPASettings &settings) override; + int start() override; + void stop() override; + void configure(const CameraSensorInfo &sensorInfo, + const std::map &streamConfig, + const std::map &entityControls) override; + + void mapBuffers(const std::vector &buffers) override; + void unmapBuffers(const std::vector &ids) override; + + virtual void processEvent(const IPAOperationData &data) override; + +private: + static void queue_frame_action(void *ctx, unsigned int frame, + struct ipa_operation_data &data); + static const struct ipa_callback_ops callbacks_; + + void doQueueFrameAction(unsigned int frame, + const IPAOperationData &data); + + struct ipa_context *ctx_; + IPAInterface *intf_; + + ControlSerializer serializer_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPA_CONTEXT_WRAPPER_H__ */ diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h new file mode 100644 index 00000000..f07d91fc --- /dev/null +++ b/include/libcamera/internal/ipa_manager.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_manager.h - Image Processing Algorithm module manager + */ +#ifndef __LIBCAMERA_IPA_MANAGER_H__ +#define __LIBCAMERA_IPA_MANAGER_H__ + +#include +#include + +#include +#include + +#include "libcamera/internal/ipa_module.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/pub_key.h" + +namespace libcamera { + +class IPAManager +{ +public: + static IPAManager *instance(); + + std::unique_ptr createIPA(PipelineHandler *pipe, + uint32_t maxVersion, + uint32_t minVersion); + +private: + std::vector modules_; + + IPAManager(); + ~IPAManager(); + + void parseDir(const char *libDir, unsigned int maxDepth, + std::vector &files); + unsigned int addDir(const char *libDir, unsigned int maxDepth = 0); + + bool isSignatureValid(IPAModule *ipa) const; + +#if HAVE_IPA_PUBKEY + static const uint8_t publicKeyData_[]; + static const PubKey pubKey_; +#endif +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPA_MANAGER_H__ */ diff --git a/include/libcamera/internal/ipa_module.h b/include/libcamera/internal/ipa_module.h new file mode 100644 index 00000000..2f569db0 --- /dev/null +++ b/include/libcamera/internal/ipa_module.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_module.h - Image Processing Algorithm module + */ +#ifndef __LIBCAMERA_IPA_MODULE_H__ +#define __LIBCAMERA_IPA_MODULE_H__ + +#include +#include +#include + +#include +#include + +#include "libcamera/internal/log.h" +#include "libcamera/internal/pipeline_handler.h" + +namespace libcamera { + +class IPAModule : public Loggable +{ +public: + explicit IPAModule(const std::string &libPath); + ~IPAModule(); + + bool isValid() const; + + const struct IPAModuleInfo &info() const; + const std::vector signature() const; + const std::string &path() const; + + bool load(); + + struct ipa_context *createContext(); + + bool match(PipelineHandler *pipe, + uint32_t minVersion, uint32_t maxVersion) const; + +protected: + std::string logPrefix() const override; + +private: + struct IPAModuleInfo info_; + std::vector signature_; + + std::string libPath_; + bool valid_; + bool loaded_; + + void *dlHandle_; + typedef struct ipa_context *(*IPAIntfFactory)(void); + IPAIntfFactory ipaCreate_; + + int loadIPAModuleInfo(); +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPA_MODULE_H__ */ diff --git a/include/libcamera/internal/ipa_proxy.h b/include/libcamera/internal/ipa_proxy.h new file mode 100644 index 00000000..1111065b --- /dev/null +++ b/include/libcamera/internal/ipa_proxy.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_proxy.h - Image Processing Algorithm proxy + */ +#ifndef __LIBCAMERA_IPA_PROXY_H__ +#define __LIBCAMERA_IPA_PROXY_H__ + +#include +#include +#include + +#include + +namespace libcamera { + +class IPAModule; + +class IPAProxy : public IPAInterface +{ +public: + IPAProxy(IPAModule *ipam); + ~IPAProxy(); + + bool isValid() const { return valid_; } + + std::string configurationFile(const std::string &file) const; + +protected: + std::string resolvePath(const std::string &file) const; + + bool valid_; + +private: + IPAModule *ipam_; +}; + +class IPAProxyFactory +{ +public: + IPAProxyFactory(const char *name); + virtual ~IPAProxyFactory() {} + + virtual std::unique_ptr create(IPAModule *ipam) = 0; + + const std::string &name() const { return name_; } + + static void registerType(IPAProxyFactory *factory); + static std::vector &factories(); + +private: + std::string name_; +}; + +#define REGISTER_IPA_PROXY(proxy) \ +class proxy##Factory final : public IPAProxyFactory \ +{ \ +public: \ + proxy##Factory() : IPAProxyFactory(#proxy) {} \ + std::unique_ptr create(IPAModule *ipam) \ + { \ + return std::make_unique(ipam); \ + } \ +}; \ +static proxy##Factory global_##proxy##Factory; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPA_PROXY_H__ */ diff --git a/include/libcamera/internal/ipc_unixsocket.h b/include/libcamera/internal/ipc_unixsocket.h new file mode 100644 index 00000000..820d0561 --- /dev/null +++ b/include/libcamera/internal/ipc_unixsocket.h @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipc_unixsocket.h - IPC mechanism based on Unix sockets + */ + +#ifndef __LIBCAMERA_IPC_UNIXSOCKET_H__ +#define __LIBCAMERA_IPC_UNIXSOCKET_H__ + +#include +#include +#include + +#include + +namespace libcamera { + +class IPCUnixSocket +{ +public: + struct Payload { + std::vector data; + std::vector fds; + }; + + IPCUnixSocket(); + ~IPCUnixSocket(); + + int create(); + int bind(int fd); + void close(); + bool isBound() const; + + int send(const Payload &payload); + int receive(Payload *payload); + + Signal readyRead; + +private: + struct Header { + uint32_t data; + uint8_t fds; + }; + + int sendData(const void *buffer, size_t length, const int32_t *fds, unsigned int num); + int recvData(void *buffer, size_t length, int32_t *fds, unsigned int num); + + void dataNotifier(EventNotifier *notifier); + + int fd_; + bool headerReceived_; + struct Header header_; + EventNotifier *notifier_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPC_UNIXSOCKET_H__ */ diff --git a/include/libcamera/internal/log.h b/include/libcamera/internal/log.h new file mode 100644 index 00000000..cab2034a --- /dev/null +++ b/include/libcamera/internal/log.h @@ -0,0 +1,130 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2018, Google Inc. + * + * log.h - Logging infrastructure + */ +#ifndef __LIBCAMERA_LOG_H__ +#define __LIBCAMERA_LOG_H__ + +#include +#include + +#include "libcamera/internal/utils.h" + +namespace libcamera { + +enum LogSeverity { + LogInvalid = -1, + LogDebug = 0, + LogInfo, + LogWarning, + LogError, + LogFatal, +}; + +class LogCategory +{ +public: + explicit LogCategory(const char *name); + ~LogCategory(); + + const char *name() const { return name_; } + LogSeverity severity() const { return severity_; } + void setSeverity(LogSeverity severity); + + static const LogCategory &defaultCategory(); + +private: + const char *name_; + LogSeverity severity_; +}; + +#define LOG_DECLARE_CATEGORY(name) \ +extern const LogCategory &_LOG_CATEGORY(name)(); + +#define LOG_DEFINE_CATEGORY(name) \ +const LogCategory &_LOG_CATEGORY(name)() \ +{ \ + static LogCategory category(#name); \ + return category; \ +} + +class LogMessage +{ +public: + LogMessage(const char *fileName, unsigned int line, + LogSeverity severity); + LogMessage(const char *fileName, unsigned int line, + const LogCategory &category, LogSeverity severity); + LogMessage(const LogMessage &) = delete; + LogMessage(LogMessage &&); + ~LogMessage(); + + std::ostream &stream() { return msgStream_; } + + const utils::time_point ×tamp() const { return timestamp_; } + LogSeverity severity() const { return severity_; } + const LogCategory &category() const { return category_; } + const std::string &fileInfo() const { return fileInfo_; } + const std::string msg() const { return msgStream_.str(); } + +private: + void init(const char *fileName, unsigned int line); + + std::ostringstream msgStream_; + const LogCategory &category_; + LogSeverity severity_; + utils::time_point timestamp_; + std::string fileInfo_; +}; + +class Loggable +{ +public: + virtual ~Loggable(); + +protected: + virtual std::string logPrefix() const = 0; + + LogMessage _log(const char *file, unsigned int line, + LogSeverity severity) const; + LogMessage _log(const char *file, unsigned int line, + const LogCategory &category, + LogSeverity severity) const; +}; + +LogMessage _log(const char *file, unsigned int line, LogSeverity severity); +LogMessage _log(const char *file, unsigned int line, + const LogCategory &category, LogSeverity severity); + +#ifndef __DOXYGEN__ +#define _LOG_CATEGORY(name) logCategory##name + +#define _LOG1(severity) \ + _log(__FILE__, __LINE__, Log##severity).stream() +#define _LOG2(category, severity) \ + _log(__FILE__, __LINE__, _LOG_CATEGORY(category)(), Log##severity).stream() + +/* + * Expand the LOG() macro to _LOG1() or _LOG2() based on the number of + * arguments. + */ +#define _LOG_MACRO(_1, _2, NAME, ...) NAME +#define LOG(...) _LOG_MACRO(__VA_ARGS__, _LOG2, _LOG1)(__VA_ARGS__) +#else /* __DOXYGEN___ */ +#define LOG(category, severity) +#endif /* __DOXYGEN__ */ + +#ifndef NDEBUG +#define ASSERT(condition) static_cast(({ \ + if (!(condition)) \ + LOG(Fatal) << "assertion \"" #condition "\" failed"; \ +})) +#else +#define ASSERT(condition) static_cast(false && (condition)) +#endif + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_LOG_H__ */ diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h new file mode 100644 index 00000000..9fe76c51 --- /dev/null +++ b/include/libcamera/internal/media_device.h @@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2018, Google Inc. + * + * media_device.h - Media device handler + */ +#ifndef __LIBCAMERA_MEDIA_DEVICE_H__ +#define __LIBCAMERA_MEDIA_DEVICE_H__ + +#include +#include +#include +#include + +#include + +#include + +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_object.h" + +namespace libcamera { + +class MediaDevice : protected Loggable +{ +public: + MediaDevice(const std::string &deviceNode); + ~MediaDevice(); + + bool acquire(); + void release(); + bool busy() const { return acquired_; } + + bool lock(); + void unlock(); + + int populate(); + bool valid() const { return valid_; } + + const std::string driver() const { return driver_; } + const std::string deviceNode() const { return deviceNode_; } + const std::string model() const { return model_; } + unsigned int version() const { return version_; } + + const std::vector &entities() const { return entities_; } + MediaEntity *getEntityByName(const std::string &name) const; + + MediaLink *link(const std::string &sourceName, unsigned int sourceIdx, + const std::string &sinkName, unsigned int sinkIdx); + MediaLink *link(const MediaEntity *source, unsigned int sourceIdx, + const MediaEntity *sink, unsigned int sinkIdx); + MediaLink *link(const MediaPad *source, const MediaPad *sink); + int disableLinks(); + + Signal disconnected; + +protected: + std::string logPrefix() const; + +private: + std::string driver_; + std::string deviceNode_; + std::string model_; + unsigned int version_; + + int fd_; + bool valid_; + bool acquired_; + bool lockOwner_; + + int open(); + void close(); + + std::map objects_; + MediaObject *object(unsigned int id); + bool addObject(MediaObject *object); + void clear(); + + std::vector entities_; + + struct media_v2_interface *findInterface(const struct media_v2_topology &topology, + unsigned int entityId); + bool populateEntities(const struct media_v2_topology &topology); + bool populatePads(const struct media_v2_topology &topology); + bool populateLinks(const struct media_v2_topology &topology); + void fixupEntityFlags(struct media_v2_entity *entity); + + friend int MediaLink::setEnabled(bool enable); + int setupLink(const MediaLink *link, unsigned int flags); +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_MEDIA_DEVICE_H__ */ diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h new file mode 100644 index 00000000..748eafdc --- /dev/null +++ b/include/libcamera/internal/media_object.h @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2018, Google Inc. + * + * media_object.h - Media Device objects: entities, pads and links. + */ +#ifndef __LIBCAMERA_MEDIA_OBJECT_H__ +#define __LIBCAMERA_MEDIA_OBJECT_H__ + +#include +#include + +#include + +namespace libcamera { + +class MediaDevice; +class MediaEntity; +class MediaPad; + +class MediaObject +{ +public: + MediaDevice *device() { return dev_; } + unsigned int id() const { return id_; } + +protected: + friend class MediaDevice; + + MediaObject(MediaDevice *dev, unsigned int id) + : dev_(dev), id_(id) + { + } + virtual ~MediaObject() {} + + MediaDevice *dev_; + unsigned int id_; +}; + +class MediaLink : public MediaObject +{ +public: + MediaPad *source() const { return source_; } + MediaPad *sink() const { return sink_; } + unsigned int flags() const { return flags_; } + int setEnabled(bool enable); + +private: + friend class MediaDevice; + + MediaLink(const struct media_v2_link *link, + MediaPad *source, MediaPad *sink); + MediaLink(const MediaLink &) = delete; + ~MediaLink() {} + + MediaPad *source_; + MediaPad *sink_; + unsigned int flags_; +}; + +class MediaPad : public MediaObject +{ +public: + unsigned int index() const { return index_; } + MediaEntity *entity() const { return entity_; } + unsigned int flags() const { return flags_; } + const std::vector &links() const { return links_; } + + void addLink(MediaLink *link); + +private: + friend class MediaDevice; + + MediaPad(const struct media_v2_pad *pad, MediaEntity *entity); + MediaPad(const MediaPad &) = delete; + ~MediaPad(); + + unsigned int index_; + MediaEntity *entity_; + unsigned int flags_; + + std::vector links_; +}; + +class MediaEntity : public MediaObject +{ +public: + const std::string &name() const { return name_; } + unsigned int function() const { return function_; } + unsigned int flags() const { return flags_; } + const std::string &deviceNode() const { return deviceNode_; } + unsigned int deviceMajor() const { return major_; } + unsigned int deviceMinor() const { return minor_; } + + const std::vector &pads() const { return pads_; } + + const MediaPad *getPadByIndex(unsigned int index) const; + const MediaPad *getPadById(unsigned int id) const; + + int setDeviceNode(const std::string &deviceNode); + +private: + friend class MediaDevice; + + MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity, + unsigned int major = 0, unsigned int minor = 0); + MediaEntity(const MediaEntity &) = delete; + ~MediaEntity(); + + std::string name_; + unsigned int function_; + unsigned int flags_; + std::string deviceNode_; + unsigned int major_; + unsigned int minor_; + + std::vector pads_; + + void addPad(MediaPad *pad); +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_MEDIA_OBJECT_H__ */ diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build new file mode 100644 index 00000000..1f6af579 --- /dev/null +++ b/include/libcamera/internal/meson.build @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: CC0-1.0 + +libcamera_headers = files([ + 'byte_stream_buffer.h', + 'camera_controls.h', + 'camera_sensor.h', + 'control_serializer.h', + 'control_validator.h', + 'device_enumerator.h', + 'device_enumerator_sysfs.h', + 'device_enumerator_udev.h', + 'event_dispatcher_poll.h', + 'file.h', + 'formats.h', + 'ipa_context_wrapper.h', + 'ipa_manager.h', + 'ipa_module.h', + 'ipa_proxy.h', + 'ipc_unixsocket.h', + 'log.h', + 'media_device.h', + 'media_object.h', + 'message.h', + 'pipeline_handler.h', + 'process.h', + 'pub_key.h', + 'semaphore.h', + 'thread.h', + 'utils.h', + 'v4l2_controls.h', + 'v4l2_device.h', + 'v4l2_pixelformat.h', + 'v4l2_subdevice.h', + 'v4l2_videodevice.h', +]) diff --git a/include/libcamera/internal/message.h b/include/libcamera/internal/message.h new file mode 100644 index 00000000..8e8b013d --- /dev/null +++ b/include/libcamera/internal/message.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * message.h - Message queue support + */ +#ifndef __LIBCAMERA_MESSAGE_H__ +#define __LIBCAMERA_MESSAGE_H__ + +#include + +#include + +namespace libcamera { + +class BoundMethodBase; +class Object; +class Semaphore; +class Thread; + +class Message +{ +public: + enum Type { + None = 0, + InvokeMessage = 1, + ThreadMoveMessage = 2, + UserMessage = 1000, + }; + + Message(Type type); + virtual ~Message(); + + Type type() const { return type_; } + Object *receiver() const { return receiver_; } + + static Type registerMessageType(); + +private: + friend class Thread; + + Type type_; + Object *receiver_; + + static std::atomic_uint nextUserType_; +}; + +class InvokeMessage : public Message +{ +public: + InvokeMessage(BoundMethodBase *method, + std::shared_ptr pack, + Semaphore *semaphore = nullptr, + bool deleteMethod = false); + ~InvokeMessage(); + + Semaphore *semaphore() const { return semaphore_; } + + void invoke(); + +private: + BoundMethodBase *method_; + std::shared_ptr pack_; + Semaphore *semaphore_; + bool deleteMethod_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_MESSAGE_H__ */ diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h new file mode 100644 index 00000000..428f5887 --- /dev/null +++ b/include/libcamera/internal/pipeline_handler.h @@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2018, Google Inc. + * + * pipeline_handler.h - Pipeline handler infrastructure + */ +#ifndef __LIBCAMERA_PIPELINE_HANDLER_H__ +#define __LIBCAMERA_PIPELINE_HANDLER_H__ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "libcamera/internal/ipa_proxy.h" + +namespace libcamera { + +class Camera; +class CameraConfiguration; +class CameraManager; +class DeviceEnumerator; +class DeviceMatch; +class FrameBuffer; +class MediaDevice; +class PipelineHandler; +class Request; + +class CameraData +{ +public: + explicit CameraData(PipelineHandler *pipe) + : pipe_(pipe) + { + } + virtual ~CameraData() {} + + Camera *camera_; + PipelineHandler *pipe_; + std::list queuedRequests_; + ControlInfoMap controlInfo_; + ControlList properties_; + std::unique_ptr ipa_; + +private: + CameraData(const CameraData &) = delete; + CameraData &operator=(const CameraData &) = delete; +}; + +class PipelineHandler : public std::enable_shared_from_this, + public Object +{ +public: + PipelineHandler(CameraManager *manager); + virtual ~PipelineHandler(); + + virtual bool match(DeviceEnumerator *enumerator) = 0; + MediaDevice *acquireMediaDevice(DeviceEnumerator *enumerator, + const DeviceMatch &dm); + + bool lock(); + void unlock(); + + const ControlInfoMap &controls(Camera *camera); + const ControlList &properties(Camera *camera); + + virtual CameraConfiguration *generateConfiguration(Camera *camera, + const StreamRoles &roles) = 0; + virtual int configure(Camera *camera, CameraConfiguration *config) = 0; + + virtual int exportFrameBuffers(Camera *camera, Stream *stream, + std::vector> *buffers) = 0; + + virtual int start(Camera *camera) = 0; + virtual void stop(Camera *camera) = 0; + + int queueRequest(Camera *camera, Request *request); + + bool completeBuffer(Camera *camera, Request *request, + FrameBuffer *buffer); + void completeRequest(Camera *camera, Request *request); + + const char *name() const { return name_; } + +protected: + void registerCamera(std::shared_ptr camera, + std::unique_ptr data, dev_t devnum = 0); + void hotplugMediaDevice(MediaDevice *media); + + virtual int queueRequestDevice(Camera *camera, Request *request) = 0; + + CameraData *cameraData(const Camera *camera); + + CameraManager *manager_; + +private: + void mediaDeviceDisconnected(MediaDevice *media); + virtual void disconnect(); + + std::vector> mediaDevices_; + std::vector> cameras_; + std::map> cameraData_; + + const char *name_; + + friend class PipelineHandlerFactory; +}; + +class PipelineHandlerFactory +{ +public: + PipelineHandlerFactory(const char *name); + virtual ~PipelineHandlerFactory() {} + + std::shared_ptr create(CameraManager *manager); + + const std::string &name() const { return name_; } + + static void registerType(PipelineHandlerFactory *factory); + static std::vector &factories(); + +private: + virtual PipelineHandler *createInstance(CameraManager *manager) = 0; + + std::string name_; +}; + +#define REGISTER_PIPELINE_HANDLER(handler) \ +class handler##Factory final : public PipelineHandlerFactory \ +{ \ +public: \ + handler##Factory() : PipelineHandlerFactory(#handler) {} \ + \ +private: \ + PipelineHandler *createInstance(CameraManager *manager) \ + { \ + return new handler(manager); \ + } \ +}; \ +static handler##Factory global_##handler##Factory; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_PIPELINE_HANDLER_H__ */ diff --git a/include/libcamera/internal/process.h b/include/libcamera/internal/process.h new file mode 100644 index 00000000..d322fce1 --- /dev/null +++ b/include/libcamera/internal/process.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * process.h - Process object + */ +#ifndef __LIBCAMERA_PROCESS_H__ +#define __LIBCAMERA_PROCESS_H__ + +#include +#include + +#include + +namespace libcamera { + +class Process final +{ +public: + enum ExitStatus { + NotExited, + NormalExit, + SignalExit, + }; + + Process(); + ~Process(); + + int start(const std::string &path, + const std::vector &args = std::vector(), + const std::vector &fds = std::vector()); + + ExitStatus exitStatus() const { return exitStatus_; } + int exitCode() const { return exitCode_; } + + void kill(); + + Signal finished; + +private: + void closeAllFdsExcept(const std::vector &fds); + int isolate(); + void died(int wstatus); + + pid_t pid_; + bool running_; + enum ExitStatus exitStatus_; + int exitCode_; + + friend class ProcessManager; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_PROCESS_H__ */ diff --git a/include/libcamera/internal/pub_key.h b/include/libcamera/internal/pub_key.h new file mode 100644 index 00000000..f35bf373 --- /dev/null +++ b/include/libcamera/internal/pub_key.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2020, Google Inc. + * + * pub_key.h - Public key signature verification + */ +#ifndef __LIBCAMERA_PUB_KEY_H__ +#define __LIBCAMERA_PUB_KEY_H__ + +#include + +#include + +#if HAVE_GNUTLS +struct gnutls_pubkey_st; +#endif + +namespace libcamera { + +class PubKey +{ +public: + PubKey(Span key); + ~PubKey(); + + bool isValid() const { return valid_; } + bool verify(Span data, Span sig) const; + +private: + bool valid_; +#if HAVE_GNUTLS + struct gnutls_pubkey_st *pubkey_; +#endif +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_PUB_KEY_H__ */ diff --git a/include/libcamera/internal/semaphore.h b/include/libcamera/internal/semaphore.h new file mode 100644 index 00000000..4d93077c --- /dev/null +++ b/include/libcamera/internal/semaphore.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * semaphore.h - General-purpose counting semaphore + */ +#ifndef __LIBCAMERA_SEMAPHORE_H__ +#define __LIBCAMERA_SEMAPHORE_H__ + +#include + +#include "libcamera/internal/thread.h" + +namespace libcamera { + +class Semaphore +{ +public: + Semaphore(unsigned int n = 0); + + unsigned int available(); + void acquire(unsigned int n = 1); + bool tryAcquire(unsigned int n = 1); + void release(unsigned int n = 1); + +private: + Mutex mutex_; + std::condition_variable cv_; + unsigned int available_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_SEMAPHORE_H__ */ diff --git a/include/libcamera/internal/thread.h b/include/libcamera/internal/thread.h new file mode 100644 index 00000000..6594c9b0 --- /dev/null +++ b/include/libcamera/internal/thread.h @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * thread.h - Thread support + */ +#ifndef __LIBCAMERA_THREAD_H__ +#define __LIBCAMERA_THREAD_H__ + +#include +#include +#include +#include + +#include + +#include "libcamera/internal/utils.h" + +namespace libcamera { + +class EventDispatcher; +class Message; +class Object; +class ThreadData; +class ThreadMain; + +using Mutex = std::mutex; +using MutexLocker = std::unique_lock; + +class Thread +{ +public: + Thread(); + virtual ~Thread(); + + void start(); + void exit(int code = 0); + bool wait(utils::duration duration = utils::duration::max()); + + bool isRunning(); + + Signal finished; + + static Thread *current(); + static pid_t currentId(); + + EventDispatcher *eventDispatcher(); + void setEventDispatcher(std::unique_ptr dispatcher); + + void dispatchMessages(); + +protected: + int exec(); + virtual void run(); + +private: + void startThread(); + void finishThread(); + + void postMessage(std::unique_ptr msg, Object *receiver); + void removeMessages(Object *receiver); + + friend class Object; + friend class ThreadData; + friend class ThreadMain; + + void moveObject(Object *object); + void moveObject(Object *object, ThreadData *currentData, + ThreadData *targetData); + + std::thread thread_; + ThreadData *data_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_THREAD_H__ */ diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h new file mode 100644 index 00000000..3334ff16 --- /dev/null +++ b/include/libcamera/internal/utils.h @@ -0,0 +1,197 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2018, Google Inc. + * + * utils.h - Miscellaneous utility functions + */ +#ifndef __LIBCAMERA_UTILS_H__ +#define __LIBCAMERA_UTILS_H__ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + +#ifndef __DOXYGEN__ + +/* uClibc and uClibc-ng don't provide O_TMPFILE */ +#ifndef O_TMPFILE +#define O_TMPFILE (020000000 | O_DIRECTORY) +#endif + +#endif + +namespace libcamera { + +namespace utils { + +const char *basename(const char *path); + +char *secure_getenv(const char *name); +std::string dirname(const std::string &path); + +template +unsigned int set_overlap(InputIt1 first1, InputIt1 last1, + InputIt2 first2, InputIt2 last2) +{ + unsigned int count = 0; + + while (first1 != last1 && first2 != last2) { + if (*first1 < *first2) { + ++first1; + } else { + if (!(*first2 < *first1)) + count++; + ++first2; + } + } + + return count; +} + +/* C++11 doesn't provide std::clamp */ +template +const T& clamp(const T& v, const T& lo, const T& hi) +{ + return std::max(lo, std::min(v, hi)); +} + +using clock = std::chrono::steady_clock; +using duration = std::chrono::steady_clock::duration; +using time_point = std::chrono::steady_clock::time_point; + +struct timespec duration_to_timespec(const duration &value); +std::string time_point_to_string(const time_point &time); + +#ifndef __DOXYGEN__ +struct _hex { + uint64_t v; + unsigned int w; +}; + +std::basic_ostream> & +operator<<(std::basic_ostream> &stream, const _hex &h); +#endif + +template +_hex hex(T value, unsigned int width = 0); + +#ifndef __DOXYGEN__ +template<> +inline _hex hex(int32_t value, unsigned int width) +{ + return { static_cast(value), width ? width : 8 }; +} + +template<> +inline _hex hex(uint32_t value, unsigned int width) +{ + return { static_cast(value), width ? width : 8 }; +} + +template<> +inline _hex hex(int64_t value, unsigned int width) +{ + return { static_cast(value), width ? width : 16 }; +} + +template<> +inline _hex hex(uint64_t value, unsigned int width) +{ + return { static_cast(value), width ? width : 16 }; +} +#endif + +size_t strlcpy(char *dst, const char *src, size_t size); + +#ifndef __DOXYGEN__ +template +std::string join(const Container &items, const std::string &sep, UnaryOp op) +{ + std::ostringstream ss; + bool first = true; + + for (typename Container::const_iterator it = std::begin(items); + it != std::end(items); ++it) { + if (!first) + ss << sep; + else + first = false; + + ss << op(*it); + } + + return ss.str(); +} + +template +std::string join(const Container &items, const std::string &sep) +{ + std::ostringstream ss; + bool first = true; + + for (typename Container::const_iterator it = std::begin(items); + it != std::end(items); ++it) { + if (!first) + ss << sep; + else + first = false; + + ss << *it; + } + + return ss.str(); +} +#else +template +std::string join(const Container &items, const std::string &sep, UnaryOp op = nullptr); +#endif + +namespace details { + +class StringSplitter +{ +public: + StringSplitter(const std::string &str, const std::string &delim); + + class iterator + { + public: + iterator(const StringSplitter *ss, std::string::size_type pos); + + iterator &operator++(); + std::string operator*() const; + bool operator!=(const iterator &other) const; + + private: + const StringSplitter *ss_; + std::string::size_type pos_; + std::string::size_type next_; + }; + + iterator begin() const; + iterator end() const; + +private: + std::string str_; + std::string delim_; +}; + +} /* namespace details */ + +details::StringSplitter split(const std::string &str, const std::string &delim); + +std::string libcameraBuildPath(); +std::string libcameraSourcePath(); + +} /* namespace utils */ + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_UTILS_H__ */ diff --git a/include/libcamera/internal/v4l2_controls.h b/include/libcamera/internal/v4l2_controls.h new file mode 100644 index 00000000..cffe9efd --- /dev/null +++ b/include/libcamera/internal/v4l2_controls.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * v4l2_controls.h - V4L2 Controls Support + */ + +#ifndef __LIBCAMERA_V4L2_CONTROLS_H__ +#define __LIBCAMERA_V4L2_CONTROLS_H__ + +#include + +#include + +namespace libcamera { + +class V4L2ControlId : public ControlId +{ +public: + V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl); +}; + +class V4L2ControlInfo : public ControlInfo +{ +public: + V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl); +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_V4L2_CONTROLS_H__ */ diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h new file mode 100644 index 00000000..d491eafd --- /dev/null +++ b/include/libcamera/internal/v4l2_device.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * v4l2_device.h - Common base for V4L2 video devices and subdevices + */ +#ifndef __LIBCAMERA_V4L2_DEVICE_H__ +#define __LIBCAMERA_V4L2_DEVICE_H__ + +#include +#include +#include + +#include + +#include "libcamera/internal/log.h" +#include "libcamera/internal/v4l2_controls.h" + +namespace libcamera { + +class V4L2Device : protected Loggable +{ +public: + void close(); + bool isOpen() const { return fd_ != -1; } + + const ControlInfoMap &controls() const { return controls_; } + + ControlList getControls(const std::vector &ids); + int setControls(ControlList *ctrls); + + const std::string &deviceNode() const { return deviceNode_; } + +protected: + V4L2Device(const std::string &deviceNode); + ~V4L2Device(); + + int open(unsigned int flags); + int setFd(int fd); + + int ioctl(unsigned long request, void *argp); + + int fd() { return fd_; } + +private: + void listControls(); + void updateControls(ControlList *ctrls, + const struct v4l2_ext_control *v4l2Ctrls, + unsigned int count); + + std::map controlInfo_; + std::vector> controlIds_; + ControlInfoMap controls_; + std::string deviceNode_; + int fd_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_V4L2_DEVICE_H__ */ diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h new file mode 100644 index 00000000..0fe8a017 --- /dev/null +++ b/include/libcamera/internal/v4l2_pixelformat.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * + * v4l2_pixelformat.h - V4L2 Pixel Format + */ +#ifndef __LIBCAMERA_V4L2_PIXELFORMAT_H__ +#define __LIBCAMERA_V4L2_PIXELFORMAT_H__ + +#include +#include + +#include + +#include + +namespace libcamera { + +class V4L2PixelFormat +{ +public: + V4L2PixelFormat() + : fourcc_(0) + { + } + + explicit V4L2PixelFormat(uint32_t fourcc) + : fourcc_(fourcc) + { + } + + bool isValid() const { return fourcc_ != 0; } + uint32_t fourcc() const { return fourcc_; } + operator uint32_t() const { return fourcc_; } + + std::string toString() const; + + PixelFormat toPixelFormat() const; + static V4L2PixelFormat fromPixelFormat(const PixelFormat &pixelFormat, + bool multiplanar); + +private: + uint32_t fourcc_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_V4L2_PIXELFORMAT_H__ */ diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h new file mode 100644 index 00000000..1be454f0 --- /dev/null +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * v4l2_subdevice.h - V4L2 Subdevice + */ +#ifndef __LIBCAMERA_V4L2_SUBDEVICE_H__ +#define __LIBCAMERA_V4L2_SUBDEVICE_H__ + +#include +#include + +#include + +#include "libcamera/internal/formats.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_object.h" +#include "libcamera/internal/v4l2_device.h" + +namespace libcamera { + +class MediaDevice; + +struct V4L2SubdeviceFormat { + uint32_t mbus_code; + Size size; + + const std::string toString() const; + uint8_t bitsPerPixel() const; +}; + +class V4L2Subdevice : public V4L2Device +{ +public: + enum Whence { + ActiveFormat, + TryFormat, + }; + + explicit V4L2Subdevice(const MediaEntity *entity); + V4L2Subdevice(const V4L2Subdevice &) = delete; + V4L2Subdevice &operator=(const V4L2Subdevice &) = delete; + ~V4L2Subdevice(); + + int open(); + + const MediaEntity *entity() const { return entity_; } + + int getSelection(unsigned int pad, unsigned int target, + Rectangle *rect); + int setSelection(unsigned int pad, unsigned int target, + Rectangle *rect); + + ImageFormats formats(unsigned int pad); + + int getFormat(unsigned int pad, V4L2SubdeviceFormat *format, + Whence whence = ActiveFormat); + int setFormat(unsigned int pad, V4L2SubdeviceFormat *format, + Whence whence = ActiveFormat); + + static V4L2Subdevice *fromEntityName(const MediaDevice *media, + const std::string &entity); + +protected: + std::string logPrefix() const; + +private: + std::vector enumPadCodes(unsigned int pad); + std::vector enumPadSizes(unsigned int pad, + unsigned int code); + + const MediaEntity *entity_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_V4L2_SUBDEVICE_H__ */ diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h new file mode 100644 index 00000000..dc259523 --- /dev/null +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -0,0 +1,277 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * v4l2_videodevice.h - V4L2 Video Device + */ +#ifndef __LIBCAMERA_V4L2_VIDEODEVICE_H__ +#define __LIBCAMERA_V4L2_VIDEODEVICE_H__ + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "libcamera/internal/formats.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/v4l2_device.h" +#include "libcamera/internal/v4l2_pixelformat.h" + +namespace libcamera { + +class EventNotifier; +class FileDescriptor; +class MediaDevice; +class MediaEntity; + +struct V4L2Capability final : v4l2_capability { + const char *driver() const + { + return reinterpret_cast(v4l2_capability::driver); + } + const char *card() const + { + return reinterpret_cast(v4l2_capability::card); + } + const char *bus_info() const + { + return reinterpret_cast(v4l2_capability::bus_info); + } + unsigned int device_caps() const + { + return capabilities & V4L2_CAP_DEVICE_CAPS + ? v4l2_capability::device_caps + : v4l2_capability::capabilities; + } + bool isMultiplanar() const + { + return device_caps() & (V4L2_CAP_VIDEO_CAPTURE_MPLANE | + V4L2_CAP_VIDEO_OUTPUT_MPLANE | + V4L2_CAP_VIDEO_M2M_MPLANE); + } + bool isCapture() const + { + return device_caps() & (V4L2_CAP_VIDEO_CAPTURE | + V4L2_CAP_VIDEO_CAPTURE_MPLANE | + V4L2_CAP_META_CAPTURE); + } + bool isOutput() const + { + return device_caps() & (V4L2_CAP_VIDEO_OUTPUT | + V4L2_CAP_VIDEO_OUTPUT_MPLANE | + V4L2_CAP_META_OUTPUT); + } + bool isVideo() const + { + return device_caps() & (V4L2_CAP_VIDEO_CAPTURE | + V4L2_CAP_VIDEO_CAPTURE_MPLANE | + V4L2_CAP_VIDEO_OUTPUT | + V4L2_CAP_VIDEO_OUTPUT_MPLANE); + } + bool isM2M() const + { + return device_caps() & (V4L2_CAP_VIDEO_M2M | + V4L2_CAP_VIDEO_M2M_MPLANE); + } + bool isMeta() const + { + return device_caps() & (V4L2_CAP_META_CAPTURE | + V4L2_CAP_META_OUTPUT); + } + bool isVideoCapture() const + { + return isVideo() && isCapture(); + } + bool isVideoOutput() const + { + return isVideo() && isOutput(); + } + bool isMetaCapture() const + { + return isMeta() && isCapture(); + } + bool isMetaOutput() const + { + return isMeta() && isOutput(); + } + bool hasStreaming() const + { + return device_caps() & V4L2_CAP_STREAMING; + } +}; + +class V4L2BufferCache +{ +public: + V4L2BufferCache(unsigned int numEntries); + V4L2BufferCache(const std::vector> &buffers); + ~V4L2BufferCache(); + + int get(const FrameBuffer &buffer); + void put(unsigned int index); + +private: + class Entry + { + public: + Entry(); + Entry(bool free, uint64_t lastUsed, const FrameBuffer &buffer); + + bool operator==(const FrameBuffer &buffer) const; + + bool free; + uint64_t lastUsed; + + private: + struct Plane { + Plane(const FrameBuffer::Plane &plane) + : fd(plane.fd.fd()), length(plane.length) + { + } + + int fd; + unsigned int length; + }; + + std::vector planes_; + }; + + std::atomic lastUsedCounter_; + std::vector cache_; + /* \todo Expose the miss counter through an instrumentation API. */ + unsigned int missCounter_; +}; + +class V4L2DeviceFormat +{ +public: + V4L2PixelFormat fourcc; + Size size; + + struct { + uint32_t size; + uint32_t bpl; + } planes[3]; + unsigned int planesCount; + + const std::string toString() const; +}; + +class V4L2VideoDevice : public V4L2Device +{ +public: + explicit V4L2VideoDevice(const std::string &deviceNode); + explicit V4L2VideoDevice(const MediaEntity *entity); + V4L2VideoDevice(const V4L2VideoDevice &) = delete; + ~V4L2VideoDevice(); + + V4L2VideoDevice &operator=(const V4L2VideoDevice &) = delete; + + int open(); + int open(int handle, enum v4l2_buf_type type); + void close(); + + const char *driverName() const { return caps_.driver(); } + const char *deviceName() const { return caps_.card(); } + const char *busName() const { return caps_.bus_info(); } + + const V4L2Capability &caps() const { return caps_; } + + int getFormat(V4L2DeviceFormat *format); + int setFormat(V4L2DeviceFormat *format); + std::map> formats(uint32_t code = 0); + + int setSelection(unsigned int target, Rectangle *rect); + + int allocateBuffers(unsigned int count, + std::vector> *buffers); + int exportBuffers(unsigned int count, + std::vector> *buffers); + int importBuffers(unsigned int count); + int releaseBuffers(); + + int queueBuffer(FrameBuffer *buffer); + Signal bufferReady; + + int setFrameStartEnabled(bool enable); + Signal frameStart; + + int streamOn(); + int streamOff(); + + static V4L2VideoDevice *fromEntityName(const MediaDevice *media, + const std::string &entity); + + V4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat); + +protected: + std::string logPrefix() const; + +private: + int getFormatMeta(V4L2DeviceFormat *format); + int setFormatMeta(V4L2DeviceFormat *format); + + int getFormatMultiplane(V4L2DeviceFormat *format); + int setFormatMultiplane(V4L2DeviceFormat *format); + + int getFormatSingleplane(V4L2DeviceFormat *format); + int setFormatSingleplane(V4L2DeviceFormat *format); + + std::vector enumPixelformats(uint32_t code); + std::vector enumSizes(V4L2PixelFormat pixelFormat); + + int requestBuffers(unsigned int count, enum v4l2_memory memoryType); + int createBuffers(unsigned int count, + std::vector> *buffers); + std::unique_ptr createBuffer(unsigned int index); + FileDescriptor exportDmabufFd(unsigned int index, unsigned int plane); + + void bufferAvailable(EventNotifier *notifier); + FrameBuffer *dequeueBuffer(); + + void eventAvailable(EventNotifier *notifier); + + V4L2Capability caps_; + + enum v4l2_buf_type bufferType_; + enum v4l2_memory memoryType_; + + V4L2BufferCache *cache_; + std::map queuedBuffers_; + + EventNotifier *fdBufferNotifier_; + EventNotifier *fdEventNotifier_; + + bool frameStartEnabled_; +}; + +class V4L2M2MDevice +{ +public: + V4L2M2MDevice(const std::string &deviceNode); + ~V4L2M2MDevice(); + + int open(); + void close(); + + V4L2VideoDevice *output() { return output_; } + V4L2VideoDevice *capture() { return capture_; } + +private: + std::string deviceNode_; + + V4L2VideoDevice *output_; + V4L2VideoDevice *capture_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_V4L2_VIDEODEVICE_H__ */ diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index cea47eb8..f9c8e64b 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -23,6 +23,8 @@ libcamera_api = files([ include_dir = join_paths(libcamera_include_dir, 'libcamera') +subdir('internal') + install_headers(libcamera_api, subdir : include_dir) diff --git a/src/android/camera3_hal.cpp b/src/android/camera3_hal.cpp index 34301ed9..716e36c7 100644 --- a/src/android/camera3_hal.cpp +++ b/src/android/camera3_hal.cpp @@ -7,9 +7,10 @@ #include +#include "libcamera/internal/log.h" + #include "camera_device.h" #include "camera_hal_manager.h" -#include "log.h" using namespace libcamera; diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 76af70eb..4ec429fc 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -11,8 +11,8 @@ #include #include -#include "log.h" -#include "utils.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/utils.h" #include "camera_metadata.h" diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 55eac317..bce1cfbc 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -16,7 +16,7 @@ #include #include -#include "message.h" +#include "libcamera/internal/message.h" class CameraMetadata; diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp index 5bd3bdba..759e320d 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -9,7 +9,7 @@ #include -#include "log.h" +#include "libcamera/internal/log.h" #include "camera_device.h" diff --git a/src/android/camera_metadata.cpp b/src/android/camera_metadata.cpp index 76965108..47b2e4ef 100644 --- a/src/android/camera_metadata.cpp +++ b/src/android/camera_metadata.cpp @@ -7,7 +7,7 @@ #include "camera_metadata.h" -#include "log.h" +#include "libcamera/internal/log.h" using namespace libcamera; diff --git a/src/ipa/libipa/ipa_interface_wrapper.cpp b/src/ipa/libipa/ipa_interface_wrapper.cpp index 21d8c98b..90f270c0 100644 --- a/src/ipa/libipa/ipa_interface_wrapper.cpp +++ b/src/ipa/libipa/ipa_interface_wrapper.cpp @@ -14,8 +14,8 @@ #include -#include "byte_stream_buffer.h" -#include "camera_sensor.h" +#include "libcamera/internal/byte_stream_buffer.h" +#include "libcamera/internal/camera_sensor.h" /** * \file ipa_interface_wrapper.h diff --git a/src/ipa/libipa/ipa_interface_wrapper.h b/src/ipa/libipa/ipa_interface_wrapper.h index 56507aaf..b426034d 100644 --- a/src/ipa/libipa/ipa_interface_wrapper.h +++ b/src/ipa/libipa/ipa_interface_wrapper.h @@ -11,7 +11,7 @@ #include -#include "control_serializer.h" +#include "libcamera/internal/control_serializer.h" namespace libcamera { diff --git a/src/ipa/meson.build b/src/ipa/meson.build index ab73c347..5a5de267 100644 --- a/src/ipa/meson.build +++ b/src/ipa/meson.build @@ -6,7 +6,6 @@ ipa_sysconf_dir = join_paths(get_option('sysconfdir'), 'libcamera', 'ipa') ipa_includes = [ libcamera_includes, - libcamera_internal_includes, ] config_h.set('IPA_CONFIG_DIR', diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 7f05d2c6..a0c73f99 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -11,11 +11,11 @@ #include #include +#include "libcamera/internal/v4l2_videodevice.h" + #include "cam_helper.hpp" #include "md_parser.hpp" -#include "v4l2_videodevice.h" - using namespace RPi; static std::map cam_helpers; diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp index 0c8aa29a..6877f473 100644 --- a/src/ipa/raspberrypi/cam_helper.hpp +++ b/src/ipa/raspberrypi/cam_helper.hpp @@ -11,7 +11,7 @@ #include "camera_mode.h" #include "md_parser.hpp" -#include "v4l2_videodevice.h" +#include "libcamera/internal/v4l2_videodevice.h" namespace RPi { diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 3bcc0815..46b24453 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -22,6 +22,10 @@ #include #include +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/utils.h" + #include #include "agc_algorithm.hpp" @@ -44,10 +48,6 @@ #include "sdn_status.h" #include "sharpen_status.h" -#include "camera_sensor.h" -#include "log.h" -#include "utils.h" - namespace libcamera { /* Configure the sensor with these values initially. */ diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index bfa88418..4f6e0342 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -22,8 +22,8 @@ #include #include -#include "log.h" -#include "utils.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/utils.h" namespace libcamera { diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp index 9271f2d8..3fa6be65 100644 --- a/src/ipa/vimc/vimc.cpp +++ b/src/ipa/vimc/vimc.cpp @@ -19,8 +19,8 @@ #include -#include "file.h" -#include "log.h" +#include "libcamera/internal/file.h" +#include "libcamera/internal/log.h" namespace libcamera { diff --git a/src/libcamera/bound_method.cpp b/src/libcamera/bound_method.cpp index 9aa59dc3..9993e596 100644 --- a/src/libcamera/bound_method.cpp +++ b/src/libcamera/bound_method.cpp @@ -7,9 +7,9 @@ #include -#include "message.h" -#include "semaphore.h" -#include "thread.h" +#include "libcamera/internal/message.h" +#include "libcamera/internal/semaphore.h" +#include "libcamera/internal/thread.h" /** * \file bound_method.h diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp index 0c5e56cf..1a1d4bac 100644 --- a/src/libcamera/buffer.cpp +++ b/src/libcamera/buffer.cpp @@ -12,7 +12,7 @@ #include #include -#include "log.h" +#include "libcamera/internal/log.h" /** * \file buffer.h diff --git a/src/libcamera/byte_stream_buffer.cpp b/src/libcamera/byte_stream_buffer.cpp index 20d6a655..df7029b0 100644 --- a/src/libcamera/byte_stream_buffer.cpp +++ b/src/libcamera/byte_stream_buffer.cpp @@ -5,12 +5,12 @@ * byte_stream_buffer.cpp - Byte stream buffer */ -#include "byte_stream_buffer.h" +#include "libcamera/internal/byte_stream_buffer.h" #include #include -#include "log.h" +#include "libcamera/internal/log.h" namespace libcamera { diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 8c3bb2c2..eac769a4 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -14,9 +14,9 @@ #include #include -#include "log.h" -#include "pipeline_handler.h" -#include "utils.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/utils.h" /** * \file camera.h diff --git a/src/libcamera/camera_controls.cpp b/src/libcamera/camera_controls.cpp index 59dcede2..371f6d07 100644 --- a/src/libcamera/camera_controls.cpp +++ b/src/libcamera/camera_controls.cpp @@ -5,7 +5,7 @@ * camera_controls.cpp - Camera controls */ -#include "camera_controls.h" +#include "libcamera/internal/camera_controls.h" #include #include diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index fddf7349..849377ad 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -13,12 +13,12 @@ #include #include -#include "device_enumerator.h" -#include "event_dispatcher_poll.h" -#include "log.h" -#include "pipeline_handler.h" -#include "thread.h" -#include "utils.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/event_dispatcher_poll.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/thread.h" +#include "libcamera/internal/utils.h" /** * \file camera_manager.h diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 31a916a9..174df17c 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -5,7 +5,7 @@ * camera_sensor.cpp - A camera sensor */ -#include "camera_sensor.h" +#include "libcamera/internal/camera_sensor.h" #include #include @@ -16,9 +16,9 @@ #include -#include "formats.h" -#include "utils.h" -#include "v4l2_subdevice.h" +#include "libcamera/internal/formats.h" +#include "libcamera/internal/utils.h" +#include "libcamera/internal/v4l2_subdevice.h" /** * \file camera_sensor.h diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp index fcff5e56..bf162b6c 100644 --- a/src/libcamera/control_serializer.cpp +++ b/src/libcamera/control_serializer.cpp @@ -5,7 +5,7 @@ * control_serializer.cpp - Control (de)serializer */ -#include "control_serializer.h" +#include "libcamera/internal/control_serializer.h" #include #include @@ -16,8 +16,8 @@ #include #include -#include "byte_stream_buffer.h" -#include "log.h" +#include "libcamera/internal/byte_stream_buffer.h" +#include "libcamera/internal/log.h" /** * \file control_serializer.h diff --git a/src/libcamera/control_validator.cpp b/src/libcamera/control_validator.cpp index 8e5cf3c3..5a2f27ac 100644 --- a/src/libcamera/control_validator.cpp +++ b/src/libcamera/control_validator.cpp @@ -5,7 +5,7 @@ * control_validator.cpp - Control validator */ -#include "control_validator.h" +#include "libcamera/internal/control_validator.h" /** * \file control_validator.h diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 08df7f29..dca78266 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -12,9 +12,9 @@ #include #include -#include "control_validator.h" -#include "log.h" -#include "utils.h" +#include "libcamera/internal/control_validator.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/utils.h" /** * \file controls.h diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index dd17e3e3..e21a2a7d 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -5,14 +5,14 @@ * device_enumerator.cpp - Enumeration and matching */ -#include "device_enumerator.h" -#include "device_enumerator_sysfs.h" -#include "device_enumerator_udev.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/device_enumerator_sysfs.h" +#include "libcamera/internal/device_enumerator_udev.h" #include -#include "log.h" -#include "media_device.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" /** * \file device_enumerator.h diff --git a/src/libcamera/device_enumerator_sysfs.cpp b/src/libcamera/device_enumerator_sysfs.cpp index 3446db59..ff728852 100644 --- a/src/libcamera/device_enumerator_sysfs.cpp +++ b/src/libcamera/device_enumerator_sysfs.cpp @@ -5,7 +5,7 @@ * device_enumerator_sysfs.cpp - sysfs-based device enumerator */ -#include "device_enumerator_sysfs.h" +#include "libcamera/internal/device_enumerator_sysfs.h" #include #include @@ -17,8 +17,8 @@ #include #include -#include "log.h" -#include "media_device.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" namespace libcamera { diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp index 2e33c898..56ca4dc2 100644 --- a/src/libcamera/device_enumerator_udev.cpp +++ b/src/libcamera/device_enumerator_udev.cpp @@ -5,7 +5,7 @@ * device_enumerator_udev.cpp - udev-based device enumerator */ -#include "device_enumerator_udev.h" +#include "libcamera/internal/device_enumerator_udev.h" #include #include @@ -19,8 +19,8 @@ #include -#include "log.h" -#include "media_device.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" namespace libcamera { diff --git a/src/libcamera/event_dispatcher.cpp b/src/libcamera/event_dispatcher.cpp index bb4fddff..90bd5daf 100644 --- a/src/libcamera/event_dispatcher.cpp +++ b/src/libcamera/event_dispatcher.cpp @@ -7,7 +7,7 @@ #include -#include "log.h" +#include "libcamera/internal/log.h" /** * \file event_dispatcher.h diff --git a/src/libcamera/event_dispatcher_poll.cpp b/src/libcamera/event_dispatcher_poll.cpp index 51ac5adf..9ab85da7 100644 --- a/src/libcamera/event_dispatcher_poll.cpp +++ b/src/libcamera/event_dispatcher_poll.cpp @@ -5,7 +5,7 @@ * event_dispatcher_poll.cpp - Poll-based event dispatcher */ -#include "event_dispatcher_poll.h" +#include "libcamera/internal/event_dispatcher_poll.h" #include #include @@ -19,9 +19,9 @@ #include #include -#include "log.h" -#include "thread.h" -#include "utils.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/thread.h" +#include "libcamera/internal/utils.h" /** * \file event_dispatcher_poll.h diff --git a/src/libcamera/event_notifier.cpp b/src/libcamera/event_notifier.cpp index a9be686f..cc3ea0d9 100644 --- a/src/libcamera/event_notifier.cpp +++ b/src/libcamera/event_notifier.cpp @@ -10,8 +10,8 @@ #include #include -#include "message.h" -#include "thread.h" +#include "libcamera/internal/message.h" +#include "libcamera/internal/thread.h" /** * \file event_notifier.h diff --git a/src/libcamera/file.cpp b/src/libcamera/file.cpp index 8223743d..c471bde3 100644 --- a/src/libcamera/file.cpp +++ b/src/libcamera/file.cpp @@ -5,7 +5,7 @@ * file.cpp - File I/O operations */ -#include "file.h" +#include "libcamera/internal/file.h" #include #include @@ -14,7 +14,7 @@ #include #include -#include "log.h" +#include "libcamera/internal/log.h" /** * \file file.h diff --git a/src/libcamera/file_descriptor.cpp b/src/libcamera/file_descriptor.cpp index 88385476..ee60064b 100644 --- a/src/libcamera/file_descriptor.cpp +++ b/src/libcamera/file_descriptor.cpp @@ -11,7 +11,7 @@ #include #include -#include "log.h" +#include "libcamera/internal/log.h" /** * \file file_descriptor.h diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index b3af0f7f..2ac3b412 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -5,11 +5,11 @@ * formats.cpp - libcamera image formats */ -#include "formats.h" +#include "libcamera/internal/formats.h" #include -#include "log.h" +#include "libcamera/internal/log.h" /** * \file formats.h diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp index a37b564c..252191ba 100644 --- a/src/libcamera/framebuffer_allocator.cpp +++ b/src/libcamera/framebuffer_allocator.cpp @@ -13,8 +13,8 @@ #include #include -#include "log.h" -#include "pipeline_handler.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/pipeline_handler.h" /** * \file framebuffer_allocator.h diff --git a/src/libcamera/include/byte_stream_buffer.h b/src/libcamera/include/byte_stream_buffer.h deleted file mode 100644 index b3aaa8b9..00000000 --- a/src/libcamera/include/byte_stream_buffer.h +++ /dev/null @@ -1,89 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * byte_stream_buffer.h - Byte stream buffer - */ -#ifndef __LIBCAMERA_BYTE_STREAM_BUFFER_H__ -#define __LIBCAMERA_BYTE_STREAM_BUFFER_H__ - -#include -#include -#include - -#include - -namespace libcamera { - -class ByteStreamBuffer -{ -public: - ByteStreamBuffer(const uint8_t *base, size_t size); - ByteStreamBuffer(uint8_t *base, size_t size); - ByteStreamBuffer(ByteStreamBuffer &&other); - ByteStreamBuffer &operator=(ByteStreamBuffer &&other); - - const uint8_t *base() const { return base_; } - uint32_t offset() const { return (write_ ? write_ : read_) - base_; } - size_t size() const { return size_; } - bool overflow() const { return overflow_; } - - ByteStreamBuffer carveOut(size_t size); - int skip(size_t size); - - template - int read(T *t) - { - return read(reinterpret_cast(t), sizeof(*t)); - } - - template - int read(const Span &data) - { - return read(reinterpret_cast(data.data()), - data.size_bytes()); - } - - template - const std::remove_reference_t *read(size_t count = 1) - { - using return_type = const std::remove_reference_t *; - return reinterpret_cast(read(sizeof(T), count)); - } - - template - int write(const T *t) - { - return write(reinterpret_cast(t), sizeof(*t)); - } - - template - int write(const Span &data) - { - return write(reinterpret_cast(data.data()), - data.size_bytes()); - } - -private: - ByteStreamBuffer(const ByteStreamBuffer &other) = delete; - ByteStreamBuffer &operator=(const ByteStreamBuffer &other) = delete; - - void setOverflow(); - - int read(uint8_t *data, size_t size); - const uint8_t *read(size_t size, size_t count); - int write(const uint8_t *data, size_t size); - - ByteStreamBuffer *parent_; - - const uint8_t *base_; - size_t size_; - bool overflow_; - - const uint8_t *read_; - uint8_t *write_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_BYTE_STREAM_BUFFER_H__ */ diff --git a/src/libcamera/include/camera_controls.h b/src/libcamera/include/camera_controls.h deleted file mode 100644 index 265c1fe3..00000000 --- a/src/libcamera/include/camera_controls.h +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * camera_controls.h - Camera controls - */ -#ifndef __LIBCAMERA_CAMERA_CONTROLS_H__ -#define __LIBCAMERA_CAMERA_CONTROLS_H__ - -#include "control_validator.h" - -namespace libcamera { - -class Camera; - -class CameraControlValidator final : public ControlValidator -{ -public: - CameraControlValidator(Camera *camera); - - const std::string &name() const override; - bool validate(unsigned int id) const override; - -private: - Camera *camera_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_CAMERA_CONTROLS_H__ */ diff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h deleted file mode 100644 index 30cf5f34..00000000 --- a/src/libcamera/include/camera_sensor.h +++ /dev/null @@ -1,88 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * camera_sensor.h - A camera sensor - */ -#ifndef __LIBCAMERA_CAMERA_SENSOR_H__ -#define __LIBCAMERA_CAMERA_SENSOR_H__ - -#include -#include -#include - -#include -#include - -#include "formats.h" -#include "log.h" - -namespace libcamera { - -class MediaEntity; -class V4L2Subdevice; - -struct V4L2SubdeviceFormat; - -struct CameraSensorInfo { - std::string model; - - uint32_t bitsPerPixel; - - Size activeAreaSize; - Rectangle analogCrop; - Size outputSize; - - uint64_t pixelRate; - uint32_t lineLength; -}; - -class CameraSensor : protected Loggable -{ -public: - explicit CameraSensor(const MediaEntity *entity); - ~CameraSensor(); - - CameraSensor(const CameraSensor &) = delete; - CameraSensor &operator=(const CameraSensor &) = delete; - - int init(); - - const std::string &model() const { return model_; } - const MediaEntity *entity() const { return entity_; } - const std::vector &mbusCodes() const { return mbusCodes_; } - const std::vector &sizes() const { return sizes_; } - const Size &resolution() const { return resolution_; } - - V4L2SubdeviceFormat getFormat(const std::vector &mbusCodes, - const Size &size) const; - int setFormat(V4L2SubdeviceFormat *format); - - const ControlInfoMap &controls() const; - ControlList getControls(const std::vector &ids); - int setControls(ControlList *ctrls); - - const ControlList &properties() const { return properties_; } - int sensorInfo(CameraSensorInfo *info) const; - -protected: - std::string logPrefix() const; - -private: - const MediaEntity *entity_; - std::unique_ptr subdev_; - unsigned int pad_; - - std::string model_; - - ImageFormats formats_; - Size resolution_; - std::vector mbusCodes_; - std::vector sizes_; - - ControlList properties_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_CAMERA_SENSOR_H__ */ diff --git a/src/libcamera/include/control_serializer.h b/src/libcamera/include/control_serializer.h deleted file mode 100644 index 99bacd92..00000000 --- a/src/libcamera/include/control_serializer.h +++ /dev/null @@ -1,55 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * control_serializer.h - Control (de)serializer - */ -#ifndef __LIBCAMERA_CONTROL_SERIALIZER_H__ -#define __LIBCAMERA_CONTROL_SERIALIZER_H__ - -#include -#include -#include - -#include - -namespace libcamera { - -class ByteStreamBuffer; - -class ControlSerializer -{ -public: - ControlSerializer(); - - void reset(); - - static size_t binarySize(const ControlInfoMap &infoMap); - static size_t binarySize(const ControlList &list); - - int serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer); - int serialize(const ControlList &list, ByteStreamBuffer &buffer); - - template - T deserialize(ByteStreamBuffer &buffer); - -private: - static size_t binarySize(const ControlValue &value); - static size_t binarySize(const ControlInfo &info); - - static void store(const ControlValue &value, ByteStreamBuffer &buffer); - static void store(const ControlInfo &info, ByteStreamBuffer &buffer); - - ControlValue loadControlValue(ControlType type, ByteStreamBuffer &buffer, - bool isArray = false, unsigned int count = 1); - ControlInfo loadControlInfo(ControlType type, ByteStreamBuffer &buffer); - - unsigned int serial_; - std::vector> controlIds_; - std::map infoMaps_; - std::map infoMapHandles_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_CONTROL_SERIALIZER_H__ */ diff --git a/src/libcamera/include/control_validator.h b/src/libcamera/include/control_validator.h deleted file mode 100644 index f1c9110b..00000000 --- a/src/libcamera/include/control_validator.h +++ /dev/null @@ -1,27 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * control_validator.h - Control validator - */ -#ifndef __LIBCAMERA_CONTROL_VALIDATOR_H__ -#define __LIBCAMERA_CONTROL_VALIDATOR_H__ - -#include - -namespace libcamera { - -class ControlId; - -class ControlValidator -{ -public: - virtual ~ControlValidator() {} - - virtual const std::string &name() const = 0; - virtual bool validate(unsigned int id) const = 0; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_CONTROL_VALIDATOR_H__ */ diff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h deleted file mode 100644 index 433e357a..00000000 --- a/src/libcamera/include/device_enumerator.h +++ /dev/null @@ -1,57 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2018, Google Inc. - * - * device_enumerator.h - API to enumerate and find media devices - */ -#ifndef __LIBCAMERA_DEVICE_ENUMERATOR_H__ -#define __LIBCAMERA_DEVICE_ENUMERATOR_H__ - -#include -#include -#include - -#include - -namespace libcamera { - -class MediaDevice; - -class DeviceMatch -{ -public: - DeviceMatch(const std::string &driver); - - void add(const std::string &entity); - - bool match(const MediaDevice *device) const; - -private: - std::string driver_; - std::vector entities_; -}; - -class DeviceEnumerator -{ -public: - static std::unique_ptr create(); - - virtual ~DeviceEnumerator(); - - virtual int init() = 0; - virtual int enumerate() = 0; - - std::shared_ptr search(const DeviceMatch &dm); - -protected: - std::unique_ptr createDevice(const std::string &deviceNode); - void addDevice(std::unique_ptr &&media); - void removeDevice(const std::string &deviceNode); - -private: - std::vector> devices_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_DEVICE_ENUMERATOR_H__ */ diff --git a/src/libcamera/include/device_enumerator_sysfs.h b/src/libcamera/include/device_enumerator_sysfs.h deleted file mode 100644 index 5a5c9b0f..00000000 --- a/src/libcamera/include/device_enumerator_sysfs.h +++ /dev/null @@ -1,32 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * device_enumerator_sysfs.h - sysfs-based device enumerator - */ -#ifndef __LIBCAMERA_DEVICE_ENUMERATOR_SYSFS_H__ -#define __LIBCAMERA_DEVICE_ENUMERATOR_SYSFS_H__ - -#include -#include - -#include "device_enumerator.h" - -class MediaDevice; - -namespace libcamera { - -class DeviceEnumeratorSysfs final : public DeviceEnumerator -{ -public: - int init(); - int enumerate(); - -private: - int populateMediaDevice(MediaDevice *media); - std::string lookupDeviceNode(int major, int minor); -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_DEVICE_ENUMERATOR_SYSFS_H__ */ diff --git a/src/libcamera/include/device_enumerator_udev.h b/src/libcamera/include/device_enumerator_udev.h deleted file mode 100644 index fdce4520..00000000 --- a/src/libcamera/include/device_enumerator_udev.h +++ /dev/null @@ -1,75 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2018-2019, Google Inc. - * - * device_enumerator_udev.h - udev-based device enumerator - */ -#ifndef __LIBCAMERA_DEVICE_ENUMERATOR_UDEV_H__ -#define __LIBCAMERA_DEVICE_ENUMERATOR_UDEV_H__ - -#include -#include -#include -#include -#include -#include - -#include "device_enumerator.h" - -struct udev; -struct udev_device; -struct udev_monitor; - -namespace libcamera { - -class EventNotifier; -class MediaDevice; -class MediaEntity; - -class DeviceEnumeratorUdev : public DeviceEnumerator -{ -public: - DeviceEnumeratorUdev(); - ~DeviceEnumeratorUdev(); - - int init() final; - int enumerate() final; - -private: - struct udev *udev_; - struct udev_monitor *monitor_; - EventNotifier *notifier_; - - using DependencyMap = std::map>; - - struct MediaDeviceDeps { - MediaDeviceDeps(std::unique_ptr &&media, - DependencyMap &&deps) - : media_(std::move(media)), deps_(std::move(deps)) - { - } - - bool operator==(const MediaDeviceDeps &other) const - { - return media_ == other.media_; - } - - std::unique_ptr media_; - DependencyMap deps_; - }; - - std::set orphans_; - std::list pending_; - std::map devMap_; - - int addUdevDevice(struct udev_device *dev); - int populateMediaDevice(MediaDevice *media, DependencyMap *deps); - std::string lookupDeviceNode(dev_t devnum); - - int addV4L2Device(dev_t devnum); - void udevNotify(EventNotifier *notifier); -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_DEVICE_ENUMERATOR_UDEV_H__ */ diff --git a/src/libcamera/include/event_dispatcher_poll.h b/src/libcamera/include/event_dispatcher_poll.h deleted file mode 100644 index 1f073861..00000000 --- a/src/libcamera/include/event_dispatcher_poll.h +++ /dev/null @@ -1,58 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * event_dispatcher_poll.h - Poll-based event dispatcher - */ -#ifndef __LIBCAMERA_EVENT_DISPATCHER_POLL_H__ -#define __LIBCAMERA_EVENT_DISPATCHER_POLL_H__ - -#include -#include -#include - -#include - -struct pollfd; - -namespace libcamera { - -class EventNotifier; -class Timer; - -class EventDispatcherPoll final : public EventDispatcher -{ -public: - EventDispatcherPoll(); - ~EventDispatcherPoll(); - - void registerEventNotifier(EventNotifier *notifier); - void unregisterEventNotifier(EventNotifier *notifier); - - void registerTimer(Timer *timer); - void unregisterTimer(Timer *timer); - - void processEvents(); - void interrupt(); - -private: - struct EventNotifierSetPoll { - short events() const; - EventNotifier *notifiers[3]; - }; - - std::map notifiers_; - std::list timers_; - int eventfd_; - - bool processingEvents_; - - int poll(std::vector *pollfds); - void processInterrupt(const struct pollfd &pfd); - void processNotifiers(const std::vector &pollfds); - void processTimers(); -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_EVENT_DISPATCHER_POLL_H__ */ diff --git a/src/libcamera/include/file.h b/src/libcamera/include/file.h deleted file mode 100644 index f020f2cc..00000000 --- a/src/libcamera/include/file.h +++ /dev/null @@ -1,71 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2020, Google Inc. - * - * file.h - File I/O operations - */ -#ifndef __LIBCAMERA_FILE_H__ -#define __LIBCAMERA_FILE_H__ - -#include -#include -#include - -#include - -namespace libcamera { - -class File -{ -public: - enum MapFlag { - MapNoOption = 0, - MapPrivate = (1 << 0), - }; - - enum OpenMode { - NotOpen = 0, - ReadOnly = (1 << 0), - WriteOnly = (1 << 1), - ReadWrite = ReadOnly | WriteOnly, - }; - - File(const std::string &name); - File(); - ~File(); - - File(const File &) = delete; - File &operator=(const File &) = delete; - - const std::string &fileName() const { return name_; } - void setFileName(const std::string &name); - bool exists() const; - - bool open(OpenMode mode); - bool isOpen() const { return fd_ != -1; } - OpenMode openMode() const { return mode_; } - void close(); - - int error() const { return error_; } - ssize_t size() const; - - Span map(off_t offset = 0, ssize_t size = -1, - MapFlag flags = MapNoOption); - bool unmap(uint8_t *addr); - - static bool exists(const std::string &name); - -private: - void unmapAll(); - - std::string name_; - int fd_; - OpenMode mode_; - - int error_; - std::map maps_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_FILE_H__ */ diff --git a/src/libcamera/include/formats.h b/src/libcamera/include/formats.h deleted file mode 100644 index 291a1108..00000000 --- a/src/libcamera/include/formats.h +++ /dev/null @@ -1,58 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * formats.h - libcamera image formats - */ - -#ifndef __LIBCAMERA_FORMATS_H__ -#define __LIBCAMERA_FORMATS_H__ - -#include -#include - -#include -#include - -#include "v4l2_pixelformat.h" - -namespace libcamera { - -class ImageFormats -{ -public: - int addFormat(unsigned int format, const std::vector &sizes); - - bool isEmpty() const; - std::vector formats() const; - const std::vector &sizes(unsigned int format) const; - const std::map> &data() const; - -private: - std::map> data_; -}; - -class PixelFormatInfo -{ -public: - enum ColourEncoding { - ColourEncodingRGB, - ColourEncodingYUV, - ColourEncodingRAW, - }; - - bool isValid() const { return format.isValid(); } - - static const PixelFormatInfo &info(const PixelFormat &format); - - /* \todo Add support for non-contiguous memory planes */ - PixelFormat format; - V4L2PixelFormat v4l2Format; - unsigned int bitsPerPixel; - enum ColourEncoding colourEncoding; - bool packed; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_FORMATS_H__ */ diff --git a/src/libcamera/include/ipa_context_wrapper.h b/src/libcamera/include/ipa_context_wrapper.h deleted file mode 100644 index 0db022ef..00000000 --- a/src/libcamera/include/ipa_context_wrapper.h +++ /dev/null @@ -1,50 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * ipa_context_wrapper.h - Image Processing Algorithm context wrapper - */ -#ifndef __LIBCAMERA_IPA_CONTEXT_WRAPPER_H__ -#define __LIBCAMERA_IPA_CONTEXT_WRAPPER_H__ - -#include - -#include "control_serializer.h" - -namespace libcamera { - -class IPAContextWrapper final : public IPAInterface -{ -public: - IPAContextWrapper(struct ipa_context *context); - ~IPAContextWrapper(); - - int init(const IPASettings &settings) override; - int start() override; - void stop() override; - void configure(const CameraSensorInfo &sensorInfo, - const std::map &streamConfig, - const std::map &entityControls) override; - - void mapBuffers(const std::vector &buffers) override; - void unmapBuffers(const std::vector &ids) override; - - virtual void processEvent(const IPAOperationData &data) override; - -private: - static void queue_frame_action(void *ctx, unsigned int frame, - struct ipa_operation_data &data); - static const struct ipa_callback_ops callbacks_; - - void doQueueFrameAction(unsigned int frame, - const IPAOperationData &data); - - struct ipa_context *ctx_; - IPAInterface *intf_; - - ControlSerializer serializer_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_IPA_CONTEXT_WRAPPER_H__ */ diff --git a/src/libcamera/include/ipa_manager.h b/src/libcamera/include/ipa_manager.h deleted file mode 100644 index aa6b9adb..00000000 --- a/src/libcamera/include/ipa_manager.h +++ /dev/null @@ -1,51 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * ipa_manager.h - Image Processing Algorithm module manager - */ -#ifndef __LIBCAMERA_IPA_MANAGER_H__ -#define __LIBCAMERA_IPA_MANAGER_H__ - -#include -#include - -#include -#include - -#include "ipa_module.h" -#include "pipeline_handler.h" -#include "pub_key.h" - -namespace libcamera { - -class IPAManager -{ -public: - static IPAManager *instance(); - - std::unique_ptr createIPA(PipelineHandler *pipe, - uint32_t maxVersion, - uint32_t minVersion); - -private: - std::vector modules_; - - IPAManager(); - ~IPAManager(); - - void parseDir(const char *libDir, unsigned int maxDepth, - std::vector &files); - unsigned int addDir(const char *libDir, unsigned int maxDepth = 0); - - bool isSignatureValid(IPAModule *ipa) const; - -#if HAVE_IPA_PUBKEY - static const uint8_t publicKeyData_[]; - static const PubKey pubKey_; -#endif -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_IPA_MANAGER_H__ */ diff --git a/src/libcamera/include/ipa_module.h b/src/libcamera/include/ipa_module.h deleted file mode 100644 index 15022e19..00000000 --- a/src/libcamera/include/ipa_module.h +++ /dev/null @@ -1,61 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * ipa_module.h - Image Processing Algorithm module - */ -#ifndef __LIBCAMERA_IPA_MODULE_H__ -#define __LIBCAMERA_IPA_MODULE_H__ - -#include -#include -#include - -#include -#include - -#include "log.h" -#include "pipeline_handler.h" - -namespace libcamera { - -class IPAModule : public Loggable -{ -public: - explicit IPAModule(const std::string &libPath); - ~IPAModule(); - - bool isValid() const; - - const struct IPAModuleInfo &info() const; - const std::vector signature() const; - const std::string &path() const; - - bool load(); - - struct ipa_context *createContext(); - - bool match(PipelineHandler *pipe, - uint32_t minVersion, uint32_t maxVersion) const; - -protected: - std::string logPrefix() const override; - -private: - struct IPAModuleInfo info_; - std::vector signature_; - - std::string libPath_; - bool valid_; - bool loaded_; - - void *dlHandle_; - typedef struct ipa_context *(*IPAIntfFactory)(void); - IPAIntfFactory ipaCreate_; - - int loadIPAModuleInfo(); -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_IPA_MODULE_H__ */ diff --git a/src/libcamera/include/ipa_proxy.h b/src/libcamera/include/ipa_proxy.h deleted file mode 100644 index 1111065b..00000000 --- a/src/libcamera/include/ipa_proxy.h +++ /dev/null @@ -1,70 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * ipa_proxy.h - Image Processing Algorithm proxy - */ -#ifndef __LIBCAMERA_IPA_PROXY_H__ -#define __LIBCAMERA_IPA_PROXY_H__ - -#include -#include -#include - -#include - -namespace libcamera { - -class IPAModule; - -class IPAProxy : public IPAInterface -{ -public: - IPAProxy(IPAModule *ipam); - ~IPAProxy(); - - bool isValid() const { return valid_; } - - std::string configurationFile(const std::string &file) const; - -protected: - std::string resolvePath(const std::string &file) const; - - bool valid_; - -private: - IPAModule *ipam_; -}; - -class IPAProxyFactory -{ -public: - IPAProxyFactory(const char *name); - virtual ~IPAProxyFactory() {} - - virtual std::unique_ptr create(IPAModule *ipam) = 0; - - const std::string &name() const { return name_; } - - static void registerType(IPAProxyFactory *factory); - static std::vector &factories(); - -private: - std::string name_; -}; - -#define REGISTER_IPA_PROXY(proxy) \ -class proxy##Factory final : public IPAProxyFactory \ -{ \ -public: \ - proxy##Factory() : IPAProxyFactory(#proxy) {} \ - std::unique_ptr create(IPAModule *ipam) \ - { \ - return std::make_unique(ipam); \ - } \ -}; \ -static proxy##Factory global_##proxy##Factory; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_IPA_PROXY_H__ */ diff --git a/src/libcamera/include/ipc_unixsocket.h b/src/libcamera/include/ipc_unixsocket.h deleted file mode 100644 index 820d0561..00000000 --- a/src/libcamera/include/ipc_unixsocket.h +++ /dev/null @@ -1,59 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * ipc_unixsocket.h - IPC mechanism based on Unix sockets - */ - -#ifndef __LIBCAMERA_IPC_UNIXSOCKET_H__ -#define __LIBCAMERA_IPC_UNIXSOCKET_H__ - -#include -#include -#include - -#include - -namespace libcamera { - -class IPCUnixSocket -{ -public: - struct Payload { - std::vector data; - std::vector fds; - }; - - IPCUnixSocket(); - ~IPCUnixSocket(); - - int create(); - int bind(int fd); - void close(); - bool isBound() const; - - int send(const Payload &payload); - int receive(Payload *payload); - - Signal readyRead; - -private: - struct Header { - uint32_t data; - uint8_t fds; - }; - - int sendData(const void *buffer, size_t length, const int32_t *fds, unsigned int num); - int recvData(void *buffer, size_t length, int32_t *fds, unsigned int num); - - void dataNotifier(EventNotifier *notifier); - - int fd_; - bool headerReceived_; - struct Header header_; - EventNotifier *notifier_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_IPC_UNIXSOCKET_H__ */ diff --git a/src/libcamera/include/log.h b/src/libcamera/include/log.h deleted file mode 100644 index ee0b4069..00000000 --- a/src/libcamera/include/log.h +++ /dev/null @@ -1,130 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2018, Google Inc. - * - * log.h - Logging infrastructure - */ -#ifndef __LIBCAMERA_LOG_H__ -#define __LIBCAMERA_LOG_H__ - -#include -#include - -#include "utils.h" - -namespace libcamera { - -enum LogSeverity { - LogInvalid = -1, - LogDebug = 0, - LogInfo, - LogWarning, - LogError, - LogFatal, -}; - -class LogCategory -{ -public: - explicit LogCategory(const char *name); - ~LogCategory(); - - const char *name() const { return name_; } - LogSeverity severity() const { return severity_; } - void setSeverity(LogSeverity severity); - - static const LogCategory &defaultCategory(); - -private: - const char *name_; - LogSeverity severity_; -}; - -#define LOG_DECLARE_CATEGORY(name) \ -extern const LogCategory &_LOG_CATEGORY(name)(); - -#define LOG_DEFINE_CATEGORY(name) \ -const LogCategory &_LOG_CATEGORY(name)() \ -{ \ - static LogCategory category(#name); \ - return category; \ -} - -class LogMessage -{ -public: - LogMessage(const char *fileName, unsigned int line, - LogSeverity severity); - LogMessage(const char *fileName, unsigned int line, - const LogCategory &category, LogSeverity severity); - LogMessage(const LogMessage &) = delete; - LogMessage(LogMessage &&); - ~LogMessage(); - - std::ostream &stream() { return msgStream_; } - - const utils::time_point ×tamp() const { return timestamp_; } - LogSeverity severity() const { return severity_; } - const LogCategory &category() const { return category_; } - const std::string &fileInfo() const { return fileInfo_; } - const std::string msg() const { return msgStream_.str(); } - -private: - void init(const char *fileName, unsigned int line); - - std::ostringstream msgStream_; - const LogCategory &category_; - LogSeverity severity_; - utils::time_point timestamp_; - std::string fileInfo_; -}; - -class Loggable -{ -public: - virtual ~Loggable(); - -protected: - virtual std::string logPrefix() const = 0; - - LogMessage _log(const char *file, unsigned int line, - LogSeverity severity) const; - LogMessage _log(const char *file, unsigned int line, - const LogCategory &category, - LogSeverity severity) const; -}; - -LogMessage _log(const char *file, unsigned int line, LogSeverity severity); -LogMessage _log(const char *file, unsigned int line, - const LogCategory &category, LogSeverity severity); - -#ifndef __DOXYGEN__ -#define _LOG_CATEGORY(name) logCategory##name - -#define _LOG1(severity) \ - _log(__FILE__, __LINE__, Log##severity).stream() -#define _LOG2(category, severity) \ - _log(__FILE__, __LINE__, _LOG_CATEGORY(category)(), Log##severity).stream() - -/* - * Expand the LOG() macro to _LOG1() or _LOG2() based on the number of - * arguments. - */ -#define _LOG_MACRO(_1, _2, NAME, ...) NAME -#define LOG(...) _LOG_MACRO(__VA_ARGS__, _LOG2, _LOG1)(__VA_ARGS__) -#else /* __DOXYGEN___ */ -#define LOG(category, severity) -#endif /* __DOXYGEN__ */ - -#ifndef NDEBUG -#define ASSERT(condition) static_cast(({ \ - if (!(condition)) \ - LOG(Fatal) << "assertion \"" #condition "\" failed"; \ -})) -#else -#define ASSERT(condition) static_cast(false && (condition)) -#endif - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_LOG_H__ */ diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h deleted file mode 100644 index 4d9f7661..00000000 --- a/src/libcamera/include/media_device.h +++ /dev/null @@ -1,94 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2018, Google Inc. - * - * media_device.h - Media device handler - */ -#ifndef __LIBCAMERA_MEDIA_DEVICE_H__ -#define __LIBCAMERA_MEDIA_DEVICE_H__ - -#include -#include -#include -#include - -#include - -#include - -#include "log.h" -#include "media_object.h" - -namespace libcamera { - -class MediaDevice : protected Loggable -{ -public: - MediaDevice(const std::string &deviceNode); - ~MediaDevice(); - - bool acquire(); - void release(); - bool busy() const { return acquired_; } - - bool lock(); - void unlock(); - - int populate(); - bool valid() const { return valid_; } - - const std::string driver() const { return driver_; } - const std::string deviceNode() const { return deviceNode_; } - const std::string model() const { return model_; } - unsigned int version() const { return version_; } - - const std::vector &entities() const { return entities_; } - MediaEntity *getEntityByName(const std::string &name) const; - - MediaLink *link(const std::string &sourceName, unsigned int sourceIdx, - const std::string &sinkName, unsigned int sinkIdx); - MediaLink *link(const MediaEntity *source, unsigned int sourceIdx, - const MediaEntity *sink, unsigned int sinkIdx); - MediaLink *link(const MediaPad *source, const MediaPad *sink); - int disableLinks(); - - Signal disconnected; - -protected: - std::string logPrefix() const; - -private: - std::string driver_; - std::string deviceNode_; - std::string model_; - unsigned int version_; - - int fd_; - bool valid_; - bool acquired_; - bool lockOwner_; - - int open(); - void close(); - - std::map objects_; - MediaObject *object(unsigned int id); - bool addObject(MediaObject *object); - void clear(); - - std::vector entities_; - - struct media_v2_interface *findInterface(const struct media_v2_topology &topology, - unsigned int entityId); - bool populateEntities(const struct media_v2_topology &topology); - bool populatePads(const struct media_v2_topology &topology); - bool populateLinks(const struct media_v2_topology &topology); - void fixupEntityFlags(struct media_v2_entity *entity); - - friend int MediaLink::setEnabled(bool enable); - int setupLink(const MediaLink *link, unsigned int flags); -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_MEDIA_DEVICE_H__ */ diff --git a/src/libcamera/include/media_object.h b/src/libcamera/include/media_object.h deleted file mode 100644 index 748eafdc..00000000 --- a/src/libcamera/include/media_object.h +++ /dev/null @@ -1,124 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2018, Google Inc. - * - * media_object.h - Media Device objects: entities, pads and links. - */ -#ifndef __LIBCAMERA_MEDIA_OBJECT_H__ -#define __LIBCAMERA_MEDIA_OBJECT_H__ - -#include -#include - -#include - -namespace libcamera { - -class MediaDevice; -class MediaEntity; -class MediaPad; - -class MediaObject -{ -public: - MediaDevice *device() { return dev_; } - unsigned int id() const { return id_; } - -protected: - friend class MediaDevice; - - MediaObject(MediaDevice *dev, unsigned int id) - : dev_(dev), id_(id) - { - } - virtual ~MediaObject() {} - - MediaDevice *dev_; - unsigned int id_; -}; - -class MediaLink : public MediaObject -{ -public: - MediaPad *source() const { return source_; } - MediaPad *sink() const { return sink_; } - unsigned int flags() const { return flags_; } - int setEnabled(bool enable); - -private: - friend class MediaDevice; - - MediaLink(const struct media_v2_link *link, - MediaPad *source, MediaPad *sink); - MediaLink(const MediaLink &) = delete; - ~MediaLink() {} - - MediaPad *source_; - MediaPad *sink_; - unsigned int flags_; -}; - -class MediaPad : public MediaObject -{ -public: - unsigned int index() const { return index_; } - MediaEntity *entity() const { return entity_; } - unsigned int flags() const { return flags_; } - const std::vector &links() const { return links_; } - - void addLink(MediaLink *link); - -private: - friend class MediaDevice; - - MediaPad(const struct media_v2_pad *pad, MediaEntity *entity); - MediaPad(const MediaPad &) = delete; - ~MediaPad(); - - unsigned int index_; - MediaEntity *entity_; - unsigned int flags_; - - std::vector links_; -}; - -class MediaEntity : public MediaObject -{ -public: - const std::string &name() const { return name_; } - unsigned int function() const { return function_; } - unsigned int flags() const { return flags_; } - const std::string &deviceNode() const { return deviceNode_; } - unsigned int deviceMajor() const { return major_; } - unsigned int deviceMinor() const { return minor_; } - - const std::vector &pads() const { return pads_; } - - const MediaPad *getPadByIndex(unsigned int index) const; - const MediaPad *getPadById(unsigned int id) const; - - int setDeviceNode(const std::string &deviceNode); - -private: - friend class MediaDevice; - - MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity, - unsigned int major = 0, unsigned int minor = 0); - MediaEntity(const MediaEntity &) = delete; - ~MediaEntity(); - - std::string name_; - unsigned int function_; - unsigned int flags_; - std::string deviceNode_; - unsigned int major_; - unsigned int minor_; - - std::vector pads_; - - void addPad(MediaPad *pad); -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_MEDIA_OBJECT_H__ */ diff --git a/src/libcamera/include/meson.build b/src/libcamera/include/meson.build deleted file mode 100644 index 1f6af579..00000000 --- a/src/libcamera/include/meson.build +++ /dev/null @@ -1,35 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 - -libcamera_headers = files([ - 'byte_stream_buffer.h', - 'camera_controls.h', - 'camera_sensor.h', - 'control_serializer.h', - 'control_validator.h', - 'device_enumerator.h', - 'device_enumerator_sysfs.h', - 'device_enumerator_udev.h', - 'event_dispatcher_poll.h', - 'file.h', - 'formats.h', - 'ipa_context_wrapper.h', - 'ipa_manager.h', - 'ipa_module.h', - 'ipa_proxy.h', - 'ipc_unixsocket.h', - 'log.h', - 'media_device.h', - 'media_object.h', - 'message.h', - 'pipeline_handler.h', - 'process.h', - 'pub_key.h', - 'semaphore.h', - 'thread.h', - 'utils.h', - 'v4l2_controls.h', - 'v4l2_device.h', - 'v4l2_pixelformat.h', - 'v4l2_subdevice.h', - 'v4l2_videodevice.h', -]) diff --git a/src/libcamera/include/message.h b/src/libcamera/include/message.h deleted file mode 100644 index 8e8b013d..00000000 --- a/src/libcamera/include/message.h +++ /dev/null @@ -1,70 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * message.h - Message queue support - */ -#ifndef __LIBCAMERA_MESSAGE_H__ -#define __LIBCAMERA_MESSAGE_H__ - -#include - -#include - -namespace libcamera { - -class BoundMethodBase; -class Object; -class Semaphore; -class Thread; - -class Message -{ -public: - enum Type { - None = 0, - InvokeMessage = 1, - ThreadMoveMessage = 2, - UserMessage = 1000, - }; - - Message(Type type); - virtual ~Message(); - - Type type() const { return type_; } - Object *receiver() const { return receiver_; } - - static Type registerMessageType(); - -private: - friend class Thread; - - Type type_; - Object *receiver_; - - static std::atomic_uint nextUserType_; -}; - -class InvokeMessage : public Message -{ -public: - InvokeMessage(BoundMethodBase *method, - std::shared_ptr pack, - Semaphore *semaphore = nullptr, - bool deleteMethod = false); - ~InvokeMessage(); - - Semaphore *semaphore() const { return semaphore_; } - - void invoke(); - -private: - BoundMethodBase *method_; - std::shared_ptr pack_; - Semaphore *semaphore_; - bool deleteMethod_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_MESSAGE_H__ */ diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h deleted file mode 100644 index 706413fa..00000000 --- a/src/libcamera/include/pipeline_handler.h +++ /dev/null @@ -1,151 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2018, Google Inc. - * - * pipeline_handler.h - Pipeline handler infrastructure - */ -#ifndef __LIBCAMERA_PIPELINE_HANDLER_H__ -#define __LIBCAMERA_PIPELINE_HANDLER_H__ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "ipa_proxy.h" - -namespace libcamera { - -class Camera; -class CameraConfiguration; -class CameraManager; -class DeviceEnumerator; -class DeviceMatch; -class FrameBuffer; -class MediaDevice; -class PipelineHandler; -class Request; - -class CameraData -{ -public: - explicit CameraData(PipelineHandler *pipe) - : pipe_(pipe) - { - } - virtual ~CameraData() {} - - Camera *camera_; - PipelineHandler *pipe_; - std::list queuedRequests_; - ControlInfoMap controlInfo_; - ControlList properties_; - std::unique_ptr ipa_; - -private: - CameraData(const CameraData &) = delete; - CameraData &operator=(const CameraData &) = delete; -}; - -class PipelineHandler : public std::enable_shared_from_this, - public Object -{ -public: - PipelineHandler(CameraManager *manager); - virtual ~PipelineHandler(); - - virtual bool match(DeviceEnumerator *enumerator) = 0; - MediaDevice *acquireMediaDevice(DeviceEnumerator *enumerator, - const DeviceMatch &dm); - - bool lock(); - void unlock(); - - const ControlInfoMap &controls(Camera *camera); - const ControlList &properties(Camera *camera); - - virtual CameraConfiguration *generateConfiguration(Camera *camera, - const StreamRoles &roles) = 0; - virtual int configure(Camera *camera, CameraConfiguration *config) = 0; - - virtual int exportFrameBuffers(Camera *camera, Stream *stream, - std::vector> *buffers) = 0; - - virtual int start(Camera *camera) = 0; - virtual void stop(Camera *camera) = 0; - - int queueRequest(Camera *camera, Request *request); - - bool completeBuffer(Camera *camera, Request *request, - FrameBuffer *buffer); - void completeRequest(Camera *camera, Request *request); - - const char *name() const { return name_; } - -protected: - void registerCamera(std::shared_ptr camera, - std::unique_ptr data, dev_t devnum = 0); - void hotplugMediaDevice(MediaDevice *media); - - virtual int queueRequestDevice(Camera *camera, Request *request) = 0; - - CameraData *cameraData(const Camera *camera); - - CameraManager *manager_; - -private: - void mediaDeviceDisconnected(MediaDevice *media); - virtual void disconnect(); - - std::vector> mediaDevices_; - std::vector> cameras_; - std::map> cameraData_; - - const char *name_; - - friend class PipelineHandlerFactory; -}; - -class PipelineHandlerFactory -{ -public: - PipelineHandlerFactory(const char *name); - virtual ~PipelineHandlerFactory() {} - - std::shared_ptr create(CameraManager *manager); - - const std::string &name() const { return name_; } - - static void registerType(PipelineHandlerFactory *factory); - static std::vector &factories(); - -private: - virtual PipelineHandler *createInstance(CameraManager *manager) = 0; - - std::string name_; -}; - -#define REGISTER_PIPELINE_HANDLER(handler) \ -class handler##Factory final : public PipelineHandlerFactory \ -{ \ -public: \ - handler##Factory() : PipelineHandlerFactory(#handler) {} \ - \ -private: \ - PipelineHandler *createInstance(CameraManager *manager) \ - { \ - return new handler(manager); \ - } \ -}; \ -static handler##Factory global_##handler##Factory; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_PIPELINE_HANDLER_H__ */ diff --git a/src/libcamera/include/process.h b/src/libcamera/include/process.h deleted file mode 100644 index d322fce1..00000000 --- a/src/libcamera/include/process.h +++ /dev/null @@ -1,55 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * process.h - Process object - */ -#ifndef __LIBCAMERA_PROCESS_H__ -#define __LIBCAMERA_PROCESS_H__ - -#include -#include - -#include - -namespace libcamera { - -class Process final -{ -public: - enum ExitStatus { - NotExited, - NormalExit, - SignalExit, - }; - - Process(); - ~Process(); - - int start(const std::string &path, - const std::vector &args = std::vector(), - const std::vector &fds = std::vector()); - - ExitStatus exitStatus() const { return exitStatus_; } - int exitCode() const { return exitCode_; } - - void kill(); - - Signal finished; - -private: - void closeAllFdsExcept(const std::vector &fds); - int isolate(); - void died(int wstatus); - - pid_t pid_; - bool running_; - enum ExitStatus exitStatus_; - int exitCode_; - - friend class ProcessManager; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_PROCESS_H__ */ diff --git a/src/libcamera/include/pub_key.h b/src/libcamera/include/pub_key.h deleted file mode 100644 index f35bf373..00000000 --- a/src/libcamera/include/pub_key.h +++ /dev/null @@ -1,38 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2020, Google Inc. - * - * pub_key.h - Public key signature verification - */ -#ifndef __LIBCAMERA_PUB_KEY_H__ -#define __LIBCAMERA_PUB_KEY_H__ - -#include - -#include - -#if HAVE_GNUTLS -struct gnutls_pubkey_st; -#endif - -namespace libcamera { - -class PubKey -{ -public: - PubKey(Span key); - ~PubKey(); - - bool isValid() const { return valid_; } - bool verify(Span data, Span sig) const; - -private: - bool valid_; -#if HAVE_GNUTLS - struct gnutls_pubkey_st *pubkey_; -#endif -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_PUB_KEY_H__ */ diff --git a/src/libcamera/include/semaphore.h b/src/libcamera/include/semaphore.h deleted file mode 100644 index c6b28653..00000000 --- a/src/libcamera/include/semaphore.h +++ /dev/null @@ -1,34 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * semaphore.h - General-purpose counting semaphore - */ -#ifndef __LIBCAMERA_SEMAPHORE_H__ -#define __LIBCAMERA_SEMAPHORE_H__ - -#include - -#include "thread.h" - -namespace libcamera { - -class Semaphore -{ -public: - Semaphore(unsigned int n = 0); - - unsigned int available(); - void acquire(unsigned int n = 1); - bool tryAcquire(unsigned int n = 1); - void release(unsigned int n = 1); - -private: - Mutex mutex_; - std::condition_variable cv_; - unsigned int available_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_SEMAPHORE_H__ */ diff --git a/src/libcamera/include/thread.h b/src/libcamera/include/thread.h deleted file mode 100644 index d700f111..00000000 --- a/src/libcamera/include/thread.h +++ /dev/null @@ -1,77 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * thread.h - Thread support - */ -#ifndef __LIBCAMERA_THREAD_H__ -#define __LIBCAMERA_THREAD_H__ - -#include -#include -#include -#include - -#include - -#include "utils.h" - -namespace libcamera { - -class EventDispatcher; -class Message; -class Object; -class ThreadData; -class ThreadMain; - -using Mutex = std::mutex; -using MutexLocker = std::unique_lock; - -class Thread -{ -public: - Thread(); - virtual ~Thread(); - - void start(); - void exit(int code = 0); - bool wait(utils::duration duration = utils::duration::max()); - - bool isRunning(); - - Signal finished; - - static Thread *current(); - static pid_t currentId(); - - EventDispatcher *eventDispatcher(); - void setEventDispatcher(std::unique_ptr dispatcher); - - void dispatchMessages(); - -protected: - int exec(); - virtual void run(); - -private: - void startThread(); - void finishThread(); - - void postMessage(std::unique_ptr msg, Object *receiver); - void removeMessages(Object *receiver); - - friend class Object; - friend class ThreadData; - friend class ThreadMain; - - void moveObject(Object *object); - void moveObject(Object *object, ThreadData *currentData, - ThreadData *targetData); - - std::thread thread_; - ThreadData *data_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_THREAD_H__ */ diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h deleted file mode 100644 index 3334ff16..00000000 --- a/src/libcamera/include/utils.h +++ /dev/null @@ -1,197 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2018, Google Inc. - * - * utils.h - Miscellaneous utility functions - */ -#ifndef __LIBCAMERA_UTILS_H__ -#define __LIBCAMERA_UTILS_H__ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - -#ifndef __DOXYGEN__ - -/* uClibc and uClibc-ng don't provide O_TMPFILE */ -#ifndef O_TMPFILE -#define O_TMPFILE (020000000 | O_DIRECTORY) -#endif - -#endif - -namespace libcamera { - -namespace utils { - -const char *basename(const char *path); - -char *secure_getenv(const char *name); -std::string dirname(const std::string &path); - -template -unsigned int set_overlap(InputIt1 first1, InputIt1 last1, - InputIt2 first2, InputIt2 last2) -{ - unsigned int count = 0; - - while (first1 != last1 && first2 != last2) { - if (*first1 < *first2) { - ++first1; - } else { - if (!(*first2 < *first1)) - count++; - ++first2; - } - } - - return count; -} - -/* C++11 doesn't provide std::clamp */ -template -const T& clamp(const T& v, const T& lo, const T& hi) -{ - return std::max(lo, std::min(v, hi)); -} - -using clock = std::chrono::steady_clock; -using duration = std::chrono::steady_clock::duration; -using time_point = std::chrono::steady_clock::time_point; - -struct timespec duration_to_timespec(const duration &value); -std::string time_point_to_string(const time_point &time); - -#ifndef __DOXYGEN__ -struct _hex { - uint64_t v; - unsigned int w; -}; - -std::basic_ostream> & -operator<<(std::basic_ostream> &stream, const _hex &h); -#endif - -template -_hex hex(T value, unsigned int width = 0); - -#ifndef __DOXYGEN__ -template<> -inline _hex hex(int32_t value, unsigned int width) -{ - return { static_cast(value), width ? width : 8 }; -} - -template<> -inline _hex hex(uint32_t value, unsigned int width) -{ - return { static_cast(value), width ? width : 8 }; -} - -template<> -inline _hex hex(int64_t value, unsigned int width) -{ - return { static_cast(value), width ? width : 16 }; -} - -template<> -inline _hex hex(uint64_t value, unsigned int width) -{ - return { static_cast(value), width ? width : 16 }; -} -#endif - -size_t strlcpy(char *dst, const char *src, size_t size); - -#ifndef __DOXYGEN__ -template -std::string join(const Container &items, const std::string &sep, UnaryOp op) -{ - std::ostringstream ss; - bool first = true; - - for (typename Container::const_iterator it = std::begin(items); - it != std::end(items); ++it) { - if (!first) - ss << sep; - else - first = false; - - ss << op(*it); - } - - return ss.str(); -} - -template -std::string join(const Container &items, const std::string &sep) -{ - std::ostringstream ss; - bool first = true; - - for (typename Container::const_iterator it = std::begin(items); - it != std::end(items); ++it) { - if (!first) - ss << sep; - else - first = false; - - ss << *it; - } - - return ss.str(); -} -#else -template -std::string join(const Container &items, const std::string &sep, UnaryOp op = nullptr); -#endif - -namespace details { - -class StringSplitter -{ -public: - StringSplitter(const std::string &str, const std::string &delim); - - class iterator - { - public: - iterator(const StringSplitter *ss, std::string::size_type pos); - - iterator &operator++(); - std::string operator*() const; - bool operator!=(const iterator &other) const; - - private: - const StringSplitter *ss_; - std::string::size_type pos_; - std::string::size_type next_; - }; - - iterator begin() const; - iterator end() const; - -private: - std::string str_; - std::string delim_; -}; - -} /* namespace details */ - -details::StringSplitter split(const std::string &str, const std::string &delim); - -std::string libcameraBuildPath(); -std::string libcameraSourcePath(); - -} /* namespace utils */ - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_UTILS_H__ */ diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h deleted file mode 100644 index cffe9efd..00000000 --- a/src/libcamera/include/v4l2_controls.h +++ /dev/null @@ -1,31 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * v4l2_controls.h - V4L2 Controls Support - */ - -#ifndef __LIBCAMERA_V4L2_CONTROLS_H__ -#define __LIBCAMERA_V4L2_CONTROLS_H__ - -#include - -#include - -namespace libcamera { - -class V4L2ControlId : public ControlId -{ -public: - V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl); -}; - -class V4L2ControlInfo : public ControlInfo -{ -public: - V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl); -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_V4L2_CONTROLS_H__ */ diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h deleted file mode 100644 index e604a40d..00000000 --- a/src/libcamera/include/v4l2_device.h +++ /dev/null @@ -1,60 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * v4l2_device.h - Common base for V4L2 video devices and subdevices - */ -#ifndef __LIBCAMERA_V4L2_DEVICE_H__ -#define __LIBCAMERA_V4L2_DEVICE_H__ - -#include -#include -#include - -#include - -#include "log.h" -#include "v4l2_controls.h" - -namespace libcamera { - -class V4L2Device : protected Loggable -{ -public: - void close(); - bool isOpen() const { return fd_ != -1; } - - const ControlInfoMap &controls() const { return controls_; } - - ControlList getControls(const std::vector &ids); - int setControls(ControlList *ctrls); - - const std::string &deviceNode() const { return deviceNode_; } - -protected: - V4L2Device(const std::string &deviceNode); - ~V4L2Device(); - - int open(unsigned int flags); - int setFd(int fd); - - int ioctl(unsigned long request, void *argp); - - int fd() { return fd_; } - -private: - void listControls(); - void updateControls(ControlList *ctrls, - const struct v4l2_ext_control *v4l2Ctrls, - unsigned int count); - - std::map controlInfo_; - std::vector> controlIds_; - ControlInfoMap controls_; - std::string deviceNode_; - int fd_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_V4L2_DEVICE_H__ */ diff --git a/src/libcamera/include/v4l2_pixelformat.h b/src/libcamera/include/v4l2_pixelformat.h deleted file mode 100644 index 0fe8a017..00000000 --- a/src/libcamera/include/v4l2_pixelformat.h +++ /dev/null @@ -1,49 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. - * - * v4l2_pixelformat.h - V4L2 Pixel Format - */ -#ifndef __LIBCAMERA_V4L2_PIXELFORMAT_H__ -#define __LIBCAMERA_V4L2_PIXELFORMAT_H__ - -#include -#include - -#include - -#include - -namespace libcamera { - -class V4L2PixelFormat -{ -public: - V4L2PixelFormat() - : fourcc_(0) - { - } - - explicit V4L2PixelFormat(uint32_t fourcc) - : fourcc_(fourcc) - { - } - - bool isValid() const { return fourcc_ != 0; } - uint32_t fourcc() const { return fourcc_; } - operator uint32_t() const { return fourcc_; } - - std::string toString() const; - - PixelFormat toPixelFormat() const; - static V4L2PixelFormat fromPixelFormat(const PixelFormat &pixelFormat, - bool multiplanar); - -private: - uint32_t fourcc_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_V4L2_PIXELFORMAT_H__ */ diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h deleted file mode 100644 index d0e565db..00000000 --- a/src/libcamera/include/v4l2_subdevice.h +++ /dev/null @@ -1,77 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * v4l2_subdevice.h - V4L2 Subdevice - */ -#ifndef __LIBCAMERA_V4L2_SUBDEVICE_H__ -#define __LIBCAMERA_V4L2_SUBDEVICE_H__ - -#include -#include - -#include - -#include "formats.h" -#include "log.h" -#include "media_object.h" -#include "v4l2_device.h" - -namespace libcamera { - -class MediaDevice; - -struct V4L2SubdeviceFormat { - uint32_t mbus_code; - Size size; - - const std::string toString() const; - uint8_t bitsPerPixel() const; -}; - -class V4L2Subdevice : public V4L2Device -{ -public: - enum Whence { - ActiveFormat, - TryFormat, - }; - - explicit V4L2Subdevice(const MediaEntity *entity); - V4L2Subdevice(const V4L2Subdevice &) = delete; - V4L2Subdevice &operator=(const V4L2Subdevice &) = delete; - ~V4L2Subdevice(); - - int open(); - - const MediaEntity *entity() const { return entity_; } - - int getSelection(unsigned int pad, unsigned int target, - Rectangle *rect); - int setSelection(unsigned int pad, unsigned int target, - Rectangle *rect); - - ImageFormats formats(unsigned int pad); - - int getFormat(unsigned int pad, V4L2SubdeviceFormat *format, - Whence whence = ActiveFormat); - int setFormat(unsigned int pad, V4L2SubdeviceFormat *format, - Whence whence = ActiveFormat); - - static V4L2Subdevice *fromEntityName(const MediaDevice *media, - const std::string &entity); - -protected: - std::string logPrefix() const; - -private: - std::vector enumPadCodes(unsigned int pad); - std::vector enumPadSizes(unsigned int pad, - unsigned int code); - - const MediaEntity *entity_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_V4L2_SUBDEVICE_H__ */ diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h deleted file mode 100644 index 94565b97..00000000 --- a/src/libcamera/include/v4l2_videodevice.h +++ /dev/null @@ -1,277 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * v4l2_videodevice.h - V4L2 Video Device - */ -#ifndef __LIBCAMERA_V4L2_VIDEODEVICE_H__ -#define __LIBCAMERA_V4L2_VIDEODEVICE_H__ - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include "formats.h" -#include "log.h" -#include "v4l2_device.h" -#include "v4l2_pixelformat.h" - -namespace libcamera { - -class EventNotifier; -class FileDescriptor; -class MediaDevice; -class MediaEntity; - -struct V4L2Capability final : v4l2_capability { - const char *driver() const - { - return reinterpret_cast(v4l2_capability::driver); - } - const char *card() const - { - return reinterpret_cast(v4l2_capability::card); - } - const char *bus_info() const - { - return reinterpret_cast(v4l2_capability::bus_info); - } - unsigned int device_caps() const - { - return capabilities & V4L2_CAP_DEVICE_CAPS - ? v4l2_capability::device_caps - : v4l2_capability::capabilities; - } - bool isMultiplanar() const - { - return device_caps() & (V4L2_CAP_VIDEO_CAPTURE_MPLANE | - V4L2_CAP_VIDEO_OUTPUT_MPLANE | - V4L2_CAP_VIDEO_M2M_MPLANE); - } - bool isCapture() const - { - return device_caps() & (V4L2_CAP_VIDEO_CAPTURE | - V4L2_CAP_VIDEO_CAPTURE_MPLANE | - V4L2_CAP_META_CAPTURE); - } - bool isOutput() const - { - return device_caps() & (V4L2_CAP_VIDEO_OUTPUT | - V4L2_CAP_VIDEO_OUTPUT_MPLANE | - V4L2_CAP_META_OUTPUT); - } - bool isVideo() const - { - return device_caps() & (V4L2_CAP_VIDEO_CAPTURE | - V4L2_CAP_VIDEO_CAPTURE_MPLANE | - V4L2_CAP_VIDEO_OUTPUT | - V4L2_CAP_VIDEO_OUTPUT_MPLANE); - } - bool isM2M() const - { - return device_caps() & (V4L2_CAP_VIDEO_M2M | - V4L2_CAP_VIDEO_M2M_MPLANE); - } - bool isMeta() const - { - return device_caps() & (V4L2_CAP_META_CAPTURE | - V4L2_CAP_META_OUTPUT); - } - bool isVideoCapture() const - { - return isVideo() && isCapture(); - } - bool isVideoOutput() const - { - return isVideo() && isOutput(); - } - bool isMetaCapture() const - { - return isMeta() && isCapture(); - } - bool isMetaOutput() const - { - return isMeta() && isOutput(); - } - bool hasStreaming() const - { - return device_caps() & V4L2_CAP_STREAMING; - } -}; - -class V4L2BufferCache -{ -public: - V4L2BufferCache(unsigned int numEntries); - V4L2BufferCache(const std::vector> &buffers); - ~V4L2BufferCache(); - - int get(const FrameBuffer &buffer); - void put(unsigned int index); - -private: - class Entry - { - public: - Entry(); - Entry(bool free, uint64_t lastUsed, const FrameBuffer &buffer); - - bool operator==(const FrameBuffer &buffer) const; - - bool free; - uint64_t lastUsed; - - private: - struct Plane { - Plane(const FrameBuffer::Plane &plane) - : fd(plane.fd.fd()), length(plane.length) - { - } - - int fd; - unsigned int length; - }; - - std::vector planes_; - }; - - std::atomic lastUsedCounter_; - std::vector cache_; - /* \todo Expose the miss counter through an instrumentation API. */ - unsigned int missCounter_; -}; - -class V4L2DeviceFormat -{ -public: - V4L2PixelFormat fourcc; - Size size; - - struct { - uint32_t size; - uint32_t bpl; - } planes[3]; - unsigned int planesCount; - - const std::string toString() const; -}; - -class V4L2VideoDevice : public V4L2Device -{ -public: - explicit V4L2VideoDevice(const std::string &deviceNode); - explicit V4L2VideoDevice(const MediaEntity *entity); - V4L2VideoDevice(const V4L2VideoDevice &) = delete; - ~V4L2VideoDevice(); - - V4L2VideoDevice &operator=(const V4L2VideoDevice &) = delete; - - int open(); - int open(int handle, enum v4l2_buf_type type); - void close(); - - const char *driverName() const { return caps_.driver(); } - const char *deviceName() const { return caps_.card(); } - const char *busName() const { return caps_.bus_info(); } - - const V4L2Capability &caps() const { return caps_; } - - int getFormat(V4L2DeviceFormat *format); - int setFormat(V4L2DeviceFormat *format); - std::map> formats(uint32_t code = 0); - - int setSelection(unsigned int target, Rectangle *rect); - - int allocateBuffers(unsigned int count, - std::vector> *buffers); - int exportBuffers(unsigned int count, - std::vector> *buffers); - int importBuffers(unsigned int count); - int releaseBuffers(); - - int queueBuffer(FrameBuffer *buffer); - Signal bufferReady; - - int setFrameStartEnabled(bool enable); - Signal frameStart; - - int streamOn(); - int streamOff(); - - static V4L2VideoDevice *fromEntityName(const MediaDevice *media, - const std::string &entity); - - V4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat); - -protected: - std::string logPrefix() const; - -private: - int getFormatMeta(V4L2DeviceFormat *format); - int setFormatMeta(V4L2DeviceFormat *format); - - int getFormatMultiplane(V4L2DeviceFormat *format); - int setFormatMultiplane(V4L2DeviceFormat *format); - - int getFormatSingleplane(V4L2DeviceFormat *format); - int setFormatSingleplane(V4L2DeviceFormat *format); - - std::vector enumPixelformats(uint32_t code); - std::vector enumSizes(V4L2PixelFormat pixelFormat); - - int requestBuffers(unsigned int count, enum v4l2_memory memoryType); - int createBuffers(unsigned int count, - std::vector> *buffers); - std::unique_ptr createBuffer(unsigned int index); - FileDescriptor exportDmabufFd(unsigned int index, unsigned int plane); - - void bufferAvailable(EventNotifier *notifier); - FrameBuffer *dequeueBuffer(); - - void eventAvailable(EventNotifier *notifier); - - V4L2Capability caps_; - - enum v4l2_buf_type bufferType_; - enum v4l2_memory memoryType_; - - V4L2BufferCache *cache_; - std::map queuedBuffers_; - - EventNotifier *fdBufferNotifier_; - EventNotifier *fdEventNotifier_; - - bool frameStartEnabled_; -}; - -class V4L2M2MDevice -{ -public: - V4L2M2MDevice(const std::string &deviceNode); - ~V4L2M2MDevice(); - - int open(); - void close(); - - V4L2VideoDevice *output() { return output_; } - V4L2VideoDevice *capture() { return capture_; } - -private: - std::string deviceNode_; - - V4L2VideoDevice *output_; - V4L2VideoDevice *capture_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_V4L2_VIDEODEVICE_H__ */ diff --git a/src/libcamera/ipa_context_wrapper.cpp b/src/libcamera/ipa_context_wrapper.cpp index 0bd3a1ae..bcdc55c2 100644 --- a/src/libcamera/ipa_context_wrapper.cpp +++ b/src/libcamera/ipa_context_wrapper.cpp @@ -5,15 +5,15 @@ * ipa_context_wrapper.cpp - Image Processing Algorithm context wrapper */ -#include "ipa_context_wrapper.h" +#include "libcamera/internal/ipa_context_wrapper.h" #include #include -#include "byte_stream_buffer.h" -#include "camera_sensor.h" -#include "utils.h" +#include "libcamera/internal/byte_stream_buffer.h" +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/utils.h" /** * \file ipa_context_wrapper.h diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 1faa3dd3..505cf610 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -5,19 +5,19 @@ * ipa_manager.cpp - Image Processing Algorithm module manager */ -#include "ipa_manager.h" +#include "libcamera/internal/ipa_manager.h" #include #include #include #include -#include "file.h" -#include "ipa_module.h" -#include "ipa_proxy.h" -#include "log.h" -#include "pipeline_handler.h" -#include "utils.h" +#include "libcamera/internal/file.h" +#include "libcamera/internal/ipa_module.h" +#include "libcamera/internal/ipa_proxy.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/utils.h" /** * \file ipa_manager.h diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index 3444a788..91534b61 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -5,7 +5,7 @@ * ipa_module.cpp - Image Processing Algorithm module */ -#include "ipa_module.h" +#include "libcamera/internal/ipa_module.h" #include #include @@ -23,10 +23,10 @@ #include -#include "file.h" -#include "log.h" -#include "pipeline_handler.h" -#include "utils.h" +#include "libcamera/internal/file.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/utils.h" /** * \file ipa_module.h diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index 401ac52d..23be24ad 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -5,16 +5,16 @@ * ipa_proxy.cpp - Image Processing Algorithm proxy */ -#include "ipa_proxy.h" +#include "libcamera/internal/ipa_proxy.h" #include #include #include #include -#include "ipa_module.h" -#include "log.h" -#include "utils.h" +#include "libcamera/internal/ipa_module.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/utils.h" /** * \file ipa_proxy.h diff --git a/src/libcamera/ipa_pub_key.cpp.in b/src/libcamera/ipa_pub_key.cpp.in index 7ffc1e24..01e5333b 100644 --- a/src/libcamera/ipa_pub_key.cpp.in +++ b/src/libcamera/ipa_pub_key.cpp.in @@ -7,7 +7,7 @@ * This file is auto-generated. Do not edit. */ -#include "ipa_manager.h" +#include "libcamera/internal/ipa_manager.h" namespace libcamera { diff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp index 6e5cab89..7df86e88 100644 --- a/src/libcamera/ipc_unixsocket.cpp +++ b/src/libcamera/ipc_unixsocket.cpp @@ -5,14 +5,14 @@ * ipc_unixsocket.cpp - IPC mechanism based on Unix sockets */ -#include "ipc_unixsocket.h" +#include "libcamera/internal/ipc_unixsocket.h" #include #include #include #include -#include "log.h" +#include "libcamera/internal/log.h" /** * \file ipc_unixsocket.h diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp index fd1b5c39..180eb97b 100644 --- a/src/libcamera/log.cpp +++ b/src/libcamera/log.cpp @@ -5,7 +5,7 @@ * log.cpp - Logging infrastructure */ -#include "log.h" +#include "libcamera/internal/log.h" #if HAVE_BACKTRACE #include @@ -22,8 +22,8 @@ #include -#include "thread.h" -#include "utils.h" +#include "libcamera/internal/thread.h" +#include "libcamera/internal/utils.h" /** * \file log.h diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index d4e7e100..de18d572 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -5,7 +5,7 @@ * media_device.cpp - Media device handler */ -#include "media_device.h" +#include "libcamera/internal/media_device.h" #include #include @@ -18,7 +18,7 @@ #include -#include "log.h" +#include "libcamera/internal/log.h" /** * \file media_device.h diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp index ef32065c..ce77a727 100644 --- a/src/libcamera/media_object.cpp +++ b/src/libcamera/media_object.cpp @@ -5,7 +5,7 @@ * media_object.cpp - Media device objects: entities, pads and links */ -#include "media_object.h" +#include "libcamera/internal/media_object.h" #include #include @@ -15,8 +15,8 @@ #include -#include "log.h" -#include "media_device.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" /** * \file media_object.h diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index d42e9720..472af451 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -51,13 +51,8 @@ libcamera_sources = files([ 'v4l2_videodevice.cpp', ]) -subdir('include') - -libcamera_internal_includes = include_directories('include') - includes = [ libcamera_includes, - libcamera_internal_includes, ] subdir('pipeline') diff --git a/src/libcamera/message.cpp b/src/libcamera/message.cpp index 77f2bdd5..e9b3e73f 100644 --- a/src/libcamera/message.cpp +++ b/src/libcamera/message.cpp @@ -5,11 +5,11 @@ * message.cpp - Message queue support */ -#include "message.h" +#include "libcamera/internal/message.h" #include -#include "log.h" +#include "libcamera/internal/log.h" /** * \file message.h diff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp index 99c3bf9a..1544a23e 100644 --- a/src/libcamera/object.cpp +++ b/src/libcamera/object.cpp @@ -11,11 +11,11 @@ #include -#include "log.h" -#include "message.h" -#include "semaphore.h" -#include "thread.h" -#include "utils.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/message.h" +#include "libcamera/internal/semaphore.h" +#include "libcamera/internal/thread.h" +#include "libcamera/internal/utils.h" /** * \file object.h diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 1988cb0e..b805fea7 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -17,15 +17,15 @@ #include #include -#include "camera_sensor.h" -#include "device_enumerator.h" -#include "log.h" -#include "media_device.h" -#include "pipeline_handler.h" -#include "utils.h" -#include "v4l2_controls.h" -#include "v4l2_subdevice.h" -#include "v4l2_videodevice.h" +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/utils.h" +#include "libcamera/internal/v4l2_controls.h" +#include "libcamera/internal/v4l2_subdevice.h" +#include "libcamera/internal/v4l2_videodevice.h" namespace libcamera { diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 41d1a522..e254e555 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -21,15 +21,16 @@ #include #include -#include "camera_sensor.h" -#include "device_enumerator.h" -#include "ipa_manager.h" -#include "media_device.h" -#include "pipeline_handler.h" +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/ipa_manager.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/utils.h" +#include "libcamera/internal/v4l2_controls.h" +#include "libcamera/internal/v4l2_videodevice.h" + #include "staggered_ctrl.h" -#include "utils.h" -#include "v4l2_controls.h" -#include "v4l2_videodevice.h" #include "vcsm.h" namespace libcamera { diff --git a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp index d431887e..391e13f5 100644 --- a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp +++ b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp @@ -11,9 +11,9 @@ #include -#include "log.h" -#include "utils.h" -#include "v4l2_videodevice.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/utils.h" +#include "libcamera/internal/v4l2_videodevice.h" namespace libcamera { diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 1e81a004..7a0c8771 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -20,16 +20,17 @@ #include #include -#include "camera_sensor.h" -#include "device_enumerator.h" -#include "ipa_manager.h" -#include "log.h" -#include "media_device.h" -#include "pipeline_handler.h" +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/ipa_manager.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/utils.h" +#include "libcamera/internal/v4l2_subdevice.h" +#include "libcamera/internal/v4l2_videodevice.h" + #include "timeline.h" -#include "utils.h" -#include "v4l2_subdevice.h" -#include "v4l2_videodevice.h" namespace libcamera { diff --git a/src/libcamera/pipeline/rkisp1/timeline.cpp b/src/libcamera/pipeline/rkisp1/timeline.cpp index f6c6434d..f5194608 100644 --- a/src/libcamera/pipeline/rkisp1/timeline.cpp +++ b/src/libcamera/pipeline/rkisp1/timeline.cpp @@ -7,7 +7,7 @@ #include "timeline.h" -#include "log.h" +#include "libcamera/internal/log.h" /** * \file timeline.h diff --git a/src/libcamera/pipeline/rkisp1/timeline.h b/src/libcamera/pipeline/rkisp1/timeline.h index 9d30e4ea..88f99329 100644 --- a/src/libcamera/pipeline/rkisp1/timeline.h +++ b/src/libcamera/pipeline/rkisp1/timeline.h @@ -12,7 +12,7 @@ #include -#include "utils.h" +#include "libcamera/internal/utils.h" namespace libcamera { diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp index 6d88776d..02443e7f 100644 --- a/src/libcamera/pipeline/simple/converter.cpp +++ b/src/libcamera/pipeline/simple/converter.cpp @@ -13,9 +13,9 @@ #include #include -#include "log.h" -#include "media_device.h" -#include "v4l2_videodevice.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/v4l2_videodevice.h" namespace libcamera { diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 66736061..25651900 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -24,13 +24,13 @@ #include #include -#include "camera_sensor.h" -#include "device_enumerator.h" -#include "log.h" -#include "media_device.h" -#include "pipeline_handler.h" -#include "v4l2_subdevice.h" -#include "v4l2_videodevice.h" +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/v4l2_subdevice.h" +#include "libcamera/internal/v4l2_videodevice.h" #include "converter.h" diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index f0c1337d..a0749094 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -17,13 +17,13 @@ #include #include -#include "device_enumerator.h" -#include "log.h" -#include "media_device.h" -#include "pipeline_handler.h" -#include "utils.h" -#include "v4l2_controls.h" -#include "v4l2_videodevice.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/utils.h" +#include "libcamera/internal/v4l2_controls.h" +#include "libcamera/internal/v4l2_videodevice.h" namespace libcamera { diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 128301e3..50a9f2df 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -22,16 +22,16 @@ #include #include -#include "camera_sensor.h" -#include "device_enumerator.h" -#include "ipa_manager.h" -#include "log.h" -#include "media_device.h" -#include "pipeline_handler.h" -#include "utils.h" -#include "v4l2_controls.h" -#include "v4l2_subdevice.h" -#include "v4l2_videodevice.h" +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/ipa_manager.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/utils.h" +#include "libcamera/internal/v4l2_controls.h" +#include "libcamera/internal/v4l2_subdevice.h" +#include "libcamera/internal/v4l2_videodevice.h" namespace libcamera { diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 254d341f..53aeebdc 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -5,7 +5,7 @@ * pipeline_handler.cpp - Pipeline handler infrastructure */ -#include "pipeline_handler.h" +#include "libcamera/internal/pipeline_handler.h" #include @@ -13,10 +13,10 @@ #include #include -#include "device_enumerator.h" -#include "log.h" -#include "media_device.h" -#include "utils.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/utils.h" /** * \file pipeline_handler.h diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index 3b4d0f10..e816ee86 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -5,7 +5,7 @@ * process.cpp - Process object */ -#include "process.h" +#include "libcamera/internal/process.h" #include #include @@ -22,8 +22,8 @@ #include -#include "log.h" -#include "utils.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/utils.h" /** * \file process.h diff --git a/src/libcamera/proxy/ipa_proxy_linux.cpp b/src/libcamera/proxy/ipa_proxy_linux.cpp index 9e0f44cf..7d6f8799 100644 --- a/src/libcamera/proxy/ipa_proxy_linux.cpp +++ b/src/libcamera/proxy/ipa_proxy_linux.cpp @@ -10,11 +10,11 @@ #include #include -#include "ipa_module.h" -#include "ipa_proxy.h" -#include "ipc_unixsocket.h" -#include "log.h" -#include "process.h" +#include "libcamera/internal/ipa_module.h" +#include "libcamera/internal/ipa_proxy.h" +#include "libcamera/internal/ipc_unixsocket.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/process.h" namespace libcamera { diff --git a/src/libcamera/proxy/ipa_proxy_thread.cpp b/src/libcamera/proxy/ipa_proxy_thread.cpp index 81d2d68e..03d4c0d9 100644 --- a/src/libcamera/proxy/ipa_proxy_thread.cpp +++ b/src/libcamera/proxy/ipa_proxy_thread.cpp @@ -10,11 +10,11 @@ #include #include -#include "ipa_context_wrapper.h" -#include "ipa_module.h" -#include "ipa_proxy.h" -#include "log.h" -#include "thread.h" +#include "libcamera/internal/ipa_context_wrapper.h" +#include "libcamera/internal/ipa_module.h" +#include "libcamera/internal/ipa_proxy.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/thread.h" namespace libcamera { diff --git a/src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp b/src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp index 9cefa240..9ba94d01 100644 --- a/src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp +++ b/src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp @@ -13,10 +13,10 @@ #include #include -#include "ipa_module.h" -#include "ipc_unixsocket.h" -#include "log.h" -#include "thread.h" +#include "libcamera/internal/ipa_module.h" +#include "libcamera/internal/ipc_unixsocket.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/thread.h" using namespace libcamera; diff --git a/src/libcamera/proxy/worker/meson.build b/src/libcamera/proxy/worker/meson.build index 1b1bee5e..ac0310a7 100644 --- a/src/libcamera/proxy/worker/meson.build +++ b/src/libcamera/proxy/worker/meson.build @@ -8,7 +8,6 @@ proxy_install_dir = join_paths(get_option('libexecdir'), 'libcamera') foreach t : ipa_proxy_sources proxy = executable(t[0], t[1], - include_directories : libcamera_internal_includes, install : true, install_dir : proxy_install_dir, dependencies : libcamera_dep) diff --git a/src/libcamera/pub_key.cpp b/src/libcamera/pub_key.cpp index 064d2dd2..2f60adbb 100644 --- a/src/libcamera/pub_key.cpp +++ b/src/libcamera/pub_key.cpp @@ -5,7 +5,7 @@ * pub_key.cpp - Public key signature verification */ -#include "pub_key.h" +#include "libcamera/internal/pub_key.h" #if HAVE_GNUTLS #include diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index ea33736f..6b9e0b4a 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -14,8 +14,8 @@ #include #include -#include "camera_controls.h" -#include "log.h" +#include "libcamera/internal/camera_controls.h" +#include "libcamera/internal/log.h" /** * \file request.h diff --git a/src/libcamera/semaphore.cpp b/src/libcamera/semaphore.cpp index ce1eae49..d8988a91 100644 --- a/src/libcamera/semaphore.cpp +++ b/src/libcamera/semaphore.cpp @@ -5,8 +5,8 @@ * semaphore.cpp - General-purpose counting semaphore */ -#include "semaphore.h" -#include "thread.h" +#include "libcamera/internal/semaphore.h" +#include "libcamera/internal/thread.h" /** * \file semaphore.h diff --git a/src/libcamera/signal.cpp b/src/libcamera/signal.cpp index 6eab1fa7..2532df3c 100644 --- a/src/libcamera/signal.cpp +++ b/src/libcamera/signal.cpp @@ -7,7 +7,7 @@ #include -#include "thread.h" +#include "libcamera/internal/thread.h" /** * \file signal.h diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 86c0b17d..f34348f2 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -15,8 +15,8 @@ #include -#include "log.h" -#include "utils.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/utils.h" /** * \file stream.h diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp index 85293c18..d1750d72 100644 --- a/src/libcamera/thread.cpp +++ b/src/libcamera/thread.cpp @@ -5,7 +5,7 @@ * thread.cpp - Thread support */ -#include "thread.h" +#include "libcamera/internal/thread.h" #include #include @@ -16,9 +16,9 @@ #include -#include "event_dispatcher_poll.h" -#include "log.h" -#include "message.h" +#include "libcamera/internal/event_dispatcher_poll.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/message.h" /** * \page thread Thread Support diff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp index 24da5152..24e452ed 100644 --- a/src/libcamera/timer.cpp +++ b/src/libcamera/timer.cpp @@ -12,10 +12,10 @@ #include #include -#include "log.h" -#include "message.h" -#include "thread.h" -#include "utils.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/message.h" +#include "libcamera/internal/thread.h" +#include "libcamera/internal/utils.h" /** * \file timer.h diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index fbadf350..d55338fe 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -5,7 +5,7 @@ * utils.cpp - Miscellaneous utility functions */ -#include "utils.h" +#include "libcamera/internal/utils.h" #include #include diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index 8e2415f2..3f8ec6ca 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -5,7 +5,7 @@ * v4l2_controls.cpp - V4L2 Controls Support */ -#include "v4l2_controls.h" +#include "libcamera/internal/v4l2_controls.h" #include diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index d08ab531..56ea1ddd 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -5,7 +5,7 @@ * v4l2_device.cpp - Common base for V4L2 video devices and subdevices */ -#include "v4l2_device.h" +#include "libcamera/internal/v4l2_device.h" #include #include @@ -14,9 +14,9 @@ #include #include -#include "log.h" -#include "utils.h" -#include "v4l2_controls.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/utils.h" +#include "libcamera/internal/v4l2_controls.h" /** * \file v4l2_device.h diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 561f9327..36776be9 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -6,7 +6,7 @@ * v4l2_pixelformat.cpp - V4L2 Pixel Format */ -#include "v4l2_pixelformat.h" +#include "libcamera/internal/v4l2_pixelformat.h" #include #include @@ -16,8 +16,8 @@ #include -#include "formats.h" -#include "log.h" +#include "libcamera/internal/formats.h" +#include "libcamera/internal/log.h" /** * \file v4l2_pixelformat.h diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 2b756178..7aefc1be 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -5,7 +5,7 @@ * v4l2_subdevice.cpp - V4L2 Subdevice */ -#include "v4l2_subdevice.h" +#include "libcamera/internal/v4l2_subdevice.h" #include #include @@ -19,10 +19,10 @@ #include -#include "log.h" -#include "media_device.h" -#include "media_object.h" -#include "utils.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/media_object.h" +#include "libcamera/internal/utils.h" /** * \file v4l2_subdevice.h diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 4b9f8b5c..d35596bd 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -5,7 +5,7 @@ * v4l2_videodevice.cpp - V4L2 Video Device */ -#include "v4l2_videodevice.h" +#include "libcamera/internal/v4l2_videodevice.h" #include #include @@ -23,10 +23,10 @@ #include #include -#include "log.h" -#include "media_device.h" -#include "media_object.h" -#include "utils.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/media_object.h" +#include "libcamera/internal/utils.h" /** * \file v4l2_videodevice.h diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build index fc1be82d..0fb941ea 100644 --- a/src/v4l2/meson.build +++ b/src/v4l2/meson.build @@ -22,6 +22,5 @@ v4l2_compat = shared_library('v4l2-compat', v4l2_compat_sources, name_prefix : '', install : true, - include_directories : libcamera_internal_includes, dependencies : [ libcamera_dep, libdl ], cpp_args : v4l2_compat_cpp_args) diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp index ecbb70ac..50a4121c 100644 --- a/src/v4l2/v4l2_camera.cpp +++ b/src/v4l2/v4l2_camera.cpp @@ -9,7 +9,7 @@ #include -#include "log.h" +#include "libcamera/internal/log.h" using namespace libcamera; diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h index 130995d9..c969130f 100644 --- a/src/v4l2/v4l2_camera.h +++ b/src/v4l2/v4l2_camera.h @@ -17,7 +17,7 @@ #include #include -#include "semaphore.h" +#include "libcamera/internal/semaphore.h" using namespace libcamera; diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 47d0528b..19e8f6d3 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -17,8 +17,9 @@ #include #include -#include "log.h" -#include "utils.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/utils.h" + #include "v4l2_camera.h" #include "v4l2_compat_manager.h" diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp index 961d06b3..cd8ac0b8 100644 --- a/src/v4l2/v4l2_compat_manager.cpp +++ b/src/v4l2/v4l2_compat_manager.cpp @@ -22,7 +22,7 @@ #include #include -#include "log.h" +#include "libcamera/internal/log.h" using namespace libcamera; diff --git a/test/byte-stream-buffer.cpp b/test/byte-stream-buffer.cpp index bc1d462e..d606f146 100644 --- a/test/byte-stream-buffer.cpp +++ b/test/byte-stream-buffer.cpp @@ -8,7 +8,8 @@ #include #include -#include "byte_stream_buffer.h" +#include "libcamera/internal/byte_stream_buffer.h" + #include "test.h" using namespace std; diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp index 6069d668..8c7fd1d2 100644 --- a/test/camera-sensor.cpp +++ b/test/camera-sensor.cpp @@ -10,11 +10,11 @@ #include -#include "camera_sensor.h" -#include "device_enumerator.h" -#include "media_device.h" -#include "utils.h" -#include "v4l2_subdevice.h" +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/utils.h" +#include "libcamera/internal/v4l2_subdevice.h" #include "test.h" diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp index 3f392cdc..ad680a83 100644 --- a/test/camera/buffer_import.cpp +++ b/test/camera/buffer_import.cpp @@ -12,9 +12,9 @@ #include #include -#include "device_enumerator.h" -#include "media_device.h" -#include "v4l2_videodevice.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/v4l2_videodevice.h" #include "buffer_source.h" #include "camera_test.h" diff --git a/test/controls/control_info_map.cpp b/test/controls/control_info_map.cpp index eeb702db..e4305f13 100644 --- a/test/controls/control_info_map.cpp +++ b/test/controls/control_info_map.cpp @@ -12,7 +12,7 @@ #include #include -#include "camera_controls.h" +#include "libcamera/internal/camera_controls.h" #include "camera_test.h" #include "test.h" diff --git a/test/controls/control_list.cpp b/test/controls/control_list.cpp index d51ec47d..5c8485b5 100644 --- a/test/controls/control_list.cpp +++ b/test/controls/control_list.cpp @@ -12,7 +12,7 @@ #include #include -#include "camera_controls.h" +#include "libcamera/internal/camera_controls.h" #include "camera_test.h" #include "test.h" diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp index 9f9cf178..1b617786 100644 --- a/test/event-dispatcher.cpp +++ b/test/event-dispatcher.cpp @@ -13,8 +13,9 @@ #include #include +#include "libcamera/internal/thread.h" + #include "test.h" -#include "thread.h" using namespace std; using namespace libcamera; diff --git a/test/event-thread.cpp b/test/event-thread.cpp index 01120733..c90e6ac0 100644 --- a/test/event-thread.cpp +++ b/test/event-thread.cpp @@ -13,8 +13,9 @@ #include #include +#include "libcamera/internal/thread.h" + #include "test.h" -#include "thread.h" using namespace std; using namespace libcamera; diff --git a/test/event.cpp b/test/event.cpp index 816060cc..c865092c 100644 --- a/test/event.cpp +++ b/test/event.cpp @@ -13,8 +13,9 @@ #include #include +#include "libcamera/internal/thread.h" + #include "test.h" -#include "thread.h" using namespace std; using namespace libcamera; diff --git a/test/file-descriptor.cpp b/test/file-descriptor.cpp index e467f3a7..7477a843 100644 --- a/test/file-descriptor.cpp +++ b/test/file-descriptor.cpp @@ -13,8 +13,9 @@ #include +#include "libcamera/internal/utils.h" + #include "test.h" -#include "utils.h" using namespace libcamera; using namespace std; diff --git a/test/file.cpp b/test/file.cpp index 65583998..6262a6f0 100644 --- a/test/file.cpp +++ b/test/file.cpp @@ -13,7 +13,8 @@ #include #include -#include "file.h" +#include "libcamera/internal/file.h" + #include "test.h" using namespace std; diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index 7fa88efe..c394377d 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -18,12 +18,13 @@ #include -#include "device_enumerator.h" -#include "ipa_manager.h" -#include "ipa_module.h" -#include "pipeline_handler.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/ipa_manager.h" +#include "libcamera/internal/ipa_module.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/thread.h" + #include "test.h" -#include "thread.h" using namespace std; using namespace libcamera; diff --git a/test/ipa/ipa_module_test.cpp b/test/ipa/ipa_module_test.cpp index e3aee190..bd5e0e4c 100644 --- a/test/ipa/ipa_module_test.cpp +++ b/test/ipa/ipa_module_test.cpp @@ -8,7 +8,7 @@ #include #include -#include "ipa_module.h" +#include "libcamera/internal/ipa_module.h" #include "test.h" diff --git a/test/ipa/ipa_wrappers_test.cpp b/test/ipa/ipa_wrappers_test.cpp index 4de13212..aa7a9dcc 100644 --- a/test/ipa/ipa_wrappers_test.cpp +++ b/test/ipa/ipa_wrappers_test.cpp @@ -15,11 +15,11 @@ #include #include -#include "camera_sensor.h" -#include "device_enumerator.h" -#include "ipa_context_wrapper.h" -#include "media_device.h" -#include "v4l2_subdevice.h" +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/ipa_context_wrapper.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/v4l2_subdevice.h" #include "test.h" diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp index f53042b8..4487d27b 100644 --- a/test/ipc/unixsocket.cpp +++ b/test/ipc/unixsocket.cpp @@ -18,10 +18,11 @@ #include #include -#include "ipc_unixsocket.h" +#include "libcamera/internal/ipc_unixsocket.h" +#include "libcamera/internal/thread.h" +#include "libcamera/internal/utils.h" + #include "test.h" -#include "thread.h" -#include "utils.h" #define CMD_CLOSE 0 #define CMD_REVERSE 1 diff --git a/test/libtest/buffer_source.cpp b/test/libtest/buffer_source.cpp index d1dad2a0..ee87c8cd 100644 --- a/test/libtest/buffer_source.cpp +++ b/test/libtest/buffer_source.cpp @@ -10,7 +10,7 @@ #include #include -#include "device_enumerator.h" +#include "libcamera/internal/device_enumerator.h" #include "test.h" diff --git a/test/libtest/buffer_source.h b/test/libtest/buffer_source.h index ae0879c9..95a82a82 100644 --- a/test/libtest/buffer_source.h +++ b/test/libtest/buffer_source.h @@ -9,8 +9,8 @@ #include -#include "media_device.h" -#include "v4l2_videodevice.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/v4l2_videodevice.h" using namespace libcamera; diff --git a/test/libtest/meson.build b/test/libtest/meson.build index 481f6d6b..542335ea 100644 --- a/test/libtest/meson.build +++ b/test/libtest/meson.build @@ -15,7 +15,6 @@ test_includes_public = [ test_includes_internal = [ test_includes_public, - libcamera_internal_includes, ] libtest = static_library('libtest', libtest_sources, diff --git a/test/log/log_api.cpp b/test/log/log_api.cpp index 33622f84..6f3248a7 100644 --- a/test/log/log_api.cpp +++ b/test/log/log_api.cpp @@ -18,7 +18,8 @@ #include -#include "log.h" +#include "libcamera/internal/log.h" + #include "test.h" using namespace std; diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp index 2df4aa43..8463d0ed 100644 --- a/test/log/log_process.cpp +++ b/test/log/log_process.cpp @@ -18,11 +18,12 @@ #include #include -#include "log.h" -#include "process.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/process.h" +#include "libcamera/internal/thread.h" +#include "libcamera/internal/utils.h" + #include "test.h" -#include "thread.h" -#include "utils.h" using namespace std; using namespace libcamera; diff --git a/test/media_device/media_device_print_test.cpp b/test/media_device/media_device_print_test.cpp index 5018906c..1f5e3f3e 100644 --- a/test/media_device/media_device_print_test.cpp +++ b/test/media_device/media_device_print_test.cpp @@ -10,7 +10,7 @@ #include #include -#include "media_device.h" +#include "libcamera/internal/media_device.h" #include "test.h" diff --git a/test/media_device/media_device_test.h b/test/media_device/media_device_test.h index cdbd1484..0c8bf9f2 100644 --- a/test/media_device/media_device_test.h +++ b/test/media_device/media_device_test.h @@ -9,8 +9,8 @@ #include -#include "device_enumerator.h" -#include "media_device.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/media_device.h" #include "test.h" diff --git a/test/message.cpp b/test/message.cpp index 478bc79d..9553ba8c 100644 --- a/test/message.cpp +++ b/test/message.cpp @@ -9,8 +9,9 @@ #include #include -#include "message.h" -#include "thread.h" +#include "libcamera/internal/message.h" +#include "libcamera/internal/thread.h" + #include "test.h" using namespace std; diff --git a/test/object-invoke.cpp b/test/object-invoke.cpp index fa162c83..1ae11bb1 100644 --- a/test/object-invoke.cpp +++ b/test/object-invoke.cpp @@ -11,8 +11,9 @@ #include #include +#include "libcamera/internal/thread.h" + #include "test.h" -#include "thread.h" using namespace std; using namespace libcamera; diff --git a/test/object.cpp b/test/object.cpp index 16118971..264659b4 100644 --- a/test/object.cpp +++ b/test/object.cpp @@ -9,8 +9,8 @@ #include -#include "message.h" -#include "thread.h" +#include "libcamera/internal/message.h" +#include "libcamera/internal/thread.h" #include "test.h" diff --git a/test/pipeline/ipu3/ipu3_pipeline_test.cpp b/test/pipeline/ipu3/ipu3_pipeline_test.cpp index a5c6be09..34998f8f 100644 --- a/test/pipeline/ipu3/ipu3_pipeline_test.cpp +++ b/test/pipeline/ipu3/ipu3_pipeline_test.cpp @@ -13,9 +13,10 @@ #include #include -#include "device_enumerator.h" -#include "media_device.h" -#include "media_object.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/media_object.h" + #include "test.h" using namespace std; diff --git a/test/pipeline/rkisp1/rkisp1_pipeline_test.cpp b/test/pipeline/rkisp1/rkisp1_pipeline_test.cpp index d46c928f..b6678ce7 100644 --- a/test/pipeline/rkisp1/rkisp1_pipeline_test.cpp +++ b/test/pipeline/rkisp1/rkisp1_pipeline_test.cpp @@ -16,9 +16,10 @@ #include #include -#include "device_enumerator.h" -#include "media_device.h" -#include "media_object.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/media_object.h" + #include "test.h" using namespace std; diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp index 7e7b3c2c..ce0cc7c9 100644 --- a/test/process/process_test.cpp +++ b/test/process/process_test.cpp @@ -12,10 +12,11 @@ #include #include -#include "process.h" +#include "libcamera/internal/process.h" +#include "libcamera/internal/thread.h" +#include "libcamera/internal/utils.h" + #include "test.h" -#include "thread.h" -#include "utils.h" using namespace std; using namespace libcamera; diff --git a/test/serialization/control_serialization.cpp b/test/serialization/control_serialization.cpp index 11136524..e23383d1 100644 --- a/test/serialization/control_serialization.cpp +++ b/test/serialization/control_serialization.cpp @@ -11,8 +11,9 @@ #include #include -#include "byte_stream_buffer.h" -#include "control_serializer.h" +#include "libcamera/internal/byte_stream_buffer.h" +#include "libcamera/internal/control_serializer.h" + #include "serialization_test.h" #include "test.h" diff --git a/test/signal-threads.cpp b/test/signal-threads.cpp index f77733eb..3c5f3792 100644 --- a/test/signal-threads.cpp +++ b/test/signal-threads.cpp @@ -9,10 +9,11 @@ #include #include -#include "message.h" -#include "thread.h" +#include "libcamera/internal/message.h" +#include "libcamera/internal/thread.h" +#include "libcamera/internal/utils.h" + #include "test.h" -#include "utils.h" using namespace std; using namespace libcamera; diff --git a/test/threads.cpp b/test/threads.cpp index 0454761d..b4b8d913 100644 --- a/test/threads.cpp +++ b/test/threads.cpp @@ -9,7 +9,8 @@ #include #include -#include "thread.h" +#include "libcamera/internal/thread.h" + #include "test.h" using namespace std; diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp index 32853b4e..2f901787 100644 --- a/test/timer-thread.cpp +++ b/test/timer-thread.cpp @@ -11,8 +11,9 @@ #include #include +#include "libcamera/internal/thread.h" + #include "test.h" -#include "thread.h" using namespace std; using namespace libcamera; diff --git a/test/timer.cpp b/test/timer.cpp index 2bdb006e..7d5b93c3 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -11,8 +11,9 @@ #include #include +#include "libcamera/internal/thread.h" + #include "test.h" -#include "thread.h" using namespace std; using namespace libcamera; diff --git a/test/utils.cpp b/test/utils.cpp index 55ce9365..66b91f12 100644 --- a/test/utils.cpp +++ b/test/utils.cpp @@ -12,8 +12,9 @@ #include +#include "libcamera/internal/utils.h" + #include "test.h" -#include "utils.h" using namespace std; using namespace libcamera; diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp index 067dc5ed..25503c33 100644 --- a/test/v4l2_subdevice/list_formats.cpp +++ b/test/v4l2_subdevice/list_formats.cpp @@ -11,7 +11,8 @@ #include -#include "v4l2_subdevice.h" +#include "libcamera/internal/v4l2_subdevice.h" + #include "v4l2_subdevice_test.h" using namespace std; diff --git a/test/v4l2_subdevice/test_formats.cpp b/test/v4l2_subdevice/test_formats.cpp index 5cf5d566..9635c994 100644 --- a/test/v4l2_subdevice/test_formats.cpp +++ b/test/v4l2_subdevice/test_formats.cpp @@ -8,7 +8,8 @@ #include #include -#include "v4l2_subdevice.h" +#include "libcamera/internal/v4l2_subdevice.h" + #include "v4l2_subdevice_test.h" using namespace std; diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.cpp b/test/v4l2_subdevice/v4l2_subdevice_test.cpp index 562a638c..d8fbfd9f 100644 --- a/test/v4l2_subdevice/v4l2_subdevice_test.cpp +++ b/test/v4l2_subdevice/v4l2_subdevice_test.cpp @@ -9,9 +9,10 @@ #include #include -#include "device_enumerator.h" -#include "media_device.h" -#include "v4l2_subdevice.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/v4l2_subdevice.h" + #include "v4l2_subdevice_test.h" using namespace std; diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.h b/test/v4l2_subdevice/v4l2_subdevice_test.h index 3bce6691..00c6399d 100644 --- a/test/v4l2_subdevice/v4l2_subdevice_test.h +++ b/test/v4l2_subdevice/v4l2_subdevice_test.h @@ -10,10 +10,11 @@ #include -#include "device_enumerator.h" -#include "media_device.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/v4l2_subdevice.h" + #include "test.h" -#include "v4l2_subdevice.h" using namespace libcamera; diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp index 14d3055a..ba2cc40d 100644 --- a/test/v4l2_videodevice/buffer_sharing.cpp +++ b/test/v4l2_videodevice/buffer_sharing.cpp @@ -16,7 +16,8 @@ #include #include -#include "thread.h" +#include "libcamera/internal/thread.h" + #include "v4l2_videodevice_test.h" class BufferSharingTest : public V4L2VideoDeviceTest diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp index b38aabc6..13cbcc80 100644 --- a/test/v4l2_videodevice/capture_async.cpp +++ b/test/v4l2_videodevice/capture_async.cpp @@ -11,7 +11,8 @@ #include #include -#include "thread.h" +#include "libcamera/internal/thread.h" + #include "v4l2_videodevice_test.h" class CaptureAsyncTest : public V4L2VideoDeviceTest diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp index 347af211..9f09d036 100644 --- a/test/v4l2_videodevice/controls.cpp +++ b/test/v4l2_videodevice/controls.cpp @@ -10,7 +10,7 @@ #include #include -#include "v4l2_videodevice.h" +#include "libcamera/internal/v4l2_videodevice.h" #include "v4l2_videodevice_test.h" diff --git a/test/v4l2_videodevice/formats.cpp b/test/v4l2_videodevice/formats.cpp index a7421421..043732dc 100644 --- a/test/v4l2_videodevice/formats.cpp +++ b/test/v4l2_videodevice/formats.cpp @@ -8,8 +8,8 @@ #include #include -#include "utils.h" -#include "v4l2_videodevice.h" +#include "libcamera/internal/utils.h" +#include "libcamera/internal/v4l2_videodevice.h" #include "v4l2_videodevice_test.h" diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp index d20e5dfc..44a39d4d 100644 --- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp +++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp @@ -11,10 +11,10 @@ #include #include -#include "device_enumerator.h" -#include "media_device.h" -#include "thread.h" -#include "v4l2_videodevice.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/thread.h" +#include "libcamera/internal/v4l2_videodevice.h" #include "test.h" diff --git a/test/v4l2_videodevice/v4l2_videodevice_test.cpp b/test/v4l2_videodevice/v4l2_videodevice_test.cpp index 93b9e72d..f23aaf8f 100644 --- a/test/v4l2_videodevice/v4l2_videodevice_test.cpp +++ b/test/v4l2_videodevice/v4l2_videodevice_test.cpp @@ -9,10 +9,10 @@ #include -#include "v4l2_videodevice_test.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/media_device.h" -#include "device_enumerator.h" -#include "media_device.h" +#include "v4l2_videodevice_test.h" using namespace std; using namespace libcamera; diff --git a/test/v4l2_videodevice/v4l2_videodevice_test.h b/test/v4l2_videodevice/v4l2_videodevice_test.h index 9acaceb8..21054561 100644 --- a/test/v4l2_videodevice/v4l2_videodevice_test.h +++ b/test/v4l2_videodevice/v4l2_videodevice_test.h @@ -11,13 +11,13 @@ #include -#include "test.h" +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/v4l2_subdevice.h" +#include "libcamera/internal/v4l2_videodevice.h" -#include "camera_sensor.h" -#include "device_enumerator.h" -#include "media_device.h" -#include "v4l2_subdevice.h" -#include "v4l2_videodevice.h" +#include "test.h" using namespace libcamera; -- cgit v1.2.1