diff options
author | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2024-10-11 10:24:58 +0200 |
---|---|---|
committer | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2024-10-11 12:45:34 +0200 |
commit | e4edcf55ba4d5254973137107ae2b376f7635f45 (patch) | |
tree | e9180adc83d25b7c62737dd82d18615d8e824e94 | |
parent | cb32e0462f21c525c52741c9f5ca623f4bcee7a1 (diff) |
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 <jacopo.mondi@ideasonboard.com>
-rw-r--r-- | src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 30 | ||||
-rw-r--r-- | 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<FrameBuffer *> &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 <deque> #include <map> #include <memory> #include <set> @@ -57,6 +58,7 @@ public: return video_->exportBuffers(bufferCount, buffers); } + int preQueueBuffers(std::deque<FrameBuffer *> &buffers); int start(); void stop(); |