Show a patch.

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

{
    "id": 1696,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/1696/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1696/",
    "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": "<20190713172351.25452-16-laurent.pinchart@ideasonboard.com>",
    "date": "2019-07-13T17:23:50",
    "name": "[libcamera-devel,v2,15/16] libcamera: pipeline: Support importing buffers",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "005c8bec02099f3678700f64bed28b34e56b07f5",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/1696/mbox/",
    "series": [
        {
            "id": 430,
            "url": "https://patchwork.libcamera.org/api/1.1/series/430/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=430",
            "date": "2019-07-13T17:23:35",
            "name": "Add support for external buffers",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/430/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1696/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1696/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B4706175B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Jul 2019 19:24:50 +0200 (CEST)",
            "from pendragon.ideasonboard.com (softbank126209254147.bbtec.net\n\t[126.209.254.147])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0A2642B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Jul 2019 19:24:48 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1563038690;\n\tbh=VGHOiKNEy9gHqqvdAPRgaT+SmF7KogL50EqUPlP/Jk4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=fS/P2qQiOb9V9Ov1sgMvWTodhGXS59VwUJDunyjGhkFanRtZ8nwrKzY5T2fvL7CMC\n\tmM6w7lkyoSt85wpn7aoTf7rQQSZTe0QvzCTJmImOZJEDE4RIUJIebsA1c4K1t4xqwZ\n\t7E4LVgg5Cn8X4xPV3v59PCvULJP0rZPgm0dmkSyo=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 13 Jul 2019 20:23:50 +0300",
        "Message-Id": "<20190713172351.25452-16-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190713172351.25452-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20190713172351.25452-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 15/16] libcamera: pipeline: Support\n\timporting buffers",
        "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": "Sat, 13 Jul 2019 17:24:50 -0000"
    },
    "content": "From: Jacopo Mondi <jacopo@jmondi.org>\n\nAdd support for importing external buffers in all pipeline handlers.\n\nUse the stream memory type in the pipeline handlers during buffer\nallocation to import buffers to or export buffers from the video device.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp     | 49 ++++++++++++++++++------\n src/libcamera/pipeline/rkisp1/rkisp1.cpp |  6 ++-\n src/libcamera/pipeline/uvcvideo.cpp      |  5 ++-\n src/libcamera/pipeline/vimc.cpp          |  5 ++-\n 4 files changed, 51 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 488e89f25c5e..9ac5a5387dec 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -69,8 +69,9 @@ public:\n \tint configureOutput(ImgUOutput *output,\n \t\t\t    const StreamConfiguration &cfg);\n \n-\tint importBuffers(BufferPool *pool);\n-\tint exportBuffers(ImgUOutput *output, BufferPool *pool);\n+\tint importInputBuffers(BufferPool *pool);\n+\tint importOutputBuffers(ImgUOutput *output, BufferPool *pool);\n+\tint exportOutputBuffers(ImgUOutput *output, BufferPool *pool);\n \tvoid freeBuffers();\n \n \tint start();\n@@ -605,7 +606,7 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \tif (!pool)\n \t\treturn -ENOMEM;\n \n-\tret = imgu->importBuffers(pool);\n+\tret = imgu->importInputBuffers(pool);\n \tif (ret)\n \t\tgoto error;\n \n@@ -616,7 +617,7 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \t */\n \tbufferCount = pool->count();\n \timgu->stat_.pool->createBuffers(bufferCount);\n-\tret = imgu->exportBuffers(&imgu->stat_, imgu->stat_.pool);\n+\tret = imgu->exportOutputBuffers(&imgu->stat_, imgu->stat_.pool);\n \tif (ret)\n \t\tgoto error;\n \n@@ -625,7 +626,10 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \t\tIPU3Stream *stream = static_cast<IPU3Stream *>(s);\n \t\tImgUDevice::ImgUOutput *dev = stream->device_;\n \n-\t\tret = imgu->exportBuffers(dev, &stream->bufferPool());\n+\t\tif (stream->memoryType() == InternalMemory)\n+\t\t\tret = imgu->exportOutputBuffers(dev, &stream->bufferPool());\n+\t\telse\n+\t\t\tret = imgu->importOutputBuffers(dev, &stream->bufferPool());\n \t\tif (ret)\n \t\t\tgoto error;\n \t}\n@@ -637,8 +641,8 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \tif (!outStream->active_) {\n \t\tbufferCount = vfStream->configuration().bufferCount;\n \t\toutStream->device_->pool->createBuffers(bufferCount);\n-\t\tret = imgu->exportBuffers(outStream->device_,\n-\t\t\t\t\t  outStream->device_->pool);\n+\t\tret = imgu->exportOutputBuffers(outStream->device_,\n+\t\t\t\t\t\toutStream->device_->pool);\n \t\tif (ret)\n \t\t\tgoto error;\n \t}\n@@ -646,8 +650,8 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \tif (!vfStream->active_) {\n \t\tbufferCount = outStream->configuration().bufferCount;\n \t\tvfStream->device_->pool->createBuffers(bufferCount);\n-\t\tret = imgu->exportBuffers(vfStream->device_,\n-\t\t\t\t\t  vfStream->device_->pool);\n+\t\tret = imgu->exportOutputBuffers(vfStream->device_,\n+\t\t\t\t\t\tvfStream->device_->pool);\n \t\tif (ret)\n \t\t\tgoto error;\n \t}\n@@ -1113,7 +1117,7 @@ int ImgUDevice::configureOutput(ImgUOutput *output,\n  * \\param[in] pool The buffer pool to import\n  * \\return 0 on success or a negative error code otherwise\n  */\n-int ImgUDevice::importBuffers(BufferPool *pool)\n+int ImgUDevice::importInputBuffers(BufferPool *pool)\n {\n \tint ret = input_->importBuffers(pool);\n \tif (ret) {\n@@ -1134,7 +1138,7 @@ int ImgUDevice::importBuffers(BufferPool *pool)\n  *\n  * \\return 0 on success or a negative error code otherwise\n  */\n-int ImgUDevice::exportBuffers(ImgUOutput *output, BufferPool *pool)\n+int ImgUDevice::exportOutputBuffers(ImgUOutput *output, BufferPool *pool)\n {\n \tint ret = output->dev->exportBuffers(pool);\n \tif (ret) {\n@@ -1146,6 +1150,29 @@ int ImgUDevice::exportBuffers(ImgUOutput *output, BufferPool *pool)\n \treturn 0;\n }\n \n+/**\n+ * \\brief Reserve buffers in \\a output from the provided \\a pool\n+ * \\param[in] output The ImgU output device\n+ * \\param[in] pool The buffer pool used to reserve buffers in \\a output\n+ *\n+ * Reserve a number of buffers equal to the number of buffers in \\a pool\n+ * in the \\a output device.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int ImgUDevice::importOutputBuffers(ImgUOutput *output, BufferPool *pool)\n+{\n+\tint ret = output->dev->importBuffers(pool);\n+\tif (ret) {\n+\t\tLOG(IPU3, Error)\n+\t\t\t<< \"Failed to import buffer in \" << output->name\n+\t\t\t<< \" ImgU device\";\n+\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n /**\n  * \\brief Release buffers for all the ImgU video devices\n  */\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex cc33a2cb2572..efa9604bc1e3 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -319,7 +319,11 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera,\n \t\t\t\t\t   const std::set<Stream *> &streams)\n {\n \tStream *stream = *streams.begin();\n-\treturn video_->exportBuffers(&stream->bufferPool());\n+\n+\tif (stream->memoryType() == InternalMemory)\n+\t\treturn video_->exportBuffers(&stream->bufferPool());\n+\telse\n+\t\treturn video_->importBuffers(&stream->bufferPool());\n }\n \n int PipelineHandlerRkISP1::freeBuffers(Camera *camera,\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex b299c5da8471..8965210550d2 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -200,7 +200,10 @@ int PipelineHandlerUVC::allocateBuffers(Camera *camera,\n \n \tLOG(UVC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n \n-\treturn data->video_->exportBuffers(&stream->bufferPool());\n+\tif (stream->memoryType() == InternalMemory)\n+\t\treturn data->video_->exportBuffers(&stream->bufferPool());\n+\telse\n+\t\treturn data->video_->importBuffers(&stream->bufferPool());\n }\n \n int PipelineHandlerUVC::freeBuffers(Camera *camera,\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 7d96c3645c06..61b68a32ea50 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -202,7 +202,10 @@ int PipelineHandlerVimc::allocateBuffers(Camera *camera,\n \n \tLOG(VIMC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n \n-\treturn data->video_->exportBuffers(&stream->bufferPool());\n+\tif (stream->memoryType() == InternalMemory)\n+\t\treturn data->video_->exportBuffers(&stream->bufferPool());\n+\telse\n+\t\treturn data->video_->importBuffers(&stream->bufferPool());\n }\n \n int PipelineHandlerVimc::freeBuffers(Camera *camera,\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "15/16"
    ]
}