[libcamera-devel,RFC,1/7] libcamera: introduce SoftwareIsp class
diff mbox series

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

Commit Message

Andrey Konovalov Dec. 4, 2023, 12:10 a.m. UTC
Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
---
 include/libcamera/internal/meson.build    |  1 +
 include/libcamera/internal/software_isp.h | 67 +++++++++++++++++++++++
 src/libcamera/meson.build                 |  1 +
 src/libcamera/software_isp.cpp            | 25 +++++++++
 4 files changed, 94 insertions(+)
 create mode 100644 include/libcamera/internal/software_isp.h
 create mode 100644 src/libcamera/software_isp.cpp

Patch
diff mbox series

diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build
index 7f1f3440..0f725cfd 100644
--- a/include/libcamera/internal/meson.build
+++ b/include/libcamera/internal/meson.build
@@ -38,6 +38,7 @@  libcamera_internal_headers = files([
     'process.h',
     'pub_key.h',
     'request.h',
+    'software_isp.h',
     'source_paths.h',
     'sysfs.h',
     'v4l2_device.h',
diff --git a/include/libcamera/internal/software_isp.h b/include/libcamera/internal/software_isp.h
new file mode 100644
index 00000000..556203d9
--- /dev/null
+++ b/include/libcamera/internal/software_isp.h
@@ -0,0 +1,67 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2023, Linaro Ltd
+ *
+ * software_isp.h - Interface for a software implementation of an ISP
+ */
+
+#pragma once
+
+#include <functional>
+#include <initializer_list>
+#include <map>
+#include <memory>
+#include <string>
+#include <tuple>
+#include <vector>
+
+#include <libcamera/base/class.h>
+#include <libcamera/base/signal.h>
+
+#include <libcamera/geometry.h>
+
+namespace libcamera {
+
+class FrameBuffer;
+class PixelFormat;
+struct StreamConfiguration;
+
+class SoftwareIsp
+{
+public:
+	SoftwareIsp(const std::string &name);
+	virtual ~SoftwareIsp();
+
+	virtual int loadConfiguration(const std::string &filename) = 0;
+
+	virtual bool isValid() const = 0;
+
+	virtual std::vector<PixelFormat> formats(PixelFormat input) = 0;
+	virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;
+
+	virtual std::tuple<unsigned int, unsigned int>
+	strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) = 0;
+
+	virtual int configure(const StreamConfiguration &inputCfg,
+			      const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs) = 0;
+	virtual int exportBuffers(unsigned int output, unsigned int count,
+				  std::vector<std::unique_ptr<FrameBuffer>> *buffers) = 0;
+
+	virtual int start() = 0;
+	virtual void stop() = 0;
+
+	virtual int queueBuffers(FrameBuffer *input,
+				 const std::map<unsigned int, FrameBuffer *> &outputs) = 0;
+
+	Signal<FrameBuffer *> inputBufferReady;
+	Signal<FrameBuffer *> outputBufferReady;
+
+	/* The int parameter isn't actually used */
+	Signal<int> ispStatsReady;
+
+	const std::string &name() const { return name_; }
+private:
+	std::string name_;
+};
+
+} /* namespace libcamera */
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index d0e26f6b..9d26a87f 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -40,6 +40,7 @@  libcamera_sources = files([
     'process.cpp',
     'pub_key.cpp',
     'request.cpp',
+    'software_isp.cpp',
     'source_paths.cpp',
     'stream.cpp',
     'sysfs.cpp',
diff --git a/src/libcamera/software_isp.cpp b/src/libcamera/software_isp.cpp
new file mode 100644
index 00000000..3d81c27a
--- /dev/null
+++ b/src/libcamera/software_isp.cpp
@@ -0,0 +1,25 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2023, Linaro Ltd
+ *
+ * software_isp.cpp - Interface for a software implementation of an ISP
+ */
+
+#include "libcamera/internal/software_isp.h"
+
+#include <libcamera/base/log.h>
+
+namespace libcamera {
+
+LOG_DEFINE_CATEGORY(SoftwareIsp)
+
+SoftwareIsp::SoftwareIsp(const std::string &name)
+	: name_(name)
+{
+}
+
+SoftwareIsp::~SoftwareIsp()
+{
+}
+
+} /* namespace libcamera */