Patch Detail
Show a patch.
GET /api/1.1/patches/15544/?format=api
{ "id": 15544, "url": "https://patchwork.libcamera.org/api/1.1/patches/15544/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15544/", "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": "<20220325090903.880311-4-naush@raspberrypi.com>", "date": "2022-03-25T09:08:58", "name": "[libcamera-devel,v5,3/8] pipeline: raspberrypi: Free buffers in the RPiCamera destructor and re-configure", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "0af77b35f38fa4f93baa506f64a7fdf3905fd3da", "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/15544/mbox/", "series": [ { "id": 2999, "url": "https://patchwork.libcamera.org/api/1.1/series/2999/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2999", "date": "2022-03-25T09:08:55", "name": "Raspberry Pi: Efficient start/stop/start sequences", "version": 5, "mbox": "https://patchwork.libcamera.org/series/2999/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15544/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15544/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 55733C3264\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Mar 2022 09:09:11 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EDFE361FBC;\n\tFri, 25 Mar 2022 10:09:10 +0100 (CET)", "from mail-wr1-x435.google.com (mail-wr1-x435.google.com\n\t[IPv6:2a00:1450:4864:20::435])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 73ED8604EA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Mar 2022 10:09:09 +0100 (CET)", "by mail-wr1-x435.google.com with SMTP id a1so9946089wrh.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Mar 2022 02:09:09 -0700 (PDT)", "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:478c:773f:4734:d0bc])\n\tby smtp.gmail.com with ESMTPSA id\n\tc4-20020a056000184400b0020584c40778sm4915297wri.103.2022.03.25.02.09.08\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 25 Mar 2022 02:09:08 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648199350;\n\tbh=a+cNZ9Tsd22nFCcFkFyh9j5GpX5K4dniFlP0YmtW2EU=;\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=foHBg+OlX1HaSIjEtn96rgOGBKo2gUHdxsnDKQUH/HMShRGkrlGk0JzCUlnmhvo95\n\tQzWCJCwDR2nkyzosNKk9cILRsiw1QFONS6b05lf3TSKO1f5kn8QNPDCfQzzLuUxQSU\n\tE5LZzgsQWojIPoN1RzTIPnN8xIwXAzLhcF5CAulngyiR+VFVq54UrIFa54XVZDAlVw\n\tg47MYDpl6OMuHbLfrNnZ93cmh6NVj3InfjhU5waZJWIzIdJXKAEvx7beyw2+EIiBSp\n\tXqnzKdj5VqKqLJN1DkR4uNVa2sN/OutOmddzRFB/713GBDqu1yluLCfDkcEiwYZdN5\n\t9WAMCqPAxDR4w==", "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=4XNcvihWbSxz/8G2fcOly9PICUFjPwd6G8x0Dy4evVA=;\n\tb=lZFiYRnBt3MRNOzmo1L9FZ+Tx3JqzC9RB04Y0ApylTUkssD6/64Wq7rQpRWS2gDkyX\n\tH//rzbjzCw1p3mvtG/zNrdru7SEQm3amrQevjLDCUQIVqVlUdETDE95PGY5wnc9uI/oE\n\t9vPli3rr7ybHKkUx1MSXdAgQUnHIYU1m60QWaATp0OVx1WHCWQFmZQZcE3etCDxixQpK\n\tBzH4ceX03DydTMcdZO9ZPkId/GxTb1gFLsKWgz7gKjhIrd1m7RF47t68EUk83vWIMpCG\n\t9nR1Cw9hNH83gnq46pUjJ6hlyVS18PrMKI+4yJYPWR20m23+nl3i/Zot6D5uB8p53Odo\n\to8vw==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"lZFiYRnB\"; dkim-atps=neutral", "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=4XNcvihWbSxz/8G2fcOly9PICUFjPwd6G8x0Dy4evVA=;\n\tb=OaCQOxURmRWlAgJPzshXpNSi4fPsNFurj6c+YTxN5dzSRZd8K+pvT46Y7iu2wbB+2S\n\tF40bzr59OGykMMiv+6VInm+/jPqnct0VtmBlBeN/gng0U1szxGUaq0nzIQlJC8SbuWe3\n\td881Sl9UvvDgnVmhLs8mDpZNQQgK6kskX+STdhD+8akAcQHyznth8fsB/aSywOb8Ba4d\n\t1qNqv6BDMPgPI10cJpyDwuSHLgvNVJ4sz1Gw9bwfVOohGDOrkpH3knfVVVAaZnU4qqTL\n\tgF1Gpnn6dJhRYac0blN/UYJKPYwW8jRphKK9673BO4vza6JLBfqzlE+SEpj+d4E+1/CH\n\trtGQ==", "X-Gm-Message-State": "AOAM531e0zhoLKW8BwcazKh5HkQ6J/NitQMxEx7y7YLn4bBiu4pTIdLS\n\tIePhca3MWOEs4mrPPh1FTWS8Dg81HLKIzQ==", "X-Google-Smtp-Source": "ABdhPJx7A313eCVaHjqCRBZCLJY4Fthk9xisjhhdJNL+fxqdXNthFS8uzZOF7tpkfoFEVAdTa1hTFg==", "X-Received": "by 2002:a5d:588d:0:b0:204:217a:d9b0 with SMTP id\n\tn13-20020a5d588d000000b00204217ad9b0mr8294029wrf.428.1648199348906; \n\tFri, 25 Mar 2022 02:09:08 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 25 Mar 2022 09:08:58 +0000", "Message-Id": "<20220325090903.880311-4-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20220325090903.880311-1-naush@raspberrypi.com>", "References": "<20220325090903.880311-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 3/8] pipeline: raspberrypi: Free\n\tbuffers in the RPiCamera destructor and re-configure", "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": "Currently, all framebuffer allocations get freed and cleared on a stop in\nPipelineHandlerRPi::stopDevice(). If PipelineHandlerRPi::start() is then called\nwithout an intermediate PipelineHandlerRPi::configure(), it will re-allocate and\nprepare all the buffers again, which is unnecessary.\n\nFix this by not freeing the buffer in PipelineHandlerRPi::stopDevice(), but\ninsted doing it in PipelineHandlerRPi::configure(), as the buffers might have\nto be resized.\n\nAdd a flag to indicate that buffer allocations need to be done on the next\ncall to PipelineHandlerRPi::start().\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nTested-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp | 33 +++++++++++++------\n 1 file changed, 23 insertions(+), 10 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 2281b43fc3ac..92043962494b 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -185,10 +185,15 @@ public:\n \tRPiCameraData(PipelineHandler *pipe)\n \t\t: Camera::Private(pipe), state_(State::Stopped),\n \t\t supportsFlips_(false), flipsAlterBayerOrder_(false),\n-\t\t dropFrameCount_(0), ispOutputCount_(0)\n+\t\t dropFrameCount_(0), buffersAllocated_(false), ispOutputCount_(0)\n \t{\n \t}\n \n+\t~RPiCameraData()\n+\t{\n+\t\tfreeBuffers();\n+\t}\n+\n \tvoid freeBuffers();\n \tvoid frameStarted(uint32_t sequence);\n \n@@ -280,6 +285,9 @@ public:\n \t */\n \tstd::optional<int32_t> notifyGainsUnity_;\n \n+\t/* Have internal buffers been allocated? */\n+\tbool buffersAllocated_;\n+\n private:\n \tvoid checkRequestCompleted();\n \tvoid fillRequestMetadata(const ControlList &bufferControls,\n@@ -682,7 +690,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \tRPiCameraData *data = cameraData(camera);\n \tint ret;\n \n-\t/* Start by resetting the Unicam and ISP stream states. */\n+\t/* Start by freeing all buffers and reset the Unicam and ISP stream states. */\n+\tdata->freeBuffers();\n \tfor (auto const stream : data->streams_)\n \t\tstream->reset();\n \n@@ -982,12 +991,16 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)\n \tRPiCameraData *data = cameraData(camera);\n \tint ret;\n \n-\t/* Allocate buffers for internal pipeline usage. */\n-\tret = prepareBuffers(camera);\n-\tif (ret) {\n-\t\tLOG(RPI, Error) << \"Failed to allocate buffers\";\n-\t\tstop(camera);\n-\t\treturn ret;\n+\tif (!data->buffersAllocated_) {\n+\t\t/* Allocate buffers for internal pipeline usage. */\n+\t\tret = prepareBuffers(camera);\n+\t\tif (ret) {\n+\t\t\tLOG(RPI, Error) << \"Failed to allocate buffers\";\n+\t\t\tdata->freeBuffers();\n+\t\t\tstop(camera);\n+\t\t\treturn ret;\n+\t\t}\n+\t\tdata->buffersAllocated_ = true;\n \t}\n \n \t/* Check if a ScalerCrop control was specified. */\n@@ -1055,8 +1068,6 @@ void PipelineHandlerRPi::stopDevice(Camera *camera)\n \n \t/* Stop the IPA. */\n \tdata->ipa_->stop();\n-\n-\tdata->freeBuffers();\n }\n \n int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)\n@@ -1461,6 +1472,8 @@ void RPiCameraData::freeBuffers()\n \n \tfor (auto const stream : streams_)\n \t\tstream->releaseBuffers();\n+\n+\tbuffersAllocated_ = false;\n }\n \n void RPiCameraData::frameStarted(uint32_t sequence)\n", "prefixes": [ "libcamera-devel", "v5", "3/8" ] }