Show a patch.

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

{
    "id": 10831,
    "url": "https://patchwork.libcamera.org/api/patches/10831/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10831/",
    "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": "<20210106133513.34118-1-me@fabwu.ch>",
    "date": "2021-01-06T13:35:13",
    "name": "[libcamera-devel] libcamera: ipu3: Add rotation to ipu3 pipeline",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "f3084c6ed98c503fd29c9adf0e8571816c0a9051",
    "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/10831/mbox/",
    "series": [
        {
            "id": 1570,
            "url": "https://patchwork.libcamera.org/api/series/1570/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1570",
            "date": "2021-01-06T13:35:13",
            "name": "[libcamera-devel] libcamera: ipu3: Add rotation to ipu3 pipeline",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1570/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10831/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10831/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 057C9C0F1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Jan 2021 13:35:19 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 708EE630BA;\n\tWed,  6 Jan 2021 14:35:18 +0100 (CET)",
            "from gusto4.metanet.ch (gusto4.metanet.ch [80.74.154.158])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1156E6010B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Jan 2021 14:35:17 +0100 (CET)",
            "from localhost (localhost [127.0.0.1]) by gusto4.metanet.ch\n\t(Postfix) with ESMTPSA id 6A3B5100A2B8; \n\tWed,  6 Jan 2021 14:35:16 +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=\"NOkvDU44\";\n\tdkim-atps=neutral",
            "gusto.metanet.ch;\n\tspf=pass (sender IP is 2001:67c:10ec:574f:8000::217)\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=1609940116; bh=iswcJPjo2Mvx43jVLNZLPWa4o97ldHo1tRXNPU3VOT0=;\n\th=From:To:Subject;\n\tb=NOkvDU44+fSHLjvmZSH6Ib/5RnARKgILVFDG8SYO7auZ8c0Q6GhoNV0sBll9OwuSA\n\t+1Gvt9mXd505GBQW0MS/3fc0rVUbbQe5gf4NokguPdWr9IjtBjIlQPRUb9gnz5Uu3k\n\t9pf0llmMPTp5n/iKST78bd3KCYfGfDKlUR/u/1UU=",
        "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": "Wed,  6 Jan 2021 14:35:13 +0100",
        "Message-Id": "<20210106133513.34118-1-me@fabwu.ch>",
        "X-Mailer": "git-send-email 2.30.0",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH] 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---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 76 +++++++++++++++++++++++++++-\n 1 file changed, 74 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex f1151733..76d75a74 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -14,6 +14,7 @@\n #include <libcamera/camera.h>\n #include <libcamera/control_ids.h>\n #include <libcamera/formats.h>\n+#include <libcamera/property_ids.h>\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n@@ -62,6 +63,12 @@ public:\n \tStream outStream_;\n \tStream vfStream_;\n \tStream rawStream_;\n+\n+\t/*\n+\t * Manage horizontal and vertical flips supported (or not) by the\n+\t * sensor.\n+\t */\n+\tbool supportsFlips_;\n };\n \n class IPU3CameraConfiguration : public CameraConfiguration\n@@ -74,6 +81,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@@ -143,11 +153,54 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n \tif (config_.empty())\n \t\treturn Invalid;\n \n-\tif (transform != Transform::Identity) {\n-\t\ttransform = Transform::Identity;\n+\tint32_t rotation = data_->cio2_.sensor()->properties().get(properties::Rotation);\n+\tbool success;\n+\tTransform rotationTransform = transformFromRotation(rotation, &success);\n+\tif (!success)\n+\t\tLOG(IPU3, Warning) << \"Invalid rotation of \" << rotation << \" degrees - ignoring\";\n+\tTransform combined = transform * 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 transform, 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, ad 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 the inverse of the rotation. (Recall that\n+\t\t * combined = transform * rotationTransform.)\n+\t\t */\n+\t\ttransform = -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@@ -540,6 +593,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\tctrls = cio2->sensor()->controls();\n+\t\tctrls.set(V4L2_CID_HFLIP,\n+\t\t\t  static_cast<int32_t>(!!(config->combinedTransform_ & Transform::HFlip)));\n+\t\tctrls.set(V4L2_CID_VFLIP,\n+\t\t\t  static_cast<int32_t>(!!(config->combinedTransform_ & Transform::VFlip)));\n+\t\tcio2->sensor()->setControls(&ctrls);\n+\t}\n+\n \treturn 0;\n }\n \n@@ -779,6 +845,12 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t/* Initialze the camera controls. */\n \t\tdata->controlInfo_ = IPU3Controls;\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+\t\t}\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"
    ]
}