summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-01-25 15:21:05 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-01-25 16:14:43 +0100
commit67d313240c9ba5159b7600eae6a3c843fea849a8 (patch)
tree5c49d8a7f3cbab97189567a0c04d2d06653083cb /src
parent25a2f96a28fe0256f39755d2c09e37d03d02aad0 (diff)
libcamera: pipeline: uvcvideo: create a V4L2Device for the default video entity
Add a V4L2Device for the default video entity in the media graph. The UVC pipeline needs to search for the entity marked with the MEDIA_ENT_FL_DEFAULT flag as the entity names in the media graph varies depending on which device is used. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pipeline/uvcvideo.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
index 5de8a0cb..c51e8bc1 100644
--- a/src/libcamera/pipeline/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo.cpp
@@ -10,6 +10,7 @@
#include "device_enumerator.h"
#include "media_device.h"
#include "pipeline_handler.h"
+#include "v4l2_device.h"
namespace libcamera {
@@ -23,15 +24,19 @@ public:
private:
std::shared_ptr<MediaDevice> media_;
+ V4L2Device *video_;
};
PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager)
- : PipelineHandler(manager), media_(nullptr)
+ : PipelineHandler(manager), media_(nullptr), video_(nullptr)
{
}
PipelineHandlerUVC::~PipelineHandlerUVC()
{
+ if (video_)
+ delete video_;
+
if (media_)
media_->release();
}
@@ -47,6 +52,18 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)
media_->acquire();
+ for (MediaEntity *entity : media_->entities()) {
+ if (entity->flags() & MEDIA_ENT_FL_DEFAULT) {
+ video_ = new V4L2Device(*entity);
+ break;
+ }
+ }
+
+ if (!video_ || video_->open()) {
+ media_->release();
+ return false;
+ }
+
std::shared_ptr<Camera> camera = Camera::create(this, media_->model());
registerCamera(std::move(camera));
hotplugMediaDevice(media_.get());