[{"id":15910,"web_url":"https://patchwork.libcamera.org/comment/15910/","msgid":"<YF0SyAuBkYguntyC@oden.dyn.berto.se>","date":"2021-03-25T22:46:32","subject":"Re: [libcamera-devel] [PATCH v3 1/3] 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 2021-03-25 14:51:14 +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 1fe3918cfe93..4aaa76ac1db1 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\ns/2020/2021/\n\nSame for .cpp\n\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 815629db8488..17b44cc1dfa8 100644\n> --- a/src/libcamera/meson.build\n> +++ b/src/libcamera/meson.build\n> @@ -44,6 +44,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\nMaybe I'm missing something can't getInfo() be inlined here? If not I \nthink getInfo() should be decorated with 'static const'.\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> +}\n> +\n> +} /* namespace libcamera */\n> -- \n> 2.30.0\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 9EEA2BDC66\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 25 Mar 2021 22:46:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0E5D0603FF;\n\tThu, 25 Mar 2021 23:46:37 +0100 (CET)","from mail-lf1-x130.google.com (mail-lf1-x130.google.com\n\t[IPv6:2a00:1450:4864:20::130])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 13336603FE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Mar 2021 23:46:35 +0100 (CET)","by mail-lf1-x130.google.com with SMTP id n138so4900617lfa.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Mar 2021 15:46:35 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\ty23sm935558ljm.53.2021.03.25.15.46.32\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 25 Mar 2021 15:46:33 -0700 (PDT)"],"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=\"NmkO9aVy\"; 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=EMUM2vmYtOJx66QG0ncpUuhJj+bNSPF9q96Rny+dJ/w=;\n\tb=NmkO9aVyPQ3/cJHF5bxm6Nu5CA2mHzVofmLfjJnquZL0iueVuJyJzyCbFVE2oerJMA\n\tEfOtOfZ+M5Di9UgkutDZ5xo1v+ikqoicRGYu3IBtzPhNsFQdTB/APN1aziVc+AvrQRjZ\n\tQ50cN9LrwZRwT99WPw54N2Uvl0JwTFDzm+zqdm8B0rt6OQr0lbZHiIxvRioqkS5Ud3SY\n\t0eZHxmh04c3tHY7D/GfK6ZgeRfcUe3HpVKiNaeW0/ZbcyND9Vd2AJ2GAtjhNZ2EKZp3x\n\tqpLMV2ANgmahYopqUDCa+aq/3MZzlbUGZqkM2Ab1cTpYduE8SvjJOshPlKN4lVyIcQjc\n\toySA==","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=EMUM2vmYtOJx66QG0ncpUuhJj+bNSPF9q96Rny+dJ/w=;\n\tb=l7lzwVKfgPpKnDhbTiHFx2EQt+/sYkNsO1UjM+1MWcalqawB+GO6I7vI5SKdcWf5VD\n\t8QX7KRobRCc0IX7ofUCOfBJJwZoh73itNw/+t71diM92fey71rRjHeaiLbn2Gn9PX/em\n\tFq9GpPy58WGz93JYxLhAMBaQuXUVF7cNcnZQ7zpM8m2YN0EvBusoRE9wb64wbka6NVDL\n\trA5xeMEKmKxfB6yRucu4jk67XOyQVGjRO1muAdJ3Ckb21mcJGA11FBlqUFptT8ieUvh6\n\t+SdoWpcRG3yk6x1lajRWK4c5HB4Spnao88402KbDmkiZSSy/6ut4yc/FmDdTc24si24I\n\t88EQ==","X-Gm-Message-State":"AOAM533G9bPSiGBj2PG8AZ87+5hqKvxluv/mU99Q4dDMLSc7xQgoWrm2\n\t0IkZkXVmICvw+hjYzxz+Y3P+RQ==","X-Google-Smtp-Source":"ABdhPJx0gm3qjf31nQjts93X+EkLSsYGBL0jxAr7unfgNcvayNjUYHIYIaLnAXceGQxDvHqV6fRFxg==","X-Received":"by 2002:a19:6910:: with SMTP id\n\te16mr6168761lfc.482.1616712394393; \n\tThu, 25 Mar 2021 15:46:34 -0700 (PDT)","Date":"Thu, 25 Mar 2021 23:46:32 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YF0SyAuBkYguntyC@oden.dyn.berto.se>","References":"<20210325135116.21548-1-jacopo@jmondi.org>\n\t<20210325135116.21548-2-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210325135116.21548-2-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v3 1/3] 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>"}}]