[libcamera-devel] [PATCH v1 3/6] pipeline: raspberrypi: Free buffers in the RPiCamera destructor and re-configure

David Plowman david.plowman at raspberrypi.com
Thu Mar 10 11:40:49 CET 2022


Hi Naush

Thanks for this patch.

On Mon, 7 Mar 2022 at 12:46, Naushir Patuck via libcamera-devel
<libcamera-devel at lists.libcamera.org> wrote:
>
> Currently, all framebuffer allocations get freed and cleared on a stop in
> PipelineHandlerRPi::stopDevice(). If PipelineHandlerRPi::start() is then called
> without an intermediate PipelineHandlerRPi::configure(), it will re-allocate and
> prepare all the buffers again, which is unnecessary.
>
> Fix this by not freeing the buffer in PipelineHandlerRPi::stopDevice(), but
> insted doing it in PipelineHandlerRPi::configure(), as the buffers might have
> to be resized.
>
> Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
> ---
>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index 3781e4e0e3c4..8bb9fc429912 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -189,6 +189,11 @@ public:
>         {
>         }
>
> +       ~RPiCameraData()
> +       {
> +               freeBuffers();
> +       }
> +
>         void freeBuffers();
>         void frameStarted(uint32_t sequence);
>
> @@ -681,7 +686,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)
>         RPiCameraData *data = cameraData(camera);
>         int ret;
>
> -       /* Start by resetting the Unicam and ISP stream states. */
> +       /* Start by freeing all buffers and resetting the Unicam and ISP stream states. */
> +       data->freeBuffers();
>         for (auto const stream : data->streams_)
>                 stream->reset();
>
> @@ -1048,8 +1054,6 @@ void PipelineHandlerRPi::stopDevice(Camera *camera)
>
>         /* Stop the IPA. */
>         data->ipa_->stop();
> -
> -       data->freeBuffers();
>  }
>
>  int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)
> --
> 2.25.1
>

Reviewed-by: David Plowman <david.plowman at raspberrypi.com>
Tested-by: David Plowman <david.plowman at raspberrypi.com>

Thanks!
David


More information about the libcamera-devel mailing list