ipa_interface.h
Go to the documentation of this file.
/* 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__ */
buffer.h
Buffer handling.
libcamera::IPAInterface
C++ Interface for IPA implementation.
Definition: ipa_interface.h:151
libcamera::IPAInterface::mapBuffers
virtual void mapBuffers(const std::vector< IPABuffer > &buffers)=0
Map buffers shared between the pipeline handler and the IPA.
libcamera::IPAInterface::queueFrameAction
Signal< unsigned int, const IPAOperationData & > queueFrameAction
Queue an action associated with a frame to the pipeline handler.
Definition: ipa_interface.h:167
libcamera::IPAInterface::unmapBuffers
virtual void unmapBuffers(const std::vector< unsigned int > &ids)=0
Unmap buffers shared by the pipeline to the IPA.
libcamera::IPAInterface::init
virtual int init(const IPASettings &settings)=0
Initialise the IPAInterface.
libcamera::IPAInterface::stop
virtual void stop()=0
Stop the IPA.
libcamera::IPAInterface::processEvent
virtual void processEvent(const IPAOperationData &data)=0
Process an event from the pipeline handler.
libcamera::IPAInterface::start
virtual int start()=0
Start the IPA.
libcamera::IPAInterface::configure
virtual void configure(const CameraSensorInfo &sensorInfo, const std::map< unsigned int, IPAStream > &streamConfig, const std::map< unsigned int, const ControlInfoMap & > &entityControls)=0
Configure the IPA stream and sensor settings.
libcamera::Signal
Generic signal and slot communication mechanism.
Definition: signal.h:39
controls.h
Framework to manage controls related to an object.
geometry.h
Data structures related to geometric objects.
ipaCreate
struct ipa_context * ipaCreate()
Entry point to the IPA modules.
signal.h
Signal & slot implementation.
ipa_buffer_plane
A plane for an ipa_buffer.
Definition: ipa_interface.h:59
ipa_buffer_plane::dmabuf
int dmabuf
The dmabuf file descriptor for the plane (-1 for unused planes)
Definition: ipa_interface.h:60
ipa_buffer_plane::length
size_t length
The plane length in bytes (0 for unused planes)
Definition: ipa_interface.h:61
ipa_buffer
Buffer information for the IPA context operations.
Definition: ipa_interface.h:64
ipa_buffer::id
unsigned int id
The buffer unique ID (see libcamera::IPABuffer::id)
Definition: ipa_interface.h:65
ipa_buffer::planes
struct ipa_buffer_plane planes[3]
The buffer planes (up to 3)
Definition: ipa_interface.h:67
ipa_buffer::num_planes
unsigned int num_planes
The number of used planes in the ipa_buffer::planes array.
Definition: ipa_interface.h:66
ipa_callback_ops
IPA context operations as a set of function pointers.
Definition: ipa_interface.h:83
ipa_callback_ops::queue_frame_action
void(* queue_frame_action)(void *cb_ctx, unsigned int frame, struct ipa_operation_data &data)
Queue an action associated with a frame to the pipeline handler.
Definition: ipa_interface.h:84
ipa_context_ops
IPA context operations as a set of function pointers.
Definition: ipa_interface.h:88
ipa_context_ops::init
void(* init)(struct ipa_context *ctx, const struct ipa_settings *settings)
Initialise the IPA context.
Definition: ipa_interface.h:91
ipa_context_ops::map_buffers
void(* map_buffers)(struct ipa_context *ctx, const struct ipa_buffer *buffers, size_t num_buffers)
Map buffers shared between the pipeline handler and the IPA.
Definition: ipa_interface.h:104
ipa_context_ops::register_callbacks
void(* register_callbacks)(struct ipa_context *ctx, const struct ipa_callback_ops *callbacks, void *cb_ctx)
Register callback operation from the IPA to the pipeline handler.
Definition: ipa_interface.h:95
ipa_context_ops::destroy
void(* destroy)(struct ipa_context *ctx)
Destroy the IPA context created by the module's ipaCreate() function.
Definition: ipa_interface.h:89
ipa_context_ops::unmap_buffers
void(* unmap_buffers)(struct ipa_context *ctx, const unsigned int *ids, size_t num_buffers)
Unmap buffers shared by the pipeline to the IPA.
Definition: ipa_interface.h:107
ipa_context_ops::start
int(* start)(struct ipa_context *ctx)
Start the IPA context.
Definition: ipa_interface.h:93
ipa_context_ops::process_event
void(* process_event)(struct ipa_context *ctx, const struct ipa_operation_data *data)
Process an event from the pipeline handler.
Definition: ipa_interface.h:109
ipa_context_ops::stop
void(* stop)(struct ipa_context *ctx)
Stop the IPA context.
Definition: ipa_interface.h:94
ipa_context_ops::configure
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)
Configure the IPA stream and sensor settings.
Definition: ipa_interface.h:98
ipa_context
IPA module context of execution.
Definition: ipa_interface.h:17
ipa_context::ops
const struct ipa_context_ops * ops
The IPA context operations.
Definition: ipa_interface.h:18
ipa_control_info_map
ControlInfoMap description for the IPA context operations.
Definition: ipa_interface.h:53
ipa_control_info_map::size
size_t size
The size of the control packet in bytes.
Definition: ipa_interface.h:56
ipa_control_info_map::data
const uint8_t * data
Pointer to a control packet for the ControlInfoMap.
Definition: ipa_interface.h:55
ipa_control_info_map::id
unsigned int id
Identifier for the ControlInfoMap, defined by the IPA protocol.
Definition: ipa_interface.h:54
ipa_control_list
ControlList description for the IPA context operations.
Definition: ipa_interface.h:70
ipa_control_list::size
unsigned int size
The size of the control packet in bytes.
Definition: ipa_interface.h:72
ipa_control_list::data
const uint8_t * data
Pointer to a control packet for the ControlList.
Definition: ipa_interface.h:71
ipa_operation_data
IPA operation data for the IPA context operations.
Definition: ipa_interface.h:75
ipa_operation_data::lists
const struct ipa_control_list * lists
Pointer to an array of ipa_control_list.
Definition: ipa_interface.h:79
ipa_operation_data::num_data
unsigned int num_data
Number of entries in the ipa_operation_data::data array.
Definition: ipa_interface.h:78
ipa_operation_data::operation
unsigned int operation
IPA protocol operation.
Definition: ipa_interface.h:76
ipa_operation_data::data
const uint32_t * data
Pointer to the operation data array.
Definition: ipa_interface.h:77
ipa_operation_data::num_lists
unsigned int num_lists
Number of entries in the ipa_control_list array.
Definition: ipa_interface.h:80
ipa_sensor_info
Camera sensor information for the IPA context operations.
Definition: ipa_interface.h:25
ipa_sensor_info::pixel_rate
uint64_t pixel_rate
The number of pixel produced in a second.
Definition: ipa_interface.h:42
ipa_sensor_info::output_size
struct ipa_sensor_info::@5 output_size
The size of the output image.
ipa_sensor_info::line_length
uint32_t line_length
The full line length, including blanking, in pixel units.
Definition: ipa_interface.h:43
ipa_sensor_info::active_area
struct ipa_sensor_info::@3 active_area
The camera sensor pixel array active size.
ipa_sensor_info::left
int32_t left
The left coordinate of the analog crop rectangle, relative to the pixel array active area.
Definition: ipa_interface.h:33
ipa_sensor_info::bits_per_pixel
uint8_t bits_per_pixel
The camera sensor image format bit depth.
Definition: ipa_interface.h:27
ipa_sensor_info::analog_crop
struct ipa_sensor_info::@4 analog_crop
The analog crop rectangle.
ipa_sensor_info::height
uint32_t height
The camera sensor pixel array active area height.
Definition: ipa_interface.h:30
ipa_sensor_info::model
const char * model
The camera sensor model name.
Definition: ipa_interface.h:26
ipa_sensor_info::width
uint32_t width
The camera sensor pixel array active area width.
Definition: ipa_interface.h:29
ipa_sensor_info::top
int32_t top
The top coordinate of the analog crop rectangle, relative to the pixel array active area.
Definition: ipa_interface.h:34
ipa_settings
IPA initialization settings for the IPA context operations.
Definition: ipa_interface.h:21
ipa_settings::configuration_file
const char * configuration_file
The name of the IPA configuration file (may be null or point to an empty string)
Definition: ipa_interface.h:22
ipa_stream
Stream information for the IPA context operations.
Definition: ipa_interface.h:46
ipa_stream::height
unsigned int height
The stream height in pixels.
Definition: ipa_interface.h:50
ipa_stream::id
unsigned int id
Identifier for the stream, defined by the IPA protocol.
Definition: ipa_interface.h:47
ipa_stream::width
unsigned int width
The stream width in pixels.
Definition: ipa_interface.h:49
ipa_stream::pixel_format
unsigned int pixel_format
The stream pixel format, as defined by the PixelFormat class.
Definition: ipa_interface.h:48
libcamera::CameraSensorInfo
Report the image sensor characteristics.
Definition: camera_sensor.h:27
libcamera::IPABuffer
Buffer information for the IPA interface.
Definition: ipa_interface.h:137
libcamera::IPABuffer::id
unsigned int id
The buffer unique ID.
Definition: ipa_interface.h:138
libcamera::IPABuffer::planes
std::vector< FrameBuffer::Plane > planes
The buffer planes description.
Definition: ipa_interface.h:139
libcamera::IPAOperationData
Parameters for IPA operations.
Definition: ipa_interface.h:142
libcamera::IPAOperationData::data
std::vector< uint32_t > data
Operation integer data.
Definition: ipa_interface.h:144
libcamera::IPAOperationData::controls
std::vector< ControlList > controls
Operation controls data.
Definition: ipa_interface.h:145
libcamera::IPAOperationData::operation
unsigned int operation
IPA protocol operation.
Definition: ipa_interface.h:143
libcamera::IPASettings
IPA interface initialization settings.
Definition: ipa_interface.h:128
libcamera::IPASettings::configurationFile
std::string configurationFile
The name of the IPA configuration file.
Definition: ipa_interface.h:129
libcamera::IPAStream
Stream configuration for the IPA interface.
Definition: ipa_interface.h:132
libcamera::IPAStream::pixelFormat
unsigned int pixelFormat
The stream pixel format.
Definition: ipa_interface.h:133
libcamera::IPAStream::size
Size size
The stream size in pixels.
Definition: ipa_interface.h:134
libcamera::Size
Describe a two-dimensional size.
Definition: geometry.h:30