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;
31  } active_area;
32  struct {
33  int32_t left;
34  int32_t top;
35  uint32_t width;
36  uint32_t height;
37  } analog_crop;
38  struct {
39  uint32_t width;
40  uint32_t height;
41  } output_size;
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 
113 struct ipa_context *ipaCreate();
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__ */
size_t size
The size of the control packet in bytes.
Definition: ipa_interface.h:56
unsigned int id
Identifier for the stream, defined by the IPA protocol.
Definition: ipa_interface.h:47
int dmabuf
The dmabuf file descriptor for the plane (-1 for unused planes)
Definition: ipa_interface.h:60
uint32_t line_length
The full line length, including blanking, in pixel units.
Definition: ipa_interface.h:43
C++ Interface for IPA implementation.
Definition: ipa_interface.h:150
const struct ipa_context_ops * ops
The IPA context operations.
Definition: ipa_interface.h:18
Report the image sensor characteristics.
Definition: camera_sensor.h:27
unsigned int id
The buffer unique ID (see libcamera::IPABuffer::id)
Definition: ipa_interface.h:65
Definition: bound_method.h:15
unsigned int height
The stream height in pixels.
Definition: ipa_interface.h:50
IPA initialization settings for the IPA context operations.
Definition: ipa_interface.h:21
IPA module context of execution.
Definition: ipa_interface.h:17
A plane for an ipa_buffer.
Definition: ipa_interface.h:59
Parameters for IPA operations.
Definition: ipa_interface.h:142
ControlInfoMap description for the IPA context operations.
Definition: ipa_interface.h:53
unsigned int pixelFormat
The stream pixel format.
Definition: ipa_interface.h:133
size_t length
The plane length in bytes (0 for unused planes)
Definition: ipa_interface.h:61
Describe a two-dimensional size.
Definition: geometry.h:30
unsigned int id
The buffer unique ID.
Definition: ipa_interface.h:138
Camera sensor information for the IPA context operations.
Definition: ipa_interface.h:25
std::vector< ControlList > controls
Operation controls data.
Definition: ipa_interface.h:145
IPA context operations as a set of function pointers.
Definition: ipa_interface.h:83
Stream configuration for the IPA interface.
Definition: ipa_interface.h:132
ControlList description for the IPA context operations.
Definition: ipa_interface.h:70
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
Signal & slot implementation.
IPA operation data for the IPA context operations.
Definition: ipa_interface.h:75
const char * model
The camera sensor model name.
Definition: ipa_interface.h:26
unsigned int pixel_format
The stream pixel format, as defined by the PixelFormat class.
Definition: ipa_interface.h:48
Signal< unsigned int, const IPAOperationData & > queueFrameAction
Queue an action associated with a frame to the pipeline handler.
Definition: ipa_interface.h:167
unsigned int num_planes
The number of used planes in the ipa_buffer::planes array.
Definition: ipa_interface.h:66
const struct ipa_control_list * lists
Pointer to an array of ipa_control_list.
Definition: ipa_interface.h:79
IPA context operations as a set of function pointers.
Definition: ipa_interface.h:88
IPA interface initialization settings.
Definition: ipa_interface.h:128
unsigned int operation
IPA protocol operation.
Definition: ipa_interface.h:143
int32_t top
The top coordinate of the analog crop rectangle, relative to the pixel array active area...
Definition: ipa_interface.h:34
std::vector< uint32_t > data
Operation integer data.
Definition: ipa_interface.h:144
unsigned int num_lists
Number of entries in the ipa_control_list array.
Definition: ipa_interface.h:80
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
Buffer information for the IPA context operations.
Definition: ipa_interface.h:64
Generic signal and slot communication mechanism.
Definition: object.h:20
Buffer handling.
unsigned int num_data
Number of entries in the ipa_operation_data::data array.
Definition: ipa_interface.h:78
std::string configurationFile
The name of the IPA configuration file.
Definition: ipa_interface.h:129
unsigned int id
Identifier for the ControlInfoMap, defined by the IPA protocol.
Definition: ipa_interface.h:54
Stream information for the IPA context operations.
Definition: ipa_interface.h:46
unsigned int width
The stream width in pixels.
Definition: ipa_interface.h:49
std::vector< FrameBuffer::Plane > planes
The buffer planes description.
Definition: ipa_interface.h:139
const uint8_t * data
Pointer to a control packet for the ControlInfoMap.
Definition: ipa_interface.h:55
uint8_t bits_per_pixel
The camera sensor image format bit depth.
Definition: ipa_interface.h:27
Size size
The stream size in pixels.
Definition: ipa_interface.h:134
Buffer information for the IPA interface.
Definition: ipa_interface.h:137
Framework to manage controls related to an object.
int32_t left
The left coordinate of the analog crop rectangle, relative to the pixel array active area...
Definition: ipa_interface.h:33
Data structures related to geometric objects.
const uint8_t * data
Pointer to a control packet for the ControlList.
Definition: ipa_interface.h:71
uint32_t height
The camera sensor pixel array active area height.
Definition: ipa_interface.h:30
struct ipa_context * ipaCreate()
Entry point to the IPA modules.
uint32_t width
The camera sensor pixel array active area width.
Definition: ipa_interface.h:29
unsigned int size
The size of the control packet in bytes.
Definition: ipa_interface.h:72
uint64_t pixel_rate
The number of pixel produced in a second.
Definition: ipa_interface.h:42