[libcamera-devel] [PATCH 03/10] libcamera: pipeline: simple: Delay opening of video device until init()
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Fri Aug 6 00:24:29 CEST 2021
The video device is currently opened in the SimpleCameraData
constructor. This requires opening the video devices on-demand the first
time they're accessed, which gets in the way of refactoring of
per-entity data storage in the pipeline handler.
Move opening of the video device to the SimpleCameraData::init()
function. The on-demand open mechanism isn't touched yet, it will be
refactored later.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
src/libcamera/pipeline/simple/simple.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index e0695d052629..744f842dbfe6 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -308,6 +308,7 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe,
/* Remember at each entity where we came from. */
std::unordered_map<MediaEntity *, Entity> parents;
MediaEntity *entity = nullptr;
+ MediaEntity *video = nullptr;
queue.push({ sensor, nullptr });
@@ -321,7 +322,7 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe,
if (entity->function() == MEDIA_ENT_F_IO_V4L) {
LOG(SimplePipeline, Debug)
<< "Found capture device " << entity->name();
- video_ = pipe->video(entity);
+ video = entity;
break;
}
@@ -341,7 +342,7 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe,
}
}
- if (!video_)
+ if (!video)
return;
/*
@@ -384,6 +385,12 @@ int SimpleCameraData::init()
SimpleConverter *converter = pipe->converter();
int ret;
+ video_ = pipe->video(entities_.back().entity);
+ if (!video_) {
+ LOG(SimplePipeline, Error) << "Failed to open video device";
+ return -ENODEV;
+ }
+
/*
* Setup links first as some subdev drivers take active links into
* account to propagate TRY formats. Such is life :-(
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list