Show a patch.

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

{
    "id": 10762,
    "url": "https://patchwork.libcamera.org/api/patches/10762/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10762/",
    "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": "<20201228165600.53987-3-jacopo@jmondi.org>",
    "date": "2020-12-28T16:55:57",
    "name": "[libcamera-devel,v2,2/5] libcamera: camera_sensor: Initialize controls",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "fbf3aea22162ac9fc10005c78a2a72fb642b1f03",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": {
        "id": 15,
        "url": "https://patchwork.libcamera.org/api/users/15/?format=api",
        "username": "jmondi",
        "first_name": "Jacopo",
        "last_name": "Mondi",
        "email": "jacopo@jmondi.org"
    },
    "mbox": "https://patchwork.libcamera.org/patch/10762/mbox/",
    "series": [
        {
            "id": 1558,
            "url": "https://patchwork.libcamera.org/api/series/1558/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1558",
            "date": "2020-12-28T16:55:55",
            "name": "libcamera: Calculate expoure time limits",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/1558/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10762/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10762/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 3939BC0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Dec 2020 16:55:54 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C9C9362005;\n\tMon, 28 Dec 2020 17:55:51 +0100 (CET)",
            "from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C2FB06159A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Dec 2020 17:55:50 +0100 (CET)",
            "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id 8B17B100008\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Dec 2020 16:55:50 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 28 Dec 2020 17:55:57 +0100",
        "Message-Id": "<20201228165600.53987-3-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.29.2",
        "In-Reply-To": "<20201228165600.53987-1-jacopo@jmondi.org>",
        "References": "<20201228165600.53987-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v2 2/5] libcamera: camera_sensor:\n\tInitialize controls",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Initialize the ControlInfoMap of sensor available controls by\nreporting the sensor exposure time range.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/internal/camera_sensor.h |  2 +\n src/libcamera/camera_sensor.cpp            | 45 +++++++++++++++++++++-\n 2 files changed, 46 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex aee10aa6e3c7..0357b2a630f7 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -71,6 +71,7 @@ private:\n \tint generateId();\n \tint validateSensorDriver();\n \tint initProperties();\n+\tint initControls();\n \n \tconst MediaEntity *entity_;\n \tstd::unique_ptr<V4L2Subdevice> subdev_;\n@@ -85,6 +86,7 @@ private:\n \tstd::vector<Size> sizes_;\n \n \tControlList properties_;\n+\tControlInfoMap controls_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 71d7c862e69a..18dc6d723e27 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -15,6 +15,7 @@\n #include <regex>\n #include <string.h>\n \n+#include <libcamera/control_ids.h>\n #include <libcamera/property_ids.h>\n \n #include \"libcamera/internal/bayer_format.h\"\n@@ -215,7 +216,7 @@ int CameraSensor::init()\n \tif (ret)\n \t\treturn ret;\n \n-\treturn 0;\n+\treturn initControls();\n }\n \n int CameraSensor::validateSensorDriver()\n@@ -229,6 +230,7 @@ int CameraSensor::validateSensorDriver()\n \tconst std::vector<uint32_t> mandatoryControls{\n \t\tV4L2_CID_PIXEL_RATE,\n \t\tV4L2_CID_HBLANK,\n+\t\tV4L2_CID_EXPOSURE,\n \t};\n \n \tControlList ctrls = subdev_->getControls(mandatoryControls);\n@@ -428,6 +430,47 @@ int CameraSensor::initProperties()\n \treturn 0;\n }\n \n+int CameraSensor::initControls()\n+{\n+\tconst ControlInfoMap &v4l2Controls = subdev_->controls();\n+\n+\t/* Calculate exposure time limits expressed in micro-seconds. */\n+\n+\t/* Calculate the line length in pixels. */\n+\tControlList ctrls = subdev_->getControls({ V4L2_CID_HBLANK });\n+\tif (ctrls.empty())\n+\t\treturn -EINVAL;\n+\tint32_t hblank = ctrls.get(V4L2_CID_HBLANK).get<int32_t>();\n+\n+\tV4L2SubdeviceFormat format{};\n+\tint ret = subdev_->getFormat(pad_, &format);\n+\tif (ret)\n+\t\treturn ret;\n+\tint32_t ppl = format.size.width + hblank;\n+\n+\tconst ControlInfo &v4l2ExposureInfo = v4l2Controls.find(V4L2_CID_EXPOSURE)->second;\n+\tint32_t minExposurePixels = v4l2ExposureInfo.min().get<int32_t>() * ppl;\n+\tint32_t maxExposurePixels = v4l2ExposureInfo.max().get<int32_t>() * ppl;\n+\tint32_t defExposurePixels = v4l2ExposureInfo.def().get<int32_t>() * ppl;\n+\n+\t/* Get the pixel rate (in useconds) and calculate the exposure timings. */\n+\tconst ControlInfo &pixelRateInfo = v4l2Controls.find(V4L2_CID_PIXEL_RATE)->second;\n+\tfloat minPixelRate = pixelRateInfo.min().get<int64_t>() / 1e6f;\n+\tfloat maxPixelRate = pixelRateInfo.max().get<int64_t>() / 1e6f;\n+\tfloat defPixelRate = pixelRateInfo.def().get<int64_t>() / 1e6f;\n+\n+\tint32_t minExposure = static_cast<int32_t>(minExposurePixels / maxPixelRate);\n+\tint32_t maxExposure = static_cast<int32_t>(maxExposurePixels / minPixelRate);\n+\tint32_t defExposure = static_cast<int32_t>(defExposurePixels / defPixelRate);\n+\n+\tControlInfoMap::Map map;\n+\tmap[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n+\t\t\t\t\t\t   defExposure);\n+\tcontrols_ = std::move(map);\n+\n+\treturn 0;\n+}\n+\n /**\n  * \\fn CameraSensor::model()\n  * \\brief Retrieve the sensor model name\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "2/5"
    ]
}