<div dir="ltr"><div dir="ltr">Hi David,<div><br></div><div>Thank you for your review on this and the other patches in this series!</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 10 Mar 2022 at 10:57, David Plowman <<a href="mailto:david.plowman@raspberrypi.com">david.plowman@raspberrypi.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>
Thanks for this patch!<br>
<br>
On Mon, 7 Mar 2022 at 12:46, Naushir Patuck via libcamera-devel<br>
<<a href="mailto:libcamera-devel@lists.libcamera.org" target="_blank">libcamera-devel@lists.libcamera.org</a>> wrote:<br>
><br>
> The original use of RPi::Stream::reset() was to clear the external flag state<br>
> and free/clear out the framebuffers for the stream. However, the latter is now<br>
> done through PipelineHandlerRPi::configure(). Rework<br>
> PipelineHandlerRPi::configure() to call RPi::Stream::setExternal() instead of<br>
> RPi::Stream::reset() to achieve the same thing.<br>
><br>
> Repurpose RPi::Stream::reset() to instead reset the state of the buffer handling<br>
> logic, where all internally allocated buffers are put back into the queue of<br>
> available buffers. This reset() is now called from PipelineHandlerRPi::start(),<br>
> allowing the pipeline handler to correctly deal with start()/stop()/start()<br>
> sequences and reusing the buffers allocated on the first start().<br>
><br>
> Signed-off-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>><br>
> ---<br>
>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp |  5 ++++-<br>
>  src/libcamera/pipeline/raspberrypi/rpi_stream.cpp  | 11 +++++------<br>
>  2 files changed, 9 insertions(+), 7 deletions(-)<br>
><br>
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
> index b17ffa235ac7..193361686d3c 100644<br>
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
> @@ -692,7 +692,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)<br>
>         /* Start by freeing all buffers and resetting the Unicam and ISP stream states. */<br>
>         data->freeBuffers();<br>
>         for (auto const stream : data->streams_)<br>
> -               stream->reset();<br>
> +               stream->setExternal(false);<br>
<br>
So I think that replacing the former calls to reset() by setExternal()<br>
is a good thing, because "reset" didn't give you much of a clue about<br>
what was being reset!<br>
<br>
I guess my only feeling about repurposing the name "reset" is that<br>
it's still rather vague. Could we think of a name that gives someone a<br>
clue as to what is being reset? Maybe "resetAvailableBuffers", or just<br>
"resetBuffers"?<br></blockquote><div><br></div><div>Sure I'll rename this to resetBuffers in v2 to be clearer of the new function.</div><div><br></div><div>Regards,</div><div>Naush</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
><br>
>         BayerFormat::Packing packing = BayerFormat::Packing::CSI2;<br>
>         Size maxSize, sensorSize;<br>
> @@ -985,6 +985,9 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)<br>
>         RPiCameraData *data = cameraData(camera);<br>
>         int ret;<br>
><br>
> +       for (auto const stream : data->streams_)<br>
> +               stream->reset();<br>
> +<br>
>         if (data->reconfigured_) {<br>
>                 /* Allocate buffers for internal pipeline usage. */<br>
>                 ret = prepareBuffers(camera);<br>
> diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp<br>
> index f446e1ce66c7..0840ec4f54a0 100644<br>
> --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp<br>
> +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp<br>
> @@ -28,8 +28,10 @@ std::string Stream::name() const<br>
><br>
>  void Stream::reset()<br>
>  {<br>
> -       external_ = false;<br>
> -       clearBuffers();<br>
> +       /* Add all internal buffers to the queue of usable buffers. */<br>
> +       availableBuffers_ = {};<br>
> +       for (auto const &buffer : internalBuffers_)<br>
> +               availableBuffers_.push(buffer.get());<br>
>  }<br>
><br>
>  void Stream::setExternal(bool external)<br>
> @@ -97,10 +99,7 @@ int Stream::prepareBuffers(unsigned int count)<br>
><br>
>                         /* Add these exported buffers to the internal/external buffer list. */<br>
>                         setExportedBuffers(&internalBuffers_);<br>
> -<br>
> -                       /* Add these buffers to the queue of internal usable buffers. */<br>
> -                       for (auto const &buffer : internalBuffers_)<br>
> -                               availableBuffers_.push(buffer.get());<br>
> +                       reset();<br>
>                 }<br>
><br>
>                 /* We must import all internal/external exported buffers. */<br>
> --<br>
> 2.25.1<br>
><br>
<br>
But either way, with or without any further changes:<br>
<br>
Reviewed-by: David Plowman <<a href="mailto:david.plowman@raspberrypi.com" target="_blank">david.plowman@raspberrypi.com</a>><br>
Tested-by: David Plowman <<a href="mailto:david.plowman@raspberrypi.com" target="_blank">david.plowman@raspberrypi.com</a>><br>
<br>
Thanks!<br>
David<br>
</blockquote></div></div>