Show a patch.

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

{
    "id": 17975,
    "url": "https://patchwork.libcamera.org/api/patches/17975/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17975/",
    "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": "<20221209090050.19441-12-naush@raspberrypi.com>",
    "date": "2022-12-09T09:00:49",
    "name": "[libcamera-devel,v4,11/12] pipeline: raspberrypi: Allow pipeline handler to always use the newest frame",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "caee3dc2984fc4f506faa96291ea86decfae481c",
    "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/17975/mbox/",
    "series": [
        {
            "id": 3663,
            "url": "https://patchwork.libcamera.org/api/series/3663/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3663",
            "date": "2022-12-09T09:00:38",
            "name": "Raspberry Pi: Platform configuration and buffer allocation improvements",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/3663/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17975/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17975/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 622F9BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  9 Dec 2022 09:01:43 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 08C4363369;\n\tFri,  9 Dec 2022 10:01:43 +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 6F06561F1E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  9 Dec 2022 10:01:37 +0100 (CET)",
            "by mail-wm1-x334.google.com with SMTP id\n\tp13-20020a05600c468d00b003cf8859ed1bso2912508wmo.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 09 Dec 2022 01:01:37 -0800 (PST)",
            "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tbd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.36\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 09 Dec 2022 01:01:36 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1670576503;\n\tbh=rEqIEbuaGZgs29+h7K/U15YmT6g+aKk1ijX90G+xZnU=;\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=lsoK3PoktQxiszPeRnBi0CZ9DOYpexXzusUZub7xCJbL4VGi9/UWrvc62JHZ/WwdU\n\tsqvyhEMkf9GRsJMrzN/8+7UMraa2HAsLsbGlkh5sS8pccXA4eCDVN/RCVD0fg/gHlv\n\t/GCO/9IeMhmnjSRpH41MXEFToTcnPzD19DU8GWJvSTHlyrFfdveCKB6zpA54uuVL5U\n\t69pxwdilv9vxw7O4oFBOzhF4+ehxS3QYkXHP/pm99BGopYsLfUSqxVm9/DZOSw7Sze\n\tZDwP5ZD+kSLWpLougu8AKhSRkmxk2obMbRijQzEZ/hxBUEMezMttxYo5hCu0mExyTv\n\t1uGJz3wMo4GgA==",
            "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=b9p3hmsDwsTnR3TtFnBMbkk9Es9Dkr0IvE7b5jVv5W0=;\n\tb=BIlIPRuFhpuucDzOu14c2AIMEuoQfemOKBQ1Tj0ssU7J/P0FS4yF5ScV0iHQ9bJbvg\n\tS0B5tb/d2EiPkgh4mpqGZ1xhkd3If7Jc56Rdzi41fdsDiuyzPF2X/VRzhQ5QV0NF7Bho\n\tU6dDRSkNrjre9u8qw69Tdi2BS3hqGCGuki6AhgmlACRWPL85c6hdok73eQwAegzzv4mI\n\th3XFPwxO1FggukdWEDbhvImX91tO5fDbVqWRxDEascZ4ABLVbrGVLJXqKiCXaVCChs/e\n\tcDOfBhz7DWunyBSM2nPCcR+N/+upeMMX1vrhAKKCEy4Mr7bOdP9XZiuEr8U/GQW7mczI\n\tsasg=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"BIlIPRuF\"; 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=b9p3hmsDwsTnR3TtFnBMbkk9Es9Dkr0IvE7b5jVv5W0=;\n\tb=sogVWB40qGb4Ez3q9mvgMInYLnr0/CVrMvycsey+V5bvLmjF9MJnN27K6aszvGi6ik\n\tWA7i3WxOzbpamezfDXrVwYlVU1/Sr56/3Tt8hJCeqovW9WMKvjq41IT0l77rDzVH78T6\n\tuFmQB9BQ7aF73Y8/CasL+yYEn/1MFVz5cPwghb5jSkgtULZm7AOrC2QQevYHlOolqkum\n\t4Z9YGxNTMueqVq/6abbEp4qGJL6UQY4vgL1p54y5YcnZLIvemO/ZP70S+YubzBuRTSgg\n\tPeyFd4yroY16WOCD0jU01zltuchpDN8mLwadAOlREl+6uiv129B3oSkxNYfp3JcWOOrj\n\tRZhw==",
        "X-Gm-Message-State": "ANoB5pkRaz0k0XMzDzmg5etJ61DkVM0dnd5dr6d8NganwdRpT7m2Zcjh\n\tb/a6HMrgHiDgXZ8+3eccAr86dsOkmhywTVfk",
        "X-Google-Smtp-Source": "AA0mqf77tEQUaQD7JJWuDK4aLGsIosHzB7YADVsd0Wno2MP18EhyKLlenEiaTw7OXkH+3GD/ta0cCw==",
        "X-Received": "by 2002:a05:600c:35c4:b0:3cf:85f7:bbc4 with SMTP id\n\tr4-20020a05600c35c400b003cf85f7bbc4mr4272428wmq.2.1670576496889; \n\tFri, 09 Dec 2022 01:01:36 -0800 (PST)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri,  9 Dec 2022 09:00:49 +0000",
        "Message-Id": "<20221209090050.19441-12-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20221209090050.19441-1-naush@raspberrypi.com>",
        "References": "<20221209090050.19441-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 11/12] pipeline: raspberrypi: Allow\n\tpipeline handler to always use the newest frame",
        "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": "Add a pipeline config parameter \"return_newest_frames\" to always use the\nmost recently captured Unicam frame when processing a request. This effectively\nstops the pipeline handler from queuing Unicam buffers and processing requests\nusing the buffer at the front of the queue.\n\nNote that setting this parameter might incur unnecessary frame drops during\ntimes of high transient CPU loads where the application might not be able to\nprovide requests quick enough.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/raspberrypi/data/example.yaml    |  7 +++++-\n .../pipeline/raspberrypi/raspberrypi.cpp      | 23 +++++++++++++++++++\n 2 files changed, 29 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml\nindex 421f30e62aa3..04a117f38ada 100644\n--- a/src/libcamera/pipeline/raspberrypi/data/example.yaml\n+++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml\n@@ -19,6 +19,11 @@\n \n                 # Override any request from the IPA to drop a number of startup\n                 # frames.\n-                \"disable_startup_frame_drops\": false\n+                \"disable_startup_frame_drops\": false,\n+\n+                # Always process a pending request with the last captured sensor\n+                # frame.  Note that this might lead to avoidable frame drops\n+                # during periods of transient heavy CPU loading.\n+                \"return_newest_frames\": false\n         }\n }\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 4f15bcf0052a..68c70cc19995 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -313,6 +313,11 @@ public:\n \t\t * frames.\n \t\t */\n \t\tbool disableStartupFrameDrops;\n+\t\t/*\n+\t\t * Always process a pending request with the last captured sensor\n+\t\t * frame.\n+\t\t */\n+\t\tbool returnNewestFrames;\n \t};\n \n \tConfig config_;\n@@ -1712,6 +1717,7 @@ int RPiCameraData::configurePipeline()\n \t\t.minUnicamBuffers = 2,\n \t\t.minTotalUnicamBuffers = 4,\n \t\t.disableStartupFrameDrops = false,\n+\t\t.returnNewestFrames = false,\n \t};\n \n \tchar const *configFromEnv = utils::secure_getenv(\"LIBCAMERA_RPI_CONFIG_FILE\");\n@@ -1747,6 +1753,8 @@ int RPiCameraData::configurePipeline()\n \t\tphConfig[\"min_total_unicam_buffers\"].get<unsigned int>(config_.minTotalUnicamBuffers);\n \tconfig_.disableStartupFrameDrops =\n \t\tphConfig[\"disable_startup_frame_drops\"].get<bool>(config_.disableStartupFrameDrops);\n+\tconfig_.returnNewestFrames =\n+\t\tphConfig[\"return_newest_frames\"].get<bool>(config_.returnNewestFrames);\n \n \tif (config_.minTotalUnicamBuffers < config_.minUnicamBuffers) {\n \t\tLOG(RPI, Error) << \"Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers\";\n@@ -2326,6 +2334,21 @@ bool RPiCameraData::findMatchingBuffers(BayerFrame &bayerFrame, FrameBuffer *&em\n \tif (bayerQueue_.empty())\n \t\treturn false;\n \n+\t/*\n+\t * If the pipeline is configured to only ever return the most recently\n+\t * captured frame, empty the buffer queue until a single element is\n+\t * left, corresponding to the most recent buffer. Note that this will\n+\t * likely result in possibly avoidable dropped frames.\n+\t */\n+\tif (config_.returnNewestFrames && !unicam_[Unicam::Image].isExternal()) {\n+\t\twhile (bayerQueue_.size() > 1) {\n+\t\t\tFrameBuffer *bayer = bayerQueue_.front().buffer;\n+\n+\t\t\tunicam_[Unicam::Image].returnBuffer(bayer);\n+\t\t\tbayerQueue_.pop();\n+\t\t}\n+\t}\n+\n \t/*\n \t * Find the embedded data buffer with a matching timestamp to pass to\n \t * the IPA. Any embedded buffers with a timestamp lower than the\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "11/12"
    ]
}