{"id":17955,"url":"https://patchwork.libcamera.org/api/1.1/patches/17955/?format=json","web_url":"https://patchwork.libcamera.org/patch/17955/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20221206135459.25521-13-naush@raspberrypi.com>","date":"2022-12-06T13:54:58","name":"[libcamera-devel,v3,12/13] 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/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17955/mbox/","series":[{"id":3659,"url":"https://patchwork.libcamera.org/api/1.1/series/3659/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3659","date":"2022-12-06T13:54:46","name":"Raspberry Pi: Platform configuration and buffer allocation improvements","version":3,"mbox":"https://patchwork.libcamera.org/series/3659/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17955/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17955/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 9C844BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  6 Dec 2022 13:55:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5727B63359;\n\tTue,  6 Dec 2022 14:55:20 +0100 (CET)","from mail-wm1-x336.google.com (mail-wm1-x336.google.com\n\t[IPv6:2a00:1450:4864:20::336])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0390663359\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  6 Dec 2022 14:55:15 +0100 (CET)","by mail-wm1-x336.google.com with SMTP id\n\tm4-20020a05600c3b0400b003d1cb516ce0so663330wms.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 06 Dec 2022 05:55:15 -0800 (PST)","from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tq6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.13\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 06 Dec 2022 05:55:13 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1670334920;\n\tbh=tDBmBwb4sA+f2nCv8hrEGm2SYDvJRfswWxPT3X7S88U=;\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=H5owGACbSo2pRJxgGRQNTfNjDSn/hC61t3cz7MlpM92eRUzoS6CJSXYXwntHNhdVx\n\t7Npv+9JtYeDARbCDgrT8NsGjtsnOgfx7Ht/WxTl/3lV+ySg1uIsdjaQ6uccmrG29lu\n\tvE2ITI16WvEyAouzH01oImikA6kje8DqzQmc8LeYddZiRmn//XOge3eIo7wE3z6GXl\n\tHoMHCcoPvPr3ofi64Nci22U28FvBb7kiw7sU9xIvzQONmjzGSxRq+sH2XBX/gK+Ioa\n\tnByKZGLFsvq5XcXPMAaw6GfydoIvfJFhHSzkGMYtecA8NcnyGs6rhMWlEcnwWWKldp\n\t2/oSTOQ+cptZg==","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=oe40j38Jy/tRf8WT1pUPWYm8Sw3EeiCXbQh8FbPbkeA=;\n\tb=cpzQ9C7G7Y3ATpVmPMLYYE3o6fajc4/gW/yErGM3JtSZt244RgQNVjJJp+1SMPof1a\n\tbby+Em+F+00fI4bzeY6TI7iJYkxta9Nhoxo+FFMdWORZ/se+LjUFgqdJBU25uo67Jf9R\n\tYWBR/xFtSGInpWoQVfE/fUyBOD7vlJNUX7oc0UFgOPhVcKfyv41UYhQMWMRNg0YR+z+G\n\tQ2/xNV5DZemGsUrNNMoG0o+FqjADkoVyaYZfl9/KjDqAYADKMVtPRAk0fEf0tTaZbwQT\n\ts7BCCZpQRVtyD5m4zd0W1ersinmyiVl71rvppiZYSf98RjVV3qX0/fAtoNgZGiPZ5/of\n\tSVOA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"cpzQ9C7G\"; 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=oe40j38Jy/tRf8WT1pUPWYm8Sw3EeiCXbQh8FbPbkeA=;\n\tb=RUWL5B6JOpJJUsTJpQ3oeHDfc5BHy9ugSCQU/qCL03PwZESRsmXukS/7iv9ahzvouc\n\t5c66+BNMNIbsAdZ3MbmuCD1DZESwLivmZkjHttcSJM+ur5kH+ZUSMUEvzzFZOLsDQ/Ei\n\tz6kKELxc/Pm4zXcg/Vbo5010WFgxwZ7PlTGgIaTR2O4FCGtLOL+5OvXP0oU52U9t65Sn\n\t7bRqx3vw3SDCeCWir2mK3zYqLFHPPpT5D5uk5yg10apXTgUg/uHlcxMcmQ1cjBG2+lIm\n\tA6pNQDluyiU3gs59Y9gbonDeF4pusoFur2uQxRmwRkVkHzEkFcBhaosxWABTthkdd+MD\n\tBbOA==","X-Gm-Message-State":"ANoB5plHZywzpr2Ty6pbyzubRlyLQ1xx4OYK4gvj7XcKpSJa/Utx1U6V\n\t59od6wmPv3p/VgXluiTgbCWPPP6e5+V0QGaf","X-Google-Smtp-Source":"AA0mqf4LN+qx1JDCwRAbWj2BVTPjfycUF0CMcd0QQkNEv8KDHZTyrXXb+mym3LVpU+TMao1dv3jOEw==","X-Received":"by 2002:a05:600c:1d09:b0:3cf:6ab3:4a0b with SMTP id\n\tl9-20020a05600c1d0900b003cf6ab34a0bmr65556823wms.91.1670334914204; \n\tTue, 06 Dec 2022 05:55:14 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  6 Dec 2022 13:54:58 +0000","Message-Id":"<20221206135459.25521-13-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20221206135459.25521-1-naush@raspberrypi.com>","References":"<20221206135459.25521-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 12/13] 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 ffd2ba85182f..acf81a5beb83 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@@ -1730,6 +1735,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@@ -1765,6 +1771,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@@ -2354,6 +2362,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","v3","12/13"]}