Patch Detail
Show a patch.
GET /api/1.1/patches/3575/?format=api
{ "id": 3575, "url": "https://patchwork.libcamera.org/api/1.1/patches/3575/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3575/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20200427213236.333777-7-jacopo@jmondi.org>", "date": "2020-04-27T21:32:35", "name": "[libcamera-devel,v4,6/7] libcamera: camera_sensor: Add method to get sensor info", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "9645d2fd998daf311eadccccf0b479f138621879", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3575/mbox/", "series": [ { "id": 837, "url": "https://patchwork.libcamera.org/api/1.1/series/837/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=837", "date": "2020-04-27T21:32:29", "name": "libcamera: Add CameraSensorInfo", "version": 4, "mbox": "https://patchwork.libcamera.org/series/837/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3575/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3575/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 29453603F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Apr 2020 23:29:37 +0200 (CEST)", "from uno.homenet.telecomitalia.it (a-ur1-85.tin.it\n\t[212.216.150.148]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 80E6140007;\n\tMon, 27 Apr 2020 21:29:36 +0000 (UTC)" ], "X-Originating-IP": "212.216.150.148", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 27 Apr 2020 23:32:35 +0200", "Message-Id": "<20200427213236.333777-7-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.26.1", "In-Reply-To": "<20200427213236.333777-1-jacopo@jmondi.org>", "References": "<20200427213236.333777-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 6/7] libcamera: camera_sensor: Add\n\tmethod to get sensor info", "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": "Mon, 27 Apr 2020 21:29:38 -0000" }, "content": "Add method to retrieve the CameraSensorInfo to the CameraSensor class.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/camera_sensor.cpp | 83 +++++++++++++++++++++++++++\n src/libcamera/include/camera_sensor.h | 1 +\n 2 files changed, 84 insertions(+)", "diff": "diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 4fd1ee84eb47..8b37f63dc04e 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -440,6 +440,89 @@ int CameraSensor::setControls(ControlList *ctrls)\n \treturn subdev_->setControls(ctrls);\n }\n \n+/**\n+ * \\brief Assemble and return the camera sensor info\n+ * \\param[out] info The camera sensor info that reports the sensor information\n+ *\n+ * The CameraSensorInfo content is assembled by inspecting the currently\n+ * applied sensor configuration and the sensor static properties.\n+ *\n+ * \\return 0 on success, a negative error code otherwise\n+ */\n+int CameraSensor::sensorInfo(CameraSensorInfo *info) const\n+{\n+\t/*\n+\t * Construct the camera sensor name using the media entity name.\n+\t *\n+\t * \\todo There is no standardized naming scheme for sensor entities\n+\t * in the Linux kernel at the moment. The most common naming scheme\n+\t * is the one obtained by associating the sensor name and its I2C\n+\t * device and bus addresses in the form of: \"devname i2c-adapt:i2c-addr\"\n+\t * Assume this is the standard naming scheme and parse the first part\n+\t * of the entity name to obtain \"devname\".\n+\t */\n+\tstd::string entityName = subdev_->entity()->name();\n+\tinfo->model = entityName.substr(0, entityName.find(' '));\n+\n+\t/*\n+\t * Get the active area size from the ActiveAreas property. Do\n+\t * not use the content of properties::ActiveAreas but fetch it from the\n+\t * subdevice as the property registration is optional, but it's\n+\t * mandatory to construct the CameraSensorInfo.\n+\t *\n+\t * \\todo The ActiveAreas property aims to describe multiple\n+\t * active area rectangles. At the moment only a single active\n+\t * area rectangle is exposed by the subdevice API. Use that single\n+\t * rectangle width and height to construct the ActiveAreaSize.\n+\t */\n+\tRectangle rect = {};\n+\tint ret = subdev_->getSelection(0, V4L2_SEL_TGT_CROP_DEFAULT, &rect);\n+\tif (ret) {\n+\t\tLOG(CameraSensor, Error)\n+\t\t\t<< \"Failed to construct camera sensor info: \"\n+\t\t\t<< \"the camera sensor does not report the active area\";\n+\n+\t\treturn ret;\n+\t}\n+\tinfo->activeAreaSize = { rect.width, rect.height };\n+\n+\t/* It's mandatory for the subdevice to report its crop rectangle. */\n+\tret = subdev_->getSelection(0, V4L2_SEL_TGT_CROP, &info->analogCrop);\n+\tif (ret) {\n+\t\tLOG(CameraSensor, Error)\n+\t\t\t<< \"Failed to construct camera sensor info: \"\n+\t\t\t<< \"the camera sensor does not report the crop rectangle\";\n+\t\treturn ret;\n+\t}\n+\n+\t/* The bit-depth and image size depend on the currently applied format. */\n+\tV4L2SubdeviceFormat format{};\n+\tret = subdev_->getFormat(0, &format);\n+\tif (ret)\n+\t\treturn ret;\n+\tinfo->bitsPerPixel = format.bitsPerPixel();\n+\tinfo->outputSize = format.size;\n+\n+\t/*\n+\t * Retrieve the pixel rate and the line length through V4L2 controls.\n+\t * Support for the V4L2_CID_PIXEL_RATE and V4L2_CID_HBLANK controls is\n+\t * mandatory.\n+\t */\n+\tControlList ctrls = subdev_->getControls({ V4L2_CID_PIXEL_RATE,\n+\t\t\t\t\t\t V4L2_CID_HBLANK });\n+\tif (ctrls.empty()) {\n+\t\tLOG(CameraSensor, Error)\n+\t\t\t<< \"Failed to retrieve camera info controls\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tint32_t hblank = ctrls.get(V4L2_CID_HBLANK).get<int32_t>();\n+\tinfo->lineLength = info->outputSize.width + hblank;\n+\tinfo->pixelRate = ctrls.get(V4L2_CID_PIXEL_RATE).get<int64_t>();\n+\n+\treturn 0;\n+}\n+\n std::string CameraSensor::logPrefix() const\n {\n \treturn \"'\" + subdev_->entity()->name() + \"'\";\ndiff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h\nindex 28ebfaa30c22..91d270552d3f 100644\n--- a/src/libcamera/include/camera_sensor.h\n+++ b/src/libcamera/include/camera_sensor.h\n@@ -60,6 +60,7 @@ public:\n \tint setControls(ControlList *ctrls);\n \n \tconst ControlList &properties() const { return properties_; }\n+\tint sensorInfo(CameraSensorInfo *info) const;\n \n protected:\n \tstd::string logPrefix() const;\n", "prefixes": [ "libcamera-devel", "v4", "6/7" ] }