Show a patch.

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

{
    "id": 11291,
    "url": "https://patchwork.libcamera.org/api/patches/11291/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11291/",
    "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": "<20210214204126.41030-1-me@fabwu.ch>",
    "date": "2021-02-14T20:41:26",
    "name": "[libcamera-devel,v4] libcamera: ipu3: Add rotation to ipu3 pipeline",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "372691a09c69fcebda8257865723eb5652d80634",
    "submitter": {
        "id": 77,
        "url": "https://patchwork.libcamera.org/api/people/77/?format=api",
        "name": "Fabian Wüthrich",
        "email": "me@fabwu.ch"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/11291/mbox/",
    "series": [
        {
            "id": 1690,
            "url": "https://patchwork.libcamera.org/api/series/1690/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1690",
            "date": "2021-02-14T20:41:26",
            "name": "[libcamera-devel,v4] libcamera: ipu3: Add rotation to ipu3 pipeline",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/1690/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11291/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11291/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 1AE12BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 14 Feb 2021 20:42:04 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 93C3D637AA;\n\tSun, 14 Feb 2021 21:42:03 +0100 (CET)",
            "from gusto4.metanet.ch (gusto4.metanet.ch [80.74.154.158])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 40FF860106\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 14 Feb 2021 21:42:00 +0100 (CET)",
            "from localhost (localhost [127.0.0.1]) by gusto4.metanet.ch\n\t(Postfix) with ESMTPSA id DCCFA4F00FD5; \n\tSun, 14 Feb 2021 21:41:59 +0100 (CET)"
        ],
        "Authentication-Results": [
            "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=fabwu.ch header.i=@fabwu.ch header.b=\"3VFrMEtI\";\n\tdkim-atps=neutral",
            "gusto.metanet.ch;\n\tspf=pass (sender IP is 2a02:1206:458b:9c20:8cba:f18c:ae7e:4c8b)\n\tsmtp.mailfrom=me@fabwu.ch smtp.helo=localhost"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=fabwu.ch; s=default; \n\tt=1613335320; bh=jYy4Nzk0HN3G/pklgK0ipqwQkfoJpfgsP5wotRvdYUo=;\n\th=From:To:Subject;\n\tb=3VFrMEtIY2GJd+yZDolPblMVZOlZMMzJntniBHcVsgsq2QwCBXIocrc0ap6Sbckm9\n\tuDxwKTkkJcPBeOC7V8d75t26mFzKiaSZADA3/fE7DbshvvMcxQg2AwGOsWVSgtcCEM\n\tV+YYcgtRGBMU1245xnS7KpaSvyR8lGwfG+SXYqAg=",
        "Received-SPF": "pass (gusto.metanet.ch: connection is authenticated)",
        "From": "=?utf-8?q?Fabian_W=C3=BCthrich?= <me@fabwu.ch>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun, 14 Feb 2021 21:41:26 +0100",
        "Message-Id": "<20210214204126.41030-1-me@fabwu.ch>",
        "X-Mailer": "git-send-email 2.30.1",
        "In-Reply-To": "<20210122120132.3717-1-me@fabwu.ch>",
        "References": "<20210122120132.3717-1-me@fabwu.ch>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v4] libcamera: ipu3: Add rotation to ipu3\n\tpipeline",
        "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=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Use the same transformation logic as in the raspberry pipeline to\nimplement rotations in the ipu3 pipeline.\n\nTested on a Surface Book 2 with an experimental driver for OV5693.\n\nSigned-off-by: Fabian Wüthrich <me@fabwu.ch>\n---\nChanges in v2:\n - Cache rotationTransform in CameraData\n - Use separate controls for sensor\n\nChanges in v3:\n - Default rotation to 0 if sensor doesn't expose it\n\nChanges in v4:\n - Init rotation to 0\n - Drop unnecessary braces\n\n src/libcamera/pipeline/ipu3/ipu3.cpp | 80 +++++++++++++++++++++++++++-\n 1 file changed, 78 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 61f7bf43..550984d1 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -15,6 +15,7 @@\n #include <libcamera/control_ids.h>\n #include <libcamera/formats.h>\n #include <libcamera/ipa/ipu3.h>\n+#include <libcamera/property_ids.h>\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n@@ -74,6 +75,9 @@ public:\n \n \tuint32_t exposureTime_;\n \tRectangle cropRegion_;\n+\tbool supportsFlips_;\n+\tTransform rotationTransform_;\n+\n \tstd::unique_ptr<DelayedControls> delayedCtrls_;\n \tIPU3Frames frameInfos_;\n \n@@ -91,6 +95,9 @@ public:\n \tconst StreamConfiguration &cio2Format() const { return cio2Configuration_; }\n \tconst ImgUDevice::PipeConfig imguConfig() const { return pipeConfig_; }\n \n+\t/* Cache the combinedTransform_ that will be applied to the sensor */\n+\tTransform combinedTransform_;\n+\n private:\n \t/*\n \t * The IPU3CameraData instance is guaranteed to be valid as long as the\n@@ -163,11 +170,49 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n \tif (config_.empty())\n \t\treturn Invalid;\n \n-\tif (transform != Transform::Identity) {\n-\t\ttransform = Transform::Identity;\n+\tTransform combined = transform * data_->rotationTransform_;\n+\n+\t/*\n+\t * We combine the platform and user transform, but must \"adjust away\"\n+\t * any combined result that includes a transposition, as we can't do those.\n+\t * In this case, flipping only the transpose bit is helpful to\n+\t * applications - they either get the transform they requested, or have\n+\t * to do a simple transpose themselves (they don't have to worry about\n+\t * the other possible cases).\n+\t */\n+\tif (!!(combined & Transform::Transpose)) {\n+\t\t/*\n+\t\t * Flipping the transpose bit in \"transform\" flips it in the\n+\t\t * combined result too (as it's the last thing that happens),\n+\t\t * which is of course clearing it.\n+\t\t */\n+\t\ttransform ^= Transform::Transpose;\n+\t\tcombined &= ~Transform::Transpose;\n+\t\tstatus = Adjusted;\n+\t}\n+\n+\t/*\n+\t * We also check if the sensor doesn't do h/vflips at all, in which\n+\t * case we clear them, and the application will have to do everything.\n+\t */\n+\tif (!data_->supportsFlips_ && !!combined) {\n+\t\t/*\n+\t\t * If the sensor can do no transforms, then combined must be\n+\t\t * changed to the identity. The only user transform that gives\n+\t\t * rise to this is the inverse of the rotation. (Recall that\n+\t\t * combined = transform * rotationTransform.)\n+\t\t */\n+\t\ttransform = -data_->rotationTransform_;\n+\t\tcombined = Transform::Identity;\n \t\tstatus = Adjusted;\n \t}\n \n+\t/*\n+\t * Store the final combined transform that configure() will need to\n+\t * apply to the sensor to save us working it out again.\n+\t */\n+\tcombinedTransform_ = combined;\n+\n \t/* Cap the number of entries to the available streams. */\n \tif (config_.size() > IPU3_MAX_STREAMS) {\n \t\tconfig_.resize(IPU3_MAX_STREAMS);\n@@ -560,6 +605,19 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \t\treturn ret;\n \t}\n \n+\t/*\n+\t * Configure the H/V flip controls based on the combination of\n+\t * the sensor and user transform.\n+\t */\n+\tif (data->supportsFlips_) {\n+\t\tControlList sensor_ctrls(cio2->sensor()->controls());\n+\t\tsensor_ctrls.set(V4L2_CID_HFLIP,\n+\t\t\t\t static_cast<int32_t>(!!(config->combinedTransform_ & Transform::HFlip)));\n+\t\tsensor_ctrls.set(V4L2_CID_VFLIP,\n+\t\t\t\t static_cast<int32_t>(!!(config->combinedTransform_ & Transform::VFlip)));\n+\t\tcio2->sensor()->setControls(&sensor_ctrls);\n+\t}\n+\n \treturn 0;\n }\n \n@@ -999,6 +1057,24 @@ int PipelineHandlerIPU3::registerCameras()\n \t\tdata->cio2_.frameStart().connect(data->delayedCtrls_.get(),\n \t\t\t\t\t\t &DelayedControls::applyControls);\n \n+\t\t/* Convert the sensor rotation to a transformation */\n+\t\tint32_t rotation = 0;\n+\t\tif (data->properties_.contains(properties::Rotation))\n+\t\t\trotation = data->properties_.get(properties::Rotation);\n+\t\telse\n+\t\t\tLOG(IPU3, Warning) << \"Rotation control not exposed by \" << cio2->sensor()->id()\n+\t\t\t\t\t   << \". Assume rotation 0.\";\n+\n+\t\tbool success;\n+\t\tdata->rotationTransform_ = transformFromRotation(rotation, &success);\n+\t\tif (!success)\n+\t\t\tLOG(IPU3, Warning) << \"Invalid rotation of \" << rotation << \" degrees - ignoring\";\n+\n+\t\tControlList ctrls = cio2->sensor()->getControls({ V4L2_CID_HFLIP });\n+\t\tif (!ctrls.empty())\n+\t\t\t/* We assume it will support vflips too... */\n+\t\t\tdata->supportsFlips_ = true;\n+\n \t\t/**\n \t\t * \\todo Dynamically assign ImgU and output devices to each\n \t\t * stream and camera; as of now, limit support to two cameras\n",
    "prefixes": [
        "libcamera-devel",
        "v4"
    ]
}