<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 9 May 2024 at 11:23, Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank">laurent.pinchart@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Naush,<br>
<br>
On Tue, May 07, 2024 at 11:32:54AM +0100, Naushir Patuck wrote:<br>
> On Sat, 4 May 2024 at 16:04, Laurent Pinchart wrote:<br>
> > On Wed, May 01, 2024 at 05:04:03PM +0100, Naushir Patuck wrote:<br>
> > > On Wed, 1 May 2024 at 16:53, Laurent Pinchart wrote:<br>
> > > > On Fri, Apr 26, 2024 at 12:18:15PM +0100, Naushir Patuck wrote:<br>
> > > > > The maximum shutter speed calculation in the cam-helper relied on<br>
> > > > > the frame duration limits being correctly set in the cam-helper's mode<br>
> > > > > structure. This was not the case on first startup, so the maximum<br>
> > > > > shutter speed reported back via the ControlInfo was incorrect.<br>
> > > > ><br>
> > > > > Fix this by setting up the camera mode in the cam-helper before querying<br>
> > > > > for the max shutter value.<br>
> > > > ><br>
> > > > > Signed-off-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>><br>
> > > > > ---<br>
> > > > >  src/ipa/rpi/common/ipa_base.cpp | 6 ++++++<br>
> > > > >  1 file changed, 6 insertions(+)<br>
> > > > ><br>
> > > > > diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp<br>
> > > > > index 149a133ab662..1d12262bda01 100644<br>
> > > > > --- a/src/ipa/rpi/common/ipa_base.cpp<br>
> > > > > +++ b/src/ipa/rpi/common/ipa_base.cpp<br>
> > > > > @@ -592,6 +592,12 @@ void IpaBase::setMode(const IPACameraSensorInfo &sensorInfo)<br>
> > > > >       mode_.minAnalogueGain = helper_->gain(gainCtrl.min().get<int32_t>());<br>
> > > > >       mode_.maxAnalogueGain = helper_->gain(gainCtrl.max().get<int32_t>());<br>
> > > > ><br>
> > > > > +     /*<br>
> > > > > +      * We need to give the helper the min/max frame durations so it can calculate<br>
> > > > > +      * the correct exposure limits below.<br>
> > > > > +      */<br>
> > > > > +     helper_->setCameraMode(mode_);<br>
> > > > > +<br>
> > > ><br>
> > > > Don't you end up doing this twice, once here, and once in<br>
> > > > IpaBase::configure(), which calls IpaBase::setMode() ?<br>
> > ><br>
> > > Yes, it does happen twice.  The other option would be to pass a const<br>
> > > reference to mode_ into the helper through setMode(), allowing us only do<br>
> > > it once.<br>
> ><br>
> > I don't think I follow you.<br>
> <br>
> What I mean is that we don't give the cam helper its own copy of the<br>
> mode structure, but pass it a const reference to the IPA's mode<br>
> structure.   This would solve the problem with the calculation here.<br>
<br>
It's probably me, but I still don't get it :-) We have<br>
<br>
void CamHelper::setCameraMode(const CameraMode &mode)<br>
{<br>
        mode_ = mode;<br>
        if (parser_) {<br>
                parser_->reset();<br>
                parser_->setBitsPerPixel(mode.bitdepth);<br>
                parser_->setLineLengthBytes(0); /* We use SetBufferSize. */<br>
        }<br>
}<br>
<br>
called in IpaBase::configure(). This patch adds another call in<br>
IpaBase::setMode(). You wrote<br>
<br>
> The other option would be to pass a const reference to mode_ into the<br>
> helper through setMode()<br>
<br>
Doesn't this patch does exactly that ? How is it another option ?<br>
<br>
/me is confused</blockquote><div><br></div><div>In CamHelper::setCameraMode(const CameraMode &mode), I would have to store the const reference rather than make a copy of CameraMode mode:</div><div><br></div><div>diff --git a/src/ipa/rpi/cam_helper/cam_helper.h b/src/ipa/rpi/cam_helper/cam_helper.h<br>index 58a4b202d5a8..eb2a56484606 100644<br>--- a/src/ipa/rpi/cam_helper/cam_helper.h<br>+++ b/src/ipa/rpi/cam_helper/cam_helper.h<br>@@ -107,7 +107,7 @@ protected:<br>                                      Metadata &metadata) const;<br><br>        std::unique_ptr<MdParser> parser_;<br>-       CameraMode mode_;<br>+       const CameraMode &mode_;<br></div><div><br></div><div>Then in the IPA if I call CamHelper::setCameraMode() before IpaBase::setMode() + a bit of other refactoring, I think I can achieve what I want without a double call..  The "other bit of refactoring" is the bit I'm a bit hesitant to work on for such a simple fix :)</div><div><br></div><div>Regards,</div><div>Naush</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>
> > > But that was a bit more involved over this more trivial fix.  I<br>
> > > can change to do that if folks prefer.<br>
> > ><br>
> > > > >       /* Shutter speed is calculated based on the limits of the frame durations. */<br>
> > > > >       mode_.minShutter = helper_->exposure(shutterCtrl.min().get<int32_t>(), mode_.minLineLength);<br>
> > > > >       mode_.maxShutter = Duration::max();<br>
<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
</blockquote></div></div>