Show a patch.

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

{
    "id": 18734,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18734/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18734/",
    "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": "<20230614105957.15651-1-jacopo.mondi@ideasonboard.com>",
    "date": "2023-06-14T10:59:57",
    "name": "[libcamera-devel] libcamera: camera_sensor: Adjust properties::Rotation",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "aab643b4c4027fbc40660a0419904066742998e2",
    "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/18734/mbox/",
    "series": [
        {
            "id": 3922,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3922/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3922",
            "date": "2023-06-14T10:59:57",
            "name": "[libcamera-devel] libcamera: camera_sensor: Adjust properties::Rotation",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3922/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18734/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18734/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 64DE0BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 14 Jun 2023 11:00:09 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B01DC61E4D;\n\tWed, 14 Jun 2023 13:00:08 +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 9556161E4A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 14 Jun 2023 13:00:06 +0200 (CEST)",
            "from uno.lan (unknown [IPv6:2001:b07:5d2e:52c9:72c3:346:a663:c82d])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8C576BC;\n\tWed, 14 Jun 2023 12:59:35 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1686740408;\n\tbh=eQROTdT7ZMJSPQdwWt73f6ycgzTO5ppoxUmme3gpSds=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=2TZAKoyeBXmI3INHPVJM705e0MjwcEFALqGp/Z2HMzB4sRcC6IPQH+PaXw+aRlDn3\n\t8qzmn7x1VWf6wLiyg5fHYSQP9o4NQNFrqp6D5E8TtHkiYxf2ErjFLKRaDgWz4TrW84\n\tHrmIRONTDYDyFhNR4N3Ck/kiGH+LXhX5U+Ob9SDB8azL4lnQZZ7MXNKumnQWQbJDp0\n\tOCDpU4nWIdS1xDE6hIKsTrcS4VoMHAJweYOJdzhKnu933cfD8KXOFCZugCZod/OiOK\n\t7KZu8de+sgN4vBff9pgw5QfsYj4MAfwDdirULE9LdJjtLffnfMWbzX3G1v7p6mTdnC\n\tYLgRnuIfDqgsA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1686740375;\n\tbh=eQROTdT7ZMJSPQdwWt73f6ycgzTO5ppoxUmme3gpSds=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=FqrwsLGRSZ+Up17v4FP1iGOlDSIvYLgcPDRw5EEk0TaDKvPkmNV+fv0uh+8b4LK8B\n\tKUbj5tue9Z7s4eh+5Bbeu7de2uhJIBjt2pJOmDE/ZxaTvvSDlSQ1aEzdeYzw30R1p3\n\t8Dj75np/bz83IBQZkj6bpfc0nndjVfOGMJcWYOVE="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"FqrwsLGR\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 14 Jun 2023 12:59:57 +0200",
        "Message-Id": "<20230614105957.15651-1-jacopo.mondi@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.40.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] libcamera: camera_sensor: Adjust\n\tproperties::Rotation",
        "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": "As the CameraSensor::validateTransform() function compensate\nfor the sensor's mounting rotation, the properties::Rotation value\nshould be adjusted to make sure application that receive already\n\"corrected\" images do not get confused by Rotation still reporting\na value.\n\nHowever, as an image sensor can only compensate rotations by applying\nH/V flips, only correct Rotation when the mounting rotation is 180\ndegrees.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/libcamera/camera.cpp        |  3 +--\n src/libcamera/camera_sensor.cpp | 21 ++++++++++++++++++---\n 2 files changed, 19 insertions(+), 5 deletions(-)\n\n--\n2.40.1",
    "diff": "diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 99683e498697..3e252f3b8f8d 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -397,8 +397,7 @@ CameraConfiguration::Status CameraConfiguration::validateColorSpaces(ColorSpaceF\n  *\n  * The transform is a user-specified 2D plane transform that will be applied\n  * to the camera images by the processing pipeline before being handed to\n- * the application. This is subsequent to any transform that is already\n- * required to fix up any platform-defined rotation.\n+ * the application.\n  *\n  * The usual 2D plane transforms are allowed here (horizontal/vertical\n  * flips, multiple of 90-degree rotations etc.), but the validate() function\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 60bf87b49e6e..f3a5aa37149f 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -461,7 +461,17 @@ int CameraSensor::initProperties()\n\n \tconst auto &rotationControl = controls.find(V4L2_CID_CAMERA_SENSOR_ROTATION);\n \tif (rotationControl != controls.end()) {\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 */\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}\n\n@@ -1028,10 +1038,15 @@ void CameraSensor::updateControlInfo()\n  */\n Transform CameraSensor::validateTransform(Transform *transform) const\n {\n-\t/* Adjust the requested transform to compensate the sensor rotation. */\n-\tint32_t rotation = properties().get(properties::Rotation).value_or(0);\n-\tbool success;\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",
    "prefixes": [
        "libcamera-devel"
    ]
}