about summary refs log tree commit diff
path: root/users/flokli/ipu6-softisp/libcamera/0011-libcamera-ipa-add-Soft-IPA-common-files.patch
blob: d5fd94f6af379cfc7c649dcfe055938e18d28388 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
From 05b353f1e45f2af0d0989261210b4bedef5144de Mon Sep 17 00:00:00 2001
From: Andrey Konovalov <andrey.konovalov@linaro.org>
Date: Mon, 11 Dec 2023 23:41:58 +0300
Subject: [PATCH 11/25] libcamera: ipa: add Soft IPA common files

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>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s
Tested-by: Pavel Machek <pavel@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