Show a patch.

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

{
    "id": 3592,
    "url": "https://patchwork.libcamera.org/api/patches/3592/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3592/",
    "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": "<20200428091934.341550-6-jacopo@jmondi.org>",
    "date": "2020-04-28T09:19:33",
    "name": "[libcamera-devel,v5,6/7] libcamera: camera_sensor: Add method to get sensor info",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "9e7f3e30ba35d583d30beb1e84fdbbc95f208fcb",
    "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/3592/mbox/",
    "series": [
        {
            "id": 842,
            "url": "https://patchwork.libcamera.org/api/series/842/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=842",
            "date": "2020-04-28T09:17:13",
            "name": "libcamera: Add CameraSensorInfo",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/842/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3592/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3592/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 DBC4961AD4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Apr 2020 11:16:39 +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 E143140004;\n\tTue, 28 Apr 2020 09:16:38 +0000 (UTC)"
        ],
        "X-Originating-IP": "212.216.150.148",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 28 Apr 2020 11:19:33 +0200",
        "Message-Id": "<20200428091934.341550-6-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.26.1",
        "In-Reply-To": "<20200428091934.341550-1-jacopo@jmondi.org>",
        "References": "<20200428091934.341550-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 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": "Tue, 28 Apr 2020 09:16:40 -0000"
    },
    "content": "Add a method to retrieve the CameraSensorInfo to the CameraSensor class.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/camera_sensor.cpp       | 62 +++++++++++++++++++++++++++\n src/libcamera/include/camera_sensor.h |  1 +\n 2 files changed, 63 insertions(+)",
    "diff": "diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 2c016791e32f..5d2db28152be 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -461,6 +461,68 @@ 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\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+\tinfo->model = model();\n+\n+\t/* Get the active area size. */\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 33997f2ed7f2..9e029139b9b7 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",
        "v5",
        "6/7"
    ]
}