[libcamera-devel] [PATCH 11/12] libcamera: pipe-vimc: add pipeline handler for vimc

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat Dec 29 01:48:48 CET 2018


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 at 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 */


-- 
Regards,

Laurent Pinchart





More information about the libcamera-devel mailing list