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:
@@ -1,4 +1,5 @@
|
||||
libcamera_sources += files([
|
||||
'uvcvideo.cpp',
|
||||
'vimc.cpp',
|
||||
])
|
||||
|
||||
|
||||
59
src/libcamera/pipeline/uvcvideo.cpp
Normal file
59
src/libcamera/pipeline/uvcvideo.cpp
Normal 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 */
|
||||
Reference in New Issue
Block a user