[{"id":14387,"web_url":"https://patchwork.libcamera.org/comment/14387/","msgid":"<20201229042933.GG67590@pyrite.rasen.tech>","date":"2020-12-29T04:29:33","subject":"Re: [libcamera-devel] [PATCH v3 1/4] libcamera: Introduce camera\n\tsensor database","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Mon, Dec 28, 2020 at 05:52:00PM +0100, Jacopo Mondi wrote:\n> Introduce a 'database' of camera sensor information, which contains\n> a the camera sensor properties which is not possible, or desirable,\n\ns/a //\ns/is/are/\n\n> to retrieve at run-time.\n> \n> The camera sensor database is accessed through the static SensorDatabase\n> class which provides a single method to obtain the sensor information.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  include/libcamera/internal/meson.build       |   1 +\n>  include/libcamera/internal/sensor_database.h |  28 +++++\n>  src/libcamera/meson.build                    |   1 +\n>  src/libcamera/sensor_database.cpp            | 102 +++++++++++++++++++\n>  4 files changed, 132 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 1b1bdc779512..e1f22f238a10 100644\n> --- a/include/libcamera/internal/meson.build\n> +++ b/include/libcamera/internal/meson.build\n> @@ -38,6 +38,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..e074b3029932\n> --- /dev/null\n> +++ b/include/libcamera/internal/sensor_database.h\n> @@ -0,0 +1,28 @@\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 <string>\n> +\n> +#include <libcamera/geometry.h>\n> +\n> +namespace libcamera {\n> +\n> +struct SensorInfo {\n> +\tSize unitCellSize;\n> +};\n> +\n> +class SensorDatabase\n> +{\n> +public:\n> +\tstatic const SensorInfo *get(const std::string &sensor);\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..5f8538a62388\n> --- /dev/null\n> +++ b/src/libcamera/sensor_database.cpp\n> @@ -0,0 +1,102 @@\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 <algorithm>\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 Access the 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> + * SensorInfo list of properties.\n> + *\n> + * The class provides a single static getInfo() method to access the sensor\n> + * database entries. If the sensor is not supported in the database nullptr is\n> + * returned.\n> + */\n> +\n> +/**\n> + * \\struct SensorInfo\n> + * \\brief List of sensor properties\n> + *\n> + * \\var SensorInfo::unitCellSize\n> + * \\brief The physical size of pixel, including pixel edges. Width x height in\n> + * nano-meters.\n> + */\n> +\n> +namespace {\n> +\n> +/**\n> + * \\brief Sony IMX219 sensor properties\n> + */\n> +constexpr SensorInfo imx219Info = {\n> +\t.unitCellSize = { 1120, 1120 }\n> +};\n> +\n> +/**\n> + * \\brief Omnivision ov5670 sensor properties\n> + */\n> +constexpr SensorInfo ov5670Info = {\n> +\t.unitCellSize = { 1120, 1120 }\n> +};\n> +\n> +/**\n> + * \\brief Omnivision 13858 sensor properties\n> + */\n> +constexpr SensorInfo ov13858Info = {\n> +\t.unitCellSize = { 1120, 1120 }\n> +};\n> +\n> +#define SENSOR_INFO(_sensor) \\\n> +\t{ #_sensor, &_sensor##Info }\n> +\n> +/*\n> + * \\brief The database of sensor properties\n> + */\n> +constexpr std::pair<const char *const, const SensorInfo *> sensorDatabase__[] = {\n> +\tSENSOR_INFO(imx219),\n> +\tSENSOR_INFO(ov5670),\n> +\tSENSOR_INFO(ov13858),\n> +};\n> +\n> +const SensorInfo *getInfo(const std::string &sensor)\n> +{\n> +\tfor (unsigned int i = 0; i < std::size(sensorDatabase__); ++i) {\n> +\t\tif (sensorDatabase__[i].first == sensor)\n> +\t\t\treturn sensorDatabase__[i].second;\n> +\t}\n> +\n> +\treturn nullptr;\n> +}\n> +\n> +} /* namespace */\n> +\n> +/**\n> + * \\brief Retrieve the properties associated with a sensor\n> + * \\param sensor The sensor model name\n> + * \\return A pointer to the SensorInfo instance associated with a sensor or\n> + * nullptr if the sensor is not supported in the database\n> + */\n> +const SensorInfo *SensorDatabase::get(const std::string &sensor)\n> +{\n> +\treturn getInfo(sensor);\n> +}\n> +\n> +} /* namespace libcamera */\n> -- \n> 2.29.2\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 52E6FC0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Dec 2020 04:29:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DBE99615B2;\n\tTue, 29 Dec 2020 05:29:42 +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 D79CE6031A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Dec 2020 05:29:41 +0100 (CET)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6A94498;\n\tTue, 29 Dec 2020 05:29:39 +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=\"Ibnwct39\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1609216180;\n\tbh=VwJiZ7yq1ZUPRQA72sBD9ysmykSR0fDA8ITRamdB/vk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Ibnwct39W3R/jcInJ+2c1+Id34/ZZ81cqRQRAm9CQmRickHldIJysjLXnJkQgHxZq\n\tYM6s+TSBQQfyPbF46pdcTzmh9GCbLC4897HJ6fvutfunl+Fv8niji5eL7wytqFJ/Jv\n\t1t+XzH1TZPyEEHBHwSIWBGIOupG7Mam3VQdEu+vc=","Date":"Tue, 29 Dec 2020 13:29:33 +0900","From":"paul.elder@ideasonboard.com","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20201229042933.GG67590@pyrite.rasen.tech>","References":"<20201228165203.53771-1-jacopo@jmondi.org>\n\t<20201228165203.53771-2-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201228165203.53771-2-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v3 1/4] 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":14398,"web_url":"https://patchwork.libcamera.org/comment/14398/","msgid":"<X+tlaFhjDH8xFLFE@oden.dyn.berto.se>","date":"2020-12-29T17:20:40","subject":"Re: [libcamera-devel] [PATCH v3 1/4] libcamera: Introduce camera\n\tsensor database","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your work.\n\nOn 2020-12-28 17:52:00 +0100, Jacopo Mondi wrote:\n> Introduce a 'database' of camera sensor information, which contains\n> a the camera sensor properties which is not possible, or desirable,\n> to retrieve at run-time.\n> \n> The camera sensor database is accessed through the static SensorDatabase\n> class which provides a single method to obtain the sensor information.\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 |  28 +++++\n>  src/libcamera/meson.build                    |   1 +\n>  src/libcamera/sensor_database.cpp            | 102 +++++++++++++++++++\n>  4 files changed, 132 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 1b1bdc779512..e1f22f238a10 100644\n> --- a/include/libcamera/internal/meson.build\n> +++ b/include/libcamera/internal/meson.build\n> @@ -38,6 +38,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..e074b3029932\n> --- /dev/null\n> +++ b/include/libcamera/internal/sensor_database.h\n> @@ -0,0 +1,28 @@\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 <string>\n> +\n> +#include <libcamera/geometry.h>\n> +\n> +namespace libcamera {\n> +\n> +struct SensorInfo {\n> +\tSize unitCellSize;\n> +};\n> +\n> +class SensorDatabase\n> +{\n> +public:\n> +\tstatic const SensorInfo *get(const std::string &sensor);\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..5f8538a62388\n> --- /dev/null\n> +++ b/src/libcamera/sensor_database.cpp\n> @@ -0,0 +1,102 @@\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 <algorithm>\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 Access the 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> + * SensorInfo list of properties.\n> + *\n> + * The class provides a single static getInfo() method to access the sensor\n> + * database entries. If the sensor is not supported in the database nullptr is\n> + * returned.\n> + */\n> +\n> +/**\n> + * \\struct SensorInfo\n> + * \\brief List of sensor properties\n> + *\n> + * \\var SensorInfo::unitCellSize\n> + * \\brief The physical size of pixel, including pixel edges. Width x height in\n> + * nano-meters.\n> + */\n> +\n> +namespace {\n> +\n> +/**\n> + * \\brief Sony IMX219 sensor properties\n> + */\n> +constexpr SensorInfo imx219Info = {\n> +\t.unitCellSize = { 1120, 1120 }\n> +};\n> +\n> +/**\n> + * \\brief Omnivision ov5670 sensor properties\n> + */\n> +constexpr SensorInfo ov5670Info = {\n> +\t.unitCellSize = { 1120, 1120 }\n> +};\n> +\n> +/**\n> + * \\brief Omnivision 13858 sensor properties\n> + */\n> +constexpr SensorInfo ov13858Info = {\n> +\t.unitCellSize = { 1120, 1120 }\n> +};\n> +\n> +#define SENSOR_INFO(_sensor) \\\n> +\t{ #_sensor, &_sensor##Info }\n> +\n> +/*\n> + * \\brief The database of sensor properties\n> + */\n> +constexpr std::pair<const char *const, const SensorInfo *> sensorDatabase__[] = {\n\nMaybe something for later but if model registration similar to \nREGISTER_PIPELINE_HANDLER() this could be a std::map which would improve \nlookup speeds, if we ever get a large set of sensors. But I think this \ncould be done on-top as it won't impact any users.\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> +\tSENSOR_INFO(imx219),\n> +\tSENSOR_INFO(ov5670),\n> +\tSENSOR_INFO(ov13858),\n> +};\n> +\n> +const SensorInfo *getInfo(const std::string &sensor)\n> +{\n> +\tfor (unsigned int i = 0; i < std::size(sensorDatabase__); ++i) {\n> +\t\tif (sensorDatabase__[i].first == sensor)\n> +\t\t\treturn sensorDatabase__[i].second;\n> +\t}\n> +\n> +\treturn nullptr;\n> +}\n> +\n> +} /* namespace */\n> +\n> +/**\n> + * \\brief Retrieve the properties associated with a sensor\n> + * \\param sensor The sensor model name\n> + * \\return A pointer to the SensorInfo instance associated with a sensor or\n> + * nullptr if the sensor is not supported in the database\n> + */\n> +const SensorInfo *SensorDatabase::get(const std::string &sensor)\n> +{\n> +\treturn getInfo(sensor);\n> +}\n> +\n> +} /* namespace libcamera */\n> -- \n> 2.29.2\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 31B20C0F1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Dec 2020 17:20:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A63A7615B2;\n\tTue, 29 Dec 2020 18:20:43 +0100 (CET)","from mail-lf1-x129.google.com (mail-lf1-x129.google.com\n\t[IPv6:2a00:1450:4864:20::129])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F6996031F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Dec 2020 18:20:42 +0100 (CET)","by mail-lf1-x129.google.com with SMTP id m12so32253423lfo.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Dec 2020 09:20:42 -0800 (PST)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tn14sm5679285lfe.95.2020.12.29.09.20.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 29 Dec 2020 09:20:40 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"C++ZiGE6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=lGTRxhNVeYjnQwYPY8LQwXJsNvRtgtJV50Zl6E4ivEU=;\n\tb=C++ZiGE6cnmIsnp2AUSaoT8hWQBJrmuFyiiicsgluyJuTlUiMtaSbaGJEhALY3ZAJd\n\tyYCWzBRuJ881fPCaVkxfJVBgW9C8c5jKcniOSryIuxbKeCf+FUcatWMJLyv/R8MChSrR\n\th17V6+8iuNZdjSe8g6Aj7M9777HPRWC2i2Vq3n7w7N75KilUFjYXWcPervu2K9q88KHL\n\tK7SnW20SNhmvdt4dUFfXrNhHIVYNGUNEiQ/MZ69jhQDSKSyw0eyRXM8BYberY90QRnEK\n\tE6uRFhD/dHXhuPDAsrLlbxBgrh43pwHlAj2sIFJpZsscbxQF/7eF6LUOaWw1GA4O+WsP\n\t4P4w==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=lGTRxhNVeYjnQwYPY8LQwXJsNvRtgtJV50Zl6E4ivEU=;\n\tb=trwFqFd5SBrCKKJgP6GvGd3XYntlKsUr9QmTHKDl3puLT+UZcxKrzDsLfbJVSBKVMr\n\t+CwpKow4io4I/mgkziaxGddml4ZeCwrCrAwPHH+//ocq8/LjklLByzgjb6cDEYGIOArV\n\t4G2kbZrQHxXt2MBr5IjkjbRUHrIuA7uPBTDIynSkPh2M1n9T4MnANnrV8gA47cpnXYo9\n\t3dJYUmy5OxotHGR35dI3mfzimeaN50S5JL3w7Hm4VmdN8fUYMiBcIR2OAToy9G7+vA26\n\tIFstXuYDVbrwTRjhEjGfAtGSaFIwT+YRffWAyAfQShxxyb0iOp5ShSAWE/D7UXJrYa1f\n\tm9+A==","X-Gm-Message-State":"AOAM530HQ3gj8HEHRBQv5GAQL1l3v4GOzKQYKDgAujfMMtB2oGA2cRkQ\n\tvIrgmh4Mz9+fPxauKxSf+GTFmQ==","X-Google-Smtp-Source":"ABdhPJx3Qz4WE4BGNyuenaFhfQMRFhFnzi2L01y017YWY3R0eSF8/XmS1ry7Xq48L5FVZm/s1C5alQ==","X-Received":"by 2002:a19:5050:: with SMTP id\n\tz16mr20371676lfj.48.1609262441696; \n\tTue, 29 Dec 2020 09:20:41 -0800 (PST)","Date":"Tue, 29 Dec 2020 18:20:40 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<X+tlaFhjDH8xFLFE@oden.dyn.berto.se>","References":"<20201228165203.53771-1-jacopo@jmondi.org>\n\t<20201228165203.53771-2-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201228165203.53771-2-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v3 1/4] 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=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":14406,"web_url":"https://patchwork.libcamera.org/comment/14406/","msgid":"<20201230081347.xdv4gda2w4enaobp@uno.localdomain>","date":"2020-12-30T08:13:47","subject":"Re: [libcamera-devel] [PATCH v3 1/4] 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 Niklas,\n\nOn Tue, Dec 29, 2020 at 06:20:40PM +0100, Niklas Söderlund wrote:\n> Hi Jacopo,\n>\n> Thanks for your work.\n>\n> On 2020-12-28 17:52:00 +0100, Jacopo Mondi wrote:\n> > Introduce a 'database' of camera sensor information, which contains\n> > a the camera sensor properties which is not possible, or desirable,\n> > to retrieve at run-time.\n> >\n> > The camera sensor database is accessed through the static SensorDatabase\n> > class which provides a single method to obtain the sensor information.\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 |  28 +++++\n> >  src/libcamera/meson.build                    |   1 +\n> >  src/libcamera/sensor_database.cpp            | 102 +++++++++++++++++++\n> >  4 files changed, 132 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 1b1bdc779512..e1f22f238a10 100644\n> > --- a/include/libcamera/internal/meson.build\n> > +++ b/include/libcamera/internal/meson.build\n> > @@ -38,6 +38,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..e074b3029932\n> > --- /dev/null\n> > +++ b/include/libcamera/internal/sensor_database.h\n> > @@ -0,0 +1,28 @@\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 <string>\n> > +\n> > +#include <libcamera/geometry.h>\n> > +\n> > +namespace libcamera {\n> > +\n> > +struct SensorInfo {\n> > +\tSize unitCellSize;\n> > +};\n> > +\n> > +class SensorDatabase\n> > +{\n> > +public:\n> > +\tstatic const SensorInfo *get(const std::string &sensor);\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..5f8538a62388\n> > --- /dev/null\n> > +++ b/src/libcamera/sensor_database.cpp\n> > @@ -0,0 +1,102 @@\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 <algorithm>\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 Access the 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> > + * SensorInfo list of properties.\n> > + *\n> > + * The class provides a single static getInfo() method to access the sensor\n> > + * database entries. If the sensor is not supported in the database nullptr is\n> > + * returned.\n> > + */\n> > +\n> > +/**\n> > + * \\struct SensorInfo\n> > + * \\brief List of sensor properties\n> > + *\n> > + * \\var SensorInfo::unitCellSize\n> > + * \\brief The physical size of pixel, including pixel edges. Width x height in\n> > + * nano-meters.\n> > + */\n> > +\n> > +namespace {\n> > +\n> > +/**\n> > + * \\brief Sony IMX219 sensor properties\n> > + */\n> > +constexpr SensorInfo imx219Info = {\n> > +\t.unitCellSize = { 1120, 1120 }\n> > +};\n> > +\n> > +/**\n> > + * \\brief Omnivision ov5670 sensor properties\n> > + */\n> > +constexpr SensorInfo ov5670Info = {\n> > +\t.unitCellSize = { 1120, 1120 }\n> > +};\n> > +\n> > +/**\n> > + * \\brief Omnivision 13858 sensor properties\n> > + */\n> > +constexpr SensorInfo ov13858Info = {\n> > +\t.unitCellSize = { 1120, 1120 }\n> > +};\n> > +\n> > +#define SENSOR_INFO(_sensor) \\\n> > +\t{ #_sensor, &_sensor##Info }\n> > +\n> > +/*\n> > + * \\brief The database of sensor properties\n> > + */\n> > +constexpr std::pair<const char *const, const SensorInfo *> sensorDatabase__[] = {\n>\n> Maybe something for later but if model registration similar to\n> REGISTER_PIPELINE_HANDLER() this could be a std::map which would improve\n> lookup speeds, if we ever get a large set of sensors. But I think this\n> could be done on-top as it won't impact any users.\n\nMy understanding is that the factory implementation we have realized\nwith REGISTER_PIPELINE_HANDLER() guarantees the static list of\nhandlers is initialized at library startup, but does not guarantee\nthat it is compile-time evaluated and statically initialized as\nconstexpr does.\n\nas detailed in the cover letter I moved from an std::map, to an\nstd::array, and finally fell back on a plain C-style array to be able\nto ensure that and please all the compilers I've tested with.\n\nThanks\n  j\n\n\n>\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n>\n> > +\tSENSOR_INFO(imx219),\n> > +\tSENSOR_INFO(ov5670),\n> > +\tSENSOR_INFO(ov13858),\n> > +};\n> > +\n> > +const SensorInfo *getInfo(const std::string &sensor)\n> > +{\n> > +\tfor (unsigned int i = 0; i < std::size(sensorDatabase__); ++i) {\n> > +\t\tif (sensorDatabase__[i].first == sensor)\n> > +\t\t\treturn sensorDatabase__[i].second;\n> > +\t}\n> > +\n> > +\treturn nullptr;\n> > +}\n> > +\n> > +} /* namespace */\n> > +\n> > +/**\n> > + * \\brief Retrieve the properties associated with a sensor\n> > + * \\param sensor The sensor model name\n> > + * \\return A pointer to the SensorInfo instance associated with a sensor or\n> > + * nullptr if the sensor is not supported in the database\n> > + */\n> > +const SensorInfo *SensorDatabase::get(const std::string &sensor)\n> > +{\n> > +\treturn getInfo(sensor);\n> > +}\n> > +\n> > +} /* namespace libcamera */\n> > --\n> > 2.29.2\n> >\n> > _______________________________________________\n> > libcamera-devel mailing list\n> > libcamera-devel@lists.libcamera.org\n> > https://lists.libcamera.org/listinfo/libcamera-devel\n>\n> --\n> Regards,\n> Niklas Söderlund","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 5C10CC0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 30 Dec 2020 08:13:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CD413615B2;\n\tWed, 30 Dec 2020 09:13:34 +0100 (CET)","from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 39B526031B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 30 Dec 2020 09:13:34 +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 relay6-d.mail.gandi.net (Postfix) with ESMTPSA id A60A6C000E;\n\tWed, 30 Dec 2020 08:13:33 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Wed, 30 Dec 2020 09:13:47 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Message-ID":"<20201230081347.xdv4gda2w4enaobp@uno.localdomain>","References":"<20201228165203.53771-1-jacopo@jmondi.org>\n\t<20201228165203.53771-2-jacopo@jmondi.org>\n\t<X+tlaFhjDH8xFLFE@oden.dyn.berto.se>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<X+tlaFhjDH8xFLFE@oden.dyn.berto.se>","Subject":"Re: [libcamera-devel] [PATCH v3 1/4] 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=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]