Show a patch.

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

{
    "id": 18205,
    "url": "https://patchwork.libcamera.org/api/patches/18205/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18205/",
    "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": "<20230127154322.29019-6-naush@raspberrypi.com>",
    "date": "2023-01-27T15:43:12",
    "name": "[libcamera-devel,v6,05/15] pipeline: raspberrypi: Handle MandatoryStream hints for Unicam Image",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "b9a5c5077698fad972d4b9b88cff1b38edf83fb6",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18205/mbox/",
    "series": [
        {
            "id": 3728,
            "url": "https://patchwork.libcamera.org/api/series/3728/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3728",
            "date": "2023-01-27T15:43:07",
            "name": "[libcamera-devel,v6,01/15] libcamera: stream: Add stream hints to StreamConfiguration",
            "version": 6,
            "mbox": "https://patchwork.libcamera.org/series/3728/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18205/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18205/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 920FCC3242\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 Jan 2023 15:43:45 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 08DC9625FE;\n\tFri, 27 Jan 2023 16:43:45 +0100 (CET)",
            "from mail-wm1-x334.google.com (mail-wm1-x334.google.com\n\t[IPv6:2a00:1450:4864:20::334])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DFC8A625EA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Jan 2023 16:43:38 +0100 (CET)",
            "by mail-wm1-x334.google.com with SMTP id\n\tm5-20020a05600c4f4500b003db03b2559eso3769664wmq.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Jan 2023 07:43:38 -0800 (PST)",
            "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\th18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.37\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 27 Jan 2023 07:43:38 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1674834225;\n\tbh=LSY3MtkRkonnhlfUVdGTa0WEosqs8kEbZpn/jYt5LZY=;\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:\n\tFrom;\n\tb=a8D+0brLNSlrtXMPTxP8iNwmOenJD5NwdakEo/B5yKQQxwXcl7qKyK/pNJOkCuZQn\n\tGtmO+f7IHrR6KNGzThzkMP0hWm/F/+h+yGcKzHL2eHVXesNdLwwVjNN3dmOYLnkc+G\n\tUedVKG1esAn9S3lTm4z++D13Wh0sqahOBPFVE2b9LH06KFd65YCV1HsW3SQg2L5Yc2\n\tKtia/uS46rC+Pf17G+0PPC3bYRMDQCr/yjnSkjHVG7wMn0mH/U1lVp5NgyooZvdrTu\n\tY8PBE9EBVOC4XlA1FtFfeLxroePhTc5iJ5sfkBkPwjg6e+yazXmYTq/KnVg2PSrUll\n\tqtZfEDaFn37lQ==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=Gu7pQeRtJKEaZCE/Wr2FRS5oI/UGPEaX00FNTi5YwBM=;\n\tb=pgE6kJY/paPxzankVf1PJOunKzUYED3veXEDEpnt0KyoNweXNj6u9jQ/kp//BlIOah\n\t4vNpkgbCvzHmDIeuPBo5wxy6zKNkYe0bVFfkbe/MzrKnDOZr1a80coyNFA/PYotPgf/6\n\t0z57w789a+P7ZQjOWr1/HDMyTmLY7QU/ojW1B4mpUH2jJtiCum1UaAad+cqcbNtaZi+/\n\tUZn4GKjhLTxhTjnLK1NDGYKh8GvsJhe3g8TeczHwtkbJeqx7Rv0NITkZC3ucZ4SCMZdr\n\tRTdwlPMf0xvxt4wt5mWpqfmbrjH3U0hW36OyRr6rLphrcJEZsPZzvtaHAScIWqwUuEzt\n\tlT3w=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"pgE6kJY/\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=Gu7pQeRtJKEaZCE/Wr2FRS5oI/UGPEaX00FNTi5YwBM=;\n\tb=wHWNQYcWdaHgNyn6514uDf1L3oMSYZc0Glc6vOXuQUBXxKwe9dAPdWNxhVg8otw/Kk\n\tVsH96CikUvhnSOD2POMPE9Rwlo2PCgCymqT9Ub2aqAZ3nx8E2Nmwyfo6jGPib9lWvJtw\n\tgkRbFniIxqTzMgbWCPS+cd28kHi/Wml+4mgj5ib1x16+91GTlIqfbw39VVwQ2lTdX18l\n\tfe2tEDHWZzU9+t41jQ+7f77deFwuby1bUEwaqFoyN4vRqoMsfuzrRhz8lC7FKbQeccXC\n\tYSvScUGywd8cNgVHx2VAC4J7sFsHGAAij2QbFgR1lJqNmtPrTmyNj7L5WgjZHo1n9ZjZ\n\tRuIw==",
        "X-Gm-Message-State": "AFqh2kodKcOb57/UCGfaIR81xNN/KV8PzSb5oVpZcEdMe5CgmkupT87Y\n\tl3WMJ5hC94uoc3t7gFVSIL5D6iI7oMft4W+kZgE=",
        "X-Google-Smtp-Source": "AMrXdXuV7SP6+X9wg7d8aYWTl4OQ/jBQtdAOofrGdwGio5YM0SymVnZsKerqlCMzc8+z5HzQdf4B2g==",
        "X-Received": "by 2002:a05:600c:500c:b0:3db:2537:5ad3 with SMTP id\n\tn12-20020a05600c500c00b003db25375ad3mr33419995wmr.30.1674834218437; \n\tFri, 27 Jan 2023 07:43:38 -0800 (PST)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 27 Jan 2023 15:43:12 +0000",
        "Message-Id": "<20230127154322.29019-6-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20230127154322.29019-1-naush@raspberrypi.com>",
        "References": "<20230127154322.29019-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v6 05/15] pipeline: raspberrypi: Handle\n\tMandatoryStream hints for Unicam Image",
        "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": "Look for MandatoryStream flag in the hints field of the Unicam Image\nStreamConfiguration structure. If this flag is set, it guarantees that the\napplication will provide buffers for Unicam Image, so override the\nminUnicamBuffers and minTotalUnicamBuffers config parameters in the following\nway:\n\n- If startup drop frames are required, allocate at least 1 internal buffer.\n- If no startup drop frames are required, do not allocate any internal buffers.\n\nAll other buffer allocations remain unchanged.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 34 +++++++++++++++----\n 1 file changed, 27 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 8aa83aa76ae0..44b1727678c7 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1452,12 +1452,33 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera)\n int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n {\n \tRPiCameraData *data = cameraData(camera);\n+\tunsigned int minUnicamBuffers = data->config_.minUnicamBuffers;\n+\tunsigned int minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers;\n \tunsigned int numRawBuffers = 0;\n \tint ret;\n \n \tfor (Stream *s : camera->streams()) {\n-\t\tif (isRaw(s->configuration().pixelFormat)) {\n+\t\tif (s == &data->unicam_[Unicam::Image]) {\n \t\t\tnumRawBuffers = s->configuration().bufferCount;\n+\t\t\t/*\n+\t\t\t * If the application provides a guarantees that Unicam\n+\t\t\t * image buffers will always be provided for the RAW stream\n+\t\t\t * in a Request, we need:\n+\t\t\t * - at least 1 internal Unicam buffer to handle startup frame drops,\n+\t\t\t * - no internal Unicam buffers if there are no startup frame drops.\n+\t\t\t */\n+\t\t\tif (s->configuration().hints &\n+\t\t\t    StreamConfiguration::Hint::MandatoryStream) {\n+\t\t\t\tif (data->dropFrameCount_) {\n+\t\t\t\t\tminUnicamBuffers = std::max(1u, minUnicamBuffers);\n+\t\t\t\t\tminTotalUnicamBuffers =\n+\t\t\t\t\t\tstd::max(minUnicamBuffers, minTotalUnicamBuffers);\n+\t\t\t\t} else {\n+\t\t\t\t\tminUnicamBuffers = 0;\n+\t\t\t\t\tminTotalUnicamBuffers = 0;\n+\t\t\t\t}\n+\t\t\t}\n+\n \t\t\tbreak;\n \t\t}\n \t}\n@@ -1469,7 +1490,6 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n \t\t * For Unicam, allocate a minimum number of buffers for internal\n \t\t * use as we want to avoid any frame drops.\n \t\t */\n-\t\tconst unsigned int minBuffers = data->config_.minTotalUnicamBuffers;\n \t\tif (stream == &data->unicam_[Unicam::Image]) {\n \t\t\t/*\n \t\t\t * If an application has configured a RAW stream, allocate\n@@ -1477,8 +1497,8 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n \t\t\t * we have at least minUnicamBuffers of internal buffers\n \t\t\t * to use to minimise frame drops.\n \t\t\t */\n-\t\t\tnumBuffers = std::max<int>(data->config_.minUnicamBuffers,\n-\t\t\t\t\t\t   minBuffers - numRawBuffers);\n+\t\t\tnumBuffers = std::max<int>(minUnicamBuffers,\n+\t\t\t\t\t\t   minTotalUnicamBuffers - numRawBuffers);\n \t\t} else if (stream == &data->isp_[Isp::Input]) {\n \t\t\t/*\n \t\t\t * ISP input buffers are imported from Unicam, so follow\n@@ -1486,15 +1506,15 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n \t\t\t * available.\n \t\t\t */\n \t\t\tnumBuffers = numRawBuffers +\n-\t\t\t\t     std::max<int>(data->config_.minUnicamBuffers,\n-\t\t\t\t\t\t   minBuffers - numRawBuffers);\n+\t\t\t\t     std::max<int>(minUnicamBuffers,\n+\t\t\t\t\t\t   minTotalUnicamBuffers - numRawBuffers);\n \n \t\t} else if (stream == &data->unicam_[Unicam::Embedded]) {\n \t\t\t/*\n \t\t\t * Embedded data buffers are (currently) for internal use,\n \t\t\t * so allocate the minimum required to avoid frame drops.\n \t\t\t */\n-\t\t\tnumBuffers = minBuffers;\n+\t\t\tnumBuffers = data->config_.minTotalUnicamBuffers;\n \t\t} else {\n \t\t\t/*\n \t\t\t * Since the ISP runs synchronous with the IPA and requests,\n",
    "prefixes": [
        "libcamera-devel",
        "v6",
        "05/15"
    ]
}