Show a patch.

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

{
    "id": 19870,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/19870/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19870/",
    "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": "<20240416091357.211951-2-mzamazal@redhat.com>",
    "date": "2024-04-16T09:13:37",
    "name": "[v8,01/18] libcamera: pipeline: simple: fix size adjustment in validate()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "20110899141e3d3180d8f8f1eb0872cc86091e0c",
    "submitter": {
        "id": 177,
        "url": "https://patchwork.libcamera.org/api/1.1/people/177/?format=api",
        "name": "Milan Zamazal",
        "email": "mzamazal@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19870/mbox/",
    "series": [
        {
            "id": 4257,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4257/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4257",
            "date": "2024-04-16T09:13:36",
            "name": "libcamera: introduce Software ISP and Software IPA",
            "version": 8,
            "mbox": "https://patchwork.libcamera.org/series/4257/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19870/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19870/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 E65D6BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Apr 2024 09:14:29 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 988BC63360;\n\tTue, 16 Apr 2024 11:14:29 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0711C61B4F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Apr 2024 11:14:27 +0200 (CEST)",
            "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n\t[66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-397-TXeS9z5nPdCOMYIciRB96A-1; Tue, 16 Apr 2024 05:14:22 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED82F1887317;\n\tTue, 16 Apr 2024 09:14:21 +0000 (UTC)",
            "from nuthatch.redhat.com (unknown [10.45.225.245])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id ABB312026D06;\n\tTue, 16 Apr 2024 09:14:19 +0000 (UTC)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"UbUApC/O\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1713258866;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=MfX9ZKKKoj2RJT2yKsfJyo/tLfrArroq5HIAZ/YlauQ=;\n\tb=UbUApC/OVWN0/Yfe9xG4yBnE0az5wcd3MjAgvyEjGGeYdPD5FdYyrpntUdhw78UUjH5Vjh\n\t4iPtGhMqyTVvDfVZc1Qirt2obj8ZjTLtShUFt7RHWuC+j9svsvDAOPfjw9HiInH+hWZ+db\n\tr0aBRAxGxZlW+STDWnMH0og+7mfkvks=",
        "X-MC-Unique": "TXeS9z5nPdCOMYIciRB96A-1",
        "From": "Milan Zamazal <mzamazal@redhat.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Andrey Konovalov <andrey.konovalov@linaro.org>,\n\tMilan Zamazal <mzamazal@redhat.com>,\n\tAndrei Konovalov <andrey.konovalov.ynk@gmail.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tMaxime Ripard <mripard@redhat.com>, Pavel Machek <pavel@ucw.cz>,\n\tHans de Goede <hdegoede@redhat.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Subject": "[PATCH v8 01/18] libcamera: pipeline: simple: fix size adjustment in\n\tvalidate()",
        "Date": "Tue, 16 Apr 2024 11:13:37 +0200",
        "Message-ID": "<20240416091357.211951-2-mzamazal@redhat.com>",
        "In-Reply-To": "<20240416091357.211951-1-mzamazal@redhat.com>",
        "References": "<20240416091357.211951-1-mzamazal@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.4",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "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": "From: Andrey Konovalov <andrey.konovalov@linaro.org>\n\nSimpleCameraConfiguration::validate() adjusts the configuration of its\nstreams (if the size is not in the outputSizes) to the captureSize. But\nthe captureSize itself can be not in the outputSizes, and then the\nadjusted configuration won't be valid resulting in camera configuration\nfailure.\n\nTested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s\nTested-by: Pavel Machek <pavel@ucw.cz>\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nReviewed-by: Pavel Machek <pavel@ucw.cz>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n---\n src/libcamera/pipeline/simple/simple.cpp | 40 ++++++++++++++++++++++--\n 1 file changed, 38 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 01f2a977..d2b88795 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -882,6 +882,33 @@ SimpleCameraConfiguration::SimpleCameraConfiguration(Camera *camera,\n {\n }\n \n+namespace {\n+\n+static Size adjustSize(const Size &requestedSize, const SizeRange &supportedSizes)\n+{\n+\tASSERT(supportedSizes.min <= supportedSizes.max);\n+\n+\tif (supportedSizes.min == supportedSizes.max)\n+\t\treturn supportedSizes.max;\n+\n+\tunsigned int hStep = supportedSizes.hStep;\n+\tunsigned int vStep = supportedSizes.vStep;\n+\n+\tif (hStep == 0)\n+\t\thStep = supportedSizes.max.width - supportedSizes.min.width;\n+\tif (vStep == 0)\n+\t\tvStep = supportedSizes.max.height - supportedSizes.min.height;\n+\n+\tSize adjusted = requestedSize.boundedTo(supportedSizes.max)\n+\t\t\t\t.expandedTo(supportedSizes.min);\n+\n+\treturn adjusted.shrunkBy(supportedSizes.min)\n+\t\t.alignedDownTo(hStep, vStep)\n+\t\t.grownBy(supportedSizes.min);\n+}\n+\n+} /* namespace */\n+\n CameraConfiguration::Status SimpleCameraConfiguration::validate()\n {\n \tconst CameraSensor *sensor = data_->sensor_.get();\n@@ -998,10 +1025,19 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()\n \t\t}\n \n \t\tif (!pipeConfig_->outputSizes.contains(cfg.size)) {\n+\t\t\tSize adjustedSize = pipeConfig_->captureSize;\n+\t\t\t/*\n+\t\t\t * The converter (when present) may not be able to output\n+\t\t\t * a size identical to its input size. The capture size is thus\n+\t\t\t * not guaranteed to be a valid output size. In such cases, use\n+\t\t\t * the smaller valid output size closest to the requested.\n+\t\t\t */\n+\t\t\tif (!pipeConfig_->outputSizes.contains(adjustedSize))\n+\t\t\t\tadjustedSize = adjustSize(cfg.size, pipeConfig_->outputSizes);\n \t\t\tLOG(SimplePipeline, Debug)\n \t\t\t\t<< \"Adjusting size from \" << cfg.size\n-\t\t\t\t<< \" to \" << pipeConfig_->captureSize;\n-\t\t\tcfg.size = pipeConfig_->captureSize;\n+\t\t\t\t<< \" to \" << adjustedSize;\n+\t\t\tcfg.size = adjustedSize;\n \t\t\tstatus = Adjusted;\n \t\t}\n \n",
    "prefixes": [
        "v8",
        "01/18"
    ]
}