Message ID | 20181222230041.29999-12-niklas.soderlund@ragnatech.se |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Niklas, Thank you for the patch. On Sunday, 23 December 2018 01:00:40 EET Niklas Söderlund wrote: > Provide a pipeline handler for the virtual vimc driver. > > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > src/libcamera/meson.build | 1 + > src/libcamera/pipe-vimc.cpp | 92 +++++++++++++++++++++++++++++++++++++ > 2 files changed, 93 insertions(+) > create mode 100644 src/libcamera/pipe-vimc.cpp > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build > index 8457e57939b862ed..088c76f72d331784 100644 > --- a/src/libcamera/meson.build > +++ b/src/libcamera/meson.build > @@ -4,6 +4,7 @@ libcamera_sources = files([ > 'deviceenumerator.cpp', > 'log.cpp', > 'main.cpp', > + 'pipe-vimc.cpp', > 'pipelinehandler.cpp', > ]) > > diff --git a/src/libcamera/pipe-vimc.cpp b/src/libcamera/pipe-vimc.cpp > new file mode 100644 > index 0000000000000000..14bb96faece908de > --- /dev/null > +++ b/src/libcamera/pipe-vimc.cpp > @@ -0,0 +1,92 @@ > +/* SPDX-License-Identifier: LGPL-2.1-or-later */ > +/* > + * Copyright (C) 2018, Google Inc. > + * > + * pipe-vimc.cpp - Pipeline handler for the vimc device > + */ > + > +#include <libcamera/camera.h> > + > +#include "deviceenumerator.h" > +#include "pipelinehandler.h" > + > +namespace libcamera { > + > +class PipeHandlerVimc : public PipelineHandler > +{ > +public: > + PipeHandlerVimc(); > + ~PipeHandlerVimc(); > + > + bool match(DeviceEnumerator *enumerator); > + > + unsigned int count(); > + Camera *camera(unsigned int id); > +private: > + DeviceInfo *info_; > + Camera *camera_; > +}; > + > +PipeHandlerVimc::PipeHandlerVimc() > + : info_(NULL), camera_(NULL) > +{ > +} > + > +PipeHandlerVimc::~PipeHandlerVimc() > +{ > + if (camera_) > + camera_->put(); > + > + if (info_) > + info_->release(); > +} > + > +unsigned int PipeHandlerVimc::count() > +{ > + return 1; > +} > + > +Camera *PipeHandlerVimc::camera(unsigned int id) > +{ > + if (id != 0) > + return NULL; > + > + return camera_; > +} > + > +bool PipeHandlerVimc::match(DeviceEnumerator *enumerator) > +{ > + DeviceMatch dm("vimc"); > + > + dm.add("Raw Capture 0"); > + dm.add("Raw Capture 1"); > + dm.add("RGB/YUV Capture"); > + dm.add("Sensor A"); > + dm.add("Sensor B"); > + dm.add("Debayer A"); > + dm.add("Debayer B"); > + dm.add("RGB/YUV Input"); > + dm.add("Scaler"); > + > + info_ = enumerator->search(dm); > + > + if (info_) { > + info_->acquire(); > + > + /* NOTE: A more complete Camera implementation could > + * be passed the DeviceInfo(s) it controls here or > + * a reference to the PipelineHandler. Which method > + * that is chosen will depend on how the Camera > + * object is modeled. > + */ > + camera_ = new Camera("Dummy VIMC Camera"); > + > + return true; > + } > + > + return info_ ? true : false; What if multiple vimc devices exist in the system ? It seems to me that only the first one will be handled. > +} > + > +REGISTER_PIPELINE(PipeHandlerVimc); > + > +} /* namespace libcamera */
Hi Laurent, Thanks for your feedback. On 2018-12-29 02:48:48 +0200, Laurent Pinchart wrote: > Hi Niklas, > > Thank you for the patch. > > On Sunday, 23 December 2018 01:00:40 EET Niklas Söderlund wrote: > > Provide a pipeline handler for the virtual vimc driver. > > > > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > > --- > > src/libcamera/meson.build | 1 + > > src/libcamera/pipe-vimc.cpp | 92 +++++++++++++++++++++++++++++++++++++ > > 2 files changed, 93 insertions(+) > > create mode 100644 src/libcamera/pipe-vimc.cpp > > > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build > > index 8457e57939b862ed..088c76f72d331784 100644 > > --- a/src/libcamera/meson.build > > +++ b/src/libcamera/meson.build > > @@ -4,6 +4,7 @@ libcamera_sources = files([ > > 'deviceenumerator.cpp', > > 'log.cpp', > > 'main.cpp', > > + 'pipe-vimc.cpp', > > 'pipelinehandler.cpp', > > ]) > > > > diff --git a/src/libcamera/pipe-vimc.cpp b/src/libcamera/pipe-vimc.cpp > > new file mode 100644 > > index 0000000000000000..14bb96faece908de > > --- /dev/null > > +++ b/src/libcamera/pipe-vimc.cpp > > @@ -0,0 +1,92 @@ > > +/* SPDX-License-Identifier: LGPL-2.1-or-later */ > > +/* > > + * Copyright (C) 2018, Google Inc. > > + * > > + * pipe-vimc.cpp - Pipeline handler for the vimc device > > + */ > > + > > +#include <libcamera/camera.h> > > + > > +#include "deviceenumerator.h" > > +#include "pipelinehandler.h" > > + > > +namespace libcamera { > > + > > +class PipeHandlerVimc : public PipelineHandler > > +{ > > +public: > > + PipeHandlerVimc(); > > + ~PipeHandlerVimc(); > > + > > + bool match(DeviceEnumerator *enumerator); > > + > > + unsigned int count(); > > + Camera *camera(unsigned int id); > > +private: > > + DeviceInfo *info_; > > + Camera *camera_; > > +}; > > + > > +PipeHandlerVimc::PipeHandlerVimc() > > + : info_(NULL), camera_(NULL) > > +{ > > +} > > + > > +PipeHandlerVimc::~PipeHandlerVimc() > > +{ > > + if (camera_) > > + camera_->put(); > > + > > + if (info_) > > + info_->release(); > > +} > > + > > +unsigned int PipeHandlerVimc::count() > > +{ > > + return 1; > > +} > > + > > +Camera *PipeHandlerVimc::camera(unsigned int id) > > +{ > > + if (id != 0) > > + return NULL; > > + > > + return camera_; > > +} > > + > > +bool PipeHandlerVimc::match(DeviceEnumerator *enumerator) > > +{ > > + DeviceMatch dm("vimc"); > > + > > + dm.add("Raw Capture 0"); > > + dm.add("Raw Capture 1"); > > + dm.add("RGB/YUV Capture"); > > + dm.add("Sensor A"); > > + dm.add("Sensor B"); > > + dm.add("Debayer A"); > > + dm.add("Debayer B"); > > + dm.add("RGB/YUV Input"); > > + dm.add("Scaler"); > > + > > + info_ = enumerator->search(dm); > > + > > + if (info_) { > > + info_->acquire(); > > + > > + /* NOTE: A more complete Camera implementation could > > + * be passed the DeviceInfo(s) it controls here or > > + * a reference to the PipelineHandler. Which method > > + * that is chosen will depend on how the Camera > > + * object is modeled. > > + */ > > + camera_ = new Camera("Dummy VIMC Camera"); > > + > > + return true; > > + } > > + > > + return info_ ? true : false; > > What if multiple vimc devices exist in the system ? It seems to me that only > the first one will be handled. Only one vimc device will be handled by one instance of PipeHandlerVimc. If there are more then one device two instances of PipeHandlerVimc will be created, see CameraManager::start(): for (std::string const &handler : handlers) { PipelineHandler *pipe; /* * Try each pipeline handler until it exhaust * all pipelines it can provide. */ do { pipe = PipelineHandlerFactory::create(handler, enumerator_); if (pipe) pipes_.push_back(pipe); } while (pipe); } > > > +} > > + > > +REGISTER_PIPELINE(PipeHandlerVimc); > > + > > +} /* namespace libcamera */ > > > -- > Regards, > > Laurent Pinchart > > >
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 8457e57939b862ed..088c76f72d331784 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -4,6 +4,7 @@ libcamera_sources = files([ 'deviceenumerator.cpp', 'log.cpp', 'main.cpp', + 'pipe-vimc.cpp', 'pipelinehandler.cpp', ]) diff --git a/src/libcamera/pipe-vimc.cpp b/src/libcamera/pipe-vimc.cpp new file mode 100644 index 0000000000000000..14bb96faece908de --- /dev/null +++ b/src/libcamera/pipe-vimc.cpp @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2018, Google Inc. + * + * pipe-vimc.cpp - Pipeline handler for the vimc device + */ + +#include <libcamera/camera.h> + +#include "deviceenumerator.h" +#include "pipelinehandler.h" + +namespace libcamera { + +class PipeHandlerVimc : public PipelineHandler +{ +public: + PipeHandlerVimc(); + ~PipeHandlerVimc(); + + bool match(DeviceEnumerator *enumerator); + + unsigned int count(); + Camera *camera(unsigned int id); +private: + DeviceInfo *info_; + Camera *camera_; +}; + +PipeHandlerVimc::PipeHandlerVimc() + : info_(NULL), camera_(NULL) +{ +} + +PipeHandlerVimc::~PipeHandlerVimc() +{ + if (camera_) + camera_->put(); + + if (info_) + info_->release(); +} + +unsigned int PipeHandlerVimc::count() +{ + return 1; +} + +Camera *PipeHandlerVimc::camera(unsigned int id) +{ + if (id != 0) + return NULL; + + return camera_; +} + +bool PipeHandlerVimc::match(DeviceEnumerator *enumerator) +{ + DeviceMatch dm("vimc"); + + dm.add("Raw Capture 0"); + dm.add("Raw Capture 1"); + dm.add("RGB/YUV Capture"); + dm.add("Sensor A"); + dm.add("Sensor B"); + dm.add("Debayer A"); + dm.add("Debayer B"); + dm.add("RGB/YUV Input"); + dm.add("Scaler"); + + info_ = enumerator->search(dm); + + if (info_) { + info_->acquire(); + + /* NOTE: A more complete Camera implementation could + * be passed the DeviceInfo(s) it controls here or + * a reference to the PipelineHandler. Which method + * that is chosen will depend on how the Camera + * object is modeled. + */ + camera_ = new Camera("Dummy VIMC Camera"); + + return true; + } + + return info_ ? true : false; +} + +REGISTER_PIPELINE(PipeHandlerVimc); + +} /* namespace libcamera */
Provide a pipeline handler for the virtual vimc driver. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> --- src/libcamera/meson.build | 1 + src/libcamera/pipe-vimc.cpp | 92 +++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 src/libcamera/pipe-vimc.cpp