From cd3f70a14c69d2cc86dd483249d1943a80947be1 Mon Sep 17 00:00:00 2001 From: Naushir Patuck Date: Sat, 13 Mar 2021 10:27:40 +0000 Subject: pipeline: raspberrypi: Avoid multiple opens of Unicam embedded data node It is possible for the application to call pipeline_handler::configure() multiple times, which would attempt to open the Unicam embedded data node on every call. This would cause a warning message as the node would have already been opened. Avoid this by tracking if the node has previously been opened. Note that this is a temporary fix since the open call for the Unicam embedded data node will be moved from pipeline_handler::configure() to pipeline_handler::match(). Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 41f1cbff..9847e926 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -138,7 +138,7 @@ class RPiCameraData : public CameraData { public: RPiCameraData(PipelineHandler *pipe) - : CameraData(pipe), state_(State::Stopped), + : CameraData(pipe), embeddedNodeOpened_(false), state_(State::Stopped), supportsFlips_(false), flipsAlterBayerOrder_(false), updateScalerCrop_(true), dropFrameCount_(0), ispOutputCount_(0) { @@ -183,6 +183,7 @@ public: std::unique_ptr delayedCtrls_; bool sensorMetadata_; + bool embeddedNodeOpened_; /* * All the functions in this class are called from a single calling @@ -726,8 +727,13 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) if (data->sensorMetadata_) { format = {}; format.fourcc = V4L2PixelFormat(V4L2_META_FMT_SENSOR_DATA); + + if (!data->embeddedNodeOpened_) { + data->unicam_[Unicam::Embedded].dev()->open(); + data->embeddedNodeOpened_ = true; + } + LOG(RPI, Debug) << "Setting embedded data format."; - data->unicam_[Unicam::Embedded].dev()->open(); ret = data->unicam_[Unicam::Embedded].dev()->setFormat(&format); if (ret) { LOG(RPI, Error) << "Failed to set format on Unicam embedded: " -- cgit v1.2.1