Show a patch.

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

{
    "id": 15486,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/15486/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15486/",
    "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": "<20220321102702.1753800-4-naush@raspberrypi.com>",
    "date": "2022-03-21T10:27:00",
    "name": "[libcamera-devel,v3,3/5] pipeline: raspberrypi: Free buffers in the RPiCamera destructor and re-configure",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "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/15486/mbox/",
    "series": [
        {
            "id": 2977,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2977/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2977",
            "date": "2022-03-21T10:26:57",
            "name": "Raspberry Pi: Efficient start/stop/start sequences",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/2977/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15486/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15486/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 F38F5C3263\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Mar 2022 10:27:10 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 56E04604E9;\n\tMon, 21 Mar 2022 11:27:10 +0100 (CET)",
            "from mail-wr1-x430.google.com (mail-wr1-x430.google.com\n\t[IPv6:2a00:1450:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CD9FC604E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Mar 2022 11:27:07 +0100 (CET)",
            "by mail-wr1-x430.google.com with SMTP id j18so10374210wrd.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Mar 2022 03:27:07 -0700 (PDT)",
            "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:77bd:7c6c:a8b9:8855])\n\tby smtp.gmail.com with ESMTPSA id\n\tv10-20020a056000144a00b00203df06cf9bsm13530115wrx.106.2022.03.21.03.27.06\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 21 Mar 2022 03:27:06 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647858430;\n\tbh=OxqN9wPG8w9e6CpTtvUEfPWMYZqPcncE8Vf26vFzLOs=;\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=BRKwTbJeeJdl72qVCqfmy6OCyNSFhatVPIDx44JOcQG7uAEE5hGpmChF1C85yKHH2\n\td6zq0TXLg/6JvoXY7EVhVcUHMcN2PsxqU4Y53dEgjmcfztLVp1g9dUnxyfLQgLo1gI\n\tWJQwWCBnokNqAl5g/LZ6Iyc4dyd0G71poUgSiwxvaPYDpeALso7id2g7SyS5568Ac1\n\tAF8E2Xbp2GXI+m8E2h/Zi632gSFzYGvDTMLnDZKtnFwas6xIz4LpEUOTKI70XWF9b0\n\tdx2+OG/fR3xUf9+n9tqDd4haaBkBD5ECXPGDiGzV5ALthn97zirXVNtqMTjczAWkC6\n\tH9lifCj4xlrhw==",
            "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=n8rXhvCEYFa+f6swEAKkBsiiVnN1PTWYev6x2wU9AhU=;\n\tb=PIlQ5vyNtzhcqtIQhcThmKLwfx/90FkpZp511hatj8DwTVIgFtWvwocKJXKaTdss6P\n\tEuWc36RpzY6Ji03h8HrRu9iCkeB1Y6GWDzVb/lI33BYUatV/m3l8n3EwBUp6Dvy6t6tx\n\tjCfW85y9/GcwAwMlZRNPcHnQ4kLdCxEbqRACPfmw3HaoEgMJ7JN/bz6EismQ8fKZG3iB\n\tdbgMGRwp3dy73LaxTEuEu5KiQbfR5wWfbvwdyx2kraeNT5tPPnjxmce+XbYMchPXirXO\n\tt0CCgHgGaJsBG9deruHZ6I2cQFS2XzgkNVx1UparYeXLnna9zcWvThMlNAGrsobeliad\n\tkNKQ=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"PIlQ5vyN\"; 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=n8rXhvCEYFa+f6swEAKkBsiiVnN1PTWYev6x2wU9AhU=;\n\tb=mnBv4gQx4cW+MMg2ATRR12gBUP0VhVSEwGS6b2NS8IcX+u2sC+KH+cN5+Jzc49YGdm\n\tza03FhvNL0PLr+CBpvgFL5qMrO5l+SoFV2D3S0PmlyDasUctmZ20jDMgY/KT8tSby33f\n\tmtFr5QJWR3qQOoOKQZPMCUswzdJckgV+KRZZErBVzqKNAi6Z7KNiqXsja6Ss+cBPmRwt\n\tnsNGiuehv/5H/zIVcW/acQLJqGrqkCnCrTWOgnJ6ZrBm9ahqZXRnIGyDA1DiLlz67hS7\n\thOzsPDZGWJ2Fvhd4rEym4OUPf/bicOME6EitBLvZMQiBPDiG7HTmst2mWwSxj8UMptAL\n\t8O8w==",
        "X-Gm-Message-State": "AOAM5325BkSPft3Gk8KkGTdhRNrVDSBk7NTpL26jBTl9sNzt7WRro+52\n\tJK1JUVFM/dp8vl3GrV8IqmhB1dpWsYMTSg==",
        "X-Google-Smtp-Source": "ABdhPJxAmQYgfkqRbaF5FHclJre4fig5/DR2/jZYWyqlnNmdrL5DW+bVuUmLP7bivMZ29Y9tMPy2Cg==",
        "X-Received": "by 2002:a5d:4ecd:0:b0:203:fd7b:bdd1 with SMTP id\n\ts13-20020a5d4ecd000000b00203fd7bbdd1mr9833282wrv.265.1647858427288; \n\tMon, 21 Mar 2022 03:27:07 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 21 Mar 2022 10:27:00 +0000",
        "Message-Id": "<20220321102702.1753800-4-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220321102702.1753800-1-naush@raspberrypi.com>",
        "References": "<20220321102702.1753800-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 3/5] 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>\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",
        "v3",
        "3/5"
    ]
}