[libcamera-devel,RFC,v2,3/7] libcamera: ipa: add Soft IPA common files
diff mbox series

Message ID 20231212115046.102726-4-andrey.konovalov@linaro.org
State Superseded
Headers show
Series
  • libcamera: introduce Software ISP and Software IPA
Related show

Commit Message

Andrey Konovalov Dec. 12, 2023, 11:50 a.m. UTC
Define the Soft IPA main and event interfaces, add IPASoftBase
class the Soft IPA implementation inherit from.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
---
 include/libcamera/ipa/meson.build   |  1 +
 include/libcamera/ipa/soft.mojom    | 27 ++++++++++++
 src/ipa/simple/common/meson.build   | 17 ++++++++
 src/ipa/simple/common/soft_base.cpp | 66 +++++++++++++++++++++++++++++
 src/ipa/simple/common/soft_base.h   | 47 ++++++++++++++++++++
 src/ipa/simple/meson.build          |  3 ++
 6 files changed, 161 insertions(+)
 create mode 100644 include/libcamera/ipa/soft.mojom
 create mode 100644 src/ipa/simple/common/meson.build
 create mode 100644 src/ipa/simple/common/soft_base.cpp
 create mode 100644 src/ipa/simple/common/soft_base.h
 create mode 100644 src/ipa/simple/meson.build

Patch
diff mbox series

diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build
index f3b4881c..aaee5cbf 100644
--- a/include/libcamera/ipa/meson.build
+++ b/include/libcamera/ipa/meson.build
@@ -65,6 +65,7 @@  pipeline_ipa_mojom_mapping = {
     'ipu3': 'ipu3.mojom',
     'rkisp1': 'rkisp1.mojom',
     'rpi/vc4': 'raspberrypi.mojom',
+    'simple/linaro': 'soft.mojom',
     'vimc': 'vimc.mojom',
 }
 
diff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom
new file mode 100644
index 00000000..c3449188
--- /dev/null
+++ b/include/libcamera/ipa/soft.mojom
@@ -0,0 +1,27 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+/*
+ * \todo Document the interface and remove the related EXCLUDE_PATTERNS entry.
+ * \todo Add a way to tell SoftIPA the list of params SoftISP accepts?
+ */
+
+module ipa.soft;
+
+import "include/libcamera/ipa/core.mojom";
+
+interface IPASoftInterface {
+	init(libcamera.IPASettings settings,
+	     libcamera.SharedFD fdStats,
+	     libcamera.ControlInfoMap sensorCtrlInfoMap)
+		=> (int32 ret);
+	start() => (int32 ret);
+	stop();
+	configure(libcamera.ControlInfoMap sensorCtrlInfoMap)
+		=> (int32 ret);
+
+	[async] processStats(libcamera.ControlList sensorControls);
+};
+
+interface IPASoftEventInterface {
+	setSensorControls(libcamera.ControlList sensorControls);
+};
diff --git a/src/ipa/simple/common/meson.build b/src/ipa/simple/common/meson.build
new file mode 100644
index 00000000..023e617b
--- /dev/null
+++ b/src/ipa/simple/common/meson.build
@@ -0,0 +1,17 @@ 
+# SPDX-License-Identifier: CC0-1.0
+
+soft_ipa_common_sources = files([
+    'soft_base.cpp',
+])
+
+soft_ipa_common_includes = [
+    include_directories('..'),
+]
+
+soft_ipa_common_deps = [
+    libcamera_private,
+]
+
+soft_ipa_common_lib = static_library('soft_ipa_common', soft_ipa_common_sources,
+                                     include_directories : soft_ipa_common_includes,
+                                     dependencies : soft_ipa_common_deps)
diff --git a/src/ipa/simple/common/soft_base.cpp b/src/ipa/simple/common/soft_base.cpp
new file mode 100644
index 00000000..7bd9b8de
--- /dev/null
+++ b/src/ipa/simple/common/soft_base.cpp
@@ -0,0 +1,66 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2023, Linaro Ltd
+ *
+ * soft-base.cpp - Software IPA base class
+ */
+
+#include "soft_base.h"
+
+#include <sys/mman.h>
+
+#include <libcamera/base/file.h>
+#include <libcamera/base/log.h>
+
+#include <libcamera/control_ids.h>
+
+namespace libcamera {
+
+LOG_DEFINE_CATEGORY(IPASoft)
+
+namespace ipa::soft {
+
+IPASoftBase::IPASoftBase()
+{
+}
+
+IPASoftBase::~IPASoftBase()
+{
+}
+
+int IPASoftBase::init([[maybe_unused]] const IPASettings &settings,
+		      const SharedFD &fdStats,
+		      const ControlInfoMap &sensorInfoMap)
+{
+	fdStats_ = std::move(fdStats);
+	if (!fdStats_.isValid()) {
+		LOG(IPASoft, Error) << "Invalid Statistics handle";
+		return -ENODEV;
+	}
+
+	return platformInit(sensorInfoMap);
+}
+
+int IPASoftBase::configure(const ControlInfoMap &sensorInfoMap)
+{
+	return platformConfigure(sensorInfoMap);
+}
+
+int IPASoftBase::start()
+{
+	return platformStart();
+}
+
+void IPASoftBase::stop()
+{
+	return platformStop();
+}
+
+void IPASoftBase::processStats(const ControlList &sensorControls)
+{
+	return platformProcessStats(sensorControls);
+}
+
+} /* namespace ipa::soft */
+
+} /* namespace libcamera */
diff --git a/src/ipa/simple/common/soft_base.h b/src/ipa/simple/common/soft_base.h
new file mode 100644
index 00000000..bff53713
--- /dev/null
+++ b/src/ipa/simple/common/soft_base.h
@@ -0,0 +1,47 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2023, Linaro Ltd
+ *
+ * soft-base.h - Software IPA base class
+ */
+#pragma once
+
+#include <libcamera/base/shared_fd.h>
+#include <libcamera/controls.h>
+
+#include <libcamera/ipa/soft_ipa_interface.h>
+
+namespace libcamera {
+
+namespace ipa::soft {
+
+class IPASoftBase : public ipa::soft::IPASoftInterface
+{
+public:
+	IPASoftBase();
+	~IPASoftBase();
+
+	int init(const IPASettings &settings,
+		 const SharedFD &fdStats,
+		 const ControlInfoMap &sensorInfoMap) override;
+	int configure(const ControlInfoMap &sensorInfoMap) override;
+
+	int start() override;
+	void stop() override;
+
+	void processStats(const ControlList &sensorControls) override;
+
+protected:
+	SharedFD fdStats_;
+
+private:
+	virtual int platformInit(const ControlInfoMap &sensorInfoMap) = 0;
+	virtual int platformConfigure(const ControlInfoMap &sensorInfoMap) = 0;
+	virtual int platformStart() = 0;
+	virtual void platformStop() = 0;
+	virtual void platformProcessStats(const ControlList &sensorControls) = 0;
+};
+
+} /* namespace ipa::soft */
+
+} /* namespace libcamera */
diff --git a/src/ipa/simple/meson.build b/src/ipa/simple/meson.build
new file mode 100644
index 00000000..9688bbdb
--- /dev/null
+++ b/src/ipa/simple/meson.build
@@ -0,0 +1,3 @@ 
+# SPDX-License-Identifier: CC0-1.0
+
+subdir('common')