summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2020-12-05 19:30:54 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2021-02-16 19:22:28 +0900
commite201cb4f5450a84fc669e313bc039174cf54c263 (patch)
tree86d116cc7b9359e63fed2e3bd1747c03156809da /include
parent18b3e27461f8d6e3115c932f2799851cbb62e357 (diff)
libcamera: IPAInterface: Replace C API with the new C++-only API
Remove everything related to the C API, including ipa_context, ipa_context_wrapper, and IPAInterfaceWrapper. Also remove relevant documentation. ipaCreate() provided by IPA implementations, and createInterface() provided by IPAModule (wrapper around IPA implementation) both now return a C++ object IPAInterface instead of struct ipa_context. Although IPAInterfaceWrapper is the only component of libipa, the skeleton and build files for libipa are retained. After converting the C API to the C++-only API, make all pipeline handlers and IPAs use the new API. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- This is a combination of 21 commits: --- libcamera: IPAModule: Replace ipa_context with IPAInterface With the new IPC infrastructure, we no longer need the C interface as provided by struct ipa_context. Make ipaCreate_() and createInterface() return IPAInterface. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: ipa_context_wrapper: Remove ipa_context_wrapper Since ipa_context has been replaced with custom IPAInterfaces, it is not longer needed. Remove it. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAInterface: remove ipa_context and functions from documentation Remove all the documentation related to ipa_context and the C IPA API, as well as the documentation about the functions in the IPAInterface. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> --- libcamera: IPAInterface: Remove all functions from IPAInterface Now that all the functions in the IPA interface are defined in the data definition file and a specialized IPAInterface is generated per pipeline handler, remove all the functions from the base IPAInterface. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAInterface: make ipaCreate return IPAInterface With the new IPC infrastructure, we no longer need the C interface as provided by struct ipa_context. Make ipaCreate return IPAinterface. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> --- ipa: remove IPAInterfaceWrapper As every pipeline has its own proxy, IPAInterfaceWrapper is no longer necessary. Remove it. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> --- libcamera: IPAProxy: Remove stop() override Since stop() is part of the IPA interface, and the IPA interface is now generated based on the data definition file per pipeline, this no longer needs to be overrided by the base IPAProxy. Remove it. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAProxy, IPAManager: Switch to one-proxy-per-pipeline scheme IPAProxy is changed in two major ways: - Every pipeline has its own proxy, to support each pipeline's IPA interface - IPAProxy implementations always encapsulate IPA modules, and switch internally for isolation or threaded The IPAProxy registration mechanism is removed, as each pipeline will have its own proxy, so the pipeline can pass the specialized class name of the IPAProxy to the IPAManager for construction. IPAManager is changed accordingly to support these changes: - createIPA is a template function that takes an IPAProxy class, and always returns an IPAProxy - IPAManager no longer decides on isolation, and simply creates an IPAProxy instance while passing the isolation flag Consequently, the old IPAProxy classes (IPAProxyThread and IPAProxyLinux) are removed. The IPAInterfaceTest is updated to use the new IPAManager interface, and to construct a ProcessManager as no single global instance is created anymore. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> --- libcamera: IPAProxy: Add isolate parameter to create() Since IPAProxy implementations now always encapsulate IPA modules, add a parameter to create() to signal if the proxy should isolate the IPA or not. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAManager: Fetch IPAProxy corresponding to pipeline Now that each pipeline handler has its own IPAProxy implementation, make the IPAManager fetch the IPAProxy based on the pipeline handler name. Also, since the IPAProxy is used regardless of isolation or no isolation, remove the isolation check from the proxy selection. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> --- libcamera: IPAManager: add isolation flag to proxy creation When the IPA proxy is created, it needs to know whether to isolate or not. Feed the flag at creation of the IPA proxy. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAManager: Make createIPA return proxy directly Since every pipeline knows the type of the proxy that it needs, and since all IPAs are to be wrapped in a proxy, IPAManager no longer needs to search in the factory list to fetch the proxy factory to construct a factory. Instead, we define createIPA as a template function, and the pipeline handler can declare the proxy type when it calls createIPA. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAProxy: Remove registration mechanism Implementations of IPA proxies use a registration mechanism to register themselves with the main IPA proxy factory. This registration declares static objects, causing a risk of things being constructed before the proper libcamera facilities are ready. Since each pipeline handler has its own IPA proxy and knows the type, it isn't necessary to have a proxy factory. Remove it to alleviate the risk of early construction. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: proxy: Remove IPAProxyLinux and IPAProxyThread We have now changed the proxy from per-IPC mechanism to per-pipeline. The per-IPC mechanism proxies are thus no longer needed; remove them. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- tests: ipa_interface_test: Update to use new createIPA Update the IPA interface test to use the new createIPA function from IPAManager. Also create an instance of ProcessManager, as no single global instance is created automatically anymore. Update meson.build to to depend on the generated IPA interface headers. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: PipelineHandler: Remove IPA from base class Since pipeline handlers now have their own IPA interface types, it can no longer be defined in the base class, and each pipeline handler implementation must declare it and its type themselves. Remove it from the base class. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- ipa: raspberrypi: Add mojom data definition file Add a mojom data definition for raspberrypi pipeline handler's IPAs. This simplifies the API between the raspberrypi pipeline handler and the IPA, and is not a direct translation of what was used before with IPAOperationData. Also move the enums from raspberrypi.h to raspberrypi.mojom Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: pipeline, ipa: raspberrypi: Use new data definition Now that we can generate custom functions and data structures with mojo, switch the raspberrypi pipeline handler and IPA to use the custom data structures as defined in the mojom data definition file. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: pipeline, ipa: vimc: Support the new IPC mechanism Add support to vimc pipeline handler and IPA for the new IPC mechanism. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> --- libcamera: pipeline, ipa: rkisp1: Support the new IPC mechanism Add support to the rkisp1 pipeline handler and IPA for the new IPC mechanism. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: pipeline, ipa: ipu3: Support the new IPC mechanism Add support to ipu3 pipeline handler and IPA for the new IPC mechanism. [Original version] Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> [Fixed commit message and small changes] Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/internal/ipa_context_wrapper.h53
-rw-r--r--include/libcamera/internal/ipa_manager.h31
-rw-r--r--include/libcamera/internal/ipa_module.h4
-rw-r--r--include/libcamera/internal/ipa_proxy.h31
-rw-r--r--include/libcamera/internal/meson.build1
-rw-r--r--include/libcamera/internal/pipeline_handler.h1
-rw-r--r--include/libcamera/ipa/ipa_interface.h147
-rw-r--r--include/libcamera/ipa/ipu3.h23
-rw-r--r--include/libcamera/ipa/ipu3.mojom43
-rw-r--r--include/libcamera/ipa/meson.build7
-rw-r--r--include/libcamera/ipa/raspberrypi.h31
-rw-r--r--include/libcamera/ipa/raspberrypi.mojom131
-rw-r--r--include/libcamera/ipa/rkisp1.h22
-rw-r--r--include/libcamera/ipa/rkisp1.mojom44
-rw-r--r--include/libcamera/ipa/vimc.h28
-rw-r--r--include/libcamera/ipa/vimc.mojom24
16 files changed, 282 insertions, 339 deletions
diff --git a/include/libcamera/internal/ipa_context_wrapper.h b/include/libcamera/internal/ipa_context_wrapper.h
deleted file mode 100644
index ec27e48e..00000000
--- a/include/libcamera/internal/ipa_context_wrapper.h
+++ /dev/null
@@ -1,53 +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_INTERNAL_IPA_CONTEXT_WRAPPER_H__
-#define __LIBCAMERA_INTERNAL_IPA_CONTEXT_WRAPPER_H__
-
-#include <libcamera/ipa/ipa_interface.h>
-
-#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(const IPAOperationData &data,
- IPAOperationData *result) override;
- void stop() override;
- void configure(const CameraSensorInfo &sensorInfo,
- const std::map<unsigned int, IPAStream> &streamConfig,
- const std::map<unsigned int, const ControlInfoMap &> &entityControls,
- const IPAOperationData &ipaConfig,
- IPAOperationData *result) override;
-
- void mapBuffers(const std::vector<IPABuffer> &buffers) override;
- void unmapBuffers(const std::vector<unsigned int> &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_INTERNAL_IPA_CONTEXT_WRAPPER_H__ */
diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h
index 4a143b6a..e904a2be 100644
--- a/include/libcamera/internal/ipa_manager.h
+++ b/include/libcamera/internal/ipa_manager.h
@@ -14,20 +14,45 @@
#include <libcamera/ipa/ipa_module_info.h>
#include "libcamera/internal/ipa_module.h"
+#include "libcamera/internal/log.h"
#include "libcamera/internal/pipeline_handler.h"
#include "libcamera/internal/pub_key.h"
namespace libcamera {
+LOG_DECLARE_CATEGORY(IPAManager)
+
class IPAManager
{
public:
IPAManager();
~IPAManager();
- static std::unique_ptr<IPAProxy> createIPA(PipelineHandler *pipe,
- uint32_t maxVersion,
- uint32_t minVersion);
+ template<typename T>
+ static std::unique_ptr<T> createIPA(PipelineHandler *pipe,
+ uint32_t maxVersion,
+ uint32_t minVersion)
+ {
+ IPAModule *m = nullptr;
+
+ for (IPAModule *module : self_->modules_) {
+ if (module->match(pipe, minVersion, maxVersion)) {
+ m = module;
+ break;
+ }
+ }
+
+ if (!m)
+ return nullptr;
+
+ std::unique_ptr<T> proxy = std::make_unique<T>(m, !self_->isSignatureValid(m));
+ if (!proxy->isValid()) {
+ LOG(IPAManager, Error) << "Failed to load proxy";
+ return nullptr;
+ }
+
+ return proxy;
+ }
private:
static IPAManager *self_;
diff --git a/include/libcamera/internal/ipa_module.h b/include/libcamera/internal/ipa_module.h
index c2df2476..19fc5827 100644
--- a/include/libcamera/internal/ipa_module.h
+++ b/include/libcamera/internal/ipa_module.h
@@ -33,7 +33,7 @@ public:
bool load();
- struct ipa_context *createContext();
+ IPAInterface *createInterface();
bool match(PipelineHandler *pipe,
uint32_t minVersion, uint32_t maxVersion) const;
@@ -52,7 +52,7 @@ private:
bool loaded_;
void *dlHandle_;
- typedef struct ipa_context *(*IPAIntfFactory)();
+ typedef IPAInterface *(*IPAIntfFactory)(void);
IPAIntfFactory ipaCreate_;
};
diff --git a/include/libcamera/internal/ipa_proxy.h b/include/libcamera/internal/ipa_proxy.h
index 49399f4e..f651a3ae 100644
--- a/include/libcamera/internal/ipa_proxy.h
+++ b/include/libcamera/internal/ipa_proxy.h
@@ -27,8 +27,6 @@ public:
std::string configurationFile(const std::string &file) const;
- void stop() override = 0;
-
protected:
std::string resolvePath(const std::string &file) const;
@@ -38,35 +36,6 @@ private:
IPAModule *ipam_;
};
-class IPAProxyFactory
-{
-public:
- IPAProxyFactory(const char *name);
- virtual ~IPAProxyFactory() = default;
-
- virtual std::unique_ptr<IPAProxy> create(IPAModule *ipam) = 0;
-
- const std::string &name() const { return name_; }
-
- static void registerType(IPAProxyFactory *factory);
- static std::vector<IPAProxyFactory *> &factories();
-
-private:
- std::string name_;
-};
-
-#define REGISTER_IPA_PROXY(proxy) \
-class proxy##Factory final : public IPAProxyFactory \
-{ \
-public: \
- proxy##Factory() : IPAProxyFactory(#proxy) {} \
- std::unique_ptr<IPAProxy> create(IPAModule *ipam) \
- { \
- return std::make_unique<proxy>(ipam); \
- } \
-}; \
-static proxy##Factory global_##proxy##Factory;
-
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_IPA_PROXY_H__ */
diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build
index a1071721..1fe3918c 100644
--- a/include/libcamera/internal/meson.build
+++ b/include/libcamera/internal/meson.build
@@ -26,7 +26,6 @@ libcamera_internal_headers = files([
'event_notifier.h',
'file.h',
'formats.h',
- 'ipa_context_wrapper.h',
'ipa_manager.h',
'ipa_module.h',
'ipa_proxy.h',
diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h
index d81c9b85..d455d3c9 100644
--- a/include/libcamera/internal/pipeline_handler.h
+++ b/include/libcamera/internal/pipeline_handler.h
@@ -47,7 +47,6 @@ public:
std::list<Request *> queuedRequests_;
ControlInfoMap controlInfo_;
ControlList properties_;
- std::unique_ptr<IPAProxy> ipa_;
private:
LIBCAMERA_DISABLE_COPY(CameraData)
diff --git a/include/libcamera/ipa/ipa_interface.h b/include/libcamera/ipa/ipa_interface.h
index df12f9ce..47f81d1d 100644
--- a/include/libcamera/ipa/ipa_interface.h
+++ b/include/libcamera/ipa/ipa_interface.h
@@ -10,111 +10,6 @@
#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>
@@ -125,52 +20,18 @@ struct ipa_context *ipaCreate();
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() = default;
-
- virtual int init(const IPASettings &settings) = 0;
- virtual int start(const IPAOperationData &data,
- IPAOperationData *result) = 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,
- const IPAOperationData &ipaConfig,
- IPAOperationData *result) = 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
+
+extern "C" {
+libcamera::IPAInterface *ipaCreate();
+}
#endif /* __LIBCAMERA_IPA_INTERFACE_H__ */
diff --git a/include/libcamera/ipa/ipu3.h b/include/libcamera/ipa/ipu3.h
deleted file mode 100644
index cbaaef04..00000000
--- a/include/libcamera/ipa/ipu3.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-/*
- * Copyright (C) 2020, Google Inc.
- *
- * ipu3.h - Image Processing Algorithm interface for IPU3
- */
-#ifndef __LIBCAMERA_IPA_INTERFACE_IPU3_H__
-#define __LIBCAMERA_IPA_INTERFACE_IPU3_H__
-
-#ifndef __DOXYGEN__
-
-enum IPU3Operations {
- IPU3_IPA_ACTION_SET_SENSOR_CONTROLS = 1,
- IPU3_IPA_ACTION_PARAM_FILLED = 2,
- IPU3_IPA_ACTION_METADATA_READY = 3,
- IPU3_IPA_EVENT_PROCESS_CONTROLS = 4,
- IPU3_IPA_EVENT_STAT_READY = 5,
- IPU3_IPA_EVENT_FILL_PARAMS = 6,
-};
-
-#endif /* __DOXYGEN__ */
-
-#endif /* __LIBCAMERA_IPA_INTERFACE_IPU3_H__ */
diff --git a/include/libcamera/ipa/ipu3.mojom b/include/libcamera/ipa/ipu3.mojom
new file mode 100644
index 00000000..6ee11333
--- /dev/null
+++ b/include/libcamera/ipa/ipu3.mojom
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+module ipa.ipu3;
+
+import "include/libcamera/ipa/core.mojom";
+
+enum IPU3Operations {
+ ActionSetSensorControls = 1,
+ ActionParamFilled = 2,
+ ActionMetadataReady = 3,
+ EventProcessControls = 4,
+ EventStatReady = 5,
+ EventFillParams = 6,
+};
+
+struct IPU3Event {
+ IPU3Operations op;
+ uint32 frame;
+ uint32 bufferId;
+ ControlList controls;
+};
+
+struct IPU3Action {
+ IPU3Operations op;
+ ControlList controls;
+};
+
+interface IPAIPU3Interface {
+ init(IPASettings settings) => (int32 ret);
+ start() => (int32 ret);
+ stop();
+
+ configure(map<uint32, ControlInfoMap> entityControls) => ();
+
+ mapBuffers(array<IPABuffer> buffers);
+ unmapBuffers(array<uint32> ids);
+
+ [async] processEvent(IPU3Event ev);
+};
+
+interface IPAIPU3EventInterface {
+ queueFrameAction(uint32 frame, IPU3Action action);
+};
diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build
index 499d1bc0..fe8aa65b 100644
--- a/include/libcamera/ipa/meson.build
+++ b/include/libcamera/ipa/meson.build
@@ -54,7 +54,12 @@ libcamera_generated_ipa_headers += custom_target('core_ipa_serializer_h',
'./' +'@INPUT@'
])
-ipa_mojom_files = []
+ipa_mojom_files = [
+ 'ipu3.mojom',
+ 'raspberrypi.mojom',
+ 'rkisp1.mojom',
+ 'vimc.mojom',
+]
ipa_mojoms = []
diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h
index ee673a46..d10c1733 100644
--- a/include/libcamera/ipa/raspberrypi.h
+++ b/include/libcamera/ipa/raspberrypi.h
@@ -18,37 +18,6 @@ namespace libcamera {
namespace RPi {
-enum ConfigParameters {
- IPA_CONFIG_LS_TABLE = (1 << 0),
- IPA_CONFIG_STARTUP_CTRLS = (1 << 1),
- IPA_RESULT_CONFIG_FAILED = (1 << 2),
- IPA_RESULT_SENSOR_PARAMS = (1 << 3),
- IPA_RESULT_SENSOR_CTRLS = (1 << 4),
- IPA_RESULT_DROP_FRAMES = (1 << 5),
-};
-
-enum Operations {
- IPA_ACTION_SET_DELAYED_CTRLS = 1,
- IPA_ACTION_V4L2_SET_ISP,
- IPA_ACTION_STATS_METADATA_COMPLETE,
- IPA_ACTION_RUN_ISP,
- IPA_ACTION_EMBEDDED_COMPLETE,
- IPA_EVENT_SIGNAL_STAT_READY,
- IPA_EVENT_SIGNAL_ISP_PREPARE,
- IPA_EVENT_QUEUE_REQUEST,
-};
-
-enum BufferMask {
- ID = 0x00ffff,
- STATS = 0x010000,
- EMBEDDED_DATA = 0x020000,
- BAYER_DATA = 0x040000,
- EXTERNAL_BUFFER = 0x100000,
-};
-
-/* Size of the LS grid allocation. */
-static constexpr unsigned int MaxLsGridSize = 32 << 10;
-
/*
* List of controls handled by the Raspberry Pi IPA
*
diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom
new file mode 100644
index 00000000..bab19a94
--- /dev/null
+++ b/include/libcamera/ipa/raspberrypi.mojom
@@ -0,0 +1,131 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+module ipa.rpi;
+
+import "include/libcamera/ipa/core.mojom";
+
+enum BufferMask {
+ MaskID = 0x00ffff,
+ MaskStats = 0x010000,
+ MaskEmbeddedData = 0x020000,
+ MaskBayerData = 0x040000,
+ MaskExternalBuffer = 0x100000,
+};
+
+/* Size of the LS grid allocation. */
+const uint32 MaxLsGridSize = 0x8000;
+
+enum ConfigOutputParameters {
+ ConfigStaggeredWrite = 0x01,
+};
+
+struct SensorConfig {
+ uint32 gainDelay;
+ uint32 exposureDelay;
+ uint32 vblank;
+ uint32 sensorMetadata;
+};
+
+struct ISPConfig {
+ uint32 embeddedbufferId;
+ uint32 bayerbufferId;
+};
+
+struct ConfigInput {
+ uint32 op;
+ uint32 transform;
+ FileDescriptor lsTableHandle;
+};
+
+struct ConfigOutput {
+ uint32 params;
+ SensorConfig sensorConfig;
+ ControlList controls;
+};
+
+struct StartControls {
+ ControlList controls;
+ int32 dropFrameCount;
+};
+
+interface IPARPiInterface {
+ init(IPASettings settings) => (int32 ret);
+ start(StartControls controls) => (StartControls result);
+ stop();
+
+ /**
+ * \fn configure()
+ * \brief Configure the IPA stream and sensor settings
+ * \param[in] sensorInfo Camera sensor information
+ * \param[in] streamConfig Configuration of all active streams
+ * \param[in] entityControls Controls provided by the pipeline entities
+ * \param[in] ipaConfig Pipeline-handler-specific configuration data
+ * \param[out] results Pipeline-handler-specific configuration result
+ *
+ * This method shall be called when the camera is configured to inform
+ * the IPA of the camera's streams and the sensor settings.
+ *
+ * The \a sensorInfo conveys information about the camera sensor settings that
+ * the pipeline handler has selected for the configuration.
+ *
+ * The \a ipaConfig and \a results parameters carry data passed by the
+ * pipeline handler to the IPA and back.
+ */
+ configure(CameraSensorInfo sensorInfo,
+ map<uint32, IPAStream> streamConfig,
+ map<uint32, ControlInfoMap> entityControls,
+ ConfigInput ipaConfig)
+ => (ConfigOutput results, int32 ret);
+
+ /**
+ * \fn mapBuffers()
+ * \brief Map buffers shared between the pipeline handler and the IPA
+ * \param[in] buffers List of buffers to map
+ *
+ * This method informs the IPA module of memory buffers set up by the pipeline
+ * handler that the IPA needs to access. It provides dmabuf file handles for
+ * each buffer, and associates the buffers with unique numerical IDs.
+ *
+ * IPAs shall map the dmabuf file handles to their address space and keep a
+ * cache of the mappings, indexed by the buffer numerical IDs. The IDs are used
+ * in all other IPA interface methods to refer to buffers, including the
+ * unmapBuffers() method.
+ *
+ * All buffers that the pipeline handler wishes to share with an IPA shall be
+ * mapped with this method. Buffers may be mapped all at once with a single
+ * call, or mapped and unmapped dynamically at runtime, depending on the IPA
+ * protocol. Regardless of the protocol, all buffers mapped at a given time
+ * shall have unique numerical IDs.
+ *
+ * The numerical IDs have no meaning defined by the IPA interface, and
+ * should be treated as opaque handles by IPAs, with the only exception
+ * that ID zero is invalid.
+ *
+ * \sa unmapBuffers()
+ */
+ mapBuffers(array<IPABuffer> buffers);
+
+ /**
+ * \fn unmapBuffers()
+ * \brief Unmap buffers shared by the pipeline to the IPA
+ * \param[in] ids List of buffer IDs to unmap
+ *
+ * This method removes mappings set up with mapBuffers(). Numerical IDs
+ * of unmapped buffers may be reused when mapping new buffers.
+ *
+ * \sa mapBuffers()
+ */
+ unmapBuffers(array<uint32> ids);
+
+ [async] signalStatReady(uint32 bufferId);
+ [async] signalQueueRequest(ControlList controls);
+ [async] signalIspPrepare(ISPConfig data);
+};
+
+interface IPARPiEventInterface {
+ statsMetadataComplete(uint32 bufferId, ControlList controls);
+ runIsp(uint32 bufferId);
+ embeddedComplete(uint32 bufferId);
+ setIsp(ControlList controls);
+ setDelayedControls(ControlList controls);
+};
diff --git a/include/libcamera/ipa/rkisp1.h b/include/libcamera/ipa/rkisp1.h
deleted file mode 100644
index bb824f29..00000000
--- a/include/libcamera/ipa/rkisp1.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* 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__
-
-#ifndef __DOXYGEN__
-
-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 /* __DOXYGEN__ */
-
-#endif /* __LIBCAMERA_IPA_INTERFACE_RKISP1_H__ */
diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom
new file mode 100644
index 00000000..9270f9c7
--- /dev/null
+++ b/include/libcamera/ipa/rkisp1.mojom
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+module ipa.rkisp1;
+
+import "include/libcamera/ipa/core.mojom";
+
+enum RkISP1Operations {
+ ActionV4L2Set = 1,
+ ActionParamFilled = 2,
+ ActionMetadata = 3,
+ EventSignalStatBuffer = 4,
+ EventQueueRequest = 5,
+};
+
+struct RkISP1Event {
+ RkISP1Operations op;
+ uint32 frame;
+ uint32 bufferId;
+ ControlList controls;
+};
+
+struct RkISP1Action {
+ RkISP1Operations op;
+ ControlList controls;
+};
+
+interface IPARkISP1Interface {
+ init(IPASettings settings) => (int32 ret);
+ start() => (int32 ret);
+ stop();
+
+ configure(CameraSensorInfo sensorInfo,
+ map<uint32, IPAStream> streamConfig,
+ map<uint32, ControlInfoMap> entityControls) => ();
+
+ mapBuffers(array<IPABuffer> buffers);
+ unmapBuffers(array<uint32> ids);
+
+ [async] processEvent(RkISP1Event ev);
+};
+
+interface IPARkISP1EventInterface {
+ queueFrameAction(uint32 frame, RkISP1Action action);
+};
diff --git a/include/libcamera/ipa/vimc.h b/include/libcamera/ipa/vimc.h
deleted file mode 100644
index 27a4a61d..00000000
--- a/include/libcamera/ipa/vimc.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-/*
- * Copyright (C) 2019, Google Inc.
- *
- * vimc.h - Vimc Image Processing Algorithm module
- */
-
-#ifndef __LIBCAMERA_IPA_VIMC_H__
-#define __LIBCAMERA_IPA_VIMC_H__
-
-#ifndef __DOXYGEN__
-
-namespace libcamera {
-
-#define VIMC_IPA_FIFO_PATH "/tmp/libcamera_ipa_vimc_fifo"
-
-enum IPAOperationCode {
- IPAOperationNone,
- IPAOperationInit,
- IPAOperationStart,
- IPAOperationStop,
-};
-
-} /* namespace libcamera */
-
-#endif /* __DOXYGEN__ */
-
-#endif /* __LIBCAMERA_IPA_VIMC_H__ */
diff --git a/include/libcamera/ipa/vimc.mojom b/include/libcamera/ipa/vimc.mojom
new file mode 100644
index 00000000..165d9401
--- /dev/null
+++ b/include/libcamera/ipa/vimc.mojom
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+module ipa.vimc;
+
+import "include/libcamera/ipa/core.mojom";
+
+const string VimcIPAFIFOPath = "/tmp/libcamera_ipa_vimc_fifo";
+
+enum IPAOperationCode {
+ IPAOperationNone,
+ IPAOperationInit,
+ IPAOperationStart,
+ IPAOperationStop,
+};
+
+interface IPAVimcInterface {
+ init(IPASettings settings) => (int32 ret);
+ start() => (int32 ret);
+ stop();
+};
+
+interface IPAVimcEventInterface {
+ dummyEvent(uint32 val);
+};