Show a patch.

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

{
    "id": 768,
    "url": "https://patchwork.libcamera.org/api/patches/768/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/768/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20190320163055.22056-23-jacopo@jmondi.org>",
    "date": "2019-03-20T16:30:46",
    "name": "[libcamera-devel,v4,22/31] RFC: libcamera: pipeline_handlers: Add postFreeBuffers",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "c744fbf9c69fe1dcc76b84a7e636a5eed579b0ce",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/768/mbox/",
    "series": [
        {
            "id": 214,
            "url": "https://patchwork.libcamera.org/api/series/214/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=214",
            "date": "2019-03-20T16:30:24",
            "name": "libcamera: ipu3: Add ImgU support + multiple streams",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/214/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/768/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/768/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AD56A611B4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Mar 2019 17:30:41 +0100 (CET)",
            "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id 4171320000D;\n\tWed, 20 Mar 2019 16:30:41 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 20 Mar 2019 17:30:46 +0100",
        "Message-Id": "<20190320163055.22056-23-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190320163055.22056-1-jacopo@jmondi.org>",
        "References": "<20190320163055.22056-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 22/31] RFC: libcamera:\n\tpipeline_handlers: Add postFreeBuffers",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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>",
        "X-List-Received-Date": "Wed, 20 Mar 2019 16:30:41 -0000"
    },
    "content": "Add a postFreeBuffers virtual method to the PipelineHandler base class\nand call if after performing per-stream memory release.\n\nImplement the method in the IPU3 pipeline handler to perform memory\nrelease on the CIO2 unit and ImgU input and stat video nodes.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/camera.cpp                 |  2 +\n src/libcamera/include/pipeline_handler.h |  4 ++\n src/libcamera/pipeline/ipu3/ipu3.cpp     | 48 +++++++++++++++---------\n src/libcamera/pipeline_handler.cpp       | 19 +++++++++-\n 4 files changed, 54 insertions(+), 19 deletions(-)",
    "diff": "diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 8020dff8f8ea..cf618ec567fc 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -514,6 +514,8 @@ int Camera::freeBuffers()\n \t\tpipe_->freeBuffers(this, stream);\n \t}\n \n+\tpipe_->postFreeBuffers(this);\n+\n \tstate_ = CameraConfigured;\n \n \treturn 0;\ndiff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\nindex 7ce5b67cc7fc..d3066550f1b7 100644\n--- a/src/libcamera/include/pipeline_handler.h\n+++ b/src/libcamera/include/pipeline_handler.h\n@@ -64,6 +64,10 @@ public:\n \t}\n \tvirtual int allocateBuffers(Camera *camera, Stream *stream) = 0;\n \tvirtual int freeBuffers(Camera *camera, Stream *stream) = 0;\n+\tvirtual int postFreeBuffers(Camera *camera)\n+\t{\n+\t\treturn 0;\n+\t}\n \n \tvirtual int start(Camera *camera) = 0;\n \tvirtual void stop(Camera *camera);\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 5f323888d84f..ac2b14156d4f 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -109,6 +109,7 @@ public:\n \t\t\t       const std::set<Stream *> &activeStreams) override;\n \tint allocateBuffers(Camera *camera, Stream *stream) override;\n \tint freeBuffers(Camera *camera, Stream *stream) override;\n+\tint postFreeBuffers(Camera *camera) override;\n \n \tint start(Camera *camera) override;\n \tvoid stop(Camera *camera) override;\n@@ -543,26 +544,8 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)\n \tIPU3CameraData *data = cameraData(camera);\n \tV4L2Device *viewfinder = data->imgu->viewfinder;\n \tV4L2Device *output = data->imgu->output;\n-\tV4L2Device *input = data->imgu->input;\n-\tV4L2Device *cio2 = data->cio2.output;\n-\tV4L2Device *stat = data->imgu->stat;\n \tint ret;\n \n-\tif (data->cio2.pool.count()) {\n-\t\tret = input->releaseBuffers();\n-\t\tif (ret)\n-\t\t\tLOG(IPU3, Error) << \"Failed to release ImgU input memory\";\n-\n-\t\tret = cio2->releaseBuffers();\n-\t\tif (ret)\n-\t\t\tLOG(IPU3, Error) << \"Failed to release CIO2 memory\";\n-\n-\t\tret = stat->releaseBuffers();\n-\t\tif (ret)\n-\t\t\tLOG(IPU3, Error) << \"Failed to release ImgU stat memory\";\n-\n-\t}\n-\n \tif (isOutput(data, stream)) {\n \t\tret = output->releaseBuffers();\n \t\tif (ret)\n@@ -594,6 +577,35 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)\n \treturn 0;\n }\n \n+int PipelineHandlerIPU3::postFreeBuffers(Camera *camera)\n+{\n+\tIPU3CameraData *data = cameraData(camera);\n+\tV4L2Device *input = data->imgu->input;\n+\tV4L2Device *cio2 = data->cio2.output;\n+\tV4L2Device *stat = data->imgu->stat;\n+\tint retval = 0;\n+\n+\tint ret = input->releaseBuffers();\n+\tif (ret) {\n+\t\tretval |= ret;\n+\t\tLOG(IPU3, Error) << \"Failed to release ImgU input memory\";\n+\t}\n+\n+\tret = cio2->releaseBuffers();\n+\tif (ret) {\n+\t\tretval |= ret;\n+\t\tLOG(IPU3, Error) << \"Failed to release CIO2 memory\";\n+\t}\n+\n+\tret = stat->releaseBuffers();\n+\tif (ret) {\n+\t\tretval |= ret;\n+\t\tLOG(IPU3, Error) << \"Failed to release ImgU stat memory\";\n+\t}\n+\n+\treturn retval;\n+}\n+\n int PipelineHandlerIPU3::start(Camera *camera)\n {\n \tIPU3CameraData *data = cameraData(camera);\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 1f556ed789b6..d0dee64b9844 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -231,7 +231,24 @@ PipelineHandler::~PipelineHandler()\n  * After a capture session has been stopped all buffers associated with the\n  * stream shall be freed.\n  *\n- * The intended caller of this method is the Camera class.\n+ * The intended caller of this method is the Camera class which calls it\n+ * once per each active stream.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+\n+/**\n+ * \\fn PipelineHandler::postFreeBuffers()\n+ * \\brief Perform post-memory release operations. Optional for pipeline\n+ * handlers to implement\n+ * \\param[in] camera The camera to release memory on\n+ *\n+ * If any clean up operation is required this virtual method provides an entry\n+ * point for pipeline handlers to do so.\n+ *\n+ * The intended caller of this method is the Camera class, which call it once\n+ * after performing per-stream memory release by calling\n+ * PipelineHandler::freeBuffers() on each active stream.\n  *\n  * \\return 0 on success or a negative error code otherwise\n  */\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "22/31"
    ]
}