Show a patch.

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

{
    "id": 19360,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/19360/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19360/",
    "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": "<20240104113855.23865-1-naush@raspberrypi.com>",
    "date": "2024-01-04T11:38:55",
    "name": "[libcamera-devel,v2] ipa: rpi: Add hardware line rate constraints",
    "commit_ref": "271598618d81c99fa047f22297df56433321f9b7",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "6f2c97241b3927152993843629f65da373062bd8",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19360/mbox/",
    "series": [
        {
            "id": 4131,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4131/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4131",
            "date": "2024-01-04T11:38:55",
            "name": "[libcamera-devel,v2] ipa: rpi: Add hardware line rate constraints",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/4131/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19360/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19360/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 F2F4BBDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Jan 2024 11:39:04 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C49562B41;\n\tThu,  4 Jan 2024 12:39:04 +0100 (CET)",
            "from mail-wm1-x329.google.com (mail-wm1-x329.google.com\n\t[IPv6:2a00:1450:4864:20::329])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 03E8F61D82\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Jan 2024 12:39:02 +0100 (CET)",
            "by mail-wm1-x329.google.com with SMTP id\n\t5b1f17b1804b1-40d88fff7faso3498005e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 04 Jan 2024 03:39:01 -0800 (PST)",
            "from localhost.localdomain ([188.39.149.98])\n\tby smtp.gmail.com with ESMTPSA id\n\tl27-20020a05600c1d1b00b0040d6e07a147sm5458117wms.23.2024.01.04.03.39.00\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 04 Jan 2024 03:39:00 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1704368344;\n\tbh=caPkXhcQMHaYW1zTzID4GH9oXuOQGwWLlhWB5p0T8o4=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=3qQveGb5QvW+0BtHlr/3f6auYd+qlsM8cw3EL2/83BWgywY1rUeag1d9l5wFpOE4L\n\tiur2JHUOWE0f3N5T7/Gq91QfSBfC4c6mMVMMbixLP1ZznrFqUU0s7O+iitqoZps8Z7\n\tczMTkRpd/a5aY/N5w8dRn3BmEmaTEBR3ojB40SkcXBNYpI6C78QwQ8Klev4dl7PrJq\n\t/RhKdSZR9qjfReU9TSEstvJequR+/JJTp3gKtX8wrSwgTE8DzvXo4gpmWx/TZL2i+m\n\tB7APYctqcJIzOGd50EUshnRddxwMg1b2M9o7zq5SkDQc49Q1UUybbAsBzrXYuG0QRp\n\thBDbRf1Ub1XPQ==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1704368341; x=1704973141;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=KQ2XdtIJKFUdHvKJJqI57au9cLadPk5h2KB/ovL+qAk=;\n\tb=Lm2ENOnQ1RWhT/gHYZkgSoxdqahAS6v18nmzp8Br5/4MI2NDO164pcL+m9BDvhZfug\n\tthPwT5ejjyd0nioMx9vkkaGvvpDqDKG49GzFZHHvyfIL4Zwj2mdKRtbK9OElWMPtucww\n\t9+XOaBif2MnAtKWYUSOXj6C6Otnxe5boZnfEG0TqhZvFauQpZ5qcqwv6Fou3u2VdhWfz\n\t68rmVD2NzmGs0VPO/HPKs6qRcazQaB2ZY6Qr1pJ+e/g2JYX+Awtp1yDKA0a97TuSd/9i\n\teJ4X2CzPFn2OdLgH/Dk0/D17AksBjbEqPuX2RjP8xZChJm4z61z1lUlpohDpogf2iQvO\n\toMzg=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Lm2ENOnQ\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1704368341; x=1704973141;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=KQ2XdtIJKFUdHvKJJqI57au9cLadPk5h2KB/ovL+qAk=;\n\tb=jNQwhu8sHF3s71XfVbIzsz1X8NgsqBy0+jG2X4ADFUp+cR15srFmT+oZnfxSuG5AOK\n\tQQ7rNkE1OEnzWP/Hz8h4AUeqRCbflAgpean7xiJ/Hf/HGzqlrTczpZtikFD9TMiNVUg0\n\tsGz+aYsJP2qBwgvq486HwlMNfolJJIb7KIuenKf20Ft0tegp0kfNbm8CStc9k7fbc2ol\n\tG/PIHjAJY+NQfpaXPr8ESGUzBE/Rd9iBEKQIqjtx1SddElZXt0vHVGcl0aInvIfaQe4v\n\tmhWhfBEpzJpcuLvZN4DIuQ3/lD0THXlNX77jV9qbQeK1+Dqi4v+gZnPfJujzeLwgDrUG\n\tdgzw==",
        "X-Gm-Message-State": "AOJu0Yx1EwK9sEMhUbM1AefGLyhxaJFHQ6XzcDiibUkA6bqqIOcK6tVm\n\tYNJB+Bfrf4LtsyfY5Oqkjl/y4KmPV2MalKdYSVBtWylu1f8=",
        "X-Google-Smtp-Source": "AGHT+IH32Bjl1AJY7J6sytMrzTsyYgbpiJ7t7Xfomir/F7z9nPr620tvPcL8kLIckTxncOQGZpQX6Q==",
        "X-Received": "by 2002:a7b:c391:0:b0:40d:71f3:d744 with SMTP id\n\ts17-20020a7bc391000000b0040d71f3d744mr132835wmj.343.1704368341133; \n\tThu, 04 Jan 2024 03:39:01 -0800 (PST)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu,  4 Jan 2024 11:38:55 +0000",
        "Message-Id": "<20240104113855.23865-1-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2] ipa: rpi: Add hardware line rate\n\tconstraints",
        "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": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Naushir Patuck <naush@raspberrypi.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Advertise hardware constraints on the pixel processing rate through the\nController::HardwareConfig structure. When calculating the minimum line\nlength during a configure() operation, ensure that we don't exceed this\nconstraint.\n\nIf we do exceed the hardware constraints, increase the modes's minimum\nline length so the pixel processing rate falls below the hardware limit.\nIf this is not possible, throw a loud error message in the logs.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\n---\n src/ipa/rpi/common/ipa_base.cpp       | 27 +++++++++++++++++++++++++++\n src/ipa/rpi/controller/controller.cpp | 20 ++++++++++++++++++++\n src/ipa/rpi/controller/controller.h   |  2 ++\n 3 files changed, 49 insertions(+)",
    "diff": "diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\nindex 6ac9d5de2f88..6ec9157561cf 100644\n--- a/src/ipa/rpi/common/ipa_base.cpp\n+++ b/src/ipa/rpi/common/ipa_base.cpp\n@@ -531,6 +531,33 @@ void IpaBase::setMode(const IPACameraSensorInfo &sensorInfo)\n \tmode_.minLineLength = sensorInfo.minLineLength * (1.0s / sensorInfo.pixelRate);\n \tmode_.maxLineLength = sensorInfo.maxLineLength * (1.0s / sensorInfo.pixelRate);\n \n+\t/*\n+\t * Ensure that the maximum pixel processing rate does not exceed the ISP\n+\t * hardware capabilities. If it does, try adjusting the minimum line\n+\t * length to compensate if possible.\n+\t */\n+\tDuration minPixelTime = controller_.getHardwareConfig().minPixelProcessingTime;\n+\tDuration pixelTime = mode_.minLineLength / mode_.width;\n+\tif (minPixelTime && pixelTime < minPixelTime) {\n+\t\tDuration adjustedLineLength = minPixelTime * mode_.width;\n+\t\tif (adjustedLineLength <= mode_.maxLineLength) {\n+\t\t\tLOG(IPARPI, Info)\n+\t\t\t\t<< \"Adjusting mode minimum line length from \" << mode_.minLineLength\n+\t\t\t\t<< \" to \" << adjustedLineLength << \" because of ISP constraints.\";\n+\t\t\tmode_.minLineLength = adjustedLineLength;\n+\t\t} else {\n+\t\t\tLOG(IPARPI, Error)\n+\t\t\t\t<< \"Sensor minimum line length of \" << pixelTime * mode_.width\n+\t\t\t\t<< \" (\" << 1us / pixelTime << \" MPix/s)\"\n+\t\t\t\t<< \" is below the minimum allowable ISP limit of \"\n+\t\t\t\t<< adjustedLineLength\n+\t\t\t\t<< \" (\" << 1us / minPixelTime << \" MPix/s) \";\n+\t\t\tLOG(IPARPI, Error)\n+\t\t\t\t<< \"THIS WILL CAUSE IMAGE CORRUPTION!!! \"\n+\t\t\t\t<< \"Please update the camera sensor driver to allow more horizontal blanking control.\";\n+\t\t}\n+\t}\n+\n \t/*\n \t * Set the frame length limits for the mode to ensure exposure and\n \t * framerate calculations are clipped appropriately.\ndiff --git a/src/ipa/rpi/controller/controller.cpp b/src/ipa/rpi/controller/controller.cpp\nindex e62becd87e85..5ca98b989740 100644\n--- a/src/ipa/rpi/controller/controller.cpp\n+++ b/src/ipa/rpi/controller/controller.cpp\n@@ -17,6 +17,7 @@\n \n using namespace RPiController;\n using namespace libcamera;\n+using namespace std::literals::chrono_literals;\n \n LOG_DEFINE_CATEGORY(RPiController)\n \n@@ -37,6 +38,7 @@ static const std::map<std::string, Controller::HardwareConfig> HardwareConfigMap\n \t\t\t.numGammaPoints = 33,\n \t\t\t.pipelineWidth = 13,\n \t\t\t.statsInline = false,\n+\t\t\t.minPixelProcessingTime = 0s,\n \t\t}\n \t},\n \t{\n@@ -51,6 +53,24 @@ static const std::map<std::string, Controller::HardwareConfig> HardwareConfigMap\n \t\t\t.numGammaPoints = 64,\n \t\t\t.pipelineWidth = 16,\n \t\t\t.statsInline = true,\n+\n+\t\t\t/*\n+\t\t\t * The constraint below is on the rate of pixels going\n+\t\t\t * from CSI2 peripheral to ISP-FE (400Mpix/s, plus tiny\n+\t\t\t * overheads per scanline, for which 380Mpix/s is a\n+\t\t\t * conservative bound).\n+\t\t\t *\n+\t\t\t * There is a 64kbit data FIFO before the bottleneck,\n+\t\t\t * which means that in all reasonable cases the\n+\t\t\t * constraint applies at a timescale >= 1 scanline, so\n+\t\t\t * adding horizontal blanking can prevent loss.\n+\t\t\t *\n+\t\t\t * If the backlog were to grow beyond 64kbit during a\n+\t\t\t * single scanline, there could still be loss. This\n+\t\t\t * could happen using 4 lanes at 1.5Gbps at 10bpp with\n+\t\t\t * frames wider than ~16,000 pixels.\n+\t\t\t */\n+\t\t\t.minPixelProcessingTime = 1.0us / 380,\n \t\t}\n \t},\n };\ndiff --git a/src/ipa/rpi/controller/controller.h b/src/ipa/rpi/controller/controller.h\nindex 6e5f595284fd..170aea740789 100644\n--- a/src/ipa/rpi/controller/controller.h\n+++ b/src/ipa/rpi/controller/controller.h\n@@ -15,6 +15,7 @@\n #include <vector>\n #include <string>\n \n+#include <libcamera/base/utils.h>\n #include \"libcamera/internal/yaml_parser.h\"\n \n #include \"camera_mode.h\"\n@@ -47,6 +48,7 @@ public:\n \t\tunsigned int numGammaPoints;\n \t\tunsigned int pipelineWidth;\n \t\tbool statsInline;\n+\t\tlibcamera::utils::Duration minPixelProcessingTime;\n \t};\n \n \tController();\n",
    "prefixes": [
        "libcamera-devel",
        "v2"
    ]
}