Show a patch.

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

{
    "id": 10817,
    "url": "https://patchwork.libcamera.org/api/patches/10817/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10817/",
    "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": "<20210105190522.682324-4-jacopo@jmondi.org>",
    "date": "2021-01-05T19:05:13",
    "name": "[libcamera-devel,03/12] libcamera: ipu3: Register Exposure control",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "78a3e85ac4abef9c0208a27730891d1d7867dbde",
    "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/10817/mbox/",
    "series": [
        {
            "id": 1568,
            "url": "https://patchwork.libcamera.org/api/series/1568/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1568",
            "date": "2021-01-05T19:05:10",
            "name": "android: Exposure times + scaler crop + android metadata",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1568/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10817/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10817/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 580D8C0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  5 Jan 2021 19:05:18 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7EAC9631B9;\n\tTue,  5 Jan 2021 20:05:16 +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 B56576220D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Jan 2021 20:05:14 +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 7D352100003\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Jan 2021 19:05:14 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  5 Jan 2021 20:05:13 +0100",
        "Message-Id": "<20210105190522.682324-4-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.29.2",
        "In-Reply-To": "<20210105190522.682324-1-jacopo@jmondi.org>",
        "References": "<20210105190522.682324-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 03/12] libcamera: ipu3: Register Exposure\n\tcontrol",
        "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": "Calculate the controls::Exposure limits at camera registration time\nand register it in the list of camera supported controls.\n\nCache the default exposure value to report it in the request metadata.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 67 ++++++++++++++++++++++++++--\n 1 file changed, 63 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex f1151733d9fe..879057dab328 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -41,7 +41,7 @@ static constexpr unsigned int IMGU_OUTPUT_HEIGHT_ALIGN = 4;\n static constexpr unsigned int IMGU_OUTPUT_WIDTH_MARGIN = 64;\n static constexpr unsigned int IMGU_OUTPUT_HEIGHT_MARGIN = 32;\n \n-static const ControlInfoMap IPU3Controls = {\n+static const ControlInfoMap::Map IPU3Controls = {\n \t{ &controls::draft::PipelineDepth, ControlInfo(2, 3) },\n };\n \n@@ -49,7 +49,7 @@ class IPU3CameraData : public CameraData\n {\n public:\n \tIPU3CameraData(PipelineHandler *pipe)\n-\t\t: CameraData(pipe)\n+\t\t: CameraData(pipe), exposureTime_(0)\n \t{\n \t}\n \n@@ -62,6 +62,8 @@ public:\n \tStream outStream_;\n \tStream vfStream_;\n \tStream rawStream_;\n+\n+\tint32_t exposureTime_;\n };\n \n class IPU3CameraConfiguration : public CameraConfiguration\n@@ -119,6 +121,7 @@ private:\n \t\t\tPipelineHandler::cameraData(camera));\n \t}\n \n+\tint initControls(IPU3CameraData *data);\n \tint registerCameras();\n \n \tint allocateBuffers(Camera *camera);\n@@ -731,6 +734,60 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n \treturn ret == 0;\n }\n \n+/*\n+ * \\brief Initialize the camera controls\n+ * \\param[in] data The camera data\n+ *\n+ * Initialize the camera controls by registering the pipeline handler\n+ * ones along with the controls assembled by inspecting the sensor\n+ * capabilities.\n+ *\n+ * \\return 0 on success or a negative error code for error\n+ */\n+int PipelineHandlerIPU3::initControls(IPU3CameraData *data)\n+{\n+\tconst CameraSensor *sensor = data->cio2_.sensor();\n+\tCameraSensorInfo sensorInfo{};\n+\n+\tint ret = sensor->sensorInfo(&sensorInfo);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tControlInfoMap::Map controls = IPU3Controls;\n+\n+\t/*\n+\t * Compute exposure time limits.\n+\t *\n+\t * \\todo The exposure limits depend on the sensor configuration.\n+\t * Initialize the control using the line lenght and pixel rate of the\n+\t * current configurtion, as reported by the CameraSensorInfo. Use the\n+\t * V4L2_CID_EXPOSURE control to get exposure min and max and convert it\n+\t * from lines into micro-seconds.\n+\t */\n+\tfloat pixelRate = sensorInfo.pixelRate / 1e6f;\n+\tconst ControlInfoMap &sensorControls = sensor->controls();\n+\tconst ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n+\tint32_t minExposure = v4l2Exposure.min().get<int32_t>()\n+\t\t\t    * sensorInfo.lineLength / pixelRate;\n+\tint32_t maxExposure = v4l2Exposure.max().get<int32_t>()\n+\t\t\t    * sensorInfo.lineLength / pixelRate;\n+\tint32_t defExposure = v4l2Exposure.def().get<int32_t>()\n+\t\t\t    * sensorInfo.lineLength / pixelRate;\n+\n+\t/*\n+\t * \\todo Report the actual exposure time, use the default for the\n+\t * moment.\n+\t */\n+\tdata->exposureTime_ = defExposure;\n+\n+\tcontrols[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n+\t\t\t\t\t\t\tdefExposure);\n+\n+\tdata->controlInfo_ = std::move(controls);\n+\n+\treturn 0;\n+}\n+\n /**\n  * \\brief Initialise ImgU and CIO2 devices associated with cameras\n  *\n@@ -776,8 +833,9 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t/* Initialize the camera properties. */\n \t\tdata->properties_ = cio2->sensor()->properties();\n \n-\t\t/* Initialze the camera controls. */\n-\t\tdata->controlInfo_ = IPU3Controls;\n+\t\tret = initControls(data.get());\n+\t\tif (ret)\n+\t\t\tcontinue;\n \n \t\t/**\n \t\t * \\todo Dynamically assign ImgU and output devices to each\n@@ -842,6 +900,7 @@ void IPU3CameraData::imguOutputBufferReady(FrameBuffer *buffer)\n \n \t/* Mark the request as complete. */\n \trequest->metadata().set(controls::draft::PipelineDepth, 3);\n+\trequest->metadata().set(controls::ExposureTime, exposureTime_);\n \tpipe_->completeRequest(request);\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "03/12"
    ]
}