From e4edcf55ba4d5254973137107ae2b376f7635f45 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 11 Oct 2024 10:24:58 +0200 Subject: rkisp1_path: Allow to pre-queue video buffers In order to pre-queue video buffers, the memory management mode of the video device should be switched to DMABUF and the buffer cache needs to be initialized. This is done by the V4L2VideoDevice::importBuffers() function. Currently the RkISP1Path class calls importBuffers() in its start() function, preventing buffer pre-queueing before starting the video device. Break out the buffer import operation to a pre-queue buffer function to allow buffer pre-queueing. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 30 ++++++++++++++++++++++----- src/libcamera/pipeline/rkisp1/rkisp1_path.h | 2 ++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index 1999094e..3ce059a2 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -474,6 +474,31 @@ int RkISP1Path::configure(const StreamConfiguration &config, return 0; } +/* + * NOTE: the 'buffers' will be empty after calling this function. + */ +int RkISP1Path::preQueueBuffers(std::deque &buffers) +{ + /* \todo Make buffer count user configurable. */ + int ret = video_->importBuffers(RKISP1_BUFFER_COUNT); + if (ret) + return ret; + + /* Pre-queue buffers in the video output. */ + while (!buffers.empty()) { + auto buf = buffers.front(); + buffers.pop_front(); + + ret = video_->queueBuffer(buf); + if (ret) { + LOG(RkISP1, Error) << "Failed to pre-queue capture buffers"; + return ret; + } + } + + return 0; +} + int RkISP1Path::start() { int ret; @@ -481,11 +506,6 @@ int RkISP1Path::start() if (running_) return -EBUSY; - /* \todo Make buffer count user configurable. */ - ret = video_->importBuffers(RKISP1_BUFFER_COUNT); - if (ret) - return ret; - ret = video_->streamOn(); if (ret) { LOG(RkISP1, Error) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h index ce9a5666..4ec7ce5c 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -57,6 +58,7 @@ public: return video_->exportBuffers(bufferCount, buffers); } + int preQueueBuffers(std::deque &buffers); int start(); void stop(); -- cgit v1.2.1