[libcamera-devel] [PATCH 2/8] Allow only one camera being started
Harvey Yang
chenghaoyang at chromium.org
Thu May 12 12:32:52 CEST 2022
From: Harvey Yang <chenghaoyang at chromium.org>
As we hardly have use cases/applications that need both cameras at the
same time, this patch adds a rule that only one camera can be started
one time. This also allows the following patches that use both imgus to
process frames from one single camera.
Signed-off-by: Harvey Yang <chenghaoyang at chromium.org>
---
src/libcamera/pipeline/ipu3/ipu3.cpp | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index fd989e61..111ba053 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -166,6 +166,8 @@ private:
MediaDevice *cio2MediaDev_;
MediaDevice *imguMediaDev_;
+ Camera *inUseCamera_ = nullptr;
+
std::vector<IPABuffer> ipaBuffers_;
};
@@ -765,6 +767,10 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera)
int PipelineHandlerIPU3::start(Camera *camera, [[maybe_unused]] const ControlList *controls)
{
+ // Deny second camera being started.
+ if (inUseCamera_ && inUseCamera_ != camera)
+ return -1;
+
IPU3CameraData *data = cameraData(camera);
CIO2Device *cio2 = &data->cio2_;
ImgUDevice *imgu = data->imgu_;
@@ -781,6 +787,8 @@ int PipelineHandlerIPU3::start(Camera *camera, [[maybe_unused]] const ControlLis
if (ret)
return ret;
+ inUseCamera_ = camera;
+
ret = data->ipa_->start();
if (ret)
goto error;
@@ -808,6 +816,8 @@ error:
freeBuffers(camera);
LOG(IPU3, Error) << "Failed to start camera " << camera->id();
+ inUseCamera_ = nullptr;
+
return ret;
}
@@ -826,6 +836,8 @@ void PipelineHandlerIPU3::stopDevice(Camera *camera)
LOG(IPU3, Warning) << "Failed to stop camera " << camera->id();
freeBuffers(camera);
+
+ inUseCamera_ = nullptr;
}
void IPU3CameraData::cancelPendingRequests()
--
2.36.0.512.ge40c2bad7a-goog
More information about the libcamera-devel
mailing list