<div dir="ltr"><div dir="ltr">Hi David,<div><br></div><div>New sensors, very nice!</div><div><br></div><div>On Tue, 15 Jun 2021 at 11:51, David Plowman <<a href="mailto:david.plowman@raspberrypi.com">david.plowman@raspberrypi.com</a>> wrote:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The necessary tuning file and CamHelper is added for the ov9281 sensor<br>
(which the driver names as the "mov9281").<br>
<br>
The ov9281 is a 1280x800 monochrome global shutter sensor. To enable<br>
it, please add<br>
<br>
dtoverlay=ov9281<br>
<br>
to the /boot/config.txt file and reboot the Pi.<br>
<br>
Signed-off-by: David Plowman <<a href="mailto:david.plowman@raspberrypi.com" target="_blank">david.plowman@raspberrypi.com</a>><br>
---<br>
src/ipa/raspberrypi/cam_helper_mov9281.cpp | 108 +++++++++++++++++++++<br>
src/ipa/raspberrypi/data/meson.build | 1 +<br>
src/ipa/raspberrypi/data/mov9281.json | 92 ++++++++++++++++++<br>
src/ipa/raspberrypi/meson.build | 1 +<br>
4 files changed, 202 insertions(+)<br>
create mode 100644 src/ipa/raspberrypi/cam_helper_mov9281.cpp<br>
create mode 100644 src/ipa/raspberrypi/data/mov9281.json<br>
<br>
diff --git a/src/ipa/raspberrypi/cam_helper_mov9281.cpp b/src/ipa/raspberrypi/cam_helper_mov9281.cpp<br>
new file mode 100644<br>
index 00000000..5645c73a<br>
--- /dev/null<br>
+++ b/src/ipa/raspberrypi/cam_helper_mov9281.cpp<br>
@@ -0,0 +1,108 @@<br>
+/* SPDX-License-Identifier: BSD-2-Clause */<br>
+/*<br>
+ * Copyright (C) 2019, Raspberry Pi (Trading) Limited<br>
+ *<br>
+ * cam_helper_mov9281.cpp - camera information for ov9281 sensor<br>
+ */<br>
+<br>
+#include <assert.h><br>
+<br>
+#include "cam_helper.hpp"<br>
+<br>
+using namespace RPiController;<br>
+<br>
+class CamHelperOv9281 : public CamHelper<br>
+{<br>
+public:<br>
+ CamHelperOv9281();<br>
+ uint32_t GainCode(double gain) const override;<br>
+ double Gain(uint32_t gain_code) const override;<br>
+ void GetDelays(int &exposure_delay, int &gain_delay,<br>
+ int &vblank_delay) const override;<br>
+ unsigned int HideFramesStartup() const override;<br>
+ unsigned int HideFramesModeSwitch() const override;<br>
+ unsigned int MistrustFramesStartup() const override;<br>
+ unsigned int MistrustFramesModeSwitch() const override;<br>
+<br>
+private:<br>
+ /*<br>
+ * Smallest difference between the frame length and integration time,<br>
+ * in units of lines.<br>
+ */<br>
+ static constexpr int frameIntegrationDiff = 4;<br>
+};<br>
+<br>
+/*<br>
+ * OV9281 doesn't output metadata, so we have to use the "unicam parser" which<br>
+ * works by counting frames.<br>
+ */<br>
+<br>
+CamHelperOv9281::CamHelperOv9281()<br>
+ : CamHelper(nullptr, frameIntegrationDiff)<br>
+{<br>
+}<br>
+<br>
+uint32_t CamHelperOv9281::GainCode(double gain) const<br>
+{<br>
+ return static_cast<uint32_t>(gain * 16.0);<br>
+}<br>
+<br>
+double CamHelperOv9281::Gain(uint32_t gain_code) const<br>
+{<br>
+ return static_cast<double>(gain_code) / 16.0;<br>
+}<br>
+<br>
+void CamHelperOv9281::GetDelays(int &exposure_delay, int &gain_delay,<br>
+ int &vblank_delay) const<br>
+{<br>
+ /*<br>
+ * We run this sensor in a mode where the gain delay is bumped up to<br>
+ * 2. It seems to be the only way to make the delays "predictable".<br>
+ */<br>
+ exposure_delay = 2;<br>
+ gain_delay = 2;<br>
+ vblank_delay = 2;<br>
+}<br>
+<br>
+unsigned int CamHelperOv9281::HideFramesStartup() const<br>
+{<br>
+ /*<br>
+ * On startup, we get a couple of under-exposed frames which<br>
+ * we don't want shown.<br>
+ */<br>
+ return 2;<br>
+}<br>
+<br>
+unsigned int CamHelperOv9281::HideFramesModeSwitch() const<br>
+{<br>
+ /*<br>
+ * After a mode switch, we get a couple of under-exposed frames which<br>
+ * we don't want shown.<br>
+ */<br>
+ return 2;<br>
+}<br>
+<br>
+unsigned int CamHelperOv9281::MistrustFramesStartup() const<br>
+{<br>
+ /*<br>
+ * First couple of frames are under-exposed and are no good for control<br>
+ * algos.<br>
+ */<br>
+ return 2;<br>
+}<br>
+<br>
+unsigned int CamHelperOv9281::MistrustFramesModeSwitch() const<br>
+{<br>
+ /*<br>
+ * First couple of frames are under-exposed even after a simple<br>
+ * mode switch, and are no good for control algos.<br>
+ */<br>
+ return 2;<br>
+}<br></blockquote><div><br></div><div>Perhaps we need to see if these numbers can be reduced or (ideally) set to 0?</div><div>Other than that, looks good!</div><div><br></div><div>Reviewed-by: Naushir Patuck <<a href="mailto:naush@raspberrpyi.com">naush@raspberrpyi.com</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+static CamHelper *Create()<br>
+{<br>
+ return new CamHelperOv9281();<br>
+}<br>
+<br>
+static RegisterCamHelper reg("mov9281", &Create);<br>
diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build<br>
index 92ad3272..f8baab6d 100644<br>
--- a/src/ipa/raspberrypi/data/meson.build<br>
+++ b/src/ipa/raspberrypi/data/meson.build<br>
@@ -4,6 +4,7 @@ conf_files = files([<br>
'imx219.json',<br>
'imx290.json',<br>
'imx477.json',<br>
+ 'mov9281.json',<br>
'ov5647.json',<br>
'se327m12.json',<br>
'uncalibrated.json',<br>
diff --git a/src/ipa/raspberrypi/data/mov9281.json b/src/ipa/raspberrypi/data/mov9281.json<br>
new file mode 100644<br>
index 00000000..ecd262be<br>
--- /dev/null<br>
+++ b/src/ipa/raspberrypi/data/mov9281.json<br>
@@ -0,0 +1,92 @@<br>
+{<br>
+ "rpi.black_level":<br>
+ {<br>
+ "black_level": 4096<br>
+ },<br>
+ "rpi.lux":<br>
+ {<br>
+ "reference_shutter_speed": 2000,<br>
+ "reference_gain": 1.0,<br>
+ "reference_aperture": 1.0,<br>
+ "reference_lux": 800,<br>
+ "reference_Y": 20000<br>
+ },<br>
+ "rpi.noise":<br>
+ {<br>
+ "reference_constant": 0,<br>
+ "reference_slope": 2.5<br>
+ },<br>
+ "rpi.sdn":<br>
+ {<br>
+ },<br>
+ "rpi.agc":<br>
+ {<br>
+ "metering_modes":<br>
+ {<br>
+ "centre-weighted": {<br>
+ "weights": [4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0]<br>
+ }<br>
+ },<br>
+ "exposure_modes":<br>
+ {<br>
+ "normal":<br>
+ {<br>
+ "shutter": [ 100, 15000, 30000, 60000, 120000 ],<br>
+ "gain": [ 1.0, 2.0, 3.0, 4.0, 6.0 ]<br>
+ }<br>
+ },<br>
+ "constraint_modes":<br>
+ {<br>
+ "normal":<br>
+ [<br>
+ { "bound": "LOWER", "q_lo": 0.98, "q_hi": 1.0, "y_target": [ 0, 0.4, 1000, 0.4 ] }<br>
+ ]<br>
+ },<br>
+ "y_target": [ 0, 0.16, 1000, 0.165, 10000, 0.17 ]<br>
+ },<br>
+ "rpi.alsc":<br>
+ {<br>
+ "n_iter": 0,<br>
+ "luminance_strength": 1.0,<br>
+ "corner_strength": 1.5<br>
+ },<br>
+ "rpi.contrast":<br>
+ {<br>
+ "ce_enable": 0,<br>
+ "gamma_curve": [<br>
+ 0, 0,<br>
+ 1024, 5040,<br>
+ 2048, 9338,<br>
+ 3072, 12356,<br>
+ 4096, 15312,<br>
+ 5120, 18051,<br>
+ 6144, 20790,<br>
+ 7168, 23193,<br>
+ 8192, 25744,<br>
+ 9216, 27942,<br>
+ 10240, 30035,<br>
+ 11264, 32005,<br>
+ 12288, 33975,<br>
+ 13312, 35815,<br>
+ 14336, 37600,<br>
+ 15360, 39168,<br>
+ 16384, 40642,<br>
+ 18432, 43379,<br>
+ 20480, 45749,<br>
+ 22528, 47753,<br>
+ 24576, 49621,<br>
+ 26624, 51253,<br>
+ 28672, 52698,<br>
+ 30720, 53796,<br>
+ 32768, 54876,<br>
+ 36864, 57012,<br>
+ 40960, 58656,<br>
+ 45056, 59954,<br>
+ 49152, 61183,<br>
+ 53248, 62355,<br>
+ 57344, 63419,<br>
+ 61440, 64476,<br>
+ 65535, 65535<br>
+ ]<br>
+ }<br>
+}<br>
diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build<br>
index d1397a32..e384c7ce 100644<br>
--- a/src/ipa/raspberrypi/meson.build<br>
+++ b/src/ipa/raspberrypi/meson.build<br>
@@ -22,6 +22,7 @@ rpi_ipa_sources = files([<br>
'cam_helper_imx219.cpp',<br>
'cam_helper_imx290.cpp',<br>
'cam_helper_imx477.cpp',<br>
+ 'cam_helper_mov9281.cpp',<br>
'controller/controller.cpp',<br>
'controller/histogram.cpp',<br>
'controller/algorithm.cpp',<br>
-- <br>
2.20.1<br>
<br>
</blockquote></div></div>