[libcamera-devel] [PATCH 06/10] libcamera: ipu3: Implement buffer release
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Sat Mar 2 23:54:05 CET 2019
Hi Jacopo,
Thank you for the patch.
On Thu, Feb 28, 2019 at 09:04:06PM +0100, Jacopo Mondi wrote:
> Release buffers on all video devices in the pipeline.
>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
> src/libcamera/pipeline/ipu3/ipu3.cpp | 40 +++++++++++++++++++++++++---
> 1 file changed, 36 insertions(+), 4 deletions(-)
>
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index c7b7973952a0..60a48859b398 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -145,6 +145,8 @@ private:
> int initCio2(unsigned int index, Cio2Device *cio2);
> void registerCameras();
>
> + int releaseBuffers(V4L2Device *dev);
> +
> ImguDevice imgu0_;
> ImguDevice imgu1_;
>
> @@ -371,13 +373,32 @@ error_reserve_memory:
> int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)
> {
> IPU3CameraData *data = cameraData(camera);
> + V4L2Device *viewfinder = data->imgu->viewfinder;
> + V4L2Device *output = data->imgu->output;
> + V4L2Device *input = data->imgu->input;
> V4L2Device *cio2 = data->cio2.output;
> + V4L2Device *stat = data->imgu->stat;
> + int ret;
>
> - int ret = cio2->releaseBuffers();
> - if (ret) {
> - LOG(IPU3, Error) << "Failed to release memory";
> + ret = releaseBuffers(viewfinder);
> + if (ret)
> + return ret;
Let's not bail out early. If we fail to release buffers for one video
node, we can still try the other ones.
> +
> + ret = releaseBuffers(stat);
> + if (ret)
> + return ret;
> +
> + ret = releaseBuffers(output);
> + if (ret)
> + return ret;
> +
> + ret = releaseBuffers(cio2);
> + if (ret)
> + return ret;
> +
> + ret = releaseBuffers(input);
> + if (ret)
> return ret;
> - }
>
> return 0;
> }
> @@ -877,6 +898,17 @@ void PipelineHandlerIPU3::registerCameras()
> }
> }
>
> +int PipelineHandlerIPU3::releaseBuffers(V4L2Device *dev)
> +{
> + int ret = dev->releaseBuffers();
Interestingly enough this function never fails. Should we turn it into a
void function, or keep the return type for later use ?
> + if (ret) {
> + LOG(IPU3, Error) << "Failed to release memory";
> + return ret;
> + }
I'd print this in V4L2Device::releaseBuffers(), not here. That way you
can remove the releaseBuffers() method in this class.
> +
> + return 0;
> +}
> +
> REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3);
>
> } /* namespace libcamera */
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list