[{"id":14317,"web_url":"https://patchwork.libcamera.org/comment/14317/","msgid":"<X+Laeg4D0LMPJQV8@pendragon.ideasonboard.com>","date":"2020-12-23T05:49:46","subject":"Re: [libcamera-devel] [PATCH v2 7/9] libcamera: Introduce camera\n\tsensor database","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\nOn Fri, Dec 18, 2020 at 05:47:52PM +0100, Jacopo Mondi wrote:\n\nThank you for the patch.\n\n> Introduce a 'database' of camera sensor information, which contains\n> a list of camera sensor properties which is not possible, or desirable,\n> to retrieve at run-time.\n> \n> The camera sensor database is a global read-only library object.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  include/libcamera/internal/meson.build       |   1 +\n>  include/libcamera/internal/sensor_database.h |  37 +++++++\n>  src/libcamera/meson.build                    |   1 +\n>  src/libcamera/sensor_database.cpp            | 106 +++++++++++++++++++\n>  4 files changed, 145 insertions(+)\n>  create mode 100644 include/libcamera/internal/sensor_database.h\n>  create mode 100644 src/libcamera/sensor_database.cpp\n> \n> diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\n> index 7cde023f7c3a..ac08f0761238 100644\n> --- a/include/libcamera/internal/meson.build\n> +++ b/include/libcamera/internal/meson.build\n> @@ -36,6 +36,7 @@ libcamera_internal_headers = files([\n>      'process.h',\n>      'pub_key.h',\n>      'semaphore.h',\n> +    'sensor_database.h',\n>      'sysfs.h',\n>      'thread.h',\n>      'timer.h',\n> diff --git a/include/libcamera/internal/sensor_database.h b/include/libcamera/internal/sensor_database.h\n> new file mode 100644\n> index 000000000000..b7d3a6e7468e\n> --- /dev/null\n> +++ b/include/libcamera/internal/sensor_database.h\n> @@ -0,0 +1,37 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2020, Google Inc.\n> + *\n> + * sensor_database.h - Database of camera sensor properties\n> + */\n> +#ifndef __LIBCAMERA_SENSOR_DATABASE_H__\n> +#define __LIBCAMERA_SENSOR_DATABASE_H__\n> +\n> +#include <initializer_list>\n> +#include <unordered_map>\n> +\n> +#include <libcamera/controls.h>\n> +#include <libcamera/geometry.h>\n> +\n> +namespace libcamera {\n> +\n> +class SensorDatabase : private std::unordered_map<std::string, const ControlList>\n> +{\n> +private:\n> +\tusing Map = std::unordered_map<std::string, const ControlList>;\n> +\n> +public:\n> +\tSensorDatabase(std::initializer_list<Map::value_type> items)\n> +\t\t: Map(items)\n> +\t{\n> +\t}\n> +\n> +\tbool contains(Map::key_type sensor) const;\n> +\tconst ControlList &properties(Map::key_type sensor) const;\n\nShould both functions take a const reference as argument ?\n\n> +};\n> +\n> +extern const SensorDatabase sensorDatabase;\n\nTo reduce the exposure of details to the outside of this class, what\nwould you think of\n\nclass SensorDatabase \n{\npublic:\n\tstatic bool contains(const std::string &model);\n\tstatic const ControlList &properties(const std::string &model);\n};\n\n? Everything else could be moved from the header file to the .cpp file.\nNo instance would need to be created, the functions could operate on a\nstatic map.\n\n> +\n> +} /* namespace libcamera */\n> +\n> +#endif /* __LIBCAMERA_SENSOR_DATABASE_H__ */\n> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> index 387d5d88ecae..54f3b81ad7b2 100644\n> --- a/src/libcamera/meson.build\n> +++ b/src/libcamera/meson.build\n> @@ -41,6 +41,7 @@ libcamera_sources = files([\n>      'pub_key.cpp',\n>      'request.cpp',\n>      'semaphore.cpp',\n> +    'sensor_database.cpp',\n>      'signal.cpp',\n>      'stream.cpp',\n>      'sysfs.cpp',\n> diff --git a/src/libcamera/sensor_database.cpp b/src/libcamera/sensor_database.cpp\n> new file mode 100644\n> index 000000000000..b90eb45ed46d\n> --- /dev/null\n> +++ b/src/libcamera/sensor_database.cpp\n> @@ -0,0 +1,106 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2020, Google Inc.\n> + *\n> + * sensor_database.cpp - Database of camera sensor properties\n> + */\n> +\n> +#include \"libcamera/internal/sensor_database.h\"\n> +\n> +#include <libcamera/property_ids.h>\n> +\n> +namespace libcamera {\n> +\n> +/**\n> + * \\file sensor_database.h\n> + * \\brief Database of camera sensor properties\n> + *\n> + * The camera sensor database collects information on camera sensors\n> + * which is not possible or desirable to retrieve at run-time.\n> + */\n> +\n> +/**\n> + * \\class SensorDatabase\n> + * \\brief Database of camera sensor properties\n> + *\n> + * The database is indexed using the camera sensor model, as reported by the\n> + * properties::Model property, and for each supported sensor it contains a\n> + * list of properties.\n> + *\n> + * The database is statically allocated and cannot be modified at runtime, and\n> + * only provides two methods: one to verify if a sensor is supported\n> + * (SensorDatabase::contains()) and one to retrieve the sensor properties\n> + * (SensorDatabase::properties()).\n> + */\n> +\n> +/**\n> + * \\fn SensorDatabase::SensorDatabase(std::initializer_list<Map::value_type> items)\n> + * \\brief Contruct the sensor database with a list of sensor properties\n> + * \\param[in] items The list of sensor properties\n> + */\n> +\n> +/**\n> + * \\brief Verify if a sensor is part of the database\n> + * \\param sensor The sensor model name\n> + * \\return True if the sensor has an associated list of properties in the\n> + * database, false otherwise\n> + */\n> +bool SensorDatabase::contains(Map::key_type sensor) const\n> +{\n> +\treturn Map::find(sensor) != Map::end();\n> +}\n> +\n> +/**\n> + * \\brief Retrieve the properties associated with a sensor\n> + * \\param sensor The sensor model name\n> + * \\return The properties list associated with a sensor or an empty list if the\n> + * sensor is not supported\n> + */\n> +const ControlList &SensorDatabase::properties(Map::key_type sensor) const\n> +{\n> +\tstatic ControlList empty{};\n> +\n> +\tauto it = Map::find(sensor);\n> +\tif (it != Map::end())\n> +\t\treturn it->second;\n> +\n> +\treturn empty;\n> +}\n> +\n> +/**\n> + * \\brief Sony IMX219 sensor properties\n> + */\n> +extern const ControlList imx219Properties = {\n> +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 5.095, 4.93 }) },\n> +\t{ &properties::UnitCellSize, Size(1120, 1120) },\n> +};\n> +\n> +/**\n> + * \\brief Omnivision ov5670 sensor properties\n> + */\n> +extern const ControlList ov5670Properties = {\n> +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 2.9457, 2.214 }) },\n> +\t{ &properties::UnitCellSize, Size(1120, 1120) }\n> +};\n> +\n> +/**\n> + * \\brief Omnivision 13858 sensor properties\n> + */\n> +extern const ControlList ov13858Properties = {\n> +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 4.7497, 3.53549 }) },\n> +\t{ &properties::UnitCellSize, Size(1120, 1120) }\n> +};\n\nWe'll probably need a mechanism to ensure that all properties are\nincluded for all sensors, but that can come later.\n\n> +\n> +#define SENSOR_ENTRY(_sensor)\t\\\n> +\t{ #_sensor, _sensor ## Properties }\n> +\n> +/**\n> + * \\brief Database of sensor properties\n> + */\n> +extern const SensorDatabase sensorDatabase = {\n> +\tSENSOR_ENTRY(imx219),\n> +\tSENSOR_ENTRY(ov5670),\n> +\tSENSOR_ENTRY(ov13858),\n> +};\n> +\n> +} /* namespace libcamera */","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5278DC0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Dec 2020 05:49:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C5809615AC;\n\tWed, 23 Dec 2020 06:49:55 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F100560320\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Dec 2020 06:49:54 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 53BFCA32;\n\tWed, 23 Dec 2020 06:49:54 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"BWWLdBOq\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1608702594;\n\tbh=F8CdNISx9k1y/g+eD0QuXLlxNcd5SAvLr0rN4JTBTa4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=BWWLdBOqv76+IMihxNyGhV10NhtanTO4zxonYAhedmMVpbxGaEODkAqUIzyPQrfQo\n\tbfTbaOo8q+sreJ9V+xuENy9w5YQDiczF726p2uuux7M5ICu6odfwhnkujZ1+LSlSBJ\n\tuCHxz/r2HrBZ5gtesI71BwQGA+UM5JNNrQh8G4Aw=","Date":"Wed, 23 Dec 2020 07:49:46 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<X+Laeg4D0LMPJQV8@pendragon.ideasonboard.com>","References":"<20201218164754.81422-1-jacopo@jmondi.org>\n\t<20201218164754.81422-8-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201218164754.81422-8-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v2 7/9] libcamera: Introduce camera\n\tsensor database","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":14319,"web_url":"https://patchwork.libcamera.org/comment/14319/","msgid":"<X+LqDdwawvpEvzDc@pendragon.ideasonboard.com>","date":"2020-12-23T06:56:13","subject":"Re: [libcamera-devel] [PATCH v2 7/9] libcamera: Introduce camera\n\tsensor database","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nAnother comment.\n\nOn Wed, Dec 23, 2020 at 07:49:46AM +0200, Laurent Pinchart wrote:\n> Hi Jacopo,\n> On Fri, Dec 18, 2020 at 05:47:52PM +0100, Jacopo Mondi wrote:\n> \n> Thank you for the patch.\n> \n> > Introduce a 'database' of camera sensor information, which contains\n> > a list of camera sensor properties which is not possible, or desirable,\n> > to retrieve at run-time.\n> > \n> > The camera sensor database is a global read-only library object.\n> > \n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  include/libcamera/internal/meson.build       |   1 +\n> >  include/libcamera/internal/sensor_database.h |  37 +++++++\n> >  src/libcamera/meson.build                    |   1 +\n> >  src/libcamera/sensor_database.cpp            | 106 +++++++++++++++++++\n> >  4 files changed, 145 insertions(+)\n> >  create mode 100644 include/libcamera/internal/sensor_database.h\n> >  create mode 100644 src/libcamera/sensor_database.cpp\n> > \n> > diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\n> > index 7cde023f7c3a..ac08f0761238 100644\n> > --- a/include/libcamera/internal/meson.build\n> > +++ b/include/libcamera/internal/meson.build\n> > @@ -36,6 +36,7 @@ libcamera_internal_headers = files([\n> >      'process.h',\n> >      'pub_key.h',\n> >      'semaphore.h',\n> > +    'sensor_database.h',\n> >      'sysfs.h',\n> >      'thread.h',\n> >      'timer.h',\n> > diff --git a/include/libcamera/internal/sensor_database.h b/include/libcamera/internal/sensor_database.h\n> > new file mode 100644\n> > index 000000000000..b7d3a6e7468e\n> > --- /dev/null\n> > +++ b/include/libcamera/internal/sensor_database.h\n> > @@ -0,0 +1,37 @@\n> > +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> > +/*\n> > + * Copyright (C) 2020, Google Inc.\n> > + *\n> > + * sensor_database.h - Database of camera sensor properties\n> > + */\n> > +#ifndef __LIBCAMERA_SENSOR_DATABASE_H__\n> > +#define __LIBCAMERA_SENSOR_DATABASE_H__\n> > +\n> > +#include <initializer_list>\n> > +#include <unordered_map>\n> > +\n> > +#include <libcamera/controls.h>\n> > +#include <libcamera/geometry.h>\n> > +\n> > +namespace libcamera {\n> > +\n> > +class SensorDatabase : private std::unordered_map<std::string, const ControlList>\n> > +{\n> > +private:\n> > +\tusing Map = std::unordered_map<std::string, const ControlList>;\n> > +\n> > +public:\n> > +\tSensorDatabase(std::initializer_list<Map::value_type> items)\n> > +\t\t: Map(items)\n> > +\t{\n> > +\t}\n> > +\n> > +\tbool contains(Map::key_type sensor) const;\n> > +\tconst ControlList &properties(Map::key_type sensor) const;\n> \n> Should both functions take a const reference as argument ?\n> \n> > +};\n> > +\n> > +extern const SensorDatabase sensorDatabase;\n> \n> To reduce the exposure of details to the outside of this class, what\n> would you think of\n> \n> class SensorDatabase \n> {\n> public:\n> \tstatic bool contains(const std::string &model);\n> \tstatic const ControlList &properties(const std::string &model);\n> };\n> \n> ? Everything else could be moved from the header file to the .cpp file.\n> No instance would need to be created, the functions could operate on a\n> static map.\n\nI wonder if the sensor database should actually expose a ControList, or\nif we should use a custom structure instead. One of my short term goals\nwith this is to move the sensor static information stored in the RPi\nIPA, and there are no corresponding libcamera properties.\n\n> > +\n> > +} /* namespace libcamera */\n> > +\n> > +#endif /* __LIBCAMERA_SENSOR_DATABASE_H__ */\n> > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> > index 387d5d88ecae..54f3b81ad7b2 100644\n> > --- a/src/libcamera/meson.build\n> > +++ b/src/libcamera/meson.build\n> > @@ -41,6 +41,7 @@ libcamera_sources = files([\n> >      'pub_key.cpp',\n> >      'request.cpp',\n> >      'semaphore.cpp',\n> > +    'sensor_database.cpp',\n> >      'signal.cpp',\n> >      'stream.cpp',\n> >      'sysfs.cpp',\n> > diff --git a/src/libcamera/sensor_database.cpp b/src/libcamera/sensor_database.cpp\n> > new file mode 100644\n> > index 000000000000..b90eb45ed46d\n> > --- /dev/null\n> > +++ b/src/libcamera/sensor_database.cpp\n> > @@ -0,0 +1,106 @@\n> > +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> > +/*\n> > + * Copyright (C) 2020, Google Inc.\n> > + *\n> > + * sensor_database.cpp - Database of camera sensor properties\n> > + */\n> > +\n> > +#include \"libcamera/internal/sensor_database.h\"\n> > +\n> > +#include <libcamera/property_ids.h>\n> > +\n> > +namespace libcamera {\n> > +\n> > +/**\n> > + * \\file sensor_database.h\n> > + * \\brief Database of camera sensor properties\n> > + *\n> > + * The camera sensor database collects information on camera sensors\n> > + * which is not possible or desirable to retrieve at run-time.\n> > + */\n> > +\n> > +/**\n> > + * \\class SensorDatabase\n> > + * \\brief Database of camera sensor properties\n> > + *\n> > + * The database is indexed using the camera sensor model, as reported by the\n> > + * properties::Model property, and for each supported sensor it contains a\n> > + * list of properties.\n> > + *\n> > + * The database is statically allocated and cannot be modified at runtime, and\n> > + * only provides two methods: one to verify if a sensor is supported\n> > + * (SensorDatabase::contains()) and one to retrieve the sensor properties\n> > + * (SensorDatabase::properties()).\n> > + */\n> > +\n> > +/**\n> > + * \\fn SensorDatabase::SensorDatabase(std::initializer_list<Map::value_type> items)\n> > + * \\brief Contruct the sensor database with a list of sensor properties\n> > + * \\param[in] items The list of sensor properties\n> > + */\n> > +\n> > +/**\n> > + * \\brief Verify if a sensor is part of the database\n> > + * \\param sensor The sensor model name\n> > + * \\return True if the sensor has an associated list of properties in the\n> > + * database, false otherwise\n> > + */\n> > +bool SensorDatabase::contains(Map::key_type sensor) const\n> > +{\n> > +\treturn Map::find(sensor) != Map::end();\n> > +}\n> > +\n> > +/**\n> > + * \\brief Retrieve the properties associated with a sensor\n> > + * \\param sensor The sensor model name\n> > + * \\return The properties list associated with a sensor or an empty list if the\n> > + * sensor is not supported\n> > + */\n> > +const ControlList &SensorDatabase::properties(Map::key_type sensor) const\n> > +{\n> > +\tstatic ControlList empty{};\n> > +\n> > +\tauto it = Map::find(sensor);\n> > +\tif (it != Map::end())\n> > +\t\treturn it->second;\n> > +\n> > +\treturn empty;\n> > +}\n> > +\n> > +/**\n> > + * \\brief Sony IMX219 sensor properties\n> > + */\n> > +extern const ControlList imx219Properties = {\n> > +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 5.095, 4.93 }) },\n> > +\t{ &properties::UnitCellSize, Size(1120, 1120) },\n> > +};\n> > +\n> > +/**\n> > + * \\brief Omnivision ov5670 sensor properties\n> > + */\n> > +extern const ControlList ov5670Properties = {\n> > +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 2.9457, 2.214 }) },\n> > +\t{ &properties::UnitCellSize, Size(1120, 1120) }\n> > +};\n> > +\n> > +/**\n> > + * \\brief Omnivision 13858 sensor properties\n> > + */\n> > +extern const ControlList ov13858Properties = {\n> > +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 4.7497, 3.53549 }) },\n> > +\t{ &properties::UnitCellSize, Size(1120, 1120) }\n> > +};\n> \n> We'll probably need a mechanism to ensure that all properties are\n> included for all sensors, but that can come later.\n> \n> > +\n> > +#define SENSOR_ENTRY(_sensor)\t\\\n> > +\t{ #_sensor, _sensor ## Properties }\n> > +\n> > +/**\n> > + * \\brief Database of sensor properties\n> > + */\n> > +extern const SensorDatabase sensorDatabase = {\n> > +\tSENSOR_ENTRY(imx219),\n> > +\tSENSOR_ENTRY(ov5670),\n> > +\tSENSOR_ENTRY(ov13858),\n> > +};\n> > +\n> > +} /* namespace libcamera */","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 99905C0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Dec 2020 06:56:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8DBA8615AC;\n\tWed, 23 Dec 2020 07:56:23 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4716C60320\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Dec 2020 07:56:22 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B0AE7A32;\n\tWed, 23 Dec 2020 07:56:21 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"BABvrioG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1608706581;\n\tbh=yh2th8x/ssjfb8TmkmnV49LDVMHVvTLcJjBNDrwzx+A=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=BABvrioGZeIW2U5MSY+P8HZxPLCJH+05Tl2KvZXc7NTtj8LBcvt6VnUgBLegEqN5y\n\txJ3tg4UStePljYlPRUVMnYXVOfPpubNsdKLgpUbiMN9Qg8s5RJHNKl3+GurMJofBD0\n\tH+m+9nQ1Clu7rWWnV0lSV05rNqT/MgjsmYv+tCvE=","Date":"Wed, 23 Dec 2020 08:56:13 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<X+LqDdwawvpEvzDc@pendragon.ideasonboard.com>","References":"<20201218164754.81422-1-jacopo@jmondi.org>\n\t<20201218164754.81422-8-jacopo@jmondi.org>\n\t<X+Laeg4D0LMPJQV8@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<X+Laeg4D0LMPJQV8@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 7/9] libcamera: Introduce camera\n\tsensor database","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":14322,"web_url":"https://patchwork.libcamera.org/comment/14322/","msgid":"<20201223164001.k4zkkapb7s5yvni3@uno.localdomain>","date":"2020-12-23T16:40:01","subject":"Re: [libcamera-devel] [PATCH v2 7/9] libcamera: Introduce camera\n\tsensor database","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Wed, Dec 23, 2020 at 08:56:13AM +0200, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> Another comment.\n>\n> On Wed, Dec 23, 2020 at 07:49:46AM +0200, Laurent Pinchart wrote:\n> > Hi Jacopo,\n> > On Fri, Dec 18, 2020 at 05:47:52PM +0100, Jacopo Mondi wrote:\n> >\n> > Thank you for the patch.\n> >\n> > > Introduce a 'database' of camera sensor information, which contains\n> > > a list of camera sensor properties which is not possible, or desirable,\n> > > to retrieve at run-time.\n> > >\n> > > The camera sensor database is a global read-only library object.\n> > >\n> > > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > > ---\n> > >  include/libcamera/internal/meson.build       |   1 +\n> > >  include/libcamera/internal/sensor_database.h |  37 +++++++\n> > >  src/libcamera/meson.build                    |   1 +\n> > >  src/libcamera/sensor_database.cpp            | 106 +++++++++++++++++++\n> > >  4 files changed, 145 insertions(+)\n> > >  create mode 100644 include/libcamera/internal/sensor_database.h\n> > >  create mode 100644 src/libcamera/sensor_database.cpp\n> > >\n> > > diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\n> > > index 7cde023f7c3a..ac08f0761238 100644\n> > > --- a/include/libcamera/internal/meson.build\n> > > +++ b/include/libcamera/internal/meson.build\n> > > @@ -36,6 +36,7 @@ libcamera_internal_headers = files([\n> > >      'process.h',\n> > >      'pub_key.h',\n> > >      'semaphore.h',\n> > > +    'sensor_database.h',\n> > >      'sysfs.h',\n> > >      'thread.h',\n> > >      'timer.h',\n> > > diff --git a/include/libcamera/internal/sensor_database.h b/include/libcamera/internal/sensor_database.h\n> > > new file mode 100644\n> > > index 000000000000..b7d3a6e7468e\n> > > --- /dev/null\n> > > +++ b/include/libcamera/internal/sensor_database.h\n> > > @@ -0,0 +1,37 @@\n> > > +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> > > +/*\n> > > + * Copyright (C) 2020, Google Inc.\n> > > + *\n> > > + * sensor_database.h - Database of camera sensor properties\n> > > + */\n> > > +#ifndef __LIBCAMERA_SENSOR_DATABASE_H__\n> > > +#define __LIBCAMERA_SENSOR_DATABASE_H__\n> > > +\n> > > +#include <initializer_list>\n> > > +#include <unordered_map>\n> > > +\n> > > +#include <libcamera/controls.h>\n> > > +#include <libcamera/geometry.h>\n> > > +\n> > > +namespace libcamera {\n> > > +\n> > > +class SensorDatabase : private std::unordered_map<std::string, const ControlList>\n> > > +{\n> > > +private:\n> > > +\tusing Map = std::unordered_map<std::string, const ControlList>;\n> > > +\n> > > +public:\n> > > +\tSensorDatabase(std::initializer_list<Map::value_type> items)\n> > > +\t\t: Map(items)\n> > > +\t{\n> > > +\t}\n> > > +\n> > > +\tbool contains(Map::key_type sensor) const;\n> > > +\tconst ControlList &properties(Map::key_type sensor) const;\n> >\n> > Should both functions take a const reference as argument ?\n> >\n> > > +};\n> > > +\n> > > +extern const SensorDatabase sensorDatabase;\n> >\n> > To reduce the exposure of details to the outside of this class, what\n> > would you think of\n> >\n> > class SensorDatabase\n> > {\n> > public:\n> > \tstatic bool contains(const std::string &model);\n> > \tstatic const ControlList &properties(const std::string &model);\n> > };\n> >\n> > ? Everything else could be moved from the header file to the .cpp file.\n> > No instance would need to be created, the functions could operate on a\n> > static map.\n>\n> I wonder if the sensor database should actually expose a ControList, or\n> if we should use a custom structure instead. One of my short term goals\n> with this is to move the sensor static information stored in the RPi\n> IPA, and there are no corresponding libcamera properties.\n>\n\nGood question.\n\nAre you referring to information contained in cam_helper_xxxx.cpp ?\nAre we sure that information like the number of frames to mis-trust is\nsomething that should be part of the sensor database. Ideally one\nshould be able to expand the database with only the support of the\nsensor's datasheet, am I wrong ? It seems to me that some information\nthere are implementation decision specific...\n\nThanks\n  j\n\n> > > +\n> > > +} /* namespace libcamera */\n> > > +\n> > > +#endif /* __LIBCAMERA_SENSOR_DATABASE_H__ */\n> > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> > > index 387d5d88ecae..54f3b81ad7b2 100644\n> > > --- a/src/libcamera/meson.build\n> > > +++ b/src/libcamera/meson.build\n> > > @@ -41,6 +41,7 @@ libcamera_sources = files([\n> > >      'pub_key.cpp',\n> > >      'request.cpp',\n> > >      'semaphore.cpp',\n> > > +    'sensor_database.cpp',\n> > >      'signal.cpp',\n> > >      'stream.cpp',\n> > >      'sysfs.cpp',\n> > > diff --git a/src/libcamera/sensor_database.cpp b/src/libcamera/sensor_database.cpp\n> > > new file mode 100644\n> > > index 000000000000..b90eb45ed46d\n> > > --- /dev/null\n> > > +++ b/src/libcamera/sensor_database.cpp\n> > > @@ -0,0 +1,106 @@\n> > > +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> > > +/*\n> > > + * Copyright (C) 2020, Google Inc.\n> > > + *\n> > > + * sensor_database.cpp - Database of camera sensor properties\n> > > + */\n> > > +\n> > > +#include \"libcamera/internal/sensor_database.h\"\n> > > +\n> > > +#include <libcamera/property_ids.h>\n> > > +\n> > > +namespace libcamera {\n> > > +\n> > > +/**\n> > > + * \\file sensor_database.h\n> > > + * \\brief Database of camera sensor properties\n> > > + *\n> > > + * The camera sensor database collects information on camera sensors\n> > > + * which is not possible or desirable to retrieve at run-time.\n> > > + */\n> > > +\n> > > +/**\n> > > + * \\class SensorDatabase\n> > > + * \\brief Database of camera sensor properties\n> > > + *\n> > > + * The database is indexed using the camera sensor model, as reported by the\n> > > + * properties::Model property, and for each supported sensor it contains a\n> > > + * list of properties.\n> > > + *\n> > > + * The database is statically allocated and cannot be modified at runtime, and\n> > > + * only provides two methods: one to verify if a sensor is supported\n> > > + * (SensorDatabase::contains()) and one to retrieve the sensor properties\n> > > + * (SensorDatabase::properties()).\n> > > + */\n> > > +\n> > > +/**\n> > > + * \\fn SensorDatabase::SensorDatabase(std::initializer_list<Map::value_type> items)\n> > > + * \\brief Contruct the sensor database with a list of sensor properties\n> > > + * \\param[in] items The list of sensor properties\n> > > + */\n> > > +\n> > > +/**\n> > > + * \\brief Verify if a sensor is part of the database\n> > > + * \\param sensor The sensor model name\n> > > + * \\return True if the sensor has an associated list of properties in the\n> > > + * database, false otherwise\n> > > + */\n> > > +bool SensorDatabase::contains(Map::key_type sensor) const\n> > > +{\n> > > +\treturn Map::find(sensor) != Map::end();\n> > > +}\n> > > +\n> > > +/**\n> > > + * \\brief Retrieve the properties associated with a sensor\n> > > + * \\param sensor The sensor model name\n> > > + * \\return The properties list associated with a sensor or an empty list if the\n> > > + * sensor is not supported\n> > > + */\n> > > +const ControlList &SensorDatabase::properties(Map::key_type sensor) const\n> > > +{\n> > > +\tstatic ControlList empty{};\n> > > +\n> > > +\tauto it = Map::find(sensor);\n> > > +\tif (it != Map::end())\n> > > +\t\treturn it->second;\n> > > +\n> > > +\treturn empty;\n> > > +}\n> > > +\n> > > +/**\n> > > + * \\brief Sony IMX219 sensor properties\n> > > + */\n> > > +extern const ControlList imx219Properties = {\n> > > +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 5.095, 4.93 }) },\n> > > +\t{ &properties::UnitCellSize, Size(1120, 1120) },\n> > > +};\n> > > +\n> > > +/**\n> > > + * \\brief Omnivision ov5670 sensor properties\n> > > + */\n> > > +extern const ControlList ov5670Properties = {\n> > > +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 2.9457, 2.214 }) },\n> > > +\t{ &properties::UnitCellSize, Size(1120, 1120) }\n> > > +};\n> > > +\n> > > +/**\n> > > + * \\brief Omnivision 13858 sensor properties\n> > > + */\n> > > +extern const ControlList ov13858Properties = {\n> > > +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 4.7497, 3.53549 }) },\n> > > +\t{ &properties::UnitCellSize, Size(1120, 1120) }\n> > > +};\n> >\n> > We'll probably need a mechanism to ensure that all properties are\n> > included for all sensors, but that can come later.\n> >\n> > > +\n> > > +#define SENSOR_ENTRY(_sensor)\t\\\n> > > +\t{ #_sensor, _sensor ## Properties }\n> > > +\n> > > +/**\n> > > + * \\brief Database of sensor properties\n> > > + */\n> > > +extern const SensorDatabase sensorDatabase = {\n> > > +\tSENSOR_ENTRY(imx219),\n> > > +\tSENSOR_ENTRY(ov5670),\n> > > +\tSENSOR_ENTRY(ov13858),\n> > > +};\n> > > +\n> > > +} /* namespace libcamera */\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 49051C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Dec 2020 16:39:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B2EEB615B0;\n\tWed, 23 Dec 2020 17:39:50 +0100 (CET)","from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C03C660527\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Dec 2020 17:39:49 +0100 (CET)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 38247FF80C;\n\tWed, 23 Dec 2020 16:39:48 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Wed, 23 Dec 2020 17:40:01 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20201223164001.k4zkkapb7s5yvni3@uno.localdomain>","References":"<20201218164754.81422-1-jacopo@jmondi.org>\n\t<20201218164754.81422-8-jacopo@jmondi.org>\n\t<X+Laeg4D0LMPJQV8@pendragon.ideasonboard.com>\n\t<X+LqDdwawvpEvzDc@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<X+LqDdwawvpEvzDc@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 7/9] libcamera: Introduce camera\n\tsensor database","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":14325,"web_url":"https://patchwork.libcamera.org/comment/14325/","msgid":"<X+OA9JbPXLHrCyNQ@pendragon.ideasonboard.com>","date":"2020-12-23T17:40:04","subject":"Re: [libcamera-devel] [PATCH v2 7/9] libcamera: Introduce camera\n\tsensor database","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Wed, Dec 23, 2020 at 05:40:01PM +0100, Jacopo Mondi wrote:\n> On Wed, Dec 23, 2020 at 08:56:13AM +0200, Laurent Pinchart wrote:\n> > On Wed, Dec 23, 2020 at 07:49:46AM +0200, Laurent Pinchart wrote:\n> > > On Fri, Dec 18, 2020 at 05:47:52PM +0100, Jacopo Mondi wrote:\n> > > > Introduce a 'database' of camera sensor information, which contains\n> > > > a list of camera sensor properties which is not possible, or desirable,\n> > > > to retrieve at run-time.\n> > > >\n> > > > The camera sensor database is a global read-only library object.\n> > > >\n> > > > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > > > ---\n> > > >  include/libcamera/internal/meson.build       |   1 +\n> > > >  include/libcamera/internal/sensor_database.h |  37 +++++++\n> > > >  src/libcamera/meson.build                    |   1 +\n> > > >  src/libcamera/sensor_database.cpp            | 106 +++++++++++++++++++\n> > > >  4 files changed, 145 insertions(+)\n> > > >  create mode 100644 include/libcamera/internal/sensor_database.h\n> > > >  create mode 100644 src/libcamera/sensor_database.cpp\n> > > >\n> > > > diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\n> > > > index 7cde023f7c3a..ac08f0761238 100644\n> > > > --- a/include/libcamera/internal/meson.build\n> > > > +++ b/include/libcamera/internal/meson.build\n> > > > @@ -36,6 +36,7 @@ libcamera_internal_headers = files([\n> > > >      'process.h',\n> > > >      'pub_key.h',\n> > > >      'semaphore.h',\n> > > > +    'sensor_database.h',\n> > > >      'sysfs.h',\n> > > >      'thread.h',\n> > > >      'timer.h',\n> > > > diff --git a/include/libcamera/internal/sensor_database.h b/include/libcamera/internal/sensor_database.h\n> > > > new file mode 100644\n> > > > index 000000000000..b7d3a6e7468e\n> > > > --- /dev/null\n> > > > +++ b/include/libcamera/internal/sensor_database.h\n> > > > @@ -0,0 +1,37 @@\n> > > > +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> > > > +/*\n> > > > + * Copyright (C) 2020, Google Inc.\n> > > > + *\n> > > > + * sensor_database.h - Database of camera sensor properties\n> > > > + */\n> > > > +#ifndef __LIBCAMERA_SENSOR_DATABASE_H__\n> > > > +#define __LIBCAMERA_SENSOR_DATABASE_H__\n> > > > +\n> > > > +#include <initializer_list>\n> > > > +#include <unordered_map>\n> > > > +\n> > > > +#include <libcamera/controls.h>\n> > > > +#include <libcamera/geometry.h>\n> > > > +\n> > > > +namespace libcamera {\n> > > > +\n> > > > +class SensorDatabase : private std::unordered_map<std::string, const ControlList>\n> > > > +{\n> > > > +private:\n> > > > +\tusing Map = std::unordered_map<std::string, const ControlList>;\n> > > > +\n> > > > +public:\n> > > > +\tSensorDatabase(std::initializer_list<Map::value_type> items)\n> > > > +\t\t: Map(items)\n> > > > +\t{\n> > > > +\t}\n> > > > +\n> > > > +\tbool contains(Map::key_type sensor) const;\n> > > > +\tconst ControlList &properties(Map::key_type sensor) const;\n> > >\n> > > Should both functions take a const reference as argument ?\n> > >\n> > > > +};\n> > > > +\n> > > > +extern const SensorDatabase sensorDatabase;\n> > >\n> > > To reduce the exposure of details to the outside of this class, what\n> > > would you think of\n> > >\n> > > class SensorDatabase\n> > > {\n> > > public:\n> > > \tstatic bool contains(const std::string &model);\n> > > \tstatic const ControlList &properties(const std::string &model);\n> > > };\n> > >\n> > > ? Everything else could be moved from the header file to the .cpp file.\n> > > No instance would need to be created, the functions could operate on a\n> > > static map.\n> >\n> > I wonder if the sensor database should actually expose a ControList, or\n> > if we should use a custom structure instead. One of my short term goals\n> > with this is to move the sensor static information stored in the RPi\n> > IPA, and there are no corresponding libcamera properties.\n> >\n> \n> Good question.\n> \n> Are you referring to information contained in cam_helper_xxxx.cpp ?\n> Are we sure that information like the number of frames to mis-trust is\n> something that should be part of the sensor database. Ideally one\n> should be able to expand the database with only the support of the\n> sensor's datasheet, am I wrong ? It seems to me that some information\n> there are implementation decision specific...\n\nIt was very implementation-specific, but with David's recent rework of\nthe AGC and AWB algorithms, the information exposed by the CamHelper\nclass has been refactored. It now only carries intrinsic properties of\nthe camera sensor, with the decision on how to use that information\nmoved to the IPA itself.\n\n> > > > +\n> > > > +} /* namespace libcamera */\n> > > > +\n> > > > +#endif /* __LIBCAMERA_SENSOR_DATABASE_H__ */\n> > > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> > > > index 387d5d88ecae..54f3b81ad7b2 100644\n> > > > --- a/src/libcamera/meson.build\n> > > > +++ b/src/libcamera/meson.build\n> > > > @@ -41,6 +41,7 @@ libcamera_sources = files([\n> > > >      'pub_key.cpp',\n> > > >      'request.cpp',\n> > > >      'semaphore.cpp',\n> > > > +    'sensor_database.cpp',\n> > > >      'signal.cpp',\n> > > >      'stream.cpp',\n> > > >      'sysfs.cpp',\n> > > > diff --git a/src/libcamera/sensor_database.cpp b/src/libcamera/sensor_database.cpp\n> > > > new file mode 100644\n> > > > index 000000000000..b90eb45ed46d\n> > > > --- /dev/null\n> > > > +++ b/src/libcamera/sensor_database.cpp\n> > > > @@ -0,0 +1,106 @@\n> > > > +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> > > > +/*\n> > > > + * Copyright (C) 2020, Google Inc.\n> > > > + *\n> > > > + * sensor_database.cpp - Database of camera sensor properties\n> > > > + */\n> > > > +\n> > > > +#include \"libcamera/internal/sensor_database.h\"\n> > > > +\n> > > > +#include <libcamera/property_ids.h>\n> > > > +\n> > > > +namespace libcamera {\n> > > > +\n> > > > +/**\n> > > > + * \\file sensor_database.h\n> > > > + * \\brief Database of camera sensor properties\n> > > > + *\n> > > > + * The camera sensor database collects information on camera sensors\n> > > > + * which is not possible or desirable to retrieve at run-time.\n> > > > + */\n> > > > +\n> > > > +/**\n> > > > + * \\class SensorDatabase\n> > > > + * \\brief Database of camera sensor properties\n> > > > + *\n> > > > + * The database is indexed using the camera sensor model, as reported by the\n> > > > + * properties::Model property, and for each supported sensor it contains a\n> > > > + * list of properties.\n> > > > + *\n> > > > + * The database is statically allocated and cannot be modified at runtime, and\n> > > > + * only provides two methods: one to verify if a sensor is supported\n> > > > + * (SensorDatabase::contains()) and one to retrieve the sensor properties\n> > > > + * (SensorDatabase::properties()).\n> > > > + */\n> > > > +\n> > > > +/**\n> > > > + * \\fn SensorDatabase::SensorDatabase(std::initializer_list<Map::value_type> items)\n> > > > + * \\brief Contruct the sensor database with a list of sensor properties\n> > > > + * \\param[in] items The list of sensor properties\n> > > > + */\n> > > > +\n> > > > +/**\n> > > > + * \\brief Verify if a sensor is part of the database\n> > > > + * \\param sensor The sensor model name\n> > > > + * \\return True if the sensor has an associated list of properties in the\n> > > > + * database, false otherwise\n> > > > + */\n> > > > +bool SensorDatabase::contains(Map::key_type sensor) const\n> > > > +{\n> > > > +\treturn Map::find(sensor) != Map::end();\n> > > > +}\n> > > > +\n> > > > +/**\n> > > > + * \\brief Retrieve the properties associated with a sensor\n> > > > + * \\param sensor The sensor model name\n> > > > + * \\return The properties list associated with a sensor or an empty list if the\n> > > > + * sensor is not supported\n> > > > + */\n> > > > +const ControlList &SensorDatabase::properties(Map::key_type sensor) const\n> > > > +{\n> > > > +\tstatic ControlList empty{};\n> > > > +\n> > > > +\tauto it = Map::find(sensor);\n> > > > +\tif (it != Map::end())\n> > > > +\t\treturn it->second;\n> > > > +\n> > > > +\treturn empty;\n> > > > +}\n> > > > +\n> > > > +/**\n> > > > + * \\brief Sony IMX219 sensor properties\n> > > > + */\n> > > > +extern const ControlList imx219Properties = {\n> > > > +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 5.095, 4.93 }) },\n> > > > +\t{ &properties::UnitCellSize, Size(1120, 1120) },\n> > > > +};\n> > > > +\n> > > > +/**\n> > > > + * \\brief Omnivision ov5670 sensor properties\n> > > > + */\n> > > > +extern const ControlList ov5670Properties = {\n> > > > +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 2.9457, 2.214 }) },\n> > > > +\t{ &properties::UnitCellSize, Size(1120, 1120) }\n> > > > +};\n> > > > +\n> > > > +/**\n> > > > + * \\brief Omnivision 13858 sensor properties\n> > > > + */\n> > > > +extern const ControlList ov13858Properties = {\n> > > > +\t{ &properties::draft::SensorPhysicalSize, Span<const float>({ 4.7497, 3.53549 }) },\n> > > > +\t{ &properties::UnitCellSize, Size(1120, 1120) }\n> > > > +};\n> > >\n> > > We'll probably need a mechanism to ensure that all properties are\n> > > included for all sensors, but that can come later.\n> > >\n> > > > +\n> > > > +#define SENSOR_ENTRY(_sensor)\t\\\n> > > > +\t{ #_sensor, _sensor ## Properties }\n> > > > +\n> > > > +/**\n> > > > + * \\brief Database of sensor properties\n> > > > + */\n> > > > +extern const SensorDatabase sensorDatabase = {\n> > > > +\tSENSOR_ENTRY(imx219),\n> > > > +\tSENSOR_ENTRY(ov5670),\n> > > > +\tSENSOR_ENTRY(ov13858),\n> > > > +};\n> > > > +\n> > > > +} /* namespace libcamera */","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9E670C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Dec 2020 17:40:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 38B9560527;\n\tWed, 23 Dec 2020 18:40:14 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2DA6260527\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Dec 2020 18:40:13 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A39279E6;\n\tWed, 23 Dec 2020 18:40:12 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"gcyEJGci\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1608745212;\n\tbh=8UsM2w3FS+0GNDB6QzxQVie9DwNqwOQrsAPy3Fi/qKM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gcyEJGciCPnkx3hq4pWE5c/DMvHPNeg3Eekw2FM+syfOiPfojSzy+JiNPlxmdFskm\n\tloAkU0RTRftPJV9bJXzIt331eebRWqTLcOYRm3RBkgs9v+pTsdohLlQ9aMEPHDfu/h\n\tPnL+oBSJrc16kEMPpBh2lHw2I+bcp/aFoV/vAv0o=","Date":"Wed, 23 Dec 2020 19:40:04 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<X+OA9JbPXLHrCyNQ@pendragon.ideasonboard.com>","References":"<20201218164754.81422-1-jacopo@jmondi.org>\n\t<20201218164754.81422-8-jacopo@jmondi.org>\n\t<X+Laeg4D0LMPJQV8@pendragon.ideasonboard.com>\n\t<X+LqDdwawvpEvzDc@pendragon.ideasonboard.com>\n\t<20201223164001.k4zkkapb7s5yvni3@uno.localdomain>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201223164001.k4zkkapb7s5yvni3@uno.localdomain>","Subject":"Re: [libcamera-devel] [PATCH v2 7/9] libcamera: Introduce camera\n\tsensor database","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]