[libcamera-devel] [PATCH v2 11/18] libcamera: ipa: add Soft IPA common files
Hans de Goede
hdegoede at redhat.com
Sat Jan 13 15:22:11 CET 2024
From: Andrey Konovalov <andrey.konovalov at linaro.org>
Define the Soft IPA main and event interfaces, add IPASoftBase
class the Soft IPA implementation inherit from.
Signed-off-by: Andrey Konovalov <andrey.konovalov at linaro.org>
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
Tested-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org> # sc8280xp Lenovo x13s
Tested-by: Pavel Machek <pavel at ucw.cz>
---
Documentation/Doxyfile.in | 1 +
include/libcamera/ipa/meson.build | 1 +
include/libcamera/ipa/soft.mojom | 29 ++++++++++++
src/ipa/simple/common/meson.build | 17 +++++++
src/ipa/simple/common/soft_base.cpp | 73 +++++++++++++++++++++++++++++
src/ipa/simple/common/soft_base.h | 50 ++++++++++++++++++++
src/ipa/simple/meson.build | 3 ++
7 files changed, 174 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
diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in
index a86ea6c1..2be8d47b 100644
--- a/Documentation/Doxyfile.in
+++ b/Documentation/Doxyfile.in
@@ -44,6 +44,7 @@ EXCLUDE = @TOP_SRCDIR@/include/libcamera/base/span.h \
@TOP_SRCDIR@/src/libcamera/pipeline/ \
@TOP_SRCDIR@/src/libcamera/tracepoints.cpp \
@TOP_BUILDDIR@/include/libcamera/internal/tracepoints.h \
+ @TOP_BUILDDIR@/include/libcamera/ipa/soft_ipa_interface.h \
@TOP_BUILDDIR@/src/libcamera/proxy/
EXCLUDE_PATTERNS = @TOP_BUILDDIR@/include/libcamera/ipa/*_serializer.h \
diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build
index f3b4881c..894e38a6 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/simple': '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..2dae652b
--- /dev/null
+++ b/include/libcamera/ipa/soft.mojom
@@ -0,0 +1,29 @@
+/* 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.SharedFD fdParams,
+ 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);
+ setIspParams(int32 dummy);
+};
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..b4ed9023
--- /dev/null
+++ b/src/ipa/simple/common/soft_base.cpp
@@ -0,0 +1,73 @@
+/* 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 SharedFD &fdParams,
+ const ControlInfoMap &sensorInfoMap)
+{
+ fdStats_ = std::move(fdStats);
+ if (!fdStats_.isValid()) {
+ LOG(IPASoft, Error) << "Invalid Statistics handle";
+ return -ENODEV;
+ }
+
+ fdParams_ = std::move(fdParams);
+ if (!fdParams_.isValid()) {
+ LOG(IPASoft, Error) << "Invalid Parameters 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..85c98702
--- /dev/null
+++ b/src/ipa/simple/common/soft_base.h
@@ -0,0 +1,50 @@
+/* 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 SharedFD &fdParams,
+ 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_;
+ SharedFD fdParams_;
+
+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')
--
2.43.0
More information about the libcamera-devel
mailing list