[libcamera-devel,29/38] libcamera: pipeline, ipa: vimc: Support the new IPC mechanism

Message ID 20200922133537.258098-30-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • IPA isolation implementation
Related show

Commit Message

Paul Elder Sept. 22, 2020, 1:35 p.m. UTC
Add support to vimc pipeline handler and IPA for the new IPC mechanism.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
New in v2
---
 include/libcamera/ipa/meson.build            |  1 +
 include/libcamera/ipa/{ipa_vimc.h => vimc.h} |  4 ++++
 include/libcamera/ipa/vimc.mojom             | 12 ++++++++++++
 src/ipa/vimc/meson.build                     |  2 +-
 src/ipa/vimc/vimc.cpp                        | 18 +++++-------------
 src/libcamera/pipeline/vimc/vimc.cpp         |  8 +++++++-
 6 files changed, 30 insertions(+), 15 deletions(-)
 rename include/libcamera/ipa/{ipa_vimc.h => vimc.h} (87%)
 create mode 100644 include/libcamera/ipa/vimc.mojom

Patch

diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build
index 0b74bc10..cececee5 100644
--- a/include/libcamera/ipa/meson.build
+++ b/include/libcamera/ipa/meson.build
@@ -25,6 +25,7 @@  ipa_mojom_core = custom_target(core_mojom_file.split('.')[0] + '_mojom_module',
 
 ipa_mojom_files = [
     'raspberrypi.mojom',
+    'vimc.mojom',
 ]
 
 ipa_mojoms = []
diff --git a/include/libcamera/ipa/ipa_vimc.h b/include/libcamera/ipa/vimc.h
similarity index 87%
rename from include/libcamera/ipa/ipa_vimc.h
rename to include/libcamera/ipa/vimc.h
index 8e82dd94..b68d0ade 100644
--- a/include/libcamera/ipa/ipa_vimc.h
+++ b/include/libcamera/ipa/vimc.h
@@ -8,6 +8,8 @@ 
 #ifndef __LIBCAMERA_IPA_VIMC_H__
 #define __LIBCAMERA_IPA_VIMC_H__
 
+#include <libcamera/controls.h>
+
 namespace libcamera {
 
 #define VIMC_IPA_FIFO_PATH "/tmp/libcamera_ipa_vimc_fifo"
@@ -19,6 +21,8 @@  enum IPAOperationCode {
 	IPAOperationStop,
 };
 
+static ControlInfoMap VimcControls;
+
 } /* namespace libcamera */
 
 #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..9ab6d005
--- /dev/null
+++ b/include/libcamera/ipa/vimc.mojom
@@ -0,0 +1,12 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+import "include/libcamera/ipa/core.mojom";
+
+interface IPAVimcInterface {
+	init(IPASettings settings) => (int32 ret);
+	start() => (int32 ret);
+	stop();
+};
+
+interface IPAVimcCallbackInterface {
+};
diff --git a/src/ipa/vimc/meson.build b/src/ipa/vimc/meson.build
index 8c9df854..b2b7a09d 100644
--- a/src/ipa/vimc/meson.build
+++ b/src/ipa/vimc/meson.build
@@ -3,7 +3,7 @@ 
 ipa_name = 'ipa_vimc'
 
 mod = shared_module(ipa_name,
-                    'vimc.cpp',
+                    ['vimc.cpp', libcamera_generated_headers],
                     name_prefix : '',
                     include_directories : [ipa_includes, libipa_includes],
                     dependencies : libcamera_dep,
diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp
index ef257762..00ec7b80 100644
--- a/src/ipa/vimc/vimc.cpp
+++ b/src/ipa/vimc/vimc.cpp
@@ -5,7 +5,8 @@ 
  * ipa_vimc.cpp - Vimc Image Processing Algorithm module
  */
 
-#include <libcamera/ipa/ipa_vimc.h>
+#include <libcamera/ipa/vimc.h>
+#include <libcamera/ipa/vimc_generated.h>
 
 #include <fcntl.h>
 #include <string.h>
@@ -26,7 +27,7 @@  namespace libcamera {
 
 LOG_DEFINE_CATEGORY(IPAVimc)
 
-class IPAVimc : public IPAInterface
+class IPAVimc : public IPAVimcInterface
 {
 public:
 	IPAVimc();
@@ -37,15 +38,6 @@  public:
 	int start() override;
 	void stop() override;
 
-	void configure([[maybe_unused]] const CameraSensorInfo &sensorInfo,
-		       [[maybe_unused]] const std::map<unsigned int, IPAStream> &streamConfig,
-		       [[maybe_unused]] const std::map<unsigned int, const ControlInfoMap &> &entityControls,
-		       [[maybe_unused]] const IPAOperationData &ipaConfig,
-		       [[maybe_unused]] IPAOperationData *result) override {}
-	void mapBuffers([[maybe_unused]] const std::vector<IPABuffer> &buffers) override {}
-	void unmapBuffers([[maybe_unused]] const std::vector<unsigned int> &ids) override {}
-	void processEvent([[maybe_unused]] const IPAOperationData &event) override {}
-
 private:
 	void initTrace();
 	void trace(enum IPAOperationCode operation);
@@ -141,9 +133,9 @@  const struct IPAModuleInfo ipaModuleInfo = {
 	"vimc",
 };
 
-struct ipa_context *ipaCreate()
+IPAInterface *ipaCreate()
 {
-	return new IPAInterfaceWrapper(std::make_unique<IPAVimc>());
+	return new IPAVimc();
 }
 }
 
diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
index d192670b..466629d7 100644
--- a/src/libcamera/pipeline/vimc/vimc.cpp
+++ b/src/libcamera/pipeline/vimc/vimc.cpp
@@ -34,6 +34,10 @@ 
 #include "libcamera/internal/v4l2_subdevice.h"
 #include "libcamera/internal/v4l2_videodevice.h"
 
+#include <libcamera/ipa/vimc.h>
+#include <libcamera/ipa/vimc_generated.h>
+#include <libcamera/ipa/ipa_proxy_vimc.h>
+
 namespace libcamera {
 
 LOG_DEFINE_CATEGORY(VIMC)
@@ -67,6 +71,8 @@  public:
 	V4L2VideoDevice *video_;
 	V4L2VideoDevice *raw_;
 	Stream stream_;
+
+	std::unique_ptr<IPAProxyVimc> ipa_;
 };
 
 class VimcCameraConfiguration : public CameraConfiguration
@@ -423,7 +429,7 @@  bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)
 
 	std::unique_ptr<VimcCameraData> data = std::make_unique<VimcCameraData>(this, media);
 
-	data->ipa_ = IPAManager::createIPA(this, 0, 0);
+	data->ipa_ = IPAManager::createIPA<IPAProxyVimc>(this, 0, 0);
 	if (data->ipa_ != nullptr) {
 		std::string conf = data->ipa_->configurationFile("vimc.conf");
 		data->ipa_->init(IPASettings{ conf });