diff options
Diffstat (limited to 'include/libcamera')
-rw-r--r-- | include/libcamera/internal/ipa_context_wrapper.h | 2 | ||||
-rw-r--r-- | include/libcamera/internal/ipa_manager.h | 4 | ||||
-rw-r--r-- | include/libcamera/internal/ipa_module.h | 4 | ||||
-rw-r--r-- | include/libcamera/internal/ipa_proxy.h | 2 | ||||
-rw-r--r-- | include/libcamera/ipa/ipa_controls.h | 47 | ||||
-rw-r--r-- | include/libcamera/ipa/ipa_interface.h | 173 | ||||
-rw-r--r-- | include/libcamera/ipa/ipa_module_info.h | 29 | ||||
-rw-r--r-- | include/libcamera/ipa/ipa_vimc.h | 24 | ||||
-rw-r--r-- | include/libcamera/ipa/meson.build | 10 | ||||
-rw-r--r-- | include/libcamera/ipa/raspberrypi.h | 58 | ||||
-rw-r--r-- | include/libcamera/ipa/rkisp1.h | 18 | ||||
-rw-r--r-- | include/libcamera/meson.build | 1 |
12 files changed, 366 insertions, 6 deletions
diff --git a/include/libcamera/internal/ipa_context_wrapper.h b/include/libcamera/internal/ipa_context_wrapper.h index a717d406..bd770e13 100644 --- a/include/libcamera/internal/ipa_context_wrapper.h +++ b/include/libcamera/internal/ipa_context_wrapper.h @@ -7,7 +7,7 @@ #ifndef __LIBCAMERA_IPA_CONTEXT_WRAPPER_H__ #define __LIBCAMERA_IPA_CONTEXT_WRAPPER_H__ -#include <ipa/ipa_interface.h> +#include <libcamera/ipa/ipa_interface.h> #include "libcamera/internal/control_serializer.h" diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h index f07d91fc..2412d757 100644 --- a/include/libcamera/internal/ipa_manager.h +++ b/include/libcamera/internal/ipa_manager.h @@ -10,8 +10,8 @@ #include <stdint.h> #include <vector> -#include <ipa/ipa_interface.h> -#include <ipa/ipa_module_info.h> +#include <libcamera/ipa/ipa_interface.h> +#include <libcamera/ipa/ipa_module_info.h> #include "libcamera/internal/ipa_module.h" #include "libcamera/internal/pipeline_handler.h" diff --git a/include/libcamera/internal/ipa_module.h b/include/libcamera/internal/ipa_module.h index 2f569db0..5b54cb31 100644 --- a/include/libcamera/internal/ipa_module.h +++ b/include/libcamera/internal/ipa_module.h @@ -11,8 +11,8 @@ #include <string> #include <vector> -#include <ipa/ipa_interface.h> -#include <ipa/ipa_module_info.h> +#include <libcamera/ipa/ipa_interface.h> +#include <libcamera/ipa/ipa_module_info.h> #include "libcamera/internal/log.h" #include "libcamera/internal/pipeline_handler.h" diff --git a/include/libcamera/internal/ipa_proxy.h b/include/libcamera/internal/ipa_proxy.h index 1111065b..e9a36608 100644 --- a/include/libcamera/internal/ipa_proxy.h +++ b/include/libcamera/internal/ipa_proxy.h @@ -11,7 +11,7 @@ #include <string> #include <vector> -#include <ipa/ipa_interface.h> +#include <libcamera/ipa/ipa_interface.h> namespace libcamera { diff --git a/include/libcamera/ipa/ipa_controls.h b/include/libcamera/ipa/ipa_controls.h new file mode 100644 index 00000000..6d3bf279 --- /dev/null +++ b/include/libcamera/ipa/ipa_controls.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_controls.h - IPA Control handling + */ +#ifndef __LIBCAMERA_IPA_CONTROLS_H__ +#define __LIBCAMERA_IPA_CONTROLS_H__ + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define IPA_CONTROLS_FORMAT_VERSION 1 + +struct ipa_controls_header { + uint32_t version; + uint32_t handle; + uint32_t entries; + uint32_t size; + uint32_t data_offset; + uint32_t reserved[3]; +}; + +struct ipa_control_value_entry { + uint32_t id; + uint8_t type; + uint8_t is_array; + uint16_t count; + uint32_t offset; + uint32_t padding[1]; +}; + +struct ipa_control_info_entry { + uint32_t id; + uint32_t type; + uint32_t offset; + uint32_t padding[1]; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* __LIBCAMERA_IPA_CONTROLS_H__ */ diff --git a/include/libcamera/ipa/ipa_interface.h b/include/libcamera/ipa/ipa_interface.h new file mode 100644 index 00000000..dc9fc714 --- /dev/null +++ b/include/libcamera/ipa/ipa_interface.h @@ -0,0 +1,173 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_interface.h - Image Processing Algorithm interface + */ +#ifndef __LIBCAMERA_IPA_INTERFACE_H__ +#define __LIBCAMERA_IPA_INTERFACE_H__ + +#include <stddef.h> +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct ipa_context { + const struct ipa_context_ops *ops; +}; + +struct ipa_settings { + const char *configuration_file; +}; + +struct ipa_sensor_info { + const char *model; + uint8_t bits_per_pixel; + struct { + uint32_t width; + uint32_t height; + } active_area; + struct { + int32_t left; + int32_t top; + uint32_t width; + uint32_t height; + } analog_crop; + struct { + uint32_t width; + uint32_t height; + } output_size; + uint64_t pixel_rate; + uint32_t line_length; +}; + +struct ipa_stream { + unsigned int id; + unsigned int pixel_format; + unsigned int width; + unsigned int height; +}; + +struct ipa_control_info_map { + unsigned int id; + const uint8_t *data; + size_t size; +}; + +struct ipa_buffer_plane { + int dmabuf; + size_t length; +}; + +struct ipa_buffer { + unsigned int id; + unsigned int num_planes; + struct ipa_buffer_plane planes[3]; +}; + +struct ipa_control_list { + const uint8_t *data; + unsigned int size; +}; + +struct ipa_operation_data { + unsigned int operation; + const uint32_t *data; + unsigned int num_data; + const struct ipa_control_list *lists; + unsigned int num_lists; +}; + +struct ipa_callback_ops { + void (*queue_frame_action)(void *cb_ctx, unsigned int frame, + struct ipa_operation_data &data); +}; + +struct ipa_context_ops { + void (*destroy)(struct ipa_context *ctx); + void *(*get_interface)(struct ipa_context *ctx); + void (*init)(struct ipa_context *ctx, + const struct ipa_settings *settings); + int (*start)(struct ipa_context *ctx); + void (*stop)(struct ipa_context *ctx); + void (*register_callbacks)(struct ipa_context *ctx, + const struct ipa_callback_ops *callbacks, + void *cb_ctx); + void (*configure)(struct ipa_context *ctx, + const struct ipa_sensor_info *sensor_info, + const struct ipa_stream *streams, + unsigned int num_streams, + const struct ipa_control_info_map *maps, + unsigned int num_maps); + void (*map_buffers)(struct ipa_context *ctx, + const struct ipa_buffer *buffers, + size_t num_buffers); + void (*unmap_buffers)(struct ipa_context *ctx, const unsigned int *ids, + size_t num_buffers); + void (*process_event)(struct ipa_context *ctx, + const struct ipa_operation_data *data); +}; + +struct ipa_context *ipaCreate(); + +#ifdef __cplusplus +} + +#include <map> +#include <vector> + +#include <libcamera/buffer.h> +#include <libcamera/controls.h> +#include <libcamera/geometry.h> +#include <libcamera/signal.h> + +namespace libcamera { + +struct IPASettings { + std::string configurationFile; +}; + +struct IPAStream { + unsigned int pixelFormat; + Size size; +}; + +struct IPABuffer { + unsigned int id; + std::vector<FrameBuffer::Plane> planes; +}; + +struct IPAOperationData { + unsigned int operation; + std::vector<uint32_t> data; + std::vector<ControlList> controls; +}; + +struct CameraSensorInfo; + +class IPAInterface +{ +public: + virtual ~IPAInterface() {} + + virtual int init(const IPASettings &settings) = 0; + virtual int start() = 0; + virtual void stop() = 0; + + virtual void configure(const CameraSensorInfo &sensorInfo, + const std::map<unsigned int, IPAStream> &streamConfig, + const std::map<unsigned int, const ControlInfoMap &> &entityControls) = 0; + + virtual void mapBuffers(const std::vector<IPABuffer> &buffers) = 0; + virtual void unmapBuffers(const std::vector<unsigned int> &ids) = 0; + + virtual void processEvent(const IPAOperationData &data) = 0; + Signal<unsigned int, const IPAOperationData &> queueFrameAction; +}; + +} /* namespace libcamera */ +#endif + +#endif /* __LIBCAMERA_IPA_INTERFACE_H__ */ diff --git a/include/libcamera/ipa/ipa_module_info.h b/include/libcamera/ipa/ipa_module_info.h new file mode 100644 index 00000000..3b1c37d2 --- /dev/null +++ b/include/libcamera/ipa/ipa_module_info.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_module_info.h - Image Processing Algorithm module information + */ +#ifndef __LIBCAMERA_IPA_MODULE_INFO_H__ +#define __LIBCAMERA_IPA_MODULE_INFO_H__ + +#include <stdint.h> + +#define IPA_MODULE_API_VERSION 1 + +namespace libcamera { + +struct IPAModuleInfo { + int moduleAPIVersion; + uint32_t pipelineVersion; + char pipelineName[256]; + char name[256]; +} __attribute__((packed)); + +extern "C" { +extern const struct IPAModuleInfo ipaModuleInfo; +} + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPA_MODULE_INFO_H__ */ diff --git a/include/libcamera/ipa/ipa_vimc.h b/include/libcamera/ipa/ipa_vimc.h new file mode 100644 index 00000000..8e82dd94 --- /dev/null +++ b/include/libcamera/ipa/ipa_vimc.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_vimc.h - Vimc Image Processing Algorithm module + */ + +#ifndef __LIBCAMERA_IPA_VIMC_H__ +#define __LIBCAMERA_IPA_VIMC_H__ + +namespace libcamera { + +#define VIMC_IPA_FIFO_PATH "/tmp/libcamera_ipa_vimc_fifo" + +enum IPAOperationCode { + IPAOperationNone, + IPAOperationInit, + IPAOperationStart, + IPAOperationStop, +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPA_VIMC_H__ */ diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build new file mode 100644 index 00000000..3d5c0dd6 --- /dev/null +++ b/include/libcamera/ipa/meson.build @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: CC0-1.0 + +libcamera_ipa_api = files([ + 'ipa_controls.h', + 'ipa_interface.h', + 'ipa_module_info.h', +]) + +install_headers(libcamera_ipa_api, + subdir: join_paths(libcamera_include_dir, 'ipa')) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h new file mode 100644 index 00000000..c109469e --- /dev/null +++ b/include/libcamera/ipa/raspberrypi.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019-2020, Raspberry Pi Ltd. + * + * raspberrypi.h - Image Processing Algorithm interface for Raspberry Pi + */ +#ifndef __LIBCAMERA_IPA_INTERFACE_RASPBERRYPI_H__ +#define __LIBCAMERA_IPA_INTERFACE_RASPBERRYPI_H__ + +#include <libcamera/control_ids.h> +#include <libcamera/controls.h> + +enum RPiOperations { + RPI_IPA_ACTION_V4L2_SET_STAGGERED = 1, + RPI_IPA_ACTION_V4L2_SET_ISP, + RPI_IPA_ACTION_STATS_METADATA_COMPLETE, + RPI_IPA_ACTION_RUN_ISP, + RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME, + RPI_IPA_ACTION_SET_SENSOR_CONFIG, + RPI_IPA_ACTION_EMBEDDED_COMPLETE, + RPI_IPA_EVENT_SIGNAL_STAT_READY, + RPI_IPA_EVENT_SIGNAL_ISP_PREPARE, + RPI_IPA_EVENT_QUEUE_REQUEST, + RPI_IPA_EVENT_LS_TABLE_ALLOCATION, +}; + +enum RPiIpaMask { + ID = 0x0ffff, + STATS = 0x10000, + EMBEDDED_DATA = 0x20000, + BAYER_DATA = 0x40000 +}; + +/* Size of the LS grid allocation. */ +#define MAX_LS_GRID_SIZE (32 << 10) + +namespace libcamera { + +/* List of controls handled by the Raspberry Pi IPA */ +static const ControlInfoMap RPiControls = { + { &controls::AeEnable, ControlInfo(false, true) }, + { &controls::ExposureTime, ControlInfo(0, 999999) }, + { &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) }, + { &controls::AeMeteringMode, ControlInfo(0, static_cast<int32_t>(controls::MeteringModeMax)) }, + { &controls::AeConstraintMode, ControlInfo(0, static_cast<int32_t>(controls::ConstraintModeMax)) }, + { &controls::AeExposureMode, ControlInfo(0, static_cast<int32_t>(controls::ExposureModeMax)) }, + { &controls::ExposureValue, ControlInfo(0.0f, 16.0f) }, + { &controls::AwbEnable, ControlInfo(false, true) }, + { &controls::ColourGains, ControlInfo(0.0f, 32.0f) }, + { &controls::AwbMode, ControlInfo(0, static_cast<int32_t>(controls::AwbModeMax)) }, + { &controls::Brightness, ControlInfo(-1.0f, 1.0f) }, + { &controls::Contrast, ControlInfo(0.0f, 32.0f) }, + { &controls::Saturation, ControlInfo(0.0f, 32.0f) }, +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPA_INTERFACE_RASPBERRYPI_H__ */ diff --git a/include/libcamera/ipa/rkisp1.h b/include/libcamera/ipa/rkisp1.h new file mode 100644 index 00000000..4fe0482b --- /dev/null +++ b/include/libcamera/ipa/rkisp1.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * rkisp1.h - Image Processing Algorithm interface for RkISP1 + */ +#ifndef __LIBCAMERA_IPA_INTERFACE_RKISP1_H__ +#define __LIBCAMERA_IPA_INTERFACE_RKISP1_H__ + +enum RkISP1Operations { + RKISP1_IPA_ACTION_V4L2_SET = 1, + RKISP1_IPA_ACTION_PARAM_FILLED = 2, + RKISP1_IPA_ACTION_METADATA = 3, + RKISP1_IPA_EVENT_SIGNAL_STAT_BUFFER = 4, + RKISP1_IPA_EVENT_QUEUE_REQUEST = 5, +}; + +#endif /* __LIBCAMERA_IPA_INTERFACE_RKISP1_H__ */ diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index f9c8e64b..32b8d142 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -24,6 +24,7 @@ libcamera_api = files([ include_dir = join_paths(libcamera_include_dir, 'libcamera') subdir('internal') +subdir('ipa') install_headers(libcamera_api, subdir : include_dir) |