summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/simple
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-07-03 18:33:55 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-08-31 22:44:11 +0300
commit0e8d6903b2f27b6cd31bf7a25f5d47483fc5c36f (patch)
treeccebd7b62323f0e763973973cb7c1e3c0ae0a4fc /src/libcamera/pipeline/simple
parent0f65875bafd7a870319283413810922f88dc0464 (diff)
libcamera: pipeline: simple: Delay opening of video device until init()
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@ideasonboard.com> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Diffstat (limited to 'src/libcamera/pipeline/simple')
-rw-r--r--src/libcamera/pipeline/simple/simple.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index 32bfd45f..76ead3e0 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -309,6 +309,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 });
@@ -322,7 +323,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;
}
@@ -342,7 +343,7 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe,
}
}
- if (!video_)
+ if (!video)
return;
/*
@@ -386,9 +387,16 @@ SimplePipelineHandler *SimpleCameraData::pipe()
int SimpleCameraData::init()
{
- SimpleConverter *converter = pipe()->converter();
+ SimplePipelineHandler *pipe = SimpleCameraData::pipe();
+ 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 :-(