Patch Detail
Show a patch.
GET /api/1.1/patches/14516/?format=api
{ "id": 14516, "url": "https://patchwork.libcamera.org/api/1.1/patches/14516/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14516/", "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": "<20211110100802.349623-2-naush@raspberrypi.com>", "date": "2021-11-10T10:08:01", "name": "[libcamera-devel,2/3] pipeline: raspberrypi: Rework the internal buffer allocation scheme", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "05000437a8fdee48e8b50c61cf705f192235285a", "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/14516/mbox/", "series": [ { "id": 2703, "url": "https://patchwork.libcamera.org/api/1.1/series/2703/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2703", "date": "2021-11-10T10:08:00", "name": "[libcamera-devel,1/3] pipeline: raspberrypi: Add const qualifer in isRaw()", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2703/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14516/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14516/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 532A8BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Nov 2021 10:08:11 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 707D160362;\n\tWed, 10 Nov 2021 11:08:09 +0100 (CET)", "from mail-wm1-x333.google.com (mail-wm1-x333.google.com\n\t[IPv6:2a00:1450:4864:20::333])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0604B6034E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Nov 2021 11:08:08 +0100 (CET)", "by mail-wm1-x333.google.com with SMTP id\n\tb184-20020a1c1bc1000000b0033140bf8dd5so1508956wmb.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Nov 2021 02:08:08 -0800 (PST)", "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:8747:6ef9:ee17:3d59])\n\tby smtp.gmail.com with ESMTPSA id\n\td11sm21969133wrs.38.2021.11.10.02.08.07\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 10 Nov 2021 02:08:07 -0800 (PST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"G7ZJ8DU0\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=QTcjocxvUEcxxWS64VuvQEsn0E3guGnqlF2N2jhQXIA=;\n\tb=G7ZJ8DU0FOU5kEsKIMfDqw+ueTGPv0G457N9OFJPoi+rtT8Neg1/euRG/Sa5Rl1IDb\n\tVQW6ulVh15x8EWAfczygmIiiCbVl0V6/oQzSzOi8VqiFeZehThombHiOQ7Lyo5XK73pX\n\tyjRQPE7iexIWJqFrllzl7n9UcCRlw1dBSkcdC95dTB92PH5WEFQAzLJCw1ky4em8NeoJ\n\tpgM3H5JCYAetcyOPER4/tU+M6u+ocUaBOlhnE+CR2heCtLYUi8dUvzY/WDaNY/TNvhnV\n\tF81LrQ6quDp9TAtYWIVu8kBnTt8+mWK+so3b8N6DWTu9Ssrur/wDbzOWMFTWmUZmN4a+\n\tF8Xg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=QTcjocxvUEcxxWS64VuvQEsn0E3guGnqlF2N2jhQXIA=;\n\tb=00Nt+fDCbRntMRibbILQ426tQEbtMt8Mh5i0wQAzudgjzv5jZ9XWCYeqNHsNXjZ6Xt\n\tHae5E4JQykRQ4EKaM5JuiPBSuTFRc2ottKDtqdAV/JbqQXePmlke1wavkiEfmO4hx5UD\n\tAhC6OATmmBlx+OwgiJtzohSYCp6c5/+L12UUqxfv4jLXbxpnZ6ZS2yewblM8yMllpa9X\n\t0wq0/uRDzYJcvG+ZPACd3H3KCJWAQVYATqPZzoypO9eotm3Gq2y9wluIt3mkImcUHelD\n\tdbRye8r2kkKbI3FzSdQ4aIk6IlTpzkIImI45bbUXejSZVCH1OLQd5JixABWI5fXlZgg+\n\tFn+Q==", "X-Gm-Message-State": "AOAM532/eKavn0iXAKUMC7qeztsC7+lHOxQihzPwwv/wkAzdKe5unolW\n\tBygiKhSM8ZwyD9lad17ssTDp2GfjfsvRsH0I", "X-Google-Smtp-Source": "ABdhPJxrrooSvciRVg7K3SAmvB8fttkHSkt3WyNcbUqpdymDo+Oez/mRKN1gcr/enypf7LZSsdkvoA==", "X-Received": "by 2002:a7b:c8c8:: with SMTP id f8mr14886473wml.49.1636538887596;\n\tWed, 10 Nov 2021 02:08:07 -0800 (PST)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 10 Nov 2021 10:08:01 +0000", "Message-Id": "<20211110100802.349623-2-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20211110100802.349623-1-naush@raspberrypi.com>", "References": "<20211110100802.349623-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/3] pipeline: raspberrypi: Rework the\n\tinternal buffer allocation scheme", "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>", "Cc": "Roman Stratiienko <r.stratiienko@gmail.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "For simplicity, the pipeline handler would look at the maximum number of\nbuffers set in the StreamConfiguration and allocate the same number of internal\nbuffers for all device nodes. This would likely overallocate buffers for some\nnodes. Rework this logic to try and minimise overallcations without compromising\nperformance.\n\nFor ISP nodes, we only ever need 1 set of internal buffers, as the hardware runs\nsynchronous with the requests and IPA.\n\nFor Unicam nodes, allocate a minimum for 4 buffers (exported + internal), but\nalso require at least 1 internal buffer.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp | 44 ++++++++++++++-----\n 1 file changed, 33 insertions(+), 11 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 11d3c2b120dd..5f0f00aacd59 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1211,21 +1211,43 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera)\n int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n {\n \tRPiCameraData *data = cameraData(camera);\n+\tunsigned int numBuffers;\n+\tbool rawStream = false;\n \tint ret;\n \n-\t/*\n-\t * Decide how many internal buffers to allocate. For now, simply look\n-\t * at how many external buffers will be provided. We'll need to improve\n-\t * this logic. However, we really must have all streams allocate the same\n-\t * number of buffers to simplify error handling in queueRequestDevice().\n-\t */\n-\tunsigned int maxBuffers = 0;\n-\tfor (const Stream *s : camera->streams())\n-\t\tif (static_cast<const RPi::Stream *>(s)->isExternal())\n-\t\t\tmaxBuffers = std::max(maxBuffers, s->configuration().bufferCount);\n+\tfor (Stream *s : camera->streams()) {\n+\t\tif (isRaw(s->configuration().pixelFormat)) {\n+\t\t\tnumBuffers = s->configuration().bufferCount;\n+\t\t\trawStream = true;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n \n+\t/* Decide how many internal buffers to allocate. */\n \tfor (auto const stream : data->streams_) {\n-\t\tret = stream->prepareBuffers(maxBuffers);\n+\t\tif (stream == &data->unicam_[Unicam::Image] ||\n+\t\t stream == &data->unicam_[Unicam::Embedded]) {\n+\t\t\t/*\n+\t\t\t * For Unicam, allocate a minimum of 4 buffers as we want\n+\t\t\t * to avoid any frame drops. If an application has configured\n+\t\t\t * a RAW stream, allocate additional buffers to make up the\n+\t\t\t * minimum, but ensure we have at least 1 set of internal\n+\t\t\t * buffers to use to minimise frame drops.\n+\t\t\t */\n+\t\t\tconstexpr unsigned int minBuffers = 4;\n+\t\t\tnumBuffers = rawStream ? std::max<int>(1, minBuffers - numBuffers)\n+\t\t\t\t\t : minBuffers;\n+\t\t} else {\n+\t\t\t/*\n+\t\t\t * Since the ISP runs synchronous with the IPA and requests,\n+\t\t\t * we only ever need one set of internal buffers. Any buffers\n+\t\t\t * the application wants to hold onto will already be exported\n+\t\t\t * through PipelineHandlerRPi::exportFrameBuffers().\n+\t\t\t */\n+\t\t\tnumBuffers = 1;\n+\t\t}\n+\n+\t\tret = stream->prepareBuffers(numBuffers);\n \t\tif (ret < 0)\n \t\t\treturn ret;\n \t}\n", "prefixes": [ "libcamera-devel", "2/3" ] }