libcamera  v0.0.0
Supporting cameras in Linux since 2019
ipa_interface.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2019, Google Inc.
4  *
5  * ipa_interface.h - Image Processing Algorithm interface
6  */
7 #ifndef __LIBCAMERA_IPA_INTERFACE_H__
8 #define __LIBCAMERA_IPA_INTERFACE_H__
9 
10 #include <stddef.h>
11 #include <stdint.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 struct ipa_context {
18  const struct ipa_context_ops *ops;
19 };
20 
21 struct ipa_settings {
22  const char *configuration_file;
23 };
24 
26  const char *model;
27  uint8_t bits_per_pixel;
28  struct {
29  uint32_t width;
30  uint32_t height;
32  struct {
33  int32_t left;
34  int32_t top;
35  uint32_t width;
36  uint32_t height;
38  struct {
39  uint32_t width;
40  uint32_t height;
42  uint64_t pixel_rate;
43  uint32_t line_length;
44 };
45 
46 struct ipa_stream {
47  unsigned int id;
48  unsigned int pixel_format;
49  unsigned int width;
50  unsigned int height;
51 };
52 
54  unsigned int id;
55  const uint8_t *data;
56  size_t size;
57 };
58 
60  int dmabuf;
61  size_t length;
62 };
63 
64 struct ipa_buffer {
65  unsigned int id;
66  unsigned int num_planes;
67  struct ipa_buffer_plane planes[3];
68 };
69 
71  const uint8_t *data;
72  unsigned int size;
73 };
74 
76  unsigned int operation;
77  const uint32_t *data;
78  unsigned int num_data;
79  const struct ipa_control_list *lists;
80  unsigned int num_lists;
81 };
82 
84  void (*queue_frame_action)(void *cb_ctx, unsigned int frame,
85  struct ipa_operation_data &data);
86 };
87 
89  void (*destroy)(struct ipa_context *ctx);
90  void *(*get_interface)(struct ipa_context *ctx);
91  void (*init)(struct ipa_context *ctx,
92  const struct ipa_settings *settings);
93  int (*start)(struct ipa_context *ctx);
94  void (*stop)(struct ipa_context *ctx);
95  void (*register_callbacks)(struct ipa_context *ctx,
96  const struct ipa_callback_ops *callbacks,
97  void *cb_ctx);
98  void (*configure)(struct ipa_context *ctx,
99  const struct ipa_sensor_info *sensor_info,
100  const struct ipa_stream *streams,
101  unsigned int num_streams,
102  const struct ipa_control_info_map *maps,
103  unsigned int num_maps);
104  void (*map_buffers)(struct ipa_context *ctx,
105  const struct ipa_buffer *buffers,
106  size_t num_buffers);
107  void (*unmap_buffers)(struct ipa_context *ctx, const unsigned int *ids,
108  size_t num_buffers);
109  void (*process_event)(struct ipa_context *ctx,
110  const struct ipa_operation_data *data);
111 };
112 
114 
115 #ifdef __cplusplus
116 }
117 
118 #include <map>
119 #include <vector>
120 
121 #include <libcamera/buffer.h>
122 #include <libcamera/controls.h>
123 #include <libcamera/geometry.h>
124 #include <libcamera/signal.h>
125 
126 namespace libcamera {
127 
128 struct IPASettings {
129  std::string configurationFile;
130 };
131 
132 struct IPAStream {
133  unsigned int pixelFormat;
135 };
136 
137 struct IPABuffer {
138  unsigned int id;
139  std::vector<FrameBuffer::Plane> planes;
140 };
141 
143  unsigned int operation;
144  std::vector<uint32_t> data;
145  std::vector<ControlList> controls;
146 };
147 
148 struct CameraSensorInfo;
149 
151 {
152 public:
153  virtual ~IPAInterface() {}
154 
155  virtual int init(const IPASettings &settings) = 0;
156  virtual int start() = 0;
157  virtual void stop() = 0;
158 
159  virtual void configure(const CameraSensorInfo &sensorInfo,
160  const std::map<unsigned int, IPAStream> &streamConfig,
161  const std::map<unsigned int, const ControlInfoMap &> &entityControls) = 0;
162 
163  virtual void mapBuffers(const std::vector<IPABuffer> &buffers) = 0;
164  virtual void unmapBuffers(const std::vector<unsigned int> &ids) = 0;
165 
166  virtual void processEvent(const IPAOperationData &data) = 0;
168 };
169 
170 } /* namespace libcamera */
171 #endif
172 
173 #endif /* __LIBCAMERA_IPA_INTERFACE_H__ */
Buffer handling.
C++ Interface for IPA implementation.
Definition: ipa_interface.h:151
virtual void mapBuffers(const std::vector< IPABuffer > &buffers)=0
Map buffers shared between the pipeline handler and the IPA.
Signal< unsigned int, const IPAOperationData & > queueFrameAction
Queue an action associated with a frame to the pipeline handler.
Definition: ipa_interface.h:167
virtual void unmapBuffers(const std::vector< unsigned int > &ids)=0
Unmap buffers shared by the pipeline to the IPA.
virtual int init(const IPASettings &settings)=0
Initialise the IPAInterface.
virtual void stop()=0
Stop the IPA.
virtual void processEvent(const IPAOperationData &data)=0
Process an event from the pipeline handler.
virtual int start()=0
Start the IPA.
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.
Generic signal and slot communication mechanism.
Definition: signal.h:39
Framework to manage controls related to an object.
Data structures related to geometric objects.
struct ipa_context * ipaCreate()
Entry point to the IPA modules.
Signal & slot implementation.
A plane for an ipa_buffer.
Definition: ipa_interface.h:59
int dmabuf
The dmabuf file descriptor for the plane (-1 for unused planes)
Definition: ipa_interface.h:60
size_t length
The plane length in bytes (0 for unused planes)
Definition: ipa_interface.h:61
Buffer information for the IPA context operations.
Definition: ipa_interface.h:64
unsigned int id
The buffer unique ID (see libcamera::IPABuffer::id)
Definition: ipa_interface.h:65
struct ipa_buffer_plane planes[3]
The buffer planes (up to 3)
Definition: ipa_interface.h:67
unsigned int num_planes
The number of used planes in the ipa_buffer::planes array.
Definition: ipa_interface.h:66
IPA context operations as a set of function pointers.
Definition: ipa_interface.h:83
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 operations as a set of function pointers.
Definition: ipa_interface.h:88
void(* init)(struct ipa_context *ctx, const struct ipa_settings *settings)
Initialise the IPA context.
Definition: ipa_interface.h:91
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
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
void(* destroy)(struct ipa_context *ctx)
Destroy the IPA context created by the module's ipaCreate() function.
Definition: ipa_interface.h:89
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
int(* start)(struct ipa_context *ctx)
Start the IPA context.
Definition: ipa_interface.h:93
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
void(* stop)(struct ipa_context *ctx)
Stop the IPA context.
Definition: ipa_interface.h:94
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 module context of execution.
Definition: ipa_interface.h:17
const struct ipa_context_ops * ops
The IPA context operations.
Definition: ipa_interface.h:18
ControlInfoMap description for the IPA context operations.
Definition: ipa_interface.h:53
size_t size
The size of the control packet in bytes.
Definition: ipa_interface.h:56
const uint8_t * data
Pointer to a control packet for the ControlInfoMap.
Definition: ipa_interface.h:55
unsigned int id
Identifier for the ControlInfoMap, defined by the IPA protocol.
Definition: ipa_interface.h:54
ControlList description for the IPA context operations.
Definition: ipa_interface.h:70
unsigned int size
The size of the control packet in bytes.
Definition: ipa_interface.h:72
const uint8_t * data
Pointer to a control packet for the ControlList.
Definition: ipa_interface.h:71
IPA operation data for the IPA context operations.
Definition: ipa_interface.h:75
const struct ipa_control_list * lists
Pointer to an array of ipa_control_list.
Definition: ipa_interface.h:79
unsigned int num_data
Number of entries in the ipa_operation_data::data array.
Definition: ipa_interface.h:78
unsigned int operation
IPA protocol operation.
Definition: ipa_interface.h:76
const uint32_t * data
Pointer to the operation data array.
Definition: ipa_interface.h:77
unsigned int num_lists
Number of entries in the ipa_control_list array.
Definition: ipa_interface.h:80
Camera sensor information for the IPA context operations.
Definition: ipa_interface.h:25
uint64_t pixel_rate
The number of pixel produced in a second.
Definition: ipa_interface.h:42
struct ipa_sensor_info::@5 output_size
The size of the output image.
uint32_t line_length
The full line length, including blanking, in pixel units.
Definition: ipa_interface.h:43
struct ipa_sensor_info::@3 active_area
The camera sensor pixel array active size.
int32_t left
The left coordinate of the analog crop rectangle, relative to the pixel array active area.
Definition: ipa_interface.h:33
uint8_t bits_per_pixel
The camera sensor image format bit depth.
Definition: ipa_interface.h:27
struct ipa_sensor_info::@4 analog_crop
The analog crop rectangle.
uint32_t height
The camera sensor pixel array active area height.
Definition: ipa_interface.h:30
const char * model
The camera sensor model name.
Definition: ipa_interface.h:26
uint32_t width
The camera sensor pixel array active area width.
Definition: ipa_interface.h:29
int32_t top
The top coordinate of the analog crop rectangle, relative to the pixel array active area.
Definition: ipa_interface.h:34
IPA initialization settings for the IPA context operations.
Definition: ipa_interface.h:21
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
Stream information for the IPA context operations.
Definition: ipa_interface.h:46
unsigned int height
The stream height in pixels.
Definition: ipa_interface.h:50
unsigned int id
Identifier for the stream, defined by the IPA protocol.
Definition: ipa_interface.h:47
unsigned int width
The stream width in pixels.
Definition: ipa_interface.h:49
unsigned int pixel_format
The stream pixel format, as defined by the PixelFormat class.
Definition: ipa_interface.h:48
Report the image sensor characteristics.
Definition: camera_sensor.h:27
Buffer information for the IPA interface.
Definition: ipa_interface.h:137
unsigned int id
The buffer unique ID.
Definition: ipa_interface.h:138
std::vector< FrameBuffer::Plane > planes
The buffer planes description.
Definition: ipa_interface.h:139
Parameters for IPA operations.
Definition: ipa_interface.h:142
std::vector< uint32_t > data
Operation integer data.
Definition: ipa_interface.h:144
std::vector< ControlList > controls
Operation controls data.
Definition: ipa_interface.h:145
unsigned int operation
IPA protocol operation.
Definition: ipa_interface.h:143
IPA interface initialization settings.
Definition: ipa_interface.h:128
std::string configurationFile
The name of the IPA configuration file.
Definition: ipa_interface.h:129
Stream configuration for the IPA interface.
Definition: ipa_interface.h:132
unsigned int pixelFormat
The stream pixel format.
Definition: ipa_interface.h:133
Size size
The stream size in pixels.
Definition: ipa_interface.h:134
Describe a two-dimensional size.
Definition: geometry.h:30