diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-03 18:33:55 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-08-31 22:44:11 +0300 |
commit | 41a8f8a9cc09bbcb933d44b7ba5aa41f2230678c (patch) | |
tree | 6badd6c57ba840e833fa4a05459fae5176be9fd5 | |
parent | 0e8d6903b2f27b6cd31bf7a25f5d47483fc5c36f (diff) |
libcamera: pipeline: simple: Store video node entity in camera data
Store the entity corresponding to the video node at the end of the
pipeline in the SimpleCameraData::entities_ list. This requires special
handling of the video node in the loops that iterate over all entities,
but will be useful to implement mutually exclusive access to entities
for concurrent camera usage.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
-rw-r--r-- | src/libcamera/pipeline/simple/simple.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 76ead3e0..a91ee639 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -196,8 +196,13 @@ public: }; std::vector<Stream> streams_; - std::unique_ptr<CameraSensor> sensor_; + + /* + * All entities in the pipeline, from the camera sensor to the video + * node. + */ std::list<Entity> entities_; + std::unique_ptr<CameraSensor> sensor_; V4L2VideoDevice *video_; std::vector<Configuration> configs_; @@ -310,12 +315,11 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, std::unordered_map<MediaEntity *, Entity> parents; MediaEntity *entity = nullptr; MediaEntity *video = nullptr; + MediaPad *sinkPad; queue.push({ sensor, nullptr }); while (!queue.empty()) { - MediaPad *sinkPad; - std::tie(entity, sinkPad) = queue.front(); queue.pop(); @@ -348,8 +352,11 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, /* * With the parents, we can follow back our way from the capture device - * to the sensor. + * to the sensor. Store all the entities in the pipeline, from the + * camera sensor to the video node, in entities_. */ + entities_.push_front({ entity, sinkPad, nullptr, nullptr }); + for (auto it = parents.find(entity); it != parents.end(); it = parents.find(entity)) { const Entity &e = it->second; @@ -490,6 +497,9 @@ int SimpleCameraData::setupLinks() * want to enable) before enabling the pipeline link. */ for (SimpleCameraData::Entity &e : entities_) { + if (!e.link) + break; + MediaEntity *remote = e.link->sink()->entity(); for (MediaPad *pad : remote->pads()) { for (MediaLink *link : pad->links()) { @@ -530,6 +540,9 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, return ret; for (const Entity &e : entities_) { + if (!e.link) + break; + MediaLink *link = e.link; MediaPad *source = link->source(); MediaPad *sink = link->sink(); @@ -1055,8 +1068,14 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) if (entities.empty()) return false; - /* Create and open V4L2Subdev instances for all the entities. */ + /* + * Create and open V4L2Subdevice instances for all entities + * corresponding to a V4L2 subdevice. + */ for (MediaEntity *entity : entities) { + if (entity->type() != MediaEntity::Type::V4L2Subdevice) + continue; + auto elem = subdevs_.emplace(std::piecewise_construct, std::forward_as_tuple(entity), std::forward_as_tuple(entity)); |