[libcamera-devel] [RFC 2/7] libcamera: sensor: Add OV5670 camera sensor
Niklas Söderlund
niklas.soderlund at ragnatech.se
Wed Jan 15 20:55:32 CET 2020
Hi Jacopo,
Thanks for your work.
On 2019-12-18 15:49:56 +0100, Jacopo Mondi wrote:
> Add OV5670CameraSensor class to handle Omnivision OV5670 image sensor
> and add support for it in the CameraSensorFactory::create() method.
>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
> src/libcamera/camera_sensor.cpp | 6 ++++++
> src/libcamera/meson.build | 1 +
> src/libcamera/sensor/meson.build | 3 +++
> src/libcamera/sensor/ov5670.cpp | 18 ++++++++++++++++++
> src/libcamera/sensor/ov5670.h | 23 +++++++++++++++++++++++
> 5 files changed, 51 insertions(+)
> create mode 100644 src/libcamera/sensor/meson.build
> create mode 100644 src/libcamera/sensor/ov5670.cpp
> create mode 100644 src/libcamera/sensor/ov5670.h
>
> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
> index ac8878fe336e..d1c9c9bcd58f 100644
> --- a/src/libcamera/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor.cpp
> @@ -6,12 +6,14 @@
> */
>
> #include "camera_sensor.h"
> +#include "sensor/ov5670.h"
>
> #include <algorithm>
> #include <float.h>
> #include <iomanip>
> #include <limits.h>
> #include <math.h>
> +#include <string>
>
> #include <libcamera/property_ids.h>
>
> @@ -47,6 +49,10 @@ LOG_DEFINE_CATEGORY(CameraSensor);
> */
> CameraSensor *CameraSensorFactory::create(const MediaEntity *entity)
> {
> + const std::string &sensorName = entity->name();
> + if (sensorName == "ov5670")
> + return new OV5670CameraSensor(entity);
> +
> return new CameraSensor(entity);
> }
>
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index 14aff6e5fc13..d8d7ac248ae3 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -55,6 +55,7 @@ includes = [
>
> subdir('pipeline')
> subdir('proxy')
> +subdir('sensor')
>
> libudev = dependency('libudev', required : false)
>
> diff --git a/src/libcamera/sensor/meson.build b/src/libcamera/sensor/meson.build
> new file mode 100644
> index 000000000000..7af70370cf5c
> --- /dev/null
> +++ b/src/libcamera/sensor/meson.build
> @@ -0,0 +1,3 @@
> +libcamera_sources += files([
> + 'ov5670.cpp',
> +])
> diff --git a/src/libcamera/sensor/ov5670.cpp b/src/libcamera/sensor/ov5670.cpp
> new file mode 100644
> index 000000000000..ca9f3c1d544f
> --- /dev/null
> +++ b/src/libcamera/sensor/ov5670.cpp
> @@ -0,0 +1,18 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Copyright (C) 2019, Google Inc.
> + *
> + * ov5670.cpp - OV5670 camera sensor
> + */
> +
> +#include "ov5670.h"
> +#include "camera_sensor.h"
> +
> +namespace libcamera {
> +
> +OV5670CameraSensor::OV5670CameraSensor(const MediaEntity *entity)
> + : CameraSensor(entity)
> +{
> +}
> +
> +}; /* namespace libcamera */
> diff --git a/src/libcamera/sensor/ov5670.h b/src/libcamera/sensor/ov5670.h
> new file mode 100644
> index 000000000000..f84239c8411d
> --- /dev/null
> +++ b/src/libcamera/sensor/ov5670.h
> @@ -0,0 +1,23 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Copyright (C) 2019, Google Inc.
> + *
> + * ov5670.h - OV5670 camera sensor
> + */
> +#ifndef __LIBCAMERA_OV5670_H__
> +#define __LIBCAMERA_OV5670_H__
> +
> +#include "camera_sensor.h"
> +
> +namespace libcamera {
> +
> +class OV5670CameraSensor final : public CameraSensor
> +{
> +private:
> + OV5670CameraSensor(const MediaEntity *entity);
> + friend CameraSensorFactory;
Can't we make the constructor public for sub-classes?
> +};
> +
> +}; /* namespace libcamera */
> +
> +#endif /* __LIBCAMERA_OV5670_H__ */
> --
> 2.24.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list