Show a patch.

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

{
    "id": 19149,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/19149/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19149/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20231019140133.32090-2-jacopo.mondi@ideasonboard.com>",
    "date": "2023-10-19T14:01:22",
    "name": "[libcamera-devel,v6,01/12] libcamera: camera_sensor: Cache rotationTransform_",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "da06f4fafdad4cf4b74b0d6d69fd7bf52cd0bff4",
    "submitter": {
        "id": 143,
        "url": "https://patchwork.libcamera.org/api/1.1/people/143/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo.mondi@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19149/mbox/",
    "series": [
        {
            "id": 4053,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4053/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4053",
            "date": "2023-10-19T14:01:21",
            "name": "libcamera: Replace CameraConfiguration::transform",
            "version": 6,
            "mbox": "https://patchwork.libcamera.org/series/4053/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19149/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19149/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 F180EC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Oct 2023 14:01:52 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9E6CA6298C;\n\tThu, 19 Oct 2023 16:01:52 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 53A7762982\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Oct 2023 16:01:50 +0200 (CEST)",
            "from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 82E8E735;\n\tThu, 19 Oct 2023 16:01:41 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697724112;\n\tbh=qzATXSHm72d3aHaV/WK7YBAxRxoxUrHeW6c5YnGSVDo=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=mHL94N7H3lJYhKpsNi13VSxA0ge9yHWGtpo9K0xGiow4GXckOOKc2fmT9IArO39c3\n\titUnOk1nfc76tcSfgQnVoFKlW7EovYx2HCmF9WNePW8kvhR8pqQszRjb4+6aRph6X0\n\tuxk/OsRaWNDGS2xpBQPTML7ATIlJSjv2GQKdrAV5PMXgCvqJg5P87BheuCl4E4iSCF\n\tAv6LhGQfg/q0gi8IX5mpM0MowyqADOBZZPIKrmKwtk+Xlk5C0UJxcMy9pg+Zs4tV1X\n\tJfxF2CwajSj3Ipc/JkTqfXf1rFlYE76D1MFvsxIAXJvDepcOHn3ccPdq85s9hZ1W8C\n\tXbdoPWZSnkBTQ==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1697724101;\n\tbh=qzATXSHm72d3aHaV/WK7YBAxRxoxUrHeW6c5YnGSVDo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=GgZuOt6VBN7Y+bhOuRGHfZ0eqfHb4yTI93L78L5bvh/voQYqqz0uk95zyIjxTpoDQ\n\tgs0WEll/OBZZN+lveZPPgjflUMLuet/wPlF1ORFb/uQYJzOi5UDxwa439MQEmEczrD\n\t0zoNlfh4u1ShvgS53elpB8G0KI6wgwyDb7uzNq3k="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"GgZuOt6V\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 19 Oct 2023 16:01:22 +0200",
        "Message-ID": "<20231019140133.32090-2-jacopo.mondi@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.42.0",
        "In-Reply-To": "<20231019140133.32090-1-jacopo.mondi@ideasonboard.com>",
        "References": "<20231019140133.32090-1-jacopo.mondi@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v6 01/12] libcamera: camera_sensor: Cache\n\trotationTransform_",
        "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>",
        "From": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The rotationTransform_ depends on a V4L2 control whose value does not\nchange for the whole lifetime of the camera.\n\nInstead of re-calculating it everytime the camera is configured, cache\nit at properties initialization time.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n include/libcamera/internal/camera_sensor.h |  1 +\n src/libcamera/camera_sensor.cpp            | 54 +++++++++++++---------\n 2 files changed, 32 insertions(+), 23 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex 06791c3c6425..0b2ece317b2a 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -112,6 +112,7 @@ private:\n \tRectangle activeArea_;\n \tconst BayerFormat *bayerFormat_;\n \tbool supportFlips_;\n+\tTransform rotationTransform_;\n \n \tControlList properties_;\n \ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 7baa08b38140..e3826cebeeff 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -462,18 +462,36 @@ int CameraSensor::initProperties()\n \n \tconst auto &rotationControl = controls.find(V4L2_CID_CAMERA_SENSOR_ROTATION);\n \tif (rotationControl != controls.end()) {\n+\t\tpropertyValue = rotationControl->second.def().get<int32_t>();\n+\n \t\t/*\n-\t\t * validateTransform() compensates for the mounting rotation.\n-\t\t * However, as a camera sensor can only compensate rotations\n-\t\t * by applying H/VFlips, only rotation of 180 degrees are\n-\t\t * automatically compensated. The other valid rotations (Rot90\n-\t\t * and Rot270) require transposition, which the camera sensor\n-\t\t * cannot perform, so leave them untouched.\n+\t\t * Cache the Transform associated with the camera mounting\n+\t\t * rotation for later use in validateTransform().\n+\t\t */\n+\t\tbool success;\n+\t\trotationTransform_ = transformFromRotation(propertyValue, &success);\n+\t\tif (!success) {\n+\t\t\tLOG(CameraSensor, Warning)\n+\t\t\t\t<< \"Invalid rotation of \" << propertyValue\n+\t\t\t\t<< \" degrees - ignoring\";\n+\t\t\trotationTransform_ = Transform::Identity;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Adjust property::Rotation as validateTransform() compensates\n+\t\t * for the mounting rotation. However, as a camera sensor can\n+\t\t * only compensate rotations by applying H/VFlips, only rotation\n+\t\t * of 180 degrees are automatically compensated. The other valid\n+\t\t * rotations (Rot90 and Rot270) require transposition, which the\n+\t\t * camera sensor cannot perform, so leave them untouched.\n \t\t */\n-\t\tpropertyValue = rotationControl->second.def().get<int32_t>();\n \t\tif (propertyValue == 180 && supportFlips_)\n \t\t\tpropertyValue = 0;\n \t\tproperties_.set(properties::Rotation, propertyValue);\n+\t} else {\n+\t\tLOG(CameraSensor, Warning)\n+\t\t\t<< \"Rotation control not available, default to 0 degrees\";\n+\t\trotationTransform_ = Transform::Identity;\n \t}\n \n \tproperties_.set(properties::PixelArraySize, pixelArraySize_);\n@@ -1123,21 +1141,11 @@ void CameraSensor::updateControlInfo()\n  */\n Transform CameraSensor::validateTransform(Transform *transform) const\n {\n-\t/* Adjust the requested transform to compensate the sensor mounting rotation. */\n-\tconst ControlInfoMap &controls = subdev_->controls();\n-\tint rotation = 0;\n-\n-\tconst auto &rotationControl = controls.find(V4L2_CID_CAMERA_SENSOR_ROTATION);\n-\tif (rotationControl != controls.end())\n-\t\trotation = rotationControl->second.def().get<int32_t>();\n-\n-\tbool success;\n-\tTransform rotationTransform = transformFromRotation(rotation, &success);\n-\tif (!success)\n-\t\tLOG(CameraSensor, Warning) << \"Invalid rotation of \" << rotation\n-\t\t\t\t\t   << \" degrees - ignoring\";\n-\n-\tTransform combined = *transform * rotationTransform;\n+\t/*\n+\t * Combine the requested transform to compensate the sensor mounting\n+\t * rotation.\n+\t */\n+\tTransform combined = *transform * rotationTransform_;\n \n \t/*\n \t * We combine the platform and user transform, but must \"adjust away\"\n@@ -1168,7 +1176,7 @@ Transform CameraSensor::validateTransform(Transform *transform) const\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\t*transform = -rotationTransform;\n+\t\t*transform = -rotationTransform_;\n \t\tcombined = Transform::Identity;\n \t}\n \n",
    "prefixes": [
        "libcamera-devel",
        "v6",
        "01/12"
    ]
}