Show a patch.

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

{
    "id": 15500,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/15500/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15500/",
    "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": "<20220322092257.2713521-4-naush@raspberrypi.com>",
    "date": "2022-03-22T09:22:52",
    "name": "[libcamera-devel,v4,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/15500/mbox/",
    "series": [
        {
            "id": 2982,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2982/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2982",
            "date": "2022-03-22T09:22:49",
            "name": "Raspberry Pi: Efficient start/stop/start sequences",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/2982/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15500/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15500/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 B770DC3264\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Mar 2022 09:23:07 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0292D632E2;\n\tTue, 22 Mar 2022 10:23:07 +0100 (CET)",
            "from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6CA77604C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Mar 2022 10:23:03 +0100 (CET)",
            "by mail-wm1-x32b.google.com with SMTP id\n\tv2-20020a7bcb42000000b0037b9d960079so1057390wmj.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Mar 2022 02:23:03 -0700 (PDT)",
            "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:9e9a:99af:e5a6:319b])\n\tby smtp.gmail.com with ESMTPSA id\n\tr14-20020a05600c35ce00b0038c9f469979sm1471695wmq.40.2022.03.22.02.23.02\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 22 Mar 2022 02:23:02 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647940987;\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=Kebno7PGZXQzOq2i+LlcI2n67otkMZDiWDdUx5jiD6Ndd2pyYw83SL4V9QyH8H9I2\n\tW57siq5RMpXnc0fXYuBiZQv7o+yCJFpdn1VobmlPdbG0bT+WJ2j9rPvRIwS8r1wN8R\n\tSvujXDfqtC5cKEP32sIUQ8lqgiGdA62pDNo7PHwYMWTpgx0qCUCzcAWOgng8gFktWq\n\tWZYIoFwQYNqqv2ZMfHcPJ+F8R6YFoKXjRp5HatHzSCiHmagl2wEr/OWNg9bRUCv4W1\n\tckBbW9bmSdlXI6fLQi/XX6LcbEcfUOaNw5aWPgGXbqTX+9ilz3lo7gbbHcDHWb0RgX\n\tFsAMetuTOK5YA==",
            "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=DWwulMRnfOB2inueInUAqOlxTanlA2gEHXmI1LAwkKxJMdRkIFoked7ayhPrsh7Psw\n\tTy0N4Byha0juF3lUYVE1n9+7OMC+6aKJNIrRmvZ+xRX2yaI6oZpoXHCpPnAC0RTpReKP\n\tDP6EN2FHm5oiqrJfGb47LB4+s1dM5nf2vh6xjEMRopm7JtI8BBgDX4V4GofYzw+lcPb9\n\t4w5HSpWptkAqlMZvZjoaMVezfQx9VGWuMTyvUfP5xA3LvjbtVEgAP/hYUD25m9D2fQzY\n\trjLs40mgahEj6XN5Qr8NC4KlQDtWPJ5BC20XxIL4Y8NNH3fZ4sUrDIdSBadvj0k/nxSk\n\tVFlA=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"DWwulMRn\"; 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=TD/6zsf+p8w8ltE0q10ejkYyBLsYmc1fRoVI4TTgtZWBcf/qSurjTnn11K+kTi93oO\n\tuZwMvXEx/gN0/jpgfIz2UI5LUImLLbZUiSw0vNvjWwXe+u1aRBkt2Q8EuAq29rCeetlB\n\tvhxLYbqMvtN8VYp4hvqXurrOHXW8x6SzjZXD1uiB9r4oTUKsJgWPT33oStU8cEIsUNo3\n\tEK0pkyWjIm1SQPlFHeixBB7iIrIEh0Bw39P+riY5OQJEd34dbYhHQ3hUkibpa+hVewcS\n\tAkRA95U/FguVSu+SKQZ/cC4k9foTSOKXozp2l/6Qpz7X6ugsVdl2xq1y7X4veL4KtyVv\n\tWK4A==",
        "X-Gm-Message-State": "AOAM532EbYy17utlmxKGDRehr6sQEA2fb1xYqAVG5E9n7/QOx2PLbTW9\n\tsZD3Y+9sTRtECzpE8mc/8Gj2OQS+nIVpNg==",
        "X-Google-Smtp-Source": "ABdhPJwCgQJlsvc9dpR2TjhD5HEkLuA681bz2GrKIfaJ+X9T2bB4I2RbQYdWDS84N9m0wkxrMD8OTg==",
        "X-Received": "by 2002:a7b:c319:0:b0:38c:8655:4019 with SMTP id\n\tk25-20020a7bc319000000b0038c86554019mr2906672wmj.60.1647940982789; \n\tTue, 22 Mar 2022 02:23:02 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 22 Mar 2022 09:22:52 +0000",
        "Message-Id": "<20220322092257.2713521-4-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220322092257.2713521-1-naush@raspberrypi.com>",
        "References": "<20220322092257.2713521-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 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",
        "v4",
        "3/8"
    ]
}