Show a patch.

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

{
    "id": 22069,
    "url": "https://patchwork.libcamera.org/api/patches/22069/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22069/",
    "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": "<20241125151430.2437285-3-stefan.klug@ideasonboard.com>",
    "date": "2024-11-25T15:14:11",
    "name": "[v2,2/8] libcamera: rkisp1: Keep aspect ratio on imx8mp",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "8e7b79df16ce985c8eae235aad02cc431403f059",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22069/mbox/",
    "series": [
        {
            "id": 4818,
            "url": "https://patchwork.libcamera.org/api/series/4818/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4818",
            "date": "2024-11-25T15:14:09",
            "name": "rkisp1: Fix aspect ratio and ScalerCrop",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/4818/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22069/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22069/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 3B9DEC32A3\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 25 Nov 2024 15:14:43 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E2ADA65FA9;\n\tMon, 25 Nov 2024 16:14:42 +0100 (CET)",
            "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 7B9E265F66\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 25 Nov 2024 16:14:40 +0100 (CET)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:4cf:a935:de6f:a329])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8A3A26B5;\n\tMon, 25 Nov 2024 16:14:18 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"fTQyFCDT\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1732547658;\n\tbh=cgO8lxy+ffKobDxcO/AnCPxhEEU35ecVqeqPt8Withs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=fTQyFCDT2gHCqTi8OjS4tRSHBicUnOIB377tHe8Yoa2wn1zwadI0PzPrSVlB36nA8\n\t5WvYUJo78r0cY3KJXaRsGRfdXSESV9HlQLvVM+dOBLp/VZhWXw09KwwxoCB1FBs/hv\n\tZ+7/qM2rq70ESVLNYQx+mo3aUmt9azZiIpon960w=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Subject": "[PATCH v2 2/8] libcamera: rkisp1: Keep aspect ratio on imx8mp",
        "Date": "Mon, 25 Nov 2024 16:14:11 +0100",
        "Message-ID": "<20241125151430.2437285-3-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20241125151430.2437285-1-stefan.klug@ideasonboard.com>",
        "References": "<20241125151430.2437285-1-stefan.klug@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "In the current code, the input stage of the image resizer is used to\napply a crop to keep the aspect ratio in cases where the requested\noutput aspect ratio differs from the one of the selected sensor mode. On\nthe imx8mp the resizer hardware is not capable of cropping (for\nreference see also rkisp1-resizer.c:rkisp1_rsz_set_sink_crop() in the\nlinux kernel v6.10).\n\nTherefore apply the necessary cropping on the output of the ISP (on the\nimage stabilization block). The cropping code on the image resizer\ndoesn't need modifications as the requested crop gets ignored by the\nkernel.\n\nWhile at it, remove a todo comment that is no longer needed.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\n---\n\nChanges in v2:\n- Fixed alignment\n- Improved comments\n- Removed todo comment\n- Collected tags\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      | 16 ++++++++++++++++\n src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 13 ++++++++-----\n 2 files changed, 24 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 5ffcfbce56be..a66b9dda83ab 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -811,6 +811,22 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n \tif (!isRaw_)\n \t\tformat.code = MEDIA_BUS_FMT_YUYV8_2X8;\n \n+\t/*\n+\t * On devices without DUAL_CROP (like the imx8mp) cropping needs to be\n+\t * done on the ISP/IS output.\n+\t */\n+\tif (media_->hwRevision() == RKISP1_V_IMX8MP) {\n+\t\t/* imx8mp has only a single path. */\n+\t\tconst auto &cfg = config->at(0);\n+\t\tSize ispCrop = format.size.boundedToAspectRatio(cfg.size)\n+\t\t\t\t\t  .alignedUpTo(2, 2);\n+\t\trect = ispCrop.centeredTo(Rectangle(format.size).center());\n+\t\tif (ispCrop != format.size)\n+\t\t\tLOG(RkISP1, Info) << \"ISP output needs to be cropped to \"\n+\t\t\t\t\t  << rect;\n+\t\tformat.size = ispCrop;\n+\t}\n+\n \tLOG(RkISP1, Debug)\n \t\t<< \"Configuring ISP output pad with \" << format\n \t\t<< \" crop \" << rect;\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\nindex 236d05af7a2f..eee5b09e2ff0 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n@@ -417,11 +417,14 @@ int RkISP1Path::configure(const StreamConfiguration &config,\n \t/*\n \t * Crop on the resizer input to maintain FOV before downscaling.\n \t *\n-\t * \\todo The alignment to a multiple of 2 pixels is required but may\n-\t * change the aspect ratio very slightly. A more advanced algorithm to\n-\t * compute the resizer input crop rectangle is needed, and it should\n-\t * also take into account the need to crop away the edge pixels affected\n-\t * by the ISP processing blocks.\n+\t * Note that this does not apply to devices without DUAL_CROP support\n+\t * (like imx8mp) , where the cropping needs to be done on the\n+\t * ImageStabilizer block on the ISP source pad and therefore is\n+\t * configured before this stage. For simplicity we still set the crop.\n+\t * This gets ignored by the kernel driver because the hardware is\n+\t * missing the capability.\n+\t *\n+\t * Alignment to a multiple of 2 pixels is required by the resizer.\n \t */\n \tSize ispCrop = inputFormat.size.boundedToAspectRatio(config.size)\n \t\t\t\t       .alignedUpTo(2, 2);\n",
    "prefixes": [
        "v2",
        "2/8"
    ]
}