summaryrefslogtreecommitdiff
path: root/src/libcamera/camera_sensor_properties.cpp
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2020-12-08 09:43:56 +0100
committerJacopo Mondi <jacopo@jmondi.org>2021-05-10 15:07:59 +0200
commita58a94e4c21465ede803c48162f1f791188a17f4 (patch)
treeb26714ca4e4e1322d307af2d7feb45bca9c59368 /src/libcamera/camera_sensor_properties.cpp
parent5fda81e1f441670796b81095595b98af7719779c (diff)
libcamera: Introduce camera sensor properties
Introduce a database of camera sensor properties, which contains information on the camera sensor which are not possible, or desirable, to retrieve from the device at run time. The camera sensor database is accessed through a static function and is indexed using the camera sensor model as reported by properties::Model. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/camera_sensor_properties.cpp')
-rw-r--r--src/libcamera/camera_sensor_properties.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/libcamera/camera_sensor_properties.cpp b/src/libcamera/camera_sensor_properties.cpp
new file mode 100644
index 00000000..6ded31dc
--- /dev/null
+++ b/src/libcamera/camera_sensor_properties.cpp
@@ -0,0 +1,71 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Google Inc.
+ *
+ * camera_sensor_properties.cpp - Database of camera sensor properties
+ */
+
+#include "libcamera/internal/camera_sensor_properties.h"
+
+#include <map>
+
+#include "libcamera/internal/log.h"
+
+/**
+ * \file camera_sensor_properties.h
+ * \brief Database of camera sensor properties
+ *
+ * The database of camera sensor properties collects static information about
+ * camera sensors that is not possible or desirable to retrieve from the device
+ * at run time.
+ *
+ * The database is indexed using the camera sensor model, as reported by the
+ * properties::Model property, and for each supported sensor it contains a
+ * list of properties.
+ */
+
+namespace libcamera {
+
+LOG_DEFINE_CATEGORY(CameraSensorProperties)
+
+/**
+ * \struct CameraSensorProperties
+ * \brief Database of camera sensor properties
+ *
+ * \var CameraSensorProperties::unitCellSize
+ * \brief The physical size of a pixel, including pixel edges, in nanometers.
+ */
+
+/**
+ * \brief Retrieve the properties associated with a sensor
+ * \param sensor The sensor model name as reported by properties::Model
+ * \return A pointer to the CameraSensorProperties instance associated with a sensor
+ * or nullptr if the sensor is not supported
+ */
+const CameraSensorProperties *CameraSensorProperties::get(const std::string &sensor)
+{
+ static const std::map<std::string, const CameraSensorProperties> sensorProps = {
+ { "imx219", {
+ .unitCellSize = { 1120, 1120 },
+ } },
+ { "ov5670", {
+ .unitCellSize = { 1120, 1120 },
+ } },
+ { "ov13858", {
+ .unitCellSize = { 1120, 1120 },
+ } },
+ };
+
+ const auto it = sensorProps.find(sensor);
+ if (it == sensorProps.end()) {
+ LOG(CameraSensorProperties, Warning)
+ << "No static properties available for '" << sensor << "'";
+ LOG(CameraSensorProperties, Warning)
+ << "Please consider updating the camera sensor properties database";
+ return nullptr;
+ }
+
+ return &it->second;
+}
+
+} /* namespace libcamera */