9948eb64d1
Refresh them with the patches from https://patchwork.libcamera.org/cover/19663/. This is still based off v0.2.0. Change-Id: I875fd64e3bb71a95c92af1108a23d27c0f3494e0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11179 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: flokli <flokli@flokli.de>
240 lines
8.3 KiB
Diff
240 lines
8.3 KiB
Diff
From 050440eed6ab90686df217f5ff7dea0b241e3898 Mon Sep 17 00:00:00 2001
|
|
From: Andrey Konovalov <andrey.konovalov@linaro.org>
|
|
Date: Mon, 11 Mar 2024 15:15:15 +0100
|
|
Subject: [PATCH 11/21] libcamera: pipeline: simple: rename converterBuffers_
|
|
and related vars
|
|
|
|
The converterBuffers_ and the converterQueue_ are not that specific
|
|
to the Converter, and could be used by another entity doing the format
|
|
conversion.
|
|
|
|
Rename converterBuffers_, converterQueue_, and useConverter_ to
|
|
conversionBuffers_, conversionQueue_ and useConversion_ to
|
|
disassociate them from the Converter.
|
|
|
|
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s
|
|
Tested-by: Pavel Machek <pavel@ucw.cz>
|
|
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Reviewed-by: Pavel Machek <pavel@ucw.cz>
|
|
Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
---
|
|
src/libcamera/pipeline/simple/simple.cpp | 63 ++++++++++++------------
|
|
1 file changed, 32 insertions(+), 31 deletions(-)
|
|
|
|
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
|
|
index a84f6760..78854ef8 100644
|
|
--- a/src/libcamera/pipeline/simple/simple.cpp
|
|
+++ b/src/libcamera/pipeline/simple/simple.cpp
|
|
@@ -269,17 +269,18 @@ public:
|
|
std::vector<Configuration> configs_;
|
|
std::map<PixelFormat, std::vector<const Configuration *>> formats_;
|
|
|
|
+ std::vector<std::unique_ptr<FrameBuffer>> conversionBuffers_;
|
|
+ std::queue<std::map<unsigned int, FrameBuffer *>> conversionQueue_;
|
|
+ bool useConversion_;
|
|
+
|
|
std::unique_ptr<Converter> converter_;
|
|
- std::vector<std::unique_ptr<FrameBuffer>> converterBuffers_;
|
|
- bool useConverter_;
|
|
- std::queue<std::map<unsigned int, FrameBuffer *>> converterQueue_;
|
|
|
|
private:
|
|
void tryPipeline(unsigned int code, const Size &size);
|
|
static std::vector<const MediaPad *> routedSourcePads(MediaPad *sink);
|
|
|
|
- void converterInputDone(FrameBuffer *buffer);
|
|
- void converterOutputDone(FrameBuffer *buffer);
|
|
+ void conversionInputDone(FrameBuffer *buffer);
|
|
+ void conversionOutputDone(FrameBuffer *buffer);
|
|
};
|
|
|
|
class SimpleCameraConfiguration : public CameraConfiguration
|
|
@@ -503,8 +504,8 @@ int SimpleCameraData::init()
|
|
<< "Failed to create converter, disabling format conversion";
|
|
converter_.reset();
|
|
} else {
|
|
- converter_->inputBufferReady.connect(this, &SimpleCameraData::converterInputDone);
|
|
- converter_->outputBufferReady.connect(this, &SimpleCameraData::converterOutputDone);
|
|
+ converter_->inputBufferReady.connect(this, &SimpleCameraData::conversionInputDone);
|
|
+ converter_->outputBufferReady.connect(this, &SimpleCameraData::conversionOutputDone);
|
|
}
|
|
}
|
|
|
|
@@ -740,7 +741,7 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)
|
|
* point converting an erroneous buffer.
|
|
*/
|
|
if (buffer->metadata().status != FrameMetadata::FrameSuccess) {
|
|
- if (!useConverter_) {
|
|
+ if (!useConversion_) {
|
|
/* No conversion, just complete the request. */
|
|
Request *request = buffer->request();
|
|
pipe->completeBuffer(request, buffer);
|
|
@@ -756,16 +757,16 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)
|
|
if (buffer->metadata().status != FrameMetadata::FrameCancelled)
|
|
video_->queueBuffer(buffer);
|
|
|
|
- if (converterQueue_.empty())
|
|
+ if (conversionQueue_.empty())
|
|
return;
|
|
|
|
Request *request = nullptr;
|
|
- for (auto &item : converterQueue_.front()) {
|
|
+ for (auto &item : conversionQueue_.front()) {
|
|
FrameBuffer *outputBuffer = item.second;
|
|
request = outputBuffer->request();
|
|
pipe->completeBuffer(request, outputBuffer);
|
|
}
|
|
- converterQueue_.pop();
|
|
+ conversionQueue_.pop();
|
|
|
|
if (request)
|
|
pipe->completeRequest(request);
|
|
@@ -782,9 +783,9 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)
|
|
*/
|
|
Request *request = buffer->request();
|
|
|
|
- if (useConverter_ && !converterQueue_.empty()) {
|
|
+ if (useConversion_ && !conversionQueue_.empty()) {
|
|
const std::map<unsigned int, FrameBuffer *> &outputs =
|
|
- converterQueue_.front();
|
|
+ conversionQueue_.front();
|
|
if (!outputs.empty()) {
|
|
FrameBuffer *outputBuffer = outputs.begin()->second;
|
|
if (outputBuffer)
|
|
@@ -801,14 +802,14 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)
|
|
* conversion is needed. If there's no queued request, just requeue the
|
|
* captured buffer for capture.
|
|
*/
|
|
- if (useConverter_) {
|
|
- if (converterQueue_.empty()) {
|
|
+ if (useConversion_) {
|
|
+ if (conversionQueue_.empty()) {
|
|
video_->queueBuffer(buffer);
|
|
return;
|
|
}
|
|
|
|
- converter_->queueBuffers(buffer, converterQueue_.front());
|
|
- converterQueue_.pop();
|
|
+ converter_->queueBuffers(buffer, conversionQueue_.front());
|
|
+ conversionQueue_.pop();
|
|
return;
|
|
}
|
|
|
|
@@ -817,13 +818,13 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)
|
|
pipe->completeRequest(request);
|
|
}
|
|
|
|
-void SimpleCameraData::converterInputDone(FrameBuffer *buffer)
|
|
+void SimpleCameraData::conversionInputDone(FrameBuffer *buffer)
|
|
{
|
|
/* Queue the input buffer back for capture. */
|
|
video_->queueBuffer(buffer);
|
|
}
|
|
|
|
-void SimpleCameraData::converterOutputDone(FrameBuffer *buffer)
|
|
+void SimpleCameraData::conversionOutputDone(FrameBuffer *buffer)
|
|
{
|
|
SimplePipelineHandler *pipe = SimpleCameraData::pipe();
|
|
|
|
@@ -1189,14 +1190,14 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
|
|
|
|
/* Configure the converter if needed. */
|
|
std::vector<std::reference_wrapper<StreamConfiguration>> outputCfgs;
|
|
- data->useConverter_ = config->needConversion();
|
|
+ data->useConversion_ = config->needConversion();
|
|
|
|
for (unsigned int i = 0; i < config->size(); ++i) {
|
|
StreamConfiguration &cfg = config->at(i);
|
|
|
|
cfg.setStream(&data->streams_[i]);
|
|
|
|
- if (data->useConverter_)
|
|
+ if (data->useConversion_)
|
|
outputCfgs.push_back(cfg);
|
|
}
|
|
|
|
@@ -1222,7 +1223,7 @@ int SimplePipelineHandler::exportFrameBuffers(Camera *camera, Stream *stream,
|
|
* Export buffers on the converter or capture video node, depending on
|
|
* whether the converter is used or not.
|
|
*/
|
|
- if (data->useConverter_)
|
|
+ if (data->useConversion_)
|
|
return data->converter_->exportBuffers(data->streamIndex(stream),
|
|
count, buffers);
|
|
else
|
|
@@ -1243,13 +1244,13 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL
|
|
return -EBUSY;
|
|
}
|
|
|
|
- if (data->useConverter_) {
|
|
+ if (data->useConversion_) {
|
|
/*
|
|
* When using the converter allocate a fixed number of internal
|
|
* buffers.
|
|
*/
|
|
ret = video->allocateBuffers(kNumInternalBuffers,
|
|
- &data->converterBuffers_);
|
|
+ &data->conversionBuffers_);
|
|
} else {
|
|
/* Otherwise, prepare for using buffers from the only stream. */
|
|
Stream *stream = &data->streams_[0];
|
|
@@ -1268,7 +1269,7 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL
|
|
return ret;
|
|
}
|
|
|
|
- if (data->useConverter_) {
|
|
+ if (data->useConversion_) {
|
|
ret = data->converter_->start();
|
|
if (ret < 0) {
|
|
stop(camera);
|
|
@@ -1276,7 +1277,7 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL
|
|
}
|
|
|
|
/* Queue all internal buffers for capture. */
|
|
- for (std::unique_ptr<FrameBuffer> &buffer : data->converterBuffers_)
|
|
+ for (std::unique_ptr<FrameBuffer> &buffer : data->conversionBuffers_)
|
|
video->queueBuffer(buffer.get());
|
|
}
|
|
|
|
@@ -1288,7 +1289,7 @@ void SimplePipelineHandler::stopDevice(Camera *camera)
|
|
SimpleCameraData *data = cameraData(camera);
|
|
V4L2VideoDevice *video = data->video_;
|
|
|
|
- if (data->useConverter_)
|
|
+ if (data->useConversion_)
|
|
data->converter_->stop();
|
|
|
|
video->streamOff();
|
|
@@ -1296,7 +1297,7 @@ void SimplePipelineHandler::stopDevice(Camera *camera)
|
|
|
|
video->bufferReady.disconnect(data, &SimpleCameraData::bufferReady);
|
|
|
|
- data->converterBuffers_.clear();
|
|
+ data->conversionBuffers_.clear();
|
|
|
|
releasePipeline(data);
|
|
}
|
|
@@ -1314,7 +1315,7 @@ int SimplePipelineHandler::queueRequestDevice(Camera *camera, Request *request)
|
|
* queue, it will be handed to the converter in the capture
|
|
* completion handler.
|
|
*/
|
|
- if (data->useConverter_) {
|
|
+ if (data->useConversion_) {
|
|
buffers.emplace(data->streamIndex(stream), buffer);
|
|
} else {
|
|
ret = data->video_->queueBuffer(buffer);
|
|
@@ -1323,8 +1324,8 @@ int SimplePipelineHandler::queueRequestDevice(Camera *camera, Request *request)
|
|
}
|
|
}
|
|
|
|
- if (data->useConverter_)
|
|
- data->converterQueue_.push(std::move(buffers));
|
|
+ if (data->useConversion_)
|
|
+ data->conversionQueue_.push(std::move(buffers));
|
|
|
|
return 0;
|
|
}
|
|
--
|
|
2.43.2
|
|
|