[v2,2/4] ipa: rpi: Add vd56g3 support for rpi
diff mbox series

Message ID 20250728-vd56g3_support-v2-2-cee5d5feac44@foss.st.com
State New
Headers show
Series
  • Add vd56g3 support for rpi and libipa
Related show

Commit Message

Benjamin Mugnier July 28, 2025, 9:09 a.m. UTC
The cam_helper gain formula and frameIntegrationDiff can be found in the
vd56g3 user manual.

Signed-off-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Reviewed-by: Naushir Patuck <naush@rasbperrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/ipa/rpi/cam_helper/cam_helper_vd56g3.cpp | 49 ++++++++++++++++++++++++++++
 src/ipa/rpi/cam_helper/meson.build           |  1 +
 2 files changed, 50 insertions(+)

Patch
diff mbox series

diff --git a/src/ipa/rpi/cam_helper/cam_helper_vd56g3.cpp b/src/ipa/rpi/cam_helper/cam_helper_vd56g3.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..140aabd802ade61fd785d21a73e46d88be8d1b96
--- /dev/null
+++ b/src/ipa/rpi/cam_helper/cam_helper_vd56g3.cpp
@@ -0,0 +1,49 @@ 
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*
+ * Copyright (C) STMicroelectronics SA 2025
+ *
+ * Camera information for vd56g3 sensor
+ */
+
+#include <assert.h>
+
+#include "cam_helper.h"
+
+using namespace RPiController;
+
+class CamHelperVd56g3 : public CamHelper
+{
+public:
+	CamHelperVd56g3();
+	uint32_t gainCode(double gain) const override;
+	double gain(uint32_t gainCode) const override;
+
+private:
+	/*
+	 * Smallest difference between the frame length and integration time,
+	 * in units of lines.
+	 */
+	static constexpr int frameIntegrationDiff = 61;
+};
+
+CamHelperVd56g3::CamHelperVd56g3()
+	: CamHelper({}, frameIntegrationDiff)
+{
+}
+
+uint32_t CamHelperVd56g3::gainCode(double gain) const
+{
+	return static_cast<uint32_t>(32.0 - 32.0 / gain);
+}
+
+double CamHelperVd56g3::gain(uint32_t gainCode) const
+{
+	return static_cast<double>(32.0 / (32 - gainCode));
+}
+
+static CamHelper *create()
+{
+	return new CamHelperVd56g3();
+}
+
+static RegisterCamHelper reg("vd56g3", &create);
diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build
index abf021474b5c226782b847c709de638b6e7635c1..b70acbee5fcaa94265da1f1ad75487563486679f 100644
--- a/src/ipa/rpi/cam_helper/meson.build
+++ b/src/ipa/rpi/cam_helper/meson.build
@@ -14,6 +14,7 @@  rpi_ipa_cam_helper_sources = files([
     'cam_helper_ov64a40.cpp',
     'cam_helper_ov7251.cpp',
     'cam_helper_ov9281.cpp',
+    'cam_helper_vd56g3.cpp',
     'md_parser_smia.cpp',
 ])