Show a patch.

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

{
    "id": 10881,
    "url": "https://patchwork.libcamera.org/api/patches/10881/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10881/",
    "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": "<20210116150257.2970-1-me@fabwu.ch>",
    "date": "2021-01-16T15:02:58",
    "name": "[libcamera-devel,v2] libcamera: ipu3: Add rotation to ipu3 pipeline",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "64d457eef0f6e8e70128bff44d8640a553af99fb",
    "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/10881/mbox/",
    "series": [
        {
            "id": 1580,
            "url": "https://patchwork.libcamera.org/api/series/1580/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1580",
            "date": "2021-01-16T15:02:58",
            "name": "[libcamera-devel,v2] libcamera: ipu3: Add rotation to ipu3 pipeline",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/1580/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10881/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10881/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 C6459BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 16 Jan 2021 15:03:25 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1E78E68115;\n\tSat, 16 Jan 2021 16:03:25 +0100 (CET)",
            "from gusto4.metanet.ch (gusto4.metanet.ch [80.74.154.158])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A35E168105\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 16 Jan 2021 16:03:23 +0100 (CET)",
            "from localhost (localhost [127.0.0.1]) by gusto4.metanet.ch\n\t(Postfix) with ESMTPSA id 22C6A4F01731; \n\tSat, 16 Jan 2021 16:03:23 +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=\"lexGi15t\";\n\tdkim-atps=neutral",
            "gusto.metanet.ch;\n\tspf=pass (sender IP is 2001:1715:9d9c:4e40:649e:8d07:9d6c:59c2)\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=1610809403; bh=WM8QoHoR3pjUUgucDwvIYhvePAGn9BSCEa+l2+D2gsw=;\n\th=From:To:Subject;\n\tb=lexGi15tqNUPf733HWKijeEuJsFqzsSzVsviYrkHKzFGVIZPUnCykN7yYaCheqre9\n\tCJXJqgxuj/Z9CPFjpjuUOL10LAP0GbK/T5x3QNcoZYHPvrZDaRqUKBaFHNJLGFjZOI\n\t6WfYhFyw07HZEv5Q3h1geMPUFtldP5gHALPmvJ9Y=",
        "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": "Sat, 16 Jan 2021 16:02:58 +0100",
        "Message-Id": "<20210116150257.2970-1-me@fabwu.ch>",
        "X-Mailer": "git-send-email 2.30.0",
        "In-Reply-To": "<20210106133513.34118-1-me@fabwu.ch>",
        "References": "<20210106133513.34118-1-me@fabwu.ch>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v2] 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\n src/libcamera/pipeline/ipu3/ipu3.cpp | 81 +++++++++++++++++++++++++++-\n 1 file changed, 79 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 73304ea7..8db5f2f1 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,15 @@ public:\n \tStream outStream_;\n \tStream vfStream_;\n \tStream rawStream_;\n+\n+\t/* Save transformation given by the sensor rotation */\n+\tTransform rotationTransform_;\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 +84,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 +156,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@@ -540,6 +591,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@@ -775,9 +839,22 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t/* Initialize the camera properties. */\n \t\tdata->properties_ = cio2->sensor()->properties();\n \n+\t\t/* Convert the sensor rotation to a transformation */\n+\t\tint32_t rotation = data->properties_.get(properties::Rotation);\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\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",
        "v2"
    ]
}