[{"id":4788,"web_url":"https://patchwork.libcamera.org/comment/4788/","msgid":"<20200512003804.GJ5830@pendragon.ideasonboard.com>","date":"2020-05-12T00:38:04","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: raspberrypi: Limit the\n\tmaximum framerate to 30.0fps","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Mon, May 11, 2020 at 11:01:50AM +0100, Naushir Patuck wrote:\n> With the previous change to adapt framerate using VBLANK, the maximum\n> framerate was limited by the sensor mode. This may not be entirely\n> appropriate for what an application expects in the case where a mode\n> can produce > 30.0fps.\n\nThis answers a question in my review of the previous patch :-) I\nwouldn't be opposed to squashing the two patches together.\n\n> Provide a mechanism to limit the maximum framerate. This is currently\n> a const set to 30.0fps. In future, this value could be passed in via\n> a Request or stream configuration.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/cam_helper.hpp        |  2 +-\n>  src/ipa/raspberrypi/cam_helper_imx219.cpp | 18 ++++++++++++++----\n>  src/ipa/raspberrypi/cam_helper_imx477.cpp | 18 ++++++++++++++----\n>  src/ipa/raspberrypi/cam_helper_ov5647.cpp | 18 ++++++++++++++----\n>  src/ipa/raspberrypi/raspberrypi.cpp       |  8 +++++++-\n>  5 files changed, 50 insertions(+), 14 deletions(-)\n> \n> diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp\n> index 37281c78..4f7a3897 100644\n> --- a/src/ipa/raspberrypi/cam_helper.hpp\n> +++ b/src/ipa/raspberrypi/cam_helper.hpp\n> @@ -74,7 +74,7 @@ public:\n>  \tMdParser &Parser() const { return *parser_; }\n>  \tuint32_t ExposureLines(double exposure_us) const;\n>  \tdouble Exposure(uint32_t exposure_lines) const; // in us\n> -\tvirtual uint32_t GetVBlanking(double exposure_us) const = 0;\n> +\tvirtual uint32_t GetVBlanking(double exposure_us, double maxFps) const = 0;\n>  \tvirtual uint32_t GainCode(double gain) const = 0;\n>  \tvirtual double Gain(uint32_t gain_code) const = 0;\n>  \tvirtual void GetDelays(int &exposure_delay, int &gain_delay) const;\n> diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> index d34a1f1f..51a18aca 100644\n> --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> @@ -45,7 +45,7 @@ class CamHelperImx219 : public CamHelper\n>  {\n>  public:\n>  \tCamHelperImx219();\n> -\tuint32_t GetVBlanking(double exposure) const override;\n> +\tuint32_t GetVBlanking(double exposure, double maxFps) const override;\n>  \tuint32_t GainCode(double gain) const override;\n>  \tdouble Gain(uint32_t gain_code) const override;\n>  \tunsigned int MistrustFramesModeSwitch() const override;\n> @@ -55,6 +55,8 @@ public:\n>  private:\n>  \t/* Smallest difference between the frame length and integration time. */\n>  \tstatic constexpr int frameIntegrationDiff = 4;\n> +\t/* Largest possible frame length. */\n> +\tstatic constexpr int maxFrameLength = 0xffff;\n>  };\n>  \n>  CamHelperImx219::CamHelperImx219()\n> @@ -66,12 +68,20 @@ CamHelperImx219::CamHelperImx219()\n>  {\n>  }\n>  \n> -uint32_t CamHelperImx219::GetVBlanking(double exposure) const\n> +uint32_t CamHelperImx219::GetVBlanking(double exposure, double maxFps) const\n>  {\n> +\tuint32_t frameLengthMin, vblank;\n>  \tuint32_t exposureLines = ExposureLines(exposure);\n>  \n> -\treturn std::max<uint32_t>(mode_.height, exposureLines) -\n> -\t       mode_.height + frameIntegrationDiff;\n> +\tvblank = std::max<uint32_t>(mode_.height, exposureLines) -\n> +\t\t mode_.height + frameIntegrationDiff;\n> +\n> +\t/* Limit the vblank to the maximum framerate requested. */\n> +\tframeLengthMin = std::min<uint32_t>(1e9 / (mode_.line_length * maxFps),\n> +\t\t\t\t\t    maxFrameLength);\n> +\tvblank = std::max(vblank, frameLengthMin - mode_.height);\n> +\n> +\treturn vblank;\n>  }\n>  \n>  uint32_t CamHelperImx219::GainCode(double gain) const\n> diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> index 242d9689..ff815f9c 100644\n> --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> @@ -35,7 +35,7 @@ class CamHelperImx477 : public CamHelper\n>  {\n>  public:\n>  \tCamHelperImx477();\n> -\tuint32_t GetVBlanking(double exposure) const override;\n> +\tuint32_t GetVBlanking(double exposure, double maxFps) const override;\n>  \tuint32_t GainCode(double gain) const override;\n>  \tdouble Gain(uint32_t gain_code) const override;\n>  \tbool SensorEmbeddedDataPresent() const override;\n> @@ -44,6 +44,8 @@ public:\n>  private:\n>  \t/* Smallest difference between the frame length and integration time. */\n>  \tstatic constexpr int frameIntegrationDiff = 22;\n> +\t/* Largest possible frame length. */\n> +\tstatic constexpr int maxFrameLength = 0xffdc;\n>  };\n>  \n>  CamHelperImx477::CamHelperImx477()\n> @@ -51,12 +53,20 @@ CamHelperImx477::CamHelperImx477()\n>  {\n>  }\n>  \n> -uint32_t CamHelperImx477::GetVBlanking(double exposure) const\n> +uint32_t CamHelperImx477::GetVBlanking(double exposure, double maxFps) const\n>  {\n> +\tuint32_t frameLengthMin, vblank;\n>  \tuint32_t exposureLines = ExposureLines(exposure);\n>  \n> -\treturn std::max<uint32_t>(mode_.height, exposureLines) -\n> -\t       mode_.height + frameIntegrationDiff;\n> +\tvblank = std::max<uint32_t>(mode_.height, exposureLines) -\n> +\t\t mode_.height + frameIntegrationDiff;\n> +\n> +\t/* Limit the vblank to the maximum framerate requested. */\n> +\tframeLengthMin = std::min<uint32_t>(1e9 / (mode_.line_length * maxFps),\n> +\t\t\t\t\t    maxFrameLength);\n> +\tvblank = std::max(vblank, frameLengthMin - mode_.height);\n> +\n> +\treturn vblank;\n>  }\n>  \n>  uint32_t CamHelperImx477::GainCode(double gain) const\n> diff --git a/src/ipa/raspberrypi/cam_helper_ov5647.cpp b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> index ff37779c..53ac3c3b 100644\n> --- a/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> @@ -16,7 +16,7 @@ class CamHelperOv5647 : public CamHelper\n>  {\n>  public:\n>  \tCamHelperOv5647();\n> -\tuint32_t GetVBlanking(double exposure) const override;\n> +\tuint32_t GetVBlanking(double exposure, double maxFps) const override;\n>  \tuint32_t GainCode(double gain) const override;\n>  \tdouble Gain(uint32_t gain_code) const override;\n>  \tvoid GetDelays(int &exposure_delay, int &gain_delay) const override;\n> @@ -27,6 +27,8 @@ public:\n>  private:\n>  \t/* Smallest difference between the frame length and integration time. */\n>  \tstatic constexpr int frameIntegrationDiff = 4;\n> +\t/* Largest possible frame length. */\n> +\tstatic constexpr int maxFrameLength = 0xffff;\n>  };\n>  \n>  /*\n> @@ -39,12 +41,20 @@ CamHelperOv5647::CamHelperOv5647()\n>  {\n>  }\n>  \n> -uint32_t CamHelperOv5647::GetVBlanking(double exposure) const\n> +uint32_t CamHelperOv5647::GetVBlanking(double exposure, double maxFps) const\n>  {\n> +\tuint32_t frameLengthMin, vblank;\n>  \tuint32_t exposureLines = ExposureLines(exposure);\n>  \n> -\treturn std::max<uint32_t>(mode_.height, exposureLines) -\n> -\t       mode_.height + frameIntegrationDiff;\n> +\tvblank = std::max<uint32_t>(mode_.height, exposureLines) -\n> +\t\t mode_.height + frameIntegrationDiff;\n> +\n> +\t/* Limit the vblank to the maximum framerate requested. */\n> +\tframeLengthMin = std::min<uint32_t>(1e9 / (mode_.line_length * maxFps),\n> +\t\t\t\t\t    maxFrameLength);\n> +\tvblank = std::max(vblank, frameLengthMin - mode_.height);\n\nThe implementations of this functions are growing and are still nearly\nidentical. Unless there's a good reason to keep them separate, I would\ntry to only expose frameIntegrationDiff from the derived classes and\nGetVBlanking() in the base class.\n\n> +\n> +\treturn vblank;\n>  }\n>  \n>  uint32_t CamHelperOv5647::GainCode(double gain) const\n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> index 104727ea..3a2cc16e 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -136,6 +136,12 @@ private:\n>  \t/* LS table allocation passed in from the pipeline handler. */\n>  \tuint32_t lsTableHandle_;\n>  \tvoid *lsTable_;\n> +\n> +\t/*\n> +\t * Have some defaults here, but eventually it should come from the\n> +\t * application via a Request, or perhaps stream configuration.\n> +\t */\n> +\tstatic constexpr double fpsMax = 30.0;\n>  };\n>  \n>  int IPARPi::init(const IPASettings &settings)\n> @@ -795,7 +801,7 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus)\n>  \n>  \tint32_t gain_code = helper_->GainCode(agcStatus->analogue_gain);\n>  \tint32_t exposure_lines = helper_->ExposureLines(agcStatus->shutter_time);\n> -\tint32_t vblanking = helper_->GetVBlanking(agcStatus->shutter_time);\n> +\tint32_t vblanking = helper_->GetVBlanking(agcStatus->shutter_time, fpsMax);\n>  \n>  \tif (unicam_ctrls_.find(V4L2_CID_ANALOGUE_GAIN) == unicam_ctrls_.end()) {\n>  \t\tLOG(IPARPI, Error) << \"Can't find analogue gain control\";","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DC0D9603DD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 May 2020 02:38:10 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5A4CF33E;\n\tTue, 12 May 2020 02:38:10 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"J5kPwri+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1589243890;\n\tbh=o53On7NUFbRaq5NXkx93LIa0nSWez+Cioo8vH3Q76NY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=J5kPwri+kuB0X0c9pplAzz3UORoALiHiWwA97HdXXELNO5LiL6togqXc5ud84Ian4\n\tHjVhvTDxE/jcvIdI08UFmefAe5iZ5PUgUOX7cn0EyEsS+fq02ev4GwIzDOLNyEVp2Z\n\teFwJ+ApCPozG4Rrn4EWwTkKhcp4JZx7e79Kefceo=","Date":"Tue, 12 May 2020 03:38:04 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200512003804.GJ5830@pendragon.ideasonboard.com>","References":"<20200511100150.5205-1-naush@raspberrypi.com>\n\t<20200511100150.5205-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200511100150.5205-3-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: raspberrypi: Limit the\n\tmaximum framerate to 30.0fps","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 12 May 2020 00:38:11 -0000"}},{"id":4798,"web_url":"https://patchwork.libcamera.org/comment/4798/","msgid":"<CAEmqJPpPs=hUmcSvPBZY9YbVqzEWTWvHEv_tvi0PMFSaQoX4KA@mail.gmail.com>","date":"2020-05-12T10:25:28","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: raspberrypi: Limit the\n\tmaximum framerate to 30.0fps","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\nOn Tue, 12 May 2020 at 01:38, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Naush,\n>\n> Thank you for the patch.\n>\n> On Mon, May 11, 2020 at 11:01:50AM +0100, Naushir Patuck wrote:\n> > With the previous change to adapt framerate using VBLANK, the maximum\n> > framerate was limited by the sensor mode. This may not be entirely\n> > appropriate for what an application expects in the case where a mode\n> > can produce > 30.0fps.\n>\n> This answers a question in my review of the previous patch :-) I\n> wouldn't be opposed to squashing the two patches together.\n\nSure, I have no problem with that.\n\n> > Provide a mechanism to limit the maximum framerate. This is currently\n> > a const set to 30.0fps. In future, this value could be passed in via\n> > a Request or stream configuration.\n> >\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > ---\n> >  src/ipa/raspberrypi/cam_helper.hpp        |  2 +-\n> >  src/ipa/raspberrypi/cam_helper_imx219.cpp | 18 ++++++++++++++----\n> >  src/ipa/raspberrypi/cam_helper_imx477.cpp | 18 ++++++++++++++----\n> >  src/ipa/raspberrypi/cam_helper_ov5647.cpp | 18 ++++++++++++++----\n> >  src/ipa/raspberrypi/raspberrypi.cpp       |  8 +++++++-\n> >  5 files changed, 50 insertions(+), 14 deletions(-)\n> >\n> > diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp\n> > index 37281c78..4f7a3897 100644\n> > --- a/src/ipa/raspberrypi/cam_helper.hpp\n> > +++ b/src/ipa/raspberrypi/cam_helper.hpp\n> > @@ -74,7 +74,7 @@ public:\n> >       MdParser &Parser() const { return *parser_; }\n> >       uint32_t ExposureLines(double exposure_us) const;\n> >       double Exposure(uint32_t exposure_lines) const; // in us\n> > -     virtual uint32_t GetVBlanking(double exposure_us) const = 0;\n> > +     virtual uint32_t GetVBlanking(double exposure_us, double maxFps) const = 0;\n> >       virtual uint32_t GainCode(double gain) const = 0;\n> >       virtual double Gain(uint32_t gain_code) const = 0;\n> >       virtual void GetDelays(int &exposure_delay, int &gain_delay) const;\n> > diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> > index d34a1f1f..51a18aca 100644\n> > --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> > +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> > @@ -45,7 +45,7 @@ class CamHelperImx219 : public CamHelper\n> >  {\n> >  public:\n> >       CamHelperImx219();\n> > -     uint32_t GetVBlanking(double exposure) const override;\n> > +     uint32_t GetVBlanking(double exposure, double maxFps) const override;\n> >       uint32_t GainCode(double gain) const override;\n> >       double Gain(uint32_t gain_code) const override;\n> >       unsigned int MistrustFramesModeSwitch() const override;\n> > @@ -55,6 +55,8 @@ public:\n> >  private:\n> >       /* Smallest difference between the frame length and integration time. */\n> >       static constexpr int frameIntegrationDiff = 4;\n> > +     /* Largest possible frame length. */\n> > +     static constexpr int maxFrameLength = 0xffff;\n> >  };\n> >\n> >  CamHelperImx219::CamHelperImx219()\n> > @@ -66,12 +68,20 @@ CamHelperImx219::CamHelperImx219()\n> >  {\n> >  }\n> >\n> > -uint32_t CamHelperImx219::GetVBlanking(double exposure) const\n> > +uint32_t CamHelperImx219::GetVBlanking(double exposure, double maxFps) const\n> >  {\n> > +     uint32_t frameLengthMin, vblank;\n> >       uint32_t exposureLines = ExposureLines(exposure);\n> >\n> > -     return std::max<uint32_t>(mode_.height, exposureLines) -\n> > -            mode_.height + frameIntegrationDiff;\n> > +     vblank = std::max<uint32_t>(mode_.height, exposureLines) -\n> > +              mode_.height + frameIntegrationDiff;\n> > +\n> > +     /* Limit the vblank to the maximum framerate requested. */\n> > +     frameLengthMin = std::min<uint32_t>(1e9 / (mode_.line_length * maxFps),\n> > +                                         maxFrameLength);\n> > +     vblank = std::max(vblank, frameLengthMin - mode_.height);\n> > +\n> > +     return vblank;\n> >  }\n> >\n> >  uint32_t CamHelperImx219::GainCode(double gain) const\n> > diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> > index 242d9689..ff815f9c 100644\n> > --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> > +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> > @@ -35,7 +35,7 @@ class CamHelperImx477 : public CamHelper\n> >  {\n> >  public:\n> >       CamHelperImx477();\n> > -     uint32_t GetVBlanking(double exposure) const override;\n> > +     uint32_t GetVBlanking(double exposure, double maxFps) const override;\n> >       uint32_t GainCode(double gain) const override;\n> >       double Gain(uint32_t gain_code) const override;\n> >       bool SensorEmbeddedDataPresent() const override;\n> > @@ -44,6 +44,8 @@ public:\n> >  private:\n> >       /* Smallest difference between the frame length and integration time. */\n> >       static constexpr int frameIntegrationDiff = 22;\n> > +     /* Largest possible frame length. */\n> > +     static constexpr int maxFrameLength = 0xffdc;\n> >  };\n> >\n> >  CamHelperImx477::CamHelperImx477()\n> > @@ -51,12 +53,20 @@ CamHelperImx477::CamHelperImx477()\n> >  {\n> >  }\n> >\n> > -uint32_t CamHelperImx477::GetVBlanking(double exposure) const\n> > +uint32_t CamHelperImx477::GetVBlanking(double exposure, double maxFps) const\n> >  {\n> > +     uint32_t frameLengthMin, vblank;\n> >       uint32_t exposureLines = ExposureLines(exposure);\n> >\n> > -     return std::max<uint32_t>(mode_.height, exposureLines) -\n> > -            mode_.height + frameIntegrationDiff;\n> > +     vblank = std::max<uint32_t>(mode_.height, exposureLines) -\n> > +              mode_.height + frameIntegrationDiff;\n> > +\n> > +     /* Limit the vblank to the maximum framerate requested. */\n> > +     frameLengthMin = std::min<uint32_t>(1e9 / (mode_.line_length * maxFps),\n> > +                                         maxFrameLength);\n> > +     vblank = std::max(vblank, frameLengthMin - mode_.height);\n> > +\n> > +     return vblank;\n> >  }\n> >\n> >  uint32_t CamHelperImx477::GainCode(double gain) const\n> > diff --git a/src/ipa/raspberrypi/cam_helper_ov5647.cpp b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> > index ff37779c..53ac3c3b 100644\n> > --- a/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> > +++ b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> > @@ -16,7 +16,7 @@ class CamHelperOv5647 : public CamHelper\n> >  {\n> >  public:\n> >       CamHelperOv5647();\n> > -     uint32_t GetVBlanking(double exposure) const override;\n> > +     uint32_t GetVBlanking(double exposure, double maxFps) const override;\n> >       uint32_t GainCode(double gain) const override;\n> >       double Gain(uint32_t gain_code) const override;\n> >       void GetDelays(int &exposure_delay, int &gain_delay) const override;\n> > @@ -27,6 +27,8 @@ public:\n> >  private:\n> >       /* Smallest difference between the frame length and integration time. */\n> >       static constexpr int frameIntegrationDiff = 4;\n> > +     /* Largest possible frame length. */\n> > +     static constexpr int maxFrameLength = 0xffff;\n> >  };\n> >\n> >  /*\n> > @@ -39,12 +41,20 @@ CamHelperOv5647::CamHelperOv5647()\n> >  {\n> >  }\n> >\n> > -uint32_t CamHelperOv5647::GetVBlanking(double exposure) const\n> > +uint32_t CamHelperOv5647::GetVBlanking(double exposure, double maxFps) const\n> >  {\n> > +     uint32_t frameLengthMin, vblank;\n> >       uint32_t exposureLines = ExposureLines(exposure);\n> >\n> > -     return std::max<uint32_t>(mode_.height, exposureLines) -\n> > -            mode_.height + frameIntegrationDiff;\n> > +     vblank = std::max<uint32_t>(mode_.height, exposureLines) -\n> > +              mode_.height + frameIntegrationDiff;\n> > +\n> > +     /* Limit the vblank to the maximum framerate requested. */\n> > +     frameLengthMin = std::min<uint32_t>(1e9 / (mode_.line_length * maxFps),\n> > +                                         maxFrameLength);\n> > +     vblank = std::max(vblank, frameLengthMin - mode_.height);\n>\n> The implementations of this functions are growing and are still nearly\n> identical. Unless there's a good reason to keep them separate, I would\n> try to only expose frameIntegrationDiff from the derived classes and\n> GetVBlanking() in the base class.\n\nIt was a coin toss between putting it in the base class vs derived\nclass.  I'll move it to the derived class as a virtual function so it\ncan be overridden if needed.\n\n>\n> > +\n> > +     return vblank;\n> >  }\n> >\n> >  uint32_t CamHelperOv5647::GainCode(double gain) const\n> > diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> > index 104727ea..3a2cc16e 100644\n> > --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> > +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> > @@ -136,6 +136,12 @@ private:\n> >       /* LS table allocation passed in from the pipeline handler. */\n> >       uint32_t lsTableHandle_;\n> >       void *lsTable_;\n> > +\n> > +     /*\n> > +      * Have some defaults here, but eventually it should come from the\n> > +      * application via a Request, or perhaps stream configuration.\n> > +      */\n> > +     static constexpr double fpsMax = 30.0;\n> >  };\n\nIn patch v2, I will add a control for fps so that this can be removed as well.\n\nRegards,\nNaush\n\n\n> >\n> >  int IPARPi::init(const IPASettings &settings)\n> > @@ -795,7 +801,7 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus)\n> >\n> >       int32_t gain_code = helper_->GainCode(agcStatus->analogue_gain);\n> >       int32_t exposure_lines = helper_->ExposureLines(agcStatus->shutter_time);\n> > -     int32_t vblanking = helper_->GetVBlanking(agcStatus->shutter_time);\n> > +     int32_t vblanking = helper_->GetVBlanking(agcStatus->shutter_time, fpsMax);\n> >\n> >       if (unicam_ctrls_.find(V4L2_CID_ANALOGUE_GAIN) == unicam_ctrls_.end()) {\n> >               LOG(IPARPI, Error) << \"Can't find analogue gain control\";\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<naush@raspberrypi.com>","Received":["from mail-lj1-x244.google.com (mail-lj1-x244.google.com\n\t[IPv6:2a00:1450:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F24B7603E0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 May 2020 12:25:45 +0200 (CEST)","by mail-lj1-x244.google.com with SMTP id l19so13014332lje.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 May 2020 03:25:45 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"qr5U6aZv\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=GAy55ualLGWpAiAiO+fQkQk8NztFYwN4F9qMvoCknV8=;\n\tb=qr5U6aZvYe/WktioK6kf1L54FiwqbiOrqZUFiKpncrr9iiIGKirylyrnQ9okKHZLuR\n\tLx5VcQlI7adxfn7VNaz+vEp5CpwAbaKIDohM0l9/EnSBz/WwjWEaQulswfTtDnv1o+4n\n\t7P+hw7Z3skLQTQGVqQDY+aNIB3HlzJ3Lqcy5ekdbQKHNRkbblUvohc6x9D4tP4vK3KQi\n\tsZ+3yncYpKpVzUFUkWaxVEnRWIj+MTEgX9BwirTphGynWVSioJyS0aXKxqQx6VqsLgZr\n\tTxUV4qOY4UsW6EGQoZLSzn8D+iM/oyUglfhDZmqiJDaMM0pEGMnF2KxCRlXmaiKdWsWU\n\tJIxQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=GAy55ualLGWpAiAiO+fQkQk8NztFYwN4F9qMvoCknV8=;\n\tb=CBpc2dkVrOKoTiPDW9PFNPgVfuvJ6JHT411vYlZ1zIvAKwm9JjSqlD7dUWqfgI8XEB\n\tqgGzn1F5qA8zaOtfxmQVI1br7qfzXvR3Vl/Hntx/qm4pGzwg54yX/xH7LURpkIfr33p6\n\txm62umYMcvDVnoSnps0CT75vCedlbWMXBzGsTdNV1wYADWJ2q0GNw73JosmSgT1azYuv\n\tRH15L+NOrcbMNMZjOdNjtlggBN/XVZzAvesxHqEwKrmsiO3FshT95a1EdnlStd/13TZK\n\tkMqcOsiHssZky1wemnJJkmVZ+cWKuhXhYnFDUQOZFttHorR4+4JOEjYrjHfSIBzONZv3\n\tSp9w==","X-Gm-Message-State":"AOAM531OU5TwAlY98q6e7/haf3UwgdzPOibVC2k/FSKs/X2yuqJIjxYE\n\txQE6dZ6fgEq8TNstB1W+hykcZfS5W0RpfGXER3C+9Q==","X-Google-Smtp-Source":"ABdhPJwbL2vOaG3/Z7Yr7APRywpjxAgnqXcjiuKPZBvDH3ufPuAgjE6kMJVSTBUjGyn6fSShmMYH9Beo3C/nJ+Rbo64=","X-Received":"by 2002:a2e:8199:: with SMTP id\n\te25mr13381518ljg.87.1589279145217; \n\tTue, 12 May 2020 03:25:45 -0700 (PDT)","MIME-Version":"1.0","References":"<20200511100150.5205-1-naush@raspberrypi.com>\n\t<20200511100150.5205-3-naush@raspberrypi.com>\n\t<20200512003804.GJ5830@pendragon.ideasonboard.com>","In-Reply-To":"<20200512003804.GJ5830@pendragon.ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Tue, 12 May 2020 11:25:28 +0100","Message-ID":"<CAEmqJPpPs=hUmcSvPBZY9YbVqzEWTWvHEv_tvi0PMFSaQoX4KA@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: raspberrypi: Limit the\n\tmaximum framerate to 30.0fps","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 12 May 2020 10:25:46 -0000"}}]