[v2,3/4] libcamera: rkisp1: Add base class DW100 dewarper
diff mbox series

Message ID 20240519115622.32170-4-umang.jain@ideasonboard.com
State Superseded
Headers show
Series
  • libcamera: rkisp1: Plumb i.MX8MP DW100 dewarper
Related show

Commit Message

Umang Jain May 19, 2024, 11:56 a.m. UTC
DW100 Dewarp engine is present on I.MX8MP SoC. This patch
provides a base RkISP1Dewarper class (inherited from V4L2M2MConverter)
which then can be used to load a dewarp config file and scaling
capabilites.

\todo: Add plumbing to load a vertex map on top

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/libcamera/pipeline/rkisp1/meson.build     |  1 +
 .../pipeline/rkisp1/rkisp1_dewarper.cpp       | 38 +++++++++++++++++++
 .../pipeline/rkisp1/rkisp1_dewarper.h         | 25 ++++++++++++
 3 files changed, 64 insertions(+)
 create mode 100644 src/libcamera/pipeline/rkisp1/rkisp1_dewarper.cpp
 create mode 100644 src/libcamera/pipeline/rkisp1/rkisp1_dewarper.h

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rkisp1/meson.build b/src/libcamera/pipeline/rkisp1/meson.build
index cad66535..e8a989b1 100644
--- a/src/libcamera/pipeline/rkisp1/meson.build
+++ b/src/libcamera/pipeline/rkisp1/meson.build
@@ -2,5 +2,6 @@ 
 
 libcamera_sources += files([
     'rkisp1.cpp',
+    'rkisp1_dewarper.cpp',
     'rkisp1_path.cpp',
 ])
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_dewarper.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_dewarper.cpp
new file mode 100644
index 00000000..0bd72497
--- /dev/null
+++ b/src/libcamera/pipeline/rkisp1/rkisp1_dewarper.cpp
@@ -0,0 +1,38 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024, Ideas On Board Oy
+ *
+ * i.MX8MP Dewarp Engine integration
+ */
+
+#include "rkisp1_dewarper.h"
+
+#include <libcamera/base/log.h>
+
+#include <libcamera/geometry.h>
+
+#include "libcamera/internal/media_device.h"
+#include "libcamera/internal/v4l2_videodevice.h"
+
+namespace libcamera {
+
+LOG_DECLARE_CATEGORY(RkISP1)
+
+RkISP1Dewarper::RkISP1Dewarper(std::shared_ptr<MediaDevice> media)
+	: V4L2M2MConverter(media.get())
+{
+}
+
+int RkISP1Dewarper::setScalerCrop(unsigned int output, Rectangle rect)
+{
+	int ret;
+
+	ret = setSelection(output, V4L2_SEL_TGT_CROP, &rect);
+	if (ret < 0)
+		LOG(RkISP1, Error) << "Failed to set scaler crop on dewarper "
+				   << strerror(-ret);
+
+	return ret;
+}
+
+} /* namespace libcamera */
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_dewarper.h b/src/libcamera/pipeline/rkisp1/rkisp1_dewarper.h
new file mode 100644
index 00000000..600e35bd
--- /dev/null
+++ b/src/libcamera/pipeline/rkisp1/rkisp1_dewarper.h
@@ -0,0 +1,25 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024, Ideas On Board Oy
+ *
+ *i.MX8MP Dewarp Engine integration
+ */
+
+#pragma once
+
+#include "libcamera/internal/converter/converter_v4l2_m2m.h"
+
+namespace libcamera {
+
+class Rectangle;
+struct MediaDevice;
+
+class RkISP1Dewarper : public V4L2M2MConverter
+{
+public:
+	RkISP1Dewarper(std::shared_ptr<MediaDevice> media);
+
+	int setScalerCrop(unsigned int output, Rectangle rect);
+};
+
+} /* namespace libcamera */