diff options
author | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2020-07-10 16:28:36 +0100 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2021-08-12 08:07:25 +0100 |
commit | fafa4fcc333385e89b89c5c0caa36d08cac9abd5 (patch) | |
tree | ffdb81bf9edd1e8865c0b7e02a94801ca8c1c9e7 | |
parent | f88649c321d6ee8ed95eb640dce60edbfde711db (diff) |
libcamera: pipeline: vivid: Create a Camera
Create a VividCameraData inheriting from the CameraData to handle camera
specific data, and use it to create and register the camera with the
CameraManager.
This can now be tested to see that the camera becomes available to
applications:
"""
LIBCAMERA_LOG_LEVELS=Pipeline,VIVID:0 ./src/cam/cam -l
[231:44:49.325333712] [2880028] INFO IPAManager ipa_manager.cpp:136 libcamera is not installed. Adding '/home/libcamera/build-vivid/src/ipa' to the IPA search path
[231:44:49.325428449] [2880028] WARN IPAManager ipa_manager.cpp:147 No IPA found in '/usr/local/lib/x86_64-linux-gnu/libcamera'
[231:44:49.325446253] [2880028] INFO Camera camera_manager.cpp:283 libcamera v0.0.11+713-d175334d-dirty
Available cameras:
1: vivid
"""
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r-- | src/libcamera/pipeline/vivid/vivid.cpp | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/src/libcamera/pipeline/vivid/vivid.cpp b/src/libcamera/pipeline/vivid/vivid.cpp index 6dce9928..cd4c1945 100644 --- a/src/libcamera/pipeline/vivid/vivid.cpp +++ b/src/libcamera/pipeline/vivid/vivid.cpp @@ -7,8 +7,12 @@ #include <libcamera/base/log.h> +#include <libcamera/camera.h> + #include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/v4l2_videodevice.h" /* * Explicitly disable the unused-parameter warning in this pipeline handler. @@ -27,6 +31,34 @@ namespace libcamera { LOG_DEFINE_CATEGORY(VIVID) +class VividCameraData : public CameraData +{ +public: + VividCameraData(PipelineHandler *pipe, MediaDevice *media) + : CameraData(pipe), media_(media), video_(nullptr) + { + } + + ~VividCameraData() + { + delete video_; + } + + int init(); + + MediaDevice *media_; + V4L2VideoDevice *video_; + Stream stream_; +}; + +class VividCameraConfiguration : public CameraConfiguration +{ +public: + VividCameraConfiguration(); + + Status validate() override; +}; + class PipelineHandlerVivid : public PipelineHandler { public: @@ -92,9 +124,27 @@ bool PipelineHandlerVivid::match(DeviceEnumerator *enumerator) if (!media) return false; - LOG(VIVID, Debug) << "Obtained Vivid Device"; + std::unique_ptr<VividCameraData> data = std::make_unique<VividCameraData>(this, media); + + /* Locate and open the capture video node. */ + if (data->init()) + return false; + + /* Create and register the camera. */ + std::set<Stream *> streams{ &data->stream_ }; + std::shared_ptr<Camera> camera = Camera::create(this, data->video_->deviceName(), streams); + registerCamera(std::move(camera), std::move(data)); + + return true; +} + +int VividCameraData::init() +{ + video_ = new V4L2VideoDevice(media_->getEntityByName("vivid-000-vid-cap")); + if (video_->open()) + return -ENODEV; - return false; // Prevent infinite loops for now + return 0; } REGISTER_PIPELINE_HANDLER(PipelineHandlerVivid) |