Message ID | 20241204105223.45807-1-isaac.scott@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Hi Isaac, On Wed, 4 Dec 2024 at 10:52, Isaac Scott <isaac.scott@ideasonboard.com> wrote: > > Add support for the IMX258 camera. This patch adds a minimal cam_helper > implementation that allows the IMX258 sensor to be listed by cam, and > subsequently be used remotely in tools such as Camshark. I'm not sure the cam helper alone would be enough to enumerate the camera. I would have thought you also need a camera tuning file so that the IPA can correctly initialise as well. Regards, Naush > > Based on the implementation of the IMX290's camera helper, adjusted to > use the equation listed in the IMX258 datasheet used to calculate > analogue gain. > > Signed-off-by: Isaac Scott <isaac.scott@ideasonboard.com> > --- > src/ipa/rpi/cam_helper/cam_helper_imx258.cpp | 60 ++++++++++++++++++++ > src/ipa/rpi/cam_helper/meson.build | 1 + > 2 files changed, 61 insertions(+) > create mode 100644 src/ipa/rpi/cam_helper/cam_helper_imx258.cpp > > diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx258.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx258.cpp > new file mode 100644 > index 00000000..12c0332a > --- /dev/null > +++ b/src/ipa/rpi/cam_helper/cam_helper_imx258.cpp > @@ -0,0 +1,60 @@ > +/* SPDX-License-Identifier: BSD-2-Clause */ > +/* > + * Copyright (C) 2024 Ideas On Board Oy > + * > + * camera helper for imx258 sensor > + * based on Raspberry Pi's imx290 helper > + */ > + > +#include <cmath> > + > +#include "cam_helper.h" > + > +using namespace RPiController; > + > +class CamHelperImx258 : public CamHelper > +{ > +public: > + CamHelperImx258(); > + uint32_t gainCode(double gain) const override; > + double gain(uint32_t gainCode) const override; > + void getDelays(int &exposureDelay, int &gainDelay, > + int &vblankDelay, int &hblankDelay) const override; > +private: > + /* > + * Smallest difference between the frame length and integration time, > + * in units of lines. > + */ > + static constexpr int frameIntegrationDiff = 2; > +}; > + > +CamHelperImx258::CamHelperImx258() > + : CamHelper({}, frameIntegrationDiff) > +{ > +} > + > +uint32_t CamHelperImx258::gainCode(double gain) const > +{ > + return static_cast<uint32_t>(512 - 512 / gain); > +} > + > +double CamHelperImx258::gain(uint32_t gainCode) const > +{ > + return 512.0 / (512.0 - gainCode); > +} > + > +void CamHelperImx258::getDelays(int &exposureDelay, int &gainDelay, > + int &vblankDelay, int &hblankDelay) const > +{ > + exposureDelay = 2; > + gainDelay = 2; > + vblankDelay = 2; > + hblankDelay = 2; > +} > + > +static CamHelper *create() > +{ > + return new CamHelperImx258(); > +} > + > +static RegisterCamHelper reg("imx258", &create); > diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build > index 03e88fe0..a8245e42 100644 > --- a/src/ipa/rpi/cam_helper/meson.build > +++ b/src/ipa/rpi/cam_helper/meson.build > @@ -4,6 +4,7 @@ rpi_ipa_cam_helper_sources = files([ > 'cam_helper.cpp', > 'cam_helper_ov5647.cpp', > 'cam_helper_imx219.cpp', > + 'cam_helper_imx258.cpp', > 'cam_helper_imx283.cpp', > 'cam_helper_imx290.cpp', > 'cam_helper_imx296.cpp', > -- > 2.43.0 >
Hi Naushir, On Wed, 2024-12-04 at 11:19 +0000, Naushir Patuck wrote: > Hi Isaac, > > On Wed, 4 Dec 2024 at 10:52, Isaac Scott > <isaac.scott@ideasonboard.com> wrote: > > > > Add support for the IMX258 camera. This patch adds a minimal > > cam_helper > > implementation that allows the IMX258 sensor to be listed by cam, > > and > > subsequently be used remotely in tools such as Camshark. > > I'm not sure the cam helper alone would be enough to enumerate the > camera. I would have thought you also need a camera tuning file so > that the IPA can correctly initialise as well. > You're right! I used uncalibrated.yaml to make this, I am running through the tuning process now. > Regards, > Naush > > Best wishes, Isaac >
diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx258.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx258.cpp new file mode 100644 index 00000000..12c0332a --- /dev/null +++ b/src/ipa/rpi/cam_helper/cam_helper_imx258.cpp @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2024 Ideas On Board Oy + * + * camera helper for imx258 sensor + * based on Raspberry Pi's imx290 helper + */ + +#include <cmath> + +#include "cam_helper.h" + +using namespace RPiController; + +class CamHelperImx258 : public CamHelper +{ +public: + CamHelperImx258(); + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + void getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay, int &hblankDelay) const override; +private: + /* + * Smallest difference between the frame length and integration time, + * in units of lines. + */ + static constexpr int frameIntegrationDiff = 2; +}; + +CamHelperImx258::CamHelperImx258() + : CamHelper({}, frameIntegrationDiff) +{ +} + +uint32_t CamHelperImx258::gainCode(double gain) const +{ + return static_cast<uint32_t>(512 - 512 / gain); +} + +double CamHelperImx258::gain(uint32_t gainCode) const +{ + return 512.0 / (512.0 - gainCode); +} + +void CamHelperImx258::getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay, int &hblankDelay) const +{ + exposureDelay = 2; + gainDelay = 2; + vblankDelay = 2; + hblankDelay = 2; +} + +static CamHelper *create() +{ + return new CamHelperImx258(); +} + +static RegisterCamHelper reg("imx258", &create); diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build index 03e88fe0..a8245e42 100644 --- a/src/ipa/rpi/cam_helper/meson.build +++ b/src/ipa/rpi/cam_helper/meson.build @@ -4,6 +4,7 @@ rpi_ipa_cam_helper_sources = files([ 'cam_helper.cpp', 'cam_helper_ov5647.cpp', 'cam_helper_imx219.cpp', + 'cam_helper_imx258.cpp', 'cam_helper_imx283.cpp', 'cam_helper_imx290.cpp', 'cam_helper_imx296.cpp',
Add support for the IMX258 camera. This patch adds a minimal cam_helper implementation that allows the IMX258 sensor to be listed by cam, and subsequently be used remotely in tools such as Camshark. Based on the implementation of the IMX290's camera helper, adjusted to use the equation listed in the IMX258 datasheet used to calculate analogue gain. Signed-off-by: Isaac Scott <isaac.scott@ideasonboard.com> --- src/ipa/rpi/cam_helper/cam_helper_imx258.cpp | 60 ++++++++++++++++++++ src/ipa/rpi/cam_helper/meson.build | 1 + 2 files changed, 61 insertions(+) create mode 100644 src/ipa/rpi/cam_helper/cam_helper_imx258.cpp