Show a patch.

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

{
    "id": 815,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/815/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/815/",
    "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": "<20190326165011.10817-1-jacopo@jmondi.org>",
    "date": "2019-03-26T16:50:11",
    "name": "[libcamera-devel] libcamera: camera: allocateBuffers: Pass the stream set",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "6cc07deac1836da7afe0f169b30f52cf453658cd",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": {
        "id": 15,
        "url": "https://patchwork.libcamera.org/api/1.1/users/15/?format=api",
        "username": "jmondi",
        "first_name": "Jacopo",
        "last_name": "Mondi",
        "email": "jacopo@jmondi.org"
    },
    "mbox": "https://patchwork.libcamera.org/patch/815/mbox/",
    "series": [
        {
            "id": 220,
            "url": "https://patchwork.libcamera.org/api/1.1/series/220/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=220",
            "date": "2019-03-26T16:50:11",
            "name": "[libcamera-devel] libcamera: camera: allocateBuffers: Pass the stream set",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/220/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/815/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/815/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B357F600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Mar 2019 17:49:37 +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 relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 353E460006;\n\tTue, 26 Mar 2019 16:49:37 +0000 (UTC)"
        ],
        "X-Originating-IP": "2.224.242.101",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 26 Mar 2019 17:50:11 +0100",
        "Message-Id": "<20190326165011.10817-1-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.21.0",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] libcamera: camera: allocateBuffers: Pass\n\tthe stream set",
        "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": "Tue, 26 Mar 2019 16:49:38 -0000"
    },
    "content": "Pipeline handlers might need to perform allocation of internal buffers,\nsetup operations, or simple sanity check before going into the\nper-stream buffer allocation.\n\nAs of now, PipelineHandler::allocateBuffers() is called once per each\nactive stream, leaving no space for stream-independent configuration.\n\nChange this by providing to the pipeline handler the full set of active\nstream, and ask them to loop over them to perform per-streams\nallocations after eventual stream-independent operations.\n\nThe same rational applies to PipelineHandler::freeBuffers() and eventual\nstream-independent clean up operations.\n\nWhile at it, change the return type of freeBuffers() to void as it was\nnot checked by the Camera class method calling it.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nAs noted with the development of multi stream support for the IPU3 platform,\npipeline handlers might need room to perform pre and post stream buffer memory\nallocation operations.\n\nI initally implemented pre and post hooks, but as Laurent suggested, changing\nthe interface between Camera and Pipeline Handlers is a much nicer solution.\n---\n src/libcamera/camera.cpp                 | 15 +++++++--------\n src/libcamera/include/pipeline_handler.h |  6 ++++--\n src/libcamera/pipeline/ipu3/ipu3.cpp     | 19 ++++++++++---------\n src/libcamera/pipeline/uvcvideo.cpp      | 15 ++++++++++-----\n src/libcamera/pipeline/vimc.cpp          | 15 ++++++++++-----\n src/libcamera/pipeline_handler.cpp       |  8 ++++----\n 6 files changed, 45 insertions(+), 33 deletions(-)\n\n--\n2.21.0",
    "diff": "diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 8ee9cc086616..99eb0e6876f0 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -467,13 +467,11 @@ int Camera::allocateBuffers()\n \t\treturn -EINVAL;\n \t}\n\n-\tfor (Stream *stream : activeStreams_) {\n-\t\tint ret = pipe_->allocateBuffers(this, stream);\n-\t\tif (ret) {\n-\t\t\tLOG(Camera, Error) << \"Failed to allocate buffers\";\n-\t\t\tfreeBuffers();\n-\t\t\treturn ret;\n-\t\t}\n+\tint ret = pipe_->allocateBuffers(this, activeStreams_);\n+\tif (ret) {\n+\t\tLOG(Camera, Error) << \"Failed to allocate buffers\";\n+\t\tfreeBuffers();\n+\t\treturn ret;\n \t}\n\n \tstate_ = CameraPrepared;\n@@ -503,9 +501,10 @@ int Camera::freeBuffers()\n \t\t * by the V4L2 device that has allocated them.\n \t\t */\n \t\tstream->bufferPool().destroyBuffers();\n-\t\tpipe_->freeBuffers(this, stream);\n \t}\n\n+\tpipe_->freeBuffers(this, activeStreams_);\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 acb376e07030..920b57609470 100644\n--- a/src/libcamera/include/pipeline_handler.h\n+++ b/src/libcamera/include/pipeline_handler.h\n@@ -57,8 +57,10 @@ public:\n \tvirtual int configureStreams(Camera *camera,\n \t\t\t\t     std::map<Stream *, StreamConfiguration> &config) = 0;\n\n-\tvirtual int allocateBuffers(Camera *camera, Stream *stream) = 0;\n-\tvirtual int freeBuffers(Camera *camera, Stream *stream) = 0;\n+\tvirtual int allocateBuffers(Camera *camera,\n+\t\t\t\t    const std::set<Stream *> &streams) = 0;\n+\tvirtual void freeBuffers(Camera *camera,\n+\t\t\t\t const std::set<Stream *> &streams) = 0;\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 55489c31df2d..c13252b6f77e 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -36,8 +36,10 @@ public:\n \tint configureStreams(Camera *camera,\n \t\t\t     std::map<Stream *, StreamConfiguration> &config) override;\n\n-\tint allocateBuffers(Camera *camera, Stream *stream) override;\n-\tint freeBuffers(Camera *camera, Stream *stream) override;\n+\tint allocateBuffers(Camera *camera,\n+\t\t\t    const std::set<Stream *> &streams) override;\n+\tvoid freeBuffers(Camera *camera,\n+\t\t\t const std::set<Stream *> &streams) override;\n\n \tint start(Camera *camera) override;\n \tvoid stop(Camera *camera) override;\n@@ -188,9 +190,11 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n \treturn 0;\n }\n\n-int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)\n+int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n+\t\t\t\t\t const std::set<Stream *> &streams)\n {\n \tIPU3CameraData *data = cameraData(camera);\n+\tStream *stream = *streams.begin();\n \tconst StreamConfiguration &cfg = stream->configuration();\n\n \tif (!cfg.bufferCount)\n@@ -205,17 +209,14 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)\n \treturn 0;\n }\n\n-int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)\n+void PipelineHandlerIPU3::freeBuffers(Camera *camera,\n+\t\t\t\t      const std::set<Stream *> &streams)\n {\n \tIPU3CameraData *data = cameraData(camera);\n\n \tint ret = data->cio2_->releaseBuffers();\n-\tif (ret) {\n+\tif (ret)\n \t\tLOG(IPU3, Error) << \"Failed to release memory\";\n-\t\treturn ret;\n-\t}\n-\n-\treturn 0;\n }\n\n int PipelineHandlerIPU3::start(Camera *camera)\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex cc3e0cd9afab..128f0c49dba3 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -32,8 +32,10 @@ public:\n \tint configureStreams(Camera *camera,\n \t\t\t     std::map<Stream *, StreamConfiguration> &config) override;\n\n-\tint allocateBuffers(Camera *camera, Stream *stream) override;\n-\tint freeBuffers(Camera *camera, Stream *stream) override;\n+\tint allocateBuffers(Camera *camera,\n+\t\t\t    const std::set<Stream *> &streams) override;\n+\tvoid freeBuffers(Camera *camera,\n+\t\t\t const std::set<Stream *> &streams) override;\n\n \tint start(Camera *camera) override;\n \tvoid stop(Camera *camera) override;\n@@ -129,9 +131,11 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,\n \treturn 0;\n }\n\n-int PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream)\n+int PipelineHandlerUVC::allocateBuffers(Camera *camera,\n+\t\t\t\t\tconst std::set<Stream *> &streams)\n {\n \tUVCCameraData *data = cameraData(camera);\n+\tStream *stream = *streams.begin();\n \tconst StreamConfiguration &cfg = stream->configuration();\n\n \tLOG(UVC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n@@ -139,10 +143,11 @@ int PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream)\n \treturn data->video_->exportBuffers(&stream->bufferPool());\n }\n\n-int PipelineHandlerUVC::freeBuffers(Camera *camera, Stream *stream)\n+void PipelineHandlerUVC::freeBuffers(Camera *camera,\n+\t\t\t\t     const std::set<Stream *> &streams)\n {\n \tUVCCameraData *data = cameraData(camera);\n-\treturn data->video_->releaseBuffers();\n+\tdata->video_->releaseBuffers();\n }\n\n int PipelineHandlerUVC::start(Camera *camera)\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 2e8c26fb7c0b..6735940799d8 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -32,8 +32,10 @@ public:\n \tint configureStreams(Camera *camera,\n \t\t\t     std::map<Stream *, StreamConfiguration> &config) override;\n\n-\tint allocateBuffers(Camera *camera, Stream *stream) override;\n-\tint freeBuffers(Camera *camera, Stream *stream) override;\n+\tint allocateBuffers(Camera *camera,\n+\t\t\t    const std::set<Stream *> &streams) override;\n+\tvoid freeBuffers(Camera *camera,\n+\t\t\t const std::set<Stream *> &streams) override;\n\n \tint start(Camera *camera) override;\n \tvoid stop(Camera *camera) override;\n@@ -129,9 +131,11 @@ int PipelineHandlerVimc::configureStreams(Camera *camera,\n \treturn 0;\n }\n\n-int PipelineHandlerVimc::allocateBuffers(Camera *camera, Stream *stream)\n+int PipelineHandlerVimc::allocateBuffers(Camera *camera,\n+\t\t\t\t\t const std::set<Stream *> &streams)\n {\n \tVimcCameraData *data = cameraData(camera);\n+\tStream *stream = *streams.begin();\n \tconst StreamConfiguration &cfg = stream->configuration();\n\n \tLOG(VIMC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n@@ -139,10 +143,11 @@ int PipelineHandlerVimc::allocateBuffers(Camera *camera, Stream *stream)\n \treturn data->video_->exportBuffers(&stream->bufferPool());\n }\n\n-int PipelineHandlerVimc::freeBuffers(Camera *camera, Stream *stream)\n+void PipelineHandlerVimc::freeBuffers(Camera *camera,\n+\t\t\t\t      const std::set<Stream *> &streams)\n {\n \tVimcCameraData *data = cameraData(camera);\n-\treturn data->video_->releaseBuffers();\n+\tdata->video_->releaseBuffers();\n }\n\n int PipelineHandlerVimc::start(Camera *camera)\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 1a858f2638ce..d14d463cf610 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -193,10 +193,10 @@ PipelineHandler::~PipelineHandler()\n  * \\fn PipelineHandler::allocateBuffers()\n  * \\brief Allocate buffers for a stream\n  * \\param[in] camera The camera the \\a stream belongs to\n- * \\param[in] stream The stream to allocate buffers for\n+ * \\param[in] streams The group of active streams to allocate buffers for\n  *\n  * This method allocates buffers internally in the pipeline handler and\n- * associates them with the stream's buffer pool.\n+ * associates them with each stream's buffer pool.\n  *\n  * The intended caller of this method is the Camera class.\n  *\n@@ -207,9 +207,9 @@ PipelineHandler::~PipelineHandler()\n  * \\fn PipelineHandler::freeBuffers()\n  * \\brief Free all buffers associated with a stream\n  * \\param[in] camera The camera the \\a stream belongs to\n- * \\param[in] stream The stream to free buffers from\n+ * \\param[in] streams The group of active streams to free buffers from\n  *\n- * After a capture session has been stopped all buffers associated with the\n+ * After a capture session has been stopped all buffers associated with each\n  * stream shall be freed.\n  *\n  * The intended caller of this method is the Camera class.\n",
    "prefixes": [
        "libcamera-devel"
    ]
}