[v2,1/5] ipa: rpi: cam_helper: Add Mira220 cam helper
diff mbox series

Message ID 20260724-mira220-v2-1-240003749dd0@ideasonboard.com
State Changes Requested
Headers show
Series
  • ipa: rpi: Add support for Mira220 RGB version
Related show

Commit Message

Jacopo Mondi July 24, 2026, 3:47 p.m. UTC
From: Philippe Baetens <philippebaetens@gmail.com>

AMS-OSRAM Mira220 is a global shutter sensor with a maximum
resolution of 1600x1400.

This patch upports the Mira220 support available at
https://github.com/ams-OSRAM/libcamera.git at revision d7d5e17ec961
("update json files so they are truly mono")

Signed-off-by: Philippe Baetens <philippebaetens@gmail.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Acked-by: Naushir Patuck <naush@raspberrypi.com>
---
 src/ipa/rpi/cam_helper/cam_helper_mira220.cpp | 55 +++++++++++++++++++++++++++
 src/ipa/rpi/cam_helper/meson.build            |  1 +
 2 files changed, 56 insertions(+)

Comments

Kieran Bingham July 24, 2026, 4:02 p.m. UTC | #1
Quoting Jacopo Mondi (2026-07-24 16:47:40)
> From: Philippe Baetens <philippebaetens@gmail.com>
> 
> AMS-OSRAM Mira220 is a global shutter sensor with a maximum
> resolution of 1600x1400.
> 
> This patch upports the Mira220 support available at
> https://github.com/ams-OSRAM/libcamera.git at revision d7d5e17ec961
> ("update json files so they are truly mono")

I'd put that after the '---' I don't think it's needed in the commit
message.

Anyway,

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Philippe Baetens <philippebaetens@gmail.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> Acked-by: Naushir Patuck <naush@raspberrypi.com>
> ---
>  src/ipa/rpi/cam_helper/cam_helper_mira220.cpp | 55 +++++++++++++++++++++++++++
>  src/ipa/rpi/cam_helper/meson.build            |  1 +
>  2 files changed, 56 insertions(+)
> 
> diff --git a/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
> new file mode 100644
> index 000000000000..f0bd1ecbfff6
> --- /dev/null
> +++ b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
> @@ -0,0 +1,55 @@
> +/* SPDX-License-Identifier: BSD-2-Clause */
> +/*
> + * Copyright (C) 2026, ams-OSRAM
> + *
> + * cam_helper_Mira220.cpp - camera information for Mira220 sensor
> + */
> +
> +#include <assert.h>
> +
> +#include "cam_helper.h"
> +
> +using namespace RPiController;
> +
> +class CamHelperMira220 : public CamHelper
> +{
> +public:
> +       CamHelperMira220();
> +       uint32_t gainCode(double gain) const override;
> +       double gain(uint32_t gainCode) const override;
> +       unsigned int hideFramesModeSwitch() const override;
> +
> +private:
> +       /*
> +        * Smallest difference between the frame length and integration time,
> +        * in units of lines.
> +        */
> +       static constexpr int frameIntegrationDiff = 4;
> +};
> +
> +/*
> + * Mira220 doesn't output metadata, so we have to use the delayed controls which
> + * works by counting frames.
> + */
> +
> +CamHelperMira220::CamHelperMira220()
> +       : CamHelper({}, frameIntegrationDiff)
> +{
> +}
> +
> +uint32_t CamHelperMira220::gainCode(double gain) const
> +{
> +       return static_cast<uint32_t>(2048.0 - 2048.0 / gain);
> +}
> +
> +double CamHelperMira220::gain(uint32_t gainCode) const
> +{
> +       return static_cast<double>(2048.0 / (2048 - gainCode));
> +}
> +
> +static CamHelper *create()
> +{
> +       return new CamHelperMira220();
> +}
> +
> +static RegisterCamHelper reg("mira220", &create);
> diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build
> index eabd55dce5a1..a8756a1a0226 100644
> --- a/src/ipa/rpi/cam_helper/meson.build
> +++ b/src/ipa/rpi/cam_helper/meson.build
> @@ -12,6 +12,7 @@ rpi_ipa_cam_helper_sources = files([
>      'cam_helper_imx519.cpp',
>      'cam_helper_imx678.cpp',
>      'cam_helper_imx708.cpp',
> +    'cam_helper_mira220.cpp',
>      'cam_helper_ov64a40.cpp',
>      'cam_helper_ov7251.cpp',
>      'cam_helper_ov9281.cpp',
> 
> -- 
> 2.54.0
>
Jacopo Mondi July 31, 2026, 7:31 a.m. UTC | #2
Hi Kieran

On Fri, Jul 24, 2026 at 05:02:32PM +0100, Kieran Bingham wrote:
> Quoting Jacopo Mondi (2026-07-24 16:47:40)
> > From: Philippe Baetens <philippebaetens@gmail.com>
> >
> > AMS-OSRAM Mira220 is a global shutter sensor with a maximum
> > resolution of 1600x1400.
> >
> > This patch upports the Mira220 support available at
> > https://github.com/ams-OSRAM/libcamera.git at revision d7d5e17ec961
> > ("update json files so they are truly mono")
>
> I'd put that after the '---' I don't think it's needed in the commit
> message.

Isn't it worth to have this information in the commit history ? I
would say it is. What do others think ?

>
> Anyway,
>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>
> > Signed-off-by: Philippe Baetens <philippebaetens@gmail.com>
> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > Acked-by: Naushir Patuck <naush@raspberrypi.com>
> > ---
> >  src/ipa/rpi/cam_helper/cam_helper_mira220.cpp | 55 +++++++++++++++++++++++++++
> >  src/ipa/rpi/cam_helper/meson.build            |  1 +
> >  2 files changed, 56 insertions(+)
> >
> > diff --git a/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
> > new file mode 100644
> > index 000000000000..f0bd1ecbfff6
> > --- /dev/null
> > +++ b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
> > @@ -0,0 +1,55 @@
> > +/* SPDX-License-Identifier: BSD-2-Clause */
> > +/*
> > + * Copyright (C) 2026, ams-OSRAM
> > + *
> > + * cam_helper_Mira220.cpp - camera information for Mira220 sensor
> > + */
> > +
> > +#include <assert.h>
> > +
> > +#include "cam_helper.h"
> > +
> > +using namespace RPiController;
> > +
> > +class CamHelperMira220 : public CamHelper
> > +{
> > +public:
> > +       CamHelperMira220();
> > +       uint32_t gainCode(double gain) const override;
> > +       double gain(uint32_t gainCode) const override;
> > +       unsigned int hideFramesModeSwitch() const override;
> > +
> > +private:
> > +       /*
> > +        * Smallest difference between the frame length and integration time,
> > +        * in units of lines.
> > +        */
> > +       static constexpr int frameIntegrationDiff = 4;
> > +};
> > +
> > +/*
> > + * Mira220 doesn't output metadata, so we have to use the delayed controls which
> > + * works by counting frames.
> > + */
> > +
> > +CamHelperMira220::CamHelperMira220()
> > +       : CamHelper({}, frameIntegrationDiff)
> > +{
> > +}
> > +
> > +uint32_t CamHelperMira220::gainCode(double gain) const
> > +{
> > +       return static_cast<uint32_t>(2048.0 - 2048.0 / gain);
> > +}
> > +
> > +double CamHelperMira220::gain(uint32_t gainCode) const
> > +{
> > +       return static_cast<double>(2048.0 / (2048 - gainCode));
> > +}
> > +
> > +static CamHelper *create()
> > +{
> > +       return new CamHelperMira220();
> > +}
> > +
> > +static RegisterCamHelper reg("mira220", &create);
> > diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build
> > index eabd55dce5a1..a8756a1a0226 100644
> > --- a/src/ipa/rpi/cam_helper/meson.build
> > +++ b/src/ipa/rpi/cam_helper/meson.build
> > @@ -12,6 +12,7 @@ rpi_ipa_cam_helper_sources = files([
> >      'cam_helper_imx519.cpp',
> >      'cam_helper_imx678.cpp',
> >      'cam_helper_imx708.cpp',
> > +    'cam_helper_mira220.cpp',
> >      'cam_helper_ov64a40.cpp',
> >      'cam_helper_ov7251.cpp',
> >      'cam_helper_ov9281.cpp',
> >
> > --
> > 2.54.0
> >
Laurent Pinchart July 31, 2026, 7:58 a.m. UTC | #3
On Fri, Jul 31, 2026 at 09:31:54AM +0200, Jacopo Mondi wrote:
> On Fri, Jul 24, 2026 at 05:02:32PM +0100, Kieran Bingham wrote:
> > Quoting Jacopo Mondi (2026-07-24 16:47:40)
> > > From: Philippe Baetens <philippebaetens@gmail.com>
> > >
> > > AMS-OSRAM Mira220 is a global shutter sensor with a maximum
> > > resolution of 1600x1400.
> > >
> > > This patch upports the Mira220 support available at
> > > https://github.com/ams-OSRAM/libcamera.git at revision d7d5e17ec961

You can also include the commit ID in the URL, that would be easier to
copy & paste:

https://github.com/ams-OSRAM/libcamera/commit/d7d5e17ec961d3f1d2b217217b70ec242e6d8bd4

> > > ("update json files so they are truly mono")
> >
> > I'd put that after the '---' I don't think it's needed in the commit
> > message.
> 
> Isn't it worth to have this information in the commit history ? I
> would say it is. What do others think ?

I would probably have put the information below a --- line, but I don't
have a strong preference in this case.

> > Anyway,
> >
> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> >
> > > Signed-off-by: Philippe Baetens <philippebaetens@gmail.com>
> > > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > > Acked-by: Naushir Patuck <naush@raspberrypi.com>
> > > ---
> > >  src/ipa/rpi/cam_helper/cam_helper_mira220.cpp | 55 +++++++++++++++++++++++++++
> > >  src/ipa/rpi/cam_helper/meson.build            |  1 +
> > >  2 files changed, 56 insertions(+)
> > >
> > > diff --git a/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
> > > new file mode 100644
> > > index 000000000000..f0bd1ecbfff6
> > > --- /dev/null
> > > +++ b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
> > > @@ -0,0 +1,55 @@
> > > +/* SPDX-License-Identifier: BSD-2-Clause */
> > > +/*
> > > + * Copyright (C) 2026, ams-OSRAM
> > > + *
> > > + * cam_helper_Mira220.cpp - camera information for Mira220 sensor

Drop the file name.

> > > + */
> > > +
> > > +#include <assert.h>
> > > +
> > > +#include "cam_helper.h"
> > > +
> > > +using namespace RPiController;
> > > +
> > > +class CamHelperMira220 : public CamHelper
> > > +{
> > > +public:
> > > +       CamHelperMira220();
> > > +       uint32_t gainCode(double gain) const override;
> > > +       double gain(uint32_t gainCode) const override;
> > > +       unsigned int hideFramesModeSwitch() const override;
> > > +
> > > +private:
> > > +       /*
> > > +        * Smallest difference between the frame length and integration time,
> > > +        * in units of lines.
> > > +        */
> > > +       static constexpr int frameIntegrationDiff = 4;

I don't think this is correct. The datasheet (v9.00) states on page 39

tEXP,max = Tframe - tGLOB

where tGLOB is 1928 * TCLK_IN.

> > > +};
> > > +
> > > +/*
> > > + * Mira220 doesn't output metadata, so we have to use the delayed controls which
> > > + * works by counting frames.
> > > + */

I would have put that in the commit message.

> > > +
> > > +CamHelperMira220::CamHelperMira220()
> > > +       : CamHelper({}, frameIntegrationDiff)
> > > +{
> > > +}
> > > +
> > > +uint32_t CamHelperMira220::gainCode(double gain) const
> > > +{
> > > +       return static_cast<uint32_t>(2048.0 - 2048.0 / gain);
> > > +}
> > > +
> > > +double CamHelperMira220::gain(uint32_t gainCode) const
> > > +{
> > > +       return static_cast<double>(2048.0 / (2048 - gainCode));
> > > +}
> > > +
> > > +static CamHelper *create()
> > > +{
> > > +       return new CamHelperMira220();
> > > +}
> > > +
> > > +static RegisterCamHelper reg("mira220", &create);
> > > diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build
> > > index eabd55dce5a1..a8756a1a0226 100644
> > > --- a/src/ipa/rpi/cam_helper/meson.build
> > > +++ b/src/ipa/rpi/cam_helper/meson.build
> > > @@ -12,6 +12,7 @@ rpi_ipa_cam_helper_sources = files([
> > >      'cam_helper_imx519.cpp',
> > >      'cam_helper_imx678.cpp',
> > >      'cam_helper_imx708.cpp',
> > > +    'cam_helper_mira220.cpp',
> > >      'cam_helper_ov64a40.cpp',
> > >      'cam_helper_ov7251.cpp',
> > >      'cam_helper_ov9281.cpp',
Jacopo Mondi Aug. 25, 2026, 4:27 p.m. UTC | #4
Hi Laurent

On Fri, Jul 31, 2026 at 10:58:49AM +0300, Laurent Pinchart wrote:
> On Fri, Jul 31, 2026 at 09:31:54AM +0200, Jacopo Mondi wrote:
> > On Fri, Jul 24, 2026 at 05:02:32PM +0100, Kieran Bingham wrote:
> > > Quoting Jacopo Mondi (2026-07-24 16:47:40)
> > > > From: Philippe Baetens <philippebaetens@gmail.com>
> > > >
> > > > AMS-OSRAM Mira220 is a global shutter sensor with a maximum
> > > > resolution of 1600x1400.
> > > >
> > > > This patch upports the Mira220 support available at
> > > > https://github.com/ams-OSRAM/libcamera.git at revision d7d5e17ec961
>
> You can also include the commit ID in the URL, that would be easier to
> copy & paste:
>
> https://github.com/ams-OSRAM/libcamera/commit/d7d5e17ec961d3f1d2b217217b70ec242e6d8bd4
>
> > > > ("update json files so they are truly mono")
> > >
> > > I'd put that after the '---' I don't think it's needed in the commit
> > > message.
> >
> > Isn't it worth to have this information in the commit history ? I
> > would say it is. What do others think ?
>
> I would probably have put the information below a --- line, but I don't
> have a strong preference in this case.
>
> > > Anyway,
> > >
> > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > >
> > > > Signed-off-by: Philippe Baetens <philippebaetens@gmail.com>
> > > > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > > > Acked-by: Naushir Patuck <naush@raspberrypi.com>
> > > > ---
> > > >  src/ipa/rpi/cam_helper/cam_helper_mira220.cpp | 55 +++++++++++++++++++++++++++
> > > >  src/ipa/rpi/cam_helper/meson.build            |  1 +
> > > >  2 files changed, 56 insertions(+)
> > > >
> > > > diff --git a/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
> > > > new file mode 100644
> > > > index 000000000000..f0bd1ecbfff6
> > > > --- /dev/null
> > > > +++ b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
> > > > @@ -0,0 +1,55 @@
> > > > +/* SPDX-License-Identifier: BSD-2-Clause */
> > > > +/*
> > > > + * Copyright (C) 2026, ams-OSRAM
> > > > + *
> > > > + * cam_helper_Mira220.cpp - camera information for Mira220 sensor
>
> Drop the file name.
>
> > > > + */
> > > > +
> > > > +#include <assert.h>
> > > > +
> > > > +#include "cam_helper.h"
> > > > +
> > > > +using namespace RPiController;
> > > > +
> > > > +class CamHelperMira220 : public CamHelper
> > > > +{
> > > > +public:
> > > > +       CamHelperMira220();
> > > > +       uint32_t gainCode(double gain) const override;
> > > > +       double gain(uint32_t gainCode) const override;
> > > > +       unsigned int hideFramesModeSwitch() const override;
> > > > +
> > > > +private:
> > > > +       /*
> > > > +        * Smallest difference between the frame length and integration time,
> > > > +        * in units of lines.
> > > > +        */
> > > > +       static constexpr int frameIntegrationDiff = 4;
>
> I don't think this is correct. The datasheet (v9.00) states on page 39
>
> tEXP,max = Tframe - tGLOB
>
> where tGLOB is 1928 * TCLK_IN.

As we want exposure in lines, the max exposure is computed as

   max_exp = (height + vblank) - 1928 / row_length

Where row_lenght is expressed in TCLK_IN cycles and determines the
line duration in the sensor.

In facts the driver does:

	u32 max_exposure = (height + vblank) -
			   (MIRA220_GLOB_NUM_CLK_CYCLES /
			    mira220_min_row_length(mira220));

The mira220_min_row_length() depends on the number of data lanes in
use, the D-PHY data rate and can be arbirtary controlled to slow the
sensor read out so it's not a fixed value.

With a row_legth of 304 (minimum value for 2 data lanes @1.5Gbps) the
frame integration diff computes as 6.

With a single data lane, row_length doubles and the resulting frame
integration diff becomes 3.

Using a different data rate changes the row_length as well, increasing
it to maintain the timings stable (page 59)

If I'm not mistaken frameIntegrationDiff is used by the RPi IPA to
limit the max exposure. If it's off by a few lines it shouldn't be a
problem.

I can however use 6 here and specify to which configuration it applies
to.

>
> > > > +};
> > > > +
> > > > +/*
> > > > + * Mira220 doesn't output metadata, so we have to use the delayed controls which
> > > > + * works by counting frames.
> > > > + */
>
> I would have put that in the commit message.
>
> > > > +
> > > > +CamHelperMira220::CamHelperMira220()
> > > > +       : CamHelper({}, frameIntegrationDiff)
> > > > +{
> > > > +}
> > > > +
> > > > +uint32_t CamHelperMira220::gainCode(double gain) const
> > > > +{
> > > > +       return static_cast<uint32_t>(2048.0 - 2048.0 / gain);
> > > > +}
> > > > +
> > > > +double CamHelperMira220::gain(uint32_t gainCode) const
> > > > +{
> > > > +       return static_cast<double>(2048.0 / (2048 - gainCode));
> > > > +}
> > > > +
> > > > +static CamHelper *create()
> > > > +{
> > > > +       return new CamHelperMira220();
> > > > +}
> > > > +
> > > > +static RegisterCamHelper reg("mira220", &create);
> > > > diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build
> > > > index eabd55dce5a1..a8756a1a0226 100644
> > > > --- a/src/ipa/rpi/cam_helper/meson.build
> > > > +++ b/src/ipa/rpi/cam_helper/meson.build
> > > > @@ -12,6 +12,7 @@ rpi_ipa_cam_helper_sources = files([
> > > >      'cam_helper_imx519.cpp',
> > > >      'cam_helper_imx678.cpp',
> > > >      'cam_helper_imx708.cpp',
> > > > +    'cam_helper_mira220.cpp',
> > > >      'cam_helper_ov64a40.cpp',
> > > >      'cam_helper_ov7251.cpp',
> > > >      'cam_helper_ov9281.cpp',
>
> --
> Regards,
>
> Laurent Pinchart
Laurent Pinchart Aug. 27, 2026, 8:29 a.m. UTC | #5
On Tue, Aug 25, 2026 at 06:27:26PM +0200, Jacopo Mondi wrote:
> Hi Laurent
> 
> On Fri, Jul 31, 2026 at 10:58:49AM +0300, Laurent Pinchart wrote:
> > On Fri, Jul 31, 2026 at 09:31:54AM +0200, Jacopo Mondi wrote:
> > > On Fri, Jul 24, 2026 at 05:02:32PM +0100, Kieran Bingham wrote:
> > > > Quoting Jacopo Mondi (2026-07-24 16:47:40)
> > > > > From: Philippe Baetens <philippebaetens@gmail.com>
> > > > >
> > > > > AMS-OSRAM Mira220 is a global shutter sensor with a maximum
> > > > > resolution of 1600x1400.
> > > > >
> > > > > This patch upports the Mira220 support available at
> > > > > https://github.com/ams-OSRAM/libcamera.git at revision d7d5e17ec961
> >
> > You can also include the commit ID in the URL, that would be easier to
> > copy & paste:
> >
> > https://github.com/ams-OSRAM/libcamera/commit/d7d5e17ec961d3f1d2b217217b70ec242e6d8bd4
> >
> > > > > ("update json files so they are truly mono")
> > > >
> > > > I'd put that after the '---' I don't think it's needed in the commit
> > > > message.
> > >
> > > Isn't it worth to have this information in the commit history ? I
> > > would say it is. What do others think ?
> >
> > I would probably have put the information below a --- line, but I don't
> > have a strong preference in this case.
> >
> > > > Anyway,
> > > >
> > > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > > >
> > > > > Signed-off-by: Philippe Baetens <philippebaetens@gmail.com>
> > > > > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > > > > Acked-by: Naushir Patuck <naush@raspberrypi.com>
> > > > > ---
> > > > >  src/ipa/rpi/cam_helper/cam_helper_mira220.cpp | 55 +++++++++++++++++++++++++++
> > > > >  src/ipa/rpi/cam_helper/meson.build            |  1 +
> > > > >  2 files changed, 56 insertions(+)
> > > > >
> > > > > diff --git a/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
> > > > > new file mode 100644
> > > > > index 000000000000..f0bd1ecbfff6
> > > > > --- /dev/null
> > > > > +++ b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
> > > > > @@ -0,0 +1,55 @@
> > > > > +/* SPDX-License-Identifier: BSD-2-Clause */
> > > > > +/*
> > > > > + * Copyright (C) 2026, ams-OSRAM
> > > > > + *
> > > > > + * cam_helper_Mira220.cpp - camera information for Mira220 sensor
> >
> > Drop the file name.
> >
> > > > > + */
> > > > > +
> > > > > +#include <assert.h>
> > > > > +
> > > > > +#include "cam_helper.h"
> > > > > +
> > > > > +using namespace RPiController;
> > > > > +
> > > > > +class CamHelperMira220 : public CamHelper
> > > > > +{
> > > > > +public:
> > > > > +       CamHelperMira220();
> > > > > +       uint32_t gainCode(double gain) const override;
> > > > > +       double gain(uint32_t gainCode) const override;
> > > > > +       unsigned int hideFramesModeSwitch() const override;
> > > > > +
> > > > > +private:
> > > > > +       /*
> > > > > +        * Smallest difference between the frame length and integration time,
> > > > > +        * in units of lines.
> > > > > +        */
> > > > > +       static constexpr int frameIntegrationDiff = 4;
> >
> > I don't think this is correct. The datasheet (v9.00) states on page 39
> >
> > tEXP,max = Tframe - tGLOB
> >
> > where tGLOB is 1928 * TCLK_IN.
> 
> As we want exposure in lines, the max exposure is computed as
> 
>    max_exp = (height + vblank) - 1928 / row_length
> 
> Where row_lenght is expressed in TCLK_IN cycles and determines the
> line duration in the sensor.
> 
> In facts the driver does:
> 
> 	u32 max_exposure = (height + vblank) -
> 			   (MIRA220_GLOB_NUM_CLK_CYCLES /
> 			    mira220_min_row_length(mira220));
> 
> The mira220_min_row_length() depends on the number of data lanes in
> use, the D-PHY data rate and can be arbirtary controlled to slow the
> sensor read out so it's not a fixed value.
> 
> With a row_legth of 304 (minimum value for 2 data lanes @1.5Gbps) the
> frame integration diff computes as 6.
> 
> With a single data lane, row_length doubles and the resulting frame
> integration diff becomes 3.
> 
> Using a different data rate changes the row_length as well, increasing
> it to maintain the timings stable (page 59)
> 
> If I'm not mistaken frameIntegrationDiff is used by the RPi IPA to
> limit the max exposure. If it's off by a few lines it shouldn't be a
> problem.
> 
> I can however use 6 here and specify to which configuration it applies
> to.

I'd start with the worst case of 6 lines. We can improve it later if
needed. A comment to explain the issue would be nice.

> > > > > +};
> > > > > +
> > > > > +/*
> > > > > + * Mira220 doesn't output metadata, so we have to use the delayed controls which
> > > > > + * works by counting frames.
> > > > > + */
> >
> > I would have put that in the commit message.
> >
> > > > > +
> > > > > +CamHelperMira220::CamHelperMira220()
> > > > > +       : CamHelper({}, frameIntegrationDiff)
> > > > > +{
> > > > > +}
> > > > > +
> > > > > +uint32_t CamHelperMira220::gainCode(double gain) const
> > > > > +{
> > > > > +       return static_cast<uint32_t>(2048.0 - 2048.0 / gain);
> > > > > +}
> > > > > +
> > > > > +double CamHelperMira220::gain(uint32_t gainCode) const
> > > > > +{
> > > > > +       return static_cast<double>(2048.0 / (2048 - gainCode));
> > > > > +}
> > > > > +
> > > > > +static CamHelper *create()
> > > > > +{
> > > > > +       return new CamHelperMira220();
> > > > > +}
> > > > > +
> > > > > +static RegisterCamHelper reg("mira220", &create);
> > > > > diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build
> > > > > index eabd55dce5a1..a8756a1a0226 100644
> > > > > --- a/src/ipa/rpi/cam_helper/meson.build
> > > > > +++ b/src/ipa/rpi/cam_helper/meson.build
> > > > > @@ -12,6 +12,7 @@ rpi_ipa_cam_helper_sources = files([
> > > > >      'cam_helper_imx519.cpp',
> > > > >      'cam_helper_imx678.cpp',
> > > > >      'cam_helper_imx708.cpp',
> > > > > +    'cam_helper_mira220.cpp',
> > > > >      'cam_helper_ov64a40.cpp',
> > > > >      'cam_helper_ov7251.cpp',
> > > > >      'cam_helper_ov9281.cpp',

Patch
diff mbox series

diff --git a/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
new file mode 100644
index 000000000000..f0bd1ecbfff6
--- /dev/null
+++ b/src/ipa/rpi/cam_helper/cam_helper_mira220.cpp
@@ -0,0 +1,55 @@ 
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*
+ * Copyright (C) 2026, ams-OSRAM
+ *
+ * cam_helper_Mira220.cpp - camera information for Mira220 sensor
+ */
+
+#include <assert.h>
+
+#include "cam_helper.h"
+
+using namespace RPiController;
+
+class CamHelperMira220 : public CamHelper
+{
+public:
+	CamHelperMira220();
+	uint32_t gainCode(double gain) const override;
+	double gain(uint32_t gainCode) const override;
+	unsigned int hideFramesModeSwitch() const override;
+
+private:
+	/*
+	 * Smallest difference between the frame length and integration time,
+	 * in units of lines.
+	 */
+	static constexpr int frameIntegrationDiff = 4;
+};
+
+/*
+ * Mira220 doesn't output metadata, so we have to use the delayed controls which
+ * works by counting frames.
+ */
+
+CamHelperMira220::CamHelperMira220()
+	: CamHelper({}, frameIntegrationDiff)
+{
+}
+
+uint32_t CamHelperMira220::gainCode(double gain) const
+{
+	return static_cast<uint32_t>(2048.0 - 2048.0 / gain);
+}
+
+double CamHelperMira220::gain(uint32_t gainCode) const
+{
+	return static_cast<double>(2048.0 / (2048 - gainCode));
+}
+
+static CamHelper *create()
+{
+	return new CamHelperMira220();
+}
+
+static RegisterCamHelper reg("mira220", &create);
diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build
index eabd55dce5a1..a8756a1a0226 100644
--- a/src/ipa/rpi/cam_helper/meson.build
+++ b/src/ipa/rpi/cam_helper/meson.build
@@ -12,6 +12,7 @@  rpi_ipa_cam_helper_sources = files([
     'cam_helper_imx519.cpp',
     'cam_helper_imx678.cpp',
     'cam_helper_imx708.cpp',
+    'cam_helper_mira220.cpp',
     'cam_helper_ov64a40.cpp',
     'cam_helper_ov7251.cpp',
     'cam_helper_ov9281.cpp',