Show a patch.

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

{
    "id": 3529,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/3529/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3529/",
    "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": "<20200424215304.558317-12-jacopo@jmondi.org>",
    "date": "2020-04-24T21:53:02",
    "name": "[libcamera-devel,v3,11/13] libcamera: camera_sensor: Add method to get sensor info",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "3fc3b3c6d68db62bd0919f132a977347f401b927",
    "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/3529/mbox/",
    "series": [
        {
            "id": 822,
            "url": "https://patchwork.libcamera.org/api/1.1/series/822/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=822",
            "date": "2020-04-24T21:52:51",
            "name": "libcamera: Add CameraSensorInfo",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/822/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3529/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3529/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 276EA62F6D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Apr 2020 23:50:15 +0200 (CEST)",
            "from uno.homenet.telecomitalia.it\n\t(host240-55-dynamic.3-87-r.retail.telecomitalia.it [87.3.55.240])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 70E2F60002;\n\tFri, 24 Apr 2020 21:50:14 +0000 (UTC)"
        ],
        "X-Originating-IP": "87.3.55.240",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 24 Apr 2020 23:53:02 +0200",
        "Message-Id": "<20200424215304.558317-12-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.26.1",
        "In-Reply-To": "<20200424215304.558317-1-jacopo@jmondi.org>",
        "References": "<20200424215304.558317-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 11/13] 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": "Fri, 24 Apr 2020 21:50:15 -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       | 84 +++++++++++++++++++++++++++\n src/libcamera/include/camera_sensor.h |  1 +\n 2 files changed, 85 insertions(+)",
    "diff": "diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex e39f277622ae..c1ef4adb579c 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -492,6 +492,90 @@ int CameraSensor::setControls(ControlList *ctrls)\n  * \\return The list of camera sensor properties\n  */\n \n+/**\n+ * \\brief Assemble and return the camera sensor info\n+ * \\param[out] info The camera sensor info that report 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 * Make sure the sub-device exports all the controls we need to operate.\n+\t *\n+\t * Currently V4L2_CID_PIXEL_RATE and V4L2_CID_HBLANK are required.\n+\t *\n+\t * \\todo This is an hard policy that all sensors that want to export\n+\t * a properly populated CameraSensorInfo have to adhere to. Consider if\n+\t * it's worth relaxing it and providing default values instead.\n+\t */\n+\tconst ControlInfoMap &controlMap = subdev_->controls();\n+\tif (controlMap.find(V4L2_CID_PIXEL_RATE) == controlMap.end()) {\n+\t\tLOG(CameraSensor, Error) << \"'Pixel rate' control not available\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (controlMap.find(V4L2_CID_HBLANK) == controlMap.end()) {\n+\t\tLOG(CameraSensor, Error) << \"'HBLANK' control not available\";\n+\t\treturn -EINVAL;\n+\t}\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->name = *utils::split(entityName, \" \").begin();\n+\n+\t/*\n+\t * Get the active area size from the ActiveAreas property.\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+\tSpan<const int> activeArea = properties_.get(properties::ActiveAreas);\n+\tinfo->activeAreaSize = { static_cast<unsigned int>(activeArea[2]),\n+\t\t\t\t static_cast<unsigned int>(activeArea[3]) };\n+\n+\t/* The bit-depth and image size depend on the currently applied format. */\n+\tV4L2SubdeviceFormat format{};\n+\tint ret = subdev_->getFormat(0, &format);\n+\tif (ret)\n+\t\treturn ret;\n+\tinfo->bitsPerPixel = format.bitsPerPixel();\n+\tinfo->outputSize = format.size;\n+\n+\t/* It's mandatory for the subdevice to report its crop rectangle. */\n+\tret = subdev_->getCropRectangle(0, &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+\tint64_t pixelRate;\n+\tsubdev_->getControl(V4L2_CID_PIXEL_RATE, &pixelRate);\n+\tinfo->pixelClock = pixelRate;\n+\n+\tint32_t hblank;\n+\tsubdev_->getControl(V4L2_CID_HBLANK, &hblank);\n+\tinfo->lineLength = info->outputSize.width + hblank;\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 e19852d4cabe..b162c3886b1d 100644\n--- a/src/libcamera/include/camera_sensor.h\n+++ b/src/libcamera/include/camera_sensor.h\n@@ -61,6 +61,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",
        "v3",
        "11/13"
    ]
}