Patch Detail
Show a patch.
GET /api/patches/2782/?format=api
{ "id": 2782, "url": "https://patchwork.libcamera.org/api/patches/2782/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2782/", "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": "<20200206012601.153858-7-jacopo@jmondi.org>", "date": "2020-02-06T01:25:58", "name": "[libcamera-devel,v5,6/9] libcamera: camera_sensor: Parse camera properties", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "6ed76af50c8988ca320aee65bbf83f8e57c91ee6", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2782/mbox/", "series": [ { "id": 662, "url": "https://patchwork.libcamera.org/api/series/662/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=662", "date": "2020-02-06T01:25:52", "name": "Introduce camera properties", "version": 5, "mbox": "https://patchwork.libcamera.org/series/662/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2782/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2782/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6E6D260446\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 6 Feb 2020 02:23:35 +0100 (CET)", "from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay10.mail.gandi.net (Postfix) with ESMTPSA id 43099240002\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 6 Feb 2020 01:23:35 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 6 Feb 2020 02:25:58 +0100", "Message-Id": "<20200206012601.153858-7-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.24.1", "In-Reply-To": "<20200206012601.153858-1-jacopo@jmondi.org>", "References": "<20200206012601.153858-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 6/9] libcamera: camera_sensor: Parse\n\tcamera properties", "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>", "X-List-Received-Date": "Thu, 06 Feb 2020 01:23:36 -0000" }, "content": "Parse and collect camera sensor properties by inspecting the associated\nv4l2 controls.\n\nAugment the CameraSensor class with an operation to retrieve the\ncollected properties.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/camera_sensor.cpp | 49 ++++++++++++++++++++++++++-\n src/libcamera/include/camera_sensor.h | 7 ++--\n 2 files changed, 53 insertions(+), 3 deletions(-)", "diff": "diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 86f0c772861b..2219a4307436 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -13,6 +13,8 @@\n #include <limits.h>\n #include <math.h>\n \n+#include <libcamera/property_ids.h>\n+\n #include \"formats.h\"\n #include \"utils.h\"\n #include \"v4l2_subdevice.h\"\n@@ -47,7 +49,7 @@ LOG_DEFINE_CATEGORY(CameraSensor);\n * Once constructed the instance must be initialized with init().\n */\n CameraSensor::CameraSensor(const MediaEntity *entity)\n-\t: entity_(entity)\n+\t: entity_(entity), properties_(properties::properties)\n {\n \tsubdev_ = new V4L2Subdevice(entity);\n }\n@@ -89,6 +91,45 @@ int CameraSensor::init()\n \tif (ret < 0)\n \t\treturn ret;\n \n+\t/* Retrieve and store the camera sensor properties. */\n+\tconst ControlInfoMap &controls = subdev_->controls();\n+\tint32_t propertyValue;\n+\n+\t/* Camera Location: default is front location. */\n+\tconst auto &locationControl = controls.find(V4L2_CID_CAMERA_SENSOR_LOCATION);\n+\tif (locationControl != controls.end()) {\n+\t\tint32_t v4l2Location =\n+\t\t\tlocationControl->second.def().get<int32_t>();\n+\n+\t\tswitch (v4l2Location) {\n+\t\tdefault:\n+\t\t\tLOG(CameraSensor, Warning)\n+\t\t\t\t<< \"Unsupported camera location \"\n+\t\t\t\t<< v4l2Location << \", setting to Front\";\n+\t\t\t/* Fall-through */\n+\t\tcase V4L2_LOCATION_FRONT:\n+\t\t\tpropertyValue = properties::CameraLocationFront;\n+\t\t\tbreak;\n+\t\tcase V4L2_LOCATION_BACK:\n+\t\t\tpropertyValue = properties::CameraLocationBack;\n+\t\t\tbreak;\n+\t\tcase V4L2_LOCATION_EXTERNAL:\n+\t\t\tpropertyValue = properties::CameraLocationExternal;\n+\t\t\tbreak;\n+\t\t}\n+\t} else {\n+\t\tpropertyValue = properties::CameraLocationFront;\n+\t}\n+\tproperties_.set(properties::Location, propertyValue);\n+\n+\t/* Camera Rotation: default is 0 degrees. */\n+\tconst auto &rotationControl = controls.find(V4L2_CID_CAMERA_SENSOR_ROTATION);\n+\tif (rotationControl != controls.end())\n+\t\tpropertyValue = rotationControl->second.def().get<int32_t>();\n+\telse\n+\t\tpropertyValue = 0;\n+\tproperties_.set(properties::Rotation, propertyValue);\n+\n \t/* Enumerate and cache media bus codes and sizes. */\n \tconst ImageFormats formats = subdev_->formats(0);\n \tif (formats.isEmpty()) {\n@@ -284,6 +325,12 @@ int CameraSensor::getControls(ControlList *ctrls)\n \treturn subdev_->getControls(ctrls);\n }\n \n+/**\n+ * \\fn CameraSensor::properties()\n+ * \\brief Retrieve the camera sensor properties\n+ * \\return The list of camera sensor properties\n+ */\n+\n /**\n * \\brief Write controls to the sensor\n * \\param[in] ctrls The list of controls to write\ndiff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h\nindex 1fb36a4f4951..99cff98128dc 100644\n--- a/src/libcamera/include/camera_sensor.h\n+++ b/src/libcamera/include/camera_sensor.h\n@@ -10,14 +10,13 @@\n #include <string>\n #include <vector>\n \n+#include <libcamera/controls.h>\n #include <libcamera/geometry.h>\n \n #include \"log.h\"\n \n namespace libcamera {\n \n-class ControlInfoMap;\n-class ControlList;\n class MediaEntity;\n class V4L2Subdevice;\n \n@@ -47,6 +46,8 @@ public:\n \tint getControls(ControlList *ctrls);\n \tint setControls(ControlList *ctrls);\n \n+\tconst ControlList &properties() const { return properties_; }\n+\n protected:\n \tstd::string logPrefix() const;\n \n@@ -56,6 +57,8 @@ private:\n \n \tstd::vector<unsigned int> mbusCodes_;\n \tstd::vector<Size> sizes_;\n+\n+\tControlList properties_;\n };\n \n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "v5", "6/9" ] }