libcamera: pipeline: uvcvideo: add pipeline handler for uvcvideo

Provide a pipeline handler for uvcvideo devices. The entity names for
UVC devices are different for different cameras so matching on entity
names is not possible in the generic case. This leaves options to create
specialized UVC pipeline handlers if needed to fit a specific model's
needs.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Niklas Söderlund 2018-12-28 23:04:31 +01:00
parent 5db44e6da7
commit 70b0518ba7
2 changed files with 60 additions and 0 deletions

View file

@ -1,4 +1,5 @@
libcamera_sources += files([
'uvcvideo.cpp',
'vimc.cpp',
])

View file

@ -0,0 +1,59 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* uvcvideo.cpp - Pipeline handler for uvcvideo devices
*/
#include <libcamera/camera.h>
#include <libcamera/camera_manager.h>
#include "device_enumerator.h"
#include "media_device.h"
#include "pipeline_handler.h"
namespace libcamera {
class PipelineHandlerUVC : public PipelineHandler
{
public:
PipelineHandlerUVC();
~PipelineHandlerUVC();
bool match(CameraManager *manager, DeviceEnumerator *enumerator);
private:
MediaDevice *dev_;
};
PipelineHandlerUVC::PipelineHandlerUVC()
: dev_(nullptr)
{
}
PipelineHandlerUVC::~PipelineHandlerUVC()
{
if (dev_)
dev_->release();
}
bool PipelineHandlerUVC::match(CameraManager *manager, DeviceEnumerator *enumerator)
{
DeviceMatch dm("uvcvideo");
dev_ = enumerator->search(dm);
if (!dev_)
return false;
dev_->acquire();
std::shared_ptr<Camera> camera = Camera::create(dev_->model());
manager->addCamera(std::move(camera));
return true;
}
REGISTER_PIPELINE_HANDLER(PipelineHandlerUVC);
} /* namespace libcamera */