Show a patch.

GET /api/patches/10610/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 10610,
    "url": "https://patchwork.libcamera.org/api/patches/10610/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10610/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20201208090042.4824-2-jacopo@jmondi.org>",
    "date": "2020-12-08T09:00:41",
    "name": "[libcamera-devel,1/2] libcamera: Introduce camera sensor database",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "56839b909eb0e36015f3881f678b4e363d2870b2",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": {
        "id": 15,
        "url": "https://patchwork.libcamera.org/api/users/15/?format=api",
        "username": "jmondi",
        "first_name": "Jacopo",
        "last_name": "Mondi",
        "email": "jacopo@jmondi.org"
    },
    "mbox": "https://patchwork.libcamera.org/patch/10610/mbox/",
    "series": [
        {
            "id": 1514,
            "url": "https://patchwork.libcamera.org/api/series/1514/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1514",
            "date": "2020-12-08T09:00:40",
            "name": "libcamera: Introduce sensor database",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1514/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10610/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10610/checks/",
    "tags": {},
    "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 36D3EBDB21\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Dec 2020 09:00:41 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 63BB567E6F;\n\tTue,  8 Dec 2020 10:00:40 +0100 (CET)",
            "from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 35C3B635F2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Dec 2020 10:00:38 +0100 (CET)",
            "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id E9BD310000A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Dec 2020 09:00:37 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  8 Dec 2020 10:00:41 +0100",
        "Message-Id": "<20201208090042.4824-2-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.29.1",
        "In-Reply-To": "<20201208090042.4824-1-jacopo@jmondi.org>",
        "References": "<20201208090042.4824-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: Introduce camera sensor\n\tdatabase",
        "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>",
        "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>"
    },
    "content": "Introduce a 'database' of camera sensor information, which contains\na list of camera sensor properties which is not possible, or desirable,\nto retrieve at run-time.\n\nThe camera sensor database is a global read-only library object,\naccessible by all the library components.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/camera_sensor_database.h |  41 +++++++\n include/libcamera/meson.build              |   1 +\n src/libcamera/camera_sensor_database.cpp   | 119 +++++++++++++++++++++\n src/libcamera/meson.build                  |   1 +\n 4 files changed, 162 insertions(+)\n create mode 100644 include/libcamera/camera_sensor_database.h\n create mode 100644 src/libcamera/camera_sensor_database.cpp",
    "diff": "diff --git a/include/libcamera/camera_sensor_database.h b/include/libcamera/camera_sensor_database.h\nnew file mode 100644\nindex 000000000000..bbc38546e60e\n--- /dev/null\n+++ b/include/libcamera/camera_sensor_database.h\n@@ -0,0 +1,41 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * camera_sensor_database.h - Database of camera sensor properties\n+ */\n+#ifndef __LIBCAMERA_CAMERA_SENSOR_DATABASE_H__\n+#define __LIBCAMERA_CAMERA_SENSOR_DATABASE_H__\n+\n+#include <initializer_list>\n+#include <unordered_map>\n+\n+#include <libcamera/geometry.h>\n+\n+namespace libcamera {\n+\n+struct SensorEntry {\n+\tSize physicalSize;\n+\tSize pixelPhysicalSize;\n+};\n+\n+class SensorDatabase : private std::unordered_map<std::string, const SensorEntry>\n+{\n+private:\n+\tusing Map = std::unordered_map<std::string, const SensorEntry>;\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 SensorEntry &get(Map::key_type sensor) const;\n+};\n+\n+extern const SensorDatabase sensorDatabase;\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_CAMERA_SENSOR_DATABASE_H__ */\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex cf2935f1ee95..0747adbda90a 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -5,6 +5,7 @@ libcamera_public_headers = files([\n     'buffer.h',\n     'camera.h',\n     'camera_manager.h',\n+    'camera_sensor_database.h',\n     'controls.h',\n     'extensible.h',\n     'file_descriptor.h',\ndiff --git a/src/libcamera/camera_sensor_database.cpp b/src/libcamera/camera_sensor_database.cpp\nnew file mode 100644\nindex 000000000000..67800fa641c7\n--- /dev/null\n+++ b/src/libcamera/camera_sensor_database.cpp\n@@ -0,0 +1,119 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * camera_sensor_database.cpp - Database of camera sensor properties\n+ */\n+\n+#include \"libcamera/camera_sensor_database.h\"\n+\n+namespace libcamera {\n+\n+/**\n+ * \\file camera_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+ * \\struct SensorEntry\n+ * \\brief List of sensor properties\n+ *\n+ * \\var SensorEntry::physicalSize\n+ * \\brief The physical size of the sensor area covered by pixels (active and non\n+ * active ones). Width x height in nano-meters.\n+ *\n+ * \\var SensorEntry::pixelPhysicalSize\n+ * \\brief The physical size of pixel, including pixel edges. Width x height in\n+ * nano-meters.\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+ * SensorEntry instance.\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 SensorEntry that\n+ * describes a sensor (SensorDatabase::get())\n+ */\n+\n+/**\n+ * \\fn SensorDatabase::SensorDatabase()\n+ * \\brief Contruct the sensor database with a list of values\n+ * \\param[in] items The list of sensor entries\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 entry in the database, false\n+ * 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 SensorEntry associated with a sensor or an empty SensorEntry if\n+ * the sensor is not supported\n+ */\n+const SensorEntry &SensorDatabase::get(Map::key_type sensor) const\n+{\n+\tstatic SensorEntry 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+/** \\todo Autogenerate the per-sensor entries from a yaml schema. */\n+\n+/**\n+ * \\brief Sony IMX219 sensor properties\n+ */\n+extern const SensorEntry imx219SensorEntry = {\n+\t.physicalSize = { 5095000, 4930000 },\n+\t.pixelPhysicalSize = { 1120, 1120 }\n+};\n+\n+/**\n+ * \\brief Omnivision ov5670 sensor properties\n+ */\n+extern const SensorEntry ov5670SensorEntry = {\n+\t.physicalSize = { 2945700, 2214000 },\n+\t.pixelPhysicalSize = { 1120, 1120 }\n+};\n+\n+/**\n+ * \\brief Omnivision 13858 sensor properties\n+ */\n+extern const SensorEntry ov13858SensorEntry = {\n+\t.physicalSize = { 4749700, 3535490 },\n+\t.pixelPhysicalSize = { 1120, 1120 }\n+};\n+\n+#define SENSOR_ENTRY(_sensor)\t\\\n+\t{ #_sensor, _sensor ## SensorEntry }\n+\n+/**\n+ * \\brief Database of sensor information\n+ */\n+extern const SensorDatabase sensorDatabase = {\n+\tSENSOR_ENTRY(imx219),\n+\tSENSOR_ENTRY(ov5670),\n+\tSENSOR_ENTRY(ov13858),\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 387d5d88ecae..3495d9ce45f8 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -9,6 +9,7 @@ libcamera_sources = files([\n     'camera_controls.cpp',\n     'camera_manager.cpp',\n     'camera_sensor.cpp',\n+    'camera_sensor_database.cpp',\n     'controls.cpp',\n     'control_serializer.cpp',\n     'control_validator.cpp',\n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}