| Message ID | 20260618-imx678-v2-2-a288102744c3@ideasonboard.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Quoting Jai Luthra (2026-06-18 15:56:42) > From: will whang <will@willwhang.com> > > This adds a basic cam helper for Sony IMX678, modelling the gain curve > and the sensor limits for the maximum exposure time. > > Link: https://github.com/will127534/libcamera/commit/619459e7c70306ba18476 > Signed-off-by: will whang <will@willwhang.com> > Co-developed-by: Jai Luthra <jai.luthra@ideasonboard.com> > Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com> We're in RPi IPA space here, so I've added Naush for consideration, but you've tackled my concerns, Thanks. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > Changes in v2: > - Drop hideFramesStartup() and hideFramesModeSwitch() > - Use std::pow() instead of pow() > - Drop unnecessary includes, and include <algorithm> and <cmath> for > std::pow and std::min/max > - Reword comment for embedded data, as the sensor supports it but the > driver currently does not > - Cleanup more issues with whitespace > - Add a Co-developed-by tag now that it's not a complete copy-paste > - Update commit message > --- > src/ipa/rpi/cam_helper/cam_helper_imx678.cpp | 56 ++++++++++++++++++++++++++++ > src/ipa/rpi/cam_helper/meson.build | 1 + > 2 files changed, 57 insertions(+) > > diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp > new file mode 100644 > index 000000000..916433bf6 > --- /dev/null > +++ b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp > @@ -0,0 +1,56 @@ > +/* SPDX-License-Identifier: BSD-2-Clause */ > +/* > + * Copyright (C) 2026, Will Whang > + * > + * cam_helper_imx678.cpp - camera information for Sony IMX678 sensor > + */ > + > +#include <algorithm> > +#include <cmath> > + > +#include "cam_helper.h" > + > +using namespace RPiController; > + > +class CamHelperImx678 : public CamHelper > +{ > +public: > + CamHelperImx678(); > + 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 = 4; > +}; > + > +/* > + * IMX678 driver currently doesn't expose a metadata stream, so we have to use > + * the "unicam parser" which works by counting frames. > + */ > + > +CamHelperImx678::CamHelperImx678() > + : CamHelper({}, frameIntegrationDiff) > +{ > +} > + > +uint32_t CamHelperImx678::gainCode(double gain) const > +{ > + int code = 66.6667 * log10(gain); > + return std::max(0, std::min(code, 0xf0)); > +} > + > +double CamHelperImx678::gain(uint32_t gainCode) const > +{ > + return std::pow(10, 0.015 * gainCode); > +} > + > +static CamHelper *create() > +{ > + return new CamHelperImx678(); > +} > + > +static RegisterCamHelper reg("imx678", &create); > diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build > index 87b6a3600..eabd55dce 100644 > --- a/src/ipa/rpi/cam_helper/meson.build > +++ b/src/ipa/rpi/cam_helper/meson.build > @@ -10,6 +10,7 @@ rpi_ipa_cam_helper_sources = files([ > 'cam_helper_imx415.cpp', > 'cam_helper_imx477.cpp', > 'cam_helper_imx519.cpp', > + 'cam_helper_imx678.cpp', > 'cam_helper_imx708.cpp', > 'cam_helper_ov64a40.cpp', > 'cam_helper_ov7251.cpp', > > -- > 2.54.0 >
On Thu, Jun 18, 2026 at 08:26:42PM +0530, Jai Luthra wrote: > From: will whang <will@willwhang.com> > > This adds a basic cam helper for Sony IMX678, modelling the gain curve > and the sensor limits for the maximum exposure time. > > Link: https://github.com/will127534/libcamera/commit/619459e7c70306ba18476 > Signed-off-by: will whang <will@willwhang.com> > Co-developed-by: Jai Luthra <jai.luthra@ideasonboard.com> > Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > Changes in v2: > - Drop hideFramesStartup() and hideFramesModeSwitch() > - Use std::pow() instead of pow() > - Drop unnecessary includes, and include <algorithm> and <cmath> for > std::pow and std::min/max > - Reword comment for embedded data, as the sensor supports it but the > driver currently does not > - Cleanup more issues with whitespace > - Add a Co-developed-by tag now that it's not a complete copy-paste > - Update commit message > --- > src/ipa/rpi/cam_helper/cam_helper_imx678.cpp | 56 ++++++++++++++++++++++++++++ > src/ipa/rpi/cam_helper/meson.build | 1 + > 2 files changed, 57 insertions(+) > > diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp > new file mode 100644 > index 000000000..916433bf6 > --- /dev/null > +++ b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp > @@ -0,0 +1,56 @@ > +/* SPDX-License-Identifier: BSD-2-Clause */ > +/* > + * Copyright (C) 2026, Will Whang > + * > + * cam_helper_imx678.cpp - camera information for Sony IMX678 sensor > + */ > + > +#include <algorithm> > +#include <cmath> > + > +#include "cam_helper.h" > + > +using namespace RPiController; > + > +class CamHelperImx678 : public CamHelper > +{ > +public: > + CamHelperImx678(); > + 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 = 4; > +}; > + > +/* > + * IMX678 driver currently doesn't expose a metadata stream, so we have to use > + * the "unicam parser" which works by counting frames. > + */ > + > +CamHelperImx678::CamHelperImx678() > + : CamHelper({}, frameIntegrationDiff) > +{ > +} > + > +uint32_t CamHelperImx678::gainCode(double gain) const > +{ > + int code = 66.6667 * log10(gain); > + return std::max(0, std::min(code, 0xf0)); > +} > + > +double CamHelperImx678::gain(uint32_t gainCode) const > +{ > + return std::pow(10, 0.015 * gainCode); > +} > + > +static CamHelper *create() > +{ > + return new CamHelperImx678(); > +} > + > +static RegisterCamHelper reg("imx678", &create); > diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build > index 87b6a3600..eabd55dce 100644 > --- a/src/ipa/rpi/cam_helper/meson.build > +++ b/src/ipa/rpi/cam_helper/meson.build > @@ -10,6 +10,7 @@ rpi_ipa_cam_helper_sources = files([ > 'cam_helper_imx415.cpp', > 'cam_helper_imx477.cpp', > 'cam_helper_imx519.cpp', > + 'cam_helper_imx678.cpp', > 'cam_helper_imx708.cpp', > 'cam_helper_ov64a40.cpp', > 'cam_helper_ov7251.cpp',
diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp new file mode 100644 index 000000000..916433bf6 --- /dev/null +++ b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2026, Will Whang + * + * cam_helper_imx678.cpp - camera information for Sony IMX678 sensor + */ + +#include <algorithm> +#include <cmath> + +#include "cam_helper.h" + +using namespace RPiController; + +class CamHelperImx678 : public CamHelper +{ +public: + CamHelperImx678(); + 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 = 4; +}; + +/* + * IMX678 driver currently doesn't expose a metadata stream, so we have to use + * the "unicam parser" which works by counting frames. + */ + +CamHelperImx678::CamHelperImx678() + : CamHelper({}, frameIntegrationDiff) +{ +} + +uint32_t CamHelperImx678::gainCode(double gain) const +{ + int code = 66.6667 * log10(gain); + return std::max(0, std::min(code, 0xf0)); +} + +double CamHelperImx678::gain(uint32_t gainCode) const +{ + return std::pow(10, 0.015 * gainCode); +} + +static CamHelper *create() +{ + return new CamHelperImx678(); +} + +static RegisterCamHelper reg("imx678", &create); diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build index 87b6a3600..eabd55dce 100644 --- a/src/ipa/rpi/cam_helper/meson.build +++ b/src/ipa/rpi/cam_helper/meson.build @@ -10,6 +10,7 @@ rpi_ipa_cam_helper_sources = files([ 'cam_helper_imx415.cpp', 'cam_helper_imx477.cpp', 'cam_helper_imx519.cpp', + 'cam_helper_imx678.cpp', 'cam_helper_imx708.cpp', 'cam_helper_ov64a40.cpp', 'cam_helper_ov7251.cpp',