{"id":3950,"url":"https://patchwork.libcamera.org/api/1.1/patches/3950/?format=json","web_url":"https://patchwork.libcamera.org/patch/3950/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200605141002.49119-7-jacopo@jmondi.org>","date":"2020-06-05T14:10:00","name":"[libcamera-devel,v3,6/8] libcamera: camera_sensor: Break out properties initialization","commit_ref":null,"pull_url":null,"state":"superseded","archived":true,"hash":"7bc19f93354e3d9b73695fa3ca272bae6517747c","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/1.1/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/3950/mbox/","series":[{"id":958,"url":"https://patchwork.libcamera.org/api/1.1/series/958/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=958","date":"2020-06-05T14:09:54","name":"android: Build stream configuration map","version":3,"mbox":"https://patchwork.libcamera.org/series/958/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3950/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3950/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CF3C160410\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Jun 2020 16:07:12 +0200 (CEST)","from localhost.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 9102A20002;\n\tFri,  5 Jun 2020 14:07:11 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  5 Jun 2020 16:10:00 +0200","Message-Id":"<20200605141002.49119-7-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200605141002.49119-1-jacopo@jmondi.org>","References":"<20200605141002.49119-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 6/8] libcamera: camera_sensor: Break\n\tout properties initialization","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":"Fri, 05 Jun 2020 14:07:13 -0000"},"content":"Refactor the CameraSensor properties initialization to a dedicated\nfunction as it is expected to grow as we augment the number of\nproperties.\n\nWhile at it, move documentation of the properties() method to match the\ndeclaration order in the class definition.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/internal/camera_sensor.h |  2 +\n src/libcamera/camera_sensor.cpp            | 83 ++++++++++++----------\n 2 files changed, 49 insertions(+), 36 deletions(-)","diff":"diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex d79bd9ce9d58..44dd4b099913 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -69,6 +69,8 @@ protected:\n \tstd::string logPrefix() const;\n \n private:\n+\tint initProperties();\n+\n \tconst MediaEntity *entity_;\n \tstd::unique_ptr<V4L2Subdevice> subdev_;\n \tunsigned int pad_;\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex b14b4051dca6..b9428175c55e 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -205,7 +205,47 @@ int CameraSensor::init()\n \tif (ret < 0)\n \t\treturn ret;\n \n-\t/* Retrieve and store the camera sensor properties. */\n+\t/* Enumerate, sort and cache media bus codes and sizes. */\n+\tformats_ = subdev_->formats(pad_);\n+\tif (formats_.isEmpty()) {\n+\t\tLOG(CameraSensor, Error) << \"No image format found\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tmbusCodes_ = formats_.formats();\n+\tstd::sort(mbusCodes_.begin(), mbusCodes_.end());\n+\n+\tfor (const auto &format : formats_.data()) {\n+\t\tconst std::vector<SizeRange> &ranges = format.second;\n+\t\tstd::transform(ranges.begin(), ranges.end(), std::back_inserter(sizes_),\n+\t\t\t       [](const SizeRange &range) { return range.max; });\n+\t}\n+\n+\tstd::sort(sizes_.begin(), sizes_.end());\n+\n+\t/* Remove duplicates. */\n+\tauto last = std::unique(sizes_.begin(), sizes_.end());\n+\tsizes_.erase(last, sizes_.end());\n+\n+\t/*\n+\t * The sizes_ vector is sorted in ascending order, the resolution is\n+\t * thus the last element of the vector.\n+\t */\n+\tresolution_ = sizes_.back();\n+\n+\treturn initProperties();\n+}\n+\n+/**\n+ * \\brief Initialize the camera sensor standard properties\n+ *\n+ * This method initializes the camera sensor standard properties, by inspecting\n+ * the control information reported by the sensor subdevice.\n+ *\n+ * \\return 0 on success, a negative error code otherwise\n+ */\n+int CameraSensor::initProperties()\n+{\n \tconst ControlInfoMap &controls = subdev_->controls();\n \tint32_t propertyValue;\n \n@@ -243,35 +283,6 @@ int CameraSensor::init()\n \t\tpropertyValue = 0;\n \tproperties_.set(properties::Rotation, propertyValue);\n \n-\t/* Enumerate, sort and cache media bus codes and sizes. */\n-\tformats_ = subdev_->formats(pad_);\n-\tif (formats_.isEmpty()) {\n-\t\tLOG(CameraSensor, Error) << \"No image format found\";\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tmbusCodes_ = formats_.formats();\n-\tstd::sort(mbusCodes_.begin(), mbusCodes_.end());\n-\n-\tfor (const auto &format : formats_.data()) {\n-\t\tconst std::vector<SizeRange> &ranges = format.second;\n-\t\tstd::transform(ranges.begin(), ranges.end(), std::back_inserter(sizes_),\n-\t\t\t       [](const SizeRange &range) { return range.max; });\n-\t}\n-\n-\tstd::sort(sizes_.begin(), sizes_.end());\n-\n-\t/* Remove duplicates. */\n-\tauto last = std::unique(sizes_.begin(), sizes_.end());\n-\tsizes_.erase(last, sizes_.end());\n-\n-\t/*\n-\t * The sizes_ vector is sorted in ascending order, the resolution is\n-\t * thus the last element of the vector.\n-\t */\n-\tresolution_ = sizes_.back();\n-\n-\treturn 0;\n }\n \n /**\n@@ -438,12 +449,6 @@ ControlList CameraSensor::getControls(const std::vector<uint32_t> &ids)\n \treturn subdev_->getControls(ids);\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\n@@ -535,6 +540,12 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const\n \treturn 0;\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 std::string CameraSensor::logPrefix() const\n {\n \treturn \"'\" + entity_->name() + \"'\";\n","prefixes":["libcamera-devel","v3","6/8"]}