From patchwork Wed Dec 18 14:49:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2436 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A41D960475 for ; Wed, 18 Dec 2019 15:47:52 +0100 (CET) X-Originating-IP: 93.34.114.233 Received: from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 3932060012; Wed, 18 Dec 2019 14:47:52 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Dec 2019 15:49:55 +0100 Message-Id: <20191218145001.22283-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191218145001.22283-1-jacopo@jmondi.org> References: <20191218145001.22283-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 1/7] libcamera: camera_sensor: Introduce CameraSensorFactory X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2019 14:47:52 -0000 Introduce a factory to create CameraSensor derived classes instances by inspecting the sensor media entity name. For now, unconditionally create and return an instance of the only existing CameraSensor class in CameraSensorFactory::create() Signed-off-by: Jacopo Mondi --- src/libcamera/camera_sensor.cpp | 22 +++++++++++++++++++ src/libcamera/include/camera_sensor.h | 10 ++++++++- src/libcamera/pipeline/ipu3/ipu3.cpp | 2 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +- src/libcamera/pipeline/vimc.cpp | 2 +- test/camera-sensor.cpp | 2 +- .../v4l2_videodevice_test.cpp | 2 +- 7 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index bc8b9e78bc42..ac8878fe336e 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -28,6 +28,28 @@ namespace libcamera { LOG_DEFINE_CATEGORY(CameraSensor); +/** + * \class CameraSensorFactory + * \brief Factory of camera sensor + * + * The CameraSensorFactory instantiate and return the opportune CameraSensor + * sub-class by inspecting the name of the sensor entity to handle. + */ + +/** + * \brief Create and return a CameraSensor + * \param[in] entity The media entity that represents the sensor to handle + * + * Instantiate and return the opportune CameraSensor subclass inspecting the + * \a entity name. + * + * \return A pointer to a CameraSensor derived class instance + */ +CameraSensor *CameraSensorFactory::create(const MediaEntity *entity) +{ + return new CameraSensor(entity); +} + /** * \class CameraSensor * \brief A camera sensor based on V4L2 subdevices diff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h index 99cff98128dc..2c09b1bdb61b 100644 --- a/src/libcamera/include/camera_sensor.h +++ b/src/libcamera/include/camera_sensor.h @@ -22,10 +22,16 @@ class V4L2Subdevice; struct V4L2SubdeviceFormat; +class CameraSensor; +class CameraSensorFactory final +{ +public: + static CameraSensor *create(const MediaEntity *entity); +}; + class CameraSensor : protected Loggable { public: - explicit CameraSensor(const MediaEntity *entity); ~CameraSensor(); CameraSensor(const CameraSensor &) = delete; @@ -49,6 +55,8 @@ public: const ControlList &properties() const { return properties_; } protected: + friend class CameraSensorFactory; + explicit CameraSensor(const MediaEntity *entity); std::string logPrefix() const; private: diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 536a63a30018..6de2f548fe1c 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1362,7 +1362,7 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index) MediaLink *link = links[0]; MediaEntity *sensorEntity = link->source()->entity(); - sensor_ = new CameraSensor(sensorEntity); + sensor_ = CameraSensorFactory::create(sensorEntity); ret = sensor_->init(); if (ret) return ret; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index e9a70755f4c5..276a12755f59 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -883,7 +883,7 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) data->controlInfo_ = std::move(ctrls); - data->sensor_ = new CameraSensor(sensor); + data->sensor_ = CameraSensorFactory::create(sensor); ret = data->sensor_->init(); if (ret) return ret; diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 2bfab35314c4..5d6baa56ba8b 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -403,7 +403,7 @@ int VimcCameraData::init(MediaDevice *media) return ret; /* Create and open the camera sensor, debayer, scaler and video device. */ - sensor_ = new CameraSensor(media->getEntityByName("Sensor B")); + sensor_ = CameraSensorFactory::create(media->getEntityByName("Sensor B")); ret = sensor_->init(); if (ret) return ret; diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp index 27c190fe7ace..0e7e3f5585d2 100644 --- a/test/camera-sensor.cpp +++ b/test/camera-sensor.cpp @@ -50,7 +50,7 @@ protected: return TestFail; } - sensor_ = new CameraSensor(entity); + sensor_ = CameraSensorFactory::create(entity); if (sensor_->init() < 0) { cerr << "Unable to initialise camera sensor" << endl; return TestFail; diff --git a/test/v4l2_videodevice/v4l2_videodevice_test.cpp b/test/v4l2_videodevice/v4l2_videodevice_test.cpp index 577da4cb601c..3c4ca60b9076 100644 --- a/test/v4l2_videodevice/v4l2_videodevice_test.cpp +++ b/test/v4l2_videodevice/v4l2_videodevice_test.cpp @@ -61,7 +61,7 @@ int V4L2VideoDeviceTest::init() return TestFail; if (driver_ == "vimc") { - sensor_ = new CameraSensor(media_->getEntityByName("Sensor A")); + sensor_ = CameraSensorFactory::create(media_->getEntityByName("Sensor A")); if (sensor_->init()) return TestFail; From patchwork Wed Dec 18 14:49:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2437 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 48677605D2 for ; Wed, 18 Dec 2019 15:47:53 +0100 (CET) X-Originating-IP: 93.34.114.233 Received: from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id CC2EA60003; Wed, 18 Dec 2019 14:47:52 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Dec 2019 15:49:56 +0100 Message-Id: <20191218145001.22283-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191218145001.22283-1-jacopo@jmondi.org> References: <20191218145001.22283-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 2/7] libcamera: sensor: Add OV5670 camera sensor X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2019 14:47:54 -0000 Add OV5670CameraSensor class to handle Omnivision OV5670 image sensor and add support for it in the CameraSensorFactory::create() method. Signed-off-by: Jacopo Mondi --- 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 #include #include #include #include +#include #include @@ -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; +}; + +}; /* namespace libcamera */ + +#endif /* __LIBCAMERA_OV5670_H__ */ From patchwork Wed Dec 18 14:49:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2438 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DEB01605D7 for ; Wed, 18 Dec 2019 15:47:53 +0100 (CET) X-Originating-IP: 93.34.114.233 Received: from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 6EF4160003; Wed, 18 Dec 2019 14:47:53 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Dec 2019 15:49:57 +0100 Message-Id: <20191218145001.22283-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191218145001.22283-1-jacopo@jmondi.org> References: <20191218145001.22283-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 3/7] libcamera: camera_sensor: Factorize out properties X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2019 14:47:54 -0000 Factorize CameraSensor properties initialization to a dedicated virtual function that dervied classes could subclass to register sensor-specific properties. Signed-off-by: Jacopo Mondi --- src/libcamera/camera_sensor.cpp | 94 ++++++++++++++++----------- src/libcamera/include/camera_sensor.h | 5 +- 2 files changed, 60 insertions(+), 39 deletions(-) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index d1c9c9bcd58f..9692895d9b7b 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -77,7 +77,7 @@ CameraSensor *CameraSensorFactory::create(const MediaEntity *entity) * Once constructed the instance must be initialized with init(). */ CameraSensor::CameraSensor(const MediaEntity *entity) - : entity_(entity), properties_(properties::properties) + : properties_(properties::properties), entity_(entity) { subdev_ = new V4L2Subdevice(entity); } @@ -119,42 +119,6 @@ int CameraSensor::init() if (ret < 0) return ret; - /* Retrieve and store the camera sensor properties. */ - const ControlInfoMap &controls = subdev_->controls(); - int32_t propertyValue; - - /* Camera Location: default is front location. */ - const auto &locationControl = controls.find(V4L2_CID_CAMERA_SENSOR_LOCATION); - if (locationControl != controls.end()) { - int32_t v4l2Location = - locationControl->second.def().get(); - switch (v4l2Location) { - case V4L2_LOCATION_EXTERNAL: - propertyValue = properties::CameraLocationExternal; - break; - case V4L2_LOCATION_FRONT: - propertyValue = properties::CameraLocationFront; - break; - case V4L2_LOCATION_BACK: - propertyValue = properties::CameraLocationBack; - break; - default: - LOG(CameraSensor, Error) - << "Unsupported camera location: " << v4l2Location; - return -EINVAL; - } - } else { - propertyValue = properties::CameraLocationFront; - } - properties_.set(properties::Location, propertyValue); - - /* Camera Rotation: default is 0 degrees. */ - propertyValue = 0; - const auto &rotationControl = controls.find(V4L2_CID_CAMERA_SENSOR_ROTATION); - if (rotationControl != controls.end()) - propertyValue = rotationControl->second.def().get(); - properties_.set(properties::Rotation, propertyValue); - /* Enumerate and cache media bus codes and sizes. */ const ImageFormats formats = subdev_->formats(0); if (formats.isEmpty()) { @@ -185,6 +149,62 @@ int CameraSensor::init() std::sort(mbusCodes_.begin(), mbusCodes_.end()); std::sort(sizes_.begin(), sizes_.end()); + return initProperties(subdev_->controls()); +} + +/** + * \brief Initialize the camera sensor properties + * \param[in] controlMap The map of control information provided by the sensor + * + * This method initializes the camera sensor properties, by inspecting the + * control information reported by the sensor media entity in \a controlMap. + * For each supported standard V4L2 control reported by the sensor, a libcamera + * property is created and registered in the list of properties supported by the + * sensor. + * + * Derived classes are free to override this method to register sensor specific + * properties as they like, by inspecting custom controls or by adding + * properties with pre-defined values, and eventually call this base class + * implementation to register standard ones. + * + * \return 0 on success, a negative error code otherwise + */ +int CameraSensor::initProperties(const ControlInfoMap &controlMap) +{ + int32_t propertyValue; + + /* Camera Location: default is front location. */ + const auto &locationControl = controlMap.find(V4L2_CID_CAMERA_SENSOR_LOCATION); + if (locationControl != controlMap.end()) { + int32_t v4l2Location = + locationControl->second.def().get(); + switch (v4l2Location) { + case V4L2_LOCATION_EXTERNAL: + propertyValue = properties::CameraLocationExternal; + break; + case V4L2_LOCATION_FRONT: + propertyValue = properties::CameraLocationFront; + break; + case V4L2_LOCATION_BACK: + propertyValue = properties::CameraLocationBack; + break; + default: + LOG(CameraSensor, Error) + << "Unsupported camera location: " << v4l2Location; + return -EINVAL; + } + } else { + propertyValue = properties::CameraLocationFront; + } + properties_.set(properties::Location, propertyValue); + + /* Camera Rotation: default is 0 degrees. */ + propertyValue = 0; + const auto &rotationControl = controlMap.find(V4L2_CID_CAMERA_SENSOR_ROTATION); + if (rotationControl != controlMap.end()) + propertyValue = rotationControl->second.def().get(); + properties_.set(properties::Rotation, propertyValue); + return 0; } diff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h index 2c09b1bdb61b..43748a6c8535 100644 --- a/src/libcamera/include/camera_sensor.h +++ b/src/libcamera/include/camera_sensor.h @@ -38,6 +38,7 @@ public: CameraSensor &operator=(const CameraSensor &) = delete; int init(); + virtual int initProperties(const ControlInfoMap &controlMap); const MediaEntity *entity() const { return entity_; } const std::vector &mbusCodes() const { return mbusCodes_; } @@ -55,6 +56,8 @@ public: const ControlList &properties() const { return properties_; } protected: + ControlList properties_; + friend class CameraSensorFactory; explicit CameraSensor(const MediaEntity *entity); std::string logPrefix() const; @@ -65,8 +68,6 @@ private: std::vector mbusCodes_; std::vector sizes_; - - ControlList properties_; }; } /* namespace libcamera */ From patchwork Wed Dec 18 14:49:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2439 Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6A50E60475 for ; Wed, 18 Dec 2019 15:47:54 +0100 (CET) X-Originating-IP: 93.34.114.233 Received: from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 0D4B860010; Wed, 18 Dec 2019 14:47:53 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Dec 2019 15:49:58 +0100 Message-Id: <20191218145001.22283-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191218145001.22283-1-jacopo@jmondi.org> References: <20191218145001.22283-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 4/7] libcamera: properties: Define pixel array properties X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2019 14:47:54 -0000 Add definition of pixel array related properties. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/property_ids.yaml | 177 ++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index 811c300c6b0a..9e2333cb7206 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -31,4 +31,181 @@ controls: Camera mounting rotation expressed as counterclockwise rotation degrees towards the axis perpendicular to the sensor surface and directed away from it + + - PixelArraySize: + type: float + compound: true + description: | + The physical sizes of the pixel array (width and height), in + millimeters. + + - PixelArrayBounds: + type: int32_t + compound: true + description: | + The camera sensor pixel array bounding rectangle vertical and + horizontal sizes. + + For image sensors with a rectangular pixel array the sizes described by + this property are the same as the PixelAreaSize property size. + + For image sensors with more complex pixel array displacements (such as + cross-shaped pixel arrays, non symmetrical pixel arrays etc) this + property represents the bounding rectangle in which all pixel array + dimensions are inscribed into. + + In example, the bounding rectangle sizes for image sensor with a + cross-shaped pixel array is described as + + + PixelArrayBound(0) = width + /-----------------/ + + (0,0)-> +----+------+----+ / + | |//////| | | + +----+//////+----+ | + |////////////////| | PixelArrayBound(1) = height + +----+//////+----+ | + | |//////| | | + +----+------+----+ / + | + -> Cross-shaped pixel area + + - PixelArrays: + type: int32_t + compound: true + description: | + The sensor pixel array rectangles, relative to the rectangle described + by the PixelArrayBounds property. + + This property describes an arbitrary number of (likely overlapping) + rectangles, representing the pixel array areas the sensor is composed + of. + + Each rectangle is defined by its displacement from pixel (0, 0) of + the bounding rectangle described by the PixelArrayBound property. + + For image sensors with a rectangular pixel array, a single rectangle + is required. For sensors with more complex pixel array displacements + multiple rectangles shall be specified, ordered from the tallest to the + shorter one. + + For each rectangle, this property reports the full pixel array size, + including non-active pixels, black level calibration pixels etc. + + In example, a simple sensor with a rectangular pixel array is described + as + + PixelArrayBound(0) = width + /-----------------/ + x1 x2 + (0,0)-> +-o------------o-+ / + y1 o +------------+ | | + | |////////////| | | + | |////////////| | | PixelArrayBound(1) = height + | |////////////| | | + y2 o +------------+ | | + +----------------+ / + + PixelArray = (x1, y1, (x2 - x1), (y2 - y1)) + + A more complex sensor, with a cross shaped pixel array displacement + is described with 2 rectangles, with the vertical rectangle + described first + + PixelArrayBound(0) = width + /-----------------/ + x1 x2 x3 x4 W + (0,0)-> +o---o------o---o+ / + | |//////| | | + y1 o+---+------+---+| | + ||///|//////|///|| | PixelArrayBound(1) = height + y2 o+---+------+---+| | + | |//////| | | + H +----+------+----+ / + + + PixelArray = ( (x2, 0, (x3 - x2), H), + (x1, y1, (x4 - x1), (y2 - y1)) + + - ActiveAreaSize: + type: int32_t + compound: true + description: | + The sensor active pixel area sizes, represented as rectangles + inscribed in the ones described by the PixelArrays property. + + One ActiveAreaSize rectangle per each rectangle described in the + PixelArrays property is required. As a consequence, the two properties + shall transport the same number of elements. + + The ActiveAreaSize rectangles represent the maximum image sizes the + sensor can produce. + + - BayerFilterArrangement: + type: int32_t + description: | + The pixel array color filter displacement. + + This property describes the arrangement and readout sequence of the + three RGB color components of the sensor's Bayer Color Filter Array + (CFA). + + Color filters are usually displaced in line-alternating fashion on the + sensor pixel array. In example, one line might be composed of Red-Green + while the successive is composed of Blue-Green color information. + + The value of this property represent the arrangement of color filters + in the top-left 2x2 pixel square. + + In example, for a sensor with the following color filter displacement + + (0, 0) (max-col) + +---+ +--------------...---+ + |B|G|<---|B|G|B|G|B|G|B|...B|G| + |G|R|<---|G|R|G|R|G|R|G|...G|R| + +---+ |B|G|B|G|B|G|B|...B|G| + ... .. + ... .. + |G|R|G|R|G|R|G|...G|R| + |B|G|B|G|B|G|B|...B|G| (max-lines) + +--------------...---+ + + The filer arrangement is represented by the BGGR value, which correspond + to the pixel readout sequence in line interleaved mode. + + enum: + - BayerFilterRGGB: + value: 0 + description: | + Color filter array displacement is Red-Green/Green-Blue + + - BayerFilterGRBG: + value: 1 + description: | + Color filter array displacement is Green-Red/Blue-Green + + - BayerFilterGBRG: + value: 2 + description: | + Color filter array displacement is Green-Blue/Red-Green + + - BayerFilterBGGR: + value: 3 + description: | + Color filter array displacement is Blue-Green/Green-Red + + - BayerFilterNonStandard: + value: 4 + description: | + The pixel array color filter does not use the standard Bayer RGB + color model + + - ISOSensitivityRange: + type: int32_t + compound: true + description: | + The range of supported ISO sensitivities, as documented by the + ISO 12232:2006 standard + ... From patchwork Wed Dec 18 14:49:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2441 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D3C5605D8 for ; Wed, 18 Dec 2019 15:47:56 +0100 (CET) X-Originating-IP: 93.34.114.233 Received: from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 975E860008; Wed, 18 Dec 2019 14:47:54 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Dec 2019 15:49:59 +0100 Message-Id: <20191218145001.22283-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191218145001.22283-1-jacopo@jmondi.org> References: <20191218145001.22283-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 5/7] libcamera: sensor: ov5670: Register pixel array properties X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2019 14:47:56 -0000 Implement sensor specific pixel array properties initialization for the OV5670 sensor driver by overriding CameraSensor::initProperties() method. Signed-off-by: Jacopo Mondi --- src/libcamera/sensor/ov5670.cpp | 19 +++++++++++++++++++ src/libcamera/sensor/ov5670.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/src/libcamera/sensor/ov5670.cpp b/src/libcamera/sensor/ov5670.cpp index ca9f3c1d544f..c2d996785717 100644 --- a/src/libcamera/sensor/ov5670.cpp +++ b/src/libcamera/sensor/ov5670.cpp @@ -6,6 +6,10 @@ */ #include "ov5670.h" + +#include +#include + #include "camera_sensor.h" namespace libcamera { @@ -15,4 +19,19 @@ OV5670CameraSensor::OV5670CameraSensor(const MediaEntity *entity) { } +int OV5670CameraSensor::initProperties(const ControlInfoMap &controlMap) +{ + /* Pixel Array Properties. */ + properties_.set(properties::PixelArraySize, { 2.9f, 1.18f }); + properties_.set(properties::PixelArrayBounds, { 2592, 1944 }); + properties_.set(properties::PixelArrays, { 2592, 1944 }); + properties_.set(properties::ActiveAreaSize, { 16, 6, 2560, 1920 }); + int32_t bayerFilter = properties::BayerFilterGRBG; + properties_.set(properties::BayerFilterArrangement, bayerFilter); + properties_.set(properties::ISOSensitivityRange, { 50, 800 }); + + return CameraSensor::initProperties(controlMap); +} + }; /* namespace libcamera */ + diff --git a/src/libcamera/sensor/ov5670.h b/src/libcamera/sensor/ov5670.h index f84239c8411d..564a4546d69b 100644 --- a/src/libcamera/sensor/ov5670.h +++ b/src/libcamera/sensor/ov5670.h @@ -11,8 +11,11 @@ namespace libcamera { +class ControlInfoMap; class OV5670CameraSensor final : public CameraSensor { + int initProperties(const ControlInfoMap &controlMap); + private: OV5670CameraSensor(const MediaEntity *entity); friend CameraSensorFactory; From patchwork Wed Dec 18 14:50:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2440 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B5A6360475 for ; Wed, 18 Dec 2019 15:47:55 +0100 (CET) X-Originating-IP: 93.34.114.233 Received: from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 464DC60007; Wed, 18 Dec 2019 14:47:55 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Dec 2019 15:50:00 +0100 Message-Id: <20191218145001.22283-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191218145001.22283-1-jacopo@jmondi.org> References: <20191218145001.22283-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 6/7] libcamera: properties: Define 'lens' properties X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2019 14:47:56 -0000 Define properties that describe the optical characteristics of the image sensor. Signed-off-by: Jacopo Mondi --- src/libcamera/property_ids.yaml | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index 9e2333cb7206..fdadfb8b1da4 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -208,4 +208,38 @@ controls: The range of supported ISO sensitivities, as documented by the ISO 12232:2006 standard + - LensApertures: + type: float + compound: true + description: | + The available lens apertures, expressed as f numbers (the ratio between + the lens focal distance and the diameter of the pupil aperture). + + If the sensor has a fixed aperture, the property transports a single + value. + + - LensFocalDistance: + type: float + compound: true + description: | + The available focal length distances, expressed in millimeters. + + If the sensor is featured with a movable lens mechanism this property + reports the focal lengths associated with each discrete step. For + sensor with fixed-focus lenses, a single focal length should be instead + reported. + + - LensHyperfocalDistance: + type: float + compound: true + description: | + The hyperfocal distance of the sensor. The property is particularly + meaningful for fixed-focus devices. + + - LensMinimumFocalDistance: + type: float + description: | + The shortest distance in millimeters from the lens surface in which an + object could be brought into sharp focus. + ... From patchwork Wed Dec 18 14:50:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2442 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5EE82605DB for ; Wed, 18 Dec 2019 15:47:56 +0100 (CET) X-Originating-IP: 93.34.114.233 Received: from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id D79D960011; Wed, 18 Dec 2019 14:47:55 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Dec 2019 15:50:01 +0100 Message-Id: <20191218145001.22283-8-jacopo@jmondi.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191218145001.22283-1-jacopo@jmondi.org> References: <20191218145001.22283-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 7/7] libcamera: sensor: ov5670: Add lens properties X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2019 14:47:56 -0000 Signed-off-by: Jacopo Mondi --- src/libcamera/sensor/ov5670.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libcamera/sensor/ov5670.cpp b/src/libcamera/sensor/ov5670.cpp index c2d996785717..a25bfd246f8b 100644 --- a/src/libcamera/sensor/ov5670.cpp +++ b/src/libcamera/sensor/ov5670.cpp @@ -30,6 +30,12 @@ int OV5670CameraSensor::initProperties(const ControlInfoMap &controlMap) properties_.set(properties::BayerFilterArrangement, bayerFilter); properties_.set(properties::ISOSensitivityRange, { 50, 800 }); + /* Lens Properties. */ + properties_.set(properties::LensApertures, 0.0f); + properties_.set(properties::LensFocalDistance, 3.69f); + properties_.set(properties::LensHyperfocalDistance, 0.0f); + properties_.set(properties::LensMinimumFocalDistance, 3.69f); + return CameraSensor::initProperties(controlMap); }