From e9e6135d97d0afd3191e59578a71d51db14d6ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Mon, 30 Dec 2019 00:49:14 +0100 Subject: libcamera: pipeline: Add FrameBuffer handlers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extend the pipeline handlers to support the FrameBuffer API with three new methods to handle allocation, importing and freeing of buffers. The new methods will replace allocateBuffers() and freeBuffers(). The FrameBuffer API will use the methods on a stream level and either allocate or import buffers for each active stream controlled from the Camera class and an upcoming FrameBufferAllocator helper. With this new API the implementation in pipeline handlers can be made simpler as all streams don't need to be handled in allocateBuffers(). Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/ipu3/ipu3.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/libcamera/pipeline/ipu3/ipu3.cpp') diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 7c4539d4..b73f0f07 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -210,6 +210,11 @@ public: const StreamRoles &roles) override; int configure(Camera *camera, CameraConfiguration *config) override; + int exportFrameBuffers(Camera *camera, Stream *stream, + std::vector> *buffers) override; + int importFrameBuffers(Camera *camera, Stream *stream) override; + void freeFrameBuffers(Camera *camera, Stream *stream) override; + int allocateBuffers(Camera *camera, const std::set &streams) override; int freeBuffers(Camera *camera, @@ -616,6 +621,33 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) return 0; } +int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream, + std::vector> *buffers) +{ + IPU3Stream *ipu3stream = static_cast(stream); + V4L2VideoDevice *video = ipu3stream->device_->dev; + unsigned int count = stream->configuration().bufferCount; + + return video->exportBuffers(count, buffers); +} + +int PipelineHandlerIPU3::importFrameBuffers(Camera *camera, Stream *stream) +{ + IPU3Stream *ipu3stream = static_cast(stream); + V4L2VideoDevice *video = ipu3stream->device_->dev; + unsigned int count = stream->configuration().bufferCount; + + return video->importBuffers(count); +} + +void PipelineHandlerIPU3::freeFrameBuffers(Camera *camera, Stream *stream) +{ + IPU3Stream *ipu3stream = static_cast(stream); + V4L2VideoDevice *video = ipu3stream->device_->dev; + + video->releaseBuffers(); +} + /** * \todo Clarify if 'viewfinder' and 'stat' nodes have to be set up and * started even if not in use. As of now, if not properly configured and -- cgit v1.2.1