[libcamera-devel] [PATCH v2 3/3] libcamera: pipeline: uvcvideo: create a V4L2Device for the default video entity
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Fri Jan 25 15:49:56 CET 2019
Hi Niklas,
Thank you for the patch.
On Fri, Jan 25, 2019 at 03:39:51PM +0100, Niklas Söderlund wrote:
> 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 at ragnatech.se>
> ---
> src/libcamera/pipeline/uvcvideo.cpp | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
> index 1a445edfa8df777c..e3a475704c080e90 100644
> --- a/src/libcamera/pipeline/uvcvideo.cpp
> +++ b/src/libcamera/pipeline/uvcvideo.cpp
> @@ -11,6 +11,7 @@
> #include "log.h"
> #include "media_device.h"
> #include "pipeline_handler.h"
> +#include "v4l2_device.h"
>
> namespace libcamera {
>
> @@ -26,15 +27,20 @@ public:
>
> private:
> std::shared_ptr<MediaDevice> media_;
> +
I wouldn't have added a blank line, but it's up to you :-)
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> + 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();
> }
> @@ -50,6 +56,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());
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list